From 87cd4305bbf4f272e412797684b4ef002236a757 Mon Sep 17 00:00:00 2001 From: aB0t Date: Sat, 9 Mar 2024 21:52:51 +0200 Subject: [PATCH] Stable release of v5.0.0-alpha1 First alpha release of Component Builder towards Joomla 5 (very unstable...). --- CHANGELOG.md | 62 +- ComponentbuilderInstallerScript.php | 4813 +++ README.md | 14 +- admin/README.txt | 14 +- admin/access.xml | 21 + .../assets/css/component_router.css | 0 admin/assets/css/components_routers.css | 13 + admin/assets/css/dashboard.css | 202 +- admin/assets/images/import.gif | Bin 65516 -> 66680 bytes admin/compiler/joomla_3/AdminController.php | 4 +- .../joomla_3/AdminControllerDashboard.php | 4 +- .../joomla_3/AdminController_custom_admin.php | 10 +- admin/compiler/joomla_3/AdminModel.php | 108 +- admin/compiler/joomla_3/AdminModel_site.php | 110 +- admin/compiler/joomla_3/BaseController.php | 36 +- .../compiler/joomla_3/BaseControllerAjax.php | 22 +- .../joomla_3/BaseControllerAjaxSite.php | 24 +- .../compiler/joomla_3/BaseControllerHelp.php | 37 +- .../joomla_3/BaseControllerHelp_site.php | 35 +- .../compiler/joomla_3/BaseControllerSITE.php | 47 +- .../joomla_3/BaseController_custom_admin.php | 6 +- .../joomla_3/BaseController_import.php | 12 +- .../joomla_3/BaseController_import_custom.php | 12 +- .../joomla_3/BaseDatabaseModel_import.php | 131 +- .../BaseDatabaseModel_import_custom.php | 96 +- admin/compiler/joomla_3/DASHJViewLagacy.php | 42 +- admin/compiler/joomla_3/DASHdefault.php | 4 +- admin/compiler/joomla_3/FormController.php | 51 +- .../joomla_3/FormController_custom_site.php | 14 +- .../compiler/joomla_3/FormController_site.php | 54 +- admin/compiler/joomla_3/Helper.php | 98 +- admin/compiler/joomla_3/Helper_category.php | 4 +- .../joomla_3/Helper_category_view.php | 6 +- admin/compiler/joomla_3/Helper_email.php | 143 +- admin/compiler/joomla_3/Helper_site.php | 100 +- .../joomla_3/HtmlView_custom_admin.php | 38 +- admin/compiler/joomla_3/HtmlView_edit.php | 40 +- .../compiler/joomla_3/HtmlView_edit_site.php | 46 +- admin/compiler/joomla_3/HtmlView_import.php | 31 +- .../joomla_3/HtmlView_import_custom.php | 18 +- admin/compiler/joomla_3/HtmlView_list.php | 66 +- .../joomla_3/HtmlView_list_custom_admin.php | 36 +- .../compiler/joomla_3/HtmlView_list_site.php | 36 +- admin/compiler/joomla_3/HtmlView_site.php | 36 +- .../joomla_3/ItemModel_custom_admin.php | 20 +- admin/compiler/joomla_3/ItemModel_site.php | 14 +- admin/compiler/joomla_3/JCB_Helper.php | 697 - admin/compiler/joomla_3/JCB_Helper_site.php | 686 - .../joomla_3/JFormFieldCheckboxes.php | 12 +- admin/compiler/joomla_3/JFormFieldCustom.php | 10 +- admin/compiler/joomla_3/JFormFieldList.php | 12 +- admin/compiler/joomla_3/JFormFieldRadio.php | 12 +- admin/compiler/joomla_3/JFormFieldUser.php | 10 +- admin/compiler/joomla_3/JFormRule.php | 7 +- admin/compiler/joomla_3/ListModel.php | 20 +- admin/compiler/joomla_3/ListModelAjax.php | 16 +- admin/compiler/joomla_3/ListModelAjaxSite.php | 6 +- admin/compiler/joomla_3/ListModelDASH.php | 130 +- .../joomla_3/ListModel_custom_admin.php | 20 +- admin/compiler/joomla_3/ListModel_site.php | 12 +- admin/compiler/joomla_3/Table.php | 112 +- admin/compiler/joomla_3/ajax.json.php | 23 +- admin/compiler/joomla_3/ajax.php | 25 +- admin/compiler/joomla_3/batch_.php | 6 +- admin/compiler/joomla_3/batchselection.php | 23 +- admin/compiler/joomla_3/component_admin.php | 19 +- admin/compiler/joomla_3/component_site.php | 13 +- admin/compiler/joomla_3/dashboard.css | 202 +- admin/compiler/joomla_3/default.php | 7 +- .../compiler/joomla_3/default_batch_body.php | 9 +- .../joomla_3/default_batch_footer.php | 10 +- admin/compiler/joomla_3/default_body.php | 8 +- .../joomla_3/default_custom_admin.php | 8 +- .../default_custom_admin_template.php | 10 +- admin/compiler/joomla_3/default_foot.php | 4 +- admin/compiler/joomla_3/default_head.php | 7 +- admin/compiler/joomla_3/default_import.php | 84 +- .../joomla_3/default_import_custom.php | 17 +- .../joomla_3/default_list_custom_admin.php | 6 +- admin/compiler/joomla_3/default_list_site.php | 4 +- admin/compiler/joomla_3/default_main.php | 12 +- admin/compiler/joomla_3/default_site.php | 4 +- .../joomla_3/default_site_template.php | 10 +- admin/compiler/joomla_3/default_toolbar.php | 63 +- admin/compiler/joomla_3/default_vdm.php | 24 +- admin/compiler/joomla_3/edit.php | 7 +- admin/compiler/joomla_3/edit_site.php | 7 +- admin/compiler/joomla_3/headercheck.php | 80 +- admin/compiler/joomla_3/headercheck_admin.php | 52 +- admin/compiler/joomla_3/import.gif | Bin 65516 -> 66680 bytes admin/compiler/joomla_3/layout.php | 36 +- admin/compiler/joomla_3/layout_admin.php | 4 +- .../compiler/joomla_3/layout_custom_admin.php | 4 +- admin/compiler/joomla_3/layout_site.php | 4 +- admin/compiler/joomla_3/layoutfull.php | 6 +- admin/compiler/joomla_3/layoutitems.php | 6 +- admin/compiler/joomla_3/layoutlinkedview.php | 10 +- admin/compiler/joomla_3/layoutmetadata.php | 8 +- admin/compiler/joomla_3/layoutoverride.php | 4 +- admin/compiler/joomla_3/layoutpublished.php | 6 +- admin/compiler/joomla_3/layouttitle.php | 6 +- admin/compiler/joomla_3/module_forms.js | 2 +- admin/compiler/joomla_3/module_forms.xml | 2 +- admin/compiler/joomla_3/routeHelper.php | 59 +- admin/compiler/joomla_3/router.php | 39 +- admin/compiler/joomla_3/router_4.php | 4 +- admin/compiler/joomla_3/script.php | 22 +- .../joomla_3/settings_componentbuilder.json | 790 - admin/compiler/joomla_3/submitbutton.js | 2 +- admin/compiler/joomla_3/submitbutton_site.js | 2 +- admin/compiler/joomla_3/whmcs.php | 4 +- admin/compiler/joomla_4/1.0.0.sql | 1 + .../joomla_4/ADMIN_AJAX_CONTROLLER.php | 102 + admin/compiler/joomla_4/ADMIN_AJAX_MODEL.php | 62 + .../joomla_4/ADMIN_DISPLAY_CONTROLLER.php | 50 + .../joomla_4/ADMIN_EXTENSION_COMPONENT.php | 80 + admin/compiler/joomla_4/ADMIN_HEADERCHECK.php | 135 + .../compiler/joomla_4/ADMIN_HELPER_CLASS.php | 937 + .../joomla_4/ADMIN_HELPER_CONTROLLER.php | 128 + .../compiler/joomla_4/ADMIN_HELPER_EMAIL.php | 474 + .../joomla_4/ADMIN_IMPORT_CONTROLLER.php | 63 + .../ADMIN_IMPORT_CONTROLLER_CUSTOM.php | 63 + admin/compiler/joomla_4/ADMIN_IMPORT_HTML.php | 110 + .../joomla_4/ADMIN_IMPORT_HTML_CUSTOM.php | 60 + .../compiler/joomla_4/ADMIN_IMPORT_MODEL.php | 460 + .../joomla_4/ADMIN_IMPORT_MODEL_CUSTOM.php | 351 + admin/compiler/joomla_4/ADMIN_LAYOUT.php | 22 + admin/compiler/joomla_4/ADMIN_PROVIDER.php | 78 + admin/compiler/joomla_4/ADMIN_VIEW.php | 27 + admin/compiler/joomla_4/ADMIN_VIEWS.php | 28 + .../joomla_4/ADMIN_VIEWS_CONTROLLER.php | 53 + .../joomla_4/ADMIN_VIEWS_EMPTYSTATE.php | 33 + admin/compiler/joomla_4/ADMIN_VIEWS_HTML.php | 188 + admin/compiler/joomla_4/ADMIN_VIEWS_MODEL.php | 189 + .../joomla_4/ADMIN_VIEW_CONTROLLER.php | 274 + admin/compiler/joomla_4/ADMIN_VIEW_HTML.php | 143 + admin/compiler/joomla_4/ADMIN_VIEW_MODEL.php | 491 + admin/compiler/joomla_4/ADMIN_VIEW_TABLE.php | 372 + admin/compiler/joomla_4/CHANGELOG.md | 1 + .../compiler/joomla_4/CUSTOM_ADMIN_LAYOUT.php | 22 + admin/compiler/joomla_4/CUSTOM_ADMIN_VIEW.php | 28 + .../compiler/joomla_4/CUSTOM_ADMIN_VIEWS.php | 27 + .../CUSTOM_ADMIN_VIEWS_CONTROLLER.php | 65 + .../joomla_4/CUSTOM_ADMIN_VIEWS_HTML.php | 119 + .../joomla_4/CUSTOM_ADMIN_VIEWS_MODEL.php | 220 + .../joomla_4/CUSTOM_ADMIN_VIEW_CONTROLLER.php | 56 + .../joomla_4/CUSTOM_ADMIN_VIEW_HTML.php | 129 + .../joomla_4/CUSTOM_ADMIN_VIEW_MODEL.php | 267 + admin/compiler/joomla_4/DASH_CONTROLLER.php | 31 + admin/compiler/joomla_4/DASH_MODEL.php | 225 + admin/compiler/joomla_4/DASH_VIEW.php | 22 + admin/compiler/joomla_4/DASH_VIEW_HTML.php | 100 + .../joomla_4/FORM_CHECKBOXES_FIELD.php | 51 + admin/compiler/joomla_4/FORM_CUSTOM_FIELD.php | 36 + admin/compiler/joomla_4/FORM_LIST_FIELD.php | 52 + admin/compiler/joomla_4/FORM_RADIO_FIELD.php | 51 + admin/compiler/joomla_4/FORM_RULE.php | 37 + admin/compiler/joomla_4/FORM_USER_FIELD.php | 65 + admin/compiler/joomla_4/INSTALLER_SCRIPT.php | 1099 + admin/compiler/joomla_4/LAYOUT_OVERRIDE.php | 22 + admin/compiler/joomla_4/LICENSE.txt | 340 + admin/compiler/joomla_4/README.md | 1 + admin/compiler/joomla_4/README.txt | 1 + admin/compiler/joomla_4/SITE_ADMIN_VIEW.php | 28 + .../joomla_4/SITE_ADMIN_VIEW_CONTROLLER.php | 291 + .../joomla_4/SITE_ADMIN_VIEW_HTML.php | 142 + .../joomla_4/SITE_ADMIN_VIEW_MODEL.php | 446 + .../joomla_4/SITE_AJAX_CONTROLLER.php | 97 + admin/compiler/joomla_4/SITE_AJAX_MODEL.php | 62 + admin/compiler/joomla_4/SITE_DISPATCHER.php | 41 + .../joomla_4/SITE_DISPLAY_CONTROLLER.php | 132 + .../joomla_4/SITE_FORM_CHECKBOXES_FIELD.php | 51 + .../joomla_4/SITE_FORM_CUSTOM_FIELD.php | 36 + .../joomla_4/SITE_FORM_LIST_FIELD.php | 52 + .../joomla_4/SITE_FORM_RADIO_FIELD.php | 51 + admin/compiler/joomla_4/SITE_FORM_RULE.php | 37 + .../joomla_4/SITE_FORM_USER_FIELD.php | 65 + admin/compiler/joomla_4/SITE_HEADERCHECK.php | 135 + admin/compiler/joomla_4/SITE_HELPER_CLASS.php | 926 + .../joomla_4/SITE_HELPER_CONTROLLER.php | 129 + admin/compiler/joomla_4/SITE_LAYOUT.php | 22 + admin/compiler/joomla_4/SITE_ROUTER.php | 97 + admin/compiler/joomla_4/SITE_ROUTE_HELPER.php | 141 + admin/compiler/joomla_4/SITE_VIEW.php | 23 + admin/compiler/joomla_4/SITE_VIEWS.php | 23 + admin/compiler/joomla_4/SITE_VIEWS_HTML.php | 108 + admin/compiler/joomla_4/SITE_VIEWS_MODEL.php | 212 + .../joomla_4/SITE_VIEW_CONTROLLER.php | 120 + admin/compiler/joomla_4/SITE_VIEW_HTML.php | 108 + admin/compiler/joomla_4/SITE_VIEW_MODEL.php | 262 + admin/compiler/joomla_4/access.xml | 4 + admin/compiler/joomla_4/admin.css | 7 + admin/compiler/joomla_4/admin.js | 4 + admin/compiler/joomla_4/component.xml | 87 + admin/compiler/joomla_4/config.xml | 19 + admin/compiler/joomla_4/dashboard.css | 155 + admin/compiler/joomla_4/default.xml | 1 + .../compiler/joomla_4/default_batch_body.php | 26 + .../joomla_4/default_batch_footer.php | 30 + admin/compiler/joomla_4/default_body.php | 28 + .../default_custom_admin_template.php | 24 + admin/compiler/joomla_4/default_foot.php | 23 + admin/compiler/joomla_4/default_head.php | 24 + admin/compiler/joomla_4/default_import.php | 199 + .../joomla_4/default_import_custom.php | 30 + admin/compiler/joomla_4/default_list.xml | 6 + admin/compiler/joomla_4/default_main.php | 37 + .../joomla_4/default_site_template.php | 24 + admin/compiler/joomla_4/default_toolbar.php | 53 + admin/compiler/joomla_4/default_vdm.php | 45 + admin/compiler/joomla_4/edit.xml | 1 + admin/compiler/joomla_4/en-GB.com_admin.ini | 1 + .../compiler/joomla_4/en-GB.com_admin.sys.ini | 1 + admin/compiler/joomla_4/en-GB.com_site.ini | 1 + .../compiler/joomla_4/en-GB.com_site.sys.ini | 1 + admin/compiler/joomla_4/filter_forms.xml | 9 + admin/compiler/joomla_4/import.gif | Bin 0 -> 66680 bytes .../joomla_4}/index.html | 0 .../compiler/joomla_4/install.mysql.utf8.sql | 1 + admin/compiler/joomla_4/layout.php | 47 + admin/compiler/joomla_4/layoutfull.php | 49 + admin/compiler/joomla_4/layoutitems.php | 47 + admin/compiler/joomla_4/layoutlinkedview.php | 34 + admin/compiler/joomla_4/layoutmetadata.php | 48 + admin/compiler/joomla_4/layoutpublished.php | 47 + admin/compiler/joomla_4/layouttitle.php | 57 + admin/compiler/joomla_4/module_forms.js | 3 + admin/compiler/joomla_4/module_forms.xml | 12 + admin/compiler/joomla_4/settings.json | 824 + admin/compiler/joomla_4/site.css | 7 + admin/compiler/joomla_4/site.js | 4 + admin/compiler/joomla_4/submitbutton.js | 17 + admin/compiler/joomla_4/submitbutton_site.js | 17 + .../joomla_4/uninstall.mysql.utf8.sql | 1 + admin/compiler/joomla_4/update_server.xml | 1 + admin/compiler/joomla_4/view.css | 5 + admin/compiler/joomla_4/viewFile.js | 4 + .../compiler/joomla_4/viewFileCustomAdmin.js | 4 + admin/compiler/joomla_4/viewFileSite.js | 4 + admin/compiler/joomla_4/view_custom_admin.css | 5 + admin/compiler/joomla_4/view_site.css | 5 + admin/compiler/joomla_4/view_site_edit.css | 5 + admin/compiler/joomla_4/views.css | 5 + .../compiler/joomla_4/views_custom_admin.css | 5 + admin/compiler/joomla_4/views_site.css | 5 + admin/compiler/joomla_4/whmcs.php | 20 + admin/compiler/joomla_basic.txt | 10 + admin/componentbuilder.php | 98 - admin/config.xml | 30 +- admin/controller.php | 160 - admin/controllers/admin_custom_tabs.php | 324 - admin/controllers/admin_fields.php | 324 - admin/controllers/admin_fields_conditions.php | 324 - admin/controllers/admin_fields_relations.php | 324 - admin/controllers/admin_view.php | 351 - admin/controllers/admin_views.php | 151 - admin/controllers/admins_custom_tabs.php | 46 - admin/controllers/admins_fields.php | 46 - .../controllers/admins_fields_conditions.php | 46 - admin/controllers/admins_fields_relations.php | 46 - admin/controllers/ajax.json.php | 2017 -- admin/controllers/class_extendings.php | 46 - admin/controllers/class_extends.php | 324 - admin/controllers/class_method.php | 324 - admin/controllers/class_methods.php | 109 - admin/controllers/class_properties.php | 109 - admin/controllers/class_property.php | 324 - admin/controllers/compiler.php | 630 - admin/controllers/component_admin_views.php | 324 - admin/controllers/component_config.php | 324 - .../component_custom_admin_menus.php | 324 - .../component_custom_admin_views.php | 324 - admin/controllers/component_dashboard.php | 324 - admin/controllers/component_files_folders.php | 324 - admin/controllers/component_modules.php | 324 - admin/controllers/component_mysql_tweaks.php | 324 - admin/controllers/component_placeholders.php | 324 - admin/controllers/component_plugins.php | 324 - admin/controllers/component_site_views.php | 324 - admin/controllers/component_updates.php | 354 - admin/controllers/componentbuilder.php | 24 - admin/controllers/components_admin_views.php | 46 - admin/controllers/components_config.php | 46 - .../components_custom_admin_menus.php | 46 - .../components_custom_admin_views.php | 46 - admin/controllers/components_dashboard.php | 46 - .../controllers/components_files_folders.php | 46 - admin/controllers/components_modules.php | 46 - admin/controllers/components_mysql_tweaks.php | 46 - admin/controllers/components_placeholders.php | 46 - admin/controllers/components_plugins.php | 46 - admin/controllers/components_site_views.php | 46 - admin/controllers/components_updates.php | 46 - admin/controllers/custom_admin_view.php | 324 - admin/controllers/custom_admin_views.php | 118 - admin/controllers/custom_code.php | 324 - admin/controllers/custom_codes.php | 151 - admin/controllers/dynamic_get.php | 324 - admin/controllers/dynamic_gets.php | 151 - admin/controllers/field.php | 323 - admin/controllers/fields.php | 151 - admin/controllers/fieldtype.php | 323 - admin/controllers/fieldtypes.php | 109 - admin/controllers/get_snippets.php | 101 - admin/controllers/help.php | 116 - admin/controllers/help_document.php | 324 - admin/controllers/help_documents.php | 109 - admin/controllers/import.php | 56 - .../controllers/import_joomla_components.php | 57 - .../import_language_translations.php | 56 - admin/controllers/joomla_component.php | 383 - admin/controllers/joomla_components.php | 513 - admin/controllers/joomla_module.php | 350 - .../joomla_module_files_folders_urls.php | 324 - admin/controllers/joomla_module_updates.php | 344 - admin/controllers/joomla_modules.php | 118 - .../joomla_modules_files_folders_urls.php | 46 - admin/controllers/joomla_modules_updates.php | 46 - admin/controllers/joomla_plugin.php | 350 - .../joomla_plugin_files_folders_urls.php | 324 - admin/controllers/joomla_plugin_group.php | 317 - admin/controllers/joomla_plugin_groups.php | 46 - admin/controllers/joomla_plugin_updates.php | 344 - admin/controllers/joomla_plugins.php | 140 - .../joomla_plugins_files_folders_urls.php | 46 - admin/controllers/joomla_plugins_updates.php | 46 - admin/controllers/language.php | 324 - admin/controllers/language_translation.php | 324 - admin/controllers/language_translations.php | 109 - admin/controllers/languages.php | 136 - admin/controllers/layout.php | 324 - admin/controllers/layouts.php | 118 - admin/controllers/libraries.php | 55 - admin/controllers/libraries_config.php | 46 - .../libraries_files_folders_urls.php | 46 - admin/controllers/library.php | 349 - admin/controllers/library_config.php | 324 - .../library_files_folders_urls.php | 324 - admin/controllers/placeholder.php | 324 - admin/controllers/placeholders.php | 109 - admin/controllers/power.php | 381 - admin/controllers/powers.php | 168 - admin/controllers/search.php | 42 - admin/controllers/server.php | 324 - admin/controllers/servers.php | 109 - admin/controllers/site_view.php | 324 - admin/controllers/site_views.php | 118 - admin/controllers/snippet.php | 324 - admin/controllers/snippet_type.php | 324 - admin/controllers/snippet_types.php | 46 - admin/controllers/snippets.php | 183 - admin/controllers/template.php | 324 - admin/controllers/templates.php | 118 - admin/controllers/validation_rule.php | 324 - admin/controllers/validation_rules.php | 151 - .../{models => }/forms/admin_custom_tabs.xml | 10 +- admin/{models => }/forms/admin_fields.xml | 10 +- .../forms/admin_fields_conditions.xml | 10 +- .../forms/admin_fields_relations.xml | 10 +- admin/{models => }/forms/admin_view.xml | 14 +- admin/{models => }/forms/class_extends.xml | 10 +- admin/{models => }/forms/class_method.xml | 10 +- admin/{models => }/forms/class_property.xml | 10 +- .../forms/component_admin_views.xml | 10 +- admin/{models => }/forms/component_config.xml | 10 +- .../forms/component_custom_admin_menus.xml | 10 +- .../forms/component_custom_admin_views.xml | 10 +- .../forms/component_dashboard.xml | 10 +- .../forms/component_files_folders.xml | 10 +- .../{models => }/forms/component_modules.xml | 10 +- .../forms/component_mysql_tweaks.xml | 10 +- .../forms/component_placeholders.xml | 10 +- .../{models => }/forms/component_plugins.xml | 10 +- admin/forms/component_router.xml | 277 + .../forms/component_site_views.xml | 11 +- .../{models => }/forms/component_updates.xml | 10 +- .../{models => }/forms/custom_admin_view.xml | 10 +- admin/{models => }/forms/custom_code.xml | 22 +- admin/{models => }/forms/dynamic_get.xml | 484 +- admin/{models => }/forms/field.xml | 10 +- admin/{models => }/forms/fieldtype.xml | 10 +- .../{models => }/forms/filter_admin_views.xml | 38 +- admin/forms/filter_admins_custom_tabs.xml | 62 + admin/forms/filter_admins_fields.xml | 62 + .../forms/filter_admins_fields_conditions.xml | 62 + .../forms/filter_admins_fields_relations.xml | 62 + admin/forms/filter_class_extendings.xml | 73 + .../forms/filter_class_methods.xml | 29 +- .../forms/filter_class_properties.xml | 29 +- admin/forms/filter_components_admin_views.xml | 62 + admin/forms/filter_components_config.xml | 62 + .../filter_components_custom_admin_menus.xml | 62 + .../filter_components_custom_admin_views.xml | 62 + admin/forms/filter_components_dashboard.xml | 62 + .../forms/filter_components_files_folders.xml | 62 + admin/forms/filter_components_modules.xml | 62 + .../forms/filter_components_mysql_tweaks.xml | 62 + .../forms/filter_components_placeholders.xml | 62 + admin/forms/filter_components_plugins.xml | 62 + admin/forms/filter_components_routers.xml | 83 + admin/forms/filter_components_site_views.xml | 62 + admin/forms/filter_components_updates.xml | 62 + .../forms/filter_custom_admin_views.xml | 34 +- .../forms/filter_custom_codes.xml | 35 +- .../forms/filter_dynamic_gets.xml | 29 +- admin/{models => }/forms/filter_fields.xml | 39 +- .../{models => }/forms/filter_fieldtypes.xml | 29 +- admin/forms/filter_help_documents.xml | 91 + .../forms/filter_joomla_components.xml | 35 +- admin/forms/filter_joomla_modules.xml | 73 + ...lter_joomla_modules_files_folders_urls.xml | 62 + admin/forms/filter_joomla_modules_updates.xml | 62 + admin/forms/filter_joomla_plugin_groups.xml | 73 + .../forms/filter_joomla_plugins.xml | 29 +- ...lter_joomla_plugins_files_folders_urls.xml | 62 + admin/forms/filter_joomla_plugins_updates.xml | 62 + admin/forms/filter_language_translations.xml | 64 + admin/forms/filter_languages.xml | 66 + admin/{models => }/forms/filter_layouts.xml | 29 +- admin/{models => }/forms/filter_libraries.xml | 31 +- admin/forms/filter_libraries_config.xml | 62 + .../filter_libraries_files_folders_urls.xml | 62 + admin/forms/filter_placeholders.xml | 66 + admin/{models => }/forms/filter_powers.xml | 32 +- admin/forms/filter_servers.xml | 80 + .../{models => }/forms/filter_site_views.xml | 34 +- admin/forms/filter_snippet_types.xml | 66 + admin/{models => }/forms/filter_snippets.xml | 29 +- admin/{models => }/forms/filter_templates.xml | 29 +- admin/forms/filter_validation_rules.xml | 66 + admin/{models => }/forms/help_document.xml | 15 +- admin/{helpers/compiler => forms}/index.html | 0 admin/{models => }/forms/joomla_component.xml | 1200 +- admin/{models => }/forms/joomla_module.xml | 10 +- .../joomla_module_files_folders_urls.xml | 10 +- .../forms/joomla_module_updates.xml | 10 +- admin/{models => }/forms/joomla_plugin.xml | 10 +- .../joomla_plugin_files_folders_urls.xml | 10 +- .../forms/joomla_plugin_group.xml | 10 +- .../forms/joomla_plugin_updates.xml | 10 +- admin/{models => }/forms/language.xml | 10 +- .../forms/language_translation.xml | 10 +- admin/{models => }/forms/layout.xml | 10 +- admin/{models => }/forms/library.xml | 10 +- admin/{models => }/forms/library_config.xml | 10 +- .../forms/library_files_folders_urls.xml | 10 +- admin/{models => }/forms/placeholder.xml | 10 +- admin/{models => }/forms/power.xml | 10 +- admin/{models => }/forms/server.xml | 10 +- admin/{models => }/forms/site_view.xml | 10 +- admin/{models => }/forms/snippet.xml | 10 +- admin/{models => }/forms/snippet_type.xml | 10 +- admin/{models => }/forms/template.xml | 10 +- admin/{models => }/forms/validation_rule.xml | 10 +- admin/helpers/compiler.php | 1701 - admin/helpers/compiler/a_Get.php | 3167 -- admin/helpers/compiler/b_Structure.php | 889 - admin/helpers/compiler/c_Fields.php | 1242 - admin/helpers/compiler/e_Interpretation.php | 26830 ---------------- admin/helpers/compiler/f_Infusion.php | 2235 -- admin/helpers/componentbuilder.php | 6727 ---- admin/helpers/componentbuilderemail.php | 461 - admin/helpers/extrusion/a_mapping.php | 420 - admin/helpers/extrusion/b_builder.php | 294 - admin/helpers/extrusion/c_extrusion.php | 111 - admin/helpers/headercheck.php | 71 - admin/helpers/html/batch_.php | 78 - admin/helpers/indenter.php | 204 - .../en-GB/en-GB.com_componentbuilder.ini | 380 +- .../en-GB/en-GB.com_componentbuilder.sys.ini | 21 + .../layouts/admin_custom_tabs/publishing.php | 4 +- .../layouts/admin_custom_tabs/publlshing.php | 4 +- .../layouts/admin_custom_tabs/tabs_above.php | 20 +- .../admin_custom_tabs/tabs_fullwidth.php | 4 +- admin/layouts/admin_fields/fields_above.php | 20 +- .../layouts/admin_fields/fields_fullwidth.php | 4 +- admin/layouts/admin_fields/publishing.php | 4 +- admin/layouts/admin_fields/publlshing.php | 4 +- .../conditions_above.php | 20 +- .../conditions_fullwidth.php | 4 +- .../admin_fields_conditions/publishing.php | 4 +- .../admin_fields_conditions/publlshing.php | 4 +- .../admin_fields_relations/publishing.php | 4 +- .../admin_fields_relations/publlshing.php | 4 +- .../relations_above.php | 20 +- .../relations_fullwidth.php | 4 +- admin/layouts/admin_view/css_fullwidth.php | 4 +- .../admin_view/custom_buttons_fullwidth.php | 4 +- .../admin_view/custom_buttons_left.php | 4 +- .../admin_view/custom_import_fullwidth.php | 4 +- admin/layouts/admin_view/details_above.php | 20 +- .../layouts/admin_view/details_fullwidth.php | 4 +- admin/layouts/admin_view/details_left.php | 4 +- admin/layouts/admin_view/details_right.php | 4 +- admin/layouts/admin_view/details_under.php | 20 +- admin/layouts/admin_view/fields_fullwidth.php | 4 +- admin/layouts/admin_view/fields_left.php | 4 +- admin/layouts/admin_view/fields_right.php | 4 +- .../admin_view/javascript_fullwidth.php | 4 +- admin/layouts/admin_view/mysql_fullwidth.php | 4 +- admin/layouts/admin_view/mysql_left.php | 4 +- admin/layouts/admin_view/php_fullwidth.php | 4 +- admin/layouts/admin_view/publishing.php | 4 +- admin/layouts/admin_view/publlshing.php | 4 +- .../layouts/admin_view/settings_fullwidth.php | 4 +- admin/layouts/batchselection.php | 48 - .../class_extends/details_fullwidth.php | 4 +- admin/layouts/class_extends/details_left.php | 4 +- admin/layouts/class_extends/details_right.php | 4 +- admin/layouts/class_extends/publishing.php | 4 +- admin/layouts/class_extends/publlshing.php | 4 +- .../class_method/details_fullwidth.php | 4 +- admin/layouts/class_method/details_left.php | 4 +- admin/layouts/class_method/details_right.php | 4 +- admin/layouts/class_method/publishing.php | 4 +- admin/layouts/class_method/publlshing.php | 4 +- admin/layouts/class_property/details_left.php | 4 +- .../layouts/class_property/details_right.php | 4 +- admin/layouts/class_property/publishing.php | 4 +- admin/layouts/class_property/publlshing.php | 4 +- .../component_admin_views/clone_left.php | 4 +- .../component_admin_views/publishing.php | 4 +- .../component_admin_views/publlshing.php | 4 +- .../component_admin_views/views_above.php | 20 +- .../component_admin_views/views_fullwidth.php | 4 +- admin/layouts/component_config/clone_left.php | 4 +- .../component_config/options_above.php | 20 +- .../component_config/options_fullwidth.php | 4 +- admin/layouts/component_config/publishing.php | 4 +- admin/layouts/component_config/publlshing.php | 4 +- .../clone_left.php | 4 +- .../menus_above.php | 20 +- .../menus_fullwidth.php | 4 +- .../publishing.php | 4 +- .../publlshing.php | 4 +- .../clone_left.php | 4 +- .../publishing.php | 4 +- .../publlshing.php | 4 +- .../views_above.php | 20 +- .../views_fullwidth.php | 4 +- .../component_dashboard/clone_left.php | 4 +- .../component_dashboard/dashboard_above.php | 20 +- .../dashboard_fullwidth.php | 4 +- .../component_dashboard/publishing.php | 4 +- .../component_dashboard/publlshing.php | 4 +- .../advance_fullwidth.php | 4 +- .../component_files_folders/basic_above.php | 20 +- .../basic_fullwidth.php | 4 +- .../component_files_folders/clone_left.php | 4 +- .../component_files_folders/publishing.php | 4 +- .../component_files_folders/publlshing.php | 4 +- .../layouts/component_modules/clone_left.php | 4 +- .../component_modules/modules_above.php | 20 +- .../component_modules/modules_fullwidth.php | 4 +- .../layouts/component_modules/publishing.php | 4 +- .../layouts/component_modules/publlshing.php | 4 +- .../component_mysql_tweaks/clone_left.php | 4 +- .../mysql_tweaks_above.php | 20 +- .../mysql_tweaks_fullwidth.php | 4 +- .../component_mysql_tweaks/publishing.php | 4 +- .../component_mysql_tweaks/publlshing.php | 4 +- .../component_placeholders/clone_left.php | 4 +- .../component_placeholders/details_above.php | 20 +- .../details_fullwidth.php | 4 +- .../component_placeholders/publishing.php | 4 +- .../component_placeholders/publlshing.php | 4 +- .../layouts/component_plugins/clone_left.php | 4 +- .../component_plugins/plugins_above.php | 20 +- .../component_plugins/plugins_fullwidth.php | 4 +- .../layouts/component_plugins/publishing.php | 4 +- .../layouts/component_plugins/publlshing.php | 4 +- .../component_router}/index.html | 0 admin/layouts/component_router/publishing.php | 46 + admin/layouts/component_router/publlshing.php | 47 + .../component_router/settings_above.php | 52 + .../component_router/settings_fullwidth.php | 54 + .../component_site_views/clone_left.php | 4 +- .../component_site_views/publishing.php | 4 +- .../component_site_views/publlshing.php | 4 +- .../component_site_views/views_above.php | 20 +- .../component_site_views/views_fullwidth.php | 4 +- .../layouts/component_updates/clone_left.php | 4 +- .../layouts/component_updates/publishing.php | 4 +- .../layouts/component_updates/publlshing.php | 4 +- .../component_updates/updates_above.php | 20 +- .../component_updates/updates_fullwidth.php | 4 +- .../custom_buttons_fullwidth.php | 4 +- .../custom_admin_view/custom_buttons_left.php | 4 +- .../custom_admin_view/details_above.php | 20 +- .../custom_admin_view/details_fullwidth.php | 4 +- .../custom_admin_view/details_left.php | 4 +- .../custom_admin_view/details_right.php | 4 +- .../custom_admin_view/details_rightside.php | 4 +- .../custom_admin_view/details_under.php | 20 +- .../javascript_css_fullwidth.php | 4 +- .../linked_components_fullwidth.php | 4 +- .../custom_admin_view/php_fullwidth.php | 4 +- .../layouts/custom_admin_view/publishing.php | 4 +- .../layouts/custom_admin_view/publlshing.php | 4 +- admin/layouts/custom_code/details_above.php | 21 +- .../layouts/custom_code/details_fullwidth.php | 4 +- admin/layouts/custom_code/details_left.php | 4 +- admin/layouts/custom_code/details_right.php | 4 +- admin/layouts/custom_code/details_under.php | 20 +- admin/layouts/custom_code/publishing.php | 4 +- admin/layouts/custom_code/publlshing.php | 4 +- .../layouts/dynamic_get/abacus_fullwidth.php | 4 +- admin/layouts/dynamic_get/abacus_left.php | 4 +- .../dynamic_get/custom_script_fullwidth.php | 5 +- admin/layouts/dynamic_get/joint_fullwidth.php | 4 +- admin/layouts/dynamic_get/main_above.php | 20 +- admin/layouts/dynamic_get/main_fullwidth.php | 4 +- admin/layouts/dynamic_get/main_left.php | 4 +- admin/layouts/dynamic_get/main_right.php | 4 +- admin/layouts/dynamic_get/main_under.php | 20 +- admin/layouts/dynamic_get/publishing.php | 4 +- admin/layouts/dynamic_get/publlshing.php | 4 +- admin/layouts/dynamic_get/tweak_fullwidth.php | 4 +- admin/layouts/field/database_fullwidth.php | 4 +- admin/layouts/field/database_left.php | 4 +- admin/layouts/field/database_right.php | 4 +- admin/layouts/field/publishing.php | 4 +- admin/layouts/field/publlshing.php | 4 +- admin/layouts/field/scripts_left.php | 4 +- admin/layouts/field/scripts_right.php | 4 +- admin/layouts/field/set_properties_above.php | 20 +- .../field/set_properties_fullwidth.php | 4 +- admin/layouts/field/set_properties_under.php | 20 +- admin/layouts/field/type_info_fullwidth.php | 4 +- .../fieldtype/database_defaults_left.php | 4 +- .../fieldtype/database_defaults_right.php | 4 +- admin/layouts/fieldtype/details_above.php | 20 +- admin/layouts/fieldtype/details_fullwidth.php | 4 +- admin/layouts/fieldtype/details_left.php | 4 +- admin/layouts/fieldtype/details_right.php | 4 +- admin/layouts/fieldtype/fields_fullwidth.php | 71 +- admin/layouts/fieldtype/publishing.php | 4 +- admin/layouts/fieldtype/publlshing.php | 4 +- admin/layouts/help_document/details_above.php | 20 +- .../help_document/details_fullwidth.php | 4 +- admin/layouts/help_document/details_left.php | 4 +- admin/layouts/help_document/details_right.php | 4 +- admin/layouts/help_document/details_under.php | 20 +- admin/layouts/help_document/publishing.php | 4 +- admin/layouts/help_document/publlshing.php | 4 +- admin/layouts/jcbnoticeboardpro.php | 14 +- admin/layouts/jcbnoticeboardtabs.php | 32 +- admin/layouts/jcbnoticeboardvdm.php | 14 +- admin/layouts/jcbsupportmessage.php | 154 +- .../admin_views_fullwidth.php | 4 +- .../custom_admin_views_fullwidth.php | 4 +- .../dash_install_fullwidth.php | 4 +- .../joomla_component/dash_install_left.php | 4 +- .../joomla_component/dash_install_right.php | 4 +- .../joomla_component/details_above.php | 21 +- .../layouts/joomla_component/details_left.php | 4 +- .../joomla_component/details_right.php | 4 +- .../joomla_component/details_under.php | 20 +- .../dynamic_build_beta_fullwidth.php | 4 +- .../dynamic_integration_left.php | 4 +- .../dynamic_integration_right.php | 4 +- .../libs_helpers_fullwidth.php | 4 +- admin/layouts/joomla_component/metadata.php | 6 +- .../joomla_component/mysql_fullwidth.php | 4 +- admin/layouts/joomla_component/publishing.php | 4 +- .../layouts/joomla_component/readme_left.php | 4 +- .../layouts/joomla_component/readme_right.php | 4 +- .../joomla_component/settings_fullwidth.php | 6 +- .../joomla_component/settings_left.php | 4 +- .../joomla_component/settings_right.php | 11 +- .../joomla_component/site_views_fullwidth.php | 4 +- .../layouts/joomla_module/code_fullwidth.php | 4 +- admin/layouts/joomla_module/code_left.php | 4 +- admin/layouts/joomla_module/code_right.php | 4 +- .../dynamic_integration_left.php | 4 +- .../joomla_module/forms_fields_fullwidth.php | 4 +- .../joomla_module/helper_fullwidth.php | 4 +- admin/layouts/joomla_module/helper_left.php | 4 +- admin/layouts/joomla_module/helper_right.php | 4 +- admin/layouts/joomla_module/html_above.php | 20 +- .../layouts/joomla_module/html_fullwidth.php | 4 +- admin/layouts/joomla_module/html_left.php | 4 +- admin/layouts/joomla_module/html_right.php | 4 +- .../layouts/joomla_module/mysql_fullwidth.php | 4 +- admin/layouts/joomla_module/publishing.php | 4 +- admin/layouts/joomla_module/publlshing.php | 4 +- admin/layouts/joomla_module/readme_left.php | 4 +- .../joomla_module/script_file_fullwidth.php | 4 +- .../advance_fullwidth.php | 4 +- .../basic_above.php | 20 +- .../basic_fullwidth.php | 4 +- .../publishing.php | 4 +- .../publlshing.php | 4 +- .../joomla_module_updates/publishing.php | 4 +- .../joomla_module_updates/publlshing.php | 4 +- .../joomla_module_updates/updates_above.php | 20 +- .../updates_fullwidth.php | 4 +- admin/layouts/joomla_plugin/code_above.php | 20 +- .../layouts/joomla_plugin/code_fullwidth.php | 4 +- admin/layouts/joomla_plugin/code_left.php | 4 +- admin/layouts/joomla_plugin/code_right.php | 4 +- .../dynamic_integration_left.php | 4 +- .../joomla_plugin/forms_fields_fullwidth.php | 4 +- .../layouts/joomla_plugin/mysql_fullwidth.php | 4 +- admin/layouts/joomla_plugin/publishing.php | 4 +- admin/layouts/joomla_plugin/publlshing.php | 4 +- admin/layouts/joomla_plugin/readme_left.php | 4 +- .../joomla_plugin/script_file_fullwidth.php | 4 +- .../advance_fullwidth.php | 4 +- .../basic_above.php | 20 +- .../basic_fullwidth.php | 4 +- .../publishing.php | 4 +- .../publlshing.php | 4 +- .../joomla_plugin_group/details_left.php | 4 +- .../joomla_plugin_group/details_right.php | 4 +- .../joomla_plugin_group/publishing.php | 4 +- .../joomla_plugin_group/publlshing.php | 4 +- .../joomla_plugin_updates/publishing.php | 4 +- .../joomla_plugin_updates/publlshing.php | 4 +- .../joomla_plugin_updates/updates_above.php | 20 +- .../updates_fullwidth.php | 4 +- admin/layouts/language/details_left.php | 4 +- admin/layouts/language/details_right.php | 4 +- admin/layouts/language/publishing.php | 4 +- admin/layouts/language/publlshing.php | 4 +- .../details_fullwidth.php | 4 +- .../language_translation/publishing.php | 4 +- .../language_translation/publlshing.php | 4 +- .../layout/custom_script_fullwidth.php | 4 +- admin/layouts/layout/details_fullwidth.php | 4 +- admin/layouts/layout/details_left.php | 4 +- admin/layouts/layout/details_right.php | 4 +- admin/layouts/layout/details_rightside.php | 4 +- admin/layouts/layout/details_under.php | 20 +- admin/layouts/layout/publishing.php | 4 +- admin/layouts/layout/publlshing.php | 4 +- admin/layouts/library/behaviour_above.php | 20 +- admin/layouts/library/behaviour_fullwidth.php | 4 +- admin/layouts/library/behaviour_left.php | 4 +- admin/layouts/library/behaviour_right.php | 4 +- admin/layouts/library/behaviour_under.php | 20 +- admin/layouts/library/config_fullwidth.php | 4 +- .../library/files_folders_urls_fullwidth.php | 4 +- admin/layouts/library/linked_fullwidth.php | 4 +- admin/layouts/library/publishing.php | 4 +- admin/layouts/library/publlshing.php | 4 +- admin/layouts/library_config/publishing.php | 4 +- admin/layouts/library_config/publlshing.php | 4 +- admin/layouts/library_config/tweaks_above.php | 20 +- .../library_config/tweaks_fullwidth.php | 4 +- .../advance_fullwidth.php | 4 +- .../basic_above.php | 20 +- .../basic_fullwidth.php | 4 +- .../library_files_folders_urls/publishing.php | 4 +- .../library_files_folders_urls/publlshing.php | 4 +- .../layouts/placeholder/details_fullwidth.php | 4 +- admin/layouts/placeholder/details_left.php | 4 +- admin/layouts/placeholder/details_right.php | 4 +- admin/layouts/placeholder/publishing.php | 4 +- admin/layouts/placeholder/publlshing.php | 4 +- admin/layouts/power/code_above.php | 20 +- admin/layouts/power/code_fullwidth.php | 4 +- admin/layouts/power/code_left.php | 4 +- admin/layouts/power/code_right.php | 4 +- admin/layouts/power/composer_fullwidth.php | 4 +- admin/layouts/power/licensing_fullwidth.php | 4 +- admin/layouts/power/publishing.php | 4 +- admin/layouts/power/publlshing.php | 4 +- admin/layouts/power/super_power_left.php | 4 +- admin/layouts/power/super_power_right.php | 4 +- admin/layouts/repeatablejcb.php | 20 +- admin/layouts/rows.php | 10 +- admin/layouts/sectionjcb.php | 16 +- admin/layouts/server/details_above.php | 20 +- admin/layouts/server/details_fullwidth.php | 4 +- admin/layouts/server/details_left.php | 4 +- admin/layouts/server/details_right.php | 4 +- .../server/linked_components_fullwidth.php | 248 +- admin/layouts/server/publishing.php | 4 +- admin/layouts/server/publlshing.php | 4 +- .../site_view/custom_buttons_fullwidth.php | 4 +- .../layouts/site_view/custom_buttons_left.php | 4 +- .../site_view/custom_buttons_right.php | 4 +- admin/layouts/site_view/details_above.php | 20 +- admin/layouts/site_view/details_fullwidth.php | 4 +- admin/layouts/site_view/details_left.php | 4 +- admin/layouts/site_view/details_right.php | 4 +- admin/layouts/site_view/details_rightside.php | 4 +- admin/layouts/site_view/details_under.php | 20 +- .../site_view/javascript_css_fullwidth.php | 4 +- .../site_view/linked_components_fullwidth.php | 4 +- admin/layouts/site_view/php_fullwidth.php | 4 +- admin/layouts/site_view/publishing.php | 4 +- admin/layouts/site_view/publlshing.php | 4 +- .../layouts/snippet/contributor_fullwidth.php | 4 +- admin/layouts/snippet/contributor_left.php | 4 +- admin/layouts/snippet/contributor_right.php | 4 +- admin/layouts/snippet/details_above.php | 20 +- admin/layouts/snippet/details_left.php | 4 +- admin/layouts/snippet/details_right.php | 4 +- admin/layouts/snippet/publishing.php | 4 +- admin/layouts/snippet/publlshing.php | 4 +- admin/layouts/snippet_type/details_left.php | 4 +- admin/layouts/snippet_type/details_right.php | 4 +- admin/layouts/snippet_type/publishing.php | 4 +- admin/layouts/snippet_type/publlshing.php | 4 +- admin/layouts/table.php | 23 +- .../template/custom_script_fullwidth.php | 4 +- admin/layouts/template/details_fullwidth.php | 4 +- admin/layouts/template/details_left.php | 4 +- admin/layouts/template/details_right.php | 4 +- admin/layouts/template/details_rightside.php | 4 +- admin/layouts/template/details_under.php | 20 +- admin/layouts/template/publishing.php | 4 +- admin/layouts/template/publlshing.php | 4 +- admin/layouts/trashhelper.php | 26 +- .../extends_formrule_above.php | 20 +- .../extends_formrule_fullwidth.php | 4 +- .../validation_rule/extends_formrule_left.php | 4 +- .../extends_formrule_right.php | 4 +- admin/layouts/validation_rule/publishing.php | 4 +- admin/layouts/validation_rule/publlshing.php | 4 +- admin/models/admin_custom_tabs.php | 897 - admin/models/admin_fields.php | 928 - admin/models/admin_fields_conditions.php | 918 - admin/models/admin_fields_relations.php | 982 - admin/models/admin_view.php | 1880 -- admin/models/admin_views.php | 861 - admin/models/admins_custom_tabs.php | 281 - admin/models/admins_fields.php | 281 - admin/models/admins_fields_conditions.php | 281 - admin/models/admins_fields_relations.php | 281 - admin/models/ajax.php | 4101 --- admin/models/class_extendings.php | 364 - admin/models/class_extends.php | 1007 - admin/models/class_method.php | 1081 - admin/models/class_methods.php | 543 - admin/models/class_properties.php | 539 - admin/models/class_property.php | 1066 - admin/models/compiler.php | 387 - admin/models/component_admin_views.php | 944 - admin/models/component_config.php | 940 - admin/models/component_custom_admin_menus.php | 943 - admin/models/component_custom_admin_views.php | 944 - admin/models/component_dashboard.php | 1044 - admin/models/component_files_folders.php | 1020 - admin/models/component_modules.php | 910 - admin/models/component_mysql_tweaks.php | 940 - admin/models/component_placeholders.php | 909 - admin/models/component_plugins.php | 910 - admin/models/component_site_views.php | 944 - admin/models/component_updates.php | 943 - admin/models/componentbuilder.php | 559 - admin/models/components_admin_views.php | 281 - admin/models/components_config.php | 281 - .../models/components_custom_admin_menus.php | 281 - .../models/components_custom_admin_views.php | 281 - admin/models/components_dashboard.php | 281 - admin/models/components_files_folders.php | 281 - admin/models/components_modules.php | 281 - admin/models/components_mysql_tweaks.php | 281 - admin/models/components_placeholders.php | 281 - admin/models/components_plugins.php | 281 - admin/models/components_site_views.php | 281 - admin/models/components_updates.php | 281 - admin/models/custom_admin_view.php | 1339 - admin/models/custom_admin_views.php | 715 - admin/models/custom_code.php | 1078 - admin/models/custom_codes.php | 633 - admin/models/dynamic_get.php | 1389 - admin/models/dynamic_gets.php | 544 - admin/models/field.php | 1292 - admin/models/fields.php | 903 - .../fields/adminlistvieworderfields.php | 141 - admin/models/fields/adminsviews.php | 57 - admin/models/fields/adminviewfolderlist.php | 58 - admin/models/fields/adminviews.php | 58 - .../adminviewsfilteraddcustombutton.php | 71 - .../adminviewsfilteraddcustomimport.php | 71 - .../fields/adminviewsfilteraddfadein.php | 71 - .../fields/adminviewsfilteraddphpajax.php | 71 - admin/models/fields/adminviewsfiltertype.php | 70 - admin/models/fields/adminviewsreadonly.php | 57 - admin/models/fields/aliasbuilder.php | 99 - admin/models/fields/articles.php | 57 - .../classextendingsfilterextensiontype.php | 71 - admin/models/fields/classextends.php | 174 - .../classmethodsfilterextensiontype.php | 71 - .../fields/classmethodsfiltervisibility.php | 71 - admin/models/fields/classpowers.php | 195 - .../classpropertiesfilterextensiontype.php | 71 - .../classpropertiesfiltervisibility.php | 71 - admin/models/fields/componentadminmenus.php | 102 - admin/models/fields/componentadminviews.php | 102 - admin/models/fields/customadminviews.php | 57 - .../customadminviewsfilteraddcustombutton.php | 71 - .../customadminviewsfilteraddphpajax.php | 71 - .../fields/customcodesfiltercommenttype.php | 71 - .../models/fields/customcodesfiltertarget.php | 71 - admin/models/fields/customcodesfiltertype.php | 71 - admin/models/fields/customfilelist.php | 61 - admin/models/fields/customfolderlist.php | 61 - admin/models/fields/customgets.php | 59 - admin/models/fields/dbtables.php | 61 - admin/models/fields/dynamicdashboard.php | 103 - admin/models/fields/dynamicget.php | 163 - admin/models/fields/dynamicgets.php | 58 - .../fields/dynamicgetsfiltergettype.php | 71 - .../fields/dynamicgetsfiltermainsource.php | 71 - admin/models/fields/excludedlanguages.php | 176 - .../models/fields/existingvalidationrules.php | 51 - admin/models/fields/fields.php | 70 - admin/models/fields/fieldsfilterdatatype.php | 71 - admin/models/fields/fieldsfilterindexes.php | 71 - .../models/fields/fieldsfilternullswitch.php | 71 - admin/models/fields/fieldsfilterstore.php | 71 - admin/models/fields/fieldtypes.php | 162 - admin/models/fields/filebehaviour.php | 54 - .../fields/helpdocumentsfilterlocation.php | 71 - .../models/fields/helpdocumentsfiltertype.php | 71 - admin/models/fields/interfacepowers.php | 190 - admin/models/fields/joinfields.php | 109 - admin/models/fields/joomlacomponent.php | 162 - admin/models/fields/joomlacomponents.php | 57 - .../fields/joomlacomponentsfilterauthor.php | 66 - .../joomlacomponentsfiltercompanyname.php | 66 - admin/models/fields/joomlamodules.php | 71 - .../fields/joomlamodulesfiltertarget.php | 71 - admin/models/fields/joomlaplugingroups.php | 174 - admin/models/fields/joomlaplugins.php | 177 - admin/models/fields/lang.php | 78 - .../models/fields/layoutsfilteraddphpview.php | 71 - admin/models/fields/libconfigfield.php | 92 - admin/models/fields/libraries.php | 162 - admin/models/fields/librariesfiltertarget.php | 71 - admin/models/fields/librariesfiltertype.php | 71 - admin/models/fields/librariesx.php | 170 - admin/models/fields/library.php | 163 - admin/models/fields/libraryfiles.php | 57 - admin/models/fields/libraryreadonly.php | 56 - .../models/fields/linkedviewsorderfields.php | 108 - admin/models/fields/listfields.php | 115 - admin/models/fields/maingets.php | 163 - admin/models/fields/matchfield.php | 103 - admin/models/fields/namespaces.php | 89 - admin/models/fields/pluginsclassmethods.php | 81 - .../models/fields/pluginsclassproperties.php | 81 - admin/models/fields/powers.php | 80 - admin/models/fields/powersclassmethods.php | 81 - admin/models/fields/powersclassproperties.php | 81 - admin/models/fields/powersfilterapproved.php | 71 - admin/models/fields/powersfiltertype.php | 70 - admin/models/fields/servers.php | 162 - admin/models/fields/serversfiltername.php | 67 - admin/models/fields/serversfilterprotocol.php | 71 - admin/models/fields/siteviewfolderlist.php | 58 - admin/models/fields/siteviews.php | 57 - .../fields/siteviewsfilteraddcustombutton.php | 71 - .../fields/siteviewsfilteraddphpajax.php | 71 - admin/models/fields/snippets.php | 167 - admin/models/fields/snippettype.php | 57 - admin/models/fields/superpowerpaths.php | 100 - admin/models/fields/targetfields.php | 109 - .../fields/templatesfilteraddphpview.php | 71 - admin/models/fields/viewtabs.php | 100 - admin/models/fieldtype.php | 1359 - admin/models/fieldtypes.php | 508 - .../forms/filter_admins_custom_tabs.xml | 65 - admin/models/forms/filter_admins_fields.xml | 65 - .../forms/filter_admins_fields_conditions.xml | 65 - .../forms/filter_admins_fields_relations.xml | 65 - .../models/forms/filter_class_extendings.xml | 76 - .../forms/filter_components_admin_views.xml | 65 - .../models/forms/filter_components_config.xml | 65 - .../filter_components_custom_admin_menus.xml | 65 - .../filter_components_custom_admin_views.xml | 65 - .../forms/filter_components_dashboard.xml | 65 - .../forms/filter_components_files_folders.xml | 65 - .../forms/filter_components_modules.xml | 65 - .../forms/filter_components_mysql_tweaks.xml | 65 - .../forms/filter_components_placeholders.xml | 65 - .../forms/filter_components_plugins.xml | 65 - .../forms/filter_components_site_views.xml | 65 - .../forms/filter_components_updates.xml | 65 - admin/models/forms/filter_help_documents.xml | 94 - admin/models/forms/filter_joomla_modules.xml | 76 - ...lter_joomla_modules_files_folders_urls.xml | 65 - .../forms/filter_joomla_modules_updates.xml | 65 - .../forms/filter_joomla_plugin_groups.xml | 76 - ...lter_joomla_plugins_files_folders_urls.xml | 65 - .../forms/filter_joomla_plugins_updates.xml | 65 - .../forms/filter_language_translations.xml | 67 - admin/models/forms/filter_languages.xml | 69 - .../models/forms/filter_libraries_config.xml | 65 - .../filter_libraries_files_folders_urls.xml | 65 - admin/models/forms/filter_placeholders.xml | 69 - admin/models/forms/filter_servers.xml | 83 - admin/models/forms/filter_snippet_types.xml | 69 - .../models/forms/filter_validation_rules.xml | 69 - admin/models/get_snippets.php | 135 - admin/models/help_document.php | 1008 - admin/models/help_documents.php | 547 - admin/models/import.php | 742 - admin/models/import_joomla_components.php | 3590 --- admin/models/import_language_translations.php | 789 - admin/models/joomla_component.php | 1641 - admin/models/joomla_components.php | 2908 -- admin/models/joomla_module.php | 1413 - .../joomla_module_files_folders_urls.php | 992 - admin/models/joomla_module_updates.php | 897 - admin/models/joomla_modules.php | 520 - .../joomla_modules_files_folders_urls.php | 281 - admin/models/joomla_modules_updates.php | 281 - admin/models/joomla_plugin.php | 1364 - .../joomla_plugin_files_folders_urls.php | 992 - admin/models/joomla_plugin_group.php | 874 - admin/models/joomla_plugin_groups.php | 310 - admin/models/joomla_plugin_updates.php | 897 - admin/models/joomla_plugins.php | 533 - .../joomla_plugins_files_folders_urls.php | 281 - admin/models/joomla_plugins_updates.php | 281 - admin/models/language.php | 871 - admin/models/language_translation.php | 1001 - admin/models/language_translations.php | 722 - admin/models/languages.php | 556 - admin/models/layout.php | 1117 - admin/models/layouts.php | 526 - admin/models/libraries.php | 459 - admin/models/libraries_config.php | 281 - admin/models/libraries_files_folders_urls.php | 281 - admin/models/library.php | 1192 - admin/models/library_config.php | 894 - admin/models/library_files_folders_urls.php | 992 - admin/models/placeholder.php | 975 - admin/models/placeholders.php | 436 - admin/models/power.php | 1266 - admin/models/powers.php | 612 - admin/models/rules/code.php | 53 - admin/models/rules/guid.php | 54 - admin/models/rules/int.php | 56 - admin/models/rules/uniqueplaceholder.php | 46 - admin/models/search.php | 244 - admin/models/server.php | 1139 - admin/models/servers.php | 552 - admin/models/site_view.php | 1360 - admin/models/site_views.php | 724 - admin/models/snippet.php | 946 - admin/models/snippet_type.php | 871 - admin/models/snippet_types.php | 310 - admin/models/snippets.php | 620 - admin/models/template.php | 1117 - admin/models/templates.php | 526 - admin/models/validation_rule.php | 973 - admin/models/validation_rules.php | 434 - admin/{helpers/html => presets}/index.html | 0 admin/{helpers => services}/index.html | 0 admin/services/provider.php | 128 + admin/sql/install.mysql.utf8.sql | 705 +- admin/sql/uninstall.mysql.utf8.sql | 3 +- admin/sql/updates/mysql/2.10.1.sql | 1 - admin/sql/updates/mysql/2.10.10.sql | 13 - admin/sql/updates/mysql/2.10.11.sql | 1 - admin/sql/updates/mysql/2.10.12.sql | 3 - admin/sql/updates/mysql/2.10.2.sql | 7 - admin/sql/updates/mysql/2.10.5.sql | 133 - admin/sql/updates/mysql/2.10.6.sql | 33 - admin/sql/updates/mysql/2.10.7.sql | 1 - admin/sql/updates/mysql/2.10.9.sql | 25 - admin/sql/updates/mysql/2.11.4.sql | 5 - admin/sql/updates/mysql/2.11.5.sql | 1 - admin/sql/updates/mysql/2.12.1.sql | 1 - admin/sql/updates/mysql/2.12.10.sql | 1 - admin/sql/updates/mysql/2.12.16.sql | 1 - admin/sql/updates/mysql/2.12.4.sql | 1 - admin/sql/updates/mysql/2.13.1.sql | 47 - admin/sql/updates/mysql/2.5.1.sql | 25 - admin/sql/updates/mysql/2.5.2.sql | 3 - admin/sql/updates/mysql/2.5.3.sql | 1 - admin/sql/updates/mysql/2.5.5.sql | 3 - admin/sql/updates/mysql/2.5.6.sql | 24 - admin/sql/updates/mysql/2.5.7.sql | 23 - admin/sql/updates/mysql/2.5.8.sql | 235 - admin/sql/updates/mysql/2.6.11.sql | 1 - admin/sql/updates/mysql/2.6.12.sql | 3 - admin/sql/updates/mysql/2.6.13.sql | 5 - admin/sql/updates/mysql/2.6.14.sql | 22 - admin/sql/updates/mysql/2.6.16.sql | 1 - admin/sql/updates/mysql/2.6.17.sql | 5 - admin/sql/updates/mysql/2.6.3.sql | 106 - admin/sql/updates/mysql/2.6.4.sql | 7 - admin/sql/updates/mysql/2.6.5.sql | 113 - admin/sql/updates/mysql/2.6.6.sql | 7 - admin/sql/updates/mysql/2.6.9.sql | 13 - admin/sql/updates/mysql/2.7.0.sql | 31 - admin/sql/updates/mysql/2.7.10.sql | 25 - admin/sql/updates/mysql/2.7.5.sql | 1 - admin/sql/updates/mysql/2.7.8.sql | 1 - admin/sql/updates/mysql/2.7.9.sql | 3 - admin/sql/updates/mysql/2.8.1.sql | 2 - admin/sql/updates/mysql/2.8.2.sql | 1 - admin/sql/updates/mysql/2.8.5.sql | 3 - admin/sql/updates/mysql/2.8.6.sql | 1 - admin/sql/updates/mysql/2.8.7.sql | 1 - admin/sql/updates/mysql/2.8.8.sql | 1 - admin/sql/updates/mysql/2.8.9.sql | 25 - admin/sql/updates/mysql/2.9.1.sql | 3 - admin/sql/updates/mysql/2.9.11.sql | 25 - admin/sql/updates/mysql/2.9.12.sql | 25 - admin/sql/updates/mysql/2.9.14.sql | 1 - admin/sql/updates/mysql/2.9.15.sql | 9 - admin/sql/updates/mysql/2.9.16.sql | 9 - admin/sql/updates/mysql/2.9.18.sql | 3 - admin/sql/updates/mysql/2.9.19.sql | 3 - admin/sql/updates/mysql/2.9.21.sql | 59 - admin/sql/updates/mysql/2.9.31.sql | 92 - admin/sql/updates/mysql/2.9.32.sql | 25 - admin/sql/updates/mysql/2.9.33.sql | 5 - admin/sql/updates/mysql/2.9.34.sql | 77 - admin/sql/updates/mysql/2.9.35.sql | 33 - admin/sql/updates/mysql/2.9.4.sql | 5 - admin/sql/updates/mysql/2.9.8.sql | 37 - admin/sql/updates/mysql/2.9.9.sql | 1 - admin/sql/updates/mysql/3.1.12.sql | 1 - admin/sql/updates/mysql/3.1.21.sql | 2 - admin/sql/updates/mysql/3.1.25.sql | 1 - admin/sql/updates/mysql/3.1.26.sql | 1 - admin/sql/updates/mysql/3.1.27.sql | 7 - admin/sql/updates/mysql/3.1.5.sql | 2 - .../mysql/{3.1.19.sql => 3.2.0-beta4.sql} | 0 .../mysql/{3.1.24.sql => 4.0.0-alpha1.sql} | 0 admin/{layouts => sql/xml}/index.html | 0 .../Admin_custom_tabsController.php | 343 + .../src/Controller/Admin_fieldsController.php | 343 + .../Admin_fields_conditionsController.php | 343 + .../Admin_fields_relationsController.php | 343 + admin/src/Controller/Admin_viewController.php | 371 + .../src/Controller/Admin_viewsController.php | 161 + .../Admins_custom_tabsController.php | 54 + .../Controller/Admins_fieldsController.php | 54 + .../Admins_fields_conditionsController.php | 54 + .../Admins_fields_relationsController.php | 54 + admin/src/Controller/AjaxController.php | 2401 ++ .../Controller/Class_extendingsController.php | 54 + .../Controller/Class_extendsController.php | 343 + .../src/Controller/Class_methodController.php | 343 + .../Controller/Class_methodsController.php | 119 + .../Controller/Class_propertiesController.php | 119 + .../Controller/Class_propertyController.php | 343 + admin/src/Controller/CompilerController.php | 652 + .../Component_admin_viewsController.php | 343 + .../Controller/Component_configController.php | 343 + ...Component_custom_admin_menusController.php | 343 + ...Component_custom_admin_viewsController.php | 343 + .../Component_dashboardController.php | 343 + .../Component_files_foldersController.php | 343 + .../Component_modulesController.php | 343 + .../Component_mysql_tweaksController.php | 343 + .../Component_placeholdersController.php | 343 + .../Component_pluginsController.php | 343 + .../Controller/Component_routerController.php | 343 + .../Component_site_viewsController.php | 343 + .../Component_updatesController.php | 374 + .../Controller/ComponentbuilderController.php | 32 + .../Components_admin_viewsController.php | 54 + .../Components_configController.php | 54 + ...omponents_custom_admin_menusController.php | 54 + ...omponents_custom_admin_viewsController.php | 54 + .../Components_dashboardController.php | 54 + .../Components_files_foldersController.php | 54 + .../Components_modulesController.php | 54 + .../Components_mysql_tweaksController.php | 54 + .../Components_placeholdersController.php | 54 + .../Components_pluginsController.php | 54 + .../Components_routersController.php | 54 + .../Components_site_viewsController.php | 54 + .../Components_updatesController.php | 54 + .../Custom_admin_viewController.php | 343 + .../Custom_admin_viewsController.php | 128 + .../src/Controller/Custom_codeController.php | 343 + .../src/Controller/Custom_codesController.php | 161 + admin/src/Controller/DisplayController.php | 45 + .../src/Controller/Dynamic_getController.php | 343 + .../src/Controller/Dynamic_getsController.php | 161 + admin/src/Controller/FieldController.php | 342 + admin/src/Controller/FieldsController.php | 161 + admin/src/Controller/FieldtypeController.php | 342 + admin/src/Controller/FieldtypesController.php | 119 + .../src/Controller/Get_snippetsController.php | 120 + admin/src/Controller/HelpController.php | 123 + .../Controller/Help_documentController.php | 343 + .../Controller/Help_documentsController.php | 119 + admin/src/Controller/ImportController.php | 64 + ...port_joomla_componentsimportController.php | 65 + ..._language_translationsimportController.php | 64 + .../Controller/Joomla_componentController.php | 404 + .../Joomla_componentsController.php | 520 + .../Controller/Joomla_moduleController.php | 370 + ...la_module_files_folders_urlsController.php | 343 + .../Joomla_module_updatesController.php | 363 + .../Controller/Joomla_modulesController.php | 128 + ...a_modules_files_folders_urlsController.php | 54 + .../Joomla_modules_updatesController.php | 54 + .../Controller/Joomla_pluginController.php | 370 + ...la_plugin_files_folders_urlsController.php | 343 + .../Joomla_plugin_groupController.php | 336 + .../Joomla_plugin_groupsController.php | 54 + .../Joomla_plugin_updatesController.php | 363 + .../Controller/Joomla_pluginsController.php | 148 + ...a_plugins_files_folders_urlsController.php | 54 + .../Joomla_plugins_updatesController.php | 54 + admin/src/Controller/LanguageController.php | 343 + .../Language_translationController.php | 343 + .../Language_translationsController.php | 119 + admin/src/Controller/LanguagesController.php | 146 + admin/src/Controller/LayoutController.php | 343 + admin/src/Controller/LayoutsController.php | 128 + admin/src/Controller/LibrariesController.php | 63 + .../Controller/Libraries_configController.php | 54 + ...Libraries_files_folders_urlsController.php | 54 + admin/src/Controller/LibraryController.php | 369 + .../Controller/Library_configController.php | 343 + .../Library_files_folders_urlsController.php | 343 + .../src/Controller/PlaceholderController.php | 343 + .../src/Controller/PlaceholdersController.php | 119 + admin/src/Controller/PowerController.php | 400 + admin/src/Controller/PowersController.php | 176 + admin/src/Controller/SearchController.php | 66 + admin/src/Controller/ServerController.php | 343 + admin/src/Controller/ServersController.php | 119 + admin/src/Controller/Site_viewController.php | 343 + admin/src/Controller/Site_viewsController.php | 128 + admin/src/Controller/SnippetController.php | 343 + .../src/Controller/Snippet_typeController.php | 343 + .../Controller/Snippet_typesController.php | 54 + admin/src/Controller/SnippetsController.php | 192 + admin/src/Controller/TemplateController.php | 343 + admin/src/Controller/TemplatesController.php | 128 + .../Controller/Validation_ruleController.php | 343 + .../Controller/Validation_rulesController.php | 161 + .../fields => src/Controller}/index.html | 0 .../Extension/ComponentbuilderComponent.php | 75 + .../forms => src/Extension}/index.html | 0 admin/src/Field/AdminsviewsField.php | 64 + admin/src/Field/AdminviewfolderlistField.php | 69 + admin/src/Field/AdminviewsField.php | 65 + .../AdminviewsfilteraddcustombuttonField.php | 78 + .../AdminviewsfilteraddcustomimportField.php | 78 + .../Field/AdminviewsfilteraddfadeinField.php | 78 + .../Field/AdminviewsfilteraddphpajaxField.php | 78 + admin/src/Field/AdminviewsfiltertypeField.php | 77 + admin/src/Field/AdminviewsreadonlyField.php | 64 + admin/src/Field/AliasbuilderField.php | 108 + admin/src/Field/ArticlesField.php | 64 + ...lassextendingsfilterextensiontypeField.php | 78 + admin/src/Field/ClassextendsField.php | 183 + .../ClassmethodsfilterextensiontypeField.php | 78 + .../ClassmethodsfiltervisibilityField.php | 78 + admin/src/Field/ClasspowersField.php | 204 + ...lasspropertiesfilterextensiontypeField.php | 78 + .../ClasspropertiesfiltervisibilityField.php | 78 + admin/src/Field/ComponentadminmenusField.php | 109 + admin/src/Field/ComponentadminviewsField.php | 109 + ...sfiltermodeconstructorafterparentField.php | 78 + ...filtermodeconstructorbeforeparentField.php | 78 + ...omponentsroutersfiltermodemethodsField.php | 78 + admin/src/Field/CustomadminviewsField.php | 64 + ...omadminviewsfilteraddcustombuttonField.php | 78 + .../CustomadminviewsfilteraddphpajaxField.php | 78 + .../CustomcodesfiltercommenttypeField.php | 78 + .../Field/CustomcodesfiltertargetField.php | 78 + .../src/Field/CustomcodesfiltertypeField.php | 78 + admin/src/Field/CustomfilelistField.php | 68 + admin/src/Field/CustomfolderlistField.php | 68 + admin/src/Field/CustomgetsField.php | 66 + admin/src/Field/DbtablesField.php | 68 + admin/src/Field/DynamicdashboardField.php | 114 + admin/src/Field/DynamicgetField.php | 172 + admin/src/Field/DynamicgetsField.php | 65 + .../Field/DynamicgetsfiltergettypeField.php | 78 + .../DynamicgetsfiltermainsourceField.php | 78 + .../Field/ExistingvalidationrulesField.php | 58 + admin/src/Field/FieldsField.php | 77 + admin/src/Field/FieldsfilterdatatypeField.php | 78 + admin/src/Field/FieldsfilterindexesField.php | 78 + .../src/Field/FieldsfilternullswitchField.php | 78 + admin/src/Field/FieldsfilterstoreField.php | 78 + admin/src/Field/FieldtypesField.php | 171 + admin/src/Field/FilebehaviourField.php | 61 + .../HelpdocumentsfilterlocationField.php | 78 + .../Field/HelpdocumentsfiltertypeField.php | 78 + admin/src/Field/InterfacepowersField.php | 199 + admin/src/Field/JoinfieldsField.php | 116 + admin/src/Field/JoomlacomponentField.php | 171 + admin/src/Field/JoomlacomponentsField.php | 64 + .../JoomlacomponentsfilterauthorField.php | 73 + ...JoomlacomponentsfiltercompanynameField.php | 73 + admin/src/Field/JoomlamodulesField.php | 78 + .../Field/JoomlamodulesfiltertargetField.php | 78 + admin/src/Field/JoomlaplugingroupsField.php | 183 + admin/src/Field/JoomlapluginsField.php | 80 + admin/src/Field/LangField.php | 85 + .../Field/LayoutsfilteraddphpviewField.php | 78 + admin/src/Field/LibconfigfieldField.php | 99 + admin/src/Field/LibrariesField.php | 171 + .../src/Field/LibrariesfiltertargetField.php | 78 + admin/src/Field/LibrariesfiltertypeField.php | 78 + admin/src/Field/LibrariesxField.php | 179 + admin/src/Field/LibraryField.php | 172 + admin/src/Field/LibraryfilesField.php | 64 + admin/src/Field/LibraryreadonlyField.php | 63 + admin/src/Field/ListfieldsField.php | 122 + admin/src/Field/MaingetsField.php | 172 + admin/src/Field/MatchfieldField.php | 110 + admin/src/Field/NamespacesField.php | 96 + admin/src/Field/PluginsclassmethodsField.php | 88 + .../src/Field/PluginsclasspropertiesField.php | 88 + admin/src/Field/PowersclassmethodsField.php | 88 + .../src/Field/PowersclasspropertiesField.php | 88 + admin/src/Field/PowersfilterapprovedField.php | 78 + admin/src/Field/PowersfiltertypeField.php | 77 + admin/src/Field/ServersField.php | 171 + admin/src/Field/ServersfilternameField.php | 74 + .../src/Field/ServersfilterprotocolField.php | 78 + admin/src/Field/SiteviewfolderlistField.php | 69 + admin/src/Field/SiteviewsField.php | 68 + .../SiteviewsfilteraddcustombuttonField.php | 78 + .../Field/SiteviewsfilteraddphpajaxField.php | 78 + admin/src/Field/SnippetsField.php | 176 + admin/src/Field/SnippettypeField.php | 64 + admin/src/Field/SuperpowerpathsField.php | 105 + admin/src/Field/TargetfieldsField.php | 116 + .../Field/TemplatesfilteraddphpviewField.php | 78 + admin/src/Field/ViewtabsField.php | 107 + admin/{models => src/Field}/index.html | 0 admin/src/Helper/ComponentbuilderEmail.php | 470 + admin/src/Helper/ComponentbuilderHelper.php | 7372 +++++ admin/src/Helper/HeaderCheck.php | 130 + admin/{models/rules => src/Helper}/index.html | 0 admin/src/Model/Admin_custom_tabsModel.php | 957 + admin/src/Model/Admin_fieldsModel.php | 988 + .../Model/Admin_fields_conditionsModel.php | 978 + .../src/Model/Admin_fields_relationsModel.php | 1040 + admin/src/Model/Admin_viewModel.php | 1916 ++ admin/src/Model/Admin_viewsModel.php | 965 + admin/src/Model/Admins_custom_tabsModel.php | 385 + admin/src/Model/Admins_fieldsModel.php | 385 + .../Model/Admins_fields_conditionsModel.php | 385 + .../Model/Admins_fields_relationsModel.php | 385 + admin/src/Model/AjaxModel.php | 4126 +++ admin/src/Model/Class_extendingsModel.php | 468 + admin/src/Model/Class_extendsModel.php | 1064 + admin/src/Model/Class_methodModel.php | 1137 + admin/src/Model/Class_methodsModel.php | 647 + admin/src/Model/Class_propertiesModel.php | 643 + admin/src/Model/Class_propertyModel.php | 1122 + admin/src/Model/CompilerModel.php | 530 + .../src/Model/Component_admin_viewsModel.php | 1005 + admin/src/Model/Component_configModel.php | 1001 + .../Component_custom_admin_menusModel.php | 1004 + .../Component_custom_admin_viewsModel.php | 1005 + admin/src/Model/Component_dashboardModel.php | 1103 + .../Model/Component_files_foldersModel.php | 1081 + admin/src/Model/Component_modulesModel.php | 971 + .../src/Model/Component_mysql_tweaksModel.php | 1001 + .../src/Model/Component_placeholdersModel.php | 970 + admin/src/Model/Component_pluginsModel.php | 971 + admin/src/Model/Component_routerModel.php | 1102 + admin/src/Model/Component_site_viewsModel.php | 1005 + admin/src/Model/Component_updatesModel.php | 1004 + admin/src/Model/ComponentbuilderModel.php | 602 + .../src/Model/Components_admin_viewsModel.php | 385 + admin/src/Model/Components_configModel.php | 385 + .../Components_custom_admin_menusModel.php | 385 + .../Components_custom_admin_viewsModel.php | 385 + admin/src/Model/Components_dashboardModel.php | 385 + .../Model/Components_files_foldersModel.php | 385 + admin/src/Model/Components_modulesModel.php | 385 + .../Model/Components_mysql_tweaksModel.php | 385 + .../Model/Components_placeholdersModel.php | 385 + admin/src/Model/Components_pluginsModel.php | 385 + admin/src/Model/Components_routersModel.php | 529 + .../src/Model/Components_site_viewsModel.php | 385 + admin/src/Model/Components_updatesModel.php | 385 + admin/src/Model/Custom_admin_viewModel.php | 1395 + admin/src/Model/Custom_admin_viewsModel.php | 819 + admin/src/Model/Custom_codeModel.php | 1136 + admin/src/Model/Custom_codesModel.php | 748 + admin/src/Model/Dynamic_getModel.php | 1446 + admin/src/Model/Dynamic_getsModel.php | 648 + admin/src/Model/FieldModel.php | 1348 + admin/src/Model/FieldsModel.php | 1006 + admin/src/Model/FieldtypeModel.php | 1415 + admin/src/Model/FieldtypesModel.php | 612 + admin/src/Model/Get_snippetsModel.php | 280 + admin/src/Model/Help_documentModel.php | 1068 + admin/src/Model/Help_documentsModel.php | 643 + admin/src/Model/ImportModel.php | 752 + .../Import_joomla_componentsimportModel.php | 3598 +++ ...mport_language_translationsimportModel.php | 798 + admin/src/Model/Joomla_componentModel.php | 1704 + admin/src/Model/Joomla_componentsModel.php | 3009 ++ admin/src/Model/Joomla_moduleModel.php | 1469 + .../Joomla_module_files_folders_urlsModel.php | 1052 + .../src/Model/Joomla_module_updatesModel.php | 957 + admin/src/Model/Joomla_modulesModel.php | 624 + ...Joomla_modules_files_folders_urlsModel.php | 385 + .../src/Model/Joomla_modules_updatesModel.php | 385 + admin/src/Model/Joomla_pluginModel.php | 1420 + .../Joomla_plugin_files_folders_urlsModel.php | 1052 + admin/src/Model/Joomla_plugin_groupModel.php | 934 + admin/src/Model/Joomla_plugin_groupsModel.php | 413 + .../src/Model/Joomla_plugin_updatesModel.php | 957 + admin/src/Model/Joomla_pluginsModel.php | 636 + ...Joomla_plugins_files_folders_urlsModel.php | 385 + .../src/Model/Joomla_plugins_updatesModel.php | 385 + admin/src/Model/LanguageModel.php | 931 + admin/src/Model/Language_translationModel.php | 1071 + .../src/Model/Language_translationsModel.php | 824 + admin/src/Model/LanguagesModel.php | 660 + admin/src/Model/LayoutModel.php | 1174 + admin/src/Model/LayoutsModel.php | 630 + admin/src/Model/LibrariesModel.php | 541 + admin/src/Model/Libraries_configModel.php | 385 + .../Libraries_files_folders_urlsModel.php | 385 + admin/src/Model/LibraryModel.php | 1246 + admin/src/Model/Library_configModel.php | 954 + .../Model/Library_files_folders_urlsModel.php | 1052 + admin/src/Model/PlaceholderModel.php | 1033 + admin/src/Model/PlaceholdersModel.php | 540 + admin/src/Model/PowerModel.php | 1322 + admin/src/Model/PowersModel.php | 716 + admin/src/Model/SearchModel.php | 384 + admin/src/Model/ServerModel.php | 1105 + admin/src/Model/ServersModel.php | 656 + admin/src/Model/Site_viewModel.php | 1416 + admin/src/Model/Site_viewsModel.php | 828 + admin/src/Model/SnippetModel.php | 1005 + admin/src/Model/Snippet_typeModel.php | 931 + admin/src/Model/Snippet_typesModel.php | 414 + admin/src/Model/SnippetsModel.php | 721 + admin/src/Model/TemplateModel.php | 1174 + admin/src/Model/TemplatesModel.php | 630 + admin/src/Model/Validation_ruleModel.php | 1031 + admin/src/Model/Validation_rulesModel.php | 538 + admin/{tables => src/Model}/index.html | 0 admin/src/Rule/CodeRule.php | 61 + admin/src/Rule/GuidRule.php | 62 + admin/src/Rule/IntRule.php | 64 + admin/src/Rule/SourcemapcheckerRule.php | 143 + admin/src/Rule/UniqueplaceholderRule.php | 54 + .../tmpl => src/Rule}/index.html | 0 .../tmpl => src/Service}/index.html | 0 admin/src/Table/Admin_custom_tabsTable.php | 377 + admin/src/Table/Admin_fieldsTable.php | 377 + .../Table/Admin_fields_conditionsTable.php | 377 + .../src/Table/Admin_fields_relationsTable.php | 377 + admin/src/Table/Admin_viewTable.php | 377 + admin/src/Table/Class_extendsTable.php | 377 + admin/src/Table/Class_methodTable.php | 377 + admin/src/Table/Class_propertyTable.php | 377 + .../src/Table/Component_admin_viewsTable.php | 377 + admin/src/Table/Component_configTable.php | 377 + .../Component_custom_admin_menusTable.php | 377 + .../Component_custom_admin_viewsTable.php | 377 + admin/src/Table/Component_dashboardTable.php | 377 + .../Table/Component_files_foldersTable.php | 377 + admin/src/Table/Component_modulesTable.php | 377 + .../src/Table/Component_mysql_tweaksTable.php | 377 + .../src/Table/Component_placeholdersTable.php | 377 + admin/src/Table/Component_pluginsTable.php | 377 + admin/src/Table/Component_routerTable.php | 377 + admin/src/Table/Component_site_viewsTable.php | 377 + admin/src/Table/Component_updatesTable.php | 377 + admin/src/Table/Custom_admin_viewTable.php | 377 + admin/src/Table/Custom_codeTable.php | 377 + admin/src/Table/Dynamic_getTable.php | 377 + admin/src/Table/FieldTable.php | 377 + admin/src/Table/FieldtypeTable.php | 377 + admin/src/Table/Help_documentTable.php | 390 + admin/src/Table/Joomla_componentTable.php | 377 + admin/src/Table/Joomla_moduleTable.php | 377 + .../Joomla_module_files_folders_urlsTable.php | 377 + .../src/Table/Joomla_module_updatesTable.php | 377 + admin/src/Table/Joomla_pluginTable.php | 377 + .../Joomla_plugin_files_folders_urlsTable.php | 377 + admin/src/Table/Joomla_plugin_groupTable.php | 377 + .../src/Table/Joomla_plugin_updatesTable.php | 377 + admin/src/Table/LanguageTable.php | 377 + admin/src/Table/Language_translationTable.php | 377 + admin/src/Table/LayoutTable.php | 390 + admin/src/Table/LibraryTable.php | 377 + admin/src/Table/Library_configTable.php | 377 + .../Table/Library_files_folders_urlsTable.php | 377 + admin/src/Table/PlaceholderTable.php | 377 + admin/src/Table/PowerTable.php | 377 + admin/src/Table/ServerTable.php | 377 + admin/src/Table/Site_viewTable.php | 377 + admin/src/Table/SnippetTable.php | 377 + admin/src/Table/Snippet_typeTable.php | 377 + admin/src/Table/TemplateTable.php | 390 + admin/src/Table/Validation_ruleTable.php | 377 + .../tmpl => src/Table}/index.html | 0 admin/src/View/Admin_custom_tabs/HtmlView.php | 236 + .../View/Admin_custom_tabs}/index.html | 0 admin/src/View/Admin_fields/HtmlView.php | 251 + .../tmpl => src/View/Admin_fields}/index.html | 0 .../View/Admin_fields_conditions/HtmlView.php | 238 + .../View/Admin_fields_conditions}/index.html | 0 .../View/Admin_fields_relations/HtmlView.php | 242 + .../View/Admin_fields_relations}/index.html | 0 admin/src/View/Admin_view/HtmlView.php | 248 + .../View/Admin_view}/index.html | 0 admin/src/View/Admin_views/HtmlView.php | 224 + .../tmpl => src/View/Admin_views}/index.html | 0 .../src/View/Admins_custom_tabs/HtmlView.php | 216 + .../View/Admins_custom_tabs}/index.html | 0 admin/src/View/Admins_fields/HtmlView.php | 216 + .../View/Admins_fields}/index.html | 0 .../Admins_fields_conditions/HtmlView.php | 216 + .../View/Admins_fields_conditions}/index.html | 0 .../View/Admins_fields_relations/HtmlView.php | 216 + .../View/Admins_fields_relations}/index.html | 0 admin/src/View/Class_extendings/HtmlView.php | 218 + .../View/Class_extendings}/index.html | 0 admin/src/View/Class_extends/HtmlView.php | 248 + .../View/Class_extends}/index.html | 0 admin/src/View/Class_method/HtmlView.php | 248 + .../View/Class_method}/index.html | 0 admin/src/View/Class_methods/HtmlView.php | 219 + .../View/Class_methods}/index.html | 0 admin/src/View/Class_properties/HtmlView.php | 219 + .../View/Class_properties}/index.html | 0 admin/src/View/Class_property/HtmlView.php | 248 + .../View/Class_property}/index.html | 0 admin/src/View/Compiler/HtmlView.php | 819 + .../View/Compiler}/index.html | 0 .../View/Component_admin_views/HtmlView.php | 236 + .../View/Component_admin_views}/index.html | 0 admin/src/View/Component_config/HtmlView.php | 230 + .../View/Component_config}/index.html | 0 .../Component_custom_admin_menus/HtmlView.php | 236 + .../Component_custom_admin_menus}/index.html | 0 .../Component_custom_admin_views/HtmlView.php | 236 + .../Component_custom_admin_views}/index.html | 0 .../src/View/Component_dashboard/HtmlView.php | 248 + .../View/Component_dashboard}/index.html | 0 .../View/Component_files_folders/HtmlView.php | 230 + .../View/Component_files_folders}/index.html | 0 admin/src/View/Component_modules/HtmlView.php | 230 + .../View/Component_modules}/index.html | 0 .../View/Component_mysql_tweaks/HtmlView.php | 230 + .../View/Component_mysql_tweaks}/index.html | 0 .../View/Component_placeholders/HtmlView.php | 230 + .../View/Component_placeholders}/index.html | 0 admin/src/View/Component_plugins/HtmlView.php | 230 + .../View/Component_plugins}/index.html | 0 admin/src/View/Component_router/HtmlView.php | 238 + .../View/Component_router}/index.html | 0 .../View/Component_site_views/HtmlView.php | 236 + .../View/Component_site_views}/index.html | 0 admin/src/View/Component_updates/HtmlView.php | 230 + .../View/Component_updates}/index.html | 0 admin/src/View/Componentbuilder/HtmlView.php | 106 + .../View/Componentbuilder}/index.html | 0 .../View/Components_admin_views/HtmlView.php | 216 + .../View/Components_admin_views}/index.html | 0 admin/src/View/Components_config/HtmlView.php | 216 + .../View/Components_config}/index.html | 0 .../HtmlView.php | 216 + .../Components_custom_admin_menus}/index.html | 0 .../HtmlView.php | 216 + .../Components_custom_admin_views}/index.html | 0 .../View/Components_dashboard/HtmlView.php | 216 + .../View/Components_dashboard}/index.html | 0 .../Components_files_folders/HtmlView.php | 216 + .../View/Components_files_folders}/index.html | 0 .../src/View/Components_modules/HtmlView.php | 216 + .../View/Components_modules}/index.html | 0 .../View/Components_mysql_tweaks/HtmlView.php | 216 + .../View/Components_mysql_tweaks}/index.html | 0 .../View/Components_placeholders/HtmlView.php | 216 + .../View/Components_placeholders}/index.html | 0 .../src/View/Components_plugins/HtmlView.php | 216 + .../View/Components_plugins}/index.html | 0 .../src/View/Components_routers/HtmlView.php | 216 + .../View/Components_routers}/index.html | 0 .../View/Components_site_views/HtmlView.php | 216 + .../View/Components_site_views}/index.html | 0 .../src/View/Components_updates/HtmlView.php | 216 + .../View/Components_updates}/index.html | 0 admin/src/View/Custom_admin_view/HtmlView.php | 248 + .../View/Custom_admin_view}/index.html | 0 .../src/View/Custom_admin_views/HtmlView.php | 225 + .../View/Custom_admin_views}/index.html | 0 admin/src/View/Custom_code/HtmlView.php | 251 + .../tmpl => src/View/Custom_code}/index.html | 0 admin/src/View/Custom_codes/HtmlView.php | 227 + .../View/Custom_codes}/index.html | 0 admin/src/View/Dynamic_get/HtmlView.php | 248 + .../tmpl => src/View/Dynamic_get}/index.html | 0 admin/src/View/Dynamic_gets/HtmlView.php | 224 + .../View/Dynamic_gets}/index.html | 0 admin/src/View/Field/HtmlView.php | 257 + .../tmpl => src/View/Field}/index.html | 0 admin/src/View/Fields/HtmlView.php | 228 + .../View/Fields}/index.html | 0 admin/src/View/Fieldtype/HtmlView.php | 299 + .../tmpl => src/View/Fieldtype}/index.html | 0 admin/src/View/Fieldtypes/HtmlView.php | 219 + .../View/Fieldtypes}/index.html | 0 admin/src/View/Get_snippets/HtmlView.php | 361 + .../tmpl => src/View/Get_snippets}/index.html | 0 admin/src/View/Help_document/HtmlView.php | 230 + .../View/Help_document}/index.html | 0 admin/src/View/Help_documents/HtmlView.php | 221 + .../View/Help_documents}/index.html | 0 admin/src/View/Import/HtmlView.php | 106 + .../View/Import}/index.html | 0 .../HtmlView.php | 475 + .../index.html | 0 .../HtmlView.php | 107 + .../index.html | 0 admin/src/View/Joomla_component/HtmlView.php | 248 + .../View/Joomla_component}/index.html | 0 admin/src/View/Joomla_components/HtmlView.php | 252 + .../View/Joomla_components}/index.html | 0 admin/src/View/Joomla_module/HtmlView.php | 283 + .../View/Joomla_module}/index.html | 0 .../HtmlView.php | 230 + .../index.html | 0 .../View/Joomla_module_updates/HtmlView.php | 230 + .../View/Joomla_module_updates}/index.html | 0 admin/src/View/Joomla_modules/HtmlView.php | 228 + .../View/Joomla_modules}/index.html | 0 .../HtmlView.php | 216 + .../index.html | 0 .../View/Joomla_modules_updates/HtmlView.php | 216 + .../View/Joomla_modules_updates}/index.html | 0 admin/src/View/Joomla_plugin/HtmlView.php | 326 + .../View/Joomla_plugin}/index.html | 0 .../HtmlView.php | 230 + .../index.html | 0 .../src/View/Joomla_plugin_group/HtmlView.php | 230 + .../View/Joomla_plugin_group}/index.html | 0 .../View/Joomla_plugin_groups/HtmlView.php | 218 + .../View/Joomla_plugin_groups}/index.html | 0 .../View/Joomla_plugin_updates/HtmlView.php | 230 + .../View/Joomla_plugin_updates}/index.html | 0 admin/src/View/Joomla_plugins/HtmlView.php | 239 + .../View/Joomla_plugins}/index.html | 0 .../HtmlView.php | 216 + .../index.html | 0 .../View/Joomla_plugins_updates/HtmlView.php | 216 + .../View/Joomla_plugins_updates}/index.html | 0 admin/src/View/Language/HtmlView.php | 230 + .../View/Language}/index.html | 0 .../View/Language_translation/HtmlView.php | 241 + .../View/Language_translation}/index.html | 0 .../View/Language_translations/HtmlView.php | 217 + .../View/Language_translations}/index.html | 0 admin/src/View/Languages/HtmlView.php | 223 + .../View/Languages}/index.html | 0 admin/src/View/Layout/HtmlView.php | 248 + .../tmpl => src/View/Layout}/index.html | 0 admin/src/View/Layouts/HtmlView.php | 224 + .../import => src/View/Layouts}/index.html | 0 admin/src/View/Libraries/HtmlView.php | 225 + .../tmpl => src/View/Libraries}/index.html | 0 admin/src/View/Libraries_config/HtmlView.php | 216 + .../View/Libraries_config}/index.html | 0 .../Libraries_files_folders_urls/HtmlView.php | 216 + .../Libraries_files_folders_urls}/index.html | 0 admin/src/View/Library/HtmlView.php | 248 + .../View/Library}/index.html | 0 admin/src/View/Library_config/HtmlView.php | 230 + .../View/Library_config}/index.html | 0 .../Library_files_folders_urls/HtmlView.php | 230 + .../Library_files_folders_urls}/index.html | 0 admin/src/View/Placeholder/HtmlView.php | 251 + .../tmpl => src/View/Placeholder}/index.html | 0 admin/src/View/Placeholders/HtmlView.php | 218 + .../View/Placeholders}/index.html | 0 admin/src/View/Power/HtmlView.php | 295 + .../tmpl => src/View/Power}/index.html | 0 admin/src/View/Powers/HtmlView.php | 235 + .../tmpl => src/View/Powers}/index.html | 0 admin/src/View/Search/HtmlView.php | 475 + .../tmpl => src/View/Search}/index.html | 0 admin/src/View/Server/HtmlView.php | 230 + .../tmpl => src/View/Server}/index.html | 0 admin/src/View/Servers/HtmlView.php | 218 + .../View/Servers}/index.html | 0 admin/src/View/Site_view/HtmlView.php | 248 + .../tmpl => src/View/Site_view}/index.html | 0 admin/src/View/Site_views/HtmlView.php | 226 + .../View/Site_views}/index.html | 0 admin/src/View/Snippet/HtmlView.php | 230 + .../tmpl => src/View/Snippet}/index.html | 0 admin/src/View/Snippet_type/HtmlView.php | 230 + .../View/Snippet_type}/index.html | 0 admin/src/View/Snippet_types/HtmlView.php | 218 + .../View/Snippet_types}/index.html | 0 admin/src/View/Snippets/HtmlView.php | 231 + .../tmpl => src/View/Snippets}/index.html | 0 admin/src/View/Template/HtmlView.php | 248 + .../tmpl => src/View/Template}/index.html | 0 admin/src/View/Templates/HtmlView.php | 224 + .../tmpl => src/View/Templates}/index.html | 0 admin/src/View/Validation_rule/HtmlView.php | 251 + .../View/Validation_rule}/index.html | 0 admin/src/View/Validation_rules/HtmlView.php | 223 + .../View/Validation_rules}/index.html | 0 .../tmpl => src/View}/index.html | 0 .../{views/joomla_plugins => src}/index.html | 0 admin/tables/admin_custom_tabs.php | 324 - admin/tables/admin_fields.php | 324 - admin/tables/admin_fields_conditions.php | 324 - admin/tables/admin_fields_relations.php | 324 - admin/tables/admin_view.php | 324 - admin/tables/class_extends.php | 324 - admin/tables/class_method.php | 324 - admin/tables/class_property.php | 324 - admin/tables/component_admin_views.php | 324 - admin/tables/component_config.php | 324 - admin/tables/component_custom_admin_menus.php | 324 - admin/tables/component_custom_admin_views.php | 324 - admin/tables/component_dashboard.php | 324 - admin/tables/component_files_folders.php | 324 - admin/tables/component_modules.php | 324 - admin/tables/component_mysql_tweaks.php | 324 - admin/tables/component_placeholders.php | 324 - admin/tables/component_plugins.php | 324 - admin/tables/component_site_views.php | 324 - admin/tables/component_updates.php | 324 - admin/tables/custom_admin_view.php | 324 - admin/tables/custom_code.php | 324 - admin/tables/dynamic_get.php | 324 - admin/tables/field.php | 324 - admin/tables/fieldtype.php | 324 - admin/tables/help_document.php | 337 - admin/tables/joomla_component.php | 324 - admin/tables/joomla_module.php | 324 - .../joomla_module_files_folders_urls.php | 324 - admin/tables/joomla_module_updates.php | 324 - admin/tables/joomla_plugin.php | 324 - .../joomla_plugin_files_folders_urls.php | 324 - admin/tables/joomla_plugin_group.php | 324 - admin/tables/joomla_plugin_updates.php | 324 - admin/tables/language.php | 324 - admin/tables/language_translation.php | 324 - admin/tables/layout.php | 337 - admin/tables/library.php | 324 - admin/tables/library_config.php | 324 - admin/tables/library_files_folders_urls.php | 324 - admin/tables/placeholder.php | 324 - admin/tables/power.php | 324 - admin/tables/server.php | 324 - admin/tables/site_view.php | 324 - admin/tables/snippet.php | 324 - admin/tables/snippet_type.php | 324 - admin/tables/template.php | 337 - admin/tables/validation_rule.php | 324 - admin/tmpl/admin_custom_tabs/default.php | 105 + .../admin_custom_tabs}/index.html | 0 admin/tmpl/admin_fields/default.php | 294 + .../admin_fields}/index.html | 0 .../tmpl/admin_fields_conditions/default.php | 150 + .../admin_fields_conditions}/index.html | 0 admin/tmpl/admin_fields_relations/default.php | 128 + .../admin_fields_relations}/index.html | 0 admin/tmpl/admin_view/default.php | 808 + .../tmpl => tmpl/admin_view}/index.html | 0 admin/tmpl/admin_views/default.php | 80 + admin/tmpl/admin_views/default_body.php | 161 + admin/tmpl/admin_views/default_foot.php | 18 + admin/tmpl/admin_views/default_head.php | 56 + admin/tmpl/admin_views/default_toolbar.php | 48 + admin/tmpl/admin_views/emptystate.php | 28 + .../tmpl => tmpl/admin_views}/index.html | 0 admin/tmpl/admins_custom_tabs/default.php | 51 + .../tmpl/admins_custom_tabs/default_body.php | 98 + .../tmpl/admins_custom_tabs/default_foot.php | 18 + .../tmpl/admins_custom_tabs/default_head.php | 50 + .../admins_custom_tabs/default_toolbar.php | 48 + admin/tmpl/admins_custom_tabs/emptystate.php | 28 + .../admins_custom_tabs}/index.html | 0 admin/tmpl/admins_fields/default.php | 51 + admin/tmpl/admins_fields/default_body.php | 98 + admin/tmpl/admins_fields/default_foot.php | 18 + admin/tmpl/admins_fields/default_head.php | 50 + admin/tmpl/admins_fields/default_toolbar.php | 48 + admin/tmpl/admins_fields/emptystate.php | 28 + .../admins_fields}/index.html | 0 .../tmpl/admins_fields_conditions/default.php | 51 + .../admins_fields_conditions/default_body.php | 98 + .../admins_fields_conditions/default_foot.php | 18 + .../admins_fields_conditions/default_head.php | 50 + .../default_toolbar.php | 48 + .../admins_fields_conditions/emptystate.php | 28 + .../admins_fields_conditions}/index.html | 0 .../tmpl/admins_fields_relations/default.php | 51 + .../admins_fields_relations/default_body.php | 98 + .../admins_fields_relations/default_foot.php | 18 + .../admins_fields_relations/default_head.php | 50 + .../default_toolbar.php | 48 + .../admins_fields_relations/emptystate.php | 28 + .../admins_fields_relations}/index.html | 0 admin/tmpl/class_extendings/default.php | 51 + admin/tmpl/class_extendings/default_body.php | 101 + admin/tmpl/class_extendings/default_foot.php | 18 + admin/tmpl/class_extendings/default_head.php | 53 + .../tmpl/class_extendings/default_toolbar.php | 48 + admin/tmpl/class_extendings/emptystate.php | 28 + .../tmpl => tmpl/class_extendings}/index.html | 0 admin/tmpl/class_extends/default.php | 133 + .../tmpl => tmpl/class_extends}/index.html | 0 admin/tmpl/class_method/default.php | 148 + .../layouts => tmpl/class_method}/index.html | 0 admin/tmpl/class_methods/default.php | 51 + admin/tmpl/class_methods/default_body.php | 113 + admin/tmpl/class_methods/default_foot.php | 18 + admin/tmpl/class_methods/default_head.php | 56 + admin/tmpl/class_methods/default_toolbar.php | 48 + admin/tmpl/class_methods/emptystate.php | 28 + .../tmpl => tmpl/class_methods}/index.html | 0 admin/tmpl/class_properties/default.php | 51 + admin/tmpl/class_properties/default_body.php | 113 + admin/tmpl/class_properties/default_foot.php | 18 + admin/tmpl/class_properties/default_head.php | 56 + .../tmpl/class_properties/default_toolbar.php | 48 + admin/tmpl/class_properties/emptystate.php | 28 + .../class_properties}/index.html | 0 admin/tmpl/class_property/default.php | 143 + .../tmpl => tmpl/class_property}/index.html | 0 admin/tmpl/compiler/default.php | 262 + .../compiler}/index.html | 0 admin/tmpl/component_admin_views/default.php | 147 + .../component_admin_views}/index.html | 0 admin/tmpl/component_config/default.php | 113 + .../component_config}/index.html | 0 .../component_custom_admin_menus/default.php | 113 + .../component_custom_admin_menus}/index.html | 0 .../component_custom_admin_views/default.php | 137 + .../component_custom_admin_views}/index.html | 0 admin/tmpl/component_dashboard/default.php | 151 + .../component_dashboard}/index.html | 0 .../tmpl/component_files_folders/default.php | 123 + .../component_files_folders}/index.html | 0 admin/tmpl/component_modules/default.php | 129 + .../component_modules}/index.html | 0 admin/tmpl/component_mysql_tweaks/default.php | 113 + .../component_mysql_tweaks}/index.html | 0 admin/tmpl/component_placeholders/default.php | 113 + .../component_placeholders}/index.html | 0 admin/tmpl/component_plugins/default.php | 129 + .../component_plugins}/index.html | 0 admin/tmpl/component_router/default.php | 105 + .../component_router}/index.html | 0 admin/tmpl/component_site_views/default.php | 113 + .../component_site_views}/index.html | 0 admin/tmpl/component_updates/default.php | 113 + .../component_updates}/index.html | 0 admin/tmpl/componentbuilder/default.php | 82 + admin/tmpl/componentbuilder/default_main.php | 32 + ...t_notice_board_vast_development_method.php | 6 +- .../default_readme_information.php | 6 +- admin/tmpl/componentbuilder/default_vdm.php | 41 + .../default_wiki_tutorials.php | 6 +- .../tmpl => tmpl/componentbuilder}/index.html | 0 admin/tmpl/components_admin_views/default.php | 51 + .../components_admin_views/default_body.php | 98 + .../components_admin_views/default_foot.php | 18 + .../components_admin_views/default_head.php | 50 + .../default_toolbar.php | 48 + .../components_admin_views/emptystate.php | 28 + .../components_admin_views}/index.html | 0 admin/tmpl/components_config/default.php | 51 + admin/tmpl/components_config/default_body.php | 98 + admin/tmpl/components_config/default_foot.php | 18 + admin/tmpl/components_config/default_head.php | 50 + .../components_config/default_toolbar.php | 48 + admin/tmpl/components_config/emptystate.php | 28 + .../components_config}/index.html | 0 .../components_custom_admin_menus/default.php | 51 + .../default_body.php | 98 + .../default_foot.php | 18 + .../default_head.php | 50 + .../default_toolbar.php | 48 + .../emptystate.php | 28 + .../components_custom_admin_menus}/index.html | 0 .../components_custom_admin_views/default.php | 51 + .../default_body.php | 98 + .../default_foot.php | 18 + .../default_head.php | 50 + .../default_toolbar.php | 48 + .../emptystate.php | 28 + .../components_custom_admin_views}/index.html | 0 admin/tmpl/components_dashboard/default.php | 51 + .../components_dashboard/default_body.php | 98 + .../components_dashboard/default_foot.php | 18 + .../components_dashboard/default_head.php | 50 + .../components_dashboard/default_toolbar.php | 48 + .../tmpl/components_dashboard/emptystate.php | 28 + .../components_dashboard}/index.html | 0 .../tmpl/components_files_folders/default.php | 51 + .../components_files_folders/default_body.php | 98 + .../components_files_folders/default_foot.php | 18 + .../components_files_folders/default_head.php | 50 + .../default_toolbar.php | 48 + .../components_files_folders/emptystate.php | 28 + .../components_files_folders}/index.html | 0 admin/tmpl/components_modules/default.php | 51 + .../tmpl/components_modules/default_body.php | 98 + .../tmpl/components_modules/default_foot.php | 18 + .../tmpl/components_modules/default_head.php | 50 + .../components_modules/default_toolbar.php | 48 + admin/tmpl/components_modules/emptystate.php | 28 + .../components_modules}/index.html | 0 .../tmpl/components_mysql_tweaks/default.php | 51 + .../components_mysql_tweaks/default_body.php | 98 + .../components_mysql_tweaks/default_foot.php | 18 + .../components_mysql_tweaks/default_head.php | 50 + .../default_toolbar.php | 48 + .../components_mysql_tweaks/emptystate.php | 28 + .../components_mysql_tweaks}/index.html | 0 .../tmpl/components_placeholders/default.php | 51 + .../components_placeholders/default_body.php | 98 + .../components_placeholders/default_foot.php | 18 + .../components_placeholders/default_head.php | 50 + .../default_toolbar.php | 48 + .../components_placeholders/emptystate.php | 28 + .../components_placeholders}/index.html | 0 admin/tmpl/components_plugins/default.php | 51 + .../tmpl/components_plugins/default_body.php | 98 + .../tmpl/components_plugins/default_foot.php | 18 + .../tmpl/components_plugins/default_head.php | 50 + .../components_plugins/default_toolbar.php | 48 + admin/tmpl/components_plugins/emptystate.php | 28 + .../components_plugins}/index.html | 0 admin/tmpl/components_routers/default.php | 86 + .../tmpl/components_routers/default_body.php | 107 + .../tmpl/components_routers/default_foot.php | 18 + .../tmpl/components_routers/default_head.php | 59 + .../components_routers/default_toolbar.php | 48 + admin/tmpl/components_routers/emptystate.php | 28 + .../components_routers}/index.html | 0 admin/tmpl/components_site_views/default.php | 51 + .../components_site_views/default_body.php | 98 + .../components_site_views/default_foot.php | 18 + .../components_site_views/default_head.php | 50 + .../components_site_views/default_toolbar.php | 48 + .../tmpl/components_site_views/emptystate.php | 28 + .../components_site_views}/index.html | 0 admin/tmpl/components_updates/default.php | 51 + .../tmpl/components_updates/default_body.php | 98 + .../tmpl/components_updates/default_foot.php | 18 + .../tmpl/components_updates/default_head.php | 50 + .../components_updates/default_toolbar.php | 48 + admin/tmpl/components_updates/emptystate.php | 28 + .../components_updates}/index.html | 0 admin/tmpl/custom_admin_view/default.php | 439 + .../custom_admin_view}/index.html | 0 admin/tmpl/custom_admin_views/default.php | 51 + .../tmpl/custom_admin_views/default_body.php | 130 + .../tmpl/custom_admin_views/default_foot.php | 18 + .../tmpl/custom_admin_views/default_head.php | 59 + .../custom_admin_views/default_toolbar.php | 48 + admin/tmpl/custom_admin_views/emptystate.php | 28 + .../custom_admin_views}/index.html | 0 admin/tmpl/custom_code/default.php | 288 + .../tmpl => tmpl/custom_code}/index.html | 0 admin/tmpl/custom_codes/default.php | 80 + admin/tmpl/custom_codes/default_body.php | 118 + admin/tmpl/custom_codes/default_foot.php | 18 + admin/tmpl/custom_codes/default_head.php | 65 + admin/tmpl/custom_codes/default_toolbar.php | 48 + admin/tmpl/custom_codes/emptystate.php | 28 + .../custom_codes}/index.html | 0 admin/tmpl/dynamic_get/default.php | 716 + .../tmpl => tmpl/dynamic_get}/index.html | 0 admin/tmpl/dynamic_gets/default.php | 80 + admin/tmpl/dynamic_gets/default_body.php | 104 + admin/tmpl/dynamic_gets/default_foot.php | 18 + admin/tmpl/dynamic_gets/default_head.php | 56 + admin/tmpl/dynamic_gets/default_toolbar.php | 48 + admin/tmpl/dynamic_gets/emptystate.php | 28 + .../tmpl/dynamic_gets}/index.html | 0 admin/tmpl/field/default.php | 392 + .../images => admin/tmpl/field}/index.html | 0 admin/tmpl/fields/default.php | 80 + admin/tmpl/fields/default_body.php | 128 + admin/tmpl/fields/default_foot.php | 18 + admin/tmpl/fields/default_head.php | 68 + admin/tmpl/fields/default_toolbar.php | 48 + admin/tmpl/fields/emptystate.php | 28 + {site/assets => admin/tmpl/fields}/index.html | 0 admin/tmpl/fieldtype/default.php | 547 + .../js => admin/tmpl/fieldtype}/index.html | 0 admin/tmpl/fieldtypes/default.php | 51 + admin/tmpl/fieldtypes/default_body.php | 110 + admin/tmpl/fieldtypes/default_foot.php | 18 + admin/tmpl/fieldtypes/default_head.php | 56 + admin/tmpl/fieldtypes/default_toolbar.php | 48 + admin/tmpl/fieldtypes/emptystate.php | 28 + .../tmpl/fieldtypes}/index.html | 0 admin/tmpl/get_snippets/default.php | 261 + .../tmpl/get_snippets}/index.html | 0 admin/tmpl/help_document/default.php | 189 + {site => admin/tmpl/help_document}/index.html | 0 admin/tmpl/help_documents/default.php | 51 + admin/tmpl/help_documents/default_body.php | 113 + admin/tmpl/help_documents/default_foot.php | 18 + admin/tmpl/help_documents/default_head.php | 65 + admin/tmpl/help_documents/default_toolbar.php | 48 + admin/tmpl/help_documents/emptystate.php | 28 + .../tmpl/help_documents}/index.html | 0 admin/tmpl/import/default.php | 196 + .../language => admin/tmpl/import}/index.html | 0 .../default.php | 565 + .../index.html | 0 .../default.php | 240 + .../index.html | 0 {site/views/api => admin/tmpl}/index.html | 0 admin/tmpl/joomla_component/default.php | 794 + .../tmpl/joomla_component}/index.html | 0 admin/tmpl/joomla_components/default.php | 98 + admin/tmpl/joomla_components/default_body.php | 241 + admin/tmpl/joomla_components/default_foot.php | 18 + admin/tmpl/joomla_components/default_head.php | 59 + .../joomla_components/default_toolbar.php | 48 + admin/tmpl/joomla_components/emptystate.php | 28 + .../tmpl/joomla_components}/index.html | 0 admin/tmpl/joomla_module/default.php | 665 + admin/tmpl/joomla_module/index.html | 1 + .../default.php | 115 + .../index.html | 1 + admin/tmpl/joomla_module_updates/default.php | 105 + admin/tmpl/joomla_module_updates/index.html | 1 + admin/tmpl/joomla_modules/default.php | 81 + admin/tmpl/joomla_modules/default_body.php | 135 + admin/tmpl/joomla_modules/default_foot.php | 18 + admin/tmpl/joomla_modules/default_head.php | 56 + admin/tmpl/joomla_modules/default_toolbar.php | 48 + admin/tmpl/joomla_modules/emptystate.php | 28 + admin/tmpl/joomla_modules/index.html | 1 + .../default.php | 51 + .../default_body.php | 98 + .../default_foot.php | 18 + .../default_head.php | 50 + .../default_toolbar.php | 48 + .../emptystate.php | 28 + .../index.html | 1 + admin/tmpl/joomla_modules_updates/default.php | 51 + .../joomla_modules_updates/default_body.php | 98 + .../joomla_modules_updates/default_foot.php | 18 + .../joomla_modules_updates/default_head.php | 50 + .../default_toolbar.php | 48 + .../joomla_modules_updates/emptystate.php | 28 + admin/tmpl/joomla_modules_updates/index.html | 1 + admin/tmpl/joomla_plugin/default.php | 659 + admin/tmpl/joomla_plugin/index.html | 1 + .../default.php | 115 + .../index.html | 1 + admin/tmpl/joomla_plugin_group/default.php | 105 + admin/tmpl/joomla_plugin_group/index.html | 1 + admin/tmpl/joomla_plugin_groups/default.php | 51 + .../joomla_plugin_groups/default_body.php | 107 + .../joomla_plugin_groups/default_foot.php | 18 + .../joomla_plugin_groups/default_head.php | 53 + .../joomla_plugin_groups/default_toolbar.php | 48 + .../tmpl/joomla_plugin_groups/emptystate.php | 28 + admin/tmpl/joomla_plugin_groups/index.html | 1 + admin/tmpl/joomla_plugin_updates/default.php | 105 + admin/tmpl/joomla_plugin_updates/index.html | 1 + admin/tmpl/joomla_plugins/default.php | 81 + admin/tmpl/joomla_plugins/default_body.php | 147 + admin/tmpl/joomla_plugins/default_foot.php | 18 + admin/tmpl/joomla_plugins/default_head.php | 56 + admin/tmpl/joomla_plugins/default_toolbar.php | 48 + admin/tmpl/joomla_plugins/emptystate.php | 28 + admin/tmpl/joomla_plugins/index.html | 1 + .../default.php | 51 + .../default_body.php | 98 + .../default_foot.php | 18 + .../default_head.php | 50 + .../default_toolbar.php | 48 + .../emptystate.php | 28 + .../index.html | 1 + admin/tmpl/joomla_plugins_updates/default.php | 51 + .../joomla_plugins_updates/default_body.php | 98 + .../joomla_plugins_updates/default_foot.php | 18 + .../joomla_plugins_updates/default_head.php | 50 + .../default_toolbar.php | 48 + .../joomla_plugins_updates/emptystate.php | 28 + admin/tmpl/joomla_plugins_updates/index.html | 1 + admin/tmpl/language/default.php | 105 + admin/tmpl/language/index.html | 1 + admin/tmpl/language_translation/default.php | 127 + admin/tmpl/language_translation/index.html | 1 + admin/tmpl/language_translations/default.php | 51 + .../language_translations/default_body.php | 184 + .../language_translations/default_foot.php | 18 + .../language_translations/default_head.php | 50 + .../language_translations/default_toolbar.php | 48 + .../tmpl/language_translations/emptystate.php | 28 + admin/tmpl/language_translations/index.html | 1 + admin/tmpl/languages/default.php | 81 + admin/tmpl/languages/default_body.php | 101 + admin/tmpl/languages/default_foot.php | 18 + admin/tmpl/languages/default_head.php | 53 + admin/tmpl/languages/default_toolbar.php | 48 + admin/tmpl/languages/emptystate.php | 28 + admin/tmpl/languages/index.html | 1 + admin/tmpl/layout/default.php | 231 + admin/tmpl/layout/index.html | 1 + admin/tmpl/layouts/default.php | 77 + admin/tmpl/layouts/default_body.php | 118 + admin/tmpl/layouts/default_foot.php | 18 + admin/tmpl/layouts/default_head.php | 56 + admin/tmpl/layouts/default_toolbar.php | 48 + admin/tmpl/layouts/emptystate.php | 28 + admin/tmpl/layouts/index.html | 1 + admin/tmpl/libraries/default.php | 51 + admin/tmpl/libraries/default_body.php | 143 + admin/tmpl/libraries/default_foot.php | 18 + admin/tmpl/libraries/default_head.php | 62 + admin/tmpl/libraries/default_toolbar.php | 48 + admin/tmpl/libraries/emptystate.php | 28 + admin/tmpl/libraries/index.html | 1 + admin/tmpl/libraries_config/default.php | 51 + admin/tmpl/libraries_config/default_body.php | 98 + admin/tmpl/libraries_config/default_foot.php | 18 + admin/tmpl/libraries_config/default_head.php | 50 + .../tmpl/libraries_config/default_toolbar.php | 48 + admin/tmpl/libraries_config/emptystate.php | 28 + admin/tmpl/libraries_config/index.html | 1 + .../libraries_files_folders_urls/default.php | 51 + .../default_body.php | 98 + .../default_foot.php | 18 + .../default_head.php | 50 + .../default_toolbar.php | 48 + .../emptystate.php | 28 + .../libraries_files_folders_urls/index.html | 1 + admin/tmpl/library/default.php | 608 + admin/tmpl/library/index.html | 1 + admin/tmpl/library_config/default.php | 105 + admin/tmpl/library_config/index.html | 1 + .../library_files_folders_urls/default.php | 115 + .../library_files_folders_urls/index.html | 1 + admin/tmpl/placeholder/default.php | 156 + admin/tmpl/placeholder/index.html | 1 + admin/tmpl/placeholders/default.php | 51 + admin/tmpl/placeholders/default_body.php | 101 + admin/tmpl/placeholders/default_foot.php | 18 + admin/tmpl/placeholders/default_head.php | 53 + admin/tmpl/placeholders/default_toolbar.php | 48 + admin/tmpl/placeholders/emptystate.php | 28 + admin/tmpl/placeholders/index.html | 1 + admin/tmpl/power/default.php | 199 + admin/tmpl/power/index.html | 1 + admin/tmpl/powers/default.php | 83 + admin/tmpl/powers/default_body.php | 117 + admin/tmpl/powers/default_foot.php | 18 + admin/tmpl/powers/default_head.php | 59 + admin/tmpl/powers/default_toolbar.php | 48 + admin/tmpl/powers/emptystate.php | 28 + admin/tmpl/powers/index.html | 1 + admin/tmpl/search/default.php | 360 + admin/tmpl/search/index.html | 1 + admin/tmpl/server/default.php | 293 + admin/tmpl/server/index.html | 1 + admin/tmpl/servers/default.php | 51 + admin/tmpl/servers/default_body.php | 101 + admin/tmpl/servers/default_foot.php | 18 + admin/tmpl/servers/default_head.php | 53 + admin/tmpl/servers/default_toolbar.php | 48 + admin/tmpl/servers/emptystate.php | 28 + admin/tmpl/servers/index.html | 1 + admin/tmpl/site_view/default.php | 457 + admin/tmpl/site_view/index.html | 1 + admin/tmpl/site_views/default.php | 51 + admin/tmpl/site_views/default_body.php | 130 + admin/tmpl/site_views/default_foot.php | 18 + admin/tmpl/site_views/default_head.php | 59 + admin/tmpl/site_views/default_toolbar.php | 48 + admin/tmpl/site_views/emptystate.php | 28 + admin/tmpl/site_views/index.html | 1 + admin/tmpl/snippet/default.php | 122 + admin/tmpl/snippet/index.html | 1 + admin/tmpl/snippet_type/default.php | 105 + admin/tmpl/snippet_type/index.html | 1 + admin/tmpl/snippet_types/default.php | 51 + admin/tmpl/snippet_types/default_body.php | 101 + admin/tmpl/snippet_types/default_foot.php | 18 + admin/tmpl/snippet_types/default_head.php | 53 + admin/tmpl/snippet_types/default_toolbar.php | 48 + admin/tmpl/snippet_types/emptystate.php | 28 + admin/tmpl/snippet_types/index.html | 1 + admin/tmpl/snippets/default.php | 51 + admin/tmpl/snippets/default_body.php | 116 + admin/tmpl/snippets/default_foot.php | 18 + admin/tmpl/snippets/default_head.php | 62 + admin/tmpl/snippets/default_toolbar.php | 48 + admin/tmpl/snippets/emptystate.php | 28 + admin/tmpl/snippets/index.html | 1 + admin/tmpl/template/default.php | 236 + admin/tmpl/template/index.html | 1 + admin/tmpl/templates/default.php | 77 + admin/tmpl/templates/default_body.php | 118 + admin/tmpl/templates/default_foot.php | 18 + admin/tmpl/templates/default_head.php | 56 + admin/tmpl/templates/default_toolbar.php | 48 + admin/tmpl/templates/emptystate.php | 28 + admin/tmpl/templates/index.html | 1 + admin/tmpl/validation_rule/default.php | 161 + admin/tmpl/validation_rule/index.html | 1 + admin/tmpl/validation_rules/default.php | 51 + admin/tmpl/validation_rules/default_body.php | 101 + admin/tmpl/validation_rules/default_foot.php | 18 + admin/tmpl/validation_rules/default_head.php | 53 + .../tmpl/validation_rules/default_toolbar.php | 48 + admin/tmpl/validation_rules/emptystate.php | 28 + admin/tmpl/validation_rules/index.html | 1 + admin/views/admin_custom_tabs/submitbutton.js | 25 - admin/views/admin_custom_tabs/tmpl/edit.php | 105 - admin/views/admin_custom_tabs/view.html.php | 203 - admin/views/admin_fields/submitbutton.js | 25 - admin/views/admin_fields/tmpl/edit.php | 294 - admin/views/admin_fields/view.html.php | 218 - .../admin_fields_conditions/submitbutton.js | 25 - .../admin_fields_conditions/tmpl/edit.php | 150 - .../admin_fields_conditions/view.html.php | 205 - .../admin_fields_relations/submitbutton.js | 25 - .../admin_fields_relations/tmpl/edit.php | 128 - .../admin_fields_relations/view.html.php | 209 - admin/views/admin_view/submitbutton.js | 25 - admin/views/admin_view/tmpl/edit.php | 806 - admin/views/admin_view/view.html.php | 215 - admin/views/admin_views/tmpl/default.php | 90 - .../admin_views/tmpl/default_batch_body.php | 18 - .../admin_views/tmpl/default_batch_footer.php | 23 - admin/views/admin_views/tmpl/default_body.php | 153 - admin/views/admin_views/tmpl/default_foot.php | 18 - admin/views/admin_views/tmpl/default_head.php | 53 - .../admin_views/tmpl/default_toolbar.php | 45 - admin/views/admin_views/view.html.php | 338 - .../views/admins_custom_tabs/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../admins_custom_tabs/tmpl/default_body.php | 91 - .../admins_custom_tabs/tmpl/default_foot.php | 18 - .../admins_custom_tabs/tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - admin/views/admins_custom_tabs/view.html.php | 220 - admin/views/admins_fields/tmpl/default.php | 67 - .../admins_fields/tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../views/admins_fields/tmpl/default_body.php | 91 - .../views/admins_fields/tmpl/default_foot.php | 18 - .../views/admins_fields/tmpl/default_head.php | 47 - .../admins_fields/tmpl/default_toolbar.php | 45 - admin/views/admins_fields/view.html.php | 220 - .../admins_fields_conditions/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../tmpl/default_body.php | 91 - .../tmpl/default_foot.php | 18 - .../tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - .../admins_fields_conditions/view.html.php | 220 - .../admins_fields_relations/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../tmpl/default_body.php | 91 - .../tmpl/default_foot.php | 18 - .../tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - .../admins_fields_relations/view.html.php | 220 - admin/views/class_extendings/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../class_extendings/tmpl/default_body.php | 94 - .../class_extendings/tmpl/default_foot.php | 18 - .../class_extendings/tmpl/default_head.php | 50 - .../class_extendings/tmpl/default_toolbar.php | 45 - admin/views/class_extendings/view.html.php | 242 - admin/views/class_extends/submitbutton.js | 25 - admin/views/class_extends/tmpl/edit.php | 133 - admin/views/class_extends/view.html.php | 215 - admin/views/class_method/submitbutton.js | 25 - admin/views/class_method/tmpl/edit.php | 148 - admin/views/class_method/view.html.php | 215 - admin/views/class_methods/tmpl/default.php | 67 - .../class_methods/tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../views/class_methods/tmpl/default_body.php | 106 - .../views/class_methods/tmpl/default_foot.php | 18 - .../views/class_methods/tmpl/default_head.php | 53 - .../class_methods/tmpl/default_toolbar.php | 45 - admin/views/class_methods/view.html.php | 273 - admin/views/class_properties/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../class_properties/tmpl/default_body.php | 106 - .../class_properties/tmpl/default_foot.php | 18 - .../class_properties/tmpl/default_head.php | 53 - .../class_properties/tmpl/default_toolbar.php | 45 - admin/views/class_properties/view.html.php | 273 - admin/views/class_property/submitbutton.js | 25 - admin/views/class_property/tmpl/edit.php | 143 - admin/views/class_property/view.html.php | 215 - admin/views/compiler/tmpl/default.php | 239 - admin/views/compiler/view.html.php | 771 - .../component_admin_views/submitbutton.js | 25 - .../views/component_admin_views/tmpl/edit.php | 147 - .../views/component_admin_views/view.html.php | 203 - admin/views/component_config/submitbutton.js | 25 - admin/views/component_config/tmpl/edit.php | 113 - admin/views/component_config/view.html.php | 197 - .../submitbutton.js | 25 - .../tmpl/edit.php | 113 - .../view.html.php | 203 - .../submitbutton.js | 25 - .../tmpl/edit.php | 137 - .../view.html.php | 203 - .../views/component_dashboard/submitbutton.js | 25 - admin/views/component_dashboard/tmpl/edit.php | 149 - admin/views/component_dashboard/view.html.php | 215 - .../component_files_folders/submitbutton.js | 25 - .../component_files_folders/tmpl/edit.php | 123 - .../component_files_folders/view.html.php | 197 - admin/views/component_modules/submitbutton.js | 25 - admin/views/component_modules/tmpl/edit.php | 129 - admin/views/component_modules/view.html.php | 197 - .../component_mysql_tweaks/submitbutton.js | 25 - .../component_mysql_tweaks/tmpl/edit.php | 113 - .../component_mysql_tweaks/view.html.php | 197 - .../component_placeholders/submitbutton.js | 25 - .../component_placeholders/tmpl/edit.php | 113 - .../component_placeholders/view.html.php | 197 - admin/views/component_plugins/submitbutton.js | 25 - admin/views/component_plugins/tmpl/edit.php | 129 - admin/views/component_plugins/view.html.php | 197 - .../component_site_views/submitbutton.js | 25 - .../views/component_site_views/tmpl/edit.php | 113 - .../views/component_site_views/view.html.php | 203 - admin/views/component_updates/submitbutton.js | 25 - admin/views/component_updates/tmpl/edit.php | 113 - admin/views/component_updates/view.html.php | 197 - admin/views/componentbuilder/tmpl/default.php | 89 - .../componentbuilder/tmpl/default_main.php | 30 - .../componentbuilder/tmpl/default_vdm.php | 38 - admin/views/componentbuilder/view.html.php | 94 - .../components_admin_views/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../tmpl/default_body.php | 91 - .../tmpl/default_foot.php | 18 - .../tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - .../components_admin_views/view.html.php | 220 - .../views/components_config/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../components_config/tmpl/default_body.php | 91 - .../components_config/tmpl/default_foot.php | 18 - .../components_config/tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - admin/views/components_config/view.html.php | 220 - .../tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../tmpl/default_body.php | 91 - .../tmpl/default_foot.php | 18 - .../tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - .../view.html.php | 220 - .../tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../tmpl/default_body.php | 91 - .../tmpl/default_foot.php | 18 - .../tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - .../view.html.php | 220 - .../components_dashboard/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../tmpl/default_body.php | 91 - .../tmpl/default_foot.php | 18 - .../tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - .../views/components_dashboard/view.html.php | 220 - .../components_files_folders/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../tmpl/default_body.php | 91 - .../tmpl/default_foot.php | 18 - .../tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - .../components_files_folders/view.html.php | 220 - .../views/components_modules/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../components_modules/tmpl/default_body.php | 91 - .../components_modules/tmpl/default_foot.php | 18 - .../components_modules/tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - admin/views/components_modules/view.html.php | 220 - .../components_mysql_tweaks/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../tmpl/default_body.php | 91 - .../tmpl/default_foot.php | 18 - .../tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - .../components_mysql_tweaks/view.html.php | 220 - .../components_placeholders/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../tmpl/default_body.php | 91 - .../tmpl/default_foot.php | 18 - .../tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - .../components_placeholders/view.html.php | 220 - .../views/components_plugins/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../components_plugins/tmpl/default_body.php | 91 - .../components_plugins/tmpl/default_foot.php | 18 - .../components_plugins/tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - admin/views/components_plugins/view.html.php | 220 - .../components_site_views/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../tmpl/default_body.php | 91 - .../tmpl/default_foot.php | 18 - .../tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - .../views/components_site_views/view.html.php | 220 - .../views/components_updates/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../components_updates/tmpl/default_body.php | 91 - .../components_updates/tmpl/default_foot.php | 18 - .../components_updates/tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - admin/views/components_updates/view.html.php | 220 - admin/views/custom_admin_view/submitbutton.js | 25 - admin/views/custom_admin_view/tmpl/edit.php | 434 - admin/views/custom_admin_view/view.html.php | 215 - .../views/custom_admin_views/tmpl/default.php | 68 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../custom_admin_views/tmpl/default_body.php | 123 - .../custom_admin_views/tmpl/default_foot.php | 18 - .../custom_admin_views/tmpl/default_head.php | 56 - .../tmpl/default_toolbar.php | 45 - admin/views/custom_admin_views/view.html.php | 299 - admin/views/custom_code/submitbutton.js | 25 - admin/views/custom_code/tmpl/edit.php | 286 - admin/views/custom_code/view.html.php | 218 - admin/views/custom_codes/tmpl/default.php | 89 - .../custom_codes/tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../views/custom_codes/tmpl/default_body.php | 103 - .../views/custom_codes/tmpl/default_foot.php | 18 - .../views/custom_codes/tmpl/default_head.php | 59 - .../custom_codes/tmpl/default_toolbar.php | 45 - admin/views/custom_codes/view.html.php | 320 - admin/views/dynamic_get/submitbutton.js | 25 - admin/views/dynamic_get/tmpl/edit.php | 714 - admin/views/dynamic_get/view.html.php | 215 - admin/views/dynamic_gets/tmpl/default.php | 89 - .../dynamic_gets/tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../views/dynamic_gets/tmpl/default_body.php | 97 - .../views/dynamic_gets/tmpl/default_foot.php | 18 - .../views/dynamic_gets/tmpl/default_head.php | 53 - .../dynamic_gets/tmpl/default_toolbar.php | 45 - admin/views/dynamic_gets/view.html.php | 278 - admin/views/field/submitbutton.js | 25 - admin/views/field/tmpl/edit.php | 390 - admin/views/field/view.html.php | 224 - admin/views/fields/tmpl/default.php | 90 - .../views/fields/tmpl/default_batch_body.php | 18 - .../fields/tmpl/default_batch_footer.php | 23 - admin/views/fields/tmpl/default_body.php | 121 - admin/views/fields/tmpl/default_foot.php | 18 - admin/views/fields/tmpl/default_head.php | 65 - admin/views/fields/tmpl/default_toolbar.php | 45 - admin/views/fields/view.html.php | 352 - admin/views/fieldtype/submitbutton.js | 25 - admin/views/fieldtype/tmpl/edit.php | 547 - admin/views/fieldtype/view.html.php | 266 - admin/views/fieldtypes/tmpl/default.php | 68 - .../fieldtypes/tmpl/default_batch_body.php | 18 - .../fieldtypes/tmpl/default_batch_footer.php | 23 - admin/views/fieldtypes/tmpl/default_body.php | 103 - admin/views/fieldtypes/tmpl/default_foot.php | 18 - admin/views/fieldtypes/tmpl/default_head.php | 53 - .../views/fieldtypes/tmpl/default_toolbar.php | 45 - admin/views/fieldtypes/view.html.php | 243 - admin/views/get_snippets/tmpl/default.php | 251 - admin/views/get_snippets/view.html.php | 321 - admin/views/help_document/submitbutton.js | 25 - admin/views/help_document/tmpl/edit.php | 189 - admin/views/help_document/view.html.php | 197 - admin/views/help_documents/tmpl/default.php | 66 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../help_documents/tmpl/default_body.php | 106 - .../help_documents/tmpl/default_foot.php | 18 - .../help_documents/tmpl/default_head.php | 62 - .../help_documents/tmpl/default_toolbar.php | 45 - admin/views/help_documents/view.html.php | 305 - admin/views/import/tmpl/default.php | 217 - admin/views/import/view.html.php | 95 - .../import_joomla_components/tmpl/default.php | 550 - .../import_joomla_components/view.html.php | 462 - .../tmpl/default.php | 233 - .../view.html.php | 94 - admin/views/joomla_component/submitbutton.js | 25 - admin/views/joomla_component/tmpl/edit.php | 792 - admin/views/joomla_component/view.html.php | 215 - .../views/joomla_components/tmpl/default.php | 109 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../joomla_components/tmpl/default_body.php | 227 - .../joomla_components/tmpl/default_foot.php | 18 - .../joomla_components/tmpl/default_head.php | 56 - .../tmpl/default_toolbar.php | 45 - admin/views/joomla_components/view.html.php | 306 - admin/views/joomla_module/submitbutton.js | 25 - admin/views/joomla_module/tmpl/edit.php | 663 - admin/views/joomla_module/view.html.php | 250 - .../submitbutton.js | 25 - .../tmpl/edit.php | 115 - .../view.html.php | 197 - .../joomla_module_updates/submitbutton.js | 25 - .../views/joomla_module_updates/tmpl/edit.php | 105 - .../views/joomla_module_updates/view.html.php | 197 - admin/views/joomla_modules/tmpl/default.php | 90 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../joomla_modules/tmpl/default_body.php | 127 - .../joomla_modules/tmpl/default_foot.php | 18 - .../joomla_modules/tmpl/default_head.php | 53 - .../joomla_modules/tmpl/default_toolbar.php | 45 - admin/views/joomla_modules/view.html.php | 262 - .../tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../tmpl/default_body.php | 91 - .../tmpl/default_foot.php | 18 - .../tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - .../view.html.php | 220 - .../joomla_modules_updates/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../tmpl/default_body.php | 91 - .../tmpl/default_foot.php | 18 - .../tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - .../joomla_modules_updates/view.html.php | 220 - admin/views/joomla_plugin/submitbutton.js | 25 - admin/views/joomla_plugin/tmpl/edit.php | 657 - admin/views/joomla_plugin/view.html.php | 293 - .../submitbutton.js | 25 - .../tmpl/edit.php | 115 - .../view.html.php | 197 - .../views/joomla_plugin_group/submitbutton.js | 25 - admin/views/joomla_plugin_group/tmpl/edit.php | 105 - admin/views/joomla_plugin_group/view.html.php | 197 - .../joomla_plugin_groups/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../tmpl/default_body.php | 100 - .../tmpl/default_foot.php | 18 - .../tmpl/default_head.php | 50 - .../tmpl/default_toolbar.php | 45 - .../views/joomla_plugin_groups/view.html.php | 242 - .../joomla_plugin_updates/submitbutton.js | 25 - .../views/joomla_plugin_updates/tmpl/edit.php | 105 - .../views/joomla_plugin_updates/view.html.php | 197 - admin/views/joomla_plugins/tmpl/default.php | 90 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../joomla_plugins/tmpl/default_body.php | 139 - .../joomla_plugins/tmpl/default_foot.php | 18 - .../joomla_plugins/tmpl/default_head.php | 53 - .../joomla_plugins/tmpl/default_toolbar.php | 45 - admin/views/joomla_plugins/view.html.php | 283 - .../tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../tmpl/default_body.php | 91 - .../tmpl/default_foot.php | 18 - .../tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - .../view.html.php | 220 - .../joomla_plugins_updates/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../tmpl/default_body.php | 91 - .../tmpl/default_foot.php | 18 - .../tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - .../joomla_plugins_updates/view.html.php | 220 - admin/views/language/submitbutton.js | 25 - admin/views/language/tmpl/edit.php | 105 - admin/views/language/view.html.php | 197 - .../language_translation/submitbutton.js | 25 - .../views/language_translation/tmpl/edit.php | 127 - .../views/language_translation/view.html.php | 208 - .../language_translations/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../tmpl/default_body.php | 177 - .../tmpl/default_foot.php | 18 - .../tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - .../views/language_translations/view.html.php | 231 - admin/views/languages/tmpl/default.php | 90 - .../languages/tmpl/default_batch_body.php | 18 - .../languages/tmpl/default_batch_footer.php | 23 - admin/views/languages/tmpl/default_body.php | 94 - admin/views/languages/tmpl/default_foot.php | 18 - admin/views/languages/tmpl/default_head.php | 50 - .../views/languages/tmpl/default_toolbar.php | 45 - admin/views/languages/view.html.php | 237 - admin/views/layout/submitbutton.js | 25 - admin/views/layout/tmpl/edit.php | 228 - admin/views/layout/view.html.php | 215 - admin/views/layouts/tmpl/default.php | 93 - .../views/layouts/tmpl/default_batch_body.php | 18 - .../layouts/tmpl/default_batch_footer.php | 23 - admin/views/layouts/tmpl/default_body.php | 111 - admin/views/layouts/tmpl/default_foot.php | 18 - admin/views/layouts/tmpl/default_head.php | 53 - admin/views/layouts/tmpl/default_toolbar.php | 45 - admin/views/layouts/view.html.php | 278 - admin/views/libraries/tmpl/default.php | 67 - .../libraries/tmpl/default_batch_body.php | 18 - .../libraries/tmpl/default_batch_footer.php | 23 - admin/views/libraries/tmpl/default_body.php | 135 - admin/views/libraries/tmpl/default_foot.php | 18 - admin/views/libraries/tmpl/default_head.php | 59 - .../views/libraries/tmpl/default_toolbar.php | 45 - admin/views/libraries/view.html.php | 289 - admin/views/libraries_config/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../libraries_config/tmpl/default_body.php | 91 - .../libraries_config/tmpl/default_foot.php | 18 - .../libraries_config/tmpl/default_head.php | 47 - .../libraries_config/tmpl/default_toolbar.php | 45 - admin/views/libraries_config/view.html.php | 220 - .../tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../tmpl/default_body.php | 91 - .../tmpl/default_foot.php | 18 - .../tmpl/default_head.php | 47 - .../tmpl/default_toolbar.php | 45 - .../view.html.php | 220 - admin/views/library/submitbutton.js | 25 - admin/views/library/tmpl/edit.php | 606 - admin/views/library/view.html.php | 215 - admin/views/library_config/submitbutton.js | 25 - admin/views/library_config/tmpl/edit.php | 105 - admin/views/library_config/view.html.php | 197 - .../submitbutton.js | 25 - .../library_files_folders_urls/tmpl/edit.php | 115 - .../library_files_folders_urls/view.html.php | 197 - admin/views/placeholder/submitbutton.js | 25 - admin/views/placeholder/tmpl/edit.php | 154 - admin/views/placeholder/view.html.php | 218 - admin/views/placeholders/tmpl/default.php | 67 - .../placeholders/tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../views/placeholders/tmpl/default_body.php | 94 - .../views/placeholders/tmpl/default_foot.php | 18 - .../views/placeholders/tmpl/default_head.php | 50 - .../placeholders/tmpl/default_toolbar.php | 45 - admin/views/placeholders/view.html.php | 232 - admin/views/power/submitbutton.js | 25 - admin/views/power/tmpl/edit.php | 197 - admin/views/power/view.html.php | 262 - admin/views/powers/tmpl/default.php | 93 - .../views/powers/tmpl/default_batch_body.php | 18 - .../powers/tmpl/default_batch_footer.php | 23 - admin/views/powers/tmpl/default_body.php | 110 - admin/views/powers/tmpl/default_foot.php | 18 - admin/views/powers/tmpl/default_head.php | 56 - admin/views/powers/tmpl/default_toolbar.php | 45 - admin/views/powers/view.html.php | 279 - admin/views/search/tmpl/default.php | 342 - admin/views/search/view.html.php | 440 - admin/views/server/submitbutton.js | 25 - admin/views/server/tmpl/edit.php | 293 - admin/views/server/view.html.php | 210 - admin/views/servers/tmpl/default.php | 67 - .../views/servers/tmpl/default_batch_body.php | 18 - .../servers/tmpl/default_batch_footer.php | 23 - admin/views/servers/tmpl/default_body.php | 94 - admin/views/servers/tmpl/default_foot.php | 18 - admin/views/servers/tmpl/default_head.php | 50 - admin/views/servers/tmpl/default_toolbar.php | 45 - admin/views/servers/view.html.php | 272 - admin/views/site_view/submitbutton.js | 25 - admin/views/site_view/tmpl/edit.php | 452 - admin/views/site_view/view.html.php | 215 - admin/views/site_views/tmpl/default.php | 68 - .../site_views/tmpl/default_batch_body.php | 18 - .../site_views/tmpl/default_batch_footer.php | 23 - admin/views/site_views/tmpl/default_body.php | 123 - admin/views/site_views/tmpl/default_foot.php | 18 - admin/views/site_views/tmpl/default_head.php | 56 - .../views/site_views/tmpl/default_toolbar.php | 45 - admin/views/site_views/view.html.php | 300 - admin/views/snippet/submitbutton.js | 25 - admin/views/snippet/tmpl/edit.php | 115 - admin/views/snippet/view.html.php | 197 - admin/views/snippet_type/submitbutton.js | 25 - admin/views/snippet_type/tmpl/edit.php | 105 - admin/views/snippet_type/view.html.php | 197 - admin/views/snippet_types/tmpl/default.php | 67 - .../snippet_types/tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../views/snippet_types/tmpl/default_body.php | 94 - .../views/snippet_types/tmpl/default_foot.php | 18 - .../views/snippet_types/tmpl/default_head.php | 50 - .../snippet_types/tmpl/default_toolbar.php | 45 - admin/views/snippet_types/view.html.php | 222 - admin/views/snippets/tmpl/default.php | 67 - .../snippets/tmpl/default_batch_body.php | 18 - .../snippets/tmpl/default_batch_footer.php | 23 - admin/views/snippets/tmpl/default_body.php | 109 - admin/views/snippets/tmpl/default_foot.php | 18 - admin/views/snippets/tmpl/default_head.php | 59 - admin/views/snippets/tmpl/default_toolbar.php | 45 - admin/views/snippets/view.html.php | 285 - admin/views/template/submitbutton.js | 25 - admin/views/template/tmpl/edit.php | 233 - admin/views/template/view.html.php | 215 - admin/views/templates/tmpl/default.php | 93 - .../templates/tmpl/default_batch_body.php | 18 - .../templates/tmpl/default_batch_footer.php | 23 - admin/views/templates/tmpl/default_body.php | 111 - admin/views/templates/tmpl/default_foot.php | 18 - admin/views/templates/tmpl/default_head.php | 53 - .../views/templates/tmpl/default_toolbar.php | 45 - admin/views/templates/view.html.php | 278 - admin/views/validation_rule/submitbutton.js | 25 - admin/views/validation_rule/tmpl/edit.php | 159 - admin/views/validation_rule/view.html.php | 218 - admin/views/validation_rules/tmpl/default.php | 67 - .../tmpl/default_batch_body.php | 18 - .../tmpl/default_batch_footer.php | 23 - .../validation_rules/tmpl/default_body.php | 94 - .../validation_rules/tmpl/default_foot.php | 18 - .../validation_rules/tmpl/default_head.php | 50 - .../validation_rules/tmpl/default_toolbar.php | 45 - admin/views/validation_rules/view.html.php | 237 - componentbuilder.xml | 55 +- componentbuilder_update_server.xml | 1198 +- .../VDM.Joomla.Gitea/src/Utilities/Http.php | 4 +- .../src/Utilities/Response.php | 26 +- .../src/Utilities/Response.php | 21 +- .../src/Abstraction/ActiveRegistry.php | 24 +- .../VDM.Joomla/src/Abstraction/BaseConfig.php | 6 +- .../VDM.Joomla/src/Abstraction/Database.php | 9 +- .../VDM.Joomla/src/Abstraction/Registry.php | 10 +- .../Compiler/Adminview/Data.php | 29 +- .../Componentbuilder/Compiler/Alias/Data.php | 8 +- .../JoomlaFive/Controller/AllowAdd.php | 129 + .../JoomlaFive/Controller/AllowEdit.php | 300 + .../JoomlaFive/Controller/index.html | 1 + .../JoomlaFive/Model/CanDelete.php | 87 + .../JoomlaFive/Model/CanEditState.php | 108 + .../Architecture/JoomlaFive/Model/index.html | 1 + .../JoomlaFour/Controller/AllowAdd.php | 129 + .../JoomlaFour/Controller/AllowEdit.php | 300 + .../JoomlaFour/Controller/index.html | 1 + .../JoomlaFour/Model/CanDelete.php | 87 + .../JoomlaFour/Model/CanEditState.php | 108 + .../Architecture/JoomlaFour/Model/index.html | 1 + .../JoomlaThree/Controller/AllowAdd.php | 129 + .../JoomlaThree/Controller/AllowEdit.php | 300 + .../JoomlaThree/Controller/index.html | 1 + .../JoomlaThree/Model/CanDelete.php | 91 + .../JoomlaThree/Model/CanEditState.php | 108 + .../Architecture/JoomlaThree/Model/index.html | 1 + .../Compiler/Builder/AssetsRules.php | 42 + .../Compiler/Builder/ConfigFieldsets.php | 34 + .../Builder/ConfigFieldsetsCustomfield.php | 34 + .../Compiler/Builder/Contributors.php | 27 + .../Compiler/Builder/DatabaseUninstall.php | 42 + .../Compiler/Builder/ExtensionsParams.php | 42 + .../Compiler/Builder/FrontendParams.php | 27 + .../Compiler/Builder/HasMenuGlobal.php | 27 + .../Compiler/Builder/LanguageMessages.php | 34 + .../Compiler/Builder/PermissionFields.php | 34 + .../Compiler/Builder/Request.php | 42 + .../Compiler/Builder/Router.php | 27 + .../Compiler/Builder/ViewsDefaultOrdering.php | 27 + .../Componentbuilder/Compiler/Component.php | 2 +- .../Compiler/Component/Data.php | 96 +- .../Component/JoomlaFive/Settings.php | 748 + .../Compiler/Component/JoomlaFive/index.html | 1 + .../Component/JoomlaFour/Settings.php | 748 + .../Compiler/Component/JoomlaFour/index.html | 1 + .../Component/JoomlaThree/Settings.php | 752 + .../Compiler/Component/JoomlaThree/index.html | 1 + .../Compiler/Component/Placeholder.php | 7 +- .../Compiler/Component/Settings.php | 756 - .../Compiler/Component/Structure.php | 2 +- .../Compiler/Component/Structuremultiple.php | 2 +- .../Compiler/Component/Structuresingle.php | 60 +- .../src/Componentbuilder/Compiler/Config.php | 91 +- .../Compiler/Creator/AccessSections.php | 709 + .../Creator/AccessSectionsCategory.php | 80 + .../Creator/AccessSectionsJoomlaFields.php | 63 + .../Compiler/Creator/Builders.php | 25 +- .../Compiler/Creator/ConfigFieldsets.php | 388 + .../Creator/ConfigFieldsetsCustomfield.php | 142 + .../Creator/ConfigFieldsetsEmailHelper.php | 916 + .../Creator/ConfigFieldsetsEncryption.php | 414 + .../Creator/ConfigFieldsetsGlobal.php | 634 + .../Creator/ConfigFieldsetsGooglechart.php | 633 + .../Creator/ConfigFieldsetsGroupControl.php | 163 + .../Creator/ConfigFieldsetsSiteControl.php | 225 + .../Compiler/Creator/ConfigFieldsetsUikit.php | 367 + .../Creator/CustomButtonPermissions.php | 141 + .../Compiler/Creator/CustomFieldTypeFile.php | 1132 +- .../Compiler/Creator/FieldsetString.php | 24 +- .../Compiler/Creator/FieldsetXML.php | 24 +- .../Compiler/Creator/Request.php | 79 + .../Compiler/Creator/Router.php | 263 + .../Creator/RouterConstructorDefault.php | 77 + .../Creator/RouterConstructorManual.php | 77 + .../Compiler/Creator/RouterMethodsDefault.php | 137 + .../Compiler/Creator/RouterMethodsManual.php | 137 + .../Componentbuilder/Compiler/Customcode.php | 15 +- .../Compiler/Customcode/Dispenser.php | 4 +- .../Compiler/Customcode/External.php | 21 +- .../Compiler/Customcode/Extractor.php | 42 +- .../Compiler/Customcode/Extractor/Paths.php | 8 +- .../Compiler/Customcode/Gui.php | 15 +- .../Compiler/Customview/Data.php | 20 +- .../Compiler/Dynamicget/Data.php | 17 +- .../Compiler/Dynamicget/Selection.php | 10 +- .../Extension/JoomlaFive/InstallScript.php | 374 + .../Compiler/Extension/JoomlaFive/index.html | 1 + .../Extension/JoomlaFour/InstallScript.php | 374 + .../Compiler/Extension/JoomlaFour/index.html | 1 + .../Extension/JoomlaThree/InstallScript.php | 10 +- .../src/Componentbuilder/Compiler/Factory.php | 12 +- .../Componentbuilder/Compiler/Field/Data.php | 124 +- .../Compiler/Field/Groups.php | 9 +- .../Compiler/Field/InputButton.php | 338 - .../Compiler/Field/JoomlaFive/CoreField.php | 129 + .../Compiler/Field/JoomlaFive/CoreRule.php | 125 + .../Compiler/Field/JoomlaFive/InputButton.php | 345 + .../Compiler/Field/JoomlaFive/index.html | 1 + .../Compiler/Field/JoomlaFour/CoreField.php | 129 + .../Compiler/Field/JoomlaFour/CoreRule.php | 125 + .../Compiler/Field/JoomlaFour/InputButton.php | 345 + .../Compiler/Field/JoomlaFour/index.html | 1 + .../Compiler/Field/JoomlaThree/CoreField.php | 130 + .../Compiler/Field/JoomlaThree/CoreRule.php | 125 + .../Field/JoomlaThree/CoreValidation.php | 116 - .../Field/JoomlaThree/InputButton.php | 339 + .../Componentbuilder/Compiler/Field/Rule.php | 166 + .../Compiler/Field/Validation.php | 168 - .../Compiler/Helper/Compiler.php | 1667 + .../Compiler/Helper/Fields.php | 1585 + .../Componentbuilder/Compiler/Helper/Get.php | 3157 ++ .../Compiler/Helper/Infusion.php | 2572 ++ .../Compiler/Helper/Interpretation.php | 23808 ++++++++++++++ .../Compiler/Helper/Structure.php | 901 + .../Compiler/Helper/index.html | 1 + .../Controller/AllowAddInterface.php | 32 + .../Controller/AllowEditInterface.php | 33 + .../Architecture/Controller/index.html | 1 + .../Architecture/Model/CanDeleteInterface.php | 32 + .../Model/CanEditStateInterface.php | 32 + .../Interfaces/Architecture/Model/index.html | 1 + .../Component/SettingsInterface.php | 74 + .../Compiler/Interfaces/EventInterface.php | 2 +- .../Interfaces/Field/CoreFieldInterface.php | 32 + .../Interfaces/Field/CoreRuleInterface.php | 32 + .../Field/CoreValidationInterface.php | 32 - .../Interfaces/Field/InputButtonInterface.php | 32 + .../Compiler/Interfaces/HeaderInterface.php | 33 + .../Interfaces/Model/CustomtabsInterface.php | 32 + .../Compiler/Interfaces/Model/index.html | 1 + .../Compiler/JoomlaFive/Event.php | 100 + .../Compiler/JoomlaFive/Header.php | 584 + .../Compiler/JoomlaFive/History.php | 211 + .../Compiler/JoomlaFive/index.html | 1 + .../Compiler/JoomlaFour/Event.php | 100 + .../Compiler/JoomlaFour/Header.php | 584 + .../Compiler/JoomlaFour/History.php | 211 + .../Compiler/JoomlaFour/index.html | 1 + .../Compiler/JoomlaThree/Event.php | 6 +- .../Compiler/JoomlaThree/Header.php | 556 + .../Compiler/JoomlaThree/History.php | 12 +- .../Compiler/Joomlamodule/Data.php | 13 +- .../Compiler/Joomlamodule/Structure.php | 38 +- .../Compiler/Joomlaplugin/Data.php | 8 +- .../Compiler/Joomlaplugin/Structure.php | 34 +- .../Componentbuilder/Compiler/Language.php | 39 +- .../Compiler/Language/Extractor.php | 17 +- .../Compiler/Language/Fieldset.php | 5 + .../Compiler/Library/Data.php | 9 +- .../Compiler/Model/Customtabs.php | 239 - .../Compiler/Model/Historycomponent.php | 22 +- .../Compiler/Model/JoomlaFive/Customtabs.php | 240 + .../Compiler/Model/JoomlaFive/index.html | 1 + .../Compiler/Model/JoomlaFour/Customtabs.php | 240 + .../Compiler/Model/JoomlaFour/index.html | 1 + .../Compiler/Model/JoomlaThree/Customtabs.php | 240 + .../Compiler/Model/JoomlaThree/index.html | 1 + .../Compiler/Model/Router.php | 330 + .../Compiler/Model/Sqldump.php | 7 +- .../src/Componentbuilder/Compiler/Power.php | 15 +- .../Compiler/Power/Autoloader.php | 4 +- .../Compiler/Power/Extractor.php | 8 +- .../Compiler/Power/Infusion.php | 87 +- .../Compiler/Power/Injector.php | 371 +- .../Compiler/Power/Structure.php | 56 +- .../Service/ArchitectureController.php | 221 + .../Compiler/Service/ArchitectureModel.php | 209 + .../Compiler/Service/Builder.php | 1550 - .../Compiler/Service/BuilderAJ.php | 870 + .../Compiler/Service/BuilderLZ.php | 938 + .../Compiler/Service/Component.php | 119 +- .../Compiler/Service/Creator.php | 436 +- .../Compiler/Service/Event.php | 35 +- .../Compiler/Service/Extension.php | 34 + .../Compiler/Service/Field.php | 384 +- .../Compiler/Service/Header.php | 151 + .../Compiler/Service/History.php | 39 +- .../Compiler/Service/Model.php | 383 +- .../Compiler/Service/Power.php | 1 - .../Compiler/Service/Utilities.php | 20 + .../Compiler/Templatelayout/Data.php | 4 +- .../Compiler/Utilities/FileInjector.php | 213 + .../Compiler/Utilities/Structure.php | 103 +- .../Extrusion/Helper/Builder.php | 287 + .../Extrusion/Helper/Extrusion.php | 103 + .../Extrusion/Helper/Mapping.php | 422 + .../Extrusion/Helper/index.html | 1 + .../Componentbuilder/Power/Database/Load.php | 2 +- .../Search/Database/Insert.php | 8 +- .../Componentbuilder/Search/Model/Load.php | 22 + .../VDM.Joomla/src/Componentbuilder/Table.php | 894 +- .../Interfaces/Activeregistryinterface.php | 10 +- .../src/Interfaces/Registryinterface.php | 10 +- .../jcb_powers/VDM.Joomla/src/Utilities.php | 669 - .../src/Utilities/Component/Helper.php | 135 +- .../VDM.Joomla/src/Utilities/FileHelper.php | 16 +- .../VDM.Joomla/src/Utilities/FormHelper.php | 38 +- .../VDM.Joomla/src/Utilities/GetHelper.php | 4 +- .../VDM.Joomla/src/Utilities/GuidHelper.php | 2 +- .../src/Utilities/String/NamespaceHelper.php | 53 +- .../VDM.Joomla/src/Utilities/StringHelper.php | 6 +- media/js/admin_custom_tabs.js | 2 +- media/js/admin_fields.js | 2 +- media/js/admin_fields_conditions.js | 2 +- media/js/admin_fields_relations.js | 71 +- media/js/admin_view.js | 75 +- media/js/class_extends.js | 71 +- media/js/class_method.js | 75 +- media/js/class_property.js | 75 +- media/js/component_admin_views.js | 2 +- media/js/component_config.js | 2 +- media/js/component_custom_admin_menus.js | 2 +- media/js/component_custom_admin_views.js | 2 +- media/js/component_dashboard.js | 71 +- media/js/component_files_folders.js | 2 +- media/js/component_modules.js | 2 +- media/js/component_mysql_tweaks.js | 2 +- media/js/component_placeholders.js | 2 +- media/js/component_plugins.js | 2 +- media/js/component_router.js | 67 + media/js/component_site_views.js | 2 +- media/js/component_updates.js | 2 +- media/js/custom_admin_view.js | 73 +- media/js/custom_code.js | 75 +- media/js/dynamic_get.js | 75 +- media/js/field.js | 75 +- media/js/fieldtype.js | 75 +- media/js/help_document.js | 6 +- media/js/joomla_component.js | 75 +- media/js/joomla_module.js | 75 +- media/js/joomla_module_files_folders_urls.js | 2 +- media/js/joomla_module_updates.js | 2 +- media/js/joomla_plugin.js | 75 +- media/js/joomla_plugin_files_folders_urls.js | 2 +- media/js/joomla_plugin_group.js | 2 +- media/js/joomla_plugin_updates.js | 2 +- media/js/language.js | 2 +- media/js/language_translation.js | 2 +- media/js/layout.js | 73 +- media/js/library.js | 75 +- media/js/library_config.js | 2 +- media/js/library_files_folders_urls.js | 2 +- media/js/placeholder.js | 2 +- media/js/power.js | 76 +- media/js/server.js | 6 +- media/js/site_view.js | 73 +- media/js/snippet.js | 2 +- media/js/snippet_type.js | 2 +- media/js/template.js | 73 +- media/js/validation_rule.js | 71 +- script.php | 11235 ------- site/assets/css/site.css | 15 - site/assets/js/site.js | 11 - site/componentbuilder.php | 92 - site/controller.php | 123 - site/controllers/api.php | 554 - site/controllers/help.php | 117 - site/helpers/category.php | 38 - site/helpers/categoryfield.php | 33 - site/helpers/categoryfieldtype.php | 33 - site/helpers/componentbuilder.php | 6393 ---- site/helpers/headercheck.php | 71 - site/helpers/route.php | 257 - .../en-GB/en-GB.com_componentbuilder.ini | 162 - .../en-GB/en-GB.com_componentbuilder.sys.ini | 3 - site/models/api.php | 276 - site/router.php | 228 - site/views/api/submitbutton.js | 25 - site/views/api/tmpl/default.php | 20 - site/views/api/view.html.php | 116 - 3040 files changed, 296309 insertions(+), 269802 deletions(-) create mode 100644 ComponentbuilderInstallerScript.php rename site/assets/css/api.css => admin/assets/css/component_router.css (100%) create mode 100644 admin/assets/css/components_routers.css delete mode 100644 admin/compiler/joomla_3/JCB_Helper.php delete mode 100644 admin/compiler/joomla_3/JCB_Helper_site.php delete mode 100644 admin/compiler/joomla_3/settings_componentbuilder.json create mode 100644 admin/compiler/joomla_4/1.0.0.sql create mode 100644 admin/compiler/joomla_4/ADMIN_AJAX_CONTROLLER.php create mode 100644 admin/compiler/joomla_4/ADMIN_AJAX_MODEL.php create mode 100644 admin/compiler/joomla_4/ADMIN_DISPLAY_CONTROLLER.php create mode 100644 admin/compiler/joomla_4/ADMIN_EXTENSION_COMPONENT.php create mode 100644 admin/compiler/joomla_4/ADMIN_HEADERCHECK.php create mode 100644 admin/compiler/joomla_4/ADMIN_HELPER_CLASS.php create mode 100644 admin/compiler/joomla_4/ADMIN_HELPER_CONTROLLER.php create mode 100644 admin/compiler/joomla_4/ADMIN_HELPER_EMAIL.php create mode 100644 admin/compiler/joomla_4/ADMIN_IMPORT_CONTROLLER.php create mode 100644 admin/compiler/joomla_4/ADMIN_IMPORT_CONTROLLER_CUSTOM.php create mode 100644 admin/compiler/joomla_4/ADMIN_IMPORT_HTML.php create mode 100644 admin/compiler/joomla_4/ADMIN_IMPORT_HTML_CUSTOM.php create mode 100644 admin/compiler/joomla_4/ADMIN_IMPORT_MODEL.php create mode 100644 admin/compiler/joomla_4/ADMIN_IMPORT_MODEL_CUSTOM.php create mode 100644 admin/compiler/joomla_4/ADMIN_LAYOUT.php create mode 100644 admin/compiler/joomla_4/ADMIN_PROVIDER.php create mode 100644 admin/compiler/joomla_4/ADMIN_VIEW.php create mode 100644 admin/compiler/joomla_4/ADMIN_VIEWS.php create mode 100644 admin/compiler/joomla_4/ADMIN_VIEWS_CONTROLLER.php create mode 100644 admin/compiler/joomla_4/ADMIN_VIEWS_EMPTYSTATE.php create mode 100644 admin/compiler/joomla_4/ADMIN_VIEWS_HTML.php create mode 100644 admin/compiler/joomla_4/ADMIN_VIEWS_MODEL.php create mode 100644 admin/compiler/joomla_4/ADMIN_VIEW_CONTROLLER.php create mode 100644 admin/compiler/joomla_4/ADMIN_VIEW_HTML.php create mode 100644 admin/compiler/joomla_4/ADMIN_VIEW_MODEL.php create mode 100644 admin/compiler/joomla_4/ADMIN_VIEW_TABLE.php create mode 100644 admin/compiler/joomla_4/CHANGELOG.md create mode 100644 admin/compiler/joomla_4/CUSTOM_ADMIN_LAYOUT.php create mode 100644 admin/compiler/joomla_4/CUSTOM_ADMIN_VIEW.php create mode 100644 admin/compiler/joomla_4/CUSTOM_ADMIN_VIEWS.php create mode 100644 admin/compiler/joomla_4/CUSTOM_ADMIN_VIEWS_CONTROLLER.php create mode 100644 admin/compiler/joomla_4/CUSTOM_ADMIN_VIEWS_HTML.php create mode 100644 admin/compiler/joomla_4/CUSTOM_ADMIN_VIEWS_MODEL.php create mode 100644 admin/compiler/joomla_4/CUSTOM_ADMIN_VIEW_CONTROLLER.php create mode 100644 admin/compiler/joomla_4/CUSTOM_ADMIN_VIEW_HTML.php create mode 100644 admin/compiler/joomla_4/CUSTOM_ADMIN_VIEW_MODEL.php create mode 100644 admin/compiler/joomla_4/DASH_CONTROLLER.php create mode 100644 admin/compiler/joomla_4/DASH_MODEL.php create mode 100644 admin/compiler/joomla_4/DASH_VIEW.php create mode 100644 admin/compiler/joomla_4/DASH_VIEW_HTML.php create mode 100644 admin/compiler/joomla_4/FORM_CHECKBOXES_FIELD.php create mode 100644 admin/compiler/joomla_4/FORM_CUSTOM_FIELD.php create mode 100644 admin/compiler/joomla_4/FORM_LIST_FIELD.php create mode 100644 admin/compiler/joomla_4/FORM_RADIO_FIELD.php create mode 100644 admin/compiler/joomla_4/FORM_RULE.php create mode 100644 admin/compiler/joomla_4/FORM_USER_FIELD.php create mode 100644 admin/compiler/joomla_4/INSTALLER_SCRIPT.php create mode 100644 admin/compiler/joomla_4/LAYOUT_OVERRIDE.php create mode 100644 admin/compiler/joomla_4/LICENSE.txt create mode 100644 admin/compiler/joomla_4/README.md create mode 100644 admin/compiler/joomla_4/README.txt create mode 100644 admin/compiler/joomla_4/SITE_ADMIN_VIEW.php create mode 100644 admin/compiler/joomla_4/SITE_ADMIN_VIEW_CONTROLLER.php create mode 100644 admin/compiler/joomla_4/SITE_ADMIN_VIEW_HTML.php create mode 100644 admin/compiler/joomla_4/SITE_ADMIN_VIEW_MODEL.php create mode 100644 admin/compiler/joomla_4/SITE_AJAX_CONTROLLER.php create mode 100644 admin/compiler/joomla_4/SITE_AJAX_MODEL.php create mode 100644 admin/compiler/joomla_4/SITE_DISPATCHER.php create mode 100644 admin/compiler/joomla_4/SITE_DISPLAY_CONTROLLER.php create mode 100644 admin/compiler/joomla_4/SITE_FORM_CHECKBOXES_FIELD.php create mode 100644 admin/compiler/joomla_4/SITE_FORM_CUSTOM_FIELD.php create mode 100644 admin/compiler/joomla_4/SITE_FORM_LIST_FIELD.php create mode 100644 admin/compiler/joomla_4/SITE_FORM_RADIO_FIELD.php create mode 100644 admin/compiler/joomla_4/SITE_FORM_RULE.php create mode 100644 admin/compiler/joomla_4/SITE_FORM_USER_FIELD.php create mode 100644 admin/compiler/joomla_4/SITE_HEADERCHECK.php create mode 100644 admin/compiler/joomla_4/SITE_HELPER_CLASS.php create mode 100644 admin/compiler/joomla_4/SITE_HELPER_CONTROLLER.php create mode 100644 admin/compiler/joomla_4/SITE_LAYOUT.php create mode 100644 admin/compiler/joomla_4/SITE_ROUTER.php create mode 100644 admin/compiler/joomla_4/SITE_ROUTE_HELPER.php create mode 100644 admin/compiler/joomla_4/SITE_VIEW.php create mode 100644 admin/compiler/joomla_4/SITE_VIEWS.php create mode 100644 admin/compiler/joomla_4/SITE_VIEWS_HTML.php create mode 100644 admin/compiler/joomla_4/SITE_VIEWS_MODEL.php create mode 100644 admin/compiler/joomla_4/SITE_VIEW_CONTROLLER.php create mode 100644 admin/compiler/joomla_4/SITE_VIEW_HTML.php create mode 100644 admin/compiler/joomla_4/SITE_VIEW_MODEL.php create mode 100644 admin/compiler/joomla_4/access.xml create mode 100644 admin/compiler/joomla_4/admin.css create mode 100644 admin/compiler/joomla_4/admin.js create mode 100644 admin/compiler/joomla_4/component.xml create mode 100644 admin/compiler/joomla_4/config.xml create mode 100644 admin/compiler/joomla_4/dashboard.css create mode 100644 admin/compiler/joomla_4/default.xml create mode 100644 admin/compiler/joomla_4/default_batch_body.php create mode 100644 admin/compiler/joomla_4/default_batch_footer.php create mode 100644 admin/compiler/joomla_4/default_body.php create mode 100644 admin/compiler/joomla_4/default_custom_admin_template.php create mode 100644 admin/compiler/joomla_4/default_foot.php create mode 100644 admin/compiler/joomla_4/default_head.php create mode 100644 admin/compiler/joomla_4/default_import.php create mode 100644 admin/compiler/joomla_4/default_import_custom.php create mode 100644 admin/compiler/joomla_4/default_list.xml create mode 100644 admin/compiler/joomla_4/default_main.php create mode 100644 admin/compiler/joomla_4/default_site_template.php create mode 100644 admin/compiler/joomla_4/default_toolbar.php create mode 100644 admin/compiler/joomla_4/default_vdm.php create mode 100644 admin/compiler/joomla_4/edit.xml create mode 100644 admin/compiler/joomla_4/en-GB.com_admin.ini create mode 100644 admin/compiler/joomla_4/en-GB.com_admin.sys.ini create mode 100644 admin/compiler/joomla_4/en-GB.com_site.ini create mode 100644 admin/compiler/joomla_4/en-GB.com_site.sys.ini create mode 100644 admin/compiler/joomla_4/filter_forms.xml create mode 100644 admin/compiler/joomla_4/import.gif rename admin/{controllers => compiler/joomla_4}/index.html (100%) create mode 100644 admin/compiler/joomla_4/install.mysql.utf8.sql create mode 100644 admin/compiler/joomla_4/layout.php create mode 100644 admin/compiler/joomla_4/layoutfull.php create mode 100644 admin/compiler/joomla_4/layoutitems.php create mode 100644 admin/compiler/joomla_4/layoutlinkedview.php create mode 100644 admin/compiler/joomla_4/layoutmetadata.php create mode 100644 admin/compiler/joomla_4/layoutpublished.php create mode 100644 admin/compiler/joomla_4/layouttitle.php create mode 100644 admin/compiler/joomla_4/module_forms.js create mode 100644 admin/compiler/joomla_4/module_forms.xml create mode 100644 admin/compiler/joomla_4/settings.json create mode 100644 admin/compiler/joomla_4/site.css create mode 100644 admin/compiler/joomla_4/site.js create mode 100644 admin/compiler/joomla_4/submitbutton.js create mode 100644 admin/compiler/joomla_4/submitbutton_site.js create mode 100644 admin/compiler/joomla_4/uninstall.mysql.utf8.sql create mode 100644 admin/compiler/joomla_4/update_server.xml create mode 100644 admin/compiler/joomla_4/view.css create mode 100644 admin/compiler/joomla_4/viewFile.js create mode 100644 admin/compiler/joomla_4/viewFileCustomAdmin.js create mode 100644 admin/compiler/joomla_4/viewFileSite.js create mode 100644 admin/compiler/joomla_4/view_custom_admin.css create mode 100644 admin/compiler/joomla_4/view_site.css create mode 100644 admin/compiler/joomla_4/view_site_edit.css create mode 100644 admin/compiler/joomla_4/views.css create mode 100644 admin/compiler/joomla_4/views_custom_admin.css create mode 100644 admin/compiler/joomla_4/views_site.css create mode 100644 admin/compiler/joomla_4/whmcs.php create mode 100644 admin/compiler/joomla_basic.txt delete mode 100644 admin/componentbuilder.php delete mode 100644 admin/controller.php delete mode 100644 admin/controllers/admin_custom_tabs.php delete mode 100644 admin/controllers/admin_fields.php delete mode 100644 admin/controllers/admin_fields_conditions.php delete mode 100644 admin/controllers/admin_fields_relations.php delete mode 100644 admin/controllers/admin_view.php delete mode 100644 admin/controllers/admin_views.php delete mode 100644 admin/controllers/admins_custom_tabs.php delete mode 100644 admin/controllers/admins_fields.php delete mode 100644 admin/controllers/admins_fields_conditions.php delete mode 100644 admin/controllers/admins_fields_relations.php delete mode 100644 admin/controllers/ajax.json.php delete mode 100644 admin/controllers/class_extendings.php delete mode 100644 admin/controllers/class_extends.php delete mode 100644 admin/controllers/class_method.php delete mode 100644 admin/controllers/class_methods.php delete mode 100644 admin/controllers/class_properties.php delete mode 100644 admin/controllers/class_property.php delete mode 100644 admin/controllers/compiler.php delete mode 100644 admin/controllers/component_admin_views.php delete mode 100644 admin/controllers/component_config.php delete mode 100644 admin/controllers/component_custom_admin_menus.php delete mode 100644 admin/controllers/component_custom_admin_views.php delete mode 100644 admin/controllers/component_dashboard.php delete mode 100644 admin/controllers/component_files_folders.php delete mode 100644 admin/controllers/component_modules.php delete mode 100644 admin/controllers/component_mysql_tweaks.php delete mode 100644 admin/controllers/component_placeholders.php delete mode 100644 admin/controllers/component_plugins.php delete mode 100644 admin/controllers/component_site_views.php delete mode 100644 admin/controllers/component_updates.php delete mode 100644 admin/controllers/componentbuilder.php delete mode 100644 admin/controllers/components_admin_views.php delete mode 100644 admin/controllers/components_config.php delete mode 100644 admin/controllers/components_custom_admin_menus.php delete mode 100644 admin/controllers/components_custom_admin_views.php delete mode 100644 admin/controllers/components_dashboard.php delete mode 100644 admin/controllers/components_files_folders.php delete mode 100644 admin/controllers/components_modules.php delete mode 100644 admin/controllers/components_mysql_tweaks.php delete mode 100644 admin/controllers/components_placeholders.php delete mode 100644 admin/controllers/components_plugins.php delete mode 100644 admin/controllers/components_site_views.php delete mode 100644 admin/controllers/components_updates.php delete mode 100644 admin/controllers/custom_admin_view.php delete mode 100644 admin/controllers/custom_admin_views.php delete mode 100644 admin/controllers/custom_code.php delete mode 100644 admin/controllers/custom_codes.php delete mode 100644 admin/controllers/dynamic_get.php delete mode 100644 admin/controllers/dynamic_gets.php delete mode 100644 admin/controllers/field.php delete mode 100644 admin/controllers/fields.php delete mode 100644 admin/controllers/fieldtype.php delete mode 100644 admin/controllers/fieldtypes.php delete mode 100644 admin/controllers/get_snippets.php delete mode 100644 admin/controllers/help.php delete mode 100644 admin/controllers/help_document.php delete mode 100644 admin/controllers/help_documents.php delete mode 100644 admin/controllers/import.php delete mode 100644 admin/controllers/import_joomla_components.php delete mode 100644 admin/controllers/import_language_translations.php delete mode 100644 admin/controllers/joomla_component.php delete mode 100644 admin/controllers/joomla_components.php delete mode 100644 admin/controllers/joomla_module.php delete mode 100644 admin/controllers/joomla_module_files_folders_urls.php delete mode 100644 admin/controllers/joomla_module_updates.php delete mode 100644 admin/controllers/joomla_modules.php delete mode 100644 admin/controllers/joomla_modules_files_folders_urls.php delete mode 100644 admin/controllers/joomla_modules_updates.php delete mode 100644 admin/controllers/joomla_plugin.php delete mode 100644 admin/controllers/joomla_plugin_files_folders_urls.php delete mode 100644 admin/controllers/joomla_plugin_group.php delete mode 100644 admin/controllers/joomla_plugin_groups.php delete mode 100644 admin/controllers/joomla_plugin_updates.php delete mode 100644 admin/controllers/joomla_plugins.php delete mode 100644 admin/controllers/joomla_plugins_files_folders_urls.php delete mode 100644 admin/controllers/joomla_plugins_updates.php delete mode 100644 admin/controllers/language.php delete mode 100644 admin/controllers/language_translation.php delete mode 100644 admin/controllers/language_translations.php delete mode 100644 admin/controllers/languages.php delete mode 100644 admin/controllers/layout.php delete mode 100644 admin/controllers/layouts.php delete mode 100644 admin/controllers/libraries.php delete mode 100644 admin/controllers/libraries_config.php delete mode 100644 admin/controllers/libraries_files_folders_urls.php delete mode 100644 admin/controllers/library.php delete mode 100644 admin/controllers/library_config.php delete mode 100644 admin/controllers/library_files_folders_urls.php delete mode 100644 admin/controllers/placeholder.php delete mode 100644 admin/controllers/placeholders.php delete mode 100644 admin/controllers/power.php delete mode 100644 admin/controllers/powers.php delete mode 100644 admin/controllers/search.php delete mode 100644 admin/controllers/server.php delete mode 100644 admin/controllers/servers.php delete mode 100644 admin/controllers/site_view.php delete mode 100644 admin/controllers/site_views.php delete mode 100644 admin/controllers/snippet.php delete mode 100644 admin/controllers/snippet_type.php delete mode 100644 admin/controllers/snippet_types.php delete mode 100644 admin/controllers/snippets.php delete mode 100644 admin/controllers/template.php delete mode 100644 admin/controllers/templates.php delete mode 100644 admin/controllers/validation_rule.php delete mode 100644 admin/controllers/validation_rules.php rename admin/{models => }/forms/admin_custom_tabs.xml (96%) rename admin/{models => }/forms/admin_fields.xml (98%) rename admin/{models => }/forms/admin_fields_conditions.xml (97%) rename admin/{models => }/forms/admin_fields_relations.xml (97%) rename admin/{models => }/forms/admin_view.xml (99%) rename admin/{models => }/forms/class_extends.xml (96%) rename admin/{models => }/forms/class_method.xml (97%) rename admin/{models => }/forms/class_property.xml (97%) rename admin/{models => }/forms/component_admin_views.xml (99%) rename admin/{models => }/forms/component_config.xml (96%) rename admin/{models => }/forms/component_custom_admin_menus.xml (97%) rename admin/{models => }/forms/component_custom_admin_views.xml (99%) rename admin/{models => }/forms/component_dashboard.xml (97%) rename admin/{models => }/forms/component_files_folders.xml (98%) rename admin/{models => }/forms/component_modules.xml (96%) rename admin/{models => }/forms/component_mysql_tweaks.xml (97%) rename admin/{models => }/forms/component_placeholders.xml (96%) rename admin/{models => }/forms/component_plugins.xml (96%) create mode 100644 admin/forms/component_router.xml rename admin/{models => }/forms/component_site_views.xml (97%) rename admin/{models => }/forms/component_updates.xml (98%) rename admin/{models => }/forms/custom_admin_view.xml (99%) rename admin/{models => }/forms/custom_code.xml (95%) rename admin/{models => }/forms/dynamic_get.xml (98%) rename admin/{models => }/forms/field.xml (98%) rename admin/{models => }/forms/fieldtype.xml (98%) rename admin/{models => }/forms/filter_admin_views.xml (77%) create mode 100644 admin/forms/filter_admins_custom_tabs.xml create mode 100644 admin/forms/filter_admins_fields.xml create mode 100644 admin/forms/filter_admins_fields_conditions.xml create mode 100644 admin/forms/filter_admins_fields_relations.xml create mode 100644 admin/forms/filter_class_extendings.xml rename admin/{models => }/forms/filter_class_methods.xml (76%) rename admin/{models => }/forms/filter_class_properties.xml (76%) create mode 100644 admin/forms/filter_components_admin_views.xml create mode 100644 admin/forms/filter_components_config.xml create mode 100644 admin/forms/filter_components_custom_admin_menus.xml create mode 100644 admin/forms/filter_components_custom_admin_views.xml create mode 100644 admin/forms/filter_components_dashboard.xml create mode 100644 admin/forms/filter_components_files_folders.xml create mode 100644 admin/forms/filter_components_modules.xml create mode 100644 admin/forms/filter_components_mysql_tweaks.xml create mode 100644 admin/forms/filter_components_placeholders.xml create mode 100644 admin/forms/filter_components_plugins.xml create mode 100644 admin/forms/filter_components_routers.xml create mode 100644 admin/forms/filter_components_site_views.xml create mode 100644 admin/forms/filter_components_updates.xml rename admin/{models => }/forms/filter_custom_admin_views.xml (77%) rename admin/{models => }/forms/filter_custom_codes.xml (77%) rename admin/{models => }/forms/filter_dynamic_gets.xml (76%) rename admin/{models => }/forms/filter_fields.xml (80%) rename admin/{models => }/forms/filter_fieldtypes.xml (76%) create mode 100644 admin/forms/filter_help_documents.xml rename admin/{models => }/forms/filter_joomla_components.xml (78%) create mode 100644 admin/forms/filter_joomla_modules.xml create mode 100644 admin/forms/filter_joomla_modules_files_folders_urls.xml create mode 100644 admin/forms/filter_joomla_modules_updates.xml create mode 100644 admin/forms/filter_joomla_plugin_groups.xml rename admin/{models => }/forms/filter_joomla_plugins.xml (76%) create mode 100644 admin/forms/filter_joomla_plugins_files_folders_urls.xml create mode 100644 admin/forms/filter_joomla_plugins_updates.xml create mode 100644 admin/forms/filter_language_translations.xml create mode 100644 admin/forms/filter_languages.xml rename admin/{models => }/forms/filter_layouts.xml (76%) rename admin/{models => }/forms/filter_libraries.xml (77%) create mode 100644 admin/forms/filter_libraries_config.xml create mode 100644 admin/forms/filter_libraries_files_folders_urls.xml create mode 100644 admin/forms/filter_placeholders.xml rename admin/{models => }/forms/filter_powers.xml (76%) create mode 100644 admin/forms/filter_servers.xml rename admin/{models => }/forms/filter_site_views.xml (78%) create mode 100644 admin/forms/filter_snippet_types.xml rename admin/{models => }/forms/filter_snippets.xml (78%) rename admin/{models => }/forms/filter_templates.xml (76%) create mode 100644 admin/forms/filter_validation_rules.xml rename admin/{models => }/forms/help_document.xml (96%) rename admin/{helpers/compiler => forms}/index.html (100%) rename admin/{models => }/forms/joomla_component.xml (97%) rename admin/{models => }/forms/joomla_module.xml (99%) rename admin/{models => }/forms/joomla_module_files_folders_urls.xml (98%) rename admin/{models => }/forms/joomla_module_updates.xml (96%) rename admin/{models => }/forms/joomla_plugin.xml (99%) rename admin/{models => }/forms/joomla_plugin_files_folders_urls.xml (98%) rename admin/{models => }/forms/joomla_plugin_group.xml (95%) rename admin/{models => }/forms/joomla_plugin_updates.xml (96%) rename admin/{models => }/forms/language.xml (95%) rename admin/{models => }/forms/language_translation.xml (96%) rename admin/{models => }/forms/layout.xml (97%) rename admin/{models => }/forms/library.xml (98%) rename admin/{models => }/forms/library_config.xml (96%) rename admin/{models => }/forms/library_files_folders_urls.xml (98%) rename admin/{models => }/forms/placeholder.xml (95%) rename admin/{models => }/forms/power.xml (98%) rename admin/{models => }/forms/server.xml (97%) rename admin/{models => }/forms/site_view.xml (99%) rename admin/{models => }/forms/snippet.xml (97%) rename admin/{models => }/forms/snippet_type.xml (95%) rename admin/{models => }/forms/template.xml (97%) rename admin/{models => }/forms/validation_rule.xml (96%) delete mode 100644 admin/helpers/compiler.php delete mode 100644 admin/helpers/compiler/a_Get.php delete mode 100644 admin/helpers/compiler/b_Structure.php delete mode 100644 admin/helpers/compiler/c_Fields.php delete mode 100644 admin/helpers/compiler/e_Interpretation.php delete mode 100644 admin/helpers/compiler/f_Infusion.php delete mode 100644 admin/helpers/componentbuilder.php delete mode 100644 admin/helpers/componentbuilderemail.php delete mode 100644 admin/helpers/extrusion/a_mapping.php delete mode 100644 admin/helpers/extrusion/b_builder.php delete mode 100644 admin/helpers/extrusion/c_extrusion.php delete mode 100644 admin/helpers/headercheck.php delete mode 100644 admin/helpers/html/batch_.php delete mode 100644 admin/helpers/indenter.php delete mode 100644 admin/layouts/batchselection.php rename admin/{helpers/extrusion => layouts/component_router}/index.html (100%) create mode 100644 admin/layouts/component_router/publishing.php create mode 100644 admin/layouts/component_router/publlshing.php create mode 100644 admin/layouts/component_router/settings_above.php create mode 100644 admin/layouts/component_router/settings_fullwidth.php delete mode 100644 admin/models/admin_custom_tabs.php delete mode 100644 admin/models/admin_fields.php delete mode 100644 admin/models/admin_fields_conditions.php delete mode 100644 admin/models/admin_fields_relations.php delete mode 100644 admin/models/admin_view.php delete mode 100644 admin/models/admin_views.php delete mode 100644 admin/models/admins_custom_tabs.php delete mode 100644 admin/models/admins_fields.php delete mode 100644 admin/models/admins_fields_conditions.php delete mode 100644 admin/models/admins_fields_relations.php delete mode 100644 admin/models/ajax.php delete mode 100644 admin/models/class_extendings.php delete mode 100644 admin/models/class_extends.php delete mode 100644 admin/models/class_method.php delete mode 100644 admin/models/class_methods.php delete mode 100644 admin/models/class_properties.php delete mode 100644 admin/models/class_property.php delete mode 100644 admin/models/compiler.php delete mode 100644 admin/models/component_admin_views.php delete mode 100644 admin/models/component_config.php delete mode 100644 admin/models/component_custom_admin_menus.php delete mode 100644 admin/models/component_custom_admin_views.php delete mode 100644 admin/models/component_dashboard.php delete mode 100644 admin/models/component_files_folders.php delete mode 100644 admin/models/component_modules.php delete mode 100644 admin/models/component_mysql_tweaks.php delete mode 100644 admin/models/component_placeholders.php delete mode 100644 admin/models/component_plugins.php delete mode 100644 admin/models/component_site_views.php delete mode 100644 admin/models/component_updates.php delete mode 100644 admin/models/componentbuilder.php delete mode 100644 admin/models/components_admin_views.php delete mode 100644 admin/models/components_config.php delete mode 100644 admin/models/components_custom_admin_menus.php delete mode 100644 admin/models/components_custom_admin_views.php delete mode 100644 admin/models/components_dashboard.php delete mode 100644 admin/models/components_files_folders.php delete mode 100644 admin/models/components_modules.php delete mode 100644 admin/models/components_mysql_tweaks.php delete mode 100644 admin/models/components_placeholders.php delete mode 100644 admin/models/components_plugins.php delete mode 100644 admin/models/components_site_views.php delete mode 100644 admin/models/components_updates.php delete mode 100644 admin/models/custom_admin_view.php delete mode 100644 admin/models/custom_admin_views.php delete mode 100644 admin/models/custom_code.php delete mode 100644 admin/models/custom_codes.php delete mode 100644 admin/models/dynamic_get.php delete mode 100644 admin/models/dynamic_gets.php delete mode 100644 admin/models/field.php delete mode 100644 admin/models/fields.php delete mode 100644 admin/models/fields/adminlistvieworderfields.php delete mode 100644 admin/models/fields/adminsviews.php delete mode 100644 admin/models/fields/adminviewfolderlist.php delete mode 100644 admin/models/fields/adminviews.php delete mode 100644 admin/models/fields/adminviewsfilteraddcustombutton.php delete mode 100644 admin/models/fields/adminviewsfilteraddcustomimport.php delete mode 100644 admin/models/fields/adminviewsfilteraddfadein.php delete mode 100644 admin/models/fields/adminviewsfilteraddphpajax.php delete mode 100644 admin/models/fields/adminviewsfiltertype.php delete mode 100644 admin/models/fields/adminviewsreadonly.php delete mode 100644 admin/models/fields/aliasbuilder.php delete mode 100644 admin/models/fields/articles.php delete mode 100644 admin/models/fields/classextendingsfilterextensiontype.php delete mode 100644 admin/models/fields/classextends.php delete mode 100644 admin/models/fields/classmethodsfilterextensiontype.php delete mode 100644 admin/models/fields/classmethodsfiltervisibility.php delete mode 100644 admin/models/fields/classpowers.php delete mode 100644 admin/models/fields/classpropertiesfilterextensiontype.php delete mode 100644 admin/models/fields/classpropertiesfiltervisibility.php delete mode 100644 admin/models/fields/componentadminmenus.php delete mode 100644 admin/models/fields/componentadminviews.php delete mode 100644 admin/models/fields/customadminviews.php delete mode 100644 admin/models/fields/customadminviewsfilteraddcustombutton.php delete mode 100644 admin/models/fields/customadminviewsfilteraddphpajax.php delete mode 100644 admin/models/fields/customcodesfiltercommenttype.php delete mode 100644 admin/models/fields/customcodesfiltertarget.php delete mode 100644 admin/models/fields/customcodesfiltertype.php delete mode 100644 admin/models/fields/customfilelist.php delete mode 100644 admin/models/fields/customfolderlist.php delete mode 100644 admin/models/fields/customgets.php delete mode 100644 admin/models/fields/dbtables.php delete mode 100644 admin/models/fields/dynamicdashboard.php delete mode 100644 admin/models/fields/dynamicget.php delete mode 100644 admin/models/fields/dynamicgets.php delete mode 100644 admin/models/fields/dynamicgetsfiltergettype.php delete mode 100644 admin/models/fields/dynamicgetsfiltermainsource.php delete mode 100644 admin/models/fields/excludedlanguages.php delete mode 100644 admin/models/fields/existingvalidationrules.php delete mode 100644 admin/models/fields/fields.php delete mode 100644 admin/models/fields/fieldsfilterdatatype.php delete mode 100644 admin/models/fields/fieldsfilterindexes.php delete mode 100644 admin/models/fields/fieldsfilternullswitch.php delete mode 100644 admin/models/fields/fieldsfilterstore.php delete mode 100644 admin/models/fields/fieldtypes.php delete mode 100644 admin/models/fields/filebehaviour.php delete mode 100644 admin/models/fields/helpdocumentsfilterlocation.php delete mode 100644 admin/models/fields/helpdocumentsfiltertype.php delete mode 100644 admin/models/fields/interfacepowers.php delete mode 100644 admin/models/fields/joinfields.php delete mode 100644 admin/models/fields/joomlacomponent.php delete mode 100644 admin/models/fields/joomlacomponents.php delete mode 100644 admin/models/fields/joomlacomponentsfilterauthor.php delete mode 100644 admin/models/fields/joomlacomponentsfiltercompanyname.php delete mode 100644 admin/models/fields/joomlamodules.php delete mode 100644 admin/models/fields/joomlamodulesfiltertarget.php delete mode 100644 admin/models/fields/joomlaplugingroups.php delete mode 100644 admin/models/fields/joomlaplugins.php delete mode 100644 admin/models/fields/lang.php delete mode 100644 admin/models/fields/layoutsfilteraddphpview.php delete mode 100644 admin/models/fields/libconfigfield.php delete mode 100644 admin/models/fields/libraries.php delete mode 100644 admin/models/fields/librariesfiltertarget.php delete mode 100644 admin/models/fields/librariesfiltertype.php delete mode 100644 admin/models/fields/librariesx.php delete mode 100644 admin/models/fields/library.php delete mode 100644 admin/models/fields/libraryfiles.php delete mode 100644 admin/models/fields/libraryreadonly.php delete mode 100644 admin/models/fields/linkedviewsorderfields.php delete mode 100644 admin/models/fields/listfields.php delete mode 100644 admin/models/fields/maingets.php delete mode 100644 admin/models/fields/matchfield.php delete mode 100644 admin/models/fields/namespaces.php delete mode 100644 admin/models/fields/pluginsclassmethods.php delete mode 100644 admin/models/fields/pluginsclassproperties.php delete mode 100644 admin/models/fields/powers.php delete mode 100644 admin/models/fields/powersclassmethods.php delete mode 100644 admin/models/fields/powersclassproperties.php delete mode 100644 admin/models/fields/powersfilterapproved.php delete mode 100644 admin/models/fields/powersfiltertype.php delete mode 100644 admin/models/fields/servers.php delete mode 100644 admin/models/fields/serversfiltername.php delete mode 100644 admin/models/fields/serversfilterprotocol.php delete mode 100644 admin/models/fields/siteviewfolderlist.php delete mode 100644 admin/models/fields/siteviews.php delete mode 100644 admin/models/fields/siteviewsfilteraddcustombutton.php delete mode 100644 admin/models/fields/siteviewsfilteraddphpajax.php delete mode 100644 admin/models/fields/snippets.php delete mode 100644 admin/models/fields/snippettype.php delete mode 100644 admin/models/fields/superpowerpaths.php delete mode 100644 admin/models/fields/targetfields.php delete mode 100644 admin/models/fields/templatesfilteraddphpview.php delete mode 100644 admin/models/fields/viewtabs.php delete mode 100644 admin/models/fieldtype.php delete mode 100644 admin/models/fieldtypes.php delete mode 100644 admin/models/forms/filter_admins_custom_tabs.xml delete mode 100644 admin/models/forms/filter_admins_fields.xml delete mode 100644 admin/models/forms/filter_admins_fields_conditions.xml delete mode 100644 admin/models/forms/filter_admins_fields_relations.xml delete mode 100644 admin/models/forms/filter_class_extendings.xml delete mode 100644 admin/models/forms/filter_components_admin_views.xml delete mode 100644 admin/models/forms/filter_components_config.xml delete mode 100644 admin/models/forms/filter_components_custom_admin_menus.xml delete mode 100644 admin/models/forms/filter_components_custom_admin_views.xml delete mode 100644 admin/models/forms/filter_components_dashboard.xml delete mode 100644 admin/models/forms/filter_components_files_folders.xml delete mode 100644 admin/models/forms/filter_components_modules.xml delete mode 100644 admin/models/forms/filter_components_mysql_tweaks.xml delete mode 100644 admin/models/forms/filter_components_placeholders.xml delete mode 100644 admin/models/forms/filter_components_plugins.xml delete mode 100644 admin/models/forms/filter_components_site_views.xml delete mode 100644 admin/models/forms/filter_components_updates.xml delete mode 100644 admin/models/forms/filter_help_documents.xml delete mode 100644 admin/models/forms/filter_joomla_modules.xml delete mode 100644 admin/models/forms/filter_joomla_modules_files_folders_urls.xml delete mode 100644 admin/models/forms/filter_joomla_modules_updates.xml delete mode 100644 admin/models/forms/filter_joomla_plugin_groups.xml delete mode 100644 admin/models/forms/filter_joomla_plugins_files_folders_urls.xml delete mode 100644 admin/models/forms/filter_joomla_plugins_updates.xml delete mode 100644 admin/models/forms/filter_language_translations.xml delete mode 100644 admin/models/forms/filter_languages.xml delete mode 100644 admin/models/forms/filter_libraries_config.xml delete mode 100644 admin/models/forms/filter_libraries_files_folders_urls.xml delete mode 100644 admin/models/forms/filter_placeholders.xml delete mode 100644 admin/models/forms/filter_servers.xml delete mode 100644 admin/models/forms/filter_snippet_types.xml delete mode 100644 admin/models/forms/filter_validation_rules.xml delete mode 100644 admin/models/get_snippets.php delete mode 100644 admin/models/help_document.php delete mode 100644 admin/models/help_documents.php delete mode 100644 admin/models/import.php delete mode 100644 admin/models/import_joomla_components.php delete mode 100644 admin/models/import_language_translations.php delete mode 100644 admin/models/joomla_component.php delete mode 100644 admin/models/joomla_components.php delete mode 100644 admin/models/joomla_module.php delete mode 100644 admin/models/joomla_module_files_folders_urls.php delete mode 100644 admin/models/joomla_module_updates.php delete mode 100644 admin/models/joomla_modules.php delete mode 100644 admin/models/joomla_modules_files_folders_urls.php delete mode 100644 admin/models/joomla_modules_updates.php delete mode 100644 admin/models/joomla_plugin.php delete mode 100644 admin/models/joomla_plugin_files_folders_urls.php delete mode 100644 admin/models/joomla_plugin_group.php delete mode 100644 admin/models/joomla_plugin_groups.php delete mode 100644 admin/models/joomla_plugin_updates.php delete mode 100644 admin/models/joomla_plugins.php delete mode 100644 admin/models/joomla_plugins_files_folders_urls.php delete mode 100644 admin/models/joomla_plugins_updates.php delete mode 100644 admin/models/language.php delete mode 100644 admin/models/language_translation.php delete mode 100644 admin/models/language_translations.php delete mode 100644 admin/models/languages.php delete mode 100644 admin/models/layout.php delete mode 100644 admin/models/layouts.php delete mode 100644 admin/models/libraries.php delete mode 100644 admin/models/libraries_config.php delete mode 100644 admin/models/libraries_files_folders_urls.php delete mode 100644 admin/models/library.php delete mode 100644 admin/models/library_config.php delete mode 100644 admin/models/library_files_folders_urls.php delete mode 100644 admin/models/placeholder.php delete mode 100644 admin/models/placeholders.php delete mode 100644 admin/models/power.php delete mode 100644 admin/models/powers.php delete mode 100644 admin/models/rules/code.php delete mode 100644 admin/models/rules/guid.php delete mode 100644 admin/models/rules/int.php delete mode 100644 admin/models/rules/uniqueplaceholder.php delete mode 100644 admin/models/search.php delete mode 100644 admin/models/server.php delete mode 100644 admin/models/servers.php delete mode 100644 admin/models/site_view.php delete mode 100644 admin/models/site_views.php delete mode 100644 admin/models/snippet.php delete mode 100644 admin/models/snippet_type.php delete mode 100644 admin/models/snippet_types.php delete mode 100644 admin/models/snippets.php delete mode 100644 admin/models/template.php delete mode 100644 admin/models/templates.php delete mode 100644 admin/models/validation_rule.php delete mode 100644 admin/models/validation_rules.php rename admin/{helpers/html => presets}/index.html (100%) rename admin/{helpers => services}/index.html (100%) create mode 100644 admin/services/provider.php delete mode 100644 admin/sql/updates/mysql/2.10.1.sql delete mode 100644 admin/sql/updates/mysql/2.10.10.sql delete mode 100644 admin/sql/updates/mysql/2.10.11.sql delete mode 100644 admin/sql/updates/mysql/2.10.12.sql delete mode 100644 admin/sql/updates/mysql/2.10.2.sql delete mode 100644 admin/sql/updates/mysql/2.10.5.sql delete mode 100644 admin/sql/updates/mysql/2.10.6.sql delete mode 100644 admin/sql/updates/mysql/2.10.7.sql delete mode 100644 admin/sql/updates/mysql/2.10.9.sql delete mode 100644 admin/sql/updates/mysql/2.11.4.sql delete mode 100644 admin/sql/updates/mysql/2.11.5.sql delete mode 100644 admin/sql/updates/mysql/2.12.1.sql delete mode 100644 admin/sql/updates/mysql/2.12.10.sql delete mode 100644 admin/sql/updates/mysql/2.12.16.sql delete mode 100644 admin/sql/updates/mysql/2.12.4.sql delete mode 100644 admin/sql/updates/mysql/2.13.1.sql delete mode 100644 admin/sql/updates/mysql/2.5.1.sql delete mode 100644 admin/sql/updates/mysql/2.5.2.sql delete mode 100644 admin/sql/updates/mysql/2.5.3.sql delete mode 100644 admin/sql/updates/mysql/2.5.5.sql delete mode 100644 admin/sql/updates/mysql/2.5.6.sql delete mode 100644 admin/sql/updates/mysql/2.5.7.sql delete mode 100644 admin/sql/updates/mysql/2.5.8.sql delete mode 100644 admin/sql/updates/mysql/2.6.11.sql delete mode 100644 admin/sql/updates/mysql/2.6.12.sql delete mode 100644 admin/sql/updates/mysql/2.6.13.sql delete mode 100644 admin/sql/updates/mysql/2.6.14.sql delete mode 100644 admin/sql/updates/mysql/2.6.16.sql delete mode 100644 admin/sql/updates/mysql/2.6.17.sql delete mode 100644 admin/sql/updates/mysql/2.6.3.sql delete mode 100644 admin/sql/updates/mysql/2.6.4.sql delete mode 100644 admin/sql/updates/mysql/2.6.5.sql delete mode 100644 admin/sql/updates/mysql/2.6.6.sql delete mode 100644 admin/sql/updates/mysql/2.6.9.sql delete mode 100644 admin/sql/updates/mysql/2.7.0.sql delete mode 100644 admin/sql/updates/mysql/2.7.10.sql delete mode 100644 admin/sql/updates/mysql/2.7.5.sql delete mode 100644 admin/sql/updates/mysql/2.7.8.sql delete mode 100644 admin/sql/updates/mysql/2.7.9.sql delete mode 100644 admin/sql/updates/mysql/2.8.1.sql delete mode 100644 admin/sql/updates/mysql/2.8.2.sql delete mode 100644 admin/sql/updates/mysql/2.8.5.sql delete mode 100644 admin/sql/updates/mysql/2.8.6.sql delete mode 100644 admin/sql/updates/mysql/2.8.7.sql delete mode 100644 admin/sql/updates/mysql/2.8.8.sql delete mode 100644 admin/sql/updates/mysql/2.8.9.sql delete mode 100644 admin/sql/updates/mysql/2.9.1.sql delete mode 100644 admin/sql/updates/mysql/2.9.11.sql delete mode 100644 admin/sql/updates/mysql/2.9.12.sql delete mode 100644 admin/sql/updates/mysql/2.9.14.sql delete mode 100644 admin/sql/updates/mysql/2.9.15.sql delete mode 100644 admin/sql/updates/mysql/2.9.16.sql delete mode 100644 admin/sql/updates/mysql/2.9.18.sql delete mode 100644 admin/sql/updates/mysql/2.9.19.sql delete mode 100644 admin/sql/updates/mysql/2.9.21.sql delete mode 100644 admin/sql/updates/mysql/2.9.31.sql delete mode 100644 admin/sql/updates/mysql/2.9.32.sql delete mode 100644 admin/sql/updates/mysql/2.9.33.sql delete mode 100644 admin/sql/updates/mysql/2.9.34.sql delete mode 100644 admin/sql/updates/mysql/2.9.35.sql delete mode 100644 admin/sql/updates/mysql/2.9.4.sql delete mode 100644 admin/sql/updates/mysql/2.9.8.sql delete mode 100644 admin/sql/updates/mysql/2.9.9.sql delete mode 100644 admin/sql/updates/mysql/3.1.12.sql delete mode 100644 admin/sql/updates/mysql/3.1.21.sql delete mode 100644 admin/sql/updates/mysql/3.1.25.sql delete mode 100644 admin/sql/updates/mysql/3.1.26.sql delete mode 100644 admin/sql/updates/mysql/3.1.27.sql delete mode 100644 admin/sql/updates/mysql/3.1.5.sql rename admin/sql/updates/mysql/{3.1.19.sql => 3.2.0-beta4.sql} (100%) rename admin/sql/updates/mysql/{3.1.24.sql => 4.0.0-alpha1.sql} (100%) rename admin/{layouts => sql/xml}/index.html (100%) create mode 100644 admin/src/Controller/Admin_custom_tabsController.php create mode 100644 admin/src/Controller/Admin_fieldsController.php create mode 100644 admin/src/Controller/Admin_fields_conditionsController.php create mode 100644 admin/src/Controller/Admin_fields_relationsController.php create mode 100644 admin/src/Controller/Admin_viewController.php create mode 100644 admin/src/Controller/Admin_viewsController.php create mode 100644 admin/src/Controller/Admins_custom_tabsController.php create mode 100644 admin/src/Controller/Admins_fieldsController.php create mode 100644 admin/src/Controller/Admins_fields_conditionsController.php create mode 100644 admin/src/Controller/Admins_fields_relationsController.php create mode 100644 admin/src/Controller/AjaxController.php create mode 100644 admin/src/Controller/Class_extendingsController.php create mode 100644 admin/src/Controller/Class_extendsController.php create mode 100644 admin/src/Controller/Class_methodController.php create mode 100644 admin/src/Controller/Class_methodsController.php create mode 100644 admin/src/Controller/Class_propertiesController.php create mode 100644 admin/src/Controller/Class_propertyController.php create mode 100644 admin/src/Controller/CompilerController.php create mode 100644 admin/src/Controller/Component_admin_viewsController.php create mode 100644 admin/src/Controller/Component_configController.php create mode 100644 admin/src/Controller/Component_custom_admin_menusController.php create mode 100644 admin/src/Controller/Component_custom_admin_viewsController.php create mode 100644 admin/src/Controller/Component_dashboardController.php create mode 100644 admin/src/Controller/Component_files_foldersController.php create mode 100644 admin/src/Controller/Component_modulesController.php create mode 100644 admin/src/Controller/Component_mysql_tweaksController.php create mode 100644 admin/src/Controller/Component_placeholdersController.php create mode 100644 admin/src/Controller/Component_pluginsController.php create mode 100644 admin/src/Controller/Component_routerController.php create mode 100644 admin/src/Controller/Component_site_viewsController.php create mode 100644 admin/src/Controller/Component_updatesController.php create mode 100644 admin/src/Controller/ComponentbuilderController.php create mode 100644 admin/src/Controller/Components_admin_viewsController.php create mode 100644 admin/src/Controller/Components_configController.php create mode 100644 admin/src/Controller/Components_custom_admin_menusController.php create mode 100644 admin/src/Controller/Components_custom_admin_viewsController.php create mode 100644 admin/src/Controller/Components_dashboardController.php create mode 100644 admin/src/Controller/Components_files_foldersController.php create mode 100644 admin/src/Controller/Components_modulesController.php create mode 100644 admin/src/Controller/Components_mysql_tweaksController.php create mode 100644 admin/src/Controller/Components_placeholdersController.php create mode 100644 admin/src/Controller/Components_pluginsController.php create mode 100644 admin/src/Controller/Components_routersController.php create mode 100644 admin/src/Controller/Components_site_viewsController.php create mode 100644 admin/src/Controller/Components_updatesController.php create mode 100644 admin/src/Controller/Custom_admin_viewController.php create mode 100644 admin/src/Controller/Custom_admin_viewsController.php create mode 100644 admin/src/Controller/Custom_codeController.php create mode 100644 admin/src/Controller/Custom_codesController.php create mode 100644 admin/src/Controller/DisplayController.php create mode 100644 admin/src/Controller/Dynamic_getController.php create mode 100644 admin/src/Controller/Dynamic_getsController.php create mode 100644 admin/src/Controller/FieldController.php create mode 100644 admin/src/Controller/FieldsController.php create mode 100644 admin/src/Controller/FieldtypeController.php create mode 100644 admin/src/Controller/FieldtypesController.php create mode 100644 admin/src/Controller/Get_snippetsController.php create mode 100644 admin/src/Controller/HelpController.php create mode 100644 admin/src/Controller/Help_documentController.php create mode 100644 admin/src/Controller/Help_documentsController.php create mode 100644 admin/src/Controller/ImportController.php create mode 100644 admin/src/Controller/Import_joomla_componentsimportController.php create mode 100644 admin/src/Controller/Import_language_translationsimportController.php create mode 100644 admin/src/Controller/Joomla_componentController.php create mode 100644 admin/src/Controller/Joomla_componentsController.php create mode 100644 admin/src/Controller/Joomla_moduleController.php create mode 100644 admin/src/Controller/Joomla_module_files_folders_urlsController.php create mode 100644 admin/src/Controller/Joomla_module_updatesController.php create mode 100644 admin/src/Controller/Joomla_modulesController.php create mode 100644 admin/src/Controller/Joomla_modules_files_folders_urlsController.php create mode 100644 admin/src/Controller/Joomla_modules_updatesController.php create mode 100644 admin/src/Controller/Joomla_pluginController.php create mode 100644 admin/src/Controller/Joomla_plugin_files_folders_urlsController.php create mode 100644 admin/src/Controller/Joomla_plugin_groupController.php create mode 100644 admin/src/Controller/Joomla_plugin_groupsController.php create mode 100644 admin/src/Controller/Joomla_plugin_updatesController.php create mode 100644 admin/src/Controller/Joomla_pluginsController.php create mode 100644 admin/src/Controller/Joomla_plugins_files_folders_urlsController.php create mode 100644 admin/src/Controller/Joomla_plugins_updatesController.php create mode 100644 admin/src/Controller/LanguageController.php create mode 100644 admin/src/Controller/Language_translationController.php create mode 100644 admin/src/Controller/Language_translationsController.php create mode 100644 admin/src/Controller/LanguagesController.php create mode 100644 admin/src/Controller/LayoutController.php create mode 100644 admin/src/Controller/LayoutsController.php create mode 100644 admin/src/Controller/LibrariesController.php create mode 100644 admin/src/Controller/Libraries_configController.php create mode 100644 admin/src/Controller/Libraries_files_folders_urlsController.php create mode 100644 admin/src/Controller/LibraryController.php create mode 100644 admin/src/Controller/Library_configController.php create mode 100644 admin/src/Controller/Library_files_folders_urlsController.php create mode 100644 admin/src/Controller/PlaceholderController.php create mode 100644 admin/src/Controller/PlaceholdersController.php create mode 100644 admin/src/Controller/PowerController.php create mode 100644 admin/src/Controller/PowersController.php create mode 100644 admin/src/Controller/SearchController.php create mode 100644 admin/src/Controller/ServerController.php create mode 100644 admin/src/Controller/ServersController.php create mode 100644 admin/src/Controller/Site_viewController.php create mode 100644 admin/src/Controller/Site_viewsController.php create mode 100644 admin/src/Controller/SnippetController.php create mode 100644 admin/src/Controller/Snippet_typeController.php create mode 100644 admin/src/Controller/Snippet_typesController.php create mode 100644 admin/src/Controller/SnippetsController.php create mode 100644 admin/src/Controller/TemplateController.php create mode 100644 admin/src/Controller/TemplatesController.php create mode 100644 admin/src/Controller/Validation_ruleController.php create mode 100644 admin/src/Controller/Validation_rulesController.php rename admin/{models/fields => src/Controller}/index.html (100%) create mode 100644 admin/src/Extension/ComponentbuilderComponent.php rename admin/{models/forms => src/Extension}/index.html (100%) create mode 100644 admin/src/Field/AdminsviewsField.php create mode 100644 admin/src/Field/AdminviewfolderlistField.php create mode 100644 admin/src/Field/AdminviewsField.php create mode 100644 admin/src/Field/AdminviewsfilteraddcustombuttonField.php create mode 100644 admin/src/Field/AdminviewsfilteraddcustomimportField.php create mode 100644 admin/src/Field/AdminviewsfilteraddfadeinField.php create mode 100644 admin/src/Field/AdminviewsfilteraddphpajaxField.php create mode 100644 admin/src/Field/AdminviewsfiltertypeField.php create mode 100644 admin/src/Field/AdminviewsreadonlyField.php create mode 100644 admin/src/Field/AliasbuilderField.php create mode 100644 admin/src/Field/ArticlesField.php create mode 100644 admin/src/Field/ClassextendingsfilterextensiontypeField.php create mode 100644 admin/src/Field/ClassextendsField.php create mode 100644 admin/src/Field/ClassmethodsfilterextensiontypeField.php create mode 100644 admin/src/Field/ClassmethodsfiltervisibilityField.php create mode 100644 admin/src/Field/ClasspowersField.php create mode 100644 admin/src/Field/ClasspropertiesfilterextensiontypeField.php create mode 100644 admin/src/Field/ClasspropertiesfiltervisibilityField.php create mode 100644 admin/src/Field/ComponentadminmenusField.php create mode 100644 admin/src/Field/ComponentadminviewsField.php create mode 100644 admin/src/Field/ComponentsroutersfiltermodeconstructorafterparentField.php create mode 100644 admin/src/Field/ComponentsroutersfiltermodeconstructorbeforeparentField.php create mode 100644 admin/src/Field/ComponentsroutersfiltermodemethodsField.php create mode 100644 admin/src/Field/CustomadminviewsField.php create mode 100644 admin/src/Field/CustomadminviewsfilteraddcustombuttonField.php create mode 100644 admin/src/Field/CustomadminviewsfilteraddphpajaxField.php create mode 100644 admin/src/Field/CustomcodesfiltercommenttypeField.php create mode 100644 admin/src/Field/CustomcodesfiltertargetField.php create mode 100644 admin/src/Field/CustomcodesfiltertypeField.php create mode 100644 admin/src/Field/CustomfilelistField.php create mode 100644 admin/src/Field/CustomfolderlistField.php create mode 100644 admin/src/Field/CustomgetsField.php create mode 100644 admin/src/Field/DbtablesField.php create mode 100644 admin/src/Field/DynamicdashboardField.php create mode 100644 admin/src/Field/DynamicgetField.php create mode 100644 admin/src/Field/DynamicgetsField.php create mode 100644 admin/src/Field/DynamicgetsfiltergettypeField.php create mode 100644 admin/src/Field/DynamicgetsfiltermainsourceField.php create mode 100644 admin/src/Field/ExistingvalidationrulesField.php create mode 100644 admin/src/Field/FieldsField.php create mode 100644 admin/src/Field/FieldsfilterdatatypeField.php create mode 100644 admin/src/Field/FieldsfilterindexesField.php create mode 100644 admin/src/Field/FieldsfilternullswitchField.php create mode 100644 admin/src/Field/FieldsfilterstoreField.php create mode 100644 admin/src/Field/FieldtypesField.php create mode 100644 admin/src/Field/FilebehaviourField.php create mode 100644 admin/src/Field/HelpdocumentsfilterlocationField.php create mode 100644 admin/src/Field/HelpdocumentsfiltertypeField.php create mode 100644 admin/src/Field/InterfacepowersField.php create mode 100644 admin/src/Field/JoinfieldsField.php create mode 100644 admin/src/Field/JoomlacomponentField.php create mode 100644 admin/src/Field/JoomlacomponentsField.php create mode 100644 admin/src/Field/JoomlacomponentsfilterauthorField.php create mode 100644 admin/src/Field/JoomlacomponentsfiltercompanynameField.php create mode 100644 admin/src/Field/JoomlamodulesField.php create mode 100644 admin/src/Field/JoomlamodulesfiltertargetField.php create mode 100644 admin/src/Field/JoomlaplugingroupsField.php create mode 100644 admin/src/Field/JoomlapluginsField.php create mode 100644 admin/src/Field/LangField.php create mode 100644 admin/src/Field/LayoutsfilteraddphpviewField.php create mode 100644 admin/src/Field/LibconfigfieldField.php create mode 100644 admin/src/Field/LibrariesField.php create mode 100644 admin/src/Field/LibrariesfiltertargetField.php create mode 100644 admin/src/Field/LibrariesfiltertypeField.php create mode 100644 admin/src/Field/LibrariesxField.php create mode 100644 admin/src/Field/LibraryField.php create mode 100644 admin/src/Field/LibraryfilesField.php create mode 100644 admin/src/Field/LibraryreadonlyField.php create mode 100644 admin/src/Field/ListfieldsField.php create mode 100644 admin/src/Field/MaingetsField.php create mode 100644 admin/src/Field/MatchfieldField.php create mode 100644 admin/src/Field/NamespacesField.php create mode 100644 admin/src/Field/PluginsclassmethodsField.php create mode 100644 admin/src/Field/PluginsclasspropertiesField.php create mode 100644 admin/src/Field/PowersclassmethodsField.php create mode 100644 admin/src/Field/PowersclasspropertiesField.php create mode 100644 admin/src/Field/PowersfilterapprovedField.php create mode 100644 admin/src/Field/PowersfiltertypeField.php create mode 100644 admin/src/Field/ServersField.php create mode 100644 admin/src/Field/ServersfilternameField.php create mode 100644 admin/src/Field/ServersfilterprotocolField.php create mode 100644 admin/src/Field/SiteviewfolderlistField.php create mode 100644 admin/src/Field/SiteviewsField.php create mode 100644 admin/src/Field/SiteviewsfilteraddcustombuttonField.php create mode 100644 admin/src/Field/SiteviewsfilteraddphpajaxField.php create mode 100644 admin/src/Field/SnippetsField.php create mode 100644 admin/src/Field/SnippettypeField.php create mode 100644 admin/src/Field/SuperpowerpathsField.php create mode 100644 admin/src/Field/TargetfieldsField.php create mode 100644 admin/src/Field/TemplatesfilteraddphpviewField.php create mode 100644 admin/src/Field/ViewtabsField.php rename admin/{models => src/Field}/index.html (100%) create mode 100644 admin/src/Helper/ComponentbuilderEmail.php create mode 100644 admin/src/Helper/ComponentbuilderHelper.php create mode 100644 admin/src/Helper/HeaderCheck.php rename admin/{models/rules => src/Helper}/index.html (100%) create mode 100644 admin/src/Model/Admin_custom_tabsModel.php create mode 100644 admin/src/Model/Admin_fieldsModel.php create mode 100644 admin/src/Model/Admin_fields_conditionsModel.php create mode 100644 admin/src/Model/Admin_fields_relationsModel.php create mode 100644 admin/src/Model/Admin_viewModel.php create mode 100644 admin/src/Model/Admin_viewsModel.php create mode 100644 admin/src/Model/Admins_custom_tabsModel.php create mode 100644 admin/src/Model/Admins_fieldsModel.php create mode 100644 admin/src/Model/Admins_fields_conditionsModel.php create mode 100644 admin/src/Model/Admins_fields_relationsModel.php create mode 100644 admin/src/Model/AjaxModel.php create mode 100644 admin/src/Model/Class_extendingsModel.php create mode 100644 admin/src/Model/Class_extendsModel.php create mode 100644 admin/src/Model/Class_methodModel.php create mode 100644 admin/src/Model/Class_methodsModel.php create mode 100644 admin/src/Model/Class_propertiesModel.php create mode 100644 admin/src/Model/Class_propertyModel.php create mode 100644 admin/src/Model/CompilerModel.php create mode 100644 admin/src/Model/Component_admin_viewsModel.php create mode 100644 admin/src/Model/Component_configModel.php create mode 100644 admin/src/Model/Component_custom_admin_menusModel.php create mode 100644 admin/src/Model/Component_custom_admin_viewsModel.php create mode 100644 admin/src/Model/Component_dashboardModel.php create mode 100644 admin/src/Model/Component_files_foldersModel.php create mode 100644 admin/src/Model/Component_modulesModel.php create mode 100644 admin/src/Model/Component_mysql_tweaksModel.php create mode 100644 admin/src/Model/Component_placeholdersModel.php create mode 100644 admin/src/Model/Component_pluginsModel.php create mode 100644 admin/src/Model/Component_routerModel.php create mode 100644 admin/src/Model/Component_site_viewsModel.php create mode 100644 admin/src/Model/Component_updatesModel.php create mode 100644 admin/src/Model/ComponentbuilderModel.php create mode 100644 admin/src/Model/Components_admin_viewsModel.php create mode 100644 admin/src/Model/Components_configModel.php create mode 100644 admin/src/Model/Components_custom_admin_menusModel.php create mode 100644 admin/src/Model/Components_custom_admin_viewsModel.php create mode 100644 admin/src/Model/Components_dashboardModel.php create mode 100644 admin/src/Model/Components_files_foldersModel.php create mode 100644 admin/src/Model/Components_modulesModel.php create mode 100644 admin/src/Model/Components_mysql_tweaksModel.php create mode 100644 admin/src/Model/Components_placeholdersModel.php create mode 100644 admin/src/Model/Components_pluginsModel.php create mode 100644 admin/src/Model/Components_routersModel.php create mode 100644 admin/src/Model/Components_site_viewsModel.php create mode 100644 admin/src/Model/Components_updatesModel.php create mode 100644 admin/src/Model/Custom_admin_viewModel.php create mode 100644 admin/src/Model/Custom_admin_viewsModel.php create mode 100644 admin/src/Model/Custom_codeModel.php create mode 100644 admin/src/Model/Custom_codesModel.php create mode 100644 admin/src/Model/Dynamic_getModel.php create mode 100644 admin/src/Model/Dynamic_getsModel.php create mode 100644 admin/src/Model/FieldModel.php create mode 100644 admin/src/Model/FieldsModel.php create mode 100644 admin/src/Model/FieldtypeModel.php create mode 100644 admin/src/Model/FieldtypesModel.php create mode 100644 admin/src/Model/Get_snippetsModel.php create mode 100644 admin/src/Model/Help_documentModel.php create mode 100644 admin/src/Model/Help_documentsModel.php create mode 100644 admin/src/Model/ImportModel.php create mode 100644 admin/src/Model/Import_joomla_componentsimportModel.php create mode 100644 admin/src/Model/Import_language_translationsimportModel.php create mode 100644 admin/src/Model/Joomla_componentModel.php create mode 100644 admin/src/Model/Joomla_componentsModel.php create mode 100644 admin/src/Model/Joomla_moduleModel.php create mode 100644 admin/src/Model/Joomla_module_files_folders_urlsModel.php create mode 100644 admin/src/Model/Joomla_module_updatesModel.php create mode 100644 admin/src/Model/Joomla_modulesModel.php create mode 100644 admin/src/Model/Joomla_modules_files_folders_urlsModel.php create mode 100644 admin/src/Model/Joomla_modules_updatesModel.php create mode 100644 admin/src/Model/Joomla_pluginModel.php create mode 100644 admin/src/Model/Joomla_plugin_files_folders_urlsModel.php create mode 100644 admin/src/Model/Joomla_plugin_groupModel.php create mode 100644 admin/src/Model/Joomla_plugin_groupsModel.php create mode 100644 admin/src/Model/Joomla_plugin_updatesModel.php create mode 100644 admin/src/Model/Joomla_pluginsModel.php create mode 100644 admin/src/Model/Joomla_plugins_files_folders_urlsModel.php create mode 100644 admin/src/Model/Joomla_plugins_updatesModel.php create mode 100644 admin/src/Model/LanguageModel.php create mode 100644 admin/src/Model/Language_translationModel.php create mode 100644 admin/src/Model/Language_translationsModel.php create mode 100644 admin/src/Model/LanguagesModel.php create mode 100644 admin/src/Model/LayoutModel.php create mode 100644 admin/src/Model/LayoutsModel.php create mode 100644 admin/src/Model/LibrariesModel.php create mode 100644 admin/src/Model/Libraries_configModel.php create mode 100644 admin/src/Model/Libraries_files_folders_urlsModel.php create mode 100644 admin/src/Model/LibraryModel.php create mode 100644 admin/src/Model/Library_configModel.php create mode 100644 admin/src/Model/Library_files_folders_urlsModel.php create mode 100644 admin/src/Model/PlaceholderModel.php create mode 100644 admin/src/Model/PlaceholdersModel.php create mode 100644 admin/src/Model/PowerModel.php create mode 100644 admin/src/Model/PowersModel.php create mode 100644 admin/src/Model/SearchModel.php create mode 100644 admin/src/Model/ServerModel.php create mode 100644 admin/src/Model/ServersModel.php create mode 100644 admin/src/Model/Site_viewModel.php create mode 100644 admin/src/Model/Site_viewsModel.php create mode 100644 admin/src/Model/SnippetModel.php create mode 100644 admin/src/Model/Snippet_typeModel.php create mode 100644 admin/src/Model/Snippet_typesModel.php create mode 100644 admin/src/Model/SnippetsModel.php create mode 100644 admin/src/Model/TemplateModel.php create mode 100644 admin/src/Model/TemplatesModel.php create mode 100644 admin/src/Model/Validation_ruleModel.php create mode 100644 admin/src/Model/Validation_rulesModel.php rename admin/{tables => src/Model}/index.html (100%) create mode 100644 admin/src/Rule/CodeRule.php create mode 100644 admin/src/Rule/GuidRule.php create mode 100644 admin/src/Rule/IntRule.php create mode 100644 admin/src/Rule/SourcemapcheckerRule.php create mode 100644 admin/src/Rule/UniqueplaceholderRule.php rename admin/{views/admin_custom_tabs/tmpl => src/Rule}/index.html (100%) rename admin/{views/admin_fields/tmpl => src/Service}/index.html (100%) create mode 100644 admin/src/Table/Admin_custom_tabsTable.php create mode 100644 admin/src/Table/Admin_fieldsTable.php create mode 100644 admin/src/Table/Admin_fields_conditionsTable.php create mode 100644 admin/src/Table/Admin_fields_relationsTable.php create mode 100644 admin/src/Table/Admin_viewTable.php create mode 100644 admin/src/Table/Class_extendsTable.php create mode 100644 admin/src/Table/Class_methodTable.php create mode 100644 admin/src/Table/Class_propertyTable.php create mode 100644 admin/src/Table/Component_admin_viewsTable.php create mode 100644 admin/src/Table/Component_configTable.php create mode 100644 admin/src/Table/Component_custom_admin_menusTable.php create mode 100644 admin/src/Table/Component_custom_admin_viewsTable.php create mode 100644 admin/src/Table/Component_dashboardTable.php create mode 100644 admin/src/Table/Component_files_foldersTable.php create mode 100644 admin/src/Table/Component_modulesTable.php create mode 100644 admin/src/Table/Component_mysql_tweaksTable.php create mode 100644 admin/src/Table/Component_placeholdersTable.php create mode 100644 admin/src/Table/Component_pluginsTable.php create mode 100644 admin/src/Table/Component_routerTable.php create mode 100644 admin/src/Table/Component_site_viewsTable.php create mode 100644 admin/src/Table/Component_updatesTable.php create mode 100644 admin/src/Table/Custom_admin_viewTable.php create mode 100644 admin/src/Table/Custom_codeTable.php create mode 100644 admin/src/Table/Dynamic_getTable.php create mode 100644 admin/src/Table/FieldTable.php create mode 100644 admin/src/Table/FieldtypeTable.php create mode 100644 admin/src/Table/Help_documentTable.php create mode 100644 admin/src/Table/Joomla_componentTable.php create mode 100644 admin/src/Table/Joomla_moduleTable.php create mode 100644 admin/src/Table/Joomla_module_files_folders_urlsTable.php create mode 100644 admin/src/Table/Joomla_module_updatesTable.php create mode 100644 admin/src/Table/Joomla_pluginTable.php create mode 100644 admin/src/Table/Joomla_plugin_files_folders_urlsTable.php create mode 100644 admin/src/Table/Joomla_plugin_groupTable.php create mode 100644 admin/src/Table/Joomla_plugin_updatesTable.php create mode 100644 admin/src/Table/LanguageTable.php create mode 100644 admin/src/Table/Language_translationTable.php create mode 100644 admin/src/Table/LayoutTable.php create mode 100644 admin/src/Table/LibraryTable.php create mode 100644 admin/src/Table/Library_configTable.php create mode 100644 admin/src/Table/Library_files_folders_urlsTable.php create mode 100644 admin/src/Table/PlaceholderTable.php create mode 100644 admin/src/Table/PowerTable.php create mode 100644 admin/src/Table/ServerTable.php create mode 100644 admin/src/Table/Site_viewTable.php create mode 100644 admin/src/Table/SnippetTable.php create mode 100644 admin/src/Table/Snippet_typeTable.php create mode 100644 admin/src/Table/TemplateTable.php create mode 100644 admin/src/Table/Validation_ruleTable.php rename admin/{views/admin_fields_conditions/tmpl => src/Table}/index.html (100%) create mode 100644 admin/src/View/Admin_custom_tabs/HtmlView.php rename admin/{views/admin_fields_relations/tmpl => src/View/Admin_custom_tabs}/index.html (100%) create mode 100644 admin/src/View/Admin_fields/HtmlView.php rename admin/{views/admin_view/tmpl => src/View/Admin_fields}/index.html (100%) create mode 100644 admin/src/View/Admin_fields_conditions/HtmlView.php rename admin/{views/admin_views => src/View/Admin_fields_conditions}/index.html (100%) create mode 100644 admin/src/View/Admin_fields_relations/HtmlView.php rename admin/{views/admin_views/tmpl => src/View/Admin_fields_relations}/index.html (100%) create mode 100644 admin/src/View/Admin_view/HtmlView.php rename admin/{views/admins_custom_tabs => src/View/Admin_view}/index.html (100%) create mode 100644 admin/src/View/Admin_views/HtmlView.php rename admin/{views/admins_custom_tabs/tmpl => src/View/Admin_views}/index.html (100%) create mode 100644 admin/src/View/Admins_custom_tabs/HtmlView.php rename admin/{views/admins_fields => src/View/Admins_custom_tabs}/index.html (100%) create mode 100644 admin/src/View/Admins_fields/HtmlView.php rename admin/{views/admins_fields/tmpl => src/View/Admins_fields}/index.html (100%) create mode 100644 admin/src/View/Admins_fields_conditions/HtmlView.php rename admin/{views/admins_fields_conditions => src/View/Admins_fields_conditions}/index.html (100%) create mode 100644 admin/src/View/Admins_fields_relations/HtmlView.php rename admin/{views/admins_fields_conditions/tmpl => src/View/Admins_fields_relations}/index.html (100%) create mode 100644 admin/src/View/Class_extendings/HtmlView.php rename admin/{views/admins_fields_relations => src/View/Class_extendings}/index.html (100%) create mode 100644 admin/src/View/Class_extends/HtmlView.php rename admin/{views/admins_fields_relations/tmpl => src/View/Class_extends}/index.html (100%) create mode 100644 admin/src/View/Class_method/HtmlView.php rename admin/{views/class_extendings => src/View/Class_method}/index.html (100%) create mode 100644 admin/src/View/Class_methods/HtmlView.php rename admin/{views/class_extendings/tmpl => src/View/Class_methods}/index.html (100%) create mode 100644 admin/src/View/Class_properties/HtmlView.php rename admin/{views/class_extends/tmpl => src/View/Class_properties}/index.html (100%) create mode 100644 admin/src/View/Class_property/HtmlView.php rename admin/{views/class_method/tmpl => src/View/Class_property}/index.html (100%) create mode 100644 admin/src/View/Compiler/HtmlView.php rename admin/{views/class_methods => src/View/Compiler}/index.html (100%) create mode 100644 admin/src/View/Component_admin_views/HtmlView.php rename admin/{views/class_methods/tmpl => src/View/Component_admin_views}/index.html (100%) create mode 100644 admin/src/View/Component_config/HtmlView.php rename admin/{views/class_properties => src/View/Component_config}/index.html (100%) create mode 100644 admin/src/View/Component_custom_admin_menus/HtmlView.php rename admin/{views/class_properties/tmpl => src/View/Component_custom_admin_menus}/index.html (100%) create mode 100644 admin/src/View/Component_custom_admin_views/HtmlView.php rename admin/{views/class_property/tmpl => src/View/Component_custom_admin_views}/index.html (100%) create mode 100644 admin/src/View/Component_dashboard/HtmlView.php rename admin/{views/compiler => src/View/Component_dashboard}/index.html (100%) create mode 100644 admin/src/View/Component_files_folders/HtmlView.php rename admin/{views/compiler/tmpl => src/View/Component_files_folders}/index.html (100%) create mode 100644 admin/src/View/Component_modules/HtmlView.php rename admin/{views/component_admin_views/tmpl => src/View/Component_modules}/index.html (100%) create mode 100644 admin/src/View/Component_mysql_tweaks/HtmlView.php rename admin/{views/component_config/tmpl => src/View/Component_mysql_tweaks}/index.html (100%) create mode 100644 admin/src/View/Component_placeholders/HtmlView.php rename admin/{views/component_custom_admin_menus/tmpl => src/View/Component_placeholders}/index.html (100%) create mode 100644 admin/src/View/Component_plugins/HtmlView.php rename admin/{views/component_custom_admin_views/tmpl => src/View/Component_plugins}/index.html (100%) create mode 100644 admin/src/View/Component_router/HtmlView.php rename admin/{views/component_dashboard/tmpl => src/View/Component_router}/index.html (100%) create mode 100644 admin/src/View/Component_site_views/HtmlView.php rename admin/{views/component_files_folders/tmpl => src/View/Component_site_views}/index.html (100%) create mode 100644 admin/src/View/Component_updates/HtmlView.php rename admin/{views/component_modules/tmpl => src/View/Component_updates}/index.html (100%) create mode 100644 admin/src/View/Componentbuilder/HtmlView.php rename admin/{views/component_mysql_tweaks/tmpl => src/View/Componentbuilder}/index.html (100%) create mode 100644 admin/src/View/Components_admin_views/HtmlView.php rename admin/{views/component_placeholders/tmpl => src/View/Components_admin_views}/index.html (100%) create mode 100644 admin/src/View/Components_config/HtmlView.php rename admin/{views/component_plugins/tmpl => src/View/Components_config}/index.html (100%) create mode 100644 admin/src/View/Components_custom_admin_menus/HtmlView.php rename admin/{views/component_site_views/tmpl => src/View/Components_custom_admin_menus}/index.html (100%) create mode 100644 admin/src/View/Components_custom_admin_views/HtmlView.php rename admin/{views/component_updates/tmpl => src/View/Components_custom_admin_views}/index.html (100%) create mode 100644 admin/src/View/Components_dashboard/HtmlView.php rename admin/{views/componentbuilder => src/View/Components_dashboard}/index.html (100%) create mode 100644 admin/src/View/Components_files_folders/HtmlView.php rename admin/{views/componentbuilder/tmpl => src/View/Components_files_folders}/index.html (100%) create mode 100644 admin/src/View/Components_modules/HtmlView.php rename admin/{views/components_admin_views => src/View/Components_modules}/index.html (100%) create mode 100644 admin/src/View/Components_mysql_tweaks/HtmlView.php rename admin/{views/components_admin_views/tmpl => src/View/Components_mysql_tweaks}/index.html (100%) create mode 100644 admin/src/View/Components_placeholders/HtmlView.php rename admin/{views/components_config => src/View/Components_placeholders}/index.html (100%) create mode 100644 admin/src/View/Components_plugins/HtmlView.php rename admin/{views/components_config/tmpl => src/View/Components_plugins}/index.html (100%) create mode 100644 admin/src/View/Components_routers/HtmlView.php rename admin/{views/components_custom_admin_menus => src/View/Components_routers}/index.html (100%) create mode 100644 admin/src/View/Components_site_views/HtmlView.php rename admin/{views/components_custom_admin_menus/tmpl => src/View/Components_site_views}/index.html (100%) create mode 100644 admin/src/View/Components_updates/HtmlView.php rename admin/{views/components_custom_admin_views => src/View/Components_updates}/index.html (100%) create mode 100644 admin/src/View/Custom_admin_view/HtmlView.php rename admin/{views/components_custom_admin_views/tmpl => src/View/Custom_admin_view}/index.html (100%) create mode 100644 admin/src/View/Custom_admin_views/HtmlView.php rename admin/{views/components_dashboard => src/View/Custom_admin_views}/index.html (100%) create mode 100644 admin/src/View/Custom_code/HtmlView.php rename admin/{views/components_dashboard/tmpl => src/View/Custom_code}/index.html (100%) create mode 100644 admin/src/View/Custom_codes/HtmlView.php rename admin/{views/components_files_folders => src/View/Custom_codes}/index.html (100%) create mode 100644 admin/src/View/Dynamic_get/HtmlView.php rename admin/{views/components_files_folders/tmpl => src/View/Dynamic_get}/index.html (100%) create mode 100644 admin/src/View/Dynamic_gets/HtmlView.php rename admin/{views/components_modules => src/View/Dynamic_gets}/index.html (100%) create mode 100644 admin/src/View/Field/HtmlView.php rename admin/{views/components_modules/tmpl => src/View/Field}/index.html (100%) create mode 100644 admin/src/View/Fields/HtmlView.php rename admin/{views/components_mysql_tweaks => src/View/Fields}/index.html (100%) create mode 100644 admin/src/View/Fieldtype/HtmlView.php rename admin/{views/components_mysql_tweaks/tmpl => src/View/Fieldtype}/index.html (100%) create mode 100644 admin/src/View/Fieldtypes/HtmlView.php rename admin/{views/components_placeholders => src/View/Fieldtypes}/index.html (100%) create mode 100644 admin/src/View/Get_snippets/HtmlView.php rename admin/{views/components_placeholders/tmpl => src/View/Get_snippets}/index.html (100%) create mode 100644 admin/src/View/Help_document/HtmlView.php rename admin/{views/components_plugins => src/View/Help_document}/index.html (100%) create mode 100644 admin/src/View/Help_documents/HtmlView.php rename admin/{views/components_plugins/tmpl => src/View/Help_documents}/index.html (100%) create mode 100644 admin/src/View/Import/HtmlView.php rename admin/{views/components_site_views => src/View/Import}/index.html (100%) create mode 100644 admin/src/View/Import_joomla_componentsimport/HtmlView.php rename admin/{views/components_site_views/tmpl => src/View/Import_joomla_componentsimport}/index.html (100%) create mode 100644 admin/src/View/Import_language_translationsimport/HtmlView.php rename admin/{views/components_updates => src/View/Import_language_translationsimport}/index.html (100%) create mode 100644 admin/src/View/Joomla_component/HtmlView.php rename admin/{views/components_updates/tmpl => src/View/Joomla_component}/index.html (100%) create mode 100644 admin/src/View/Joomla_components/HtmlView.php rename admin/{views/custom_admin_view/tmpl => src/View/Joomla_components}/index.html (100%) create mode 100644 admin/src/View/Joomla_module/HtmlView.php rename admin/{views/custom_admin_views => src/View/Joomla_module}/index.html (100%) create mode 100644 admin/src/View/Joomla_module_files_folders_urls/HtmlView.php rename admin/{views/custom_admin_views/tmpl => src/View/Joomla_module_files_folders_urls}/index.html (100%) create mode 100644 admin/src/View/Joomla_module_updates/HtmlView.php rename admin/{views/custom_code/tmpl => src/View/Joomla_module_updates}/index.html (100%) create mode 100644 admin/src/View/Joomla_modules/HtmlView.php rename admin/{views/custom_codes => src/View/Joomla_modules}/index.html (100%) create mode 100644 admin/src/View/Joomla_modules_files_folders_urls/HtmlView.php rename admin/{views/custom_codes/tmpl => src/View/Joomla_modules_files_folders_urls}/index.html (100%) create mode 100644 admin/src/View/Joomla_modules_updates/HtmlView.php rename admin/{views/dynamic_get/tmpl => src/View/Joomla_modules_updates}/index.html (100%) create mode 100644 admin/src/View/Joomla_plugin/HtmlView.php rename admin/{views/dynamic_gets => src/View/Joomla_plugin}/index.html (100%) create mode 100644 admin/src/View/Joomla_plugin_files_folders_urls/HtmlView.php rename admin/{views/dynamic_gets/tmpl => src/View/Joomla_plugin_files_folders_urls}/index.html (100%) create mode 100644 admin/src/View/Joomla_plugin_group/HtmlView.php rename admin/{views/field/tmpl => src/View/Joomla_plugin_group}/index.html (100%) create mode 100644 admin/src/View/Joomla_plugin_groups/HtmlView.php rename admin/{views/fields => src/View/Joomla_plugin_groups}/index.html (100%) create mode 100644 admin/src/View/Joomla_plugin_updates/HtmlView.php rename admin/{views/fields/tmpl => src/View/Joomla_plugin_updates}/index.html (100%) create mode 100644 admin/src/View/Joomla_plugins/HtmlView.php rename admin/{views/fieldtype/tmpl => src/View/Joomla_plugins}/index.html (100%) create mode 100644 admin/src/View/Joomla_plugins_files_folders_urls/HtmlView.php rename admin/{views/fieldtypes => src/View/Joomla_plugins_files_folders_urls}/index.html (100%) create mode 100644 admin/src/View/Joomla_plugins_updates/HtmlView.php rename admin/{views/fieldtypes/tmpl => src/View/Joomla_plugins_updates}/index.html (100%) create mode 100644 admin/src/View/Language/HtmlView.php rename admin/{views/get_snippets => src/View/Language}/index.html (100%) create mode 100644 admin/src/View/Language_translation/HtmlView.php rename admin/{views/get_snippets/tmpl => src/View/Language_translation}/index.html (100%) create mode 100644 admin/src/View/Language_translations/HtmlView.php rename admin/{views/help_document/tmpl => src/View/Language_translations}/index.html (100%) create mode 100644 admin/src/View/Languages/HtmlView.php rename admin/{views/help_documents => src/View/Languages}/index.html (100%) create mode 100644 admin/src/View/Layout/HtmlView.php rename admin/{views/help_documents/tmpl => src/View/Layout}/index.html (100%) create mode 100644 admin/src/View/Layouts/HtmlView.php rename admin/{views/import => src/View/Layouts}/index.html (100%) create mode 100644 admin/src/View/Libraries/HtmlView.php rename admin/{views/import/tmpl => src/View/Libraries}/index.html (100%) create mode 100644 admin/src/View/Libraries_config/HtmlView.php rename admin/{views/import_joomla_components => src/View/Libraries_config}/index.html (100%) create mode 100644 admin/src/View/Libraries_files_folders_urls/HtmlView.php rename admin/{views/import_joomla_components/tmpl => src/View/Libraries_files_folders_urls}/index.html (100%) create mode 100644 admin/src/View/Library/HtmlView.php rename admin/{views/import_language_translations => src/View/Library}/index.html (100%) create mode 100644 admin/src/View/Library_config/HtmlView.php rename admin/{views/import_language_translations/tmpl => src/View/Library_config}/index.html (100%) create mode 100644 admin/src/View/Library_files_folders_urls/HtmlView.php rename admin/{views => src/View/Library_files_folders_urls}/index.html (100%) create mode 100644 admin/src/View/Placeholder/HtmlView.php rename admin/{views/joomla_component/tmpl => src/View/Placeholder}/index.html (100%) create mode 100644 admin/src/View/Placeholders/HtmlView.php rename admin/{views/joomla_components => src/View/Placeholders}/index.html (100%) create mode 100644 admin/src/View/Power/HtmlView.php rename admin/{views/joomla_components/tmpl => src/View/Power}/index.html (100%) create mode 100644 admin/src/View/Powers/HtmlView.php rename admin/{views/joomla_module/tmpl => src/View/Powers}/index.html (100%) create mode 100644 admin/src/View/Search/HtmlView.php rename admin/{views/joomla_module_files_folders_urls/tmpl => src/View/Search}/index.html (100%) create mode 100644 admin/src/View/Server/HtmlView.php rename admin/{views/joomla_module_updates/tmpl => src/View/Server}/index.html (100%) create mode 100644 admin/src/View/Servers/HtmlView.php rename admin/{views/joomla_modules => src/View/Servers}/index.html (100%) create mode 100644 admin/src/View/Site_view/HtmlView.php rename admin/{views/joomla_modules/tmpl => src/View/Site_view}/index.html (100%) create mode 100644 admin/src/View/Site_views/HtmlView.php rename admin/{views/joomla_modules_files_folders_urls => src/View/Site_views}/index.html (100%) create mode 100644 admin/src/View/Snippet/HtmlView.php rename admin/{views/joomla_modules_files_folders_urls/tmpl => src/View/Snippet}/index.html (100%) create mode 100644 admin/src/View/Snippet_type/HtmlView.php rename admin/{views/joomla_modules_updates => src/View/Snippet_type}/index.html (100%) create mode 100644 admin/src/View/Snippet_types/HtmlView.php rename admin/{views/joomla_modules_updates/tmpl => src/View/Snippet_types}/index.html (100%) create mode 100644 admin/src/View/Snippets/HtmlView.php rename admin/{views/joomla_plugin/tmpl => src/View/Snippets}/index.html (100%) create mode 100644 admin/src/View/Template/HtmlView.php rename admin/{views/joomla_plugin_files_folders_urls/tmpl => src/View/Template}/index.html (100%) create mode 100644 admin/src/View/Templates/HtmlView.php rename admin/{views/joomla_plugin_group/tmpl => src/View/Templates}/index.html (100%) create mode 100644 admin/src/View/Validation_rule/HtmlView.php rename admin/{views/joomla_plugin_groups => src/View/Validation_rule}/index.html (100%) create mode 100644 admin/src/View/Validation_rules/HtmlView.php rename admin/{views/joomla_plugin_groups/tmpl => src/View/Validation_rules}/index.html (100%) rename admin/{views/joomla_plugin_updates/tmpl => src/View}/index.html (100%) rename admin/{views/joomla_plugins => src}/index.html (100%) delete mode 100644 admin/tables/admin_custom_tabs.php delete mode 100644 admin/tables/admin_fields.php delete mode 100644 admin/tables/admin_fields_conditions.php delete mode 100644 admin/tables/admin_fields_relations.php delete mode 100644 admin/tables/admin_view.php delete mode 100644 admin/tables/class_extends.php delete mode 100644 admin/tables/class_method.php delete mode 100644 admin/tables/class_property.php delete mode 100644 admin/tables/component_admin_views.php delete mode 100644 admin/tables/component_config.php delete mode 100644 admin/tables/component_custom_admin_menus.php delete mode 100644 admin/tables/component_custom_admin_views.php delete mode 100644 admin/tables/component_dashboard.php delete mode 100644 admin/tables/component_files_folders.php delete mode 100644 admin/tables/component_modules.php delete mode 100644 admin/tables/component_mysql_tweaks.php delete mode 100644 admin/tables/component_placeholders.php delete mode 100644 admin/tables/component_plugins.php delete mode 100644 admin/tables/component_site_views.php delete mode 100644 admin/tables/component_updates.php delete mode 100644 admin/tables/custom_admin_view.php delete mode 100644 admin/tables/custom_code.php delete mode 100644 admin/tables/dynamic_get.php delete mode 100644 admin/tables/field.php delete mode 100644 admin/tables/fieldtype.php delete mode 100644 admin/tables/help_document.php delete mode 100644 admin/tables/joomla_component.php delete mode 100644 admin/tables/joomla_module.php delete mode 100644 admin/tables/joomla_module_files_folders_urls.php delete mode 100644 admin/tables/joomla_module_updates.php delete mode 100644 admin/tables/joomla_plugin.php delete mode 100644 admin/tables/joomla_plugin_files_folders_urls.php delete mode 100644 admin/tables/joomla_plugin_group.php delete mode 100644 admin/tables/joomla_plugin_updates.php delete mode 100644 admin/tables/language.php delete mode 100644 admin/tables/language_translation.php delete mode 100644 admin/tables/layout.php delete mode 100644 admin/tables/library.php delete mode 100644 admin/tables/library_config.php delete mode 100644 admin/tables/library_files_folders_urls.php delete mode 100644 admin/tables/placeholder.php delete mode 100644 admin/tables/power.php delete mode 100644 admin/tables/server.php delete mode 100644 admin/tables/site_view.php delete mode 100644 admin/tables/snippet.php delete mode 100644 admin/tables/snippet_type.php delete mode 100644 admin/tables/template.php delete mode 100644 admin/tables/validation_rule.php create mode 100644 admin/tmpl/admin_custom_tabs/default.php rename admin/{views/joomla_plugins/tmpl => tmpl/admin_custom_tabs}/index.html (100%) create mode 100644 admin/tmpl/admin_fields/default.php rename admin/{views/joomla_plugins_files_folders_urls => tmpl/admin_fields}/index.html (100%) create mode 100644 admin/tmpl/admin_fields_conditions/default.php rename admin/{views/joomla_plugins_files_folders_urls/tmpl => tmpl/admin_fields_conditions}/index.html (100%) create mode 100644 admin/tmpl/admin_fields_relations/default.php rename admin/{views/joomla_plugins_updates => tmpl/admin_fields_relations}/index.html (100%) create mode 100644 admin/tmpl/admin_view/default.php rename admin/{views/joomla_plugins_updates/tmpl => tmpl/admin_view}/index.html (100%) create mode 100644 admin/tmpl/admin_views/default.php create mode 100644 admin/tmpl/admin_views/default_body.php create mode 100644 admin/tmpl/admin_views/default_foot.php create mode 100644 admin/tmpl/admin_views/default_head.php create mode 100644 admin/tmpl/admin_views/default_toolbar.php create mode 100644 admin/tmpl/admin_views/emptystate.php rename admin/{views/language/tmpl => tmpl/admin_views}/index.html (100%) create mode 100644 admin/tmpl/admins_custom_tabs/default.php create mode 100644 admin/tmpl/admins_custom_tabs/default_body.php create mode 100644 admin/tmpl/admins_custom_tabs/default_foot.php create mode 100644 admin/tmpl/admins_custom_tabs/default_head.php create mode 100644 admin/tmpl/admins_custom_tabs/default_toolbar.php create mode 100644 admin/tmpl/admins_custom_tabs/emptystate.php rename admin/{views/language_translation/tmpl => tmpl/admins_custom_tabs}/index.html (100%) create mode 100644 admin/tmpl/admins_fields/default.php create mode 100644 admin/tmpl/admins_fields/default_body.php create mode 100644 admin/tmpl/admins_fields/default_foot.php create mode 100644 admin/tmpl/admins_fields/default_head.php create mode 100644 admin/tmpl/admins_fields/default_toolbar.php create mode 100644 admin/tmpl/admins_fields/emptystate.php rename admin/{views/language_translations => tmpl/admins_fields}/index.html (100%) create mode 100644 admin/tmpl/admins_fields_conditions/default.php create mode 100644 admin/tmpl/admins_fields_conditions/default_body.php create mode 100644 admin/tmpl/admins_fields_conditions/default_foot.php create mode 100644 admin/tmpl/admins_fields_conditions/default_head.php create mode 100644 admin/tmpl/admins_fields_conditions/default_toolbar.php create mode 100644 admin/tmpl/admins_fields_conditions/emptystate.php rename admin/{views/language_translations/tmpl => tmpl/admins_fields_conditions}/index.html (100%) create mode 100644 admin/tmpl/admins_fields_relations/default.php create mode 100644 admin/tmpl/admins_fields_relations/default_body.php create mode 100644 admin/tmpl/admins_fields_relations/default_foot.php create mode 100644 admin/tmpl/admins_fields_relations/default_head.php create mode 100644 admin/tmpl/admins_fields_relations/default_toolbar.php create mode 100644 admin/tmpl/admins_fields_relations/emptystate.php rename admin/{views/languages => tmpl/admins_fields_relations}/index.html (100%) create mode 100644 admin/tmpl/class_extendings/default.php create mode 100644 admin/tmpl/class_extendings/default_body.php create mode 100644 admin/tmpl/class_extendings/default_foot.php create mode 100644 admin/tmpl/class_extendings/default_head.php create mode 100644 admin/tmpl/class_extendings/default_toolbar.php create mode 100644 admin/tmpl/class_extendings/emptystate.php rename admin/{views/languages/tmpl => tmpl/class_extendings}/index.html (100%) create mode 100644 admin/tmpl/class_extends/default.php rename admin/{views/layout/tmpl => tmpl/class_extends}/index.html (100%) create mode 100644 admin/tmpl/class_method/default.php rename admin/{views/layouts => tmpl/class_method}/index.html (100%) create mode 100644 admin/tmpl/class_methods/default.php create mode 100644 admin/tmpl/class_methods/default_body.php create mode 100644 admin/tmpl/class_methods/default_foot.php create mode 100644 admin/tmpl/class_methods/default_head.php create mode 100644 admin/tmpl/class_methods/default_toolbar.php create mode 100644 admin/tmpl/class_methods/emptystate.php rename admin/{views/layouts/tmpl => tmpl/class_methods}/index.html (100%) create mode 100644 admin/tmpl/class_properties/default.php create mode 100644 admin/tmpl/class_properties/default_body.php create mode 100644 admin/tmpl/class_properties/default_foot.php create mode 100644 admin/tmpl/class_properties/default_head.php create mode 100644 admin/tmpl/class_properties/default_toolbar.php create mode 100644 admin/tmpl/class_properties/emptystate.php rename admin/{views/libraries => tmpl/class_properties}/index.html (100%) create mode 100644 admin/tmpl/class_property/default.php rename admin/{views/libraries/tmpl => tmpl/class_property}/index.html (100%) create mode 100644 admin/tmpl/compiler/default.php rename admin/{views/libraries_config => tmpl/compiler}/index.html (100%) create mode 100644 admin/tmpl/component_admin_views/default.php rename admin/{views/libraries_config/tmpl => tmpl/component_admin_views}/index.html (100%) create mode 100644 admin/tmpl/component_config/default.php rename admin/{views/libraries_files_folders_urls => tmpl/component_config}/index.html (100%) create mode 100644 admin/tmpl/component_custom_admin_menus/default.php rename admin/{views/libraries_files_folders_urls/tmpl => tmpl/component_custom_admin_menus}/index.html (100%) create mode 100644 admin/tmpl/component_custom_admin_views/default.php rename admin/{views/library/tmpl => tmpl/component_custom_admin_views}/index.html (100%) create mode 100644 admin/tmpl/component_dashboard/default.php rename admin/{views/library_config/tmpl => tmpl/component_dashboard}/index.html (100%) create mode 100644 admin/tmpl/component_files_folders/default.php rename admin/{views/library_files_folders_urls/tmpl => tmpl/component_files_folders}/index.html (100%) create mode 100644 admin/tmpl/component_modules/default.php rename admin/{views/placeholder/tmpl => tmpl/component_modules}/index.html (100%) create mode 100644 admin/tmpl/component_mysql_tweaks/default.php rename admin/{views/placeholders => tmpl/component_mysql_tweaks}/index.html (100%) create mode 100644 admin/tmpl/component_placeholders/default.php rename admin/{views/placeholders/tmpl => tmpl/component_placeholders}/index.html (100%) create mode 100644 admin/tmpl/component_plugins/default.php rename admin/{views/power/tmpl => tmpl/component_plugins}/index.html (100%) create mode 100644 admin/tmpl/component_router/default.php rename admin/{views/powers => tmpl/component_router}/index.html (100%) create mode 100644 admin/tmpl/component_site_views/default.php rename admin/{views/powers/tmpl => tmpl/component_site_views}/index.html (100%) create mode 100644 admin/tmpl/component_updates/default.php rename admin/{views/search => tmpl/component_updates}/index.html (100%) create mode 100644 admin/tmpl/componentbuilder/default.php create mode 100644 admin/tmpl/componentbuilder/default_main.php rename admin/{views/componentbuilder/tmpl => tmpl/componentbuilder}/default_notice_board_vast_development_method.php (78%) rename admin/{views/componentbuilder/tmpl => tmpl/componentbuilder}/default_readme_information.php (78%) create mode 100644 admin/tmpl/componentbuilder/default_vdm.php rename admin/{views/componentbuilder/tmpl => tmpl/componentbuilder}/default_wiki_tutorials.php (78%) rename admin/{views/search/tmpl => tmpl/componentbuilder}/index.html (100%) create mode 100644 admin/tmpl/components_admin_views/default.php create mode 100644 admin/tmpl/components_admin_views/default_body.php create mode 100644 admin/tmpl/components_admin_views/default_foot.php create mode 100644 admin/tmpl/components_admin_views/default_head.php create mode 100644 admin/tmpl/components_admin_views/default_toolbar.php create mode 100644 admin/tmpl/components_admin_views/emptystate.php rename admin/{views/server/tmpl => tmpl/components_admin_views}/index.html (100%) create mode 100644 admin/tmpl/components_config/default.php create mode 100644 admin/tmpl/components_config/default_body.php create mode 100644 admin/tmpl/components_config/default_foot.php create mode 100644 admin/tmpl/components_config/default_head.php create mode 100644 admin/tmpl/components_config/default_toolbar.php create mode 100644 admin/tmpl/components_config/emptystate.php rename admin/{views/servers => tmpl/components_config}/index.html (100%) create mode 100644 admin/tmpl/components_custom_admin_menus/default.php create mode 100644 admin/tmpl/components_custom_admin_menus/default_body.php create mode 100644 admin/tmpl/components_custom_admin_menus/default_foot.php create mode 100644 admin/tmpl/components_custom_admin_menus/default_head.php create mode 100644 admin/tmpl/components_custom_admin_menus/default_toolbar.php create mode 100644 admin/tmpl/components_custom_admin_menus/emptystate.php rename admin/{views/servers/tmpl => tmpl/components_custom_admin_menus}/index.html (100%) create mode 100644 admin/tmpl/components_custom_admin_views/default.php create mode 100644 admin/tmpl/components_custom_admin_views/default_body.php create mode 100644 admin/tmpl/components_custom_admin_views/default_foot.php create mode 100644 admin/tmpl/components_custom_admin_views/default_head.php create mode 100644 admin/tmpl/components_custom_admin_views/default_toolbar.php create mode 100644 admin/tmpl/components_custom_admin_views/emptystate.php rename admin/{views/site_view/tmpl => tmpl/components_custom_admin_views}/index.html (100%) create mode 100644 admin/tmpl/components_dashboard/default.php create mode 100644 admin/tmpl/components_dashboard/default_body.php create mode 100644 admin/tmpl/components_dashboard/default_foot.php create mode 100644 admin/tmpl/components_dashboard/default_head.php create mode 100644 admin/tmpl/components_dashboard/default_toolbar.php create mode 100644 admin/tmpl/components_dashboard/emptystate.php rename admin/{views/site_views => tmpl/components_dashboard}/index.html (100%) create mode 100644 admin/tmpl/components_files_folders/default.php create mode 100644 admin/tmpl/components_files_folders/default_body.php create mode 100644 admin/tmpl/components_files_folders/default_foot.php create mode 100644 admin/tmpl/components_files_folders/default_head.php create mode 100644 admin/tmpl/components_files_folders/default_toolbar.php create mode 100644 admin/tmpl/components_files_folders/emptystate.php rename admin/{views/site_views/tmpl => tmpl/components_files_folders}/index.html (100%) create mode 100644 admin/tmpl/components_modules/default.php create mode 100644 admin/tmpl/components_modules/default_body.php create mode 100644 admin/tmpl/components_modules/default_foot.php create mode 100644 admin/tmpl/components_modules/default_head.php create mode 100644 admin/tmpl/components_modules/default_toolbar.php create mode 100644 admin/tmpl/components_modules/emptystate.php rename admin/{views/snippet/tmpl => tmpl/components_modules}/index.html (100%) create mode 100644 admin/tmpl/components_mysql_tweaks/default.php create mode 100644 admin/tmpl/components_mysql_tweaks/default_body.php create mode 100644 admin/tmpl/components_mysql_tweaks/default_foot.php create mode 100644 admin/tmpl/components_mysql_tweaks/default_head.php create mode 100644 admin/tmpl/components_mysql_tweaks/default_toolbar.php create mode 100644 admin/tmpl/components_mysql_tweaks/emptystate.php rename admin/{views/snippet_type/tmpl => tmpl/components_mysql_tweaks}/index.html (100%) create mode 100644 admin/tmpl/components_placeholders/default.php create mode 100644 admin/tmpl/components_placeholders/default_body.php create mode 100644 admin/tmpl/components_placeholders/default_foot.php create mode 100644 admin/tmpl/components_placeholders/default_head.php create mode 100644 admin/tmpl/components_placeholders/default_toolbar.php create mode 100644 admin/tmpl/components_placeholders/emptystate.php rename admin/{views/snippet_types => tmpl/components_placeholders}/index.html (100%) create mode 100644 admin/tmpl/components_plugins/default.php create mode 100644 admin/tmpl/components_plugins/default_body.php create mode 100644 admin/tmpl/components_plugins/default_foot.php create mode 100644 admin/tmpl/components_plugins/default_head.php create mode 100644 admin/tmpl/components_plugins/default_toolbar.php create mode 100644 admin/tmpl/components_plugins/emptystate.php rename admin/{views/snippet_types/tmpl => tmpl/components_plugins}/index.html (100%) create mode 100644 admin/tmpl/components_routers/default.php create mode 100644 admin/tmpl/components_routers/default_body.php create mode 100644 admin/tmpl/components_routers/default_foot.php create mode 100644 admin/tmpl/components_routers/default_head.php create mode 100644 admin/tmpl/components_routers/default_toolbar.php create mode 100644 admin/tmpl/components_routers/emptystate.php rename admin/{views/snippets => tmpl/components_routers}/index.html (100%) create mode 100644 admin/tmpl/components_site_views/default.php create mode 100644 admin/tmpl/components_site_views/default_body.php create mode 100644 admin/tmpl/components_site_views/default_foot.php create mode 100644 admin/tmpl/components_site_views/default_head.php create mode 100644 admin/tmpl/components_site_views/default_toolbar.php create mode 100644 admin/tmpl/components_site_views/emptystate.php rename admin/{views/snippets/tmpl => tmpl/components_site_views}/index.html (100%) create mode 100644 admin/tmpl/components_updates/default.php create mode 100644 admin/tmpl/components_updates/default_body.php create mode 100644 admin/tmpl/components_updates/default_foot.php create mode 100644 admin/tmpl/components_updates/default_head.php create mode 100644 admin/tmpl/components_updates/default_toolbar.php create mode 100644 admin/tmpl/components_updates/emptystate.php rename admin/{views/template/tmpl => tmpl/components_updates}/index.html (100%) create mode 100644 admin/tmpl/custom_admin_view/default.php rename admin/{views/templates => tmpl/custom_admin_view}/index.html (100%) create mode 100644 admin/tmpl/custom_admin_views/default.php create mode 100644 admin/tmpl/custom_admin_views/default_body.php create mode 100644 admin/tmpl/custom_admin_views/default_foot.php create mode 100644 admin/tmpl/custom_admin_views/default_head.php create mode 100644 admin/tmpl/custom_admin_views/default_toolbar.php create mode 100644 admin/tmpl/custom_admin_views/emptystate.php rename admin/{views/templates/tmpl => tmpl/custom_admin_views}/index.html (100%) create mode 100644 admin/tmpl/custom_code/default.php rename admin/{views/validation_rule/tmpl => tmpl/custom_code}/index.html (100%) create mode 100644 admin/tmpl/custom_codes/default.php create mode 100644 admin/tmpl/custom_codes/default_body.php create mode 100644 admin/tmpl/custom_codes/default_foot.php create mode 100644 admin/tmpl/custom_codes/default_head.php create mode 100644 admin/tmpl/custom_codes/default_toolbar.php create mode 100644 admin/tmpl/custom_codes/emptystate.php rename admin/{views/validation_rules => tmpl/custom_codes}/index.html (100%) create mode 100644 admin/tmpl/dynamic_get/default.php rename admin/{views/validation_rules/tmpl => tmpl/dynamic_get}/index.html (100%) create mode 100644 admin/tmpl/dynamic_gets/default.php create mode 100644 admin/tmpl/dynamic_gets/default_body.php create mode 100644 admin/tmpl/dynamic_gets/default_foot.php create mode 100644 admin/tmpl/dynamic_gets/default_head.php create mode 100644 admin/tmpl/dynamic_gets/default_toolbar.php create mode 100644 admin/tmpl/dynamic_gets/emptystate.php rename {site/assets/css => admin/tmpl/dynamic_gets}/index.html (100%) create mode 100644 admin/tmpl/field/default.php rename {site/assets/images => admin/tmpl/field}/index.html (100%) create mode 100644 admin/tmpl/fields/default.php create mode 100644 admin/tmpl/fields/default_body.php create mode 100644 admin/tmpl/fields/default_foot.php create mode 100644 admin/tmpl/fields/default_head.php create mode 100644 admin/tmpl/fields/default_toolbar.php create mode 100644 admin/tmpl/fields/emptystate.php rename {site/assets => admin/tmpl/fields}/index.html (100%) create mode 100644 admin/tmpl/fieldtype/default.php rename {site/assets/js => admin/tmpl/fieldtype}/index.html (100%) create mode 100644 admin/tmpl/fieldtypes/default.php create mode 100644 admin/tmpl/fieldtypes/default_body.php create mode 100644 admin/tmpl/fieldtypes/default_foot.php create mode 100644 admin/tmpl/fieldtypes/default_head.php create mode 100644 admin/tmpl/fieldtypes/default_toolbar.php create mode 100644 admin/tmpl/fieldtypes/emptystate.php rename {site/controllers => admin/tmpl/fieldtypes}/index.html (100%) create mode 100644 admin/tmpl/get_snippets/default.php rename {site/helpers => admin/tmpl/get_snippets}/index.html (100%) create mode 100644 admin/tmpl/help_document/default.php rename {site => admin/tmpl/help_document}/index.html (100%) create mode 100644 admin/tmpl/help_documents/default.php create mode 100644 admin/tmpl/help_documents/default_body.php create mode 100644 admin/tmpl/help_documents/default_foot.php create mode 100644 admin/tmpl/help_documents/default_head.php create mode 100644 admin/tmpl/help_documents/default_toolbar.php create mode 100644 admin/tmpl/help_documents/emptystate.php rename {site/language/en-GB => admin/tmpl/help_documents}/index.html (100%) create mode 100644 admin/tmpl/import/default.php rename {site/language => admin/tmpl/import}/index.html (100%) create mode 100644 admin/tmpl/import_joomla_componentsimport/default.php rename {site/layouts => admin/tmpl/import_joomla_componentsimport}/index.html (100%) create mode 100644 admin/tmpl/import_language_translationsimport/default.php rename {site/models => admin/tmpl/import_language_translationsimport}/index.html (100%) rename {site/views/api => admin/tmpl}/index.html (100%) create mode 100644 admin/tmpl/joomla_component/default.php rename {site/views/api/tmpl => admin/tmpl/joomla_component}/index.html (100%) create mode 100644 admin/tmpl/joomla_components/default.php create mode 100644 admin/tmpl/joomla_components/default_body.php create mode 100644 admin/tmpl/joomla_components/default_foot.php create mode 100644 admin/tmpl/joomla_components/default_head.php create mode 100644 admin/tmpl/joomla_components/default_toolbar.php create mode 100644 admin/tmpl/joomla_components/emptystate.php rename {site/views => admin/tmpl/joomla_components}/index.html (100%) create mode 100644 admin/tmpl/joomla_module/default.php create mode 100644 admin/tmpl/joomla_module/index.html create mode 100644 admin/tmpl/joomla_module_files_folders_urls/default.php create mode 100644 admin/tmpl/joomla_module_files_folders_urls/index.html create mode 100644 admin/tmpl/joomla_module_updates/default.php create mode 100644 admin/tmpl/joomla_module_updates/index.html create mode 100644 admin/tmpl/joomla_modules/default.php create mode 100644 admin/tmpl/joomla_modules/default_body.php create mode 100644 admin/tmpl/joomla_modules/default_foot.php create mode 100644 admin/tmpl/joomla_modules/default_head.php create mode 100644 admin/tmpl/joomla_modules/default_toolbar.php create mode 100644 admin/tmpl/joomla_modules/emptystate.php create mode 100644 admin/tmpl/joomla_modules/index.html create mode 100644 admin/tmpl/joomla_modules_files_folders_urls/default.php create mode 100644 admin/tmpl/joomla_modules_files_folders_urls/default_body.php create mode 100644 admin/tmpl/joomla_modules_files_folders_urls/default_foot.php create mode 100644 admin/tmpl/joomla_modules_files_folders_urls/default_head.php create mode 100644 admin/tmpl/joomla_modules_files_folders_urls/default_toolbar.php create mode 100644 admin/tmpl/joomla_modules_files_folders_urls/emptystate.php create mode 100644 admin/tmpl/joomla_modules_files_folders_urls/index.html create mode 100644 admin/tmpl/joomla_modules_updates/default.php create mode 100644 admin/tmpl/joomla_modules_updates/default_body.php create mode 100644 admin/tmpl/joomla_modules_updates/default_foot.php create mode 100644 admin/tmpl/joomla_modules_updates/default_head.php create mode 100644 admin/tmpl/joomla_modules_updates/default_toolbar.php create mode 100644 admin/tmpl/joomla_modules_updates/emptystate.php create mode 100644 admin/tmpl/joomla_modules_updates/index.html create mode 100644 admin/tmpl/joomla_plugin/default.php create mode 100644 admin/tmpl/joomla_plugin/index.html create mode 100644 admin/tmpl/joomla_plugin_files_folders_urls/default.php create mode 100644 admin/tmpl/joomla_plugin_files_folders_urls/index.html create mode 100644 admin/tmpl/joomla_plugin_group/default.php create mode 100644 admin/tmpl/joomla_plugin_group/index.html create mode 100644 admin/tmpl/joomla_plugin_groups/default.php create mode 100644 admin/tmpl/joomla_plugin_groups/default_body.php create mode 100644 admin/tmpl/joomla_plugin_groups/default_foot.php create mode 100644 admin/tmpl/joomla_plugin_groups/default_head.php create mode 100644 admin/tmpl/joomla_plugin_groups/default_toolbar.php create mode 100644 admin/tmpl/joomla_plugin_groups/emptystate.php create mode 100644 admin/tmpl/joomla_plugin_groups/index.html create mode 100644 admin/tmpl/joomla_plugin_updates/default.php create mode 100644 admin/tmpl/joomla_plugin_updates/index.html create mode 100644 admin/tmpl/joomla_plugins/default.php create mode 100644 admin/tmpl/joomla_plugins/default_body.php create mode 100644 admin/tmpl/joomla_plugins/default_foot.php create mode 100644 admin/tmpl/joomla_plugins/default_head.php create mode 100644 admin/tmpl/joomla_plugins/default_toolbar.php create mode 100644 admin/tmpl/joomla_plugins/emptystate.php create mode 100644 admin/tmpl/joomla_plugins/index.html create mode 100644 admin/tmpl/joomla_plugins_files_folders_urls/default.php create mode 100644 admin/tmpl/joomla_plugins_files_folders_urls/default_body.php create mode 100644 admin/tmpl/joomla_plugins_files_folders_urls/default_foot.php create mode 100644 admin/tmpl/joomla_plugins_files_folders_urls/default_head.php create mode 100644 admin/tmpl/joomla_plugins_files_folders_urls/default_toolbar.php create mode 100644 admin/tmpl/joomla_plugins_files_folders_urls/emptystate.php create mode 100644 admin/tmpl/joomla_plugins_files_folders_urls/index.html create mode 100644 admin/tmpl/joomla_plugins_updates/default.php create mode 100644 admin/tmpl/joomla_plugins_updates/default_body.php create mode 100644 admin/tmpl/joomla_plugins_updates/default_foot.php create mode 100644 admin/tmpl/joomla_plugins_updates/default_head.php create mode 100644 admin/tmpl/joomla_plugins_updates/default_toolbar.php create mode 100644 admin/tmpl/joomla_plugins_updates/emptystate.php create mode 100644 admin/tmpl/joomla_plugins_updates/index.html create mode 100644 admin/tmpl/language/default.php create mode 100644 admin/tmpl/language/index.html create mode 100644 admin/tmpl/language_translation/default.php create mode 100644 admin/tmpl/language_translation/index.html create mode 100644 admin/tmpl/language_translations/default.php create mode 100644 admin/tmpl/language_translations/default_body.php create mode 100644 admin/tmpl/language_translations/default_foot.php create mode 100644 admin/tmpl/language_translations/default_head.php create mode 100644 admin/tmpl/language_translations/default_toolbar.php create mode 100644 admin/tmpl/language_translations/emptystate.php create mode 100644 admin/tmpl/language_translations/index.html create mode 100644 admin/tmpl/languages/default.php create mode 100644 admin/tmpl/languages/default_body.php create mode 100644 admin/tmpl/languages/default_foot.php create mode 100644 admin/tmpl/languages/default_head.php create mode 100644 admin/tmpl/languages/default_toolbar.php create mode 100644 admin/tmpl/languages/emptystate.php create mode 100644 admin/tmpl/languages/index.html create mode 100644 admin/tmpl/layout/default.php create mode 100644 admin/tmpl/layout/index.html create mode 100644 admin/tmpl/layouts/default.php create mode 100644 admin/tmpl/layouts/default_body.php create mode 100644 admin/tmpl/layouts/default_foot.php create mode 100644 admin/tmpl/layouts/default_head.php create mode 100644 admin/tmpl/layouts/default_toolbar.php create mode 100644 admin/tmpl/layouts/emptystate.php create mode 100644 admin/tmpl/layouts/index.html create mode 100644 admin/tmpl/libraries/default.php create mode 100644 admin/tmpl/libraries/default_body.php create mode 100644 admin/tmpl/libraries/default_foot.php create mode 100644 admin/tmpl/libraries/default_head.php create mode 100644 admin/tmpl/libraries/default_toolbar.php create mode 100644 admin/tmpl/libraries/emptystate.php create mode 100644 admin/tmpl/libraries/index.html create mode 100644 admin/tmpl/libraries_config/default.php create mode 100644 admin/tmpl/libraries_config/default_body.php create mode 100644 admin/tmpl/libraries_config/default_foot.php create mode 100644 admin/tmpl/libraries_config/default_head.php create mode 100644 admin/tmpl/libraries_config/default_toolbar.php create mode 100644 admin/tmpl/libraries_config/emptystate.php create mode 100644 admin/tmpl/libraries_config/index.html create mode 100644 admin/tmpl/libraries_files_folders_urls/default.php create mode 100644 admin/tmpl/libraries_files_folders_urls/default_body.php create mode 100644 admin/tmpl/libraries_files_folders_urls/default_foot.php create mode 100644 admin/tmpl/libraries_files_folders_urls/default_head.php create mode 100644 admin/tmpl/libraries_files_folders_urls/default_toolbar.php create mode 100644 admin/tmpl/libraries_files_folders_urls/emptystate.php create mode 100644 admin/tmpl/libraries_files_folders_urls/index.html create mode 100644 admin/tmpl/library/default.php create mode 100644 admin/tmpl/library/index.html create mode 100644 admin/tmpl/library_config/default.php create mode 100644 admin/tmpl/library_config/index.html create mode 100644 admin/tmpl/library_files_folders_urls/default.php create mode 100644 admin/tmpl/library_files_folders_urls/index.html create mode 100644 admin/tmpl/placeholder/default.php create mode 100644 admin/tmpl/placeholder/index.html create mode 100644 admin/tmpl/placeholders/default.php create mode 100644 admin/tmpl/placeholders/default_body.php create mode 100644 admin/tmpl/placeholders/default_foot.php create mode 100644 admin/tmpl/placeholders/default_head.php create mode 100644 admin/tmpl/placeholders/default_toolbar.php create mode 100644 admin/tmpl/placeholders/emptystate.php create mode 100644 admin/tmpl/placeholders/index.html create mode 100644 admin/tmpl/power/default.php create mode 100644 admin/tmpl/power/index.html create mode 100644 admin/tmpl/powers/default.php create mode 100644 admin/tmpl/powers/default_body.php create mode 100644 admin/tmpl/powers/default_foot.php create mode 100644 admin/tmpl/powers/default_head.php create mode 100644 admin/tmpl/powers/default_toolbar.php create mode 100644 admin/tmpl/powers/emptystate.php create mode 100644 admin/tmpl/powers/index.html create mode 100644 admin/tmpl/search/default.php create mode 100644 admin/tmpl/search/index.html create mode 100644 admin/tmpl/server/default.php create mode 100644 admin/tmpl/server/index.html create mode 100644 admin/tmpl/servers/default.php create mode 100644 admin/tmpl/servers/default_body.php create mode 100644 admin/tmpl/servers/default_foot.php create mode 100644 admin/tmpl/servers/default_head.php create mode 100644 admin/tmpl/servers/default_toolbar.php create mode 100644 admin/tmpl/servers/emptystate.php create mode 100644 admin/tmpl/servers/index.html create mode 100644 admin/tmpl/site_view/default.php create mode 100644 admin/tmpl/site_view/index.html create mode 100644 admin/tmpl/site_views/default.php create mode 100644 admin/tmpl/site_views/default_body.php create mode 100644 admin/tmpl/site_views/default_foot.php create mode 100644 admin/tmpl/site_views/default_head.php create mode 100644 admin/tmpl/site_views/default_toolbar.php create mode 100644 admin/tmpl/site_views/emptystate.php create mode 100644 admin/tmpl/site_views/index.html create mode 100644 admin/tmpl/snippet/default.php create mode 100644 admin/tmpl/snippet/index.html create mode 100644 admin/tmpl/snippet_type/default.php create mode 100644 admin/tmpl/snippet_type/index.html create mode 100644 admin/tmpl/snippet_types/default.php create mode 100644 admin/tmpl/snippet_types/default_body.php create mode 100644 admin/tmpl/snippet_types/default_foot.php create mode 100644 admin/tmpl/snippet_types/default_head.php create mode 100644 admin/tmpl/snippet_types/default_toolbar.php create mode 100644 admin/tmpl/snippet_types/emptystate.php create mode 100644 admin/tmpl/snippet_types/index.html create mode 100644 admin/tmpl/snippets/default.php create mode 100644 admin/tmpl/snippets/default_body.php create mode 100644 admin/tmpl/snippets/default_foot.php create mode 100644 admin/tmpl/snippets/default_head.php create mode 100644 admin/tmpl/snippets/default_toolbar.php create mode 100644 admin/tmpl/snippets/emptystate.php create mode 100644 admin/tmpl/snippets/index.html create mode 100644 admin/tmpl/template/default.php create mode 100644 admin/tmpl/template/index.html create mode 100644 admin/tmpl/templates/default.php create mode 100644 admin/tmpl/templates/default_body.php create mode 100644 admin/tmpl/templates/default_foot.php create mode 100644 admin/tmpl/templates/default_head.php create mode 100644 admin/tmpl/templates/default_toolbar.php create mode 100644 admin/tmpl/templates/emptystate.php create mode 100644 admin/tmpl/templates/index.html create mode 100644 admin/tmpl/validation_rule/default.php create mode 100644 admin/tmpl/validation_rule/index.html create mode 100644 admin/tmpl/validation_rules/default.php create mode 100644 admin/tmpl/validation_rules/default_body.php create mode 100644 admin/tmpl/validation_rules/default_foot.php create mode 100644 admin/tmpl/validation_rules/default_head.php create mode 100644 admin/tmpl/validation_rules/default_toolbar.php create mode 100644 admin/tmpl/validation_rules/emptystate.php create mode 100644 admin/tmpl/validation_rules/index.html delete mode 100644 admin/views/admin_custom_tabs/submitbutton.js delete mode 100644 admin/views/admin_custom_tabs/tmpl/edit.php delete mode 100644 admin/views/admin_custom_tabs/view.html.php delete mode 100644 admin/views/admin_fields/submitbutton.js delete mode 100644 admin/views/admin_fields/tmpl/edit.php delete mode 100644 admin/views/admin_fields/view.html.php delete mode 100644 admin/views/admin_fields_conditions/submitbutton.js delete mode 100644 admin/views/admin_fields_conditions/tmpl/edit.php delete mode 100644 admin/views/admin_fields_conditions/view.html.php delete mode 100644 admin/views/admin_fields_relations/submitbutton.js delete mode 100644 admin/views/admin_fields_relations/tmpl/edit.php delete mode 100644 admin/views/admin_fields_relations/view.html.php delete mode 100644 admin/views/admin_view/submitbutton.js delete mode 100644 admin/views/admin_view/tmpl/edit.php delete mode 100644 admin/views/admin_view/view.html.php delete mode 100644 admin/views/admin_views/tmpl/default.php delete mode 100644 admin/views/admin_views/tmpl/default_batch_body.php delete mode 100644 admin/views/admin_views/tmpl/default_batch_footer.php delete mode 100644 admin/views/admin_views/tmpl/default_body.php delete mode 100644 admin/views/admin_views/tmpl/default_foot.php delete mode 100644 admin/views/admin_views/tmpl/default_head.php delete mode 100644 admin/views/admin_views/tmpl/default_toolbar.php delete mode 100644 admin/views/admin_views/view.html.php delete mode 100644 admin/views/admins_custom_tabs/tmpl/default.php delete mode 100644 admin/views/admins_custom_tabs/tmpl/default_batch_body.php delete mode 100644 admin/views/admins_custom_tabs/tmpl/default_batch_footer.php delete mode 100644 admin/views/admins_custom_tabs/tmpl/default_body.php delete mode 100644 admin/views/admins_custom_tabs/tmpl/default_foot.php delete mode 100644 admin/views/admins_custom_tabs/tmpl/default_head.php delete mode 100644 admin/views/admins_custom_tabs/tmpl/default_toolbar.php delete mode 100644 admin/views/admins_custom_tabs/view.html.php delete mode 100644 admin/views/admins_fields/tmpl/default.php delete mode 100644 admin/views/admins_fields/tmpl/default_batch_body.php delete mode 100644 admin/views/admins_fields/tmpl/default_batch_footer.php delete mode 100644 admin/views/admins_fields/tmpl/default_body.php delete mode 100644 admin/views/admins_fields/tmpl/default_foot.php delete mode 100644 admin/views/admins_fields/tmpl/default_head.php delete mode 100644 admin/views/admins_fields/tmpl/default_toolbar.php delete mode 100644 admin/views/admins_fields/view.html.php delete mode 100644 admin/views/admins_fields_conditions/tmpl/default.php delete mode 100644 admin/views/admins_fields_conditions/tmpl/default_batch_body.php delete mode 100644 admin/views/admins_fields_conditions/tmpl/default_batch_footer.php delete mode 100644 admin/views/admins_fields_conditions/tmpl/default_body.php delete mode 100644 admin/views/admins_fields_conditions/tmpl/default_foot.php delete mode 100644 admin/views/admins_fields_conditions/tmpl/default_head.php delete mode 100644 admin/views/admins_fields_conditions/tmpl/default_toolbar.php delete mode 100644 admin/views/admins_fields_conditions/view.html.php delete mode 100644 admin/views/admins_fields_relations/tmpl/default.php delete mode 100644 admin/views/admins_fields_relations/tmpl/default_batch_body.php delete mode 100644 admin/views/admins_fields_relations/tmpl/default_batch_footer.php delete mode 100644 admin/views/admins_fields_relations/tmpl/default_body.php delete mode 100644 admin/views/admins_fields_relations/tmpl/default_foot.php delete mode 100644 admin/views/admins_fields_relations/tmpl/default_head.php delete mode 100644 admin/views/admins_fields_relations/tmpl/default_toolbar.php delete mode 100644 admin/views/admins_fields_relations/view.html.php delete mode 100644 admin/views/class_extendings/tmpl/default.php delete mode 100644 admin/views/class_extendings/tmpl/default_batch_body.php delete mode 100644 admin/views/class_extendings/tmpl/default_batch_footer.php delete mode 100644 admin/views/class_extendings/tmpl/default_body.php delete mode 100644 admin/views/class_extendings/tmpl/default_foot.php delete mode 100644 admin/views/class_extendings/tmpl/default_head.php delete mode 100644 admin/views/class_extendings/tmpl/default_toolbar.php delete mode 100644 admin/views/class_extendings/view.html.php delete mode 100644 admin/views/class_extends/submitbutton.js delete mode 100644 admin/views/class_extends/tmpl/edit.php delete mode 100644 admin/views/class_extends/view.html.php delete mode 100644 admin/views/class_method/submitbutton.js delete mode 100644 admin/views/class_method/tmpl/edit.php delete mode 100644 admin/views/class_method/view.html.php delete mode 100644 admin/views/class_methods/tmpl/default.php delete mode 100644 admin/views/class_methods/tmpl/default_batch_body.php delete mode 100644 admin/views/class_methods/tmpl/default_batch_footer.php delete mode 100644 admin/views/class_methods/tmpl/default_body.php delete mode 100644 admin/views/class_methods/tmpl/default_foot.php delete mode 100644 admin/views/class_methods/tmpl/default_head.php delete mode 100644 admin/views/class_methods/tmpl/default_toolbar.php delete mode 100644 admin/views/class_methods/view.html.php delete mode 100644 admin/views/class_properties/tmpl/default.php delete mode 100644 admin/views/class_properties/tmpl/default_batch_body.php delete mode 100644 admin/views/class_properties/tmpl/default_batch_footer.php delete mode 100644 admin/views/class_properties/tmpl/default_body.php delete mode 100644 admin/views/class_properties/tmpl/default_foot.php delete mode 100644 admin/views/class_properties/tmpl/default_head.php delete mode 100644 admin/views/class_properties/tmpl/default_toolbar.php delete mode 100644 admin/views/class_properties/view.html.php delete mode 100644 admin/views/class_property/submitbutton.js delete mode 100644 admin/views/class_property/tmpl/edit.php delete mode 100644 admin/views/class_property/view.html.php delete mode 100644 admin/views/compiler/tmpl/default.php delete mode 100644 admin/views/compiler/view.html.php delete mode 100644 admin/views/component_admin_views/submitbutton.js delete mode 100644 admin/views/component_admin_views/tmpl/edit.php delete mode 100644 admin/views/component_admin_views/view.html.php delete mode 100644 admin/views/component_config/submitbutton.js delete mode 100644 admin/views/component_config/tmpl/edit.php delete mode 100644 admin/views/component_config/view.html.php delete mode 100644 admin/views/component_custom_admin_menus/submitbutton.js delete mode 100644 admin/views/component_custom_admin_menus/tmpl/edit.php delete mode 100644 admin/views/component_custom_admin_menus/view.html.php delete mode 100644 admin/views/component_custom_admin_views/submitbutton.js delete mode 100644 admin/views/component_custom_admin_views/tmpl/edit.php delete mode 100644 admin/views/component_custom_admin_views/view.html.php delete mode 100644 admin/views/component_dashboard/submitbutton.js delete mode 100644 admin/views/component_dashboard/tmpl/edit.php delete mode 100644 admin/views/component_dashboard/view.html.php delete mode 100644 admin/views/component_files_folders/submitbutton.js delete mode 100644 admin/views/component_files_folders/tmpl/edit.php delete mode 100644 admin/views/component_files_folders/view.html.php delete mode 100644 admin/views/component_modules/submitbutton.js delete mode 100644 admin/views/component_modules/tmpl/edit.php delete mode 100644 admin/views/component_modules/view.html.php delete mode 100644 admin/views/component_mysql_tweaks/submitbutton.js delete mode 100644 admin/views/component_mysql_tweaks/tmpl/edit.php delete mode 100644 admin/views/component_mysql_tweaks/view.html.php delete mode 100644 admin/views/component_placeholders/submitbutton.js delete mode 100644 admin/views/component_placeholders/tmpl/edit.php delete mode 100644 admin/views/component_placeholders/view.html.php delete mode 100644 admin/views/component_plugins/submitbutton.js delete mode 100644 admin/views/component_plugins/tmpl/edit.php delete mode 100644 admin/views/component_plugins/view.html.php delete mode 100644 admin/views/component_site_views/submitbutton.js delete mode 100644 admin/views/component_site_views/tmpl/edit.php delete mode 100644 admin/views/component_site_views/view.html.php delete mode 100644 admin/views/component_updates/submitbutton.js delete mode 100644 admin/views/component_updates/tmpl/edit.php delete mode 100644 admin/views/component_updates/view.html.php delete mode 100644 admin/views/componentbuilder/tmpl/default.php delete mode 100644 admin/views/componentbuilder/tmpl/default_main.php delete mode 100644 admin/views/componentbuilder/tmpl/default_vdm.php delete mode 100644 admin/views/componentbuilder/view.html.php delete mode 100644 admin/views/components_admin_views/tmpl/default.php delete mode 100644 admin/views/components_admin_views/tmpl/default_batch_body.php delete mode 100644 admin/views/components_admin_views/tmpl/default_batch_footer.php delete mode 100644 admin/views/components_admin_views/tmpl/default_body.php delete mode 100644 admin/views/components_admin_views/tmpl/default_foot.php delete mode 100644 admin/views/components_admin_views/tmpl/default_head.php delete mode 100644 admin/views/components_admin_views/tmpl/default_toolbar.php delete mode 100644 admin/views/components_admin_views/view.html.php delete mode 100644 admin/views/components_config/tmpl/default.php delete mode 100644 admin/views/components_config/tmpl/default_batch_body.php delete mode 100644 admin/views/components_config/tmpl/default_batch_footer.php delete mode 100644 admin/views/components_config/tmpl/default_body.php delete mode 100644 admin/views/components_config/tmpl/default_foot.php delete mode 100644 admin/views/components_config/tmpl/default_head.php delete mode 100644 admin/views/components_config/tmpl/default_toolbar.php delete mode 100644 admin/views/components_config/view.html.php delete mode 100644 admin/views/components_custom_admin_menus/tmpl/default.php delete mode 100644 admin/views/components_custom_admin_menus/tmpl/default_batch_body.php delete mode 100644 admin/views/components_custom_admin_menus/tmpl/default_batch_footer.php delete mode 100644 admin/views/components_custom_admin_menus/tmpl/default_body.php delete mode 100644 admin/views/components_custom_admin_menus/tmpl/default_foot.php delete mode 100644 admin/views/components_custom_admin_menus/tmpl/default_head.php delete mode 100644 admin/views/components_custom_admin_menus/tmpl/default_toolbar.php delete mode 100644 admin/views/components_custom_admin_menus/view.html.php delete mode 100644 admin/views/components_custom_admin_views/tmpl/default.php delete mode 100644 admin/views/components_custom_admin_views/tmpl/default_batch_body.php delete mode 100644 admin/views/components_custom_admin_views/tmpl/default_batch_footer.php delete mode 100644 admin/views/components_custom_admin_views/tmpl/default_body.php delete mode 100644 admin/views/components_custom_admin_views/tmpl/default_foot.php delete mode 100644 admin/views/components_custom_admin_views/tmpl/default_head.php delete mode 100644 admin/views/components_custom_admin_views/tmpl/default_toolbar.php delete mode 100644 admin/views/components_custom_admin_views/view.html.php delete mode 100644 admin/views/components_dashboard/tmpl/default.php delete mode 100644 admin/views/components_dashboard/tmpl/default_batch_body.php delete mode 100644 admin/views/components_dashboard/tmpl/default_batch_footer.php delete mode 100644 admin/views/components_dashboard/tmpl/default_body.php delete mode 100644 admin/views/components_dashboard/tmpl/default_foot.php delete mode 100644 admin/views/components_dashboard/tmpl/default_head.php delete mode 100644 admin/views/components_dashboard/tmpl/default_toolbar.php delete mode 100644 admin/views/components_dashboard/view.html.php delete mode 100644 admin/views/components_files_folders/tmpl/default.php delete mode 100644 admin/views/components_files_folders/tmpl/default_batch_body.php delete mode 100644 admin/views/components_files_folders/tmpl/default_batch_footer.php delete mode 100644 admin/views/components_files_folders/tmpl/default_body.php delete mode 100644 admin/views/components_files_folders/tmpl/default_foot.php delete mode 100644 admin/views/components_files_folders/tmpl/default_head.php delete mode 100644 admin/views/components_files_folders/tmpl/default_toolbar.php delete mode 100644 admin/views/components_files_folders/view.html.php delete mode 100644 admin/views/components_modules/tmpl/default.php delete mode 100644 admin/views/components_modules/tmpl/default_batch_body.php delete mode 100644 admin/views/components_modules/tmpl/default_batch_footer.php delete mode 100644 admin/views/components_modules/tmpl/default_body.php delete mode 100644 admin/views/components_modules/tmpl/default_foot.php delete mode 100644 admin/views/components_modules/tmpl/default_head.php delete mode 100644 admin/views/components_modules/tmpl/default_toolbar.php delete mode 100644 admin/views/components_modules/view.html.php delete mode 100644 admin/views/components_mysql_tweaks/tmpl/default.php delete mode 100644 admin/views/components_mysql_tweaks/tmpl/default_batch_body.php delete mode 100644 admin/views/components_mysql_tweaks/tmpl/default_batch_footer.php delete mode 100644 admin/views/components_mysql_tweaks/tmpl/default_body.php delete mode 100644 admin/views/components_mysql_tweaks/tmpl/default_foot.php delete mode 100644 admin/views/components_mysql_tweaks/tmpl/default_head.php delete mode 100644 admin/views/components_mysql_tweaks/tmpl/default_toolbar.php delete mode 100644 admin/views/components_mysql_tweaks/view.html.php delete mode 100644 admin/views/components_placeholders/tmpl/default.php delete mode 100644 admin/views/components_placeholders/tmpl/default_batch_body.php delete mode 100644 admin/views/components_placeholders/tmpl/default_batch_footer.php delete mode 100644 admin/views/components_placeholders/tmpl/default_body.php delete mode 100644 admin/views/components_placeholders/tmpl/default_foot.php delete mode 100644 admin/views/components_placeholders/tmpl/default_head.php delete mode 100644 admin/views/components_placeholders/tmpl/default_toolbar.php delete mode 100644 admin/views/components_placeholders/view.html.php delete mode 100644 admin/views/components_plugins/tmpl/default.php delete mode 100644 admin/views/components_plugins/tmpl/default_batch_body.php delete mode 100644 admin/views/components_plugins/tmpl/default_batch_footer.php delete mode 100644 admin/views/components_plugins/tmpl/default_body.php delete mode 100644 admin/views/components_plugins/tmpl/default_foot.php delete mode 100644 admin/views/components_plugins/tmpl/default_head.php delete mode 100644 admin/views/components_plugins/tmpl/default_toolbar.php delete mode 100644 admin/views/components_plugins/view.html.php delete mode 100644 admin/views/components_site_views/tmpl/default.php delete mode 100644 admin/views/components_site_views/tmpl/default_batch_body.php delete mode 100644 admin/views/components_site_views/tmpl/default_batch_footer.php delete mode 100644 admin/views/components_site_views/tmpl/default_body.php delete mode 100644 admin/views/components_site_views/tmpl/default_foot.php delete mode 100644 admin/views/components_site_views/tmpl/default_head.php delete mode 100644 admin/views/components_site_views/tmpl/default_toolbar.php delete mode 100644 admin/views/components_site_views/view.html.php delete mode 100644 admin/views/components_updates/tmpl/default.php delete mode 100644 admin/views/components_updates/tmpl/default_batch_body.php delete mode 100644 admin/views/components_updates/tmpl/default_batch_footer.php delete mode 100644 admin/views/components_updates/tmpl/default_body.php delete mode 100644 admin/views/components_updates/tmpl/default_foot.php delete mode 100644 admin/views/components_updates/tmpl/default_head.php delete mode 100644 admin/views/components_updates/tmpl/default_toolbar.php delete mode 100644 admin/views/components_updates/view.html.php delete mode 100644 admin/views/custom_admin_view/submitbutton.js delete mode 100644 admin/views/custom_admin_view/tmpl/edit.php delete mode 100644 admin/views/custom_admin_view/view.html.php delete mode 100644 admin/views/custom_admin_views/tmpl/default.php delete mode 100644 admin/views/custom_admin_views/tmpl/default_batch_body.php delete mode 100644 admin/views/custom_admin_views/tmpl/default_batch_footer.php delete mode 100644 admin/views/custom_admin_views/tmpl/default_body.php delete mode 100644 admin/views/custom_admin_views/tmpl/default_foot.php delete mode 100644 admin/views/custom_admin_views/tmpl/default_head.php delete mode 100644 admin/views/custom_admin_views/tmpl/default_toolbar.php delete mode 100644 admin/views/custom_admin_views/view.html.php delete mode 100644 admin/views/custom_code/submitbutton.js delete mode 100644 admin/views/custom_code/tmpl/edit.php delete mode 100644 admin/views/custom_code/view.html.php delete mode 100644 admin/views/custom_codes/tmpl/default.php delete mode 100644 admin/views/custom_codes/tmpl/default_batch_body.php delete mode 100644 admin/views/custom_codes/tmpl/default_batch_footer.php delete mode 100644 admin/views/custom_codes/tmpl/default_body.php delete mode 100644 admin/views/custom_codes/tmpl/default_foot.php delete mode 100644 admin/views/custom_codes/tmpl/default_head.php delete mode 100644 admin/views/custom_codes/tmpl/default_toolbar.php delete mode 100644 admin/views/custom_codes/view.html.php delete mode 100644 admin/views/dynamic_get/submitbutton.js delete mode 100644 admin/views/dynamic_get/tmpl/edit.php delete mode 100644 admin/views/dynamic_get/view.html.php delete mode 100644 admin/views/dynamic_gets/tmpl/default.php delete mode 100644 admin/views/dynamic_gets/tmpl/default_batch_body.php delete mode 100644 admin/views/dynamic_gets/tmpl/default_batch_footer.php delete mode 100644 admin/views/dynamic_gets/tmpl/default_body.php delete mode 100644 admin/views/dynamic_gets/tmpl/default_foot.php delete mode 100644 admin/views/dynamic_gets/tmpl/default_head.php delete mode 100644 admin/views/dynamic_gets/tmpl/default_toolbar.php delete mode 100644 admin/views/dynamic_gets/view.html.php delete mode 100644 admin/views/field/submitbutton.js delete mode 100644 admin/views/field/tmpl/edit.php delete mode 100644 admin/views/field/view.html.php delete mode 100644 admin/views/fields/tmpl/default.php delete mode 100644 admin/views/fields/tmpl/default_batch_body.php delete mode 100644 admin/views/fields/tmpl/default_batch_footer.php delete mode 100644 admin/views/fields/tmpl/default_body.php delete mode 100644 admin/views/fields/tmpl/default_foot.php delete mode 100644 admin/views/fields/tmpl/default_head.php delete mode 100644 admin/views/fields/tmpl/default_toolbar.php delete mode 100644 admin/views/fields/view.html.php delete mode 100644 admin/views/fieldtype/submitbutton.js delete mode 100644 admin/views/fieldtype/tmpl/edit.php delete mode 100644 admin/views/fieldtype/view.html.php delete mode 100644 admin/views/fieldtypes/tmpl/default.php delete mode 100644 admin/views/fieldtypes/tmpl/default_batch_body.php delete mode 100644 admin/views/fieldtypes/tmpl/default_batch_footer.php delete mode 100644 admin/views/fieldtypes/tmpl/default_body.php delete mode 100644 admin/views/fieldtypes/tmpl/default_foot.php delete mode 100644 admin/views/fieldtypes/tmpl/default_head.php delete mode 100644 admin/views/fieldtypes/tmpl/default_toolbar.php delete mode 100644 admin/views/fieldtypes/view.html.php delete mode 100644 admin/views/get_snippets/tmpl/default.php delete mode 100644 admin/views/get_snippets/view.html.php delete mode 100644 admin/views/help_document/submitbutton.js delete mode 100644 admin/views/help_document/tmpl/edit.php delete mode 100644 admin/views/help_document/view.html.php delete mode 100644 admin/views/help_documents/tmpl/default.php delete mode 100644 admin/views/help_documents/tmpl/default_batch_body.php delete mode 100644 admin/views/help_documents/tmpl/default_batch_footer.php delete mode 100644 admin/views/help_documents/tmpl/default_body.php delete mode 100644 admin/views/help_documents/tmpl/default_foot.php delete mode 100644 admin/views/help_documents/tmpl/default_head.php delete mode 100644 admin/views/help_documents/tmpl/default_toolbar.php delete mode 100644 admin/views/help_documents/view.html.php delete mode 100644 admin/views/import/tmpl/default.php delete mode 100644 admin/views/import/view.html.php delete mode 100644 admin/views/import_joomla_components/tmpl/default.php delete mode 100644 admin/views/import_joomla_components/view.html.php delete mode 100644 admin/views/import_language_translations/tmpl/default.php delete mode 100644 admin/views/import_language_translations/view.html.php delete mode 100644 admin/views/joomla_component/submitbutton.js delete mode 100644 admin/views/joomla_component/tmpl/edit.php delete mode 100644 admin/views/joomla_component/view.html.php delete mode 100644 admin/views/joomla_components/tmpl/default.php delete mode 100644 admin/views/joomla_components/tmpl/default_batch_body.php delete mode 100644 admin/views/joomla_components/tmpl/default_batch_footer.php delete mode 100644 admin/views/joomla_components/tmpl/default_body.php delete mode 100644 admin/views/joomla_components/tmpl/default_foot.php delete mode 100644 admin/views/joomla_components/tmpl/default_head.php delete mode 100644 admin/views/joomla_components/tmpl/default_toolbar.php delete mode 100644 admin/views/joomla_components/view.html.php delete mode 100644 admin/views/joomla_module/submitbutton.js delete mode 100644 admin/views/joomla_module/tmpl/edit.php delete mode 100644 admin/views/joomla_module/view.html.php delete mode 100644 admin/views/joomla_module_files_folders_urls/submitbutton.js delete mode 100644 admin/views/joomla_module_files_folders_urls/tmpl/edit.php delete mode 100644 admin/views/joomla_module_files_folders_urls/view.html.php delete mode 100644 admin/views/joomla_module_updates/submitbutton.js delete mode 100644 admin/views/joomla_module_updates/tmpl/edit.php delete mode 100644 admin/views/joomla_module_updates/view.html.php delete mode 100644 admin/views/joomla_modules/tmpl/default.php delete mode 100644 admin/views/joomla_modules/tmpl/default_batch_body.php delete mode 100644 admin/views/joomla_modules/tmpl/default_batch_footer.php delete mode 100644 admin/views/joomla_modules/tmpl/default_body.php delete mode 100644 admin/views/joomla_modules/tmpl/default_foot.php delete mode 100644 admin/views/joomla_modules/tmpl/default_head.php delete mode 100644 admin/views/joomla_modules/tmpl/default_toolbar.php delete mode 100644 admin/views/joomla_modules/view.html.php delete mode 100644 admin/views/joomla_modules_files_folders_urls/tmpl/default.php delete mode 100644 admin/views/joomla_modules_files_folders_urls/tmpl/default_batch_body.php delete mode 100644 admin/views/joomla_modules_files_folders_urls/tmpl/default_batch_footer.php delete mode 100644 admin/views/joomla_modules_files_folders_urls/tmpl/default_body.php delete mode 100644 admin/views/joomla_modules_files_folders_urls/tmpl/default_foot.php delete mode 100644 admin/views/joomla_modules_files_folders_urls/tmpl/default_head.php delete mode 100644 admin/views/joomla_modules_files_folders_urls/tmpl/default_toolbar.php delete mode 100644 admin/views/joomla_modules_files_folders_urls/view.html.php delete mode 100644 admin/views/joomla_modules_updates/tmpl/default.php delete mode 100644 admin/views/joomla_modules_updates/tmpl/default_batch_body.php delete mode 100644 admin/views/joomla_modules_updates/tmpl/default_batch_footer.php delete mode 100644 admin/views/joomla_modules_updates/tmpl/default_body.php delete mode 100644 admin/views/joomla_modules_updates/tmpl/default_foot.php delete mode 100644 admin/views/joomla_modules_updates/tmpl/default_head.php delete mode 100644 admin/views/joomla_modules_updates/tmpl/default_toolbar.php delete mode 100644 admin/views/joomla_modules_updates/view.html.php delete mode 100644 admin/views/joomla_plugin/submitbutton.js delete mode 100644 admin/views/joomla_plugin/tmpl/edit.php delete mode 100644 admin/views/joomla_plugin/view.html.php delete mode 100644 admin/views/joomla_plugin_files_folders_urls/submitbutton.js delete mode 100644 admin/views/joomla_plugin_files_folders_urls/tmpl/edit.php delete mode 100644 admin/views/joomla_plugin_files_folders_urls/view.html.php delete mode 100644 admin/views/joomla_plugin_group/submitbutton.js delete mode 100644 admin/views/joomla_plugin_group/tmpl/edit.php delete mode 100644 admin/views/joomla_plugin_group/view.html.php delete mode 100644 admin/views/joomla_plugin_groups/tmpl/default.php delete mode 100644 admin/views/joomla_plugin_groups/tmpl/default_batch_body.php delete mode 100644 admin/views/joomla_plugin_groups/tmpl/default_batch_footer.php delete mode 100644 admin/views/joomla_plugin_groups/tmpl/default_body.php delete mode 100644 admin/views/joomla_plugin_groups/tmpl/default_foot.php delete mode 100644 admin/views/joomla_plugin_groups/tmpl/default_head.php delete mode 100644 admin/views/joomla_plugin_groups/tmpl/default_toolbar.php delete mode 100644 admin/views/joomla_plugin_groups/view.html.php delete mode 100644 admin/views/joomla_plugin_updates/submitbutton.js delete mode 100644 admin/views/joomla_plugin_updates/tmpl/edit.php delete mode 100644 admin/views/joomla_plugin_updates/view.html.php delete mode 100644 admin/views/joomla_plugins/tmpl/default.php delete mode 100644 admin/views/joomla_plugins/tmpl/default_batch_body.php delete mode 100644 admin/views/joomla_plugins/tmpl/default_batch_footer.php delete mode 100644 admin/views/joomla_plugins/tmpl/default_body.php delete mode 100644 admin/views/joomla_plugins/tmpl/default_foot.php delete mode 100644 admin/views/joomla_plugins/tmpl/default_head.php delete mode 100644 admin/views/joomla_plugins/tmpl/default_toolbar.php delete mode 100644 admin/views/joomla_plugins/view.html.php delete mode 100644 admin/views/joomla_plugins_files_folders_urls/tmpl/default.php delete mode 100644 admin/views/joomla_plugins_files_folders_urls/tmpl/default_batch_body.php delete mode 100644 admin/views/joomla_plugins_files_folders_urls/tmpl/default_batch_footer.php delete mode 100644 admin/views/joomla_plugins_files_folders_urls/tmpl/default_body.php delete mode 100644 admin/views/joomla_plugins_files_folders_urls/tmpl/default_foot.php delete mode 100644 admin/views/joomla_plugins_files_folders_urls/tmpl/default_head.php delete mode 100644 admin/views/joomla_plugins_files_folders_urls/tmpl/default_toolbar.php delete mode 100644 admin/views/joomla_plugins_files_folders_urls/view.html.php delete mode 100644 admin/views/joomla_plugins_updates/tmpl/default.php delete mode 100644 admin/views/joomla_plugins_updates/tmpl/default_batch_body.php delete mode 100644 admin/views/joomla_plugins_updates/tmpl/default_batch_footer.php delete mode 100644 admin/views/joomla_plugins_updates/tmpl/default_body.php delete mode 100644 admin/views/joomla_plugins_updates/tmpl/default_foot.php delete mode 100644 admin/views/joomla_plugins_updates/tmpl/default_head.php delete mode 100644 admin/views/joomla_plugins_updates/tmpl/default_toolbar.php delete mode 100644 admin/views/joomla_plugins_updates/view.html.php delete mode 100644 admin/views/language/submitbutton.js delete mode 100644 admin/views/language/tmpl/edit.php delete mode 100644 admin/views/language/view.html.php delete mode 100644 admin/views/language_translation/submitbutton.js delete mode 100644 admin/views/language_translation/tmpl/edit.php delete mode 100644 admin/views/language_translation/view.html.php delete mode 100644 admin/views/language_translations/tmpl/default.php delete mode 100644 admin/views/language_translations/tmpl/default_batch_body.php delete mode 100644 admin/views/language_translations/tmpl/default_batch_footer.php delete mode 100644 admin/views/language_translations/tmpl/default_body.php delete mode 100644 admin/views/language_translations/tmpl/default_foot.php delete mode 100644 admin/views/language_translations/tmpl/default_head.php delete mode 100644 admin/views/language_translations/tmpl/default_toolbar.php delete mode 100644 admin/views/language_translations/view.html.php delete mode 100644 admin/views/languages/tmpl/default.php delete mode 100644 admin/views/languages/tmpl/default_batch_body.php delete mode 100644 admin/views/languages/tmpl/default_batch_footer.php delete mode 100644 admin/views/languages/tmpl/default_body.php delete mode 100644 admin/views/languages/tmpl/default_foot.php delete mode 100644 admin/views/languages/tmpl/default_head.php delete mode 100644 admin/views/languages/tmpl/default_toolbar.php delete mode 100644 admin/views/languages/view.html.php delete mode 100644 admin/views/layout/submitbutton.js delete mode 100644 admin/views/layout/tmpl/edit.php delete mode 100644 admin/views/layout/view.html.php delete mode 100644 admin/views/layouts/tmpl/default.php delete mode 100644 admin/views/layouts/tmpl/default_batch_body.php delete mode 100644 admin/views/layouts/tmpl/default_batch_footer.php delete mode 100644 admin/views/layouts/tmpl/default_body.php delete mode 100644 admin/views/layouts/tmpl/default_foot.php delete mode 100644 admin/views/layouts/tmpl/default_head.php delete mode 100644 admin/views/layouts/tmpl/default_toolbar.php delete mode 100644 admin/views/layouts/view.html.php delete mode 100644 admin/views/libraries/tmpl/default.php delete mode 100644 admin/views/libraries/tmpl/default_batch_body.php delete mode 100644 admin/views/libraries/tmpl/default_batch_footer.php delete mode 100644 admin/views/libraries/tmpl/default_body.php delete mode 100644 admin/views/libraries/tmpl/default_foot.php delete mode 100644 admin/views/libraries/tmpl/default_head.php delete mode 100644 admin/views/libraries/tmpl/default_toolbar.php delete mode 100644 admin/views/libraries/view.html.php delete mode 100644 admin/views/libraries_config/tmpl/default.php delete mode 100644 admin/views/libraries_config/tmpl/default_batch_body.php delete mode 100644 admin/views/libraries_config/tmpl/default_batch_footer.php delete mode 100644 admin/views/libraries_config/tmpl/default_body.php delete mode 100644 admin/views/libraries_config/tmpl/default_foot.php delete mode 100644 admin/views/libraries_config/tmpl/default_head.php delete mode 100644 admin/views/libraries_config/tmpl/default_toolbar.php delete mode 100644 admin/views/libraries_config/view.html.php delete mode 100644 admin/views/libraries_files_folders_urls/tmpl/default.php delete mode 100644 admin/views/libraries_files_folders_urls/tmpl/default_batch_body.php delete mode 100644 admin/views/libraries_files_folders_urls/tmpl/default_batch_footer.php delete mode 100644 admin/views/libraries_files_folders_urls/tmpl/default_body.php delete mode 100644 admin/views/libraries_files_folders_urls/tmpl/default_foot.php delete mode 100644 admin/views/libraries_files_folders_urls/tmpl/default_head.php delete mode 100644 admin/views/libraries_files_folders_urls/tmpl/default_toolbar.php delete mode 100644 admin/views/libraries_files_folders_urls/view.html.php delete mode 100644 admin/views/library/submitbutton.js delete mode 100644 admin/views/library/tmpl/edit.php delete mode 100644 admin/views/library/view.html.php delete mode 100644 admin/views/library_config/submitbutton.js delete mode 100644 admin/views/library_config/tmpl/edit.php delete mode 100644 admin/views/library_config/view.html.php delete mode 100644 admin/views/library_files_folders_urls/submitbutton.js delete mode 100644 admin/views/library_files_folders_urls/tmpl/edit.php delete mode 100644 admin/views/library_files_folders_urls/view.html.php delete mode 100644 admin/views/placeholder/submitbutton.js delete mode 100644 admin/views/placeholder/tmpl/edit.php delete mode 100644 admin/views/placeholder/view.html.php delete mode 100644 admin/views/placeholders/tmpl/default.php delete mode 100644 admin/views/placeholders/tmpl/default_batch_body.php delete mode 100644 admin/views/placeholders/tmpl/default_batch_footer.php delete mode 100644 admin/views/placeholders/tmpl/default_body.php delete mode 100644 admin/views/placeholders/tmpl/default_foot.php delete mode 100644 admin/views/placeholders/tmpl/default_head.php delete mode 100644 admin/views/placeholders/tmpl/default_toolbar.php delete mode 100644 admin/views/placeholders/view.html.php delete mode 100644 admin/views/power/submitbutton.js delete mode 100644 admin/views/power/tmpl/edit.php delete mode 100644 admin/views/power/view.html.php delete mode 100644 admin/views/powers/tmpl/default.php delete mode 100644 admin/views/powers/tmpl/default_batch_body.php delete mode 100644 admin/views/powers/tmpl/default_batch_footer.php delete mode 100644 admin/views/powers/tmpl/default_body.php delete mode 100644 admin/views/powers/tmpl/default_foot.php delete mode 100644 admin/views/powers/tmpl/default_head.php delete mode 100644 admin/views/powers/tmpl/default_toolbar.php delete mode 100644 admin/views/powers/view.html.php delete mode 100644 admin/views/search/tmpl/default.php delete mode 100644 admin/views/search/view.html.php delete mode 100644 admin/views/server/submitbutton.js delete mode 100644 admin/views/server/tmpl/edit.php delete mode 100644 admin/views/server/view.html.php delete mode 100644 admin/views/servers/tmpl/default.php delete mode 100644 admin/views/servers/tmpl/default_batch_body.php delete mode 100644 admin/views/servers/tmpl/default_batch_footer.php delete mode 100644 admin/views/servers/tmpl/default_body.php delete mode 100644 admin/views/servers/tmpl/default_foot.php delete mode 100644 admin/views/servers/tmpl/default_head.php delete mode 100644 admin/views/servers/tmpl/default_toolbar.php delete mode 100644 admin/views/servers/view.html.php delete mode 100644 admin/views/site_view/submitbutton.js delete mode 100644 admin/views/site_view/tmpl/edit.php delete mode 100644 admin/views/site_view/view.html.php delete mode 100644 admin/views/site_views/tmpl/default.php delete mode 100644 admin/views/site_views/tmpl/default_batch_body.php delete mode 100644 admin/views/site_views/tmpl/default_batch_footer.php delete mode 100644 admin/views/site_views/tmpl/default_body.php delete mode 100644 admin/views/site_views/tmpl/default_foot.php delete mode 100644 admin/views/site_views/tmpl/default_head.php delete mode 100644 admin/views/site_views/tmpl/default_toolbar.php delete mode 100644 admin/views/site_views/view.html.php delete mode 100644 admin/views/snippet/submitbutton.js delete mode 100644 admin/views/snippet/tmpl/edit.php delete mode 100644 admin/views/snippet/view.html.php delete mode 100644 admin/views/snippet_type/submitbutton.js delete mode 100644 admin/views/snippet_type/tmpl/edit.php delete mode 100644 admin/views/snippet_type/view.html.php delete mode 100644 admin/views/snippet_types/tmpl/default.php delete mode 100644 admin/views/snippet_types/tmpl/default_batch_body.php delete mode 100644 admin/views/snippet_types/tmpl/default_batch_footer.php delete mode 100644 admin/views/snippet_types/tmpl/default_body.php delete mode 100644 admin/views/snippet_types/tmpl/default_foot.php delete mode 100644 admin/views/snippet_types/tmpl/default_head.php delete mode 100644 admin/views/snippet_types/tmpl/default_toolbar.php delete mode 100644 admin/views/snippet_types/view.html.php delete mode 100644 admin/views/snippets/tmpl/default.php delete mode 100644 admin/views/snippets/tmpl/default_batch_body.php delete mode 100644 admin/views/snippets/tmpl/default_batch_footer.php delete mode 100644 admin/views/snippets/tmpl/default_body.php delete mode 100644 admin/views/snippets/tmpl/default_foot.php delete mode 100644 admin/views/snippets/tmpl/default_head.php delete mode 100644 admin/views/snippets/tmpl/default_toolbar.php delete mode 100644 admin/views/snippets/view.html.php delete mode 100644 admin/views/template/submitbutton.js delete mode 100644 admin/views/template/tmpl/edit.php delete mode 100644 admin/views/template/view.html.php delete mode 100644 admin/views/templates/tmpl/default.php delete mode 100644 admin/views/templates/tmpl/default_batch_body.php delete mode 100644 admin/views/templates/tmpl/default_batch_footer.php delete mode 100644 admin/views/templates/tmpl/default_body.php delete mode 100644 admin/views/templates/tmpl/default_foot.php delete mode 100644 admin/views/templates/tmpl/default_head.php delete mode 100644 admin/views/templates/tmpl/default_toolbar.php delete mode 100644 admin/views/templates/view.html.php delete mode 100644 admin/views/validation_rule/submitbutton.js delete mode 100644 admin/views/validation_rule/tmpl/edit.php delete mode 100644 admin/views/validation_rule/view.html.php delete mode 100644 admin/views/validation_rules/tmpl/default.php delete mode 100644 admin/views/validation_rules/tmpl/default_batch_body.php delete mode 100644 admin/views/validation_rules/tmpl/default_batch_footer.php delete mode 100644 admin/views/validation_rules/tmpl/default_body.php delete mode 100644 admin/views/validation_rules/tmpl/default_foot.php delete mode 100644 admin/views/validation_rules/tmpl/default_head.php delete mode 100644 admin/views/validation_rules/tmpl/default_toolbar.php delete mode 100644 admin/views/validation_rules/view.html.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Controller/AllowAdd.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Controller/AllowEdit.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Controller/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Model/CanDelete.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Model/CanEditState.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Model/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Controller/AllowAdd.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Controller/AllowEdit.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Controller/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Model/CanDelete.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Model/CanEditState.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Model/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Controller/AllowAdd.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Controller/AllowEdit.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Controller/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Model/CanDelete.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Model/CanEditState.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Model/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/AssetsRules.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/ConfigFieldsets.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/ConfigFieldsetsCustomfield.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/Contributors.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/DatabaseUninstall.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/ExtensionsParams.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/FrontendParams.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/HasMenuGlobal.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/LanguageMessages.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/PermissionFields.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/Request.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/Router.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/ViewsDefaultOrdering.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaFive/Settings.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaFive/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaFour/Settings.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaFour/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaThree/Settings.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaThree/index.html delete mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Settings.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/AccessSections.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/AccessSectionsCategory.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/AccessSectionsJoomlaFields.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsets.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsCustomfield.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsEmailHelper.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsEncryption.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsGlobal.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsGooglechart.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsGroupControl.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsSiteControl.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsUikit.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/CustomButtonPermissions.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/Request.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/Router.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/RouterConstructorDefault.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/RouterConstructorManual.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/RouterMethodsDefault.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/RouterMethodsManual.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaFive/InstallScript.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaFive/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaFour/InstallScript.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaFour/index.html delete mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/InputButton.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFive/CoreField.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFive/CoreRule.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFive/InputButton.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFive/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFour/CoreField.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFour/CoreRule.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFour/InputButton.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFour/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaThree/CoreField.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaThree/CoreRule.php delete mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaThree/CoreValidation.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaThree/InputButton.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/Rule.php delete mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/Validation.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Compiler.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Fields.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Get.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Infusion.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Interpretation.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Structure.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Controller/AllowAddInterface.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Controller/AllowEditInterface.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Controller/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Model/CanDeleteInterface.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Model/CanEditStateInterface.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Model/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Component/SettingsInterface.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Field/CoreFieldInterface.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Field/CoreRuleInterface.php delete mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Field/CoreValidationInterface.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Field/InputButtonInterface.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/HeaderInterface.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Model/CustomtabsInterface.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Model/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFive/Event.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFive/Header.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFive/History.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFive/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFour/Event.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFour/Header.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFour/History.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFour/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaThree/Header.php delete mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/Customtabs.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaFive/Customtabs.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaFive/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaFour/Customtabs.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaFour/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaThree/Customtabs.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaThree/index.html create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/Router.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/ArchitectureController.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/ArchitectureModel.php delete mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Builder.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/BuilderAJ.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/BuilderLZ.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Header.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Utilities/FileInjector.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Extrusion/Helper/Builder.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Extrusion/Helper/Extrusion.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Extrusion/Helper/Mapping.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Extrusion/Helper/index.html delete mode 100644 libraries/jcb_powers/VDM.Joomla/src/Utilities.php create mode 100644 media/js/component_router.js delete mode 100644 script.php delete mode 100644 site/assets/css/site.css delete mode 100644 site/assets/js/site.js delete mode 100644 site/componentbuilder.php delete mode 100644 site/controller.php delete mode 100644 site/controllers/api.php delete mode 100644 site/controllers/help.php delete mode 100644 site/helpers/category.php delete mode 100644 site/helpers/categoryfield.php delete mode 100644 site/helpers/categoryfieldtype.php delete mode 100644 site/helpers/componentbuilder.php delete mode 100644 site/helpers/headercheck.php delete mode 100644 site/helpers/route.php delete mode 100644 site/language/en-GB/en-GB.com_componentbuilder.ini delete mode 100644 site/language/en-GB/en-GB.com_componentbuilder.sys.ini delete mode 100644 site/models/api.php delete mode 100644 site/router.php delete mode 100644 site/views/api/submitbutton.js delete mode 100644 site/views/api/tmpl/default.php delete mode 100644 site/views/api/view.html.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bcc73892..48a338b3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,61 +1,11 @@ -# v3.1.28 +# v5.0.0-alpha1 -- Updates PHPSecLib. -- Fixed connection failure to remote server. -- Adds overriding of back-folder and git-folder on component level. +- First alpha release of Component Builder towards Joomla 5 (very unstable...) -# v3.1.27 +# v4.0.0-alpha1 -- Adds better remote repository management for the super power features. -- Fixes #1014 so that powers are added to components. +- First alpha release of Component Builder towards Joomla 4 (very unstable...) -# v3.1.26 +# v3.2.0-beta4 -- Fixed changelog direction so newest changes is listed at top of the file. -- Finished the init function of super powers. -- Adds rest function inside super power. -- Adds super powers to all templates. -- Updates many helper class methods to now use the utility classes. -- Adds the `spl_autoload_register` method to the component entry file (as-well). -- Moved most methods from the compiler fields class to powers. #955 -- Refactored many new builder classes from the registry class. -- Converted the Content class to two builder classes. -- Adds option to add additional templates to a module. -- Resolves #1002 by adding STRING instead of WORD. -- Ported the FOF encryption class into Powers. https://git.vdm.dev/joomla/fof -- Changed all CSS and JS to use `JHtml::_(` instead of `$this->document->` in compiler code. -- Adds option to turn jQuery off if UIKIT 3 is added. -- Adds option to auto write injection boilerplate code in Powers area. -- Adds option to auto write service provider boilerplate code in the Powers area. -- Improved the `getDynamicContent` method and all banner locations to fetch from https://git.vdm.dev/joomla/jcb-external/ instead. -- Major stability improvements all over the new powers complier classes. -- New [base Registry class](https://git.vdm.dev/joomla/super-powers/src/branch/master/src/7e822c03-1b20-41d1-9427-f5b8d5836af7) has been created specially for JCB. -- Remember to update all plug-ins with this version update (use the package). - -# v3.1.24 - -- Fix the update server #978 issue. -- Fixed the change log to load all entries, not just the last one. -- Fixed #983 so that database updates are created when adding a new adminview -- Moved a few builder arrays to the Compiler Registry -- Adds super powers to JCB -- Adds Gitea API library -- Improves Power filters -- Fix #991 to add the Utilities service class -- Adds Superpower Key (SPK) replacement feature -- Adds Superpower search (GREP) feature -- Adds Power Insert/Update Classes -- Fix #995 that all update sites are using the correct URL - -# v3.1.19 - -- We fixed #972 so that custom code (in the header) will be added after the power namespaces -- We added a message to show when a server move failed -- We fixed the BaseConfig to not use '_' as separator -- We fixed the footable loading issue -- We removed the need for passing placeholders by reference -- We added the option to generate a CHANGELOG -- We fixed the server class to load new client if server details changed. -- We fixed the readme placeholder issue #978. -- We fixed the empty server url issue #978. -- Fixed Package import to now use the phplibsec version 3 \ No newline at end of file +- Add Preferred Joomla Version to Components \ No newline at end of file diff --git a/ComponentbuilderInstallerScript.php b/ComponentbuilderInstallerScript.php new file mode 100644 index 000000000..c0feacc41 --- /dev/null +++ b/ComponentbuilderInstallerScript.php @@ -0,0 +1,4813 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Installer\InstallerAdapter; +use Joomla\CMS\Installer\InstallerScriptInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\Log\Log; +use Joomla\CMS\Version; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\Filesystem\Folder; +use Joomla\Database\DatabaseInterface; + +// No direct access to this file +defined('_JEXEC') or die; + +/** + * Script File of Componentbuilder Component + * + * @since 3.6 + */ +class Com_ComponentbuilderInstallerScript implements InstallerScriptInterface +{ + /** + * The CMS Application. + * + * @var CMSApplication + * @since 4.4.2 + */ + protected CMSApplication $app; + + /** + * The database class. + * + * @since 4.4.2 + */ + protected $db; + + /** + * The version number of the extension. + * + * @var string + * @since 3.6 + */ + protected $release; + + /** + * The table the parameters are stored in. + * + * @var string + * @since 3.6 + */ + protected $paramTable; + + /** + * The extension name. This should be set in the installer script. + * + * @var string + * @since 3.6 + */ + protected $extension; + + /** + * A list of files to be deleted + * + * @var array + * @since 3.6 + */ + protected $deleteFiles = []; + + /** + * A list of folders to be deleted + * + * @var array + * @since 3.6 + */ + protected $deleteFolders = []; + + /** + * A list of CLI script files to be copied to the cli directory + * + * @var array + * @since 3.6 + */ + protected $cliScriptFiles = []; + + /** + * Minimum PHP version required to install the extension + * + * @var string + * @since 3.6 + */ + protected $minimumPhp; + + /** + * Minimum Joomla! version required to install the extension + * + * @var string + * @since 3.6 + */ + protected $minimumJoomla; + + /** + * Extension script constructor. + * + * @since 3.0.0 + */ + public function __construct() + { + $this->minimumJoomla = '4.3'; + $this->minimumPhp = JOOMLA_MINIMUM_PHP; + $this->app ??= Factory::getApplication(); + $this->db = Factory::getContainer()->get(DatabaseInterface::class); + + // check if the files exist + if (is_file(JPATH_ROOT . '/administrator/components/com_componentbuilder/componentbuilder.php')) + { + // remove Joomla 3 files + $this->deleteFiles = [ + '/administrator/components/com_componentbuilder/componentbuilder.php', + '/administrator/components/com_componentbuilder/controller.php', + '/components/com_componentbuilder/componentbuilder.php', + '/components/com_componentbuilder/controller.php', + '/components/com_componentbuilder/router.php', + ]; + } + + // check if the Folders exist + if (is_dir(JPATH_ROOT . '/administrator/components/com_componentbuilder/modules')) + { + // remove Joomla 3 folder + $this->deleteFolders = [ + '/administrator/components/com_componentbuilder/controllers', + '/administrator/components/com_componentbuilder/helpers', + '/administrator/components/com_componentbuilder/modules', + '/administrator/components/com_componentbuilder/tables', + '/administrator/components/com_componentbuilder/views', + '/components/com_componentbuilder/controllers', + '/components/com_componentbuilder/helpers', + '/components/com_componentbuilder/modules', + '/components/com_componentbuilder/views', + ]; + } + } + + /** + * Function called after the extension is installed. + * + * @param InstallerAdapter $adapter The adapter calling this method + * + * @return boolean True on success + * + * @since 4.2.0 + */ + public function install(InstallerAdapter $adapter): bool {return true;} + + /** + * Function called after the extension is updated. + * + * @param InstallerAdapter $adapter The adapter calling this method + * + * @return boolean True on success + * + * @since 4.2.0 + */ + public function update(InstallerAdapter $adapter): bool {return true;} + + /** + * Function called after the extension is uninstalled. + * + * @param InstallerAdapter $adapter The adapter calling this method + * + * @return boolean True on success + * + * @since 4.2.0 + */ + public function uninstall(InstallerAdapter $adapter): bool + { + // Remove Related Component Data. + + // Remove Joomla component Data + $this->removeViewData("com_componentbuilder.joomla_component"); + + // Remove Joomla module Data + $this->removeViewData("com_componentbuilder.joomla_module"); + + // Remove Joomla plugin Data + $this->removeViewData("com_componentbuilder.joomla_plugin"); + + // Remove Power Data + $this->removeViewData("com_componentbuilder.power"); + + // Remove Admin view Data + $this->removeViewData("com_componentbuilder.admin_view"); + + // Remove Custom admin view Data + $this->removeViewData("com_componentbuilder.custom_admin_view"); + + // Remove Site view Data + $this->removeViewData("com_componentbuilder.site_view"); + + // Remove Template Data + $this->removeViewData("com_componentbuilder.template"); + + // Remove Layout Data + $this->removeViewData("com_componentbuilder.layout"); + + // Remove Dynamic get Data + $this->removeViewData("com_componentbuilder.dynamic_get"); + + // Remove Custom code Data + $this->removeViewData("com_componentbuilder.custom_code"); + + // Remove Class property Data + $this->removeViewData("com_componentbuilder.class_property"); + + // Remove Class method Data + $this->removeViewData("com_componentbuilder.class_method"); + + // Remove Placeholder Data + $this->removeViewData("com_componentbuilder.placeholder"); + + // Remove Library Data + $this->removeViewData("com_componentbuilder.library"); + + // Remove Snippet Data + $this->removeViewData("com_componentbuilder.snippet"); + + // Remove Validation rule Data + $this->removeViewData("com_componentbuilder.validation_rule"); + + // Remove Field Data + $this->removeViewData("com_componentbuilder.field"); + + // Remove Field catid Data + $this->removeViewData("com_componentbuilder.field.category"); + + // Remove Fieldtype Data + $this->removeViewData("com_componentbuilder.fieldtype"); + + // Remove Fieldtype catid Data + $this->removeViewData("com_componentbuilder.fieldtype.category"); + + // Remove Language translation Data + $this->removeViewData("com_componentbuilder.language_translation"); + + // Remove Language Data + $this->removeViewData("com_componentbuilder.language"); + + // Remove Server Data + $this->removeViewData("com_componentbuilder.server"); + + // Remove Help document Data + $this->removeViewData("com_componentbuilder.help_document"); + + // Remove Admin fields Data + $this->removeViewData("com_componentbuilder.admin_fields"); + + // Remove Admin fields conditions Data + $this->removeViewData("com_componentbuilder.admin_fields_conditions"); + + // Remove Admin fields relations Data + $this->removeViewData("com_componentbuilder.admin_fields_relations"); + + // Remove Admin custom tabs Data + $this->removeViewData("com_componentbuilder.admin_custom_tabs"); + + // Remove Component admin views Data + $this->removeViewData("com_componentbuilder.component_admin_views"); + + // Remove Component site views Data + $this->removeViewData("com_componentbuilder.component_site_views"); + + // Remove Component custom admin views Data + $this->removeViewData("com_componentbuilder.component_custom_admin_views"); + + // Remove Component updates Data + $this->removeViewData("com_componentbuilder.component_updates"); + + // Remove Component mysql tweaks Data + $this->removeViewData("com_componentbuilder.component_mysql_tweaks"); + + // Remove Component custom admin menus Data + $this->removeViewData("com_componentbuilder.component_custom_admin_menus"); + + // Remove Component router Data + $this->removeViewData("com_componentbuilder.component_router"); + + // Remove Component config Data + $this->removeViewData("com_componentbuilder.component_config"); + + // Remove Component dashboard Data + $this->removeViewData("com_componentbuilder.component_dashboard"); + + // Remove Component files folders Data + $this->removeViewData("com_componentbuilder.component_files_folders"); + + // Remove Component placeholders Data + $this->removeViewData("com_componentbuilder.component_placeholders"); + + // Remove Component plugins Data + $this->removeViewData("com_componentbuilder.component_plugins"); + + // Remove Component modules Data + $this->removeViewData("com_componentbuilder.component_modules"); + + // Remove Snippet type Data + $this->removeViewData("com_componentbuilder.snippet_type"); + + // Remove Library config Data + $this->removeViewData("com_componentbuilder.library_config"); + + // Remove Library files folders urls Data + $this->removeViewData("com_componentbuilder.library_files_folders_urls"); + + // Remove Class extends Data + $this->removeViewData("com_componentbuilder.class_extends"); + + // Remove Joomla module updates Data + $this->removeViewData("com_componentbuilder.joomla_module_updates"); + + // Remove Joomla module files folders urls Data + $this->removeViewData("com_componentbuilder.joomla_module_files_folders_urls"); + + // Remove Joomla plugin group Data + $this->removeViewData("com_componentbuilder.joomla_plugin_group"); + + // Remove Joomla plugin updates Data + $this->removeViewData("com_componentbuilder.joomla_plugin_updates"); + + // Remove Joomla plugin files folders urls Data + $this->removeViewData("com_componentbuilder.joomla_plugin_files_folders_urls"); + + // Remove Asset Data. + $this->removeAssetData(); + + // Revert the assets table rules column back to the default. + $this->removeDatabaseAssetsRulesFix(); + + // Remove component from action logs extensions table. + $this->removeActionLogsExtensions(); + + // Remove Joomla_component from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.joomla_component'); + + // Remove Joomla_module from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.joomla_module'); + + // Remove Joomla_plugin from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.joomla_plugin'); + + // Remove Power from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.power'); + + // Remove Admin_view from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.admin_view'); + + // Remove Custom_admin_view from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.custom_admin_view'); + + // Remove Site_view from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.site_view'); + + // Remove Template from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.template'); + + // Remove Layout from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.layout'); + + // Remove Dynamic_get from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.dynamic_get'); + + // Remove Custom_code from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.custom_code'); + + // Remove Class_property from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.class_property'); + + // Remove Class_method from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.class_method'); + + // Remove Placeholder from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.placeholder'); + + // Remove Library from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.library'); + + // Remove Snippet from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.snippet'); + + // Remove Validation_rule from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.validation_rule'); + + // Remove Field from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.field'); + + // Remove Fieldtype from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.fieldtype'); + + // Remove Language_translation from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.language_translation'); + + // Remove Language from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.language'); + + // Remove Server from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.server'); + + // Remove Help_document from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.help_document'); + + // Remove Admin_fields from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.admin_fields'); + + // Remove Admin_fields_conditions from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.admin_fields_conditions'); + + // Remove Admin_fields_relations from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.admin_fields_relations'); + + // Remove Admin_custom_tabs from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.admin_custom_tabs'); + + // Remove Component_admin_views from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.component_admin_views'); + + // Remove Component_site_views from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.component_site_views'); + + // Remove Component_custom_admin_views from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.component_custom_admin_views'); + + // Remove Component_updates from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.component_updates'); + + // Remove Component_mysql_tweaks from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.component_mysql_tweaks'); + + // Remove Component_custom_admin_menus from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.component_custom_admin_menus'); + + // Remove Component_router from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.component_router'); + + // Remove Component_config from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.component_config'); + + // Remove Component_dashboard from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.component_dashboard'); + + // Remove Component_files_folders from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.component_files_folders'); + + // Remove Component_placeholders from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.component_placeholders'); + + // Remove Component_plugins from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.component_plugins'); + + // Remove Component_modules from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.component_modules'); + + // Remove Snippet_type from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.snippet_type'); + + // Remove Library_config from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.library_config'); + + // Remove Library_files_folders_urls from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.library_files_folders_urls'); + + // Remove Class_extends from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.class_extends'); + + // Remove Joomla_module_updates from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.joomla_module_updates'); + + // Remove Joomla_module_files_folders_urls from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.joomla_module_files_folders_urls'); + + // Remove Joomla_plugin_group from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.joomla_plugin_group'); + + // Remove Joomla_plugin_updates from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.joomla_plugin_updates'); + + // Remove Joomla_plugin_files_folders_urls from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.joomla_plugin_files_folders_urls'); + + // Remove Joomla_component from action logs config table. + $this->removeActionLogConfig('com_componentbuilder.joomla_component'); + // little notice as after service, in case of bad experience with component. + echo '
+

Did something go wrong? Are you disappointed?

+

Please let me know at joomla@vdm.io. +
We at Vast Development Method are committed to building extensions that performs proficiently! You can help us, really! +
Send me your thoughts on improvements that is needed, trust me, I will be very grateful! +
Visit us at https://dev.vdm.io today!

'; + + return true; + } + + /** + * Function called before extension installation/update/removal procedure commences. + * + * @param string $type The type of change (install or discover_install, update, uninstall) + * @param InstallerAdapter $adapter The adapter calling this method + * + * @return boolean True on success + * + * @since 4.2.0 + */ + public function preflight(string $type, InstallerAdapter $adapter): bool + { + // Check for the minimum PHP version before continuing + if (!empty($this->minimumPhp) && version_compare(PHP_VERSION, $this->minimumPhp, '<')) + { + Log::add(Text::sprintf('JLIB_INSTALLER_MINIMUM_PHP', $this->minimumPhp), Log::WARNING, 'jerror'); + + return false; + } + + // Check for the minimum Joomla version before continuing + if (!empty($this->minimumJoomla) && version_compare(JVERSION, $this->minimumJoomla, '<')) + { + Log::add(Text::sprintf('JLIB_INSTALLER_MINIMUM_JOOMLA', $this->minimumJoomla), Log::WARNING, 'jerror'); + + return false; + } + + // Extension manifest file version + $this->extension = $adapter->getName(); + $this->release = $adapter->getManifest()->version; + + // do any updates needed + if ($type === 'update') + { + // path to the new compiler + $jcb_powers = JPATH_LIBRARIES . '/jcb_powers/VDM.Joomla/src/Componentbuilder'; + // we always remove all the old files to avoid mismatching + \VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper::removeFolder($jcb_powers); + } + + // do any install needed + if ($type === 'install') + { + } + + return true; + } + + /** + * Function called after extension installation/update/removal procedure commences. + * + * @param string $type The type of change (install or discover_install, update, uninstall) + * @param InstallerAdapter $adapter The adapter calling this method + * + * @return boolean True on success + * + * @since 4.2.0 + */ + public function postflight(string $type, InstallerAdapter $adapter): bool + { + // We check if we have dynamic folders to copy + $this->moveFolders($adapter); + + // set the default component settings + if ($type === 'install') + { + + // Install Joomla component Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Joomla_component', + // typeAlias + 'com_componentbuilder.joomla_component', + // table + '{"special": {"dbtable": "#__componentbuilder_joomla_component","key": "id","type": "Joomla_componentTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "system_name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "php_method_uninstall","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "metadata","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "metakey","core_metadesc": "metadesc","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","name_code":"name_code","short_description":"short_description","companyname":"companyname","buildcompsql":"buildcompsql","translation_tool":"translation_tool","add_sales_server":"add_sales_server","php_method_uninstall":"php_method_uninstall","php_preflight_install":"php_preflight_install","css_admin":"css_admin","mvc_versiondate":"mvc_versiondate","remove_line_breaks":"remove_line_breaks","add_placeholders":"add_placeholders","debug_linenr":"debug_linenr","php_site_event":"php_site_event","description":"description","author":"author","php_postflight_install":"php_postflight_install","email":"email","sql_uninstall":"sql_uninstall","website":"website","add_license":"add_license","backup_folder_path":"backup_folder_path","php_helper_both":"php_helper_both","crowdin_username":"crowdin_username","php_admin_event":"php_admin_event","license_type":"license_type","component_version":"component_version","php_helper_admin":"php_helper_admin","php_helper_site":"php_helper_site","whmcs_key":"whmcs_key","javascript":"javascript","whmcs_url":"whmcs_url","css_site":"css_site","whmcs_buy_link":"whmcs_buy_link","license":"license","php_preflight_update":"php_preflight_update","bom":"bom","php_postflight_update":"php_postflight_update","image":"image","sql":"sql","copyright":"copyright","addreadme":"addreadme","preferred_joomla_version":"preferred_joomla_version","update_server_url":"update_server_url","add_powers":"add_powers","add_backup_folder_path":"add_backup_folder_path","crowdin_project_identifier":"crowdin_project_identifier","add_php_helper_both":"add_php_helper_both","add_php_helper_admin":"add_php_helper_admin","add_admin_event":"add_admin_event","add_php_helper_site":"add_php_helper_site","add_site_event":"add_site_event","add_namespace_prefix":"add_namespace_prefix","add_javascript":"add_javascript","namespace_prefix":"namespace_prefix","add_css_admin":"add_css_admin","add_css_site":"add_css_site","add_menu_prefix":"add_menu_prefix","dashboard_type":"dashboard_type","menu_prefix":"menu_prefix","dashboard":"dashboard","add_php_preflight_install":"add_php_preflight_install","add_php_preflight_update":"add_php_preflight_update","toignore":"toignore","add_php_postflight_install":"add_php_postflight_install","add_php_postflight_update":"add_php_postflight_update","add_php_method_uninstall":"add_php_method_uninstall","export_key":"export_key","add_sql":"add_sql","joomla_source_link":"joomla_source_link","add_sql_uninstall":"add_sql_uninstall","export_buy_link":"export_buy_link","assets_table_fix":"assets_table_fix","readme":"readme","add_update_server":"add_update_server","update_server_target":"update_server_target","emptycontributors":"emptycontributors","number":"number","update_server":"update_server","sales_server":"sales_server","add_git_folder_path":"add_git_folder_path","git_folder_path":"git_folder_path","crowdin_project_api_key":"crowdin_project_api_key","creatuserhelper":"creatuserhelper","crowdin_account_api_key":"crowdin_account_api_key","adduikit":"adduikit","buildcomp":"buildcomp","addfootable":"addfootable","guid":"guid","add_email_helper":"add_email_helper","name":"name"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/joomla_component.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","translation_tool","add_sales_server","mvc_versiondate","remove_line_breaks","add_placeholders","debug_linenr","add_license","license_type","addreadme","preferred_joomla_version","add_powers","add_backup_folder_path","add_php_helper_both","add_php_helper_admin","add_admin_event","add_php_helper_site","add_site_event","add_javascript","add_css_admin","add_css_site","dashboard_type","add_php_preflight_install","add_php_preflight_update","add_php_postflight_install","add_php_postflight_update","add_php_method_uninstall","add_sql","add_sql_uninstall","assets_table_fix","add_update_server","update_server_target","emptycontributors","number","update_server","sales_server","add_git_folder_path","creatuserhelper","adduikit","buildcomp","addfootable","add_email_helper"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "dashboard","targetTable": "#__componentbuilder_custom_admin_view","targetColumn": "","displayColumn": "system_name"},{"sourceColumn": "update_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "sales_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Joomla module Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Joomla_module', + // typeAlias + 'com_componentbuilder.joomla_module', + // table + '{"special": {"dbtable": "#__componentbuilder_joomla_module","key": "id","type": "Joomla_moduleTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "system_name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "default","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","target":"target","description":"description","add_php_method_uninstall":"add_php_method_uninstall","add_php_postflight_update":"add_php_postflight_update","add_php_postflight_install":"add_php_postflight_install","add_php_preflight_uninstall":"add_php_preflight_uninstall","addreadme":"addreadme","default":"default","snippet":"snippet","add_sql":"add_sql","update_server_target":"update_server_target","add_sql_uninstall":"add_sql_uninstall","update_server":"update_server","add_update_server":"add_update_server","libraries":"libraries","module_version":"module_version","sales_server":"sales_server","custom_get":"custom_get","php_preflight_update":"php_preflight_update","php_preflight_uninstall":"php_preflight_uninstall","mod_code":"mod_code","php_postflight_install":"php_postflight_install","add_class_helper":"add_class_helper","php_postflight_update":"php_postflight_update","add_class_helper_header":"add_class_helper_header","php_method_uninstall":"php_method_uninstall","class_helper_header":"class_helper_header","sql":"sql","class_helper_code":"class_helper_code","sql_uninstall":"sql_uninstall","readme":"readme","add_php_script_construct":"add_php_script_construct","update_server_url":"update_server_url","php_script_construct":"php_script_construct","add_php_preflight_install":"add_php_preflight_install","php_preflight_install":"php_preflight_install","add_sales_server":"add_sales_server","add_php_preflight_update":"add_php_preflight_update","guid":"guid","name":"name"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/joomla_module.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","target","add_php_method_uninstall","add_php_postflight_update","add_php_postflight_install","add_php_preflight_uninstall","addreadme","snippet","add_sql","update_server_target","add_sql_uninstall","update_server","add_update_server","sales_server","add_class_helper","add_class_helper_header","add_php_script_construct","add_php_preflight_install","add_sales_server","add_php_preflight_update"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "snippet","targetTable": "#__componentbuilder_snippet","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "update_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "sales_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "custom_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Joomla plugin Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Joomla_plugin', + // typeAlias + 'com_componentbuilder.joomla_plugin', + // table + '{"special": {"dbtable": "#__componentbuilder_joomla_plugin","key": "id","type": "Joomla_pluginTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "system_name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "head","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","class_extends":"class_extends","joomla_plugin_group":"joomla_plugin_group","add_sql":"add_sql","add_php_method_uninstall":"add_php_method_uninstall","add_php_postflight_update":"add_php_postflight_update","add_php_postflight_install":"add_php_postflight_install","sales_server":"sales_server","add_update_server":"add_update_server","add_head":"add_head","add_sql_uninstall":"add_sql_uninstall","addreadme":"addreadme","head":"head","update_server_target":"update_server_target","main_class_code":"main_class_code","update_server":"update_server","description":"description","php_postflight_install":"php_postflight_install","plugin_version":"plugin_version","php_postflight_update":"php_postflight_update","php_method_uninstall":"php_method_uninstall","add_php_script_construct":"add_php_script_construct","sql":"sql","php_script_construct":"php_script_construct","sql_uninstall":"sql_uninstall","add_php_preflight_install":"add_php_preflight_install","readme":"readme","php_preflight_install":"php_preflight_install","update_server_url":"update_server_url","add_php_preflight_update":"add_php_preflight_update","php_preflight_update":"php_preflight_update","add_php_preflight_uninstall":"add_php_preflight_uninstall","add_sales_server":"add_sales_server","php_preflight_uninstall":"php_preflight_uninstall","guid":"guid","name":"name"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/joomla_plugin.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","class_extends","joomla_plugin_group","add_sql","add_php_method_uninstall","add_php_postflight_update","add_php_postflight_install","sales_server","add_update_server","add_head","add_sql_uninstall","addreadme","update_server_target","update_server","add_php_script_construct","add_php_preflight_install","add_php_preflight_update","add_php_preflight_uninstall","add_sales_server"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "class_extends","targetTable": "#__componentbuilder_class_extends","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_plugin_group","targetTable": "#__componentbuilder_joomla_plugin_group","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "sales_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "update_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Power Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Power', + // typeAlias + 'com_componentbuilder.power', + // table + '{"special": {"dbtable": "#__componentbuilder_power","key": "id","type": "PowerTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "system_name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "head","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","namespace":"namespace","type":"type","power_version":"power_version","licensing_template":"licensing_template","description":"description","extends":"extends","approved":"approved","add_head":"add_head","extends_custom":"extends_custom","implements_custom":"implements_custom","implements":"implements","head":"head","approved_paths":"approved_paths","main_class_code":"main_class_code","add_licensing_template":"add_licensing_template","guid":"guid","name":"name"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/power.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","approved","add_head","add_licensing_template"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "extends","targetTable": "#__componentbuilder_power","targetColumn": "guid","displayColumn": "name"},{"sourceColumn": "implements","targetTable": "#__componentbuilder_power","targetColumn": "guid","displayColumn": "name"}]}' + ); + // Install Admin view Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Admin_view', + // typeAlias + 'com_componentbuilder.admin_view', + // table + '{"special": {"dbtable": "#__componentbuilder_admin_view","key": "id","type": "Admin_viewTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "null","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "php_allowedit","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","name_single":"name_single","short_description":"short_description","php_allowedit":"php_allowedit","php_postsavehook":"php_postsavehook","php_before_save":"php_before_save","php_getlistquery":"php_getlistquery","php_import_ext":"php_import_ext","icon":"icon","php_after_publish":"php_after_publish","add_fadein":"add_fadein","description":"description","icon_category":"icon_category","icon_add":"icon_add","php_after_cancel":"php_after_cancel","mysql_table_charset":"mysql_table_charset","php_batchmove":"php_batchmove","type":"type","php_after_delete":"php_after_delete","source":"source","php_import":"php_import","php_getitems_after_all":"php_getitems_after_all","php_getform":"php_getform","php_save":"php_save","php_allowadd":"php_allowadd","php_before_cancel":"php_before_cancel","php_batchcopy":"php_batchcopy","php_before_publish":"php_before_publish","alias_builder_type":"alias_builder_type","php_before_delete":"php_before_delete","php_document":"php_document","mysql_table_row_format":"mysql_table_row_format","alias_builder":"alias_builder","sql":"sql","php_import_display":"php_import_display","add_category_submenu":"add_category_submenu","php_import_setdata":"php_import_setdata","name_list":"name_list","add_php_getlistquery":"add_php_getlistquery","add_css_view":"add_css_view","add_php_getform":"add_php_getform","css_view":"css_view","add_php_before_save":"add_php_before_save","add_css_views":"add_css_views","add_php_save":"add_php_save","css_views":"css_views","add_php_postsavehook":"add_php_postsavehook","add_javascript_view_file":"add_javascript_view_file","add_php_allowadd":"add_php_allowadd","javascript_view_file":"javascript_view_file","add_php_allowedit":"add_php_allowedit","add_javascript_view_footer":"add_javascript_view_footer","add_php_before_cancel":"add_php_before_cancel","javascript_view_footer":"javascript_view_footer","add_php_after_cancel":"add_php_after_cancel","add_javascript_views_file":"add_javascript_views_file","add_php_batchcopy":"add_php_batchcopy","javascript_views_file":"javascript_views_file","add_php_batchmove":"add_php_batchmove","add_javascript_views_footer":"add_javascript_views_footer","add_php_before_publish":"add_php_before_publish","javascript_views_footer":"javascript_views_footer","add_php_after_publish":"add_php_after_publish","add_custom_button":"add_custom_button","add_php_before_delete":"add_php_before_delete","add_php_after_delete":"add_php_after_delete","php_controller":"php_controller","add_php_document":"add_php_document","php_model":"php_model","mysql_table_engine":"mysql_table_engine","php_controller_list":"php_controller_list","mysql_table_collate":"mysql_table_collate","php_model_list":"php_model_list","add_sql":"add_sql","add_php_ajax":"add_php_ajax","php_ajaxmethod":"php_ajaxmethod","add_custom_import":"add_custom_import","add_php_getitem":"add_php_getitem","html_import_view":"html_import_view","php_getitem":"php_getitem","php_import_headers":"php_import_headers","add_php_getitems":"add_php_getitems","php_import_save":"php_import_save","php_getitems":"php_getitems","guid":"guid","add_php_getitems_after_all":"add_php_getitems_after_all"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/admin_view.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","add_fadein","type","source","add_category_submenu","add_php_getlistquery","add_css_view","add_php_getform","add_php_before_save","add_css_views","add_php_save","add_php_postsavehook","add_javascript_view_file","add_php_allowadd","add_php_allowedit","add_javascript_view_footer","add_php_before_cancel","add_php_after_cancel","add_javascript_views_file","add_php_batchcopy","add_php_batchmove","add_javascript_views_footer","add_php_before_publish","add_php_after_publish","add_custom_button","add_php_before_delete","add_php_after_delete","add_php_document","add_sql","add_php_ajax","add_custom_import","add_php_getitem","add_php_getitems","add_php_getitems_after_all"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "alias_builder","targetTable": "#__componentbuilder_field","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Custom admin view Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Custom_admin_view', + // typeAlias + 'com_componentbuilder.custom_admin_view', + // table + '{"special": {"dbtable": "#__componentbuilder_custom_admin_view","key": "id","type": "Custom_admin_viewTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "css_document","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","name":"name","description":"description","main_get":"main_get","add_php_jview_display":"add_php_jview_display","css_document":"css_document","css":"css","js_document":"js_document","javascript_file":"javascript_file","codename":"codename","default":"default","snippet":"snippet","icon":"icon","add_php_jview":"add_php_jview","context":"context","add_js_document":"add_js_document","custom_get":"custom_get","add_javascript_file":"add_javascript_file","php_ajaxmethod":"php_ajaxmethod","add_css_document":"add_css_document","add_php_document":"add_php_document","add_css":"add_css","add_php_view":"add_php_view","add_php_ajax":"add_php_ajax","libraries":"libraries","dynamic_get":"dynamic_get","php_document":"php_document","php_view":"php_view","add_custom_button":"add_custom_button","php_jview_display":"php_jview_display","php_jview":"php_jview","php_controller":"php_controller","guid":"guid","php_model":"php_model"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/custom_admin_view.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","main_get","add_php_jview_display","snippet","add_php_jview","add_js_document","add_javascript_file","add_css_document","add_php_document","add_css","add_php_view","add_php_ajax","dynamic_get","add_custom_button"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "main_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "snippet","targetTable": "#__componentbuilder_snippet","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "custom_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "dynamic_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Site view Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Site_view', + // typeAlias + 'com_componentbuilder.site_view', + // table + '{"special": {"dbtable": "#__componentbuilder_site_view","key": "id","type": "Site_viewTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "js_document","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","name":"name","description":"description","main_get":"main_get","add_php_jview_display":"add_php_jview_display","add_php_document":"add_php_document","add_php_view":"add_php_view","js_document":"js_document","codename":"codename","javascript_file":"javascript_file","context":"context","default":"default","snippet":"snippet","add_php_jview":"add_php_jview","custom_get":"custom_get","css_document":"css_document","add_javascript_file":"add_javascript_file","css":"css","add_js_document":"add_js_document","php_ajaxmethod":"php_ajaxmethod","add_css_document":"add_css_document","libraries":"libraries","add_css":"add_css","dynamic_get":"dynamic_get","add_php_ajax":"add_php_ajax","add_custom_button":"add_custom_button","php_document":"php_document","button_position":"button_position","php_view":"php_view","php_jview_display":"php_jview_display","php_jview":"php_jview","php_controller":"php_controller","guid":"guid","php_model":"php_model"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/site_view.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","main_get","add_php_jview_display","add_php_document","add_php_view","snippet","add_php_jview","add_javascript_file","add_js_document","add_css_document","add_css","dynamic_get","add_php_ajax","add_custom_button","button_position"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "main_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "snippet","targetTable": "#__componentbuilder_snippet","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "custom_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "dynamic_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Template Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Template', + // typeAlias + 'com_componentbuilder.template', + // table + '{"special": {"dbtable": "#__componentbuilder_template","key": "id","type": "TemplateTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "php_view","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description","dynamic_get":"dynamic_get","php_view":"php_view","add_php_view":"add_php_view","template":"template","snippet":"snippet","libraries":"libraries","alias":"alias"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/template.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","dynamic_get","add_php_view","snippet"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "dynamic_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "snippet","targetTable": "#__componentbuilder_snippet","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Layout Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Layout', + // typeAlias + 'com_componentbuilder.layout', + // table + '{"special": {"dbtable": "#__componentbuilder_layout","key": "id","type": "LayoutTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "php_view","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description","dynamic_get":"dynamic_get","snippet":"snippet","php_view":"php_view","add_php_view":"add_php_view","layout":"layout","libraries":"libraries","alias":"alias"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/layout.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","dynamic_get","snippet","add_php_view"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "dynamic_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "snippet","targetTable": "#__componentbuilder_snippet","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Dynamic get Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Dynamic_get', + // typeAlias + 'com_componentbuilder.dynamic_get', + // table + '{"special": {"dbtable": "#__componentbuilder_dynamic_get","key": "id","type": "Dynamic_getTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "php_calculation","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","main_source":"main_source","gettype":"gettype","php_calculation":"php_calculation","php_router_parse":"php_router_parse","add_php_after_getitems":"add_php_after_getitems","add_php_router_parse":"add_php_router_parse","view_selection":"view_selection","add_php_before_getitems":"add_php_before_getitems","add_php_before_getitem":"add_php_before_getitem","add_php_after_getitem":"add_php_after_getitem","db_table_main":"db_table_main","php_custom_get":"php_custom_get","plugin_events":"plugin_events","db_selection":"db_selection","view_table_main":"view_table_main","add_php_getlistquery":"add_php_getlistquery","select_all":"select_all","php_before_getitem":"php_before_getitem","getcustom":"getcustom","php_after_getitem":"php_after_getitem","pagination":"pagination","php_getlistquery":"php_getlistquery","php_before_getitems":"php_before_getitems","php_after_getitems":"php_after_getitems","addcalculation":"addcalculation","guid":"guid"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/dynamic_get.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","main_source","gettype","add_php_after_getitems","add_php_router_parse","add_php_before_getitems","add_php_before_getitem","add_php_after_getitem","view_table_main","add_php_getlistquery","select_all","pagination"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "view_table_main","targetTable": "#__componentbuilder_admin_view","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Custom code Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Custom_code', + // typeAlias + 'com_componentbuilder.custom_code', + // table + '{"special": {"dbtable": "#__componentbuilder_custom_code","key": "id","type": "Custom_codeTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "code","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"component":"component","path":"path","target":"target","type":"type","comment_type":"comment_type","joomla_version":"joomla_version","function_name":"function_name","system_name":"system_name","code":"code","hashendtarget":"hashendtarget","to_line":"to_line","from_line":"from_line","hashtarget":"hashtarget"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/custom_code.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","component","target","type","comment_type","joomla_version"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Class property Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Class_property', + // typeAlias + 'com_componentbuilder.class_property', + // table + '{"special": {"dbtable": "#__componentbuilder_class_property","key": "id","type": "Class_propertyTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","visibility":"visibility","extension_type":"extension_type","guid":"guid","comment":"comment","joomla_plugin_group":"joomla_plugin_group","default":"default"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/class_property.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_plugin_group"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_plugin_group","targetTable": "#__componentbuilder_joomla_plugin_group","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Class method Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Class_method', + // typeAlias + 'com_componentbuilder.class_method', + // table + '{"special": {"dbtable": "#__componentbuilder_class_method","key": "id","type": "Class_methodTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "code","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","visibility":"visibility","extension_type":"extension_type","guid":"guid","code":"code","comment":"comment","joomla_plugin_group":"joomla_plugin_group","arguments":"arguments"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/class_method.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_plugin_group"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_plugin_group","targetTable": "#__componentbuilder_joomla_plugin_group","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Placeholder Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Placeholder', + // typeAlias + 'com_componentbuilder.placeholder', + // table + '{"special": {"dbtable": "#__componentbuilder_placeholder","key": "id","type": "PlaceholderTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "target","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"target":"target","value":"value"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/placeholder.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Library Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Library', + // typeAlias + 'com_componentbuilder.library', + // table + '{"special": {"dbtable": "#__componentbuilder_library","key": "id","type": "LibraryTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","target":"target","how":"how","type":"type","description":"description","libraries":"libraries","php_setdocument":"php_setdocument","guid":"guid"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/library.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","target","how","type"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Snippet Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Snippet', + // typeAlias + 'com_componentbuilder.snippet', + // table + '{"special": {"dbtable": "#__componentbuilder_snippet","key": "id","type": "SnippetTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","url":"url","type":"type","heading":"heading","library":"library","guid":"guid","contributor_email":"contributor_email","contributor_name":"contributor_name","contributor_website":"contributor_website","contributor_company":"contributor_company","snippet":"snippet","usage":"usage","description":"description"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/snippet.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","type","library"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "type","targetTable": "#__componentbuilder_snippet_type","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "library","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Validation rule Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Validation_rule', + // typeAlias + 'com_componentbuilder.validation_rule', + // table + '{"special": {"dbtable": "#__componentbuilder_validation_rule","key": "id","type": "Validation_ruleTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","short_description":"short_description","inherit":"inherit","php":"php"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/validation_rule.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "inherit","targetTable": "#__componentbuilder_validation_rule","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Field Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Field', + // typeAlias + 'com_componentbuilder.field', + // table + '{"special": {"dbtable": "#__componentbuilder_field","key": "id","type": "FieldTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "css_views","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "catid","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","fieldtype":"fieldtype","datatype":"datatype","indexes":"indexes","null_switch":"null_switch","store":"store","on_save_model_field":"on_save_model_field","initiator_on_get_model":"initiator_on_get_model","initiator_on_save_model":"initiator_on_save_model","xml":"xml","datalenght":"datalenght","css_views":"css_views","css_view":"css_view","datadefault_other":"datadefault_other","datadefault":"datadefault","datalenght_other":"datalenght_other","on_get_model_field":"on_get_model_field","javascript_view_footer":"javascript_view_footer","javascript_views_footer":"javascript_views_footer","add_css_view":"add_css_view","add_css_views":"add_css_views","add_javascript_view_footer":"add_javascript_view_footer","add_javascript_views_footer":"add_javascript_views_footer","guid":"guid"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/field.xml","hideFields": ["asset_id","checked_out","checked_out_time","xml"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","fieldtype","store","catid","add_css_view","add_css_views","add_javascript_view_footer","add_javascript_views_footer"],"displayLookup": [{"sourceColumn": "catid","targetTable": "#__categories","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "fieldtype","targetTable": "#__componentbuilder_fieldtype","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Field category Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Field Catid', + // typeAlias + 'com_componentbuilder.field.category', + // table + '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}', + // rules + '', + // fieldMappings + '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}', + // router + '', + // contentHistoryOptions + '{"formFile":"administrator\/components\/com_categories\/forms\/category.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"], "ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version", "hits", "path"],"convertToInt":["publish_up", "publish_down"], "displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}' + ); + // Install Fieldtype Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Fieldtype', + // typeAlias + 'com_componentbuilder.fieldtype', + // table + '{"special": {"dbtable": "#__componentbuilder_fieldtype","key": "id","type": "FieldtypeTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "catid","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","store":"store","null_switch":"null_switch","indexes":"indexes","datadefault_other":"datadefault_other","datadefault":"datadefault","short_description":"short_description","datatype":"datatype","has_defaults":"has_defaults","description":"description","datalenght":"datalenght","datalenght_other":"datalenght_other","guid":"guid"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/fieldtype.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","store","has_defaults","catid"],"displayLookup": [{"sourceColumn": "catid","targetTable": "#__categories","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Fieldtype category Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Fieldtype Catid', + // typeAlias + 'com_componentbuilder.fieldtype.category', + // table + '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}', + // rules + '', + // fieldMappings + '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}', + // router + '', + // contentHistoryOptions + '{"formFile":"administrator\/components\/com_categories\/forms\/category.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"], "ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version", "hits", "path"],"convertToInt":["publish_up", "publish_down"], "displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}' + ); + // Install Language translation Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Language_translation', + // typeAlias + 'com_componentbuilder.language_translation', + // table + '{"special": {"dbtable": "#__componentbuilder_language_translation","key": "id","type": "Language_translationTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "source","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"source":"source","plugins":"plugins","modules":"modules","components":"components"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/language_translation.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "plugins","targetTable": "#__componentbuilder_joomla_plugin","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "modules","targetTable": "#__componentbuilder_joomla_module","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "components","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Language Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Language', + // typeAlias + 'com_componentbuilder.language', + // table + '{"special": {"dbtable": "#__componentbuilder_language","key": "id","type": "LanguageTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","langtag":"langtag"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/language.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Server Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Server', + // typeAlias + 'com_componentbuilder.server', + // table + '{"special": {"dbtable": "#__componentbuilder_server","key": "id","type": "ServerTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","protocol":"protocol","signature":"signature","private_key":"private_key","secret":"secret","password":"password","private":"private","authentication":"authentication","path":"path","port":"port","host":"host","username":"username"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/server.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","protocol","authentication"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Help document Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Help_document', + // typeAlias + 'com_componentbuilder.help_document', + // table + '{"special": {"dbtable": "#__componentbuilder_help_document","key": "id","type": "Help_documentTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "title","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "content","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "null","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"title":"title","type":"type","groups":"groups","location":"location","admin_view":"admin_view","site_view":"site_view","not_required":"not_required","content":"content","article":"article","url":"url","target":"target","alias":"alias"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/help_document.xml","hideFields": ["asset_id","checked_out","checked_out_time","not_required"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","type","location","not_required","article","target"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "article","targetTable": "#__content","targetColumn": "id","displayColumn": "title"}]}' + ); + // Install Admin fields Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Admin_fields', + // typeAlias + 'com_componentbuilder.admin_fields', + // table + '{"special": {"dbtable": "#__componentbuilder_admin_fields","key": "id","type": "Admin_fieldsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "admin_view","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"admin_view":"admin_view"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/admin_fields.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","admin_view"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "admin_view","targetTable": "#__componentbuilder_admin_view","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Admin fields conditions Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Admin_fields_conditions', + // typeAlias + 'com_componentbuilder.admin_fields_conditions', + // table + '{"special": {"dbtable": "#__componentbuilder_admin_fields_conditions","key": "id","type": "Admin_fields_conditionsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "admin_view","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"admin_view":"admin_view"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/admin_fields_conditions.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","admin_view"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "admin_view","targetTable": "#__componentbuilder_admin_view","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Admin fields relations Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Admin_fields_relations', + // typeAlias + 'com_componentbuilder.admin_fields_relations', + // table + '{"special": {"dbtable": "#__componentbuilder_admin_fields_relations","key": "id","type": "Admin_fields_relationsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "admin_view","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"admin_view":"admin_view"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/admin_fields_relations.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","admin_view"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "admin_view","targetTable": "#__componentbuilder_admin_view","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Admin custom tabs Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Admin_custom_tabs', + // typeAlias + 'com_componentbuilder.admin_custom_tabs', + // table + '{"special": {"dbtable": "#__componentbuilder_admin_custom_tabs","key": "id","type": "Admin_custom_tabsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "admin_view","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"admin_view":"admin_view"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/admin_custom_tabs.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","admin_view"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "admin_view","targetTable": "#__componentbuilder_admin_view","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Component admin views Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_admin_views', + // typeAlias + 'com_componentbuilder.component_admin_views', + // table + '{"special": {"dbtable": "#__componentbuilder_component_admin_views","key": "id","type": "Component_admin_viewsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_admin_views.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Component site views Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_site_views', + // typeAlias + 'com_componentbuilder.component_site_views', + // table + '{"special": {"dbtable": "#__componentbuilder_component_site_views","key": "id","type": "Component_site_viewsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_site_views.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Component custom admin views Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_custom_admin_views', + // typeAlias + 'com_componentbuilder.component_custom_admin_views', + // table + '{"special": {"dbtable": "#__componentbuilder_component_custom_admin_views","key": "id","type": "Component_custom_admin_viewsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_custom_admin_views.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Component updates Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_updates', + // typeAlias + 'com_componentbuilder.component_updates', + // table + '{"special": {"dbtable": "#__componentbuilder_component_updates","key": "id","type": "Component_updatesTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_updates.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Component mysql tweaks Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_mysql_tweaks', + // typeAlias + 'com_componentbuilder.component_mysql_tweaks', + // table + '{"special": {"dbtable": "#__componentbuilder_component_mysql_tweaks","key": "id","type": "Component_mysql_tweaksTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_mysql_tweaks.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Component custom admin menus Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_custom_admin_menus', + // typeAlias + 'com_componentbuilder.component_custom_admin_menus', + // table + '{"special": {"dbtable": "#__componentbuilder_component_custom_admin_menus","key": "id","type": "Component_custom_admin_menusTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_custom_admin_menus.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Component router Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_router', + // typeAlias + 'com_componentbuilder.component_router', + // table + '{"special": {"dbtable": "#__componentbuilder_component_router","key": "id","type": "Component_routerTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "methods_code","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component","mode_constructor_before_parent":"mode_constructor_before_parent","mode_constructor_after_parent":"mode_constructor_after_parent","mode_methods":"mode_methods","methods_code":"methods_code","constructor_after_parent_code":"constructor_after_parent_code","constructor_before_parent_code":"constructor_before_parent_code"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_router.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component","mode_constructor_before_parent","mode_constructor_after_parent","mode_methods"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Component config Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_config', + // typeAlias + 'com_componentbuilder.component_config', + // table + '{"special": {"dbtable": "#__componentbuilder_component_config","key": "id","type": "Component_configTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_config.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Component dashboard Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_dashboard', + // typeAlias + 'com_componentbuilder.component_dashboard', + // table + '{"special": {"dbtable": "#__componentbuilder_component_dashboard","key": "id","type": "Component_dashboardTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component","php_dashboard_methods":"php_dashboard_methods"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_dashboard.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Component files folders Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_files_folders', + // typeAlias + 'com_componentbuilder.component_files_folders', + // table + '{"special": {"dbtable": "#__componentbuilder_component_files_folders","key": "id","type": "Component_files_foldersTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_files_folders.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Component placeholders Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_placeholders', + // typeAlias + 'com_componentbuilder.component_placeholders', + // table + '{"special": {"dbtable": "#__componentbuilder_component_placeholders","key": "id","type": "Component_placeholdersTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_placeholders.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Component plugins Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_plugins', + // typeAlias + 'com_componentbuilder.component_plugins', + // table + '{"special": {"dbtable": "#__componentbuilder_component_plugins","key": "id","type": "Component_pluginsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_plugins.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Component modules Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_modules', + // typeAlias + 'com_componentbuilder.component_modules', + // table + '{"special": {"dbtable": "#__componentbuilder_component_modules","key": "id","type": "Component_modulesTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_modules.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Snippet type Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Snippet_type', + // typeAlias + 'com_componentbuilder.snippet_type', + // table + '{"special": {"dbtable": "#__componentbuilder_snippet_type","key": "id","type": "Snippet_typeTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/snippet_type.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Library config Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Library_config', + // typeAlias + 'com_componentbuilder.library_config', + // table + '{"special": {"dbtable": "#__componentbuilder_library_config","key": "id","type": "Library_configTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "library","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"library":"library"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/library_config.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","library"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "library","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Library files folders urls Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Library_files_folders_urls', + // typeAlias + 'com_componentbuilder.library_files_folders_urls', + // table + '{"special": {"dbtable": "#__componentbuilder_library_files_folders_urls","key": "id","type": "Library_files_folders_urlsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "library","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"library":"library"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/library_files_folders_urls.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","library"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "library","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Class extends Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Class_extends', + // typeAlias + 'com_componentbuilder.class_extends', + // table + '{"special": {"dbtable": "#__componentbuilder_class_extends","key": "id","type": "Class_extendsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "head","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","extension_type":"extension_type","head":"head","comment":"comment"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/class_extends.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Joomla module updates Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Joomla_module_updates', + // typeAlias + 'com_componentbuilder.joomla_module_updates', + // table + '{"special": {"dbtable": "#__componentbuilder_joomla_module_updates","key": "id","type": "Joomla_module_updatesTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_module","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_module":"joomla_module"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/joomla_module_updates.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_module"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_module","targetTable": "#__componentbuilder_joomla_module","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Joomla module files folders urls Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Joomla_module_files_folders_urls', + // typeAlias + 'com_componentbuilder.joomla_module_files_folders_urls', + // table + '{"special": {"dbtable": "#__componentbuilder_joomla_module_files_folders_urls","key": "id","type": "Joomla_module_files_folders_urlsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_module","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_module":"joomla_module"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/joomla_module_files_folders_urls.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_module"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_module","targetTable": "#__componentbuilder_joomla_module","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Joomla plugin group Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Joomla_plugin_group', + // typeAlias + 'com_componentbuilder.joomla_plugin_group', + // table + '{"special": {"dbtable": "#__componentbuilder_joomla_plugin_group","key": "id","type": "Joomla_plugin_groupTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","class_extends":"class_extends"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/joomla_plugin_group.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","class_extends"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "class_extends","targetTable": "#__componentbuilder_class_extends","targetColumn": "id","displayColumn": "name"}]}' + ); + // Install Joomla plugin updates Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Joomla_plugin_updates', + // typeAlias + 'com_componentbuilder.joomla_plugin_updates', + // table + '{"special": {"dbtable": "#__componentbuilder_joomla_plugin_updates","key": "id","type": "Joomla_plugin_updatesTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_plugin","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_plugin":"joomla_plugin"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/joomla_plugin_updates.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_plugin"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_plugin","targetTable": "#__componentbuilder_joomla_plugin","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Install Joomla plugin files folders urls Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Joomla_plugin_files_folders_urls', + // typeAlias + 'com_componentbuilder.joomla_plugin_files_folders_urls', + // table + '{"special": {"dbtable": "#__componentbuilder_joomla_plugin_files_folders_urls","key": "id","type": "Joomla_plugin_files_folders_urlsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_plugin","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_plugin":"joomla_plugin"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/joomla_plugin_files_folders_urls.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_plugin"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_plugin","targetTable": "#__componentbuilder_joomla_plugin","targetColumn": "id","displayColumn": "system_name"}]}' + ); + + + // Fix the assets table rules column size. + $this->setDatabaseAssetsRulesFix(99360, "MEDIUMTEXT"); + // Install the global extension params. + $this->setExtensionsParams( + '{"autorName":"Llewellyn van der Merwe","autorEmail":"joomla@vdm.io","subform_layouts":"default","editor":"none","manage_jcb_package_directories":"2","set_browser_storage":"1","storage_time_to_live":"global","super_powers_documentation":"0","powers_repository":"0","super_powers_repositories":"0","approved_paths":"default","add_custom_gitea_url":"1","custom_gitea_url":"https://git.vdm.dev","super_powers_core_organisation":"joomla","super_powers_core":"joomla/super-powers","builder_gif_size":"480-272","compiler_plugin":["componentbuilderactionlogcompiler","componentbuilderfieldorderingcompiler","componentbuilderheaderscompiler","componentbuilderpowersautoloadercompiler","componentbuilderprivacycompiler"],"add_menu_prefix":"1","menu_prefix":"»","namespace_prefix":"JCB","minify":"0","language":"en-GB","percentagelanguageadd":"30","assets_table_fix":"2","compiler_field_builder_type":"2","field_name_builder":"1","type_name_builder":"1","import_guid_only":"1","export_language_strings":"1","development_method":"1","expansion":"0","return_options_build":"2","cronjob_backup_type":"1","cronjob_backup_server":"0","backup_package_name":"JCB_Backup_[YEAR]_[MONTH]_[DAY]","export_license":"GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html","export_copyright":"Copyright (C) 2015. All Rights Reserved","check_in":"-1 day","save_history":"1","history_limit":"10","add_jquery_framework":"1","uikit_load":"1","uikit_min":"","uikit_style":""}' + ); + + + echo ''; + + // Add component to the action logs extensions table. + $this->setActionLogsExtensions(); + + // Add Joomla_component to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'JOOMLA_COMPONENT', + // typeAlias + 'com_componentbuilder.joomla_component', + // idHolder + 'id', + // titleHolder + 'system_name', + // tableName + '#__componentbuilder_joomla_component', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Joomla_module to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'JOOMLA_MODULE', + // typeAlias + 'com_componentbuilder.joomla_module', + // idHolder + 'id', + // titleHolder + 'system_name', + // tableName + '#__componentbuilder_joomla_module', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Joomla_plugin to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'JOOMLA_PLUGIN', + // typeAlias + 'com_componentbuilder.joomla_plugin', + // idHolder + 'id', + // titleHolder + 'system_name', + // tableName + '#__componentbuilder_joomla_plugin', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Power to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'POWER', + // typeAlias + 'com_componentbuilder.power', + // idHolder + 'id', + // titleHolder + 'system_name', + // tableName + '#__componentbuilder_power', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Admin_view to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'ADMIN_VIEW', + // typeAlias + 'com_componentbuilder.admin_view', + // idHolder + 'id', + // titleHolder + 'system_name', + // tableName + '#__componentbuilder_admin_view', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Custom_admin_view to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'CUSTOM_ADMIN_VIEW', + // typeAlias + 'com_componentbuilder.custom_admin_view', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_custom_admin_view', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Site_view to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'SITE_VIEW', + // typeAlias + 'com_componentbuilder.site_view', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_site_view', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Template to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'TEMPLATE', + // typeAlias + 'com_componentbuilder.template', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_template', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Layout to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'LAYOUT', + // typeAlias + 'com_componentbuilder.layout', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_layout', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Dynamic_get to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'DYNAMIC_GET', + // typeAlias + 'com_componentbuilder.dynamic_get', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_dynamic_get', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Custom_code to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'CUSTOM_CODE', + // typeAlias + 'com_componentbuilder.custom_code', + // idHolder + 'id', + // titleHolder + 'component', + // tableName + '#__componentbuilder_custom_code', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Class_property to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'CLASS_PROPERTY', + // typeAlias + 'com_componentbuilder.class_property', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_class_property', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Class_method to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'CLASS_METHOD', + // typeAlias + 'com_componentbuilder.class_method', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_class_method', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Placeholder to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'PLACEHOLDER', + // typeAlias + 'com_componentbuilder.placeholder', + // idHolder + 'id', + // titleHolder + 'target', + // tableName + '#__componentbuilder_placeholder', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Library to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'LIBRARY', + // typeAlias + 'com_componentbuilder.library', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_library', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Snippet to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'SNIPPET', + // typeAlias + 'com_componentbuilder.snippet', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_snippet', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Validation_rule to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'VALIDATION_RULE', + // typeAlias + 'com_componentbuilder.validation_rule', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_validation_rule', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Field to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'FIELD', + // typeAlias + 'com_componentbuilder.field', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_field', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Fieldtype to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'FIELDTYPE', + // typeAlias + 'com_componentbuilder.fieldtype', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_fieldtype', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Language_translation to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'LANGUAGE_TRANSLATION', + // typeAlias + 'com_componentbuilder.language_translation', + // idHolder + 'id', + // titleHolder + 'source', + // tableName + '#__componentbuilder_language_translation', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Language to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'LANGUAGE', + // typeAlias + 'com_componentbuilder.language', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_language', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Server to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'SERVER', + // typeAlias + 'com_componentbuilder.server', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_server', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Help_document to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'HELP_DOCUMENT', + // typeAlias + 'com_componentbuilder.help_document', + // idHolder + 'id', + // titleHolder + 'title', + // tableName + '#__componentbuilder_help_document', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Admin_fields to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'ADMIN_FIELDS', + // typeAlias + 'com_componentbuilder.admin_fields', + // idHolder + 'id', + // titleHolder + 'admin_view', + // tableName + '#__componentbuilder_admin_fields', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Admin_fields_conditions to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'ADMIN_FIELDS_CONDITIONS', + // typeAlias + 'com_componentbuilder.admin_fields_conditions', + // idHolder + 'id', + // titleHolder + 'admin_view', + // tableName + '#__componentbuilder_admin_fields_conditions', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Admin_fields_relations to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'ADMIN_FIELDS_RELATIONS', + // typeAlias + 'com_componentbuilder.admin_fields_relations', + // idHolder + 'id', + // titleHolder + 'admin_view', + // tableName + '#__componentbuilder_admin_fields_relations', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Admin_custom_tabs to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'ADMIN_CUSTOM_TABS', + // typeAlias + 'com_componentbuilder.admin_custom_tabs', + // idHolder + 'id', + // titleHolder + 'admin_view', + // tableName + '#__componentbuilder_admin_custom_tabs', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Component_admin_views to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_ADMIN_VIEWS', + // typeAlias + 'com_componentbuilder.component_admin_views', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_admin_views', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Component_site_views to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_SITE_VIEWS', + // typeAlias + 'com_componentbuilder.component_site_views', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_site_views', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Component_custom_admin_views to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_CUSTOM_ADMIN_VIEWS', + // typeAlias + 'com_componentbuilder.component_custom_admin_views', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_custom_admin_views', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Component_updates to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_UPDATES', + // typeAlias + 'com_componentbuilder.component_updates', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_updates', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Component_mysql_tweaks to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_MYSQL_TWEAKS', + // typeAlias + 'com_componentbuilder.component_mysql_tweaks', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_mysql_tweaks', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Component_custom_admin_menus to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_CUSTOM_ADMIN_MENUS', + // typeAlias + 'com_componentbuilder.component_custom_admin_menus', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_custom_admin_menus', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Component_router to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_ROUTER', + // typeAlias + 'com_componentbuilder.component_router', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_router', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Component_config to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_CONFIG', + // typeAlias + 'com_componentbuilder.component_config', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_config', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Component_dashboard to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_DASHBOARD', + // typeAlias + 'com_componentbuilder.component_dashboard', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_dashboard', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Component_files_folders to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_FILES_FOLDERS', + // typeAlias + 'com_componentbuilder.component_files_folders', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_files_folders', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Component_placeholders to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_PLACEHOLDERS', + // typeAlias + 'com_componentbuilder.component_placeholders', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_placeholders', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Component_plugins to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_PLUGINS', + // typeAlias + 'com_componentbuilder.component_plugins', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_plugins', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Component_modules to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_MODULES', + // typeAlias + 'com_componentbuilder.component_modules', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_modules', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Snippet_type to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'SNIPPET_TYPE', + // typeAlias + 'com_componentbuilder.snippet_type', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_snippet_type', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Library_config to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'LIBRARY_CONFIG', + // typeAlias + 'com_componentbuilder.library_config', + // idHolder + 'id', + // titleHolder + 'library', + // tableName + '#__componentbuilder_library_config', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Library_files_folders_urls to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'LIBRARY_FILES_FOLDERS_URLS', + // typeAlias + 'com_componentbuilder.library_files_folders_urls', + // idHolder + 'id', + // titleHolder + 'library', + // tableName + '#__componentbuilder_library_files_folders_urls', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Class_extends to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'CLASS_EXTENDS', + // typeAlias + 'com_componentbuilder.class_extends', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_class_extends', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Joomla_module_updates to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'JOOMLA_MODULE_UPDATES', + // typeAlias + 'com_componentbuilder.joomla_module_updates', + // idHolder + 'id', + // titleHolder + 'joomla_module', + // tableName + '#__componentbuilder_joomla_module_updates', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Joomla_module_files_folders_urls to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'JOOMLA_MODULE_FILES_FOLDERS_URLS', + // typeAlias + 'com_componentbuilder.joomla_module_files_folders_urls', + // idHolder + 'id', + // titleHolder + 'joomla_module', + // tableName + '#__componentbuilder_joomla_module_files_folders_urls', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Joomla_plugin_group to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'JOOMLA_PLUGIN_GROUP', + // typeAlias + 'com_componentbuilder.joomla_plugin_group', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_joomla_plugin_group', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Joomla_plugin_updates to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'JOOMLA_PLUGIN_UPDATES', + // typeAlias + 'com_componentbuilder.joomla_plugin_updates', + // idHolder + 'id', + // titleHolder + 'joomla_plugin', + // tableName + '#__componentbuilder_joomla_plugin_updates', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Joomla_plugin_files_folders_urls to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'JOOMLA_PLUGIN_FILES_FOLDERS_URLS', + // typeAlias + 'com_componentbuilder.joomla_plugin_files_folders_urls', + // idHolder + 'id', + // titleHolder + 'joomla_plugin', + // tableName + '#__componentbuilder_joomla_plugin_files_folders_urls', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add Joomla_component to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'JOOMLA_COMPONENT', + // typeAlias + 'com_componentbuilder.joomla_component', + // idHolder + 'id', + // titleHolder + 'system_name', + // tableName + '#__componentbuilder_joomla_component', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + } + + // do any updates needed + if ($type === 'update') + { + + // Update Joomla component Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Joomla_component', + // typeAlias + 'com_componentbuilder.joomla_component', + // table + '{"special": {"dbtable": "#__componentbuilder_joomla_component","key": "id","type": "Joomla_componentTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "system_name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "php_method_uninstall","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "metadata","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "metakey","core_metadesc": "metadesc","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","name_code":"name_code","short_description":"short_description","companyname":"companyname","buildcompsql":"buildcompsql","translation_tool":"translation_tool","add_sales_server":"add_sales_server","php_method_uninstall":"php_method_uninstall","php_preflight_install":"php_preflight_install","css_admin":"css_admin","mvc_versiondate":"mvc_versiondate","remove_line_breaks":"remove_line_breaks","add_placeholders":"add_placeholders","debug_linenr":"debug_linenr","php_site_event":"php_site_event","description":"description","author":"author","php_postflight_install":"php_postflight_install","email":"email","sql_uninstall":"sql_uninstall","website":"website","add_license":"add_license","backup_folder_path":"backup_folder_path","php_helper_both":"php_helper_both","crowdin_username":"crowdin_username","php_admin_event":"php_admin_event","license_type":"license_type","component_version":"component_version","php_helper_admin":"php_helper_admin","php_helper_site":"php_helper_site","whmcs_key":"whmcs_key","javascript":"javascript","whmcs_url":"whmcs_url","css_site":"css_site","whmcs_buy_link":"whmcs_buy_link","license":"license","php_preflight_update":"php_preflight_update","bom":"bom","php_postflight_update":"php_postflight_update","image":"image","sql":"sql","copyright":"copyright","addreadme":"addreadme","preferred_joomla_version":"preferred_joomla_version","update_server_url":"update_server_url","add_powers":"add_powers","add_backup_folder_path":"add_backup_folder_path","crowdin_project_identifier":"crowdin_project_identifier","add_php_helper_both":"add_php_helper_both","add_php_helper_admin":"add_php_helper_admin","add_admin_event":"add_admin_event","add_php_helper_site":"add_php_helper_site","add_site_event":"add_site_event","add_namespace_prefix":"add_namespace_prefix","add_javascript":"add_javascript","namespace_prefix":"namespace_prefix","add_css_admin":"add_css_admin","add_css_site":"add_css_site","add_menu_prefix":"add_menu_prefix","dashboard_type":"dashboard_type","menu_prefix":"menu_prefix","dashboard":"dashboard","add_php_preflight_install":"add_php_preflight_install","add_php_preflight_update":"add_php_preflight_update","toignore":"toignore","add_php_postflight_install":"add_php_postflight_install","add_php_postflight_update":"add_php_postflight_update","add_php_method_uninstall":"add_php_method_uninstall","export_key":"export_key","add_sql":"add_sql","joomla_source_link":"joomla_source_link","add_sql_uninstall":"add_sql_uninstall","export_buy_link":"export_buy_link","assets_table_fix":"assets_table_fix","readme":"readme","add_update_server":"add_update_server","update_server_target":"update_server_target","emptycontributors":"emptycontributors","number":"number","update_server":"update_server","sales_server":"sales_server","add_git_folder_path":"add_git_folder_path","git_folder_path":"git_folder_path","crowdin_project_api_key":"crowdin_project_api_key","creatuserhelper":"creatuserhelper","crowdin_account_api_key":"crowdin_account_api_key","adduikit":"adduikit","buildcomp":"buildcomp","addfootable":"addfootable","guid":"guid","add_email_helper":"add_email_helper","name":"name"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/joomla_component.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","translation_tool","add_sales_server","mvc_versiondate","remove_line_breaks","add_placeholders","debug_linenr","add_license","license_type","addreadme","preferred_joomla_version","add_powers","add_backup_folder_path","add_php_helper_both","add_php_helper_admin","add_admin_event","add_php_helper_site","add_site_event","add_javascript","add_css_admin","add_css_site","dashboard_type","add_php_preflight_install","add_php_preflight_update","add_php_postflight_install","add_php_postflight_update","add_php_method_uninstall","add_sql","add_sql_uninstall","assets_table_fix","add_update_server","update_server_target","emptycontributors","number","update_server","sales_server","add_git_folder_path","creatuserhelper","adduikit","buildcomp","addfootable","add_email_helper"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "dashboard","targetTable": "#__componentbuilder_custom_admin_view","targetColumn": "","displayColumn": "system_name"},{"sourceColumn": "update_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "sales_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Joomla module Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Joomla_module', + // typeAlias + 'com_componentbuilder.joomla_module', + // table + '{"special": {"dbtable": "#__componentbuilder_joomla_module","key": "id","type": "Joomla_moduleTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "system_name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "default","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","target":"target","description":"description","add_php_method_uninstall":"add_php_method_uninstall","add_php_postflight_update":"add_php_postflight_update","add_php_postflight_install":"add_php_postflight_install","add_php_preflight_uninstall":"add_php_preflight_uninstall","addreadme":"addreadme","default":"default","snippet":"snippet","add_sql":"add_sql","update_server_target":"update_server_target","add_sql_uninstall":"add_sql_uninstall","update_server":"update_server","add_update_server":"add_update_server","libraries":"libraries","module_version":"module_version","sales_server":"sales_server","custom_get":"custom_get","php_preflight_update":"php_preflight_update","php_preflight_uninstall":"php_preflight_uninstall","mod_code":"mod_code","php_postflight_install":"php_postflight_install","add_class_helper":"add_class_helper","php_postflight_update":"php_postflight_update","add_class_helper_header":"add_class_helper_header","php_method_uninstall":"php_method_uninstall","class_helper_header":"class_helper_header","sql":"sql","class_helper_code":"class_helper_code","sql_uninstall":"sql_uninstall","readme":"readme","add_php_script_construct":"add_php_script_construct","update_server_url":"update_server_url","php_script_construct":"php_script_construct","add_php_preflight_install":"add_php_preflight_install","php_preflight_install":"php_preflight_install","add_sales_server":"add_sales_server","add_php_preflight_update":"add_php_preflight_update","guid":"guid","name":"name"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/joomla_module.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","target","add_php_method_uninstall","add_php_postflight_update","add_php_postflight_install","add_php_preflight_uninstall","addreadme","snippet","add_sql","update_server_target","add_sql_uninstall","update_server","add_update_server","sales_server","add_class_helper","add_class_helper_header","add_php_script_construct","add_php_preflight_install","add_sales_server","add_php_preflight_update"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "snippet","targetTable": "#__componentbuilder_snippet","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "update_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "sales_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "custom_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Joomla plugin Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Joomla_plugin', + // typeAlias + 'com_componentbuilder.joomla_plugin', + // table + '{"special": {"dbtable": "#__componentbuilder_joomla_plugin","key": "id","type": "Joomla_pluginTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "system_name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "head","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","class_extends":"class_extends","joomla_plugin_group":"joomla_plugin_group","add_sql":"add_sql","add_php_method_uninstall":"add_php_method_uninstall","add_php_postflight_update":"add_php_postflight_update","add_php_postflight_install":"add_php_postflight_install","sales_server":"sales_server","add_update_server":"add_update_server","add_head":"add_head","add_sql_uninstall":"add_sql_uninstall","addreadme":"addreadme","head":"head","update_server_target":"update_server_target","main_class_code":"main_class_code","update_server":"update_server","description":"description","php_postflight_install":"php_postflight_install","plugin_version":"plugin_version","php_postflight_update":"php_postflight_update","php_method_uninstall":"php_method_uninstall","add_php_script_construct":"add_php_script_construct","sql":"sql","php_script_construct":"php_script_construct","sql_uninstall":"sql_uninstall","add_php_preflight_install":"add_php_preflight_install","readme":"readme","php_preflight_install":"php_preflight_install","update_server_url":"update_server_url","add_php_preflight_update":"add_php_preflight_update","php_preflight_update":"php_preflight_update","add_php_preflight_uninstall":"add_php_preflight_uninstall","add_sales_server":"add_sales_server","php_preflight_uninstall":"php_preflight_uninstall","guid":"guid","name":"name"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/joomla_plugin.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","class_extends","joomla_plugin_group","add_sql","add_php_method_uninstall","add_php_postflight_update","add_php_postflight_install","sales_server","add_update_server","add_head","add_sql_uninstall","addreadme","update_server_target","update_server","add_php_script_construct","add_php_preflight_install","add_php_preflight_update","add_php_preflight_uninstall","add_sales_server"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "class_extends","targetTable": "#__componentbuilder_class_extends","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_plugin_group","targetTable": "#__componentbuilder_joomla_plugin_group","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "sales_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "update_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Power Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Power', + // typeAlias + 'com_componentbuilder.power', + // table + '{"special": {"dbtable": "#__componentbuilder_power","key": "id","type": "PowerTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "system_name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "head","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","namespace":"namespace","type":"type","power_version":"power_version","licensing_template":"licensing_template","description":"description","extends":"extends","approved":"approved","add_head":"add_head","extends_custom":"extends_custom","implements_custom":"implements_custom","implements":"implements","head":"head","approved_paths":"approved_paths","main_class_code":"main_class_code","add_licensing_template":"add_licensing_template","guid":"guid","name":"name"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/power.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","approved","add_head","add_licensing_template"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "extends","targetTable": "#__componentbuilder_power","targetColumn": "guid","displayColumn": "name"},{"sourceColumn": "implements","targetTable": "#__componentbuilder_power","targetColumn": "guid","displayColumn": "name"}]}' + ); + // Update Admin view Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Admin_view', + // typeAlias + 'com_componentbuilder.admin_view', + // table + '{"special": {"dbtable": "#__componentbuilder_admin_view","key": "id","type": "Admin_viewTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "null","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "php_allowedit","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","name_single":"name_single","short_description":"short_description","php_allowedit":"php_allowedit","php_postsavehook":"php_postsavehook","php_before_save":"php_before_save","php_getlistquery":"php_getlistquery","php_import_ext":"php_import_ext","icon":"icon","php_after_publish":"php_after_publish","add_fadein":"add_fadein","description":"description","icon_category":"icon_category","icon_add":"icon_add","php_after_cancel":"php_after_cancel","mysql_table_charset":"mysql_table_charset","php_batchmove":"php_batchmove","type":"type","php_after_delete":"php_after_delete","source":"source","php_import":"php_import","php_getitems_after_all":"php_getitems_after_all","php_getform":"php_getform","php_save":"php_save","php_allowadd":"php_allowadd","php_before_cancel":"php_before_cancel","php_batchcopy":"php_batchcopy","php_before_publish":"php_before_publish","alias_builder_type":"alias_builder_type","php_before_delete":"php_before_delete","php_document":"php_document","mysql_table_row_format":"mysql_table_row_format","alias_builder":"alias_builder","sql":"sql","php_import_display":"php_import_display","add_category_submenu":"add_category_submenu","php_import_setdata":"php_import_setdata","name_list":"name_list","add_php_getlistquery":"add_php_getlistquery","add_css_view":"add_css_view","add_php_getform":"add_php_getform","css_view":"css_view","add_php_before_save":"add_php_before_save","add_css_views":"add_css_views","add_php_save":"add_php_save","css_views":"css_views","add_php_postsavehook":"add_php_postsavehook","add_javascript_view_file":"add_javascript_view_file","add_php_allowadd":"add_php_allowadd","javascript_view_file":"javascript_view_file","add_php_allowedit":"add_php_allowedit","add_javascript_view_footer":"add_javascript_view_footer","add_php_before_cancel":"add_php_before_cancel","javascript_view_footer":"javascript_view_footer","add_php_after_cancel":"add_php_after_cancel","add_javascript_views_file":"add_javascript_views_file","add_php_batchcopy":"add_php_batchcopy","javascript_views_file":"javascript_views_file","add_php_batchmove":"add_php_batchmove","add_javascript_views_footer":"add_javascript_views_footer","add_php_before_publish":"add_php_before_publish","javascript_views_footer":"javascript_views_footer","add_php_after_publish":"add_php_after_publish","add_custom_button":"add_custom_button","add_php_before_delete":"add_php_before_delete","add_php_after_delete":"add_php_after_delete","php_controller":"php_controller","add_php_document":"add_php_document","php_model":"php_model","mysql_table_engine":"mysql_table_engine","php_controller_list":"php_controller_list","mysql_table_collate":"mysql_table_collate","php_model_list":"php_model_list","add_sql":"add_sql","add_php_ajax":"add_php_ajax","php_ajaxmethod":"php_ajaxmethod","add_custom_import":"add_custom_import","add_php_getitem":"add_php_getitem","html_import_view":"html_import_view","php_getitem":"php_getitem","php_import_headers":"php_import_headers","add_php_getitems":"add_php_getitems","php_import_save":"php_import_save","php_getitems":"php_getitems","guid":"guid","add_php_getitems_after_all":"add_php_getitems_after_all"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/admin_view.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","add_fadein","type","source","add_category_submenu","add_php_getlistquery","add_css_view","add_php_getform","add_php_before_save","add_css_views","add_php_save","add_php_postsavehook","add_javascript_view_file","add_php_allowadd","add_php_allowedit","add_javascript_view_footer","add_php_before_cancel","add_php_after_cancel","add_javascript_views_file","add_php_batchcopy","add_php_batchmove","add_javascript_views_footer","add_php_before_publish","add_php_after_publish","add_custom_button","add_php_before_delete","add_php_after_delete","add_php_document","add_sql","add_php_ajax","add_custom_import","add_php_getitem","add_php_getitems","add_php_getitems_after_all"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "alias_builder","targetTable": "#__componentbuilder_field","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Custom admin view Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Custom_admin_view', + // typeAlias + 'com_componentbuilder.custom_admin_view', + // table + '{"special": {"dbtable": "#__componentbuilder_custom_admin_view","key": "id","type": "Custom_admin_viewTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "css_document","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","name":"name","description":"description","main_get":"main_get","add_php_jview_display":"add_php_jview_display","css_document":"css_document","css":"css","js_document":"js_document","javascript_file":"javascript_file","codename":"codename","default":"default","snippet":"snippet","icon":"icon","add_php_jview":"add_php_jview","context":"context","add_js_document":"add_js_document","custom_get":"custom_get","add_javascript_file":"add_javascript_file","php_ajaxmethod":"php_ajaxmethod","add_css_document":"add_css_document","add_php_document":"add_php_document","add_css":"add_css","add_php_view":"add_php_view","add_php_ajax":"add_php_ajax","libraries":"libraries","dynamic_get":"dynamic_get","php_document":"php_document","php_view":"php_view","add_custom_button":"add_custom_button","php_jview_display":"php_jview_display","php_jview":"php_jview","php_controller":"php_controller","guid":"guid","php_model":"php_model"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/custom_admin_view.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","main_get","add_php_jview_display","snippet","add_php_jview","add_js_document","add_javascript_file","add_css_document","add_php_document","add_css","add_php_view","add_php_ajax","dynamic_get","add_custom_button"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "main_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "snippet","targetTable": "#__componentbuilder_snippet","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "custom_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "dynamic_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Site view Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Site_view', + // typeAlias + 'com_componentbuilder.site_view', + // table + '{"special": {"dbtable": "#__componentbuilder_site_view","key": "id","type": "Site_viewTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "js_document","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","name":"name","description":"description","main_get":"main_get","add_php_jview_display":"add_php_jview_display","add_php_document":"add_php_document","add_php_view":"add_php_view","js_document":"js_document","codename":"codename","javascript_file":"javascript_file","context":"context","default":"default","snippet":"snippet","add_php_jview":"add_php_jview","custom_get":"custom_get","css_document":"css_document","add_javascript_file":"add_javascript_file","css":"css","add_js_document":"add_js_document","php_ajaxmethod":"php_ajaxmethod","add_css_document":"add_css_document","libraries":"libraries","add_css":"add_css","dynamic_get":"dynamic_get","add_php_ajax":"add_php_ajax","add_custom_button":"add_custom_button","php_document":"php_document","button_position":"button_position","php_view":"php_view","php_jview_display":"php_jview_display","php_jview":"php_jview","php_controller":"php_controller","guid":"guid","php_model":"php_model"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/site_view.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","main_get","add_php_jview_display","add_php_document","add_php_view","snippet","add_php_jview","add_javascript_file","add_js_document","add_css_document","add_css","dynamic_get","add_php_ajax","add_custom_button","button_position"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "main_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "snippet","targetTable": "#__componentbuilder_snippet","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "custom_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "dynamic_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Template Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Template', + // typeAlias + 'com_componentbuilder.template', + // table + '{"special": {"dbtable": "#__componentbuilder_template","key": "id","type": "TemplateTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "php_view","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description","dynamic_get":"dynamic_get","php_view":"php_view","add_php_view":"add_php_view","template":"template","snippet":"snippet","libraries":"libraries","alias":"alias"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/template.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","dynamic_get","add_php_view","snippet"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "dynamic_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "snippet","targetTable": "#__componentbuilder_snippet","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Layout Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Layout', + // typeAlias + 'com_componentbuilder.layout', + // table + '{"special": {"dbtable": "#__componentbuilder_layout","key": "id","type": "LayoutTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "php_view","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description","dynamic_get":"dynamic_get","snippet":"snippet","php_view":"php_view","add_php_view":"add_php_view","layout":"layout","libraries":"libraries","alias":"alias"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/layout.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","dynamic_get","snippet","add_php_view"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "dynamic_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "snippet","targetTable": "#__componentbuilder_snippet","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Dynamic get Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Dynamic_get', + // typeAlias + 'com_componentbuilder.dynamic_get', + // table + '{"special": {"dbtable": "#__componentbuilder_dynamic_get","key": "id","type": "Dynamic_getTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "php_calculation","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","main_source":"main_source","gettype":"gettype","php_calculation":"php_calculation","php_router_parse":"php_router_parse","add_php_after_getitems":"add_php_after_getitems","add_php_router_parse":"add_php_router_parse","view_selection":"view_selection","add_php_before_getitems":"add_php_before_getitems","add_php_before_getitem":"add_php_before_getitem","add_php_after_getitem":"add_php_after_getitem","db_table_main":"db_table_main","php_custom_get":"php_custom_get","plugin_events":"plugin_events","db_selection":"db_selection","view_table_main":"view_table_main","add_php_getlistquery":"add_php_getlistquery","select_all":"select_all","php_before_getitem":"php_before_getitem","getcustom":"getcustom","php_after_getitem":"php_after_getitem","pagination":"pagination","php_getlistquery":"php_getlistquery","php_before_getitems":"php_before_getitems","php_after_getitems":"php_after_getitems","addcalculation":"addcalculation","guid":"guid"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/dynamic_get.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","main_source","gettype","add_php_after_getitems","add_php_router_parse","add_php_before_getitems","add_php_before_getitem","add_php_after_getitem","view_table_main","add_php_getlistquery","select_all","pagination"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "view_table_main","targetTable": "#__componentbuilder_admin_view","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Custom code Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Custom_code', + // typeAlias + 'com_componentbuilder.custom_code', + // table + '{"special": {"dbtable": "#__componentbuilder_custom_code","key": "id","type": "Custom_codeTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "code","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"component":"component","path":"path","target":"target","type":"type","comment_type":"comment_type","joomla_version":"joomla_version","function_name":"function_name","system_name":"system_name","code":"code","hashendtarget":"hashendtarget","to_line":"to_line","from_line":"from_line","hashtarget":"hashtarget"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/custom_code.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","component","target","type","comment_type","joomla_version"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Class property Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Class_property', + // typeAlias + 'com_componentbuilder.class_property', + // table + '{"special": {"dbtable": "#__componentbuilder_class_property","key": "id","type": "Class_propertyTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","visibility":"visibility","extension_type":"extension_type","guid":"guid","comment":"comment","joomla_plugin_group":"joomla_plugin_group","default":"default"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/class_property.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_plugin_group"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_plugin_group","targetTable": "#__componentbuilder_joomla_plugin_group","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Class method Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Class_method', + // typeAlias + 'com_componentbuilder.class_method', + // table + '{"special": {"dbtable": "#__componentbuilder_class_method","key": "id","type": "Class_methodTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "code","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","visibility":"visibility","extension_type":"extension_type","guid":"guid","code":"code","comment":"comment","joomla_plugin_group":"joomla_plugin_group","arguments":"arguments"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/class_method.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_plugin_group"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_plugin_group","targetTable": "#__componentbuilder_joomla_plugin_group","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Placeholder Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Placeholder', + // typeAlias + 'com_componentbuilder.placeholder', + // table + '{"special": {"dbtable": "#__componentbuilder_placeholder","key": "id","type": "PlaceholderTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "target","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"target":"target","value":"value"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/placeholder.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Library Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Library', + // typeAlias + 'com_componentbuilder.library', + // table + '{"special": {"dbtable": "#__componentbuilder_library","key": "id","type": "LibraryTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","target":"target","how":"how","type":"type","description":"description","libraries":"libraries","php_setdocument":"php_setdocument","guid":"guid"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/library.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","target","how","type"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Snippet Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Snippet', + // typeAlias + 'com_componentbuilder.snippet', + // table + '{"special": {"dbtable": "#__componentbuilder_snippet","key": "id","type": "SnippetTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","url":"url","type":"type","heading":"heading","library":"library","guid":"guid","contributor_email":"contributor_email","contributor_name":"contributor_name","contributor_website":"contributor_website","contributor_company":"contributor_company","snippet":"snippet","usage":"usage","description":"description"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/snippet.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","type","library"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "type","targetTable": "#__componentbuilder_snippet_type","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "library","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Validation rule Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Validation_rule', + // typeAlias + 'com_componentbuilder.validation_rule', + // table + '{"special": {"dbtable": "#__componentbuilder_validation_rule","key": "id","type": "Validation_ruleTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","short_description":"short_description","inherit":"inherit","php":"php"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/validation_rule.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "inherit","targetTable": "#__componentbuilder_validation_rule","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Field Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Field', + // typeAlias + 'com_componentbuilder.field', + // table + '{"special": {"dbtable": "#__componentbuilder_field","key": "id","type": "FieldTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "css_views","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "catid","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","fieldtype":"fieldtype","datatype":"datatype","indexes":"indexes","null_switch":"null_switch","store":"store","on_save_model_field":"on_save_model_field","initiator_on_get_model":"initiator_on_get_model","initiator_on_save_model":"initiator_on_save_model","xml":"xml","datalenght":"datalenght","css_views":"css_views","css_view":"css_view","datadefault_other":"datadefault_other","datadefault":"datadefault","datalenght_other":"datalenght_other","on_get_model_field":"on_get_model_field","javascript_view_footer":"javascript_view_footer","javascript_views_footer":"javascript_views_footer","add_css_view":"add_css_view","add_css_views":"add_css_views","add_javascript_view_footer":"add_javascript_view_footer","add_javascript_views_footer":"add_javascript_views_footer","guid":"guid"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/field.xml","hideFields": ["asset_id","checked_out","checked_out_time","xml"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","fieldtype","store","catid","add_css_view","add_css_views","add_javascript_view_footer","add_javascript_views_footer"],"displayLookup": [{"sourceColumn": "catid","targetTable": "#__categories","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "fieldtype","targetTable": "#__componentbuilder_fieldtype","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Field category Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Field Catid', + // typeAlias + 'com_componentbuilder.field.category', + // table + '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}', + // rules + '', + // fieldMappings + '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}', + // router + '', + // contentHistoryOptions + '{"formFile":"administrator\/components\/com_categories\/forms\/category.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"], "ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version", "hits", "path"],"convertToInt":["publish_up", "publish_down"], "displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}' + ); + // Update Fieldtype Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Fieldtype', + // typeAlias + 'com_componentbuilder.fieldtype', + // table + '{"special": {"dbtable": "#__componentbuilder_fieldtype","key": "id","type": "FieldtypeTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "catid","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","store":"store","null_switch":"null_switch","indexes":"indexes","datadefault_other":"datadefault_other","datadefault":"datadefault","short_description":"short_description","datatype":"datatype","has_defaults":"has_defaults","description":"description","datalenght":"datalenght","datalenght_other":"datalenght_other","guid":"guid"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/fieldtype.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","store","has_defaults","catid"],"displayLookup": [{"sourceColumn": "catid","targetTable": "#__categories","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Fieldtype category Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Fieldtype Catid', + // typeAlias + 'com_componentbuilder.fieldtype.category', + // table + '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}', + // rules + '', + // fieldMappings + '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}', + // router + '', + // contentHistoryOptions + '{"formFile":"administrator\/components\/com_categories\/forms\/category.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"], "ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version", "hits", "path"],"convertToInt":["publish_up", "publish_down"], "displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}' + ); + // Update Language translation Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Language_translation', + // typeAlias + 'com_componentbuilder.language_translation', + // table + '{"special": {"dbtable": "#__componentbuilder_language_translation","key": "id","type": "Language_translationTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "source","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"source":"source","plugins":"plugins","modules":"modules","components":"components"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/language_translation.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "plugins","targetTable": "#__componentbuilder_joomla_plugin","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "modules","targetTable": "#__componentbuilder_joomla_module","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "components","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Language Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Language', + // typeAlias + 'com_componentbuilder.language', + // table + '{"special": {"dbtable": "#__componentbuilder_language","key": "id","type": "LanguageTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","langtag":"langtag"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/language.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Server Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Server', + // typeAlias + 'com_componentbuilder.server', + // table + '{"special": {"dbtable": "#__componentbuilder_server","key": "id","type": "ServerTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","protocol":"protocol","signature":"signature","private_key":"private_key","secret":"secret","password":"password","private":"private","authentication":"authentication","path":"path","port":"port","host":"host","username":"username"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/server.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","protocol","authentication"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Help document Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Help_document', + // typeAlias + 'com_componentbuilder.help_document', + // table + '{"special": {"dbtable": "#__componentbuilder_help_document","key": "id","type": "Help_documentTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "title","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "content","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "null","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"title":"title","type":"type","groups":"groups","location":"location","admin_view":"admin_view","site_view":"site_view","not_required":"not_required","content":"content","article":"article","url":"url","target":"target","alias":"alias"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/help_document.xml","hideFields": ["asset_id","checked_out","checked_out_time","not_required"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","type","location","not_required","article","target"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "article","targetTable": "#__content","targetColumn": "id","displayColumn": "title"}]}' + ); + // Update Admin fields Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Admin_fields', + // typeAlias + 'com_componentbuilder.admin_fields', + // table + '{"special": {"dbtable": "#__componentbuilder_admin_fields","key": "id","type": "Admin_fieldsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "admin_view","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"admin_view":"admin_view"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/admin_fields.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","admin_view"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "admin_view","targetTable": "#__componentbuilder_admin_view","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Admin fields conditions Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Admin_fields_conditions', + // typeAlias + 'com_componentbuilder.admin_fields_conditions', + // table + '{"special": {"dbtable": "#__componentbuilder_admin_fields_conditions","key": "id","type": "Admin_fields_conditionsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "admin_view","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"admin_view":"admin_view"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/admin_fields_conditions.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","admin_view"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "admin_view","targetTable": "#__componentbuilder_admin_view","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Admin fields relations Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Admin_fields_relations', + // typeAlias + 'com_componentbuilder.admin_fields_relations', + // table + '{"special": {"dbtable": "#__componentbuilder_admin_fields_relations","key": "id","type": "Admin_fields_relationsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "admin_view","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"admin_view":"admin_view"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/admin_fields_relations.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","admin_view"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "admin_view","targetTable": "#__componentbuilder_admin_view","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Admin custom tabs Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Admin_custom_tabs', + // typeAlias + 'com_componentbuilder.admin_custom_tabs', + // table + '{"special": {"dbtable": "#__componentbuilder_admin_custom_tabs","key": "id","type": "Admin_custom_tabsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "admin_view","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"admin_view":"admin_view"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/admin_custom_tabs.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","admin_view"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "admin_view","targetTable": "#__componentbuilder_admin_view","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Component admin views Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_admin_views', + // typeAlias + 'com_componentbuilder.component_admin_views', + // table + '{"special": {"dbtable": "#__componentbuilder_component_admin_views","key": "id","type": "Component_admin_viewsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_admin_views.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Component site views Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_site_views', + // typeAlias + 'com_componentbuilder.component_site_views', + // table + '{"special": {"dbtable": "#__componentbuilder_component_site_views","key": "id","type": "Component_site_viewsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_site_views.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Component custom admin views Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_custom_admin_views', + // typeAlias + 'com_componentbuilder.component_custom_admin_views', + // table + '{"special": {"dbtable": "#__componentbuilder_component_custom_admin_views","key": "id","type": "Component_custom_admin_viewsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_custom_admin_views.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Component updates Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_updates', + // typeAlias + 'com_componentbuilder.component_updates', + // table + '{"special": {"dbtable": "#__componentbuilder_component_updates","key": "id","type": "Component_updatesTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_updates.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Component mysql tweaks Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_mysql_tweaks', + // typeAlias + 'com_componentbuilder.component_mysql_tweaks', + // table + '{"special": {"dbtable": "#__componentbuilder_component_mysql_tweaks","key": "id","type": "Component_mysql_tweaksTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_mysql_tweaks.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Component custom admin menus Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_custom_admin_menus', + // typeAlias + 'com_componentbuilder.component_custom_admin_menus', + // table + '{"special": {"dbtable": "#__componentbuilder_component_custom_admin_menus","key": "id","type": "Component_custom_admin_menusTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_custom_admin_menus.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Component router Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_router', + // typeAlias + 'com_componentbuilder.component_router', + // table + '{"special": {"dbtable": "#__componentbuilder_component_router","key": "id","type": "Component_routerTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "methods_code","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component","mode_constructor_before_parent":"mode_constructor_before_parent","mode_constructor_after_parent":"mode_constructor_after_parent","mode_methods":"mode_methods","methods_code":"methods_code","constructor_after_parent_code":"constructor_after_parent_code","constructor_before_parent_code":"constructor_before_parent_code"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_router.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component","mode_constructor_before_parent","mode_constructor_after_parent","mode_methods"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Component config Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_config', + // typeAlias + 'com_componentbuilder.component_config', + // table + '{"special": {"dbtable": "#__componentbuilder_component_config","key": "id","type": "Component_configTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_config.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Component dashboard Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_dashboard', + // typeAlias + 'com_componentbuilder.component_dashboard', + // table + '{"special": {"dbtable": "#__componentbuilder_component_dashboard","key": "id","type": "Component_dashboardTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component","php_dashboard_methods":"php_dashboard_methods"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_dashboard.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Component files folders Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_files_folders', + // typeAlias + 'com_componentbuilder.component_files_folders', + // table + '{"special": {"dbtable": "#__componentbuilder_component_files_folders","key": "id","type": "Component_files_foldersTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_files_folders.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Component placeholders Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_placeholders', + // typeAlias + 'com_componentbuilder.component_placeholders', + // table + '{"special": {"dbtable": "#__componentbuilder_component_placeholders","key": "id","type": "Component_placeholdersTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_placeholders.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Component plugins Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_plugins', + // typeAlias + 'com_componentbuilder.component_plugins', + // table + '{"special": {"dbtable": "#__componentbuilder_component_plugins","key": "id","type": "Component_pluginsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_plugins.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Component modules Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Component_modules', + // typeAlias + 'com_componentbuilder.component_modules', + // table + '{"special": {"dbtable": "#__componentbuilder_component_modules","key": "id","type": "Component_modulesTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/component_modules.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Snippet type Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Snippet_type', + // typeAlias + 'com_componentbuilder.snippet_type', + // table + '{"special": {"dbtable": "#__componentbuilder_snippet_type","key": "id","type": "Snippet_typeTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/snippet_type.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Library config Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Library_config', + // typeAlias + 'com_componentbuilder.library_config', + // table + '{"special": {"dbtable": "#__componentbuilder_library_config","key": "id","type": "Library_configTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "library","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"library":"library"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/library_config.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","library"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "library","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Library files folders urls Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Library_files_folders_urls', + // typeAlias + 'com_componentbuilder.library_files_folders_urls', + // table + '{"special": {"dbtable": "#__componentbuilder_library_files_folders_urls","key": "id","type": "Library_files_folders_urlsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "library","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"library":"library"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/library_files_folders_urls.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","library"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "library","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Class extends Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Class_extends', + // typeAlias + 'com_componentbuilder.class_extends', + // table + '{"special": {"dbtable": "#__componentbuilder_class_extends","key": "id","type": "Class_extendsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "head","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","extension_type":"extension_type","head":"head","comment":"comment"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/class_extends.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Joomla module updates Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Joomla_module_updates', + // typeAlias + 'com_componentbuilder.joomla_module_updates', + // table + '{"special": {"dbtable": "#__componentbuilder_joomla_module_updates","key": "id","type": "Joomla_module_updatesTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_module","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_module":"joomla_module"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/joomla_module_updates.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_module"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_module","targetTable": "#__componentbuilder_joomla_module","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Joomla module files folders urls Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Joomla_module_files_folders_urls', + // typeAlias + 'com_componentbuilder.joomla_module_files_folders_urls', + // table + '{"special": {"dbtable": "#__componentbuilder_joomla_module_files_folders_urls","key": "id","type": "Joomla_module_files_folders_urlsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_module","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_module":"joomla_module"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/joomla_module_files_folders_urls.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_module"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_module","targetTable": "#__componentbuilder_joomla_module","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Joomla plugin group Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Joomla_plugin_group', + // typeAlias + 'com_componentbuilder.joomla_plugin_group', + // table + '{"special": {"dbtable": "#__componentbuilder_joomla_plugin_group","key": "id","type": "Joomla_plugin_groupTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","class_extends":"class_extends"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/joomla_plugin_group.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","class_extends"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "class_extends","targetTable": "#__componentbuilder_class_extends","targetColumn": "id","displayColumn": "name"}]}' + ); + // Update Joomla plugin updates Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Joomla_plugin_updates', + // typeAlias + 'com_componentbuilder.joomla_plugin_updates', + // table + '{"special": {"dbtable": "#__componentbuilder_joomla_plugin_updates","key": "id","type": "Joomla_plugin_updatesTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_plugin","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_plugin":"joomla_plugin"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/joomla_plugin_updates.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_plugin"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_plugin","targetTable": "#__componentbuilder_joomla_plugin","targetColumn": "id","displayColumn": "system_name"}]}' + ); + // Update Joomla plugin files folders urls Content Types. + $this->setContentType( + // typeTitle + 'Componentbuilder Joomla_plugin_files_folders_urls', + // typeAlias + 'com_componentbuilder.joomla_plugin_files_folders_urls', + // table + '{"special": {"dbtable": "#__componentbuilder_joomla_plugin_files_folders_urls","key": "id","type": "Joomla_plugin_files_folders_urlsTable","prefix": "VDM\Component\Componentbuilder\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "joomla_plugin","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_plugin":"joomla_plugin"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_componentbuilder/forms/joomla_plugin_files_folders_urls.xml","hideFields": ["asset_id","checked_out","checked_out_time"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits","joomla_plugin"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_plugin","targetTable": "#__componentbuilder_joomla_plugin","targetColumn": "id","displayColumn": "system_name"}]}' + ); + + + + echo '
+ + +

Upgrade to Version 5.0.0-alpha1 Was Successful! Let us know if anything is not working as expected.

'; + + // Add/Update component in the action logs extensions table. + $this->setActionLogsExtensions(); + + // Add/Update Joomla_component in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'JOOMLA_COMPONENT', + // typeAlias + 'com_componentbuilder.joomla_component', + // idHolder + 'id', + // titleHolder + 'system_name', + // tableName + '#__componentbuilder_joomla_component', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Joomla_module in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'JOOMLA_MODULE', + // typeAlias + 'com_componentbuilder.joomla_module', + // idHolder + 'id', + // titleHolder + 'system_name', + // tableName + '#__componentbuilder_joomla_module', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Joomla_plugin in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'JOOMLA_PLUGIN', + // typeAlias + 'com_componentbuilder.joomla_plugin', + // idHolder + 'id', + // titleHolder + 'system_name', + // tableName + '#__componentbuilder_joomla_plugin', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Power in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'POWER', + // typeAlias + 'com_componentbuilder.power', + // idHolder + 'id', + // titleHolder + 'system_name', + // tableName + '#__componentbuilder_power', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Admin_view in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'ADMIN_VIEW', + // typeAlias + 'com_componentbuilder.admin_view', + // idHolder + 'id', + // titleHolder + 'system_name', + // tableName + '#__componentbuilder_admin_view', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Custom_admin_view in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'CUSTOM_ADMIN_VIEW', + // typeAlias + 'com_componentbuilder.custom_admin_view', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_custom_admin_view', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Site_view in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'SITE_VIEW', + // typeAlias + 'com_componentbuilder.site_view', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_site_view', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Template in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'TEMPLATE', + // typeAlias + 'com_componentbuilder.template', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_template', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Layout in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'LAYOUT', + // typeAlias + 'com_componentbuilder.layout', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_layout', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Dynamic_get in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'DYNAMIC_GET', + // typeAlias + 'com_componentbuilder.dynamic_get', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_dynamic_get', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Custom_code in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'CUSTOM_CODE', + // typeAlias + 'com_componentbuilder.custom_code', + // idHolder + 'id', + // titleHolder + 'component', + // tableName + '#__componentbuilder_custom_code', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Class_property in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'CLASS_PROPERTY', + // typeAlias + 'com_componentbuilder.class_property', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_class_property', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Class_method in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'CLASS_METHOD', + // typeAlias + 'com_componentbuilder.class_method', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_class_method', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Placeholder in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'PLACEHOLDER', + // typeAlias + 'com_componentbuilder.placeholder', + // idHolder + 'id', + // titleHolder + 'target', + // tableName + '#__componentbuilder_placeholder', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Library in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'LIBRARY', + // typeAlias + 'com_componentbuilder.library', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_library', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Snippet in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'SNIPPET', + // typeAlias + 'com_componentbuilder.snippet', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_snippet', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Validation_rule in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'VALIDATION_RULE', + // typeAlias + 'com_componentbuilder.validation_rule', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_validation_rule', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Field in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'FIELD', + // typeAlias + 'com_componentbuilder.field', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_field', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Fieldtype in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'FIELDTYPE', + // typeAlias + 'com_componentbuilder.fieldtype', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_fieldtype', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Language_translation in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'LANGUAGE_TRANSLATION', + // typeAlias + 'com_componentbuilder.language_translation', + // idHolder + 'id', + // titleHolder + 'source', + // tableName + '#__componentbuilder_language_translation', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Language in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'LANGUAGE', + // typeAlias + 'com_componentbuilder.language', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_language', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Server in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'SERVER', + // typeAlias + 'com_componentbuilder.server', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_server', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Help_document in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'HELP_DOCUMENT', + // typeAlias + 'com_componentbuilder.help_document', + // idHolder + 'id', + // titleHolder + 'title', + // tableName + '#__componentbuilder_help_document', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Admin_fields in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'ADMIN_FIELDS', + // typeAlias + 'com_componentbuilder.admin_fields', + // idHolder + 'id', + // titleHolder + 'admin_view', + // tableName + '#__componentbuilder_admin_fields', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Admin_fields_conditions in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'ADMIN_FIELDS_CONDITIONS', + // typeAlias + 'com_componentbuilder.admin_fields_conditions', + // idHolder + 'id', + // titleHolder + 'admin_view', + // tableName + '#__componentbuilder_admin_fields_conditions', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Admin_fields_relations in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'ADMIN_FIELDS_RELATIONS', + // typeAlias + 'com_componentbuilder.admin_fields_relations', + // idHolder + 'id', + // titleHolder + 'admin_view', + // tableName + '#__componentbuilder_admin_fields_relations', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Admin_custom_tabs in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'ADMIN_CUSTOM_TABS', + // typeAlias + 'com_componentbuilder.admin_custom_tabs', + // idHolder + 'id', + // titleHolder + 'admin_view', + // tableName + '#__componentbuilder_admin_custom_tabs', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Component_admin_views in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_ADMIN_VIEWS', + // typeAlias + 'com_componentbuilder.component_admin_views', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_admin_views', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Component_site_views in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_SITE_VIEWS', + // typeAlias + 'com_componentbuilder.component_site_views', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_site_views', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Component_custom_admin_views in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_CUSTOM_ADMIN_VIEWS', + // typeAlias + 'com_componentbuilder.component_custom_admin_views', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_custom_admin_views', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Component_updates in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_UPDATES', + // typeAlias + 'com_componentbuilder.component_updates', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_updates', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Component_mysql_tweaks in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_MYSQL_TWEAKS', + // typeAlias + 'com_componentbuilder.component_mysql_tweaks', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_mysql_tweaks', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Component_custom_admin_menus in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_CUSTOM_ADMIN_MENUS', + // typeAlias + 'com_componentbuilder.component_custom_admin_menus', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_custom_admin_menus', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Component_router in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_ROUTER', + // typeAlias + 'com_componentbuilder.component_router', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_router', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Component_config in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_CONFIG', + // typeAlias + 'com_componentbuilder.component_config', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_config', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Component_dashboard in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_DASHBOARD', + // typeAlias + 'com_componentbuilder.component_dashboard', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_dashboard', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Component_files_folders in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_FILES_FOLDERS', + // typeAlias + 'com_componentbuilder.component_files_folders', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_files_folders', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Component_placeholders in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_PLACEHOLDERS', + // typeAlias + 'com_componentbuilder.component_placeholders', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_placeholders', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Component_plugins in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_PLUGINS', + // typeAlias + 'com_componentbuilder.component_plugins', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_plugins', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Component_modules in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'COMPONENT_MODULES', + // typeAlias + 'com_componentbuilder.component_modules', + // idHolder + 'id', + // titleHolder + 'joomla_component', + // tableName + '#__componentbuilder_component_modules', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Snippet_type in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'SNIPPET_TYPE', + // typeAlias + 'com_componentbuilder.snippet_type', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_snippet_type', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Library_config in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'LIBRARY_CONFIG', + // typeAlias + 'com_componentbuilder.library_config', + // idHolder + 'id', + // titleHolder + 'library', + // tableName + '#__componentbuilder_library_config', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Library_files_folders_urls in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'LIBRARY_FILES_FOLDERS_URLS', + // typeAlias + 'com_componentbuilder.library_files_folders_urls', + // idHolder + 'id', + // titleHolder + 'library', + // tableName + '#__componentbuilder_library_files_folders_urls', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Class_extends in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'CLASS_EXTENDS', + // typeAlias + 'com_componentbuilder.class_extends', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_class_extends', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Joomla_module_updates in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'JOOMLA_MODULE_UPDATES', + // typeAlias + 'com_componentbuilder.joomla_module_updates', + // idHolder + 'id', + // titleHolder + 'joomla_module', + // tableName + '#__componentbuilder_joomla_module_updates', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Joomla_module_files_folders_urls in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'JOOMLA_MODULE_FILES_FOLDERS_URLS', + // typeAlias + 'com_componentbuilder.joomla_module_files_folders_urls', + // idHolder + 'id', + // titleHolder + 'joomla_module', + // tableName + '#__componentbuilder_joomla_module_files_folders_urls', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Joomla_plugin_group in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'JOOMLA_PLUGIN_GROUP', + // typeAlias + 'com_componentbuilder.joomla_plugin_group', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__componentbuilder_joomla_plugin_group', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Joomla_plugin_updates in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'JOOMLA_PLUGIN_UPDATES', + // typeAlias + 'com_componentbuilder.joomla_plugin_updates', + // idHolder + 'id', + // titleHolder + 'joomla_plugin', + // tableName + '#__componentbuilder_joomla_plugin_updates', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Joomla_plugin_files_folders_urls in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'JOOMLA_PLUGIN_FILES_FOLDERS_URLS', + // typeAlias + 'com_componentbuilder.joomla_plugin_files_folders_urls', + // idHolder + 'id', + // titleHolder + 'joomla_plugin', + // tableName + '#__componentbuilder_joomla_plugin_files_folders_urls', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + + // Add/Update Joomla_component in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'JOOMLA_COMPONENT', + // typeAlias + 'com_componentbuilder.joomla_component', + // idHolder + 'id', + // titleHolder + 'system_name', + // tableName + '#__componentbuilder_joomla_component', + // textPrefix + 'COM_COMPONENTBUILDER' + ); + } + + // move CLI files + $this->moveCliFiles(); + + // remove old files and folders + $this->removeFiles(); + + return true; + } + + /** + * Remove the files and folders in the given array from + * + * @return void + * + * @since 3.6 + */ + protected function removeFiles() + { + if (!empty($this->deleteFiles)) + { + foreach ($this->deleteFiles as $file) + { + if (is_file(JPATH_ROOT . $file) && !File::delete(JPATH_ROOT . $file)) + { + echo Text::sprintf('JLIB_INSTALLER_ERROR_FILE_FOLDER', $file) . '
'; + } + } + } + + if (!empty($this->deleteFolders)) + { + foreach ($this->deleteFolders as $folder) + { + if (is_dir(JPATH_ROOT . $folder) && !Folder::delete(JPATH_ROOT . $folder)) + { + echo Text::sprintf('JLIB_INSTALLER_ERROR_FILE_FOLDER', $folder) . '
'; + } + } + } + } + + /** + * Moves the CLI scripts into the CLI folder in the CMS + * + * @return void + * + * @since 3.6 + */ + protected function moveCliFiles() + { + if (!empty($this->cliScriptFiles)) + { + foreach ($this->cliScriptFiles as $file) + { + $name = basename($file); + + if (file_exists(JPATH_ROOT . $file) && !File::move(JPATH_ROOT . $file, JPATH_ROOT . '/cli/' . $name)) + { + echo Text::sprintf('JLIB_INSTALLER_FILE_ERROR_MOVE', $name); + } + } + } + } + + /** + * Set content type integration + * + * @param string $typeTitle + * @param string $typeAlias + * @param string $table + * @param string $rules + * @param string $fieldMappings + * @param string $router + * @param string $contentHistoryOptions + * + * @return void + * @since 4.4.2 + */ + protected function setContentType( + string $typeTitle, + string $typeAlias, + string $table, + string $rules, + string $fieldMappings, + string $router, + string $contentHistoryOptions): void + { + // Create the content type object. + $content = new stdClass(); + $content->type_title = $typeTitle; + $content->type_alias = $typeAlias; + $content->table = $table; + $content->rules = $rules; + $content->field_mappings = $fieldMappings; + $content->router = $router; + $content->content_history_options = $contentHistoryOptions; + + // Check if content type is already in content_type DB. + $query = $this->db->getQuery(true); + $query->select($this->db->quoteName(array('type_id'))); + $query->from($this->db->quoteName('#__content_types')); + $query->where($this->db->quoteName('type_alias') . ' LIKE '. $this->db->quote($content->type_alias)); + + $this->db->setQuery($query); + $this->db->execute(); + + // Check if the type alias is already in the content types table. + if ($this->db->getNumRows()) + { + $content->type_id = $this->db->loadResult(); + if ($this->db->updateObject('#__content_types', $content, 'type_id')) + { + // If its successfully update. + $this->app->enqueueMessage( + Text::sprintf('The (%s) was found in the #__content_types table, and updated.', $content->type_alias) + ); + } + } + elseif ($this->db->insertObject('#__content_types', $content)) + { + // If its successfully added. + $this->app->enqueueMessage( + Text::sprintf('The (%s) was added to the #__content_types table.', $content->type_alias) + ); + } + } + + /** + * Set action log config integration + * + * @param string $typeTitle + * @param string $typeAlias + * @param string $idHolder + * @param string $titleHolder + * @param string $tableName + * @param string $textPrefix + * + * @return void + * @since 4.4.2 + */ + protected function setActionLogConfig( + string $typeTitle, + string $typeAlias, + string $idHolder, + string $titleHolder, + string $tableName, + string $textPrefix): void + { + // Create the content action log config object. + $content = new stdClass(); + $content->type_title = $typeTitle; + $content->type_alias = $typeAlias; + $content->id_holder = $idHolder; + $content->title_holder = $titleHolder; + $content->table_name = $tableName; + $content->text_prefix = $textPrefix; + + // Check if the action log config is already in action_log_config DB. + $query = $this->db->getQuery(true); + $query->select($this->db->quoteName(['id'])); + $query->from($this->db->quoteName('#__action_log_config')); + $query->where($this->db->quoteName('type_alias') . ' LIKE '. $this->db->quote($content->type_alias)); + + $this->db->setQuery($query); + $this->db->execute(); + + // Check if the type alias is already in the action log config table. + if ($this->db->getNumRows()) + { + $content->id = $this->db->loadResult(); + if ($this->db->updateObject('#__action_log_config', $content, 'id')) + { + // If its successfully update. + $this->app->enqueueMessage( + Text::sprintf('The (%s) was found in the #__action_log_config table, and updated.', $content->type_alias) + ); + } + } + elseif ($this->db->insertObject('#__action_log_config', $content)) + { + // If its successfully added. + $this->app->enqueueMessage( + Text::sprintf('The (%s) was added to the #__action_log_config table.', $content->type_alias) + ); + } + } + + /** + * Set action logs extensions integration + * + * @return void + * @since 4.4.2 + */ + protected function setActionLogsExtensions(): void + { + // Create the extension action logs object. + $data = new stdClass(); + $data->extension = 'com_componentbuilder'; + + // Check if componentbuilder action log extension is already in action logs extensions DB. + $query = $this->db->getQuery(true); + $query->select($this->db->quoteName(['id'])); + $query->from($this->db->quoteName('#__action_logs_extensions')); + $query->where($this->db->quoteName('extension') . ' = '. $this->db->quote($data->extension)); + + $this->db->setQuery($query); + $this->db->execute(); + + // Set the object into the action logs extensions table if not found. + if ($this->db->getNumRows()) + { + // If its already set don't set it again. + $this->app->enqueueMessage( + Text::_('The (com_componentbuilder) is already in the #__action_logs_extensions table.') + ); + } + elseif ($this->db->insertObject('#__action_logs_extensions', $data)) + { + // give a success message + $this->app->enqueueMessage( + Text::_('The (com_componentbuilder) was successfully added to the #__action_logs_extensions table.') + ); + } + } + + /** + * Set global extension assets permission of this component + * (on install only) + * + * @param string $rules The component rules + * + * @return void + * @since 4.4.2 + */ + protected function setAssetsRules(string $rules): void + { + // Condition. + $conditions = [ + $this->db->quoteName('name') . ' = ' . $this->db->quote('com_componentbuilder') + ]; + + // Field to update. + $fields = [ + $this->db->quoteName('rules') . ' = ' . $this->db->quote($rules), + ]; + + $query = $this->db->getQuery(true); + $query->update( + $this->db->quoteName('#__assets') + )->set($fields)->where($conditions); + + $this->db->setQuery($query); + + $done = $this->db->execute(); + if ($done) + { + // give a success message + $this->app->enqueueMessage( + Text::_('The (com_componentbuilder) rules was successfully added to the #__assets table.') + ); + } + } + + /** + * Set global extension params of this component + * (on install only) + * + * @param string $params The component rules + * + * @return void + * @since 4.4.2 + */ + protected function setExtensionsParams(string $params): void + { + // Condition. + $conditions = [ + $this->db->quoteName('element') . ' = ' . $this->db->quote('com_componentbuilder') + ]; + + // Field to update. + $fields = [ + $this->db->quoteName('params') . ' = ' . $this->db->quote($params), + ]; + + $query = $this->db->getQuery(true); + $query->update( + $this->db->quoteName('#__extensions') + )->set($fields)->where($conditions); + + $this->db->setQuery($query); + + $done = $this->db->execute(); + if ($done) + { + // give a success message + $this->app->enqueueMessage( + Text::_('The (com_componentbuilder) params was successfully added to the #__extensions table.') + ); + } + } + + /** + * Set database fix (if needed) + * => WHY DO WE NEED AN ASSET TABLE FIX? + * https://git.vdm.dev/joomla/Component-Builder/issues/616#issuecomment-12085 + * https://www.mysqltutorial.org/mysql-varchar/ + * https://stackoverflow.com/a/15227917/1429677 + * https://forums.mysql.com/read.php?24,105964,105964 + * + * @param int $accessWorseCase This is the max rules column size com_componentbuilder would needs. + * @param string $dataType This datatype we will change the rules column to if it to small. + * + * @return void + * @since 4.4.2 + */ + protected function setDatabaseAssetsRulesFix(int $accessWorseCase, string $dataType): void + { + // Get the biggest rule column in the assets table at this point. + $length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1"; + $this->db->setQuery($length); + if ($this->db->execute()) + { + $rule_length = $this->db->loadResult(); + // Check the size of the rules column + if ($rule_length <= $accessWorseCase) + { + // Fix the assets table rules column size + $fix = "ALTER TABLE `#__assets` CHANGE `rules` `rules` {$dataType} NOT NULL COMMENT 'JSON encoded access control. Enlarged to {$dataType} by Componentbuilder';"; + $this->db->setQuery($fix); + + $done = $this->db->execute(); + if ($done) + { + $this->app->enqueueMessage( + Text::sprintf('The #__assets table rules column was resized to the %s datatype for the components possible large permission rules.', $dataType) + ); + } + } + } + } + + /** + * Remove remnant data related to this view + * + * @param string $context The view context + * @param bool $fields The switch to also remove related field data + * + * @return void + * @since 4.4.2 + */ + protected function removeViewData(string $context, bool $fields = false): void + { + $this->removeContentTypes($context); + $this->removeViewHistory($context); + $this->removeUcmContent($context); // this might be obsolete... + $this->removeContentItemTagMap($context); + $this->removeActionLogConfig($context); + + if ($fields) + { + $this->removeFields($context); + $this->removeFieldsGroups($context); + } + } + + /** + * Remove content types related to this view + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeContentTypes(string $context): void + { + // Create a new query object. + $query = $this->db->getQuery(true); + + // Select id from content type table + $query->select($this->db->quoteName('type_id')); + $query->from($this->db->quoteName('#__content_types')); + + // Where Item alias is found + $query->where($this->db->quoteName('type_alias') . ' = '. $this->db->quote($context)); + $this->db->setQuery($query); + + // Execute query to see if alias is found + $this->db->execute(); + $found = $this->db->getNumRows(); + + // Now check if there were any rows + if ($found) + { + // Since there are load the needed item type ids + $ids = $this->db->loadColumn(); + + // Remove Item from the content type table + $condition = [ + $this->db->quoteName('type_alias') . ' = '. $this->db->quote($context) + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__content_types')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove Item items + $done = $this->db->execute(); + if ($done) + { + // If successfully remove Item add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The (%s) type alias was removed from the #__content_type table.', $context) + ); + } + + // Make sure that all the items are cleared from DB + $this->removeUcmBase($ids); + } + } + + /** + * Remove fields related to this view + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeFields(string $context): void + { + // Create a new query object. + $query = $this->db->getQuery(true); + + // Select ids from fields + $query->select($this->db->quoteName('id')); + $query->from($this->db->quoteName('#__fields')); + + // Where context is found + $query->where( + $this->db->quoteName('context') . ' = '. $this->db->quote($context) + ); + $this->db->setQuery($query); + + // Execute query to see if context is found + $this->db->execute(); + $found = $this->db->getNumRows(); + + // Now check if there were any rows + if ($found) + { + // Since there are load the needed release_check field ids + $ids = $this->db->loadColumn(); + + // Create a new query object. + $query = $this->db->getQuery(true); + + // Remove context from the field table + $condition = [ + $this->db->quoteName('context') . ' = '. $this->db->quote($context) + ]; + + $query->delete($this->db->quoteName('#__fields')); + $query->where($condition); + + $this->db->setQuery($query); + + // Execute the query to remove release_check items + $done = $this->db->execute(); + if ($done) + { + // If successfully remove context add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The fields with context (%s) was removed from the #__fields table.', $context) + ); + } + + // Make sure that all the field values are cleared from DB + $this->removeFieldsValues($context, $ids); + } + } + + /** + * Remove fields values related to fields + * + * @param string $context The view context + * @param array $ids The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeFieldsValues(string $context, array $ids): void + { + $condition = [ + $this->db->quoteName('field_id') . ' IN ('. implode(',', $ids) .')' + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__fields_values')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove field values + $done = $this->db->execute(); + if ($done) + { + // If successfully remove release_check add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The fields values for (%s) was removed from the #__fields_values table.', $context) + ); + } + } + + /** + * Remove fields groups related to fields + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeFieldsGroups(string $context): void + { + // Create a new query object. + $query = $this->db->getQuery(true); + + // Select ids from fields + $query->select($this->db->quoteName('id')); + $query->from($this->db->quoteName('#__fields_groups')); + + // Where context is found + $query->where( + $this->db->quoteName('context') . ' = '. $this->db->quote($context) + ); + $this->db->setQuery($query); + + // Execute query to see if context is found + $this->db->execute(); + $found = $this->db->getNumRows(); + + // Now check if there were any rows + if ($found) + { + // Create a new query object. + $query = $this->db->getQuery(true); + + // Remove context from the field table + $condition = [ + $this->db->quoteName('context') . ' = '. $this->db->quote($context) + ]; + + $query->delete($this->db->quoteName('#__fields_groups')); + $query->where($condition); + + $this->db->setQuery($query); + + // Execute the query to remove release_check items + $done = $this->db->execute(); + if ($done) + { + // If successfully remove context add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The fields with context (%s) was removed from the #__fields_groups table.', $context) + ); + } + } + } + + /** + * Remove history related to this view + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeViewHistory(string $context): void + { + // Remove Item items from the ucm content table + $condition = [ + $this->db->quoteName('item_id') . ' LIKE ' . $this->db->quote($context . '.%') + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__history')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove Item items + $done = $this->db->execute(); + if ($done) + { + // If successfully removed Items add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The (%s) items were removed from the #__history table.', $context) + ); + } + } + + /** + * Remove ucm base values related to these IDs + * + * @param array $ids The type ids + * + * @return void + * @since 4.4.2 + */ + protected function removeUcmBase(array $ids): void + { + // Make sure that all the items are cleared from DB + foreach ($ids as $type_id) + { + // Remove Item items from the ucm base table + $condition = [ + $this->db->quoteName('ucm_type_id') . ' = ' . $type_id + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__ucm_base')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove Item items + $this->db->execute(); + } + + $this->app->enqueueMessage( + Text::_('All related items was removed from the #__ucm_base table.') + ); + } + + /** + * Remove ucm content values related to this view + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeUcmContent(string $context): void + { + // Remove Item items from the ucm content table + $condition = [ + $this->db->quoteName('core_type_alias') . ' = ' . $this->db->quote($context) + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__ucm_content')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove Item items + $done = $this->db->execute(); + if ($done) + { + // If successfully removed Item add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The (%s) type alias was removed from the #__ucm_content table.', $context) + ); + } + } + + /** + * Remove content item tag map related to this view + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeContentItemTagMap(string $context): void + { + // Create a new query object. + $query = $this->db->getQuery(true); + + // Remove Item items from the contentitem tag map table + $condition = [ + $this->db->quoteName('type_alias') . ' = '. $this->db->quote($context) + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__contentitem_tag_map')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove Item items + $done = $this->db->execute(); + if ($done) + { + // If successfully remove Item add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The (%s) type alias was removed from the #__contentitem_tag_map table.', $context) + ); + } + } + + /** + * Remove action log config related to this view + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeActionLogConfig(string $context): void + { + // Remove componentbuilder view from the action_log_config table + $condition = [ + $this->db->quoteName('type_alias') . ' = '. $this->db->quote($context) + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__action_log_config')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove com_componentbuilder.view + $done = $this->db->execute(); + if ($done) + { + // If successfully removed componentbuilder view add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The (%s) type alias was removed from the #__action_log_config table.', $context) + ); + } + } + + /** + * Remove Asset Table Integrated + * + * @return void + * @since 4.4.2 + */ + protected function removeAssetData(): void + { + // Remove componentbuilder assets from the assets table + $condition = [ + $this->db->quoteName('name') . ' LIKE ' . $this->db->quote('com_componentbuilder.%') + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__assets')); + $query->where($condition); + $this->db->setQuery($query); + $done = $this->db->execute(); + if ($done) + { + // If successfully removed componentbuilder add queued success message. + $this->app->enqueueMessage( + Text::_('All related (com_componentbuilder) items was removed from the #__assets table.') + ); + } + } + + /** + * Remove action logs extensions integrated + * + * @return void + * @since 4.4.2 + */ + protected function removeActionLogsExtensions(): void + { + // Remove componentbuilder from the action_logs_extensions table + $extension = [ + $this->db->quoteName('extension') . ' = ' . $this->db->quote('com_componentbuilder') + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__action_logs_extensions')); + $query->where($extension); + $this->db->setQuery($query); + + // Execute the query to remove componentbuilder + $done = $this->db->execute(); + if ($done) + { + // If successfully remove componentbuilder add queued success message. + $this->app->enqueueMessage( + Text::_('The (com_componentbuilder) extension was removed from the #__action_logs_extensions table.') + ); + } + } + + /** + * Remove remove database fix (if possible) + * + * @return void + * @since 4.4.2 + */ + protected function removeDatabaseAssetsRulesFix(): void + { + // Get the biggest rule column in the assets table at this point. + $length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1"; + $this->db->setQuery($length); + if ($this->db->execute()) + { + $rule_length = $this->db->loadResult(); + // Check the size of the rules column + if ($rule_length < 5120) + { + // Revert the assets table rules column back to the default + $revert_rule = "ALTER TABLE `#__assets` CHANGE `rules` `rules` varchar(5120) NOT NULL COMMENT 'JSON encoded access control.';"; + $this->db->setQuery($revert_rule); + $this->db->execute(); + + $this->app->enqueueMessage( + Text::_('Reverted the #__assets table rules column back to its default size of varchar(5120).') + ); + } + else + { + $this->app->enqueueMessage( + Text::_('Could not revert the #__assets table rules column back to its default size of varchar(5120), since there is still one or more components that still requires the column to be larger.') + ); + } + } + } + + /** + * Method to move folders into place. + * + * @param InstallerAdapter $adapter The adapter calling this method + * + * @return void + * @since 4.4.2 + */ + protected function moveFolders(InstallerAdapter $adapter): void + { + // get the installation path + $installer = $adapter->getParent(); + $installPath = $installer->getPath('source'); + // get all the folders + $folders = Folder::folders($installPath); + // check if we have folders we may want to copy + $doNotCopy = ['media','admin','site']; // Joomla already deals with these + if (count((array) $folders) > 1) + { + foreach ($folders as $folder) + { + // Only copy if not a standard folders + if (!in_array($folder, $doNotCopy)) + { + // set the source path + $src = $installPath.'/'.$folder; + // set the destination path + $dest = JPATH_ROOT.'/'.$folder; + // now try to copy the folder + if (!Folder::copy($src, $dest, '', true)) + { + $this->app->enqueueMessage('Could not copy '.$folder.' folder into place, please make sure destination is writable!', 'error'); + } + } + } + } + } +} diff --git a/README.md b/README.md index 1ec22857e..6943b31ae 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have! -You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (3.1.28) with **ALL** its features and **ALL** concepts totally open-source and free! +You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (5.0.0-alpha1) with **ALL** its features and **ALL** concepts totally open-source and free! > Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45) @@ -144,14 +144,14 @@ TODO + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 24th October, 2023 -+ *Version*: 3.1.28 ++ *Last Build*: 9th March, 2024 ++ *Version*: 5.0.0-alpha1 + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **635155** -+ *Field count*: **2047** -+ *File count*: **4731** -+ *Folder count*: **436** ++ *Line count*: **707644** ++ *Field count*: **1690** ++ *File count*: **4985** ++ *Folder count*: **453** > This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com). > Developed by [Llewellyn van der Merwe](mailto:joomla@vdm.io) diff --git a/admin/README.txt b/admin/README.txt index 1ec22857e..6943b31ae 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have! -You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (3.1.28) with **ALL** its features and **ALL** concepts totally open-source and free! +You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (5.0.0-alpha1) with **ALL** its features and **ALL** concepts totally open-source and free! > Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45) @@ -144,14 +144,14 @@ TODO + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 24th October, 2023 -+ *Version*: 3.1.28 ++ *Last Build*: 9th March, 2024 ++ *Version*: 5.0.0-alpha1 + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **635155** -+ *Field count*: **2047** -+ *File count*: **4731** -+ *Folder count*: **436** ++ *Line count*: **707644** ++ *Field count*: **1690** ++ *File count*: **4985** ++ *Folder count*: **453** > This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com). > Developed by [Llewellyn van der Merwe](mailto:joomla@vdm.io) diff --git a/admin/access.xml b/admin/access.xml index 37dfadbef..86cf7d64b 100644 --- a/admin/access.xml +++ b/admin/access.xml @@ -211,6 +211,16 @@ + + + + + + + + + + @@ -899,6 +909,17 @@ +
+ + + + + + + + + +
diff --git a/site/assets/css/api.css b/admin/assets/css/component_router.css similarity index 100% rename from site/assets/css/api.css rename to admin/assets/css/component_router.css diff --git a/admin/assets/css/components_routers.css b/admin/assets/css/components_routers.css new file mode 100644 index 000000000..2731fc5aa --- /dev/null +++ b/admin/assets/css/components_routers.css @@ -0,0 +1,13 @@ +/** + * @package Joomla.Component.Builder + * + * @created 30th April, 2015 + * @author Llewellyn van der Merwe + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +/* CSS Document */ + + diff --git a/admin/assets/css/dashboard.css b/admin/assets/css/dashboard.css index 615e5f30f..3b92116c7 100644 --- a/admin/assets/css/dashboard.css +++ b/admin/assets/css/dashboard.css @@ -11,153 +11,153 @@ /* CSS Document */ .dashboard-container { - margin-left: 10px; - margin-top: 10px; - width: 100%; + margin-left: 10px; + margin-top: 10px; + width: 100%; } .dashboard-container [class*="span"] { - display: block; - float: none; - margin-left: 0; - width: auto; + display: block; + float: none; + margin-left: 0; + width: auto; } .dashboard-container:before, .dashboard-container:after { - content: ""; - display: table; + content: ""; + display: table; } .dashboard-container:after { - clear: both; + clear: both; } .dashboard-container [class*="span"] { - box-sizing: border-box; - display: block; - float: left; - min-height: 145px; - min-width: 96px; - width: 100%; + box-sizing: border-box; + display: block; + float: left; + min-height: 145px; + min-width: 96px; + width: 100%; } .dashboard-container [class*="span"]:first-child { - margin-left: 0; + margin-left: 0; } .dashboard-wraper { - background: none repeat scroll 0 0 hsl(0, 0%, 93%); - border-radius: 5px; - float: left; - margin: 1%; - padding: 3px; - width: 17%; - min-height: 194px; - min-width: 96px; + background: none repeat scroll 0 0 hsl(0, 0%, 93%); + border-radius: 5px; + float: left; + margin: 1%; + padding: 3px; + width: 17%; + min-height: 194px; + min-width: 96px; } .dashboard-content a { - background: linear-gradient(to bottom, hsl(0, 0%, 100%) 0%, hsl(0, 0%, 96%) 47%, hsl(0, 0%, 93%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); - border: 1px solid hsl(0, 0%, 85%); - border-radius: 4px; - box-shadow: 0 0 3px hsla(0, 0%, 0%, 0.1) inset; - color: hsl(0, 0%, 20%); - display: block; - min-height: 89px; - padding: 10px; - text-align: center; - text-decoration: none; + background: linear-gradient(to bottom, hsl(0, 0%, 100%) 0%, hsl(0, 0%, 96%) 47%, hsl(0, 0%, 93%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + border: 1px solid hsl(0, 0%, 85%); + border-radius: 4px; + box-shadow: 0 0 3px hsla(0, 0%, 0%, 0.1) inset; + color: hsl(0, 0%, 20%); + display: block; + min-height: 89px; + padding: 10px; + text-align: center; + text-decoration: none; } .dashboard-content a:hover { - background: linear-gradient(to bottom, hsl(0, 0%, 90%) 0%, hsl(0, 0%, 100%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); - color: hsl(200, 100%, 30%); - text-decoration: none; + background: linear-gradient(to bottom, hsl(0, 0%, 90%) 0%, hsl(0, 0%, 100%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + color: hsl(200, 100%, 30%); + text-decoration: none; } .dashboard-title { - display: block; - padding-top: 5px; + display: block; + padding-top: 5px; } .dashboard-info { - background: linear-gradient(to bottom, hsl(0, 0%, 100%) 0%, hsl(0, 0%, 96%) 47%, hsl(0, 0%, 93%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); - border: 1px solid hsl(0, 0%, 85%); - border-radius: 4px; - box-shadow: 0 0 3px hsla(0, 0%, 0%, 0.1) inset; - color: hsl(0, 0%, 20%); - display: block; - font-size: 12px; - padding: 10px; - text-align: center; + background: linear-gradient(to bottom, hsl(0, 0%, 100%) 0%, hsl(0, 0%, 96%) 47%, hsl(0, 0%, 93%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + border: 1px solid hsl(0, 0%, 85%); + border-radius: 4px; + box-shadow: 0 0 3px hsla(0, 0%, 0%, 0.1) inset; + color: hsl(0, 0%, 20%); + display: block; + font-size: 12px; + padding: 10px; + text-align: center; } .dashboard-info span { - display: block; - text-align: center; + display: block; + text-align: center; } .dashboard-info img { - margin: 0 auto; + margin: 0 auto; } .dashboard-table { - border-top: 1px solid hsl(0, 0%, 87%); - margin-top: 5px; - width: 100%; + border-top: 1px solid hsl(0, 0%, 87%); + margin-top: 5px; + width: 100%; } .dashboard-info h5 { - font-size: 11px; - font-weight: bold; + font-size: 11px; + font-weight: bold; } .dashboard-block { - background: linear-gradient(to bottom, hsl(0, 0%, 95%) 0%, hsl(0, 0%, 86%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); - border: 1px solid hsl(0, 0%, 76%); - border-radius: 3px; - box-shadow: 0 1px 0 hsl(0, 0%, 98%) inset; - margin-bottom: 20px; + background: linear-gradient(to bottom, hsl(0, 0%, 95%) 0%, hsl(0, 0%, 86%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + border: 1px solid hsl(0, 0%, 76%); + border-radius: 3px; + box-shadow: 0 1px 0 hsl(0, 0%, 98%) inset; + margin-bottom: 20px; } .dashboard-block .dashboard-block-head { - background: linear-gradient(to bottom, hsl(0, 0%, 95%) 0%, hsl(0, 0%, 86%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); - border-bottom: 1px solid hsl(0, 0%, 76%); - border-radius: 3px 3px 0 0; - box-shadow: 0 1px 0 hsl(0, 0%, 98%) inset, 0 0 3px hsl(0, 0%, 87%); - height: 40px; - position: relative; + background: linear-gradient(to bottom, hsl(0, 0%, 95%) 0%, hsl(0, 0%, 86%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + border-bottom: 1px solid hsl(0, 0%, 76%); + border-radius: 3px 3px 0 0; + box-shadow: 0 1px 0 hsl(0, 0%, 98%) inset, 0 0 3px hsl(0, 0%, 87%); + height: 40px; + position: relative; } .dashboard-block .dashboard-block-head h5 { - font-size: 12px; - margin: 0; - padding-left: 10px; - padding-top: 11px; - text-transform: uppercase; + font-size: 12px; + margin: 0; + padding-left: 10px; + padding-top: 11px; + text-transform: uppercase; } .dashboard-block .dashboard-block-content { - background: none repeat scroll 0 0 hsl(0, 0%, 93%); - border-radius: 0 0 3px 3px; + background: none repeat scroll 0 0 hsl(0, 0%, 93%); + border-radius: 0 0 3px 3px; } .dashboard-block .dashboard-block-box { - background: none repeat scroll 0 0 hsl(0, 0%, 100%); - border-top: 1px solid hsl(0, 0%, 82%); - box-shadow: 0 0 5px hsl(0, 0%, 87%) inset; + background: none repeat scroll 0 0 hsl(0, 0%, 100%); + border-top: 1px solid hsl(0, 0%, 82%); + box-shadow: 0 0 5px hsl(0, 0%, 87%) inset; } .dashboard-block .dashboard-block-content .dashboard-block-box { - margin-top: 0 !important; + margin-top: 0 !important; } .dashboard-block .dashboard-block-content .dashboard-block-box .dashboard-block-table { - margin-bottom: 0 !important; + margin-bottom: 0 !important; } .dashboard-block-table { - background-color: hsla(0, 0%, 0%, 0); - border-collapse: collapse; - border-spacing: 0; - margin-bottom: 20px; - max-width: 100%; - width: 100%; + background-color: hsla(0, 0%, 0%, 0); + border-collapse: collapse; + border-spacing: 0; + margin-bottom: 20px; + max-width: 100%; + width: 100%; } .dashboard-block-table th, .dashboard-block-table td { - border-top: 1px solid hsl(0, 0%, 87%); - line-height: 20px; - padding: 5px; - text-align: left; - vertical-align: middle; + border-top: 1px solid hsl(0, 0%, 87%); + line-height: 20px; + padding: 5px; + text-align: left; + vertical-align: middle; } .dashboard-badge { - background-color: hsl(0, 0%, 60%); - border-radius: 9px; - color: hsl(0, 0%, 100%); - font-size: 11.844px; - font-weight: bold; - line-height: 14px; - padding: 1px 9px 2px; - text-shadow: 0 -1px 0 hsla(0, 0%, 0%, 0.25); - vertical-align: baseline; - white-space: nowrap; + background-color: hsl(0, 0%, 60%); + border-radius: 9px; + color: hsl(0, 0%, 100%); + font-size: 11.844px; + font-weight: bold; + line-height: 14px; + padding: 1px 9px 2px; + text-shadow: 0 -1px 0 hsla(0, 0%, 0%, 0.25); + vertical-align: baseline; + white-space: nowrap; } \ No newline at end of file diff --git a/admin/assets/images/import.gif b/admin/assets/images/import.gif index 4371cc618bdc1702aad69fc871a50182a01537ec..10bcb856924dbc48ac739332a40ce1617c88687b 100644 GIT binary patch delta 4162 zcmeHKYgm&<7S5MIE)Xuka1RiIcvnJE7O+;tsI<09tst#biMkbwNRYA?9xV|F0i-rK zRG?77T9sC$DFgJ8b=`u>qQYv?LKbg$tE`I))cRPeXfqf1g8koL=1TA|H z8%G|sPGV#z^1553X>X!OPV(#-Cch~++#&?F1DH`Ma26ngm+B9E#cn_?@F%JCf)ti5 z*v#ey-Gv)zs-2>B1a(_vAt=Z!$OGotSX0z)+XjMCi9cnz{$fUX0;7{H=v~W)BD+%* z{crnHg5K!x^4N3$W95IqM~-t{k;Z^rL!|Yt%*;ZGtmv}{J{kgN9otA0kUV8`1fv|# z=yZ*-Lns&Zfhkik{8MQMiweVfwa(kAf)STXgsaoFlSN^@@T6Nd` zgi#)@G&aF=s~d99GHF``ldTz!?=Xg-F`z7!0j;wL+RNez9433UGi;GXbuv&D>Inu+ zd{|Swo59s`p7JV&XNM1NSm%`M5dHuYE#3PgN$gu<$HqftsRI{}gYeJ(r9jATq18iY z)qeS!)B5=JQh)!o!Z-H67m+hmwiWXX`A4IFxiDV4eupBGFXbpNX)8A@R)i&NpWfe^ zi$U>|;>IMx!SXUHz2NgnwB~R3jj#Y?CyQO8xpYejf%jbzFh+^M{1ab* z?~nA5sPdX38a1<4KQ5|x4!mDGg-7(b)Fry3bbW`8{J*K+#nZ}i4PjAT0%MQdSC6Gh zduovdnfg1F_-;coON{mv-r-Q&_#IuCkYj5|mXc$8$La*^!aIPprW*vY>hDL0@x$UF zY`}-dB^HOmAF74(Pb?-nVD3L@ioNsKe+rV^t$X4M1~B{+T~ zeuDT(?BQ-7^a)nAD+wU4{jBBGy2GT7(M>Bjzkyb@`9kCPsytx$4=U=^b)Ljj@YRco zQT(OtmZYcx5x8(#1PnSc=(r_<6MuB3(6Fwrh>+V|uM%Tc_iMyR?_Nxd@4Ksrp*BTZ z>IiI7!KbD?%B1gkg`iq{s>P_t09jinF7|`V1;q30@)BY!xe~+*B*&!y#9a*{Uc=Qo zVn{aS5Tosy7dGHe*OpuCDzs@`p?6|AkpP=E2T(EhlH?@Pc1!E?nfRbC`8c6V);Q8o zZHlYKst=Z%1S?EcSbbXRWFP;Hn@|ED@CMQsu zzX=3v+eipXwk;>d-EBLF@z)Q(B!*48iWtk&DW)>rg^V<&`w*im-NzSYPVK0PJ*4sT zy{D-@Xn*dIbajbRY;a!Q_Wm5>el(C*x9J1Yy>W|xz z`TQK&9%%lEdRsEXaem0t?in{l-C#>r7LhiT>Rr2_PW)Uf<_yuw$T&T z>Rx9&km{Mg<(DzaD*qJ&S9EI4BApIzAYiXgB>Wlr>BKmspM}q9{=n9>Cxy1mWL)!g z{df4rU~pvIybQfn#bWuzZiYYg?QG>?45-PA#jUquDtI&04fx~>SV^M`)=DyX71Wbb zIt$j)QeG;gr_s7XEjv*~bv}^yv6f(9&Ta`8mlD`pm8Gt?9@k7cB!_o}2wpaXF%d{p z1CJXOBx#(<@7pzJTEqFt?ooDO?uxK>Q%r!t8Uak+L(^lIpQ_exsZ-YQ6)R3G6i8YMe7KfcUNqwu&G2|@ zR=yc{5#iRjFRkGE*-SiJrg*)stgQLArsJ*91;M4rx93sP*wVq|M`>I(n;*{hYmHZA0 Cx!!>Q delta 2752 zcmeHJ`&Z0q81Fl`dYjs2=r+@I9V()tqzh||R_^5zp{20OCY2RS*)Ehzp}eg`+F7hD z9c|u5II%@*J7{wkT1^htC0({XyOhg5&s6Ncu;=*Yb7nrz=lwj-dwbsR%gut8cl?|U zJVMH{EI0un29C5$YsIR$c^pTmJwFpUC2byV&d&4wfZHiNf|R#jc1ak^4Ixd|6B>5K z$T!A$4{1=kHe0I=#cf388aV#sstThi2Ym(OGmRb9?$Om!LSqe8;9F*xfF?d*V#_8P zMPaUTvItOatk38L8Re|TScs82u@*4XwldyB$kl} zTwMu$YhH(DDz$<}xLGiPrM|p4s~a#f$od+@n4?U?8I#SW;pM|8d?_I8s@w{TX|Y); zCGHKW=L}thoPpyjOyUbOQL?>?2oSJ$wwF2dF4Zb%RaQS*(rCsc4%;~?F?h=_eC4fb zU$UrQrkSdf(5~G#VZe4LQ~j=>i=6$e?8G$Pg}(x(Im-dRa}EU@U1SY7wOhp3IFB8tnUHbCA)e5LgAah6^TRnn+e3c6V&+r)nAbP( z^^sOS8BFLgZ$~h;E(twz}@;a>ewmqTE^`5|A3A@-c7uoTv z1z5qpYfG?#s_+v%6)0HKjX-2vZk>m4>n$hzQy-Cxi;FeLSzM$Sa?kJl2)O(1L_p2r zNr0`3#{;gvrvY?q3`N8CsqU<#QG@!B`=0_%jXEqM9*Wv)gmTeaf!Glp1Zc1GLV3?+ z3IHOZ`8c4D6V zDM8`NudMWAb64F1WqjgtKwYAffYc`tX0kdAU82`?{`UZ>X(6?sR@qDGsI^fLE?yf9 z*tK>&VA8sSfXbvmz?dZD&n8&{HYC{tcI(kDSq8rYlI6Y20Qb&?QfkBMlJ&JO|3-;f zX-dk6s*PAzssLGDI&>^HK7D6z)wgNI#&qCEXW)^TpRpQ6H#2el7H^u51}gP9MmA63 z%*oKMEd`vXX5fsr#*E1L&oVMh2#wnk1Je6j+yG6tx{HaZZDr!?Y%%9T=#;G$mLx~Q zS=;95G5=8{dsLr`1(kS-SR(c3{D_v%3-OYk7%F;_ zHDa)~-bEH->MwKhzuYj}BS%OY>^j`Sf@=^KwW*)ij$H4)a4XRq%X zAMWVK9tVf{V~_iv_PA25B^&*)2rpIBqgj9>A9ov*U&PY9E7c}KSDKbIfO*D{nLaJtDRSk*`|(ijE?Di zjU#>EKgBvBVe9_#$4Bkt-|+2147?y_&Q$+=j{5Ikx?2%0@29Ux=sBT6=@;g5L{&SP z2F8vewC&|qsFt3p3->0#R8`(#|sLoAI8_s^c(B5 zo6tqwv6#eL|6Fx;&*kAiC05B|-%f+CE@4fffsoMJcllthjp97PJRjQfY*P~065!;p auROd_WJmG^JT4v-70Em<5+%)iF8^Od#l!;u diff --git a/admin/compiler/joomla_3/AdminController.php b/admin/compiler/joomla_3/AdminController.php index 98c6d9aeb..1837a17b6 100644 --- a/admin/compiler/joomla_3/AdminController.php +++ b/admin/compiler/joomla_3/AdminController.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ diff --git a/admin/compiler/joomla_3/AdminControllerDashboard.php b/admin/compiler/joomla_3/AdminControllerDashboard.php index 8f53ecd75..4bb2b3659 100644 --- a/admin/compiler/joomla_3/AdminControllerDashboard.php +++ b/admin/compiler/joomla_3/AdminControllerDashboard.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ diff --git a/admin/compiler/joomla_3/AdminController_custom_admin.php b/admin/compiler/joomla_3/AdminController_custom_admin.php index 8c32dc3cb..2cd69c6ed 100644 --- a/admin/compiler/joomla_3/AdminController_custom_admin.php +++ b/admin/compiler/joomla_3/AdminController_custom_admin.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -34,9 +34,9 @@ class ###Component###Controller###SViews### extends AdminController /** * Proxy for getModel. - * @since 2.5 + * @since 2.5 */ - public function getModel($name = '###SView###', $prefix = '###Component###Model', $config = array()) + public function getModel($name = '###SView###', $prefix = '###Component###Model', $config = []) { $model = parent::getModel($name, $prefix, array('ignore_request' => true)); @@ -45,7 +45,7 @@ class ###Component###Controller###SViews### extends AdminController public function dashboard() { - $this->setRedirect(JRoute::_('index.php?option=com_###component###', false)); + $this->setRedirect(Route::_('index.php?option=com_###component###', false)); return; }###CUSTOM_ADMIN_CUSTOM_BUTTONS_CONTROLLER### } diff --git a/admin/compiler/joomla_3/AdminModel.php b/admin/compiler/joomla_3/AdminModel.php index 4c2c92c56..a41ce196a 100644 --- a/admin/compiler/joomla_3/AdminModel.php +++ b/admin/compiler/joomla_3/AdminModel.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -52,18 +52,18 @@ class ###Component###Model###View### extends AdminModel * @param string $prefix A prefix for the table class name. Optional. * @param array $config Configuration array for model. Optional. * - * @return JTable A database object + * @return Table A database object * * @since 1.6 */ - public function getTable($type = '###view###', $prefix = '###Component###Table', $config = array()) + public function getTable($type = '###view###', $prefix = '###Component###Table', $config = []) { // add table path for when model gets used from other component $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_###component###/tables'); // get instance of the table - return JTable::getInstance($type, $prefix, $config); + return Table::getInstance($type, $prefix, $config); }###ADMIN_CUSTOM_BUTTONS_METHOD### - + /** * Method to get a single record. * @@ -108,7 +108,7 @@ class ###Component###Model###View### extends AdminModel * * @since 1.6 */ - public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) + public function getForm($data = [], $loadData = true, $options = array('control' => 'jform')) { // set load data option $options['load_data'] = $loadData;###JMODELADMIN_GETFORM### @@ -117,13 +117,13 @@ class ###Component###Model###View### extends AdminModel /** * Method to get the script that have to be included on the form * - * @return string script files + * @return string script files */ public function getScript() { return 'media/com_###component###/js/###view###.js'; } - + /** * Method to test whether a record can be deleted. * @@ -149,24 +149,24 @@ class ###Component###Model###View### extends AdminModel protected function canEditState($record) {###JMODELADMIN_CANEDITSTATE### } - + /** * Method override to check if you can edit an existing record. * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. * - * @return boolean - * @since 2.5 + * @return boolean + * @since 2.5 */ - protected function allowEdit($data = array(), $key = 'id') + protected function allowEdit($data = [], $key = 'id') {###JMODELADMIN_ALLOWEDIT### } - + /** * Prepare and sanitise the table data prior to saving. * - * @param JTable $table A JTable object. + * @param Table $table A Table object. * * @return void * @@ -174,19 +174,19 @@ class ###Component###Model###View### extends AdminModel */ protected function prepareTable($table) {###LICENSE_TABLE_LOCKED_CHECK### - $date = JFactory::getDate(); - $user = JFactory::getUser(); - + $date = Factory::getDate(); + $user = Factory::getUser(); + if (isset($table->name)) { $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); } - + if (isset($table->alias) && empty($table->alias)) { $table->generateAlias(); } - + if (empty($table->id)) { $table->created = $date->toSql(); @@ -198,7 +198,7 @@ class ###Component###Model###View### extends AdminModel // Set ordering to the last item if not set if (empty($table->ordering)) { - $db = JFactory::getDbo(); + $db = Factory::getDbo(); $query = $db->getQuery(true) ->select('MAX(ordering)') ->from($db->quoteName('#__###component###_###view###')); @@ -213,7 +213,7 @@ class ###Component###Model###View### extends AdminModel $table->modified = $date->toSql(); $table->modified_by = $user->id; } - + if (!empty($table->id)) { // Increment the items version number. @@ -228,10 +228,10 @@ class ###Component###Model###View### extends AdminModel * * @since 1.6 */ - protected function loadFormData() + protected function loadFormData() { // Check the session for previously entered form data. - $data = JFactory::getApplication()->getUserState('com_###component###.edit.###view###.data', array()); + $data = Factory::getApplication()->getUserState('com_###component###.edit.###view###.data', []); if (empty($data)) { @@ -242,7 +242,7 @@ class ###Component###Model###View### extends AdminModel return $data; }###VALIDATIONFIX######UNIQUEFIELDS### - + /** * Method to delete one or more records. * @@ -258,7 +258,7 @@ class ###Component###Model###View### extends AdminModel { return false; }###JMODELADMIN_AFTER_DELETE### - + return true; } @@ -278,10 +278,10 @@ class ###Component###Model###View### extends AdminModel { return false; }###JMODELADMIN_AFTER_PUBLISH### - + return true; - } - + } + /** * Method to perform batch operations on an item or a set of items. * @@ -307,30 +307,30 @@ class ###Component###Model###View### extends AdminModel if (empty($pks)) { - $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); return false; } $done = false; // Set some needed variables. - $this->user = JFactory::getUser(); - $this->table = $this->getTable(); - $this->tableClassName = get_class($this->table); - $this->contentType = new JUcmType; - $this->type = $this->contentType->getTypeByTable($this->tableClassName); - $this->canDo = ###Component###Helper::getActions('###view###'); - $this->batchSet = true; + $this->user = Factory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ###Component###Helper::getActions('###view###'); + $this->batchSet = true; if (!$this->canDo->get('core.batch')) { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); return false; } - + if ($this->type == false) { - $type = new JUcmType; + $type = new UCMType; $this->type = $type->getTypeByAlias($this->typeAlias); } @@ -367,8 +367,7 @@ class ###Component###Model###View### extends AdminModel if (!$done) { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); - + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); return false; } @@ -377,7 +376,7 @@ class ###Component###Model###View### extends AdminModel return true; }###MODEL_BATCH_COPY######MODEL_BATCH_MOVE### - + /** * Method to save the form data. * @@ -389,34 +388,34 @@ class ###Component###Model###View### extends AdminModel */ public function save($data) { - $input = JFactory::getApplication()->input; - $filter = JFilterInput::getInstance(); - + $input = Factory::getApplication()->input; + $filter = InputFilter::getInstance(); + // set the metadata to the Item Data if (isset($data['metadata']) && isset($data['metadata']['author'])) { $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); - - $metadata = new JRegistry; + + $metadata = new Registry; $metadata->loadArray($data['metadata']); $data['metadata'] = (string) $metadata; }###CHECKBOX_SAVE######METHOD_ITEM_SAVE### - + // Set the Params Items to data if (isset($data['params']) && is_array($data['params'])) { - $params = new JRegistry; + $params = new Registry; $params->loadArray($data['params']); $data['params'] = (string) $params; }###TITLEALIASFIX### - + if (parent::save($data)) { return true; } return false; } - + /** * Method to generate a unique value. * @@ -429,7 +428,6 @@ class ###Component###Model###View### extends AdminModel */ protected function generateUnique($field,$value) { - // set field value unique $table = $this->getTable(); diff --git a/admin/compiler/joomla_3/AdminModel_site.php b/admin/compiler/joomla_3/AdminModel_site.php index b805c970f..beb541e8d 100644 --- a/admin/compiler/joomla_3/AdminModel_site.php +++ b/admin/compiler/joomla_3/AdminModel_site.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -52,18 +52,18 @@ class ###Component###Model###View### extends AdminModel * @param string $prefix A prefix for the table class name. Optional. * @param array $config Configuration array for model. Optional. * - * @return JTable A database object + * @return Table A database object * * @since 1.6 */ - public function getTable($type = '###view###', $prefix = '###Component###Table', $config = array()) + public function getTable($type = '###view###', $prefix = '###Component###Table', $config = []) { // add table path for when model gets used from other component $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_###component###/tables'); // get instance of the table - return JTable::getInstance($type, $prefix, $config); + return Table::getInstance($type, $prefix, $config); }###ADMIN_CUSTOM_BUTTONS_METHOD### - + /** * Method to get a single record. * @@ -108,7 +108,7 @@ class ###Component###Model###View### extends AdminModel * * @since 1.6 */ - public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) + public function getForm($data = [], $loadData = true, $options = array('control' => 'jform')) { // set load data option $options['load_data'] = $loadData;###JMODELADMIN_GETFORM### @@ -117,13 +117,13 @@ class ###Component###Model###View### extends AdminModel /** * Method to get the script that have to be included on the form * - * @return string script files + * @return string script files */ public function getScript() { return 'media/com_###component###/js/###view###.js'; } - + /** * Method to test whether a record can be deleted. * @@ -149,24 +149,24 @@ class ###Component###Model###View### extends AdminModel protected function canEditState($record) {###JMODELADMIN_CANEDITSTATE### } - + /** * Method override to check if you can edit an existing record. * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. * - * @return boolean - * @since 2.5 + * @return boolean + * @since 2.5 */ - protected function allowEdit($data = array(), $key = 'id') + protected function allowEdit($data = [], $key = 'id') {###JMODELADMIN_ALLOWEDIT### } - + /** * Prepare and sanitise the table data prior to saving. * - * @param JTable $table A JTable object. + * @param Table $table A Table object. * * @return void * @@ -174,19 +174,19 @@ class ###Component###Model###View### extends AdminModel */ protected function prepareTable($table) {###LICENSE_TABLE_LOCKED_CHECK### - $date = JFactory::getDate(); - $user = JFactory::getUser(); - + $date = Factory::getDate(); + $user = Factory::getUser(); + if (isset($table->name)) { $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); } - + if (isset($table->alias) && empty($table->alias)) { $table->generateAlias(); } - + if (empty($table->id)) { $table->created = $date->toSql(); @@ -198,7 +198,7 @@ class ###Component###Model###View### extends AdminModel // Set ordering to the last item if not set if (empty($table->ordering)) { - $db = JFactory::getDbo(); + $db = Factory::getDbo(); $query = $db->getQuery(true) ->select('MAX(ordering)') ->from($db->quoteName('#__###component###_###view###')); @@ -213,7 +213,7 @@ class ###Component###Model###View### extends AdminModel $table->modified = $date->toSql(); $table->modified_by = $user->id; } - + if (!empty($table->id)) { // Increment the items version number. @@ -228,10 +228,10 @@ class ###Component###Model###View### extends AdminModel * * @since 1.6 */ - protected function loadFormData() + protected function loadFormData() { // Check the session for previously entered form data. - $data = JFactory::getApplication()->getUserState('com_###component###.edit.###view###.data', array()); + $data = Factory::getApplication()->getUserState('com_###component###.edit.###view###.data', []); if (empty($data)) { @@ -242,7 +242,7 @@ class ###Component###Model###View### extends AdminModel return $data; }###VALIDATIONFIX######UNIQUEFIELDS### - + /** * Method to delete one or more records. * @@ -258,7 +258,7 @@ class ###Component###Model###View### extends AdminModel { return false; }###JMODELADMIN_AFTER_DELETE### - + return true; } @@ -278,10 +278,10 @@ class ###Component###Model###View### extends AdminModel { return false; }###JMODELADMIN_AFTER_PUBLISH### - + return true; - } - + } + /** * Method to perform batch operations on an item or a set of items. * @@ -307,30 +307,30 @@ class ###Component###Model###View### extends AdminModel if (empty($pks)) { - $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); return false; } $done = false; // Set some needed variables. - $this->user = JFactory::getUser(); - $this->table = $this->getTable(); - $this->tableClassName = get_class($this->table); - $this->contentType = new JUcmType; - $this->type = $this->contentType->getTypeByTable($this->tableClassName); - $this->canDo = ###Component###Helper::getActions('###view###'); - $this->batchSet = true; + $this->user = Factory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ###Component###Helper::getActions('###view###'); + $this->batchSet = true; if (!$this->canDo->get('core.batch')) { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); return false; } - + if ($this->type == false) { - $type = new JUcmType; + $type = new UCMType; $this->type = $type->getTypeByAlias($this->typeAlias); } @@ -367,8 +367,7 @@ class ###Component###Model###View### extends AdminModel if (!$done) { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); - + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); return false; } @@ -377,7 +376,7 @@ class ###Component###Model###View### extends AdminModel return true; }###MODEL_BATCH_COPY######MODEL_BATCH_MOVE### - + /** * Method to save the form data. * @@ -389,34 +388,34 @@ class ###Component###Model###View### extends AdminModel */ public function save($data) { - $input = JFactory::getApplication()->input; - $filter = JFilterInput::getInstance(); - + $input = Factory::getApplication()->input; + $filter = InputFilter::getInstance(); + // set the metadata to the Item Data if (isset($data['metadata']) && isset($data['metadata']['author'])) { $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); - - $metadata = new JRegistry; + + $metadata = new Registry; $metadata->loadArray($data['metadata']); $data['metadata'] = (string) $metadata; }###CHECKBOX_SAVE######METHOD_ITEM_SAVE### - + // Set the Params Items to data if (isset($data['params']) && is_array($data['params'])) { - $params = new JRegistry; + $params = new Registry; $params->loadArray($data['params']); $data['params'] = (string) $params; }###TITLEALIASFIX### - + if (parent::save($data)) { return true; } return false; } - + /** * Method to generate a unique value. * @@ -427,9 +426,8 @@ class ###Component###Model###View### extends AdminModel * * @since 3.0 */ - protected function generateUnique($field,$value) + protected function generateUnique($field, $value) { - // set field value unique $table = $this->getTable(); diff --git a/admin/compiler/joomla_3/BaseController.php b/admin/compiler/joomla_3/BaseController.php index b7dd77c85..51991743a 100644 --- a/admin/compiler/joomla_3/BaseController.php +++ b/admin/compiler/joomla_3/BaseController.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -19,6 +19,8 @@ defined('_JEXEC') or die('Restricted access'); use Joomla\CMS\MVC\Controller\BaseController; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Router\Route; /** * General Controller of ###Component### component @@ -34,7 +36,7 @@ class ###Component###Controller extends BaseController * * @since 3.0 */ - public function __construct($config = array()) + public function __construct($config = []) { // set the default view $config['default_view'] = '###DASHBOARDVIEW###'; @@ -50,38 +52,38 @@ class ###Component###Controller extends BaseController function display($cachable = false, $urlparams = false) { // set default view if not set - $view = $this->input->getCmd('view', '###DASHBOARDVIEW###'); - $data = $this->getViewRelation($view); - $layout = $this->input->get('layout', null, 'WORD'); - $id = $this->input->getInt('id'); + $view = $this->input->getCmd('view', '###DASHBOARDVIEW###'); + $data = $this->getViewRelation($view); + $layout = $this->input->get('layout', null, 'WORD'); + $id = $this->input->getInt('id'); // Check for edit form. - if(###Component###Helper::checkArray($data)) + if(Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($data)) { if ($data['edit'] && $layout == 'edit' && !$this->checkEditId('com_###component###.edit.'.$data['view'], $id)) { // Somehow the person just went to the form - we don't allow that. - $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); // check if item was opend from other then its own list view - $ref = $this->input->getCmd('ref', 0); - $refid = $this->input->getInt('refid', 0); + $ref = $this->input->getCmd('ref', 0); + $refid = $this->input->getInt('refid', 0); // set redirect - if ($refid > 0 && ###Component###Helper::checkString($ref)) + if ($refid > 0 && Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($ref)) { // redirect to item of ref - $this->setRedirect(JRoute::_('index.php?option=com_###component###&view='.(string)$ref.'&layout=edit&id='.(int)$refid, false)); + $this->setRedirect(Route::_('index.php?option=com_###component###&view='.(string)$ref.'&layout=edit&id='.(int)$refid, false)); } - elseif (###Component###Helper::checkString($ref)) + elseif (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($ref)) { // redirect to ref - $this->setRedirect(JRoute::_('index.php?option=com_###component###&view='.(string)$ref, false)); + $this->setRedirect(Route::_('index.php?option=com_###component###&view='.(string)$ref, false)); } else { // normal redirect back to the list view - $this->setRedirect(JRoute::_('index.php?option=com_###component###&view='.$data['views'], false)); + $this->setRedirect(Route::_('index.php?option=com_###component###&view='.$data['views'], false)); } return false; @@ -94,7 +96,7 @@ class ###Component###Controller extends BaseController protected function getViewRelation($view) { // check the we have a value - if (###Component###Helper::checkString($view)) + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($view)) { // the view relationships $views = array(###VIEWARRAY### diff --git a/admin/compiler/joomla_3/BaseControllerAjax.php b/admin/compiler/joomla_3/BaseControllerAjax.php index fb3b4ac1c..1d9640c5b 100644 --- a/admin/compiler/joomla_3/BaseControllerAjax.php +++ b/admin/compiler/joomla_3/BaseControllerAjax.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,7 +17,9 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\CMS\Session\Session; use Joomla\Utilities\ArrayHelper; /** @@ -29,9 +31,9 @@ class ###Component###ControllerAjax extends BaseController { parent::__construct($config); // make sure all json stuff are set - JFactory::getDocument()->setMimeEncoding( 'application/json' ); + Factory::getDocument()->setMimeEncoding( 'application/json' ); // get the application - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $app->setHeader('Content-Disposition','attachment;filename="getajax.json"'); $app->setHeader('Access-Control-Allow-Origin', '*'); // load the tasks ###REGISTER_AJAX_TASK### @@ -40,16 +42,16 @@ class ###Component###ControllerAjax extends BaseController public function ajax() { // get the user for later use - $user = JFactory::getUser(); + $user = Factory::getUser(); // get the input values - $jinput = JFactory::getApplication()->input; + $jinput = Factory::getApplication()->input; // check if we should return raw - $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); + $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); // return to a callback function - $callback = $jinput->get('callback', null, 'CMD'); + $callback = $jinput->get('callback', null, 'CMD'); // Check Token! - $token = JSession::getFormToken(); - $call_token = $jinput->get('token', 0, 'ALNUM'); + $token = Session::getFormToken(); + $call_token = $jinput->get('token', 0, 'ALNUM'); if($jinput->get($token, 0, 'ALNUM') || $token === $call_token) { // get the task diff --git a/admin/compiler/joomla_3/BaseControllerAjaxSite.php b/admin/compiler/joomla_3/BaseControllerAjaxSite.php index b32768f64..a02fa0127 100644 --- a/admin/compiler/joomla_3/BaseControllerAjaxSite.php +++ b/admin/compiler/joomla_3/BaseControllerAjaxSite.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,7 +17,9 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\CMS\Session\Session; use Joomla\Utilities\ArrayHelper; /** @@ -29,9 +31,9 @@ class ###Component###ControllerAjax extends BaseController { parent::__construct($config); // make sure all json stuff are set - JFactory::getDocument()->setMimeEncoding( 'application/json' ); + Factory::getDocument()->setMimeEncoding( 'application/json' ); // get the application - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $app->setHeader('Content-Disposition','attachment;filename="getajax.json"'); $app->setHeader('Access-Control-Allow-Origin', '*'); // load the tasks ###REGISTER_SITE_AJAX_TASK### @@ -40,16 +42,16 @@ class ###Component###ControllerAjax extends BaseController public function ajax() { // get the user for later use - $user = JFactory::getUser(); + $user = Factory::getUser(); // get the input values - $jinput = JFactory::getApplication()->input; + $jinput = Factory::getApplication()->input; // check if we should return raw - $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); + $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); // return to a callback function - $callback = $jinput->get('callback', null, 'CMD'); + $callback = $jinput->get('callback', null, 'CMD'); // Check Token! - $token = JSession::getFormToken(); - $call_token = $jinput->get('token', 0, 'ALNUM'); + $token = Session::getFormToken(); + $call_token = $jinput->get('token', 0, 'ALNUM'); if($jinput->get($token, 0, 'ALNUM') || $token === $call_token) { // get the task @@ -71,7 +73,7 @@ class ###Component###ControllerAjax extends BaseController echo json_encode(false); } else - { + { echo "(".json_encode(false).");"; } } diff --git a/admin/compiler/joomla_3/BaseControllerHelp.php b/admin/compiler/joomla_3/BaseControllerHelp.php index 86f92aa41..8cd3d0ebf 100644 --- a/admin/compiler/joomla_3/BaseControllerHelp.php +++ b/admin/compiler/joomla_3/BaseControllerHelp.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,7 +17,10 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Session\Session; use Joomla\Utilities\ArrayHelper; /** @@ -34,12 +37,12 @@ class ###Component###ControllerHelp extends BaseController public function help() { - $user = JFactory::getUser(); - $jinput = JFactory::getApplication()->input; + $user = Factory::getUser(); + $jinput = Factory::getApplication()->input; // Check Token! - $token = JSession::getFormToken(); - $call_token = $jinput->get('token', 0, 'ALNUM'); - if($user->id != 0 && $token == $call_token) + $token = Session::getFormToken(); + $call_token = $jinput->get('token', 0, 'ALNUM'); + if($user->id != 0 && ($jinput->get($token, 0, 'ALNUM') || $token === $call_token)) { $task = $this->getTask(); switch($task){ @@ -67,7 +70,7 @@ class ###Component###ControllerHelp extends BaseController break; } } - else + else { // stop execution gracefully jexit(); @@ -76,8 +79,8 @@ class ###Component###ControllerHelp extends BaseController protected function getHelpDocumentText($id) { - $db = JFactory::getDbo(); - $query = $db->getQuery(true); + $db = Factory::getDbo(); + $query = $db->getQuery(true); $query->select(array('a.title','a.content')); $query->from('#__###component###_help_document AS a'); $query->where('a.id = '.(int) $id); @@ -86,21 +89,21 @@ class ###Component###ControllerHelp extends BaseController $db->execute(); if($db->getNumRows()) { - $text = array(); + $text = []; $document = $db->loadObject(); // fix image issue - $images['src="images'] = 'src="'.JURI::root().'images'; - $images["src='images"] = "src='".JURI::root()."images"; - $images['src="/images'] = 'src="'.JURI::root().'images'; - $images["src='/images"] = "src='".JURI::root()."images"; + $images['src="images'] = 'src="'.Uri::root().'images'; + $images["src='images"] = "src='".Uri::root()."images"; + $images['src="/images'] = 'src="'.Uri::root().'images'; + $images["src='/images"] = "src='".Uri::root()."images"; // set document template $text[] = ""; $text[] = ''; $text[] = ""; $text[] = ''; $text[] = "".$document->title.""; - $text[] = ''; - $text[] = ''; + $text[] = ''; + $text[] = ''; $text[] = ""; $text[] = '
'; $text[] = '
'; diff --git a/admin/compiler/joomla_3/BaseControllerHelp_site.php b/admin/compiler/joomla_3/BaseControllerHelp_site.php index 2df722c4b..dfeb2d229 100644 --- a/admin/compiler/joomla_3/BaseControllerHelp_site.php +++ b/admin/compiler/joomla_3/BaseControllerHelp_site.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,7 +17,10 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Session\Session; use Joomla\Utilities\ArrayHelper; /** @@ -34,12 +37,12 @@ class ###Component###ControllerHelp extends BaseController public function help() { - $user = JFactory::getUser(); - $jinput = JFactory::getApplication()->input; + $user = Factory::getUser(); + $jinput = Factory::getApplication()->input; // Check Token! - $token = JSession::getFormToken(); - $call_token = $jinput->get('token', 0, 'ALNUM'); - if($token == $call_token) + $token = Session::getFormToken(); + $call_token = $jinput->get('token', 0, 'ALNUM'); + if($user->id != 0 && ($jinput->get($token, 0, 'ALNUM') || $token === $call_token)) { $task = $this->getTask(); switch($task){ @@ -76,8 +79,8 @@ class ###Component###ControllerHelp extends BaseController protected function getHelpDocumentText($id) { - $db = JFactory::getDbo(); - $query = $db->getQuery(true); + $db = Factory::getDbo(); + $query = $db->getQuery(true); $query->select(array('a.title','a.content')); $query->from('#__###component###_help_document AS a'); $query->where('a.id = '.(int) $id); @@ -87,21 +90,21 @@ class ###Component###ControllerHelp extends BaseController $db->execute(); if($db->getNumRows()) { - $text = array(); + $text = []; $document = $db->loadObject(); // fix image issue - $images['src="images'] = 'src="'.JURI::root().'images'; - $images["src='images"] = "src='".JURI::root()."images"; - $images['src="/images'] = 'src="'.JURI::root().'images'; - $images["src='/images"] = "src='".JURI::root()."images"; + $images['src="images'] = 'src="'.Uri::root().'images'; + $images["src='images"] = "src='".Uri::root()."images"; + $images['src="/images'] = 'src="'.Uri::root().'images'; + $images["src='/images"] = "src='".Uri::root()."images"; // set document template $text[] = ""; $text[] = ''; $text[] = ""; $text[] = ''; $text[] = "".$document->title.""; - $text[] = ''; - $text[] = ''; + $text[] = ''; + $text[] = ''; $text[] = ""; $text[] = '
'; $text[] = '
'; diff --git a/admin/compiler/joomla_3/BaseControllerSITE.php b/admin/compiler/joomla_3/BaseControllerSITE.php index af2bde03e..cee5dbb72 100644 --- a/admin/compiler/joomla_3/BaseControllerSITE.php +++ b/admin/compiler/joomla_3/BaseControllerSITE.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,8 +17,11 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\CMS\Router\Route; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Language\Text; /** * ###Component### Component Base Controller @@ -37,51 +40,51 @@ class ###Component###Controller extends BaseController function display($cachable = false, $urlparams = false) { // set default view if not set - $view = $this->input->getCmd('view', '###SITE_DEFAULT_VIEW###'); + $view = $this->input->getCmd('view', '###SITE_DEFAULT_VIEW###'); $this->input->set('view', $view); - $isEdit = $this->checkEditView($view); - $layout = $this->input->get('layout', null, 'WORD'); - $id = $this->input->getInt('id'); - // $cachable = true; (TODO) working on a fix [gh-238](https://github.com/vdm-io/Joomla-Component-Builder/issues/238) - + $isEdit = $this->checkEditView($view); + $layout = $this->input->get('layout', null, 'WORD'); + $id = $this->input->getInt('id'); + // $cachable = true; (TODO) working on a fix [gh-238](https://github.com/vdm-io/Joomla-Component-Builder/issues/238) + // insure that the view is not cashable if edit view or if user is logged in - $user = JFactory::getUser(); + $user = Factory::getUser(); if ($user->get('id') || $isEdit) { $cachable = false; } - + // Check for edit form. if($isEdit) { if ($layout == 'edit' && !$this->checkEditId('com_###component###.edit.'.$view, $id)) { // Somehow the person just went to the form - we don't allow that. - $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); // check if item was opend from other then its own list view - $ref = $this->input->getCmd('ref', 0); - $refid = $this->input->getInt('refid', 0); + $ref = $this->input->getCmd('ref', 0); + $refid = $this->input->getInt('refid', 0); // set redirect - if ($refid > 0 && ###Component###Helper::checkString($ref)) + if ($refid > 0 && Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($ref)) { // redirect to item of ref - $this->setRedirect(JRoute::_('index.php?option=com_###component###&view='.(string)$ref.'&layout=edit&id='.(int)$refid, false)); + $this->setRedirect(Route::_('index.php?option=com_###component###&view='.(string)$ref.'&layout=edit&id='.(int)$refid, false)); } - elseif (###Component###Helper::checkString($ref)) + elseif (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($ref)) { // redirect to ref - $this->setRedirect(JRoute::_('index.php?option=com_###component###&view='.(string)$ref, false)); + $this->setRedirect(Route::_('index.php?option=com_###component###&view='.(string)$ref, false)); } else { // normal redirect back to the list default site view - $this->setRedirect(JRoute::_('index.php?option=com_###component###&view=###SITE_DEFAULT_VIEW###', false)); + $this->setRedirect(Route::_('index.php?option=com_###component###&view=###SITE_DEFAULT_VIEW###', false)); } return false; } } - + // we may need to make this more dynamic in the future. (TODO) $safeurlparams = array( 'catid' => 'INT', @@ -102,9 +105,9 @@ class ###Component###Controller extends BaseController 'Itemid' => 'INT'); // should these not merge? - if (###Component###Helper::checkArray($urlparams)) + if (Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($urlparams)) { - $safeurlparams = ###Component###Helper::mergeArrays(array($urlparams, $safeurlparams)); + $safeurlparams = Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::merge(array($urlparams, $safeurlparams)); } return parent::display($cachable, $safeurlparams); @@ -112,7 +115,7 @@ class ###Component###Controller extends BaseController protected function checkEditView($view) { - if (###Component###Helper::checkString($view)) + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($view)) { $views = array(###SITE_EDIT_VIEW_ARRAY### ); diff --git a/admin/compiler/joomla_3/BaseController_custom_admin.php b/admin/compiler/joomla_3/BaseController_custom_admin.php index 8ed50653a..3976b770a 100644 --- a/admin/compiler/joomla_3/BaseController_custom_admin.php +++ b/admin/compiler/joomla_3/BaseController_custom_admin.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -31,7 +31,7 @@ class ###Component###Controller###SView### extends BaseController public function dashboard() { - $this->setRedirect(JRoute::_('index.php?option=com_###component###', false)); + $this->setRedirect(Route::_('index.php?option=com_###component###', false)); return; }###CUSTOM_ADMIN_CUSTOM_BUTTONS_CONTROLLER### } diff --git a/admin/compiler/joomla_3/BaseController_import.php b/admin/compiler/joomla_3/BaseController_import.php index 504c266f2..f5811358a 100644 --- a/admin/compiler/joomla_3/BaseController_import.php +++ b/admin/compiler/joomla_3/BaseController_import.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -32,21 +32,21 @@ class ###Component###ControllerImport extends BaseController public function import() { // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); $model = $this->getModel('import'); if ($model->import()) { - $cache = JFactory::getCache('mod_menu'); + $cache = Factory::getCache('mod_menu'); $cache->clean(); // TODO: Reset the users acl here as well to kill off any missing bits } - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $redirect_url = $app->getUserState('com_###component###.redirect_url'); if (empty($redirect_url)) { - $redirect_url = JRoute::_('index.php?option=com_###component###&view=import', false); + $redirect_url = Route::_('index.php?option=com_###component###&view=import', false); } else { diff --git a/admin/compiler/joomla_3/BaseController_import_custom.php b/admin/compiler/joomla_3/BaseController_import_custom.php index dbe424603..a9283454a 100644 --- a/admin/compiler/joomla_3/BaseController_import_custom.php +++ b/admin/compiler/joomla_3/BaseController_import_custom.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -32,21 +32,21 @@ class ###Component###Controller###View### extends BaseController public function import() { // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); $model = $this->getModel('###View###'); if ($model->import()) { - $cache = JFactory::getCache('mod_menu'); + $cache = Factory::getCache('mod_menu'); $cache->clean(); // TODO: Reset the users acl here as well to kill off any missing bits } - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $redirect_url = $app->getUserState('com_###component###.redirect_url'); if (empty($redirect_url)) { - $redirect_url = JRoute::_('index.php?option=com_###component###&view=###view###', false); + $redirect_url = Route::_('index.php?option=com_###component###&view=###view###', false); } else { diff --git a/admin/compiler/joomla_3/BaseDatabaseModel_import.php b/admin/compiler/joomla_3/BaseDatabaseModel_import.php index f7501c7ec..020739141 100644 --- a/admin/compiler/joomla_3/BaseDatabaseModel_import.php +++ b/admin/compiler/joomla_3/BaseDatabaseModel_import.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -27,8 +27,8 @@ class ###Component###ModelImport extends BaseDatabaseModel // set uploading values protected $use_streams = false; protected $allow_unsafe = false; - protected $safeFileOptions = array(); - + protected $safeFileOptions = []; + /** * @var object JTable object */ @@ -45,13 +45,13 @@ class ###Component###ModelImport extends BaseDatabaseModel * @var string */ protected $_context = 'com_###component###.import'; - + /** * Import Settings */ - protected $getType = NULL; - protected $dataType = NULL; - + protected $getType = NULL; + protected $dataType = NULL; + /** * Method to auto-populate the model state. * @@ -62,7 +62,7 @@ class ###Component###ModelImport extends BaseDatabaseModel */ protected function populateState() { - $app = JFactory::getApplication('administrator'); + $app = Factory::getApplication('administrator'); $this->setState('message', $app->getUserState('com_###component###.message')); $app->setUserState('com_###component###.message', ''); @@ -82,14 +82,14 @@ class ###Component###ModelImport extends BaseDatabaseModel public function import() { $this->setState('action', 'import'); - $app = JFactory::getApplication(); - $session = JFactory::getSession(); + $app = Factory::getApplication(); + $session = Factory::getSession(); $package = null; $continue = false; // get import type $this->getType = $app->input->getString('gettype', NULL); // get import type - $this->dataType = $session->get('dataType_VDM_IMPORTINTO', NULL); + $this->dataType = $session->get('dataType_VDM_IMPORTINTO', NULL); if ($package === null) { @@ -110,9 +110,9 @@ class ###Component###ModelImport extends BaseDatabaseModel break; case 'continue': - $continue = true; - $package = $session->get('package', null); - $package = json_decode($package, true); + $continue = true; + $package = $session->get('package', null); + $package = json_decode($package, true); // clear session $session->clear('package'); $session->clear('dataType'); @@ -120,7 +120,7 @@ class ###Component###ModelImport extends BaseDatabaseModel break; default: - $app->setUserState('com_###component###.message', JText::_('COM_###COMPONENT###_IMPORT_NO_IMPORT_TYPE_FOUND')); + $app->setUserState('com_###component###.message', Text::_('COM_###COMPONENT###_IMPORT_NO_IMPORT_TYPE_FOUND')); return false; break; @@ -134,10 +134,10 @@ class ###Component###ModelImport extends BaseDatabaseModel $this->remove($package['packagename']); } - $app->setUserState('com_###component###.message', JText::_('COM_###COMPONENT###_IMPORT_UNABLE_TO_FIND_IMPORT_PACKAGE')); + $app->setUserState('com_###component###.message', Text::_('COM_###COMPONENT###_IMPORT_UNABLE_TO_FIND_IMPORT_PACKAGE')); return false; } - + // first link data to table headers if(!$continue){ $package = json_encode($package); @@ -146,13 +146,13 @@ class ###Component###ModelImport extends BaseDatabaseModel $session->set('hasPackage', true); return true; } - + // set the data $headerList = json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS', false), true); if (!$this->setData($package,$this->dataType,$headerList)) { // There was an error importing the package - $msg = JText::_('COM_###COMPONENT###_IMPORT_ERROR'); + $msg = Text::_('COM_###COMPONENT###_IMPORT_ERROR'); $back = $session->get('backto_VDM_IMPORT', NULL); if ($back) { @@ -164,12 +164,12 @@ class ###Component###ModelImport extends BaseDatabaseModel else { // Package imported sucessfully - $msg = JText::sprintf('COM_###COMPONENT###_IMPORT_SUCCESS', $package['packagename']); + $msg = Text::sprintf('COM_###COMPONENT###_IMPORT_SUCCESS', $package['packagename']); $back = $session->get('backto_VDM_IMPORT', NULL); if ($back) { - $app->setUserState('com_###component###.redirect_url', 'index.php?option=com_###component###&view='.$back); - $session->clear('backto_VDM_IMPORT'); + $app->setUserState('com_###component###.redirect_url', 'index.php?option=com_###component###&view='.$back); + $session->clear('backto_VDM_IMPORT'); } $result = true; } @@ -180,7 +180,7 @@ class ###Component###ModelImport extends BaseDatabaseModel // remove file after import $this->remove($package['packagename']); $session->clear($this->getType.'_VDM_IMPORTHEADERS'); - + return $result; } @@ -190,48 +190,47 @@ class ###Component###ModelImport extends BaseDatabaseModel * @return spreadsheet definition or false on failure */ protected function _getPackageFromUpload() - { + { // Get the uploaded file information - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $input = $app->input; // Do not change the filter type 'raw'. We need this to let files containing PHP code to upload. See JInputFiles::get. $userfile = $input->files->get('import_package', null, 'raw'); - + // Make sure that file uploads are enabled in php if (!(bool) ini_get('file_uploads')) { - $app->enqueueMessage(JText::_('COM_###COMPONENT###_IMPORT_MSG_WARNIMPORTFILE'), 'warning'); + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_WARNIMPORTFILE'), 'warning'); return false; } // If there is no uploaded file, we have a problem... if (!is_array($userfile)) { - $app->enqueueMessage(JText::_('COM_###COMPONENT###_IMPORT_MSG_NO_FILE_SELECTED'), 'warning'); + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_NO_FILE_SELECTED'), 'warning'); return false; } // Check if there was a problem uploading the file. if ($userfile['error'] || $userfile['size'] < 1) { - $app->enqueueMessage(JText::_('COM_###COMPONENT###_IMPORT_MSG_WARNIMPORTUPLOADERROR'), 'warning'); + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_WARNIMPORTUPLOADERROR'), 'warning'); return false; } // Build the appropriate paths - $config = JFactory::getConfig(); + $config = Factory::getConfig(); $tmp_dest = $config->get('tmp_path') . '/' . $userfile['name']; $tmp_src = $userfile['tmp_name']; // Move uploaded file - jimport('joomla.filesystem.file'); $p_file = File::upload($tmp_src, $tmp_dest, $this->use_streams, $this->allow_unsafe, $this->safeFileOptions); // Was the package downloaded? if (!$p_file) { - $session = JFactory::getSession(); + $session = Factory::getSession(); $session->clear('package'); $session->clear('dataType'); $session->clear('hasPackage'); @@ -253,16 +252,16 @@ class ###Component###ModelImport extends BaseDatabaseModel */ protected function _getPackageFromFolder() { - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $input = $app->input; // Get the path to the package to import $p_dir = $input->getString('import_directory'); - $p_dir = JPath::clean($p_dir); + $p_dir = Path::clean($p_dir); // Did you give us a valid path? if (!file_exists($p_dir)) { - $app->enqueueMessage(JText::_('COM_###COMPONENT###_IMPORT_MSG_PLEASE_ENTER_A_PACKAGE_DIRECTORY'), 'warning'); + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_PLEASE_ENTER_A_PACKAGE_DIRECTORY'), 'warning'); return false; } @@ -272,17 +271,17 @@ class ###Component###ModelImport extends BaseDatabaseModel // Did you give us a valid package? if (!$type) { - $app->enqueueMessage(JText::_('COM_###COMPONENT###_IMPORT_MSG_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE'), 'warning'); + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE'), 'warning'); } - + // check the extention if(!$this->checkExtension($p_dir)) { // set error message - $app->enqueueMessage(JText::_('COM_###COMPONENT###_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); return false; } - + $package['packagename'] = null; $package['dir'] = $p_dir; $package['type'] = $type; @@ -298,26 +297,26 @@ class ###Component###ModelImport extends BaseDatabaseModel */ protected function _getPackageFromUrl() { - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $input = $app->input; - + // Get the URL of the package to import $url = $input->getString('import_url'); // Did you give us a URL? if (!$url) { - $app->enqueueMessage(JText::_('COM_###COMPONENT###_IMPORT_MSG_ENTER_A_URL'), 'warning'); + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_ENTER_A_URL'), 'warning'); return false; } // Download the package at the URL given - $p_file = JInstallerHelper::downloadPackage($url); + $p_file = InstallerHelper::downloadPackage($url); // Was the package downloaded? if (!$p_file) { - $app->enqueueMessage(JText::_('COM_###COMPONENT###_IMPORT_MSG_INVALID_URL'), 'warning'); + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_INVALID_URL'), 'warning'); return false; } @@ -326,7 +325,7 @@ class ###Component###ModelImport extends BaseDatabaseModel return $package; } - + /** * Check a file and verifies it as a spreadsheet file * Supports .csv .xlsx .xls and .ods @@ -338,29 +337,29 @@ class ###Component###ModelImport extends BaseDatabaseModel */ protected function check($archivename) { - $app = JFactory::getApplication(); + $app = Factory::getApplication(); // Clean the name - $archivename = JPath::clean($archivename); - + $archivename = Path::clean($archivename); + // check the extention if(!$this->checkExtension($archivename)) { // Cleanup the import files $this->remove($archivename); - $app->enqueueMessage(JText::_('COM_###COMPONENT###_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); return false; } - - $config = JFactory::getConfig(); + + $config = Factory::getConfig(); // set Package Name $check['packagename'] = $archivename; - + // set directory $check['dir'] = $config->get('tmp_path'). '/' .$archivename; - + // set type $check['type'] = $this->getType; - + return $check; }###IMPORT_EXT_METHOD### @@ -375,8 +374,8 @@ class ###Component###ModelImport extends BaseDatabaseModel protected function remove($package) { jimport('joomla.filesystem.file'); - - $config = JFactory::getConfig(); + + $config = Factory::getConfig(); $package = $config->get('tmp_path'). '/' .$package; // Is the package file a valid file? @@ -384,23 +383,23 @@ class ###Component###ModelImport extends BaseDatabaseModel { File::delete($package); } - elseif (is_file(JPath::clean($package))) + elseif (is_file(Path::clean($package))) { // It might also be just a base filename - File::delete(JPath::clean($package)); + File::delete(Path::clean($package)); } }###IMPORT_SETDATA_METHOD######IMPORT_SAVE_METHOD### protected function getAlias($name,$type = false) { // sanitize the name to an alias - if (JFactory::getConfig()->get('unicodeslugs') == 1) + if (Factory::getConfig()->get('unicodeslugs') == 1) { - $alias = JFilterOutput::stringURLUnicodeSlug($name); + $alias = OutputFilter::stringURLUnicodeSlug($name); } else { - $alias = JFilterOutput::stringURLSafe($name); + $alias = OutputFilter::stringURLSafe($name); } // must be a uniqe alias if ($type) @@ -409,7 +408,7 @@ class ###Component###ModelImport extends BaseDatabaseModel } return $alias; } - + /** * Method to generate a uniqe value. * @@ -424,16 +423,16 @@ class ###Component###ModelImport extends BaseDatabaseModel // insure the filed is always uniqe while (isset($this->uniqeValueArray[$type][$field][$value])) { - $value = JString::increment($value, 'dash'); + $value = StringHelper::increment($value, 'dash'); } $this->uniqeValueArray[$type][$field][$value] = $value; return $value; } - + protected function getAliasesUsed($table) { // Get a db connection. - $db = JFactory::getDbo(); + $db = Factory::getDbo(); // first we check if there is a alias column $columns = $db->getTableColumns('#__###component###_'.$table); if(isset($columns['alias'])){ diff --git a/admin/compiler/joomla_3/BaseDatabaseModel_import_custom.php b/admin/compiler/joomla_3/BaseDatabaseModel_import_custom.php index 19be712eb..e429a0223 100644 --- a/admin/compiler/joomla_3/BaseDatabaseModel_import_custom.php +++ b/admin/compiler/joomla_3/BaseDatabaseModel_import_custom.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -27,8 +27,8 @@ class ###Component###Model###View### extends BaseDatabaseModel // set uploading values protected $use_streams = false; protected $allow_unsafe = false; - protected $safeFileOptions = array(); - + protected $safeFileOptions = []; + /** * @var object JTable object */ @@ -45,13 +45,13 @@ class ###Component###Model###View### extends BaseDatabaseModel * @var string */ protected $_context = 'com_###component###.###view###'; - + /** * Import Settings */ protected $getType = NULL; protected $dataType = NULL; - + /** * Method to auto-populate the model state. * @@ -62,7 +62,7 @@ class ###Component###Model###View### extends BaseDatabaseModel */ protected function populateState() { - $app = JFactory::getApplication('administrator'); + $app = Factory::getApplication('administrator'); $this->setState('message', $app->getUserState('com_###component###.message')); $app->setUserState('com_###component###.message', ''); @@ -72,7 +72,7 @@ class ###Component###Model###View### extends BaseDatabaseModel $this->setState('import.directory', $path); parent::populateState(); } - ###IMPORT_METHOD_CUSTOM### + ###IMPORT_METHOD_CUSTOM### /** * Works out an importation spreadsheet from a HTTP upload @@ -80,37 +80,37 @@ class ###Component###Model###View### extends BaseDatabaseModel * @return spreadsheet definition or false on failure */ protected function _getPackageFromUpload() - { + { // Get the uploaded file information - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $input = $app->input; // Do not change the filter type 'raw'. We need this to let files containing PHP code to upload. See JInputFiles::get. $userfile = $input->files->get('import_package', null, 'raw'); - + // Make sure that file uploads are enabled in php if (!(bool) ini_get('file_uploads')) { - $app->enqueueMessage(JText::_('COM_###COMPONENT###_IMPORT_MSG_WARNIMPORTFILE'), 'warning'); + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_WARNIMPORTFILE'), 'warning'); return false; } // If there is no uploaded file, we have a problem... if (!is_array($userfile)) { - $app->enqueueMessage(JText::_('COM_###COMPONENT###_IMPORT_MSG_NO_FILE_SELECTED'), 'warning'); + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_NO_FILE_SELECTED'), 'warning'); return false; } // Check if there was a problem uploading the file. if ($userfile['error'] || $userfile['size'] < 1) { - $app->enqueueMessage(JText::_('COM_###COMPONENT###_IMPORT_MSG_WARNIMPORTUPLOADERROR'), 'warning'); + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_WARNIMPORTUPLOADERROR'), 'warning'); return false; } // Build the appropriate paths - $config = JFactory::getConfig(); + $config = Factory::getConfig(); $tmp_dest = $config->get('tmp_path') . '/' . $userfile['name']; $tmp_src = $userfile['tmp_name']; @@ -120,7 +120,7 @@ class ###Component###Model###View### extends BaseDatabaseModel // Was the package downloaded? if (!$p_file) { - $session = JFactory::getSession(); + $session = Factory::getSession(); $session->clear('package'); $session->clear('dataType'); $session->clear('hasPackage'); @@ -142,16 +142,16 @@ class ###Component###Model###View### extends BaseDatabaseModel */ protected function _getPackageFromFolder() { - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $input = $app->input; // Get the path to the package to import $p_dir = $input->getString('import_directory'); - $p_dir = JPath::clean($p_dir); + $p_dir = Path::clean($p_dir); // Did you give us a valid path? if (!file_exists($p_dir)) { - $app->enqueueMessage(JText::_('COM_###COMPONENT###_IMPORT_MSG_PLEASE_ENTER_A_PACKAGE_DIRECTORY'), 'warning'); + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_PLEASE_ENTER_A_PACKAGE_DIRECTORY'), 'warning'); return false; } @@ -161,17 +161,17 @@ class ###Component###Model###View### extends BaseDatabaseModel // Did you give us a valid package? if (!$type) { - $app->enqueueMessage(JText::_('COM_###COMPONENT###_IMPORT_MSG_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE'), 'warning'); + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE'), 'warning'); } - + // check the extention if(!$this->checkExtension($p_dir)) { // set error message - $app->enqueueMessage(JText::_('COM_###COMPONENT###_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); return false; } - + $package['packagename'] = null; $package['dir'] = $p_dir; $package['type'] = $type; @@ -187,7 +187,7 @@ class ###Component###Model###View### extends BaseDatabaseModel */ protected function _getPackageFromUrl() { - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $input = $app->input; // Get the URL of the package to import @@ -196,17 +196,17 @@ class ###Component###Model###View### extends BaseDatabaseModel // Did you give us a URL? if (!$url) { - $app->enqueueMessage(JText::_('COM_###COMPONENT###_IMPORT_MSG_ENTER_A_URL'), 'warning'); + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_ENTER_A_URL'), 'warning'); return false; } // Download the package at the URL given - $p_file = JInstallerHelper::downloadPackage($url); + $p_file = InstallerHelper::downloadPackage($url); // Was the package downloaded? if (!$p_file) { - $app->enqueueMessage(JText::_('COM_###COMPONENT###_IMPORT_MSG_INVALID_URL'), 'warning'); + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_INVALID_URL'), 'warning'); return false; } @@ -215,7 +215,7 @@ class ###Component###Model###View### extends BaseDatabaseModel return $package; } - + /** * Check a file and verifies it as a spreadsheet file * Supports .csv .xlsx .xls and .ods @@ -227,29 +227,29 @@ class ###Component###Model###View### extends BaseDatabaseModel */ protected function check($archivename) { - $app = JFactory::getApplication(); + $app = Factory::getApplication(); // Clean the name - $archivename = JPath::clean($archivename); - + $archivename = Path::clean($archivename); + // check the extention if(!$this->checkExtension($archivename)) { // Cleanup the import files $this->remove($archivename); - $app->enqueueMessage(JText::_('COM_###COMPONENT###_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); return false; } - - $config = JFactory::getConfig(); + + $config = Factory::getConfig(); // set Package Name $check['packagename'] = $archivename; - + // set directory $check['dir'] = $config->get('tmp_path'). '/' .$archivename; - + // set type $check['type'] = $this->getType; - + return $check; } ###IMPORT_EXT_METHOD### @@ -264,9 +264,7 @@ class ###Component###Model###View### extends BaseDatabaseModel */ protected function remove($package) { - jimport('joomla.filesystem.file'); - - $config = JFactory::getConfig(); + $config = Factory::getConfig(); $package = $config->get('tmp_path'). '/' .$package; // Is the package file a valid file? @@ -274,10 +272,10 @@ class ###Component###Model###View### extends BaseDatabaseModel { File::delete($package); } - elseif (is_file(JPath::clean($package))) + elseif (is_file(Path::clean($package))) { // It might also be just a base filename - File::delete(JPath::clean($package)); + File::delete(Path::clean($package)); } } ###IMPORT_SETDATA_METHOD### @@ -286,13 +284,13 @@ class ###Component###Model###View### extends BaseDatabaseModel protected function getAlias($name,$type = false) { // sanitize the name to an alias - if (JFactory::getConfig()->get('unicodeslugs') == 1) + if (Factory::getConfig()->get('unicodeslugs') == 1) { - $alias = JFilterOutput::stringURLUnicodeSlug($name); + $alias = OutputFilter::stringURLUnicodeSlug($name); } else { - $alias = JFilterOutput::stringURLSafe($name); + $alias = OutputFilter::stringURLSafe($name); } // must be a uniqe alias if ($type) @@ -301,7 +299,7 @@ class ###Component###Model###View### extends BaseDatabaseModel } return $alias; } - + /** * Method to generate a uniqe value. * @@ -316,16 +314,16 @@ class ###Component###Model###View### extends BaseDatabaseModel // insure the filed is always uniqe while (isset($this->uniqeValueArray[$type][$field][$value])) { - $value = JString::increment($value, 'dash'); + $value = StringHelper::increment($value, 'dash'); } $this->uniqeValueArray[$type][$field][$value] = $value; return $value; } - + protected function getAliasesUsed($table) { // Get a db connection. - $db = JFactory::getDbo(); + $db = Factory::getDbo(); // first we check if there is a alias column $columns = $db->getTableColumns('#__###component###_'.$table); if(isset($columns['alias'])){ diff --git a/admin/compiler/joomla_3/DASHJViewLagacy.php b/admin/compiler/joomla_3/DASHJViewLagacy.php index c9a759f75..d8dc3d60f 100644 --- a/admin/compiler/joomla_3/DASHJViewLagacy.php +++ b/admin/compiler/joomla_3/DASHJViewLagacy.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -22,7 +22,7 @@ defined('_JEXEC') or die('Restricted access'); /** * ###Component### View class */ -class ###Component###View###Component### extends JViewLegacy +class ###Component###View###Component### extends HtmlView { /** * View display method @@ -31,15 +31,15 @@ class ###Component###View###Component### extends JViewLegacy function display($tpl = null) { // Assign data to the view - $this->icons = $this->get('Icons'); - $this->contributors = ###Component###Helper::getContributors();###DASH_GET_CUSTOM_DATA### - + $this->icons = $this->get('Icons'); + $this->contributors = ###Component###Helper::getContributors();###DASH_GET_CUSTOM_DATA### + // get the manifest details of the component $this->manifest = ###Component###Helper::manifest(); - + // Set the toolbar $this->addToolBar(); - + // Check for errors. if (count($errors = $this->get('Errors'))) { @@ -59,18 +59,18 @@ class ###Component###View###Component### extends JViewLegacy protected function addToolBar() { $canDo = ###Component###Helper::getActions('###component###'); - JToolBarHelper::title(JText::_('COM_###COMPONENT###_DASHBOARD'), 'grid-2'); + ToolbarHelper::title(Text::_('COM_###COMPONENT###_DASHBOARD'), 'grid-2'); // set help url for this view if found $this->help_url = ###Component###Helper::getHelpUrl('###component###'); - if (###Component###Helper::checkString($this->help_url)) + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($this->help_url)) { - JToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); + ToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); } if ($canDo->get('core.admin') || $canDo->get('core.options')) { - JToolBarHelper::preferences('com_###component###'); + ToolbarHelper::preferences('com_###component###'); } } @@ -81,15 +81,17 @@ class ###Component###View###Component### extends JViewLegacy */ protected function setDocument() { - $document = JFactory::getDocument(); - - // add dashboard style sheets - $document->addStyleSheet(JURI::root() . "administrator/components/com_###component###/assets/css/dashboard.css"); - + if (!isset($this->document)) + { + $this->document = Factory::getDocument(); + } // set page title - $document->setTitle(JText::_('COM_###COMPONENT###_DASHBOARD')); - + $this->document->setTitle(Text::_('COM_###COMPONENT###_DASHBOARD')); + // add manifest to page JavaScript - $document->addScriptDeclaration("var manifest = jQuery.parseJSON('" . json_encode($this->manifest) . "');", "text/javascript"); + $this->document->addScriptDeclaration("var manifest = jQuery.parseJSON('" . json_encode($this->manifest) . "');", "text/javascript"); + + // add dashboard style sheets + Html::_('stylesheet', "administrator/components/com_###component###/assets/css/dashboard.css", ['version' => 'auto']); } } diff --git a/admin/compiler/joomla_3/DASHdefault.php b/admin/compiler/joomla_3/DASHdefault.php index 14691c6cd..bda607bcf 100644 --- a/admin/compiler/joomla_3/DASHdefault.php +++ b/admin/compiler/joomla_3/DASHdefault.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ diff --git a/admin/compiler/joomla_3/FormController.php b/admin/compiler/joomla_3/FormController.php index feb4ec217..59827b281 100644 --- a/admin/compiler/joomla_3/FormController.php +++ b/admin/compiler/joomla_3/FormController.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -40,13 +40,13 @@ class ###Component###Controller###View### extends FormController * * @since 1.6 */ - public function __construct($config = array()) + public function __construct($config = []) { $this->view_list = '###Views###'; // safeguard for setting the return view listing to the main view. parent::__construct($config); }###ADMIN_CUSTOM_BUTTONS_CONTROLLER### - /** + /** * Method override to check if you can add a new record. * * @param array $data An array of input data. @@ -55,7 +55,7 @@ class ###Component###Controller###View### extends FormController * * @since 1.6 */ - protected function allowAdd($data = array()) + protected function allowAdd($data = []) {###JCONTROLLERFORM_ALLOWADD### } @@ -69,7 +69,7 @@ class ###Component###Controller###View### extends FormController * * @since 1.6 */ - protected function allowEdit($data = array(), $key = 'id') + protected function allowEdit($data = [], $key = 'id') {###JCONTROLLERFORM_ALLOWEDIT### } @@ -94,12 +94,12 @@ class ###Component###Controller###View### extends FormController // set the referral options if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; } elseif ($ref) { - $append = '&ref='. (string)$ref . $append; + $append = '&ref='. (string) $ref . $append; } return $append; @@ -116,13 +116,13 @@ class ###Component###Controller###View### extends FormController */ public function batch($model = null) { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); // Set the model - $model = $this->getModel('###View###', '', array()); + $model = $this->getModel('###View###', '', []); // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_###component###&view=###views###' . $this->getRedirectToListAppend(), false)); + $this->setRedirect(Route::_('index.php?option=com_###component###&view=###views###' . $this->getRedirectToListAppend(), false)); return parent::batch($model); } @@ -147,13 +147,13 @@ class ###Component###Controller###View### extends FormController $cancel = parent::cancel($key); - if (!is_null($return) && JUri::isInternal(base64_decode($return))) + if (!is_null($return) && Uri::isInternal(base64_decode($return))) { $redirect = base64_decode($return); // Redirect to the return value. $this->setRedirect( - JRoute::_( + Route::_( $redirect, false ) ); @@ -164,7 +164,7 @@ class ###Component###Controller###View### extends FormController // Redirect to the item screen. $this->setRedirect( - JRoute::_( + Route::_( 'index.php?option=' . $this->option . $redirect, false ) ); @@ -175,7 +175,7 @@ class ###Component###Controller###View### extends FormController // Redirect to the list screen. $this->setRedirect( - JRoute::_( + Route::_( 'index.php?option=' . $this->option . $redirect, false ) ); @@ -201,7 +201,7 @@ class ###Component###Controller###View### extends FormController // Check if there is a return value $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); if ($this->ref || $this->refid || $canReturn) { @@ -219,29 +219,29 @@ class ###Component###Controller###View### extends FormController // Redirect to the return value. $this->setRedirect( - JRoute::_( + Route::_( $redirect, false ) ); } elseif ($this->refid && $this->ref) { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; // Redirect to the item screen. $this->setRedirect( - JRoute::_( + Route::_( 'index.php?option=' . $this->option . $redirect, false ) ); } elseif ($this->ref) { - $redirect = '&view=' . (string)$this->ref; + $redirect = '&view=' . (string) $this->ref; // Redirect to the list screen. $this->setRedirect( - JRoute::_( + Route::_( 'index.php?option=' . $this->option . $redirect, false ) ); @@ -253,15 +253,14 @@ class ###Component###Controller###View### extends FormController * Function that allows child controller access to model data * after the data has been saved. * - * @param JModel &$model The data model object. - * @param array $validData The validated data. + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. * * @return void * * @since 11.1 */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) {###POSTSAVEHOOK### } - } diff --git a/admin/compiler/joomla_3/FormController_custom_site.php b/admin/compiler/joomla_3/FormController_custom_site.php index 8d6d30cd5..6f38faedb 100644 --- a/admin/compiler/joomla_3/FormController_custom_site.php +++ b/admin/compiler/joomla_3/FormController_custom_site.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -33,7 +33,7 @@ class ###Component###Controller###SView### extends FormController */ protected $task; - public function __construct($config = array()) + public function __construct($config = []) { $this->view_list = '###SITE_DEFAULT_VIEW###'; // safeguard for setting the return view listing to the default site view. parent::__construct($config); @@ -51,13 +51,13 @@ class ###Component###Controller###SView### extends FormController * * @since 12.2 */ - protected function allowEdit($data = array(), $key = 'id') + protected function allowEdit($data = [], $key = 'id') { // to insure no other tampering return false; } - /** + /** * Method override to check if you can add a new record. * * @param array $data An array of input data. @@ -66,7 +66,7 @@ class ###Component###Controller###SView### extends FormController * * @since 1.6 */ - protected function allowAdd($data = array()) + protected function allowAdd($data = []) { // to insure no other tampering return false; @@ -101,7 +101,7 @@ class ###Component###Controller###SView### extends FormController * * @since 12.2 */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) + protected function postSaveHook(JModelLegacy $model, $validData = []) { } } diff --git a/admin/compiler/joomla_3/FormController_site.php b/admin/compiler/joomla_3/FormController_site.php index 530f3ac90..b55b176fc 100644 --- a/admin/compiler/joomla_3/FormController_site.php +++ b/admin/compiler/joomla_3/FormController_site.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -40,13 +40,13 @@ class ###Component###Controller###View### extends FormController * * @since 1.6 */ - public function __construct($config = array()) + public function __construct($config = []) { $this->view_list = '###SITE_DEFAULT_VIEW###'; // safeguard for setting the return view listing to the default site view. parent::__construct($config); }###ADMIN_CUSTOM_BUTTONS_CONTROLLER### - /** + /** * Method override to check if you can add a new record. * * @param array $data An array of input data. @@ -55,7 +55,7 @@ class ###Component###Controller###View### extends FormController * * @since 1.6 */ - protected function allowAdd($data = array()) + protected function allowAdd($data = []) {###JCONTROLLERFORM_ALLOWADD### } @@ -69,7 +69,7 @@ class ###Component###Controller###View### extends FormController * * @since 1.6 */ - protected function allowEdit($data = array(), $key = 'id') + protected function allowEdit($data = [], $key = 'id') {###JCONTROLLERFORM_ALLOWEDIT### } @@ -94,12 +94,12 @@ class ###Component###Controller###View### extends FormController // set the referral options if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; } elseif ($ref) { - $append = '&ref='. (string)$ref . $append; + $append = '&ref='. (string) $ref . $append; } return $append; @@ -116,13 +116,13 @@ class ###Component###Controller###View### extends FormController */ public function batch($model = null) { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); // Set the model - $model = $this->getModel('###View###', '', array()); + $model = $this->getModel('###View###', '', []); // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_###component###&view=###views###' . $this->getRedirectToListAppend(), false)); + $this->setRedirect(Route::_('index.php?option=com_###component###&view=###views###' . $this->getRedirectToListAppend(), false)); return parent::batch($model); } @@ -147,35 +147,35 @@ class ###Component###Controller###View### extends FormController $cancel = parent::cancel($key); - if (!is_null($return) && JUri::isInternal(base64_decode($return))) + if (!is_null($return) && Uri::isInternal(base64_decode($return))) { $redirect = base64_decode($return); // Redirect to the return value. $this->setRedirect( - JRoute::_( + Route::_( $redirect, false ) ); } elseif ($this->refid && $this->ref) { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; // Redirect to the item screen. $this->setRedirect( - JRoute::_( + Route::_( 'index.php?option=' . $this->option . $redirect, false ) ); } elseif ($this->ref) { - $redirect = '&view=' . (string)$this->ref; + $redirect = '&view=' . (string) $this->ref; // Redirect to the list screen. $this->setRedirect( - JRoute::_( + Route::_( 'index.php?option=' . $this->option . $redirect, false ) ); @@ -201,7 +201,7 @@ class ###Component###Controller###View### extends FormController // Check if there is a return value $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); if ($this->ref || $this->refid || $canReturn) { @@ -219,29 +219,29 @@ class ###Component###Controller###View### extends FormController // Redirect to the return value. $this->setRedirect( - JRoute::_( + Route::_( $redirect, false ) ); } elseif ($this->refid && $this->ref) { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; // Redirect to the item screen. $this->setRedirect( - JRoute::_( + Route::_( 'index.php?option=' . $this->option . $redirect, false ) ); } elseif ($this->ref) { - $redirect = '&view=' . (string)$this->ref; + $redirect = '&view=' . (string) $this->ref; // Redirect to the list screen. $this->setRedirect( - JRoute::_( + Route::_( 'index.php?option=' . $this->option . $redirect, false ) ); @@ -253,14 +253,14 @@ class ###Component###Controller###View### extends FormController * Function that allows child controller access to model data * after the data has been saved. * - * @param JModel &$model The data model object. - * @param array $validData The validated data. + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. * * @return void * * @since 11.1 */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) {###POSTSAVEHOOK### } diff --git a/admin/compiler/joomla_3/Helper.php b/admin/compiler/joomla_3/Helper.php index ded32f2d4..6caa65c0a 100644 --- a/admin/compiler/joomla_3/Helper.php +++ b/admin/compiler/joomla_3/Helper.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -29,7 +29,7 @@ abstract class ###Component###Helper * * @var array */ - protected static $composer = array(); + protected static $composer = []; /** * The Main Active Language @@ -80,7 +80,7 @@ abstract class ###Component###Helper // check if set if (!Super___91004529_94a9_4590_b842_e7c6b624ecf5___Power::check(self::$JVersion)) { - self::$JVersion = new JVersion(); + self::$JVersion = new Version(); } return self::$JVersion; } @@ -91,18 +91,18 @@ abstract class ###Component###Helper public static function getContributors() { // get params - $params = JComponentHelper::getParams('com_###component###'); + $params = ComponentHelper::getParams('com_###component###'); // start contributors array - $contributors = array(); + $contributors = []; // get all Contributors (max 20) $searchArray = range('0','20'); foreach($searchArray as $nr) - { + { if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 1 || $params->get("showContributor".$nr) == 3)) { // set link based of selected option if($params->get("useContributor".$nr) == 1) - { + { $link_front = ''; $link_back = ''; } @@ -116,8 +116,8 @@ abstract class ###Component###Helper $link_front = ''; $link_back = ''; } - $contributors[$nr]['title'] = Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($params->get("titleContributor".$nr)); - $contributors[$nr]['name'] = $link_front.Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($params->get("nameContributor".$nr)).$link_back; + $contributors[$nr]['title'] = Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($params->get("titleContributor".$nr)); + $contributors[$nr]['name'] = $link_front.Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($params->get("nameContributor".$nr)).$link_back; } } return $contributors; @@ -129,7 +129,7 @@ abstract class ###Component###Helper public static function addSubmenu($submenu) { // load user for access menus - $user = JFactory::getUser(); + $user = Factory::getUser(); // load the submenus to sidebar ###SUBMENU### }###HELPER_CREATEUSER######HELPER_UIKIT######HELPER_EXEL### @@ -211,7 +211,7 @@ abstract class ###Component###Helper { $type = 'item'; } - $db = JFactory::getDbo(); + $db = Factory::getDbo(); $query = $db->getQuery(true); $query->select(array('a.published')); $query->from('#__###component###_'.$type.' AS a'); @@ -229,7 +229,7 @@ abstract class ###Component###Helper public static function getGroupName($id) { - $db = JFactory::getDBO(); + $db = Factory::getDBO(); $query = $db->getQuery(true); $query->select(array('a.title')); $query->from('#__usergroups AS a'); @@ -238,7 +238,7 @@ abstract class ###Component###Helper $db->execute(); $found = $db->getNumRows(); if($found) - { + { return $db->loadResult(); } return $id; @@ -254,7 +254,7 @@ abstract class ###Component###Helper * @param string $component The target component * @param object $user The user whose permissions we are loading * - * @return object The JObject of permission/authorised actions + * @return object The CMSObject of permission/authorised actions * */ public static function getActions($view, &$record = null, $views = null, $target = null, $component = '###component###', $user = 'null') @@ -263,22 +263,22 @@ abstract class ###Component###Helper if (!Super___91004529_94a9_4590_b842_e7c6b624ecf5___Power::check($user)) { // get the user object - $user = JFactory::getUser(); + $user = Factory::getUser(); } - // load the JObject - $result = new JObject; + // load the CMSObject + $result = new CMSObject; // make view name safe (just incase) $view = Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($view); if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($views)) { $views = Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($views); - } + } // get all actions from component - $actions = JAccess::getActionsFromFile( + $actions = Access::getActionsFromFile( JPATH_ADMINISTRATOR . '/components/com_' . $component . '/access.xml', "/access/section[@name='component']/" ); - // if non found then return empty JObject + // if non found then return empty CMSObject if (empty($actions)) { return $result; @@ -445,14 +445,14 @@ abstract class ###Component###Helper /** * Get any component's model */ - public static function getModel($name, $path = JPATH_COMPONENT_ADMINISTRATOR, $Component = '###Component###', $config = array()) + public static function getModel($name, $path = JPATH_COMPONENT_ADMINISTRATOR, $Component = '###Component###', $config = []) { // fix the name $name = Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($name); // full path to models $fullPathModels = $path . '/models'; // load the model file - JModelLegacy::addIncludePath($fullPathModels, $Component . 'Model'); + BaseDatabaseModel::addIncludePath($fullPathModels, $Component . 'Model'); // make sure the table path is loaded if (!isset($config['table_path']) || !Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($config['table_path'])) { @@ -460,7 +460,7 @@ abstract class ###Component###Helper $config['table_path'] = JPATH_ADMINISTRATOR . '/components/com_' . strtolower($Component) . '/tables'; } // get instance - $model = JModelLegacy::getInstance($name, $Component . 'Model', $config); + $model = BaseDatabaseModel::getInstance($name, $Component . 'Model', $config); // if model not found (strange) if ($model == false) { @@ -495,14 +495,14 @@ abstract class ###Component###Helper */ public static function setAsset($id, $table, $inherit = true) { - $parent = JTable::getInstance('Asset'); + $parent = Table::getInstance('Asset'); $parent->loadByName('com_###component###'); $parentId = $parent->id; $name = 'com_###component###.'.$table.'.'.$id; $title = ''; - $asset = JTable::getInstance('Asset'); + $asset = Table::getInstance('Asset'); $asset->loadByName($name); // Check for an error. @@ -526,14 +526,14 @@ abstract class ###Component###Helper $asset->title = $title; // get the default asset rules $rules = self::getDefaultAssetRules('com_###component###', $table, $inherit); - if ($rules instanceof JAccessRules) + if ($rules instanceof AccessRules) { $asset->rules = (string) $rules; } if (!$asset->check() || !$asset->store()) { - JFactory::getApplication()->enqueueMessage($asset->getError(), 'warning'); + Factory::getApplication()->enqueueMessage($asset->getError(), 'warning'); return false; } else @@ -546,7 +546,7 @@ abstract class ###Component###Helper $object->asset_id = (int) $asset->id; // Update their asset_id to link to the asset table. - return JFactory::getDbo()->updateObject('#__###component###_'.$table, $object, 'id'); + return Factory::getDbo()->updateObject('#__###component###_'.$table, $object, 'id'); } } return false; @@ -563,7 +563,7 @@ abstract class ###Component###Helper if (!$inherit) { // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); + $db = Factory::getDbo(); $query = $db->getQuery(true) ->select($db->quoteName('id')) ->from($db->quoteName('#__assets')) @@ -578,8 +578,8 @@ abstract class ###Component###Helper } } // get asset rules - $result = JAccess::getAssetRules($assetId); - if ($result instanceof JAccessRules) + $result = Access::getAssetRules($assetId); + if ($result instanceof AccessRules) { $_result = (string) $result; $_result = json_decode($_result); @@ -594,7 +594,7 @@ abstract class ###Component###Helper elseif ($inherit) { // clear the value since we inherit - $rule = array(); + $rule = []; } } // check if there are any view values remaining @@ -602,8 +602,8 @@ abstract class ###Component###Helper { $_result = json_encode($_result); $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules($_result); // return filtered rules return $rules; } @@ -648,7 +648,7 @@ abstract class ###Component###Helper * @return null * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::attributes($xml, $attributes); */ - public static function xmlAddAttributes(&$xml, $attributes = array()) + public static function xmlAddAttributes(&$xml, $attributes = []) { Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::attributes($xml, $attributes); } @@ -662,7 +662,7 @@ abstract class ###Component###Helper * @return void * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::options($xml, $options); */ - public static function xmlAddOptions(&$xml, $options = array()) + public static function xmlAddOptions(&$xml, $options = []) { Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::options($xml, $options); } @@ -733,7 +733,7 @@ abstract class ###Component###Helper /** * Check if have an json string * - * @input string The json string to check + * @input string The json string to check * * @returns bool true on success * @deprecated 3.3 Use Super___4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::check($string); @@ -746,7 +746,7 @@ abstract class ###Component###Helper /** * Check if have an object with a length * - * @input object The object to check + * @input object The object to check * * @returns bool true on success * @deprecated 3.3 Use Super___91004529_94a9_4590_b842_e7c6b624ecf5___Power::check($object); @@ -759,7 +759,7 @@ abstract class ###Component###Helper /** * Check if have an array with a length * - * @input array The array to check + * @input array The array to check * * @returns bool/int number of items in array on success * @deprecated 3.3 Use Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($array, $removeEmptyString); @@ -772,7 +772,7 @@ abstract class ###Component###Helper /** * Check if have a string with a length * - * @input string The string to check + * @input string The string to check * * @returns bool true on success * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($string); @@ -792,7 +792,7 @@ abstract class ###Component###Helper { // If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right? $connected = @fsockopen("www.example.com", 80); - // website, port (try 80 or 443) + // website, port (try 80 or 443) if ($connected) { //action when connected @@ -810,7 +810,7 @@ abstract class ###Component###Helper /** * Merge an array of array's * - * @input array The arrays you would like to merge + * @input array The arrays you would like to merge * * @returns array on success * @deprecated 3.3 Use Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::merge($arrays); @@ -829,7 +829,7 @@ abstract class ###Component###Helper /** * Shorten a string * - * @input string The you would like to shorten + * @input string The you would like to shorten * * @returns string on success * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::shorten(...); @@ -842,7 +842,7 @@ abstract class ###Component###Helper /** * Making strings safe (various ways) * - * @input string The you would like to make safe + * @input string The you would like to make safe * * @returns string on success * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe(...); @@ -861,7 +861,7 @@ abstract class ###Component###Helper /** * Convert none English strings to code usable string * - * @input an string + * @input an string * * @returns a string * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::transliterate($string); @@ -874,7 +874,7 @@ abstract class ###Component###Helper /** * make sure a string is HTML save * - * @input an html string + * @input an html string * * @returns a string * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html(...); @@ -892,7 +892,7 @@ abstract class ###Component###Helper /** * Convert all int in a string to an English word string * - * @input an string with numbers + * @input an string with numbers * * @returns a string * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::numbers($string); @@ -906,7 +906,7 @@ abstract class ###Component###Helper * Convert an integer into an English word string * Thanks to Tom Nicholson * - * @input an int + * @input an int * @returns a string * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::number($x); */ diff --git a/admin/compiler/joomla_3/Helper_category.php b/admin/compiler/joomla_3/Helper_category.php index ad4ed490c..193ebff3a 100644 --- a/admin/compiler/joomla_3/Helper_category.php +++ b/admin/compiler/joomla_3/Helper_category.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ diff --git a/admin/compiler/joomla_3/Helper_category_view.php b/admin/compiler/joomla_3/Helper_category_view.php index 53e2d88d3..ac2046a0e 100644 --- a/admin/compiler/joomla_3/Helper_category_view.php +++ b/admin/compiler/joomla_3/Helper_category_view.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -28,7 +28,7 @@ class ###Component######View###Categories extends JCategories * @param array $options Array of options * */ - public function __construct($options = array()) + public function __construct($options = []) { $options['table'] = '#__###component###_###view###'; $options['extension'] = 'com_###component###.###view###'; diff --git a/admin/compiler/joomla_3/Helper_email.php b/admin/compiler/joomla_3/Helper_email.php index 309817cac..f51347eb9 100644 --- a/admin/compiler/joomla_3/Helper_email.php +++ b/admin/compiler/joomla_3/Helper_email.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,6 +17,11 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Mail\Mail; +use Joomla\Registry\Registry; + /** * ###Component### component email helper */ @@ -27,28 +32,28 @@ abstract class ###Component###Email * * @var activeRecipient (array) */ - public static $active = array(); + public static $active = []; /** * Configuraiton object * - * @var JConfig + * @var Registry */ - public static $config = null; + public static ?Registry $config = null; /** * Mailer object * - * @var JMail + * @var Mail */ - public static $mailer = null; + public static ?Mail $mailer = null; /** * Custom Headers * * @var array */ - protected static $header = array(); + protected static array $header = []; /** * Get a configuration object @@ -58,7 +63,7 @@ abstract class ###Component###Email { if (!self::$config) { - self::$config = JComponentHelper::getParams('com_###component###'); + self::$config = ComponentHelper::getParams('com_###component###'); } return self::$config; @@ -97,7 +102,7 @@ abstract class ###Component###Email * @static * @access public */ - public static function validateAddress($address, $patternselect = null) + public static function validateAddress($address, $patternselect = null): bool { return self::getMailerInstance()->validateAddress($address, $patternselect); } @@ -105,13 +110,13 @@ abstract class ###Component###Email /** * Get a mailer object. * - * Returns the global {@link JMail} object, only creating it if it doesn't already exist. + * Returns the global {@link Mail} object, only creating it if it doesn't already exist. * - * @return JMail object + * @return Mail object * - * @see JMail + * @see Mail */ - public static function getMailer() + public static function getMailer(): Mail { if (!self::$mailer) { @@ -126,58 +131,58 @@ abstract class ###Component###Email /** * Create a mailer object * - * @return JMail object + * @return Mail object * - * @see JMail + * @see Mail */ - protected static function createMailer() + protected static function createMailer(): Mail { // set component params $conf = self::getConfig(); - + // now load the mailer $mailer = $conf->get('mailer', 'global'); - - // Create a JMail object - $mail = JMail::getInstance(); + + // Create a Mail object + $mail = Mail::getInstance(); // check if set to global if ('global' == $mailer) { // get the global details - $globalConf = JFactory::getConfig(); - - $mailer = $globalConf->get('mailer'); - $smtpauth = ($globalConf->get('smtpauth') == 0) ? null : 1; - $smtpuser = $globalConf->get('smtpuser'); - $smtppass = $globalConf->get('smtppass'); - $smtphost = $globalConf->get('smtphost'); - $smtpsecure = $globalConf->get('smtpsecure'); - $smtpport = $globalConf->get('smtpport'); - $sendmail = $globalConf->get('sendmail'); - $mailfrom = $globalConf->get('mailfrom'); - $fromname = $globalConf->get('fromname'); - $replyto = $globalConf->get('replyto'); - $replytoname = $globalConf->get('replytoname'); + $globalConf = Factory::getConfig(); + + $mailer = $globalConf->get('mailer'); + $smtpauth = ($globalConf->get('smtpauth') == 0) ? null : 1; + $smtpuser = $globalConf->get('smtpuser'); + $smtppass = $globalConf->get('smtppass'); + $smtphost = $globalConf->get('smtphost'); + $smtpsecure = $globalConf->get('smtpsecure'); + $smtpport = $globalConf->get('smtpport'); + $sendmail = $globalConf->get('sendmail'); + $mailfrom = $globalConf->get('mailfrom'); + $fromname = $globalConf->get('fromname'); + $replyto = $globalConf->get('replyto'); + $replytoname = $globalConf->get('replytoname'); } else { - $smtpauth = ($conf->get('smtpauth') == 0) ? null : 1; - $smtpuser = $conf->get('smtpuser'); - $smtppass = $conf->get('smtppass'); - $smtphost = $conf->get('smtphost'); - $smtpsecure = $conf->get('smtpsecure'); - $smtpport = $conf->get('smtpport'); - $sendmail = $conf->get('sendmail'); - $mailfrom = $conf->get('emailfrom'); - $fromname = $conf->get('fromname'); - $replyto = $conf->get('replyto'); - $replytoname = $conf->get('replytoname'); + $smtpauth = ($conf->get('smtpauth') == 0) ? null : 1; + $smtpuser = $conf->get('smtpuser'); + $smtppass = $conf->get('smtppass'); + $smtphost = $conf->get('smtphost'); + $smtpsecure = $conf->get('smtpsecure'); + $smtpport = $conf->get('smtpport'); + $sendmail = $conf->get('sendmail'); + $mailfrom = $conf->get('emailfrom'); + $fromname = $conf->get('fromname'); + $replyto = $conf->get('replyto'); + $replytoname = $conf->get('replytoname'); } // Set global sender $mail->setSender(array($mailfrom, $fromname)); - + // set the global reply-to if found if ($replyto && $replytoname) { @@ -226,25 +231,25 @@ abstract class ###Component###Email */ public static function send($recipient, $subject, $body, $textonly, $mode = 0, $bounce_email = null, $idsession = null, $mailreply = null, $replyname = null , $mailfrom = null, $fromname = null, $cc = null, $bcc = null, $attachment = null, $embeded = null , $embeds = null) { - // Get a JMail instance + // Get a Mail instance $mail = self::getMailer(); - + // set component params $conf = self::getConfig(); - + // set if we have override if ($mailfrom && $fromname) { $mail->setSender(array($mailfrom, $fromname)); } - + // load the bounce email as sender if set if (!is_null($bounce_email)) - { + { $mail->Sender = $bounce_email; } - - // Add tag to email to identify it + + // Add tag to email to identify it if (!is_null($idsession)) { $mail->addCustomHeader('X-VDMmethodID:'.$idsession); @@ -262,7 +267,7 @@ abstract class ###Component###Email // set the subject & Body $mail->setSubject($subject); $mail->setBody($body); - + // Are we sending the email as HTML? if ($mode) { @@ -273,7 +278,7 @@ abstract class ###Component###Email //embed images if ($embeded) { - if(###Component###Helper::checkArray($embeds)) + if(Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($embeds)) { foreach($embeds as $embed) { @@ -308,21 +313,21 @@ abstract class ###Component###Email { if (!empty($conf->get('dkim_domain')) && !empty($conf->get('dkim_selector')) && !empty($conf->get('dkim_private')) && !empty($conf->get('dkim_public'))) { - $mail->DKIM_domain = $conf->get('dkim_domain'); - $mail->DKIM_selector = $conf->get('dkim_selector'); - $mail->DKIM_identity = $conf->get('dkim_identity'); - $mail->DKIM_passphrase = $conf->get('dkim_passphrase'); - - $tmp = tempnam(sys_get_temp_dir(), 'VDM'); - $h = fopen($tmp, 'w'); + $mail->DKIM_domain = $conf->get('dkim_domain'); + $mail->DKIM_selector = $conf->get('dkim_selector'); + $mail->DKIM_identity = $conf->get('dkim_identity'); + $mail->DKIM_passphrase = $conf->get('dkim_passphrase'); + + $tmp = tempnam(sys_get_temp_dir(), 'VDM'); + $h = fopen($tmp, 'w'); fwrite($h, $conf->get('dkim_private')); fclose($h); - $mail->DKIM_private = $tmp; + $mail->DKIM_private = $tmp; } } $sendmail = $mail->Send(); - + if ($conf->get('enable_dkim') && !empty($conf->get('dkim_domain')) && !empty($conf->get('dkim_selector')) && !empty($conf->get('dkim_private')) && !empty($conf->get('dkim_public'))) { @unlink($tmp); @@ -351,7 +356,7 @@ abstract class ###Component###Email /** * Set html text (in a row) and subject (as title) to a email table. * do not use

instead use
- * in your html that you pass to this method + * in your html that you pass to this method * since it is a table row it does not * work well with paragraphs * @@ -360,7 +365,7 @@ abstract class ###Component###Email */ public static function setBasicBody($html, $subject) { - $body = array(); + $body = []; $body[] = ""; $body[] = ""; $body[] = ""; @@ -397,7 +402,7 @@ abstract class ###Component###Email /** * Set html text (in a row) and subject (as title) to a email table. * do not use

instead use
- * in your html that you pass to this method + * in your html that you pass to this method * since it is a table row it does not * work well with paragraphs * @@ -406,7 +411,7 @@ abstract class ###Component###Email */ public static function setTableBody($html, $subject) { - $body = array(); + $body = []; $body[] = ""; $body[] = ""; $body[] = ""; diff --git a/admin/compiler/joomla_3/Helper_site.php b/admin/compiler/joomla_3/Helper_site.php index 2f61d0c50..c831a708b 100644 --- a/admin/compiler/joomla_3/Helper_site.php +++ b/admin/compiler/joomla_3/Helper_site.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -29,7 +29,7 @@ abstract class ###Component###Helper * * @var array */ - protected static $composer = array(); + protected static $composer = []; /** * The Main Active Language @@ -99,7 +99,7 @@ abstract class ###Component###Helper // check if set if (!Super___91004529_94a9_4590_b842_e7c6b624ecf5___Power::check(self::$JVersion)) { - self::$JVersion = new JVersion(); + self::$JVersion = new Version(); } return self::$JVersion; } @@ -110,9 +110,9 @@ abstract class ###Component###Helper public static function getContributors() { // get params - $params = JComponentHelper::getParams('com_###component###'); + $params = ComponentHelper::getParams('com_###component###'); // start contributors array - $contributors = array(); + $contributors = []; // get all Contributors (max 20) $searchArray = range('0','20'); foreach($searchArray as $nr) @@ -121,22 +121,22 @@ abstract class ###Component###Helper { // set link based of selected option if($params->get("useContributor".$nr) == 1) - { + { $link_front = ''; $link_back = ''; } - elseif($params->get("useContributor".$nr) == 2) - { + elseif($params->get("useContributor".$nr) == 2) + { $link_front = ''; $link_back = ''; } - else - { + else + { $link_front = ''; $link_back = ''; } - $contributors[$nr]['title'] = Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($params->get("titleContributor".$nr)); - $contributors[$nr]['name'] = $link_front.Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($params->get("nameContributor".$nr)).$link_back; + $contributors[$nr]['title'] = Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($params->get("titleContributor".$nr)); + $contributors[$nr]['name'] = $link_front.Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($params->get("nameContributor".$nr)).$link_back; } } return $contributors; @@ -145,14 +145,14 @@ abstract class ###Component###Helper /** * Get any component's model */ - public static function getModel($name, $path = JPATH_COMPONENT_SITE, $Component = '###Component###', $config = array()) + public static function getModel($name, $path = JPATH_COMPONENT_SITE, $Component = '###Component###', $config = []) { // fix the name $name = Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($name); // full path to models $fullPathModels = $path . '/models'; // load the model file - JModelLegacy::addIncludePath($fullPathModels, $Component . 'Model'); + BaseDatabaseModel::addIncludePath($fullPathModels, $Component . 'Model'); // make sure the table path is loaded if (!isset($config['table_path']) || !Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($config['table_path'])) { @@ -160,7 +160,7 @@ abstract class ###Component###Helper $config['table_path'] = JPATH_ADMINISTRATOR . '/components/com_' . strtolower($Component) . '/tables'; } // get instance - $model = JModelLegacy::getInstance($name, $Component . 'Model', $config); + $model = BaseDatabaseModel::getInstance($name, $Component . 'Model', $config); // if model not found (strange) if ($model == false) { @@ -195,14 +195,14 @@ abstract class ###Component###Helper */ public static function setAsset($id, $table, $inherit = true) { - $parent = JTable::getInstance('Asset'); + $parent = Table::getInstance('Asset'); $parent->loadByName('com_###component###'); $parentId = $parent->id; $name = 'com_###component###.'.$table.'.'.$id; $title = ''; - $asset = JTable::getInstance('Asset'); + $asset = Table::getInstance('Asset'); $asset->loadByName($name); // Check for an error. @@ -226,14 +226,14 @@ abstract class ###Component###Helper $asset->title = $title; // get the default asset rules $rules = self::getDefaultAssetRules('com_###component###', $table, $inherit); - if ($rules instanceof JAccessRules) + if ($rules instanceof AccessRules) { $asset->rules = (string) $rules; } if (!$asset->check() || !$asset->store()) { - JFactory::getApplication()->enqueueMessage($asset->getError(), 'warning'); + Factory::getApplication()->enqueueMessage($asset->getError(), 'warning'); return false; } else @@ -246,7 +246,7 @@ abstract class ###Component###Helper $object->asset_id = (int) $asset->id; // Update their asset_id to link to the asset table. - return JFactory::getDbo()->updateObject('#__###component###_'.$table, $object, 'id'); + return Factory::getDbo()->updateObject('#__###component###_'.$table, $object, 'id'); } } return false; @@ -263,7 +263,7 @@ abstract class ###Component###Helper if (!$inherit) { // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); + $db = Factory::getDbo(); $query = $db->getQuery(true) ->select($db->quoteName('id')) ->from($db->quoteName('#__assets')) @@ -278,8 +278,8 @@ abstract class ###Component###Helper } } // get asset rules - $result = JAccess::getAssetRules($assetId); - if ($result instanceof JAccessRules) + $result = Access::getAssetRules($assetId); + if ($result instanceof AccessRules) { $_result = (string) $result; $_result = json_decode($_result); @@ -294,7 +294,7 @@ abstract class ###Component###Helper elseif ($inherit) { // clear the value since we inherit - $rule = array(); + $rule = []; } } // check if there are any view values remaining @@ -302,8 +302,8 @@ abstract class ###Component###Helper { $_result = json_encode($_result); $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules($_result); // return filtered rules return $rules; } @@ -348,7 +348,7 @@ abstract class ###Component###Helper * @return null * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::attributes($xml, $attributes); */ - public static function xmlAddAttributes(&$xml, $attributes = array()) + public static function xmlAddAttributes(&$xml, $attributes = []) { Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::attributes($xml, $attributes); } @@ -362,7 +362,7 @@ abstract class ###Component###Helper * @return void * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::options($xml, $options); */ - public static function xmlAddOptions(&$xml, $options = array()) + public static function xmlAddOptions(&$xml, $options = []) { Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::options($xml, $options); } @@ -488,7 +488,7 @@ abstract class ###Component###Helper { $type = 'item'; } - $db = JFactory::getDbo(); + $db = Factory::getDbo(); $query = $db->getQuery(true); $query->select(array('a.published')); $query->from('#__###component###_'.$type.' AS a'); @@ -506,7 +506,7 @@ abstract class ###Component###Helper public static function getGroupName($id) { - $db = JFactory::getDBO(); + $db = Factory::getDBO(); $query = $db->getQuery(true); $query->select(array('a.title')); $query->from('#__usergroups AS a'); @@ -531,7 +531,7 @@ abstract class ###Component###Helper * @param string $component The target component * @param object $user The user whose permissions we are loading * - * @return object The JObject of permission/authorised actions + * @return object The CMSObject of permission/authorised actions * */ public static function getActions($view, &$record = null, $views = null, $target = null, $component = '###component###', $user = 'null') @@ -540,22 +540,22 @@ abstract class ###Component###Helper if (!Super___91004529_94a9_4590_b842_e7c6b624ecf5___Power::check($user)) { // get the user object - $user = JFactory::getUser(); + $user = Factory::getUser(); } - // load the JObject - $result = new JObject; + // load the CMSObject + $result = new CMSObject; // make view name safe (just incase) $view = Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($view); if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($views)) { $views = Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($views); - } + } // get all actions from component - $actions = JAccess::getActionsFromFile( + $actions = Access::getActionsFromFile( JPATH_ADMINISTRATOR . '/components/com_' . $component . '/access.xml', "/access/section[@name='component']/" ); - // if non found then return empty JObject + // if non found then return empty CMSObject if (empty($actions)) { return $result; @@ -722,7 +722,7 @@ abstract class ###Component###Helper /** * Check if have an json string * - * @input string The json string to check + * @input string The json string to check * * @returns bool true on success * @deprecated 3.3 Use Super___4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::check($string); @@ -735,7 +735,7 @@ abstract class ###Component###Helper /** * Check if have an object with a length * - * @input object The object to check + * @input object The object to check * * @returns bool true on success * @deprecated 3.3 Use Super___91004529_94a9_4590_b842_e7c6b624ecf5___Power::check($object); @@ -748,7 +748,7 @@ abstract class ###Component###Helper /** * Check if have an array with a length * - * @input array The array to check + * @input array The array to check * * @returns bool/int number of items in array on success * @deprecated 3.3 Use Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($array, $removeEmptyString); @@ -761,7 +761,7 @@ abstract class ###Component###Helper /** * Check if have a string with a length * - * @input string The string to check + * @input string The string to check * * @returns bool true on success * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($string); @@ -781,7 +781,7 @@ abstract class ###Component###Helper { // If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right? $connected = @fsockopen("www.example.com", 80); - // website, port (try 80 or 443) + // website, port (try 80 or 443) if ($connected) { //action when connected @@ -799,7 +799,7 @@ abstract class ###Component###Helper /** * Merge an array of array's * - * @input array The arrays you would like to merge + * @input array The arrays you would like to merge * * @returns array on success * @deprecated 3.3 Use Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::merge($arrays); @@ -818,7 +818,7 @@ abstract class ###Component###Helper /** * Shorten a string * - * @input string The you would like to shorten + * @input string The you would like to shorten * * @returns string on success * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::shorten(...); @@ -831,7 +831,7 @@ abstract class ###Component###Helper /** * Making strings safe (various ways) * - * @input string The you would like to make safe + * @input string The you would like to make safe * * @returns string on success * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe(...); @@ -850,7 +850,7 @@ abstract class ###Component###Helper /** * Convert none English strings to code usable string * - * @input an string + * @input an string * * @returns a string * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::transliterate($string); @@ -863,7 +863,7 @@ abstract class ###Component###Helper /** * make sure a string is HTML save * - * @input an html string + * @input an html string * * @returns a string * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html(...); @@ -881,7 +881,7 @@ abstract class ###Component###Helper /** * Convert all int in a string to an English word string * - * @input an string with numbers + * @input an string with numbers * * @returns a string * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::numbers($string); @@ -895,7 +895,7 @@ abstract class ###Component###Helper * Convert an integer into an English word string * Thanks to Tom Nicholson * - * @input an int + * @input an int * @returns a string * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::number($x); */ diff --git a/admin/compiler/joomla_3/HtmlView_custom_admin.php b/admin/compiler/joomla_3/HtmlView_custom_admin.php index a7f97fbee..dc0f06ed4 100644 --- a/admin/compiler/joomla_3/HtmlView_custom_admin.php +++ b/admin/compiler/joomla_3/HtmlView_custom_admin.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -15,9 +15,9 @@ defined('_JEXEC') or die('Restricted access'); ###BOM### // No direct access to this file -defined('_JEXEC') or die('Restricted access'); ###LICENSE_LOCKED_DEFINED######CUSTOM_ADMIN_GET_MODULE_JIMPORT### +defined('_JEXEC') or die('Restricted access'); ###LICENSE_LOCKED_DEFINED### -###CUSTOM_ADMIN_VIEW_HTML_HEADER### +###CUSTOM_ADMIN_VIEW_HTML_HEADER######CUSTOM_ADMIN_GET_MODULE_JIMPORT### /** * ###Component### Html View class for the ###SView### @@ -28,11 +28,11 @@ class ###Component###View###SView### extends HtmlView function display($tpl = null) { // get component params - $this->params = JComponentHelper::getParams('com_###component###'); + $this->params = ComponentHelper::getParams('com_###component###'); // get the application - $this->app = JFactory::getApplication(); + $this->app = Factory::getApplication(); // get the user object - $this->user = JFactory::getUser(); + $this->user = Factory::getUser(); // get global action permissions $this->canDo = ###Component###Helper::getActions('###sview###');###CUSTOM_ADMIN_DIPLAY_METHOD### }###CUSTOM_ADMIN_EXTRA_DIPLAY_METHODS### @@ -43,7 +43,7 @@ class ###Component###View###SView### extends HtmlView protected function setDocument() {###CUSTOM_ADMIN_LIBRARIES_LOADER######CUSTOM_ADMIN_DOCUMENT_METADATA######CUSTOM_ADMIN_UIKIT_LOADER######CUSTOM_ADMIN_GOOGLECHART_LOADER######CUSTOM_ADMIN_FOOTABLE_LOADER######CUSTOM_ADMIN_DOCUMENT_CUSTOM_PHP### // add the document default css file - JHtml::_('stylesheet', 'administrator/components/com_###component###/assets/css/###sview###.css', ['version' => 'auto']);###CUSTOM_ADMIN_DOCUMENT_CUSTOM_CSS######CUSTOM_ADMIN_DOCUMENT_CUSTOM_JS### + Html::_('stylesheet', 'administrator/components/com_###component###/assets/css/###sview###.css', ['version' => 'auto']);###CUSTOM_ADMIN_DOCUMENT_CUSTOM_CSS######CUSTOM_ADMIN_DOCUMENT_CUSTOM_JS### } /** @@ -59,22 +59,22 @@ class ###Component###View###SView### extends HtmlView // Check for empty title and add view name if param is set if (empty($title)) { - $title = JText::_('COM_###COMPONENT###_###SVIEW###'); + $title = Text::_('COM_###COMPONENT###_###SVIEW###'); } // add title to the page - JToolbarHelper::title($title,'###ICOMOON###');###CUSTOM_ADMIN_CUSTOM_BUTTONS### + ToolbarHelper::title($title,'###ICOMOON###');###CUSTOM_ADMIN_CUSTOM_BUTTONS### // set help url for this view if found $this->help_url = ###Component###Helper::getHelpUrl('###sviews###'); - if (###Component###Helper::checkString($this->help_url)) + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($this->help_url)) { - JToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); + ToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); } // add the options comp button if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) { - JToolBarHelper::preferences('com_###component###'); + ToolbarHelper::preferences('com_###component###'); } }###CUSTOM_ADMIN_GET_MODULE### @@ -88,7 +88,17 @@ class ###Component###View###SView### extends HtmlView public function escape($var) { // use the helper htmlEscape method instead. - return ###Component###Helper::htmlEscape($var, $this->_charset); + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($var, $this->_charset); + } + + /** + * Get the Document (helper method toward Joomla 4 and 5) + */ + public function getDocument() + { + $this->document ??= JFactory::getDocument(); + + return $this->document; } } ?> diff --git a/admin/compiler/joomla_3/HtmlView_edit.php b/admin/compiler/joomla_3/HtmlView_edit.php index 309e298b9..a0c3431a5 100644 --- a/admin/compiler/joomla_3/HtmlView_edit.php +++ b/admin/compiler/joomla_3/HtmlView_edit.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -31,7 +31,7 @@ class ###Component###View###View### extends HtmlView public function display($tpl = null) { // set params - $this->params = JComponentHelper::getParams('com_###component###'); + $this->params = ComponentHelper::getParams('com_###component###'); // Assign the variables $this->form = $this->get('Form'); $this->item = $this->get('Item'); @@ -40,7 +40,7 @@ class ###Component###View###View### extends HtmlView // get action permissions $this->canDo = ###Component###Helper::getActions('###view###', $this->item); // get input - $jinput = JFactory::getApplication()->input; + $jinput = Factory::getApplication()->input; $this->ref = $jinput->get('ref', 0, 'word'); $this->refid = $jinput->get('refid', 0, 'int'); $return = $jinput->get('return', null, 'base64'); @@ -65,7 +65,7 @@ class ###Component###View###View### extends HtmlView // Set the toolbar $this->addToolBar(); - + // Check for errors. if (count($errors = $this->get('Errors'))) { @@ -99,11 +99,11 @@ class ###Component###View###View### extends HtmlView { if(strlen($var) > 30) { - // use the helper htmlEscape method instead and shorten the string - return ###Component###Helper::htmlEscape($var, $this->_charset, true, 30); + // use the helper htmlEscape method instead and shorten the string + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($var, $this->_charset, true, 30); } // use the helper htmlEscape method instead. - return ###Component###Helper::htmlEscape($var, $this->_charset); + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($var, $this->_charset); } /** @@ -114,14 +114,20 @@ class ###Component###View###View### extends HtmlView protected function setDocument() { $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_###COMPONENT###_###VIEW###_NEW' : 'COM_###COMPONENT###_###VIEW###_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_###component###/assets/css/###view###.css", (###Component###Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');###AJAXTOKE######LINKEDVIEWTABLESCRIPTS### - $this->document->addScript(JURI::root() . $this->script, (###Component###Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_###component###/views/###view###/submitbutton.js", (###Component###Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); ###DOCUMENT_CUSTOM_PHP### - JText::script('view not acceptable. Error'); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_###COMPONENT###_###VIEW###_NEW' : 'COM_###COMPONENT###_###VIEW###_EDIT')); + Html::_('stylesheet', "administrator/components/com_###component###/assets/css/###view###.css", ['version' => 'auto']);###AJAXTOKE######LINKEDVIEWTABLESCRIPTS### + Html::_('script', $this->script, ['version' => 'auto']); + Html::_('script', "administrator/components/com_###component###/views/###view###/submitbutton.js", ['version' => 'auto']);###DOCUMENT_CUSTOM_PHP### + Text::script('view not acceptable. Error'); + } + + /** + * Get the Document (helper method toward Joomla 4 and 5) + */ + public function getDocument() + { + $this->document ??= JFactory::getDocument(); + + return $this->document; } } diff --git a/admin/compiler/joomla_3/HtmlView_edit_site.php b/admin/compiler/joomla_3/HtmlView_edit_site.php index b2fd1f338..070fde9f5 100644 --- a/admin/compiler/joomla_3/HtmlView_edit_site.php +++ b/admin/compiler/joomla_3/HtmlView_edit_site.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -31,7 +31,7 @@ class ###Component###View###View### extends HtmlView public function display($tpl = null) { // set params - $this->params = JComponentHelper::getParams('com_###component###'); + $this->params = ComponentHelper::getParams('com_###component###'); // Assign the variables $this->form = $this->get('Form'); $this->item = $this->get('Item'); @@ -40,7 +40,7 @@ class ###Component###View###View### extends HtmlView // get action permissions $this->canDo = ###Component###Helper::getActions('###view###', $this->item); // get input - $jinput = JFactory::getApplication()->input; + $jinput = Factory::getApplication()->input; $this->ref = $jinput->get('ref', 0, 'word'); $this->refid = $jinput->get('refid', 0, 'int'); $return = $jinput->get('return', null, 'base64'); @@ -65,7 +65,7 @@ class ###Component###View###View### extends HtmlView // Set the toolbar $this->addToolBar(); - + // Check for errors. if (count($errors = $this->get('Errors'))) { @@ -86,7 +86,7 @@ class ###Component###View###View### extends HtmlView protected function addToolBar() {###ADDTOOLBAR### // now initiate the toolbar - $this->toolbar = JToolbar::getInstance(); + $this->toolbar = Toolbar::getInstance(); } /** @@ -100,11 +100,11 @@ class ###Component###View###View### extends HtmlView { if(strlen($var) > 30) { - // use the helper htmlEscape method instead and shorten the string - return ###Component###Helper::htmlEscape($var, $this->_charset, true, 30); + // use the helper htmlEscape method instead and shorten the string + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($var, $this->_charset, true, 30); } // use the helper htmlEscape method instead. - return ###Component###Helper::htmlEscape($var, $this->_charset); + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($var, $this->_charset); } /** @@ -115,11 +115,7 @@ class ###Component###View###View### extends HtmlView protected function setDocument() { $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_###COMPONENT###_###VIEW###_NEW' : 'COM_###COMPONENT###_###VIEW###_EDIT')); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_###COMPONENT###_###VIEW###_NEW' : 'COM_###COMPONENT###_###VIEW###_EDIT')); // only add the ISIS template css & js if needed (default is 1 = true) // you can override this in the global component options // just add a (radio yes/no field) with a name called add_isis_template @@ -127,14 +123,24 @@ class ###Component###View###View### extends HtmlView if ($this->params->get('add_isis_template', 1)) { // we need this to fix the form display (TODO) - $this->document->addStyleSheet(JURI::root() . "administrator/templates/isis/css/template.css", (###Component###Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . "administrator/templates/isis/js/template.js", (###Component###Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + Html::_('stylesheet', "administrator/templates/isis/css/template.css", ['version' => 'auto']); + Html::_('script', "administrator/templates/isis/js/template.js", ['version' => 'auto']); } // the default style of this view - $this->document->addStyleSheet(JURI::root()."components/com_###component###/assets/css/###view###.css", (###Component###Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');###AJAXTOKE######LINKEDVIEWTABLESCRIPTS### + Html::_('stylesheet', "components/com_###component###/assets/css/###view###.css", ['version' => 'auto']);###AJAXTOKE######LINKEDVIEWTABLESCRIPTS### // default javascript of this view - $this->document->addScript(JURI::root(). $this->script, (###Component###Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root(). "components/com_###component###/views/###view###/submitbutton.js", (###Component###Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); ###DOCUMENT_CUSTOM_PHP### - JText::script('view not acceptable. Error'); + Html::_('script', $this->script, ['version' => 'auto']); + Html::_('script', "components/com_###component###/views/###view###/submitbutton.js", ['version' => 'auto']);###DOCUMENT_CUSTOM_PHP### + Text::script('view not acceptable. Error'); + } + + /** + * Get the Document (helper method toward Joomla 4 and 5) + */ + public function getDocument() + { + $this->document ??= JFactory::getDocument(); + + return $this->document; } } diff --git a/admin/compiler/joomla_3/HtmlView_import.php b/admin/compiler/joomla_3/HtmlView_import.php index c19e19f8d..9569a7aec 100644 --- a/admin/compiler/joomla_3/HtmlView_import.php +++ b/admin/compiler/joomla_3/HtmlView_import.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,7 +17,10 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED### +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\Toolbar\ToolbarHelper; /** * ###Component### Import Html View @@ -31,7 +34,7 @@ class ###Component###ViewImport extends HtmlView protected $dataType; public function display($tpl = null) - { + { if ($this->getLayout() !== 'modal') { // Include helper submenu @@ -44,7 +47,7 @@ class ###Component###ViewImport extends HtmlView $this->paths = &$paths; $this->state = &$state; - // get global action permissions + // get global action permissions $this->canDo = ###Component###Helper::getActions('import'); // We don't need toolbar in the modal window. @@ -55,18 +58,18 @@ class ###Component###ViewImport extends HtmlView } // get the session object - $session = JFactory::getSession(); + $session = Factory::getSession(); // check if it has package - $this->hasPackage = $session->get('hasPackage', false); - $this->dataType = $session->get('dataType', false); + $this->hasPackage = $session->get('hasPackage', false); + $this->dataType = $session->get('dataType', false); if($this->hasPackage && $this->dataType) { - $this->headerList = json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS', false),true); - $this->headers = ###Component###Helper::getFileHeaders($this->dataType); + $this->headerList = json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS', false),true); + $this->headers = ###Component###Helper::getFileHeaders($this->dataType); // clear the data type $session->clear('dataType'); } - + // Check for errors. if (count($errors = $this->get('Errors'))) { @@ -82,19 +85,19 @@ class ###Component###ViewImport extends HtmlView */ protected function addToolBar() { - JToolBarHelper::title(JText::_('COM_###COMPONENT###_IMPORT_TITLE'), 'upload'); + ToolbarHelper::title(Text::_('COM_###COMPONENT###_IMPORT_TITLE'), 'upload'); JHtmlSidebar::setAction('index.php?option=com_###component###&view=import'); if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) { - JToolBarHelper::preferences('com_###component###'); + ToolbarHelper::preferences('com_###component###'); } // set help url for this view if found $this->help_url = ###Component###Helper::getHelpUrl('import'); - if (###Component###Helper::checkString($this->help_url)) + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($this->help_url)) { - JToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); + ToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); } } } diff --git a/admin/compiler/joomla_3/HtmlView_import_custom.php b/admin/compiler/joomla_3/HtmlView_import_custom.php index bee878fc1..68390de5b 100644 --- a/admin/compiler/joomla_3/HtmlView_import_custom.php +++ b/admin/compiler/joomla_3/HtmlView_import_custom.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,7 +17,13 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED### +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormHelper; use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; /** * ###Component### ###View### Html View @@ -30,19 +36,19 @@ class ###Component###View###View### extends HtmlView */ protected function addToolBar() { - JToolBarHelper::title(JText::_('COM_###COMPONENT###_IMPORT_TITLE'), 'upload'); + ToolbarHelper::title(Text::_('COM_###COMPONENT###_IMPORT_TITLE'), 'upload'); JHtmlSidebar::setAction('index.php?option=com_###component###&view=###view###'); if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) { - JToolBarHelper::preferences('com_###component###'); + ToolbarHelper::preferences('com_###component###'); } // set help url for this view if found $this->help_url = ###Component###Helper::getHelpUrl('###view###'); - if (###Component###Helper::checkString($this->help_url)) + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($this->help_url)) { - JToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); + ToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); } } } diff --git a/admin/compiler/joomla_3/HtmlView_list.php b/admin/compiler/joomla_3/HtmlView_list.php index 740a8c545..f00898087 100644 --- a/admin/compiler/joomla_3/HtmlView_list.php +++ b/admin/compiler/joomla_3/HtmlView_list.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -40,10 +40,10 @@ class ###Component###View###Views### extends HtmlView $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); - $this->user = JFactory::getUser();###ADMIN_DIPLAY_METHOD### + $this->user = Factory::getUser();###ADMIN_DIPLAY_METHOD### $this->saveOrder = $this->listOrder == 'a.ordering'; // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); // get global action permissions $this->canDo = ###Component###Helper::getActions('###view###');###JVIEWLISTCANDO### @@ -58,7 +58,7 @@ class ###Component###View###Views### extends HtmlView $this->batchDisplay = JHtmlBatch_::render(); } } - + // Check for errors. if (count($errors = $this->get('Errors'))) { @@ -77,32 +77,32 @@ class ###Component###View###Views### extends HtmlView */ protected function addToolBar() { - JToolBarHelper::title(JText::_('COM_###COMPONENT###_###VIEWS###'), '###ICOMOON###'); JHtmlSidebar::setAction('index.php?option=com_###component###&view=###views###'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); + ToolbarHelper::title(Text::_('COM_###COMPONENT###_###VIEWS###'), '###ICOMOON###'); + FormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); if ($this->canCreate) { - JToolBarHelper::addNew('###view###.add'); + ToolbarHelper::addNew('###view###.add'); } // Only load if there are items - if (###Component###Helper::checkArray($this->items)) + if (Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($this->items)) { if ($this->canEdit) { - JToolBarHelper::editList('###view###.edit'); + ToolbarHelper::editList('###view###.edit'); } if ($this->canState) { - JToolBarHelper::publishList('###views###.publish'); - JToolBarHelper::unpublishList('###views###.unpublish'); - JToolBarHelper::archiveList('###views###.archive'); + ToolbarHelper::publishList('###views###.publish'); + ToolbarHelper::unpublishList('###views###.unpublish'); + ToolbarHelper::archiveList('###views###.archive'); if ($this->canDo->get('core.admin')) { - JToolBarHelper::checkin('###views###.checkin'); + ToolbarHelper::checkin('###views###.checkin'); } } @@ -110,11 +110,11 @@ class ###Component###View###Views### extends HtmlView if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) { // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); + $bar = Toolbar::getInstance('toolbar'); // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); + $title = Text::_('JTOOLBAR_BATCH'); // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); + $layout = new FileLayout('joomla.toolbar.batch'); // add the button to the page $dhtml = $layout->render(array('title' => $title)); $bar->appendButton('Custom', $dhtml, 'batch'); @@ -122,25 +122,25 @@ class ###Component###View###Views### extends HtmlView if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) { - JToolbarHelper::deleteList('', '###views###.delete', 'JTOOLBAR_EMPTY_TRASH'); + ToolbarHelper::deleteList('', '###views###.delete', 'JTOOLBAR_EMPTY_TRASH'); } elseif ($this->canState && $this->canDelete) { - JToolbarHelper::trash('###views###.trash'); + ToolbarHelper::trash('###views###.trash'); }###EXPORTBUTTON### }###ADMIN_CUSTOM_FUNCTION_ONLY_BUTTONS_LIST######IMPORTBUTTON### // set help url for this view if found $this->help_url = ###Component###Helper::getHelpUrl('###views###'); - if (###Component###Helper::checkString($this->help_url)) + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($this->help_url)) { - JToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); + ToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); } // add the options comp button if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) { - JToolBarHelper::preferences('com_###component###'); + ToolbarHelper::preferences('com_###component###'); }###FILTERFIELDDISPLAYHELPER######BATCHDISPLAYHELPER### } @@ -153,10 +153,10 @@ class ###Component###View###Views### extends HtmlView { if (!isset($this->document)) { - $this->document = JFactory::getDocument(); + $this->document = Factory::getDocument(); } - $this->document->setTitle(JText::_('COM_###COMPONENT###_###VIEWS###')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_###component###/assets/css/###views###.css", (###Component###Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');###ADMIN_ADD_JAVASCRIPT_FILE### + $this->document->setTitle(Text::_('COM_###COMPONENT###_###VIEWS###')); + Html::_('stylesheet', "administrator/components/com_###component###/assets/css/###views###.css", ['version' => 'auto']);###ADMIN_ADD_JAVASCRIPT_FILE### } /** @@ -171,19 +171,29 @@ class ###Component###View###Views### extends HtmlView if(strlen($var) > 50) { // use the helper htmlEscape method instead and shorten the string - return ###Component###Helper::htmlEscape($var, $this->_charset, true); + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($var, $this->_charset, true); } // use the helper htmlEscape method instead. - return ###Component###Helper::htmlEscape($var, $this->_charset); + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($var, $this->_charset); } /** * Returns an array of fields the table can be sorted by * - * @return array Array containing the field name to sort by as the key and display text as value + * @return array Array containing the field name to sort by as the key and display text as value */ protected function getSortFields() { ###SORTFIELDS### + } + + /** + * Get the Document (helper method toward Joomla 4 and 5) + */ + public function getDocument() + { + $this->document ??= JFactory::getDocument(); + + return $this->document; }###FILTERFUNCTIONS### } diff --git a/admin/compiler/joomla_3/HtmlView_list_custom_admin.php b/admin/compiler/joomla_3/HtmlView_list_custom_admin.php index 171226444..ebea61327 100644 --- a/admin/compiler/joomla_3/HtmlView_list_custom_admin.php +++ b/admin/compiler/joomla_3/HtmlView_list_custom_admin.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -15,9 +15,9 @@ defined('_JEXEC') or die('Restricted access'); ###BOM### // No direct access to this file -defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED######CUSTOM_ADMIN_GET_MODULE_JIMPORT### +defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED### -###CUSTOM_ADMIN_VIEWS_HTML_HEADER### +###CUSTOM_ADMIN_VIEWS_HTML_HEADER######CUSTOM_ADMIN_GET_MODULE_JIMPORT### /** * ###Component### Html View class for the ###SViews### @@ -28,11 +28,11 @@ class ###Component###View###SViews### extends HtmlView function display($tpl = null) { // get component params - $this->params = JComponentHelper::getParams('com_###component###'); + $this->params = ComponentHelper::getParams('com_###component###'); // get the application - $this->app = JFactory::getApplication(); + $this->app = Factory::getApplication(); // get the user object - $this->user = JFactory::getUser(); + $this->user = Factory::getUser(); // get global action permissions $this->canDo = ###Component###Helper::getActions('###sview###');###CUSTOM_ADMIN_DIPLAY_METHOD### }###CUSTOM_ADMIN_EXTRA_DIPLAY_METHODS### @@ -43,7 +43,7 @@ class ###Component###View###SViews### extends HtmlView protected function setDocument() {###CUSTOM_ADMIN_LIBRARIES_LOADER######CUSTOM_ADMIN_UIKIT_LOADER######CUSTOM_ADMIN_GOOGLECHART_LOADER######CUSTOM_ADMIN_FOOTABLE_LOADER######CUSTOM_ADMIN_DOCUMENT_CUSTOM_PHP### // add the document default css file - JHtml::_('stylesheet', 'administrator/components/com_###component###/assets/css/###sviews###.css', ['version' => 'auto']);###CUSTOM_ADMIN_DOCUMENT_CUSTOM_CSS######CUSTOM_ADMIN_DOCUMENT_CUSTOM_JS### + Html::_('stylesheet', 'administrator/components/com_###component###/assets/css/###sviews###.css', ['version' => 'auto']);###CUSTOM_ADMIN_DOCUMENT_CUSTOM_CSS######CUSTOM_ADMIN_DOCUMENT_CUSTOM_JS### } /** @@ -52,19 +52,19 @@ class ###Component###View###SViews### extends HtmlView protected function addToolBar() {###HIDEMAINMENU### // add title to the page - JToolbarHelper::title(JText::_('COM_###COMPONENT###_###SVIEWS###'),'###ICOMOON###');###CUSTOM_ADMIN_CUSTOM_BUTTONS### + ToolbarHelper::title(Text::_('COM_###COMPONENT###_###SVIEWS###'),'###ICOMOON###');###CUSTOM_ADMIN_CUSTOM_BUTTONS### // set help url for this view if found $this->help_url = ###Component###Helper::getHelpUrl('###sviews###'); - if (###Component###Helper::checkString($this->help_url)) + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($this->help_url)) { - JToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); + ToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); } // add the options comp button if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) { - JToolBarHelper::preferences('com_###component###'); + ToolbarHelper::preferences('com_###component###'); } }###CUSTOM_ADMIN_GET_MODULE### @@ -78,6 +78,16 @@ class ###Component###View###SViews### extends HtmlView public function escape($var) { // use the helper htmlEscape method instead. - return ###Component###Helper::htmlEscape($var, $this->_charset); + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($var, $this->_charset); + } + + /** + * Get the Document (helper method toward Joomla 4 and 5) + */ + public function getDocument() + { + $this->document ??= JFactory::getDocument(); + + return $this->document; } } diff --git a/admin/compiler/joomla_3/HtmlView_list_site.php b/admin/compiler/joomla_3/HtmlView_list_site.php index e981783d2..424a6acae 100644 --- a/admin/compiler/joomla_3/HtmlView_list_site.php +++ b/admin/compiler/joomla_3/HtmlView_list_site.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -15,9 +15,9 @@ defined('_JEXEC') or die('Restricted access'); ###BOM### // No direct access to this file -defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED######SITE_GET_MODULE_JIMPORT### +defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED### -###SITE_VIEWS_HTML_HEADER### +###SITE_VIEWS_HTML_HEADER######SITE_GET_MODULE_JIMPORT### /** * ###Component### Html View class for the ###SViews### @@ -26,13 +26,13 @@ class ###Component###View###SViews### extends HtmlView { // Overwriting JView display method function display($tpl = null) - { + { // get combined params of both component and menu - $this->app = JFactory::getApplication(); + $this->app = Factory::getApplication(); $this->params = $this->app->getParams(); $this->menu = $this->app->getMenu()->getActive(); // get the user object - $this->user = JFactory::getUser();###SITE_DIPLAY_METHOD### + $this->user = Factory::getUser();###SITE_DIPLAY_METHOD### }###SITE_EXTRA_DIPLAY_METHODS### /** @@ -41,7 +41,7 @@ class ###Component###View###SViews### extends HtmlView protected function _prepareDocument() {###SITE_LIBRARIES_LOADER######SITE_UIKIT_LOADER######SITE_GOOGLECHART_LOADER######SITE_FOOTABLE_LOADER######SITE_DOCUMENT_METADATA######SITE_DOCUMENT_CUSTOM_PHP### // add the document default css file - JHtml::_('stylesheet', 'components/com_###component###/assets/css/###sview###.css', ['version' => 'auto']);###SITE_DOCUMENT_CUSTOM_CSS######SITE_DOCUMENT_CUSTOM_JS######SITE_JAVASCRIPT_FOR_BUTTONS### + Html::_('stylesheet', 'components/com_###component###/assets/css/###sview###.css', ['version' => 'auto']);###SITE_DOCUMENT_CUSTOM_CSS######SITE_DOCUMENT_CUSTOM_JS######SITE_JAVASCRIPT_FOR_BUTTONS### } /** @@ -49,15 +49,15 @@ class ###Component###View###SViews### extends HtmlView */ protected function addToolBar() {###SITE_CUSTOM_BUTTONS### - + // set help url for this view if found $this->help_url = ###Component###Helper::getHelpUrl('###sviews###'); - if (###Component###Helper::checkString($this->help_url)) + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($this->help_url)) { - JToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); + ToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); } // now initiate the toolbar - $this->toolbar = JToolbar::getInstance(); + $this->toolbar = Toolbar::getInstance(); }###SITE_GET_MODULE### /** @@ -70,6 +70,16 @@ class ###Component###View###SViews### extends HtmlView public function escape($var, $sorten = false, $length = 40) { // use the helper htmlEscape method instead. - return ###Component###Helper::htmlEscape($var, $this->_charset, $sorten, $length); + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($var, $this->_charset, $sorten, $length); + } + + /** + * Get the Document (helper method toward Joomla 4 and 5) + */ + public function getDocument() + { + $this->document ??= JFactory::getDocument(); + + return $this->document; } } diff --git a/admin/compiler/joomla_3/HtmlView_site.php b/admin/compiler/joomla_3/HtmlView_site.php index 13bc3fd01..5c4ca5ecd 100644 --- a/admin/compiler/joomla_3/HtmlView_site.php +++ b/admin/compiler/joomla_3/HtmlView_site.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -15,9 +15,9 @@ defined('_JEXEC') or die('Restricted access'); ###BOM### // No direct access to this file -defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED######SITE_GET_MODULE_JIMPORT### +defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED### -###SITE_VIEW_HTML_HEADER### +###SITE_VIEW_HTML_HEADER######SITE_GET_MODULE_JIMPORT### /** * ###Component### Html View class for the ###SView### @@ -26,22 +26,22 @@ class ###Component###View###SView### extends HtmlView { // Overwriting JView display method function display($tpl = null) - { + { // get combined params of both component and menu - $this->app = JFactory::getApplication(); + $this->app = Factory::getApplication(); $this->params = $this->app->getParams(); $this->menu = $this->app->getMenu()->getActive(); // get the user object - $this->user = JFactory::getUser();###SITE_DIPLAY_METHOD### + $this->user = Factory::getUser();###SITE_DIPLAY_METHOD### }###SITE_EXTRA_DIPLAY_METHODS### /** * Prepares the document */ protected function _prepareDocument() - {###SITE_LIBRARIES_LOADER######SITE_UIKIT_LOADER######SITE_GOOGLECHART_LOADER######SITE_FOOTABLE_LOADER######SITE_DOCUMENT_METADATA######SITE_DOCUMENT_CUSTOM_PHP### + {###SITE_LIBRARIES_LOADER######SITE_UIKIT_LOADER######SITE_GOOGLECHART_LOADER######SITE_FOOTABLE_LOADER######SITE_DOCUMENT_METADATA######SITE_DOCUMENT_CUSTOM_PHP### // add the document default css file - JHtml::_('stylesheet', 'components/com_###component###/assets/css/###sview###.css', ['version' => 'auto']);###SITE_DOCUMENT_CUSTOM_CSS######SITE_DOCUMENT_CUSTOM_JS######SITE_JAVASCRIPT_FOR_BUTTONS### + Html::_('stylesheet', 'components/com_###component###/assets/css/###sview###.css', ['version' => 'auto']);###SITE_DOCUMENT_CUSTOM_CSS######SITE_DOCUMENT_CUSTOM_JS######SITE_JAVASCRIPT_FOR_BUTTONS### } /** @@ -52,12 +52,12 @@ class ###Component###View###SView### extends HtmlView // set help url for this view if found $this->help_url = ###Component###Helper::getHelpUrl('###sview###'); - if (###Component###Helper::checkString($this->help_url)) + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($this->help_url)) { - JToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); + ToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); } // now initiate the toolbar - $this->toolbar = JToolbar::getInstance(); + $this->toolbar = Toolbar::getInstance(); }###SITE_GET_MODULE### /** @@ -70,6 +70,16 @@ class ###Component###View###SView### extends HtmlView public function escape($var, $sorten = false, $length = 40) { // use the helper htmlEscape method instead. - return ###Component###Helper::htmlEscape($var, $this->_charset, $sorten, $length); + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($var, $this->_charset, $sorten, $length); + } + + /** + * Get the Document (helper method toward Joomla 4 and 5) + */ + public function getDocument() + { + $this->document ??= JFactory::getDocument(); + + return $this->document; } } diff --git a/admin/compiler/joomla_3/ItemModel_custom_admin.php b/admin/compiler/joomla_3/ItemModel_custom_admin.php index 56f08cab1..c8c49b430 100644 --- a/admin/compiler/joomla_3/ItemModel_custom_admin.php +++ b/admin/compiler/joomla_3/ItemModel_custom_admin.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -31,7 +31,7 @@ class ###Component###Model###SView### extends ItemModel */ protected $_context = 'com_###component###.###sview###'; - /** + /** * Model user data. * * @var strings @@ -61,7 +61,7 @@ class ###Component###Model###SView### extends ItemModel */ protected function populateState() { - $this->app = JFactory::getApplication(); + $this->app = Factory::getApplication(); $this->input = $this->app->input; // Get the item main id $id = $this->input->getInt('id', null); @@ -80,12 +80,12 @@ class ###Component###Model###SView### extends ItemModel */ public function getItem($pk = null) { - $this->user = JFactory::getUser(); + $this->user = Factory::getUser(); // check if this user has permission to access item if (!$this->user->authorise('###sview###.access', 'com_###component###')) { - $app = JFactory::getApplication(); - $app->enqueueMessage(JText::_('Not authorised!'), 'error'); + $app = Factory::getApplication(); + $app->enqueueMessage(Text::_('Not authorised!'), 'error'); // redirect away if not a correct to cPanel/default view $app->redirect('index.php?option=com_###component###'); return false; @@ -98,10 +98,10 @@ class ###Component###Model###SView### extends ItemModel $this->initSet = true; $pk = (!empty($pk)) ? $pk : (int) $this->getState('###sview###.id');###CUSTOM_ADMIN_BEFORE_GET_ITEM### - + if ($this->_item === null) { - $this->_item = array(); + $this->_item = []; }###LICENSE_LOCKED_CHECK### if (!isset($this->_item[$pk])) @@ -114,7 +114,7 @@ class ###Component###Model###SView### extends ItemModel if ($e->getCode() == 404) { // Need to go thru the error handler to allow Redirect to work. - JError::raiseWarning(404, $e->getMessage()); + JError::raiseError(404, $e->getMessage()); } else { diff --git a/admin/compiler/joomla_3/ItemModel_site.php b/admin/compiler/joomla_3/ItemModel_site.php index 621f2f1c7..ca73e7e3e 100644 --- a/admin/compiler/joomla_3/ItemModel_site.php +++ b/admin/compiler/joomla_3/ItemModel_site.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -61,7 +61,7 @@ class ###Component###Model###SView### extends ItemModel */ protected function populateState() { - $this->app = JFactory::getApplication(); + $this->app = Factory::getApplication(); $this->input = $this->app->input; // Get the itme main id $id = $this->input->getInt('id', null); @@ -82,7 +82,7 @@ class ###Component###Model###SView### extends ItemModel */ public function getItem($pk = null) { - $this->user = JFactory::getUser();###USER_PERMISSION_CHECK_ACCESS### + $this->user = Factory::getUser();###USER_PERMISSION_CHECK_ACCESS### $this->userId = $this->user->get('id'); $this->guest = $this->user->get('guest'); $this->groups = $this->user->get('groups'); @@ -91,10 +91,10 @@ class ###Component###Model###SView### extends ItemModel $this->initSet = true; $pk = (!empty($pk)) ? $pk : (int) $this->getState('###sview###.id');###SITE_BEFORE_GET_ITEM### - + if ($this->_item === null) { - $this->_item = array(); + $this->_item = []; }###LICENSE_LOCKED_CHECK### if (!isset($this->_item[$pk])) @@ -107,7 +107,7 @@ class ###Component###Model###SView### extends ItemModel if ($e->getCode() == 404) { // Need to go thru the error handler to allow Redirect to work. - JError::raiseWarning(404, $e->getMessage()); + JError::raiseError(404, $e->getMessage()); } else { diff --git a/admin/compiler/joomla_3/JCB_Helper.php b/admin/compiler/joomla_3/JCB_Helper.php deleted file mode 100644 index 1819d2ba2..000000000 --- a/admin/compiler/joomla_3/JCB_Helper.php +++ /dev/null @@ -1,697 +0,0 @@ - - * @github Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); -?> -###BOM### - -// No direct access to this file -defined('_JEXEC') or die('Restricted access');###ADMIN_POWER_HELPER### - -###ADMIN_HELPER_CLASS_HEADER### - -/** - * ###Component### component helper. - */ -abstract class ###Component###Helper -{ - /** - * Adding the utilities trait to this class - * - * @deprecated 4.0 - Check the trait methods for details, a legacy implementation - */ - use Utilities; - - /** - * get the Component Code Name - */ - public static $ComponentCodeName = '###component###'; - - /** - * Composer Switch - * - * @var array - */ - protected static $composer = array();###ADMIN_GLOBAL_EVENT_HELPER######CUSTOM_HELPER_SCRIPT######BOTH_CUSTOM_HELPER_SCRIPT### - - /** - * Load the Composer Vendors - */ - public static function composerAutoload($target) - { - // insure we load the composer vendor only once - if (!isset(self::$composer[$target])) - { - // get the function name - $functionName = self::safeString('compose' . $target); - // check if method exist - if (method_exists(__CLASS__, $functionName)) - { - return self::{$functionName}(); - } - return false; - } - return self::$composer[$target]; - } - - /** - * Load the Component xml manifest. - */ - public static function manifest() - { - $manifestUrl = JPATH_ADMINISTRATOR."/components/com_###component###/###component###.xml"; - return simplexml_load_file($manifestUrl); - } - - /** - * Joomla version object - */ - protected static $JVersion; - - /** - * set/get Joomla version - */ - public static function jVersion() - { - // check if set - if (!self::checkObject(self::$JVersion)) - { - self::$JVersion = new JVersion(); - } - return self::$JVersion; - } - - /** - * Load the Contributors details. - */ - public static function getContributors() - { - // get params - $params = JComponentHelper::getParams('com_###component###'); - // start contributors array - $contributors = array(); - // get all Contributors (max 20) - $searchArray = range('0','20'); - foreach($searchArray as $nr) - { - if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 1 || $params->get("showContributor".$nr) == 3)) - { - // set link based of selected option - if($params->get("useContributor".$nr) == 1) - { - $link_front = ''; - $link_back = ''; - } - elseif($params->get("useContributor".$nr) == 2) - { - $link_front = ''; - $link_back = ''; - } - else - { - $link_front = ''; - $link_back = ''; - } - $contributors[$nr]['title'] = self::htmlEscape($params->get("titleContributor".$nr)); - $contributors[$nr]['name'] = $link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back; - } - } - return $contributors; - }###HELP### - - /** - * Configure the Linkbar. - */ - public static function addSubmenu($submenu) - { - // load user for access menus - $user = JFactory::getUser(); - // load the submenus to sidebar - ###SUBMENU### - }###HELPER_CREATEUSER######HELPER_UIKIT######HELPER_EXEL### - - public static function isPublished($id,$type) - { - if ($type == 'raw') - { - $type = 'item'; - } - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $query->select(array('a.published')); - $query->from('#__###component###_'.$type.' AS a'); - $query->where('a.id = '. (int) $id); - $query->where('a.published = 1'); - $db->setQuery($query); - $db->execute(); - $found = $db->getNumRows(); - if($found) - { - return true; - } - return false; - } - - public static function getGroupName($id) - { - $db = JFactory::getDBO(); - $query = $db->getQuery(true); - $query->select(array('a.title')); - $query->from('#__usergroups AS a'); - $query->where('a.id = '. (int) $id); - $db->setQuery($query); - $db->execute(); - $found = $db->getNumRows(); - if($found) - { - return $db->loadResult(); - } - return $id; - } - - /** - * Get the action permissions - * - * @param string $view The related view name - * @param int $record The item to act upon - * @param string $views The related list view name - * @param mixed $target Only get this permission (like edit, create, delete) - * @param string $component The target component - * @param object $user The user whose permissions we are loading - * - * @return object The JObject of permission/authorised actions - * - */ - public static function getActions($view, &$record = null, $views = null, $target = null, $component = '###component###', $user = 'null') - { - // load the user if not given - if (!self::checkObject($user)) - { - // get the user object - $user = JFactory::getUser(); - } - // load the JObject - $result = new JObject; - // make view name safe (just incase) - $view = self::safeString($view); - if (self::checkString($views)) - { - $views = self::safeString($views); - } - // get all actions from component - $actions = JAccess::getActionsFromFile( - JPATH_ADMINISTRATOR . '/components/com_' . $component . '/access.xml', - "/access/section[@name='component']/" - ); - // if non found then return empty JObject - if (empty($actions)) - { - return $result; - } - // get created by if not found - if (self::checkObject($record) && !isset($record->created_by) && isset($record->id)) - { - $record->created_by = self::getVar($view, $record->id, 'id', 'created_by', '=', $component); - } - // set actions only set in component settings - $componentActions = array('core.admin', 'core.manage', 'core.options', 'core.export'); - // check if we have a target - $checkTarget = false; - if ($target) - { - // convert to an array - if (self::checkString($target)) - { - $target = array($target); - } - // check if we are good to go - if (self::checkArray($target)) - { - $checkTarget = true; - } - } - // loop the actions and set the permissions - foreach ($actions as $action) - { - // check target action filter - if ($checkTarget && self::filterActions($view, $action->name, $target)) - { - continue; - } - // set to use component default - $fallback = true; - // reset permission per/action - $permission = false; - $catpermission = false; - // set area - $area = 'comp'; - // check if the record has an ID and the action is item related (not a component action) - if (self::checkObject($record) && isset($record->id) && $record->id > 0 && !in_array($action->name, $componentActions) && - (strpos($action->name, 'core.') !== false || strpos($action->name, $view . '.') !== false)) - { - // we are in item - $area = 'item'; - // The record has been set. Check the record permissions. - $permission = $user->authorise($action->name, 'com_' . $component . '.' . $view . '.' . (int) $record->id); - // if no permission found, check edit own - if (!$permission) - { - // With edit, if the created_by matches current user then dig deeper. - if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) - { - // the correct target - $coreCheck = (array) explode('.', $action->name); - // check that we have both local and global access - if ($user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component . '.' . $view . '.' . (int) $record->id) && - $user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component)) - { - // allow edit - $result->set($action->name, true); - // set not to use global default - // because we already validated it - $fallback = false; - } - else - { - // do not allow edit - $result->set($action->name, false); - $fallback = false; - } - } - } - elseif (self::checkString($views) && isset($record->catid) && $record->catid > 0) - { - // we are in item - $area = 'category'; - // set the core check - $coreCheck = explode('.', $action->name); - $core = $coreCheck[0]; - // make sure we use the core. action check for the categories - if (strpos($action->name, $view) !== false && strpos($action->name, 'core.') === false ) - { - $coreCheck[0] = 'core'; - $categoryCheck = implode('.', $coreCheck); - } - else - { - $categoryCheck = $action->name; - } - // The record has a category. Check the category permissions. - $catpermission = $user->authorise($categoryCheck, 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid); - if (!$catpermission && !is_null($catpermission)) - { - // With edit, if the created_by matches current user then dig deeper. - if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) - { - // check that we have both local and global access - if ($user->authorise('core.edit.own', 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid) && - $user->authorise($core . '.edit.own', 'com_' . $component)) - { - // allow edit - $result->set($action->name, true); - // set not to use global default - // because we already validated it - $fallback = false; - } - else - { - // do not allow edit - $result->set($action->name, false); - $fallback = false; - } - } - } - } - } - // if allowed then fallback on component global settings - if ($fallback) - { - // if item/category blocks access then don't fall back on global - if ((($area === 'item') && !$permission) || (($area === 'category') && !$catpermission)) - { - // do not allow - $result->set($action->name, false); - } - // Finally remember the global settings have the final say. (even if item allow) - // The local item permissions can block, but it can't open and override of global permissions. - // Since items are created by users and global permissions is set by system admin. - else - { - $result->set($action->name, $user->authorise($action->name, 'com_' . $component)); - } - } - } - return $result; - } - - /** - * Filter the action permissions - * - * @param string $action The action to check - * @param array $targets The array of target actions - * - * @return boolean true if action should be filtered out - * - */ - protected static function filterActions(&$view, &$action, &$targets) - { - foreach ($targets as $target) - { - if (strpos($action, $view . '.' . $target) !== false || - strpos($action, 'core.' . $target) !== false) - { - return false; - break; - } - } - return true; - } - - /** - * Get any component's model - */ - public static function getModel($name, $path = JPATH_COMPONENT_ADMINISTRATOR, $Component = '###Component###', $config = array()) - { - // fix the name - $name = self::safeString($name); - // full path to models - $fullPathModels = $path . '/models'; - // load the model file - JModelLegacy::addIncludePath($fullPathModels, $Component . 'Model'); - // make sure the table path is loaded - if (!isset($config['table_path']) || !self::checkString($config['table_path'])) - { - // This is the JCB default path to tables in Joomla 3.x - $config['table_path'] = JPATH_ADMINISTRATOR . '/components/com_' . strtolower($Component) . '/tables'; - } - // get instance - $model = JModelLegacy::getInstance($name, $Component . 'Model', $config); - // if model not found (strange) - if ($model == false) - { - jimport('joomla.filesystem.file'); - // get file path - $filePath = $path . '/' . $name . '.php'; - $fullPathModel = $fullPathModels . '/' . $name . '.php'; - // check if it exists - if (File::exists($filePath)) - { - // get the file - require_once $filePath; - } - elseif (File::exists($fullPathModel)) - { - // get the file - require_once $fullPathModel; - } - // build class names - $modelClass = $Component . 'Model' . $name; - if (class_exists($modelClass)) - { - // initialize the model - return new $modelClass($config); - } - } - return $model; - } - - /** - * Add to asset Table - */ - public static function setAsset($id, $table, $inherit = true) - { - $parent = JTable::getInstance('Asset'); - $parent->loadByName('com_###component###'); - - $parentId = $parent->id; - $name = 'com_###component###.'.$table.'.'.$id; - $title = ''; - - $asset = JTable::getInstance('Asset'); - $asset->loadByName($name); - - // Check for an error. - $error = $asset->getError(); - - if ($error) - { - return false; - } - else - { - // Specify how a new or moved node asset is inserted into the tree. - if ($asset->parent_id != $parentId) - { - $asset->setLocation($parentId, 'last-child'); - } - - // Prepare the asset to be stored. - $asset->parent_id = $parentId; - $asset->name = $name; - $asset->title = $title; - // get the default asset rules - $rules = self::getDefaultAssetRules('com_###component###', $table, $inherit); - if ($rules instanceof JAccessRules) - { - $asset->rules = (string) $rules; - } - - if (!$asset->check() || !$asset->store()) - { - JFactory::getApplication()->enqueueMessage($asset->getError(), 'warning'); - return false; - } - else - { - // Create an asset_id or heal one that is corrupted. - $object = new stdClass(); - - // Must be a valid primary key value. - $object->id = $id; - $object->asset_id = (int) $asset->id; - - // Update their asset_id to link to the asset table. - return JFactory::getDbo()->updateObject('#__###component###_'.$table, $object, 'id'); - } - } - return false; - } - - /** - * Gets the default asset Rules for a component/view. - */ - protected static function getDefaultAssetRules($component, $view, $inherit = true) - { - // if new or inherited - $assetId = 0; - // Only get the actual item rules if not inheriting - if (!$inherit) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - // check that there is a value - if ($db->getNumRows()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - } - } - // get asset rules - $result = JAccess::getAssetRules($assetId); - if ($result instanceof JAccessRules) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($view !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - elseif ($inherit) - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count((array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules($_result); - // return filtered rules - return $rules; - } - } - return $result; - } - - /** - * xmlAppend - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement - * - * @return void - * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::append($xml, $node); - */ - public static function xmlAppend(&$xml, $node) - { - Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::append($xml, $node); - } - - /** - * xmlComment - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param string $comment The comment to inject - * - * @return void - * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::comment($xml, $comment); - */ - public static function xmlComment(&$xml, $comment) - { - Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::comment($xml, $comment); - } - - /** - * xmlAddAttributes - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param array $attributes The attributes to apply to the XML element - * - * @return null - * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::attributes($xml, $attributes); - */ - public static function xmlAddAttributes(&$xml, $attributes = array()) - { - Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::attributes($xml, $attributes); - } - - /** - * xmlAddOptions - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param array $options The options to apply to the XML element - * - * @return void - * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::options($xml, $options); - */ - public static function xmlAddOptions(&$xml, $options = array()) - { - Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::options($xml, $options); - } - - /** - * get the field object - * - * @param array $attributes The array of attributes - * @param string $default The default of the field - * @param array $options The options to apply to the XML element - * - * @return object - * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::field($attributes, $default, $options); - */ - public static function getFieldObject(&$attributes, $default = '', $options = null) - { - return Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::field($attributes, $default, $options); - } - - /** - * get the field xml - * - * @param array $attributes The array of attributes - * @param array $options The options to apply to the XML element - * - * @return object - * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::xml($attributes, $options); - */ - public static function getFieldXML(&$attributes, $options = null) - { - return Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::xml($attributes, $options); - } - - /** - * Render Bool Button - * - * @param array $args All the args for the button - * 0) name - * 1) additional (options class) // not used at this time - * 2) default - * 3) yes (name) - * 4) no (name) - * - * @return string The input html of the button - * - */ - public static function renderBoolButton() - { - $args = func_get_args(); - // check if there is additional button class - $additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time - // button attributes - $buttonAttributes = array( - 'type' => 'radio', - 'name' => isset($args[0]) ? self::htmlEscape($args[0]) : 'bool_button', - 'label' => isset($args[0]) ? self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool Button', // not seen anyway - 'class' => 'btn-group', - 'filter' => 'INT', - 'default' => isset($args[2]) ? (int) $args[2] : 0); - // set the button options - $buttonOptions = array( - '1' => isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES', - '0' => isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO'); - // return the input - return self::getFieldObject($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input; - } - - /** - * Check if we are connected - * Thanks https://stackoverflow.com/a/4860432/1429677 - * - * @returns bool true on success - */ - public static function isConnected() - { - // If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right? - $connected = @fsockopen("www.example.com", 80); - // website, port (try 80 or 443) - if ($connected) - { - //action when connected - $is_conn = true; - fclose($connected); - } - else - { - //action in connection failure - $is_conn = false; - } - return $is_conn; - } - - // typo sorry! - public static function sorten($string, $length = 40, $addTip = true) - { - return self::shorten($string, $length, $addTip); - }###HELPER_LICENSE_LOCK######GET_CRYPT_KEY### -} diff --git a/admin/compiler/joomla_3/JCB_Helper_site.php b/admin/compiler/joomla_3/JCB_Helper_site.php deleted file mode 100644 index 2d37461ba..000000000 --- a/admin/compiler/joomla_3/JCB_Helper_site.php +++ /dev/null @@ -1,686 +0,0 @@ - - * @github Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); -?> -###BOM### - -// No direct access to this file -defined('_JEXEC') or die('Restricted access');###SITE_POWER_HELPER### - -###SITE_HELPER_CLASS_HEADER### - -/** - * ###Component### component helper - */ -abstract class ###Component###Helper -{ - /** - * Adding the utilities trait to this class - * - * @deprecated 4.0 - Check the trait methods for details, a legacy implementation - */ - use Utilities; - - /** - * get the Component Code Name - */ - public static $ComponentCodeName = '###component###'; - - /** - * Composer Switch - * - * @var array - */ - protected static $composer = array();###SITE_GLOBAL_EVENT_HELPER######SITE_CUSTOM_HELPER_SCRIPT######BOTH_CUSTOM_HELPER_SCRIPT### - - /** - * Load the Composer Vendors - */ - public static function composerAutoload($target) - { - // insure we load the composer vendor only once - if (!isset(self::$composer[$target])) - { - // get the function name - $functionName = self::safeString('compose' . $target); - // check if method exist - if (method_exists(__CLASS__, $functionName)) - { - return self::{$functionName}(); - } - return false; - } - return self::$composer[$target]; - } - - /** - * Load the Component xml manifest. - */ - public static function manifest() - { - $manifestUrl = JPATH_ADMINISTRATOR."/components/com_###component###/###component###.xml"; - return simplexml_load_file($manifestUrl); - } - - /** - * Joomla version object - */ - protected static $JVersion; - - /** - * set/get Joomla version - */ - public static function jVersion() - { - // check if set - if (!self::checkObject(self::$JVersion)) - { - self::$JVersion = new JVersion(); - } - return self::$JVersion; - } - - /** - * Load the Contributors details. - */ - public static function getContributors() - { - // get params - $params = JComponentHelper::getParams('com_###component###'); - // start contributors array - $contributors = array(); - // get all Contributors (max 20) - $searchArray = range('0','20'); - foreach($searchArray as $nr) - { - if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 2 || $params->get("showContributor".$nr) == 3)) - { - // set link based of selected option - if($params->get("useContributor".$nr) == 1) - { - $link_front = ''; - $link_back = ''; - } - elseif($params->get("useContributor".$nr) == 2) - { - $link_front = ''; - $link_back = ''; - } - else - { - $link_front = ''; - $link_back = ''; - } - $contributors[$nr]['title'] = self::htmlEscape($params->get("titleContributor".$nr)); - $contributors[$nr]['name'] = $link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back; - } - } - return $contributors; - }###HELP_SITE### - - /** - * Get any component's model - */ - public static function getModel($name, $path = JPATH_COMPONENT_SITE, $Component = '###Component###', $config = array()) - { - // fix the name - $name = self::safeString($name); - // full path to models - $fullPathModels = $path . '/models'; - // load the model file - JModelLegacy::addIncludePath($fullPathModels, $Component . 'Model'); - // make sure the table path is loaded - if (!isset($config['table_path']) || !self::checkString($config['table_path'])) - { - // This is the JCB default path to tables in Joomla 3.x - $config['table_path'] = JPATH_ADMINISTRATOR . '/components/com_' . strtolower($Component) . '/tables'; - } - // get instance - $model = JModelLegacy::getInstance($name, $Component . 'Model', $config); - // if model not found (strange) - if ($model == false) - { - jimport('joomla.filesystem.file'); - // get file path - $filePath = $path . '/' . $name . '.php'; - $fullPathModel = $fullPathModels . '/' . $name . '.php'; - // check if it exists - if (File::exists($filePath)) - { - // get the file - require_once $filePath; - } - elseif (File::exists($fullPathModel)) - { - // get the file - require_once $fullPathModel; - } - // build class names - $modelClass = $Component . 'Model' . $name; - if (class_exists($modelClass)) - { - // initialize the model - return new $modelClass($config); - } - } - return $model; - } - - /** - * Add to asset Table - */ - public static function setAsset($id, $table, $inherit = true) - { - $parent = JTable::getInstance('Asset'); - $parent->loadByName('com_###component###'); - - $parentId = $parent->id; - $name = 'com_###component###.'.$table.'.'.$id; - $title = ''; - - $asset = JTable::getInstance('Asset'); - $asset->loadByName($name); - - // Check for an error. - $error = $asset->getError(); - - if ($error) - { - return false; - } - else - { - // Specify how a new or moved node asset is inserted into the tree. - if ($asset->parent_id != $parentId) - { - $asset->setLocation($parentId, 'last-child'); - } - - // Prepare the asset to be stored. - $asset->parent_id = $parentId; - $asset->name = $name; - $asset->title = $title; - // get the default asset rules - $rules = self::getDefaultAssetRules('com_###component###', $table, $inherit); - if ($rules instanceof JAccessRules) - { - $asset->rules = (string) $rules; - } - - if (!$asset->check() || !$asset->store()) - { - JFactory::getApplication()->enqueueMessage($asset->getError(), 'warning'); - return false; - } - else - { - // Create an asset_id or heal one that is corrupted. - $object = new stdClass(); - - // Must be a valid primary key value. - $object->id = $id; - $object->asset_id = (int) $asset->id; - - // Update their asset_id to link to the asset table. - return JFactory::getDbo()->updateObject('#__###component###_'.$table, $object, 'id'); - } - } - return false; - } - - /** - * Gets the default asset Rules for a component/view. - */ - protected static function getDefaultAssetRules($component, $view, $inherit = true) - { - // if new or inherited - $assetId = 0; - // Only get the actual item rules if not inheriting - if (!$inherit) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - // check that there is a value - if ($db->getNumRows()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - } - } - // get asset rules - $result = JAccess::getAssetRules($assetId); - if ($result instanceof JAccessRules) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($view !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - elseif ($inherit) - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count((array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules($_result); - // return filtered rules - return $rules; - } - } - return $result; - } - - /** - * xmlAppend - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement - * - * @return void - * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::append($xml, $node); - */ - public static function xmlAppend(&$xml, $node) - { - Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::append($xml, $node); - } - - /** - * xmlComment - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param string $comment The comment to inject - * - * @return void - * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::comment($xml, $comment); - */ - public static function xmlComment(&$xml, $comment) - { - Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::comment($xml, $comment); - } - - /** - * xmlAddAttributes - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param array $attributes The attributes to apply to the XML element - * - * @return void - * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::attributes($xml, $attributes); - */ - public static function xmlAddAttributes(&$xml, $attributes = array()) - { - Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::attributes($xml, $attributes); - } - - /** - * xmlAddOptions - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param array $options The options to apply to the XML element - * - * @return void - * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::options($xml, $options); - */ - public static function xmlAddOptions(&$xml, $options = array()) - { - Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::options($xml, $options); - } - - /** - * get the field object - * - * @param array $attributes The array of attributes - * @param string $default The default of the field - * @param array $options The options to apply to the XML element - * - * @return object - * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::field($attributes, $default, $options); - */ - public static function getFieldObject(&$attributes, $default = '', $options = null) - { - return Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::field($attributes, $default, $options); - } - - /** - * get the field xml - * - * @param array $attributes The array of attributes - * @param array $options The options to apply to the XML element - * - * @return object - * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::xml($attributes, $options); - */ - public static function getFieldXML(&$attributes, $options = null) - { - return Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::xml($attributes, $options); - } - - /** - * Render Bool Button - * - * @param array $args All the args for the button - * 0) name - * 1) additional (options class) // not used at this time - * 2) default - * 3) yes (name) - * 4) no (name) - * - * @return string The input html of the button - * - */ - public static function renderBoolButton() - { - $args = func_get_args(); - // check if there is additional button class - $additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time - // button attributes - $buttonAttributes = array( - 'type' => 'radio', - 'name' => isset($args[0]) ? self::htmlEscape($args[0]) : 'bool_button', - 'label' => isset($args[0]) ? self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool Button', // not seen anyway - 'class' => 'btn-group', - 'filter' => 'INT', - 'default' => isset($args[2]) ? (int) $args[2] : 0); - // set the button options - $buttonOptions = array( - '1' => isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES', - '0' => isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO'); - // return the input - return self::getFieldObject($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input; - }###HELPER_UIKIT######HELPER_CREATEUSER### - - public static function isPublished($id,$type) - { - if ($type == 'raw') - { - $type = 'item'; - } - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $query->select(array('a.published')); - $query->from('#__###component###_'.$type.' AS a'); - $query->where('a.id = '. (int) $id); - $query->where('a.published = 1'); - $db->setQuery($query); - $db->execute(); - $found = $db->getNumRows(); - if($found) - { - return true; - } - return false; - } - - public static function getGroupName($id) - { - $db = JFactory::getDBO(); - $query = $db->getQuery(true); - $query->select(array('a.title')); - $query->from('#__usergroups AS a'); - $query->where('a.id = '. (int) $id); - $db->setQuery($query); - $db->execute(); - $found = $db->getNumRows(); - if($found) - { - return $db->loadResult(); - } - return $id; - } - - /** - * Get the action permissions - * - * @param string $view The related view name - * @param int $record The item to act upon - * @param string $views The related list view name - * @param mixed $target Only get this permission (like edit, create, delete) - * @param string $component The target component - * @param object $user The user whose permissions we are loading - * - * @return object The JObject of permission/authorised actions - * - */ - public static function getActions($view, &$record = null, $views = null, $target = null, $component = '###component###', $user = 'null') - { - // load the user if not given - if (!self::checkObject($user)) - { - // get the user object - $user = JFactory::getUser(); - } - // load the JObject - $result = new JObject; - // make view name safe (just incase) - $view = self::safeString($view); - if (self::checkString($views)) - { - $views = self::safeString($views); - } - // get all actions from component - $actions = JAccess::getActionsFromFile( - JPATH_ADMINISTRATOR . '/components/com_' . $component . '/access.xml', - "/access/section[@name='component']/" - ); - // if non found then return empty JObject - if (empty($actions)) - { - return $result; - } - // get created by if not found - if (self::checkObject($record) && !isset($record->created_by) && isset($record->id)) - { - $record->created_by = self::getVar($view, $record->id, 'id', 'created_by', '=', $component); - } - // set actions only set in component settings - $componentActions = array('core.admin', 'core.manage', 'core.options', 'core.export'); - // check if we have a target - $checkTarget = false; - if ($target) - { - // convert to an array - if (self::checkString($target)) - { - $target = array($target); - } - // check if we are good to go - if (self::checkArray($target)) - { - $checkTarget = true; - } - } - // loop the actions and set the permissions - foreach ($actions as $action) - { - // check target action filter - if ($checkTarget && self::filterActions($view, $action->name, $target)) - { - continue; - } - // set to use component default - $fallback = true; - // reset permission per/action - $permission = false; - $catpermission = false; - // set area - $area = 'comp'; - // check if the record has an ID and the action is item related (not a component action) - if (self::checkObject($record) && isset($record->id) && $record->id > 0 && !in_array($action->name, $componentActions) && - (strpos($action->name, 'core.') !== false || strpos($action->name, $view . '.') !== false)) - { - // we are in item - $area = 'item'; - // The record has been set. Check the record permissions. - $permission = $user->authorise($action->name, 'com_' . $component . '.' . $view . '.' . (int) $record->id); - // if no permission found, check edit own - if (!$permission) - { - // With edit, if the created_by matches current user then dig deeper. - if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) - { - // the correct target - $coreCheck = (array) explode('.', $action->name); - // check that we have both local and global access - if ($user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component . '.' . $view . '.' . (int) $record->id) && - $user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component)) - { - // allow edit - $result->set($action->name, true); - // set not to use global default - // because we already validated it - $fallback = false; - } - else - { - // do not allow edit - $result->set($action->name, false); - $fallback = false; - } - } - } - elseif (self::checkString($views) && isset($record->catid) && $record->catid > 0) - { - // we are in item - $area = 'category'; - // set the core check - $coreCheck = explode('.', $action->name); - $core = $coreCheck[0]; - // make sure we use the core. action check for the categories - if (strpos($action->name, $view) !== false && strpos($action->name, 'core.') === false ) - { - $coreCheck[0] = 'core'; - $categoryCheck = implode('.', $coreCheck); - } - else - { - $categoryCheck = $action->name; - } - // The record has a category. Check the category permissions. - $catpermission = $user->authorise($categoryCheck, 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid); - if (!$catpermission && !is_null($catpermission)) - { - // With edit, if the created_by matches current user then dig deeper. - if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) - { - // check that we have both local and global access - if ($user->authorise('core.edit.own', 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid) && - $user->authorise($core . '.edit.own', 'com_' . $component)) - { - // allow edit - $result->set($action->name, true); - // set not to use global default - // because we already validated it - $fallback = false; - } - else - { - // do not allow edit - $result->set($action->name, false); - $fallback = false; - } - } - } - } - } - // if allowed then fallback on component global settings - if ($fallback) - { - // if item/category blocks access then don't fall back on global - if ((($area === 'item') && !$permission) || (($area === 'category') && !$catpermission)) - { - // do not allow - $result->set($action->name, false); - } - // Finally remember the global settings have the final say. (even if item allow) - // The local item permissions can block, but it can't open and override of global permissions. - // Since items are created by users and global permissions is set by system admin. - else - { - $result->set($action->name, $user->authorise($action->name, 'com_' . $component)); - } - } - } - return $result; - } - - /** - * Filter the action permissions - * - * @param string $action The action to check - * @param array $targets The array of target actions - * - * @return boolean true if action should be filtered out - * - */ - protected static function filterActions(&$view, &$action, &$targets) - { - foreach ($targets as $target) - { - if (strpos($action, $view . '.' . $target) !== false || - strpos($action, 'core.' . $target) !== false) - { - return false; - break; - } - } - return true; - } - - /** - * Check if we are connected - * Thanks https://stackoverflow.com/a/4860432/1429677 - * - * @returns bool true on success - */ - public static function isConnected() - { - // If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right? - $connected = @fsockopen("www.example.com", 80); - // website, port (try 80 or 443) - if ($connected) - { - //action when connected - $is_conn = true; - fclose($connected); - } - else - { - //action in connection failure - $is_conn = false; - } - return $is_conn; - } - - // typo sorry! - public static function sorten($string, $length = 40, $addTip = true) - { - return self::shorten($string, $length, $addTip); - }###HELPER_SITE_LICENSE_LOCK######GET_CRYPT_KEY### -} diff --git a/admin/compiler/joomla_3/JFormFieldCheckboxes.php b/admin/compiler/joomla_3/JFormFieldCheckboxes.php index d5a12f4ba..f852886b6 100644 --- a/admin/compiler/joomla_3/JFormFieldCheckboxes.php +++ b/admin/compiler/joomla_3/JFormFieldCheckboxes.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,6 +17,10 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + // import the list field type jimport('joomla.form.helper'); JFormHelper::loadFieldClass('checkboxes'); @@ -29,14 +33,14 @@ class ###JPREFIX###FormField###Type### extends JFormFieldCheckboxes /** * The ###type### field type. * - * @var string + * @var string */ public $type = '###type###'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. */ protected function getOptions() { diff --git a/admin/compiler/joomla_3/JFormFieldCustom.php b/admin/compiler/joomla_3/JFormFieldCustom.php index ee8b72e07..307bc608a 100644 --- a/admin/compiler/joomla_3/JFormFieldCustom.php +++ b/admin/compiler/joomla_3/JFormFieldCustom.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,7 +17,7 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); -###JFORM_TYPE_HEADER### +###FORM_CUSTOM_FIELD_HEADER### /** * ###Type### Form Field class for the ###Component### component @@ -27,7 +27,7 @@ class ###JPREFIX###FormField###Type### extends JFormField###JFORM_EXTENDS### /** * The ###type### field type. * - * @var string + * @var string */ - public $type = '###type###';###JFORM_TYPE_PHP### + public $type = '###type###';###FORM_CUSTOM_FIELD_PHP### } diff --git a/admin/compiler/joomla_3/JFormFieldList.php b/admin/compiler/joomla_3/JFormFieldList.php index 5a56cd132..504167838 100644 --- a/admin/compiler/joomla_3/JFormFieldList.php +++ b/admin/compiler/joomla_3/JFormFieldList.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,6 +17,10 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + // import the list field type jimport('joomla.form.helper'); JFormHelper::loadFieldClass('list'); @@ -29,14 +33,14 @@ class ###JPREFIX###FormField###Type### extends JFormFieldList /** * The ###type### field type. * - * @var string + * @var string */ public $type = '###type###';###ADD_BUTTON### /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. */ protected function getOptions() { diff --git a/admin/compiler/joomla_3/JFormFieldRadio.php b/admin/compiler/joomla_3/JFormFieldRadio.php index ac9412514..75ec4e5c5 100644 --- a/admin/compiler/joomla_3/JFormFieldRadio.php +++ b/admin/compiler/joomla_3/JFormFieldRadio.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,6 +17,10 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + // import the list field type jimport('joomla.form.helper'); JFormHelper::loadFieldClass('radio'); @@ -29,14 +33,14 @@ class ###JPREFIX###FormField###Type### extends JFormFieldRadio /** * The ###type### field type. * - * @var string + * @var string */ public $type = '###type###'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. */ protected function getOptions() { diff --git a/admin/compiler/joomla_3/JFormFieldUser.php b/admin/compiler/joomla_3/JFormFieldUser.php index 4a9966db1..85ed69077 100644 --- a/admin/compiler/joomla_3/JFormFieldUser.php +++ b/admin/compiler/joomla_3/JFormFieldUser.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,6 +17,10 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + // import the list field type jimport('joomla.form.helper'); JFormHelper::loadFieldClass('user'); @@ -29,7 +33,7 @@ class ###JPREFIX###FormField###Type### extends JFormFieldUser /** * The ###type### field type. * - * @var string + * @var string */ public $type = '###type###'; diff --git a/admin/compiler/joomla_3/JFormRule.php b/admin/compiler/joomla_3/JFormRule.php index 830ed92a0..34b02fefa 100644 --- a/admin/compiler/joomla_3/JFormRule.php +++ b/admin/compiler/joomla_3/JFormRule.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,9 +17,12 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('JPATH_PLATFORM') or die; +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; use Joomla\CMS\Form\Form; use Joomla\CMS\Form\FormRule; use Joomla\Registry\Registry; +use Joomla\CMS\HTML\HTMLHelper as Html; /** * Form Rule (###Name###) class for the Joomla Platform. diff --git a/admin/compiler/joomla_3/ListModel.php b/admin/compiler/joomla_3/ListModel.php index 2d45037ab..f2d12e963 100644 --- a/admin/compiler/joomla_3/ListModel.php +++ b/admin/compiler/joomla_3/ListModel.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -24,10 +24,10 @@ defined('_JEXEC') or die('Restricted access'); */ class ###Component###Model###Views### extends ListModel { - public function __construct($config = array()) + public function __construct($config = []) { if (empty($config['filter_fields'])) - { + { $config['filter_fields'] = array( ###FILTER_FIELDS### ); @@ -49,7 +49,7 @@ class ###Component###Model###Views### extends ListModel */ protected function populateState($ordering = null, $direction = null) { - $app = JFactory::getApplication(); + $app = Factory::getApplication(); // Adjust the context to support modal layouts. if ($layout = $app->input->get('layout')) @@ -60,7 +60,7 @@ class ###Component###Model###Views### extends ListModel // List state information. parent::populateState($ordering, $direction); } - + /** * Method to get an array of data items. * @@ -70,21 +70,21 @@ class ###Component###Model###Views### extends ListModel {###LICENSE_LOCKED_CHECK######CHECKINCALL### // load parent items $items = parent::getItems();###GET_ITEMS_METHOD_STRING_FIX######SELECTIONTRANSLATIONFIX######GET_ITEMS_METHOD_AFTER_ALL### - + // return items return $items; }###SELECTIONTRANSLATIONFIXFUNC### - + /** * Method to build an SQL query to load the list data. * - * @return string An SQL query + * @return string An SQL query */ protected function getListQuery() {###LICENSE_LOCKED_CHECK### ###LISTQUERY### }###MODELEXPORTMETHOD######LICENSE_LOCKED_SET_BOOL### - + /** * Method to get a store id based on model configuration state. * diff --git a/admin/compiler/joomla_3/ListModelAjax.php b/admin/compiler/joomla_3/ListModelAjax.php index cf9cb916f..18d5f23b7 100644 --- a/admin/compiler/joomla_3/ListModelAjax.php +++ b/admin/compiler/joomla_3/ListModelAjax.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -25,12 +25,12 @@ defined('_JEXEC') or die('Restricted access'); class ###Component###ModelAjax extends ListModel { protected $app_params; - - public function __construct() - { - parent::__construct(); + + public function __construct() + { + parent::__construct(); // get params - $this->app_params = JComponentHelper::getParams('com_###component###'); - + $this->app_params = ComponentHelper::getParams('com_###component###'); + }###AJAX_MODEL_METHODS### } diff --git a/admin/compiler/joomla_3/ListModelAjaxSite.php b/admin/compiler/joomla_3/ListModelAjaxSite.php index 2aacc4948..d02c9bfca 100644 --- a/admin/compiler/joomla_3/ListModelAjaxSite.php +++ b/admin/compiler/joomla_3/ListModelAjaxSite.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -30,7 +30,7 @@ class ###Component###ModelAjax extends ListModel { parent::__construct(); // get params - $this->app_params = JComponentHelper::getParams('com_###component###'); + $this->app_params = ComponentHelper::getParams('com_###component###'); }###AJAX_SITE_MODEL_METHODS### } diff --git a/admin/compiler/joomla_3/ListModelDASH.php b/admin/compiler/joomla_3/ListModelDASH.php index ad8357abb..25f57f5eb 100644 --- a/admin/compiler/joomla_3/ListModelDASH.php +++ b/admin/compiler/joomla_3/ListModelDASH.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -27,9 +27,9 @@ class ###Component###Model###Component### extends ListModel public function getIcons() { // load user for access menus - $user = JFactory::getUser(); + $user = Factory::getUser(); // reset icon array - $icons = array(); + $icons = []; // view groups array $viewGroups = array( 'main' => array(###DASHBOARDICONS###) @@ -38,7 +38,7 @@ class ###Component###Model###Component### extends ListModel foreach($viewGroups as $group => $views) { $i = 0; - if (###Component###Helper::checkArray($views)) + if (Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($views)) { foreach($views as $view) { @@ -50,11 +50,11 @@ class ###Component###Model###Component### extends ListModel if (count($dwd) == 3) { list($type, $name, $url) = $dwd; - $viewName = $name; - $alt = $name; - $url = $url; - $image = $name . '.' . $type; - $name = 'COM_###COMPONENT###_DASHBOARD_' . ###Component###Helper::safeString($name,'U'); + $viewName = $name; + $alt = $name; + $url = $url; + $image = $name . '.' . $type; + $name = 'COM_###COMPONENT###_DASHBOARD_' . Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($name,'U'); } } // internal views @@ -76,11 +76,11 @@ class ###Component###Model###Component### extends ListModel switch($action) { case 'add': - $url = 'index.php?option=com_###component###&view=' . $name . '&layout=edit'; - $image = $name . '_' . $action. '.' . $type; - $alt = $name . ' ' . $action; - $name = 'COM_###COMPONENT###_DASHBOARD_'.###Component###Helper::safeString($name,'U').'_ADD'; - $add = true; + $url = 'index.php?option=com_###component###&view=' . $name . '&layout=edit'; + $image = $name . '_' . $action. '.' . $type; + $alt = $name . ' ' . $action; + $name = 'COM_###COMPONENT###_DASHBOARD_'.Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($name,'U').'_ADD'; + $add = true; break; default: // check for new convention (more stable) @@ -93,34 +93,34 @@ class ###Component###Model###Component### extends ListModel { $extension = 'com_###component###.' . $name; } - $url = 'index.php?option=com_categories&view=categories&extension=' . $extension; - $image = $name . '_' . $action . '.' . $type; - $alt = $viewName . ' ' . $action; - $name = 'COM_###COMPONENT###_DASHBOARD_' . ###Component###Helper::safeString($name,'U') . '_' . ###Component###Helper::safeString($action,'U'); + $url = 'index.php?option=com_categories&view=categories&extension=' . $extension; + $image = $name . '_' . $action . '.' . $type; + $alt = $viewName . ' ' . $action; + $name = 'COM_###COMPONENT###_DASHBOARD_' . Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($name,'U') . '_' . Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($action,'U'); break; } } else { - $viewName = $name; - $alt = $name; - $url = 'index.php?option=com_###component###&view=' . $name; - $image = $name . '.' . $type; - $name = 'COM_###COMPONENT###_DASHBOARD_' . ###Component###Helper::safeString($name,'U'); - $hover = false; + $viewName = $name; + $alt = $name; + $url = 'index.php?option=com_###component###&view=' . $name; + $image = $name . '.' . $type; + $name = 'COM_###COMPONENT###_DASHBOARD_' . Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($name,'U'); + $hover = false; } } else { - $viewName = $view; - $alt = $view; - $url = 'index.php?option=com_###component###&view=' . $view; - $image = $view . '.png'; - $name = ucwords($view).'

'; - $hover = false; + $viewName = $view; + $alt = $view; + $url = 'index.php?option=com_###component###&view=' . $view; + $image = $view . '.png'; + $name = ucwords($view).'

'; + $hover = false; } // first make sure the view access is set - if (###Component###Helper::checkArray($viewAccess)) + if (Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($viewAccess)) { // setup some defaults $dashboard_add = false; @@ -128,11 +128,11 @@ class ###Component###Model###Component### extends ListModel $accessTo = ''; $accessAdd = ''; // access checking start - $accessCreate = (isset($viewAccess[$viewName.'.create'])) ? ###Component###Helper::checkString($viewAccess[$viewName.'.create']):false; - $accessAccess = (isset($viewAccess[$viewName.'.access'])) ? ###Component###Helper::checkString($viewAccess[$viewName.'.access']):false; + $accessCreate = (isset($viewAccess[$viewName.'.create'])) ? Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($viewAccess[$viewName.'.create']):false; + $accessAccess = (isset($viewAccess[$viewName.'.access'])) ? Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($viewAccess[$viewName.'.access']):false; // set main controllers - $accessDashboard_add = (isset($viewAccess[$viewName.'.dashboard_add'])) ? ###Component###Helper::checkString($viewAccess[$viewName.'.dashboard_add']):false; - $accessDashboard_list = (isset($viewAccess[$viewName.'.dashboard_list'])) ? ###Component###Helper::checkString($viewAccess[$viewName.'.dashboard_list']):false; + $accessDashboard_add = (isset($viewAccess[$viewName.'.dashboard_add'])) ? Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($viewAccess[$viewName.'.dashboard_add']):false; + $accessDashboard_list = (isset($viewAccess[$viewName.'.dashboard_list'])) ? Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($viewAccess[$viewName.'.dashboard_list']):false; // check for adding access if ($add && $accessCreate) { @@ -150,64 +150,64 @@ class ###Component###Model###Component### extends ListModel // set main access controllers if ($accessDashboard_add) { - $dashboard_add = $user->authorise($viewAccess[$viewName.'.dashboard_add'], 'com_###component###'); + $dashboard_add = $user->authorise($viewAccess[$viewName.'.dashboard_add'], 'com_###component###'); } if ($accessDashboard_list) { $dashboard_list = $user->authorise($viewAccess[$viewName.'.dashboard_list'], 'com_###component###'); } - if (###Component###Helper::checkString($accessAdd) && ###Component###Helper::checkString($accessTo)) + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($accessAdd) && Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($accessTo)) { // check access if($user->authorise($accessAdd, 'com_###component###') && $user->authorise($accessTo, 'com_###component###') && $dashboard_add) { - $icons[$group][$i] = new StdClass; - $icons[$group][$i]->url = $url; - $icons[$group][$i]->name = $name; - $icons[$group][$i]->image = $image; - $icons[$group][$i]->alt = $alt; + $icons[$group][$i] = new StdClass; + $icons[$group][$i]->url = $url; + $icons[$group][$i]->name = $name; + $icons[$group][$i]->image = $image; + $icons[$group][$i]->alt = $alt; } } - elseif (###Component###Helper::checkString($accessTo)) + elseif (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($accessTo)) { // check access if($user->authorise($accessTo, 'com_###component###') && $dashboard_list) { - $icons[$group][$i] = new StdClass; - $icons[$group][$i]->url = $url; - $icons[$group][$i]->name = $name; - $icons[$group][$i]->image = $image; - $icons[$group][$i]->alt = $alt; + $icons[$group][$i] = new StdClass; + $icons[$group][$i]->url = $url; + $icons[$group][$i]->name = $name; + $icons[$group][$i]->image = $image; + $icons[$group][$i]->alt = $alt; } } - elseif (###Component###Helper::checkString($accessAdd)) + elseif (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($accessAdd)) { // check access if($user->authorise($accessAdd, 'com_###component###') && $dashboard_add) { - $icons[$group][$i] = new StdClass; - $icons[$group][$i]->url = $url; - $icons[$group][$i]->name = $name; - $icons[$group][$i]->image = $image; - $icons[$group][$i]->alt = $alt; + $icons[$group][$i] = new StdClass; + $icons[$group][$i]->url = $url; + $icons[$group][$i]->name = $name; + $icons[$group][$i]->image = $image; + $icons[$group][$i]->alt = $alt; } } else { - $icons[$group][$i] = new StdClass; - $icons[$group][$i]->url = $url; - $icons[$group][$i]->name = $name; - $icons[$group][$i]->image = $image; - $icons[$group][$i]->alt = $alt; + $icons[$group][$i] = new StdClass; + $icons[$group][$i]->url = $url; + $icons[$group][$i]->name = $name; + $icons[$group][$i]->image = $image; + $icons[$group][$i]->alt = $alt; } } else { - $icons[$group][$i] = new StdClass; - $icons[$group][$i]->url = $url; - $icons[$group][$i]->name = $name; - $icons[$group][$i]->image = $image; - $icons[$group][$i]->alt = $alt; + $icons[$group][$i] = new StdClass; + $icons[$group][$i]->url = $url; + $icons[$group][$i]->name = $name; + $icons[$group][$i]->image = $image; + $icons[$group][$i]->alt = $alt; } $i++; } diff --git a/admin/compiler/joomla_3/ListModel_custom_admin.php b/admin/compiler/joomla_3/ListModel_custom_admin.php index d49fcec4a..fd561d58e 100644 --- a/admin/compiler/joomla_3/ListModel_custom_admin.php +++ b/admin/compiler/joomla_3/ListModel_custom_admin.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -46,15 +46,15 @@ class ###Component###Model###SViews### extends ListModel protected function getListQuery() { // Get the current user for authorisation checks - $this->user = JFactory::getUser(); + $this->user = Factory::getUser(); $this->userId = $this->user->get('id'); $this->guest = $this->user->get('guest'); $this->groups = $this->user->get('groups'); - $this->authorisedGroups = $this->user->getAuthorisedGroups(); + $this->authorisedGroups = $this->user->getAuthorisedGroups(); $this->levels = $this->user->getAuthorisedViewLevels(); - $this->app = JFactory::getApplication(); + $this->app = Factory::getApplication(); $this->input = $this->app->input; - $this->initSet = true; ###CUSTOM_ADMIN_GET_LIST_QUERY### + $this->initSet = true;###CUSTOM_ADMIN_GET_LIST_QUERY### } /** @@ -64,12 +64,12 @@ class ###Component###Model###SViews### extends ListModel */ public function getItems() { - $user = JFactory::getUser(); + $user = Factory::getUser(); // check if this user has permission to access items if (!$user->authorise('###sviews###.access', 'com_###component###')) { - $app = JFactory::getApplication(); - $app->enqueueMessage(JText::_('Not authorised!'), 'error'); + $app = Factory::getApplication(); + $app->enqueueMessage(Text::_('Not authorised!'), 'error'); // redirect away if not a correct (TODO for now we go to default view) $app->redirect('index.php?option=com_###component###'); return false; @@ -78,7 +78,7 @@ class ###Component###Model###SViews### extends ListModel $items = parent::getItems(); // Get the global params - $globalParams = JComponentHelper::getParams('com_###component###', true);###CUSTOM_ADMIN_GET_ITEMS######CUSTOM_ADMIN_AFTER_GET_ITEMS### + $globalParams = ComponentHelper::getParams('com_###component###', true);###CUSTOM_ADMIN_GET_ITEMS######CUSTOM_ADMIN_AFTER_GET_ITEMS### // return items return $items; diff --git a/admin/compiler/joomla_3/ListModel_site.php b/admin/compiler/joomla_3/ListModel_site.php index 441031541..4ccc2f36b 100644 --- a/admin/compiler/joomla_3/ListModel_site.php +++ b/admin/compiler/joomla_3/ListModel_site.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -46,13 +46,13 @@ class ###Component###Model###SViews### extends ListModel protected function getListQuery() { // Get the current user for authorisation checks - $this->user = JFactory::getUser(); + $this->user = Factory::getUser(); $this->userId = $this->user->get('id'); $this->guest = $this->user->get('guest'); $this->groups = $this->user->get('groups'); $this->authorisedGroups = $this->user->getAuthorisedGroups(); $this->levels = $this->user->getAuthorisedViewLevels(); - $this->app = JFactory::getApplication(); + $this->app = Factory::getApplication(); $this->input = $this->app->input; $this->initSet = true; ###SITE_GET_LIST_QUERY### } @@ -64,12 +64,12 @@ class ###Component###Model###SViews### extends ListModel */ public function getItems() { - $user = JFactory::getUser();###USER_PERMISSION_CHECK_ACCESS######LICENSE_LOCKED_CHECK######SITE_BEFORE_GET_ITEMS### + $user = Factory::getUser();###USER_PERMISSION_CHECK_ACCESS######LICENSE_LOCKED_CHECK######SITE_BEFORE_GET_ITEMS### // load parent items $items = parent::getItems(); // Get the global params - $globalParams = JComponentHelper::getParams('com_###component###', true);###SITE_GET_ITEMS######SITE_AFTER_GET_ITEMS### + $globalParams = ComponentHelper::getParams('com_###component###', true);###SITE_GET_ITEMS######SITE_AFTER_GET_ITEMS### // return items return $items; diff --git a/admin/compiler/joomla_3/Table.php b/admin/compiler/joomla_3/Table.php index fd286af4b..cacbbf67c 100644 --- a/admin/compiler/joomla_3/Table.php +++ b/admin/compiler/joomla_3/Table.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,10 +17,17 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; use Joomla\CMS\Table\Table; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; use Joomla\Registry\Registry; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Table\Observer\Tags as TableObserverTags; +use Joomla\CMS\Table\Observer\ContentHistory as TableObserverContenthistory; +use Joomla\CMS\Application\ApplicationHelper; /** * ###Views### Table class @@ -34,60 +41,60 @@ class ###Component###Table###View### extends Table * @since 3.3 */ protected $_jsonEncode = array('params', 'metadata'); - + /** * Constructor * * @param object Database connector object */ - function __construct(&$db) + function __construct(&$db) { parent::__construct('#__###component###_###view###', 'id', $db);###JTABLECONSTRUCTOR######LICENSE_LOCKED_CHECK### - } - + } + public function bind($array, $ignore = '') { - + if (isset($array['params']) && is_array($array['params'])) { - $registry = new JRegistry; + $registry = new Registry; $registry->loadArray($array['params']); $array['params'] = (string) $registry; } if (isset($array['metadata']) && is_array($array['metadata'])) { - $registry = new JRegistry; + $registry = new Registry; $registry->loadArray($array['metadata']); $array['metadata'] = (string) $registry; } - - // Bind the rules. + + // Bind the rules. if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); } return parent::bind($array, $ignore); } - + /** * Overload the store method for the ###View### table. * - * @param boolean Toggle whether null values should be updated. + * @param boolean Toggle whether null values should be updated. * @return boolean True on success, false on failure. * @since 1.6 */ public function store($updateNulls = false) { - $date = JFactory::getDate(); - $user = JFactory::getUser(); + $date = Factory::getDate(); + $user = Factory::getUser(); if ($this->id) { // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); + $this->modified = $date->toSql(); + $this->modified_by = $user->get('id'); } else { @@ -102,33 +109,38 @@ class ###Component###Table###View### extends Table $this->created_by = $user->get('id'); } } - + if (isset($this->alias)) { // Verify that the alias is unique - $table = JTable::getInstance('###view###', '###Component###Table'); + $table = Table::getInstance('###view###', '###Component###Table'); if ($table->load(array('alias' => $this->alias###JTABLEALIASCATEGORY###)) && ($table->id != $this->id || $this->id == 0)) { - $this->setError(JText::_('COM_###COMPONENT###_###VIEW###_ERROR_UNIQUE_ALIAS')); + $this->setError(Text::_('COM_###COMPONENT###_###VIEW###_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_###COMPONENT###_###VIEW###_ERROR_UNIQUE_ALIAS_TRASHED')); + } return false; } } - + if (isset($this->url)) { // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); + $this->url = PunycodeHelper::urlToPunycode($this->url); } if (isset($this->website)) { // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); + $this->website = PunycodeHelper::urlToPunycode($this->website); } return parent::store($updateNulls); } - + /** * Overloaded check method to ensure data integrity. * @@ -140,20 +152,20 @@ class ###Component###Table###View### extends Table { // Generate a valid alias $this->generateAlias(); - - $table = JTable::getInstance('###view###', '###component###Table'); + + $table = Table::getInstance('###view###', '###component###Table'); while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) { $this->alias = StringHelper::increment($this->alias, 'dash'); } } - + /* * Clean up keywords -- eliminate extra spaces between phrases * and cr (\r) and lf (\n) characters from string. * Only process if not empty. - */ + */ if (!empty($this->metakey)) { // Array of characters to remove. @@ -164,7 +176,7 @@ class ###Component###Table###View### extends Table // Create array using commas as delimiter. $keys = explode(',', $after_clean); - $clean_keys = array(); + $clean_keys = []; foreach ($keys as $key) { @@ -187,13 +199,13 @@ class ###Component###Table###View### extends Table $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); } - // If we don't have any access rules set at this point just use an empty JAccessRules class + // If we don't have any access rules set at this point just use an empty AccessRules class if (!$this->getRules()) { $rules = $this->getDefaultAssetValues('com_###component###.###view###.'.$this->id); $this->setRules($rules); } - + // Set ordering if ($this->published < 0) { @@ -209,12 +221,12 @@ class ###Component###Table###View### extends Table * * @param $string $component The component asset name to search for * - * @return JAccessRules The JAccessRules object for the asset + * @return AccessRules The AccessRules object for the asset */ protected function getDefaultAssetValues($component, $try = true) { // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); + $db = Factory::getDbo(); $query = $db->getQuery(true) ->select($db->quoteName('id')) ->from($db->quoteName('#__assets')) @@ -225,14 +237,14 @@ class ###Component###Table###View### extends Table { // asset already set so use saved rules $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. } // try again elseif ($try) { $try = explode('.',$component); $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) + if ($result instanceof AccessRules) { if (isset($try[1])) { @@ -249,7 +261,7 @@ class ###Component###Table###View### extends Table else { // clear the value since we inherit - $rule = array(); + $rule = []; } } // check if there are any view values remaining @@ -257,8 +269,8 @@ class ###Component###Table###View### extends Table { $_result = json_encode($_result); $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; $rules->mergeCollection($_result); return $rules; @@ -267,7 +279,7 @@ class ###Component###Table###View### extends Table return $result; } } - return JAccess::getAssetRules(0); + return AccessRules::getAssetRules(0); } /** @@ -275,8 +287,8 @@ class ###Component###Table###View### extends Table * The default name is in the form 'table_name.id' * where id is the value of the primary key of the table. * - * @return string - * @since 2.5 + * @return string + * @since 2.5 */ protected function _getAssetName() { @@ -287,8 +299,8 @@ class ###Component###Table###View### extends Table /** * Method to return the title to use for the asset table. * - * @return string - * @since 2.5 + * @return string + * @since 2.5 */ protected function _getAssetTitle() { @@ -302,12 +314,12 @@ class ###Component###Table###View### extends Table /** * Get the parent asset id for the record * - * @return int - * @since 2.5 + * @return int + * @since 2.5 */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) + protected function _getAssetParentId(?Table $table = null, $id = null) { - $asset = JTable::getInstance('Asset'); + $asset = Table::getInstance('Asset'); $asset->loadByName('com_###component###'); return $asset->id; diff --git a/admin/compiler/joomla_3/ajax.json.php b/admin/compiler/joomla_3/ajax.json.php index 6883172ef..54ca2b52a 100644 --- a/admin/compiler/joomla_3/ajax.json.php +++ b/admin/compiler/joomla_3/ajax.json.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,6 +17,9 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; +use Joomla\CMS\Session\Session; + /** * ###Component### Ajax Controller */ @@ -26,19 +29,19 @@ class ###Component###ControllerAjax extends JControllerLegacy { parent::__construct($config); // make sure all json stuff are set - JFactory::getDocument()->setMimeEncoding( 'application/json' ); - JFactory::getApplication()->setHeader('Content-Disposition','attachment;filename="getajax.json"'); - JFactory::getApplication()->setHeader("Access-Control-Allow-Origin", "*"); + Factory::getDocument()->setMimeEncoding( 'application/json' ); + Factory::getApplication()->setHeader('Content-Disposition','attachment;filename="getajax.json"'); + Factory::getApplication()->setHeader("Access-Control-Allow-Origin", "*"); // load the tasks $this->registerTask('fieldRequired', 'ajax'); } public function ajax() { - $user = JFactory::getUser(); - $jinput = JFactory::getApplication()->input; + $user = Factory::getUser(); + $jinput = Factory::getApplication()->input; // Check Token! - $token = JSession::getFormToken(); + $token = Session::getFormToken(); $call_token = $jinput->get('token', 0, 'ALNUM'); if($user->id != 0 && $token == $call_token) { @@ -50,8 +53,8 @@ class ###Component###ControllerAjax extends JControllerLegacy $name = $jinput->get('name', NULL, 'WORD'); $form = $jinput->get('form', NULL, 'WORD'); $status = $jinput->get('status', NULL, 'INT'); - - if (###Component###Helper::checkString($name) && ###Component###Helper::checkString($form)) + + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($name) && Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($form)) { $result = $this->getModel('ajax')->setFieldRequired($name,$form,$status); } diff --git a/admin/compiler/joomla_3/ajax.php b/admin/compiler/joomla_3/ajax.php index 198a571f4..9500de486 100644 --- a/admin/compiler/joomla_3/ajax.php +++ b/admin/compiler/joomla_3/ajax.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,27 +17,32 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\Component\ComponentHelper; + /** * ###Component### Ajax Model */ -class ###Component###ModelAjax extends JModelList +class ###Component###ModelAjax extends ListModel { protected $app_params; public function __construct() - { - parent::__construct(); + { + parent::__construct(); // get params - $this->app_params = JComponentHelper::getParams('com_###component###'); + $this->app_params = ComponentHelper::getParams('com_###component###'); } public function setFieldRequired($name,$form,$status) { // get the session - $session = JFactory::getSession(); + $session = Factory::getSession(); // get this forms set fields $fields = $session->get($form.'_requiredFieldFix'); - if(###Component###Helper::checkArray($fields)) + if(Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($fields)) { if ($status == 1) { @@ -45,7 +50,7 @@ class ###Component###ModelAjax extends JModelList $fields = array_unique($fields); } else - { + { // remove from array if(($key = array_search($name, $fields)) !== false) { @@ -61,7 +66,7 @@ class ###Component###ModelAjax extends JModelList } } // load the remaining values to session - if(###Component###Helper::checkArray($fields)) + if(Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($fields)) { $session->set($form.'_requiredFieldFix', $fields); } diff --git a/admin/compiler/joomla_3/batch_.php b/admin/compiler/joomla_3/batch_.php index 0d8a36c64..ef1abac7f 100644 --- a/admin/compiler/joomla_3/batch_.php +++ b/admin/compiler/joomla_3/batch_.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -30,7 +30,7 @@ abstract class JHtmlBatch_ * @var array * @since 3.0 */ - protected static $ListSelection = array(); + protected static $ListSelection = []; /** * Render the batch selection options. diff --git a/admin/compiler/joomla_3/batchselection.php b/admin/compiler/joomla_3/batchselection.php index 455979edf..d8199d7bb 100644 --- a/admin/compiler/joomla_3/batchselection.php +++ b/admin/compiler/joomla_3/batchselection.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,6 +17,7 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('JPATH_BASE') or die; +use Joomla\CMS\Language\Text; JHtmlBehavior::core(); $divWrapper = range(1,120,2); $counter = 0; @@ -24,8 +25,8 @@ $counter = 0; ListSelection) : ?>

ListSelection as $ListSelection) : ?> -
-
+
+
-
+
- +
- - -
+ + +
\ No newline at end of file diff --git a/admin/compiler/joomla_3/component_admin.php b/admin/compiler/joomla_3/component_admin.php index 43ddf1f01..cc77f250d 100644 --- a/admin/compiler/joomla_3/component_admin.php +++ b/admin/compiler/joomla_3/component_admin.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -20,25 +20,24 @@ defined('_JEXEC') or die('Restricted access');###ADMIN_POWER_HELPER### ###ADMIN_COMPONENT_HEADER### // Access check. -if (!JFactory::getUser()->authorise('core.manage', 'com_###component###')) +if (!Factory::getUser()->authorise('core.manage', 'com_###component###')) { - throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); -}; + throw new NotAllowed(Text::_('JERROR_ALERTNOAUTHOR'), 403); +} // Add CSS file for all pages -$document = JFactory::getDocument(); -$document->addStyleSheet('components/com_###component###/assets/css/admin.css'); -$document->addScript('components/com_###component###/assets/js/admin.js'); +Html::_('stylesheet', 'components/com_###component###/assets/css/admin.css', ['version' => 'auto']); +Html::_('script', 'components/com_###component###/assets/js/admin.js', ['version' => 'auto']); // require helper files JLoader::register('###Component###Helper', __DIR__ . '/helpers/###component###.php');###HELPER_EMAIL### JLoader::register('JHtmlBatch_', __DIR__ . '/helpers/html/batch_.php');###LICENSE_LOCKED_INT######ADMIN_GLOBAL_EVENT### // Get an instance of the controller prefixed by ###Component### -$controller = JControllerLegacy::getInstance('###Component###'); +$controller = BaseController::getInstance('###Component###'); // Perform the Request task -$controller->execute(JFactory::getApplication()->input->get('task')); +$controller->execute(Factory::getApplication()->input->get('task')); // Redirect if set by the controller $controller->redirect(); diff --git a/admin/compiler/joomla_3/component_site.php b/admin/compiler/joomla_3/component_site.php index 88d3a5de8..cd21c9a13 100644 --- a/admin/compiler/joomla_3/component_site.php +++ b/admin/compiler/joomla_3/component_site.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -20,19 +20,18 @@ defined('_JEXEC') or die('Restricted access');###ADMIN_POWER_HELPER### ###SITE_COMPONENT_HEADER### // Set the component css/js -$document = JFactory::getDocument(); -$document->addStyleSheet('components/com_###component###/assets/css/site.css'); -$document->addScript('components/com_###component###/assets/js/site.js'); +Html::_('stylesheet', 'components/com_###component###/assets/css/site.css', ['version' => 'auto']); +Html::_('script', 'components/com_###component###/assets/js/site.js', ['version' => 'auto']); // Require helper files JLoader::register('###Component###Helper', __DIR__ . '/helpers/###component###.php');###HELPER_EMAIL### JLoader::register('###Component###HelperRoute', __DIR__ . '/helpers/route.php');###LICENSE_LOCKED_INT######SITE_GLOBAL_EVENT### // Get an instance of the controller prefixed by ###Component### -$controller = JControllerLegacy::getInstance('###Component###'); +$controller = BaseController::getInstance('###Component###'); // Perform the request task -$controller->execute(JFactory::getApplication()->input->get('task')); +$controller->execute(Factory::getApplication()->input->get('task')); // Redirect if set by the controller $controller->redirect(); diff --git a/admin/compiler/joomla_3/dashboard.css b/admin/compiler/joomla_3/dashboard.css index 65aa4e8b2..6502707ff 100644 --- a/admin/compiler/joomla_3/dashboard.css +++ b/admin/compiler/joomla_3/dashboard.css @@ -3,153 +3,153 @@ /* CSS Document */ .dashboard-container { - margin-left: 10px; - margin-top: 10px; - width: 100%; + margin-left: 10px; + margin-top: 10px; + width: 100%; } .dashboard-container [class*="span"] { - display: block; - float: none; - margin-left: 0; - width: auto; + display: block; + float: none; + margin-left: 0; + width: auto; } .dashboard-container:before, .dashboard-container:after { - content: ""; - display: table; + content: ""; + display: table; } .dashboard-container:after { - clear: both; + clear: both; } .dashboard-container [class*="span"] { - box-sizing: border-box; - display: block; - float: left; - min-height: 145px; - min-width: 96px; - width: 100%; + box-sizing: border-box; + display: block; + float: left; + min-height: 145px; + min-width: 96px; + width: 100%; } .dashboard-container [class*="span"]:first-child { - margin-left: 0; + margin-left: 0; } .dashboard-wraper { - background: none repeat scroll 0 0 hsl(0, 0%, 93%); - border-radius: 5px; - float: left; - margin: 1%; - padding: 3px; - width: 17%; - min-height: 194px; - min-width: 96px; + background: none repeat scroll 0 0 hsl(0, 0%, 93%); + border-radius: 5px; + float: left; + margin: 1%; + padding: 3px; + width: 17%; + min-height: 194px; + min-width: 96px; } .dashboard-content a { - background: linear-gradient(to bottom, hsl(0, 0%, 100%) 0%, hsl(0, 0%, 96%) 47%, hsl(0, 0%, 93%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); - border: 1px solid hsl(0, 0%, 85%); - border-radius: 4px; - box-shadow: 0 0 3px hsla(0, 0%, 0%, 0.1) inset; - color: hsl(0, 0%, 20%); - display: block; - min-height: 89px; - padding: 10px; - text-align: center; - text-decoration: none; + background: linear-gradient(to bottom, hsl(0, 0%, 100%) 0%, hsl(0, 0%, 96%) 47%, hsl(0, 0%, 93%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + border: 1px solid hsl(0, 0%, 85%); + border-radius: 4px; + box-shadow: 0 0 3px hsla(0, 0%, 0%, 0.1) inset; + color: hsl(0, 0%, 20%); + display: block; + min-height: 89px; + padding: 10px; + text-align: center; + text-decoration: none; } .dashboard-content a:hover { - background: linear-gradient(to bottom, hsl(0, 0%, 90%) 0%, hsl(0, 0%, 100%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); - color: hsl(200, 100%, 30%); - text-decoration: none; + background: linear-gradient(to bottom, hsl(0, 0%, 90%) 0%, hsl(0, 0%, 100%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + color: hsl(200, 100%, 30%); + text-decoration: none; } .dashboard-title { - display: block; - padding-top: 5px; + display: block; + padding-top: 5px; } .dashboard-info { - background: linear-gradient(to bottom, hsl(0, 0%, 100%) 0%, hsl(0, 0%, 96%) 47%, hsl(0, 0%, 93%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); - border: 1px solid hsl(0, 0%, 85%); - border-radius: 4px; - box-shadow: 0 0 3px hsla(0, 0%, 0%, 0.1) inset; - color: hsl(0, 0%, 20%); - display: block; - font-size: 12px; - padding: 10px; - text-align: center; + background: linear-gradient(to bottom, hsl(0, 0%, 100%) 0%, hsl(0, 0%, 96%) 47%, hsl(0, 0%, 93%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + border: 1px solid hsl(0, 0%, 85%); + border-radius: 4px; + box-shadow: 0 0 3px hsla(0, 0%, 0%, 0.1) inset; + color: hsl(0, 0%, 20%); + display: block; + font-size: 12px; + padding: 10px; + text-align: center; } .dashboard-info span { - display: block; - text-align: center; + display: block; + text-align: center; } .dashboard-info img { - margin: 0 auto; + margin: 0 auto; } .dashboard-table { - border-top: 1px solid hsl(0, 0%, 87%); - margin-top: 5px; - width: 100%; + border-top: 1px solid hsl(0, 0%, 87%); + margin-top: 5px; + width: 100%; } .dashboard-info h5 { - font-size: 11px; - font-weight: bold; + font-size: 11px; + font-weight: bold; } .dashboard-block { - background: linear-gradient(to bottom, hsl(0, 0%, 95%) 0%, hsl(0, 0%, 86%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); - border: 1px solid hsl(0, 0%, 76%); - border-radius: 3px; - box-shadow: 0 1px 0 hsl(0, 0%, 98%) inset; - margin-bottom: 20px; + background: linear-gradient(to bottom, hsl(0, 0%, 95%) 0%, hsl(0, 0%, 86%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + border: 1px solid hsl(0, 0%, 76%); + border-radius: 3px; + box-shadow: 0 1px 0 hsl(0, 0%, 98%) inset; + margin-bottom: 20px; } .dashboard-block .dashboard-block-head { - background: linear-gradient(to bottom, hsl(0, 0%, 95%) 0%, hsl(0, 0%, 86%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); - border-bottom: 1px solid hsl(0, 0%, 76%); - border-radius: 3px 3px 0 0; - box-shadow: 0 1px 0 hsl(0, 0%, 98%) inset, 0 0 3px hsl(0, 0%, 87%); - height: 40px; - position: relative; + background: linear-gradient(to bottom, hsl(0, 0%, 95%) 0%, hsl(0, 0%, 86%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + border-bottom: 1px solid hsl(0, 0%, 76%); + border-radius: 3px 3px 0 0; + box-shadow: 0 1px 0 hsl(0, 0%, 98%) inset, 0 0 3px hsl(0, 0%, 87%); + height: 40px; + position: relative; } .dashboard-block .dashboard-block-head h5 { - font-size: 12px; - margin: 0; - padding-left: 10px; - padding-top: 11px; - text-transform: uppercase; + font-size: 12px; + margin: 0; + padding-left: 10px; + padding-top: 11px; + text-transform: uppercase; } .dashboard-block .dashboard-block-content { - background: none repeat scroll 0 0 hsl(0, 0%, 93%); - border-radius: 0 0 3px 3px; + background: none repeat scroll 0 0 hsl(0, 0%, 93%); + border-radius: 0 0 3px 3px; } .dashboard-block .dashboard-block-box { - background: none repeat scroll 0 0 hsl(0, 0%, 100%); - border-top: 1px solid hsl(0, 0%, 82%); - box-shadow: 0 0 5px hsl(0, 0%, 87%) inset; + background: none repeat scroll 0 0 hsl(0, 0%, 100%); + border-top: 1px solid hsl(0, 0%, 82%); + box-shadow: 0 0 5px hsl(0, 0%, 87%) inset; } .dashboard-block .dashboard-block-content .dashboard-block-box { - margin-top: 0 !important; + margin-top: 0 !important; } .dashboard-block .dashboard-block-content .dashboard-block-box .dashboard-block-table { - margin-bottom: 0 !important; + margin-bottom: 0 !important; } .dashboard-block-table { - background-color: hsla(0, 0%, 0%, 0); - border-collapse: collapse; - border-spacing: 0; - margin-bottom: 20px; - max-width: 100%; - width: 100%; + background-color: hsla(0, 0%, 0%, 0); + border-collapse: collapse; + border-spacing: 0; + margin-bottom: 20px; + max-width: 100%; + width: 100%; } .dashboard-block-table th, .dashboard-block-table td { - border-top: 1px solid hsl(0, 0%, 87%); - line-height: 20px; - padding: 5px; - text-align: left; - vertical-align: middle; + border-top: 1px solid hsl(0, 0%, 87%); + line-height: 20px; + padding: 5px; + text-align: left; + vertical-align: middle; } .dashboard-badge { - background-color: hsl(0, 0%, 60%); - border-radius: 9px; - color: hsl(0, 0%, 100%); - font-size: 11.844px; - font-weight: bold; - line-height: 14px; - padding: 1px 9px 2px; - text-shadow: 0 -1px 0 hsla(0, 0%, 0%, 0.25); - vertical-align: baseline; - white-space: nowrap; + background-color: hsl(0, 0%, 60%); + border-radius: 9px; + color: hsl(0, 0%, 100%); + font-size: 11.844px; + font-weight: bold; + line-height: 14px; + padding: 1px 9px 2px; + text-shadow: 0 -1px 0 hsla(0, 0%, 0%, 0.25); + vertical-align: baseline; + white-space: nowrap; } \ No newline at end of file diff --git a/admin/compiler/joomla_3/default.php b/admin/compiler/joomla_3/default.php index 0166c0fb8..8eecd5d99 100644 --- a/admin/compiler/joomla_3/default.php +++ b/admin/compiler/joomla_3/default.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -18,10 +18,11 @@ defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED### ###ADMIN_VIEWS_HEADER### + if ($this->saveOrder) { $saveOrderingUrl = 'index.php?option=com_###component###&task=###views###.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', '###view###List', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); + Html::_('sortablelist.sortable', '###view###List', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); } ?> ###VIEWS_DEFAULT_BODY######VIEWS_FOOTER_SCRIPT### diff --git a/admin/compiler/joomla_3/default_batch_body.php b/admin/compiler/joomla_3/default_batch_body.php index a1fe1378e..ec4f6be38 100644 --- a/admin/compiler/joomla_3/default_batch_body.php +++ b/admin/compiler/joomla_3/default_batch_body.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,7 +17,10 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED### +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + ?> -

+

batchDisplay; ?> \ No newline at end of file diff --git a/admin/compiler/joomla_3/default_batch_footer.php b/admin/compiler/joomla_3/default_batch_footer.php index 7964422a5..73d7824e9 100644 --- a/admin/compiler/joomla_3/default_batch_footer.php +++ b/admin/compiler/joomla_3/default_batch_footer.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,12 +17,14 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED### +use Joomla\CMS\Language\Text; + ?> \ No newline at end of file diff --git a/admin/compiler/joomla_3/default_body.php b/admin/compiler/joomla_3/default_body.php index 5db8ffb81..d5c40e434 100644 --- a/admin/compiler/joomla_3/default_body.php +++ b/admin/compiler/joomla_3/default_body.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,6 +17,10 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED### +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + $edit = "index.php?option=com_###component###&view=###views###&task=###view###.edit"; ?> diff --git a/admin/compiler/joomla_3/default_custom_admin.php b/admin/compiler/joomla_3/default_custom_admin.php index 925f748c9..c68079a4d 100644 --- a/admin/compiler/joomla_3/default_custom_admin.php +++ b/admin/compiler/joomla_3/default_custom_admin.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -18,11 +18,11 @@ defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED### ###CUSTOM_ADMIN_VIEW_HEADER######CUSTOM_ADMIN_CODE_BODY### + ?> canDo->get('###sview###.access')): ?>###CUSTOM_ADMIN_SUBMITBUTTON_SCRIPT### item->id)) ? '&id='. (int) $this->item->id : ''; ?> ###CUSTOM_ADMIN_TOP_FORM######CUSTOM_ADMIN_BODY######CUSTOM_ADMIN_BOTTOM_FORM### -

+

- diff --git a/admin/compiler/joomla_3/default_custom_admin_template.php b/admin/compiler/joomla_3/default_custom_admin_template.php index 3b5ea3e22..de8533c69 100644 --- a/admin/compiler/joomla_3/default_custom_admin_template.php +++ b/admin/compiler/joomla_3/default_custom_admin_template.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -15,6 +15,10 @@ defined('_JEXEC') or die('Restricted access'); ###BOM### // No direct access to this file -defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED######CUSTOM_ADMIN_TEMPLATE_CODE_BODY### +defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED### + +use Joomla\CMS\Language\Text; +use Joomla\CMS\Router\Route; +use Joomla\CMS\HTML\HTMLHelper as Html;###CUSTOM_ADMIN_TEMPLATE_CODE_BODY### ?>###CUSTOM_ADMIN_TEMPLATE_BODY### diff --git a/admin/compiler/joomla_3/default_foot.php b/admin/compiler/joomla_3/default_foot.php index 725eba045..93585b9b7 100644 --- a/admin/compiler/joomla_3/default_foot.php +++ b/admin/compiler/joomla_3/default_foot.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ diff --git a/admin/compiler/joomla_3/default_head.php b/admin/compiler/joomla_3/default_head.php index 894d421fe..72243e3e8 100644 --- a/admin/compiler/joomla_3/default_head.php +++ b/admin/compiler/joomla_3/default_head.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,5 +17,8 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED### +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + ?> ###LISTHEAD### \ No newline at end of file diff --git a/admin/compiler/joomla_3/default_import.php b/admin/compiler/joomla_3/default_import.php index 1cab7a6c4..ba0519b09 100644 --- a/admin/compiler/joomla_3/default_import.php +++ b/admin/compiler/joomla_3/default_import.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,13 +17,17 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED### -JHtml::_('jquery.framework'); -JHtml::_('bootstrap.tooltip'); -JHtml::_('script', 'system/core.js', false, true); -JHtml::_('behavior.keepalive'); +use Joomla\CMS\Language\Text; +use Joomla\CMS\Router\Route; +use Joomla\CMS\HTML\HTMLHelper as Html; +Html::_('jquery.framework'); +Html::_('bootstrap.tooltip'); +Html::_('script', 'system/core.js', false, true); +Html::_('behavior.keepalive'); + ?>
-
+ sidebar)) : ?>
@@ -137,13 +141,13 @@ jQuery(document).ready(function($) {
- hasPackage && ###Component###Helper::checkArray($this->headerList) && ###Component###Helper::checkArray($this->headers)) : ?> + hasPackage && Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($this->headerList) && Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($this->headers)) : ?>
- +
- +
- +
headerList as $name => $title): ?> @@ -151,72 +155,72 @@ jQuery(document).ready(function($) {
- +
- 'upload')); ?> - - + 'upload')); ?> + +
- +
- +
-     (.csv .xls .ods) +     (.csv .xls .ods)
- - - + + +
- +
- +
-     (.csv .xls .ods) +     (.csv .xls .ods)
- + - +
- +
- +
-     (.csv .xls .ods) +     (.csv .xls .ods)
- - + + - +
\ No newline at end of file diff --git a/admin/compiler/joomla_3/default_import_custom.php b/admin/compiler/joomla_3/default_import_custom.php index 6329fd18b..04bc64bdc 100644 --- a/admin/compiler/joomla_3/default_import_custom.php +++ b/admin/compiler/joomla_3/default_import_custom.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,8 +17,13 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED### -JHtml::_('jquery.framework'); -JHtml::_('bootstrap.tooltip'); -JHtml::_('script', 'system/core.js', false, true); -JHtml::_('behavior.keepalive'); +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Router\Route; +use Joomla\CMS\HTML\HTMLHelper as Html; +Html::_('jquery.framework'); +Html::_('bootstrap.tooltip'); +Html::_('script', 'system/core.js', false, true); +Html::_('behavior.keepalive'); + ?>###IMPORT_DEFAULT_VIEW_CUSTOM### diff --git a/admin/compiler/joomla_3/default_list_custom_admin.php b/admin/compiler/joomla_3/default_list_custom_admin.php index 3f6dd6fb1..a3d41a83f 100644 --- a/admin/compiler/joomla_3/default_list_custom_admin.php +++ b/admin/compiler/joomla_3/default_list_custom_admin.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -22,5 +22,5 @@ defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED### canDo->get('###sview###.access')): ?>###CUSTOM_ADMIN_SUBMITBUTTON_SCRIPT### ###CUSTOM_ADMIN_TOP_FORM######CUSTOM_ADMIN_BODY######CUSTOM_ADMIN_BOTTOM_FORM### -

+

diff --git a/admin/compiler/joomla_3/default_list_site.php b/admin/compiler/joomla_3/default_list_site.php index 936804bd2..62479ff87 100644 --- a/admin/compiler/joomla_3/default_list_site.php +++ b/admin/compiler/joomla_3/default_list_site.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ diff --git a/admin/compiler/joomla_3/default_main.php b/admin/compiler/joomla_3/default_main.php index 4bde280d1..5bec37199 100644 --- a/admin/compiler/joomla_3/default_main.php +++ b/admin/compiler/joomla_3/default_main.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,19 +17,21 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Language\Text; + ?> icons['main']) && is_array($this->icons['main'])) :?> icons['main'] as $icon): ?>
-
-

+

\ No newline at end of file diff --git a/admin/compiler/joomla_3/default_site.php b/admin/compiler/joomla_3/default_site.php index 61864331f..6ab8f1a3a 100644 --- a/admin/compiler/joomla_3/default_site.php +++ b/admin/compiler/joomla_3/default_site.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ diff --git a/admin/compiler/joomla_3/default_site_template.php b/admin/compiler/joomla_3/default_site_template.php index 55687f70a..337f5b7ca 100644 --- a/admin/compiler/joomla_3/default_site_template.php +++ b/admin/compiler/joomla_3/default_site_template.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -15,6 +15,10 @@ defined('_JEXEC') or die('Restricted access'); ###BOM### // No direct access to this file -defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED######SITE_TEMPLATE_CODE_BODY### +defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED### + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper;###SITE_TEMPLATE_CODE_BODY### ?>###SITE_TEMPLATE_BODY### diff --git a/admin/compiler/joomla_3/default_toolbar.php b/admin/compiler/joomla_3/default_toolbar.php index c608f71e0..ba3d37eb1 100644 --- a/admin/compiler/joomla_3/default_toolbar.php +++ b/admin/compiler/joomla_3/default_toolbar.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,34 +17,37 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED### +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + ?>
- -
- - -
-
- - pagination->getLimitBox(); ?> -
-
- - -
-
- - -
-
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
\ No newline at end of file diff --git a/admin/compiler/joomla_3/default_vdm.php b/admin/compiler/joomla_3/default_vdm.php index ec4349bd6..4f12c9cab 100644 --- a/admin/compiler/joomla_3/default_vdm.php +++ b/admin/compiler/joomla_3/default_vdm.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,22 +17,24 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Language\Text; + ?> -<?php echo JText::_('COM_###COMPONENT###'); ?> +<?php echo Text::_('COM_###COMPONENT###'); ?>
-contributors)): ?> +contributors)): ?> contributors) > 1): ?> -

+

-

+

    contributors as $contributor): ?> diff --git a/admin/compiler/joomla_3/edit.php b/admin/compiler/joomla_3/edit.php index 86edbead4..fa2f7ff82 100644 --- a/admin/compiler/joomla_3/edit.php +++ b/admin/compiler/joomla_3/edit.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -18,10 +18,11 @@ defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access'); ###ADMIN_VIEW_HEADER### + $componentParams = $this->params; // will be removed just use $this->params instead ?> ###EDITBODYFADEIN### -
    + ###EDITBODY###
###EDITBODYSCRIPT### diff --git a/admin/compiler/joomla_3/edit_site.php b/admin/compiler/joomla_3/edit_site.php index 7a6efb4f7..a398e73e7 100644 --- a/admin/compiler/joomla_3/edit_site.php +++ b/admin/compiler/joomla_3/edit_site.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -18,10 +18,11 @@ defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access'); ###SITE_ADMIN_VIEW_HEADER### + ?>
toolbar->render(); ?> -
+ ###EDITBODY###
###EDITBODYSCRIPT### diff --git a/admin/compiler/joomla_3/headercheck.php b/admin/compiler/joomla_3/headercheck.php index 6dcee6c35..36d0e0d04 100644 --- a/admin/compiler/joomla_3/headercheck.php +++ b/admin/compiler/joomla_3/headercheck.php @@ -1,24 +1,24 @@ - @my wife Roline van der Merwe - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - - Builds Complex Joomla Components - + @package Component Builder + @subpackage componentbuilder.php + @author Llewellyn van der Merwe + @my wife Roline van der Merwe + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + + Builds Complex Joomla Components + /-----------------------------------------------------------------------------------------------------------------------------*/ // No direct access to this file @@ -29,24 +29,36 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; + class ###component###HeaderCheck { + protected $document = null; + protected $app = null; + function js_loaded($script_name) { // UIkit check point if (strpos($script_name,'uikit') !== false) { - $app = JFactory::getApplication(); - $getTemplateName = $app->getTemplate('template')->template; - + if (!$this->app) + { + $this->app = Factory::getApplication(); + } + + $getTemplateName = $this->app->getTemplate('template')->template; if (strpos($getTemplateName,'yoo') !== false) { return true; } } - - $document = JFactory::getDocument(); - $head_data = $document->getHeadData(); + + if (!$this->document) + { + $this->document = Factory::getDocument(); + } + + $head_data = $this->document->getHeadData(); foreach (array_keys($head_data['scripts']) as $script) { if (stristr($script, $script_name)) @@ -57,24 +69,30 @@ class ###component###HeaderCheck return false; } - + function css_loaded($script_name) { // UIkit check point if (strpos($script_name,'uikit') !== false) { - $app = JFactory::getApplication(); - $getTemplateName = $app->getTemplate('template')->template; - + if (!$this->app) + { + $this->app = Factory::getApplication(); + } + + $getTemplateName = $this->app->getTemplate('template')->template; if (strpos($getTemplateName,'yoo') !== false) { return true; } } - - $document = JFactory::getDocument(); - $head_data = $document->getHeadData(); - + + if (!$this->document) + { + $this->document = Factory::getDocument(); + } + + $head_data = $this->document->getHeadData(); foreach (array_keys($head_data['styleSheets']) as $script) { if (stristr($script, $script_name)) diff --git a/admin/compiler/joomla_3/headercheck_admin.php b/admin/compiler/joomla_3/headercheck_admin.php index 402101246..7955eb0e0 100644 --- a/admin/compiler/joomla_3/headercheck_admin.php +++ b/admin/compiler/joomla_3/headercheck_admin.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,24 +17,36 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; + class ###component###HeaderCheck { + protected $document = null; + protected $app = null; + function js_loaded($script_name) { // UIkit check point if (strpos($script_name,'uikit') !== false) { - $app = JFactory::getApplication(); - $getTemplateName = $app->getTemplate('template')->template; - + if (!$this->app) + { + $this->app = Factory::getApplication(); + } + + $getTemplateName = $this->app->getTemplate('template')->template; if (strpos($getTemplateName,'yoo') !== false) { return true; } } - - $document = JFactory::getDocument(); - $head_data = $document->getHeadData(); + + if (!$this->document) + { + $this->document = Factory::getDocument(); + } + + $head_data = $this->document->getHeadData(); foreach (array_keys($head_data['scripts']) as $script) { if (stristr($script, $script_name)) @@ -45,24 +57,30 @@ class ###component###HeaderCheck return false; } - + function css_loaded($script_name) { // UIkit check point if (strpos($script_name,'uikit') !== false) { - $app = JFactory::getApplication(); - $getTemplateName = $app->getTemplate('template')->template; - + if (!$this->app) + { + $this->app = Factory::getApplication(); + } + + $getTemplateName = $this->app->getTemplate('template')->template; if (strpos($getTemplateName,'yoo') !== false) { return true; } } - - $document = JFactory::getDocument(); - $head_data = $document->getHeadData(); - + + if (!$this->document) + { + $this->document = Factory::getDocument(); + } + + $head_data = $this->document->getHeadData(); foreach (array_keys($head_data['styleSheets']) as $script) { if (stristr($script, $script_name)) @@ -73,4 +91,4 @@ class ###component###HeaderCheck return false; } -} \ No newline at end of file +} diff --git a/admin/compiler/joomla_3/import.gif b/admin/compiler/joomla_3/import.gif index 4371cc618bdc1702aad69fc871a50182a01537ec..10bcb856924dbc48ac739332a40ce1617c88687b 100644 GIT binary patch delta 4162 zcmeHKYgm&<7S5MIE)Xuka1RiIcvnJE7O+;tsI<09tst#biMkbwNRYA?9xV|F0i-rK zRG?77T9sC$DFgJ8b=`u>qQYv?LKbg$tE`I))cRPeXfqf1g8koL=1TA|H z8%G|sPGV#z^1553X>X!OPV(#-Cch~++#&?F1DH`Ma26ngm+B9E#cn_?@F%JCf)ti5 z*v#ey-Gv)zs-2>B1a(_vAt=Z!$OGotSX0z)+XjMCi9cnz{$fUX0;7{H=v~W)BD+%* z{crnHg5K!x^4N3$W95IqM~-t{k;Z^rL!|Yt%*;ZGtmv}{J{kgN9otA0kUV8`1fv|# z=yZ*-Lns&Zfhkik{8MQMiweVfwa(kAf)STXgsaoFlSN^@@T6Nd` zgi#)@G&aF=s~d99GHF``ldTz!?=Xg-F`z7!0j;wL+RNez9433UGi;GXbuv&D>Inu+ zd{|Swo59s`p7JV&XNM1NSm%`M5dHuYE#3PgN$gu<$HqftsRI{}gYeJ(r9jATq18iY z)qeS!)B5=JQh)!o!Z-H67m+hmwiWXX`A4IFxiDV4eupBGFXbpNX)8A@R)i&NpWfe^ zi$U>|;>IMx!SXUHz2NgnwB~R3jj#Y?CyQO8xpYejf%jbzFh+^M{1ab* z?~nA5sPdX38a1<4KQ5|x4!mDGg-7(b)Fry3bbW`8{J*K+#nZ}i4PjAT0%MQdSC6Gh zduovdnfg1F_-;coON{mv-r-Q&_#IuCkYj5|mXc$8$La*^!aIPprW*vY>hDL0@x$UF zY`}-dB^HOmAF74(Pb?-nVD3L@ioNsKe+rV^t$X4M1~B{+T~ zeuDT(?BQ-7^a)nAD+wU4{jBBGy2GT7(M>Bjzkyb@`9kCPsytx$4=U=^b)Ljj@YRco zQT(OtmZYcx5x8(#1PnSc=(r_<6MuB3(6Fwrh>+V|uM%Tc_iMyR?_Nxd@4Ksrp*BTZ z>IiI7!KbD?%B1gkg`iq{s>P_t09jinF7|`V1;q30@)BY!xe~+*B*&!y#9a*{Uc=Qo zVn{aS5Tosy7dGHe*OpuCDzs@`p?6|AkpP=E2T(EhlH?@Pc1!E?nfRbC`8c6V);Q8o zZHlYKst=Z%1S?EcSbbXRWFP;Hn@|ED@CMQsu zzX=3v+eipXwk;>d-EBLF@z)Q(B!*48iWtk&DW)>rg^V<&`w*im-NzSYPVK0PJ*4sT zy{D-@Xn*dIbajbRY;a!Q_Wm5>el(C*x9J1Yy>W|xz z`TQK&9%%lEdRsEXaem0t?in{l-C#>r7LhiT>Rr2_PW)Uf<_yuw$T&T z>Rx9&km{Mg<(DzaD*qJ&S9EI4BApIzAYiXgB>Wlr>BKmspM}q9{=n9>Cxy1mWL)!g z{df4rU~pvIybQfn#bWuzZiYYg?QG>?45-PA#jUquDtI&04fx~>SV^M`)=DyX71Wbb zIt$j)QeG;gr_s7XEjv*~bv}^yv6f(9&Ta`8mlD`pm8Gt?9@k7cB!_o}2wpaXF%d{p z1CJXOBx#(<@7pzJTEqFt?ooDO?uxK>Q%r!t8Uak+L(^lIpQ_exsZ-YQ6)R3G6i8YMe7KfcUNqwu&G2|@ zR=yc{5#iRjFRkGE*-SiJrg*)stgQLArsJ*91;M4rx93sP*wVq|M`>I(n;*{hYmHZA0 Cx!!>Q delta 2752 zcmeHJ`&Z0q81Fl`dYjs2=r+@I9V()tqzh||R_^5zp{20OCY2RS*)Ehzp}eg`+F7hD z9c|u5II%@*J7{wkT1^htC0({XyOhg5&s6Ncu;=*Yb7nrz=lwj-dwbsR%gut8cl?|U zJVMH{EI0un29C5$YsIR$c^pTmJwFpUC2byV&d&4wfZHiNf|R#jc1ak^4Ixd|6B>5K z$T!A$4{1=kHe0I=#cf388aV#sstThi2Ym(OGmRb9?$Om!LSqe8;9F*xfF?d*V#_8P zMPaUTvItOatk38L8Re|TScs82u@*4XwldyB$kl} zTwMu$YhH(DDz$<}xLGiPrM|p4s~a#f$od+@n4?U?8I#SW;pM|8d?_I8s@w{TX|Y); zCGHKW=L}thoPpyjOyUbOQL?>?2oSJ$wwF2dF4Zb%RaQS*(rCsc4%;~?F?h=_eC4fb zU$UrQrkSdf(5~G#VZe4LQ~j=>i=6$e?8G$Pg}(x(Im-dRa}EU@U1SY7wOhp3IFB8tnUHbCA)e5LgAah6^TRnn+e3c6V&+r)nAbP( z^^sOS8BFLgZ$~h;E(twz}@;a>ewmqTE^`5|A3A@-c7uoTv z1z5qpYfG?#s_+v%6)0HKjX-2vZk>m4>n$hzQy-Cxi;FeLSzM$Sa?kJl2)O(1L_p2r zNr0`3#{;gvrvY?q3`N8CsqU<#QG@!B`=0_%jXEqM9*Wv)gmTeaf!Glp1Zc1GLV3?+ z3IHOZ`8c4D6V zDM8`NudMWAb64F1WqjgtKwYAffYc`tX0kdAU82`?{`UZ>X(6?sR@qDGsI^fLE?yf9 z*tK>&VA8sSfXbvmz?dZD&n8&{HYC{tcI(kDSq8rYlI6Y20Qb&?QfkBMlJ&JO|3-;f zX-dk6s*PAzssLGDI&>^HK7D6z)wgNI#&qCEXW)^TpRpQ6H#2el7H^u51}gP9MmA63 z%*oKMEd`vXX5fsr#*E1L&oVMh2#wnk1Je6j+yG6tx{HaZZDr!?Y%%9T=#;G$mLx~Q zS=;95G5=8{dsLr`1(kS-SR(c3{D_v%3-OYk7%F;_ zHDa)~-bEH->MwKhzuYj}BS%OY>^j`Sf@=^KwW*)ij$H4)a4XRq%X zAMWVK9tVf{V~_iv_PA25B^&*)2rpIBqgj9>A9ov*U&PY9E7c}KSDKbIfO*D{nLaJtDRSk*`|(ijE?Di zjU#>EKgBvBVe9_#$4Bkt-|+2147?y_&Q$+=j{5Ikx?2%0@29Ux=sBT6=@;g5L{&SP z2F8vewC&|qsFt3p3->0#R8`(#|sLoAI8_s^c(B5 zo6tqwv6#eL|6Fx;&*kAiC05B|-%f+CE@4fffsoMJcllthjp97PJRjQfY*P~065!;p auROd_WJmG^JT4v-70Em<5+%)iF8^Od#l!;u diff --git a/admin/compiler/joomla_3/layout.php b/admin/compiler/joomla_3/layout.php index 2a1d95ed8..d7af88c11 100644 --- a/admin/compiler/joomla_3/layout.php +++ b/admin/compiler/joomla_3/layout.php @@ -1,24 +1,24 @@ - @my wife Roline van der Merwe - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - - Builds Complex Joomla Components - + @package Component Builder + @subpackage componentbuilder.php + @author Llewellyn van der Merwe + @my wife Roline van der Merwe + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + + Builds Complex Joomla Components + /-----------------------------------------------------------------------------------------------------------------------------*/ // No direct access to this file @@ -46,7 +46,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( ###LAYOUTITEMS### ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/compiler/joomla_3/layout_admin.php b/admin/compiler/joomla_3/layout_admin.php index c9c13b2cd..5188aec67 100644 --- a/admin/compiler/joomla_3/layout_admin.php +++ b/admin/compiler/joomla_3/layout_admin.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ diff --git a/admin/compiler/joomla_3/layout_custom_admin.php b/admin/compiler/joomla_3/layout_custom_admin.php index c26e133cc..12e0c32d7 100644 --- a/admin/compiler/joomla_3/layout_custom_admin.php +++ b/admin/compiler/joomla_3/layout_custom_admin.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ diff --git a/admin/compiler/joomla_3/layout_site.php b/admin/compiler/joomla_3/layout_site.php index 31edafa09..cd8bd0548 100644 --- a/admin/compiler/joomla_3/layout_site.php +++ b/admin/compiler/joomla_3/layout_site.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ diff --git a/admin/compiler/joomla_3/layoutfull.php b/admin/compiler/joomla_3/layoutfull.php index e6b6cc02a..bdc3cda15 100644 --- a/admin/compiler/joomla_3/layoutfull.php +++ b/admin/compiler/joomla_3/layoutfull.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( ###LAYOUTITEMS### ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/compiler/joomla_3/layoutitems.php b/admin/compiler/joomla_3/layoutitems.php index 1314a034e..b58e0dcf4 100644 --- a/admin/compiler/joomla_3/layoutitems.php +++ b/admin/compiler/joomla_3/layoutitems.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( ###LAYOUTITEMS### ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/compiler/joomla_3/layoutlinkedview.php b/admin/compiler/joomla_3/layoutlinkedview.php index 86c99b879..5ab1010a0 100644 --- a/admin/compiler/joomla_3/layoutlinkedview.php +++ b/admin/compiler/joomla_3/layoutlinkedview.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,9 +17,13 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + // set the defaults $items = $displayData->###LAYOUTITEMS###; -$user = JFactory::getUser(); +$user = Factory::getUser(); $id = $displayData->item->id; ###LAYOUTITEMSHEADER### diff --git a/admin/compiler/joomla_3/layoutmetadata.php b/admin/compiler/joomla_3/layoutmetadata.php index d19a24cb1..3c465bddb 100644 --- a/admin/compiler/joomla_3/layoutmetadata.php +++ b/admin/compiler/joomla_3/layoutmetadata.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,6 +17,8 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Language\Text; + $form = $displayData->getForm(); // JLayout for standard handling of metadata fields in the administrator content edit screens. @@ -25,7 +27,7 @@ $fieldSets = $form->getFieldsets('metadata'); $fieldSet) : ?> description) && trim($fieldSet->description)) : ?> -

escape(JText::_($fieldSet->description)); ?>

+

escape(Text::_($fieldSet->description)); ?>

- * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ diff --git a/admin/compiler/joomla_3/layoutpublished.php b/admin/compiler/joomla_3/layoutpublished.php index 1314a034e..b58e0dcf4 100644 --- a/admin/compiler/joomla_3/layoutpublished.php +++ b/admin/compiler/joomla_3/layoutpublished.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( ###LAYOUTITEMS### ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/compiler/joomla_3/layouttitle.php b/admin/compiler/joomla_3/layouttitle.php index 95149e8c8..2afa93ac1 100644 --- a/admin/compiler/joomla_3/layouttitle.php +++ b/admin/compiler/joomla_3/layouttitle.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( ###LAYOUTITEMS### ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/compiler/joomla_3/module_forms.js b/admin/compiler/joomla_3/module_forms.js index ec598c680..4bf5019bf 100644 --- a/admin/compiler/joomla_3/module_forms.js +++ b/admin/compiler/joomla_3/module_forms.js @@ -1,3 +1,3 @@ ###BOM### -###VIEW_SCRIPT### +###VIEW_SCRIPT### diff --git a/admin/compiler/joomla_3/module_forms.xml b/admin/compiler/joomla_3/module_forms.xml index a31e5d4ac..8028c6880 100644 --- a/admin/compiler/joomla_3/module_forms.xml +++ b/admin/compiler/joomla_3/module_forms.xml @@ -4,6 +4,6 @@ addfieldpath="/administrator/components/com_###component###/models/fields" > ###FIELDSETS### - + ###ACCESSCONTROL### \ No newline at end of file diff --git a/admin/compiler/joomla_3/routeHelper.php b/admin/compiler/joomla_3/routeHelper.php index d28c1c0ec..afa52631f 100644 --- a/admin/compiler/joomla_3/routeHelper.php +++ b/admin/compiler/joomla_3/routeHelper.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,6 +17,13 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Language\Multilanguage; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Categories\CategoryNode; +use Joomla\CMS\Categories\Categories; + /** * ###Component### Route Helper **/ @@ -27,7 +34,7 @@ abstract class ###Component###HelperRoute /** * Get the URL route for ###component### category from a category ID and language * - * @param mixed $catid The id of the items's category either an integer id or a instance of JCategoryNode + * @param mixed $catid The id of the items's category either an integer id or a instance of CategoryNode * @param mixed $language The id of the language being used. * * @return string The link to the contact @@ -36,20 +43,20 @@ abstract class ###Component###HelperRoute */ public static function getCategoryRoute_keep_for_later($catid, $language = 0) { - if ($catid instanceof JCategoryNode) + if ($catid instanceof CategoryNode) { - $id = $catid->id; - $category = $catid; + $id = $catid->id; + $category = $catid; } else - { - throw new Exception('First parameter must be JCategoryNode'); + { + throw new Exception('First parameter must be CategoryNode'); } - + $views = array(###ROUTER_CATEGORY_VIEWS###); $view = $views[$category->extension]; - - if ($id < 1 || !($category instanceof JCategoryNode)) + + if ($id < 1 || !($category instanceof CategoryNode)) { $link = ''; } @@ -57,20 +64,20 @@ abstract class ###Component###HelperRoute { //Create the link $link = 'index.php?option=com_###component###&view='.$view.'&category='.$category->slug; - + $needles = array( $view => array($id), 'category' => array($id) ); - - if ($language && $language != "*" && JLanguageMultilang::isEnabled()) + + if ($language && $language != "*" && Multilanguage::isEnabled()) { - $db = JFactory::getDbo(); - $query = $db->getQuery(true) + $db = Factory::getDbo(); + $query = $db->getQuery(true) ->select('a.sef AS sef') ->select('a.lang_code AS lang_code') ->from('#__languages AS a'); - + $db->setQuery($query); $langs = $db->loadObjectList(); foreach ($langs as $lang) @@ -82,11 +89,11 @@ abstract class ###Component###HelperRoute } } } - + if ($item = self::_findItem($needles,'category')) { - $link .= '&Itemid='.$item; + $link .= '&Itemid='.$item; } else { @@ -112,16 +119,16 @@ abstract class ###Component###HelperRoute protected static function _findItem($needles = null,$type = null) { - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $menus = $app->getMenu('site'); $language = isset($needles['language']) ? $needles['language'] : '*'; // Prepare the reverse lookup array. if (!isset(self::$lookup[$language])) { - self::$lookup[$language] = array(); + self::$lookup[$language] = []; - $component = JComponentHelper::getComponent('com_###component###'); + $component = ComponentHelper::getComponent('com_###component###'); $attributes = array('component_id'); $values = array($component->id); @@ -142,7 +149,7 @@ abstract class ###Component###HelperRoute if (!isset(self::$lookup[$language][$view])) { - self::$lookup[$language][$view] = array(); + self::$lookup[$language][$view] = []; } if (isset($item->query['id'])) @@ -171,7 +178,7 @@ abstract class ###Component###HelperRoute { if (isset(self::$lookup[$language][$view])) { - if (###Component###Helper::checkArray($ids)) + if (Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($ids)) { foreach ($ids as $id) { @@ -192,7 +199,7 @@ abstract class ###Component###HelperRoute if ($type) { // Check if the global menu item has been set. - $params = JComponentHelper::getParams('com_###component###'); + $params = ComponentHelper::getParams('com_###component###'); if ($item = $params->get($type.'_menu', 0)) { return $item; @@ -204,7 +211,7 @@ abstract class ###Component###HelperRoute if ($active && $active->component == 'com_###component###' - && ($language == '*' || in_array($active->language, array('*', $language)) || !JLanguageMultilang::isEnabled())) + && ($language == '*' || in_array($active->language, array('*', $language)) || !Multilanguage::isEnabled())) { return $active->id; } diff --git a/admin/compiler/joomla_3/router.php b/admin/compiler/joomla_3/router.php index 6bd91af36..834ab4e37 100644 --- a/admin/compiler/joomla_3/router.php +++ b/admin/compiler/joomla_3/router.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -17,13 +17,16 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; +use Joomla\CMS\Component\ComponentHelper; + /** * Routing class from com_###component### * * @since 3.3 */ class ###Component###Router extends JComponentRouterBase -{ +{ /** * Build the route for the com_###component### component * @@ -35,11 +38,11 @@ class ###Component###Router extends JComponentRouterBase */ public function build(&$query) { - $segments = array(); + $segments = []; // Get a menu item based on Itemid or currently active - $params = JComponentHelper::getParams('com_###component###'); - + $params = ComponentHelper::getParams('com_###component###'); + if (empty($query['Itemid'])) { $menuItem = $this->menu->getActive(); @@ -63,7 +66,7 @@ class ###Component###Router extends JComponentRouterBase unset($query['view']); } - + // Are we dealing with a item that is attached to a menu item? if (isset($view) && ($mView == $view) and (isset($query['id'])) and ($mId == (int) $query['id'])) { @@ -93,7 +96,7 @@ class ###Component###Router extends JComponentRouterBase } unset($query['id']); } - + $total = count($segments); for ($i = 0; $i < $total; $i++) @@ -101,8 +104,8 @@ class ###Component###Router extends JComponentRouterBase $segments[$i] = str_replace(':', '-', $segments[$i]); } - return $segments; - + return $segments; + } /** @@ -115,17 +118,17 @@ class ###Component###Router extends JComponentRouterBase * @since 3.3 */ public function parse(&$segments) - { + { $count = count($segments); - $vars = array(); - + $vars = []; + // Handle View and Identifier switch($segments[0]) {###ROUTER_PARSE_SWITCH### } return $vars; - } + } protected function getVar($table, $where = null, $whereString = null, $what = null, $category = false, $operator = '=', $main = '###component###') { @@ -134,7 +137,7 @@ class ###Component###Router extends JComponentRouterBase return false; } // Get a db connection. - $db = JFactory::getDbo(); + $db = Factory::getDbo(); // Create a new query object. $query = $db->getQuery(true); @@ -150,7 +153,7 @@ class ###Component###Router extends JComponentRouterBase { // we must check if the table exist (TODO not ideal) $tables = $db->getTableList(); - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $prefix = $app->get('dbprefix'); $check = $prefix.$main.'_'.$table; if (in_array($check, $tables)) @@ -192,7 +195,7 @@ class ###Component###Router extends JComponentRouterBase } return false; } - + protected function checkString($string) { if (isset($string) && is_string($string) && strlen($string) > 0) @@ -206,7 +209,7 @@ class ###Component###Router extends JComponentRouterBase function ###Component###BuildRoute(&$query) { $router = new ###Component###Router; - + return $router->build($query); } diff --git a/admin/compiler/joomla_3/router_4.php b/admin/compiler/joomla_3/router_4.php index 72b9168c2..c03d0f2f4 100644 --- a/admin/compiler/joomla_3/router_4.php +++ b/admin/compiler/joomla_3/router_4.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ diff --git a/admin/compiler/joomla_3/script.php b/admin/compiler/joomla_3/script.php index 7240aed62..2b16ff45d 100644 --- a/admin/compiler/joomla_3/script.php +++ b/admin/compiler/joomla_3/script.php @@ -17,20 +17,24 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; use Joomla\CMS\Filesystem\File; use Joomla\CMS\Filesystem\Folder; use Joomla\CMS\Installer\Adapter\ComponentAdapter; -JHTML::_('bootstrap.renderModal'); +use Joomla\CMS\Version; +use Joomla\CMS\HTML\HTMLHelper as Html; +HTML::_('bootstrap.renderModal'); /** * Script File of ###Component### Component */ -class com_###component###InstallerScript +class Com_###Component###InstallerScript { /** * Constructor * - * @param JAdapterInstance $parent The object responsible for running this script + * @param ComponentAdapter $parent The object responsible for running this script */ public function __construct(ComponentAdapter $parent) {} @@ -78,14 +82,14 @@ class com_###component###InstallerScript public function preflight($type, ComponentAdapter $parent) { // get application - $app = JFactory::getApplication(); + $app = Factory::getApplication(); // is redundant or so it seems ...hmmm let me know if it works again if ($type === 'uninstall') { return true; } // the default for both install and update - $jversion = new JVersion(); + $jversion = new Version(); if (!$jversion->isCompatible('3.8.0')) { $app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error'); @@ -121,7 +125,7 @@ class com_###component###InstallerScript public function postflight($type, ComponentAdapter $parent) { // get application - $app = JFactory::getApplication();###MOVEFOLDERSSCRIPT### + $app = Factory::getApplication();###MOVEFOLDERSSCRIPT### // set the default component settings if ($type === 'install') {###POSTINSTALLSCRIPT### @@ -135,12 +139,12 @@ class com_###component###InstallerScript /** * Remove folders with files - * + * * @param string $dir The path to folder to remove * @param boolean $ignore The folders and files to ignore and not remove * * @return boolean True in all is removed - * + * */ protected function removeFolder($dir, $ignore = false) { @@ -209,7 +213,7 @@ class com_###component###InstallerScript /** * Check if have an array with a length * - * @input array The array to check + * @input array The array to check * * @returns bool/int number of items in array on success */ diff --git a/admin/compiler/joomla_3/settings_componentbuilder.json b/admin/compiler/joomla_3/settings_componentbuilder.json deleted file mode 100644 index 79cbabbfa..000000000 --- a/admin/compiler/joomla_3/settings_componentbuilder.json +++ /dev/null @@ -1,790 +0,0 @@ -{ - "create": { - "admin": { - "assets": { - "css": "css", - "images": { - "icons": "icons" - }, - "js": "js" - }, - "controllers": "controllers", - "helpers": { - "html": "html" - }, - "language": { - "en-GB": "en-GB" - }, - "layouts": "layouts", - "models": { - "fields": "fields", - "forms": "forms", - "rules": "rules" - }, - "sql": { - "updates": { - "mysql": "mysql" - } - }, - "tables": "tables", - "views": "views" - }, - "site": { - "assets": { - "css": "css", - "images": "images", - "js": "js" - }, - "controllers": "controllers", - "helpers": "helpers", - "language": { - "en-GB": "en-GB" - }, - "layouts": "layouts", - "models": "models", - "views": "views" - }, - "media": { - "css": "css", - "images": "images", - "js": "js" - } - }, - "move": { - "static": { - "access.xml": { - "naam": "access.xml", - "path": "c0mp0n3nt/admin", - "rename": false, - "type": "file" - }, - "config.xml": { - "naam": "config.xml", - "path": "c0mp0n3nt/admin", - "rename": false, - "type": "file" - }, - "BaseController.php": { - "naam": "BaseController.php", - "path": "c0mp0n3nt/admin", - "rename": "new", - "newName": "controller.php", - "type": "file" - }, - "component.xml": { - "naam": "component.xml", - "path": "c0mp0n3nt/", - "rename": "component", - "type": "file" - }, - "component_admin.php": { - "naam": "component_admin.php", - "path": "c0mp0n3nt/admin", - "rename": "component_admin", - "type": "file" - }, - "admin.css": { - "naam": "admin.css", - "path": "c0mp0n3nt/admin/assets/css", - "rename": false, - "type": "file" - }, - "admin.js": { - "naam": "admin.js", - "path": "c0mp0n3nt/admin/assets/js", - "rename": false, - "type": "file" - }, - "site.css": { - "naam": "site.css", - "path": "c0mp0n3nt/site/assets/css", - "rename": false, - "type": "file" - }, - "site.js": { - "naam": "site.js", - "path": "c0mp0n3nt/site/assets/js", - "rename": false, - "type": "file" - }, - "batch_.php": { - "naam": "batch_.php", - "path": "c0mp0n3nt/admin/helpers/html", - "rename": false, - "type": "file" - }, - "batchselection.php": { - "naam": "batchselection.php", - "path": "c0mp0n3nt/admin/layouts", - "rename": false, - "type": "file" - }, - "component_site.php": { - "naam": "component_site.php", - "path": "c0mp0n3nt/site", - "rename": "component_site", - "type": "file" - }, - "router.php": { - "naam": "router.php", - "path": "c0mp0n3nt/site", - "rename": false, - "type": "file" - }, - "routeHelper.php": { - "naam": "routeHelper.php", - "path": "c0mp0n3nt/site/helpers", - "rename": "new", - "newName": "route.php", - "type": "file" - }, - "BaseControllerSITE.php": { - "naam": "BaseControllerSITE.php", - "path": "c0mp0n3nt/site", - "rename": "new", - "newName": "controller.php", - "type": "file" - }, - "Helper.php": { - "naam": "JCB_Helper.php", - "path": "c0mp0n3nt/admin/helpers", - "rename": "JCB_Helper", - "type": "file" - }, - "Helper_site.php": { - "naam": "JCB_Helper_site.php", - "path": "c0mp0n3nt/site/helpers", - "rename": "JCB_Helper_site", - "type": "file" - }, - "Helper_category.php": { - "naam": "Helper_category.php", - "path": "c0mp0n3nt/site/helpers", - "rename": "new", - "newName": "category.php", - "type": "file" - }, - "script.php": { - "naam": "script.php", - "path": "c0mp0n3nt/", - "rename": false, - "type": "file" - }, - "install.mysql.utf8.sql": { - "naam": "install.mysql.utf8.sql", - "path": "c0mp0n3nt/admin/sql", - "rename": false, - "type": "file" - }, - "uninstall.mysql.utf8.sql": { - "naam": "uninstall.mysql.utf8.sql", - "path": "c0mp0n3nt/admin/sql", - "rename": false, - "type": "file" - }, - "headercheck_admin.php": { - "naam": "headercheck_admin.php", - "path": "c0mp0n3nt/admin/helpers", - "rename": "new", - "newName": "headercheck.php", - "type": "file" - }, - "LICENSE.txt": { - "naam": "LICENSE.txt", - "path": "c0mp0n3nt/", - "rename": false, - "type": "file" - }, - "README.txt": { - "naam": "README.txt", - "path": "c0mp0n3nt/admin", - "rename": false, - "type": "file" - }, - "README.md": { - "naam": "README.md", - "path": "c0mp0n3nt/", - "rename": false, - "type": "file" - }, - "CHANGELOG.md": { - "naam": "CHANGELOG.md", - "path": "c0mp0n3nt/", - "rename": false, - "type": "file" - }, - "headercheck.php": { - "naam": "headercheck.php", - "path": "c0mp0n3nt/site/helpers", - "rename": false, - "type": "file" - }, - "import.gif": { - "naam": "import.gif", - "path": "c0mp0n3nt/admin/assets/images", - "rename": false, - "type": "file" - } - }, - "dynamic": { - "admin": { - "whmcs.php": { - "path": "c0mp0n3nt/admin", - "rename": false, - "type": "whmcs" - }, - "Helper_email.php": { - "path": "c0mp0n3nt/admin/helpers", - "rename": "Helper_", - "type": "emailer" - }, - "AdminControllerDashboard.php": { - "path": "c0mp0n3nt/admin/controllers", - "rename": "AdminControllerDashboard", - "type": "dashboard" - }, - "ListModelDASH.php": { - "path": "c0mp0n3nt/admin/models", - "rename": "ListModelDASH", - "type": "dashboard" - }, - "DASHJViewLagacy.php": { - "path": "c0mp0n3nt/admin/views/VIEW", - "rename": "new", - "newName": "view.html.php", - "type": "dashboard" - }, - "default_vdm.php": { - "path": "c0mp0n3nt/admin/views/VIEW/tmpl", - "rename": false, - "type": "dashboard" - }, - "default_main.php": { - "path": "c0mp0n3nt/admin/views/VIEW/tmpl", - "rename": false, - "type": "dashboard" - }, - "DASHdefault.php": { - "path": "c0mp0n3nt/admin/views/VIEW/tmpl", - "rename": "new", - "newName": "default.php", - "type": "dashboard" - }, - "dashboard.css": { - "path": "c0mp0n3nt/admin/assets/css", - "rename": false, - "type": "dashboard" - }, - "filter_forms.xml": { - "path": "c0mp0n3nt/admin/models/forms", - "rename": "filter_forms", - "type": "filter" - }, - "module_forms.xml": { - "path": "c0mp0n3nt/admin/models/forms", - "rename": "module_forms", - "type": "single" - }, - "module_forms.js": { - "path": "c0mp0n3nt/media/js", - "rename": "module_forms", - "type": "single" - }, - "edit.php": { - "path": "c0mp0n3nt/admin/views/VIEW/tmpl", - "rename": false, - "type": "single" - }, - "AdminModel.php": { - "path": "c0mp0n3nt/admin/models", - "rename": "AdminModel", - "type": "single" - }, - "FormController.php": { - "path": "c0mp0n3nt/admin/controllers", - "rename": "FormController", - "type": "single" - }, - "Table.php": { - "path": "c0mp0n3nt/admin/tables", - "rename": "Table", - "type": "single" - }, - "submitbutton.js": { - "path": "c0mp0n3nt/admin/views/VIEW", - "rename": false, - "type": "single" - }, - "HtmlView_edit.php": { - "path": "c0mp0n3nt/admin/views/VIEW", - "rename": "new", - "newName": "view.html.php", - "type": "single" - }, - "view.css": { - "path": "c0mp0n3nt/admin/assets/css", - "rename": "view", - "type": "single" - }, - "AdminController.php": { - "path": "c0mp0n3nt/admin/controllers", - "rename": "AdminController", - "type": "list" - }, - "ListModel.php": { - "path": "c0mp0n3nt/admin/models", - "rename": "ListModel", - "type": "list" - }, - "views.css": { - "path": "c0mp0n3nt/admin/assets/css", - "rename": "views", - "type": "list" - }, - "HtmlView_list.php": { - "path": "c0mp0n3nt/admin/views/VIEW", - "rename": "new", - "newName": "view.html.php", - "type": "list" - }, - "default.php": { - "path": "c0mp0n3nt/admin/views/VIEW/tmpl", - "rename": false, - "type": "list" - }, - "default_batch_body.php": { - "path": "c0mp0n3nt/admin/views/VIEW/tmpl", - "rename": false, - "type": "list" - }, - "default_batch_footer.php": { - "path": "c0mp0n3nt/admin/views/VIEW/tmpl", - "rename": false, - "type": "list" - }, - "default_toolbar.php": { - "path": "c0mp0n3nt/admin/views/VIEW/tmpl", - "rename": false, - "type": "list" - }, - "default_head.php": { - "path": "c0mp0n3nt/admin/views/VIEW/tmpl", - "rename": false, - "type": "list" - }, - "default_body.php": { - "path": "c0mp0n3nt/admin/views/VIEW/tmpl", - "rename": false, - "type": "list" - }, - "default_foot.php": { - "path": "c0mp0n3nt/admin/views/VIEW/tmpl", - "rename": false, - "type": "list" - }, - "JFormRule.php": { - "path": "c0mp0n3nt/admin/models/rules", - "rename": "JFormRule", - "type": "rule" - }, - "layout_admin.php": { - "path": "c0mp0n3nt/admin/layouts", - "rename": "layout_admin", - "type": "layout" - }, - "layoutoverride.php": { - "path": "c0mp0n3nt/admin/layouts/VIEW", - "rename": "layoutoverride", - "type": "layoutoverride" - }, - "layoutitems.php": { - "path": "c0mp0n3nt/admin/layouts/VIEW", - "rename": "layoutitems", - "type": "layoutitems" - }, - "layoutfull.php": { - "path": "c0mp0n3nt/admin/layouts/VIEW", - "rename": "layoutfull", - "type": "layoutfull" - }, - "layoutlinkedview.php": { - "path": "c0mp0n3nt/admin/layouts/VIEW", - "rename": "layoutlinkedview", - "type": "layoutlinkedview" - }, - "layouttitle.php": { - "path": "c0mp0n3nt/admin/layouts/VIEW", - "rename": "layouttitle", - "type": "layouttitle" - }, - "layoutpublished.php": { - "path": "c0mp0n3nt/admin/layouts/VIEW", - "rename": "layoutpublished", - "type": "layoutpublished" - }, - "layoutmetadata.php": { - "path": "c0mp0n3nt/admin/layouts/VIEW", - "rename": "layoutmetadata", - "type": "layoutmetadata" - }, - "JFormFieldCustom.php": { - "path": "c0mp0n3nt/admin/models/fields", - "rename": "JFormFieldCustom", - "type": "fieldcustom" - }, - "JFormFieldList.php": { - "path": "c0mp0n3nt/admin/models/fields", - "rename": "JFormFieldList", - "type": "fieldlist" - }, - "JFormFieldRadio.php": { - "path": "c0mp0n3nt/admin/models/fields", - "rename": "JFormFieldRadio", - "type": "fieldradio" - }, - "JFormFieldCheckboxes.php": { - "path": "c0mp0n3nt/admin/models/fields", - "rename": "JFormFieldCheckboxes", - "type": "fieldcheckboxes" - }, - "JFormFieldUser.php": { - "path": "c0mp0n3nt/admin/models/fields", - "rename": "JFormFieldUser", - "type": "fielduser" - }, - "BaseControllerAjax.php": { - "path": "c0mp0n3nt/admin/controllers", - "rename": "new", - "newName": "ajax.json.php", - "type": "ajax" - }, - "ListModelAjax.php": { - "path": "c0mp0n3nt/admin/models", - "rename": "new", - "newName": "ajax.php", - "type": "ajax" - }, - "BaseController_import.php": { - "path": "c0mp0n3nt/admin/controllers", - "rename": "new", - "newName": "import.php", - "type": "import" - }, - "BaseDatabaseModel_import.php": { - "path": "c0mp0n3nt/admin/models", - "rename": "new", - "newName": "import.php", - "type": "import" - }, - "HtmlView_import.php": { - "path": "c0mp0n3nt/admin/views/import", - "rename": "new", - "newName": "view.html.php", - "type": "import" - }, - "default_import.php": { - "path": "c0mp0n3nt/admin/views/import/tmpl", - "rename": "new", - "newName": "default.php", - "type": "import" - }, - "BaseController_import_custom.php": { - "path": "c0mp0n3nt/admin/controllers", - "rename": "BaseController_import_custom", - "type": "customimport" - }, - "BaseDatabaseModel_import_custom.php": { - "path": "c0mp0n3nt/admin/models", - "rename": "BaseDatabaseModel_import_custom", - "type": "customimport" - }, - "HtmlView_import_custom.php": { - "path": "c0mp0n3nt/admin/views/VIEW", - "rename": "new", - "newName": "view.html.php", - "type": "customimport" - }, - "default_import_custom.php": { - "path": "c0mp0n3nt/admin/views/VIEW/tmpl", - "rename": "new", - "newName": "default.php", - "type": "customimport" - }, - "BaseControllerHelp.php": { - "path": "c0mp0n3nt/admin/controllers", - "rename": "new", - "newName": "help.php", - "type": "help" - }, - "1.0.0.sql": { - "path": "c0mp0n3nt/admin/sql/updates/mysql", - "rename": "1.0.0", - "type": "sql_update" - }, - "update_server.xml": { - "path": "c0mp0n3nt/", - "rename": "update_server", - "type": "update_server" - }, - "viewFile.js": { - "path": "c0mp0n3nt/admin/assets/js", - "rename": "viewFile", - "type": "javascript_file" - } - }, - "site": { - "HtmlView_list_site.php": { - "path": "c0mp0n3nt/site/views/VIEW", - "rename": "new", - "newName": "view.html.php", - "type": "list" - }, - "ListModel_site.php": { - "path": "c0mp0n3nt/site/models", - "rename": "ListModel_site", - "type": "list" - }, - "views_site.css": { - "path": "c0mp0n3nt/site/assets/css", - "rename": "views_site", - "type": "list" - }, - "default_list_site.php": { - "path": "c0mp0n3nt/site/views/VIEW/tmpl", - "rename": "new", - "newName": "default.php", - "type": "list" - }, - "HtmlView_site.php": { - "path": "c0mp0n3nt/site/views/VIEW", - "rename": "new", - "newName": "view.html.php", - "type": "single" - }, - "view_site.css": { - "path": "c0mp0n3nt/site/assets/css", - "rename": "view_site", - "type": "single" - }, - "ItemModel_site.php": { - "path": "c0mp0n3nt/site/models", - "rename": "ItemModel_site", - "type": "single" - }, - "default_site.php": { - "path": "c0mp0n3nt/site/views/VIEW/tmpl", - "rename": "new", - "newName": "default.php", - "type": "single" - }, - "default_site_template.php": { - "path": "c0mp0n3nt/site/views/VIEW/tmpl", - "rename": "site_template", - "type": "template" - }, - "layout_site.php": { - "path": "c0mp0n3nt/site/layouts", - "rename": "layout_site", - "type": "layout" - }, - "layoutoverride.php": { - "path": "c0mp0n3nt/site/layouts/VIEW", - "rename": "layoutoverride", - "type": "layoutoverride" - }, - "layoutitems.php": { - "path": "c0mp0n3nt/site/layouts/VIEW", - "rename": "layoutitems", - "type": "layoutitems" - }, - "layoutfull.php": { - "path": "c0mp0n3nt/site/layouts/VIEW", - "rename": "layoutfull", - "type": "layoutfull" - }, - "layoutlinkedview.php": { - "path": "c0mp0n3nt/site/layouts/VIEW", - "rename": "layoutlinkedview", - "type": "layoutlinkedview" - }, - "layouttitle.php": { - "path": "c0mp0n3nt/site/layouts/VIEW", - "rename": "layouttitle", - "type": "layouttitle" - }, - "layoutpublished.php": { - "path": "c0mp0n3nt/site/layouts/VIEW", - "rename": "layoutpublished", - "type": "layoutpublished" - }, - "layoutmetadata.php": { - "path": "c0mp0n3nt/site/layouts/VIEW", - "rename": "layoutmetadata", - "type": "layoutmetadata" - }, - "default.xml": { - "path": "c0mp0n3nt/site/views/VIEW/tmpl", - "rename": false, - "type": "menu" - }, - "edit.xml": { - "path": "c0mp0n3nt/site/views/VIEW/tmpl", - "rename": false, - "type": "admin_menu" - }, - "module_forms.xml": { - "path": "c0mp0n3nt/site/models/forms", - "rename": "module_forms", - "type": "edit" - }, - "module_forms.js": { - "path": "c0mp0n3nt/site/models/forms", - "rename": "module_forms", - "type": "edit" - }, - "edit_site.php": { - "path": "c0mp0n3nt/site/views/VIEW/tmpl", - "rename": "new", - "newName": "edit.php", - "type": "edit" - }, - "AdminModel_site.php": { - "path": "c0mp0n3nt/site/models", - "rename": "AdminModel_site", - "type": "edit" - }, - "FormController_site.php": { - "path": "c0mp0n3nt/site/controllers", - "rename": "FormController_site", - "type": "edit" - }, - "submitbutton.js": { - "path": "c0mp0n3nt/site/views/VIEW", - "rename": false, - "type": "edit" - }, - "HtmlView_edit_site.php": { - "path": "c0mp0n3nt/site/views/VIEW", - "rename": "new", - "newName": "view.html.php", - "type": "edit" - }, - "view_site_edit.css": { - "path": "c0mp0n3nt/site/assets/css", - "rename": "view_site_edit", - "type": "edit" - }, - "BaseControllerAjaxSite.php": { - "path": "c0mp0n3nt/site/controllers", - "rename": "new", - "newName": "ajax.json.php", - "type": "ajax" - }, - "ListModelAjaxSite.php": { - "path": "c0mp0n3nt/site/models", - "rename": "new", - "newName": "ajax.php", - "type": "ajax" - }, - "BaseControllerHelp_site.php": { - "path": "c0mp0n3nt/site/controllers", - "rename": "new", - "newName": "help.php", - "type": "help" - }, - "FormController_custom_site.php": { - "path": "c0mp0n3nt/site/controllers", - "rename": "FormController_custom_site", - "type": "custom_form" - }, - "submitbutton_site.js": { - "path": "c0mp0n3nt/site/views/VIEW", - "rename": "new", - "newName": "submitbutton.js", - "type": "custom_form" - }, - "Helper_category_view.php": { - "path": "c0mp0n3nt/site/helpers", - "rename": "Helper_category_view", - "type": "category" - }, - "viewFileSite.js": { - "path": "c0mp0n3nt/site/assets/js", - "rename": "viewFileSite", - "type": "javascript_file" - } - }, - "custom_admin": { - "HtmlView_list_custom_admin.php": { - "path": "c0mp0n3nt/admin/views/VIEW", - "rename": "new", - "newName": "view.html.php", - "type": "list" - }, - "ListModel_custom_admin.php": { - "path": "c0mp0n3nt/admin/models", - "rename": "ListModel_custom_admin", - "type": "list" - }, - "default_list_custom_admin.php": { - "path": "c0mp0n3nt/admin/views/VIEW/tmpl", - "rename": "new", - "newName": "default.php", - "type": "list" - }, - "AdminController_custom_admin.php": { - "path": "c0mp0n3nt/admin/controllers", - "rename": "AdminController_custom_admin", - "type": "list" - }, - "views_custom_admin.css": { - "path": "c0mp0n3nt/admin/assets/css", - "rename": "views_custom_admin", - "type": "list" - }, - "view_custom_admin.css": { - "path": "c0mp0n3nt/admin/assets/css", - "rename": "view_custom_admin", - "type": "single" - }, - "HtmlView_custom_admin.php": { - "path": "c0mp0n3nt/admin/views/VIEW", - "rename": "new", - "newName": "view.html.php", - "type": "single" - }, - "ItemModel_custom_admin.php": { - "path": "c0mp0n3nt/admin/models", - "rename": "ItemModel_custom_admin", - "type": "single" - }, - "default_custom_admin.php": { - "path": "c0mp0n3nt/admin/views/VIEW/tmpl", - "rename": "new", - "newName": "default.php", - "type": "single" - }, - "BaseController_custom_admin.php": { - "path": "c0mp0n3nt/admin/controllers", - "rename": "BaseController_custom_admin", - "type": "single" - }, - "default_custom_admin_template.php": { - "path": "c0mp0n3nt/admin/views/VIEW/tmpl", - "rename": "custom_admin_template", - "type": "template" - }, - "layout_custom_admin.php": { - "path": "c0mp0n3nt/admin/layouts", - "rename": "layout_custom_admin", - "type": "layout" - }, - "viewFileCustomAdmin.js": { - "path": "c0mp0n3nt/admin/assets/js", - "rename": "viewFileCustomAdmin", - "type": "javascript_file" - } - } - } - } -} \ No newline at end of file diff --git a/admin/compiler/joomla_3/submitbutton.js b/admin/compiler/joomla_3/submitbutton.js index e459e897e..cd10493cd 100644 --- a/admin/compiler/joomla_3/submitbutton.js +++ b/admin/compiler/joomla_3/submitbutton.js @@ -4,7 +4,7 @@ Joomla.submitbutton = function(task) { if (task == ''){ return false; - } else { + } else { var action = task.split('.'); if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ Joomla.submitform(task, document.getElementById("adminForm")); diff --git a/admin/compiler/joomla_3/submitbutton_site.js b/admin/compiler/joomla_3/submitbutton_site.js index ed4feb712..40938b445 100644 --- a/admin/compiler/joomla_3/submitbutton_site.js +++ b/admin/compiler/joomla_3/submitbutton_site.js @@ -4,7 +4,7 @@ Joomla.submitbutton = function(task) { if (task == ''){ return false; - } else { + } else { var action = task.split('.'); if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ Joomla.submitform(task, document.getElementById("adminForm")); diff --git a/admin/compiler/joomla_3/whmcs.php b/admin/compiler/joomla_3/whmcs.php index 06e6cc3af..2bf15a8ff 100644 --- a/admin/compiler/joomla_3/whmcs.php +++ b/admin/compiler/joomla_3/whmcs.php @@ -3,8 +3,8 @@ * @package Joomla.Component.Builder * * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @github Joomla Component Builder + * @author Llewellyn van der Merwe + * @git Joomla Component Builder * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ diff --git a/admin/compiler/joomla_4/1.0.0.sql b/admin/compiler/joomla_4/1.0.0.sql new file mode 100644 index 000000000..2e5802f84 --- /dev/null +++ b/admin/compiler/joomla_4/1.0.0.sql @@ -0,0 +1 @@ +###UPDATE_VERSION_MYSQL### diff --git a/admin/compiler/joomla_4/ADMIN_AJAX_CONTROLLER.php b/admin/compiler/joomla_4/ADMIN_AJAX_CONTROLLER.php new file mode 100644 index 000000000..64690b202 --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_AJAX_CONTROLLER.php @@ -0,0 +1,102 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Session\Session; +use Joomla\Input\Input; +use Joomla\Utilities\ArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### Ajax Base Controller + * + * @since 1.6 + */ +class AjaxController extends BaseController +{ + /** + * Constructor. + * + * @param array $config An optional associative array of configuration settings. + * Recognized key values include 'name', 'default_task', 'model_path', and + * 'view_path' (this list is not meant to be comprehensive). + * @param ?MVCFactoryInterface $factory The factory. + * @param ?CMSApplication $app The Application for the dispatcher + * @param ?Input $input Input + * + * @since 3.0 + */ + public function __construct($config = [], ?MVCFactoryInterface $factory = null, ?CMSApplication $app = null, ?Input $input = null) + { + parent::__construct($config, $factory, $app, $input); + + // make sure all json stuff are set + $this->app->getDocument()->setMimeEncoding( 'application/json' ); + $this->app->setHeader('Content-Disposition','attachment;filename="getajax.json"'); + $this->app->setHeader('Access-Control-Allow-Origin', '*'); + // load the tasks###REGISTER_AJAX_TASK### + } + + /** + * The ajax function + * + * @since 3.10 + */ + public function ajax() + { + // get the user for later use + $user = $this->app->getIdentity(); + // get the input values + $jinput = $this->input ?? $this->app->input; + // check if we should return raw (DEFAULT TRUE SINCE J4) + $returnRaw = $jinput->get('raw', true, 'BOOLEAN'); + // return to a callback function + $callback = $jinput->get('callback', null, 'CMD'); + // Check Token! + $token = Session::getFormToken(); + $call_token = $jinput->get('token', 0, 'ALNUM'); + if($jinput->get($token, 0, 'ALNUM') || $token === $call_token) + { + // get the task + $task = $this->getTask(); + switch($task) + {###AJAX_INPUT_RETURN### + } + } + else + { + // return to a callback function + if($callback) + { + echo $callback."(".json_encode(['error' => 'There was an error! [129]']).");"; + } + elseif($returnRaw) + { + echo json_encode(['error' => 'There was an error! [129]']); + } + else + { + echo "(".json_encode(['error' => 'There was an error! [129]']).");"; + } + } + } +} diff --git a/admin/compiler/joomla_4/ADMIN_AJAX_MODEL.php b/admin/compiler/joomla_4/ADMIN_AJAX_MODEL.php new file mode 100644 index 000000000..43d6a8d19 --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_AJAX_MODEL.php @@ -0,0 +1,62 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Model; + +###AJAX_ADMIN_MODEL_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### Ajax List Model + * + * @since 1.6 + */ +class AjaxModel extends ListModel +{ + /** + * The component params. + * + * @var Registry + * @since 3.2.0 + */ + protected Registry $app_params; + + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + parent::__construct($config, $factory); + + $this->app_params = ComponentHelper::getParams('com_###component###'); + $this->app ??= Factory::getApplication(); + }###AJAX_MODEL_METHODS### +} diff --git a/admin/compiler/joomla_4/ADMIN_DISPLAY_CONTROLLER.php b/admin/compiler/joomla_4/ADMIN_DISPLAY_CONTROLLER.php new file mode 100644 index 000000000..21f59aafa --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_DISPLAY_CONTROLLER.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Controller; + +use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Router\Route; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### master admin display controller. + * + * @since 4.0 + */ +class DisplayController extends BaseController +{ + /** + * The default view. + * + * @var string + * @since 1.0.0 + */ + protected $default_view = '###DASHBOARDVIEW###'; + + /** + * display task + * + * @return void + */ + function display($cachable = false, $urlparams = false) + { + return parent::display($cachable, $urlparams); + } +} diff --git a/admin/compiler/joomla_4/ADMIN_EXTENSION_COMPONENT.php b/admin/compiler/joomla_4/ADMIN_EXTENSION_COMPONENT.php new file mode 100644 index 000000000..a3de713ee --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_EXTENSION_COMPONENT.php @@ -0,0 +1,80 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Extension; + +use Joomla\CMS\Association\AssociationServiceInterface; +use Joomla\CMS\Association\AssociationServiceTrait; +use Joomla\CMS\Categories\CategoryServiceInterface; +use Joomla\CMS\Categories\CategoryServiceTrait; +use Joomla\CMS\Component\Router\RouterServiceInterface; +use Joomla\CMS\Component\Router\RouterServiceTrait; +use Joomla\CMS\Extension\BootableExtensionInterface; +use Joomla\CMS\Extension\MVCComponent; +use Joomla\CMS\Factory; +use Joomla\CMS\Fields\FieldsServiceInterface; +use Joomla\CMS\Form\Form; +use Joomla\CMS\HTML\HTMLRegistryAwareTrait; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Tag\TagServiceInterface; +use Joomla\CMS\Tag\TagServiceTrait; +use Joomla\CMS\User\UserFactoryInterface; +// (soon) use ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Service\HTML\AdministratorService; +use Psr\Container\ContainerInterface; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Component class for com_###component### + * + * @since 4.0 + */ +class ###Component###Component extends MVCComponent implements + BootableExtensionInterface, + CategoryServiceInterface, + RouterServiceInterface +{ + use AssociationServiceTrait; + use HTMLRegistryAwareTrait; + use RouterServiceTrait; + use CategoryServiceTrait, TagServiceTrait { + CategoryServiceTrait::getTableNameForSection insteadof TagServiceTrait; + CategoryServiceTrait::getStateColumnForSection insteadof TagServiceTrait; + } + + /** + * Booting the extension. This is the function to set up the environment of the extension like + * registering new class loaders, etc. + * + * If required, some initial set up can be done from services of the container, eg. + * registering HTML services. + * + * @param ContainerInterface $container The container + * + * @return void + * + * @since 4.0.0 + */ + public function boot(ContainerInterface $container) + { + // (soon) $this->getRegistry()->register('###component###administrator', new AdministratorService()); + } + + // will fix these soon + protected function getTableNameForSection(string $section = null){} + public function countItems(array $items, string $section){} + +} diff --git a/admin/compiler/joomla_4/ADMIN_HEADERCHECK.php b/admin/compiler/joomla_4/ADMIN_HEADERCHECK.php new file mode 100644 index 000000000..6e94886ee --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_HEADERCHECK.php @@ -0,0 +1,135 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Helper; + +use Joomla\CMS\Factory; +use Joomla\CMS\Document\Document; +use Joomla\CMS\Application\CMSApplication; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Helper class for checking loaded scripts and styles in the document header. + * + * @since 3.2.0 + */ +class HeaderCheck +{ + /** + * @var CMSApplication Application object + * + * @since 3.2.0 + */ + protected CMSApplication $app; + + /** + * @var Document object + * + * @since 3.2.0 + */ + protected Document $document; + + /** + * Construct the app and document + * + * @since 3.2.0 + */ + public function __construct() + { + // Initializes the application object. + $this->app ??= Factory::getApplication(); + + // Initializes the document object. + $this->document = $this->app->getDocument(); + } + + /** + * Check if a JavaScript file is loaded in the document head. + * + * @param string $scriptName Name of the script to check. + * + * @return bool True if the script is loaded, false otherwise. + * @since 3.2.0 + */ + public function js_loaded(string $scriptName): bool + { + return $this->isLoaded($scriptName, 'scripts'); + } + + /** + * Check if a CSS file is loaded in the document head. + * + * @param string $scriptName Name of the stylesheet to check. + * + * @return bool True if the stylesheet is loaded, false otherwise. + * @since 3.2.0 + */ + public function css_loaded(string $scriptName): bool + { + return $this->isLoaded($scriptName, 'styleSheets'); + } + + /** + * Abstract method to check if a given script or stylesheet is loaded. + * + * @param string $scriptName Name of the script or stylesheet. + * @param string $type Type of asset to check ('scripts' or 'styleSheets'). + * + * @return bool True if the asset is loaded, false otherwise. + * @since 3.2.0 + */ + private function isLoaded(string $scriptName, string $type): bool + { + // UIkit specific check + if ($this->isUIkit($scriptName)) + { + return true; + } + + $head_data = $this->document->getHeadData(); + foreach (array_keys($head_data[$type]) as $script) + { + if (stristr($script, $scriptName)) + { + return true; + } + } + + return false; + } + + /** + * Check for UIkit framework specific conditions. + * + * @param string $scriptName Name of the script or stylesheet. + * + * @return bool True if UIkit specific conditions are met, false otherwise. + * @since 3.2.0 + */ + private function isUIkit(string $scriptName): bool + { + if (strpos($scriptName, 'uikit') !== false) + { + $get_template_name = $this->app->getTemplate('template')->template; + if (strpos($get_template_name, 'yoo') !== false) + { + return true; + } + } + return false; + } +} diff --git a/admin/compiler/joomla_4/ADMIN_HELPER_CLASS.php b/admin/compiler/joomla_4/ADMIN_HELPER_CLASS.php new file mode 100644 index 000000000..f7b123bd7 --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_HELPER_CLASS.php @@ -0,0 +1,937 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Helper; + +###ADMIN_POWER_HELPER### + +###ADMIN_HELPER_CLASS_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### component helper. + * + * @since 3.0 + */ +abstract class ###Component###Helper +{ + /** + * Composer Switch + * + * @var array + */ + protected static $composer = []; + + /** + * The Main Active Language + * + * @var string + */ + public static $langTag;###ADMIN_GLOBAL_EVENT_HELPER######CUSTOM_HELPER_SCRIPT######BOTH_CUSTOM_HELPER_SCRIPT### + + /** + * Load the Composer Vendors + */ + public static function composerAutoload($target) + { + // insure we load the composer vendor only once + if (!isset(self::$composer[$target])) + { + // get the function name + $functionName = Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe('compose' . $target); + // check if method exist + if (method_exists(__CLASS__, $functionName)) + { + return self::{$functionName}(); + } + return false; + } + return self::$composer[$target]; + } + + /** + * Load the Component xml manifest. + */ + public static function manifest() + { + $manifestUrl = JPATH_ADMINISTRATOR."/components/com_###component###/###component###.xml"; + return simplexml_load_file($manifestUrl); + } + + /** + * Joomla version object + */ + protected static $JVersion; + + /** + * set/get Joomla version + */ + public static function jVersion() + { + // check if set + if (!Super___91004529_94a9_4590_b842_e7c6b624ecf5___Power::check(self::$JVersion)) + { + self::$JVersion = new Version(); + } + return self::$JVersion; + } + + /** + * Load the Contributors details. + */ + public static function getContributors() + { + // get params + $params = ComponentHelper::getParams('com_###component###'); + // start contributors array + $contributors = []; + // get all Contributors (max 20) + $searchArray = range('0','20'); + foreach($searchArray as $nr) + { + if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 1 || $params->get("showContributor".$nr) == 3)) + { + // set link based of selected option + if($params->get("useContributor".$nr) == 1) + { + $link_front = ''; + $link_back = ''; + } + elseif($params->get("useContributor".$nr) == 2) + { + $link_front = ''; + $link_back = ''; + } + else + { + $link_front = ''; + $link_back = ''; + } + $contributors[$nr]['title'] = Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($params->get("titleContributor".$nr)); + $contributors[$nr]['name'] = $link_front.Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($params->get("nameContributor".$nr)).$link_back; + } + } + return $contributors; + }###HELP### + + /** + * Configure the Linkbar. + */ + public static function addSubmenu($submenu) + { + // load user for access menus + $user = Factory::getApplication()->getIdentity(); + // load the submenus to sidebar + ###SUBMENU### + }###HELPER_CREATEUSER######HELPER_UIKIT######HELPER_EXEL### + + /** + * Get a Variable + * + * @param string $table The table from which to get the variable + * @param string $where The value where + * @param string $whereString The target/field string where/name + * @param string $what The return field + * @param string $operator The operator between $whereString/field and $where/value + * @param string $main The component in which the table is found + * + * @return mix string/int/float + * @deprecated 3.3 Use Super___db87c339_5bb6_4291_a7ef_2c48ea1b06bc___Power::var(...); + */ + public static function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = '###component###') + { + return Super___db87c339_5bb6_4291_a7ef_2c48ea1b06bc___Power::var( + $table, + $where, + $whereString, + $what, + $operator, + $main + ); + } + + /** + * Get array of variables + * + * @param string $table The table from which to get the variables + * @param string $where The value where + * @param string $whereString The target/field string where/name + * @param string $what The return field + * @param string $operator The operator between $whereString/field and $where/value + * @param string $main The component in which the table is found + * @param bool $unique The switch to return a unique array + * + * @return array + * @deprecated 3.3 Use Super___db87c339_5bb6_4291_a7ef_2c48ea1b06bc___Power::vars(...); + */ + public static function getVars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = '###component###', $unique = true) + { + return Super___db87c339_5bb6_4291_a7ef_2c48ea1b06bc___Power::vars( + $table, + $where, + $whereString, + $what, + $operator, + $main, + $unique + ); + } + + /** + * Convert a json object to a string + * + * @input string $value The json string to convert + * + * @returns a string + * @deprecated 3.3 Use Super___4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::string(...); + */ + public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name') + { + return Super___4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::string( + $value, + $sperator, + $table, + $id, + $name + ); + } + + public static function isPublished($id,$type) + { + if ($type == 'raw') + { + $type = 'item'; + } + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true); + $query->select(array('a.published')); + $query->from('#__###component###_'.$type.' AS a'); + $query->where('a.id = '. (int) $id); + $query->where('a.published = 1'); + $db->setQuery($query); + $db->execute(); + $found = $db->getNumRows(); + if($found) + { + return true; + } + return false; + } + + public static function getGroupName($id) + { + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true); + $query->select(array('a.title')); + $query->from('#__usergroups AS a'); + $query->where('a.id = '. (int) $id); + $db->setQuery($query); + $db->execute(); + $found = $db->getNumRows(); + if($found) + { + return $db->loadResult(); + } + return $id; + } + + /** + * Get the action permissions + * + * @param string $view The related view name + * @param int $record The item to act upon + * @param string $views The related list view name + * @param mixed $target Only get this permission (like edit, create, delete) + * @param string $component The target component + * @param object $user The user whose permissions we are loading + * + * @return object The CMSObject of permission/authorised actions + * + */ + public static function getActions($view, &$record = null, $views = null, $target = null, $component = '###component###', $user = 'null') + { + // load the user if not given + if (!Super___91004529_94a9_4590_b842_e7c6b624ecf5___Power::check($user)) + { + // get the user object + $user = Factory::getApplication()->getIdentity(); + } + // load the CMSObject + $result = new CMSObject; + // make view name safe (just incase) + $view = Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($view); + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($views)) + { + $views = Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($views); + } + // get all actions from component + $actions = Access::getActionsFromFile( + JPATH_ADMINISTRATOR . '/components/com_' . $component . '/access.xml', + "/access/section[@name='component']/" + ); + // if non found then return empty CMSObject + if (empty($actions)) + { + return $result; + } + // get created by if not found + if (Super___91004529_94a9_4590_b842_e7c6b624ecf5___Power::check($record) && !isset($record->created_by) && isset($record->id)) + { + $record->created_by = Super___db87c339_5bb6_4291_a7ef_2c48ea1b06bc___Power::var($view, $record->id, 'id', 'created_by', '=', $component); + } + // set actions only set in component settings + $componentActions = array('core.admin', 'core.manage', 'core.options', 'core.export'); + // check if we have a target + $checkTarget = false; + if ($target) + { + // convert to an array + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($target)) + { + $target = array($target); + } + // check if we are good to go + if (Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($target)) + { + $checkTarget = true; + } + } + // loop the actions and set the permissions + foreach ($actions as $action) + { + // check target action filter + if ($checkTarget && self::filterActions($view, $action->name, $target)) + { + continue; + } + // set to use component default + $fallback = true; + // reset permission per/action + $permission = false; + $catpermission = false; + // set area + $area = 'comp'; + // check if the record has an ID and the action is item related (not a component action) + if (Super___91004529_94a9_4590_b842_e7c6b624ecf5___Power::check($record) && isset($record->id) && $record->id > 0 && !in_array($action->name, $componentActions) && + (strpos($action->name, 'core.') !== false || strpos($action->name, $view . '.') !== false)) + { + // we are in item + $area = 'item'; + // The record has been set. Check the record permissions. + $permission = $user->authorise($action->name, 'com_' . $component . '.' . $view . '.' . (int) $record->id); + // if no permission found, check edit own + if (!$permission) + { + // With edit, if the created_by matches current user then dig deeper. + if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) + { + // the correct target + $coreCheck = (array) explode('.', $action->name); + // check that we have both local and global access + if ($user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component . '.' . $view . '.' . (int) $record->id) && + $user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component)) + { + // allow edit + $result->set($action->name, true); + // set not to use global default + // because we already validated it + $fallback = false; + } + else + { + // do not allow edit + $result->set($action->name, false); + $fallback = false; + } + } + } + elseif (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($views) && isset($record->catid) && $record->catid > 0) + { + // we are in item + $area = 'category'; + // set the core check + $coreCheck = explode('.', $action->name); + $core = $coreCheck[0]; + // make sure we use the core. action check for the categories + if (strpos($action->name, $view) !== false && strpos($action->name, 'core.') === false ) + { + $coreCheck[0] = 'core'; + $categoryCheck = implode('.', $coreCheck); + } + else + { + $categoryCheck = $action->name; + } + // The record has a category. Check the category permissions. + $catpermission = $user->authorise($categoryCheck, 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid); + if (!$catpermission && !is_null($catpermission)) + { + // With edit, if the created_by matches current user then dig deeper. + if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) + { + // check that we have both local and global access + if ($user->authorise('core.edit.own', 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid) && + $user->authorise($core . '.edit.own', 'com_' . $component)) + { + // allow edit + $result->set($action->name, true); + // set not to use global default + // because we already validated it + $fallback = false; + } + else + { + // do not allow edit + $result->set($action->name, false); + $fallback = false; + } + } + } + } + } + // if allowed then fallback on component global settings + if ($fallback) + { + // if item/category blocks access then don't fall back on global + if ((($area === 'item') && !$permission) || (($area === 'category') && !$catpermission)) + { + // do not allow + $result->set($action->name, false); + } + // Finally remember the global settings have the final say. (even if item allow) + // The local item permissions can block, but it can't open and override of global permissions. + // Since items are created by users and global permissions is set by system admin. + else + { + $result->set($action->name, $user->authorise($action->name, 'com_' . $component)); + } + } + } + return $result; + } + + /** + * Filter the action permissions + * + * @param string $action The action to check + * @param array $targets The array of target actions + * + * @return boolean true if action should be filtered out + * + */ + protected static function filterActions(&$view, &$action, &$targets) + { + foreach ($targets as $target) + { + if (strpos($action, $view . '.' . $target) !== false || + strpos($action, 'core.' . $target) !== false) + { + return false; + break; + } + } + return true; + } + + /** + * Returns any Model object. + * + * @param string $type The model type to instantiate + * @param string $prefix Prefix for the model class name. Optional. + * @param string $component Component name the model belongs to. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * @throws \Exception + * @since 4.4 + */ + public static function getModel(string $type, string $prefix = 'Administrator', + string $component = '###component###', array $config = []) + { + // make sure the name is correct + $type = Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($type, 'F'); + $component = strtolower($component); + + if ($prefix !== 'Site' && $prefix !== 'Administrator') + { + $prefix = self::getPrefixFromModelPath($prefix); + } + + // Get the model through the MVCFactory + return Factory::getApplication()->bootComponent('com_' . $component)->getMVCFactory()->createModel($type, $prefix, $config); + } + + /** + * Get the prefix from the model path + * + * @param string $path The model path + * + * @return string The prefix value + * @since 4.4 + */ + protected static function getPrefixFromModelPath(string $path): string + { + // Check if $path starts with JPATH_ADMINISTRATOR path + if (str_starts_with($path, JPATH_ADMINISTRATOR . '/components/')) + { + return 'Administrator'; + } + // Check if $path starts with JPATH_SITE path + elseif (str_starts_with($path, JPATH_SITE . '/components/')) + { + return 'Site'; + } + + return 'Administrator'; + } + + /** + * Add to asset Table + */ + public static function setAsset($id, $table, $inherit = true) + { + $parent = Table::getInstance('Asset'); + $parent->loadByName('com_###component###'); + + $parentId = $parent->id; + $name = 'com_###component###.'.$table.'.'.$id; + $title = ''; + + $asset = Table::getInstance('Asset'); + $asset->loadByName($name); + + // Check for an error. + $error = $asset->getError(); + + if ($error) + { + return false; + } + else + { + // Specify how a new or moved node asset is inserted into the tree. + if ($asset->parent_id != $parentId) + { + $asset->setLocation($parentId, 'last-child'); + } + + // Prepare the asset to be stored. + $asset->parent_id = $parentId; + $asset->name = $name; + $asset->title = $title; + // get the default asset rules + $rules = self::getDefaultAssetRules('com_###component###', $table, $inherit); + if ($rules instanceof AccessRules) + { + $asset->rules = (string) $rules; + } + + if (!$asset->check() || !$asset->store()) + { + Factory::getApplication()->enqueueMessage($asset->getError(), 'warning'); + return false; + } + else + { + // Create an asset_id or heal one that is corrupted. + $object = new \StdClass(); + + // Must be a valid primary key value. + $object->id = $id; + $object->asset_id = (int) $asset->id; + + // Update their asset_id to link to the asset table. + return Factory::getDbo()->updateObject('#__###component###_'.$table, $object, 'id'); + } + } + return false; + } + + /** + * Gets the default asset Rules for a component/view. + */ + protected static function getDefaultAssetRules($component, $view, $inherit = true) + { + // if new or inherited + $assetId = 0; + // Only get the actual item rules if not inheriting + if (!$inherit) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + // check that there is a value + if ($db->getNumRows()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + } + } + // get asset rules + $result = Access::getAssetRules($assetId); + if ($result instanceof AccessRules) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($view !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + elseif ($inherit) + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count((array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules($_result); + // return filtered rules + return $rules; + } + } + return $result; + } + + /** + * xmlAppend + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement + * + * @return void + * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::append($xml, $node); + */ + public static function xmlAppend(&$xml, $node) + { + Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::append($xml, $node); + } + + /** + * xmlComment + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param string $comment The comment to inject + * + * @return void + * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::comment($xml, $comment); + */ + public static function xmlComment(&$xml, $comment) + { + Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::comment($xml, $comment); + } + + /** + * xmlAddAttributes + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param array $attributes The attributes to apply to the XML element + * + * @return null + * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::attributes($xml, $attributes); + */ + public static function xmlAddAttributes(&$xml, $attributes = []) + { + Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::attributes($xml, $attributes); + } + + /** + * xmlAddOptions + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param array $options The options to apply to the XML element + * + * @return void + * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::options($xml, $options); + */ + public static function xmlAddOptions(&$xml, $options = []) + { + Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::options($xml, $options); + } + + /** + * get the field object + * + * @param array $attributes The array of attributes + * @param string $default The default of the field + * @param array $options The options to apply to the XML element + * + * @return object + * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::field($attributes, $default, $options); + */ + public static function getFieldObject(&$attributes, $default = '', $options = null) + { + return Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::field($attributes, $default, $options); + } + + /** + * get the field xml + * + * @param array $attributes The array of attributes + * @param array $options The options to apply to the XML element + * + * @return object + * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::xml($attributes, $options); + */ + public static function getFieldXML(&$attributes, $options = null) + { + return Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::xml($attributes, $options); + } + + /** + * Render Bool Button + * + * @param array $args All the args for the button + * 0) name + * 1) additional (options class) // not used at this time + * 2) default + * 3) yes (name) + * 4) no (name) + * + * @return string The input html of the button + * + */ + public static function renderBoolButton() + { + $args = func_get_args(); + // check if there is additional button class + $additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time + // button attributes + $buttonAttributes = array( + 'type' => 'radio', + 'name' => isset($args[0]) ? Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($args[0]) : 'bool_button', + 'label' => isset($args[0]) ? Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe(Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($args[0]), 'Ww') : 'Bool Button', // not seen anyway + 'class' => 'btn-group', + 'filter' => 'INT', + 'default' => isset($args[2]) ? (int) $args[2] : 0); + // set the button options + $buttonOptions = array( + '1' => isset($args[3]) ? Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($args[3]) : 'JYES', + '0' => isset($args[4]) ? Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($args[4]) : 'JNO'); + // return the input + return Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::field($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input; + } + + /** + * Check if have an json string + * + * @input string The json string to check + * + * @returns bool true on success + * @deprecated 3.3 Use Super___4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::check($string); + */ + public static function checkJson($string) + { + return Super___4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::check($string); + } + + /** + * Check if have an object with a length + * + * @input object The object to check + * + * @returns bool true on success + * @deprecated 3.3 Use Super___91004529_94a9_4590_b842_e7c6b624ecf5___Power::check($object); + */ + public static function checkObject($object) + { + return Super___91004529_94a9_4590_b842_e7c6b624ecf5___Power::check($object); + } + + /** + * Check if have an array with a length + * + * @input array The array to check + * + * @returns bool/int number of items in array on success + * @deprecated 3.3 Use Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($array, $removeEmptyString); + */ + public static function checkArray($array, $removeEmptyString = false) + { + return Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($array, $removeEmptyString); + } + + /** + * Check if have a string with a length + * + * @input string The string to check + * + * @returns bool true on success + * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($string); + */ + public static function checkString($string) + { + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($string); + } + + /** + * Check if we are connected + * Thanks https://stackoverflow.com/a/4860432/1429677 + * + * @returns bool true on success + */ + public static function isConnected() + { + // If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right? + $connected = @fsockopen("www.example.com", 80); + // website, port (try 80 or 443) + if ($connected) + { + //action when connected + $is_conn = true; + fclose($connected); + } + else + { + //action in connection failure + $is_conn = false; + } + return $is_conn; + } + + /** + * Merge an array of array's + * + * @input array The arrays you would like to merge + * + * @returns array on success + * @deprecated 3.3 Use Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::merge($arrays); + */ + public static function mergeArrays($arrays) + { + return Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::merge($arrays); + } + + // typo sorry! + public static function sorten($string, $length = 40, $addTip = true) + { + return self::shorten($string, $length, $addTip); + } + + /** + * Shorten a string + * + * @input string The you would like to shorten + * + * @returns string on success + * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::shorten(...); + */ + public static function shorten($string, $length = 40, $addTip = true) + { + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::shorten($string, $length, $addTip); + } + + /** + * Making strings safe (various ways) + * + * @input string The you would like to make safe + * + * @returns string on success + * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe(...); + */ + public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true) + { + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe( + $string, + $type, + $spacer, + $replaceNumbers, + $keepOnlyCharacters + ); + } + + /** + * Convert none English strings to code usable string + * + * @input an string + * + * @returns a string + * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::transliterate($string); + */ + public static function transliterate($string) + { + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::transliterate($string); + } + + /** + * make sure a string is HTML save + * + * @input an html string + * + * @returns a string + * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html(...); + */ + public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40) + { + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html( + $var, + $charset, + $shorten, + $length + ); + }###HELPER_LICENSE_LOCK### + + /** + * Convert all int in a string to an English word string + * + * @input an string with numbers + * + * @returns a string + * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::numbers($string); + */ + public static function replaceNumbers($string) + { + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::numbers($string); + } + + /** + * Convert an integer into an English word string + * Thanks to Tom Nicholson + * + * @input an int + * @returns a string + * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::number($x); + */ + public static function numberToString($x) + { + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::number($x); + } + + /** + * Random Key + * + * @returns a string + * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::random($size); + */ + public static function randomkey($size) + { + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::random($size); + }###GET_CRYPT_KEY### +} diff --git a/admin/compiler/joomla_4/ADMIN_HELPER_CONTROLLER.php b/admin/compiler/joomla_4/ADMIN_HELPER_CONTROLLER.php new file mode 100644 index 000000000..215d4a778 --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_HELPER_CONTROLLER.php @@ -0,0 +1,128 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\Database\DatabaseInterface; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Session\Session; +use Joomla\Utilities\ArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### Help Base Controller + * + * @since 1.6 + */ +class HelpController extends BaseController +{ + public function __construct($config) + { + parent::__construct($config); + // load the tasks + $this->registerTask('getText', 'help'); + } + + public function help() + { + $user = Factory::getApplication()->getIdentity(); + $jinput = Factory::getApplication()->input; + // Check Token! + $token = Session::getFormToken(); + $call_token = $jinput->get('token', 0, 'ALNUM'); + if($user->id != 0 && ($jinput->get($token, 0, 'ALNUM') || $token === $call_token)) + { + $task = $this->getTask(); + switch($task){ + case 'getText': + try + { + $idValue = $jinput->get('id', 0, 'INT'); + if($idValue) + { + $result = $this->getHelpDocumentText($idValue); + } + else + { + $result = ''; + } + echo $result; + // stop execution gracefully + jexit(); + } + catch(Exception $e) + { + // stop execution gracefully + jexit(); + } + break; + } + } + else + { + // stop execution gracefully + jexit(); + } + } + + protected function getHelpDocumentText($id) + { + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true); + $query->select(array('a.title','a.content')); + $query->from('#__###component###_help_document AS a'); + $query->where('a.id = '.(int) $id); + $query->where('a.published = 1'); + $db->setQuery($query); + $db->execute(); + if($db->getNumRows()) + { + $text = []; + $document = $db->loadObject(); + // fix image issue + $images['src="images'] = 'src="'.Uri::root().'images'; + $images["src='images"] = "src='".Uri::root()."images"; + $images['src="/images'] = 'src="'.Uri::root().'images'; + $images["src='/images"] = "src='".Uri::root()."images"; + // set document template + $text[] = ""; + $text[] = ''; + $text[] = ""; + $text[] = ''; + $text[] = "".$document->title.""; + $text[] = ''; + $text[] = ''; + $text[] = ""; + $text[] = '
'; + $text[] = '
'; + $text[] = '
'; + // build the help text + $text[] = '

'.$document->title."

"; + $text[] = str_replace(array_keys($images),array_values($images),$document->content); + // end template + $text[] = '


'; + $text[] = '
'; + $text[] = ""; + $text[] = ""; + + return implode("\n",$text); + } + return false; + } +} diff --git a/admin/compiler/joomla_4/ADMIN_HELPER_EMAIL.php b/admin/compiler/joomla_4/ADMIN_HELPER_EMAIL.php new file mode 100644 index 000000000..4810aa03d --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_HELPER_EMAIL.php @@ -0,0 +1,474 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Helper; + +use Joomla\CMS\Factory; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Mail\Mail; +use Joomla\Registry\Registry; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### component email helper + * + * @since 3.0 + */ +abstract class ###Component###Email +{ + /** + * The active recipient + * + * @var activeRecipient (array) + */ + public static $active = []; + + /** + * Configuraiton object + * + * @var Registry + */ + public static ?Registry $config = null; + + /** + * Mailer object + * + * @var Mail + */ + public static ?Mail $mailer = null; + + /** + * Custom Headers + * + * @var array + */ + protected static array $header = []; + + /** + * Get a configuration object + * + */ + public static function getConfig() + { + if (!self::$config) + { + self::$config = ComponentHelper::getParams('com_###component###'); + } + + return self::$config; + } + + /** + * Returns the global mailer object, only creating it if it doesn't already exist. + * + */ + public static function getMailerInstance() + { + if (!self::$mailer) + { + self::$mailer = self::createMailer(); + } + + return self::$mailer; + } + + /** + * Check that a string looks like an email address. + * @param string $address The email address to check + * @param string|callable $patternselect A selector for the validation pattern to use : + * * `auto` Pick best pattern automatically; + * * `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0, PHP >= 5.3.2, 5.2.14; + * * `pcre` Use old PCRE implementation; + * * `php` Use PHP built-in FILTER_VALIDATE_EMAIL; + * * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements. + * * `noregex` Don't use a regex: super fast, really dumb. + * Alternatively you may pass in a callable to inject your own validator, for example: + * PHPMailer::validateAddress('user@example.com', function($address) { + * return (strpos($address, '@') !== false); + * }); + * You can also set the PHPMailer::$validator static to a callable, allowing built-in methods to use your validator. + * @return boolean + * @static + * @access public + */ + public static function validateAddress($address, $patternselect = null): bool + { + return self::getMailerInstance()->validateAddress($address, $patternselect); + } + + /** + * Get a mailer object. + * + * Returns the global {@link Mail} object, only creating it if it doesn't already exist. + * + * @return Mail object + * + * @see Mail + */ + public static function getMailer(): Mail + { + if (!self::$mailer) + { + self::$mailer = self::createMailer(); + } + + $copy = clone self::$mailer; + + return $copy; + } + + /** + * Create a mailer object + * + * @return Mail object + * + * @see Mail + */ + protected static function createMailer(): Mail + { + // set component params + $conf = self::getConfig(); + + // now load the mailer + $mailer = $conf->get('mailer', 'global'); + + // Create a Mail object + $mail = Mail::getInstance(); + + // check if set to global + if ('global' == $mailer) + { + // get the global details + $globalConf = Factory::getConfig(); + + $mailer = $globalConf->get('mailer'); + $smtpauth = ($globalConf->get('smtpauth') == 0) ? null : 1; + $smtpuser = $globalConf->get('smtpuser'); + $smtppass = $globalConf->get('smtppass'); + $smtphost = $globalConf->get('smtphost'); + $smtpsecure = $globalConf->get('smtpsecure'); + $smtpport = $globalConf->get('smtpport'); + $sendmail = $globalConf->get('sendmail'); + $mailfrom = $globalConf->get('mailfrom'); + $fromname = $globalConf->get('fromname'); + $replyto = $globalConf->get('replyto'); + $replytoname = $globalConf->get('replytoname'); + } + else + { + $smtpauth = ($conf->get('smtpauth') == 0) ? null : 1; + $smtpuser = $conf->get('smtpuser'); + $smtppass = $conf->get('smtppass'); + $smtphost = $conf->get('smtphost'); + $smtpsecure = $conf->get('smtpsecure'); + $smtpport = $conf->get('smtpport'); + $sendmail = $conf->get('sendmail'); + $mailfrom = $conf->get('emailfrom'); + $fromname = $conf->get('fromname'); + $replyto = $conf->get('replyto'); + $replytoname = $conf->get('replytoname'); + } + + // Set global sender + $mail->setSender(array($mailfrom, $fromname)); + + // set the global reply-to if found + if ($replyto && $replytoname) + { + $mail->ClearReplyTos(); + $mail->addReplyTo($replyto, $replytoname); + } + + // Default mailer is to use PHP's mail function + switch ($mailer) + { + case 'smtp': + // set the SMTP option + $mail->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport); + break; + + case 'sendmail': + // set the sendmail option + $mail->useSendmail($sendmail); + $mail->IsSendmail(); + break; + + default: + $mail->IsMail(); + break; + } + + return $mail; + } + + /** + * Set a Mail custom header. + * + * @return void + */ + public static function setHeader($target, $value) + { + // set the header + self::$header[$target] = $value; + } + + /** + * Send an email + * + * @return bool on success + * + */ + public static function send($recipient, $subject, $body, $textonly, $mode = 0, $bounce_email = null, $idsession = null, $mailreply = null, $replyname = null , $mailfrom = null, $fromname = null, $cc = null, $bcc = null, $attachment = null, $embeded = null , $embeds = null) + { + // Get a Mail instance + $mail = self::getMailer(); + + // set component params + $conf = self::getConfig(); + + // set if we have override + if ($mailfrom && $fromname) + { + $mail->setSender(array($mailfrom, $fromname)); + } + + // load the bounce email as sender if set + if (!is_null($bounce_email)) + { + $mail->Sender = $bounce_email; + } + + // Add tag to email to identify it + if (!is_null($idsession)) + { + $mail->addCustomHeader('X-VDMmethodID:'.$idsession); + } + + // set headers if found + if (isset(self::$header) && is_array(self::$header) && count((array)self::$header) > 0) + { + foreach (self::$header as $_target => $_value) + { + $mail->addCustomHeader($_target.':'.$_value); + } + } + + // set the subject & Body + $mail->setSubject($subject); + $mail->setBody($body); + + // Are we sending the email as HTML? + if ($mode) + { + $mail->IsHTML(true); + $mail->AltBody = $textonly; + } + + //embed images + if ($embeded) + { + if(Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($embeds)) + { + foreach($embeds as $embed) + { + $mail->AddEmbeddedImage($embed->Path,$embed->FileName); + } + } + } + + $mail->addRecipient($recipient); + $mail->addCC($cc); + $mail->addBCC($bcc); + $mail->addAttachment($attachment); + + // Take care of reply email addresses + if (is_array($mailreply)) + { + $mail->ClearReplyTos(); + $numReplyTo = count((array)$mailreply); + for ($i=0; $i < $numReplyTo; $i++) + { + $mail->addReplyTo($mailreply[$i], $replyname[$i]); + } + } + elseif (!empty($mailreply)) + { + $mail->ClearReplyTos(); + $mail->addReplyTo($mailreply, $replyname); + } + + // check if we can add the DKIM to email + if ($conf->get('enable_dkim')) + { + if (!empty($conf->get('dkim_domain')) && !empty($conf->get('dkim_selector')) && !empty($conf->get('dkim_private')) && !empty($conf->get('dkim_public'))) + { + $mail->DKIM_domain = $conf->get('dkim_domain'); + $mail->DKIM_selector = $conf->get('dkim_selector'); + $mail->DKIM_identity = $conf->get('dkim_identity'); + $mail->DKIM_passphrase = $conf->get('dkim_passphrase'); + + $tmp = tempnam(sys_get_temp_dir(), 'VDM'); + $h = fopen($tmp, 'w'); + fwrite($h, $conf->get('dkim_private')); + fclose($h); + $mail->DKIM_private = $tmp; + } + } + + $sendmail = $mail->Send(); + + if ($conf->get('enable_dkim') && !empty($conf->get('dkim_domain')) && !empty($conf->get('dkim_selector')) && !empty($conf->get('dkim_private')) && !empty($conf->get('dkim_public'))) + { + @unlink($tmp); + } + + if (method_exists('###Component###Helper','storeMessage')) + { + // if we have active recipient details + if (isset(self::$active[$recipient])) + { + // store the massage if the method is set + ###Component###Helper::storeMessage($sendmail, self::$active[$recipient], $subject, $body, $textonly, $mode, 'email'); + // clear memory + unset(self::$active[$recipient]); + } + else + { + // store the massage if the method is set + ###Component###Helper::storeMessage($sendmail, $recipient, $subject, $body, $textonly, $mode, 'email'); + } + } + + return $sendmail; + } + + /** + * Set html text (in a row) and subject (as title) to a email table. + * do not use

instead use
+ * in your html that you pass to this method + * since it is a table row it does not + * work well with paragraphs + * + * @return string on success + * + */ + public static function setBasicBody($html, $subject) + { + $body = []; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = "" . $subject . ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = $html; + $body[] = ""; + $body[] = ""; + + return implode("\n", $body); + } + + /** + * Set html text (in a row) and subject (as title) to a email table. + * do not use

instead use
+ * in your html that you pass to this method + * since it is a table row it does not + * work well with paragraphs + * + * @return string on success + * + */ + public static function setTableBody($html, $subject) + { + $body = []; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = "" . $subject . ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = "\n"; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = "
"; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = "
"; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = "
"; + $body[] = $html; + $body[] = "
"; + $body[] = ""; + $body[] = "
"; + $body[] = ""; + $body[] = "
"; + $body[] = ""; + $body[] = ""; + $body[] = ""; + + return implode("\n", $body); + } +} diff --git a/admin/compiler/joomla_4/ADMIN_IMPORT_CONTROLLER.php b/admin/compiler/joomla_4/ADMIN_IMPORT_CONTROLLER.php new file mode 100644 index 000000000..dff0372db --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_IMPORT_CONTROLLER.php @@ -0,0 +1,63 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Controller; + +###IMPORT_CONTROLLER_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### Import Base Controller + * + * @since 1.6 + */ +class ImportController extends BaseController +{ + /** + * Import an spreadsheet. + * + * @return void + */ + public function import() + { + // Check for request forgeries + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + $model = $this->getModel('import'); + if ($model->import()) + { + $cache = Factory::getCache('mod_menu'); + $cache->clean(); + // TODO: Reset the users acl here as well to kill off any missing bits + } + + $app = Factory::getApplication(); + $redirect_url = $app->getUserState('com_###component###.redirect_url'); + if (empty($redirect_url)) + { + $redirect_url = Route::_('index.php?option=com_###component###&view=import', false); + } + else + { + // wipe out the user state when we're going to redirect + $app->setUserState('com_###component###.redirect_url', ''); + $app->setUserState('com_###component###.message', ''); + $app->setUserState('com_###component###.extension_message', ''); + } + $this->setRedirect($redirect_url); + } +} diff --git a/admin/compiler/joomla_4/ADMIN_IMPORT_CONTROLLER_CUSTOM.php b/admin/compiler/joomla_4/ADMIN_IMPORT_CONTROLLER_CUSTOM.php new file mode 100644 index 000000000..516800bda --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_IMPORT_CONTROLLER_CUSTOM.php @@ -0,0 +1,63 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Controller; + +###IMPORT_CUSTOM_CONTROLLER_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### ###View### Base Controller + * + * @since 1.6 + */ +class ###View###importController extends BaseController +{ + /** + * Import an spreadsheet. + * + * @return void + */ + public function import() + { + // Check for request forgeries + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + $model = $this->getModel('###View###'); + if ($model->import()) + { + $cache = Factory::getCache('mod_menu'); + $cache->clean(); + // TODO: Reset the users acl here as well to kill off any missing bits + } + + $app = Factory::getApplication(); + $redirect_url = $app->getUserState('com_###component###.redirect_url'); + if (empty($redirect_url)) + { + $redirect_url = Route::_('index.php?option=com_###component###&view=###view###', false); + } + else + { + // wipe out the user state when we're going to redirect + $app->setUserState('com_###component###.redirect_url', ''); + $app->setUserState('com_###component###.message', ''); + $app->setUserState('com_###component###.extension_message', ''); + } + $this->setRedirect($redirect_url); + } +} diff --git a/admin/compiler/joomla_4/ADMIN_IMPORT_HTML.php b/admin/compiler/joomla_4/ADMIN_IMPORT_HTML.php new file mode 100644 index 000000000..bafc18095 --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_IMPORT_HTML.php @@ -0,0 +1,110 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\View\Import; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Toolbar\ToolbarHelper; +use ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Helper\###Component###Helper; + +// No direct access to this file +\defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED### + +/** + * ###Component### Import Html View + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + protected $headerList; + protected $hasPackage = false; + protected $headers; + protected $hasHeader = 0; + protected $dataType; + + /** + * Display the view + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + $paths = new \StdClass; + $paths->first = ''; + $state = $this->get('state'); + + $this->paths = &$paths; + $this->state = &$state; + // get global action permissions + $this->canDo = ###Component###Helper::getActions('import'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // get the session object + $session = Factory::getSession(); + // check if it has package + $this->hasPackage = $session->get('hasPackage', false); + $this->dataType = $session->get('dataType', false); + if($this->hasPackage && $this->dataType) + { + $this->headerList = json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS', false),true); + $this->headers = ###Component###Helper::getFileHeaders($this->dataType); + // clear the data type + $session->clear('dataType'); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_###COMPONENT###_IMPORT_TITLE'), 'upload'); + + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_###component###'); + } + + // set help url for this view if found + $this->help_url = ###Component###Helper::getHelpUrl('import'); + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($this->help_url)) + { + ToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); + } + } +} diff --git a/admin/compiler/joomla_4/ADMIN_IMPORT_HTML_CUSTOM.php b/admin/compiler/joomla_4/ADMIN_IMPORT_HTML_CUSTOM.php new file mode 100644 index 000000000..3fad91b86 --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_IMPORT_HTML_CUSTOM.php @@ -0,0 +1,60 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\View\###View###Import; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Helper\###Component###Helper; + +// No direct access to this file +\defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED### + +/** + * ###Component### ###View### Html View + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{###IMPORT_DISPLAY_METHOD_CUSTOM### + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_###COMPONENT###_IMPORT_TITLE'), 'upload'); + + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_###component###'); + } + + // set help url for this view if found + $this->help_url = ###Component###Helper::getHelpUrl('###view###'); + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($this->help_url)) + { + ToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); + } + } +} diff --git a/admin/compiler/joomla_4/ADMIN_IMPORT_MODEL.php b/admin/compiler/joomla_4/ADMIN_IMPORT_MODEL.php new file mode 100644 index 000000000..f1f5f6575 --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_IMPORT_MODEL.php @@ -0,0 +1,460 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Model; + +###IMPORT_MODEL_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/*** + * ###Component### Import Base Database Model + * + * @since 1.6 + */ +class ImportModel extends BaseDatabaseModel +{ + // set uploading values + protected $use_streams = false; + protected $allow_unsafe = false; + protected $safeFileOptions = []; + + /** + * @var object JTable object + */ + protected $_table = null; + + /** + * @var object JTable object + */ + protected $_url = null; + + /** + * Model context string. + * + * @var string + */ + protected $_context = 'com_###component###.import'; + + /** + * Import Settings + */ + protected $getType = NULL; + protected $dataType = NULL; + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @return void + * + */ + protected function populateState() + { + $app = Factory::getApplication('administrator'); + + $this->setState('message', $app->getUserState('com_###component###.message')); + $app->setUserState('com_###component###.message', ''); + + // Recall the 'Import from Directory' path. + $path = $app->getUserStateFromRequest($this->_context . '.import_directory', 'import_directory', $app->get('tmp_path')); + $this->setState('import.directory', $path); + parent::populateState(); + } + + /** + * Import an spreadsheet from either folder, url or upload. + * + * @return boolean result of import + * + */ + public function import() + { + $this->setState('action', 'import'); + $app = Factory::getApplication(); + $session = Factory::getSession(); + $package = null; + $continue = false; + // get import type + $this->getType = $app->input->getString('gettype', NULL); + // get import type + $this->dataType = $session->get('dataType_VDM_IMPORTINTO', NULL); + + if ($package === null) + { + switch ($this->getType) + { + case 'folder': + // Remember the 'Import from Directory' path. + $app->getUserStateFromRequest($this->_context . '.import_directory', 'import_directory'); + $package = $this->_getPackageFromFolder(); + break; + + case 'upload': + $package = $this->_getPackageFromUpload(); + break; + + case 'url': + $package = $this->_getPackageFromUrl(); + break; + + case 'continue': + $continue = true; + $package = $session->get('package', null); + $package = json_decode($package, true); + // clear session + $session->clear('package'); + $session->clear('dataType'); + $session->clear('hasPackage'); + break; + + default: + $app->setUserState('com_###component###.message', Text::_('COM_###COMPONENT###_IMPORT_NO_IMPORT_TYPE_FOUND')); + + return false; + break; + } + } + // Was the package valid? + if (!$package || !$package['type']) + { + if (in_array($this->getType, array('upload', 'url'))) + { + $this->remove($package['packagename']); + } + + $app->setUserState('com_###component###.message', Text::_('COM_###COMPONENT###_IMPORT_UNABLE_TO_FIND_IMPORT_PACKAGE')); + return false; + } + + // first link data to table headers + if(!$continue){ + $package = json_encode($package); + $session->set('package', $package); + $session->set('dataType', $this->dataType); + $session->set('hasPackage', true); + return true; + } + + // set the data + $headerList = json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS', false), true); + if (!$this->setData($package,$this->dataType,$headerList)) + { + // There was an error importing the package + $msg = Text::_('COM_###COMPONENT###_IMPORT_ERROR'); + $back = $session->get('backto_VDM_IMPORT', NULL); + if ($back) + { + $app->setUserState('com_###component###.redirect_url', 'index.php?option=com_###component###&view='.$back); + $session->clear('backto_VDM_IMPORT'); + } + $result = false; + } + else + { + // Package imported sucessfully + $msg = Text::sprintf('COM_###COMPONENT###_IMPORT_SUCCESS', $package['packagename']); + $back = $session->get('backto_VDM_IMPORT', NULL); + if ($back) + { + $app->setUserState('com_###component###.redirect_url', 'index.php?option=com_###component###&view='.$back); + $session->clear('backto_VDM_IMPORT'); + } + $result = true; + } + + // Set some model state values + $app->enqueueMessage($msg); + + // remove file after import + $this->remove($package['packagename']); + $session->clear($this->getType.'_VDM_IMPORTHEADERS'); + + return $result; + } + + /** + * Works out an importation spreadsheet from a HTTP upload + * + * @return spreadsheet definition or false on failure + */ + protected function _getPackageFromUpload() + { + // Get the uploaded file information + $app = Factory::getApplication(); + $input = $app->input; + + // Do not change the filter type 'raw'. We need this to let files containing PHP code to upload. See JInputFiles::get. + $userfile = $input->files->get('import_package', null, 'raw'); + + // Make sure that file uploads are enabled in php + if (!(bool) ini_get('file_uploads')) + { + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_WARNIMPORTFILE'), 'warning'); + return false; + } + + // If there is no uploaded file, we have a problem... + if (!is_array($userfile)) + { + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_NO_FILE_SELECTED'), 'warning'); + return false; + } + + // Check if there was a problem uploading the file. + if ($userfile['error'] || $userfile['size'] < 1) + { + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_WARNIMPORTUPLOADERROR'), 'warning'); + return false; + } + + // Build the appropriate paths + $config = Factory::getConfig(); + $tmp_dest = $config->get('tmp_path') . '/' . $userfile['name']; + $tmp_src = $userfile['tmp_name']; + + // Move uploaded file + $p_file = File::upload($tmp_src, $tmp_dest, $this->use_streams, $this->allow_unsafe, $this->safeFileOptions); + + // Was the package downloaded? + if (!$p_file) + { + $session = Factory::getSession(); + $session->clear('package'); + $session->clear('dataType'); + $session->clear('hasPackage'); + // was not uploaded + return false; + } + + // check that this is a valid spreadsheet + $package = $this->check($userfile['name']); + + return $package; + } + + /** + * Import an spreadsheet from a directory + * + * @return array Spreadsheet details or false on failure + * + */ + protected function _getPackageFromFolder() + { + $app = Factory::getApplication(); + $input = $app->input; + + // Get the path to the package to import + $p_dir = $input->getString('import_directory'); + $p_dir = Path::clean($p_dir); + // Did you give us a valid path? + if (!file_exists($p_dir)) + { + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_PLEASE_ENTER_A_PACKAGE_DIRECTORY'), 'warning'); + return false; + } + + // Detect the package type + $type = $this->getType; + + // Did you give us a valid package? + if (!$type) + { + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE'), 'warning'); + } + + // check the extention + if(!$this->checkExtension($p_dir)) + { + // set error message + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); + return false; + } + + $package['packagename'] = null; + $package['dir'] = $p_dir; + $package['type'] = $type; + + return $package; + } + + /** + * Import an spreadsheet from a URL + * + * @return Package details or false on failure + * + */ + protected function _getPackageFromUrl() + { + $app = Factory::getApplication(); + $input = $app->input; + + // Get the URL of the package to import + $url = $input->getString('import_url'); + + // Did you give us a URL? + if (!$url) + { + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_ENTER_A_URL'), 'warning'); + return false; + } + + // Download the package at the URL given + $p_file = InstallerHelper::downloadPackage($url); + + // Was the package downloaded? + if (!$p_file) + { + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_INVALID_URL'), 'warning'); + return false; + } + + // check that this is a valid spreadsheet + $package = $this->check($p_file); + + return $package; + } + + /** + * Check a file and verifies it as a spreadsheet file + * Supports .csv .xlsx .xls and .ods + * + * @param string $p_filename The uploaded package filename or import directory + * + * @return array of elements + * + */ + protected function check($archivename) + { + $app = Factory::getApplication(); + // Clean the name + $archivename = Path::clean($archivename); + + // check the extention + if(!$this->checkExtension($archivename)) + { + // Cleanup the import files + $this->remove($archivename); + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); + return false; + } + + $config = Factory::getConfig(); + // set Package Name + $check['packagename'] = $archivename; + + // set directory + $check['dir'] = $config->get('tmp_path'). '/' .$archivename; + + // set type + $check['type'] = $this->getType; + + return $check; + }###IMPORT_EXT_METHOD### + + /** + * Clean up temporary uploaded spreadsheet + * + * @param string $package Name of the uploaded spreadsheet file + * + * @return boolean True on success + * + */ + protected function remove($package) + { + jimport('joomla.filesystem.file'); + + $config = Factory::getConfig(); + $package = $config->get('tmp_path'). '/' .$package; + + // Is the package file a valid file? + if (is_file($package)) + { + File::delete($package); + } + elseif (is_file(Path::clean($package))) + { + // It might also be just a base filename + File::delete(Path::clean($package)); + } + }###IMPORT_SETDATA_METHOD######IMPORT_SAVE_METHOD### + + protected function getAlias($name,$type = false) + { + // sanitize the name to an alias + if (Factory::getConfig()->get('unicodeslugs') == 1) + { + $alias = OutputFilter::stringURLUnicodeSlug($name); + } + else + { + $alias = OutputFilter::stringURLSafe($name); + } + // must be a uniqe alias + if ($type) + { + return $this->getUniqe($alias,'alias',$type); + } + return $alias; + } + + /** + * Method to generate a uniqe value. + * + * @param string $field name. + * @param string $value data. + * @param string $type table. + * + * @return string New value. + */ + protected function getUniqe($value,$field,$type) + { + // insure the filed is always uniqe + while (isset($this->uniqeValueArray[$type][$field][$value])) + { + $value = StringHelper::increment($value, 'dash'); + } + $this->uniqeValueArray[$type][$field][$value] = $value; + return $value; + } + + protected function getAliasesUsed($table) + { + // Get a db connection. + $db = $this->getDatabase(); + // first we check if there is a alias column + $columns = $db->getTableColumns('#__###component###_'.$table); + if(isset($columns['alias'])){ + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('alias'))); + $query->from($db->quoteName('#__###component###_'.$table)); + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $aliases = $db->loadColumn(); + foreach($aliases as $alias) + { + $this->uniqeValueArray[$table]['alias'][$alias] = $alias; + } + } + return true; + } + return false; + } +} diff --git a/admin/compiler/joomla_4/ADMIN_IMPORT_MODEL_CUSTOM.php b/admin/compiler/joomla_4/ADMIN_IMPORT_MODEL_CUSTOM.php new file mode 100644 index 000000000..b30e5846e --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_IMPORT_MODEL_CUSTOM.php @@ -0,0 +1,351 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Model; + +###IMPORT_CUSTOM_MODEL_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### ###View### Base Database Model + * + * @since 1.6 + */ +class ###View###importModel extends BaseDatabaseModel +{ + // set uploading values + protected $use_streams = false; + protected $allow_unsafe = false; + protected $safeFileOptions = []; + + /** + * @var object JTable object + */ + protected $_table = null; + + /** + * @var object JTable object + */ + protected $_url = null; + + /** + * Model context string. + * + * @var string + */ + protected $_context = 'com_###component###.###view###'; + + /** + * Import Settings + */ + protected $getType = NULL; + protected $dataType = NULL; + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @return void + * + */ + protected function populateState() + { + $app = Factory::getApplication('administrator'); + + $this->setState('message', $app->getUserState('com_###component###.message')); + $app->setUserState('com_###component###.message', ''); + + // Recall the 'Import from Directory' path. + $path = $app->getUserStateFromRequest($this->_context . '.import_directory', 'import_directory', $app->get('tmp_path')); + $this->setState('import.directory', $path); + parent::populateState(); + } + ###IMPORT_METHOD_CUSTOM### + + /** + * Works out an importation spreadsheet from a HTTP upload + * + * @return spreadsheet definition or false on failure + */ + protected function _getPackageFromUpload() + { + // Get the uploaded file information + $app = Factory::getApplication(); + $input = $app->input; + + // Do not change the filter type 'raw'. We need this to let files containing PHP code to upload. See JInputFiles::get. + $userfile = $input->files->get('import_package', null, 'raw'); + + // Make sure that file uploads are enabled in php + if (!(bool) ini_get('file_uploads')) + { + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_WARNIMPORTFILE'), 'warning'); + return false; + } + + // If there is no uploaded file, we have a problem... + if (!is_array($userfile)) + { + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_NO_FILE_SELECTED'), 'warning'); + return false; + } + + // Check if there was a problem uploading the file. + if ($userfile['error'] || $userfile['size'] < 1) + { + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_WARNIMPORTUPLOADERROR'), 'warning'); + return false; + } + + // Build the appropriate paths + $config = Factory::getConfig(); + $tmp_dest = $config->get('tmp_path') . '/' . $userfile['name']; + $tmp_src = $userfile['tmp_name']; + + // Move uploaded file + $p_file = File::upload($tmp_src, $tmp_dest, $this->use_streams, $this->allow_unsafe, $this->safeFileOptions); + + // Was the package downloaded? + if (!$p_file) + { + $session = Factory::getSession(); + $session->clear('package'); + $session->clear('dataType'); + $session->clear('hasPackage'); + // was not uploaded + return false; + } + + // check that this is a valid spreadsheet + $package = $this->check($userfile['name']); + + return $package; + } + + /** + * Import an spreadsheet from a directory + * + * @return array Spreadsheet details or false on failure + * + */ + protected function _getPackageFromFolder() + { + $app = Factory::getApplication(); + $input = $app->input; + + // Get the path to the package to import + $p_dir = $input->getString('import_directory'); + $p_dir = Path::clean($p_dir); + // Did you give us a valid path? + if (!file_exists($p_dir)) + { + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_PLEASE_ENTER_A_PACKAGE_DIRECTORY'), 'warning'); + return false; + } + + // Detect the package type + $type = $this->getType; + + // Did you give us a valid package? + if (!$type) + { + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE'), 'warning'); + } + + // check the extention + if(!$this->checkExtension($p_dir)) + { + // set error message + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); + return false; + } + + $package['packagename'] = null; + $package['dir'] = $p_dir; + $package['type'] = $type; + + return $package; + } + + /** + * Import an spreadsheet from a URL + * + * @return Package details or false on failure + * + */ + protected function _getPackageFromUrl() + { + $app = Factory::getApplication(); + $input = $app->input; + + // Get the URL of the package to import + $url = $input->getString('import_url'); + + // Did you give us a URL? + if (!$url) + { + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_ENTER_A_URL'), 'warning'); + return false; + } + + // Download the package at the URL given + $p_file = InstallerHelper::downloadPackage($url); + + // Was the package downloaded? + if (!$p_file) + { + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_INVALID_URL'), 'warning'); + return false; + } + + // check that this is a valid spreadsheet + $package = $this->check($p_file); + + return $package; + } + + /** + * Check a file and verifies it as a spreadsheet file + * Supports .csv .xlsx .xls and .ods + * + * @param string $p_filename The uploaded package filename or import directory + * + * @return array of elements + * + */ + protected function check($archivename) + { + $app = Factory::getApplication(); + // Clean the name + $archivename = Path::clean($archivename); + + // check the extention + if(!$this->checkExtension($archivename)) + { + // Cleanup the import files + $this->remove($archivename); + $app->enqueueMessage(Text::_('COM_###COMPONENT###_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); + return false; + } + + $config = Factory::getConfig(); + // set Package Name + $check['packagename'] = $archivename; + + // set directory + $check['dir'] = $config->get('tmp_path'). '/' .$archivename; + + // set type + $check['type'] = $this->getType; + + return $check; + } + ###IMPORT_EXT_METHOD### + + /** + * Clean up temporary uploaded spreadsheet + * + * @param string $package Name of the uploaded spreadsheet file + * + * @return boolean True on success + * + */ + protected function remove($package) + { + $config = Factory::getConfig(); + $package = $config->get('tmp_path'). '/' .$package; + + // Is the package file a valid file? + if (is_file($package)) + { + File::delete($package); + } + elseif (is_file(Path::clean($package))) + { + // It might also be just a base filename + File::delete(Path::clean($package)); + } + } + ###IMPORT_SETDATA_METHOD### + ###IMPORT_SAVE_METHOD### + + protected function getAlias($name,$type = false) + { + // sanitize the name to an alias + if (Factory::getConfig()->get('unicodeslugs') == 1) + { + $alias = OutputFilter::stringURLUnicodeSlug($name); + } + else + { + $alias = OutputFilter::stringURLSafe($name); + } + // must be a uniqe alias + if ($type) + { + return $this->getUniqe($alias,'alias',$type); + } + return $alias; + } + + /** + * Method to generate a uniqe value. + * + * @param string $field name. + * @param string $value data. + * @param string $type table. + * + * @return string New value. + */ + protected function getUniqe($value,$field,$type) + { + // insure the filed is always uniqe + while (isset($this->uniqeValueArray[$type][$field][$value])) + { + $value = StringHelper::increment($value, 'dash'); + } + $this->uniqeValueArray[$type][$field][$value] = $value; + return $value; + } + + protected function getAliasesUsed($table) + { + // Get a db connection. + $db = $this->getDatabase(); + // first we check if there is a alias column + $columns = $db->getTableColumns('#__###component###_'.$table); + if(isset($columns['alias'])){ + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('alias'))); + $query->from($db->quoteName('#__###component###_'.$table)); + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $aliases = $db->loadColumn(); + foreach($aliases as $alias) + { + $this->uniqeValueArray[$table]['alias'][$alias] = $alias; + } + } + return true; + } + return false; + } +} diff --git a/admin/compiler/joomla_4/ADMIN_LAYOUT.php b/admin/compiler/joomla_4/ADMIN_LAYOUT.php new file mode 100644 index 000000000..857ae2766 --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_LAYOUT.php @@ -0,0 +1,22 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +###ADMIN_LAYOUT_HEADER### + +// No direct access to this file +defined('JPATH_BASE') or die;###ADMIN_LAYOUT_CODE### + +?>###ADMIN_LAYOUT_BODY### diff --git a/admin/compiler/joomla_4/ADMIN_PROVIDER.php b/admin/compiler/joomla_4/ADMIN_PROVIDER.php new file mode 100644 index 000000000..23696fa3f --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_PROVIDER.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +###ADMIN_POWER_HELPER### + +// (soon) use Joomla\CMS\Association\AssociationExtensionInterface; +use Joomla\CMS\Categories\CategoryFactoryInterface; +use Joomla\CMS\Component\Router\RouterFactoryInterface; +use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface; +use Joomla\CMS\Extension\ComponentInterface; +use Joomla\CMS\Extension\Service\Provider\CategoryFactory; +use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory; +use Joomla\CMS\Extension\Service\Provider\MVCFactory; +use Joomla\CMS\Extension\Service\Provider\RouterFactory; +use Joomla\CMS\HTML\Registry; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Extension\###Component###Component; +// (soon) use ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Helper\AssociationsHelper; +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * The ###NAMESPACEPREFIX### ###Component### service provider. + * + * @since 4.0.0 + */ +return new class () implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * + * @since 4.0.0 + */ + public function register(Container $container) + { + // (soon) $container->set(AssociationExtensionInterface::class, new AssociationsHelper()); + + $container->registerServiceProvider(new CategoryFactory('\\###NAMESPACEPREFIX###\\Component\\###Component###')); + $container->registerServiceProvider(new MVCFactory('\\###NAMESPACEPREFIX###\\Component\\###Component###')); + $container->registerServiceProvider(new ComponentDispatcherFactory('\\###NAMESPACEPREFIX###\\Component\\###Component###')); + $container->registerServiceProvider(new RouterFactory('\\###NAMESPACEPREFIX###\\Component\\###Component###')); + + $container->set( + ComponentInterface::class, + function (Container $container) { + $component = new ###Component###Component($container->get(ComponentDispatcherFactoryInterface::class)); + + $component->setRegistry($container->get(Registry::class)); + $component->setMVCFactory($container->get(MVCFactoryInterface::class)); + $component->setCategoryFactory($container->get(CategoryFactoryInterface::class)); + // (soon) $component->setAssociationExtension($container->get(AssociationExtensionInterface::class)); + $component->setRouterFactory($container->get(RouterFactoryInterface::class)); + + return $component; + } + ); + } +}; diff --git a/admin/compiler/joomla_4/ADMIN_VIEW.php b/admin/compiler/joomla_4/ADMIN_VIEW.php new file mode 100644 index 000000000..1790e1989 --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_VIEW.php @@ -0,0 +1,27 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +###ADMIN_VIEW_HEADER### + +// No direct access to this file +defined('_JEXEC') or die; + +?> +###EDITBODYFADEIN### +

+###EDITBODY### +
+
###EDITBODYSCRIPT### diff --git a/admin/compiler/joomla_4/ADMIN_VIEWS.php b/admin/compiler/joomla_4/ADMIN_VIEWS.php new file mode 100644 index 000000000..90dd4a345 --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_VIEWS.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +###ADMIN_VIEWS_HEADER### + +// No direct access to this file +defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED### + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_###component###&task=###views###.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', '###view###List', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +###VIEWS_DEFAULT_BODY######VIEWS_FOOTER_SCRIPT### diff --git a/admin/compiler/joomla_4/ADMIN_VIEWS_CONTROLLER.php b/admin/compiler/joomla_4/ADMIN_VIEWS_CONTROLLER.php new file mode 100644 index 000000000..f2c68be9b --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_VIEWS_CONTROLLER.php @@ -0,0 +1,53 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Controller; + +###ADMIN_VIEWS_CONTROLLER_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Views### Admin Controller + * + * @since 1.6 + */ +class ###Views###Controller extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_###COMPONENT###_###VIEWS###'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = '###View###', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + }###CONTROLLEREXIMPORTMETHOD######CUSTOM_ADMIN_DYNAMIC_BUTTONS_CONTROLLER######ADMIN_CUSTOM_BUTTONS_CONTROLLER_LIST### +} \ No newline at end of file diff --git a/admin/compiler/joomla_4/ADMIN_VIEWS_EMPTYSTATE.php b/admin/compiler/joomla_4/ADMIN_VIEWS_EMPTYSTATE.php new file mode 100644 index 000000000..7169372a0 --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_VIEWS_EMPTYSTATE.php @@ -0,0 +1,33 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED### + +$displayData = [ + 'textPrefix' => 'COM_###COMPONENT###_###VIEWS###', + 'formURL' => 'index.php?option=com_###component###&view=###views###', + 'icon' => 'icon-###ICOMOON###', +]; + +if ($this->user->authorise('###view###.create', 'com_###component###')) +{ + $displayData['createURL'] = 'index.php?option=com_###component###&task=###view###.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/compiler/joomla_4/ADMIN_VIEWS_HTML.php b/admin/compiler/joomla_4/ADMIN_VIEWS_HTML.php new file mode 100644 index 000000000..bc59999f0 --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_VIEWS_HTML.php @@ -0,0 +1,188 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\View\###Views###; + +###ADMIN_VIEWS_HTML_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED### + +/** + * ###Component### Html View class for the ###Views### + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * ###Views### view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity();###ADMIN_DIPLAY_METHOD### + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ###Component###Helper::getActions('###view###');###JVIEWLISTCANDO### + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_###COMPONENT###_###VIEWS###'), '###ICOMOON###'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('###view###.add'); + } + + // Only load if there are items + if (Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('###view###.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('###views###.publish'); + ToolbarHelper::unpublishList('###views###.unpublish'); + ToolbarHelper::archiveList('###views###.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('###views###.checkin'); + } + }###CUSTOM_ADMIN_DYNAMIC_BUTTONS######ADMIN_CUSTOM_BUTTONS_LIST### + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', '###views###.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('###views###.trash'); + }###EXPORTBUTTON### + }###ADMIN_CUSTOM_FUNCTION_ONLY_BUTTONS_LIST######IMPORTBUTTON### + + // set help url for this view if found + $this->help_url = ###Component###Helper::getHelpUrl('###views###'); + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($this->help_url)) + { + ToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_###component###'); + }###FILTERFIELDDISPLAYHELPER######BATCHDISPLAYHELPER### + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + {###JQUERY### + $this->getDocument()->setTitle(Text::_('COM_###COMPONENT###_###VIEWS###')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + }###ADMIN_ADD_JAVASCRIPT_FILE### + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + ###SORTFIELDS### + }###FILTERFUNCTIONS### +} diff --git a/admin/compiler/joomla_4/ADMIN_VIEWS_MODEL.php b/admin/compiler/joomla_4/ADMIN_VIEWS_MODEL.php new file mode 100644 index 000000000..3297824df --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_VIEWS_MODEL.php @@ -0,0 +1,189 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Model; + +###ADMIN_VIEWS_MODEL_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Views### List Model + * + * @since 1.6 + */ +class ###Views###Model extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_###component###/assets/css/admin.css', + 'administrator/components/com_###component###/assets/css/###views###.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_###component###/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + ###FILTER_FIELDS### + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + }###ADMIN_CUSTOM_BUTTONS_METHOD_LIST### + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + }###POPULATESTATE### + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + {###LICENSE_LOCKED_CHECK######CHECKINCALL### + // load parent items + $items = parent::getItems();###GET_ITEMS_METHOD_STRING_FIX######SELECTIONTRANSLATIONFIX######GET_ITEMS_METHOD_AFTER_ALL### + + // return items + return $items; + }###SELECTIONTRANSLATIONFIXFUNC### + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + {###LICENSE_LOCKED_CHECK### + ###LISTQUERY### + }###MODELEXPORTMETHOD######LICENSE_LOCKED_SET_BOOL### + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + ###STOREDID### + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + }###AUTOCHECKIN### +} diff --git a/admin/compiler/joomla_4/ADMIN_VIEW_CONTROLLER.php b/admin/compiler/joomla_4/ADMIN_VIEW_CONTROLLER.php new file mode 100644 index 000000000..aab67b639 --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_VIEW_CONTROLLER.php @@ -0,0 +1,274 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Controller; + +###ADMIN_VIEW_CONTROLLER_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###View### Form Controller + * + * @since 1.6 + */ +class ###View###Controller extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_###COMPONENT###_###VIEW###'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = '###views###';###ADMIN_CUSTOM_BUTTONS_CONTROLLER### + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + {###JCONTROLLERFORM_ALLOWADD### + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + {###JCONTROLLERFORM_ALLOWEDIT### + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('###View###', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_###component###&view=###views###' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64');###JCONTROLLERFORM_BEFORECANCEL### + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + }###JCONTROLLERFORM_AFTERCANCEL### + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + {###POSTSAVEHOOK### + } +} diff --git a/admin/compiler/joomla_4/ADMIN_VIEW_HTML.php b/admin/compiler/joomla_4/ADMIN_VIEW_HTML.php new file mode 100644 index 000000000..34750b530 --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_VIEW_HTML.php @@ -0,0 +1,143 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\View\###View###; + +###ADMIN_VIEW_HTML_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED### + +/** + * ###View### Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * ###View### view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_###component###'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ###Component###Helper::getActions('###view###', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + }###LINKEDVIEWITEMS### + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ###ADDTOOLBAR### + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + {###JQUERY### + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_###COMPONENT###_###VIEW###_NEW' : 'COM_###COMPONENT###_###VIEW###_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + }###AJAXTOKE######LINKEDVIEWTABLESCRIPTS### + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + }###DOCUMENT_CUSTOM_PHP### + } +} diff --git a/admin/compiler/joomla_4/ADMIN_VIEW_MODEL.php b/admin/compiler/joomla_4/ADMIN_VIEW_MODEL.php new file mode 100644 index 000000000..86d77aa8f --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_VIEW_MODEL.php @@ -0,0 +1,491 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Model; + +###ADMIN_VIEW_MODEL_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### ###View### Admin Model + * + * @since 1.6 + */ +class ###View###Model extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = ###TABLAYOUTFIELDSARRAY###; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_###component###/assets/css/admin.css', + 'administrator/components/com_###component###/assets/css/###view###.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_###component###/assets/js/admin.js', + 'media/com_###component###/js/###view###.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_###COMPONENT###'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_###component###.###view###'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = '###view###', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + }###ADMIN_CUSTOM_BUTTONS_METHOD### + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + {###LICENSE_LOCKED_CHECK### + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + }###METHOD_GET_ITEM### + }###LINKEDVIEWGLOBAL### + + return $item; + }###LINKEDVIEWMETHODS######LICENSE_LOCKED_SET_BOOL### + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData;###JMODELADMIN_GETFORM### + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + {###JMODELADMIN_CANDELETE### + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + {###JMODELADMIN_CANEDITSTATE### + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + {###JMODELADMIN_ALLOWEDIT### + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + {###LICENSE_TABLE_LOCKED_CHECK### + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__###component###_###view###')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_###component###.edit.###view###.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_###component###.###view###', $data); + + return $data; + }###VALIDATIONFIX######UNIQUEFIELDS### + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + {###JMODELADMIN_BEFORE_DELETE### + if (!parent::delete($pks)) + { + return false; + }###JMODELADMIN_AFTER_DELETE### + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + {###JMODELADMIN_BEFORE_PUBLISH### + if (!parent::publish($pks, $value)) + { + return false; + }###JMODELADMIN_AFTER_PUBLISH### + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ###Component###Helper::getActions('###view###'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + }###MODEL_BATCH_COPY######MODEL_BATCH_MOVE### + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + }###CHECKBOX_SAVE######METHOD_ITEM_SAVE### + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + }###TITLEALIASFIX### + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + }###GENERATENEWTITLE### +} diff --git a/admin/compiler/joomla_4/ADMIN_VIEW_TABLE.php b/admin/compiler/joomla_4/ADMIN_VIEW_TABLE.php new file mode 100644 index 000000000..6dfae6f66 --- /dev/null +++ b/admin/compiler/joomla_4/ADMIN_VIEW_TABLE.php @@ -0,0 +1,372 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Helper\###Component###Helper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Views### Table class + * + * @since 1.6 + */ +class ###View###Table extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_###component###.###view###'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__###component###_###view###', 'id', $db, $dispatcher);###LICENSE_LOCKED_CHECK### + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the ###View### table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New ###view###. A ###view### created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias###JTABLEALIASCATEGORY###]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_###COMPONENT###_###VIEW###_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_###COMPONENT###_###VIEW###_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_###component###.###view###.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + }###LICENSE_LOCKED_SET_BOOL### + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the ###component### asset + $assets->loadByName('com_###component###'); + + return $assets->id ?? $rootId ?? 1; + }###GENERATENEWALIAS### +} diff --git a/admin/compiler/joomla_4/CHANGELOG.md b/admin/compiler/joomla_4/CHANGELOG.md new file mode 100644 index 000000000..def8704dd --- /dev/null +++ b/admin/compiler/joomla_4/CHANGELOG.md @@ -0,0 +1 @@ +###CHANGELOG### \ No newline at end of file diff --git a/admin/compiler/joomla_4/CUSTOM_ADMIN_LAYOUT.php b/admin/compiler/joomla_4/CUSTOM_ADMIN_LAYOUT.php new file mode 100644 index 000000000..c3981e98e --- /dev/null +++ b/admin/compiler/joomla_4/CUSTOM_ADMIN_LAYOUT.php @@ -0,0 +1,22 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +###CUSTOM_ADMIN_LAYOUT_HEADER### + +// No direct access to this file +defined('JPATH_BASE') or die;###CUSTOM_ADMIN_LAYOUT_CODE### + +?>###CUSTOM_ADMIN_LAYOUT_BODY### diff --git a/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEW.php b/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEW.php new file mode 100644 index 000000000..47e384fe5 --- /dev/null +++ b/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEW.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +###CUSTOM_ADMIN_VIEW_HEADER### + +// No direct access to this file +defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED######CUSTOM_ADMIN_CODE_BODY### + +?> +canDo->get('###sview###.access')): ?>###CUSTOM_ADMIN_SUBMITBUTTON_SCRIPT### +item->id)) ? '&id='. (int) $this->item->id : ''; ?> +###CUSTOM_ADMIN_TOP_FORM######CUSTOM_ADMIN_BODY######CUSTOM_ADMIN_BOTTOM_FORM### + +

+ diff --git a/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEWS.php b/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEWS.php new file mode 100644 index 000000000..6b23540da --- /dev/null +++ b/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEWS.php @@ -0,0 +1,27 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +###CUSTOM_ADMIN_VIEWS_HEADER### + +// No direct access to this file +defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED######CUSTOM_ADMIN_CODE_BODY### + +?> +canDo->get('###sview###.access')): ?>###CUSTOM_ADMIN_SUBMITBUTTON_SCRIPT### +###CUSTOM_ADMIN_TOP_FORM######CUSTOM_ADMIN_BODY######CUSTOM_ADMIN_BOTTOM_FORM### + +

+ diff --git a/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEWS_CONTROLLER.php b/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEWS_CONTROLLER.php new file mode 100644 index 000000000..fb2e2468d --- /dev/null +++ b/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEWS_CONTROLLER.php @@ -0,0 +1,65 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Controller; + +###CUSTOM_ADMIN_VIEWS_CONTROLLER_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###SViews### Admin Controller + * + * @since 1.6 + */ +class ###SViews###Controller extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_###COMPONENT###_###SVIEWS###'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = '###View###', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } + + /** + * Adds option to redirect back to the dashboard. + * + * @return void + * + * @since 3.0 + */ + public function dashboard(): void + { + $this->setRedirect(Route::_('index.php?option=com_###component###', false)); + }###CUSTOM_ADMIN_CUSTOM_BUTTONS_CONTROLLER### +} diff --git a/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEWS_HTML.php b/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEWS_HTML.php new file mode 100644 index 000000000..b6a3ab8e3 --- /dev/null +++ b/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEWS_HTML.php @@ -0,0 +1,119 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\View\###SViews###; + +###CUSTOM_ADMIN_VIEWS_HTML_HEADER######CUSTOM_ADMIN_GET_MODULE_JIMPORT### + +// No direct access to this file +\defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED### + +/** + * ###Component### Html View class for the ###SViews### + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Display the view + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // get component params + $this->params = ComponentHelper::getParams('com_###component###'); + // get the application + $this->app ??= Factory::getApplication(); + // get the user object + $this->user ??= $this->app->getIdentity(); + // get global action permissions + $this->canDo = ###Component###Helper::getActions('###sview###'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts');###CUSTOM_ADMIN_DIPLAY_METHOD### + + // Set the html view document stuff + $this->_prepareDocument(); + }###CUSTOM_ADMIN_EXTRA_DIPLAY_METHODS### + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + {###CUSTOM_ADMIN_LIBRARIES_LOADER######CUSTOM_ADMIN_UIKIT_LOADER######CUSTOM_ADMIN_GOOGLECHART_LOADER######CUSTOM_ADMIN_FOOTABLE_LOADER######CUSTOM_ADMIN_DOCUMENT_CUSTOM_PHP### + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + }###CUSTOM_ADMIN_DOCUMENT_CUSTOM_CSS### + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + }###CUSTOM_ADMIN_DOCUMENT_CUSTOM_JS### + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + {###HIDEMAINMENU### + // add title to the page + ToolbarHelper::title(Text::_('COM_###COMPONENT###_###SVIEWS###'),'###ICOMOON###');###CUSTOM_ADMIN_CUSTOM_BUTTONS### + + // set help url for this view if found + $this->help_url = ###Component###Helper::getHelpUrl('###sviews###'); + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($this->help_url)) + { + ToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_###component###'); + } + }###CUSTOM_ADMIN_GET_MODULE### + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = false, int $length = 40) + { + if (!is_string($var)) + { + return $var; + } + + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } +} diff --git a/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEWS_MODEL.php b/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEWS_MODEL.php new file mode 100644 index 000000000..21260e2cc --- /dev/null +++ b/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEWS_MODEL.php @@ -0,0 +1,220 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Model; + +###CUSTOM_ADMIN_VIEWS_MODEL_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### List Model for ###SViews### + * + * @since 1.6 + */ +class ###SViews###Model extends ListModel +{ + /** + * Represents the current user object. + * + * @var User The user object representing the current user. + * @since 3.2.0 + */ + protected User $user; + + /** + * The unique identifier of the current user. + * + * @var int|null The ID of the current user. + * @since 3.2.0 + */ + protected ?int $userId; + + /** + * Flag indicating whether the current user is a guest. + * + * @var int 1 if the user is a guest, 0 otherwise. + * @since 3.2.0 + */ + protected int $guest; + + /** + * An array of groups that the current user belongs to. + * + * @var array|null An array of user group IDs. + * @since 3.2.0 + */ + protected ?array $groups; + + /** + * An array of view access levels for the current user. + * + * @var array|null An array of access level IDs. + * @since 3.2.0 + */ + protected ?array $levels; + + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The input object, providing access to the request data. + * + * @var Input The input object. + * @since 3.2.0 + */ + protected Input $input; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_###component###/assets/css/admin.css', + 'administrator/components/com_###component###/assets/css/###sviews###.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_###component###/assets/js/admin.js' + ]; + + /** + * A custom property for UIKit components. (not used unless you load v2) + */ + protected $uikitComp; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + $this->input ??= $this->app->getInput(); + + // Set the current user for authorisation checks (for those calling this model directly) + $this->user ??= $this->getCurrentUser(); + $this->userId = $this->user->get('id'); + $this->guest = $this->user->get('guest'); + $this->groups = $this->user->get('groups'); + $this->authorisedGroups = $this->user->getAuthorisedGroups(); + $this->levels = $this->user->getAuthorisedViewLevels(); + + // will be removed + $this->initSet = true; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + {###CUSTOM_ADMIN_GET_LIST_QUERY### + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + $user = $this->user; + // check if this user has permission to access items + if (!$user->authorise('###sviews###.access', 'com_###component###')) + { + $this->app->enqueueMessage(Text::_('Not authorised!'), 'error'); + // redirect away if not a correct to default view + $this->app->redirect('index.php?option=com_###component###'); + return false; + }###LICENSE_LOCKED_CHECK######CUSTOM_ADMIN_BEFORE_GET_ITEMS### + // load parent items + $items = parent::getItems(); + + // Get the global params + $globalParams = ComponentHelper::getParams('com_###component###', true);###CUSTOM_ADMIN_GET_ITEMS######CUSTOM_ADMIN_AFTER_GET_ITEMS### + + // return items + return $items; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + }###CUSTOM_ADMIN_CUSTOM_METHODS######LICENSE_LOCKED_SET_BOOL######CUSTOM_ADMIN_CUSTOM_BUTTONS_METHOD### +} diff --git a/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEW_CONTROLLER.php b/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEW_CONTROLLER.php new file mode 100644 index 000000000..6618a2b2f --- /dev/null +++ b/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEW_CONTROLLER.php @@ -0,0 +1,56 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Controller; + +###CUSTOM_ADMIN_VIEW_CONTROLLER_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### ###SView### Base Controller + * + * @since 1.6 + */ +class ###SView###Controller extends BaseController +{ + /** + * The context for storing internal data, e.g. record. + * + * @var string + * @since 1.6 + */ + protected $context = '###sview###'; + + /** + * The URL view item variable. + * + * @var string + * @since 1.6 + */ + protected $view_item = '###sview###'; + + /** + * Adds option to redirect back to the dashboard. + * + * @return void + * @since 3.0 + */ + public function dashboard(): void + { + $this->setRedirect(Route::_('index.php?option=com_###component###', false)); + }###CUSTOM_ADMIN_CUSTOM_BUTTONS_CONTROLLER### +} diff --git a/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEW_HTML.php b/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEW_HTML.php new file mode 100644 index 000000000..de896a019 --- /dev/null +++ b/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEW_HTML.php @@ -0,0 +1,129 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\View\###SView###; + +###CUSTOM_ADMIN_VIEW_HTML_HEADER######CUSTOM_ADMIN_GET_MODULE_JIMPORT### + +// No direct access to this file +\defined('_JEXEC') or die; ###LICENSE_LOCKED_DEFINED### + +/** + * ###Component### Html View class for the ###SView### + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Display the view + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // get component params + $this->params = ComponentHelper::getParams('com_###component###'); + // get the application + $this->app ??= Factory::getApplication(); + // get the user object + $this->user ??= Factory::getApplication()->getIdentity(); + // get global action permissions + $this->canDo = ###Component###Helper::getActions('###sview###'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts');###CUSTOM_ADMIN_DIPLAY_METHOD### + + // Set the html view document stuff + $this->_prepareDocument(); + }###CUSTOM_ADMIN_EXTRA_DIPLAY_METHODS### + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + {###CUSTOM_ADMIN_LIBRARIES_LOADER######CUSTOM_ADMIN_DOCUMENT_METADATA######CUSTOM_ADMIN_UIKIT_LOADER######CUSTOM_ADMIN_GOOGLECHART_LOADER######CUSTOM_ADMIN_FOOTABLE_LOADER######CUSTOM_ADMIN_DOCUMENT_CUSTOM_PHP### + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + }###CUSTOM_ADMIN_DOCUMENT_CUSTOM_CSS### + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + }###CUSTOM_ADMIN_DOCUMENT_CUSTOM_JS### + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + {###HIDEMAINMENU### + // set the title + if (isset($this->item->name) && $this->item->name) + { + $title = $this->item->name; + } + // Check for empty title and add view name if param is set + if (empty($title)) + { + $title = Text::_('COM_###COMPONENT###_###SVIEW###'); + } + // add title to the page + ToolbarHelper::title($title,'###ICOMOON###');###CUSTOM_ADMIN_CUSTOM_BUTTONS### + + // set help url for this view if found + $this->help_url = ###Component###Helper::getHelpUrl('###sviews###'); + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($this->help_url)) + { + ToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_###component###'); + } + }###CUSTOM_ADMIN_GET_MODULE### + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = false, int $length = 40) + { + if (!is_string($var)) + { + return $var; + } + + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } +} diff --git a/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEW_MODEL.php b/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEW_MODEL.php new file mode 100644 index 000000000..fc43c158c --- /dev/null +++ b/admin/compiler/joomla_4/CUSTOM_ADMIN_VIEW_MODEL.php @@ -0,0 +1,267 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Model; + +###CUSTOM_ADMIN_VIEW_MODEL_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### ###SView### Item Model + * + * @since 1.6 + */ +class ###SView###Model extends ItemModel +{ + /** + * Model context string. + * + * @var string + * @since 1.6 + */ + protected $_context = 'com_###component###.###sview###'; + + /** + * Represents the current user object. + * + * @var User The user object representing the current user. + * @since 3.2.0 + */ + protected User $user; + + /** + * The unique identifier of the current user. + * + * @var int|null The ID of the current user. + * @since 3.2.0 + */ + protected ?int $userId; + + /** + * Flag indicating whether the current user is a guest. + * + * @var int 1 if the user is a guest, 0 otherwise. + * @since 3.2.0 + */ + protected int $guest; + + /** + * An array of groups that the current user belongs to. + * + * @var array|null An array of user group IDs. + * @since 3.2.0 + */ + protected ?array $groups; + + /** + * An array of view access levels for the current user. + * + * @var array|null An array of access level IDs. + * @since 3.2.0 + */ + protected ?array $levels; + + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The input object, providing access to the request data. + * + * @var Input The input object. + * @since 3.2.0 + */ + protected Input $input; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_###component###/assets/css/admin.css', + 'administrator/components/com_###component###/assets/css/###sview###.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_###component###/assets/js/admin.js' + ]; + + /** + * A custom property for UI Kit components. + * + * @var array|null Property for storing UI Kit component-related data or objects. + * @since 3.2.0 + */ + protected ?array $uikitComp; + + /** + * @var object item + * @since 1.6 + */ + protected $item; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 3.0 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + $this->input ??= $this->app->getInput(); + + // Set the current user for authorisation checks (for those calling this model directly) + $this->user ??= $this->getCurrentUser(); + $this->userId = $this->user->get('id'); + $this->guest = $this->user->get('guest'); + $this->groups = $this->user->get('groups'); + $this->authorisedGroups = $this->user->getAuthorisedGroups(); + $this->levels = $this->user->getAuthorisedViewLevels(); + + // will be removed + $this->initSet = true; + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @return void + * @since 1.6 + */ + protected function populateState() + { + // Get the item main id + $id = $this->input->getInt('id', null); + $this->setState('###sview###.id', $id); + + // Load the parameters. + parent::populateState(); + } + + /** + * Method to get article data. + * + * @param integer $pk The id of the article. + * + * @return mixed Menu item data object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + // check if this user has permission to access item + if (!$this->user->authorise('###sview###.access', 'com_###component###')) + { + $this->app->enqueueMessage(Text::_('Not authorised!'), 'error'); + // redirect away if not a correct to cPanel/default view + $this->app->redirect('index.php?option=com_###component###'); + return false; + } + + $pk = (!empty($pk)) ? $pk : (int) $this->getState('###sview###.id');###CUSTOM_ADMIN_BEFORE_GET_ITEM### + + if ($this->_item === null) + { + $this->_item = []; + }###LICENSE_LOCKED_CHECK### + + if (!isset($this->_item[$pk])) + { + try + {###CUSTOM_ADMIN_GET_ITEM### + } + catch (\Exception $e) + { + if ($e->getCode() == 404) + { + // Need to go thru the error handler to allow Redirect to work. + throw $e; + } + else + { + $this->setError($e); + $this->_item[$pk] = false; + } + } + }###CUSTOM_ADMIN_AFTER_GET_ITEM### + + return $this->_item[$pk]; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + }###CUSTOM_ADMIN_CUSTOM_METHODS######LICENSE_LOCKED_SET_BOOL######CUSTOM_ADMIN_CUSTOM_BUTTONS_METHOD### +} diff --git a/admin/compiler/joomla_4/DASH_CONTROLLER.php b/admin/compiler/joomla_4/DASH_CONTROLLER.php new file mode 100644 index 000000000..5a2268dac --- /dev/null +++ b/admin/compiler/joomla_4/DASH_CONTROLLER.php @@ -0,0 +1,31 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Controller; + +###DASH_CONTROLLER_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### Admin Controller + * + * @since 1.6 + */ +class ###Component###Controller extends AdminController +{ + +} diff --git a/admin/compiler/joomla_4/DASH_MODEL.php b/admin/compiler/joomla_4/DASH_MODEL.php new file mode 100644 index 000000000..610e08ba9 --- /dev/null +++ b/admin/compiler/joomla_4/DASH_MODEL.php @@ -0,0 +1,225 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Model; + +###DASH_MODEL_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### List Model + * + * @since 1.6 + */ +class ###Component###Model extends ListModel +{ + public function getIcons() + { + // load user for access menus + $user = Factory::getApplication()->getIdentity(); + // reset icon array + $icons = []; + // view groups array + $viewGroups = array( + 'main' => array(###DASHBOARDICONS###) + );###DASHBOARDICONACCESS### + // loop over the $views + foreach($viewGroups as $group => $views) + { + $i = 0; + if (Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($views)) + { + foreach($views as $view) + { + $add = false; + // external views (links) + if (strpos($view,'||') !== false) + { + $dwd = explode('||', $view); + if (count($dwd) == 3) + { + list($type, $name, $url) = $dwd; + $viewName = $name; + $alt = $name; + $url = $url; + $image = $name . '.' . $type; + $name = 'COM_###COMPONENT###_DASHBOARD_' . Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($name,'U'); + } + } + // internal views + elseif (strpos($view,'.') !== false) + { + $dwd = explode('.', $view); + if (count($dwd) == 3) + { + list($type, $name, $action) = $dwd; + } + elseif (count($dwd) == 2) + { + list($type, $name) = $dwd; + $action = false; + } + if ($action) + { + $viewName = $name; + switch($action) + { + case 'add': + $url = 'index.php?option=com_###component###&view=' . $name . '&layout=edit'; + $image = $name . '_' . $action. '.' . $type; + $alt = $name . ' ' . $action; + $name = 'COM_###COMPONENT###_DASHBOARD_'.Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($name,'U').'_ADD'; + $add = true; + break; + default: + // check for new convention (more stable) + if (strpos($action, '_qpo0O0oqp_') !== false) + { + list($action, $extension) = (array) explode('_qpo0O0oqp_', $action); + $extension = str_replace('_po0O0oq_', '.', $extension); + } + else + { + $extension = 'com_###component###.' . $name; + } + $url = 'index.php?option=com_categories&view=categories&extension=' . $extension; + $image = $name . '_' . $action . '.' . $type; + $alt = $viewName . ' ' . $action; + $name = 'COM_###COMPONENT###_DASHBOARD_' . Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($name,'U') . '_' . Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($action,'U'); + break; + } + } + else + { + $viewName = $name; + $alt = $name; + $url = 'index.php?option=com_###component###&view=' . $name; + $image = $name . '.' . $type; + $name = 'COM_###COMPONENT###_DASHBOARD_' . Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($name,'U'); + $hover = false; + } + } + else + { + $viewName = $view; + $alt = $view; + $url = 'index.php?option=com_###component###&view=' . $view; + $image = $view . '.png'; + $name = ucwords($view).'

'; + $hover = false; + } + // first make sure the view access is set + if (Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($viewAccess)) + { + // setup some defaults + $dashboard_add = false; + $dashboard_list = false; + $accessTo = ''; + $accessAdd = ''; + // access checking start + $accessCreate = (isset($viewAccess[$viewName.'.create'])) ? Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($viewAccess[$viewName.'.create']):false; + $accessAccess = (isset($viewAccess[$viewName.'.access'])) ? Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($viewAccess[$viewName.'.access']):false; + // set main controllers + $accessDashboard_add = (isset($viewAccess[$viewName.'.dashboard_add'])) ? Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($viewAccess[$viewName.'.dashboard_add']):false; + $accessDashboard_list = (isset($viewAccess[$viewName.'.dashboard_list'])) ? Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($viewAccess[$viewName.'.dashboard_list']):false; + // check for adding access + if ($add && $accessCreate) + { + $accessAdd = $viewAccess[$viewName.'.create']; + } + elseif ($add) + { + $accessAdd = 'core.create'; + } + // check if access to view is set + if ($accessAccess) + { + $accessTo = $viewAccess[$viewName.'.access']; + } + // set main access controllers + if ($accessDashboard_add) + { + $dashboard_add = $user->authorise($viewAccess[$viewName.'.dashboard_add'], 'com_###component###'); + } + if ($accessDashboard_list) + { + $dashboard_list = $user->authorise($viewAccess[$viewName.'.dashboard_list'], 'com_###component###'); + } + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($accessAdd) && Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($accessTo)) + { + // check access + if($user->authorise($accessAdd, 'com_###component###') && $user->authorise($accessTo, 'com_###component###') && $dashboard_add) + { + $icons[$group][$i] = new \StdClass; + $icons[$group][$i]->url = $url; + $icons[$group][$i]->name = $name; + $icons[$group][$i]->image = $image; + $icons[$group][$i]->alt = $alt; + } + } + elseif (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($accessTo)) + { + // check access + if($user->authorise($accessTo, 'com_###component###') && $dashboard_list) + { + $icons[$group][$i] = new \StdClass; + $icons[$group][$i]->url = $url; + $icons[$group][$i]->name = $name; + $icons[$group][$i]->image = $image; + $icons[$group][$i]->alt = $alt; + } + } + elseif (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($accessAdd)) + { + // check access + if($user->authorise($accessAdd, 'com_###component###') && $dashboard_add) + { + $icons[$group][$i] = new \StdClass; + $icons[$group][$i]->url = $url; + $icons[$group][$i]->name = $name; + $icons[$group][$i]->image = $image; + $icons[$group][$i]->alt = $alt; + } + } + else + { + $icons[$group][$i] = new \StdClass; + $icons[$group][$i]->url = $url; + $icons[$group][$i]->name = $name; + $icons[$group][$i]->image = $image; + $icons[$group][$i]->alt = $alt; + } + } + else + { + $icons[$group][$i] = new \StdClass; + $icons[$group][$i]->url = $url; + $icons[$group][$i]->name = $name; + $icons[$group][$i]->image = $image; + $icons[$group][$i]->alt = $alt; + } + $i++; + } + } + else + { + $icons[$group][$i] = false; + } + } + return $icons; + }###DASH_MODEL_METHODS### +} diff --git a/admin/compiler/joomla_4/DASH_VIEW.php b/admin/compiler/joomla_4/DASH_VIEW.php new file mode 100644 index 000000000..c95d6aeb6 --- /dev/null +++ b/admin/compiler/joomla_4/DASH_VIEW.php @@ -0,0 +1,22 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +###DASH_VIEW_HEADER### + +// No direct access to this file +defined('_JEXEC') or die; + +?>###DASH_DISPLAY_DATA### \ No newline at end of file diff --git a/admin/compiler/joomla_4/DASH_VIEW_HTML.php b/admin/compiler/joomla_4/DASH_VIEW_HTML.php new file mode 100644 index 000000000..31e294e46 --- /dev/null +++ b/admin/compiler/joomla_4/DASH_VIEW_HTML.php @@ -0,0 +1,100 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\View\###Component###; + +###DASH_VIEW_HTML_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * View display method + * @return void + */ + function display($tpl = null) + { + // Assign data to the view + $this->icons = $this->get('Icons'); + $this->contributors = ###Component###Helper::getContributors(); + + // get the manifest details of the component + $this->manifest = ###Component###Helper::manifest();###DASH_GET_CUSTOM_DATA### + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + $canDo = ###Component###Helper::getActions('###component###'); + ToolbarHelper::title(Text::_('COM_###COMPONENT###_DASHBOARD'), 'grid-2'); + + // set help url for this view if found + $this->help_url = ###Component###Helper::getHelpUrl('###component###'); + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($this->help_url)) + { + ToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); + } + + if ($canDo->get('core.admin') || $canDo->get('core.options')) + { + ToolbarHelper::preferences('com_###component###'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // set page title + $this->getDocument()->setTitle(Text::_('COM_###COMPONENT###_DASHBOARD')); + + // add manifest to page JavaScript + $this->getDocument()->addScriptDeclaration("var manifest = JSON.parse('" . json_encode($this->manifest) . "');", "text/javascript"); + + // add dashboard style sheets + Html::_('stylesheet', "administrator/components/com_###component###/assets/css/dashboard.css", ['version' => 'auto']); + } +} diff --git a/admin/compiler/joomla_4/FORM_CHECKBOXES_FIELD.php b/admin/compiler/joomla_4/FORM_CHECKBOXES_FIELD.php new file mode 100644 index 000000000..3bda6475e --- /dev/null +++ b/admin/compiler/joomla_4/FORM_CHECKBOXES_FIELD.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\CheckboxesField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Helper\###Component###Helper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Type### Form Field class for the ###Component### component + * + * @since 1.6 + */ +class ###Type###Field extends CheckboxesField +{ + /** + * The ###type### field type. + * + * @var string + */ + public $type = '###Type###'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + */ + protected function getOptions() + { + ###JFORM_GETOPTIONS_PHP### + } +} diff --git a/admin/compiler/joomla_4/FORM_CUSTOM_FIELD.php b/admin/compiler/joomla_4/FORM_CUSTOM_FIELD.php new file mode 100644 index 000000000..c6d1f3c5d --- /dev/null +++ b/admin/compiler/joomla_4/FORM_CUSTOM_FIELD.php @@ -0,0 +1,36 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Field; + +###FORM_CUSTOM_FIELD_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Type### Form Field class for the ###Component### component + * + * @since 1.6 + */ +class ###Type###Field extends ###FORM_EXTENDS### +{ + /** + * The ###type### field type. + * + * @var string + */ + public $type = '###Type###';###FORM_CUSTOM_FIELD_PHP### +} diff --git a/admin/compiler/joomla_4/FORM_LIST_FIELD.php b/admin/compiler/joomla_4/FORM_LIST_FIELD.php new file mode 100644 index 000000000..cb70ab37d --- /dev/null +++ b/admin/compiler/joomla_4/FORM_LIST_FIELD.php @@ -0,0 +1,52 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Helper\###Component###Helper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Type### Form Field class for the ###Component### component + * + * @since 1.6 + */ +class ###Type###Field extends ListField +{ + /** + * The ###type### field type. + * + * @var string + */ + public $type = '###Type###';###ADD_BUTTON### + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + ###JFORM_GETOPTIONS_PHP### + } +} diff --git a/admin/compiler/joomla_4/FORM_RADIO_FIELD.php b/admin/compiler/joomla_4/FORM_RADIO_FIELD.php new file mode 100644 index 000000000..4b11f1865 --- /dev/null +++ b/admin/compiler/joomla_4/FORM_RADIO_FIELD.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\RadioField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Helper\###Component###Helper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Type### Form Field class for the ###Component### component + * + * @since 1.6 + */ +class ###Type###Field extends RadioField +{ + /** + * The ###type### field type. + * + * @var string + */ + public $type = '###Type###'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + */ + protected function getOptions() + { + ###JFORM_GETOPTIONS_PHP### + } +} diff --git a/admin/compiler/joomla_4/FORM_RULE.php b/admin/compiler/joomla_4/FORM_RULE.php new file mode 100644 index 000000000..a31ce624a --- /dev/null +++ b/admin/compiler/joomla_4/FORM_RULE.php @@ -0,0 +1,37 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Rule; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Form\FormRule; +use Joomla\Registry\Registry; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Helper\###Component###Helper; + +// No direct access to this file +\defined('JPATH_PLATFORM') or die; + +/** + * Form Rule (###Name###) class for the Joomla Platform. + * + * @since 3.5 + */ +class ###Name###Rule extends FormRule +{###VALIDATION_RULE_METHODS### +} diff --git a/admin/compiler/joomla_4/FORM_USER_FIELD.php b/admin/compiler/joomla_4/FORM_USER_FIELD.php new file mode 100644 index 000000000..3327f5a6d --- /dev/null +++ b/admin/compiler/joomla_4/FORM_USER_FIELD.php @@ -0,0 +1,65 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\UserField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Helper\###Component###Helper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Type### Form Field class for the ###Component### component + * + * @since 1.6 + */ +class ###Type###Field extends UserField +{ + /** + * The ###type### field type. + * + * @var string + */ + public $type = '###Type###'; + + /** + * Method to get the filtering groups (null means no filtering) + * + * @return mixed array of filtering groups or null. + * + * @since 1.6 + */ + protected function getGroups() + { + ###JFORM_GETGROUPS_PHP### + } + + /** + * Method to get the users to exclude from the list of users + * + * @return mixed Array of users to exclude or null to not exclude them + * + * @since 1.6 + */ + protected function getExcluded() + { + ###JFORM_GETEXCLUDED_PHP### + } +} diff --git a/admin/compiler/joomla_4/INSTALLER_SCRIPT.php b/admin/compiler/joomla_4/INSTALLER_SCRIPT.php new file mode 100644 index 000000000..c147a8e72 --- /dev/null +++ b/admin/compiler/joomla_4/INSTALLER_SCRIPT.php @@ -0,0 +1,1099 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Installer\InstallerAdapter; +use Joomla\CMS\Installer\InstallerScriptInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\Log\Log; +use Joomla\CMS\Version; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\Filesystem\Folder; +use Joomla\Database\DatabaseInterface; + +// No direct access to this file +defined('_JEXEC') or die; + +/** + * Script File of ###Component### Component + * + * @since 3.6 + */ +class Com_###Component###InstallerScript implements InstallerScriptInterface +{ + /** + * The CMS Application. + * + * @var CMSApplication + * @since 4.4.2 + */ + protected CMSApplication $app; + + /** + * The database class. + * + * @since 4.4.2 + */ + protected $db; + + /** + * The version number of the extension. + * + * @var string + * @since 3.6 + */ + protected $release; + + /** + * The table the parameters are stored in. + * + * @var string + * @since 3.6 + */ + protected $paramTable; + + /** + * The extension name. This should be set in the installer script. + * + * @var string + * @since 3.6 + */ + protected $extension; + + /** + * A list of files to be deleted + * + * @var array + * @since 3.6 + */ + protected $deleteFiles = []; + + /** + * A list of folders to be deleted + * + * @var array + * @since 3.6 + */ + protected $deleteFolders = []; + + /** + * A list of CLI script files to be copied to the cli directory + * + * @var array + * @since 3.6 + */ + protected $cliScriptFiles = []; + + /** + * Minimum PHP version required to install the extension + * + * @var string + * @since 3.6 + */ + protected $minimumPhp; + + /** + * Minimum Joomla! version required to install the extension + * + * @var string + * @since 3.6 + */ + protected $minimumJoomla; + + /** + * Extension script constructor. + * + * @since 3.0.0 + */ + public function __construct() + { + $this->minimumJoomla = '4.3'; + $this->minimumPhp = JOOMLA_MINIMUM_PHP; + $this->app ??= Factory::getApplication(); + $this->db = Factory::getContainer()->get(DatabaseInterface::class); + + // check if the files exist + if (is_file(JPATH_ROOT . '/administrator/components/com_###component###/###component###.php')) + { + // remove Joomla 3 files + $this->deleteFiles = [ + '/administrator/components/com_###component###/###component###.php', + '/administrator/components/com_###component###/controller.php', + '/components/com_###component###/###component###.php', + '/components/com_###component###/controller.php', + '/components/com_###component###/router.php', + ]; + } + + // check if the Folders exist + if (is_dir(JPATH_ROOT . '/administrator/components/com_###component###/modules')) + { + // remove Joomla 3 folder + $this->deleteFolders = [ + '/administrator/components/com_###component###/controllers', + '/administrator/components/com_###component###/helpers', + '/administrator/components/com_###component###/modules', + '/administrator/components/com_###component###/tables', + '/administrator/components/com_###component###/views', + '/components/com_###component###/controllers', + '/components/com_###component###/helpers', + '/components/com_###component###/modules', + '/components/com_###component###/views', + ]; + } + } + + /** + * Function called after the extension is installed. + * + * @param InstallerAdapter $adapter The adapter calling this method + * + * @return boolean True on success + * + * @since 4.2.0 + */ + public function install(InstallerAdapter $adapter): bool {return true;} + + /** + * Function called after the extension is updated. + * + * @param InstallerAdapter $adapter The adapter calling this method + * + * @return boolean True on success + * + * @since 4.2.0 + */ + public function update(InstallerAdapter $adapter): bool {return true;} + + /** + * Function called after the extension is uninstalled. + * + * @param InstallerAdapter $adapter The adapter calling this method + * + * @return boolean True on success + * + * @since 4.2.0 + */ + public function uninstall(InstallerAdapter $adapter): bool + {###UNINSTALLSCRIPT### + // little notice as after service, in case of bad experience with component. + echo '
+

Did something go wrong? Are you disappointed?

+

Please let me know at ###AUTHOREMAIL###. +
We at ###COMPANYNAME### are committed to building extensions that performs proficiently! You can help us, really! +
Send me your thoughts on improvements that is needed, trust me, I will be very grateful! +
Visit us at ###AUTHORWEBSITE### today!

'; + + return true; + } + + /** + * Function called before extension installation/update/removal procedure commences. + * + * @param string $type The type of change (install or discover_install, update, uninstall) + * @param InstallerAdapter $adapter The adapter calling this method + * + * @return boolean True on success + * + * @since 4.2.0 + */ + public function preflight(string $type, InstallerAdapter $adapter): bool + { + // Check for the minimum PHP version before continuing + if (!empty($this->minimumPhp) && version_compare(PHP_VERSION, $this->minimumPhp, '<')) + { + Log::add(Text::sprintf('JLIB_INSTALLER_MINIMUM_PHP', $this->minimumPhp), Log::WARNING, 'jerror'); + + return false; + } + + // Check for the minimum Joomla version before continuing + if (!empty($this->minimumJoomla) && version_compare(JVERSION, $this->minimumJoomla, '<')) + { + Log::add(Text::sprintf('JLIB_INSTALLER_MINIMUM_JOOMLA', $this->minimumJoomla), Log::WARNING, 'jerror'); + + return false; + } + + // Extension manifest file version + $this->extension = $adapter->getName(); + $this->release = $adapter->getManifest()->version; + + // do any updates needed + if ($type === 'update') + {###PREUPDATESCRIPT### + } + + // do any install needed + if ($type === 'install') + {###PREINSTALLSCRIPT### + } + + return true; + } + + /** + * Function called after extension installation/update/removal procedure commences. + * + * @param string $type The type of change (install or discover_install, update, uninstall) + * @param InstallerAdapter $adapter The adapter calling this method + * + * @return boolean True on success + * + * @since 4.2.0 + */ + public function postflight(string $type, InstallerAdapter $adapter): bool + {###MOVEFOLDERSSCRIPT### + + // set the default component settings + if ($type === 'install') + {###POSTINSTALLSCRIPT### + } + + // do any updates needed + if ($type === 'update') + {###POSTUPDATESCRIPT### + } + + // move CLI files + $this->moveCliFiles(); + + // remove old files and folders + $this->removeFiles(); + + return true; + } + + /** + * Remove the files and folders in the given array from + * + * @return void + * + * @since 3.6 + */ + protected function removeFiles() + { + if (!empty($this->deleteFiles)) + { + foreach ($this->deleteFiles as $file) + { + if (is_file(JPATH_ROOT . $file) && !File::delete(JPATH_ROOT . $file)) + { + echo Text::sprintf('JLIB_INSTALLER_ERROR_FILE_FOLDER', $file) . '
'; + } + } + } + + if (!empty($this->deleteFolders)) + { + foreach ($this->deleteFolders as $folder) + { + if (is_dir(JPATH_ROOT . $folder) && !Folder::delete(JPATH_ROOT . $folder)) + { + echo Text::sprintf('JLIB_INSTALLER_ERROR_FILE_FOLDER', $folder) . '
'; + } + } + } + } + + /** + * Moves the CLI scripts into the CLI folder in the CMS + * + * @return void + * + * @since 3.6 + */ + protected function moveCliFiles() + { + if (!empty($this->cliScriptFiles)) + { + foreach ($this->cliScriptFiles as $file) + { + $name = basename($file); + + if (file_exists(JPATH_ROOT . $file) && !File::move(JPATH_ROOT . $file, JPATH_ROOT . '/cli/' . $name)) + { + echo Text::sprintf('JLIB_INSTALLER_FILE_ERROR_MOVE', $name); + } + } + } + } + + /** + * Set content type integration + * + * @param string $typeTitle + * @param string $typeAlias + * @param string $table + * @param string $rules + * @param string $fieldMappings + * @param string $router + * @param string $contentHistoryOptions + * + * @return void + * @since 4.4.2 + */ + protected function setContentType( + string $typeTitle, + string $typeAlias, + string $table, + string $rules, + string $fieldMappings, + string $router, + string $contentHistoryOptions): void + { + // Create the content type object. + $content = new stdClass(); + $content->type_title = $typeTitle; + $content->type_alias = $typeAlias; + $content->table = $table; + $content->rules = $rules; + $content->field_mappings = $fieldMappings; + $content->router = $router; + $content->content_history_options = $contentHistoryOptions; + + // Check if content type is already in content_type DB. + $query = $this->db->getQuery(true); + $query->select($this->db->quoteName(array('type_id'))); + $query->from($this->db->quoteName('#__content_types')); + $query->where($this->db->quoteName('type_alias') . ' LIKE '. $this->db->quote($content->type_alias)); + + $this->db->setQuery($query); + $this->db->execute(); + + // Check if the type alias is already in the content types table. + if ($this->db->getNumRows()) + { + $content->type_id = $this->db->loadResult(); + if ($this->db->updateObject('#__content_types', $content, 'type_id')) + { + // If its successfully update. + $this->app->enqueueMessage( + Text::sprintf('The (%s) was found in the #__content_types table, and updated.', $content->type_alias) + ); + } + } + elseif ($this->db->insertObject('#__content_types', $content)) + { + // If its successfully added. + $this->app->enqueueMessage( + Text::sprintf('The (%s) was added to the #__content_types table.', $content->type_alias) + ); + } + } + + /** + * Set action log config integration + * + * @param string $typeTitle + * @param string $typeAlias + * @param string $idHolder + * @param string $titleHolder + * @param string $tableName + * @param string $textPrefix + * + * @return void + * @since 4.4.2 + */ + protected function setActionLogConfig( + string $typeTitle, + string $typeAlias, + string $idHolder, + string $titleHolder, + string $tableName, + string $textPrefix): void + { + // Create the content action log config object. + $content = new stdClass(); + $content->type_title = $typeTitle; + $content->type_alias = $typeAlias; + $content->id_holder = $idHolder; + $content->title_holder = $titleHolder; + $content->table_name = $tableName; + $content->text_prefix = $textPrefix; + + // Check if the action log config is already in action_log_config DB. + $query = $this->db->getQuery(true); + $query->select($this->db->quoteName(['id'])); + $query->from($this->db->quoteName('#__action_log_config')); + $query->where($this->db->quoteName('type_alias') . ' LIKE '. $this->db->quote($content->type_alias)); + + $this->db->setQuery($query); + $this->db->execute(); + + // Check if the type alias is already in the action log config table. + if ($this->db->getNumRows()) + { + $content->id = $this->db->loadResult(); + if ($this->db->updateObject('#__action_log_config', $content, 'id')) + { + // If its successfully update. + $this->app->enqueueMessage( + Text::sprintf('The (%s) was found in the #__action_log_config table, and updated.', $content->type_alias) + ); + } + } + elseif ($this->db->insertObject('#__action_log_config', $content)) + { + // If its successfully added. + $this->app->enqueueMessage( + Text::sprintf('The (%s) was added to the #__action_log_config table.', $content->type_alias) + ); + } + } + + /** + * Set action logs extensions integration + * + * @return void + * @since 4.4.2 + */ + protected function setActionLogsExtensions(): void + { + // Create the extension action logs object. + $data = new stdClass(); + $data->extension = 'com_###component###'; + + // Check if ###component### action log extension is already in action logs extensions DB. + $query = $this->db->getQuery(true); + $query->select($this->db->quoteName(['id'])); + $query->from($this->db->quoteName('#__action_logs_extensions')); + $query->where($this->db->quoteName('extension') . ' = '. $this->db->quote($data->extension)); + + $this->db->setQuery($query); + $this->db->execute(); + + // Set the object into the action logs extensions table if not found. + if ($this->db->getNumRows()) + { + // If its already set don't set it again. + $this->app->enqueueMessage( + Text::_('The (com_###component###) is already in the #__action_logs_extensions table.') + ); + } + elseif ($this->db->insertObject('#__action_logs_extensions', $data)) + { + // give a success message + $this->app->enqueueMessage( + Text::_('The (com_###component###) was successfully added to the #__action_logs_extensions table.') + ); + } + } + + /** + * Set global extension assets permission of this component + * (on install only) + * + * @param string $rules The component rules + * + * @return void + * @since 4.4.2 + */ + protected function setAssetsRules(string $rules): void + { + // Condition. + $conditions = [ + $this->db->quoteName('name') . ' = ' . $this->db->quote('com_###component###') + ]; + + // Field to update. + $fields = [ + $this->db->quoteName('rules') . ' = ' . $this->db->quote($rules), + ]; + + $query = $this->db->getQuery(true); + $query->update( + $this->db->quoteName('#__assets') + )->set($fields)->where($conditions); + + $this->db->setQuery($query); + + $done = $this->db->execute(); + if ($done) + { + // give a success message + $this->app->enqueueMessage( + Text::_('The (com_###component###) rules was successfully added to the #__assets table.') + ); + } + } + + /** + * Set global extension params of this component + * (on install only) + * + * @param string $params The component rules + * + * @return void + * @since 4.4.2 + */ + protected function setExtensionsParams(string $params): void + { + // Condition. + $conditions = [ + $this->db->quoteName('element') . ' = ' . $this->db->quote('com_###component###') + ]; + + // Field to update. + $fields = [ + $this->db->quoteName('params') . ' = ' . $this->db->quote($params), + ]; + + $query = $this->db->getQuery(true); + $query->update( + $this->db->quoteName('#__extensions') + )->set($fields)->where($conditions); + + $this->db->setQuery($query); + + $done = $this->db->execute(); + if ($done) + { + // give a success message + $this->app->enqueueMessage( + Text::_('The (com_###component###) params was successfully added to the #__extensions table.') + ); + } + } + + /** + * Set database fix (if needed) + * => WHY DO WE NEED AN ASSET TABLE FIX? + * https://git.vdm.dev/joomla/Component-Builder/issues/616#issuecomment-12085 + * https://www.mysqltutorial.org/mysql-varchar/ + * https://stackoverflow.com/a/15227917/1429677 + * https://forums.mysql.com/read.php?24,105964,105964 + * + * @param int $accessWorseCase This is the max rules column size com_###component### would needs. + * @param string $dataType This datatype we will change the rules column to if it to small. + * + * @return void + * @since 4.4.2 + */ + protected function setDatabaseAssetsRulesFix(int $accessWorseCase, string $dataType): void + { + // Get the biggest rule column in the assets table at this point. + $length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1"; + $this->db->setQuery($length); + if ($this->db->execute()) + { + $rule_length = $this->db->loadResult(); + // Check the size of the rules column + if ($rule_length <= $accessWorseCase) + { + // Fix the assets table rules column size + $fix = "ALTER TABLE `#__assets` CHANGE `rules` `rules` {$dataType} NOT NULL COMMENT 'JSON encoded access control. Enlarged to {$dataType} by ###Component###';"; + $this->db->setQuery($fix); + + $done = $this->db->execute(); + if ($done) + { + $this->app->enqueueMessage( + Text::sprintf('The #__assets table rules column was resized to the %s datatype for the components possible large permission rules.', $dataType) + ); + } + } + } + } + + /** + * Remove remnant data related to this view + * + * @param string $context The view context + * @param bool $fields The switch to also remove related field data + * + * @return void + * @since 4.4.2 + */ + protected function removeViewData(string $context, bool $fields = false): void + { + $this->removeContentTypes($context); + $this->removeViewHistory($context); + $this->removeUcmContent($context); // this might be obsolete... + $this->removeContentItemTagMap($context); + $this->removeActionLogConfig($context); + + if ($fields) + { + $this->removeFields($context); + $this->removeFieldsGroups($context); + } + } + + /** + * Remove content types related to this view + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeContentTypes(string $context): void + { + // Create a new query object. + $query = $this->db->getQuery(true); + + // Select id from content type table + $query->select($this->db->quoteName('type_id')); + $query->from($this->db->quoteName('#__content_types')); + + // Where Item alias is found + $query->where($this->db->quoteName('type_alias') . ' = '. $this->db->quote($context)); + $this->db->setQuery($query); + + // Execute query to see if alias is found + $this->db->execute(); + $found = $this->db->getNumRows(); + + // Now check if there were any rows + if ($found) + { + // Since there are load the needed item type ids + $ids = $this->db->loadColumn(); + + // Remove Item from the content type table + $condition = [ + $this->db->quoteName('type_alias') . ' = '. $this->db->quote($context) + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__content_types')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove Item items + $done = $this->db->execute(); + if ($done) + { + // If successfully remove Item add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The (%s) type alias was removed from the #__content_type table.', $context) + ); + } + + // Make sure that all the items are cleared from DB + $this->removeUcmBase($ids); + } + } + + /** + * Remove fields related to this view + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeFields(string $context): void + { + // Create a new query object. + $query = $this->db->getQuery(true); + + // Select ids from fields + $query->select($this->db->quoteName('id')); + $query->from($this->db->quoteName('#__fields')); + + // Where context is found + $query->where( + $this->db->quoteName('context') . ' = '. $this->db->quote($context) + ); + $this->db->setQuery($query); + + // Execute query to see if context is found + $this->db->execute(); + $found = $this->db->getNumRows(); + + // Now check if there were any rows + if ($found) + { + // Since there are load the needed release_check field ids + $ids = $this->db->loadColumn(); + + // Create a new query object. + $query = $this->db->getQuery(true); + + // Remove context from the field table + $condition = [ + $this->db->quoteName('context') . ' = '. $this->db->quote($context) + ]; + + $query->delete($this->db->quoteName('#__fields')); + $query->where($condition); + + $this->db->setQuery($query); + + // Execute the query to remove release_check items + $done = $this->db->execute(); + if ($done) + { + // If successfully remove context add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The fields with context (%s) was removed from the #__fields table.', $context) + ); + } + + // Make sure that all the field values are cleared from DB + $this->removeFieldsValues($context, $ids); + } + } + + /** + * Remove fields values related to fields + * + * @param string $context The view context + * @param array $ids The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeFieldsValues(string $context, array $ids): void + { + $condition = [ + $this->db->quoteName('field_id') . ' IN ('. implode(',', $ids) .')' + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__fields_values')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove field values + $done = $this->db->execute(); + if ($done) + { + // If successfully remove release_check add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The fields values for (%s) was removed from the #__fields_values table.', $context) + ); + } + } + + /** + * Remove fields groups related to fields + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeFieldsGroups(string $context): void + { + // Create a new query object. + $query = $this->db->getQuery(true); + + // Select ids from fields + $query->select($this->db->quoteName('id')); + $query->from($this->db->quoteName('#__fields_groups')); + + // Where context is found + $query->where( + $this->db->quoteName('context') . ' = '. $this->db->quote($context) + ); + $this->db->setQuery($query); + + // Execute query to see if context is found + $this->db->execute(); + $found = $this->db->getNumRows(); + + // Now check if there were any rows + if ($found) + { + // Create a new query object. + $query = $this->db->getQuery(true); + + // Remove context from the field table + $condition = [ + $this->db->quoteName('context') . ' = '. $this->db->quote($context) + ]; + + $query->delete($this->db->quoteName('#__fields_groups')); + $query->where($condition); + + $this->db->setQuery($query); + + // Execute the query to remove release_check items + $done = $this->db->execute(); + if ($done) + { + // If successfully remove context add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The fields with context (%s) was removed from the #__fields_groups table.', $context) + ); + } + } + } + + /** + * Remove history related to this view + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeViewHistory(string $context): void + { + // Remove Item items from the ucm content table + $condition = [ + $this->db->quoteName('item_id') . ' LIKE ' . $this->db->quote($context . '.%') + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__history')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove Item items + $done = $this->db->execute(); + if ($done) + { + // If successfully removed Items add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The (%s) items were removed from the #__history table.', $context) + ); + } + } + + /** + * Remove ucm base values related to these IDs + * + * @param array $ids The type ids + * + * @return void + * @since 4.4.2 + */ + protected function removeUcmBase(array $ids): void + { + // Make sure that all the items are cleared from DB + foreach ($ids as $type_id) + { + // Remove Item items from the ucm base table + $condition = [ + $this->db->quoteName('ucm_type_id') . ' = ' . $type_id + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__ucm_base')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove Item items + $this->db->execute(); + } + + $this->app->enqueueMessage( + Text::_('All related items was removed from the #__ucm_base table.') + ); + } + + /** + * Remove ucm content values related to this view + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeUcmContent(string $context): void + { + // Remove Item items from the ucm content table + $condition = [ + $this->db->quoteName('core_type_alias') . ' = ' . $this->db->quote($context) + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__ucm_content')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove Item items + $done = $this->db->execute(); + if ($done) + { + // If successfully removed Item add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The (%s) type alias was removed from the #__ucm_content table.', $context) + ); + } + } + + /** + * Remove content item tag map related to this view + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeContentItemTagMap(string $context): void + { + // Create a new query object. + $query = $this->db->getQuery(true); + + // Remove Item items from the contentitem tag map table + $condition = [ + $this->db->quoteName('type_alias') . ' = '. $this->db->quote($context) + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__contentitem_tag_map')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove Item items + $done = $this->db->execute(); + if ($done) + { + // If successfully remove Item add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The (%s) type alias was removed from the #__contentitem_tag_map table.', $context) + ); + } + } + + /** + * Remove action log config related to this view + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeActionLogConfig(string $context): void + { + // Remove ###component### view from the action_log_config table + $condition = [ + $this->db->quoteName('type_alias') . ' = '. $this->db->quote($context) + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__action_log_config')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove com_###component###.view + $done = $this->db->execute(); + if ($done) + { + // If successfully removed ###component### view add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The (%s) type alias was removed from the #__action_log_config table.', $context) + ); + } + } + + /** + * Remove Asset Table Integrated + * + * @return void + * @since 4.4.2 + */ + protected function removeAssetData(): void + { + // Remove ###component### assets from the assets table + $condition = [ + $this->db->quoteName('name') . ' LIKE ' . $this->db->quote('com_###component###.%') + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__assets')); + $query->where($condition); + $this->db->setQuery($query); + $done = $this->db->execute(); + if ($done) + { + // If successfully removed ###component### add queued success message. + $this->app->enqueueMessage( + Text::_('All related (com_###component###) items was removed from the #__assets table.') + ); + } + } + + /** + * Remove action logs extensions integrated + * + * @return void + * @since 4.4.2 + */ + protected function removeActionLogsExtensions(): void + { + // Remove ###component### from the action_logs_extensions table + $extension = [ + $this->db->quoteName('extension') . ' = ' . $this->db->quote('com_###component###') + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__action_logs_extensions')); + $query->where($extension); + $this->db->setQuery($query); + + // Execute the query to remove ###component### + $done = $this->db->execute(); + if ($done) + { + // If successfully remove ###component### add queued success message. + $this->app->enqueueMessage( + Text::_('The (com_###component###) extension was removed from the #__action_logs_extensions table.') + ); + } + } + + /** + * Remove remove database fix (if possible) + * + * @return void + * @since 4.4.2 + */ + protected function removeDatabaseAssetsRulesFix(): void + { + // Get the biggest rule column in the assets table at this point. + $length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1"; + $this->db->setQuery($length); + if ($this->db->execute()) + { + $rule_length = $this->db->loadResult(); + // Check the size of the rules column + if ($rule_length < 5120) + { + // Revert the assets table rules column back to the default + $revert_rule = "ALTER TABLE `#__assets` CHANGE `rules` `rules` varchar(5120) NOT NULL COMMENT 'JSON encoded access control.';"; + $this->db->setQuery($revert_rule); + $this->db->execute(); + + $this->app->enqueueMessage( + Text::_('Reverted the #__assets table rules column back to its default size of varchar(5120).') + ); + } + else + { + $this->app->enqueueMessage( + Text::_('Could not revert the #__assets table rules column back to its default size of varchar(5120), since there is still one or more components that still requires the column to be larger.') + ); + } + } + }###MOVEFOLDERSMETHOD### +} diff --git a/admin/compiler/joomla_4/LAYOUT_OVERRIDE.php b/admin/compiler/joomla_4/LAYOUT_OVERRIDE.php new file mode 100644 index 000000000..1db124be7 --- /dev/null +++ b/admin/compiler/joomla_4/LAYOUT_OVERRIDE.php @@ -0,0 +1,22 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +###OVERRIDE_LAYOUT_HEADER### + +// No direct access to this file +defined('JPATH_BASE') or die;###OVERRIDE_LAYOUT_CODE### + +?>###OVERRIDE_LAYOUT_BODY### diff --git a/admin/compiler/joomla_4/LICENSE.txt b/admin/compiler/joomla_4/LICENSE.txt new file mode 100644 index 000000000..df50810b8 --- /dev/null +++ b/admin/compiler/joomla_4/LICENSE.txt @@ -0,0 +1,340 @@ +GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/admin/compiler/joomla_4/README.md b/admin/compiler/joomla_4/README.md new file mode 100644 index 000000000..dbb7b6a53 --- /dev/null +++ b/admin/compiler/joomla_4/README.md @@ -0,0 +1 @@ +###README### \ No newline at end of file diff --git a/admin/compiler/joomla_4/README.txt b/admin/compiler/joomla_4/README.txt new file mode 100644 index 000000000..dbb7b6a53 --- /dev/null +++ b/admin/compiler/joomla_4/README.txt @@ -0,0 +1 @@ +###README### \ No newline at end of file diff --git a/admin/compiler/joomla_4/SITE_ADMIN_VIEW.php b/admin/compiler/joomla_4/SITE_ADMIN_VIEW.php new file mode 100644 index 000000000..285eb38ee --- /dev/null +++ b/admin/compiler/joomla_4/SITE_ADMIN_VIEW.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +###SITE_ADMIN_VIEW_HEADER### + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
+toolbar->render(); ?> +
+###EDITBODY### +
+
###EDITBODYSCRIPT### diff --git a/admin/compiler/joomla_4/SITE_ADMIN_VIEW_CONTROLLER.php b/admin/compiler/joomla_4/SITE_ADMIN_VIEW_CONTROLLER.php new file mode 100644 index 000000000..9379d7327 --- /dev/null +++ b/admin/compiler/joomla_4/SITE_ADMIN_VIEW_CONTROLLER.php @@ -0,0 +1,291 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Controller; + +###SITE_ADMIN_VIEW_CONTROLLER_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###View### Form Controller + * + * @since 1.6 + */ +class ###View###Controller extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_###COMPONENT###_###VIEW###'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The context for storing internal data, e.g. record. + * + * @var string + * @since 1.6 + */ + protected $context = '###view###'; + + /** + * The URL view item variable. + * + * @var string + * @since 1.6 + */ + protected $view_item = '###view###'; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = '###SITE_DEFAULT_VIEW###';###ADMIN_CUSTOM_BUTTONS_CONTROLLER### + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + {###JCONTROLLERFORM_ALLOWADD### + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + {###JCONTROLLERFORM_ALLOWEDIT### + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('###View###', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_###component###&view=###views###' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64');###JCONTROLLERFORM_BEFORECANCEL### + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + }###JCONTROLLERFORM_AFTERCANCEL### + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + {###POSTSAVEHOOK### + } + +} diff --git a/admin/compiler/joomla_4/SITE_ADMIN_VIEW_HTML.php b/admin/compiler/joomla_4/SITE_ADMIN_VIEW_HTML.php new file mode 100644 index 000000000..d48f41976 --- /dev/null +++ b/admin/compiler/joomla_4/SITE_ADMIN_VIEW_HTML.php @@ -0,0 +1,142 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\View\###View###; + +###SITE_ADMIN_VIEW_HTML_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED### + +/** + * ###View### Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * ###View### view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_###component###'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + // get action permissions + $this->canDo = ###Component###Helper::getActions('###view###', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string)$this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string)$return; + }###LINKEDVIEWITEMS### + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ###ADDTOOLBAR### + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + {###JQUERY### + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_###COMPONENT###_###VIEW###_NEW' : 'COM_###COMPONENT###_###VIEW###_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + }###AJAXTOKE######LINKEDVIEWTABLESCRIPTS### + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + }###DOCUMENT_CUSTOM_PHP### + } +} diff --git a/admin/compiler/joomla_4/SITE_ADMIN_VIEW_MODEL.php b/admin/compiler/joomla_4/SITE_ADMIN_VIEW_MODEL.php new file mode 100644 index 000000000..51bf65ed8 --- /dev/null +++ b/admin/compiler/joomla_4/SITE_ADMIN_VIEW_MODEL.php @@ -0,0 +1,446 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Model; + +###SITE_ADMIN_VIEW_MODEL_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### ###View### Admin Model + * + * @since 1.6 + */ +class ###View###Model extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + */ + protected $tabLayoutFields = ###TABLAYOUTFIELDSARRAY###; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_###COMPONENT###'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_###component###.###view###'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = '###view###', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + }###ADMIN_CUSTOM_BUTTONS_METHOD### + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * + * @since 1.6 + */ + public function getItem($pk = null) + {###LICENSE_LOCKED_CHECK### + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + }###METHOD_GET_ITEM### + }###LINKEDVIEWGLOBAL### + + return $item; + }###LINKEDVIEWMETHODS######LICENSE_LOCKED_SET_BOOL### + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return mixed A JForm object on success, false on failure + * + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = array('control' => 'jform')) + { + // set load data option + $options['load_data'] = $loadData;###JMODELADMIN_GETFORM### + } + + /** + * Method to get the script that have to be included on the form + * + * @return string script files + */ + public function getScript() + { + return 'media/com_###component###/js/###view###.js'; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canDelete($record) + {###JMODELADMIN_CANDELETE### + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canEditState($record) + {###JMODELADMIN_CANEDITSTATE### + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + {###JMODELADMIN_ALLOWEDIT### + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * + * @since 1.6 + */ + protected function prepareTable($table) + {###LICENSE_TABLE_LOCKED_CHECK### + $date = $this->getDatabase(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__###component###_###view###')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_###component###.edit.###view###.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_###component###.###view###', $data); + + return $data; + }###VALIDATIONFIX######UNIQUEFIELDS### + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs. + * + * @since 12.2 + */ + public function delete(&$pks) + {###JMODELADMIN_BEFORE_DELETE### + if (!parent::delete($pks)) + { + return false; + }###JMODELADMIN_AFTER_DELETE### + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + {###JMODELADMIN_BEFORE_PUBLISH### + if (!parent::publish($pks, $value)) + { + return false; + }###JMODELADMIN_AFTER_PUBLISH### + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ###Component###Helper::getActions('###view###'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + }###MODEL_BATCH_COPY######MODEL_BATCH_MOVE### + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->input; + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + }###CHECKBOX_SAVE######METHOD_ITEM_SAVE### + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + }###TITLEALIASFIX### + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load(array($field => $value))) + { + $value = StringHelper::increment($value); + } + + return $value; + }###GENERATENEWTITLE### +} diff --git a/admin/compiler/joomla_4/SITE_AJAX_CONTROLLER.php b/admin/compiler/joomla_4/SITE_AJAX_CONTROLLER.php new file mode 100644 index 000000000..f69ef0234 --- /dev/null +++ b/admin/compiler/joomla_4/SITE_AJAX_CONTROLLER.php @@ -0,0 +1,97 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Session\Session; +use Joomla\Input\Input; +use Joomla\Utilities\ArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### Ajax Base Controller + * + * @since 1.6 + */ +class AjaxController extends BaseController +{ + /** + * Constructor. + * + * @param array $config An optional associative array of configuration settings. + * Recognized key values include 'name', 'default_task', 'model_path', and + * 'view_path' (this list is not meant to be comprehensive). + * @param ?MVCFactoryInterface $factory The factory. + * @param ?CMSApplication $app The Application for the dispatcher + * @param ?Input $input Input + * + * @since 3.0 + */ + public function __construct($config = [], ?MVCFactoryInterface $factory = null, ?CMSApplication $app = null, ?Input $input = null) + { + parent::__construct($config, $factory, $app, $input); + + // make sure all json stuff are set + $this->app->getDocument()->setMimeEncoding( 'application/json' ); + $this->app->setHeader('Content-Disposition','attachment;filename="getajax.json"'); + $this->app->setHeader('Access-Control-Allow-Origin', '*'); + // load the tasks ###REGISTER_SITE_AJAX_TASK### + } + + public function ajax() + { + // get the user for later use + $user = $this->app->getIdentity(); + // get the input values + $jinput = $this->input ?? $this->app->input; + // check if we should return raw (DEFAULT TRUE SINCE J4) + $returnRaw = $jinput->get('raw', true, 'BOOLEAN'); + // return to a callback function + $callback = $jinput->get('callback', null, 'CMD'); + // Check Token! + $token = Session::getFormToken(); + $call_token = $jinput->get('token', 0, 'ALNUM'); + if($jinput->get($token, 0, 'ALNUM') || $token === $call_token) + { + // get the task + $task = $this->getTask(); + switch($task) + {###AJAX_SITE_INPUT_RETURN### + } + } + else + { + // return to a callback function + if($callback) + { + echo $callback."(".json_encode(['error' => 'There was an error! [139]']).");"; + } + elseif($returnRaw) + { + echo json_encode(['error' => 'There was an error! [139]']); + } + else + { + echo "(".json_encode(['error' => 'There was an error! [139]']).");"; + } + } + } +} diff --git a/admin/compiler/joomla_4/SITE_AJAX_MODEL.php b/admin/compiler/joomla_4/SITE_AJAX_MODEL.php new file mode 100644 index 000000000..1cec88644 --- /dev/null +++ b/admin/compiler/joomla_4/SITE_AJAX_MODEL.php @@ -0,0 +1,62 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Model; + +###AJAX_SITE_MODEL_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### Ajax List Model + * + * @since 1.6 + */ +class AjaxModel extends ListModel +{ + /** + * The component params. + * + * @var Registry + * @since 3.2.0 + */ + protected Registry $app_params; + + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + parent::__construct($config, $factory); + + $this->app_params = ComponentHelper::getParams('com_###component###'); + $this->app ??= Factory::getApplication(); + }###AJAX_SITE_MODEL_METHODS### +} diff --git a/admin/compiler/joomla_4/SITE_DISPATCHER.php b/admin/compiler/joomla_4/SITE_DISPATCHER.php new file mode 100644 index 000000000..c86e55ee1 --- /dev/null +++ b/admin/compiler/joomla_4/SITE_DISPATCHER.php @@ -0,0 +1,41 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Dispatcher; + +use Joomla\CMS\Dispatcher\ComponentDispatcher; + +// No direct access to this file +\defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED### + +/** + * ComponentDispatcher class for com_###component### + * + * @since 4.0.0 + */ +class Dispatcher extends ComponentDispatcher +{ + /** + * Dispatch a controller task. Redirecting the user if appropriate. + * + * @return void + * + * @since 4.0.0 + */ + public function dispatch() + { + parent::dispatch(); + } +} diff --git a/admin/compiler/joomla_4/SITE_DISPLAY_CONTROLLER.php b/admin/compiler/joomla_4/SITE_DISPLAY_CONTROLLER.php new file mode 100644 index 000000000..93767574c --- /dev/null +++ b/admin/compiler/joomla_4/SITE_DISPLAY_CONTROLLER.php @@ -0,0 +1,132 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\CMS\Router\Route; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Language\Text; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### master site display controller. + * + * @since 4.0 + */ +class DisplayController extends BaseController +{ + /** + * Method to display a view. + * + * @param boolean $cachable If true, the view output will be cached. + * @param boolean $urlparams An array of safe URL parameters and their variable types, for valid values see {@link InputFilter::clean()}. + * + * @return DisplayController This object to support chaining. + * @since 1.5 + */ + function display($cachable = false, $urlparams = false) + { + // set default view if not set + $view = $this->input->getCmd('view', '###SITE_DEFAULT_VIEW###'); + $this->input->set('view', $view); + $isEdit = $this->checkEditView($view); + $layout = $this->input->get('layout', null, 'WORD'); + $id = $this->input->getInt('id'); + $cachable = true; + + // ensure that the view is not cashable if edit view or if user is logged in + $user = $this->app->getIdentity(); + if ($user->get('id') || $this->input->getMethod() === 'POST' || $isEdit) + { + $cachable = false; + } + + // Check for edit form. + if ($isEdit && !$this->checkEditId('com_###component###.edit.'.$view, $id)) + { + // check if item was opened from other than its own list view + $ref = $this->input->getCmd('ref', 0); + $refid = $this->input->getInt('refid', 0); + + // set redirect + if ($refid > 0 && Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($ref)) + { + // redirect to item of ref + $this->setRedirect(Route::_('index.php?option=com_###component###&view='.(string)$ref.'&layout=edit&id='.(int)$refid, false)); + } + elseif (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($ref)) + { + // redirect to ref + $this->setRedirect(Route::_('index.php?option=com_###component###&view='.(string)$ref, false)); + } + else + { + // normal redirect back to the list default site view + $this->setRedirect(Route::_('index.php?option=com_###component###&view=###SITE_DEFAULT_VIEW###', false)); + } + + // Somehow the person just went to the form - we don't allow that. + throw new \Exception(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 403); + } + + // we may need to make this more dynamic in the future. (TODO) + $safeurlparams = array( + 'catid' => 'INT', + 'id' => 'INT', + 'cid' => 'ARRAY', + 'year' => 'INT', + 'month' => 'INT', + 'limit' => 'UINT', + 'limitstart' => 'UINT', + 'showall' => 'INT', + 'return' => 'BASE64', + 'filter' => 'STRING', + 'filter_order' => 'CMD', + 'filter_order_Dir' => 'CMD', + 'filter-search' => 'STRING', + 'print' => 'BOOLEAN', + 'lang' => 'CMD', + 'Itemid' => 'INT'); + + // should these not merge? + if (Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($urlparams)) + { + $safeurlparams = Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::merge(array($urlparams, $safeurlparams)); + } + + parent::display($cachable, $safeurlparams); + + return $this; + } + + protected function checkEditView($view) + { + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($view)) + { + $views = [###SITE_EDIT_VIEW_ARRAY### + ]; + // check if this is a edit view + if (in_array($view,$views)) + { + return true; + } + } + return false; + } +} diff --git a/admin/compiler/joomla_4/SITE_FORM_CHECKBOXES_FIELD.php b/admin/compiler/joomla_4/SITE_FORM_CHECKBOXES_FIELD.php new file mode 100644 index 000000000..bdc5586de --- /dev/null +++ b/admin/compiler/joomla_4/SITE_FORM_CHECKBOXES_FIELD.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\CheckboxesField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Helper\###Component###Helper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Type### Form Field class for the ###Component### component + * + * @since 1.6 + */ +class ###Type###Field extends CheckboxesField +{ + /** + * The ###type### field type. + * + * @var string + */ + public $type = '###Type###'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + */ + protected function getOptions() + { + ###JFORM_GETOPTIONS_PHP### + } +} diff --git a/admin/compiler/joomla_4/SITE_FORM_CUSTOM_FIELD.php b/admin/compiler/joomla_4/SITE_FORM_CUSTOM_FIELD.php new file mode 100644 index 000000000..6feabb598 --- /dev/null +++ b/admin/compiler/joomla_4/SITE_FORM_CUSTOM_FIELD.php @@ -0,0 +1,36 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Field; + +###SITE_FORM_CUSTOM_FIELD_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Type### Form Field class for the ###Component### component + * + * @since 1.6 + */ +class ###Type###Field extends ###FORM_EXTENDS### +{ + /** + * The ###type### field type. + * + * @var string + */ + public $type = '###Type###';###FORM_CUSTOM_FIELD_PHP### +} diff --git a/admin/compiler/joomla_4/SITE_FORM_LIST_FIELD.php b/admin/compiler/joomla_4/SITE_FORM_LIST_FIELD.php new file mode 100644 index 000000000..94dd388be --- /dev/null +++ b/admin/compiler/joomla_4/SITE_FORM_LIST_FIELD.php @@ -0,0 +1,52 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Helper\###Component###Helper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Type### Form Field class for the ###Component### component + * + * @since 1.6 + */ +class ###Type###Field extends ListField +{ + /** + * The ###type### field type. + * + * @var string + */ + public $type = '###Type###';###ADD_BUTTON### + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + ###JFORM_GETOPTIONS_PHP### + } +} diff --git a/admin/compiler/joomla_4/SITE_FORM_RADIO_FIELD.php b/admin/compiler/joomla_4/SITE_FORM_RADIO_FIELD.php new file mode 100644 index 000000000..635a592ca --- /dev/null +++ b/admin/compiler/joomla_4/SITE_FORM_RADIO_FIELD.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\RadioField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Helper\###Component###Helper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Type### Form Field class for the ###Component### component + * + * @since 1.6 + */ +class ###Type###Field extends RadioField +{ + /** + * The ###type### field type. + * + * @var string + */ + public $type = '###Type###'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + */ + protected function getOptions() + { + ###JFORM_GETOPTIONS_PHP### + } +} diff --git a/admin/compiler/joomla_4/SITE_FORM_RULE.php b/admin/compiler/joomla_4/SITE_FORM_RULE.php new file mode 100644 index 000000000..533bd4f38 --- /dev/null +++ b/admin/compiler/joomla_4/SITE_FORM_RULE.php @@ -0,0 +1,37 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Rule; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Form\FormRule; +use Joomla\Registry\Registry; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Helper\###Component###Helper; + +// No direct access to this file +\defined('JPATH_PLATFORM') or die; + +/** + * Form Rule (###Name###) class for the Joomla Platform. + * + * @since 3.5 + */ +class ###Name###Rule extends FormRule +{###VALIDATION_RULE_METHODS### +} diff --git a/admin/compiler/joomla_4/SITE_FORM_USER_FIELD.php b/admin/compiler/joomla_4/SITE_FORM_USER_FIELD.php new file mode 100644 index 000000000..4911b111a --- /dev/null +++ b/admin/compiler/joomla_4/SITE_FORM_USER_FIELD.php @@ -0,0 +1,65 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\UserField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Helper\###Component###Helper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Type### Form Field class for the ###Component### component + * + * @since 1.6 + */ +class ###Type###Field extends UserField +{ + /** + * The ###type### field type. + * + * @var string + */ + public $type = '###Type###'; + + /** + * Method to get the filtering groups (null means no filtering) + * + * @return mixed array of filtering groups or null. + * + * @since 1.6 + */ + protected function getGroups() + { + ###JFORM_GETGROUPS_PHP### + } + + /** + * Method to get the users to exclude from the list of users + * + * @return mixed Array of users to exclude or null to not exclude them + * + * @since 1.6 + */ + protected function getExcluded() + { + ###JFORM_GETEXCLUDED_PHP### + } +} diff --git a/admin/compiler/joomla_4/SITE_HEADERCHECK.php b/admin/compiler/joomla_4/SITE_HEADERCHECK.php new file mode 100644 index 000000000..574f45eda --- /dev/null +++ b/admin/compiler/joomla_4/SITE_HEADERCHECK.php @@ -0,0 +1,135 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Helper; + +use Joomla\CMS\Factory; +use Joomla\CMS\Document\Document; +use Joomla\CMS\Application\CMSApplication; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Helper class for checking loaded scripts and styles in the document header. + * + * @since 3.2.0 + */ +class HeaderCheck +{ + /** + * @var CMSApplication Application object + * + * @since 3.2.0 + */ + protected CMSApplication $app; + + /** + * @var Document object + * + * @since 3.2.0 + */ + protected Document $document; + + /** + * Construct the app and document + * + * @since 3.2.0 + */ + public function __construct() + { + // Initializes the application object. + $this->app ??= Factory::getApplication(); + + // Initializes the document object. + $this->document = $this->app->getDocument(); + } + + /** + * Check if a JavaScript file is loaded in the document head. + * + * @param string $scriptName Name of the script to check. + * + * @return bool True if the script is loaded, false otherwise. + * @since 3.2.0 + */ + public function js_loaded(string $scriptName): bool + { + return $this->isLoaded($scriptName, 'scripts'); + } + + /** + * Check if a CSS file is loaded in the document head. + * + * @param string $scriptName Name of the stylesheet to check. + * + * @return bool True if the stylesheet is loaded, false otherwise. + * @since 3.2.0 + */ + public function css_loaded(string $scriptName): bool + { + return $this->isLoaded($scriptName, 'styleSheets'); + } + + /** + * Abstract method to check if a given script or stylesheet is loaded. + * + * @param string $scriptName Name of the script or stylesheet. + * @param string $type Type of asset to check ('scripts' or 'styleSheets'). + * + * @return bool True if the asset is loaded, false otherwise. + * @since 3.2.0 + */ + private function isLoaded(string $scriptName, string $type): bool + { + // UIkit specific check + if ($this->isUIkit($scriptName)) + { + return true; + } + + $head_data = $this->document->getHeadData(); + foreach (array_keys($head_data[$type]) as $script) + { + if (stristr($script, $scriptName)) + { + return true; + } + } + + return false; + } + + /** + * Check for UIkit framework specific conditions. + * + * @param string $scriptName Name of the script or stylesheet. + * + * @return bool True if UIkit specific conditions are met, false otherwise. + * @since 3.2.0 + */ + private function isUIkit(string $scriptName): bool + { + if (strpos($scriptName, 'uikit') !== false) + { + $get_template_name = $this->app->getTemplate('template')->template; + if (strpos($get_template_name, 'yoo') !== false) + { + return true; + } + } + return false; + } +} diff --git a/admin/compiler/joomla_4/SITE_HELPER_CLASS.php b/admin/compiler/joomla_4/SITE_HELPER_CLASS.php new file mode 100644 index 000000000..9b2cba942 --- /dev/null +++ b/admin/compiler/joomla_4/SITE_HELPER_CLASS.php @@ -0,0 +1,926 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Helper; + +###SITE_POWER_HELPER### + +###SITE_HELPER_CLASS_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### component helper + * + * @since 3.0 + */ +abstract class ###Component###Helper +{ + /** + * Composer Switch + * + * @var array + */ + protected static $composer = []; + + /** + * The Main Active Language + * + * @var string + */ + public static $langTag;###SITE_GLOBAL_EVENT_HELPER######SITE_CUSTOM_HELPER_SCRIPT######BOTH_CUSTOM_HELPER_SCRIPT### + + /** + * Load the Composer Vendors + */ + public static function composerAutoload($target) + { + // insure we load the composer vendor only once + if (!isset(self::$composer[$target])) + { + // get the function name + $functionName = Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe('compose' . $target); + // check if method exist + if (method_exists(__CLASS__, $functionName)) + { + return self::{$functionName}(); + } + return false; + } + return self::$composer[$target]; + } + + /** + * Convert a json object to a string + * + * @input string $value The json string to convert + * + * @returns a string + * @deprecated 3.3 Use Super___4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::string(...); + */ + public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name') + { + return Super___4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::string( + $value, + $sperator, + $table, + $id, + $name + ); + } + + /** + * Load the Component xml manifest. + */ + public static function manifest() + { + $manifestUrl = JPATH_ADMINISTRATOR."/components/com_###component###/###component###.xml"; + return simplexml_load_file($manifestUrl); + } + + /** + * Joomla version object + */ + protected static $JVersion; + + /** + * set/get Joomla version + */ + public static function jVersion() + { + // check if set + if (!Super___91004529_94a9_4590_b842_e7c6b624ecf5___Power::check(self::$JVersion)) + { + self::$JVersion = new Version(); + } + return self::$JVersion; + } + + /** + * Load the Contributors details. + */ + public static function getContributors() + { + // get params + $params = ComponentHelper::getParams('com_###component###'); + // start contributors array + $contributors = []; + // get all Contributors (max 20) + $searchArray = range('0','20'); + foreach($searchArray as $nr) + { + if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 2 || $params->get("showContributor".$nr) == 3)) + { + // set link based of selected option + if($params->get("useContributor".$nr) == 1) + { + $link_front = ''; + $link_back = ''; + } + elseif($params->get("useContributor".$nr) == 2) + { + $link_front = ''; + $link_back = ''; + } + else + { + $link_front = ''; + $link_back = ''; + } + $contributors[$nr]['title'] = Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($params->get("titleContributor".$nr)); + $contributors[$nr]['name'] = $link_front.Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($params->get("nameContributor".$nr)).$link_back; + } + } + return $contributors; + }###HELP_SITE### + + /** + * Returns any Model object. + * + * @param string $type The model type to instantiate + * @param string $prefix Prefix for the model class name. Optional. + * @param string $component Component name the model belongs to. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * @throws \Exception + * @since 4.4 + */ + public static function getModel(string $type, string $prefix = 'Site', + string $component = '###component###', array $config = []) + { + // make sure the name is correct + $type = Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($type, 'F'); + $component = strtolower($component); + + if ($prefix !== 'Site' && $prefix !== 'Administrator') + { + $prefix = self::getPrefixFromModelPath($prefix); + } + + // Get the model through the MVCFactory + return Factory::getApplication()->bootComponent('com_' . $component)->getMVCFactory()->createModel($type, $prefix, $config); + } + + /** + * Get the prefix from the model path + * + * @param string $path The model path + * + * @return string The prefix value + * @since 4.4 + */ + protected static function getPrefixFromModelPath(string $path): string + { + // Check if $path starts with JPATH_ADMINISTRATOR path + if (str_starts_with($path, JPATH_ADMINISTRATOR . '/components/')) + { + return 'Administrator'; + } + // Check if $path starts with JPATH_SITE path + elseif (str_starts_with($path, JPATH_SITE . '/components/')) + { + return 'Site'; + } + + return 'Site'; + } + + /** + * Add to asset Table + */ + public static function setAsset($id, $table, $inherit = true) + { + $parent = Table::getInstance('Asset'); + $parent->loadByName('com_###component###'); + + $parentId = $parent->id; + $name = 'com_###component###.'.$table.'.'.$id; + $title = ''; + + $asset = Table::getInstance('Asset'); + $asset->loadByName($name); + + // Check for an error. + $error = $asset->getError(); + + if ($error) + { + return false; + } + else + { + // Specify how a new or moved node asset is inserted into the tree. + if ($asset->parent_id != $parentId) + { + $asset->setLocation($parentId, 'last-child'); + } + + // Prepare the asset to be stored. + $asset->parent_id = $parentId; + $asset->name = $name; + $asset->title = $title; + // get the default asset rules + $rules = self::getDefaultAssetRules('com_###component###', $table, $inherit); + if ($rules instanceof AccessRules) + { + $asset->rules = (string) $rules; + } + + if (!$asset->check() || !$asset->store()) + { + Factory::getApplication()->enqueueMessage($asset->getError(), 'warning'); + return false; + } + else + { + // Create an asset_id or heal one that is corrupted. + $object = new \StdClass(); + + // Must be a valid primary key value. + $object->id = $id; + $object->asset_id = (int) $asset->id; + + // Update their asset_id to link to the asset table. + return Factory::getDbo()->updateObject('#__###component###_'.$table, $object, 'id'); + } + } + return false; + } + + /** + * Gets the default asset Rules for a component/view. + */ + protected static function getDefaultAssetRules($component, $view, $inherit = true) + { + // if new or inherited + $assetId = 0; + // Only get the actual item rules if not inheriting + if (!$inherit) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + // check that there is a value + if ($db->getNumRows()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + } + } + // get asset rules + $result = Access::getAssetRules($assetId); + if ($result instanceof AccessRules) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($view !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + elseif ($inherit) + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count((array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules($_result); + // return filtered rules + return $rules; + } + } + return $result; + } + + /** + * xmlAppend + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement + * + * @return void + * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::append($xml, $node); + */ + public static function xmlAppend(&$xml, $node) + { + Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::append($xml, $node); + } + + /** + * xmlComment + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param string $comment The comment to inject + * + * @return void + * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::comment($xml, $comment); + */ + public static function xmlComment(&$xml, $comment) + { + Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::comment($xml, $comment); + } + + /** + * xmlAddAttributes + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param array $attributes The attributes to apply to the XML element + * + * @return null + * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::attributes($xml, $attributes); + */ + public static function xmlAddAttributes(&$xml, $attributes = []) + { + Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::attributes($xml, $attributes); + } + + /** + * xmlAddOptions + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param array $options The options to apply to the XML element + * + * @return void + * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::options($xml, $options); + */ + public static function xmlAddOptions(&$xml, $options = []) + { + Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::options($xml, $options); + } + + /** + * get the field object + * + * @param array $attributes The array of attributes + * @param string $default The default of the field + * @param array $options The options to apply to the XML element + * + * @return object + * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::field($attributes, $default, $options); + */ + public static function getFieldObject(&$attributes, $default = '', $options = null) + { + return Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::field($attributes, $default, $options); + } + + /** + * get the field xml + * + * @param array $attributes The array of attributes + * @param array $options The options to apply to the XML element + * + * @return object + * @deprecated 3.3 Use Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::xml($attributes, $options); + */ + public static function getFieldXML(&$attributes, $options = null) + { + return Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::xml($attributes, $options); + } + + /** + * Render Bool Button + * + * @param array $args All the args for the button + * 0) name + * 1) additional (options class) // not used at this time + * 2) default + * 3) yes (name) + * 4) no (name) + * + * @return string The input html of the button + * + */ + public static function renderBoolButton() + { + $args = func_get_args(); + // check if there is additional button class + $additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time + // button attributes + $buttonAttributes = array( + 'type' => 'radio', + 'name' => isset($args[0]) ? Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($args[0]) : 'bool_button', + 'label' => isset($args[0]) ? Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe(Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($args[0]), 'Ww') : 'Bool Button', // not seen anyway + 'class' => 'btn-group', + 'filter' => 'INT', + 'default' => isset($args[2]) ? (int) $args[2] : 0); + // set the button options + $buttonOptions = array( + '1' => isset($args[3]) ? Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($args[3]) : 'JYES', + '0' => isset($args[4]) ? Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($args[4]) : 'JNO'); + // return the input + return Super___1198aecf_84c6_45d2_aea8_d531aa4afdfa___Power::field($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input; + }###HELPER_UIKIT######HELPER_CREATEUSER### + + /** + * Get a variable + * + * @param string $table The table from which to get the variable + * @param string $where The value where + * @param string $whereString The target/field string where/name + * @param string $what The return field + * @param string $operator The operator between $whereString/field and $where/value + * @param string $main The component in which the table is found + * + * @return mix string/int/float + * @deprecated 3.3 Use Super___db87c339_5bb6_4291_a7ef_2c48ea1b06bc___Power::var(...); + */ + public static function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = '###component###') + { + return Super___db87c339_5bb6_4291_a7ef_2c48ea1b06bc___Power::var( + $table, + $where, + $whereString, + $what, + $operator, + $main + ); + } + + /** + * Get array of variables + * + * @param string $table The table from which to get the variables + * @param string $where The value where + * @param string $whereString The target/field string where/name + * @param string $what The return field + * @param string $operator The operator between $whereString/field and $where/value + * @param string $main The component in which the table is found + * @param bool $unique The switch to return a unique array + * + * @return array + * @deprecated 3.3 Use Super___db87c339_5bb6_4291_a7ef_2c48ea1b06bc___Power::vars(...); + */ + public static function getVars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = '###component###', $unique = true) + { + return Super___db87c339_5bb6_4291_a7ef_2c48ea1b06bc___Power::vars( + $table, + $where, + $whereString, + $what, + $operator, + $main, + $unique + ); + } + + public static function isPublished($id,$type) + { + if ($type == 'raw') + { + $type = 'item'; + } + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true); + $query->select(array('a.published')); + $query->from('#__###component###_'.$type.' AS a'); + $query->where('a.id = '. (int) $id); + $query->where('a.published = 1'); + $db->setQuery($query); + $db->execute(); + $found = $db->getNumRows(); + if($found) + { + return true; + } + return false; + } + + public static function getGroupName($id) + { + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true); + $query->select(array('a.title')); + $query->from('#__usergroups AS a'); + $query->where('a.id = '. (int) $id); + $db->setQuery($query); + $db->execute(); + $found = $db->getNumRows(); + if($found) + { + return $db->loadResult(); + } + return $id; + } + + /** + * Get the action permissions + * + * @param string $view The related view name + * @param int $record The item to act upon + * @param string $views The related list view name + * @param mixed $target Only get this permission (like edit, create, delete) + * @param string $component The target component + * @param object $user The user whose permissions we are loading + * + * @return object The CMSObject of permission/authorised actions + * + */ + public static function getActions($view, &$record = null, $views = null, $target = null, $component = '###component###', $user = 'null') + { + // load the user if not given + if (!Super___91004529_94a9_4590_b842_e7c6b624ecf5___Power::check($user)) + { + // get the user object + $user = Factory::getApplication()->getIdentity(); + } + // load the CMSObject + $result = new CMSObject; + // make view name safe (just incase) + $view = Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($view); + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($views)) + { + $views = Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe($views); + } + // get all actions from component + $actions = Access::getActionsFromFile( + JPATH_ADMINISTRATOR . '/components/com_' . $component . '/access.xml', + "/access/section[@name='component']/" + ); + // if non found then return empty CMSObject + if (empty($actions)) + { + return $result; + } + // get created by if not found + if (Super___91004529_94a9_4590_b842_e7c6b624ecf5___Power::check($record) && !isset($record->created_by) && isset($record->id)) + { + $record->created_by = Super___db87c339_5bb6_4291_a7ef_2c48ea1b06bc___Power::var($view, $record->id, 'id', 'created_by', '=', $component); + } + // set actions only set in component settings + $componentActions = array('core.admin', 'core.manage', 'core.options', 'core.export'); + // check if we have a target + $checkTarget = false; + if ($target) + { + // convert to an array + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($target)) + { + $target = array($target); + } + // check if we are good to go + if (Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($target)) + { + $checkTarget = true; + } + } + // loop the actions and set the permissions + foreach ($actions as $action) + { + // check target action filter + if ($checkTarget && self::filterActions($view, $action->name, $target)) + { + continue; + } + // set to use component default + $fallback = true; + // reset permission per/action + $permission = false; + $catpermission = false; + // set area + $area = 'comp'; + // check if the record has an ID and the action is item related (not a component action) + if (Super___91004529_94a9_4590_b842_e7c6b624ecf5___Power::check($record) && isset($record->id) && $record->id > 0 && !in_array($action->name, $componentActions) && + (strpos($action->name, 'core.') !== false || strpos($action->name, $view . '.') !== false)) + { + // we are in item + $area = 'item'; + // The record has been set. Check the record permissions. + $permission = $user->authorise($action->name, 'com_' . $component . '.' . $view . '.' . (int) $record->id); + // if no permission found, check edit own + if (!$permission) + { + // With edit, if the created_by matches current user then dig deeper. + if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) + { + // the correct target + $coreCheck = (array) explode('.', $action->name); + // check that we have both local and global access + if ($user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component . '.' . $view . '.' . (int) $record->id) && + $user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component)) + { + // allow edit + $result->set($action->name, true); + // set not to use global default + // because we already validated it + $fallback = false; + } + else + { + // do not allow edit + $result->set($action->name, false); + $fallback = false; + } + } + } + elseif (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($views) && isset($record->catid) && $record->catid > 0) + { + // we are in item + $area = 'category'; + // set the core check + $coreCheck = explode('.', $action->name); + $core = $coreCheck[0]; + // make sure we use the core. action check for the categories + if (strpos($action->name, $view) !== false && strpos($action->name, 'core.') === false ) + { + $coreCheck[0] = 'core'; + $categoryCheck = implode('.', $coreCheck); + } + else + { + $categoryCheck = $action->name; + } + // The record has a category. Check the category permissions. + $catpermission = $user->authorise($categoryCheck, 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid); + if (!$catpermission && !is_null($catpermission)) + { + // With edit, if the created_by matches current user then dig deeper. + if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) + { + // check that we have both local and global access + if ($user->authorise('core.edit.own', 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid) && + $user->authorise($core . '.edit.own', 'com_' . $component)) + { + // allow edit + $result->set($action->name, true); + // set not to use global default + // because we already validated it + $fallback = false; + } + else + { + // do not allow edit + $result->set($action->name, false); + $fallback = false; + } + } + } + } + } + // if allowed then fallback on component global settings + if ($fallback) + { + // if item/category blocks access then don't fall back on global + if ((($area === 'item') && !$permission) || (($area === 'category') && !$catpermission)) + { + // do not allow + $result->set($action->name, false); + } + // Finally remember the global settings have the final say. (even if item allow) + // The local item permissions can block, but it can't open and override of global permissions. + // Since items are created by users and global permissions is set by system admin. + else + { + $result->set($action->name, $user->authorise($action->name, 'com_' . $component)); + } + } + } + return $result; + } + + /** + * Filter the action permissions + * + * @param string $action The action to check + * @param array $targets The array of target actions + * + * @return boolean true if action should be filtered out + * + */ + protected static function filterActions(&$view, &$action, &$targets) + { + foreach ($targets as $target) + { + if (strpos($action, $view . '.' . $target) !== false || + strpos($action, 'core.' . $target) !== false) + { + return false; + break; + } + } + return true; + } + + /** + * Check if have an json string + * + * @input string The json string to check + * + * @returns bool true on success + * @deprecated 3.3 Use Super___4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::check($string); + */ + public static function checkJson($string) + { + return Super___4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::check($string); + } + + /** + * Check if have an object with a length + * + * @input object The object to check + * + * @returns bool true on success + * @deprecated 3.3 Use Super___91004529_94a9_4590_b842_e7c6b624ecf5___Power::check($object); + */ + public static function checkObject($object) + { + return Super___91004529_94a9_4590_b842_e7c6b624ecf5___Power::check($object); + } + + /** + * Check if have an array with a length + * + * @input array The array to check + * + * @returns bool/int number of items in array on success + * @deprecated 3.3 Use Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($array, $removeEmptyString); + */ + public static function checkArray($array, $removeEmptyString = false) + { + return Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($array, $removeEmptyString); + } + + /** + * Check if have a string with a length + * + * @input string The string to check + * + * @returns bool true on success + * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($string); + */ + public static function checkString($string) + { + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($string); + } + + /** + * Check if we are connected + * Thanks https://stackoverflow.com/a/4860432/1429677 + * + * @returns bool true on success + */ + public static function isConnected() + { + // If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right? + $connected = @fsockopen("www.example.com", 80); + // website, port (try 80 or 443) + if ($connected) + { + //action when connected + $is_conn = true; + fclose($connected); + } + else + { + //action in connection failure + $is_conn = false; + } + return $is_conn; + } + + /** + * Merge an array of array's + * + * @input array The arrays you would like to merge + * + * @returns array on success + * @deprecated 3.3 Use Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::merge($arrays); + */ + public static function mergeArrays($arrays) + { + return Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::merge($arrays); + } + + // typo sorry! + public static function sorten($string, $length = 40, $addTip = true) + { + return self::shorten($string, $length, $addTip); + } + + /** + * Shorten a string + * + * @input string The you would like to shorten + * + * @returns string on success + * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::shorten(...); + */ + public static function shorten($string, $length = 40, $addTip = true) + { + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::shorten($string, $length, $addTip); + } + + /** + * Making strings safe (various ways) + * + * @input string The you would like to make safe + * + * @returns string on success + * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe(...); + */ + public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true) + { + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::safe( + $string, + $type, + $spacer, + $replaceNumbers, + $keepOnlyCharacters + ); + } + + /** + * Convert none English strings to code usable string + * + * @input an string + * + * @returns a string + * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::transliterate($string); + */ + public static function transliterate($string) + { + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::transliterate($string); + } + + /** + * make sure a string is HTML save + * + * @input an html string + * + * @returns a string + * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html(...); + */ + public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40) + { + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html( + $var, + $charset, + $shorten, + $length + ); + }###HELPER_SITE_LICENSE_LOCK### + + /** + * Convert all int in a string to an English word string + * + * @input an string with numbers + * + * @returns a string + * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::numbers($string); + */ + public static function replaceNumbers($string) + { + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::numbers($string); + } + + /** + * Convert an integer into an English word string + * Thanks to Tom Nicholson + * + * @input an int + * @returns a string + * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::number($x); + */ + public static function numberToString($x) + { + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::number($x); + } + + /** + * Random Key + * + * @returns a string + * @deprecated 3.3 Use Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::random($size); + */ + public static function randomkey($size) + { + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::random($size); + }###GET_CRYPT_KEY### +} diff --git a/admin/compiler/joomla_4/SITE_HELPER_CONTROLLER.php b/admin/compiler/joomla_4/SITE_HELPER_CONTROLLER.php new file mode 100644 index 000000000..bbc91bd97 --- /dev/null +++ b/admin/compiler/joomla_4/SITE_HELPER_CONTROLLER.php @@ -0,0 +1,129 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\Database\DatabaseInterface; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Session\Session; +use Joomla\Utilities\ArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### Help Base Controller + * + * @since 1.6 + */ +class HelpController extends BaseController +{ + public function __construct($config) + { + parent::__construct($config); + // load the tasks + $this->registerTask('getText', 'help'); + } + + public function help() + { + $user = Factory::getApplication()->getIdentity(); + $jinput = Factory::getApplication()->input; + // Check Token! + $token = Session::getFormToken(); + $call_token = $jinput->get('token', 0, 'ALNUM'); + if($user->id != 0 && ($jinput->get($token, 0, 'ALNUM') || $token === $call_token)) + { + $task = $this->getTask(); + switch($task){ + case 'getText': + try + { + $idValue = $jinput->get('id', 0, 'INT'); + if($idValue) + { + $result = $this->getHelpDocumentText($idValue); + } + else + { + $result = ''; + } + echo $result; + // stop execution gracefully + jexit(); + } + catch(Exception $e) + { + // stop execution gracefully + jexit(); + } + break; + } + } + else + { + // stop execution gracefully + jexit(); + } + } + + protected function getHelpDocumentText($id) + { + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true); + $query->select(array('a.title','a.content')); + $query->from('#__###component###_help_document AS a'); + $query->where('a.id = '.(int) $id); + $query->where('a.published = 1'); + $query->where('a.location = 2'); + $db->setQuery($query); + $db->execute(); + if($db->getNumRows()) + { + $text = []; + $document = $db->loadObject(); + // fix image issue + $images['src="images'] = 'src="'.Uri::root().'images'; + $images["src='images"] = "src='".Uri::root()."images"; + $images['src="/images'] = 'src="'.Uri::root().'images'; + $images["src='/images"] = "src='".Uri::root()."images"; + // set document template + $text[] = ""; + $text[] = ''; + $text[] = ""; + $text[] = ''; + $text[] = "".$document->title.""; + $text[] = ''; + $text[] = ''; + $text[] = ""; + $text[] = '
'; + $text[] = '
'; + $text[] = '
'; + // build the help text + $text[] = '

'.$document->title."

"; + $text[] = str_replace(array_keys($images),array_values($images),$document->content); + // end template + $text[] = '


'; + $text[] = '
'; + $text[] = ""; + $text[] = ""; + + return implode("\n",$text); + } + return false; + } +} diff --git a/admin/compiler/joomla_4/SITE_LAYOUT.php b/admin/compiler/joomla_4/SITE_LAYOUT.php new file mode 100644 index 000000000..4d22fd308 --- /dev/null +++ b/admin/compiler/joomla_4/SITE_LAYOUT.php @@ -0,0 +1,22 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +###SITE_LAYOUT_HEADER### + +// No direct access to this file +defined('JPATH_BASE') or die;###SITE_LAYOUT_CODE### + +?>###SITE_LAYOUT_BODY### diff --git a/admin/compiler/joomla_4/SITE_ROUTER.php b/admin/compiler/joomla_4/SITE_ROUTER.php new file mode 100644 index 000000000..ad70467df --- /dev/null +++ b/admin/compiler/joomla_4/SITE_ROUTER.php @@ -0,0 +1,97 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Service; + +###SITE_ROUTER_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Router class for the ###Component_name### Component + * + * @since 3.10 + */ +class Router extends RouterView +{ + /** + * Flag to remove IDs + * + * @var boolean + * @since 4.0.0 + */ + protected $noIDs = false; + + /** + * The category factory + * + * @var CategoryFactoryInterface + * @since 4.0.0 + */ + private $categoryFactory; + + /** + * The category cache + * + * @var array + * @since 4.0.0 + */ + private $categoryCache = []; + + /** + * The db + * + * @var DatabaseInterface + * @since 4.0.0 + */ + private $db; + + /** + * The component params + * + * @var Registry + * @since 4.0.0 + */ + private $params; + + /** + * ###Component### Component router constructor + * + * @param SiteApplication $app The application object + * @param AbstractMenu $menu The menu object to work with + * @param CategoryFactoryInterface $categoryFactory The category object + * @param DatabaseInterface $db The database object + * + * @since 4.0.0 + */ + public function __construct( + SiteApplication $app, + AbstractMenu $menu, + CategoryFactoryInterface $categoryFactory, + DatabaseInterface $db) + { + $this->categoryFactory = $categoryFactory; + $this->db = $db; + $this->params = ComponentHelper::getParams('com_###component###'); + $this->noIDs = (bool) $this->params->get('sef_ids', false);###SITE_ROUTER_CONSTRUCTOR_BEFORE_PARENT### + + parent::__construct($app, $menu);###SITE_ROUTER_CONSTRUCTOR_AFTER_PARENT### + + $this->attachRule(new MenuRules($this)); + $this->attachRule(new StandardRules($this)); + $this->attachRule(new NomenuRules($this)); + }###SITE_ROUTER_METHODS### +} diff --git a/admin/compiler/joomla_4/SITE_ROUTE_HELPER.php b/admin/compiler/joomla_4/SITE_ROUTE_HELPER.php new file mode 100644 index 000000000..11c38f396 --- /dev/null +++ b/admin/compiler/joomla_4/SITE_ROUTE_HELPER.php @@ -0,0 +1,141 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Helper; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Language\Multilanguage; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Categories\CategoryNode; +use Joomla\CMS\Categories\Categories; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### Component Route Helper + * + * @since 1.5 + */ +abstract class RouteHelper +{ + protected static $lookup;###ROUTEHELPER### + + protected static function _findItem($needles = null,$type = null) + { + $app = Factory::getApplication(); + $menus = $app->getMenu('site'); + $language = isset($needles['language']) ? $needles['language'] : '*'; + + // Prepare the reverse lookup array. + if (!isset(self::$lookup[$language])) + { + self::$lookup[$language] = []; + + $component = ComponentHelper::getComponent('com_###component###'); + + $attributes = array('component_id'); + $values = array($component->id); + + if ($language != '*') + { + $attributes[] = 'language'; + $values[] = array($needles['language'], '*'); + } + + $items = $menus->getItems($attributes, $values); + + foreach ($items as $item) + { + if (isset($item->query) && isset($item->query['view'])) + { + $view = $item->query['view']; + + if (!isset(self::$lookup[$language][$view])) + { + self::$lookup[$language][$view] = []; + } + + if (isset($item->query['id'])) + { + /** + * Here it will become a bit tricky + * language != * can override existing entries + * language == * cannot override existing entries + */ + if (!isset(self::$lookup[$language][$view][$item->query['id']]) || $item->language != '*') + { + self::$lookup[$language][$view][$item->query['id']] = $item->id; + } + } + else + { + self::$lookup[$language][$view][0] = $item->id; + } + } + } + } + + if ($needles) + { + foreach ($needles as $view => $ids) + { + if (isset(self::$lookup[$language][$view])) + { + if (Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($ids)) + { + foreach ($ids as $id) + { + if (isset(self::$lookup[$language][$view][(int) $id])) + { + return self::$lookup[$language][$view][(int) $id]; + } + } + } + elseif (isset(self::$lookup[$language][$view][0])) + { + return self::$lookup[$language][$view][0]; + } + } + } + } + + if ($type) + { + // Check if the global menu item has been set. + $params = ComponentHelper::getParams('com_###component###'); + if ($item = $params->get($type.'_menu', 0)) + { + return $item; + } + } + + // Check if the active menuitem matches the requested language + $active = $menus->getActive(); + + if ($active + && $active->component == 'com_###component###' + && ($language == '*' || in_array($active->language, array('*', $language)) || !Multilanguage::isEnabled())) + { + return $active->id; + } + + // If not found, return language specific home link + $default = $menus->getDefault($language); + + return !empty($default->id) ? $default->id : null; + } +} diff --git a/admin/compiler/joomla_4/SITE_VIEW.php b/admin/compiler/joomla_4/SITE_VIEW.php new file mode 100644 index 000000000..baa8a5f8b --- /dev/null +++ b/admin/compiler/joomla_4/SITE_VIEW.php @@ -0,0 +1,23 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +###SITE_VIEW_HEADER### + +// No direct access to this file +defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED######SITE_CODE_BODY### + +?> +###SITE_TOP_FORM######SITE_TOP_BUTTON######SITE_BODY######SITE_BOTTOM_BUTTON######SITE_BOTTOM_FORM### diff --git a/admin/compiler/joomla_4/SITE_VIEWS.php b/admin/compiler/joomla_4/SITE_VIEWS.php new file mode 100644 index 000000000..c2efa4f45 --- /dev/null +++ b/admin/compiler/joomla_4/SITE_VIEWS.php @@ -0,0 +1,23 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +###SITE_VIEWS_HEADER### + +// No direct access to this file +defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED######SITE_CODE_BODY### + +?> +###SITE_TOP_FORM######SITE_TOP_BUTTON######SITE_BODY######SITE_BOTTOM_BUTTON######SITE_BOTTOM_FORM### diff --git a/admin/compiler/joomla_4/SITE_VIEWS_HTML.php b/admin/compiler/joomla_4/SITE_VIEWS_HTML.php new file mode 100644 index 000000000..b59f57ef7 --- /dev/null +++ b/admin/compiler/joomla_4/SITE_VIEWS_HTML.php @@ -0,0 +1,108 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\View\###SViews###; + +###SITE_VIEWS_HTML_HEADER######SITE_GET_MODULE_JIMPORT### + +// No direct access to this file +\defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED### + +/** + * ###Component### Html View class for the ###SViews### + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Display the view + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // get combined params of both component and menu + $this->app ??= Factory::getApplication(); + $this->params = $this->app->getParams(); + $this->menu = $this->app->getMenu()->getActive(); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + // get the user object + $this->user ??= $this->app->getIdentity();###SITE_DIPLAY_METHOD### + }###SITE_EXTRA_DIPLAY_METHODS### + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + {###SITE_LIBRARIES_LOADER######SITE_UIKIT_LOADER######SITE_GOOGLECHART_LOADER######SITE_FOOTABLE_LOADER######SITE_DOCUMENT_METADATA######SITE_DOCUMENT_CUSTOM_PHP### + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + }###SITE_DOCUMENT_CUSTOM_CSS### + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + }###SITE_DOCUMENT_CUSTOM_JS######SITE_JAVASCRIPT_FOR_BUTTONS### + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + {###SITE_CUSTOM_BUTTONS### + + // set help url for this view if found + $this->help_url = ###Component###Helper::getHelpUrl('###sviews###'); + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($this->help_url)) + { + ToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); + } + // now initiate the toolbar + $this->toolbar = Toolbar::getInstance(); + }###SITE_GET_MODULE### + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = false, int $length = 40) + { + if (!is_string($var)) + { + return $var; + } + + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } +} diff --git a/admin/compiler/joomla_4/SITE_VIEWS_MODEL.php b/admin/compiler/joomla_4/SITE_VIEWS_MODEL.php new file mode 100644 index 000000000..bbb1676d2 --- /dev/null +++ b/admin/compiler/joomla_4/SITE_VIEWS_MODEL.php @@ -0,0 +1,212 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Model; + +###SITE_VIEWS_MODEL_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### List Model for ###SViews### + * + * @since 1.6 + */ +class ###SViews###Model extends ListModel +{ + /** + * Represents the current user object. + * + * @var User The user object representing the current user. + * @since 3.2.0 + */ + protected User $user; + + /** + * The unique identifier of the current user. + * + * @var int|null The ID of the current user. + * @since 3.2.0 + */ + protected ?int $userId; + + /** + * Flag indicating whether the current user is a guest. + * + * @var int 1 if the user is a guest, 0 otherwise. + * @since 3.2.0 + */ + protected int $guest; + + /** + * An array of groups that the current user belongs to. + * + * @var array|null An array of user group IDs. + * @since 3.2.0 + */ + protected ?array $groups; + + /** + * An array of view access levels for the current user. + * + * @var array|null An array of access level IDs. + * @since 3.2.0 + */ + protected ?array $levels; + + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The input object, providing access to the request data. + * + * @var Input The input object. + * @since 3.2.0 + */ + protected Input $input; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'components/com_###component###/assets/css/site.css', + 'components/com_###component###/assets/css/###sview###.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'components/com_###component###/assets/js/site.js' + ]; + + /** + * A custom property for UIKit components. (not used unless you load v2) + */ + protected $uikitComp; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + $this->input ??= $this->app->getInput(); + + // Set the current user for authorisation checks (for those calling this model directly) + $this->user ??= $this->getCurrentUser(); + $this->userId = $this->user->get('id'); + $this->guest = $this->user->get('guest'); + $this->groups = $this->user->get('groups'); + $this->authorisedGroups = $this->user->getAuthorisedGroups(); + $this->levels = $this->user->getAuthorisedViewLevels(); + + // will be removed + $this->initSet = true; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + {###SITE_GET_LIST_QUERY### + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + $user = $this->user;###USER_PERMISSION_CHECK_ACCESS######LICENSE_LOCKED_CHECK######SITE_BEFORE_GET_ITEMS### + // load parent items + $items = parent::getItems(); + + // Get the global params + $globalParams = ComponentHelper::getParams('com_###component###', true);###SITE_GET_ITEMS######SITE_AFTER_GET_ITEMS### + + // return items + return $items; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + }###LICENSE_LOCKED_SET_BOOL######SITE_CUSTOM_METHODS######SITE_CUSTOM_BUTTONS_METHOD### +} diff --git a/admin/compiler/joomla_4/SITE_VIEW_CONTROLLER.php b/admin/compiler/joomla_4/SITE_VIEW_CONTROLLER.php new file mode 100644 index 000000000..0b5676074 --- /dev/null +++ b/admin/compiler/joomla_4/SITE_VIEW_CONTROLLER.php @@ -0,0 +1,120 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Controller; + +###SITE_VIEW_CONTROLLER_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### ###SView### Form Controller + * + * @since 1.6 + */ +class ###SView###Controller extends FormController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_###COMPONENT###'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = '###SITE_DEFAULT_VIEW###';###SITE_CUSTOM_BUTTONS_CONTROLLER### + + /** + * Method to check if you can edit an existing record. + * + * Extended classes can override this if necessary. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key; default is id. + * + * @return boolean + * + * @since 12.2 + */ + protected function allowEdit($data = [], $key = 'id') + { + // to insure no other tampering + return false; + } + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // to insure no other tampering + return false; + } + + /** + * Method to check if you can save a new or existing record. + * + * Extended classes can override this if necessary. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 12.2 + */ + protected function allowSave($data, $key = 'id') + { + // to insure no other tampering + return false; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModelLegacy $model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 12.2 + */ + protected function postSaveHook(JModelLegacy $model, $validData = []) + { + } +} diff --git a/admin/compiler/joomla_4/SITE_VIEW_HTML.php b/admin/compiler/joomla_4/SITE_VIEW_HTML.php new file mode 100644 index 000000000..19ad53193 --- /dev/null +++ b/admin/compiler/joomla_4/SITE_VIEW_HTML.php @@ -0,0 +1,108 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\View\###SView###; + +###SITE_VIEW_HTML_HEADER######SITE_GET_MODULE_JIMPORT### + +// No direct access to this file +\defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED### + +/** + * ###Component### Html View class for the ###SView### + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Display the view + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // get combined params of both component and menu + $this->app ??= Factory::getApplication(); + $this->params = $this->app->getParams(); + $this->menu = $this->app->getMenu()->getActive(); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + // get the user object + $this->user ??= $this->app->getIdentity();###SITE_DIPLAY_METHOD### + }###SITE_EXTRA_DIPLAY_METHODS### + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + {###SITE_LIBRARIES_LOADER######SITE_UIKIT_LOADER######SITE_GOOGLECHART_LOADER######SITE_FOOTABLE_LOADER######SITE_DOCUMENT_METADATA######SITE_DOCUMENT_CUSTOM_PHP### + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + }###SITE_DOCUMENT_CUSTOM_CSS### + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + }###SITE_DOCUMENT_CUSTOM_JS######SITE_JAVASCRIPT_FOR_BUTTONS### + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + {###SITE_CUSTOM_BUTTONS### + + // set help url for this view if found + $this->help_url = ###Component###Helper::getHelpUrl('###sview###'); + if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($this->help_url)) + { + ToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $this->help_url); + } + // now initiate the toolbar + $this->toolbar = Toolbar::getInstance(); + }###SITE_GET_MODULE### + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = false, int $length = 40) + { + if (!is_string($var)) + { + return $var; + } + + return Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } +} diff --git a/admin/compiler/joomla_4/SITE_VIEW_MODEL.php b/admin/compiler/joomla_4/SITE_VIEW_MODEL.php new file mode 100644 index 000000000..fe73b93a4 --- /dev/null +++ b/admin/compiler/joomla_4/SITE_VIEW_MODEL.php @@ -0,0 +1,262 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### +namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Site\Model; + +###SITE_VIEW_MODEL_HEADER### + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * ###Component### ###SView### Item Model + * + * @since 1.6 + */ +class ###SView###Model extends ItemModel +{ + /** + * Model context string. + * + * @var string + * @since 1.6 + */ + protected $_context = 'com_###component###.###sview###'; + + /** + * Represents the current user object. + * + * @var User The user object representing the current user. + * @since 3.2.0 + */ + protected User $user; + + /** + * The unique identifier of the current user. + * + * @var int|null The ID of the current user. + * @since 3.2.0 + */ + protected ?int $userId; + + /** + * Flag indicating whether the current user is a guest. + * + * @var int 1 if the user is a guest, 0 otherwise. + * @since 3.2.0 + */ + protected int $guest; + + /** + * An array of groups that the current user belongs to. + * + * @var array|null An array of user group IDs. + * @since 3.2.0 + */ + protected ?array $groups; + + /** + * An array of view access levels for the current user. + * + * @var array|null An array of access level IDs. + * @since 3.2.0 + */ + protected ?array $levels; + + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The input object, providing access to the request data. + * + * @var Input The input object. + * @since 3.2.0 + */ + protected Input $input; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'components/com_###component###/assets/css/site.css', + 'components/com_###component###/assets/css/###sview###.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'components/com_###component###/assets/js/site.js' + ]; + + /** + * A custom property for UI Kit components. + * + * @var array|null Property for storing UI Kit component-related data or objects. + * @since 3.2.0 + */ + protected ?array $uikitComp; + + /** + * @var object item + * @since 1.6 + */ + protected $item; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 3.0 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + $this->input ??= $this->app->getInput(); + + // Set the current user for authorisation checks (for those calling this model directly) + $this->user ??= $this->getCurrentUser(); + $this->userId = $this->user->get('id'); + $this->guest = $this->user->get('guest'); + $this->groups = $this->user->get('groups'); + $this->authorisedGroups = $this->user->getAuthorisedGroups(); + $this->levels = $this->user->getAuthorisedViewLevels(); + + // will be removed + $this->initSet = true; + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @return void + * @since 1.6 + */ + protected function populateState() + { + // Get the itme main id + $id = $this->input->getInt('id', null); + $this->setState('###sview###.id', $id); + + // Load the parameters. + $params = $this->app->getParams(); + $this->setState('params', $params); + + parent::populateState(); + } + + /** + * Method to get article data. + * + * @param integer $pk The id of the article. + * + * @return mixed Menu item data object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + {###USER_PERMISSION_CHECK_ACCESS### + + $pk = (!empty($pk)) ? $pk : (int) $this->getState('###sview###.id');###SITE_BEFORE_GET_ITEM### + + if ($this->_item === null) + { + $this->_item = []; + }###LICENSE_LOCKED_CHECK### + + if (!isset($this->_item[$pk])) + { + try + {###SITE_GET_ITEM### + } + catch (\Exception $e) + { + if ($e->getCode() == 404) + { + // Need to go thru the error handler to allow Redirect to work. + throw $e; + } + else + { + $this->setError($e); + $this->_item[$pk] = false; + } + } + }###SITE_AFTER_GET_ITEM### + + return $this->_item[$pk]; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + }###LICENSE_LOCKED_SET_BOOL######SITE_CUSTOM_METHODS######SITE_CUSTOM_BUTTONS_METHOD### +} diff --git a/admin/compiler/joomla_4/access.xml b/admin/compiler/joomla_4/access.xml new file mode 100644 index 000000000..95908e259 --- /dev/null +++ b/admin/compiler/joomla_4/access.xml @@ -0,0 +1,4 @@ + + + ###ACCESS_SECTIONS### + \ No newline at end of file diff --git a/admin/compiler/joomla_4/admin.css b/admin/compiler/joomla_4/admin.css new file mode 100644 index 000000000..589b9cd9b --- /dev/null +++ b/admin/compiler/joomla_4/admin.css @@ -0,0 +1,7 @@ +###BOM### + +/* CSS Document */ +.no-click { + pointer-events: none; +} +###ADMINCSS### diff --git a/admin/compiler/joomla_4/admin.js b/admin/compiler/joomla_4/admin.js new file mode 100644 index 000000000..9c701e5be --- /dev/null +++ b/admin/compiler/joomla_4/admin.js @@ -0,0 +1,4 @@ +###BOM### + +/* JS Document */ +###ADMINJS### \ No newline at end of file diff --git a/admin/compiler/joomla_4/component.xml b/admin/compiler/joomla_4/component.xml new file mode 100644 index 000000000..7dad78c48 --- /dev/null +++ b/admin/compiler/joomla_4/component.xml @@ -0,0 +1,87 @@ + + + COM_###COMPONENT### + ###BUILDDATE### + ###AUTHOR### + ###AUTHOREMAIL### + ###AUTHORWEBSITE### + ###COPYRIGHT### + ###LICENSE### + ###ACTUALVERSION### + ###Component_name### (v.###ACTUALVERSION###) +
+

###DESCRIPTION###

+

Created by ###AUTHOR###
Development started ###CREATIONDATE###

+ ]]>
+ ###NAMESPACEPREFIX###\Component\###ComponentNameSpace### + + + + + sql/install.mysql.utf8.sql + + + + + + + sql/uninstall.mysql.utf8.sql + + + + + ###Component###InstallerScript.php + + + index.html###EXSTRA_MEDIA_FILES### + js + css + images###EXSTRA_MEDIA_FOLDERS### + + + + + + sql/updates/mysql/ + + + + + index.html###EXSTRA_SITE_FILES### + assets + forms + layouts + src + tmpl###EXSTRA_SITE_FOLDERS### + + + + ###SITE_LANGUAGES### + + + + COM_###COMPONENT###_MENU + + ###MAINMENUS### + + + access.xml + config.xml + index.html###EXSTRA_ADMIN_FILES### + assets + forms + layouts + presets + services + sql + src + tmpl###EXSTRA_ADMIN_FOLDERS### + + + + ###ADMIN_LANGUAGES### + + + ###UPDATESERVER### +
\ No newline at end of file diff --git a/admin/compiler/joomla_4/config.xml b/admin/compiler/joomla_4/config.xml new file mode 100644 index 000000000..50b98e1fe --- /dev/null +++ b/admin/compiler/joomla_4/config.xml @@ -0,0 +1,19 @@ + + + ###CONFIG_FIELDSETS### +
+ +
+
\ No newline at end of file diff --git a/admin/compiler/joomla_4/dashboard.css b/admin/compiler/joomla_4/dashboard.css new file mode 100644 index 000000000..6502707ff --- /dev/null +++ b/admin/compiler/joomla_4/dashboard.css @@ -0,0 +1,155 @@ +###BOM### + +/* CSS Document */ + +.dashboard-container { + margin-left: 10px; + margin-top: 10px; + width: 100%; +} +.dashboard-container [class*="span"] { + display: block; + float: none; + margin-left: 0; + width: auto; +} +.dashboard-container:before, .dashboard-container:after { + content: ""; + display: table; +} +.dashboard-container:after { + clear: both; +} +.dashboard-container [class*="span"] { + box-sizing: border-box; + display: block; + float: left; + min-height: 145px; + min-width: 96px; + width: 100%; +} +.dashboard-container [class*="span"]:first-child { + margin-left: 0; +} +.dashboard-wraper { + background: none repeat scroll 0 0 hsl(0, 0%, 93%); + border-radius: 5px; + float: left; + margin: 1%; + padding: 3px; + width: 17%; + min-height: 194px; + min-width: 96px; +} +.dashboard-content a { + background: linear-gradient(to bottom, hsl(0, 0%, 100%) 0%, hsl(0, 0%, 96%) 47%, hsl(0, 0%, 93%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + border: 1px solid hsl(0, 0%, 85%); + border-radius: 4px; + box-shadow: 0 0 3px hsla(0, 0%, 0%, 0.1) inset; + color: hsl(0, 0%, 20%); + display: block; + min-height: 89px; + padding: 10px; + text-align: center; + text-decoration: none; +} +.dashboard-content a:hover { + background: linear-gradient(to bottom, hsl(0, 0%, 90%) 0%, hsl(0, 0%, 100%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + color: hsl(200, 100%, 30%); + text-decoration: none; +} +.dashboard-title { + display: block; + padding-top: 5px; +} +.dashboard-info { + background: linear-gradient(to bottom, hsl(0, 0%, 100%) 0%, hsl(0, 0%, 96%) 47%, hsl(0, 0%, 93%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + border: 1px solid hsl(0, 0%, 85%); + border-radius: 4px; + box-shadow: 0 0 3px hsla(0, 0%, 0%, 0.1) inset; + color: hsl(0, 0%, 20%); + display: block; + font-size: 12px; + padding: 10px; + text-align: center; +} +.dashboard-info span { + display: block; + text-align: center; +} +.dashboard-info img { + margin: 0 auto; +} +.dashboard-table { + border-top: 1px solid hsl(0, 0%, 87%); + margin-top: 5px; + width: 100%; +} +.dashboard-info h5 { + font-size: 11px; + font-weight: bold; +} +.dashboard-block { + background: linear-gradient(to bottom, hsl(0, 0%, 95%) 0%, hsl(0, 0%, 86%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + border: 1px solid hsl(0, 0%, 76%); + border-radius: 3px; + box-shadow: 0 1px 0 hsl(0, 0%, 98%) inset; + margin-bottom: 20px; +} +.dashboard-block .dashboard-block-head { + background: linear-gradient(to bottom, hsl(0, 0%, 95%) 0%, hsl(0, 0%, 86%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + border-bottom: 1px solid hsl(0, 0%, 76%); + border-radius: 3px 3px 0 0; + box-shadow: 0 1px 0 hsl(0, 0%, 98%) inset, 0 0 3px hsl(0, 0%, 87%); + height: 40px; + position: relative; +} +.dashboard-block .dashboard-block-head h5 { + font-size: 12px; + margin: 0; + padding-left: 10px; + padding-top: 11px; + text-transform: uppercase; +} +.dashboard-block .dashboard-block-content { + background: none repeat scroll 0 0 hsl(0, 0%, 93%); + border-radius: 0 0 3px 3px; +} +.dashboard-block .dashboard-block-box { + background: none repeat scroll 0 0 hsl(0, 0%, 100%); + border-top: 1px solid hsl(0, 0%, 82%); + box-shadow: 0 0 5px hsl(0, 0%, 87%) inset; +} +.dashboard-block .dashboard-block-content .dashboard-block-box { + margin-top: 0 !important; +} +.dashboard-block .dashboard-block-content .dashboard-block-box .dashboard-block-table { + margin-bottom: 0 !important; +} +.dashboard-block-table { + background-color: hsla(0, 0%, 0%, 0); + border-collapse: collapse; + border-spacing: 0; + margin-bottom: 20px; + max-width: 100%; + width: 100%; +} +.dashboard-block-table th, .dashboard-block-table td { + border-top: 1px solid hsl(0, 0%, 87%); + line-height: 20px; + padding: 5px; + text-align: left; + vertical-align: middle; +} +.dashboard-badge { + background-color: hsl(0, 0%, 60%); + border-radius: 9px; + color: hsl(0, 0%, 100%); + font-size: 11.844px; + font-weight: bold; + line-height: 14px; + padding: 1px 9px 2px; + text-shadow: 0 -1px 0 hsla(0, 0%, 0%, 0.25); + vertical-align: baseline; + white-space: nowrap; +} \ No newline at end of file diff --git a/admin/compiler/joomla_4/default.xml b/admin/compiler/joomla_4/default.xml new file mode 100644 index 000000000..10a8e4742 --- /dev/null +++ b/admin/compiler/joomla_4/default.xml @@ -0,0 +1 @@ +###SITE_MENU_XML### \ No newline at end of file diff --git a/admin/compiler/joomla_4/default_batch_body.php b/admin/compiler/joomla_4/default_batch_body.php new file mode 100644 index 000000000..6ca60b2b1 --- /dev/null +++ b/admin/compiler/joomla_4/default_batch_body.php @@ -0,0 +1,26 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED### + +?> + +

+batchDisplay; ?> \ No newline at end of file diff --git a/admin/compiler/joomla_4/default_batch_footer.php b/admin/compiler/joomla_4/default_batch_footer.php new file mode 100644 index 000000000..701e3c69b --- /dev/null +++ b/admin/compiler/joomla_4/default_batch_footer.php @@ -0,0 +1,30 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +use Joomla\CMS\Language\Text; + +// No direct access to this file +defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED### + +?> + + + + \ No newline at end of file diff --git a/admin/compiler/joomla_4/default_body.php b/admin/compiler/joomla_4/default_body.php new file mode 100644 index 000000000..05456df25 --- /dev/null +++ b/admin/compiler/joomla_4/default_body.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Helper\###Component###Helper; + +// No direct access to this file +defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED### + +$edit = "index.php?option=com_###component###&view=###views###&task=###view###.edit"; + +?> +###LISTBODY### \ No newline at end of file diff --git a/admin/compiler/joomla_4/default_custom_admin_template.php b/admin/compiler/joomla_4/default_custom_admin_template.php new file mode 100644 index 000000000..5601278f7 --- /dev/null +++ b/admin/compiler/joomla_4/default_custom_admin_template.php @@ -0,0 +1,24 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +use Joomla\CMS\Language\Text; +use Joomla\CMS\Router\Route; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED######CUSTOM_ADMIN_TEMPLATE_CODE_BODY### + +?>###CUSTOM_ADMIN_TEMPLATE_BODY### diff --git a/admin/compiler/joomla_4/default_foot.php b/admin/compiler/joomla_4/default_foot.php new file mode 100644 index 000000000..b5c0121af --- /dev/null +++ b/admin/compiler/joomla_4/default_foot.php @@ -0,0 +1,23 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +// No direct access to this file +defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED### + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/compiler/joomla_4/default_head.php b/admin/compiler/joomla_4/default_head.php new file mode 100644 index 000000000..c21d39531 --- /dev/null +++ b/admin/compiler/joomla_4/default_head.php @@ -0,0 +1,24 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED### + +?> +###LISTHEAD### \ No newline at end of file diff --git a/admin/compiler/joomla_4/default_import.php b/admin/compiler/joomla_4/default_import.php new file mode 100644 index 000000000..05ff76fe1 --- /dev/null +++ b/admin/compiler/joomla_4/default_import.php @@ -0,0 +1,199 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +use Joomla\CMS\Language\Text; +use Joomla\CMS\Router\Route; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED### + +Html::_('jquery.framework'); +Html::_('bootstrap.tooltip'); +Html::_('script', 'system/core.js', false, true); +Html::_('behavior.keepalive'); + +?> + + +
+
+
+ + hasPackage && Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($this->headerList) && Super___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check($this->headers)) : ?> +
+ +
+ +
+ +
+
+ headerList as $name => $title): ?> +
+ +
+ +
+
+ +
+ +
+
+ + + 'upload')); ?> + + +
+ +
+ +
+ +
+
+
+     (.csv .xls .ods) +
+
+ + + +
+ +
+ +
+ +
+
+
+     (.csv .xls .ods) +
+
+ + + +
+ +
+ +
+ +
+
+
+     (.csv .xls .ods) +
+
+ + + + + + + +
\ No newline at end of file diff --git a/admin/compiler/joomla_4/default_import_custom.php b/admin/compiler/joomla_4/default_import_custom.php new file mode 100644 index 000000000..91b71fce6 --- /dev/null +++ b/admin/compiler/joomla_4/default_import_custom.php @@ -0,0 +1,30 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Router\Route; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED### + +Html::_('jquery.framework'); +Html::_('bootstrap.tooltip'); +Html::_('script', 'system/core.js', false, true); +Html::_('behavior.keepalive'); + +?>###IMPORT_DEFAULT_VIEW_CUSTOM### diff --git a/admin/compiler/joomla_4/default_list.xml b/admin/compiler/joomla_4/default_list.xml new file mode 100644 index 000000000..5f42db0d7 --- /dev/null +++ b/admin/compiler/joomla_4/default_list.xml @@ -0,0 +1,6 @@ + + + + COM_###COMPONENT###_MENU_###VIEWS###_DESC + + \ No newline at end of file diff --git a/admin/compiler/joomla_4/default_main.php b/admin/compiler/joomla_4/default_main.php new file mode 100644 index 000000000..91b3fcb0a --- /dev/null +++ b/admin/compiler/joomla_4/default_main.php @@ -0,0 +1,37 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +use Joomla\CMS\Language\Text; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +icons['main']) && is_array($this->icons['main'])) :?> + icons['main'] as $icon): ?> + + +
+ +

+ \ No newline at end of file diff --git a/admin/compiler/joomla_4/default_site_template.php b/admin/compiler/joomla_4/default_site_template.php new file mode 100644 index 000000000..13daeb11f --- /dev/null +++ b/admin/compiler/joomla_4/default_site_template.php @@ -0,0 +1,24 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED######SITE_TEMPLATE_CODE_BODY### + +?>###SITE_TEMPLATE_BODY### diff --git a/admin/compiler/joomla_4/default_toolbar.php b/admin/compiler/joomla_4/default_toolbar.php new file mode 100644 index 000000000..6fb862f1e --- /dev/null +++ b/admin/compiler/joomla_4/default_toolbar.php @@ -0,0 +1,53 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die;###LICENSE_LOCKED_DEFINED### + +?> +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
+
\ No newline at end of file diff --git a/admin/compiler/joomla_4/default_vdm.php b/admin/compiler/joomla_4/default_vdm.php new file mode 100644 index 000000000..2af4045b4 --- /dev/null +++ b/admin/compiler/joomla_4/default_vdm.php @@ -0,0 +1,45 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +use Joomla\CMS\Language\Text; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +<?php echo Text::_('COM_###COMPONENT###'); ?> + +
+contributors)): ?> + contributors) > 1): ?> +

+ +

+ +
    + contributors as $contributor): ?> +
  • :
  • + +
+
+ \ No newline at end of file diff --git a/admin/compiler/joomla_4/edit.xml b/admin/compiler/joomla_4/edit.xml new file mode 100644 index 000000000..10a8e4742 --- /dev/null +++ b/admin/compiler/joomla_4/edit.xml @@ -0,0 +1 @@ +###SITE_MENU_XML### \ No newline at end of file diff --git a/admin/compiler/joomla_4/en-GB.com_admin.ini b/admin/compiler/joomla_4/en-GB.com_admin.ini new file mode 100644 index 000000000..e5b382a4a --- /dev/null +++ b/admin/compiler/joomla_4/en-GB.com_admin.ini @@ -0,0 +1 @@ +###LANG_ADMIN### \ No newline at end of file diff --git a/admin/compiler/joomla_4/en-GB.com_admin.sys.ini b/admin/compiler/joomla_4/en-GB.com_admin.sys.ini new file mode 100644 index 000000000..fc07f9846 --- /dev/null +++ b/admin/compiler/joomla_4/en-GB.com_admin.sys.ini @@ -0,0 +1 @@ +###LANG_ADMIN_SYS### \ No newline at end of file diff --git a/admin/compiler/joomla_4/en-GB.com_site.ini b/admin/compiler/joomla_4/en-GB.com_site.ini new file mode 100644 index 000000000..7a78b98b2 --- /dev/null +++ b/admin/compiler/joomla_4/en-GB.com_site.ini @@ -0,0 +1 @@ +###LANG_SITE### \ No newline at end of file diff --git a/admin/compiler/joomla_4/en-GB.com_site.sys.ini b/admin/compiler/joomla_4/en-GB.com_site.sys.ini new file mode 100644 index 000000000..7e16bfbe8 --- /dev/null +++ b/admin/compiler/joomla_4/en-GB.com_site.sys.ini @@ -0,0 +1 @@ +###LANG_SITE_SYS### \ No newline at end of file diff --git a/admin/compiler/joomla_4/filter_forms.xml b/admin/compiler/joomla_4/filter_forms.xml new file mode 100644 index 000000000..9f2d5d31c --- /dev/null +++ b/admin/compiler/joomla_4/filter_forms.xml @@ -0,0 +1,9 @@ + +
+###FIELDFILTERSETS### + +###FIELDLISTSETS### +
\ No newline at end of file diff --git a/admin/compiler/joomla_4/import.gif b/admin/compiler/joomla_4/import.gif new file mode 100644 index 0000000000000000000000000000000000000000..10bcb856924dbc48ac739332a40ce1617c88687b GIT binary patch literal 66680 zcmd?RcUY5YyFL1*bEQD&p$MUeYUo%e^eTcPq9TSO(u9bh2#5*2O6Xle6%ddnMNvaj zP?RDFDk@C`Ma4R{aei;ie2nFr`R1J8-uqnFKK!M0a<6r-_1x=zUUN$`gLSTSfDS|h zfTUSaW@V>yXyMr1c^#MJFAp5>TVFg}6=YSn`|M=xk?YSwFHbjw*k}|CEw+T-@W1eIr9IsC?7bK7 zJ0pf(eEOZvh>VJkiH(a-NK8sjIho2#OV7y6%FfBn%P%M_I#tXnDJ?6ns61U&U2~?k zuKsL8V^ed>xz@J!j`J5fFJ8LL?&|L8?YnZdf8ZA(h%gS2;Kk-(;lRWsASRRvx$_V} zi>ITer$q@&40>T&kjejST7t>*YI^P@^w)>5)K8xqJ{-=JA-0C67!cqTKmc(B0y9y$ zno2ouA@W?8V!%JEk3y&kH_&Ew!%&j2cCa4bzBn>}zBn=5It|{QcQ{hG{QM30T7xe= zSf{Dkp#M;{PgJAtuYsRU_fAt&k3!C}>brG*!AG~pMXn17w*4X&%iEz9$27y?^ z((XhU(R$ugf+?5Y z30u0yKs0~|04oYs5u_$qQ5*kE5CI?&K|mDN_j*K>gFpef3)UNiLS{`bhw%^QK{S9A z2hjjx1td2}Xb>?Vga4bL0D>Uxe;x$kLMW7U2Sxx6ToL6ISc>l)g7+#QdQ}qN%qKiN zc?aN!HQ`1^CZ~tt*UzGd=I#O_4Un0omy!*FvsYeDBhKD@_hjXMJ^X#Ml18p7->+jc zdsbB7U592gY~mkb-SlYUZr=2(`~`8l@UkYI@6)o83{gS53l&{PQAiQ3SNWFBl{X3u z4nLV1Xg*CEDyBrC*I2bwjg(nrsO-JgQhn8lE77nZ@c5B3SL6M$&o zLWJ8eKs0~|5vktBp! z13}hoQN{o=KpP;8!Zuq5C@f(BPZI}rie8<$? z9`c0f;QTD0{P^kEt!KlirMaGV^aNt+^HYF>oreUA$!uTo=l~tHNjcIC!3c$U!FfN0 zWMbAH)W%~|ZU8rnMavjzcy;k}J^(wcu)W54psC_|4%z)$;kQso|7$4toEAcfSlDS& zdO6=C3u%Fe6K9Mq2@=mQ!d4&uOigBQ-R$& zP$tvoxVF8ku1@F14mI}WkrK@KcAaZ?+EnjvLwEI$)@jb$%PtMKi!9q?9}i5*zP8sH zeo@AOz(*F9eIy_=mTr$traxAZ?j{k|v%`Q{8DWShmBQmn&FD)d8YfCxHkA)#kp2pB zr~VRgx?Y^0B1(jZgm)0(P)9j6FN1L{2qdgjYLGhM3cI^Uj!+v-R4*V2Yi*O-?s!xv zArtkPA8U%MSa)f~Y>d*ukkRsZY8%lkq4C0UAGIrGTiPfvdkJNKdpfSw-y;*MCe$0u zc!V8K-K(j(0eBF*m%NjSmx+v~*RZ27(zc!LFXv7~elLC6KcNqlKCtnD=;O4cuPz8g zAJ~kzxC0Rfwm-0of#?H4$AO_$IM|gy^sRP1F8V;|aS;c$FtGQ1r;2yyLBxT$0}%>> z4(ym*#DQ?*3M|-O!Ilbw4usx6mr79j^8RnpX9AN(p)ksc{xCcM5OV-d$zbU|D%rVt zxkQno1M;PLHAIz44<$sG{&bHTU*|L+OnBo=PHMa{{Vdj@@Q#+jR4K)>o1;*dA>hmgteb1=!RmY z8ga|*3PGW5t$=~Ac$KKK5?oE>iHVh9Gqm!e$*_Es-($5d%7<*Vjlkipm*SshA*>LC z+55E$1Pb=zdm}1rN?HjJlsTsOewf&6Cjq~T8 zPBge*KegpT>$7|9ho3&UaiQ(SLoWK>_kG{^^#2-qAnriT1uYl1@qy?AamNK9*NJnX z$L)Qf@dD8Y0*V8%uT~6H-c<~O&;#)WVvq|)u&MoN&hB!|83^+~8ed>02tY0p!A=Ka zkSn_&xEjX1)=xz z?d(AD^z@>9ObJb6PE%pYtMP3VOwtd_=Fc%8Rb}YAK*~b=+*bU4N4G~9&x+O?HuyQE+B{<~6DMGnf^LqNvp!|h(e&tguD0)k!H(v~ zLoDMYsV(PQmbkbJ-Omu^=k=hHJJ`@-z=uHDNEO}Xte`+-Kf5MnY3}_j-5{-PQh!=T zF8n(3j@<59_o!G0nxG`ThiE>Y)oSFy`Q4VU6(y)K!w_hqvSo9R7{5{EBl>;8zjOm3D5&{TAe)oS*uq z4VC8JA2c$&`(=3WIS31&ldyWBF}6Bl^oS&Y^V+VBWm+JTPMk>QmrTnyLUP{4NX&{L z8LTTv6HP8jj=)zk4T`gylH}@RaG8xAfI(}h-uY$*iG1l8F8ln2i&qXA)D%~ryFsfe znJC^cM$_kS9>~_ccZg?rLM(cYrZ$&>ghfAhJAIeNF8GCAfSbQ9~01|zEgJu zMCYZBrOikvh*i817o%n?!2}}HrYs<30*Q#b0&Bfr&i3I3{sP;7*HaDB@Jp1( z(dg9mar8bxc096Rr_L9&1%*1W&SwgjCHflXw@g;q{)@PL+e(r!V!YSoHzOF4 z_e9IDrJpkiTJ{Wqcuelwm%@5=7RanUXXNQ?Jh7~!TcUDxiBVxa61{D^V4`obFxa$U zPZ$n0-N5ES5FXDa6(PO{|Ic1_)lGcc(m~jBXDVPz=Neh=Neb-hpqt<}bFlaR+|Rj= z76d%l)j`06Egi)C>S2ltc3v?5IIE%zu5bazy0rvKvq5ktM<{x_5-5U&o zEa<%QE%hfvB>~_jisE*J;Y5@QrG>=JM? z#8_3P5Fy87$J)Vk$LLj-RIH3GoIp#b|wV*d%rHiGIUmLr&znCQ2b_q6A%vV+r zt9+Zac2J(Cs(qhD5KWK8J*p-tK(*jx9pUA7zrO$Q@zdwuzWn|t>?ReG%^NMFyIRHsJ%863@|s2;*+z=RRViaa&h6*x($(&G2z`8x*vvanS@vmF*k5FI6CMo`kcTzjJaBI`pFIrI* zPG*g6S|Y}y8VLn%xa$Y*?x@|^F2kF0AlKruIneQ5r!<2u-2ufBREPi!g=Tq9Gk6rM zrX#U>i__eeF68Jn6GQL}F~NV=+1LL+?Cjj0&K(e}x)yF{|F)-t_JwO!K-~Y(*0~KG z^e!OQ|4Cct%nM@6xow?mSwO6VF8bS^&ILLM?xMfx?7o(|)O60_h-4fBMIRG@XaEC?=D_5UfIv^qx# zQBiM$Ey+C=f422#O;eaw+eH&ZN?vTZ#-%IBrV=GlgDY3$&*b_G-@Ky6ACniLhabN} zhL41<^?Yzem-kKpN^;==T3=pIULXDZPjF{>wev?_iG=Y$kJO}f^Q&+GCoZI-wc_Sf zgAtL3MiLG0m0{9#MyrWi?klEw(HzF!_DfwOt3)c_i<;d}FzYGhmvt2!{DKbF`gLV_ zNx@SqNk2Z6F>F@Y5N&lKs6YGg9*4EM8uMe>b2T}VyKxMwC*#)vKi=14YM&5Lq=eF| zAlkq?oBs15ubAe%sk1gZrn6(A$HYyye1 zDit7`IPuBXX)CA`ph9q^0;CeiqaUsR*Rcnv6QD?d$5l`*K>Bcv5y%>@`(O1&Ka*%x zGycZ?S40?)uOY5z1`l~@kb)uY59RntTh1CAR`64XPRJ3CFe1%l{X@fI zGDO534DeU8TQtsA=a=3riG-@QoDoLGv>}tzgBH6u=!-w=+@fXS^EF9It`-_zZ(;*j z*eNO2jLkhQuRu$fr~525jl{&>a~SJ%h}{0gX0ynV-CFF%5^PDfgWY^C-dj#gE&CF~ zzNcD2%*yWLnRa%Nr{F7Vwq@KJu5A`QXZ&o2q;;ol2{r2ho>!%NgE?)+7HYAr#e@X>4SeUQ^{rb{ST3ryc z@~tUV|qsNUNb3(?l96S?c9BMvR_Zc;PGY>Dp@ za-;F(UZEToN}(2b^RK+)vs4f=AJmbfAGnL<>u*Ve?&yn!Cf3#BrO;oz_U{kDuqpN^ z)$<3SoZ@Iq(z{VgKlm?$e;`pHoj}_K5(%_mAi+Rht&S5p=MSrJkU}84KvIDO`1aVr zHD4g3xC0%KU7#$12M&$}`~J)Ua%T0|0U9xoUEIkI$TTjyxWnwfcVVDJ6@D*KE$vVG zJ(8-yNYcnY4nuXGHRxPy5%+;+POY@Dn(FUO5Slh`#@zp%ZZ94X9TouaF%pw3&~Y&_ z{-UbMSxGW(abYxnt?c3xuuz56L+(DOD+a+VPqNA^|?Y;zzu8!7W!VNdA zwClEnu#iRMHCJB2%|X8g?xd&JTMbur_;!7k@n)SXjZxh$k&WIn zY~-m?eZjH8AhgO9Qak9_&qG|1ocudRnV}2uhYf+)B6=H(gv0@;iiDDOCVlw^LO892 z;B>%YD2A3-Ald(6#l%YyCr|MUeibC(DEb=0vml;;WepQe>yFRAv)Tt7d99I76{P96 z#0h%SQxt&aYjJ+$;Bd1bIb@;Fs~yn3U^$r9qvvmai$_8ydD=q?oRcX~mmW5Uc#k32 zE(oo2S~rejbXtp~lp79o`HVrRYr<5&R9@Zj@Z#{blzokH&~?lfyuk52GmeSYZ*__E z%un-5QQOOCOm>7$e**&$lcZF}ge+7)J{A6M>2Wa~DZcA_|F`ZZa&ZG9a8&y9$sXj_ zD!I7Fde9E89_zoJMc%9)>p}kqj;ui40?Eal*n<>X@z*+> zk)&9CrkPsUP_)0K<-&Fxp+4zAZfCQ)7zza;*`l&D4`X`IK(VKVuUqTj+fVC^mMINI zbl9j9=FTeeJuH=DCq1OTKl7AlkPZE6&lP_ z7TKG$F5<2AW4<|K{?nxFuIZOEt)Z0wo|H!een}j0YLXav;kYqxRD6>5jzdx43#{;i z4rRr|O(2$!@|yE5BI%~|rSfI92ExZUIHigYQN^CYotZdG?MYl?-TJ3u?b#tKHE6(u z#KpIrH1Swjxn>%R40)?#Vfe--`2yqKlttIU(V1Sq?n9s5jYQ|y>O03vKIVJ*NMjB9 zLQT|Ma}Kuc!8)Byrmw6WYEQRV)p-T`k;D}b`yJYon36LjFtxbG6k%?im0<1q66+-Q z=z0-2X%Jg41kv1h$Ikse1}CZ1enfifrOpqp7jK>UOU1f50igHZY5S@b`6)qw-m7Zb zsN{Yo9?2_D6r=-;O)I=awdWxv-2sUX>^*y=?RMl!>l=1WZJ2L}v9PGG6+-xI{J?-5 z_1;ApSE|gVy9-KtjXA8*0J0r18!yTy32MK2e{%nUj>Fdu5h;d1GTV=pjaIu2V?(w& zHOQ!Gm1Y%K6y;JS1d-T*6pZiQfnmuWoe_$COOb2O?h4k@RlvR%kO@3MufC1DQ{m`P zWcy~_9cea=MOmN?na6-iaot&$Wb zkRLLPKN!-n<2OzlV$>(aryF`je3u*h70)a;4eC8zZXPyMebzGO==<#4WDS^3f4lne zH)8qiumY4xkjxy$at>jCW^aFznVY@+G@}D)&y`Hjfr5Mn`3dSJ$XIR&_oEdBHw^xj zz;VdT&0D^PaNqLzuT1ElV(F2tn6Yl#HSYe-b}=kl7vhJk1^0LMiA8F#uRF#MuCz~u z8rO}7^o0+-aDVPX_i;TQ6YGRkcMf6r!Q+@|R=7yN5MS~1`~pbi(JVl#pp41KC{Cd( zmDg^QmRBHXscchVW&4!YT`*M^EA~a}WF+_b!a4^Gv_zBIdE_jy`1b0P*E*4`Vtk$j z@_%`hVrmU{75T$j;R9p{h8`Ei6YBKv` zytP5HSf3n?h<WflnI0u)I(_t4*2b<5d%)rtKRxQ7#gM;Vd9Dgno1Ny<@4$xi6w;c5HG z^pxxzQ)Ozpf6+m7ZV9*yNAxFRrL8nhor(=Wlr}lwq{5D4^)0l|*4ODYcbUt}w#6Bo zHxq3Oj}P0>J!0G%SBEvjGo33w6IoWv4mJw?DMgeVFDUuRn}@D1E3h< z>mAL$?sIW?eNd=}5p94CJh?x|eb**H#i$;qSLUGvJ-mQC?A@5R@nREp(Q*O>rP_z@ zd;THpeR|HpD_Zgg2djEE^pRS&c}7PSYXkZEeA`~O=6j4Jd-RkQ37dxT}lBs15A&kf)>((3(k9XCHN=`=N`P5W*C?(Jm3{vusNJ1k31D$o2QpLxM zNty*`4v5m+U7?=l5)Ii6z=qljPU5Xqy7DbM|RPm*V8@Kq;dY!$5U)sCTnqM8k(}pzS*bZs@tAiag?GTV!dIs zxxScWvN+}zlE)#8P`h7(Y@U)Gw{1AstJ~dB$nICSJu6R`(ibC}b*aa;QfB=$KdTgG zFEwhxV&`_W7OM3q_xRiSP1hzfq_bU((ihIn&7Hg6Odwp2+3n6Uj=^nP~Jl`*OZr&fA*Bk5_lDN`bV zGVx|x>6Xx)GS`(;4@kmkv_}|aFJ@$+@AtOb<^La~9-TbjFH4%@Y5arK;S>moPN-=5 zO6qFZg&tR+zY`?2b@t?@=M#Y-sm;}SASh)#-3mtxryU2$oyic9Vp55GR-pl5c_d6$ zxv%EQRDZc7Gt?pGpv-VsZrSjSZ@ zbGfUmrqKtc;x{kRnoV`mW&wkT%SLyn*o|w=^!F{EC5b;<)^1n~xRyN3(}x2fj-N`8 zO^Wbgv*a{*x)Uf$B`wh7&);^Wm9ul4NIryy_jRW(pMYlT+yNB2kXZS9-oOF|i}uny ztT7-{Ci5lHKr{%w!zdDBNM0Y?lyu0|Fiu=fhgr3ag{(ywWSPm$uK{2=dh4EyBOhu@&$ z0FQLB1*t1X)|Dh4qT9otbq)zWG8eXNewv3F-825lk8Pl`z_%Q&H`#5ZS=x0l9j}L{ zYs)=-G1s4=y6kGr8G5|c4+PdXWIvz{!r5nwGYZe>P7U`E!b zZVgNPrgaayHd1x@uMf}69|q0;OQl&W&t22!9PG@w zKUnNM15DEvx;Qr52TgZtdkC1xZ8@9sOMVZD*3>jfr_OlsB z1dGd!JCT(RNLlI>CebDGDua~7$}$d$TVQFlBL8)#Tb-GijsAk>`)Z4t0KK+8rxG^X zRpV0A%}C8Fqt+5#%>g91In;Hi>+r1^vo+_-(x*)z-4_lT%)T%o-!9B>Fcn6#v<$a<7~9SwbrPuqifW4~++0M`{-O6gHsjP)Gi-R7QHB%hc7H>A7EX-%#Me&1q6+*k?8a(T*1m z&d4sv6U6sV95kGZM2SZR|FO5aN@p4OjVm-F5S>4qqC7343cbACiZ{WJ$BMnTk(9+R zmw)V(F-4nSr0wgMwKJ$#oH#^v6h#MpEV9q_v_^}aNXW*U3OZfu00qvLhf8D z1*tsGH2HUQ&aYylcL>Wl!6{dMfZ7iljr4;avJGQ z8F&}Mb>}VTMRqEY4c1wQ*BVrxT36^X?Sacs-xigj;DJcywGFgzQ8=hkZRn6xj(>y* zflysC5$z%tNUGH?ItJQLG~K`Jipta4mfJp0>)ID;p4NB1d-C+`zh$(5*!M%Q4L=RF zf8N*u(B+*O-|HY@BgR=4Q{oyt@+Ey9xxqLe zs}-p!2Tc;U(r76->Nd*HD^|YumW+KGgaaVf{4j;?5p(W1(~T!oS-^f^qdZ}-3&}!! z5fGhrG-OwK^zrPFYq{T>;hQZ<-keJ0v0TfDR8b9LQCwN<(T)6tw{<+rDVSsX0?D5e z`OKjwul34!uh7pZw<3QbsqI`;d2rcuv*~sMq`_52LF$!42%+K1-VMgW{-1w^T=0@o zZa%lN&96i>AF@Hb&?j*52Cv|?jAI`IaDldvUgC&2ElP6ImO{3>a0mulXEsl5tZsX` zs>rtx4#~${Mvdrghux-1A_9PSnN&B@qvwOBlJ<)MwF)n;cPDwog*N>zJl#}JdA*_Q z-Nw^9B5WU2$vUEcKUB&#>wpkVS5+xb2l8fC|ZVA&5v zF_H0CA&oKVc?lsp4PE<{n7y;Ir2biR)U6xs@woN#Oel=Ep?vP&Qy8??hg1pEY=}6~ zZYs-cl9sK3XVEaZ#zGB%hYQcjqbw03Oca2ZR;SS;avk?Wia15_ut?Y*`{=Rmd;6s> z>dJ8gg+#-1Wsfsc_f{p9ZgV3p$(ii918n)+c;t~1Enya#Z@@#mp@1#vh)PPYtf|2x z4NR_DofU^fK}d^C@4COH@ShWH&oj?jr;a>*);1lh`n-J!{{8X!XKMeGyz1Lc)Ky+{ z^Qv#RmR2LHZ>hbST7lI5b`$m6)aqMyuclVtj=2AAD*P?AkI8Ft?x%_$Jnp5_=g`m& zu}kYqveGE1t}#Zk%@|Tc*;QN22mBs)x)gu>XdeL+vBJqkoH!_K8fZcW5u0czn=3XNKDN$tCj~t0KH6=S-hx16L(>vsa2isBI z+9s+LftP^#_UPRf;xy)?IM^57>`)&QySPPY`a0dqCb_xMCMR=9I>3EFvcNBZ*ekIS z{0sptie!!TYtCIsL5R25>P8v6cG~v_%38>D!*GSZyRI~#HFrO_Y=g(nZvYxx<)Ltw z-`rj`xXXN6Z}hhL)yp|C(zcW0?jJNUeH{zIt%EX;G}X(bGYBiMFp06%>T~T(F?&R1 zqk0=l#;q?>sPOO~(tOu1*MLlqj1%m~p$KzC#|y?QOGsJX>?eK=?4>>@CpLJc6nEuVEEGCm?GaKRKt%xph6>e`v{ao zQs!7ITMNxHDW}w~P49xkGCGB;5+cy{6&~@(?Zzd>Q?#tOT^~7&-?vdtfxU@9H|$D$PN;=O)vj8Caz` zclqPbyJTOlK7-*j*b}(1G?P$K$mI z?`+ZTxa~V?$|=D8j$om?^_+hxVs{FugUcm(LruM=I^E}eVUJJB^PM@vo2)!aG$!xz zwVl+OH9A%0eC_?qjuKgdEE;z*8cI^R1(i48UBB^=p=>cAci@~>q?Jgwpbm44zTzhW z_$j^}CiiO+zO0oK#V%}^F-%}&W>6Q#1X*$|meQ$yRI)&1g@XC(U3+Wdd@k+6XEqRq z@sVhet#DdZtUGZ+OT+VqZ^no)4o9-%p?wm0-W4AH32i$YtWkuG5?rhKa>ps2K4vO? zda=oNpg%W`T2-s!voM5F*(!^F-#m*f2v#Q@6n_;fqGwwOj^+%X-fI`W96~9vjYIr$ z*!&U$A`S@G#;i?gOcY@VUqh8q#sq=5#p9TA@tkVXyNX*l>+@eWJqA1$pG}bhnqb>@ zYutjcBcRpLhy;2BFJu2H8f%FS3Cr-9wQXz3=q`(2FM<2NqY>JgKQ|ee&c?!$0-mKat()`(=~ASvLNG)!e9< zYs$H6^xQinAd|V={$V{5r1ZCUL%B$ZtRD399VBe8Logix0x zA6I)hyq}LKAwDMuOsm6^{owY5jL>qC+|$7dei^3<6~!%;%bI=3Rc-E&^5hGlnwH1v ze3G@>+htUhP$H^WD_l$MUL^~`?y{tYD>?cQo9o!R%|RJ?2b zv{lS&$}eWXER+`S)^+i}z$ZF(yD;UtDd}uS7BhbK=uJ#lWUx@lYme?s{=F?nQY_Nv zrpz=_$@zDPb^JLZ`pHwdGwE4?0&dSuEymXUU-BSfq|kvwCVklGy>K;??wPw}Kr%c( z;pMQ0xxBubfrl}~MFu6x@!!+~iS(F0*(hgcImo zR$%Wji@Lya5t$yP&oOX9lCuIDf{$X?&62S$=TfIXCD9DkjimB<9O#Xz5 zYIli&m!;#$!cF>NUIKD4+6o$X7lyM7$XG-t&|+X;(tcRRfE1y;vQgin#f67icXB=B zmKmzOY_nakDDGu}m@_50er;$sC9U=O>r*R{r`;e^wW$*gZyeveRLTl{-!Yd)-!_2X zq7*}1%sBDk82Ct#kX;SbBlqk{Sut*3&e2ZAhCHGOs^ZwlQU`GYt((Iv0god;QF>#b zIgIG*ykdyG{5FIKDYV?vhqNPjn+J{VrR8Mow^(^7uKvcPf}kJ7y0sbSx6aHm8wX<~ zxj91i2gYs5QxryPbXSVEU)=R|Vqq2QVN`U)*41`LEq>yF5IOvg6(-8jFvIDTWUiMG zZ15PbP3ksRHbQZ%83~tmTpxpUZLFr8K4sel?t4yB=s03uNOD&L5>d8TNg}pePWnxS1&!bR;3G06C z!0+}{V4qo&>cnG6qv687-0r~O<1gYnzN zv(H<%Y+su#Okj%zht`J+cX2YVGeoUv z=j8G^W!7~QiO+}e5*4mQcd3r#?7Hx_6Zavn4EsiiW#NvBN~K-=j^EIe)bB7B9j+(=T~;tXS3nlc33O0-yB|2^zj73TLj|Psq^Z z`Bu9(`Zz_wWEMq?kr{6+PGbEU-~dv);edw%G6hLN@7knnf$Z}*OwWp{WyS5!BVXCS z2J$BB#yXDjU$@)F~@ZJeAC z=fjUH2qOhl{|N=3MbMUZ#vsVJ%h6{Lvf9Op#Yr?XE3>z!cO^AZk?4Ds`o_VVq;aW^$~ zHdne!mGuR~ZuSFUrmfUcMMXQRC)~O};j2u$b%>K|KMr`tL8c?$vyc9lo_MKVU@~?& zz^`IL`!$?);mIS=6JBqYXXj4$@xx|Fr$R$#%DNq;0_&| zd0pnbh$vA##iCTE=Zgk^LrqHwAu!pfV3!Y%&||ZxbYWiqPJSve$>!()AZeNy6MLmp z$;WFn!|!22g!9>HlVcVYmB@XztuUZ#_g&S6mOe|ogGk+3rNF5*O>XG|lE;oJ&^xLb z4wV7^lcqIBX3juKrU{X@7@d5nz-MFSucegT0uPxZ&uL$MEx9wTqW5}4#kyLxfgQ7b zVLs1)gSWhyQGH*@d3}fmpPyCVOSO+UvHniSfX8U@5rbsCE1P%Vs_p}A>n6;x=-4=W z1OF*tcXW3L%}xvTTTpaK2$D?e!D-I3C*w$!RkMj-4Z1lS&p@HzD{L)tUuO&4Hxi}NK)^}A4q4;N)H3K?T`yt?&lg1L+7v&TwOxWeii5}eQA4K;^BSs%(u zLpD-+WQ19$C8BOS8=9AM2XQVUGT@U;mq78+S9DJ81(? zKy%tAv!4L+)GX0iuu3w>wh(7<0?6L5dSAb^zZz7xxlXL<(_G##{Y`79TWhn zAjJm#mE_9M)Sj7L`#~{3Q`6@38F~6SonfX5rrJt)eMeo5<6)uh3XvH{gx93HOY`mk zZ&ZYb!!paf*Gkiv@`;x6{-;;~0bAa(OI7kD&5h3redyzYeSa~ygv_gu{Jby z@4nzKCUS?efb40C*zEy#KQKF!1~iZpWE!jnQXqoTt_0*uD^#r5Ria(GQQ0XTo!X%F zxxQwWY6v^c@a@JNM16^}es*Ot-n-At%E9gZ{n~AE-6mU0Yj}t=-318XU=cYxv6`a(M)#n^|nA_ z*Cqua^Al27vX+p6FpjUG2|5lKeE6r|zw>o^G~>I5`stFl2~jh;ICt-@8p(3}(?YBS-Ze?*u!~`X@TF*N!f$V>%`NRm z*OUNfO(@SJl!G>-Rw6GRm!G;Zl5jg(v@Avf|Y;?`t$qEvuPNz%tslVTc zIkn%z2qvJ>4#jkRk!Mk3-zn3&Ve&du{`fx_KFJ3o_2Q!d&vw#Y1SI_B08IXl(xVV$T-V*7NA z0O4)Xx@%a-l6-8Q|ARyHjmoAwl@!*+zqN`ELkC8|`Jl!QtjJEg`w^US$XF#H$FpK9 z$})zj1eJXI-PbXiK{N}U{QnkibLMSm?y#*@!s2_={xi@2iI{^7=Q{SE^RiXb{y!X+ zeb4j2b&`){)3&8>P5U{1HgE|TG^_xFZ?6UVYhB3H^C878XWcjDMUm{fRfquxBNg$m zBXRMjFc}6-k9UWhc1mOlTrMFmST)O^vBp7^5mmO2KflUT!G%@?h}mH4PPH(g)$KcV zr7M~P6a}sQ%Ffl{JNj+-dk3j%*7&{~{sZF{;^l*iig0V`x?2H++w&%Vr!p4qmZXUWw0rn$Oj$8^4KGWnH+lxS7BRR2dntq9uc!ZT-uW5 z$i^v|kPXthZQxit0LAONx0RE1gB;Eoy~tTfn1fq(Uzz ze~M99fCW)-MrH3!d6nHn63adg*jG=cjl*Tnm>^TCs~QGvkoAHyKCVFiE)JZb33ngR ztxTO<*SA!p#bbA(532}`-bP>J-@y53?qA)O*>r-ObC} z1lMj?w#&J&7$nbY5GHWS+OgN{>Se)oE&4AZCb|foEyfRy zTeMIpzpSx|O-6sTPX{dEDrrXWHE<#<{B{-I5LolY1lSWzj3v#+%RjNBpqDc(rU9(o z@D;3Bd6k==T#F+bfIH~Ad&-3i^TXFaUu5o%ITo0}1V-3aX#s`w`He$+;U{rhv!f&q zrjVQzG(2KN`s4P@HnETO83->>vqHvVlMhsOCxiq{je2U}!h6akI&b79nLb05GENQ9 zvv=4BK=PAd5Z=hBlG{2Bkv!Ui_#T&JN1vsNT+f=N%EJFX4bQ&tA5Y|~$mz8PskDCtHoja;)v$n^#PC@JT{5p|`y+`0S$eD*e z&_}nm2S<|TY}D_xhFp0yuG_-@x(#lB-d^p?@nigQMrbetkDd!YV~OCoxC~)cGOfR6 z;M2V_lv1esMH9&aA)*L}IBw?3vXawja4JGTL`>h1w&YRqg~B80Vr$tvbn=EAkJifT z3@RfNA`$ptQdY+*`gl2gjb=k+Mx_L{eR!DK-HWQ(Q8H;k;a}4xkCnDo?ysgw8^jc8+nDn=Q=rXzBQ_IhAN2t>~wlUn)BZ+FX@&#SwJLO zLa&j1Fw&dS2Sv@uL>*Dqco~UVci&!0SjKB!!d+L35d|Ain2zLp&1=&}%AWE`%{|Q9 zfa8$9pn9Iu1(aggt; zk00Y+mtLK)gB;{K_SNW&>)1g$uaccRfdd`;>UGXl#}3kYb;8bd?BLo9_r~<lUA=a`H3{H0S z>DD{e^+G1zTf$$>sjI|zbBB%OrHlGtLaxwZBRfZH*UZ|0J}VY%lNVjI<;jiIL1yZ>&rUB5>!~^Wzok5VI;`SBw`iP>Ubx4Oy52~e?utZ`*x}R} z%9Vhby+)I2Q3qn-8VVYIfrq-0L2Fe68ZU`J)PyATuHOuKvo|pX^2D)&2q@66`trH7 z{yy&~;I0JiA5GQ!w5icZAD!0)XiaO`Yziz7&+v81aNpvC^?s5#S9}J<&3h7g0=g}V%yrUuVY4Pq`_SFL= z1?E-5U3S50Oi59^WP3c~!Hi`p^k`@!1F7V-Qdq(?`yZnAyvq-n_}{p6F0nz9bGO<+ z@#a1U0TgnO;b4IF!)cs5UH?JIxd9sYwl*lt-~~@m#kteYu_B0MIz5La5{m)1Bc#M`lA&BSZ2Y!7t`*O?e0RT{>%}3wLA6nGO_WTsvL#4Az zz$NoZ`+GN1F)QGs*>Q&gV*Irt6O%mE_-XqN9fv1pWm_R)6>0fYNNr)9Iw<7& zX@%*93A=drrX9kfs@qN1)Q8sr;=54V7sL5s9sQ!c%zVTyXlFiuTmLSMESAGWKzmKG z!@AD67_yUi-D4_xe5V|4Fb%oQiudlNSgQ6e`0OR>{L}3;7SYiQxkf=eyAj$9SfefD zZWaLs3Y61ffQ#K7{7t(!HI-pg7!c_uAnx*je?w(C(mV~>;*n@EY+{*V4pr;St+)CD zf&S_@Prg<9aFc;3P0DpxS(47PQ>5R(o{r2H7c()FtZ9kI#J`)B?5zOiMo#Zd39mTj zD5XJgnUuBK6YYISHG|e*InkN|K+P^czN=LG99&E@4 zec-F4*A&c|oV3g}-jVcs!&Sis{exS(md2_@Ya7zCVDYgHho4@;mNBBqdO{6TYsBN4 zDoHMaFFwvLOF-4KZ*7_p8bvPc^T?!D+gO34bmdp~>c z@7~Y;=sf2VA^!NOD4p9~qkn}f8cBAQoYpVq#YC1+``iQ`>@ zpt5K(^_|kZs3E)FSk(tQER%hsOtXy6nf@Xq@j=5-czg*x{y+wfGHEYJP+{z!=^>aN zus+;l=6j)da!YPp?gAWRGVu!A(o=eLRIQ%nSjTz0yF;)4VJjP2?7?adKrI@F8WZTa7ksJkqOJw#0#Jb7D5UF^D~<3c~aJm_2{F$>Nqc@N3}F^P6Sg=!XNp1}?mKPW5}T^S~a= z$~t#U`=2xCPCr=FX`QY1D#i!1y=dY`` zZj+;A#HE^;SLE;zLWNi;MQ#)q~ES{ikY2goQ zsWo`arT3XV+Z5O0B*M6ec6s!CFsv(a=UUUC>3v3`40mT@Ngx>#e64;oF{-By9VgwR zp1qDGsbN8Ww05=;ezT_L{<@lAp&Q@2AGW1WYmfP9Y;-O%mM)ym^OjGJz!J1sWe+Xu ziy<>cp6kO6HtSIs-kvGBahz~s$xiECP(BZaY5!rv6=VwhVv^ztyvD!f9H1Z1@**3Z z982WB?v880NTT-C5Rddtkm(W^_%N~|6L_jwO&zrNA)eyc9g|fNHnr=7*C*CPk4s$- zcbGT?I5s?hUoG;};}BX*cg&0z7xV2I=Z<%G?-*L0J!(?=`>>!LEhS2TY3lm%uUF(`CU<||XH8YOKgx%E3H&lgR+up4Kg#}{;E zM%kMk>m$Zj*x-ytg(eep+;EJVy-tlME!Cus?^SngI}%HyN^}mI88-J;`?fgqj@HDe zogX}qdx1(gv_ZU^VQ_u0G^JbBSxszWB24_jNs&jR)v_+c*L_@uzci9_YWs+uQ?nN> zxWqp>?7(+q<(sG(y0u97qP)$V^ph_pIIc*i;|cF6#BhQrDp~v|A+o#Q0Jj)_TC31b zjfrjyXlm2z&kuZt%|%x+%*rH{F>NCz*fUCD<)RTm-uo^}w%X@sZW49Hec0B^m0Yqi z(C@?h$Iyg`WXP@#M9+g!R5Fy-#yw*RzXDM=07o51J};5jYJmKN#SCNwDxvAKO>0d} ztt6pnBCnmqmO*Ea+GgCO_d!wFM`u6Up^g_MmEE*&bCm6nZmci3i^&vFe6CMYH5`TX z_T<|2wUywhPYCYoV`G&~x12t(ZKZ(m@rZiK^>0Ibbvo-%h^;%GT|dC8UoWS*{-?FZ7XB zK_{bQBbTuaMuboORRcE~LCmk04fvQD_RN#j7j%QBYip4yi21 z&`v@e%K5R0dqg68aM6tGSyduEpVgXh5occ?aaTgexP-YqrX2FOJ#{_kM&6+Q$rR#A z?OXBGTb*zGQ1rCHF@IZ2Q9c#)nl3Y01Jn4!c@ksE4EP5Vb7*9(f7V5-C@@ZBK?nny zoyo?4rPi$kG-;G9@a_Mlx5mB@lMXAGA~Vd_n}U*?s+bO$6kLdR1sjyqB6wKQUiDqS zY`;)vb~F?1r5KQ~Gm*S1D%D93{*CV3h177wCS@gVqbQ`6ZbakT%7dEci&fDw$+)JB^n7lU%1q)C*2V7}*)Hj$IrcITc=bD8XQp z@ui+5otvjruU&)an{-Z`U`kIntDd{a4Bo_j=X}7kSEbSw<>BcL^32nGpIy9ZDTlN5 z$&zw2x~PYiy|%`*_U#yIaX!&6qsoms`QWgWr1#X2UR@G8Gijv>rSa$Z6UOknmW!R5 zt(N(0yG2ijAvFHt$z>6>>bsqG=G8J5mbOQWW$pR-o$Zes$RcRInYA8$(!;GilO>on z18KJ58D48Uf;F6kqaGtYTa{Q{3E_s%8Obm0ic`l8o9HKEei8oc9v9lzo-VjYKmBl^ zUmgZ&Ai?!QCm$_7ff#C;jK8D_#5ncIkMR3I5^?e-FLX@EXEr_bFuWBWntfjL<5(3d z+#@oV9j=gj9c&(PKi|wFPTb~@R&(U;RxE`TXP(Tjd9|pW+44&1!|aIN{ax=R&S>&o z#jl8evcCv@Dqdy$*kx?bZ!EW0C)cA+sPLruBSUp=sU?!~Nopc=7G6<|^ns~_8r5g0 z5NA9))A_iAP$(X0uj73fBMW*0q~7ARc)D%zbo$@i1O1y74PcKZd+CaDp&=K^j0>8i zpduX3;;$q_lGL31gKj(!MnvannpOTaN_w8c2Z#HTFEpa#<5Yj>Vpa#}rA@CM=|J6T zFjR?rmUGJ_IJIG&X1mzB723C05wC9LBJ)Qvu4qKwn#R60Mg%2AuFm*gR+Zy@ra51L zLQ78wZNU}L#etfWj)P2kK|0RS&tU2L%c66Tk%KaOel8B;>Vg^@#A*=9=Oi>(68o}5 z3B>C8*Go8gIgrpmnLQ_=fuIe-HOLM?>i;h#w0VL0i!;MDw%ZoQ;aSQCavTjD&fn5c4n&N_2DI zJc^&|dn*6Nicw);cB z|L1I-1jfd(7B>~ysv-8TOeSU*4}$9yqkpZA&g-m9TMJh1I`Z=&UqSs0fs1GrKKR$l zjU#wYLVVohf3=zc-iRCECR|MKL-2TJ*A^*oF=Y}WTGT46$jlsM;9C7>( z5XYHAyxj1vLq1-eXCVgbj9zx1J(zdx(T`+`!QP}~d%fM;cKrz9z;3j4#w2=r+HURK zvK&;L|E?rKsv-&+$fD8AAC4PyeP96(%g>Luk<6RpGscEEQ}+I zQu+GN93>9#)i`=CWAj#?%3}~A@n$q`;0T3^7Mr>RwLS{PicJ>csiMbj?|k-pt%jat zLl3hbA}f7J!lDBb&g>9mr_@1{bb^#vSE&%A43|UE6n>^JJ_g zTTXh*vksmqc^zzk$~P7KEQHeXn0dv_tP~UY0}BN^ucP$q zH|fYDoDgrM<#`urK_i{L{_iW5b3PrekYW*DG7e!1a|`5uZRSJ&E+8~9;vJ@)ye(;h zITdG$-M%fNK_e}Q_TYlmYOCwKBy-d#Gkt==(z8n&Ye=CMKeJx@?B?n{HvIjN%JXX) zt66sK)JHoeuwDR1bQ%ze=5BT`xpZaWZnWcSRD`V0KIP*WdfKGy^?xeRo+}K&4)}+Z zw<*t^p&Z0|ZUJqi=a2ZwtqIzC$6Yt`p;=b(0dGEBrEX>?;pfe-@R-}19IJ0+833{`pQXE#6x&P_7?#WE_Ugi?)05sge4{f4-VBi(LP)Nfs8d_D?CX|+G-Pp_ZG zYH6$;L?2d-HpgtpBzlKB79+}mM-2|s;WPU(|*OB<*{M5Yc6 z-lr5a0`))mRl;vG0G2*eyR_n5xI%P%!X9G*+D?YIN@8Y~yG*!mE`#epQSrK!sj>Nx zc1cyS?#}%O!&X%v&crb)VjG*)SC`pq&rW%W-peDS9u#R%9;Z??Hmeh!Q`BaQq|dEJ z(0b~Uc!;#%K+N=Id(@tjc782mEph_5F`)u8L{IfPIdM`9iZxS{gXcfXB+;lP4ZH-y zkuGZ6&?yIRgS)(I6Qn<1GSmy^4=M=9WgRS5vO>OB;wM+B%*YCmg5w4&$-$UM-X>d3 z9Hn%R&~{_jo+_2~e~&OPP}U3+Kk*vhazY*Jtf$jrPH;Nfk+b_}h7QxWq8KARI`n9~ z>g8sz`|sUm8@~jbdh$z$L zfw4GqTm~WU%gxYvuC3KGX=cGEh7j5i_V&TCN*s@Ph>V|)7E!G8{IOdoKDW*9wl`}J z2#c&KU7;Np)NvrdakL}n)uAN+y5Z?uy1UyR-T)rCr~!mgDieJq`^avKStC=jv7D;GBdXH&l)FtkMYePT-00cQN0pUp;O@|KV@@HLjdWKc zk{+0+J;byR2w&UPhdxt9H;49J8V>k+6m9Wb`8Sj@j!XswGR_sT1x>ESBd45w#Pdf^ zL54op!v>l7T%T*cST_F(3Fvc!)EngB^ZQ(XCzj2>-`yqX#-CE2${9ryZbv{H?+Z>< zvq#aef}dl~bhYo>cu4McSj!s6Uw(fg#}yq)P1OI9k?N|pBPNO(o|cT8pR3T zdIPzt$E%aH&v~dQxApD2$`CtnKv^WZYbC zrB4n`wugP*^X>2QzQhLiC!>=l1e+CT-j^cpO%b*g75qDch3GUZ`Re2wL$RjbZFK^C z(#~?U^=}wlv9ARtnua4%KJypc@OvwHswTnEUV_0tFz#JZA#gkY{Wb3vzD!|<a_@DHNQ9wzX9Hr$f&8F&`xZ)uaDh~VS1bpw}W4| zj`{r>QDN-n@u~+`aQj_4f5;QIZxfK@LGD38StA&4m7b8-&9zVMDF=(xS?fc!x65(A zi7=kvDwqCo3gb9Cc8_@LGqDltDf#d8KiN zk*^ebXv_@$c@?us53`os#PWR}&E8^qkiGajqMn3;UlKVpqlglj5kRA*aKm-T_(Y@$ z*UEkD&!{6RD2_!d7<=yV8qgZuV-j21{R3y89xp8%F;=|*e~GHs$2h~;Xw!QI1Nsf? z4tW@yaF^GjmE1|c|Mrj~|4aBwA}%(&)zjoy*`J7G|sJQ1h!~V|g=QMKA4_n~*OE$y) zru3d@CbTjUav6DR!P1tTV+iUFpLKpuIzJt@f^J6{OzQpedx;#^_Q;qWk)l7QT3}?o zG`)TOlw%SLb{HC^{fG|E-%9h4NsLa8RxOQHldNf0l5!^%=GQ^$4LgkvCO1biT`t=X2f5oI9dAO|r=O%XZ zh-S%ick#<(k*{6(Lc8-iG`EUK^qlI@PIi=}da`keh-^QaRi{xf*Jzn-Fy_I)V+pVoalH$U7!=QCmw>dAG@4{`=ZUDw z-ly9=B(FjUU=dUj>#(cb`Js}b+3Pm=x5rQ89|((mcRc;(VK`BfKM_H(!g>6Rpx6+khC>y_BoejVn)HSzcPd!c6LgIvkw2|bqFss5PWgoK9;2?T zM2o(YYY9Dgc@WnhMHy`|l?cd`R6X@xn#~KH7s8iViO9~*pJ7(wtW134(yly7w`rg> ztl^n@m5O0NNBEK@Kk~K4lMg(N>)}E?W0}RZh2WVOp|{Exct0X^v-N{>L<@Zi?%N2- z{7`Z2VP5pMTf#V*S4UV(vkwPPvW#l)(i6EAD6C3elu*7DhFI)ooo;S4i`OzFGw-1k zhRq5I%0i5FTqZ6>3B3Q@?UIPy=l;MMh)lqwnL&OwGObiC}BammyXbx~W)lPatg*@g%eOl|oP>ub;zj ztc`^svjTPIli59xVas{5eCEG%k)&^dZuY-45&udzljhM4^glN_d-Z`8WCuZvLc!BN zO(HP1|3C$!JNK`6WHA=BJJ2Y4Uvi3tf>hj|jBQ9pPO{z}dVCxvw=|5GUXT?ipR9mV zSH_n4h*dJT@*5R4{tjbh7uYnAXB^sowzQX z4uVv}40}$GOWbhcZ|)A%3lp6>Le`qLFyyn5ZF-SOcpEA({(dt$t+3AS`ULt zLiU!SD>Ppm_CAtC-!Wp~X7#|NT8fVrGP{!pO4jE6r`vcAjdwkQcpHNoi;%z5t80|8 zqa`S{=X0)KEAv%SLgNY#|VD(?PnQkTYih5@FQ!sRP2xkqMVV4Ct2?=;_CNR z*N?RE-P!x3v6*Y*sI`j&{8{$>c{2tNlu>^VyUdiO=P=~;&Cnk7p;HSF; zLs5?&avi4<86j)D@_lsFCOeT^c4K~H8k^Q9GwI}0R_o}(nzXES*4R$L%&dNvH?|c0 z+BFGXOU~h46YL+jZOsY##pb8#K?ykDDwcANaV^D{M5eIr=S!NH^zn9|dCF!898vl| zA&@EL>QTeXq88R=fs8UFTR!22A zkV4<}_&tUv$;MS|a{Gl{`0GR`Mc> zho2rlc2QjY-M&=lS!jh^llQAr?)(TWPt}ow9wwUlr=ues(^L>Urg)5NiFb*AEi-** zrJ*<4(8Dr)^D{%-h@QNj6*S9GXRsQTdZD)|PIQUO}@CG;aJEYpwfQwZC^mbUBw z_Y-(m)%ev7ipl!-6E_tSpB3S-{|tI6VAFhxrAU$Ce|@uaAHqnTf()b=Zr7|tF7WcjiT1Zg&gL3iAnE38VVP@laZ2oO zkDPr~Ujv?q<-YvG{oj~6`~Ld+>)T#!ZoJ)is4V2mFv{p|NU6omZW7FqzP*ABOz)ez zWC7pmY%;ie=Hxwat8yk{fw% ziq8%T^Vm9^WU0>zeV4}eawSyDSuE(~t{)#)>Yi?<;$4iwvT69yH=3qXwHGD?;HR$fTWSe{ z!c=tlBLjPF;>~0(G~+q&M7gi<;MLzN|98z zvAZgX{hyCgw5DIxrcTA1QTUQoox{!Od`MlIo|ARQ;pRx~op2Qg9p4ElF z1O3a+-Jdde5z6p?>_RmYP5F8Gd}>*8Q*nG;20D{mnX@r^IX<{LhKopvACAR($#U;^14~R=z_bkd_ zbO+=#Buk)l7vdu1`L&rAp$u7vw6*=z%hGbaMi%Jej{!9VoWgrqA~~_;A%TKtTJ!4j z2PLAFsq~&**5BAe9#8_m^=v$XD3v|Q%*TO&Iq<8knE$pG>i~zC9!T5f_BA!rJRh>&AxHT+J3It#r>%`P{(6<8VKF zgCUY+G|gv34?s4#T%q^jG)NQ_5B$>QDu1`fc=P{H0d4V}?f-8A+HlB9ctIk2N<73N zJSWG&=tz`}i&r51E&L0b9Z9?}3%J1)R=AWt^$btHTX>wU$_hd(K}yg!I(GX$Wo2Gm zeEvH5tQd%><{=te$%I4-YRxi=iy<+0-o}PlqFi0RTGfHQ$`n_@eU)d5%a6xN#+_n#GWg0o?)=6b<7kp#MNvXU3d{+ndHaY7LTnT>o%(v*} zk~$=|{pEJv~zgL$_8JCS z1yjfNZRC0BuyT)~S>11jDhTzTRVNAjs3G%?|s_^0xp0HAHEEoLY($u6!Kk5BM{zeE46p`Wi-U_&LhypMqC!4C(E z`E<3X4b4}L<_F5~pH5|5%zE2H6E#x38+kivU|*n&7QWQ+X|=ADlTG+L?JKgnJMSGT zOAiiVR+`Toc4GT)2mSAYf)_Rc=((s2If)V z6=qq@oU0z3n;(l~HITFyZ%mt8zX0Y)fhY#9dH_EL!zlA(^}-E^Y^*Gp7X=bH7()S9 zz~%xqkia;@D0BBWzjF^F$D5n?T&Rm#sWYjT@87F?ZIjrs3yNa9QR6omI#Zj}>gp7BKO7rT#Jse{$<&nVM9i@4 zp8SGG$Ns*uA4P-g4nn+Dh!*-7Y$}=j!w}wxs+65-E>I(Oyua5ho=?Y$ig6ns%CMh) z-w-HNZCYj+>NOhTo{0F&74}LJ>q8*{IIUEa2%)vvHMKSadrxew7g^}wy$Xp} z_zykkx%GoK*YocY#ZH#WIX`{n7zzl1!^x<7GbJ`d4ULJJ)~`y0qAo^XPJi=JHoPp5 zq==^qXz3^2*vKO?E)sWP^%#?&^_C}BTFb_*-|78}K&$>ucuQ19ikZULg;d3Mb02<@ zT9>qK3iXpCfqOGLeE2CsLhC&ZPc%@K4MnDU!)om)X4#e$DxIn!NkQ(j`bKbG4Dveb z9*3Y9F`;}b7p9#YzM1BluRHzd8uAJ0X|L@F1evZeykRG68r#q*hxRDwWu~A!PNXEN zy%unk$+i7JbbDsfB8SrJbudd-v!sh`Bvp;c8-z)9`S5jE)SgEkzt><^)6$8r!y4Z5 zW#warOh$Q99ZKS0qtKpY#(TFf(8&JX))wcg$G3;Tzaek~kDk-G|85R^L2C=h+`y?9 z2;4yOUaWD?Z*6fRbNkTi(SS5I$JUVtN8R@un`4`XEWbPZD+}h>inXoTDDfA^77uf5 zaWKc0s17)`@@$T+F5uWAW0V2MRt|7%l>o<9Vm`-K9dK;Pe{yVUT!Fq0CQ~N2ho8-+UXKbXaJP0zG}y1WidOxm11%$M*+t+oBaiBltnNPFbIML9xflaeT&!gE6JODIXsY0ydESqNQ)@~Ft z1Ji8XM*pJO?mZNjg5x0>k%mOBW$aF(NHRCOjx!J@5Ao1=Q4Y>gWb3Sk=OL4(bR8nf ztXNAKH@rtxJZVp$Y=FMf&NeREJ6-Yf)jJ9d?s3PB?z4BV3Ca$Ns6Ey;PN5GOn-1Oe za`<3|BN1tOV$u<%g|&37HWBSN5&dZh7ZQs8V47P^)PrR5U6iZ6J|THG+jtgFq6Lpkk;=Z=dqk97kw5lT#vU^n_uD4) z>dOl8{t^YZ%q9v1Fqrj_s|U$ZZPdOIN)$oT`U>LX8ifZ+-!HNBaQ@v6PR{*}))ffp^RIVsn%3Y9m>;DV`!p!0*%kFN zM0XjYyA06^$+Ea}Lc1RHK7EkksdA-c;D-DQX_d(k(iYqg+!{>FtX zPSBT*1&{ST$ zbr6L6Wr*%FM0XjYyA08V2SewkLjPstW)GVzLv)uRy2}vVe~IjwoBCd?gwGG$AQp3C zHz>X5A$yjXC;P8hg|H0KU54l`Lv)*-w~ZS7%)U_lqWzl7_OB*Ilhs~!viF@VLv)uR zy2}vVWr!|3O!|#r{_k!yTYMpN{uQo&xy}q|a{s}6eHo&=4AEVN=*oU%?^0%~ZQrw2 zVR64~E@NNZF9UZo7jIUWy9Y9VxOC3X7pzs7y95HXbTC=EnB=phqW)D~Ub_s@U54l` zLv$BQ>2o(i7F6UQf&)RFa}OJo=JT83^D6RXi0(2(cNwC)4AF%N*mD^>h|+VBoYNRz zhUhLsbeAEz|6vXv(B76Iy2}vVWr*%FM7NnU=mN5HP=n9SoP#MBPTdV^?YVImuzz83 z-OU+s0Yx_`z&SB{{@(Bfb+@`p;@qMnP|b zz9FRlT~~a*mjkC?JkB;JuyMQ`I4&4jU67V@u5K^bvcl2Qzh`;U*8>u5a&Zt>=Q?4Wy`^Bd4NSRlGI9{E!G%(woB)gx?#^j5x?d!pJ1Ai8yIh^`z) z*#{G;CMFLcx?}*+RSv|fzz|(&7^161gdw_WhA!FwqDzD!x*7nYt4wefgCV-=hYtgi z^%-prL|3D$SRFug)xLu0N;~lYh^{yXqN|K^5&{riqX)@qe?oLAv%3_(g6O&dh_0=L z@ShM}ehx%e4u@53M;C#`YOnlzj;@VSF^8ioJ?$lg0vuh+7mlvV5**zM%AXuv)B=uf z?mUjJ9N_4VayYvEn57`P%6~$1GqD_q?f@?#f2;@heGuJw>yzeT1n6kh8D^qL@Jtm$ z>F`W-hQTv((SoJ^i1GfV{2VCkex7!c9-CSl2pm}raP!?Cg3+{7$ zyAXzJ?cn@>IT*fpx#+b{v${a+c{ba2V;NxEmJg+I!E9Sz?CYl?2IdBUZJU`6*tW`= z`Y_v8_b;}sku=P<)%wD=6^n*Vk{7KC@V1ID-c~BaNX#$|F9-0pVlduTV>`EAr5_&P zZC3)ktuhC1t2Dek-WGmE;$)$~7s9QYjwG{(4hXl3FyYqnYr-wD ztCUD*6K=5$KRC@1Zhhoa($^|m%p=?;0>W)RQrl(bDInaI5dOgZNw`%7gxlIb3AgtU z<}l$F3kbJL=Wj?YAlx2h9O7jYZbJa!7Ehcw#Ub2YD;|$SV5L&SzYuO$0>UlCCfr`5 zv-I#V;dZ9@nJOUMuG)1?a2O`s8m#Qri!kdMxzi%p&+tZlAA{%3%+;o?OK<-E145H0 z>0Bb1Qa)WtD8ZL^a&{|#&OYb~`;bY3p|jOL5nrZxBE|M=hsX;fPTY!|f~m7I{Kt2^ zAKCIg782DB7^7`P*1d}8i#5p4@pb%gkCJkr88Mp^EB5@_DEvsKCvHNBBX$WBv8wHT zx5V`F8I{=6AFJaEKi;Av5tKL+?;q9rC-dUI-deV_+kF=MdN23lT6D3y%?*2iT9gyw zK-8M+2hSCv!1XxpHW%gQd))kTloRFVm!k{ZZEoHJ1XbYXARhipU;DZib(mmaLh#Aw zzffnLZb6fR#B5bIb=LR-n>uR&Q)dsu)Y%a3wKOr0fvO`SD@sk0P7oz;e^v&Mir z%e#;|YdlAtHP%4laDX~%2vcW`0Cg5ON1es%UoBRJALcyjtTLd^s%bq=)l%E6j(@JD z%Aw8%_V_2Ih|-8(sIwdYqRy^-#rm2$TfPK!RyYo(&Jx(v*^JDC#R`8?XUQ;i);f8x zQkjUkZqK34Hqv%Kv-pZS`wUQLpTqCdnV{3M>I-;QmF`&)D>Rz8jv&81&2CE;kf}J0q=ZPLNpA zd^ev9qfLM28*|DI?x?#jy+)MSlc=H(=zvD*#xLVpss(eK^$ z3Zz%`RiAy74449Yu?SFL4^qt`xqt>hI+#C8Ww59m{5z=!m^o+M0yq}u>cjj&D&Pme zx8@vc{!TBDR)V!&AZwhj<1Tp}8Mqx#bLWe=AcK7S{u5{0{of^ya5>BV19tV5{kf}e zXOJMBKgET?p}<~uL_!u`gdR2pw*KjBzP)FTa44{otEFKItPEEubw?BhrobwNW+rkd zutHHqF_12x!0H~zO3*u4YapW}&qGqe1xY3`TOj4Se7!#*uq#M1+q7bOifcO3lu^ae zTJ8Sis?4og1G$RKR<*Mp3a!0V0D&c5J|IU5AoqqPsvepAQS506q}uNeCJYG;4tLDrkKjFwbsBi)L5Nw>A1>zdso*@#cG$YYaZmKOZJ!@ub~ zsNJB*yJqK`_{qA9@|AwDF>J8=rT+6}@!vX4XV>pypbxZJ3vIDBH$SPR-KL@8@sL?2 zs#G5=+*>`!5LY;n#zE8sUOl|!!ighyjL}v?q^egtTE(}#wVT;iB$SC-dFI`VU3!A# z)C6H+x>1Dp0}ErBXYQ|vZgroyFdOX94nwq3AeCI-@E}e7#LR*3aVn#j_r9W`l&y11t$Oss#J7Tb);%ZESWp8 zRzb~OIw3zPk>}7({qnZx$VwO4rkG~biEv8Z@%$CMuIKVkU+(J<@M5u|>RohO&*yhs z@e{g!IZ?(<<@CWw1&N>hlun&b(smQQ(Uh-V{KB1B`#$o`QFSBH=G>Kges3F_cx;pEYKr=#9HyLaK_ zv7gS-QM}SNoh?&+3_&%o(azR~=V|86L^>-DDNL4FS4?ejKp?WXSGU|8?ByLKb7ji= z$@V@#HAw{6;mnXveKiCOe;&T$KGZuHx*|UNgIQmEG+q2YE7MSR4a2@ai+g1&GW>>v zdKT4Ge)pinn11)<2X5Xgk}@?EySEz=7(LR3%1!6a{`2<_Z+`yi^0{+=d`aQ{E}*dO z9woBCyp6v5WCzDOCu^EdKmaz+Nt`%Y(|ikGJPJRj3d~QLmOSF&ZXH_^08a5eDbw7^ zUjF4|pJ(1~o`Z6BFevo+Yb(eaqVu=_P$)Hy2Y^CFU{L5q6Brb##|DMUO2D8{6aa-% zzJNltU{I)bvMf?X0f0h9*`QEWNdO8Z>NdIw15hYFMqN6iLQkO6MV12!MGB4-C~ABG zg_6T`0Vwp|4aXG#6iNw0Ofdu1ryVo_B@~Yf(;L6NjpvmE@wU6_)FdBjQ&GOg2W5YY zc5C9~(ByTjEpM^|ww-ByJ^}hcx6QdWE_{SfP}`^Y!_YQg`Lu0v`Q_1xeFpxwv150Q z{k%T^utDSY?6lZy9aBI(2CRQPje_BLgY>URO-| zoKX?p#9{D}cW}h3iA4M7XQd?qZwp;a8`5UvXW()g=@&Oa4e}*8((?%P&fM$N-neb~ zc!X=A|0IM{=M`$Z10UlQ%Bi1qV5>ZeZykdjSRrPmNZz z0~_R2eCz!LdE3d2tE?aBKqu2WLEp z4?rvfUiA&ZYwqx#`v)k;OE_k(a7CV+`GusZV#USc+v0Y!CCcV(b!XtN8OPAmKizbV zxwN+Dmk+BGE)_lcgYK;@ux}S7j*)7OOxm|8EjwEzbC+695ko9LLaw+XTCOZeq_Qqd zr#cW*-|WY~xtgGTq}^Myv9RNm6Tebf%IO{lLGDaGV(+jWapx|w^vJlipc?*$n&6e& zckbT1|C1AuB*&xHGMo zVGM6IqvNy>uD4QsP`3j94n%$no6hOn%PlEy?52F!WN1U4#g5hR=Tt1yZSihiJ58#` z*OU}rYu%iB^=deVAg8YWe0_Vvc#Tz_>XwoA#;b?yYOMcDj`PJPUzPxUl^3foWmcf_ zoRfHfaRDO&HU;bj&RZWm2UZ5G1{fMhgu$T+ObMg{AeM9VQucWV4fcXFs6__E%f`EB`JN(aC(31ZE$wA?tr)L`jt1e9+Yxsh0 ztPO-FDO3|Sx=}|y6s4!uv2WwC{dZqxAHMX<1vTZUP=WnP$?lQyJ7iNbv(}N)Lcz9;ed%7GZ2c;SnEW~*Mk%Y@Fx#Z z0-Wr%ufqTI65CLYl*cNJl*rk%m6Y^M(=Iw1n;I0upJP6@_RHN^EF_1VagY_%v5ivY zibJjyRJD`3GHFsKXnIm$isapA-ujMt>aV+vV+>Gi;vI42c2qkwS$ zI|CUgCnnEHhTtHALpQtf0x2X%H3TOcFe6}gz~(r~CWzR;;NVP?%@&&z=z-ya^No{o za-uP?JaA-vkF^1-DqSKbPlV`HMYmh)!pOj23cVeZ-3EApox4xiqi#e(O{8CbFWVip zJzfsS2dXVI@#y&IAV?@JFBTVdV2_-fFe$&nSD+-bSPorz$W1w+x@o&kLyOajn%V=h zt(|u0>;p}EB)WQR1WMbpw%7NLSgD_{j?}(zWvyEAAjGyWS%Cu zzO8mRkL-BZbGWVULJ`Gxqrt4-g9$Y z9;cbAzoxnK5iat^{d>`m+AisCg*3Yp?WgW`jc9G29mqG68s*u0v)In`4KmeN-t($D zm72(X&MkpgW@Gmk$r!8Sk@0a#ePB}HFazNVoK21I0@?8up2hkeOIq^K`t}Dwq|8~$_yFPV zMa;QL5GggwF3+^bTm+GFHcCJ5?`)`>< zCx~)DTXmv6{GB&uo$_ zivSYlkL(-oE~U!Sh4IBNs+5Ub;Lse#HWdB%KmtKU@eB5#d3ekigx0bXP>WUFfmMlP8jG z7~G2&kKW!DYUO$P>vQfFfydzwpB%jt@5+ne@4k7dM-7EL{jMf*@;Z7C@5S(@8El_L z=38|xy0eM51uurW<%8R?`*b%crQ+2o4k8TXyXWgy8*S)O;R$=LSKH3r+mnJMuxvN~ MO(NYF4?(N`A5CA*Q2+n{ literal 0 HcmV?d00001 diff --git a/admin/controllers/index.html b/admin/compiler/joomla_4/index.html similarity index 100% rename from admin/controllers/index.html rename to admin/compiler/joomla_4/index.html diff --git a/admin/compiler/joomla_4/install.mysql.utf8.sql b/admin/compiler/joomla_4/install.mysql.utf8.sql new file mode 100644 index 000000000..50bd3de50 --- /dev/null +++ b/admin/compiler/joomla_4/install.mysql.utf8.sql @@ -0,0 +1 @@ +###INSTALL### diff --git a/admin/compiler/joomla_4/layout.php b/admin/compiler/joomla_4/layout.php new file mode 100644 index 000000000..e5970ef27 --- /dev/null +++ b/admin/compiler/joomla_4/layout.php @@ -0,0 +1,47 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +// No direct access to this file +defined('_JEXEC') or die; + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + ###LAYOUTITEMS### +); + +$hiddenFields = $displayData->get('hidden_fields') ?: []; + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/compiler/joomla_4/layoutfull.php b/admin/compiler/joomla_4/layoutfull.php new file mode 100644 index 000000000..695619600 --- /dev/null +++ b/admin/compiler/joomla_4/layoutfull.php @@ -0,0 +1,49 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +// No direct access to this file +defined('_JEXEC') or die; + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + ###LAYOUTITEMS### +); + +$hiddenFields = $displayData->get('hidden_fields') ?: []; + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/compiler/joomla_4/layoutitems.php b/admin/compiler/joomla_4/layoutitems.php new file mode 100644 index 000000000..e5970ef27 --- /dev/null +++ b/admin/compiler/joomla_4/layoutitems.php @@ -0,0 +1,47 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +// No direct access to this file +defined('_JEXEC') or die; + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + ###LAYOUTITEMS### +); + +$hiddenFields = $displayData->get('hidden_fields') ?: []; + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/compiler/joomla_4/layoutlinkedview.php b/admin/compiler/joomla_4/layoutlinkedview.php new file mode 100644 index 000000000..92789487a --- /dev/null +++ b/admin/compiler/joomla_4/layoutlinkedview.php @@ -0,0 +1,34 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Helper\###Component###Helper; + +// No direct access to this file +defined('_JEXEC') or die; + +// set the defaults +$items = $displayData->###LAYOUTITEMS###; +$user = Factory::getApplication()->getIdentity(); +$id = $displayData->item->id; +###LAYOUTITEMSHEADER### + +?> +
+###LAYOUTITEMSTABLE### +
diff --git a/admin/compiler/joomla_4/layoutmetadata.php b/admin/compiler/joomla_4/layoutmetadata.php new file mode 100644 index 000000000..80877adb6 --- /dev/null +++ b/admin/compiler/joomla_4/layoutmetadata.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +use Joomla\CMS\Language\Text; + +// No direct access to this file +defined('_JEXEC') or die; + +$form = $displayData->getForm(); + +// JLayout for standard handling of metadata fields in the administrator content edit screens. +$fieldSets = $form->getFieldsets('metadata'); +?> + + $fieldSet) : ?> + description) && trim($fieldSet->description)) : ?> +

escape(Text::_($fieldSet->description)); ?>

+ + + renderField('metadesc'); + echo $form->renderField('metakey'); + } + + foreach ($form->getFieldset($name) as $field) + { + if ($field->name != 'jform[metadata][tags][]') + { + echo $field->renderField(); + } + } ?> + diff --git a/admin/compiler/joomla_4/layoutpublished.php b/admin/compiler/joomla_4/layoutpublished.php new file mode 100644 index 000000000..e5970ef27 --- /dev/null +++ b/admin/compiler/joomla_4/layoutpublished.php @@ -0,0 +1,47 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +// No direct access to this file +defined('_JEXEC') or die; + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + ###LAYOUTITEMS### +); + +$hiddenFields = $displayData->get('hidden_fields') ?: []; + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/compiler/joomla_4/layouttitle.php b/admin/compiler/joomla_4/layouttitle.php new file mode 100644 index 000000000..becaaccda --- /dev/null +++ b/admin/compiler/joomla_4/layouttitle.php @@ -0,0 +1,57 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +// No direct access to this file +defined('_JEXEC') or die; + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: [ + ###LAYOUTITEMS### +]; + +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?> + +
+ diff --git a/admin/compiler/joomla_4/module_forms.js b/admin/compiler/joomla_4/module_forms.js new file mode 100644 index 000000000..4bf5019bf --- /dev/null +++ b/admin/compiler/joomla_4/module_forms.js @@ -0,0 +1,3 @@ +###BOM### + +###VIEW_SCRIPT### diff --git a/admin/compiler/joomla_4/module_forms.xml b/admin/compiler/joomla_4/module_forms.xml new file mode 100644 index 000000000..bb0dcdb30 --- /dev/null +++ b/admin/compiler/joomla_4/module_forms.xml @@ -0,0 +1,12 @@ + +
+ + + + ###FIELDSETS### + + ###ACCESSCONTROL### +
\ No newline at end of file diff --git a/admin/compiler/joomla_4/settings.json b/admin/compiler/joomla_4/settings.json new file mode 100644 index 000000000..4cc56d0f4 --- /dev/null +++ b/admin/compiler/joomla_4/settings.json @@ -0,0 +1,824 @@ +{ + "create": { + "admin": { + "assets": { + "css": "css", + "images": { + "icons": "icons" + }, + "js": "js" + }, + "forms": "forms", + "language": { + "en-GB": "en-GB" + }, + "presets": "presets", + "services": "services", + "src": { + "Controller": "Controller", + "Extension": "Extension", + "Rule": "Rule", + "Field": "Field", + "Helper": "Helper", + "Model": "Model", + "Service": "Service", + "Table": "Table", + "View": "View" + }, + "sql": { + "updates": { + "mysql": "mysql" + }, + "xml": "xml" + }, + "tmpl": "tmpl" + }, + "site": { + "assets": { + "css": "css", + "images": "images", + "js": "js" + }, + "language": { + "en-GB": "en-GB" + }, + "forms": "forms", + "src": { + "Controller": "Controller", + "Dispatcher": "Dispatcher", + "Rule": "Rule", + "Field": "Field", + "Helper": "Helper", + "Model": "Model", + "Service": "Service", + "View": "View" + }, + "tmpl": "tmpl" + }, + "media": { + "css": "css", + "images": "images", + "js": "js" + } + }, + "move": { + "static": { + "ADMIN_PROVIDER.php": { + "naam": "ADMIN_PROVIDER.php", + "path": "c0mp0n3nt/admin/services", + "rename": "new", + "newName": "provider.php", + "type": "file" + }, + "ADMIN_EXTENSION_COMPONENT.php": { + "naam": "ADMIN_EXTENSION_COMPONENT.php", + "path": "c0mp0n3nt/admin/src/Extension", + "rename": "new", + "newName": "[[[Component]]]Component.php", + "type": "file" + }, + "ADMIN_DISPLAY_CONTROLLER.php": { + "naam": "ADMIN_DISPLAY_CONTROLLER.php", + "path": "c0mp0n3nt/admin/src/Controller", + "rename": "new", + "newName": "DisplayController.php", + "type": "file" + }, + "SITE_DISPLAY_CONTROLLER.php": { + "naam": "SITE_DISPLAY_CONTROLLER.php", + "path": "c0mp0n3nt/site/src/Controller", + "rename": "new", + "newName": "DisplayController.php", + "type": "file" + }, + "access.xml": { + "naam": "access.xml", + "path": "c0mp0n3nt/admin", + "rename": false, + "type": "file" + }, + "config.xml": { + "naam": "config.xml", + "path": "c0mp0n3nt/admin", + "rename": false, + "type": "file" + }, + "component.xml": { + "naam": "component.xml", + "path": "c0mp0n3nt/", + "rename": "component", + "type": "file" + }, + "admin.css": { + "naam": "admin.css", + "path": "c0mp0n3nt/admin/assets/css", + "rename": false, + "type": "file" + }, + "admin.js": { + "naam": "admin.js", + "path": "c0mp0n3nt/admin/assets/js", + "rename": false, + "type": "file" + }, + "site.css": { + "naam": "site.css", + "path": "c0mp0n3nt/site/assets/css", + "rename": false, + "type": "file" + }, + "site.js": { + "naam": "site.js", + "path": "c0mp0n3nt/site/assets/js", + "rename": false, + "type": "file" + }, + "SITE_ROUTER.php": { + "naam": "SITE_ROUTER.php", + "path": "c0mp0n3nt/site/src/Service", + "rename": "new", + "newName": "Router.php", + "type": "file" + }, + "SITE_ROUTE_HELPER.php": { + "naam": "SITE_ROUTE_HELPER.php", + "path": "c0mp0n3nt/site/src/Helper", + "rename": "new", + "newName": "RouteHelper.php", + "type": "file" + }, + "ADMIN_HELPER_CLASS.php": { + "naam": "ADMIN_HELPER_CLASS.php", + "path": "c0mp0n3nt/admin/src/Helper", + "rename": "new", + "newName": "[[[Component]]]Helper.php", + "type": "file" + }, + "SITE_HELPER_CLASS.php": { + "naam": "SITE_HELPER_CLASS.php", + "path": "c0mp0n3nt/site/src/Helper", + "rename": "new", + "newName": "[[[Component]]]Helper.php", + "type": "file" + }, + "INSTALLER_SCRIPT.php": { + "naam": "INSTALLER_SCRIPT.php", + "path": "c0mp0n3nt/", + "rename": "new", + "newName": "[[[Component]]]InstallerScript.php", + "type": "file" + }, + "SITE_DISPATCHER.php": { + "naam": "SITE_DISPATCHER.php", + "path": "c0mp0n3nt/site/src/Dispatcher", + "rename": "new", + "newName": "Dispatcher.php", + "type": "file" + }, + "install.mysql.utf8.sql": { + "naam": "install.mysql.utf8.sql", + "path": "c0mp0n3nt/admin/sql", + "rename": false, + "type": "file" + }, + "uninstall.mysql.utf8.sql": { + "naam": "uninstall.mysql.utf8.sql", + "path": "c0mp0n3nt/admin/sql", + "rename": false, + "type": "file" + }, + "ADMIN_HEADERCHECK.php": { + "naam": "ADMIN_HEADERCHECK.php", + "path": "c0mp0n3nt/admin/src/Helper", + "rename": "new", + "newName": "HeaderCheck.php", + "type": "file" + }, + "LICENSE.txt": { + "naam": "LICENSE.txt", + "path": "c0mp0n3nt/", + "rename": false, + "type": "file" + }, + "README.txt": { + "naam": "README.txt", + "path": "c0mp0n3nt/admin", + "rename": false, + "type": "file" + }, + "README.md": { + "naam": "README.md", + "path": "c0mp0n3nt/", + "rename": false, + "type": "file" + }, + "CHANGELOG.md": { + "naam": "CHANGELOG.md", + "path": "c0mp0n3nt/", + "rename": false, + "type": "file" + }, + "SITE_HEADERCHECK.php": { + "naam": "SITE_HEADERCHECK.php", + "path": "c0mp0n3nt/site/src/Helper", + "rename": "new", + "newName": "HeaderCheck.php", + "type": "file" + }, + "import.gif": { + "naam": "import.gif", + "path": "c0mp0n3nt/admin/assets/images", + "rename": false, + "type": "file" + } + }, + "dynamic": { + "admin": { + "ADMIN_HELPER_EMAIL.php": { + "naam": "ADMIN_HELPER_EMAIL.php", + "path": "c0mp0n3nt/admin/src/Helper", + "rename": "new", + "newName": "[[[Component]]]Email.php", + "type": "emailer" + }, + "DASH_CONTROLLER.php": { + "path": "c0mp0n3nt/admin/src/Controller", + "rename": "new", + "newName": "[[[Component]]]Controller.php", + "type": "dashboard" + }, + "DASH_MODEL.php": { + "path": "c0mp0n3nt/admin/src/Model", + "rename": "new", + "newName": "[[[Component]]]Model.php", + "type": "dashboard" + }, + "DASH_VIEW_HTML.php": { + "path": "c0mp0n3nt/admin/src/View/[[[Component]]]", + "rename": "new", + "newName": "HtmlView.php", + "type": "dashboard" + }, + "default_vdm.php": { + "path": "c0mp0n3nt/admin/tmpl/[[[component]]]", + "rename": false, + "type": "dashboard" + }, + "default_main.php": { + "path": "c0mp0n3nt/admin/tmpl/[[[component]]]", + "rename": false, + "type": "dashboard" + }, + "DASH_VIEW.php": { + "path": "c0mp0n3nt/admin/tmpl/[[[component]]]", + "rename": "new", + "newName": "default.php", + "type": "dashboard" + }, + "dashboard.css": { + "path": "c0mp0n3nt/admin/assets/css", + "rename": false, + "type": "dashboard" + }, + "filter_forms.xml": { + "path": "c0mp0n3nt/admin/forms", + "rename": "filter_forms", + "type": "filter" + }, + "module_forms.xml": { + "path": "c0mp0n3nt/admin/forms", + "rename": "module_forms", + "type": "single" + }, + "module_forms.js": { + "path": "c0mp0n3nt/media/js", + "rename": "module_forms", + "type": "single" + }, + "ADMIN_VIEW.php": { + "path": "c0mp0n3nt/admin/tmpl/[[[name]]]", + "rename": "new", + "newName": "default.php", + "type": "single" + }, + "ADMIN_VIEW_MODEL.php": { + "path": "c0mp0n3nt/admin/src/Model", + "rename": "new", + "newName": "[[[Name]]]Model.php", + "type": "single" + }, + "ADMIN_VIEW_CONTROLLER.php": { + "path": "c0mp0n3nt/admin/src/Controller", + "rename": "new", + "newName": "[[[Name]]]Controller.php", + "type": "single" + }, + "ADMIN_VIEW_TABLE.php": { + "path": "c0mp0n3nt/admin/src/Table", + "rename": "new", + "newName": "[[[Name]]]Table.php", + "type": "single" + }, + "ADMIN_VIEW_HTML.php": { + "path": "c0mp0n3nt/admin/src/View/[[[Name]]]", + "rename": "new", + "newName": "HtmlView.php", + "type": "single" + }, + "view.css": { + "path": "c0mp0n3nt/admin/assets/css", + "rename": "view", + "type": "single" + }, + "ADMIN_VIEWS_CONTROLLER.php": { + "path": "c0mp0n3nt/admin/src/Controller", + "rename": "new", + "newName": "[[[Name]]]Controller.php", + "type": "list" + }, + "ADMIN_VIEWS_MODEL.php": { + "path": "c0mp0n3nt/admin/src/Model", + "rename": "new", + "newName": "[[[Name]]]Model.php", + "type": "list" + }, + "views.css": { + "path": "c0mp0n3nt/admin/assets/css", + "rename": "views", + "type": "list" + }, + "ADMIN_VIEWS_HTML.php": { + "path": "c0mp0n3nt/admin/src/View/[[[Name]]]", + "rename": "new", + "newName": "HtmlView.php", + "type": "list" + }, + "ADMIN_VIEWS.php": { + "path": "c0mp0n3nt/admin/tmpl/[[[name]]]", + "rename": "new", + "newName": "default.php", + "type": "list" + }, + "ADMIN_VIEWS_EMPTYSTATE.php": { + "path": "c0mp0n3nt/admin/tmpl/[[[name]]]", + "rename": "new", + "newName": "emptystate.php", + "type": "list" + }, + "default_toolbar.php": { + "path": "c0mp0n3nt/admin/tmpl/[[[name]]]", + "rename": false, + "type": "list" + }, + "default_head.php": { + "path": "c0mp0n3nt/admin/tmpl/[[[name]]]", + "rename": false, + "type": "list" + }, + "default_body.php": { + "path": "c0mp0n3nt/admin/tmpl/[[[name]]]", + "rename": false, + "type": "list" + }, + "default_foot.php": { + "path": "c0mp0n3nt/admin/tmpl/[[[name]]]", + "rename": false, + "type": "list" + }, + "FORM_RULE.php": { + "path": "c0mp0n3nt/admin/src/Rule", + "rename": "new", + "newName": "[[[Key]]]Rule.php", + "type": "rule" + }, + "ADMIN_LAYOUT.php": { + "path": "c0mp0n3nt/admin/layouts", + "rename": "ADMIN_LAYOUT", + "type": "layout" + }, + "LAYOUT_OVERRIDE.php": { + "path": "c0mp0n3nt/admin/layouts/[[[name]]]", + "rename": "LAYOUT_OVERRIDE", + "type": "layoutoverride" + }, + "layoutitems.php": { + "path": "c0mp0n3nt/admin/layouts/[[[name]]]", + "rename": "layoutitems", + "type": "layoutitems" + }, + "layoutfull.php": { + "path": "c0mp0n3nt/admin/layouts/[[[name]]]", + "rename": "layoutfull", + "type": "layoutfull" + }, + "layoutlinkedview.php": { + "path": "c0mp0n3nt/admin/layouts/[[[name]]]", + "rename": "layoutlinkedview", + "type": "layoutlinkedview" + }, + "layouttitle.php": { + "path": "c0mp0n3nt/admin/layouts/[[[name]]]", + "rename": "layouttitle", + "type": "layouttitle" + }, + "layoutpublished.php": { + "path": "c0mp0n3nt/admin/layouts/[[[name]]]", + "rename": "layoutpublished", + "type": "layoutpublished" + }, + "layoutmetadata.php": { + "path": "c0mp0n3nt/admin/layouts/[[[name]]]", + "rename": "layoutmetadata", + "type": "layoutmetadata" + }, + "FORM_CUSTOM_FIELD.php": { + "path": "c0mp0n3nt/admin/src/Field", + "rename": "new", + "newName": "[[[Key]]]Field.php", + "type": "fieldcustom" + }, + "FORM_LIST_FIELD.php": { + "path": "c0mp0n3nt/admin/src/Field", + "rename": "new", + "newName": "[[[Key]]]Field.php", + "type": "fieldlist" + }, + "FORM_RADIO_FIELD.php": { + "path": "c0mp0n3nt/admin/src/Field", + "rename": "new", + "newName": "[[[Key]]]Field.php", + "type": "fieldradio" + }, + "FORM_CHECKBOXES_FIELD.php": { + "path": "c0mp0n3nt/admin/src/Field", + "rename": "new", + "newName": "[[[Key]]]Field.php", + "type": "fieldcheckboxes" + }, + "FORM_USER_FIELD.php": { + "path": "c0mp0n3nt/admin/src/Field", + "rename": "new", + "newName": "[[[Key]]]Field.php", + "type": "fielduser" + }, + "ADMIN_AJAX_CONTROLLER.php": { + "path": "c0mp0n3nt/admin/src/Controller", + "rename": "new", + "newName": "AjaxController.php", + "type": "ajax" + }, + "ADMIN_AJAX_MODEL.php": { + "path": "c0mp0n3nt/admin/src/Model", + "rename": "new", + "newName": "AjaxModel.php", + "type": "ajax" + }, + "ADMIN_IMPORT_CONTROLLER.php": { + "path": "c0mp0n3nt/admin/src/Controller", + "rename": "new", + "newName": "ImportController.php", + "type": "import" + }, + "ADMIN_IMPORT_MODEL.php": { + "path": "c0mp0n3nt/admin/src/Model", + "rename": "new", + "newName": "ImportModel.php", + "type": "import" + }, + "ADMIN_IMPORT_HTML.php": { + "path": "c0mp0n3nt/admin/src/View/Import", + "rename": "new", + "newName": "HtmlView.php", + "type": "import" + }, + "default_import.php": { + "path": "c0mp0n3nt/admin/tmpl/import", + "rename": "new", + "newName": "default.php", + "type": "import" + }, + "ADMIN_IMPORT_CONTROLLER_CUSTOM.php": { + "path": "c0mp0n3nt/admin/src/Controller", + "rename": "new", + "newName": "[[[Name]]]importController.php", + "type": "customimport" + }, + "ADMIN_IMPORT_MODEL_CUSTOM.php": { + "path": "c0mp0n3nt/admin/src/Model", + "rename": "new", + "newName": "[[[Name]]]importModel.php", + "type": "customimport" + }, + "ADMIN_IMPORT_HTML_CUSTOM.php": { + "path": "c0mp0n3nt/admin/src/View/[[[Name]]]import", + "rename": "new", + "newName": "HtmlView.php", + "type": "customimport" + }, + "default_import_custom.php": { + "path": "c0mp0n3nt/admin/tmpl/[[[name]]]import", + "rename": "new", + "newName": "default.php", + "type": "customimport" + }, + "ADMIN_HELPER_CONTROLLER.php": { + "path": "c0mp0n3nt/admin/src/Controller", + "rename": "new", + "newName": "HelpController.php", + "type": "help" + }, + "1.0.0.sql": { + "path": "c0mp0n3nt/admin/sql/updates/mysql", + "rename": "1.0.0", + "type": "sql_update" + }, + "update_server.xml": { + "path": "c0mp0n3nt/", + "rename": "update_server", + "type": "update_server" + }, + "viewFile.js": { + "path": "c0mp0n3nt/admin/assets/js", + "rename": "viewFile", + "type": "javascript_file" + } + }, + "site": { + "SITE_VIEWS_HTML.php": { + "path": "c0mp0n3nt/site/src/View/[[[Name]]]", + "rename": "new", + "newName": "HtmlView.php", + "type": "list" + }, + "SITE_VIEWS_MODEL.php": { + "path": "c0mp0n3nt/site/src/Model", + "rename": "new", + "newName": "[[[Name]]]Model.php", + "type": "list" + }, + "views_site.css": { + "path": "c0mp0n3nt/site/assets/css", + "rename": "views_site", + "type": "list" + }, + "SITE_VIEWS.php": { + "path": "c0mp0n3nt/site/tmpl/[[[name]]]", + "rename": "new", + "newName": "default.php", + "type": "list" + }, + "SITE_VIEW_HTML.php": { + "path": "c0mp0n3nt/site/src/View/[[[Name]]]", + "rename": "new", + "newName": "HtmlView.php", + "type": "single" + }, + "view_site.css": { + "path": "c0mp0n3nt/site/assets/css", + "rename": "view_site", + "type": "single" + }, + "SITE_VIEW_MODEL.php": { + "path": "c0mp0n3nt/site/src/Model", + "rename": "new", + "newName": "[[[Name]]]Model.php", + "type": "single" + }, + "SITE_VIEW.php": { + "path": "c0mp0n3nt/site/tmpl/[[[name]]]", + "rename": "new", + "newName": "default.php", + "type": "single" + }, + "default_site_template.php": { + "path": "c0mp0n3nt/site/tmpl/[[[name]]]", + "rename": "site_template", + "type": "template" + }, + "SITE_LAYOUT.php": { + "path": "c0mp0n3nt/site/layouts", + "rename": "SITE_LAYOUT", + "type": "layout" + }, + "LAYOUT_OVERRIDE.php": { + "path": "c0mp0n3nt/site/layouts/[[[name]]]", + "rename": "LAYOUT_OVERRIDE", + "type": "layoutoverride" + }, + "layoutitems.php": { + "path": "c0mp0n3nt/site/layouts/[[[name]]]", + "rename": "layoutitems", + "type": "layoutitems" + }, + "layoutfull.php": { + "path": "c0mp0n3nt/site/layouts/[[[name]]]", + "rename": "layoutfull", + "type": "layoutfull" + }, + "layoutlinkedview.php": { + "path": "c0mp0n3nt/site/layouts/[[[name]]]", + "rename": "layoutlinkedview", + "type": "layoutlinkedview" + }, + "layouttitle.php": { + "path": "c0mp0n3nt/site/layouts/[[[name]]]", + "rename": "layouttitle", + "type": "layouttitle" + }, + "layoutpublished.php": { + "path": "c0mp0n3nt/site/layouts/[[[name]]]", + "rename": "layoutpublished", + "type": "layoutpublished" + }, + "layoutmetadata.php": { + "path": "c0mp0n3nt/site/layouts/[[[name]]]", + "rename": "layoutmetadata", + "type": "layoutmetadata" + }, + "default.xml": { + "path": "c0mp0n3nt/site/tmpl/[[[name]]]", + "rename": false, + "type": "menu" + }, + "edit.xml": { + "path": "c0mp0n3nt/site/tmpl/[[[name]]]", + "rename": false, + "type": "admin_menu" + }, + "module_forms.xml": { + "path": "c0mp0n3nt/site/forms", + "rename": "module_forms", + "type": "edit" + }, + "module_forms.js": { + "path": "c0mp0n3nt/site/forms", + "rename": "module_forms", + "type": "edit" + }, + "SITE_ADMIN_VIEW.php": { + "path": "c0mp0n3nt/site/tmpl/[[[name]]]", + "rename": "new", + "newName": "edit.php", + "type": "edit" + }, + "SITE_ADMIN_VIEW_MODEL.php": { + "path": "c0mp0n3nt/site/src/Model", + "rename": "new", + "newName": "[[[Name]]]Model.php", + "type": "edit" + }, + "SITE_ADMIN_VIEW_CONTROLLER.php": { + "path": "c0mp0n3nt/site/src/Controller", + "rename": "new", + "newName": "[[[Name]]]Controller.php", + "type": "edit" + }, + "SITE_ADMIN_VIEW_HTML.php": { + "path": "c0mp0n3nt/site/src/View/[[[Name]]]", + "rename": "new", + "newName": "HtmlView.php", + "type": "edit" + }, + "view_site_edit.css": { + "path": "c0mp0n3nt/site/assets/css", + "rename": "view_site_edit", + "type": "edit" + }, + "SITE_FORM_CUSTOM_FIELD.php": { + "path": "c0mp0n3nt/site/src/Field", + "rename": "new", + "newName": "[[[Key]]]Field.php", + "type": "fieldcustom" + }, + "SITE_FORM_LIST_FIELD.php": { + "path": "c0mp0n3nt/site/src/Field", + "rename": "new", + "newName": "[[[Key]]]Field.php", + "type": "fieldlist" + }, + "SITE_FORM_RADIO_FIELD.php": { + "path": "c0mp0n3nt/site/src/Field", + "rename": "new", + "newName": "[[[Key]]]Field.php", + "type": "fieldradio" + }, + "SITE_FORM_CHECKBOXES_FIELD.php": { + "path": "c0mp0n3nt/site/src/Field", + "rename": "new", + "newName": "[[[Key]]]Field.php", + "type": "fieldcheckboxes" + }, + "SITE_FORM_USER_FIELD.php": { + "path": "c0mp0n3nt/site/src/Field", + "rename": "new", + "newName": "[[[Key]]]Field.php", + "type": "fielduser" + }, + "SITE_AJAX_CONTROLLER.php": { + "path": "c0mp0n3nt/site/src/Controller", + "rename": "new", + "newName": "AjaxController.php", + "type": "ajax" + }, + "SITE_AJAX_MODEL.php": { + "path": "c0mp0n3nt/site/src/Model", + "rename": "new", + "newName": "AjaxModel.php", + "type": "ajax" + }, + "SITE_HELPER_CONTROLLER.php": { + "path": "c0mp0n3nt/site/src/Controller", + "rename": "new", + "newName": "HelpController.php", + "type": "help" + }, + "SITE_VIEW_CONTROLLER.php": { + "path": "c0mp0n3nt/site/src/Controller", + "rename": "new", + "newName": "[[[Name]]]Controller.php", + "type": "custom_form" + }, + "viewFileSite.js": { + "path": "c0mp0n3nt/site/assets/js", + "rename": "viewFileSite", + "type": "javascript_file" + } + }, + "custom_admin": { + "CUSTOM_ADMIN_VIEWS_HTML.php": { + "path": "c0mp0n3nt/admin/src/View/[[[Name]]]", + "rename": "new", + "newName": "HtmlView.php", + "type": "list" + }, + "CUSTOM_ADMIN_VIEWS_MODEL.php": { + "path": "c0mp0n3nt/admin/src/Model", + "rename": "new", + "newName": "[[[Name]]]Model.php", + "type": "list" + }, + "CUSTOM_ADMIN_VIEWS.php": { + "path": "c0mp0n3nt/admin/tmpl/[[[name]]]", + "rename": "new", + "newName": "default.php", + "type": "list" + }, + "CUSTOM_ADMIN_VIEWS_CONTROLLER.php": { + "path": "c0mp0n3nt/admin/src/Controller", + "rename": "new", + "newName": "[[[Name]]]Controller.php", + "type": "list" + }, + "views_custom_admin.css": { + "path": "c0mp0n3nt/admin/assets/css", + "rename": "views_custom_admin", + "type": "list" + }, + "view_custom_admin.css": { + "path": "c0mp0n3nt/admin/assets/css", + "rename": "view_custom_admin", + "type": "single" + }, + "CUSTOM_ADMIN_VIEW_HTML.php": { + "path": "c0mp0n3nt/admin/src/View/[[[Name]]]", + "rename": "new", + "newName": "HtmlView.php", + "type": "single" + }, + "CUSTOM_ADMIN_VIEW_MODEL.php": { + "path": "c0mp0n3nt/admin/src/Model", + "rename": "new", + "newName": "[[[Name]]]Model.php", + "type": "single" + }, + "CUSTOM_ADMIN_VIEW.php": { + "path": "c0mp0n3nt/admin/tmpl/[[[name]]]", + "rename": "new", + "newName": "default.php", + "type": "single" + }, + "CUSTOM_ADMIN_VIEW_CONTROLLER.php": { + "path": "c0mp0n3nt/admin/src/Controller", + "rename": "new", + "newName": "[[[Name]]]Controller.php", + "type": "single" + }, + "default_custom_admin_template.php": { + "path": "c0mp0n3nt/admin/tmpl/[[[name]]]", + "rename": "custom_admin_template", + "type": "template" + }, + "CUSTOM_ADMIN_LAYOUT.php": { + "path": "c0mp0n3nt/admin/layouts", + "rename": "CUSTOM_ADMIN_LAYOUT", + "type": "layout" + }, + "viewFileCustomAdmin.js": { + "path": "c0mp0n3nt/admin/assets/js", + "rename": "viewFileCustomAdmin", + "type": "javascript_file" + } + } + } + } +} \ No newline at end of file diff --git a/admin/compiler/joomla_4/site.css b/admin/compiler/joomla_4/site.css new file mode 100644 index 000000000..b26522089 --- /dev/null +++ b/admin/compiler/joomla_4/site.css @@ -0,0 +1,7 @@ +###BOM### + +/* CSS Document */ +.no-click { + pointer-events: none; +} +###SITECSS### diff --git a/admin/compiler/joomla_4/site.js b/admin/compiler/joomla_4/site.js new file mode 100644 index 000000000..813632b9a --- /dev/null +++ b/admin/compiler/joomla_4/site.js @@ -0,0 +1,4 @@ +###BOM### + +/* JS Document */ +###SITEJS### \ No newline at end of file diff --git a/admin/compiler/joomla_4/submitbutton.js b/admin/compiler/joomla_4/submitbutton.js new file mode 100644 index 000000000..cd10493cd --- /dev/null +++ b/admin/compiler/joomla_4/submitbutton.js @@ -0,0 +1,17 @@ +###BOM### + +Joomla.submitbutton = function(task) +{ + if (task == ''){ + return false; + } else { + var action = task.split('.'); + if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ + Joomla.submitform(task, document.getElementById("adminForm")); + return true; + } else { + alert(Joomla.JText._('###view###, some values are not acceptable.','Some values are unacceptable')); + return false; + } + } +} \ No newline at end of file diff --git a/admin/compiler/joomla_4/submitbutton_site.js b/admin/compiler/joomla_4/submitbutton_site.js new file mode 100644 index 000000000..40938b445 --- /dev/null +++ b/admin/compiler/joomla_4/submitbutton_site.js @@ -0,0 +1,17 @@ +###BOM### + +Joomla.submitbutton = function(task) +{ + if (task == ''){ + return false; + } else { + var action = task.split('.'); + if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ + Joomla.submitform(task, document.getElementById("adminForm")); + return true; + } else { + alert(Joomla.JText._('###sview###, some values are not acceptable.','Some values are unacceptable')); + return false; + } + } +} \ No newline at end of file diff --git a/admin/compiler/joomla_4/uninstall.mysql.utf8.sql b/admin/compiler/joomla_4/uninstall.mysql.utf8.sql new file mode 100644 index 000000000..b8b61a080 --- /dev/null +++ b/admin/compiler/joomla_4/uninstall.mysql.utf8.sql @@ -0,0 +1 @@ +###UNINSTALL### diff --git a/admin/compiler/joomla_4/update_server.xml b/admin/compiler/joomla_4/update_server.xml new file mode 100644 index 000000000..8120c1923 --- /dev/null +++ b/admin/compiler/joomla_4/update_server.xml @@ -0,0 +1 @@ +###UPDATE_SERVER_XML### \ No newline at end of file diff --git a/admin/compiler/joomla_4/view.css b/admin/compiler/joomla_4/view.css new file mode 100644 index 000000000..4144e5a3c --- /dev/null +++ b/admin/compiler/joomla_4/view.css @@ -0,0 +1,5 @@ +###BOM### + +/* CSS Document */ + +###VIEWCSS### diff --git a/admin/compiler/joomla_4/viewFile.js b/admin/compiler/joomla_4/viewFile.js new file mode 100644 index 000000000..d855708a8 --- /dev/null +++ b/admin/compiler/joomla_4/viewFile.js @@ -0,0 +1,4 @@ +###BOM### + +/* JS Document */ +###ADMIN_JAVASCRIPT_FILE### \ No newline at end of file diff --git a/admin/compiler/joomla_4/viewFileCustomAdmin.js b/admin/compiler/joomla_4/viewFileCustomAdmin.js new file mode 100644 index 000000000..8abce3885 --- /dev/null +++ b/admin/compiler/joomla_4/viewFileCustomAdmin.js @@ -0,0 +1,4 @@ +###BOM### + +/* JS Document */ +###CUSTOM_ADMIN_JAVASCRIPT_FILE### \ No newline at end of file diff --git a/admin/compiler/joomla_4/viewFileSite.js b/admin/compiler/joomla_4/viewFileSite.js new file mode 100644 index 000000000..12ed97db2 --- /dev/null +++ b/admin/compiler/joomla_4/viewFileSite.js @@ -0,0 +1,4 @@ +###BOM### + +/* JS Document */ +###SITE_JAVASCRIPT_FILE### \ No newline at end of file diff --git a/admin/compiler/joomla_4/view_custom_admin.css b/admin/compiler/joomla_4/view_custom_admin.css new file mode 100644 index 000000000..291066442 --- /dev/null +++ b/admin/compiler/joomla_4/view_custom_admin.css @@ -0,0 +1,5 @@ +###BOM### + +/* CSS Document */ + +###CUSTOM_ADMIN_VIEWCSS### diff --git a/admin/compiler/joomla_4/view_site.css b/admin/compiler/joomla_4/view_site.css new file mode 100644 index 000000000..17a8824ae --- /dev/null +++ b/admin/compiler/joomla_4/view_site.css @@ -0,0 +1,5 @@ +###BOM### + +/* CSS Document */ + +###SITE_VIEWCSS### diff --git a/admin/compiler/joomla_4/view_site_edit.css b/admin/compiler/joomla_4/view_site_edit.css new file mode 100644 index 000000000..17a8824ae --- /dev/null +++ b/admin/compiler/joomla_4/view_site_edit.css @@ -0,0 +1,5 @@ +###BOM### + +/* CSS Document */ + +###SITE_VIEWCSS### diff --git a/admin/compiler/joomla_4/views.css b/admin/compiler/joomla_4/views.css new file mode 100644 index 000000000..d79fcb92b --- /dev/null +++ b/admin/compiler/joomla_4/views.css @@ -0,0 +1,5 @@ +###BOM### + +/* CSS Document */ + +###VIEWSCSS### diff --git a/admin/compiler/joomla_4/views_custom_admin.css b/admin/compiler/joomla_4/views_custom_admin.css new file mode 100644 index 000000000..291066442 --- /dev/null +++ b/admin/compiler/joomla_4/views_custom_admin.css @@ -0,0 +1,5 @@ +###BOM### + +/* CSS Document */ + +###CUSTOM_ADMIN_VIEWCSS### diff --git a/admin/compiler/joomla_4/views_site.css b/admin/compiler/joomla_4/views_site.css new file mode 100644 index 000000000..17a8824ae --- /dev/null +++ b/admin/compiler/joomla_4/views_site.css @@ -0,0 +1,5 @@ +###BOM### + +/* CSS Document */ + +###SITE_VIEWCSS### diff --git a/admin/compiler/joomla_4/whmcs.php b/admin/compiler/joomla_4/whmcs.php new file mode 100644 index 000000000..ac7524f0e --- /dev/null +++ b/admin/compiler/joomla_4/whmcs.php @@ -0,0 +1,20 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this JCB template file (EVER) +defined('_JCB_TEMPLATE') or die; +?> +###BOM### + +// No direct access to this file +defined('_JEXEC') or die; + +// NO MORE... \ No newline at end of file diff --git a/admin/compiler/joomla_basic.txt b/admin/compiler/joomla_basic.txt new file mode 100644 index 000000000..334deedc4 --- /dev/null +++ b/admin/compiler/joomla_basic.txt @@ -0,0 +1,10 @@ +/** + * @package ###Component_name### + * + * @created ###CREATIONDATE### + * @author ###AUTHOR### <###AUTHORWEBSITE###> + * @copyright ###COPYRIGHT### + * @license ###LICENSE### + * + * ###SHORT_DESCRIPTION### + */ \ No newline at end of file diff --git a/admin/componentbuilder.php b/admin/componentbuilder.php deleted file mode 100644 index 53857eff6..000000000 --- a/admin/componentbuilder.php +++ /dev/null @@ -1,98 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// add the autoloader for the composer classes -$composer_autoloader = JPATH_LIBRARIES . '/phpseclib3/vendor/autoload.php'; -if (file_exists($composer_autoloader)) -{ - require_once $composer_autoloader; -} - -// register this component namespace -spl_autoload_register(function ($class) { - // project-specific base directories and namespace prefix - $search = [ - 'libraries/jcb_powers/VDM.Joomla.Openai' => 'VDM\\Joomla\\Openai', - 'libraries/jcb_powers/VDM.Joomla.Gitea' => 'VDM\\Joomla\\Gitea', - 'libraries/jcb_powers/VDM.Joomla.FOF' => 'VDM\\Joomla\\FOF', - 'libraries/jcb_powers/VDM.Joomla' => 'VDM\\Joomla', - 'libraries/jcb_powers/VDM.Minify' => 'VDM\\Minify', - 'libraries/jcb_powers/VDM.Psr' => 'VDM\\Psr' - ]; - // Start the search and load if found - $found = false; - $found_base_dir = ""; - $found_len = 0; - foreach ($search as $base_dir => $prefix) - { - // does the class use the namespace prefix? - $len = strlen($prefix); - if (strncmp($prefix, $class, $len) === 0) - { - // we have a match so load the values - $found = true; - $found_base_dir = $base_dir; - $found_len = $len; - // done here - break; - } - } - // check if we found a match - if (!$found) - { - // not found so move to the next registered autoloader - return; - } - // get the relative class name - $relative_class = substr($class, $found_len); - // replace the namespace prefix with the base directory, replace namespace - // separators with directory separators in the relative class name, append - // with .php - $file = JPATH_ROOT . '/' . $found_base_dir . '/src' . str_replace('\\', '/', $relative_class) . '.php'; - // if the file exists, require it - if (file_exists($file)) - { - require $file; - } -}); - - - -// Access check. -if (!JFactory::getUser()->authorise('core.manage', 'com_componentbuilder')) -{ - throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); -}; - -// Add CSS file for all pages -$document = JFactory::getDocument(); -$document->addStyleSheet('components/com_componentbuilder/assets/css/admin.css'); -$document->addScript('components/com_componentbuilder/assets/js/admin.js'); - -// require helper files -JLoader::register('ComponentbuilderHelper', __DIR__ . '/helpers/componentbuilder.php'); -JLoader::register('ComponentbuilderEmail', JPATH_COMPONENT_ADMINISTRATOR . '/helpers/componentbuilderemail.php'); -JLoader::register('JHtmlBatch_', __DIR__ . '/helpers/html/batch_.php'); - -// Trigger the Global Admin Event -ComponentbuilderHelper::globalEvent($document); - -// Get an instance of the controller prefixed by Componentbuilder -$controller = JControllerLegacy::getInstance('Componentbuilder'); - -// Perform the Request task -$controller->execute(JFactory::getApplication()->input->get('task')); - -// Redirect if set by the controller -$controller->redirect(); diff --git a/admin/config.xml b/admin/config.xml index 75fbfed59..2b817ab66 100644 --- a/admin/config.xml +++ b/admin/config.xml @@ -1,8 +1,8 @@
@@ -970,6 +970,24 @@ /> + + + + COM_COMPONENTBUILDER_CONFIG_NO - - + + @@ -1012,8 +1030,8 @@ max="100" step="10" /> - - + + - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\BaseController; -use Joomla\Utilities\ArrayHelper; - -/** - * General Controller of Componentbuilder component - */ -class ComponentbuilderController extends BaseController -{ - /** - * Constructor. - * - * @param array $config An optional associative array of configuration settings. - * Recognized key values include 'name', 'default_task', 'model_path', and - * 'view_path' (this list is not meant to be comprehensive). - * - * @since 3.0 - */ - public function __construct($config = array()) - { - // set the default view - $config['default_view'] = 'componentbuilder'; - - parent::__construct($config); - } - - /** - * display task - * - * @return void - */ - function display($cachable = false, $urlparams = false) - { - // set default view if not set - $view = $this->input->getCmd('view', 'componentbuilder'); - $data = $this->getViewRelation($view); - $layout = $this->input->get('layout', null, 'WORD'); - $id = $this->input->getInt('id'); - - // Check for edit form. - if(ComponentbuilderHelper::checkArray($data)) - { - if ($data['edit'] && $layout == 'edit' && !$this->checkEditId('com_componentbuilder.edit.'.$data['view'], $id)) - { - // Somehow the person just went to the form - we don't allow that. - $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); - $this->setMessage($this->getError(), 'error'); - // check if item was opend from other then its own list view - $ref = $this->input->getCmd('ref', 0); - $refid = $this->input->getInt('refid', 0); - // set redirect - if ($refid > 0 && ComponentbuilderHelper::checkString($ref)) - { - // redirect to item of ref - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view='.(string)$ref.'&layout=edit&id='.(int)$refid, false)); - } - elseif (ComponentbuilderHelper::checkString($ref)) - { - - // redirect to ref - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view='.(string)$ref, false)); - } - else - { - // normal redirect back to the list view - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view='.$data['views'], false)); - } - - return false; - } - } - - return parent::display($cachable, $urlparams); - } - - protected function getViewRelation($view) - { - // check the we have a value - if (ComponentbuilderHelper::checkString($view)) - { - // the view relationships - $views = array( - 'joomla_component' => 'joomla_components', - 'joomla_module' => 'joomla_modules', - 'joomla_plugin' => 'joomla_plugins', - 'power' => 'powers', - 'admin_view' => 'admin_views', - 'custom_admin_view' => 'custom_admin_views', - 'site_view' => 'site_views', - 'template' => 'templates', - 'layout' => 'layouts', - 'dynamic_get' => 'dynamic_gets', - 'custom_code' => 'custom_codes', - 'class_property' => 'class_properties', - 'class_method' => 'class_methods', - 'placeholder' => 'placeholders', - 'library' => 'libraries', - 'snippet' => 'snippets', - 'validation_rule' => 'validation_rules', - 'field' => 'fields', - 'fieldtype' => 'fieldtypes', - 'language_translation' => 'language_translations', - 'language' => 'languages', - 'server' => 'servers', - 'help_document' => 'help_documents', - 'admin_fields' => 'admins_fields', - 'admin_fields_conditions' => 'admins_fields_conditions', - 'admin_fields_relations' => 'admins_fields_relations', - 'admin_custom_tabs' => 'admins_custom_tabs', - 'component_admin_views' => 'components_admin_views', - 'component_site_views' => 'components_site_views', - 'component_custom_admin_views' => 'components_custom_admin_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', - 'component_placeholders' => 'components_placeholders', - 'component_plugins' => 'components_plugins', - 'component_modules' => 'components_modules', - 'snippet_type' => 'snippet_types', - 'library_config' => 'libraries_config', - 'library_files_folders_urls' => 'libraries_files_folders_urls', - 'class_extends' => 'class_extendings', - 'joomla_module_updates' => 'joomla_modules_updates', - 'joomla_module_files_folders_urls' => 'joomla_modules_files_folders_urls', - 'joomla_plugin_group' => 'joomla_plugin_groups', - 'joomla_plugin_updates' => 'joomla_plugins_updates', - 'joomla_plugin_files_folders_urls' => 'joomla_plugins_files_folders_urls' - ); - // check if this is a list view - if (in_array($view, $views)) - { - // this is a list view - return array('edit' => false, 'view' => array_search($view,$views), 'views' => $view); - } - // check if it is an edit view - elseif (array_key_exists($view, $views)) - { - // this is a edit view - return array('edit' => true, 'view' => $view, 'views' => $views[$view]); - } - } - return false; - } -} diff --git a/admin/controllers/admin_custom_tabs.php b/admin/controllers/admin_custom_tabs.php deleted file mode 100644 index 51f8b1d9e..000000000 --- a/admin/controllers/admin_custom_tabs.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Admin_custom_tabs Form Controller - */ -class ComponentbuilderControllerAdmin_custom_tabs extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Admins_custom_tabs'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('admin_custom_tabs.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('admin_custom_tabs.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('admin_custom_tabs.access', 'com_componentbuilder.admin_custom_tabs.' . (int) $recordId) && $user->authorise('admin_custom_tabs.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('admin_custom_tabs.edit', 'com_componentbuilder.admin_custom_tabs.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('admin_custom_tabs.edit.own', 'com_componentbuilder.admin_custom_tabs.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('admin_custom_tabs.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('admin_custom_tabs.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Admin_custom_tabs', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=admins_custom_tabs' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/admin_fields.php b/admin/controllers/admin_fields.php deleted file mode 100644 index 89e3cb48b..000000000 --- a/admin/controllers/admin_fields.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Admin_fields Form Controller - */ -class ComponentbuilderControllerAdmin_fields extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Admins_fields'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('admin_fields.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('admin_fields.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('admin_fields.access', 'com_componentbuilder.admin_fields.' . (int) $recordId) && $user->authorise('admin_fields.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('admin_fields.edit', 'com_componentbuilder.admin_fields.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('admin_fields.edit.own', 'com_componentbuilder.admin_fields.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('admin_fields.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('admin_fields.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Admin_fields', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=admins_fields' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/admin_fields_conditions.php b/admin/controllers/admin_fields_conditions.php deleted file mode 100644 index f5034ec93..000000000 --- a/admin/controllers/admin_fields_conditions.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Admin_fields_conditions Form Controller - */ -class ComponentbuilderControllerAdmin_fields_conditions extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Admins_fields_conditions'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('admin_fields_conditions.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('admin_fields_conditions.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('admin_fields_conditions.access', 'com_componentbuilder.admin_fields_conditions.' . (int) $recordId) && $user->authorise('admin_fields_conditions.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('admin_fields_conditions.edit', 'com_componentbuilder.admin_fields_conditions.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('admin_fields_conditions.edit.own', 'com_componentbuilder.admin_fields_conditions.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('admin_fields_conditions.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('admin_fields_conditions.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Admin_fields_conditions', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=admins_fields_conditions' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/admin_fields_relations.php b/admin/controllers/admin_fields_relations.php deleted file mode 100644 index dbc285ddd..000000000 --- a/admin/controllers/admin_fields_relations.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Admin_fields_relations Form Controller - */ -class ComponentbuilderControllerAdmin_fields_relations extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Admins_fields_relations'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('admin_fields_relations.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('admin_fields_relations.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('admin_fields_relations.access', 'com_componentbuilder.admin_fields_relations.' . (int) $recordId) && $user->authorise('admin_fields_relations.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('admin_fields_relations.edit', 'com_componentbuilder.admin_fields_relations.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('admin_fields_relations.edit.own', 'com_componentbuilder.admin_fields_relations.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('admin_fields_relations.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('admin_fields_relations.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Admin_fields_relations', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=admins_fields_relations' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/admin_view.php b/admin/controllers/admin_view.php deleted file mode 100644 index daa98d2be..000000000 --- a/admin/controllers/admin_view.php +++ /dev/null @@ -1,351 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Admin_view Form Controller - */ -class ComponentbuilderControllerAdmin_view extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Admin_views'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('admin_view.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('admin_view.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('admin_view.access', 'com_componentbuilder.admin_view.' . (int) $recordId) && $user->authorise('admin_view.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('admin_view.edit', 'com_componentbuilder.admin_view.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('admin_view.edit.own', 'com_componentbuilder.admin_view.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('admin_view.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('admin_view.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Admin_view', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=admin_views' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - // get the state object (Joomla\CMS\Object\CMSObject) - $state = $model->get('state'); - // if we save2copy we need to also copy linked tables found! - if ($state->task === 'save2copy' && $state->{'admin_view.new'}) - { - // get new ID - $newID = $state->{'admin_view.id'}; - // get old ID - $oldID = $this->input->get('id', 0, 'INT'); - // linked tables to update - $_tablesArray = array( - 'admin_fields', - 'admin_fields_conditions', - 'admin_fields_relations', - 'admin_custom_tabs' - ); - foreach($_tablesArray as $_updateTable) - { - // get the linked ID - if ($_value = ComponentbuilderHelper::getVar($_updateTable, $oldID, 'admin_view', 'id')) - { - // copy fields to new admin view - ComponentbuilderHelper::copyItem(/*id->*/ $_value, /*table->*/ $_updateTable, /*change->*/ array('admin_view' => $newID)); - } - } - } - - return; - } - -} diff --git a/admin/controllers/admin_views.php b/admin/controllers/admin_views.php deleted file mode 100644 index 4bd01f895..000000000 --- a/admin/controllers/admin_views.php +++ /dev/null @@ -1,151 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\StringHelper; - -/** - * Admin_views Admin Controller - */ -class ComponentbuilderControllerAdmin_views extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_ADMIN_VIEWS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Admin_view', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('admin_view.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - $pks = ArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Admin_views'); - // get the data to export - $data = $model->getExportData($pks); - if (ComponentbuilderHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - ComponentbuilderHelper::xls($data,'Admin_views_'.$date->format('jS_F_Y'),'Admin views exported ('.$date->format('jS F, Y').')','admin views'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=admin_views', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('admin_view.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - // Get the import model - $model = $this->getModel('Admin_views'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (ComponentbuilderHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('admin_view_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'admin_views'); - $session->set('dataType_VDM_IMPORTINTO', 'admin_view'); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_ADMIN_VIEWS'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=admin_views', false), $message, 'error'); - return; - } - - - /** - * Run the Expansion - * - * @return void - */ - public function runExpansion() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - // check if user has the right - $user = JFactory::getUser(); - // set page redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=admin_views', false); - // set massage - $message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE'); - // check if this user has the right to run expansion - if($user->authorise('admin_views.run_expansion', 'com_componentbuilder')) - { - // set massage - $message = JText::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB'); - // run expansion via API - $result = ComponentbuilderHelper::getFileContents(JURI::root() . 'index.php?option=com_componentbuilder&task=api.expand'); - // is there a message returned - if (!is_numeric($result) && StringHelper::check($result)) - { - $this->setRedirect($redirect_url, $result); - return true; - } - elseif (is_numeric($result) && 1 == $result) - { - $message = JText::_('COM_COMPONENTBUILDER_BTHE_EXPANSION_WAS_SUCCESSFULLYB_TO_SEE_MORE_INFORMATION_CHANGE_THE_BRETURN_OPTIONS_FOR_BUILDB_TO_BDISPLAY_MESSAGEB_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TABB'); - $this->setRedirect($redirect_url, $message, 'message'); - return true; - } - } - $this->setRedirect($redirect_url, $message, 'error'); - return false; - } - -} \ No newline at end of file diff --git a/admin/controllers/admins_custom_tabs.php b/admin/controllers/admins_custom_tabs.php deleted file mode 100644 index 790c6e069..000000000 --- a/admin/controllers/admins_custom_tabs.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Admins_custom_tabs Admin Controller - */ -class ComponentbuilderControllerAdmins_custom_tabs extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_ADMINS_CUSTOM_TABS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Admin_custom_tabs', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/admins_fields.php b/admin/controllers/admins_fields.php deleted file mode 100644 index cf77f2fba..000000000 --- a/admin/controllers/admins_fields.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Admins_fields Admin Controller - */ -class ComponentbuilderControllerAdmins_fields extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_ADMINS_FIELDS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Admin_fields', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/admins_fields_conditions.php b/admin/controllers/admins_fields_conditions.php deleted file mode 100644 index 9a54b55a1..000000000 --- a/admin/controllers/admins_fields_conditions.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Admins_fields_conditions Admin Controller - */ -class ComponentbuilderControllerAdmins_fields_conditions extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_ADMINS_FIELDS_CONDITIONS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Admin_fields_conditions', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/admins_fields_relations.php b/admin/controllers/admins_fields_relations.php deleted file mode 100644 index 2a3804873..000000000 --- a/admin/controllers/admins_fields_relations.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Admins_fields_relations Admin Controller - */ -class ComponentbuilderControllerAdmins_fields_relations extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_ADMINS_FIELDS_RELATIONS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Admin_fields_relations', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/ajax.json.php b/admin/controllers/ajax.json.php deleted file mode 100644 index e27dd76da..000000000 --- a/admin/controllers/ajax.json.php +++ /dev/null @@ -1,2017 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\BaseController; -use Joomla\Utilities\ArrayHelper; - -/** - * Componentbuilder Ajax Base Controller - */ -class ComponentbuilderControllerAjax extends BaseController -{ - public function __construct($config) - { - parent::__construct($config); - // make sure all json stuff are set - JFactory::getDocument()->setMimeEncoding( 'application/json' ); - // get the application - $app = JFactory::getApplication(); - $app->setHeader('Content-Disposition','attachment;filename="getajax.json"'); - $app->setHeader('Access-Control-Allow-Origin', '*'); - // load the tasks - $this->registerTask('isNew', 'ajax'); - $this->registerTask('isRead', 'ajax'); - $this->registerTask('getComponentDetails', 'ajax'); - $this->registerTask('getCronPath', 'ajax'); - $this->registerTask('getWiki', 'ajax'); - $this->registerTask('getVersion', 'ajax'); - $this->registerTask('getJCBpackageInfo', 'ajax'); - $this->registerTask('getCrowdinDetails', 'ajax'); - $this->registerTask('getModuleCode', 'ajax'); - $this->registerTask('getClassCode', 'ajax'); - $this->registerTask('getClassCodeIds', 'ajax'); - $this->registerTask('getClassHeaderCode', 'ajax'); - $this->registerTask('tableColumns', 'ajax'); - $this->registerTask('fieldSelectOptions', 'ajax'); - $this->registerTask('getDynamicScripts', 'ajax'); - $this->registerTask('getButton', 'ajax'); - $this->registerTask('getButtonID', 'ajax'); - $this->registerTask('getAjaxDisplay', 'ajax'); - $this->registerTask('getLinked', 'ajax'); - $this->registerTask('checkAliasField', 'ajax'); - $this->registerTask('checkCategoryField', 'ajax'); - $this->registerTask('templateDetails', 'ajax'); - $this->registerTask('getLayoutDetails', 'ajax'); - $this->registerTask('dbTableColumns', 'ajax'); - $this->registerTask('viewTableColumns', 'ajax'); - $this->registerTask('getDynamicValues', 'ajax'); - $this->registerTask('checkFunctionName', 'ajax'); - $this->registerTask('usedin', 'ajax'); - $this->registerTask('getEditCustomCodeButtons', 'ajax'); - $this->registerTask('placedin', 'ajax'); - $this->registerTask('checkPlaceholderName', 'ajax'); - $this->registerTask('getExistingValidationRuleCode', 'ajax'); - $this->registerTask('getValidationRulesTable', 'ajax'); - $this->registerTask('checkRuleName', 'ajax'); - $this->registerTask('fieldTypeProperties', 'ajax'); - $this->registerTask('getFieldPropertyDesc', 'ajax'); - $this->registerTask('getCodeGlueOptions', 'ajax'); - $this->registerTask('doSearch', 'ajax'); - $this->registerTask('replaceAll', 'ajax'); - $this->registerTask('getSearchValue', 'ajax'); - $this->registerTask('getReplaceValue', 'ajax'); - $this->registerTask('setValue', 'ajax'); - $this->registerTask('snippetDetails', 'ajax'); - $this->registerTask('setSnippetGithub', 'ajax'); - $this->registerTask('getSnippets', 'ajax'); - } - - public function ajax() - { - // get the user for later use - $user = JFactory::getUser(); - // get the input values - $jinput = JFactory::getApplication()->input; - // check if we should return raw - $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); - // return to a callback function - $callback = $jinput->get('callback', null, 'CMD'); - // Check Token! - $token = JSession::getFormToken(); - $call_token = $jinput->get('token', 0, 'ALNUM'); - if($jinput->get($token, 0, 'ALNUM') || $token === $call_token) - { - // get the task - $task = $this->getTask(); - switch($task) - { - case 'isNew': - try - { - $noticeValue = $jinput->get('notice', NULL, 'STRING'); - if($noticeValue && $user->id != 0) - { - $result = $this->getModel('ajax')->isNew($noticeValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'isRead': - try - { - $noticeValue = $jinput->get('notice', NULL, 'STRING'); - if($noticeValue && $user->id != 0) - { - $result = $this->getModel('ajax')->isRead($noticeValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getComponentDetails': - try - { - $idValue = $jinput->get('id', NULL, 'INT'); - if($idValue && $user->id != 0) - { - $result = $this->getModel('ajax')->getComponentDetails($idValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getCronPath': - try - { - $getTypeValue = $jinput->get('getType', NULL, 'WORD'); - if($getTypeValue && $user->id != 0) - { - $result = $this->getModel('ajax')->getCronPath($getTypeValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getWiki': - try - { - $nameValue = $jinput->get('name', NULL, 'WORD'); - if($nameValue && $user->id != 0) - { - $result = $this->getModel('ajax')->getWiki($nameValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getVersion': - try - { - $versionValue = $jinput->get('version', NULL, 'INT'); - if($versionValue && $user->id != 0) - { - $result = $this->getModel('ajax')->getVersion($versionValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getJCBpackageInfo': - try - { - $packageValue = $jinput->get('package', NULL, 'BASE64'); - if($packageValue && $user->id != 0) - { - $result = $this->getModel('ajax')->getJCBpackageInfo($packageValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getCrowdinDetails': - try - { - $identifierValue = $jinput->get('identifier', NULL, 'CMD'); - $keyValue = $jinput->get('key', NULL, 'ALNUM'); - if($identifierValue && $user->id != 0 && $keyValue) - { - $result = $this->getModel('ajax')->getCrowdinDetails($identifierValue, $keyValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getModuleCode': - try - { - $dataValue = $jinput->get('data', NULL, 'STRING'); - if($dataValue && $user->id != 0) - { - $result = $this->getModel('ajax')->getModuleCode($dataValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getClassCode': - try - { - $idValue = $jinput->get('id', NULL, 'INT'); - $typeValue = $jinput->get('type', NULL, 'WORD'); - if($idValue && $user->id != 0 && $typeValue) - { - $result = $this->getModel('ajax')->getClassCode($idValue, $typeValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getClassCodeIds': - try - { - $idValue = $jinput->get('id', NULL, 'INT'); - $typeValue = $jinput->get('type', NULL, 'WORD'); - $keyValue = $jinput->get('key', 1, 'INT'); - if($idValue && $user->id != 0 && $typeValue) - { - $result = $this->getModel('ajax')->getClassCodeIds($idValue, $typeValue, $keyValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getClassHeaderCode': - try - { - $idValue = $jinput->get('id', NULL, 'INT'); - $typeValue = $jinput->get('type', NULL, 'WORD'); - if($idValue && $user->id != 0 && $typeValue) - { - $result = $this->getModel('ajax')->getClassHeaderCode($idValue, $typeValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'tableColumns': - try - { - $tableValue = $jinput->get('table', NULL, 'WORD'); - if($tableValue && $user->id != 0) - { - $result = $this->getModel('ajax')->getTableColumns($tableValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'fieldSelectOptions': - try - { - $idValue = $jinput->get('id', NULL, 'INT'); - if($idValue && $user->id != 0) - { - $result = $this->getModel('ajax')->getFieldSelectOptions($idValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getDynamicScripts': - try - { - $typeValue = $jinput->get('type', NULL, 'WORD'); - if($typeValue && $user->id != 0) - { - $result = $this->getModel('ajax')->getDynamicScripts($typeValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getButton': - try - { - $typeValue = $jinput->get('type', NULL, 'WORD'); - $sizeValue = $jinput->get('size', NULL, 'INT'); - if($typeValue && $user->id != 0 && $sizeValue) - { - $result = $this->getModel('ajax')->getButton($typeValue, $sizeValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getButtonID': - try - { - $typeValue = $jinput->get('type', NULL, 'WORD'); - $sizeValue = $jinput->get('size', NULL, 'INT'); - if($typeValue && $user->id != 0 && $sizeValue) - { - $result = $this->getModel('ajax')->getButtonID($typeValue, $sizeValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getAjaxDisplay': - try - { - $typeValue = $jinput->get('type', NULL, 'WORD'); - if($typeValue && $user->id != 0) - { - $result = $this->getModel('ajax')->getAjaxDisplay($typeValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getLinked': - try - { - $typeValue = $jinput->get('type', NULL, 'ALNUM'); - if($typeValue && $user->id != 0) - { - $result = $this->getModel('ajax')->getLinked($typeValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'checkAliasField': - try - { - $typeValue = $jinput->get('type', NULL, 'ALNUM'); - if($typeValue && $user->id != 0) - { - $result = $this->getModel('ajax')->checkAliasField($typeValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'checkCategoryField': - try - { - $typeValue = $jinput->get('type', NULL, 'ALNUM'); - if($typeValue && $user->id != 0) - { - $result = $this->getModel('ajax')->checkCategoryField($typeValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'templateDetails': - try - { - $idValue = $jinput->get('id', null, 'INT'); - if($idValue && $user->id != 0) - { - $result = $this->getModel('ajax')->getTemplateDetails($idValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getLayoutDetails': - try - { - $idValue = $jinput->get('id', NULL, 'INT'); - if($idValue && $user->id != 0) - { - $result = $this->getModel('ajax')->getLayoutDetails($idValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'dbTableColumns': - try - { - $nameValue = $jinput->get('name', NULL, 'WORD'); - $asValue = $jinput->get('as', NULL, 'WORD'); - $typeValue = $jinput->get('type', NULL, 'INT'); - if($nameValue && $user->id != 0 && $asValue && $typeValue) - { - $result = $this->getModel('ajax')->getDbTableColumns($nameValue, $asValue, $typeValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'viewTableColumns': - try - { - $idValue = $jinput->get('id', NULL, 'INT'); - $asValue = $jinput->get('as', NULL, 'WORD'); - $typeValue = $jinput->get('type', NULL, 'INT'); - if($idValue && $user->id != 0 && $asValue && $typeValue) - { - $result = $this->getModel('ajax')->getViewTableColumns($idValue, $asValue, $typeValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getDynamicValues': - try - { - $idValue = $jinput->get('id', NULL, 'INT'); - $viewValue = $jinput->get('view', NULL, 'WORD'); - if($idValue && $user->id != 0 && $viewValue) - { - $result = $this->getModel('ajax')->getDynamicValues($idValue, $viewValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'checkFunctionName': - try - { - $functioNameValue = $jinput->get('functioName', NULL, 'STRING'); - $idValue = $jinput->get('id', NULL, 'INT'); - if($functioNameValue && $user->id != 0 && $idValue) - { - $result = $this->getModel('ajax')->checkFunctionName($functioNameValue, $idValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'usedin': - try - { - $functioNameValue = $jinput->get('functioName', NULL, 'WORD'); - $idValue = $jinput->get('id', NULL, 'INT'); - $targetValue = $jinput->get('target', NULL, 'WORD'); - if($functioNameValue && $user->id != 0 && $idValue && $targetValue) - { - $result = $this->getModel('ajax')->usedin($functioNameValue, $idValue, $targetValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getEditCustomCodeButtons': - try - { - $idValue = $jinput->get('id', NULL, 'INT'); - if($idValue && $user->id != 0) - { - $result = $this->getModel('ajax')->getEditCustomCodeButtons($idValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'placedin': - try - { - $placeholderValue = $jinput->get('placeholder', NULL, 'WORD'); - $idValue = $jinput->get('id', NULL, 'INT'); - $targetValue = $jinput->get('target', NULL, 'WORD'); - if($placeholderValue && $user->id != 0 && $idValue && $targetValue) - { - $result = $this->getModel('ajax')->placedin($placeholderValue, $idValue, $targetValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'checkPlaceholderName': - try - { - $idValue = $jinput->get('id', NULL, 'INT'); - $placeholderNameValue = $jinput->get('placeholderName', NULL, 'STRING'); - if($idValue && $user->id != 0 && $placeholderNameValue) - { - $result = $this->getModel('ajax')->checkPlaceholderName($idValue, $placeholderNameValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getExistingValidationRuleCode': - try - { - $nameValue = $jinput->get('name', NULL, 'WORD'); - if($nameValue && $user->id != 0) - { - $result = $this->getModel('ajax')->getExistingValidationRuleCode($nameValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getValidationRulesTable': - try - { - $idValue = $jinput->get('id', NULL, 'INT'); - if($idValue && $user->id != 0) - { - $result = $this->getModel('ajax')->getValidationRulesTable($idValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'checkRuleName': - try - { - $nameValue = $jinput->get('name', NULL, 'STRING'); - $idValue = $jinput->get('id', NULL, 'INT'); - if($nameValue && $user->id != 0 && $idValue) - { - $result = $this->getModel('ajax')->checkRuleName($nameValue, $idValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'fieldTypeProperties': - try - { - $idValue = $jinput->get('id', NULL, 'INT'); - if($idValue) - { - $result = $this->getModel('ajax')->getFieldTypeProperties($idValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getFieldPropertyDesc': - try - { - $propertyValue = $jinput->get('property', NULL, 'WORD'); - $fieldtypeValue = $jinput->get('fieldtype', NULL, 'ALNUM'); - if($propertyValue && $user->id != 0 && $fieldtypeValue) - { - $result = $this->getModel('ajax')->getFieldPropertyDesc($propertyValue, $fieldtypeValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getCodeGlueOptions': - try - { - $listfieldValue = $jinput->get('listfield', NULL, 'INT'); - $joinfieldsValue = $jinput->get('joinfields', NULL, 'STRING'); - $typeValue = $jinput->get('type', NULL, 'INT'); - $areaValue = $jinput->get('area', NULL, 'INT'); - if($listfieldValue && $user->id != 0 && $joinfieldsValue && $typeValue && $areaValue) - { - $result = $this->getModel('ajax')->getCodeGlueOptions($listfieldValue, $joinfieldsValue, $typeValue, $areaValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'doSearch': - try - { - $table_nameValue = $jinput->get('table_name', NULL, 'WORD'); - $type_searchValue = $jinput->get('type_search', 1, 'INT'); - $search_valueValue = $jinput->get('search_value', NULL, 'RAW'); - $match_caseValue = $jinput->get('match_case', 0, 'INT'); - $whole_wordValue = $jinput->get('whole_word', 0, 'INT'); - $regex_searchValue = $jinput->get('regex_search', 0, 'INT'); - $component_idValue = $jinput->get('component_id', 0, 'INT'); - if($table_nameValue && $user->id != 0 && $type_searchValue && $search_valueValue) - { - $result = $this->getModel('ajax')->doSearch($table_nameValue, $type_searchValue, $search_valueValue, $match_caseValue, $whole_wordValue, $regex_searchValue, $component_idValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'replaceAll': - try - { - $table_nameValue = $jinput->get('table_name', NULL, 'WORD'); - $search_valueValue = $jinput->get('search_value', NULL, 'RAW'); - $replace_valueValue = $jinput->get('replace_value', NULL, 'RAW'); - $match_caseValue = $jinput->get('match_case', 0, 'INT'); - $whole_wordValue = $jinput->get('whole_word', 0, 'INT'); - $regex_searchValue = $jinput->get('regex_search', 0, 'INT'); - $component_idValue = $jinput->get('component_id', 0, 'INT'); - if($table_nameValue && $user->id != 0 && $search_valueValue) - { - $result = $this->getModel('ajax')->replaceAll($table_nameValue, $search_valueValue, $replace_valueValue, $match_caseValue, $whole_wordValue, $regex_searchValue, $component_idValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getSearchValue': - try - { - $field_nameValue = $jinput->get('field_name', NULL, 'WORD'); - $row_idValue = $jinput->get('row_id', NULL, 'INT'); - $table_nameValue = $jinput->get('table_name', NULL, 'WORD'); - $search_valueValue = $jinput->get('search_value', NULL, 'RAW'); - $replace_valueValue = $jinput->get('replace_value', NULL, 'RAW'); - $match_caseValue = $jinput->get('match_case', 0, 'INT'); - $whole_wordValue = $jinput->get('whole_word', 0, 'INT'); - $regex_searchValue = $jinput->get('regex_search', 0, 'INT'); - if($field_nameValue && $user->id != 0 && $row_idValue && $table_nameValue && $search_valueValue) - { - $result = $this->getModel('ajax')->getSearchValue($field_nameValue, $row_idValue, $table_nameValue, $search_valueValue, $replace_valueValue, $match_caseValue, $whole_wordValue, $regex_searchValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getReplaceValue': - try - { - $field_nameValue = $jinput->get('field_name', NULL, 'WORD'); - $row_idValue = $jinput->get('row_id', NULL, 'INT'); - $line_nrValue = $jinput->get('line_nr', 0, 'STRING'); - $table_nameValue = $jinput->get('table_name', NULL, 'WORD'); - $search_valueValue = $jinput->get('search_value', NULL, 'RAW'); - $replace_valueValue = $jinput->get('replace_value', NULL, 'RAW'); - $match_caseValue = $jinput->get('match_case', 0, 'INT'); - $whole_wordValue = $jinput->get('whole_word', 0, 'INT'); - $regex_searchValue = $jinput->get('regex_search', 0, 'INT'); - if($field_nameValue && $user->id != 0 && $row_idValue && $table_nameValue && $search_valueValue) - { - $result = $this->getModel('ajax')->getReplaceValue($field_nameValue, $row_idValue, $line_nrValue, $table_nameValue, $search_valueValue, $replace_valueValue, $match_caseValue, $whole_wordValue, $regex_searchValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'setValue': - try - { - $valueValue = $jinput->get('value', NULL, 'RAW'); - $row_idValue = $jinput->get('row_id', NULL, 'INT'); - $field_nameValue = $jinput->get('field_name', NULL, 'WORD'); - $table_nameValue = $jinput->get('table_name', NULL, 'WORD'); - if($valueValue && $user->id != 0 && $row_idValue && $field_nameValue && $table_nameValue) - { - $result = $this->getModel('ajax')->setValue($valueValue, $row_idValue, $field_nameValue, $table_nameValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'snippetDetails': - try - { - $idValue = $jinput->get('id', NULL, 'INT'); - if($idValue && $user->id != 0) - { - $result = $this->getModel('ajax')->getSnippetDetails($idValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'setSnippetGithub': - try - { - $pathValue = $jinput->get('path', NULL, 'STRING'); - $statusValue = $jinput->get('status', NULL, 'WORD'); - if($pathValue && $user->id != 0 && $statusValue) - { - $result = $this->getModel('ajax')->setSnippetGithub($pathValue, $statusValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - case 'getSnippets': - try - { - $librariesValue = $jinput->get('libraries', NULL, 'STRING'); - if($librariesValue && $user->id != 0) - { - $result = $this->getModel('ajax')->getSnippets($librariesValue); - } - else - { - $result = false; - } - if($callback) - { - echo $callback . "(".json_encode($result).");"; - } - elseif($returnRaw) - { - echo json_encode($result); - } - else - { - echo "(".json_encode($result).");"; - } - } - catch(Exception $e) - { - if($callback) - { - echo $callback."(".json_encode($e).");"; - } - elseif($returnRaw) - { - echo json_encode($e); - } - else - { - echo "(".json_encode($e).");"; - } - } - break; - } - } - else - { - // return to a callback function - if($callback) - { - echo $callback."(".json_encode(false).");"; - } - elseif($returnRaw) - { - echo json_encode(false); - } - else - { - echo "(".json_encode(false).");"; - } - } - } -} diff --git a/admin/controllers/class_extendings.php b/admin/controllers/class_extendings.php deleted file mode 100644 index db9896b75..000000000 --- a/admin/controllers/class_extendings.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Class_extendings Admin Controller - */ -class ComponentbuilderControllerClass_extendings extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_CLASS_EXTENDINGS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Class_extends', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/class_extends.php b/admin/controllers/class_extends.php deleted file mode 100644 index 5926cf210..000000000 --- a/admin/controllers/class_extends.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Class_extends Form Controller - */ -class ComponentbuilderControllerClass_extends extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Class_extendings'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('class_extends.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('class_extends.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('class_extends.access', 'com_componentbuilder.class_extends.' . (int) $recordId) && $user->authorise('class_extends.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('class_extends.edit', 'com_componentbuilder.class_extends.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('class_extends.edit.own', 'com_componentbuilder.class_extends.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('class_extends.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('class_extends.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Class_extends', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=class_extendings' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/class_method.php b/admin/controllers/class_method.php deleted file mode 100644 index 1f492caaa..000000000 --- a/admin/controllers/class_method.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Class_method Form Controller - */ -class ComponentbuilderControllerClass_method extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Class_methods'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('class_method.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('class_method.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('class_method.access', 'com_componentbuilder.class_method.' . (int) $recordId) && $user->authorise('class_method.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('class_method.edit', 'com_componentbuilder.class_method.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('class_method.edit.own', 'com_componentbuilder.class_method.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('class_method.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('class_method.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Class_method', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=class_methods' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/class_methods.php b/admin/controllers/class_methods.php deleted file mode 100644 index eb8a7660b..000000000 --- a/admin/controllers/class_methods.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Class_methods Admin Controller - */ -class ComponentbuilderControllerClass_methods extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_CLASS_METHODS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Class_method', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('class_method.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - $pks = ArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Class_methods'); - // get the data to export - $data = $model->getExportData($pks); - if (ComponentbuilderHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - ComponentbuilderHelper::xls($data,'Class_methods_'.$date->format('jS_F_Y'),'Class methods exported ('.$date->format('jS F, Y').')','class methods'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=class_methods', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('class_method.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - // Get the import model - $model = $this->getModel('Class_methods'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (ComponentbuilderHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('class_method_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'class_methods'); - $session->set('dataType_VDM_IMPORTINTO', 'class_method'); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_CLASS_METHODS'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=class_methods', false), $message, 'error'); - return; - } -} \ No newline at end of file diff --git a/admin/controllers/class_properties.php b/admin/controllers/class_properties.php deleted file mode 100644 index 76242b346..000000000 --- a/admin/controllers/class_properties.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Class_properties Admin Controller - */ -class ComponentbuilderControllerClass_properties extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_CLASS_PROPERTIES'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Class_property', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('class_property.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - $pks = ArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Class_properties'); - // get the data to export - $data = $model->getExportData($pks); - if (ComponentbuilderHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - ComponentbuilderHelper::xls($data,'Class_properties_'.$date->format('jS_F_Y'),'Class properties exported ('.$date->format('jS F, Y').')','class properties'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=class_properties', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('class_property.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - // Get the import model - $model = $this->getModel('Class_properties'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (ComponentbuilderHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('class_property_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'class_properties'); - $session->set('dataType_VDM_IMPORTINTO', 'class_property'); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_CLASS_PROPERTIES'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=class_properties', false), $message, 'error'); - return; - } -} \ No newline at end of file diff --git a/admin/controllers/class_property.php b/admin/controllers/class_property.php deleted file mode 100644 index 8729a395e..000000000 --- a/admin/controllers/class_property.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Class_property Form Controller - */ -class ComponentbuilderControllerClass_property extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Class_properties'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('class_property.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('class_property.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('class_property.access', 'com_componentbuilder.class_property.' . (int) $recordId) && $user->authorise('class_property.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('class_property.edit', 'com_componentbuilder.class_property.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('class_property.edit.own', 'com_componentbuilder.class_property.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('class_property.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('class_property.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Class_property', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=class_properties' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/compiler.php b/admin/controllers/compiler.php deleted file mode 100644 index 1314e6d02..000000000 --- a/admin/controllers/compiler.php +++ /dev/null @@ -1,630 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory; -use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; -use VDM\Joomla\Utilities\StringHelper; - -/** - * Compiler Admin Controller - */ -class ComponentbuilderControllerCompiler extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_COMPILER'; - - /** - * Proxy for getModel. - * @since 2.5 - */ - public function getModel($name = 'Compiler', $prefix = 'ComponentbuilderModel', $config = array()) - { - $model = parent::getModel($name, $prefix, array('ignore_request' => true)); - - return $model; - } - - public function dashboard() - { - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder', false)); - return; - } - - /** - * get all the animations used in the compiler - * - * @return true on success - */ - public function getDynamicContent() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - // check if user has the right - $user = JFactory::getUser(); - // set page redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=compiler', false); - $message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_DOWNLOAD_THE_COMPILER_ANIMATIONS'); - // currently only those with permissions can get these images - if($user->authorise('compiler.compiler_animations', 'com_componentbuilder')) - { - // get the model - $model = $this->getModel('compiler'); - if ($model->getDynamicContent($message)) - { - $message = JText::_('COM_COMPONENTBUILDER_BALL_THE_COMPILER_ANIMATIONS_WERE_SUCCESSFULLY_DOWNLOADED_TO_THIS_JOOMLA_INSTALLB'); - $this->setRedirect($redirect_url, $message, 'message'); - return true; - } - } - $this->setRedirect($redirect_url, $message, 'error'); - return false; - } - - /** - * Run the Compiler - * - * @return true on success - */ - public function compiler() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - // check if user has the right - $user = JFactory::getUser(); - // currently only those with admin access can compile a component - if($user->authorise('core.manage', 'com_componentbuilder')) - { - // include component compiler - require_once JPATH_ADMINISTRATOR.'/components/com_componentbuilder/helpers/compiler.php'; - $model = $this->getModel('compiler'); - if ($model->builder()) - { - $cache = JFactory::getCache('mod_menu'); - $cache->clean(); - // TODO: Reset the users acl here as well to kill off any missing bits - } - else - { - return false; - } - - // switch to set multi install button - $add_multi_install = false; - $add_plugin_install = false; - $add_module_install = false; - // get application - $app = JFactory::getApplication(); - // set redirection URL - $redirect_url = $app->getUserState('com_componentbuilder.redirect_url'); - // get system messages - $message = $app->getUserState('com_componentbuilder.message'); - if (empty($redirect_url) && CFactory::_('Config')->component_id > 0) - { - // start new message - $message = array(); - // update the redirection URL - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=compiler', false); - if (($pos = strpos($model->compiler->filepath['component'], "/tmp/")) !== FALSE) - { - $url = JURI::root() . substr($model->compiler->filepath['component'], $pos + 1); - } - // check if we have plugins - $add_plugin_install = UtilitiesArrayHelper::check($model->compiler->filepath['plugins'], true); - // check if we have modules - $add_module_install = UtilitiesArrayHelper::check($model->compiler->filepath['modules'], true); - // if a multi install we set another kind of header - if ($add_plugin_install || $add_module_install) - { - // Message of successful builds - $message[] = '

The Extensions were Successfully Compiled!

'; - $message[] = '

You can install any one of the following extensions!

'; - // set multi install - $add_multi_install = true; - } - else - { - // Message of successful build - $message[] = '

The (' . $model->compiler->filepath['component-folder'] . ') was Successfully Compiled!

'; - } - $message[] = '

'; - // check if we have modules - if ($add_module_install) - { - foreach ($model->compiler->filepath['modules-folder'] as $module_id => $module_folder) - { - $message[] = '

'; - } - } - // check if we have plugins - if ($add_plugin_install) - { - foreach ($model->compiler->filepath['plugins-folder'] as $plugin_id => $plugin_folder) - { - $message[] = '

'; - } - } - // set multi install button - if ($add_multi_install) - { - $message[] = '

You can install all compiled extensions!

'; - $message[] = '

'; - } - $message[] = '

Total time saved

'; - $message[] = '
    '; - $message[] = '
  • Total folders created: #'.'##FOLDER_COUNT##'.'#
  • '; - $message[] = '
  • Total files created: #'.'##FILE_COUNT##'.'#
  • '; - $message[] = '
  • Total fields created: #'.'##FIELD_COUNT##'.'#
  • '; - $message[] = '
  • Total lines written: #'.'##LINE_COUNT##'.'#
  • '; - $message[] = '
  • A4 Book of: #'.'##PAGE_COUNT##'.'# pages
  • '; - $message[] = '
'; - $message[] = '

#'.'##totalHours##'.'# Hours or #'.'##totalDays##'.'# Eight Hour Days (actual time you saved)
'; - $message[] = '(if creating a folder and file took 5 seconds and writing one line of code took 10 seconds, never making one mistake or taking any coffee break.)
'; - $message[] = '#'.'##actualHoursSpent##'.'# Hours or #'.'##actualDaysSpent##'.'# Eight Hour Days (the actual time you spent)
'; - $message[] = '(with the following break down: debugging @#'.'##debuggingHours##'.'#hours = codingtime / 4; planning @#'.'##planningHours##'.'#hours = codingtime / 7; mapping @#'.'##mappingHours##'.'#hours = codingtime / 10; office @#'.'##officeHours##'.'#hours = codingtime / 6;)

'; - $message[] = '

#'.'##actualTotalHours##'.'# Hours or #'.'##actualTotalDays##'.'# Eight Hour Days (a total of the realistic time frame for this project)
'; - $message[] = '(if creating a folder and file took 5 seconds and writing one line of code took 10 seconds, with the normal everyday realities at the office, that includes the component planning, mapping & debugging.)

'; - $message[] = '

Project duration: '.$model->compiler->projectWeekTime. ' weeks or #'.'##projectMonthTime##'.'# months

'; - // check if we have modules or plugins - if ($add_multi_install) - { - $message[] = '

Path to Zip Files

'; - $message[] = '

Component Path: ' . $model->compiler->filepath['component'] . '
'; - $message[] = 'Component URL: ' . $url . '

'; - // load modules if found - if ($add_module_install) - { - $module_urls = array(); - // load the modules path/url - foreach ($model->compiler->filepath['modules'] as $module_id => $module_path) - { - // set module path - $message[] = 'Module Path: ' . $module_path . '
'; - if (($pos = strpos($module_path, "/tmp/")) !== FALSE) - { - $module_urls[$module_id] = JURI::root() . substr($module_path, $pos + 1); - $message[] = 'Module URL: ' . $module_urls[$module_id] . '
'; - } - } - } - // load plugins if found - if ($add_plugin_install) - { - $plugin_urls = array(); - // load the plugins path/url - foreach ($model->compiler->filepath['plugins'] as $plugin_id => $plugin_path) - { - // set plugin path - $message[] = 'Plugin Path: ' . $plugin_path . '
'; - if (($pos = strpos($plugin_path, "/tmp/")) !== FALSE) - { - $plugin_urls[$plugin_id] = JURI::root() . substr($plugin_path, $pos + 1); - $message[] = 'Plugin URL: ' . $plugin_urls[$plugin_id] . '
'; - } - } - } - $message[] = '
Hey! you can also download these zip files right now!
'; - $message[] = 'Download Component  '; - // load the module download URL's - if (isset($module_urls) && UtilitiesArrayHelper::check($module_urls)) - { - foreach ($module_urls as $module_id => $module_url) - { - $message[] = ' '; - $message[] = 'Download ' . $model->compiler->filepath['modules-folder'][$module_id] . '  '; - } - } - // load the plugin download URL's - if (isset($plugin_urls) && UtilitiesArrayHelper::check($plugin_urls)) - { - foreach ($plugin_urls as $plugin_id => $plugin_url) - { - $message[] = ' '; - $message[] = 'Download ' . $model->compiler->filepath['plugins-folder'][$plugin_id] . '  '; - } - } - $message[] = '

'; - $message[] = '

Remember! These zip files are in your tmp folder and therefore publicly accessible until you click [Clear tmp]!

'; - } - else - { - $message[] = '

Path to Zip File

'; - $message[] = '

Path: ' . $model->compiler->filepath['component'] . '
'; - $message[] = 'URL: ' . $url . '

'; - $message[] = 'Hey! you can also download the zip file right now!
'; - $message[] = 'Download

'; - $message[] = '

Remember! This zip file is in your tmp folder and therefore publicly accessible until you click [Clear tmp]!

'; - } - $message[] = '

Compilation took #'.'##COMPILER_TIMER##'.'# seconds to complete.

'; - // pass the message via the user state... wow this is painful - $app->setUserState('com_componentbuilder.success_message', - CFactory::_('Placeholder')->update( - implode(PHP_EOL, $message), - CFactory::_('Compiler.Builder.Content.One')->allActive() - ) - ); - // set redirect - $this->setRedirect($redirect_url, '

Successful Build!

', 'message'); - $app->setUserState('com_componentbuilder.component_folder_name', $model->compiler->filepath['component-folder']); - // check if we have modules - if ($add_module_install) - { - $app->setUserState('com_componentbuilder.modules_folder_name', $model->compiler->filepath['modules-folder']); - } - // check if we have plugins - if ($add_plugin_install) - { - $app->setUserState('com_componentbuilder.plugins_folder_name', $model->compiler->filepath['plugins-folder']); - } - } - else - { - // wipe out the user state when we're going to redirect - $app->setUserState('com_componentbuilder.redirect_url', ''); - $app->setUserState('com_componentbuilder.message', ''); - $app->setUserState('com_componentbuilder.extension_message', ''); - $app->setUserState('com_componentbuilder.component_folder_name', ''); - $app->setUserState('com_componentbuilder.modules_folder_name', ''); - $app->setUserState('com_componentbuilder.plugins_folder_name', ''); - $app->setUserState('com_componentbuilder.success_message', ''); - // set redirect - $this->setRedirect($redirect_url, $message); - } - return true; - } - return false; - } - - /** - * Install All Compiled Extensions - * - * @return true on success - */ - public function installCompiledExtensions() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - // check if user has the right - $user = JFactory::getUser(); - // set page redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=compiler', false); - $message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_INSTALL_THESE_EXTENSIONS'); - // currently only those with admin access can install a component via JCB - if($user->authorise('core.manage')) - { - $message = JText::_('COM_COMPONENTBUILDER_COULD_NOT_INSTALL_EXTENSIONS'); - $_message = array('success' => array(), 'error' => array()); - $app = JFactory::getApplication(); - // start file name array - $fileNames = array(); - $fileNames[] = $app->getUserState('com_componentbuilder.component_folder_name', null); - // check if we have modules - $fileNames = UtilitiesArrayHelper::merge(array($fileNames, $app->getUserState('com_componentbuilder.modules_folder_name', array()) )); - // check if we have plugins - $fileNames = UtilitiesArrayHelper::merge(array($fileNames, $app->getUserState('com_componentbuilder.plugins_folder_name', array()) )); - - // wipe out the user c-m-p since we are done with them all - $app->setUserState('com_componentbuilder.component_folder_name', ''); - $app->setUserState('com_componentbuilder.modules_folder_name', ''); - $app->setUserState('com_componentbuilder.plugins_folder_name', ''); - $app->setUserState('com_componentbuilder.success_message', ''); - - // loop and install all extensions found - foreach ($fileNames as $fileName) - { - if ($this->installExtension($fileName)) - { - $_message['success'][] = JText::sprintf('COM_COMPONENTBUILDER_SZIP_WAS_REMOVED_THE_FROM_TMP_FOLDER_DURING_INSTALLATION', $fileName); - } - else - { - $_message['error'][] = JText::sprintf('COM_COMPONENTBUILDER_SZIP_COULD_NOT_BE_INSTALLED', $fileName); - } - } - // catch errors - if (UtilitiesArrayHelper::check($_message['error'])) - { - $app->enqueueMessage(implode('
', $_message['error']), 'Error'); - } - // build success message - if (UtilitiesArrayHelper::check($_message['success'])) - { - $this->setRedirect($redirect_url, implode('
', $_message['success']), 'message'); - return true; - } - } - $this->setRedirect($redirect_url, $message, 'error'); - return false; - } - - /** - * Install Compiled Component - * - * @return true on success - */ - public function installCompiledComponent() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - // check if user has the right - $user = JFactory::getUser(); - // set page redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=compiler', false); - $message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_INSTALL_THE_COMPONENT'); - // currently only those with admin access can install a component via JCB - if($user->authorise('core.manage')) - { - $message = JText::_('COM_COMPONENTBUILDER_COULD_NOT_INSTALL_COMPONENT'); - $app = JFactory::getApplication(); - $fileName = $app->getUserState('com_componentbuilder.component_folder_name'); - - // wipe out the user c-m-p since we are done with them all - $app->setUserState('com_componentbuilder.component_folder_name', ''); - $app->setUserState('com_componentbuilder.modules_folder_name', ''); - $app->setUserState('com_componentbuilder.plugins_folder_name', ''); - $app->setUserState('com_componentbuilder.success_message', ''); - - if ($this->installExtension($fileName)) - { - $message = JText::sprintf('COM_COMPONENTBUILDER_ONLY_SZIP_FILE_WAS_REMOVED_THE_FROM_TMP_FOLDER_DURING_INSTALLATION', $fileName); - $this->setRedirect($redirect_url, $message, 'message'); - return true; - } - } - $this->setRedirect($redirect_url, $message, 'error'); - return false; - } - - /** - * Install Compiled Module - * - * @return true on success - */ - public function installCompiledModule() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - // check if user has the right - $user = JFactory::getUser(); - // set page redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=compiler', false); - $message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_INSTALL_THE_MODULE'); - // currently only those with admin access can install a molule via JCB - if($user->authorise('core.manage')) - { - $message = JText::_('COM_COMPONENTBUILDER_COULD_NOT_INSTALL_MODULE'); - $app = JFactory::getApplication(); - $fileNames = $app->getUserState('com_componentbuilder.modules_folder_name'); - - // wipe out the user c-m-p since we are done with them all - $app->setUserState('com_componentbuilder.component_folder_name', ''); - $app->setUserState('com_componentbuilder.modules_folder_name', ''); - $app->setUserState('com_componentbuilder.plugins_folder_name', ''); - $app->setUserState('com_componentbuilder.success_message', ''); - - if (ComponentbuilderHelper::checkArray($fileNames)) - { - $jinput = JFactory::getApplication()->input; - $moduleId = $jinput->post->get('install_item_id', 0, 'INT'); - if ($moduleId > 0 && isset($fileNames[$moduleId]) && $this->installExtension($fileNames[$moduleId])) - { - $message = JText::sprintf('COM_COMPONENTBUILDER_ONLY_SZIP_FILE_WAS_REMOVED_THE_FROM_TMP_FOLDER_DURING_INSTALLATION', $fileNames[$moduleId]); - $this->setRedirect($redirect_url, $message, 'message'); - return true; - } - } - } - $this->setRedirect($redirect_url, $message, 'error'); - return false; - } - - /** - * Install Compiled Plugin - * - * @return true on success - */ - public function installCompiledPlugin() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - // check if user has the right - $user = JFactory::getUser(); - // set page redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=compiler', false); - $message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_INSTALL_THE_PLUGIN'); - // currently only those with admin access can install a plugin via JCB - if($user->authorise('core.manage')) - { - $message = JText::_('COM_COMPONENTBUILDER_COULD_NOT_INSTALL_PLUGIN'); - $app = JFactory::getApplication(); - $fileNames = $app->getUserState('com_componentbuilder.plugins_folder_name'); - - // wipe out the user c-m-p since we are done with them all - $app->setUserState('com_componentbuilder.component_folder_name', ''); - $app->setUserState('com_componentbuilder.modules_folder_name', ''); - $app->setUserState('com_componentbuilder.plugins_folder_name', ''); - $app->setUserState('com_componentbuilder.success_message', ''); - - if (ComponentbuilderHelper::checkArray($fileNames)) - { - $jinput = JFactory::getApplication()->input; - $pluginId = $jinput->post->get('install_item_id', 0, 'INT'); - if ($pluginId > 0 && isset($fileNames[$pluginId]) && $this->installExtension($fileNames[$pluginId])) - { - $message = JText::sprintf('COM_COMPONENTBUILDER_ONLY_SZIP_FILE_WAS_REMOVED_THE_FROM_TMP_FOLDER_DURING_INSTALLATION', $fileNames[$pluginId]); - $this->setRedirect($redirect_url, $message, 'message'); - return true; - } - } - } - $this->setRedirect($redirect_url, $message, 'error'); - return false; - } - - /** - * Install Extension - * - * @return true on success - */ - protected function installExtension($fileName) - { - // check that the model is set - if (!isset($this->_compiler_model)) - { - // get the compiler model - $this->_compiler_model = $this->getModel('compiler'); - } - // set the language if not set - if (!isset($this->_installer_lang)) - { - $this->_installer_lang = JFactory::getLanguage(); - $extension = 'com_installer'; - $base_dir = JPATH_ADMINISTRATOR; - $language_tag = 'en-GB'; - $reload = true; - $this->_installer_lang->load($extension, $base_dir, $language_tag, $reload); - } - // make sure we have a string - if (ComponentbuilderHelper::checkString($fileName)) - { - return $this->_compiler_model->install($fileName.'.zip'); - } - return false; - } - - /** - * Run the Expansion - * - * @return void - */ - public function runExpansion() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - // check if user has the right - $user = JFactory::getUser(); - // set page redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=compiler', false); - // set massage - $message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE'); - // check if this user has the right to run expansion - if($user->authorise('compiler.run_expansion', 'com_componentbuilder')) - { - // set massage - $message = JText::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB'); - // run expansion via API - $result = ComponentbuilderHelper::getFileContents(JURI::root() . 'index.php?option=com_componentbuilder&task=api.expand'); - // is there a message returned - if (!is_numeric($result) && StringHelper::check($result)) - { - $this->setRedirect($redirect_url, $result); - return true; - } - elseif (is_numeric($result) && 1 == $result) - { - $message = JText::_('COM_COMPONENTBUILDER_BTHE_EXPANSION_WAS_SUCCESSFULLYB_TO_SEE_MORE_INFORMATION_CHANGE_THE_BRETURN_OPTIONS_FOR_BUILDB_TO_BDISPLAY_MESSAGEB_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TABB'); - $this->setRedirect($redirect_url, $message, 'message'); - return true; - } - } - $this->setRedirect($redirect_url, $message, 'error'); - return false; - } - - - /** - * Clear tmp folder - * - * @return true on success - */ - public function clearTmp() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - // check if user has the right - $user = JFactory::getUser(); - // set page redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=compiler', false); - $message = JText::_('COM_COMPONENTBUILDER_COULD_NOT_CLEAR_THE_TMP_FOLDER'); - if($user->authorise('compiler.clear_tmp', 'com_componentbuilder') && $user->authorise('core.manage', 'com_componentbuilder')) - { - // get the model - $model = $this->getModel('compiler'); - // get tmp folder - $comConfig = JFactory::getConfig(); - $tmp = $comConfig->get('tmp_path'); - if ($model->emptyFolder($tmp)) - { - $message = JText::_('COM_COMPONENTBUILDER_BTHE_TMP_FOLDER_HAS_BEEN_CLEAR_SUCCESSFULLYB'); - $this->setRedirect($redirect_url, $message, 'message'); - // get application - $app = JFactory::getApplication(); - // wipe out the user c-m-p since we are done with them all - $app->setUserState('com_componentbuilder.component_folder_name', ''); - $app->setUserState('com_componentbuilder.modules_folder_name', ''); - $app->setUserState('com_componentbuilder.plugins_folder_name', ''); - $app->setUserState('com_componentbuilder.success_message', ''); - - return true; - } - } - $this->setRedirect($redirect_url, $message, 'error'); - return false; - } - - - /** - * Run the Translator - * - * @return void - */ - public function runTranslator() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - // check if user has the right - $user = JFactory::getUser(); - // set page redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=compiler', false); - // set massage - $message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_TRANSLATOR_MODULE'); - // check if this user has the right to run expansion - if($user->authorise('compiler.run_translator', 'com_componentbuilder')) - { - // set massage - $message = JText::_('COM_COMPONENTBUILDER_TRANSLATION_FAILED_SINCE_THERE_ARE_NO_COMPONENTS_LINKED_WITH_TRANSLATION_TOOLS'); - // run translator via API - $result = ComponentbuilderHelper::getFileContents(JURI::root() . 'index.php?option=com_componentbuilder&task=api.translator'); - // is there a message returned - if (!is_numeric($result) && StringHelper::check($result)) - { - $this->setRedirect($redirect_url, $result); - return true; - } - } - $this->setRedirect($redirect_url, $message, 'error'); - return false; - } - -} diff --git a/admin/controllers/component_admin_views.php b/admin/controllers/component_admin_views.php deleted file mode 100644 index 9547d38b6..000000000 --- a/admin/controllers/component_admin_views.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Component_admin_views Form Controller - */ -class ComponentbuilderControllerComponent_admin_views extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Components_admin_views'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('component_admin_views.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('component_admin_views.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('component_admin_views.access', 'com_componentbuilder.component_admin_views.' . (int) $recordId) && $user->authorise('component_admin_views.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('component_admin_views.edit', 'com_componentbuilder.component_admin_views.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('component_admin_views.edit.own', 'com_componentbuilder.component_admin_views.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('component_admin_views.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('component_admin_views.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Component_admin_views', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=components_admin_views' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/component_config.php b/admin/controllers/component_config.php deleted file mode 100644 index 1f17b4a44..000000000 --- a/admin/controllers/component_config.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Component_config Form Controller - */ -class ComponentbuilderControllerComponent_config extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Components_config'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('component_config.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('component_config.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('component_config.access', 'com_componentbuilder.component_config.' . (int) $recordId) && $user->authorise('component_config.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('component_config.edit', 'com_componentbuilder.component_config.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('component_config.edit.own', 'com_componentbuilder.component_config.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('component_config.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('component_config.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Component_config', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=components_config' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/component_custom_admin_menus.php b/admin/controllers/component_custom_admin_menus.php deleted file mode 100644 index b922f0bfc..000000000 --- a/admin/controllers/component_custom_admin_menus.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Component_custom_admin_menus Form Controller - */ -class ComponentbuilderControllerComponent_custom_admin_menus extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Components_custom_admin_menus'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('component_custom_admin_menus.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('component_custom_admin_menus.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('component_custom_admin_menus.access', 'com_componentbuilder.component_custom_admin_menus.' . (int) $recordId) && $user->authorise('component_custom_admin_menus.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('component_custom_admin_menus.edit', 'com_componentbuilder.component_custom_admin_menus.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('component_custom_admin_menus.edit.own', 'com_componentbuilder.component_custom_admin_menus.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('component_custom_admin_menus.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('component_custom_admin_menus.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Component_custom_admin_menus', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=components_custom_admin_menus' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/component_custom_admin_views.php b/admin/controllers/component_custom_admin_views.php deleted file mode 100644 index 250633a03..000000000 --- a/admin/controllers/component_custom_admin_views.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Component_custom_admin_views Form Controller - */ -class ComponentbuilderControllerComponent_custom_admin_views extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Components_custom_admin_views'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('component_custom_admin_views.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('component_custom_admin_views.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('component_custom_admin_views.access', 'com_componentbuilder.component_custom_admin_views.' . (int) $recordId) && $user->authorise('component_custom_admin_views.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('component_custom_admin_views.edit', 'com_componentbuilder.component_custom_admin_views.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('component_custom_admin_views.edit.own', 'com_componentbuilder.component_custom_admin_views.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('component_custom_admin_views.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('component_custom_admin_views.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Component_custom_admin_views', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=components_custom_admin_views' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/component_dashboard.php b/admin/controllers/component_dashboard.php deleted file mode 100644 index d8bb79183..000000000 --- a/admin/controllers/component_dashboard.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Component_dashboard Form Controller - */ -class ComponentbuilderControllerComponent_dashboard extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Components_dashboard'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('component_dashboard.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('component_dashboard.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('component_dashboard.access', 'com_componentbuilder.component_dashboard.' . (int) $recordId) && $user->authorise('component_dashboard.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('component_dashboard.edit', 'com_componentbuilder.component_dashboard.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('component_dashboard.edit.own', 'com_componentbuilder.component_dashboard.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('component_dashboard.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('component_dashboard.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Component_dashboard', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=components_dashboard' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/component_files_folders.php b/admin/controllers/component_files_folders.php deleted file mode 100644 index c647375e2..000000000 --- a/admin/controllers/component_files_folders.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Component_files_folders Form Controller - */ -class ComponentbuilderControllerComponent_files_folders extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Components_files_folders'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('component_files_folders.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('component_files_folders.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('component_files_folders.access', 'com_componentbuilder.component_files_folders.' . (int) $recordId) && $user->authorise('component_files_folders.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('component_files_folders.edit', 'com_componentbuilder.component_files_folders.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('component_files_folders.edit.own', 'com_componentbuilder.component_files_folders.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('component_files_folders.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('component_files_folders.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Component_files_folders', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=components_files_folders' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/component_modules.php b/admin/controllers/component_modules.php deleted file mode 100644 index 7cbbb2097..000000000 --- a/admin/controllers/component_modules.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Component_modules Form Controller - */ -class ComponentbuilderControllerComponent_modules extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Components_modules'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('component_modules.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('component_modules.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('component_modules.access', 'com_componentbuilder.component_modules.' . (int) $recordId) && $user->authorise('component_modules.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('component_modules.edit', 'com_componentbuilder.component_modules.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('component_modules.edit.own', 'com_componentbuilder.component_modules.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('component_modules.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('component_modules.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Component_modules', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=components_modules' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/component_mysql_tweaks.php b/admin/controllers/component_mysql_tweaks.php deleted file mode 100644 index 1b7ab9801..000000000 --- a/admin/controllers/component_mysql_tweaks.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Component_mysql_tweaks Form Controller - */ -class ComponentbuilderControllerComponent_mysql_tweaks extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Components_mysql_tweaks'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('component_mysql_tweaks.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('component_mysql_tweaks.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('component_mysql_tweaks.access', 'com_componentbuilder.component_mysql_tweaks.' . (int) $recordId) && $user->authorise('component_mysql_tweaks.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('component_mysql_tweaks.edit', 'com_componentbuilder.component_mysql_tweaks.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('component_mysql_tweaks.edit.own', 'com_componentbuilder.component_mysql_tweaks.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('component_mysql_tweaks.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('component_mysql_tweaks.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Component_mysql_tweaks', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=components_mysql_tweaks' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/component_placeholders.php b/admin/controllers/component_placeholders.php deleted file mode 100644 index bfb7a4ebe..000000000 --- a/admin/controllers/component_placeholders.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Component_placeholders Form Controller - */ -class ComponentbuilderControllerComponent_placeholders extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Components_placeholders'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('component_placeholders.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('component_placeholders.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('component_placeholders.access', 'com_componentbuilder.component_placeholders.' . (int) $recordId) && $user->authorise('component_placeholders.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('component_placeholders.edit', 'com_componentbuilder.component_placeholders.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('component_placeholders.edit.own', 'com_componentbuilder.component_placeholders.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('component_placeholders.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('component_placeholders.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Component_placeholders', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=components_placeholders' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/component_plugins.php b/admin/controllers/component_plugins.php deleted file mode 100644 index d3fa83894..000000000 --- a/admin/controllers/component_plugins.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Component_plugins Form Controller - */ -class ComponentbuilderControllerComponent_plugins extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Components_plugins'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('component_plugins.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('component_plugins.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('component_plugins.access', 'com_componentbuilder.component_plugins.' . (int) $recordId) && $user->authorise('component_plugins.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('component_plugins.edit', 'com_componentbuilder.component_plugins.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('component_plugins.edit.own', 'com_componentbuilder.component_plugins.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('component_plugins.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('component_plugins.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Component_plugins', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=components_plugins' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/component_site_views.php b/admin/controllers/component_site_views.php deleted file mode 100644 index 3ecb3c6c5..000000000 --- a/admin/controllers/component_site_views.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Component_site_views Form Controller - */ -class ComponentbuilderControllerComponent_site_views extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Components_site_views'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('component_site_views.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('component_site_views.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('component_site_views.access', 'com_componentbuilder.component_site_views.' . (int) $recordId) && $user->authorise('component_site_views.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('component_site_views.edit', 'com_componentbuilder.component_site_views.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('component_site_views.edit.own', 'com_componentbuilder.component_site_views.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('component_site_views.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('component_site_views.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Component_site_views', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=components_site_views' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/component_updates.php b/admin/controllers/component_updates.php deleted file mode 100644 index dfd3b0b3d..000000000 --- a/admin/controllers/component_updates.php +++ /dev/null @@ -1,354 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; -use VDM\Joomla\Utilities\StringHelper; - -/** - * Component_updates Form Controller - */ -class ComponentbuilderControllerComponent_updates extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Components_updates'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('component_updates.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('component_updates.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('component_updates.access', 'com_componentbuilder.component_updates.' . (int) $recordId) && $user->authorise('component_updates.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('component_updates.edit', 'com_componentbuilder.component_updates.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('component_updates.edit.own', 'com_componentbuilder.component_updates.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('component_updates.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('component_updates.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Component_updates', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=components_updates' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - // update the component version to match the updated last version - if (isset($validData['joomla_component']) && is_numeric($validData['joomla_component']) && $validData['joomla_component'] > 0) - { - // we must load the data (since if changed in the saved method, the $validData will not reflect this change) - if (($version_update = ComponentbuilderHelper::getVar( - 'component_updates', - $validData['joomla_component'], - 'joomla_component', - 'version_update')) !== false) - { - $version_update = json_decode($version_update, true); - - $objectUpdate = new stdClass(); - $objectUpdate->id = (int) $validData['joomla_component']; - if (UtilitiesArrayHelper::check($version_update) - && ($component_version = end($version_update)['version']) - && StringHelper::check($component_version)) - { - $objectUpdate->component_version = $component_version; - } - // be sure to update the table if we have a value - if (isset($objectUpdate->component_version)) - { - JFactory::getDbo()->updateObject('#__componentbuilder_joomla_component', $objectUpdate, 'id'); - } - } - } - - return; - } - -} diff --git a/admin/controllers/componentbuilder.php b/admin/controllers/componentbuilder.php deleted file mode 100644 index 9c3e5cc7c..000000000 --- a/admin/controllers/componentbuilder.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Componentbuilder Admin Controller - */ -class ComponentbuilderControllerComponentbuilder extends AdminController -{ - -} diff --git a/admin/controllers/components_admin_views.php b/admin/controllers/components_admin_views.php deleted file mode 100644 index fc6ed3241..000000000 --- a/admin/controllers/components_admin_views.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_admin_views Admin Controller - */ -class ComponentbuilderControllerComponents_admin_views extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Component_admin_views', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/components_config.php b/admin/controllers/components_config.php deleted file mode 100644 index 9209371e9..000000000 --- a/admin/controllers/components_config.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_config Admin Controller - */ -class ComponentbuilderControllerComponents_config extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_COMPONENTS_CONFIG'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Component_config', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/components_custom_admin_menus.php b/admin/controllers/components_custom_admin_menus.php deleted file mode 100644 index effb4eea4..000000000 --- a/admin/controllers/components_custom_admin_menus.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_custom_admin_menus Admin Controller - */ -class ComponentbuilderControllerComponents_custom_admin_menus extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_MENUS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Component_custom_admin_menus', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/components_custom_admin_views.php b/admin/controllers/components_custom_admin_views.php deleted file mode 100644 index 8f5f7f0ca..000000000 --- a/admin/controllers/components_custom_admin_views.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_custom_admin_views Admin Controller - */ -class ComponentbuilderControllerComponents_custom_admin_views extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_VIEWS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Component_custom_admin_views', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/components_dashboard.php b/admin/controllers/components_dashboard.php deleted file mode 100644 index a968864f7..000000000 --- a/admin/controllers/components_dashboard.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_dashboard Admin Controller - */ -class ComponentbuilderControllerComponents_dashboard extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_COMPONENTS_DASHBOARD'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Component_dashboard', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/components_files_folders.php b/admin/controllers/components_files_folders.php deleted file mode 100644 index 736d73283..000000000 --- a/admin/controllers/components_files_folders.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_files_folders Admin Controller - */ -class ComponentbuilderControllerComponents_files_folders extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_COMPONENTS_FILES_FOLDERS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Component_files_folders', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/components_modules.php b/admin/controllers/components_modules.php deleted file mode 100644 index 1269e6b7f..000000000 --- a/admin/controllers/components_modules.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_modules Admin Controller - */ -class ComponentbuilderControllerComponents_modules extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_COMPONENTS_MODULES'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Component_modules', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/components_mysql_tweaks.php b/admin/controllers/components_mysql_tweaks.php deleted file mode 100644 index fd13fc84d..000000000 --- a/admin/controllers/components_mysql_tweaks.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_mysql_tweaks Admin Controller - */ -class ComponentbuilderControllerComponents_mysql_tweaks extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_COMPONENTS_MYSQL_TWEAKS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Component_mysql_tweaks', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/components_placeholders.php b/admin/controllers/components_placeholders.php deleted file mode 100644 index e8c17eb5e..000000000 --- a/admin/controllers/components_placeholders.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_placeholders Admin Controller - */ -class ComponentbuilderControllerComponents_placeholders extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_COMPONENTS_PLACEHOLDERS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Component_placeholders', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/components_plugins.php b/admin/controllers/components_plugins.php deleted file mode 100644 index b69af5fb3..000000000 --- a/admin/controllers/components_plugins.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_plugins Admin Controller - */ -class ComponentbuilderControllerComponents_plugins extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_COMPONENTS_PLUGINS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Component_plugins', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/components_site_views.php b/admin/controllers/components_site_views.php deleted file mode 100644 index 118d38176..000000000 --- a/admin/controllers/components_site_views.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_site_views Admin Controller - */ -class ComponentbuilderControllerComponents_site_views extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Component_site_views', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/components_updates.php b/admin/controllers/components_updates.php deleted file mode 100644 index 13d949a72..000000000 --- a/admin/controllers/components_updates.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_updates Admin Controller - */ -class ComponentbuilderControllerComponents_updates extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_COMPONENTS_UPDATES'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Component_updates', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/custom_admin_view.php b/admin/controllers/custom_admin_view.php deleted file mode 100644 index f693798eb..000000000 --- a/admin/controllers/custom_admin_view.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Custom_admin_view Form Controller - */ -class ComponentbuilderControllerCustom_admin_view extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Custom_admin_views'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('custom_admin_view.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return parent::allowAdd($data); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('custom_admin_view.access', 'com_componentbuilder.custom_admin_view.' . (int) $recordId) && $user->authorise('custom_admin_view.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('core.edit', 'com_componentbuilder.custom_admin_view.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('core.edit.own', 'com_componentbuilder.custom_admin_view.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('core.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return parent::allowEdit($data, $key); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Custom_admin_view', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=custom_admin_views' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/custom_admin_views.php b/admin/controllers/custom_admin_views.php deleted file mode 100644 index 7cc3ad9c5..000000000 --- a/admin/controllers/custom_admin_views.php +++ /dev/null @@ -1,118 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Custom_admin_views Admin Controller - */ -class ComponentbuilderControllerCustom_admin_views extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEWS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Custom_admin_view', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('custom_admin_view.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - $pks = ArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Custom_admin_views'); - // get the data to export - $data = $model->getExportData($pks); - if (ComponentbuilderHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - ComponentbuilderHelper::xls($data,'Custom_admin_views_'.$date->format('jS_F_Y'),'Custom admin views exported ('.$date->format('jS F, Y').')','custom admin views'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=custom_admin_views', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('custom_admin_view.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - // Get the import model - $model = $this->getModel('Custom_admin_views'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (ComponentbuilderHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('custom_admin_view_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'custom_admin_views'); - $session->set('dataType_VDM_IMPORTINTO', 'custom_admin_view'); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_CUSTOM_ADMIN_VIEWS'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=custom_admin_views', false), $message, 'error'); - return; - } - - public function getSnippets() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the import snippets custom admin view - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=get_snippets', false)); - return; - } -} \ No newline at end of file diff --git a/admin/controllers/custom_code.php b/admin/controllers/custom_code.php deleted file mode 100644 index 8106c6d01..000000000 --- a/admin/controllers/custom_code.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Custom_code Form Controller - */ -class ComponentbuilderControllerCustom_code extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Custom_codes'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('custom_code.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('custom_code.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('custom_code.access', 'com_componentbuilder.custom_code.' . (int) $recordId) && $user->authorise('custom_code.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('custom_code.edit', 'com_componentbuilder.custom_code.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('custom_code.edit.own', 'com_componentbuilder.custom_code.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('custom_code.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('custom_code.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Custom_code', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=custom_codes' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/custom_codes.php b/admin/controllers/custom_codes.php deleted file mode 100644 index 3e341a31d..000000000 --- a/admin/controllers/custom_codes.php +++ /dev/null @@ -1,151 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\StringHelper; - -/** - * Custom_codes Admin Controller - */ -class ComponentbuilderControllerCustom_codes extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_CUSTOM_CODES'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Custom_code', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('custom_code.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - $pks = ArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Custom_codes'); - // get the data to export - $data = $model->getExportData($pks); - if (ComponentbuilderHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - ComponentbuilderHelper::xls($data,'Custom_codes_'.$date->format('jS_F_Y'),'Custom codes exported ('.$date->format('jS F, Y').')','custom codes'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=custom_codes', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('custom_code.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - // Get the import model - $model = $this->getModel('Custom_codes'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (ComponentbuilderHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('custom_code_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'custom_codes'); - $session->set('dataType_VDM_IMPORTINTO', 'custom_code'); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_CUSTOM_CODES'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=custom_codes', false), $message, 'error'); - return; - } - - - /** - * Run the Expansion - * - * @return void - */ - public function runExpansion() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - // check if user has the right - $user = JFactory::getUser(); - // set page redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=custom_codes', false); - // set massage - $message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE'); - // check if this user has the right to run expansion - if($user->authorise('custom_codes.run_expansion', 'com_componentbuilder')) - { - // set massage - $message = JText::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB'); - // run expansion via API - $result = ComponentbuilderHelper::getFileContents(JURI::root() . 'index.php?option=com_componentbuilder&task=api.expand'); - // is there a message returned - if (!is_numeric($result) && StringHelper::check($result)) - { - $this->setRedirect($redirect_url, $result); - return true; - } - elseif (is_numeric($result) && 1 == $result) - { - $message = JText::_('COM_COMPONENTBUILDER_BTHE_EXPANSION_WAS_SUCCESSFULLYB_TO_SEE_MORE_INFORMATION_CHANGE_THE_BRETURN_OPTIONS_FOR_BUILDB_TO_BDISPLAY_MESSAGEB_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TABB'); - $this->setRedirect($redirect_url, $message, 'message'); - return true; - } - } - $this->setRedirect($redirect_url, $message, 'error'); - return false; - } - -} \ No newline at end of file diff --git a/admin/controllers/dynamic_get.php b/admin/controllers/dynamic_get.php deleted file mode 100644 index ef4873b20..000000000 --- a/admin/controllers/dynamic_get.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Dynamic_get Form Controller - */ -class ComponentbuilderControllerDynamic_get extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Dynamic_gets'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('dynamic_get.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('dynamic_get.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('dynamic_get.access', 'com_componentbuilder.dynamic_get.' . (int) $recordId) && $user->authorise('dynamic_get.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('dynamic_get.edit', 'com_componentbuilder.dynamic_get.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('dynamic_get.edit.own', 'com_componentbuilder.dynamic_get.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('dynamic_get.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('dynamic_get.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Dynamic_get', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=dynamic_gets' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/dynamic_gets.php b/admin/controllers/dynamic_gets.php deleted file mode 100644 index d23bcf2bb..000000000 --- a/admin/controllers/dynamic_gets.php +++ /dev/null @@ -1,151 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\StringHelper; - -/** - * Dynamic_gets Admin Controller - */ -class ComponentbuilderControllerDynamic_gets extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_DYNAMIC_GETS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Dynamic_get', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('dynamic_get.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - $pks = ArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Dynamic_gets'); - // get the data to export - $data = $model->getExportData($pks); - if (ComponentbuilderHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - ComponentbuilderHelper::xls($data,'Dynamic_gets_'.$date->format('jS_F_Y'),'Dynamic gets exported ('.$date->format('jS F, Y').')','dynamic gets'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=dynamic_gets', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('dynamic_get.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - // Get the import model - $model = $this->getModel('Dynamic_gets'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (ComponentbuilderHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('dynamic_get_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'dynamic_gets'); - $session->set('dataType_VDM_IMPORTINTO', 'dynamic_get'); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_DYNAMIC_GETS'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=dynamic_gets', false), $message, 'error'); - return; - } - - - /** - * Run the Expansion - * - * @return void - */ - public function runExpansion() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - // check if user has the right - $user = JFactory::getUser(); - // set page redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=dynamic_gets', false); - // set massage - $message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE'); - // check if this user has the right to run expansion - if($user->authorise('dynamic_gets.run_expansion', 'com_componentbuilder')) - { - // set massage - $message = JText::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB'); - // run expansion via API - $result = ComponentbuilderHelper::getFileContents(JURI::root() . 'index.php?option=com_componentbuilder&task=api.expand'); - // is there a message returned - if (!is_numeric($result) && StringHelper::check($result)) - { - $this->setRedirect($redirect_url, $result); - return true; - } - elseif (is_numeric($result) && 1 == $result) - { - $message = JText::_('COM_COMPONENTBUILDER_BTHE_EXPANSION_WAS_SUCCESSFULLYB_TO_SEE_MORE_INFORMATION_CHANGE_THE_BRETURN_OPTIONS_FOR_BUILDB_TO_BDISPLAY_MESSAGEB_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TABB'); - $this->setRedirect($redirect_url, $message, 'message'); - return true; - } - } - $this->setRedirect($redirect_url, $message, 'error'); - return false; - } - -} \ No newline at end of file diff --git a/admin/controllers/field.php b/admin/controllers/field.php deleted file mode 100644 index 18d96d5ab..000000000 --- a/admin/controllers/field.php +++ /dev/null @@ -1,323 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Field Form Controller - */ -class ComponentbuilderControllerField extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Fields'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('field.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('field.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('field.access', 'com_componentbuilder.field.' . (int) $recordId) && $user->authorise('field.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('field.edit', 'com_componentbuilder.field.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('field.edit.own', 'com_componentbuilder.field.' . $recordId)) - { - // Fallback on edit.own. Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then do the test. - if ($ownerId == $user->id) - { - if ($user->authorise('field.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('field.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Field', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=fields' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/fields.php b/admin/controllers/fields.php deleted file mode 100644 index 3d07dbc8d..000000000 --- a/admin/controllers/fields.php +++ /dev/null @@ -1,151 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\StringHelper; - -/** - * Fields Admin Controller - */ -class ComponentbuilderControllerFields extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_FIELDS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Field', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('field.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - $pks = ArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Fields'); - // get the data to export - $data = $model->getExportData($pks); - if (ComponentbuilderHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - ComponentbuilderHelper::xls($data,'Fields_'.$date->format('jS_F_Y'),'Fields exported ('.$date->format('jS F, Y').')','fields'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=fields', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('field.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - // Get the import model - $model = $this->getModel('Fields'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (ComponentbuilderHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('field_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'fields'); - $session->set('dataType_VDM_IMPORTINTO', 'field'); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_FIELDS'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=fields', false), $message, 'error'); - return; - } - - - /** - * Run the Expansion - * - * @return void - */ - public function runExpansion() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - // check if user has the right - $user = JFactory::getUser(); - // set page redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=fields', false); - // set massage - $message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE'); - // check if this user has the right to run expansion - if($user->authorise('fields.run_expansion', 'com_componentbuilder')) - { - // set massage - $message = JText::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB'); - // run expansion via API - $result = ComponentbuilderHelper::getFileContents(JURI::root() . 'index.php?option=com_componentbuilder&task=api.expand'); - // is there a message returned - if (!is_numeric($result) && StringHelper::check($result)) - { - $this->setRedirect($redirect_url, $result); - return true; - } - elseif (is_numeric($result) && 1 == $result) - { - $message = JText::_('COM_COMPONENTBUILDER_BTHE_EXPANSION_WAS_SUCCESSFULLYB_TO_SEE_MORE_INFORMATION_CHANGE_THE_BRETURN_OPTIONS_FOR_BUILDB_TO_BDISPLAY_MESSAGEB_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TABB'); - $this->setRedirect($redirect_url, $message, 'message'); - return true; - } - } - $this->setRedirect($redirect_url, $message, 'error'); - return false; - } - -} \ No newline at end of file diff --git a/admin/controllers/fieldtype.php b/admin/controllers/fieldtype.php deleted file mode 100644 index 638f581a7..000000000 --- a/admin/controllers/fieldtype.php +++ /dev/null @@ -1,323 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Fieldtype Form Controller - */ -class ComponentbuilderControllerFieldtype extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Fieldtypes'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('fieldtype.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('fieldtype.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('fieldtype.access', 'com_componentbuilder.fieldtype.' . (int) $recordId) && $user->authorise('fieldtype.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('fieldtype.edit', 'com_componentbuilder.fieldtype.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('fieldtype.edit.own', 'com_componentbuilder.fieldtype.' . $recordId)) - { - // Fallback on edit.own. Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then do the test. - if ($ownerId == $user->id) - { - if ($user->authorise('fieldtype.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('fieldtype.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Fieldtype', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=fieldtypes' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/fieldtypes.php b/admin/controllers/fieldtypes.php deleted file mode 100644 index 07ce1f60f..000000000 --- a/admin/controllers/fieldtypes.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Fieldtypes Admin Controller - */ -class ComponentbuilderControllerFieldtypes extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_FIELDTYPES'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Fieldtype', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('fieldtype.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - $pks = ArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Fieldtypes'); - // get the data to export - $data = $model->getExportData($pks); - if (ComponentbuilderHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - ComponentbuilderHelper::xls($data,'Fieldtypes_'.$date->format('jS_F_Y'),'Fieldtypes exported ('.$date->format('jS F, Y').')','fieldtypes'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=fieldtypes', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('fieldtype.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - // Get the import model - $model = $this->getModel('Fieldtypes'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (ComponentbuilderHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('fieldtype_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'fieldtypes'); - $session->set('dataType_VDM_IMPORTINTO', 'fieldtype'); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_FIELDTYPES'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=fieldtypes', false), $message, 'error'); - return; - } -} \ No newline at end of file diff --git a/admin/controllers/get_snippets.php b/admin/controllers/get_snippets.php deleted file mode 100644 index 3761e39e9..000000000 --- a/admin/controllers/get_snippets.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Get_snippets Admin Controller - */ -class ComponentbuilderControllerGet_snippets extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_GET_SNIPPETS'; - - /** - * Proxy for getModel. - * @since 2.5 - */ - public function getModel($name = 'Get_snippets', $prefix = 'ComponentbuilderModel', $config = array()) - { - $model = parent::getModel($name, $prefix, array('ignore_request' => true)); - - return $model; - } - - public function dashboard() - { - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder', false)); - return; - } - - public function openLibraries() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the libraries - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=libraries', false)); - return; - } - - public function openSnippets() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the snippets - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=snippets', false)); - return; - } - - public function openSiteViews() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the site views - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=site_views', false)); - return; - } - - public function openCustomAdminViews() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the custom admin views - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=custom_admin_views', false)); - return; - } - - public function openTemplates() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the templates - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=templates', false)); - return; - } - - public function openLayouts() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the layouts - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=layouts', false)); - return; - } -} diff --git a/admin/controllers/help.php b/admin/controllers/help.php deleted file mode 100644 index c917da3fa..000000000 --- a/admin/controllers/help.php +++ /dev/null @@ -1,116 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\BaseController; -use Joomla\Utilities\ArrayHelper; - -/** - * Componentbuilder Help Base Controller - */ -class ComponentbuilderControllerHelp extends BaseController -{ - public function __construct($config) - { - parent::__construct($config); - // load the tasks - $this->registerTask('getText', 'help'); - } - - public function help() - { - $user = JFactory::getUser(); - $jinput = JFactory::getApplication()->input; - // Check Token! - $token = JSession::getFormToken(); - $call_token = $jinput->get('token', 0, 'ALNUM'); - if($user->id != 0 && $token == $call_token) - { - $task = $this->getTask(); - switch($task){ - case 'getText': - try - { - $idValue = $jinput->get('id', 0, 'INT'); - if($idValue) - { - $result = $this->getHelpDocumentText($idValue); - } - else - { - $result = ''; - } - echo $result; - // stop execution gracefully - jexit(); - } - catch(Exception $e) - { - // stop execution gracefully - jexit(); - } - break; - } - } - else - { - // stop execution gracefully - jexit(); - } - } - - protected function getHelpDocumentText($id) - { - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $query->select(array('a.title','a.content')); - $query->from('#__componentbuilder_help_document AS a'); - $query->where('a.id = '.(int) $id); - $query->where('a.published = 1'); - $db->setQuery($query); - $db->execute(); - if($db->getNumRows()) - { - $text = array(); - $document = $db->loadObject(); - // fix image issue - $images['src="images'] = 'src="'.JURI::root().'images'; - $images["src='images"] = "src='".JURI::root()."images"; - $images['src="/images'] = 'src="'.JURI::root().'images'; - $images["src='/images"] = "src='".JURI::root()."images"; - // set document template - $text[] = ""; - $text[] = ''; - $text[] = ""; - $text[] = ''; - $text[] = "".$document->title.""; - $text[] = ''; - $text[] = ''; - $text[] = ""; - $text[] = '
'; - $text[] = '
'; - $text[] = '
'; - // build the help text - $text[] = '

'.$document->title."

"; - $text[] = str_replace(array_keys($images),array_values($images),$document->content); - // end template - $text[] = '


'; - $text[] = '
'; - $text[] = ""; - $text[] = ""; - - return implode("\n",$text); - } - return false; - } -} diff --git a/admin/controllers/help_document.php b/admin/controllers/help_document.php deleted file mode 100644 index 07a4c41f9..000000000 --- a/admin/controllers/help_document.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Help_document Form Controller - */ -class ComponentbuilderControllerHelp_document extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Help_documents'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('help_document.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('help_document.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('help_document.access', 'com_componentbuilder.help_document.' . (int) $recordId) && $user->authorise('help_document.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('help_document.edit', 'com_componentbuilder.help_document.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('help_document.edit.own', 'com_componentbuilder.help_document.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('help_document.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('help_document.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Help_document', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=help_documents' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/help_documents.php b/admin/controllers/help_documents.php deleted file mode 100644 index 21f3ffdd2..000000000 --- a/admin/controllers/help_documents.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Help_documents Admin Controller - */ -class ComponentbuilderControllerHelp_documents extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_HELP_DOCUMENTS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Help_document', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('help_document.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - $pks = ArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Help_documents'); - // get the data to export - $data = $model->getExportData($pks); - if (ComponentbuilderHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - ComponentbuilderHelper::xls($data,'Help_documents_'.$date->format('jS_F_Y'),'Help documents exported ('.$date->format('jS F, Y').')','help documents'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=help_documents', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('help_document.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - // Get the import model - $model = $this->getModel('Help_documents'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (ComponentbuilderHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('help_document_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'help_documents'); - $session->set('dataType_VDM_IMPORTINTO', 'help_document'); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_HELP_DOCUMENTS'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=help_documents', false), $message, 'error'); - return; - } -} \ No newline at end of file diff --git a/admin/controllers/import.php b/admin/controllers/import.php deleted file mode 100644 index 61cf94794..000000000 --- a/admin/controllers/import.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\BaseController; -use Joomla\Utilities\ArrayHelper; - -/** - * Componentbuilder Import Base Controller - */ -class ComponentbuilderControllerImport extends BaseController -{ - /** - * Import an spreadsheet. - * - * @return void - */ - public function import() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - $model = $this->getModel('import'); - if ($model->import()) - { - $cache = JFactory::getCache('mod_menu'); - $cache->clean(); - // TODO: Reset the users acl here as well to kill off any missing bits - } - - $app = JFactory::getApplication(); - $redirect_url = $app->getUserState('com_componentbuilder.redirect_url'); - if (empty($redirect_url)) - { - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=import', false); - } - else - { - // wipe out the user state when we're going to redirect - $app->setUserState('com_componentbuilder.redirect_url', ''); - $app->setUserState('com_componentbuilder.message', ''); - $app->setUserState('com_componentbuilder.extension_message', ''); - } - $this->setRedirect($redirect_url); - } -} diff --git a/admin/controllers/import_joomla_components.php b/admin/controllers/import_joomla_components.php deleted file mode 100644 index e3fb93ce6..000000000 --- a/admin/controllers/import_joomla_components.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\BaseController; -use Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Componentbuilder\Package\Factory as PackageFactory; - -/** - * Componentbuilder Import_joomla_components Base Controller - */ -class ComponentbuilderControllerImport_joomla_components extends BaseController -{ - /** - * Import an spreadsheet. - * - * @return void - */ - public function import() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - $model = $this->getModel('Import_joomla_components'); - if ($model->import()) - { - $cache = JFactory::getCache('mod_menu'); - $cache->clean(); - // TODO: Reset the users acl here as well to kill off any missing bits - } - - $app = JFactory::getApplication(); - $redirect_url = $app->getUserState('com_componentbuilder.redirect_url'); - if (empty($redirect_url)) - { - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=import_joomla_components', false); - } - else - { - // wipe out the user state when we're going to redirect - $app->setUserState('com_componentbuilder.redirect_url', ''); - $app->setUserState('com_componentbuilder.message', ''); - $app->setUserState('com_componentbuilder.extension_message', ''); - } - $this->setRedirect($redirect_url); - } -} diff --git a/admin/controllers/import_language_translations.php b/admin/controllers/import_language_translations.php deleted file mode 100644 index b01381ec9..000000000 --- a/admin/controllers/import_language_translations.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\BaseController; -use Joomla\Utilities\ArrayHelper; - -/** - * Componentbuilder Import_language_translations Base Controller - */ -class ComponentbuilderControllerImport_language_translations extends BaseController -{ - /** - * Import an spreadsheet. - * - * @return void - */ - public function import() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - $model = $this->getModel('Import_language_translations'); - if ($model->import()) - { - $cache = JFactory::getCache('mod_menu'); - $cache->clean(); - // TODO: Reset the users acl here as well to kill off any missing bits - } - - $app = JFactory::getApplication(); - $redirect_url = $app->getUserState('com_componentbuilder.redirect_url'); - if (empty($redirect_url)) - { - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=import_language_translations', false); - } - else - { - // wipe out the user state when we're going to redirect - $app->setUserState('com_componentbuilder.redirect_url', ''); - $app->setUserState('com_componentbuilder.message', ''); - $app->setUserState('com_componentbuilder.extension_message', ''); - } - $this->setRedirect($redirect_url); - } -} diff --git a/admin/controllers/joomla_component.php b/admin/controllers/joomla_component.php deleted file mode 100644 index c5b5f3cbf..000000000 --- a/admin/controllers/joomla_component.php +++ /dev/null @@ -1,383 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_component Form Controller - */ -class ComponentbuilderControllerJoomla_component extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Joomla_components'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - public function refresh() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('joomla_component.import_jcb_packages', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - $session = JFactory::getSession(); - $session->set('backto_VDM_IMPORT', 'joomla_components'); - $session->set('dataType_VDM_IMPORTINTO', 'smart_package'); - // clear the session - ComponentbuilderHelper::set('vdmGithubPackages', null); - ComponentbuilderHelper::set('communityGithubPackages', null); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_YOU_CAN_NOW_SELECT_THE_COMPONENT_BZIPB_PACKAGE_YOU_WOULD_LIKE_TO_IMPORTBR_SMALLPLEASE_NOTE_THAT_SMART_COMPONENT_IMPORT_ONLY_WORKS_WITH_THE_FOLLOWING_FORMAT_BZIPBSMALL'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import_joomla_components&target=smartPackage', false), $message); - return; - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_IMPORT_A_COMPONENT_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_HELP'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); - return; - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('joomla_component.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('joomla_component.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('joomla_component.access', 'com_componentbuilder.joomla_component.' . (int) $recordId) && $user->authorise('joomla_component.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('joomla_component.edit', 'com_componentbuilder.joomla_component.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('joomla_component.edit.own', 'com_componentbuilder.joomla_component.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('joomla_component.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('joomla_component.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Joomla_component', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - // get the state object (Joomla\CMS\Object\CMSObject) - $state = $model->get('state'); - // if we save2copy we need to also copy linked tables found! - if ($state->task === 'save2copy' && $state->{'joomla_component.new'}) - { - // get new ID - $newID = $state->{'joomla_component.id'}; - // get old ID - $oldID = $this->input->get('id', 0, 'INT'); - // linked tables to update - $_tablesArray = array( - 'component_admin_views' => 'joomla_component', - 'component_site_views' => 'joomla_component', - 'component_custom_admin_views' => 'joomla_component', - 'component_updates' => 'joomla_component', - 'component_mysql_tweaks' => 'joomla_component', - 'component_custom_admin_menus' => 'joomla_component', - 'component_config' => 'joomla_component', - 'component_dashboard' => 'joomla_component', - 'component_files_folders' => 'joomla_component', - 'component_placeholders' => 'joomla_component', - 'custom_code' => 'component' - ); - foreach($_tablesArray as $_updateTable => $_key) - { - // get the linked ID - if ($_value = ComponentbuilderHelper::getVar($_updateTable, $oldID, $_key, 'id')) - { - // copy fields to new linked table - ComponentbuilderHelper::copyItem(/*id->*/ $_value, /*table->*/ $_updateTable, /*change->*/ array($_key => $newID)); - } - } - } - - return; - } - -} diff --git a/admin/controllers/joomla_components.php b/admin/controllers/joomla_components.php deleted file mode 100644 index e950b96dc..000000000 --- a/admin/controllers/joomla_components.php +++ /dev/null @@ -1,513 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Componentbuilder\Package\Factory as PackageFactory; -use VDM\Joomla\Utilities\ArrayHelper as JCBArrayHelper; -use VDM\Joomla\Utilities\StringHelper; -use Joomla\CMS\Language\Text; -use VDM\Joomla\Utilities\ObjectHelper; - -/** - * Joomla_components Admin Controller - */ -class ComponentbuilderControllerJoomla_components extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_COMPONENTS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Joomla_component', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('joomla_component.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - $pks = ArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Joomla_components'); - // get the data to export - $data = $model->getExportData($pks); - if (ComponentbuilderHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - ComponentbuilderHelper::xls($data,'Joomla_components_'.$date->format('jS_F_Y'),'Joomla components exported ('.$date->format('jS F, Y').')','joomla components'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('joomla_component.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - // Get the import model - $model = $this->getModel('Joomla_components'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (ComponentbuilderHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('joomla_component_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'joomla_components'); - $session->set('dataType_VDM_IMPORTINTO', 'joomla_component'); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_JOOMLA_COMPONENTS'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import_joomla_components', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); - return; - } - - - /** - * Run the Expansion - * - * @return void - */ - public function runExpansion() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - // check if user has the right - $user = JFactory::getUser(); - // set page redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false); - // set massage - $message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE'); - // check if this user has the right to run expansion - if($user->authorise('joomla_components.run_expansion', 'com_componentbuilder')) - { - // set massage - $message = JText::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB'); - // run expansion via API - $result = ComponentbuilderHelper::getFileContents(JURI::root() . 'index.php?option=com_componentbuilder&task=api.expand'); - // is there a message returned - if (!is_numeric($result) && StringHelper::check($result)) - { - $this->setRedirect($redirect_url, $result); - return true; - } - elseif (is_numeric($result) && 1 == $result) - { - $message = JText::_('COM_COMPONENTBUILDER_BTHE_EXPANSION_WAS_SUCCESSFULLYB_TO_SEE_MORE_INFORMATION_CHANGE_THE_BRETURN_OPTIONS_FOR_BUILDB_TO_BDISPLAY_MESSAGEB_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TABB'); - $this->setRedirect($redirect_url, $message, 'message'); - return true; - } - } - $this->setRedirect($redirect_url, $message, 'error'); - return false; - } - - - /** - * Clear tmp folder - * - * @return true on success - */ - public function clearTmp() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - // check if user has the right - $user = JFactory::getUser(); - // set page redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false); - $message = JText::_('COM_COMPONENTBUILDER_COULD_NOT_CLEAR_THE_TMP_FOLDER'); - if($user->authorise('joomla_components.clear_tmp', 'com_componentbuilder') && $user->authorise('core.manage', 'com_componentbuilder')) - { - // get the model - $model = $this->getModel('compiler'); - // get tmp folder - $comConfig = JFactory::getConfig(); - $tmp = $comConfig->get('tmp_path'); - if ($model->emptyFolder($tmp)) - { - $message = JText::_('COM_COMPONENTBUILDER_BTHE_TMP_FOLDER_HAS_BEEN_CLEAR_SUCCESSFULLYB'); - $this->setRedirect($redirect_url, $message, 'message'); - // get application - $app = JFactory::getApplication(); - // wipe out the user c-m-p since we are done with them all - $app->setUserState('com_componentbuilder.component_folder_name', ''); - $app->setUserState('com_componentbuilder.modules_folder_name', ''); - $app->setUserState('com_componentbuilder.plugins_folder_name', ''); - $app->setUserState('com_componentbuilder.success_message', ''); - - return true; - } - } - $this->setRedirect($redirect_url, $message, 'error'); - return false; - } - - public function smartImport() - { - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('joomla_component.import_jcb_packages', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - $session = JFactory::getSession(); - $session->set('backto_VDM_IMPORT', 'joomla_components'); - $session->set('dataType_VDM_IMPORTINTO', 'smart_package'); - // Redirect to import view. - $message = Text::_('COM_COMPONENTBUILDER_YOU_CAN_NOW_SELECT_THE_COMPONENT_BZIPB_PACKAGE_YOU_WOULD_LIKE_TO_IMPORTBR_SMALLPLEASE_NOTE_THAT_SMART_COMPONENT_IMPORT_ONLY_WORKS_WITH_THE_FOLLOWING_FORMAT_BZIPBSMALL'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import_joomla_components&target=smartPackage', false), $message); - return; - } - // Redirect to the list screen with error. - $message = Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_IMPORT_A_COMPONENT_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_HELP'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); - return; - } - - public function smartExport() - { - // Check for request forgeries - JSession::checkToken() or die(Text::_('JINVALID_TOKEN')); - // Get the model - $model = $this->getModel('Joomla_components'); - // check if export is allowed for this user. - $model->user = JFactory::getUser(); - if ($model->user->authorise('joomla_component.export_jcb_packages', 'com_componentbuilder') && $model->user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - JArrayHelper::toInteger($pks); - // check if there is any selections - if (!JCBArrayHelper::check($pks)) - { - // Redirect to the list screen with error. - $message = Text::_('COM_COMPONENTBUILDER_NO_COMPONENTS_WERE_SELECTED_PLEASE_MAKE_A_SELECTION_AND_TRY_AGAIN'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); - return; - } - // set auto loader - ComponentbuilderHelper::autoLoader('smart'); - // get the data to export - if ($model->getSmartExport($pks)) - { - // set the key string - if (StringHelper::check($model->key) && strlen($model->key) == 32) - { - $keyNotice = '

' . Text::sprintf('COM_COMPONENTBUILDER_THE_PACKAGE_KEY_IS_CODESCODE', $model->key) . '

'; - $keyNotice .= '

' . Text::_('COM_COMPONENTBUILDER_YOUR_DATA_IS_ENCRYPTED_WITH_A_AES_TWO_HUNDRED_AND_FIFTY_SIX_BIT_ENCRYPTION_USING_THE_ABOVE_THIRTY_TWO_CHARACTER_KEY') . '

'; - - // set the package owner info - if (PackageFactory::_('Display.Details')->hasOwner($model->info)) - { - $ownerDetails = PackageFactory::_('Display.Details')->owner($model->info, true); - } - else - { - $ownerDetails = '

' . Text::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_NOT_SET') . '

'; - $ownerDetails .= '

' . Text::_('COM_COMPONENTBUILDER_TO_CHANGE_THE_PACKAGE_OWNER_DEFAULTS_OPEN_THE_BJCB_GLOBAL_OPTIONSB_GO_TO_THE_BCOMPANYB_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE') . '

'; - $ownerDetails .= '

' . Text::_('COM_COMPONENTBUILDER_YOU_SHOULD_ADD_THE_CORRECT_OWNER_DETAILS') . '

'; - $ownerDetails .= '

' . Text::_('COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_BIMPORT_PROCESSB_BEFORE_ADDING_THE_KEY_THIS_WAY_IF_THE_USERDEV_BDOES_NOTB_HAVE_THE_KEY_THEY_CAN_SEE_BWHERE_TO_GET_ITB') . '

'; - } - } - else - { - $keyNotice = '

' . Text::_('COM_COMPONENTBUILDER_THIS_PACKAGE_HAS_NO_KEY') . '

'; - $ownerDetails = '

' . Text::_('COM_COMPONENTBUILDER_THAT_MEANS_ANYONE_WHO_HAS_THIS_PACKAGE_CAN_INSTALL_IT_INTO_JCB_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_BSETTINGSB_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_BEXPORT_KEYB') . '

'; - } - // Redirect to the list screen with success. - $message = array(); - $message[] = '

' . Text::_('COM_COMPONENTBUILDER_EXPORT_COMPLETED') . '

'; - $message[] = '

' . JText::sprintf('COM_COMPONENTBUILDER_PATH_TO_THE_ZIPPED_PACKAGE_IS_CODESCODE_BR_S_S', $model->zipPath, $keyNotice, $ownerDetails) . '

'; - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), implode('', $message), 'Success'); - return; - } - else - { - if (StringHelper::check($model->packagePath)) - { - // clear all if not successful - ComponentbuilderHelper::removeFolder($model->packagePath); - } - if (StringHelper::check($model->zipPath)) - { - // clear all if not successful - JFile::delete($model->zipPath); - } - } - } - // Redirect to the list screen with error. - $message = Text::_('COM_COMPONENTBUILDER_EXPORT_FAILED_PLEASE_TRY_AGAIN_LATTER'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); - return; - } - - public function backup() - { - // get params first - if (!isset($this->params) || !ObjectHelper::check($this->params)) - { - $this->params = JComponentHelper::getParams('com_componentbuilder'); - } - // Get the model - $model = componentbuilderHelper::getModel('joomla_components', JPATH_ADMINISTRATOR . '/components/com_componentbuilder'); - // set user - $model->user = $this->getApiUser(); - // make sure to set active type (adding this script from custom code :) - $model->activeType = 'manualBackup'; - // check if export is allowed for this user. (we need this sorry) - if ($model->user->authorise('joomla_component.export_jcb_packages', 'com_componentbuilder') && $model->user->authorise('core.export', 'com_componentbuilder')) - { - // get all component IDs to backup - $pks = componentbuilderHelper::getComponentIDs(); - // set auto loader - ComponentbuilderHelper::autoLoader('smart'); - // manual backup message - $backupNotice = array(); - // get the data to export - if (JCBArrayHelper::check($pks) && $model->getSmartExport($pks)) - { - $backupNotice[] = JText::_('COM_COMPONENTBUILDER_BACKUP_WAS_DONE_SUCCESSFULLY'); - $backupNoticeStatus = 'Success'; - // set the key string - if (StringHelper::check($model->key) && strlen($model->key) == 32) - { - $textNotice = array(); - $keyNotice = '

' . JText::sprintf('COM_COMPONENTBUILDER_THE_PACKAGE_KEY_IS_CODESCODE', $model->key) . '

'; - $keyNotice .= '

' . JText::_('COM_COMPONENTBUILDER_YOUR_DATA_IS_ENCRYPTED_WITH_A_AES_TWO_HUNDRED_AND_FIFTY_SIX_BIT_ENCRYPTION_USING_THE_ABOVE_THIRTY_TWO_CHARACTER_KEY') . '

'; - $textNotice[] = JText::sprintf('COM_COMPONENTBUILDER_THE_PACKAGE_KEY_IS_S', $model->key); - // set the package owner info - if ((isset($model->info['getKeyFrom']['company']) && StringHelper::check($model->info['getKeyFrom']['company'])) || (isset($model->info['getKeyFrom']['owner']) && StringHelper::check($model->info['getKeyFrom']['owner']))) - { - $ownerDetails = '

' . JText::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS') . '

'; - $textNotice[] = '# ' . JText::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS'); - $ownerDetails .= '
    '; - if (isset($model->info['getKeyFrom']['company']) && StringHelper::check($model->info['getKeyFrom']['company'])) - { - $ownerDetails .= '
  • ' . JText::sprintf('COM_COMPONENTBUILDER_EMCOMPANYEM_BSB', $model->info['getKeyFrom']['company']) . '
  • '; - $textNotice[] = '- ' . JText::sprintf('COM_COMPONENTBUILDER_COMPANY_S', $model->info['getKeyFrom']['company']); - } - // add value only if set - if (isset($model->info['getKeyFrom']['owner']) && StringHelper::check($model->info['getKeyFrom']['owner'])) - { - $ownerDetails .= '
  • ' . JText::sprintf('COM_COMPONENTBUILDER_EMOWNEREM_BSB', $model->info['getKeyFrom']['owner']) . '
  • '; - $textNotice[] = '- ' . JText::sprintf('COM_COMPONENTBUILDER_OWNER_S', $model->info['getKeyFrom']['owner']); - } - // add value only if set - if (isset($model->info['getKeyFrom']['website']) && StringHelper::check($model->info['getKeyFrom']['website'])) - { - $ownerDetails .= '
  • ' . JText::sprintf('COM_COMPONENTBUILDER_EMWEBSITEEM_BSB', $model->info['getKeyFrom']['website']) . '
  • '; - $textNotice[] = '- ' . JText::sprintf('COM_COMPONENTBUILDER_WEBSITE_S', $model->info['getKeyFrom']['website']); - } - // add value only if set - if (isset($model->info['getKeyFrom']['email']) && StringHelper::check($model->info['getKeyFrom']['email'])) - { - $ownerDetails .= '
  • ' . JText::sprintf('COM_COMPONENTBUILDER_EMEMAILEM_BSB', $model->info['getKeyFrom']['email']) . '
  • '; - $textNotice[] = '- ' . JText::sprintf('COM_COMPONENTBUILDER_EMAIL_S', $model->info['getKeyFrom']['email']); - } - // add value only if set - if (isset($model->info['getKeyFrom']['license']) && StringHelper::check($model->info['getKeyFrom']['license'])) - { - $ownerDetails .= '
  • ' . JText::sprintf('COM_COMPONENTBUILDER_EMLICENSEEM_BSB', $model->info['getKeyFrom']['license']) . '
  • '; - $textNotice[] = '- ' . JText::sprintf('COM_COMPONENTBUILDER_LICENSE_S', $model->info['getKeyFrom']['license']); - } - // add value only if set - if (isset($model->info['getKeyFrom']['copyright']) && StringHelper::check($model->info['getKeyFrom']['copyright'])) - { - $ownerDetails .= '
  • ' . JText::sprintf('COM_COMPONENTBUILDER_EMCOPYRIGHTEM_BSB', $model->info['getKeyFrom']['copyright']) . '
  • '; - $textNotice[] = '- ' . JText::sprintf('COM_COMPONENTBUILDER_COPYRIGHT_S', $model->info['getKeyFrom']['copyright']); - } - $ownerDetails .= '
'; - $backupNotice[] = JText::_('COM_COMPONENTBUILDER_OWNER_DETAILS_WAS_SET'); - } - else - { - $ownerDetails = '

' . JText::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_NOT_SET') . '

'; - $textNotice[] = '# ' . JText::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS'); - $ownerDetails .= JText::_('COM_COMPONENTBUILDER_TO_CHANGE_THE_PACKAGE_OWNER_DEFAULTS_OPEN_THE_BJCB_GLOBAL_OPTIONSB_GO_TO_THE_BCOMPANYB_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE') . '
'; - $textNotice[] = JText::_('COM_COMPONENTBUILDER_TO_CHANGE_THE_PACKAGE_OWNER_DEFAULTS_OPEN_THE_JCB_GLOBAL_OPTIONS_GO_TO_THE_COMPANY_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE'); - $ownerDetails .= '

' . JText::_('COM_COMPONENTBUILDER_YOU_SHOULD_ADD_THE_CORRECT_OWNER_DETAILS') . '

'; - $textNotice[] = '## ' . JText::_('COM_COMPONENTBUILDER_YOU_SHOULD_ADD_THE_CORRECT_OWNER_DETAILS'); - $ownerDetails .= JText::_('COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_BIMPORT_PROCESSB_BEFORE_ADDING_THE_KEY_THIS_WAY_IF_THE_USERDEV_BDOES_NOTB_HAVE_THE_KEY_THEY_CAN_SEE_BWHERE_TO_GET_ITB') . '
'; - $textNotice[] = JText::_('COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_IMPORT_PROCESS_BEFORE_ADDING_THE_KEY_THIS_WAY_IF_THE_USERDEV_DOES_NOT_HAVE_THE_KEY_THEY_CAN_SEE_WHERE_TO_GET_IT'); - $backupNotice[] = JText::_('COM_COMPONENTBUILDER_CHECK_YOUR_OWNER_DETAILS_IT_HAS_NOT_BEEN_SET_OPEN_THE_JCB_GLOBAL_OPTIONS_GO_TO_THE_COMPANY_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE'); - } - } - else - { - $keyNotice = '

' . JText::_('COM_COMPONENTBUILDER_THIS_PACKAGE_HAS_NO_KEY') . '

'; - $textNotice[] = '# ' . JText::_('COM_COMPONENTBUILDER_THIS_PACKAGE_HAS_NO_KEY'); - $ownerDetails = JText::_('COM_COMPONENTBUILDER_THAT_MEANS_ANYONE_WHO_HAS_THIS_PACKAGE_CAN_INSTALL_IT_INTO_JCB_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_BSETTINGSB_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_BEXPORT_KEYB') . '
'; - $textNotice[] = JText::_('COM_COMPONENTBUILDER_THAT_MEANS_ANYONE_WHO_HAS_THIS_PACKAGE_CAN_INSTALL_IT_INTO_JCB_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_SETTINGS_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_EXPORT_KEY'); - $backupNotice[] = JText::_('COM_COMPONENTBUILDER_NO_KEYS_WERE_FOUND_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_SETTINGS_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_EXPORT_KEY'); - } - // get email - if ($email = $this->params->get('backup_email', null)) - { - // plain text - $plainText = implode("\n", $textNotice); - // set hash to track changes - $hashTracker = md5($plainText); - if (ComponentbuilderHelper::newHash($hashTracker)) - { - // Build final massage. - $message = $keyNotice . $ownerDetails . '
HASH: ' . $hashTracker . ''; - // set the subject - $subject = JText::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BUILDER_BACKUP_KEY'); - // email the message - componentbuilderEmail::send($email, $subject, componentbuilderEmail::setTableBody($message, $subject), $plainText, 1); - $backupNotice[] = JText::_('COM_COMPONENTBUILDER_EMAIL_WITH_THE_NEW_KEY_WAS_SENT'); - } - else - { - $backupNotice[] = JText::_('COM_COMPONENTBUILDER_KEY_HAS_NOT_CHANGED'); - } - } - } - else - { - $backupNotice[] = JText::_('COM_COMPONENTBUILDER_BACKUP_FAILED_PLEASE_TRY_AGAIN_IF_THE_ERROR_CONTINUE_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR'); - $backupNoticeStatus = 'Error'; - if (StringHelper::check($model->packagePath)) - { - // clear all if not successful - ComponentbuilderHelper::removeFolder($model->packagePath); - } - if (StringHelper::check($model->zipPath)) - { - // clear all if not successful - JFile::delete($model->zipPath); - } - } - // quite only if auto backup (adding this script from custom code :) - if ('backup' === $model->activeType) - { - echo "# " . $backupNoticeStatus . "\n" .implode("\n", $backupNotice); - // clear session - JFactory::getApplication()->getSession()->destroy(); - jexit(); - } - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), implode("
", $backupNotice), $backupNoticeStatus); - return; - } - // quite only if auto backup (adding this script from custom code :) - if ('backup' === $model->activeType) - { - echo "# Error\n" . JText::_('COM_COMPONENTBUILDER_ACCESS_DENIED'); - // clear session - JFactory::getApplication()->getSession()->destroy(); - jexit(); - } - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), JText::_('COM_COMPONENTBUILDER_ACCESS_DENIED'), 'Error'); - return; - } - - public function cloner() - { - // Check for request forgeries - JSession::checkToken() or die(Text::_('JINVALID_TOKEN')); - // Get the model - $model = $this->getModel('Joomla_components'); - // check if export is allowed for this user. - $model->user = JFactory::getUser(); - if ($model->user->authorise('joomla_component.clone', 'com_componentbuilder') && $model->user->authorise('core.copy', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - JArrayHelper::toInteger($pks); - // check if there is any selections - if (!JCBArrayHelper::check($pks)) - { - // Redirect to the list screen with error. - $message = Text::_('COM_COMPONENTBUILDER_NO_COMPONENT_WAS_SELECTED_PLEASE_MAKE_A_SELECTION_OF_ONE_COMPONENT_AND_TRY_AGAIN'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); - return; - } - // only one component allowed at this time - elseif (count( (array) $pks) !== 1) - { - // Redirect to the list screen with error. - $message = Text::_('COM_COMPONENTBUILDER_ONLY_ONE_COMPONENT_CAN_BE_CLONED_AT_A_TIME_PLEASE_SELECT_ONE_AND_TRY_AGAIN'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); - return; - } - // set the active type - $model->activeType = 'clone'; - // clone the component and the views and the fields... everything linked to the component. - if ($model->cloner($pks)) - { - // clone was successful - $message = Text::_('COM_COMPONENTBUILDER_THE_COMPONENT_WITH_ALL_LINKED_ADMIN_VIEWS_FIELDS_LINKED_TO_ADMIN_VIEWS_CUSTOM_ADMIN_VIEWS_SITE_VIEWS_TEMPLATES_AND_LAYOUTS_WERE_CLONED_SUCCESSFUL'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message); - return; - } - // Redirect to the list screen with error. - $message = Text::_('COM_COMPONENTBUILDER_CLONE_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); - return; - } - // Redirect to the list screen with error. - $message = Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_CLONE_A_COMPONENT_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_HELP'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); - return; - } - - protected function getApiUser() - { - // admin area does not have API user, only front-end (so we fallback on login user) - return JFactory::getUser(); - } - -} \ No newline at end of file diff --git a/admin/controllers/joomla_module.php b/admin/controllers/joomla_module.php deleted file mode 100644 index 9c1a5636d..000000000 --- a/admin/controllers/joomla_module.php +++ /dev/null @@ -1,350 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_module Form Controller - */ -class ComponentbuilderControllerJoomla_module extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Joomla_modules'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('joomla_module.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('joomla_module.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('joomla_module.access', 'com_componentbuilder.joomla_module.' . (int) $recordId) && $user->authorise('joomla_module.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('joomla_module.edit', 'com_componentbuilder.joomla_module.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('joomla_module.edit.own', 'com_componentbuilder.joomla_module.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('joomla_module.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('joomla_module.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Joomla_module', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_modules' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - // get the state object (Joomla\CMS\Object\CMSObject) - $state = $model->get('state'); - // if we save2copy we need to also copy linked tables found! - if ($state->task === 'save2copy' && $state->{'joomla_plugin.new'}) - { - // get new ID - $newID = $state->{'joomla_module.id'}; - // get old ID - $oldID = $this->input->get('id', 0, 'INT'); - // linked tables to update - $_tablesArray = array( - 'joomla_module_updates' => 'joomla_module', - 'joomla_module_files_folders_urls' => 'joomla_module' - ); - foreach($_tablesArray as $_updateTable => $_key) - { - // get the linked ID - if ($_value = ComponentbuilderHelper::getVar($_updateTable, $oldID, $_key, 'id')) - { - // copy fields to new linked table - ComponentbuilderHelper::copyItem(/*id->*/ $_value, /*table->*/ $_updateTable, /*change->*/ array($_key => $newID)); - } - } - } - - - return; - } - -} diff --git a/admin/controllers/joomla_module_files_folders_urls.php b/admin/controllers/joomla_module_files_folders_urls.php deleted file mode 100644 index 403b2dab4..000000000 --- a/admin/controllers/joomla_module_files_folders_urls.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_module_files_folders_urls Form Controller - */ -class ComponentbuilderControllerJoomla_module_files_folders_urls extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Joomla_modules_files_folders_urls'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('joomla_module_files_folders_urls.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('joomla_module_files_folders_urls.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('joomla_module_files_folders_urls.access', 'com_componentbuilder.joomla_module_files_folders_urls.' . (int) $recordId) && $user->authorise('joomla_module_files_folders_urls.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('joomla_module_files_folders_urls.edit', 'com_componentbuilder.joomla_module_files_folders_urls.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('joomla_module_files_folders_urls.edit.own', 'com_componentbuilder.joomla_module_files_folders_urls.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('joomla_module_files_folders_urls.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('joomla_module_files_folders_urls.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Joomla_module_files_folders_urls', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_modules_files_folders_urls' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/joomla_module_updates.php b/admin/controllers/joomla_module_updates.php deleted file mode 100644 index dcc8d6c5a..000000000 --- a/admin/controllers/joomla_module_updates.php +++ /dev/null @@ -1,344 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; -use VDM\Joomla\Utilities\StringHelper; - -/** - * Joomla_module_updates Form Controller - */ -class ComponentbuilderControllerJoomla_module_updates extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Joomla_modules_updates'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('joomla_module_updates.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('joomla_module_updates.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('joomla_module_updates.access', 'com_componentbuilder.joomla_module_updates.' . (int) $recordId) && $user->authorise('joomla_module_updates.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('joomla_module_updates.edit', 'com_componentbuilder.joomla_module_updates.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('joomla_module_updates.edit.own', 'com_componentbuilder.joomla_module_updates.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('joomla_module_updates.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('joomla_module_updates.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Joomla_module_updates', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_modules_updates' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - // update the component version to match the updated last version - if (isset($validData['joomla_plugin']) && is_numeric($validData['joomla_plugin']) && $validData['joomla_plugin'] > 0) - { - $objectUpdate = new stdClass(); - $objectUpdate->id = (int) $validData['joomla_plugin']; - if (isset($validData['version_update']) && UtilitiesArrayHelper::check($validData['version_update']) - && ($plugin_version = end($validData['version_update'])['version']) - && StringHelper::check($plugin_version)) - { - $objectUpdate->plugin_version = $plugin_version; - } - // be sure to update the table if we have a value - if (isset($objectUpdate->plugin_version)) - { - JFactory::getDbo()->updateObject('#__componentbuilder_joomla_plugin', $objectUpdate, 'id'); - } - } - - return; - } - -} diff --git a/admin/controllers/joomla_modules.php b/admin/controllers/joomla_modules.php deleted file mode 100644 index 4ba53b413..000000000 --- a/admin/controllers/joomla_modules.php +++ /dev/null @@ -1,118 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_modules Admin Controller - */ -class ComponentbuilderControllerJoomla_modules extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_MODULES'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Joomla_module', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('joomla_module.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - $pks = ArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Joomla_modules'); - // get the data to export - $data = $model->getExportData($pks); - if (ComponentbuilderHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - ComponentbuilderHelper::xls($data,'Joomla_modules_'.$date->format('jS_F_Y'),'Joomla modules exported ('.$date->format('jS F, Y').')','joomla modules'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_modules', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('joomla_module.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - // Get the import model - $model = $this->getModel('Joomla_modules'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (ComponentbuilderHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('joomla_module_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'joomla_modules'); - $session->set('dataType_VDM_IMPORTINTO', 'joomla_module'); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_JOOMLA_MODULES'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_modules', false), $message, 'error'); - return; - } - - public function getSnippets() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the import snippets custom admin view - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=get_snippets', false)); - return; - } -} \ No newline at end of file diff --git a/admin/controllers/joomla_modules_files_folders_urls.php b/admin/controllers/joomla_modules_files_folders_urls.php deleted file mode 100644 index 27d9a53c6..000000000 --- a/admin/controllers/joomla_modules_files_folders_urls.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_modules_files_folders_urls Admin Controller - */ -class ComponentbuilderControllerJoomla_modules_files_folders_urls extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_MODULES_FILES_FOLDERS_URLS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Joomla_module_files_folders_urls', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/joomla_modules_updates.php b/admin/controllers/joomla_modules_updates.php deleted file mode 100644 index db28e620c..000000000 --- a/admin/controllers/joomla_modules_updates.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_modules_updates Admin Controller - */ -class ComponentbuilderControllerJoomla_modules_updates extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Joomla_module_updates', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/joomla_plugin.php b/admin/controllers/joomla_plugin.php deleted file mode 100644 index 23639480f..000000000 --- a/admin/controllers/joomla_plugin.php +++ /dev/null @@ -1,350 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_plugin Form Controller - */ -class ComponentbuilderControllerJoomla_plugin extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Joomla_plugins'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('joomla_plugin.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('joomla_plugin.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('joomla_plugin.access', 'com_componentbuilder.joomla_plugin.' . (int) $recordId) && $user->authorise('joomla_plugin.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('joomla_plugin.edit', 'com_componentbuilder.joomla_plugin.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('joomla_plugin.edit.own', 'com_componentbuilder.joomla_plugin.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('joomla_plugin.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('joomla_plugin.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Joomla_plugin', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_plugins' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - // get the state object (Joomla\CMS\Object\CMSObject) - $state = $model->get('state'); - // if we save2copy we need to also copy linked tables found! - if ($state->task === 'save2copy' && $state->{'joomla_plugin.new'}) - { - // get new ID - $newID = $state->{'joomla_plugin.id'}; - // get old ID - $oldID = $this->input->get('id', 0, 'INT'); - // linked tables to update - $_tablesArray = array( - 'joomla_plugin_updates' => 'joomla_plugin', - 'joomla_plugin_files_folders_urls' => 'joomla_plugin' - ); - foreach($_tablesArray as $_updateTable => $_key) - { - // get the linked ID - if ($_value = ComponentbuilderHelper::getVar($_updateTable, $oldID, $_key, 'id')) - { - // copy fields to new linked table - ComponentbuilderHelper::copyItem(/*id->*/ $_value, /*table->*/ $_updateTable, /*change->*/ array($_key => $newID)); - } - } - } - - - return; - } - -} diff --git a/admin/controllers/joomla_plugin_files_folders_urls.php b/admin/controllers/joomla_plugin_files_folders_urls.php deleted file mode 100644 index 8953cfd21..000000000 --- a/admin/controllers/joomla_plugin_files_folders_urls.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_plugin_files_folders_urls Form Controller - */ -class ComponentbuilderControllerJoomla_plugin_files_folders_urls extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Joomla_plugins_files_folders_urls'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('joomla_plugin_files_folders_urls.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('joomla_plugin_files_folders_urls.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('joomla_plugin_files_folders_urls.access', 'com_componentbuilder.joomla_plugin_files_folders_urls.' . (int) $recordId) && $user->authorise('joomla_plugin_files_folders_urls.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('joomla_plugin_files_folders_urls.edit', 'com_componentbuilder.joomla_plugin_files_folders_urls.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('joomla_plugin_files_folders_urls.edit.own', 'com_componentbuilder.joomla_plugin_files_folders_urls.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('joomla_plugin_files_folders_urls.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('joomla_plugin_files_folders_urls.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Joomla_plugin_files_folders_urls', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_plugins_files_folders_urls' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/joomla_plugin_group.php b/admin/controllers/joomla_plugin_group.php deleted file mode 100644 index c2a179534..000000000 --- a/admin/controllers/joomla_plugin_group.php +++ /dev/null @@ -1,317 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_plugin_group Form Controller - */ -class ComponentbuilderControllerJoomla_plugin_group extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Joomla_plugin_groups'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('joomla_plugin_group.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return parent::allowAdd($data); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('core.edit', 'com_componentbuilder.joomla_plugin_group.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('core.edit.own', 'com_componentbuilder.joomla_plugin_group.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('core.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return parent::allowEdit($data, $key); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Joomla_plugin_group', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_plugin_groups' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/joomla_plugin_groups.php b/admin/controllers/joomla_plugin_groups.php deleted file mode 100644 index 2961669d3..000000000 --- a/admin/controllers/joomla_plugin_groups.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_plugin_groups Admin Controller - */ -class ComponentbuilderControllerJoomla_plugin_groups extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUPS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Joomla_plugin_group', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/joomla_plugin_updates.php b/admin/controllers/joomla_plugin_updates.php deleted file mode 100644 index be329f3a7..000000000 --- a/admin/controllers/joomla_plugin_updates.php +++ /dev/null @@ -1,344 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; -use VDM\Joomla\Utilities\StringHelper; - -/** - * Joomla_plugin_updates Form Controller - */ -class ComponentbuilderControllerJoomla_plugin_updates extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Joomla_plugins_updates'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('joomla_plugin_updates.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('joomla_plugin_updates.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('joomla_plugin_updates.access', 'com_componentbuilder.joomla_plugin_updates.' . (int) $recordId) && $user->authorise('joomla_plugin_updates.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('joomla_plugin_updates.edit', 'com_componentbuilder.joomla_plugin_updates.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('joomla_plugin_updates.edit.own', 'com_componentbuilder.joomla_plugin_updates.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('joomla_plugin_updates.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('joomla_plugin_updates.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Joomla_plugin_updates', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_plugins_updates' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - // update the component version to match the updated last version - if (isset($validData['joomla_plugin']) && is_numeric($validData['joomla_plugin']) && $validData['joomla_plugin'] > 0) - { - $objectUpdate = new stdClass(); - $objectUpdate->id = (int) $validData['joomla_plugin']; - if (isset($validData['version_update']) && UtilitiesArrayHelper::check($validData['version_update']) - && ($plugin_version = end($validData['version_update'])['version']) - && StringHelper::check($plugin_version)) - { - $objectUpdate->plugin_version = $plugin_version; - } - // be sure to update the table if we have a value - if (isset($objectUpdate->plugin_version)) - { - JFactory::getDbo()->updateObject('#__componentbuilder_joomla_plugin', $objectUpdate, 'id'); - } - } - - return; - } - -} diff --git a/admin/controllers/joomla_plugins.php b/admin/controllers/joomla_plugins.php deleted file mode 100644 index 67c7ebc02..000000000 --- a/admin/controllers/joomla_plugins.php +++ /dev/null @@ -1,140 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\StringHelper; - -/** - * Joomla_plugins Admin Controller - */ -class ComponentbuilderControllerJoomla_plugins extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_PLUGINS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Joomla_plugin', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - - /** - * Run the Expansion - * - * @return void - */ - public function runExpansion() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - // check if user has the right - $user = JFactory::getUser(); - // set page redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=joomla_plugins', false); - // set massage - $message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE'); - // check if this user has the right to run expansion - if($user->authorise('joomla_plugins.run_expansion', 'com_componentbuilder')) - { - // set massage - $message = JText::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB'); - // run expansion via API - $result = ComponentbuilderHelper::getFileContents(JURI::root() . 'index.php?option=com_componentbuilder&task=api.expand'); - // is there a message returned - if (!is_numeric($result) && StringHelper::check($result)) - { - $this->setRedirect($redirect_url, $result); - return true; - } - elseif (is_numeric($result) && 1 == $result) - { - $message = JText::_('COM_COMPONENTBUILDER_BTHE_EXPANSION_WAS_SUCCESSFULLYB_TO_SEE_MORE_INFORMATION_CHANGE_THE_BRETURN_OPTIONS_FOR_BUILDB_TO_BDISPLAY_MESSAGEB_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TABB'); - $this->setRedirect($redirect_url, $message, 'message'); - return true; - } - } - $this->setRedirect($redirect_url, $message, 'error'); - return false; - } - - - /** - * get Boilerplate - * - * @return boolean - */ - public function getBoilerplate() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - // check if user has the right - $user = JFactory::getUser(); - // set page redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=joomla_plugins', false); - // set massage - $message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_GET_BOILERPLATE_MODULE'); - // check if this user has the right to run expansion - if($user->authorise('joomla_plugin.get_boilerplate', 'com_componentbuilder')) - { - // set massage - $message = JText::_('COM_COMPONENTBUILDER_GETTING_JOOMLA_PLUGIN_BOILERPLATE_FAILED_IF_THE_ISSUE_CONTINUES_INFORM_YOUR_SYSTEM_ADMINISTRATOR'); - // Get the model - $model = $this->getModel('joomla_plugins'); - // check if there is any selections - if (!$model->getBoilerplate()) - { - $message = '' . JText::_('COM_COMPONENTBUILDER_GETTING_JOOMLA_PLUGIN_BOILERPLATE_WAS_SUCCESSFULLY') . ''; - $this->setRedirect($redirect_url, $message, 'message'); - return true; - } - } - $this->setRedirect($redirect_url, $message, 'error'); - return false; - } - - public function openClassMethods() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the libraries - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=class_methods', false)); - return; - } - - public function openClassProperties() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the libraries - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=class_properties', false)); - return; - } -} \ No newline at end of file diff --git a/admin/controllers/joomla_plugins_files_folders_urls.php b/admin/controllers/joomla_plugins_files_folders_urls.php deleted file mode 100644 index fd9b6b0a3..000000000 --- a/admin/controllers/joomla_plugins_files_folders_urls.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_plugins_files_folders_urls Admin Controller - */ -class ComponentbuilderControllerJoomla_plugins_files_folders_urls extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Joomla_plugin_files_folders_urls', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/joomla_plugins_updates.php b/admin/controllers/joomla_plugins_updates.php deleted file mode 100644 index b8a1a74e3..000000000 --- a/admin/controllers/joomla_plugins_updates.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_plugins_updates Admin Controller - */ -class ComponentbuilderControllerJoomla_plugins_updates extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Joomla_plugin_updates', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/language.php b/admin/controllers/language.php deleted file mode 100644 index 8c0547099..000000000 --- a/admin/controllers/language.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Language Form Controller - */ -class ComponentbuilderControllerLanguage extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Languages'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('language.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('language.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('language.access', 'com_componentbuilder.language.' . (int) $recordId) && $user->authorise('language.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('language.edit', 'com_componentbuilder.language.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('language.edit.own', 'com_componentbuilder.language.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('language.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('language.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Language', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=languages' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/language_translation.php b/admin/controllers/language_translation.php deleted file mode 100644 index ead250d61..000000000 --- a/admin/controllers/language_translation.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Language_translation Form Controller - */ -class ComponentbuilderControllerLanguage_translation extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Language_translations'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('language_translation.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('language_translation.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('language_translation.access', 'com_componentbuilder.language_translation.' . (int) $recordId) && $user->authorise('language_translation.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('language_translation.edit', 'com_componentbuilder.language_translation.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('language_translation.edit.own', 'com_componentbuilder.language_translation.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('language_translation.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('language_translation.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Language_translation', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=language_translations' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/language_translations.php b/admin/controllers/language_translations.php deleted file mode 100644 index 3298e2523..000000000 --- a/admin/controllers/language_translations.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Language_translations Admin Controller - */ -class ComponentbuilderControllerLanguage_translations extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Language_translation', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('language_translation.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - $pks = ArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Language_translations'); - // get the data to export - $data = $model->getExportData($pks); - if (ComponentbuilderHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - ComponentbuilderHelper::xls($data,'Language_translations_'.$date->format('jS_F_Y'),'Language translations exported ('.$date->format('jS F, Y').')','language translations'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=language_translations', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('language_translation.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - // Get the import model - $model = $this->getModel('Language_translations'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (ComponentbuilderHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('language_translation_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'language_translations'); - $session->set('dataType_VDM_IMPORTINTO', 'language_translation'); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_LANGUAGE_TRANSLATIONS'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import_language_translations', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=language_translations', false), $message, 'error'); - return; - } -} \ No newline at end of file diff --git a/admin/controllers/languages.php b/admin/controllers/languages.php deleted file mode 100644 index 78dbc782e..000000000 --- a/admin/controllers/languages.php +++ /dev/null @@ -1,136 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Languages Admin Controller - */ -class ComponentbuilderControllerLanguages extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_LANGUAGES'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Language', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('language.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - $pks = ArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Languages'); - // get the data to export - $data = $model->getExportData($pks); - if (ComponentbuilderHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - ComponentbuilderHelper::xls($data,'Languages_'.$date->format('jS_F_Y'),'Languages exported ('.$date->format('jS F, Y').')','languages'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=languages', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('language.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - // Get the import model - $model = $this->getModel('Languages'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (ComponentbuilderHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('language_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'languages'); - $session->set('dataType_VDM_IMPORTINTO', 'language'); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_LANGUAGES'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=languages', false), $message, 'error'); - return; - } - - public function buildLanguages() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if user has the right - $user = JFactory::getUser(); - if($user->authorise('core.create', 'com_componentbuilder')) - { - // get the model - $model = $this->getModel('languages'); - if ($model->buildLanguages()) - { - // set success message - $message = '

'.JText::_('COM_COMPONENTBUILDER_IMPORT_SUCCESS').'

'; - $message .= '

'.JText::_('COM_COMPONENTBUILDER_ALL_THE_LANGUAGES_FOUND_IN_JOOMLA_WERE_SUCCESSFULLY_IMPORTED').'

'; - // set redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=languages', false); - $this->setRedirect($redirect_url, $message); - return true; - } - } - // set redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=languages', false); - $this->setRedirect($redirect_url); - return false; - } -} \ No newline at end of file diff --git a/admin/controllers/layout.php b/admin/controllers/layout.php deleted file mode 100644 index f10b523b8..000000000 --- a/admin/controllers/layout.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Layout Form Controller - */ -class ComponentbuilderControllerLayout extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Layouts'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('layout.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return parent::allowAdd($data); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('layout.access', 'com_componentbuilder.layout.' . (int) $recordId) && $user->authorise('layout.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('core.edit', 'com_componentbuilder.layout.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('core.edit.own', 'com_componentbuilder.layout.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('core.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return parent::allowEdit($data, $key); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Layout', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=layouts' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/layouts.php b/admin/controllers/layouts.php deleted file mode 100644 index 424d4f05a..000000000 --- a/admin/controllers/layouts.php +++ /dev/null @@ -1,118 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Layouts Admin Controller - */ -class ComponentbuilderControllerLayouts extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_LAYOUTS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Layout', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('layout.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - $pks = ArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Layouts'); - // get the data to export - $data = $model->getExportData($pks); - if (ComponentbuilderHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - ComponentbuilderHelper::xls($data,'Layouts_'.$date->format('jS_F_Y'),'Layouts exported ('.$date->format('jS F, Y').')','layouts'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=layouts', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('layout.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - // Get the import model - $model = $this->getModel('Layouts'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (ComponentbuilderHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('layout_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'layouts'); - $session->set('dataType_VDM_IMPORTINTO', 'layout'); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_LAYOUTS'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=layouts', false), $message, 'error'); - return; - } - - public function getSnippets() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the import snippets custom admin view - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=get_snippets', false)); - return; - } -} \ No newline at end of file diff --git a/admin/controllers/libraries.php b/admin/controllers/libraries.php deleted file mode 100644 index 65f8a664b..000000000 --- a/admin/controllers/libraries.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Libraries Admin Controller - */ -class ComponentbuilderControllerLibraries extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_LIBRARIES'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Library', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function getSnippets() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the import snippets custom admin view - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=get_snippets', false)); - return; - } -} \ No newline at end of file diff --git a/admin/controllers/libraries_config.php b/admin/controllers/libraries_config.php deleted file mode 100644 index ee88d885c..000000000 --- a/admin/controllers/libraries_config.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Libraries_config Admin Controller - */ -class ComponentbuilderControllerLibraries_config extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_LIBRARIES_CONFIG'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Library_config', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/libraries_files_folders_urls.php b/admin/controllers/libraries_files_folders_urls.php deleted file mode 100644 index 0b3b88967..000000000 --- a/admin/controllers/libraries_files_folders_urls.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Libraries_files_folders_urls Admin Controller - */ -class ComponentbuilderControllerLibraries_files_folders_urls extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Library_files_folders_urls', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/library.php b/admin/controllers/library.php deleted file mode 100644 index 3378e079b..000000000 --- a/admin/controllers/library.php +++ /dev/null @@ -1,349 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Library Form Controller - */ -class ComponentbuilderControllerLibrary extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Libraries'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('library.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('library.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('library.access', 'com_componentbuilder.library.' . (int) $recordId) && $user->authorise('library.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('library.edit', 'com_componentbuilder.library.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('library.edit.own', 'com_componentbuilder.library.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('library.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('library.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Library', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=libraries' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - // get the state object (Joomla\CMS\Object\CMSObject) - $state = $model->get('state'); - // if we save2copy we need to also copy linked tables found! - if ($state->task === 'save2copy' && $state->{'library.new'}) - { - // get new ID - $newID = $state->{'library.id'}; - // get old ID - $oldID = $this->input->get('id', 0, 'INT'); - // linked tables to update - $_tablesArray = array( - 'library_config', - 'library_files_folders_urls' - ); - foreach($_tablesArray as $_updateTable) - { - // get the linked ID - if ($_value = ComponentbuilderHelper::getVar($_updateTable, $oldID, 'library', 'id')) - { - // copy fields to new linked table - ComponentbuilderHelper::copyItem(/*id->*/ $_value, /*table->*/ $_updateTable, /*change->*/ array('library' => $newID)); - } - } - } - - return; - } - -} diff --git a/admin/controllers/library_config.php b/admin/controllers/library_config.php deleted file mode 100644 index ad2c27e2b..000000000 --- a/admin/controllers/library_config.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Library_config Form Controller - */ -class ComponentbuilderControllerLibrary_config extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Libraries_config'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('library_config.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('library_config.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('library_config.access', 'com_componentbuilder.library_config.' . (int) $recordId) && $user->authorise('library_config.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('library_config.edit', 'com_componentbuilder.library_config.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('library_config.edit.own', 'com_componentbuilder.library_config.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('library_config.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('library_config.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Library_config', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=libraries_config' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/library_files_folders_urls.php b/admin/controllers/library_files_folders_urls.php deleted file mode 100644 index 593f4d980..000000000 --- a/admin/controllers/library_files_folders_urls.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Library_files_folders_urls Form Controller - */ -class ComponentbuilderControllerLibrary_files_folders_urls extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Libraries_files_folders_urls'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('library_files_folders_urls.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('library_files_folders_urls.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('library_files_folders_urls.access', 'com_componentbuilder.library_files_folders_urls.' . (int) $recordId) && $user->authorise('library_files_folders_urls.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('library_files_folders_urls.edit', 'com_componentbuilder.library_files_folders_urls.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('library_files_folders_urls.edit.own', 'com_componentbuilder.library_files_folders_urls.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('library_files_folders_urls.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('library_files_folders_urls.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Library_files_folders_urls', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=libraries_files_folders_urls' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/placeholder.php b/admin/controllers/placeholder.php deleted file mode 100644 index dc841ef33..000000000 --- a/admin/controllers/placeholder.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Placeholder Form Controller - */ -class ComponentbuilderControllerPlaceholder extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Placeholders'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('placeholder.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('placeholder.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('placeholder.access', 'com_componentbuilder.placeholder.' . (int) $recordId) && $user->authorise('placeholder.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('placeholder.edit', 'com_componentbuilder.placeholder.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('placeholder.edit.own', 'com_componentbuilder.placeholder.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('placeholder.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('placeholder.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Placeholder', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=placeholders' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/placeholders.php b/admin/controllers/placeholders.php deleted file mode 100644 index d59a5cfc1..000000000 --- a/admin/controllers/placeholders.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Placeholders Admin Controller - */ -class ComponentbuilderControllerPlaceholders extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_PLACEHOLDERS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Placeholder', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('placeholder.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - $pks = ArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Placeholders'); - // get the data to export - $data = $model->getExportData($pks); - if (ComponentbuilderHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - ComponentbuilderHelper::xls($data,'Placeholders_'.$date->format('jS_F_Y'),'Placeholders exported ('.$date->format('jS F, Y').')','placeholders'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=placeholders', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('placeholder.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - // Get the import model - $model = $this->getModel('Placeholders'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (ComponentbuilderHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('placeholder_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'placeholders'); - $session->set('dataType_VDM_IMPORTINTO', 'placeholder'); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_PLACEHOLDERS'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=placeholders', false), $message, 'error'); - return; - } -} \ No newline at end of file diff --git a/admin/controllers/power.php b/admin/controllers/power.php deleted file mode 100644 index 4b4ebadad..000000000 --- a/admin/controllers/power.php +++ /dev/null @@ -1,381 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Componentbuilder\Power\Factory; - -/** - * Power Form Controller - */ -class ComponentbuilderControllerPower extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Powers'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - public function resetPowers() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - - // get Item posted - $item = $this->input->post->get('jform', array(), 'array'); - - // check if user has the right - $user = JFactory::getUser(); - - // set default error message - $message = '

' . JText::_('COM_COMPONENTBUILDER_PERMISSION_DENIED') . '

'; - $message .= '

' . JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RESET_THIS_POWER') . '

'; - $status = 'error'; - $success = false; - - // load the ID - $id = $item['id'] ?? null; - $guid = $item['guid'] ?? null; - - // check if there is any selections - if ($id === null || $guid === null) - { - // set error message - $message = '

' . JText::_('COM_COMPONENTBUILDER_NOT_SAVED') . '

'; - $message .= '

' . JText::_('COM_COMPONENTBUILDER_YOU_MUST_FIRST_SAVE_THE_POWER_BEFORE_YOU_CAN_USE_THIS_FEATURE') . '

'; - } - elseif($user->authorise('power.reset', 'com_componentbuilder')) - { - if (Factory::_('Superpower')->reset([$guid])) - { - // set success message - $message = '

'.JText::_('COM_COMPONENTBUILDER_SUCCESS').'

'; - $message .= '

'.JText::_('COM_COMPONENTBUILDER_THE_POWER_HAS_SUCCESSFULLY_BEEN_RESET').'

'; - $status = 'success'; - $success = true; - } - else - { - $message = '

' . JText::_('COM_COMPONENTBUILDER_RESET_FAILED') . '

'; - $message .= '

' . JText::_('COM_COMPONENTBUILDER_THE_RESET_OF_THIS_POWER_HAS_FAILED') . '

'; - } - } - - // set redirect - $redirect_url = \JRoute::_( - 'index.php?option=com_componentbuilder&view=power' - . $this->getRedirectToItemAppend($id), $success - ); - - $this->setRedirect($redirect_url, $message, $status); - - return $success; - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('power.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('power.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('power.access', 'com_componentbuilder.power.' . (int) $recordId) && $user->authorise('power.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('power.edit', 'com_componentbuilder.power.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('power.edit.own', 'com_componentbuilder.power.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('power.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('power.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Power', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=powers' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/powers.php b/admin/controllers/powers.php deleted file mode 100644 index c7eac403a..000000000 --- a/admin/controllers/powers.php +++ /dev/null @@ -1,168 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\StringHelper; -use VDM\Joomla\Componentbuilder\Power\Factory; - -/** - * Powers Admin Controller - */ -class ComponentbuilderControllerPowers extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_POWERS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Power', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - - /** - * Run the Expansion - * - * @return void - */ - public function runExpansion() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - // check if user has the right - $user = JFactory::getUser(); - // set page redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=powers', false); - // set massage - $message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE'); - // check if this user has the right to run expansion - if($user->authorise('powers.run_expansion', 'com_componentbuilder')) - { - // set massage - $message = JText::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB'); - // run expansion via API - $result = ComponentbuilderHelper::getFileContents(JURI::root() . 'index.php?option=com_componentbuilder&task=api.expand'); - // is there a message returned - if (!is_numeric($result) && StringHelper::check($result)) - { - $this->setRedirect($redirect_url, $result); - return true; - } - elseif (is_numeric($result) && 1 == $result) - { - $message = JText::_('COM_COMPONENTBUILDER_BTHE_EXPANSION_WAS_SUCCESSFULLYB_TO_SEE_MORE_INFORMATION_CHANGE_THE_BRETURN_OPTIONS_FOR_BUILDB_TO_BDISPLAY_MESSAGEB_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TABB'); - $this->setRedirect($redirect_url, $message, 'message'); - return true; - } - } - $this->setRedirect($redirect_url, $message, 'error'); - return false; - } - - public function initPowers() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - - // check if user has the right - $user = JFactory::getUser(); - - // set default error message - $message = '

' . JText::_('COM_COMPONENTBUILDER_PERMISSION_DENIED') . '

'; - $message .= '

' . JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_INITIALIZE_POWERS') . '

'; - $status = 'error'; - $success = false; - - if($user->authorise('power.init', 'com_componentbuilder')) - { - if (Factory::_('Superpower')->init()) - { - // set success message - $message = '

' . JText::_('COM_COMPONENTBUILDER_SUCCESSFULLY_INITIALIZED_ALL_REMOTE_POWERS') . '

'; - $message .= '

' . JText::_('COM_COMPONENTBUILDER_THE_LOCAL_DATABASE_POWERS_HAS_SUCCESSFULLY_BEEN_SYNCED_WITH_THE_REMOTE_REPOSITORIES') . '

'; - - $status = 'success'; - $success = true; - } - else - { - $message = '

' . JText::_('COM_COMPONENTBUILDER_INITIALIZATION_FAILED') . '

'; - $message .= '

' . JText::_('COM_COMPONENTBUILDER_THE_INITIALIZATION_OF_THIS_POWERS_HAS_FAILED') . '

'; - } - } - - // set redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=powers', $success); - $this->setRedirect($redirect_url, $message, $status); - - return $success; - } - - public function resetPowers() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - - // get IDS of the selected powers - $pks = $this->input->post->get('cid', [], 'array'); - - // Sanitize the input - JArrayHelper::toInteger($pks); - - // check if there is any selections - if ($pks == []) - { - // set error message - $message = '

'.JText::_('COM_COMPONENTBUILDER_NO_SELECTION_DETECTED').'

'; - $message .= '

'.JText::_('COM_COMPONENTBUILDER_PLEASE_FIRST_MAKE_A_SELECTION_FROM_THE_LIST').'

'; - // set redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=powers', false); - $this->setRedirect($redirect_url, $message, 'error'); - return false; - } - - // check if user has the right - $user = JFactory::getUser(); - if($user->authorise('power.reset', 'com_componentbuilder')) - { - // set success message - $message = '

'.JText::_('COM_COMPONENTBUILDER_THIS_RESET_FEATURE_IS_STILL_UNDER_DEVELOPMENT').'

'; - $message .= '

'.JText::sprintf('COM_COMPONENTBUILDER_PLEASE_CHECK_AGAIN_SOON_ANDOR_FOLLOW_THE_PROGRESS_ON_SGITVDMDEVA', '').'

'; - // set redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=powers', false); - $this->setRedirect($redirect_url, $message); - return true; - } - // set redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=powers', false); - $this->setRedirect($redirect_url); - return false; - } -} \ No newline at end of file diff --git a/admin/controllers/search.php b/admin/controllers/search.php deleted file mode 100644 index 041c25ecd..000000000 --- a/admin/controllers/search.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\BaseController; -use Joomla\Utilities\ArrayHelper; - -/** - * Componentbuilder Search Base Controller - */ -class ComponentbuilderControllerSearch extends BaseController -{ - public function __construct($config) - { - parent::__construct($config); - } - - public function dashboard() - { - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder', false)); - return; - } - - public function openCompiler() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the libraries - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=compiler', false)); - return; - } -} diff --git a/admin/controllers/server.php b/admin/controllers/server.php deleted file mode 100644 index fe4552756..000000000 --- a/admin/controllers/server.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Server Form Controller - */ -class ComponentbuilderControllerServer extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Servers'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('server.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('server.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('server.access', 'com_componentbuilder.server.' . (int) $recordId) && $user->authorise('server.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('server.edit', 'com_componentbuilder.server.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('server.edit.own', 'com_componentbuilder.server.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('server.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('server.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Server', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=servers' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/servers.php b/admin/controllers/servers.php deleted file mode 100644 index d18d9b162..000000000 --- a/admin/controllers/servers.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Servers Admin Controller - */ -class ComponentbuilderControllerServers extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_SERVERS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Server', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('server.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - $pks = ArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Servers'); - // get the data to export - $data = $model->getExportData($pks); - if (ComponentbuilderHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - ComponentbuilderHelper::xls($data,'Servers_'.$date->format('jS_F_Y'),'Servers exported ('.$date->format('jS F, Y').')','servers'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=servers', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('server.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - // Get the import model - $model = $this->getModel('Servers'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (ComponentbuilderHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('server_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'servers'); - $session->set('dataType_VDM_IMPORTINTO', 'server'); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_SERVERS'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=servers', false), $message, 'error'); - return; - } -} \ No newline at end of file diff --git a/admin/controllers/site_view.php b/admin/controllers/site_view.php deleted file mode 100644 index 902fab2ef..000000000 --- a/admin/controllers/site_view.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Site_view Form Controller - */ -class ComponentbuilderControllerSite_view extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Site_views'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('site_view.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return parent::allowAdd($data); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('site_view.access', 'com_componentbuilder.site_view.' . (int) $recordId) && $user->authorise('site_view.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('core.edit', 'com_componentbuilder.site_view.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('core.edit.own', 'com_componentbuilder.site_view.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('core.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return parent::allowEdit($data, $key); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Site_view', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=site_views' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/site_views.php b/admin/controllers/site_views.php deleted file mode 100644 index 1816faab1..000000000 --- a/admin/controllers/site_views.php +++ /dev/null @@ -1,118 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Site_views Admin Controller - */ -class ComponentbuilderControllerSite_views extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_SITE_VIEWS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Site_view', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('site_view.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - $pks = ArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Site_views'); - // get the data to export - $data = $model->getExportData($pks); - if (ComponentbuilderHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - ComponentbuilderHelper::xls($data,'Site_views_'.$date->format('jS_F_Y'),'Site views exported ('.$date->format('jS F, Y').')','site views'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=site_views', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('site_view.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - // Get the import model - $model = $this->getModel('Site_views'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (ComponentbuilderHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('site_view_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'site_views'); - $session->set('dataType_VDM_IMPORTINTO', 'site_view'); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_SITE_VIEWS'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=site_views', false), $message, 'error'); - return; - } - - public function getSnippets() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the import snippets custom admin view - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=get_snippets', false)); - return; - } -} \ No newline at end of file diff --git a/admin/controllers/snippet.php b/admin/controllers/snippet.php deleted file mode 100644 index 914cf7a12..000000000 --- a/admin/controllers/snippet.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Snippet Form Controller - */ -class ComponentbuilderControllerSnippet extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Snippets'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('snippet.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return parent::allowAdd($data); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('snippet.access', 'com_componentbuilder.snippet.' . (int) $recordId) && $user->authorise('snippet.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('core.edit', 'com_componentbuilder.snippet.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('core.edit.own', 'com_componentbuilder.snippet.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('core.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return parent::allowEdit($data, $key); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Snippet', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=snippets' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/snippet_type.php b/admin/controllers/snippet_type.php deleted file mode 100644 index b94c8a784..000000000 --- a/admin/controllers/snippet_type.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Snippet_type Form Controller - */ -class ComponentbuilderControllerSnippet_type extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Snippet_types'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('snippet_type.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('snippet_type.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('snippet_type.access', 'com_componentbuilder.snippet_type.' . (int) $recordId) && $user->authorise('snippet_type.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('snippet_type.edit', 'com_componentbuilder.snippet_type.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('snippet_type.edit.own', 'com_componentbuilder.snippet_type.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('snippet_type.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('snippet_type.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Snippet_type', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=snippet_types' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/snippet_types.php b/admin/controllers/snippet_types.php deleted file mode 100644 index 5efe65113..000000000 --- a/admin/controllers/snippet_types.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Snippet_types Admin Controller - */ -class ComponentbuilderControllerSnippet_types extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_SNIPPET_TYPES'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Snippet_type', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } -} \ No newline at end of file diff --git a/admin/controllers/snippets.php b/admin/controllers/snippets.php deleted file mode 100644 index e0fe12a80..000000000 --- a/admin/controllers/snippets.php +++ /dev/null @@ -1,183 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; - -/** - * Snippets Admin Controller - */ -class ComponentbuilderControllerSnippets extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_SNIPPETS'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Snippet', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('snippet.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - $pks = ArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Snippets'); - // get the data to export - $data = $model->getExportData($pks); - if (ComponentbuilderHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - ComponentbuilderHelper::xls($data,'Snippets_'.$date->format('jS_F_Y'),'Snippets exported ('.$date->format('jS F, Y').')','snippets'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=snippets', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('snippet.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - // Get the import model - $model = $this->getModel('Snippets'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (ComponentbuilderHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('snippet_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'snippets'); - $session->set('dataType_VDM_IMPORTINTO', 'snippet'); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_SNIPPETS'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=snippets', false), $message, 'error'); - return; - } - - public function getSnippets() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the import snippets custom admin view - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=get_snippets', false)); - return; - } - - public function shareSnippets() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // Get the model - $model = $this->getModel('snippets'); - // check if import is allowed for this user. - $model->user = JFactory::getUser(); - if ($model->user->authorise('snippet.import', 'com_componentbuilder') && $model->user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - JArrayHelper::toInteger($pks); - // check if there is any selections - if (!UtilitiesArrayHelper::check($pks)) - { - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_NO_SNIPPETS_WERE_SELECTED_PLEASE_MAKE_A_SELECTION_AND_TRY_AGAIN'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=snippets', false), $message, 'error'); - return; - } - // set auto loader - ComponentbuilderHelper::autoLoader('smart'); - // get the data to export - if ($model->shareSnippets($pks)) - { - // Message of successful build - if (count($pks) > 1) - { - $message = '

' . JText::_('COM_COMPONENTBUILDER_THE_SNIPPETS_WERE_SUCCESSFULLY_EXPORTED') . '

'; - $message .= '

' . JText::sprintf('COM_COMPONENTBUILDER_TO_SHARE_THESE_SNIPPETS_WITH_THE_REST_OF_THE_JCB_COMMUNITY'); - } - else - { - $message = '

' . JText::_('COM_COMPONENTBUILDER_THE_SNIPPET_WAS_SUCCESSFULLY_EXPORTED') . '

'; - $message .= '

' . JText::sprintf('COM_COMPONENTBUILDER_TO_SHARE_THIS_SNIPPET_WITH_THE_REST_OF_THE_JCB_COMMUNITY'); - } - $message .= JText::sprintf('COM_COMPONENTBUILDER_YOU_WILL_NEED_TO_KNOW_HOW_S_WORKS_BASIC_YOU_WILL_ALSO_NEED_A_S_ACCOUNT_AND_KNOW_HOW_TO_MAKE_A_PULL_REQUEST_ON_GITHUB', - 'git', - 'github.com') . '

'; - - $message .= '

' . JText::_('COM_COMPONENTBUILDER_NEED_HELP') . '

'; - $message .= ''; - $message .= '

' . JText::_('COM_COMPONENTBUILDER_ZIPPED_FILE_LOCATION') . '

'; - $message .= '

' . JText::sprintf('COM_COMPONENTBUILDER_PATH_CODESCODE', $model->zipPath). '

'; - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=snippets', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_SHARE_THE_SNIPPETS_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_HELP'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=snippets', false), $message, 'error'); - return; - } -} \ No newline at end of file diff --git a/admin/controllers/template.php b/admin/controllers/template.php deleted file mode 100644 index 619dd4ccb..000000000 --- a/admin/controllers/template.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Template Form Controller - */ -class ComponentbuilderControllerTemplate extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Templates'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('template.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return parent::allowAdd($data); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('template.access', 'com_componentbuilder.template.' . (int) $recordId) && $user->authorise('template.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('core.edit', 'com_componentbuilder.template.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('core.edit.own', 'com_componentbuilder.template.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('core.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return parent::allowEdit($data, $key); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Template', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=templates' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/templates.php b/admin/controllers/templates.php deleted file mode 100644 index eaa9eba37..000000000 --- a/admin/controllers/templates.php +++ /dev/null @@ -1,118 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; - -/** - * Templates Admin Controller - */ -class ComponentbuilderControllerTemplates extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_TEMPLATES'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Template', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('template.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - $pks = ArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Templates'); - // get the data to export - $data = $model->getExportData($pks); - if (ComponentbuilderHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - ComponentbuilderHelper::xls($data,'Templates_'.$date->format('jS_F_Y'),'Templates exported ('.$date->format('jS F, Y').')','templates'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=templates', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('template.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - // Get the import model - $model = $this->getModel('Templates'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (ComponentbuilderHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('template_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'templates'); - $session->set('dataType_VDM_IMPORTINTO', 'template'); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_TEMPLATES'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=templates', false), $message, 'error'); - return; - } - - public function getSnippets() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the import snippets custom admin view - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=get_snippets', false)); - return; - } -} \ No newline at end of file diff --git a/admin/controllers/validation_rule.php b/admin/controllers/validation_rule.php deleted file mode 100644 index e1dba43ac..000000000 --- a/admin/controllers/validation_rule.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; - -/** - * Validation_rule Form Controller - */ -class ComponentbuilderControllerValidation_rule extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - /** - * Class constructor. - * - * @param array $config A named array of configuration variables. - * - * @since 1.6 - */ - public function __construct($config = array()) - { - $this->view_list = 'Validation_rules'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // Get user object. - $user = JFactory::getUser(); - // Access check. - $access = $user->authorise('validation_rule.access', 'com_componentbuilder'); - if (!$access) - { - return false; - } - - // In the absence of better information, revert to the component permissions. - return $user->authorise('validation_rule.create', $this->option); - } - - /** - * Method override to check if you can edit an existing record. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // get user object. - $user = JFactory::getUser(); - // get record id. - $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - - - // Access check. - $access = ($user->authorise('validation_rule.access', 'com_componentbuilder.validation_rule.' . (int) $recordId) && $user->authorise('validation_rule.access', 'com_componentbuilder')); - if (!$access) - { - return false; - } - - if ($recordId) - { - // The record has been set. Check the record permissions. - $permission = $user->authorise('validation_rule.edit', 'com_componentbuilder.validation_rule.' . (int) $recordId); - if (!$permission) - { - if ($user->authorise('validation_rule.edit.own', 'com_componentbuilder.validation_rule.' . $recordId)) - { - // Now test the owner is the user. - $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; - if (empty($ownerId)) - { - // Need to do a lookup from the model. - $record = $this->getModel()->getItem($recordId); - - if (empty($record)) - { - return false; - } - $ownerId = $record->created_by; - } - - // If the owner matches 'me' then allow. - if ($ownerId == $user->id) - { - if ($user->authorise('validation_rule.edit.own', 'com_componentbuilder')) - { - return true; - } - } - } - return false; - } - } - // Since there is no permission, revert to the component permissions. - return $user->authorise('validation_rule.edit', $this->option); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 1.6 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - // get the referral options (old method use return instead see parent) - $ref = $this->input->get('ref', 0, 'string'); - $refid = $this->input->get('refid', 0, 'int'); - - // get redirect info. - $append = parent::getRedirectToItemAppend($recordId, $urlVar); - - // set the referral options - if ($refid && $ref) - { - $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; - } - elseif ($ref) - { - $append = '&ref='. (string)$ref . $append; - } - - return $append; - } - - /** - * Method to run batch operations. - * - * @param object $model The model. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 2.5 - */ - public function batch($model = null) - { - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Set the model - $model = $this->getModel('Validation_rule', '', array()); - - // Preset the redirect - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=validation_rules' . $this->getRedirectToListAppend(), false)); - - return parent::batch($model); - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 12.2 - */ - public function cancel($key = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - - $cancel = parent::cancel($key); - - if (!is_null($return) && JUri::isInternal(base64_decode($return))) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view='.(string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $cancel; - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // get the referral options - $this->ref = $this->input->get('ref', 0, 'word'); - $this->refid = $this->input->get('refid', 0, 'int'); - - // Check if there is a return value - $return = $this->input->get('return', null, 'base64'); - $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); - - if ($this->ref || $this->refid || $canReturn) - { - // to make sure the item is checkedin on redirect - $this->task = 'save'; - } - - $saved = parent::save($key, $urlVar); - - // This is not needed since parent save already does this - // Due to the ref and refid implementation we need to add this - if ($canReturn) - { - $redirect = base64_decode($return); - - // Redirect to the return value. - $this->setRedirect( - JRoute::_( - $redirect, false - ) - ); - } - elseif ($this->refid && $this->ref) - { - $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; - - // Redirect to the item screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - elseif ($this->ref) - { - $redirect = '&view=' . (string)$this->ref; - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . $redirect, false - ) - ); - } - return $saved; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - return; - } - -} diff --git a/admin/controllers/validation_rules.php b/admin/controllers/validation_rules.php deleted file mode 100644 index 1e87bae50..000000000 --- a/admin/controllers/validation_rules.php +++ /dev/null @@ -1,151 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\AdminController; -use Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\StringHelper; - -/** - * Validation_rules Admin Controller - */ -class ComponentbuilderControllerValidation_rules extends AdminController -{ - /** - * The prefix to use with controller messages. - * - * @var string - * @since 1.6 - */ - protected $text_prefix = 'COM_COMPONENTBUILDER_VALIDATION_RULES'; - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JModelLegacy The model. - * - * @since 1.6 - */ - public function getModel($name = 'Validation_rule', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true)) - { - return parent::getModel($name, $prefix, $config); - } - - public function exportData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if export is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('validation_rule.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - // Sanitize the input - $pks = ArrayHelper::toInteger($pks); - // Get the model - $model = $this->getModel('Validation_rules'); - // get the data to export - $data = $model->getExportData($pks); - if (ComponentbuilderHelper::checkArray($data)) - { - // now set the data to the spreadsheet - $date = JFactory::getDate(); - ComponentbuilderHelper::xls($data,'Validation_rules_'.$date->format('jS_F_Y'),'Validation rules exported ('.$date->format('jS F, Y').')','validation rules'); - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=validation_rules', false), $message, 'error'); - return; - } - - - public function importData() - { - // Check for request forgeries - JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // check if import is allowed for this user. - $user = JFactory::getUser(); - if ($user->authorise('validation_rule.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) - { - // Get the import model - $model = $this->getModel('Validation_rules'); - // get the headers to import - $headers = $model->getExImPortHeaders(); - if (ComponentbuilderHelper::checkObject($headers)) - { - // Load headers to session. - $session = JFactory::getSession(); - $headers = json_encode($headers); - $session->set('validation_rule_VDM_IMPORTHEADERS', $headers); - $session->set('backto_VDM_IMPORT', 'validation_rules'); - $session->set('dataType_VDM_IMPORTINTO', 'validation_rule'); - // Redirect to import view. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_VALIDATION_RULES'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import', false), $message); - return; - } - } - // Redirect to the list screen with error. - $message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=validation_rules', false), $message, 'error'); - return; - } - - - /** - * Run the Expansion - * - * @return void - */ - public function runExpansion() - { - // Check for request forgeries - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - // check if user has the right - $user = JFactory::getUser(); - // set page redirect - $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=validation_rules', false); - // set massage - $message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE'); - // check if this user has the right to run expansion - if($user->authorise('validation_rules.run_expansion', 'com_componentbuilder')) - { - // set massage - $message = JText::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB'); - // run expansion via API - $result = ComponentbuilderHelper::getFileContents(JURI::root() . 'index.php?option=com_componentbuilder&task=api.expand'); - // is there a message returned - if (!is_numeric($result) && StringHelper::check($result)) - { - $this->setRedirect($redirect_url, $result); - return true; - } - elseif (is_numeric($result) && 1 == $result) - { - $message = JText::_('COM_COMPONENTBUILDER_BTHE_EXPANSION_WAS_SUCCESSFULLYB_TO_SEE_MORE_INFORMATION_CHANGE_THE_BRETURN_OPTIONS_FOR_BUILDB_TO_BDISPLAY_MESSAGEB_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TABB'); - $this->setRedirect($redirect_url, $message, 'message'); - return true; - } - } - $this->setRedirect($redirect_url, $message, 'error'); - return false; - } - -} \ No newline at end of file diff --git a/admin/models/forms/admin_custom_tabs.xml b/admin/forms/admin_custom_tabs.xml similarity index 96% rename from admin/models/forms/admin_custom_tabs.xml rename to admin/forms/admin_custom_tabs.xml index 4733e880a..3cce5ff7b 100644 --- a/admin/models/forms/admin_custom_tabs.xml +++ b/admin/forms/admin_custom_tabs.xml @@ -1,8 +1,11 @@
+ + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_VERSION_LABEL" description="COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -185,7 +189,7 @@
- +
diff --git a/admin/models/forms/admin_fields.xml b/admin/forms/admin_fields.xml similarity index 98% rename from admin/models/forms/admin_fields.xml rename to admin/forms/admin_fields.xml index 4e04676ee..2d169a111 100644 --- a/admin/models/forms/admin_fields.xml +++ b/admin/forms/admin_fields.xml @@ -1,8 +1,11 @@
+ + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_ADMIN_FIELDS_VERSION_LABEL" description="COM_COMPONENTBUILDER_ADMIN_FIELDS_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -302,7 +306,7 @@
- +
diff --git a/admin/models/forms/admin_fields_conditions.xml b/admin/forms/admin_fields_conditions.xml similarity index 97% rename from admin/models/forms/admin_fields_conditions.xml rename to admin/forms/admin_fields_conditions.xml index c50f64a66..43b73af51 100644 --- a/admin/models/forms/admin_fields_conditions.xml +++ b/admin/forms/admin_fields_conditions.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_VERSION_LABEL" description="COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -232,7 +236,7 @@
- +
diff --git a/admin/models/forms/admin_fields_relations.xml b/admin/forms/admin_fields_relations.xml similarity index 97% rename from admin/models/forms/admin_fields_relations.xml rename to admin/forms/admin_fields_relations.xml index f6fc66bc0..2f30ff9ed 100644 --- a/admin/models/forms/admin_fields_relations.xml +++ b/admin/forms/admin_fields_relations.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_VERSION_LABEL" description="COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -206,7 +210,7 @@
- +
diff --git a/admin/models/forms/admin_view.xml b/admin/forms/admin_view.xml similarity index 99% rename from admin/models/forms/admin_view.xml rename to admin/forms/admin_view.xml index 3b448cbcf..18da00060 100644 --- a/admin/models/forms/admin_view.xml +++ b/admin/forms/admin_view.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_ADMIN_VIEW_VERSION_LABEL" description="COM_COMPONENTBUILDER_ADMIN_VIEW_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -2474,10 +2478,12 @@ rows="22" cols="30" description="COM_COMPONENTBUILDER_ADMIN_VIEW_SOURCEMAP_DESCRIPTION" + message="COM_COMPONENTBUILDER_ADMIN_VIEW_SOURCEMAP_MESSAGE" class="text_area span4" filter="HTML" hint="COM_COMPONENTBUILDER_ADMIN_VIEW_SOURCEMAP_HINT" - required="true" + required="false" + validate="sourcemapchecker" /> @@ -2782,7 +2788,7 @@ COM_COMPONENTBUILDER_ADMIN_VIEW_NO
- +
diff --git a/admin/models/forms/class_extends.xml b/admin/forms/class_extends.xml similarity index 96% rename from admin/models/forms/class_extends.xml rename to admin/forms/class_extends.xml index 9811a2e0c..f1d225938 100644 --- a/admin/models/forms/class_extends.xml +++ b/admin/forms/class_extends.xml @@ -1,8 +1,11 @@
+ + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_CLASS_EXTENDS_VERSION_LABEL" description="COM_COMPONENTBUILDER_CLASS_EXTENDS_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -161,7 +165,7 @@ required="false" />
- +
diff --git a/admin/models/forms/class_method.xml b/admin/forms/class_method.xml similarity index 97% rename from admin/models/forms/class_method.xml rename to admin/forms/class_method.xml index 0852532f8..67d2b3bb3 100644 --- a/admin/models/forms/class_method.xml +++ b/admin/forms/class_method.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_CLASS_METHOD_VERSION_LABEL" description="COM_COMPONENTBUILDER_CLASS_METHOD_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -222,7 +226,7 @@ autocomplete="on" />
- +
diff --git a/admin/models/forms/class_property.xml b/admin/forms/class_property.xml similarity index 97% rename from admin/models/forms/class_property.xml rename to admin/forms/class_property.xml index 7fdc145e7..99001149e 100644 --- a/admin/models/forms/class_property.xml +++ b/admin/forms/class_property.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_CLASS_PROPERTY_VERSION_LABEL" description="COM_COMPONENTBUILDER_CLASS_PROPERTY_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -206,7 +210,7 @@ hint="COM_COMPONENTBUILDER_CLASS_PROPERTY_DEFAULT_HINT" />
- +
diff --git a/admin/models/forms/component_admin_views.xml b/admin/forms/component_admin_views.xml similarity index 99% rename from admin/models/forms/component_admin_views.xml rename to admin/forms/component_admin_views.xml index d6bcfc2da..16f0d52e1 100644 --- a/admin/models/forms/component_admin_views.xml +++ b/admin/forms/component_admin_views.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_VERSION_LABEL" description="COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -721,7 +725,7 @@
- +
diff --git a/admin/models/forms/component_config.xml b/admin/forms/component_config.xml similarity index 96% rename from admin/models/forms/component_config.xml rename to admin/forms/component_config.xml index e4d4ec46c..57a7177cc 100644 --- a/admin/models/forms/component_config.xml +++ b/admin/forms/component_config.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_COMPONENT_CONFIG_VERSION_LABEL" description="COM_COMPONENTBUILDER_COMPONENT_CONFIG_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -174,7 +178,7 @@
- +
diff --git a/admin/models/forms/component_custom_admin_menus.xml b/admin/forms/component_custom_admin_menus.xml similarity index 97% rename from admin/models/forms/component_custom_admin_menus.xml rename to admin/forms/component_custom_admin_menus.xml index 547f5fd7b..2f569d81b 100644 --- a/admin/models/forms/component_custom_admin_menus.xml +++ b/admin/forms/component_custom_admin_menus.xml @@ -1,8 +1,11 @@
+ + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_VERSION_LABEL" description="COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -228,7 +232,7 @@
- +
diff --git a/admin/models/forms/component_custom_admin_views.xml b/admin/forms/component_custom_admin_views.xml similarity index 99% rename from admin/models/forms/component_custom_admin_views.xml rename to admin/forms/component_custom_admin_views.xml index 63f8e77a9..5f14ee615 100644 --- a/admin/models/forms/component_custom_admin_views.xml +++ b/admin/forms/component_custom_admin_views.xml @@ -1,8 +1,11 @@
+ + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_VERSION_LABEL" description="COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -646,7 +650,7 @@
- +
diff --git a/admin/models/forms/component_dashboard.xml b/admin/forms/component_dashboard.xml similarity index 97% rename from admin/models/forms/component_dashboard.xml rename to admin/forms/component_dashboard.xml index 2b33f5025..9cb695f50 100644 --- a/admin/models/forms/component_dashboard.xml +++ b/admin/forms/component_dashboard.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_VERSION_LABEL" description="COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -192,7 +196,7 @@
- +
diff --git a/admin/models/forms/component_files_folders.xml b/admin/forms/component_files_folders.xml similarity index 98% rename from admin/models/forms/component_files_folders.xml rename to admin/forms/component_files_folders.xml index d12e64442..9bfafa315 100644 --- a/admin/models/forms/component_files_folders.xml +++ b/admin/forms/component_files_folders.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_VERSION_LABEL" description="COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -337,7 +341,7 @@
- +
diff --git a/admin/models/forms/component_modules.xml b/admin/forms/component_modules.xml similarity index 96% rename from admin/models/forms/component_modules.xml rename to admin/forms/component_modules.xml index 1ba103160..88722970d 100644 --- a/admin/models/forms/component_modules.xml +++ b/admin/forms/component_modules.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_COMPONENT_MODULES_VERSION_LABEL" description="COM_COMPONENTBUILDER_COMPONENT_MODULES_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -162,7 +166,7 @@
- +
diff --git a/admin/models/forms/component_mysql_tweaks.xml b/admin/forms/component_mysql_tweaks.xml similarity index 97% rename from admin/models/forms/component_mysql_tweaks.xml rename to admin/forms/component_mysql_tweaks.xml index 680ccd99d..1193494c8 100644 --- a/admin/models/forms/component_mysql_tweaks.xml +++ b/admin/forms/component_mysql_tweaks.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_VERSION_LABEL" description="COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -190,7 +194,7 @@
- +
diff --git a/admin/models/forms/component_placeholders.xml b/admin/forms/component_placeholders.xml similarity index 96% rename from admin/models/forms/component_placeholders.xml rename to admin/forms/component_placeholders.xml index d6f0a341e..87484835e 100644 --- a/admin/models/forms/component_placeholders.xml +++ b/admin/forms/component_placeholders.xml @@ -1,8 +1,11 @@
+ + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_VERSION_LABEL" description="COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -161,7 +165,7 @@
- +
diff --git a/admin/models/forms/component_plugins.xml b/admin/forms/component_plugins.xml similarity index 96% rename from admin/models/forms/component_plugins.xml rename to admin/forms/component_plugins.xml index 8f1d50847..b8cdf45df 100644 --- a/admin/models/forms/component_plugins.xml +++ b/admin/forms/component_plugins.xml @@ -1,8 +1,11 @@
+ + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_COMPONENT_PLUGINS_VERSION_LABEL" description="COM_COMPONENTBUILDER_COMPONENT_PLUGINS_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -162,7 +166,7 @@
- +
diff --git a/admin/forms/component_router.xml b/admin/forms/component_router.xml new file mode 100644 index 000000000..7ae38bce9 --- /dev/null +++ b/admin/forms/component_router.xml @@ -0,0 +1,277 @@ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + +
+ \ No newline at end of file diff --git a/admin/models/forms/component_site_views.xml b/admin/forms/component_site_views.xml similarity index 97% rename from admin/models/forms/component_site_views.xml rename to admin/forms/component_site_views.xml index 50aaf46a8..cb112e0a9 100644 --- a/admin/models/forms/component_site_views.xml +++ b/admin/forms/component_site_views.xml @@ -1,8 +1,11 @@
+ + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_VERSION_LABEL" description="COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -137,7 +141,6 @@ description="COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_SITEVIEW_DESCRIPTION" class="fieldMedium" multiple="false" - default="" required="true" button="false" /> @@ -196,7 +199,7 @@
- +
diff --git a/admin/models/forms/component_updates.xml b/admin/forms/component_updates.xml similarity index 98% rename from admin/models/forms/component_updates.xml rename to admin/forms/component_updates.xml index 50996472a..56869b988 100644 --- a/admin/models/forms/component_updates.xml +++ b/admin/forms/component_updates.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_COMPONENT_UPDATES_VERSION_LABEL" description="COM_COMPONENTBUILDER_COMPONENT_UPDATES_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -283,7 +287,7 @@
- +
diff --git a/admin/models/forms/custom_admin_view.xml b/admin/forms/custom_admin_view.xml similarity index 99% rename from admin/models/forms/custom_admin_view.xml rename to admin/forms/custom_admin_view.xml index d8029fd5b..c13332b6b 100644 --- a/admin/models/forms/custom_admin_view.xml +++ b/admin/forms/custom_admin_view.xml @@ -1,8 +1,11 @@
+ + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_VERSION_LABEL" description="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -1241,7 +1245,7 @@ validate="code" />
- +
diff --git a/admin/models/forms/custom_code.xml b/admin/forms/custom_code.xml similarity index 95% rename from admin/models/forms/custom_code.xml rename to admin/forms/custom_code.xml index af321b074..edbdab80d 100644 --- a/admin/models/forms/custom_code.xml +++ b/admin/forms/custom_code.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_CUSTOM_CODE_VERSION_LABEL" description="COM_COMPONENTBUILDER_CUSTOM_CODE_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -161,6 +165,18 @@ + +
- +
diff --git a/admin/models/forms/dynamic_get.xml b/admin/forms/dynamic_get.xml similarity index 98% rename from admin/models/forms/dynamic_get.xml rename to admin/forms/dynamic_get.xml index 32af1c69c..86108bd95 100644 --- a/admin/models/forms/dynamic_get.xml +++ b/admin/forms/dynamic_get.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_DYNAMIC_GET_VERSION_LABEL" description="COM_COMPONENTBUILDER_DYNAMIC_GET_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -151,6 +155,22 @@ + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + type="list" + name="plugin_events" + label="COM_COMPONENTBUILDER_DYNAMIC_GET_PLUGIN_EVENTS_LABEL" + description="COM_COMPONENTBUILDER_DYNAMIC_GET_PLUGIN_EVENTS_DESCRIPTION" + class="list_class" + multiple="true"> + + + + + + - + + + + + + + - + - - - - - - - - + type="radio" + name="select_all" + label="COM_COMPONENTBUILDER_DYNAMIC_GET_SELECT_ALL_LABEL" + description="COM_COMPONENTBUILDER_DYNAMIC_GET_SELECT_ALL_DESCRIPTION" + class="btn-group btn-group-yesno" + default="0"> - - - + + - - - - - - - - - - - - - - - - - - - + - - - - + type="editor" + name="php_after_getitem" + label="COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_AFTER_GETITEM_LABEL" + description="COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_AFTER_GETITEM_DESCRIPTION" + width="100%" + height="450px" + cols="15" + rows="30" + buttons="no" + syntax="php" + editor="codemirror|none" + filter="raw" + validate="code" + /> COM_COMPONENTBUILDER_DYNAMIC_GET_NO - + - - - - + type="editor" + name="php_getlistquery" + label="COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_GETLISTQUERY_LABEL" + description="COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_GETLISTQUERY_DESCRIPTION" + width="100%" + height="450px" + cols="15" + rows="30" + buttons="no" + syntax="php" + editor="codemirror|none" + filter="raw" + validate="code" + /> - + - - - - + type="editor" + name="php_before_getitems" + label="COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_BEFORE_GETITEMS_LABEL" + description="COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_BEFORE_GETITEMS_DESCRIPTION" + width="100%" + height="450px" + cols="15" + rows="30" + buttons="no" + syntax="php" + editor="codemirror|none" + filter="raw" + validate="code" + /> - + - - - - + type="editor" + name="php_after_getitems" + label="COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_AFTER_GETITEMS_LABEL" + description="COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_AFTER_GETITEMS_DESCRIPTION" + width="100%" + height="450px" + cols="15" + rows="30" + buttons="no" + syntax="php" + editor="codemirror|none" + filter="raw" + validate="code" + /> - - - - - - + +
- +
diff --git a/admin/models/forms/field.xml b/admin/forms/field.xml similarity index 98% rename from admin/models/forms/field.xml rename to admin/forms/field.xml index a8a6eea36..789ecc1b6 100644 --- a/admin/models/forms/field.xml +++ b/admin/forms/field.xml @@ -1,8 +1,11 @@
+ + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_FIELD_VERSION_LABEL" description="COM_COMPONENTBUILDER_FIELD_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -546,7 +550,7 @@
- +
diff --git a/admin/models/forms/fieldtype.xml b/admin/forms/fieldtype.xml similarity index 98% rename from admin/models/forms/fieldtype.xml rename to admin/forms/fieldtype.xml index 9deddf34c..6ced85b4c 100644 --- a/admin/models/forms/fieldtype.xml +++ b/admin/forms/fieldtype.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_FIELDTYPE_VERSION_LABEL" description="COM_COMPONENTBUILDER_FIELDTYPE_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -467,7 +471,7 @@ class="inputbox" />
- +
diff --git a/admin/models/forms/filter_admin_views.xml b/admin/forms/filter_admin_views.xml similarity index 77% rename from admin/models/forms/filter_admin_views.xml rename to admin/forms/filter_admin_views.xml index b188dcca1..ce449e8ec 100644 --- a/admin/models/forms/filter_admin_views.xml +++ b/admin/forms/filter_admin_views.xml @@ -1,7 +1,7 @@ @@ -73,9 +74,8 @@ @@ -97,11 +97,9 @@ \ No newline at end of file diff --git a/admin/forms/filter_admins_custom_tabs.xml b/admin/forms/filter_admins_custom_tabs.xml new file mode 100644 index 000000000..d6aff950f --- /dev/null +++ b/admin/forms/filter_admins_custom_tabs.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_admins_fields.xml b/admin/forms/filter_admins_fields.xml new file mode 100644 index 000000000..b415b5bb2 --- /dev/null +++ b/admin/forms/filter_admins_fields.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_admins_fields_conditions.xml b/admin/forms/filter_admins_fields_conditions.xml new file mode 100644 index 000000000..f71a8506c --- /dev/null +++ b/admin/forms/filter_admins_fields_conditions.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_admins_fields_relations.xml b/admin/forms/filter_admins_fields_relations.xml new file mode 100644 index 000000000..7f720f1bb --- /dev/null +++ b/admin/forms/filter_admins_fields_relations.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_class_extendings.xml b/admin/forms/filter_class_extendings.xml new file mode 100644 index 000000000..5b8d7a9fc --- /dev/null +++ b/admin/forms/filter_class_extendings.xml @@ -0,0 +1,73 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/filter_class_methods.xml b/admin/forms/filter_class_methods.xml similarity index 76% rename from admin/models/forms/filter_class_methods.xml rename to admin/forms/filter_class_methods.xml index 1cb605191..ce54de520 100644 --- a/admin/models/forms/filter_class_methods.xml +++ b/admin/forms/filter_class_methods.xml @@ -1,7 +1,7 @@
@@ -51,9 +51,8 @@ @@ -75,11 +74,9 @@ \ No newline at end of file diff --git a/admin/models/forms/filter_class_properties.xml b/admin/forms/filter_class_properties.xml similarity index 76% rename from admin/models/forms/filter_class_properties.xml rename to admin/forms/filter_class_properties.xml index c92f82bee..d55ad89f9 100644 --- a/admin/models/forms/filter_class_properties.xml +++ b/admin/forms/filter_class_properties.xml @@ -1,7 +1,7 @@
@@ -51,9 +51,8 @@ @@ -75,11 +74,9 @@ \ No newline at end of file diff --git a/admin/forms/filter_components_admin_views.xml b/admin/forms/filter_components_admin_views.xml new file mode 100644 index 000000000..dadff38ae --- /dev/null +++ b/admin/forms/filter_components_admin_views.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_components_config.xml b/admin/forms/filter_components_config.xml new file mode 100644 index 000000000..e76ae4024 --- /dev/null +++ b/admin/forms/filter_components_config.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_components_custom_admin_menus.xml b/admin/forms/filter_components_custom_admin_menus.xml new file mode 100644 index 000000000..c6d5e4c58 --- /dev/null +++ b/admin/forms/filter_components_custom_admin_menus.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_components_custom_admin_views.xml b/admin/forms/filter_components_custom_admin_views.xml new file mode 100644 index 000000000..ce21765f1 --- /dev/null +++ b/admin/forms/filter_components_custom_admin_views.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_components_dashboard.xml b/admin/forms/filter_components_dashboard.xml new file mode 100644 index 000000000..525cbc410 --- /dev/null +++ b/admin/forms/filter_components_dashboard.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_components_files_folders.xml b/admin/forms/filter_components_files_folders.xml new file mode 100644 index 000000000..00327ec5a --- /dev/null +++ b/admin/forms/filter_components_files_folders.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_components_modules.xml b/admin/forms/filter_components_modules.xml new file mode 100644 index 000000000..aad0bc2cf --- /dev/null +++ b/admin/forms/filter_components_modules.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_components_mysql_tweaks.xml b/admin/forms/filter_components_mysql_tweaks.xml new file mode 100644 index 000000000..4f36e9713 --- /dev/null +++ b/admin/forms/filter_components_mysql_tweaks.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_components_placeholders.xml b/admin/forms/filter_components_placeholders.xml new file mode 100644 index 000000000..ca7e46fd4 --- /dev/null +++ b/admin/forms/filter_components_placeholders.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_components_plugins.xml b/admin/forms/filter_components_plugins.xml new file mode 100644 index 000000000..ee88f5fdf --- /dev/null +++ b/admin/forms/filter_components_plugins.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_components_routers.xml b/admin/forms/filter_components_routers.xml new file mode 100644 index 000000000..9ab08592d --- /dev/null +++ b/admin/forms/filter_components_routers.xml @@ -0,0 +1,83 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_components_site_views.xml b/admin/forms/filter_components_site_views.xml new file mode 100644 index 000000000..cba85f0a3 --- /dev/null +++ b/admin/forms/filter_components_site_views.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_components_updates.xml b/admin/forms/filter_components_updates.xml new file mode 100644 index 000000000..2fdc4efac --- /dev/null +++ b/admin/forms/filter_components_updates.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/filter_custom_admin_views.xml b/admin/forms/filter_custom_admin_views.xml similarity index 77% rename from admin/models/forms/filter_custom_admin_views.xml rename to admin/forms/filter_custom_admin_views.xml index 74ff3bc4a..4b2d7a225 100644 --- a/admin/models/forms/filter_custom_admin_views.xml +++ b/admin/forms/filter_custom_admin_views.xml @@ -1,7 +1,7 @@
@@ -59,9 +60,8 @@ @@ -85,11 +85,9 @@ \ No newline at end of file diff --git a/admin/models/forms/filter_custom_codes.xml b/admin/forms/filter_custom_codes.xml similarity index 77% rename from admin/models/forms/filter_custom_codes.xml rename to admin/forms/filter_custom_codes.xml index 4fd5fc0c6..98c87ca22 100644 --- a/admin/models/forms/filter_custom_codes.xml +++ b/admin/forms/filter_custom_codes.xml @@ -1,7 +1,7 @@
@@ -65,9 +65,8 @@ @@ -86,6 +85,8 @@ + + @@ -93,11 +94,9 @@ \ No newline at end of file diff --git a/admin/models/forms/filter_dynamic_gets.xml b/admin/forms/filter_dynamic_gets.xml similarity index 76% rename from admin/models/forms/filter_dynamic_gets.xml rename to admin/forms/filter_dynamic_gets.xml index 7d456c566..f2592b4c2 100644 --- a/admin/models/forms/filter_dynamic_gets.xml +++ b/admin/forms/filter_dynamic_gets.xml @@ -1,7 +1,7 @@
@@ -51,9 +51,8 @@ @@ -75,11 +74,9 @@ \ No newline at end of file diff --git a/admin/models/forms/filter_fields.xml b/admin/forms/filter_fields.xml similarity index 80% rename from admin/models/forms/filter_fields.xml rename to admin/forms/filter_fields.xml index cbeda70c9..0235e9b01 100644 --- a/admin/models/forms/filter_fields.xml +++ b/admin/forms/filter_fields.xml @@ -1,7 +1,7 @@
@@ -27,54 +27,54 @@ label="COM_COMPONENTBUILDER_FIELD_FIELDS_CATEGORIES" description="JOPTION_FILTER_CATEGORY_DESC" multiple="true" - class="multipleCategories" + class="js-select-submit-on-change" extension="com_componentbuilder.field" - onchange="this.form.submit();" + layout="joomla.form.field.list-fancy-select" published="0,1,2" /> @@ -83,9 +83,8 @@ @@ -115,11 +114,9 @@ \ No newline at end of file diff --git a/admin/models/forms/filter_fieldtypes.xml b/admin/forms/filter_fieldtypes.xml similarity index 76% rename from admin/models/forms/filter_fieldtypes.xml rename to admin/forms/filter_fieldtypes.xml index cf158e781..163214263 100644 --- a/admin/models/forms/filter_fieldtypes.xml +++ b/admin/forms/filter_fieldtypes.xml @@ -1,7 +1,7 @@
@@ -27,19 +27,19 @@ label="COM_COMPONENTBUILDER_FIELDTYPE_FIELDTYPES_CATEGORIES" description="JOPTION_FILTER_CATEGORY_DESC" multiple="true" - class="multipleCategories" + class="js-select-submit-on-change" extension="com_componentbuilder.fieldtype" - onchange="this.form.submit();" + layout="joomla.form.field.list-fancy-select" published="0,1,2" /> @@ -48,9 +48,8 @@ @@ -72,11 +71,9 @@ \ No newline at end of file diff --git a/admin/forms/filter_help_documents.xml b/admin/forms/filter_help_documents.xml new file mode 100644 index 000000000..d968ae47d --- /dev/null +++ b/admin/forms/filter_help_documents.xml @@ -0,0 +1,91 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/filter_joomla_components.xml b/admin/forms/filter_joomla_components.xml similarity index 78% rename from admin/models/forms/filter_joomla_components.xml rename to admin/forms/filter_joomla_components.xml index e1d29ea4b..a231c65c8 100644 --- a/admin/models/forms/filter_joomla_components.xml +++ b/admin/forms/filter_joomla_components.xml @@ -1,7 +1,7 @@
@@ -53,9 +55,8 @@ @@ -83,11 +84,9 @@ \ No newline at end of file diff --git a/admin/forms/filter_joomla_modules.xml b/admin/forms/filter_joomla_modules.xml new file mode 100644 index 000000000..3f0b7e73b --- /dev/null +++ b/admin/forms/filter_joomla_modules.xml @@ -0,0 +1,73 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_joomla_modules_files_folders_urls.xml b/admin/forms/filter_joomla_modules_files_folders_urls.xml new file mode 100644 index 000000000..a837b0727 --- /dev/null +++ b/admin/forms/filter_joomla_modules_files_folders_urls.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_joomla_modules_updates.xml b/admin/forms/filter_joomla_modules_updates.xml new file mode 100644 index 000000000..d498d9aa2 --- /dev/null +++ b/admin/forms/filter_joomla_modules_updates.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_joomla_plugin_groups.xml b/admin/forms/filter_joomla_plugin_groups.xml new file mode 100644 index 000000000..1e3484afa --- /dev/null +++ b/admin/forms/filter_joomla_plugin_groups.xml @@ -0,0 +1,73 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/filter_joomla_plugins.xml b/admin/forms/filter_joomla_plugins.xml similarity index 76% rename from admin/models/forms/filter_joomla_plugins.xml rename to admin/forms/filter_joomla_plugins.xml index e1de0f9cc..f0d82e7d6 100644 --- a/admin/models/forms/filter_joomla_plugins.xml +++ b/admin/forms/filter_joomla_plugins.xml @@ -1,7 +1,7 @@
@@ -51,9 +51,8 @@ @@ -75,11 +74,9 @@ \ No newline at end of file diff --git a/admin/forms/filter_joomla_plugins_files_folders_urls.xml b/admin/forms/filter_joomla_plugins_files_folders_urls.xml new file mode 100644 index 000000000..7124ebe85 --- /dev/null +++ b/admin/forms/filter_joomla_plugins_files_folders_urls.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_joomla_plugins_updates.xml b/admin/forms/filter_joomla_plugins_updates.xml new file mode 100644 index 000000000..6414e707d --- /dev/null +++ b/admin/forms/filter_joomla_plugins_updates.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_language_translations.xml b/admin/forms/filter_language_translations.xml new file mode 100644 index 000000000..99a1f0087 --- /dev/null +++ b/admin/forms/filter_language_translations.xml @@ -0,0 +1,64 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_languages.xml b/admin/forms/filter_languages.xml new file mode 100644 index 000000000..96303cee1 --- /dev/null +++ b/admin/forms/filter_languages.xml @@ -0,0 +1,66 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/filter_layouts.xml b/admin/forms/filter_layouts.xml similarity index 76% rename from admin/models/forms/filter_layouts.xml rename to admin/forms/filter_layouts.xml index 0be490cb2..76d93f150 100644 --- a/admin/models/forms/filter_layouts.xml +++ b/admin/forms/filter_layouts.xml @@ -1,7 +1,7 @@
@@ -51,9 +51,8 @@ @@ -75,11 +74,9 @@ \ No newline at end of file diff --git a/admin/models/forms/filter_libraries.xml b/admin/forms/filter_libraries.xml similarity index 77% rename from admin/models/forms/filter_libraries.xml rename to admin/forms/filter_libraries.xml index 890aecc58..e0c0fecac 100644 --- a/admin/models/forms/filter_libraries.xml +++ b/admin/forms/filter_libraries.xml @@ -1,7 +1,7 @@
@@ -58,9 +58,8 @@ @@ -84,11 +83,9 @@ \ No newline at end of file diff --git a/admin/forms/filter_libraries_config.xml b/admin/forms/filter_libraries_config.xml new file mode 100644 index 000000000..f184d051d --- /dev/null +++ b/admin/forms/filter_libraries_config.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_libraries_files_folders_urls.xml b/admin/forms/filter_libraries_files_folders_urls.xml new file mode 100644 index 000000000..a7d304400 --- /dev/null +++ b/admin/forms/filter_libraries_files_folders_urls.xml @@ -0,0 +1,62 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/forms/filter_placeholders.xml b/admin/forms/filter_placeholders.xml new file mode 100644 index 000000000..593e41124 --- /dev/null +++ b/admin/forms/filter_placeholders.xml @@ -0,0 +1,66 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/filter_powers.xml b/admin/forms/filter_powers.xml similarity index 76% rename from admin/models/forms/filter_powers.xml rename to admin/forms/filter_powers.xml index 173808595..e630ca30c 100644 --- a/admin/models/forms/filter_powers.xml +++ b/admin/forms/filter_powers.xml @@ -1,7 +1,7 @@
@@ -52,9 +53,8 @@ @@ -78,11 +78,9 @@ \ No newline at end of file diff --git a/admin/forms/filter_servers.xml b/admin/forms/filter_servers.xml new file mode 100644 index 000000000..c6361b562 --- /dev/null +++ b/admin/forms/filter_servers.xml @@ -0,0 +1,80 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/filter_site_views.xml b/admin/forms/filter_site_views.xml similarity index 78% rename from admin/models/forms/filter_site_views.xml rename to admin/forms/filter_site_views.xml index eaf8ce1fa..eea6068e6 100644 --- a/admin/models/forms/filter_site_views.xml +++ b/admin/forms/filter_site_views.xml @@ -1,7 +1,7 @@
@@ -59,9 +60,8 @@ @@ -87,11 +87,9 @@ \ No newline at end of file diff --git a/admin/forms/filter_snippet_types.xml b/admin/forms/filter_snippet_types.xml new file mode 100644 index 000000000..db236abb1 --- /dev/null +++ b/admin/forms/filter_snippet_types.xml @@ -0,0 +1,66 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/filter_snippets.xml b/admin/forms/filter_snippets.xml similarity index 78% rename from admin/models/forms/filter_snippets.xml rename to admin/forms/filter_snippets.xml index 5b1faca15..dc955284f 100644 --- a/admin/models/forms/filter_snippets.xml +++ b/admin/forms/filter_snippets.xml @@ -1,7 +1,7 @@
@@ -51,9 +51,8 @@ @@ -79,11 +78,9 @@ \ No newline at end of file diff --git a/admin/models/forms/filter_templates.xml b/admin/forms/filter_templates.xml similarity index 76% rename from admin/models/forms/filter_templates.xml rename to admin/forms/filter_templates.xml index 9b4cdfbee..d8e8a9bc8 100644 --- a/admin/models/forms/filter_templates.xml +++ b/admin/forms/filter_templates.xml @@ -1,7 +1,7 @@
@@ -51,9 +51,8 @@ @@ -75,11 +74,9 @@ \ No newline at end of file diff --git a/admin/forms/filter_validation_rules.xml b/admin/forms/filter_validation_rules.xml new file mode 100644 index 000000000..4d4896b4c --- /dev/null +++ b/admin/forms/filter_validation_rules.xml @@ -0,0 +1,66 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/help_document.xml b/admin/forms/help_document.xml similarity index 96% rename from admin/models/forms/help_document.xml rename to admin/forms/help_document.xml index a5833d977..eb68b9b0b 100644 --- a/admin/models/forms/help_document.xml +++ b/admin/forms/help_document.xml @@ -1,8 +1,11 @@
+ + +
@@ -73,6 +76,7 @@ label="COM_COMPONENTBUILDER_HELP_DOCUMENT_VERSION_LABEL" description="COM_COMPONENTBUILDER_HELP_DOCUMENT_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -113,9 +117,9 @@ - + @@ -228,7 +231,7 @@ hint="COM_COMPONENTBUILDER_HELP_DOCUMENT_ALIAS_HINT" />
- +
diff --git a/admin/helpers/compiler/index.html b/admin/forms/index.html similarity index 100% rename from admin/helpers/compiler/index.html rename to admin/forms/index.html diff --git a/admin/models/forms/joomla_component.xml b/admin/forms/joomla_component.xml similarity index 97% rename from admin/models/forms/joomla_component.xml rename to admin/forms/joomla_component.xml index 9aa8b76dc..63a9ed211 100644 --- a/admin/models/forms/joomla_component.xml +++ b/admin/forms/joomla_component.xml @@ -1,8 +1,11 @@ + + +
@@ -67,6 +70,7 @@ label="COM_COMPONENTBUILDER_JOOMLA_COMPONENT_VERSION_LABEL" description="COM_COMPONENTBUILDER_JOOMLA_COMPONENT_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -156,6 +160,81 @@ message="COM_COMPONENTBUILDER_JOOMLA_COMPONENT_COMPANYNAME_MESSAGE" hint="COM_COMPONENTBUILDER_JOOMLA_COMPONENT_COMPANYNAME_HINT" /> + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -331,16 +278,57 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - + COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CUSTOM_USED_IN_CUSTOM_CODE - + + + - + - + - - + + - - + + - + + + + + - + COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NO - + + + + + + + + + COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NO - - + + COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NO - - + + COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NO - - + + COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NO - - + + + + + + COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NO + + + + + + + + + + + + + + + + COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NO - + - + COM_COMPONENTBUILDER_JOOMLA_COMPONENT_DEFAULT + - - - - - - - - - - - - - - - - - - + + COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NO - - + + COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NO - - + + COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NO + + + + + + + + + + + + + + + + - + @@ -1105,11 +1211,11 @@ message="COM_COMPONENTBUILDER_JOOMLA_COMPONENT_JOOMLA_SOURCE_LINK_MESSAGE" hint="COM_COMPONENTBUILDER_JOOMLA_COMPONENT_JOOMLA_SOURCE_LINK_HINT" /> - + @@ -1135,38 +1241,6 @@ message="COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EXPORT_BUY_LINK_MESSAGE" hint="COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EXPORT_BUY_LINK_HINT" /> - - - - - - - - - - - - - - - - COM_COMPONENTBUILDER_JOOMLA_COMPONENT_INTELLIGENT_ADDREMOVEIF + + + + + + + + + + + + - - - - - - - - - - - - - - - - COM_COMPONENTBUILDER_JOOMLA_COMPONENT_OTHER - - + + + + + + - - + + - - + + - - + + - - + + COM_COMPONENTBUILDER_JOOMLA_COMPONENT_OVERRIDE - - + + + + + + + + + + COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NO - - + + COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_UIKIT_V3 - + + type="radio" + name="buildcomp" + label="COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BUILDCOMP_LABEL" + description="COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BUILDCOMP_DESCRIPTION" + class="btn-group btn-group-yesno" + default="0" + required="true"> + + + + COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_FOOTABLE_V2 - + COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NO - - - - - - - - - - - - - - - -
- +
diff --git a/admin/models/forms/joomla_module.xml b/admin/forms/joomla_module.xml similarity index 99% rename from admin/models/forms/joomla_module.xml rename to admin/forms/joomla_module.xml index a2fadcb5a..834f66d8b 100644 --- a/admin/models/forms/joomla_module.xml +++ b/admin/forms/joomla_module.xml @@ -1,8 +1,11 @@
+ + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_JOOMLA_MODULE_VERSION_LABEL" description="COM_COMPONENTBUILDER_JOOMLA_MODULE_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -898,7 +902,7 @@ hint="COM_COMPONENTBUILDER_JOOMLA_MODULE_NAME_HINT" />
- +
diff --git a/admin/models/forms/joomla_module_files_folders_urls.xml b/admin/forms/joomla_module_files_folders_urls.xml similarity index 98% rename from admin/models/forms/joomla_module_files_folders_urls.xml rename to admin/forms/joomla_module_files_folders_urls.xml index 751f2c2f0..63528ba52 100644 --- a/admin/models/forms/joomla_module_files_folders_urls.xml +++ b/admin/forms/joomla_module_files_folders_urls.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_VERSION_LABEL" description="COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -372,7 +376,7 @@
- +
diff --git a/admin/models/forms/joomla_module_updates.xml b/admin/forms/joomla_module_updates.xml similarity index 96% rename from admin/models/forms/joomla_module_updates.xml rename to admin/forms/joomla_module_updates.xml index c79bf1d89..c24e46165 100644 --- a/admin/models/forms/joomla_module_updates.xml +++ b/admin/forms/joomla_module_updates.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_VERSION_LABEL" description="COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -163,7 +167,7 @@
- +
diff --git a/admin/models/forms/joomla_plugin.xml b/admin/forms/joomla_plugin.xml similarity index 99% rename from admin/models/forms/joomla_plugin.xml rename to admin/forms/joomla_plugin.xml index 0a8bec6e3..d47905305 100644 --- a/admin/models/forms/joomla_plugin.xml +++ b/admin/forms/joomla_plugin.xml @@ -1,8 +1,11 @@
+ + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_VERSION_LABEL" description="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -865,7 +869,7 @@ hint="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_NAME_HINT" />
- +
diff --git a/admin/models/forms/joomla_plugin_files_folders_urls.xml b/admin/forms/joomla_plugin_files_folders_urls.xml similarity index 98% rename from admin/models/forms/joomla_plugin_files_folders_urls.xml rename to admin/forms/joomla_plugin_files_folders_urls.xml index 30c00dfe6..a8bb62425 100644 --- a/admin/models/forms/joomla_plugin_files_folders_urls.xml +++ b/admin/forms/joomla_plugin_files_folders_urls.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_VERSION_LABEL" description="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -372,7 +376,7 @@
- +
diff --git a/admin/models/forms/joomla_plugin_group.xml b/admin/forms/joomla_plugin_group.xml similarity index 95% rename from admin/models/forms/joomla_plugin_group.xml rename to admin/forms/joomla_plugin_group.xml index f68c65cc4..a4c7506fa 100644 --- a/admin/models/forms/joomla_plugin_group.xml +++ b/admin/forms/joomla_plugin_group.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_VERSION_LABEL" description="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -121,7 +125,7 @@ button="true" />
- +
diff --git a/admin/models/forms/joomla_plugin_updates.xml b/admin/forms/joomla_plugin_updates.xml similarity index 96% rename from admin/models/forms/joomla_plugin_updates.xml rename to admin/forms/joomla_plugin_updates.xml index 484d89fa1..bfd1ba9fb 100644 --- a/admin/models/forms/joomla_plugin_updates.xml +++ b/admin/forms/joomla_plugin_updates.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_VERSION_LABEL" description="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -163,7 +167,7 @@
- +
diff --git a/admin/models/forms/language.xml b/admin/forms/language.xml similarity index 95% rename from admin/models/forms/language.xml rename to admin/forms/language.xml index a4882c39d..802070045 100644 --- a/admin/models/forms/language.xml +++ b/admin/forms/language.xml @@ -1,8 +1,11 @@
+ + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_LANGUAGE_VERSION_LABEL" description="COM_COMPONENTBUILDER_LANGUAGE_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -124,7 +128,7 @@ hint="COM_COMPONENTBUILDER_LANGUAGE_LANGTAG_HINT" />
- +
diff --git a/admin/models/forms/language_translation.xml b/admin/forms/language_translation.xml similarity index 96% rename from admin/models/forms/language_translation.xml rename to admin/forms/language_translation.xml index 65f492259..c8a42b67b 100644 --- a/admin/models/forms/language_translation.xml +++ b/admin/forms/language_translation.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_VERSION_LABEL" description="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -174,7 +178,7 @@
- +
diff --git a/admin/models/forms/layout.xml b/admin/forms/layout.xml similarity index 97% rename from admin/models/forms/layout.xml rename to admin/forms/layout.xml index 75b64a30e..bb533758e 100644 --- a/admin/models/forms/layout.xml +++ b/admin/forms/layout.xml @@ -1,8 +1,11 @@
+ + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_LAYOUT_VERSION_LABEL" description="COM_COMPONENTBUILDER_LAYOUT_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -236,7 +240,7 @@ hint="COM_COMPONENTBUILDER_LAYOUT_ALIAS_HINT" />
- +
diff --git a/admin/models/forms/library.xml b/admin/forms/library.xml similarity index 98% rename from admin/models/forms/library.xml rename to admin/forms/library.xml index beb2e8d35..ecb9e6594 100644 --- a/admin/models/forms/library.xml +++ b/admin/forms/library.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_LIBRARY_VERSION_LABEL" description="COM_COMPONENTBUILDER_LIBRARY_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -358,7 +362,7 @@
- +
diff --git a/admin/models/forms/library_config.xml b/admin/forms/library_config.xml similarity index 96% rename from admin/models/forms/library_config.xml rename to admin/forms/library_config.xml index 9c006dc12..67453dac2 100644 --- a/admin/models/forms/library_config.xml +++ b/admin/forms/library_config.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_LIBRARY_CONFIG_VERSION_LABEL" description="COM_COMPONENTBUILDER_LIBRARY_CONFIG_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -161,7 +165,7 @@
- +
diff --git a/admin/models/forms/library_files_folders_urls.xml b/admin/forms/library_files_folders_urls.xml similarity index 98% rename from admin/models/forms/library_files_folders_urls.xml rename to admin/forms/library_files_folders_urls.xml index a80f94a90..46970ec74 100644 --- a/admin/models/forms/library_files_folders_urls.xml +++ b/admin/forms/library_files_folders_urls.xml @@ -1,8 +1,11 @@
+ + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_VERSION_LABEL" description="COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -374,7 +378,7 @@
- +
diff --git a/admin/models/forms/placeholder.xml b/admin/forms/placeholder.xml similarity index 95% rename from admin/models/forms/placeholder.xml rename to admin/forms/placeholder.xml index ee814f5c8..84442d55c 100644 --- a/admin/models/forms/placeholder.xml +++ b/admin/forms/placeholder.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_PLACEHOLDER_VERSION_LABEL" description="COM_COMPONENTBUILDER_PLACEHOLDER_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -126,7 +130,7 @@
- +
diff --git a/admin/models/forms/power.xml b/admin/forms/power.xml similarity index 98% rename from admin/models/forms/power.xml rename to admin/forms/power.xml index c229f7086..f08e53e74 100644 --- a/admin/models/forms/power.xml +++ b/admin/forms/power.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_POWER_VERSION_LABEL" description="COM_COMPONENTBUILDER_POWER_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -543,7 +547,7 @@ hint="COM_COMPONENTBUILDER_POWER_NAME_HINT" />
- +
diff --git a/admin/models/forms/server.xml b/admin/forms/server.xml similarity index 97% rename from admin/models/forms/server.xml rename to admin/forms/server.xml index 884ec9e73..2e226c2ca 100644 --- a/admin/models/forms/server.xml +++ b/admin/forms/server.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_SERVER_VERSION_LABEL" description="COM_COMPONENTBUILDER_SERVER_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -296,7 +300,7 @@ hint="COM_COMPONENTBUILDER_SERVER_USERNAME_HINT" />
- +
diff --git a/admin/models/forms/site_view.xml b/admin/forms/site_view.xml similarity index 99% rename from admin/models/forms/site_view.xml rename to admin/forms/site_view.xml index 28d759090..8945a2be6 100644 --- a/admin/models/forms/site_view.xml +++ b/admin/forms/site_view.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_SITE_VIEW_VERSION_LABEL" description="COM_COMPONENTBUILDER_SITE_VIEW_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -1260,7 +1264,7 @@ validate="code" />
- +
diff --git a/admin/models/forms/snippet.xml b/admin/forms/snippet.xml similarity index 97% rename from admin/models/forms/snippet.xml rename to admin/forms/snippet.xml index 5d666c212..856716d34 100644 --- a/admin/models/forms/snippet.xml +++ b/admin/forms/snippet.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_SNIPPET_VERSION_LABEL" description="COM_COMPONENTBUILDER_SNIPPET_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -272,7 +276,7 @@ hint="COM_COMPONENTBUILDER_SNIPPET_DESCRIPTION_HINT" />
- +
diff --git a/admin/models/forms/snippet_type.xml b/admin/forms/snippet_type.xml similarity index 95% rename from admin/models/forms/snippet_type.xml rename to admin/forms/snippet_type.xml index 14287a313..963cc9e3b 100644 --- a/admin/models/forms/snippet_type.xml +++ b/admin/forms/snippet_type.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_SNIPPET_TYPE_VERSION_LABEL" description="COM_COMPONENTBUILDER_SNIPPET_TYPE_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -126,7 +130,7 @@ hint="COM_COMPONENTBUILDER_SNIPPET_TYPE_DESCRIPTION_HINT" />
- +
diff --git a/admin/models/forms/template.xml b/admin/forms/template.xml similarity index 97% rename from admin/models/forms/template.xml rename to admin/forms/template.xml index 0d4e7a31d..f499e42a1 100644 --- a/admin/models/forms/template.xml +++ b/admin/forms/template.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_TEMPLATE_VERSION_LABEL" description="COM_COMPONENTBUILDER_TEMPLATE_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -236,7 +240,7 @@ hint="COM_COMPONENTBUILDER_TEMPLATE_ALIAS_HINT" />
- +
diff --git a/admin/models/forms/validation_rule.xml b/admin/forms/validation_rule.xml similarity index 96% rename from admin/models/forms/validation_rule.xml rename to admin/forms/validation_rule.xml index af0ad9b30..3da842a76 100644 --- a/admin/models/forms/validation_rule.xml +++ b/admin/forms/validation_rule.xml @@ -1,8 +1,11 @@ + + +
@@ -81,6 +84,7 @@ label="COM_COMPONENTBUILDER_VALIDATION_RULE_VERSION_LABEL" description="COM_COMPONENTBUILDER_VALIDATION_RULE_VERSION_DESC" size="6" + default="1" readonly="true" filter="unset" /> @@ -143,7 +147,7 @@ required="true" />
- +
diff --git a/admin/helpers/compiler.php b/admin/helpers/compiler.php deleted file mode 100644 index 99608c37e..000000000 --- a/admin/helpers/compiler.php +++ /dev/null @@ -1,1701 +0,0 @@ - - * @gitea Joomla Component Builder - * @github Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Filesystem\File; -use Joomla\CMS\Filesystem\Folder; -use VDM\Joomla\Utilities\StringHelper; -use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\ObjectHelper; -use VDM\Joomla\Utilities\FileHelper; -use VDM\Joomla\Utilities\GetHelper; -use VDM\Joomla\Utilities\MathHelper; -use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; - -// Use the component builder autoloader -ComponentbuilderHelper::autoLoader(); - -/** - * Compiler class - * @deprecated 3.3 - */ -class Compiler extends Infusion -{ - - /** - * The Temp path - * - * @var string - */ - public $tempPath; - - /** - * The timer - * - * @var string - */ - private $time_start; - private $time_end; - public $secondsCompiled; - - /** - * The file path array - * - * @var string - */ - public $filepath - = array( - 'component' => '', - 'component-folder' => '', - 'package' => '', - 'plugins' => array(), - 'plugins-folders' => array(), - 'modules' => array() - ); - - // fixed pathes - protected $dynamicIntegration = false; - protected $backupPath = false; - protected $repoPath = false; - protected $addCustomCodeAt = array(); - - /** - * Constructor - */ - public function __construct($config = array()) - { - // to check the compiler speed - $this->time_start = microtime(true); - CFactory::_('Utilities.Counter')->start(); - // first we run the parent constructors - if (parent::__construct()) - { - // set temp directory - $comConfig = JFactory::getConfig(); - $this->tempPath = $comConfig->get('tmp_path'); - // set some folder paths in relation to distribution - if (CFactory::_('Config')->backup) - { - $this->backupPath = $this->params->get( - 'backup_folder_path', $this->tempPath - ); - // see if component has overriding options set - if (CFactory::_('Component')->get('add_backup_folder_path', 0) == 1) - { - $this->backupPath = CFactory::_('Component')->get('backup_folder_path', $this->backupPath); - } - $this->dynamicIntegration = true; - } - // set local repos switch - if (CFactory::_('Config')->repository) - { - $this->repoPath = $this->params->get('git_folder_path', null); - - // see if component has overriding options set - if (CFactory::_('Component')->get('add_git_folder_path', 0) == 1) - { - $this->repoPath = CFactory::_('Component')->get('git_folder_path', $this->repoPath); - } - } - // remove site folder if not needed (TODO add check if custom script was moved to site folder then we must do a more complex cleanup here) - if (CFactory::_('Config')->remove_site_folder && CFactory::_('Config')->remove_site_edit_folder) - { - // first remove the files and folders - CFactory::_('Utilities.Folder')->remove(CFactory::_('Utilities.Paths')->component_path . '/site'); - // clear form component xml - $xmlPath = CFactory::_('Utilities.Paths')->component_path . '/' - . CFactory::_('Compiler.Builder.Content.One')->get('component') . '.xml'; - $componentXML = FileHelper::getContent($xmlPath); - $textToSite = GetHelper::between( - $componentXML, '', '' - ); - $textToSiteLang = GetHelper::between( - $componentXML, '', '' - ); - $componentXML = str_replace( - array('' . $textToSite . "", - '' . $textToSiteLang - . ""), array('', ''), (string) $componentXML - ); - CFactory::_('Utilities.File')->write($xmlPath, $componentXML); - } - // for plugin event TODO change event api signatures - $component_context = CFactory::_('Config')->component_context; - // Trigger Event: jcb_ce_onBeforeUpdateFiles - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeUpdateFiles', - array(&$component_context, &$this) - ); - // now update the files - if (!$this->updateFiles()) - { - return false; - } - // Trigger Event: jcb_ce_onBeforeGetCustomCode - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeGetCustomCode', - array(&$component_context, &$this) - ); - // now insert into the new files - if (CFactory::_('Customcode')->get()) - { - // Trigger Event: jcb_ce_onBeforeAddCustomCode - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeAddCustomCode', - array(&$component_context, &$this) - ); - - $this->addCustomCode(); - } - // Trigger Event: jcb_ce_onBeforeSetLangFileData - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeSetLangFileData', - array(&$component_context, &$this) - ); - // set the lang data now - $this->setLangFileData(); - // set the language notice if it was set - if (ArrayHelper::check($this->langNot) - || ArrayHelper::check($this->langSet)) - { - if (ArrayHelper::check($this->langNot)) - { - $this->app->enqueueMessage( - JText::_('

Language Warning

'), 'Warning' - ); - foreach ($this->langNot as $tag => $percentage) - { - $this->app->enqueueMessage( - JText::sprintf( - 'The %s language has %s% translated, you will need to translate %s% of the language strings before it will be added.', - $tag, $percentage, $this->percentageLanguageAdd - ), 'Warning' - ); - } - $this->app->enqueueMessage( - JText::_('

Language Notice

'), 'Notice' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'You can change this percentage of translated strings required in the global options of JCB.
Please watch this tutorial for more help surrounding the JCB translations manager.', - '"https://youtu.be/zzAcVkn_cWU?list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE" target="_blank" title="JCB Tutorial surrounding Translation Manager"' - ), 'Notice' - ); - } - // set why the strings were added - $whyAddedLang = JText::sprintf( - 'because more then %s% of the strings have been translated.', - $this->percentageLanguageAdd - ); - if (CFactory::_('Config')->get('debug_line_nr', false)) - { - $whyAddedLang = JText::_( - 'because the debugging mode is on. (debug line numbers)' - ); - } - // show languages that were added - if (ArrayHelper::check($this->langSet)) - { - $this->app->enqueueMessage( - JText::_('

Language Notice

'), 'Notice' - ); - foreach ($this->langSet as $tag => $percentage) - { - $this->app->enqueueMessage( - JText::sprintf( - 'The %s language has %s% translated. Was added %s', - $tag, $percentage, $whyAddedLang - ), 'Notice' - ); - } - } - } - // set assets table column fix type messages - $message_fix['intelligent'] = JText::_( - 'The intelligent fix only updates the #__assets table\'s column when it detects that it is too small for the worse case. The intelligent fix also only reverse the #__assets table\'s update on uninstall of the component if it detects that no other component needs the rules column to be larger any longer. This options also shows a notice to the end user of all that it does to the #__assets table on installation and uninstalling of the component.' - ); - $message_fix['sql'] = JText::_( - 'The SQL fix updates the #__assets table\'s column size on installation of the component and reverses it back to the Joomla default on uninstall of the component.' - ); - // get the asset table fix switch - $add_assets_table_fix = CFactory::_('Config')->get('add_assets_table_fix', 0); - // set assets table rules column notice - if ($add_assets_table_fix) - { - $this->app->enqueueMessage( - JText::_('

Assets Table Notice

'), 'Notice' - ); - $asset_table_fix_type = ($add_assets_table_fix == 2) - ? 'intelligent' : 'sql'; - $this->app->enqueueMessage( - JText::sprintf( - 'The #__assets table %s fix has been added to this component. %s', - $asset_table_fix_type, - $message_fix[$asset_table_fix_type] - ), 'Notice' - ); - } - // set assets table rules column Warning - elseif (CFactory::_('Utilities.Counter')->accessSize >= 30) - { - $this->app->enqueueMessage( - JText::_('

Assets Table Warning

'), 'Warning' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'The Joomla #__assets table\'s rules column has to be fixed for this component to work coherently. JCB has detected that in worse case the rules column in the #__assets table may require %s characters, and yet the Joomla default is only varchar(5120). JCB has three option to resolve this issue, first use less permissions in your component, second use the SQL fix, or the intelligent fix. %s %s', - CFactory::_('Config')->access_worse_case, $message_fix['intelligent'], - $message_fix['sql'] - ), 'Warning' - ); - } - // set assets table name column warning if not set - if (!$add_assets_table_fix && CFactory::_('Config')->add_assets_table_name_fix) - { - // only add if not already added - if (CFactory::_('Utilities.Counter')->accessSize < 30) - { - $this->app->enqueueMessage( - JText::_('

Assets Table Warning

'), - 'Warning' - ); - } - $this->app->enqueueMessage( - JText::sprintf( - 'The Joomla #__assets table\'s name column has to be fixed for this component to work correctly. JCB has detected that the #__assets table name column will need to be enlarged because this component\'s own naming convention is larger than varchar(50) which is the Joomla default. JCB has three option to resolve this issue, first shorter names for your component and/or its admin views, second use the SQL fix, or the intelligent fix. %s %s', - $message_fix['intelligent'], - $message_fix['sql'] - ), 'Warning' - ); - } - // move the update server into place - $this->setUpdateServer(); - // build read me - $this->buildReadMe(); - // set local repos - $this->setLocalRepos(); - // zip the component - if (!$this->zipComponent()) - { - // done with error - return false; - } - // if there are modules zip them - $this->zipModules(); - // if there are plugins zip them - $this->zipPlugins(); - // do lang mismatch check - if (ArrayHelper::check(CFactory::_('Language.Extractor')->langMismatch)) - { - if (ArrayHelper::check(CFactory::_('Language.Extractor')->langMatch)) - { - $mismatch = array_diff( - array_unique(CFactory::_('Language.Extractor')->langMismatch), - array_unique(CFactory::_('Language.Extractor')->langMatch) - ); - } - else - { - $mismatch = array_unique(CFactory::_('Language.Extractor')->langMismatch); - } - // set a notice if we have a mismatch - if (isset($mismatch) - && ArrayHelper::check( - $mismatch - )) - { - $this->app->enqueueMessage( - JText::_('

Language Warning

'), 'Warning' - ); - if (count((array) $mismatch) > 1) - { - $this->app->enqueueMessage( - JText::_( - '

Please check the following mismatching Joomla.JText language constants.

' - ), 'Warning' - ); - } - else - { - $this->app->enqueueMessage( - JText::_( - '

Please check the following mismatch Joomla.JText language constant.

' - ), 'Warning' - ); - } - // add the mismatching issues - foreach ($mismatch as $string) - { - $constant = CFactory::_('Config')->lang_prefix . '_' - . StringHelper::safe($string, 'U'); - $this->app->enqueueMessage( - JText::sprintf( - 'The Joomla.JText._('%s') language constant for %s does not have a corresponding JText::script('%s') decalaration, please add it.', - $constant, $string, $string - ), 'Warning' - ); - } - } - } - // check if we should add a EXTERNALCODE notice - if (ArrayHelper::check($this->externalCodeString)) - { - // number of external code strings - $externalCount = count($this->externalCodeString); - // the correct string - $externalCodeString = ($externalCount == 1) ? JText::_( - 'code/string' - ) : JText::_('code/strings'); - // the notice - $this->app->enqueueMessage( - JText::_('

External Code Notice

'), 'Notice' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'There has been %s - %s added to this component as EXTERNALCODE. To avoid shipping your component with malicious %s always make sure that the correct code/string values were used.', - $externalCount, $externalCodeString, $externalCodeString - ), 'Notice' - ); - } - // end the timer here - $this->time_end = microtime(true); - $this->secondsCompiled = $this->time_end - $this->time_start; - CFactory::_('Utilities.Counter')->end(); - - // completed the compilation - return true; - } - - return false; - } - - /** - * Set the dynamic data to the created fils - * - * @return bool true on success - * - */ - protected function updateFiles() - { - if (CFactory::_('Utilities.Files')->exists('static') - && CFactory::_('Utilities.Files')->exists('dynamic')) - { - // get the bom file - $bom = FileHelper::getContent(CFactory::_('Config')->bom_path); - // first we do the static files - foreach (CFactory::_('Utilities.Files')->get('static') as $static) - { - if (File::exists($static['path'])) - { - $this->setFileContent( - $static['name'], $static['path'], $bom - ); - } - } - // now we do the dynamic files - foreach (CFactory::_('Utilities.Files')->get('dynamic') as $view => $files) - { - if (CFactory::_('Compiler.Builder.Content.Multi')->isArray($view)) - { - foreach ($files as $file) - { - if ($file['view'] == $view) - { - if (File::exists($file['path'])) - { - $this->setFileContent( - $file['name'], $file['path'], $bom, - $file['view'] - ); - } - } - } - } - // free up some memory - CFactory::_('Compiler.Builder.Content.Multi')->remove($view); - } - // free up some memory - CFactory::_('Utilities.Files')->remove('dynamic'); - // do modules if found - if (CFactory::_('Joomlamodule.Data')->exists()) - { - foreach (CFactory::_('Joomlamodule.Data')->get() as $module) - { - if (ObjectHelper::check($module) - && CFactory::_('Utilities.Files')->exists($module->key)) - { - // move field or rule if needed - if (isset($module->fields_rules_paths) - && $module->fields_rules_paths == 2) - { - // check the config fields - if (isset($module->config_fields) - && ArrayHelper::check( - $module->config_fields - )) - { - foreach ( - $module->config_fields as $field_name => - $fieldsets - ) - { - foreach ($fieldsets as $fieldset => $fields) - { - foreach ($fields as $field) - { - $this->moveFieldsRules( - $field, $module->folder_path - ); - } - } - } - } - // check the fieldsets - if (isset($module->form_files) - && ArrayHelper::check( - $module->form_files - )) - { - foreach ($module->form_files as $file => $files) - { - foreach ( - $files as $field_name => $fieldsets - ) - { - foreach ( - $fieldsets as $fieldset => $fields - ) - { - foreach ($fields as $field) - { - $this->moveFieldsRules( - $field, $module->folder_path - ); - } - } - } - } - } - } - // update the module files - foreach (CFactory::_('Utilities.Files')->get($module->key) as $module_file) - { - if (File::exists($module_file['path'])) - { - $this->setFileContent( - $module_file['name'], $module_file['path'], - $bom, $module->key - ); - } - } - // free up some memory - CFactory::_('Utilities.Files')->remove($module->key); - CFactory::_('Compiler.Builder.Content.Multi')->remove($module->key); - } - } - } - // do plugins if found - if (CFactory::_('Joomlaplugin.Data')->exists()) - { - foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin) - { - if (ObjectHelper::check($plugin) - && CFactory::_('Utilities.Files')->exists($plugin->key)) - { - // move field or rule if needed - if (isset($plugin->fields_rules_paths) - && $plugin->fields_rules_paths == 2) - { - // check the config fields - if (isset($plugin->config_fields) - && ArrayHelper::check( - $plugin->config_fields - )) - { - foreach ( - $plugin->config_fields as $field_name => - $fieldsets - ) - { - foreach ($fieldsets as $fieldset => $fields) - { - foreach ($fields as $field) - { - $this->moveFieldsRules( - $field, $plugin->folder_path - ); - } - } - } - } - // check the fieldsets - if (isset($plugin->form_files) - && ArrayHelper::check( - $plugin->form_files - )) - { - foreach ($plugin->form_files as $file => $files) - { - foreach ( - $files as $field_name => $fieldsets - ) - { - foreach ( - $fieldsets as $fieldset => $fields - ) - { - foreach ($fields as $field) - { - $this->moveFieldsRules( - $field, $plugin->folder_path - ); - } - } - } - } - } - } - // update the plugin files - foreach (CFactory::_('Utilities.Files')->get($plugin->key) as $plugin_file) - { - if (File::exists($plugin_file['path'])) - { - $this->setFileContent( - $plugin_file['name'], $plugin_file['path'], - $bom, $plugin->key - ); - } - } - // free up some memory - CFactory::_('Utilities.Files')->remove($plugin->key); - CFactory::_('Compiler.Builder.Content.Multi')->remove($plugin->key); - } - } - } - // do powers if found - if (ArrayHelper::check(CFactory::_('Power')->active)) - { - foreach (CFactory::_('Power')->active as $power) - { - if (ObjectHelper::check($power) - && CFactory::_('Utilities.Files')->exists($power->key)) - { - // update the power files - foreach (CFactory::_('Utilities.Files')->get($power->key) as $power_file) - { - if (File::exists($power_file['path'])) - { - $this->setFileContent( - $power_file['name'], $power_file['path'], - $bom, $power->key - ); - } - } - // free up some memory - CFactory::_('Utilities.Files')->remove($power->key); - CFactory::_('Compiler.Builder.Content.Multi')->remove($power->key); - } - } - } - // do super powers details if found - if (ArrayHelper::check(CFactory::_('Power')->superpowers)) - { - foreach (CFactory::_('Power')->superpowers as $path => $powers) - { - $key = StringHelper::safe($path); - if (CFactory::_('Utilities.Files')->exists($key)) - { - // update the power files - foreach (CFactory::_('Utilities.Files')->get($key) as $power_file) - { - if (File::exists($power_file['path'])) - { - $this->setFileContent( - $power_file['name'], $power_file['path'], - $bom, $key - ); - } - } - // free up some memory - CFactory::_('Utilities.Files')->remove($key); - CFactory::_('Compiler.Builder.Content.Multi')->remove($key); - } - } - } - - return true; - } - - return false; - } - - /** - * set the file content - * - * @return void - * - */ - protected function setFileContent(&$name, &$path, &$bom, $view = null) - { - // for plugin event TODO change event api signatures - $component_context = CFactory::_('Config')->component_context; - - // Trigger Event: jcb_ce_onBeforeSetFileContent - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeSetFileContent', - array(&$component_context, &$name, &$path, &$bom, &$view) - ); - - // set the file name - CFactory::_('Compiler.Builder.Content.One')->set('FILENAME', $name); - - // check if the file should get PHP opening - $php = ''; - if (ComponentbuilderHelper::checkFileType($name, 'php')) - { - $php = "trigger( - 'jcb_ce_onGetFileContents', - array(&$component_context, &$string, &$name, &$path, &$bom, - &$view) - ); - - // see if we should add a BOM - if (strpos((string) $string, (string) Placefix::_h('BOM')) !== false) - { - list($wast, $code) = explode( - Placefix::_h('BOM'), (string) $string - ); - $string = $php . $bom . $code; - } - - // set the answer - $answer = CFactory::_('Placeholder')->update($string, CFactory::_('Compiler.Builder.Content.One')->allActive(), 3); - - // set the dynamic answer - if ($view) - { - $placeholders = CFactory::_('Compiler.Builder.Content.Multi')->get($view, []); - if (is_array($placeholders)) - { - $answer = CFactory::_('Placeholder')->update( - $answer, $placeholders, 3 - ); - } - else - { - echo '
';
-				var_dump($view, $placeholders);
-				exit;
-			}
-			unset($placeholders);
-		}
-
-		// check if this file needs extra care :)
-		if (CFactory::_('Registry')->exists('update.file.content.' . $path))
-		{
-			$answer = CFactory::_('Customcode')->update($answer);
-		}
-
-		// Trigger Event: jcb_ce_onBeforeSetFileContent
-		CFactory::_('Event')->trigger(
-			'jcb_ce_onBeforeWriteFileContent',
-			array(&$component_context, &$answer, &$name, &$path, &$bom,
-			      &$view)
-		);
-
-		// inject any super powers found
-		$answer = CFactory::_('Power.Injector')->power($answer);
-
-		// add answer back to file
-		CFactory::_('Utilities.File')->write($path, $answer);
-
-		// count the file lines
-		CFactory::_('Utilities.Counter')->line += substr_count((string) $answer, PHP_EOL);
-	}
-
-	/**
-	 * move the local update server xml file to a remote ftp server
-	 *
-	 * @return  void
-	 *
-	 */
-	protected function setUpdateServer()
-	{
-		// move the component update server to host
-		if (CFactory::_('Component')->get('add_update_server', 0) == 1
-			&& CFactory::_('Component')->get('update_server_target', 0) == 1
-			&& isset($this->updateServerFileName)
-			&& $this->dynamicIntegration)
-		{
-			$update_server_xml_path = CFactory::_('Utilities.Paths')->component_path . '/'
-				. $this->updateServerFileName . '.xml';
-			// make sure we have the correct file
-			if (File::exists($update_server_xml_path)
-				&& ($update_server = CFactory::_('Component')->get('update_server')) !== null)
-			{
-				// move to server
-				if (!CFactory::_('Server')->legacyMove(
-					$update_server_xml_path,
-					$this->updateServerFileName . '.xml',
-					(int) $update_server,
-					CFactory::_('Component')->get('update_server_protocol')
-				))
-				{
-					$this->app->enqueueMessage(
-						JText::sprintf(
-							'Upload of component (%s) update server XML failed.',
-							CFactory::_('Component')->get('system_name')
-						), 'Error'
-					);
-				}
-				// remove the local file
-				File::delete($update_server_xml_path);
-			}
-		}
-		// move the modules update server to host
-		if (CFactory::_('Joomlamodule.Data')->exists())
-		{
-			foreach (CFactory::_('Joomlamodule.Data')->get() as $module)
-			{
-				if (ObjectHelper::check($module)
-					&& isset($module->add_update_server)
-					&& $module->add_update_server == 1
-					&& isset($module->update_server_target)
-					&& $module->update_server_target == 1
-					&& isset($module->update_server)
-					&& is_numeric($module->update_server)
-					&& $module->update_server > 0
-					&& isset($module->update_server_xml_path)
-					&& File::exists($module->update_server_xml_path)
-					&& isset($module->update_server_xml_file_name)
-					&& StringHelper::check(
-						$module->update_server_xml_file_name
-					))
-				{
-					// move to server
-					if (!CFactory::_('Server')->legacyMove(
-						$module->update_server_xml_path,
-						$module->update_server_xml_file_name,
-						(int) $module->update_server,
-						$module->update_server_protocol
-					))
-					{
-						$this->app->enqueueMessage(
-							JText::sprintf(
-								'Upload of module (%s) update server XML failed.',
-								$module->name
-							), 'Error'
-						);
-					}
-					// remove the local file
-					File::delete($module->update_server_xml_path);
-				}
-				// var_dump($module->update_server_xml_path);exit;
-			}
-		}
-		// move the plugins update server to host
-		if (CFactory::_('Joomlaplugin.Data')->exists())
-		{
-			foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin)
-			{
-				if (ObjectHelper::check($plugin)
-					&& isset($plugin->add_update_server)
-					&& $plugin->add_update_server == 1
-					&& isset($plugin->update_server_target)
-					&& $plugin->update_server_target == 1
-					&& isset($plugin->update_server)
-					&& is_numeric($plugin->update_server)
-					&& $plugin->update_server > 0
-					&& isset($plugin->update_server_xml_path)
-					&& File::exists($plugin->update_server_xml_path)
-					&& isset($plugin->update_server_xml_file_name)
-					&& StringHelper::check(
-						$plugin->update_server_xml_file_name
-					))
-				{
-					// move to server
-					if (!CFactory::_('Server')->legacyMove(
-						$plugin->update_server_xml_path,
-						$plugin->update_server_xml_file_name,
-						(int) $plugin->update_server,
-						$plugin->update_server_protocol
-					))
-					{
-						$this->app->enqueueMessage(
-							JText::sprintf(
-								'Upload of plugin (%s) update server XML failed.',
-								$plugin->name
-							), 'Error'
-						);
-					}
-					// remove the local file
-					File::delete($plugin->update_server_xml_path);
-				}
-			}
-		}
-	}
-
-	// link changes made to views into the file license
-	protected function fixLicenseValues($data)
-	{
-		// check if these files have its own config data)
-		if (isset($data['config'])
-			&& ArrayHelper::check(
-				$data['config']
-			)
-			&& CFactory::_('Component')->get('mvc_versiondate', 0) == 1)
-		{
-			foreach ($data['config'] as $key => $value)
-			{
-				if (Placefix::_h('VERSION') === $key)
-				{
-					// hmm we sould in some way make it known that this version number
-					// is not in relation the the project but to the file only... any ideas?
-					// this is the best for now...
-					if (1 == $value)
-					{
-						$value = '@first version of this MVC';
-					}
-					else
-					{
-						$value = '@update number ' . $value . ' of this MVC';
-					}
-				}
-				CFactory::_('Compiler.Builder.Content.One')->set($key, $value);
-			}
-
-			return true;
-		}
-		// else insure to reset to global
-		CFactory::_('Compiler.Builder.Content.One')->set('CREATIONDATE', CFactory::_('Compiler.Builder.Content.One')->get('GLOBALCREATIONDATE'));
-		CFactory::_('Compiler.Builder.Content.One')->set('BUILDDATE', CFactory::_('Compiler.Builder.Content.One')->get('GLOBALBUILDDATE'));
-		CFactory::_('Compiler.Builder.Content.One')->set('VERSION', CFactory::_('Compiler.Builder.Content.One')->get('GLOBALVERSION'));
-	}
-
-	/**
-	 * Set all global numbers
-	 *
-	 * @return  void
-	 * @deprecated 3.3
-	 */
-	protected function setCountingStuff()
-	{
-		// set notice that we could not get a valid string from the target
-		$this->app->enqueueMessage(
-			JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - private function buildReadMe() - { - // do a final run to update the readme file - $two = 0; - // counter data if not set already - if (!CFactory::_('Compiler.Builder.Content.One')->exists('LINE_COUNT') - || CFactory::_('Compiler.Builder.Content.One')->get('LINE_COUNT') != CFactory::_('Utilities.Counter')->line) - { - CFactory::_('Utilities.Counter')->set(); - } - // search for the readme - foreach (CFactory::_('Utilities.Files')->get('static') as $static) - { - if (('README.md' === $static['name'] - || 'README.txt' === $static['name']) - && CFactory::_('Component')->get('addreadme') - && File::exists($static['path'])) - { - $this->setReadMe($static['path']); - $two++; - } - if ($two == 2) - { - break; - } - } - CFactory::_('Utilities.Files')->remove('static'); - } - - private function setReadMe($path) - { - // get the file - $string = FileHelper::getContent($path); - // update the file - $answer = CFactory::_('Placeholder')->update($string, CFactory::_('Compiler.Builder.Content.One')->allActive()); - // add to zip array - CFactory::_('Utilities.File')->write($path, $answer); - } - - /** - * Build README data - * - * @return void - * @deprecated 3.3 - */ - private function buildReadMeData() - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - private function setLocalRepos() - { - // move it to the repo folder if set - if (isset($this->repoPath) - && StringHelper::check( - $this->repoPath - )) - { - // set the repo path - $repoFullPath = $this->repoPath . '/com_' - . CFactory::_('Component')->get('sales_name') . '__joomla_' - . CFactory::_('Config')->get('version', 3); - // for plugin event TODO change event api signatures - $component_context = CFactory::_('Config')->component_context; - $component_path = CFactory::_('Utilities.Paths')->component_path; - // Trigger Event: jcb_ce_onBeforeUpdateRepo - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeUpdateRepo', - array(&$component_context, &$component_path, - &$repoFullPath, &$this->componentData) - ); - // remove old data - CFactory::_('Utilities.Folder')->remove($repoFullPath, CFactory::_('Component')->get('toignore')); - // set the new data - try { - Folder::copy(CFactory::_('Utilities.Paths')->component_path, $repoFullPath, '', true); - } catch (\RuntimeException $e) { - $this->app->enqueueMessage( - JText::_('We where was unable to transfer the component to the git repository:') . ' ' . $e->getMessage() - , 'Error' - ); - } - // Trigger Event: jcb_ce_onAfterUpdateRepo - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterUpdateRepo', - array(&$component_context, &$component_path, - &$repoFullPath, &$this->componentData) - ); - - // move the modules to local folder repos - if (CFactory::_('Joomlamodule.Data')->exists()) - { - foreach (CFactory::_('Joomlamodule.Data')->get() as $module) - { - if (ObjectHelper::check($module) - && isset($module->file_name)) - { - $module_context = 'module.' . $module->file_name . '.' - . $module->id; - // set the repo path - $repoFullPath = $this->repoPath . '/' - . $module->folder_name . '__joomla_' - . CFactory::_('Config')->get('version', 3); - // Trigger Event: jcb_ce_onBeforeUpdateRepo - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeUpdateRepo', - array(&$module_context, &$module->folder_path, - &$repoFullPath, &$module) - ); - // remove old data - CFactory::_('Utilities.Folder')->remove( - $repoFullPath, CFactory::_('Component')->get('toignore') - ); - // set the new data - try { - Folder::copy( - $module->folder_path, $repoFullPath, '', true - ); - } catch (\RuntimeException $e) { - $this->app->enqueueMessage( - JText::sprintf('We where was unable to transfer the (%s) module to the git repository:', $module->name) . ' ' . $e->getMessage() - , 'Error' - ); - } - // Trigger Event: jcb_ce_onAfterUpdateRepo - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterUpdateRepo', - array(&$module_context, &$module->folder_path, - &$repoFullPath, &$module) - ); - } - } - } - // move the plugins to local folder repos - if (CFactory::_('Joomlaplugin.Data')->exists()) - { - foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin) - { - if (ObjectHelper::check($plugin) - && isset($plugin->file_name)) - { - $plugin_context = 'plugin.' . $plugin->file_name . '.' - . $plugin->id; - // set the repo path - $repoFullPath = $this->repoPath . '/' - . $plugin->folder_name . '__joomla_' - . CFactory::_('Config')->get('version', 3); - // Trigger Event: jcb_ce_onBeforeUpdateRepo - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeUpdateRepo', - array(&$plugin_context, &$plugin->folder_path, - &$repoFullPath, &$plugin) - ); - // remove old data - CFactory::_('Utilities.Folder')->remove( - $repoFullPath, CFactory::_('Component')->get('toignore') - ); - // set the new data - try { - Folder::copy( - $plugin->folder_path, $repoFullPath, '', true - ); - } catch (\RuntimeException $e) { - $this->app->enqueueMessage( - JText::sprintf('We where was unable to transfer the (%s) plugin to the git repository:', $plugin->name) . ' ' . $e->getMessage() - , 'Error' - ); - } - // Trigger Event: jcb_ce_onAfterUpdateRepo - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterUpdateRepo', - array(&$plugin_context, &$plugin->folder_path, - &$repoFullPath, &$plugin) - ); - } - } - } - } - } - - private function zipComponent() - { - // Component Folder Name - $this->filepath['component-folder'] = CFactory::_('Utilities.Paths')->component_folder_name; - // the name of the zip file to create - $this->filepath['component'] = $this->tempPath . '/' - . $this->filepath['component-folder'] . '.zip'; - // for plugin event TODO change event api signatures - $component_context = CFactory::_('Config')->component_context; - $component_path = CFactory::_('Utilities.Paths')->component_path; - $component_sales_name = CFactory::_('Utilities.Paths')->component_sales_name; - $component_folder_name = CFactory::_('Utilities.Paths')->component_folder_name; - // Trigger Event: jcb_ce_onBeforeZipComponent - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeZipComponent', - array(&$component_context, &$component_path, - &$this->filepath['component'], &$this->tempPath, - &$component_folder_name, &$this->componentData) - ); - //create the zip file - if (FileHelper::zip( - CFactory::_('Utilities.Paths')->component_path, - $this->filepath['component'] - )) - { - // now move to backup if zip was made and backup is required - if ($this->backupPath && $this->dynamicIntegration) - { - // Trigger Event: jcb_ce_onBeforeBackupZip - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeBackupZip',[ - &$component_context, - &$this->filepath['component'], - &$this->tempPath, - &$this->backupPath, - &$this->componentData - ]); - // copy the zip to backup path - try { - File::copy( - $this->filepath['component'], - $this->backupPath . '/' . CFactory::_('Utilities.Paths')->component_backup_name - . '.zip' - ); - } catch (\RuntimeException $e) { - $this->app->enqueueMessage( - JText::_('We where was unable to transfer the component ZIP file to the backup folder:') . ' ' . $e->getMessage() - , 'Error' - ); - } - } - // move to sales server host - if (CFactory::_('Component')->get('add_sales_server', 0) == 1 - && $this->dynamicIntegration) - { - // make sure we have the correct file - if (CFactory::_('Component')->get('sales_server')) - { - // Trigger Event: jcb_ce_onBeforeMoveToServer - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeMoveToServer', - array(&$component_context, - &$this->filepath['component'], &$this->tempPath, - &$component_sales_name, &$this->componentData) - ); - // move to server - if (!CFactory::_('Server')->legacyMove( - $this->filepath['component'], - $component_sales_name . '.zip', - (int) CFactory::_('Component')->get('sales_server'), - CFactory::_('Component')->get('sales_server_protocol') - )) - { - $this->app->enqueueMessage( - JText::sprintf( - 'Upload of component (%s) zip file failed.', - CFactory::_('Component')->get('system_name') - ), 'Error' - ); - } - } - } - // Trigger Event: jcb_ce_onAfterZipComponent - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterZipComponent', - array(&$component_context, &$this->filepath['component'], - &$this->tempPath, &$component_folder_name, - &$this->componentData) - ); - // remove the component folder since we are done - if (CFactory::_('Utilities.Folder')->remove(CFactory::_('Utilities.Paths')->component_path)) - { - return true; - } - } - - return false; - } - - private function zipModules() - { - if (CFactory::_('Joomlamodule.Data')->exists()) - { - foreach (CFactory::_('Joomlamodule.Data')->get() as $module) - { - if (ObjectHelper::check($module) - && isset($module->zip_name) - && StringHelper::check($module->zip_name) - && isset($module->folder_path) - && StringHelper::check( - $module->folder_path - )) - { - // set module context - $module_context = $module->file_name . '.' . $module->id; - // Component Folder Name - $this->filepath['modules-folder'][$module->id] - = $module->zip_name; - // the name of the zip file to create - $this->filepath['modules'][$module->id] = $this->tempPath - . '/' . $module->zip_name . '.zip'; - // Trigger Event: jcb_ce_onBeforeZipModule - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeZipModule', - array(&$module_context, &$module->folder_path, - &$this->filepath['modules'][$module->id], - &$this->tempPath, &$module->zip_name, &$module) - ); - //create the zip file - if (FileHelper::zip( - $module->folder_path, - $this->filepath['modules'][$module->id] - )) - { - // now move to backup if zip was made and backup is required - if ($this->backupPath) - { - $__module_context = 'module.' . $module_context; - // Trigger Event: jcb_ce_onBeforeBackupZip - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeBackupZip', - array(&$__module_context, - &$this->filepath['modules'][$module->id], - &$this->tempPath, &$this->backupPath, - &$module) - ); - // copy the zip to backup path - try { - File::copy( - $this->filepath['modules'][$module->id], - $this->backupPath . '/' . $module->zip_name - . '.zip' - ); - } catch (\RuntimeException $e) { - $this->app->enqueueMessage( - JText::sprintf('We where was unable to transfer the (%s) module zip file to the backup folder:', $module->name) . ' ' . $e->getMessage() - , 'Error' - ); - } - } - // move to sales server host - if ($module->add_sales_server == 1) - { - // make sure we have the correct file - if (isset($module->sales_server)) - { - // Trigger Event: jcb_ce_onBeforeMoveToServer - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeMoveToServer', - array(&$__module_context, - &$this->filepath['modules'][$module->id], - &$this->tempPath, &$module->zip_name, - &$module) - ); - // move to server - if (!CFactory::_('Server')->legacyMove( - $this->filepath['modules'][$module->id], - $module->zip_name . '.zip', - (int) $module->sales_server, - $module->sales_server_protocol - )) - { - $this->app->enqueueMessage( - JText::sprintf( - 'Upload of module (%s) zip file failed.', - $module->name - ), 'Error' - ); - } - } - } - // Trigger Event: jcb_ce_onAfterZipModule - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterZipModule', array(&$module_context, - &$this->filepath['modules'][$module->id], - &$this->tempPath, - &$module->zip_name, - &$module) - ); - // remove the module folder since we are done - CFactory::_('Utilities.Folder')->remove($module->folder_path); - } - } - } - } - } - - private function zipPlugins() - { - if (CFactory::_('Joomlaplugin.Data')->exists()) - { - foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin) - { - if (ObjectHelper::check($plugin) - && isset($plugin->zip_name) - && StringHelper::check($plugin->zip_name) - && isset($plugin->folder_path) - && StringHelper::check( - $plugin->folder_path - )) - { - // set plugin context - $plugin_context = $plugin->file_name . '.' . $plugin->id; - // Component Folder Name - $this->filepath['plugins-folder'][$plugin->id] - = $plugin->zip_name; - // the name of the zip file to create - $this->filepath['plugins'][$plugin->id] = $this->tempPath - . '/' . $plugin->zip_name . '.zip'; - // Trigger Event: jcb_ce_onBeforeZipPlugin - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeZipPlugin', - array(&$plugin_context, &$plugin->folder_path, - &$this->filepath['plugins'][$plugin->id], - &$this->tempPath, &$plugin->zip_name, &$plugin) - ); - //create the zip file - if (FileHelper::zip( - $plugin->folder_path, - $this->filepath['plugins'][$plugin->id] - )) - { - // now move to backup if zip was made and backup is required - if ($this->backupPath) - { - $__plugin_context = 'plugin.' . $plugin_context; - // Trigger Event: jcb_ce_onBeforeBackupZip - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeBackupZip', - array(&$__plugin_context, - &$this->filepath['plugins'][$plugin->id], - &$this->tempPath, &$this->backupPath, - &$plugin) - ); - // copy the zip to backup path - try { - File::copy( - $this->filepath['plugins'][$plugin->id], - $this->backupPath . '/' . $plugin->zip_name - . '.zip' - ); - } catch (\RuntimeException $e) { - $this->app->enqueueMessage( - JText::sprintf('We where was unable to transfer the (%s) plugin zip file to the backup folder:', $plugin->name) . ' ' . $e->getMessage() - , 'Error' - ); - } - } - - // move to sales server host - if ($plugin->add_sales_server == 1) - { - // make sure we have the correct file - if (isset($plugin->sales_server)) - { - // Trigger Event: jcb_ce_onBeforeMoveToServer - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeMoveToServer', - array(&$__plugin_context, - &$this->filepath['plugins'][$plugin->id], - &$this->tempPath, &$plugin->zip_name, - &$plugin) - ); - // move to server - if (!CFactory::_('Server')->legacyMove( - $this->filepath['plugins'][$plugin->id], - $plugin->zip_name . '.zip', - (int) $plugin->sales_server, - $plugin->sales_server_protocol - )) - { - $this->app->enqueueMessage( - JText::sprintf( - 'Upload of plugin (%s) zip file failed.', - $plugin->name - ), 'Error' - ); - } - } - } - // Trigger Event: jcb_ce_onAfterZipPlugin - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterZipPlugin', array(&$plugin_context, - &$this->filepath['plugins'][$plugin->id], - &$this->tempPath, - &$plugin->zip_name, - &$plugin) - ); - // remove the plugin folder since we are done - CFactory::_('Utilities.Folder')->remove($plugin->folder_path); - } - } - } - } - } - - protected function addCustomCode() - { - // reset all these - CFactory::_('Placeholder')->clearType('view'); - CFactory::_('Placeholder')->clearType('arg'); - foreach (CFactory::_('Customcode')->active as $nr => $target) - { - // reset each time per custom code - $fingerPrint = array(); - if (isset($target['hashtarget'][0]) && $target['hashtarget'][0] > 3 - && isset($target['path']) - && StringHelper::check($target['path']) - && isset($target['hashtarget'][1]) - && StringHelper::check( - $target['hashtarget'][1] - )) - { - $file = CFactory::_('Utilities.Paths')->component_path . '/' . $target['path']; - $size = (int) $target['hashtarget'][0]; - $hash = $target['hashtarget'][1]; - $cut = $size - 1; - $found = false; - $bites = 0; - $lineBites = array(); - $replace = array(); - if ($target['type'] == 1 && isset($target['hashendtarget'][0]) - && $target['hashendtarget'][0] > 0) - { - $foundEnd = false; - $sizeEnd = (int) $target['hashendtarget'][0]; - $hashEnd = $target['hashendtarget'][1]; - $cutEnd = $sizeEnd - 1; - } - else - { - // replace to the end of the file - $foundEnd = true; - } - $counter = 0; - // check if file exist - if (File::exists($file)) - { - foreach ( - new SplFileObject($file) as $lineNumber => $lineContent - ) - { - // if not found we need to load line bites per line - $lineBites[$lineNumber] = (int) mb_strlen( - $lineContent, '8bit' - ); - if (!$found) - { - $bites = (int) MathHelper::bc( - 'add', $lineBites[$lineNumber], $bites - ); - } - if ($found && !$foundEnd) - { - $replace[] = (int) $lineBites[$lineNumber]; - // we must keep last three lines to dynamic find target entry - $fingerPrint[$lineNumber] = trim($lineContent); - // check lines each time if it fits our target - if (count((array) $fingerPrint) === $sizeEnd - && !$foundEnd) - { - $fingerTest = md5(implode('', $fingerPrint)); - if ($fingerTest === $hashEnd) - { - // we are done here - $foundEnd = true; - $replace = array_slice( - $replace, 0, count($replace) - $sizeEnd - ); - break; - } - else - { - $fingerPrint = array_slice( - $fingerPrint, -$cutEnd, $cutEnd, true - ); - } - } - continue; - } - if ($found && $foundEnd) - { - $replace[] = (int) $lineBites[$lineNumber]; - } - // we must keep last three lines to dynamic find target entry - $fingerPrint[$lineNumber] = trim($lineContent); - // check lines each time if it fits our target - if (count((array) $fingerPrint) === $size && !$found) - { - $fingerTest = md5(implode('', $fingerPrint)); - if ($fingerTest === $hash) - { - // we are done here - $found = true; - // reset in case - $fingerPrint = array(); - // break if it is insertion - if ($target['type'] == 2) - { - break; - } - } - else - { - $fingerPrint = array_slice( - $fingerPrint, -$cut, $cut, true - ); - } - } - } - if ($found) - { - $placeholder = CFactory::_('Placeholder')->keys( - (int) $target['comment_type'] . $target['type'], - $target['id'] - ); - $data = $placeholder['start'] . PHP_EOL - . CFactory::_('Placeholder')->update_( - $target['code'] - ) . $placeholder['end'] . PHP_EOL; - if ($target['type'] == 2) - { - // found it now add code from the next line - $this->addDataToFile($file, $data, $bites); - } - elseif ($target['type'] == 1 && $foundEnd) - { - // found it now add code from the next line - $this->addDataToFile( - $file, $data, $bites, (int) array_sum($replace) - ); - } - else - { - // Load escaped code since the target endhash has changed - $this->loadEscapedCode($file, $target, $lineBites); - $this->app->enqueueMessage( - JText::_('

Custom Code Warning

'), - 'Warning' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Custom code %s could not be added to %s please review the file after install at line %s and reposition the code, remove the comments and recompile to fix the issue. The issue could be due to a change to lines below the custom code.', - '#' - . $target['id'] . '', $target['path'], - $target['from_line'] - ), 'Warning' - ); - } - } - else - { - // Load escaped code since the target hash has changed - $this->loadEscapedCode($file, $target, $lineBites); - $this->app->enqueueMessage( - JText::_('

Custom Code Warning

'), - 'Warning' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Custom code %s could not be added to %s please review the file after install at line %s and reposition the code, remove the comments and recompile to fix the issue. The issue could be due to a change to lines above the custom code.', - '#' - . $target['id'] . '', $target['path'], - $target['from_line'] - ), 'Warning' - ); - } - } - else - { - // Give developer a notice that file is not found. - $this->app->enqueueMessage( - JText::_('

Custom Code Warning

'), - 'Warning' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'File %s could not be found, so the custom code for this file could not be addded.', - $target['path'] - ), 'Warning' - ); - } - } - } - } - - protected function loadEscapedCode($file, $target, $lineBites) - { - // get comment type - if ($target['comment_type'] == 1) - { - $commentType = "// "; - $_commentType = ""; - } - else - { - $commentType = ""; - } - // escape the code - $code = explode(PHP_EOL, (string) $target['code']); - $code = PHP_EOL . $commentType . implode( - $_commentType . PHP_EOL . $commentType, $code - ) . $_commentType . PHP_EOL; - // get placeholders - $placeholder = CFactory::_('Placeholder')->keys( - (int) $target['comment_type'] . $target['type'], $target['id'] - ); - // build the data - $data = $placeholder['start'] . $code . $placeholder['end'] . PHP_EOL; - // get the bites before insertion - $bitBucket = array(); - foreach ($lineBites as $line => $value) - { - if ($line < $target['from_line']) - { - $bitBucket[] = $value; - } - } - // add to the file - $this->addDataToFile($file, $data, (int) array_sum($bitBucket)); - } - - /** - * Inserts or replaces data in a file at a specific position. - * Thanks to http://stackoverflow.com/a/16813550/1429677 - * - * @param string $file The path of the file to modify - * @param string $data The data to insert or replace - * @param int $position The position in the file where the data should be inserted or replaced - * @param int|null $replace The number of bytes to replace; if null, data will be inserted - * - * @return void - * @throws RuntimeException if unable to open the file - */ - protected function addDataToFile(string $file, string $data, int $position, ?int $replace = null) - { - // Open the file and a temporary stream - $actual_file = fopen($file, "rw+"); - if ($actual_file === false) - { - throw new RuntimeException("Unable to open the file: {$file}"); - } - - $temp_file = fopen('php://temp', "rw+"); - - // Make a copy of the file in the temporary stream - stream_copy_to_stream($actual_file, $temp_file); - - // Move to the position where the data should be added - fseek($actual_file, $position); - - // Add the data - fwrite($actual_file, $data); - - // Truncate the file at the end of the added data if replacing - $data_length = mb_strlen($data, '8bit'); - $remove = MathHelper::bc('add', $position, $data_length); - ftruncate($actual_file, $remove); - - // check if this was a replacement of data - $position = MathHelper::bc('add', $position, $replace ?: 0); - - // Move to the position of the remaining data in the temporary stream - fseek($temp_file, $position); - - // Copy the remaining data from the temporary stream to the file - stream_copy_to_stream($temp_file, $actual_file); - - // Close both file handles - fclose($actual_file); - fclose($temp_file); - - // any help to improve this is welcome... - } - -} diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php deleted file mode 100644 index e38d6e2e1..000000000 --- a/admin/helpers/compiler/a_Get.php +++ /dev/null @@ -1,3167 +0,0 @@ - - * @gitea Joomla Component Builder - * @github Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use VDM\Joomla\Utilities\StringHelper; -use VDM\Joomla\Utilities\JsonHelper; -use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Unique; - -/** - * Get class as the main compilers class - * @deprecated 3.3 - */ -class Get -{ - - /** - * The Joomla Version - * - * @var string - * @deprecated 3.3 Use CFactory::_('Config')->joomla_version; - */ - public $joomlaVersion; - - /** - * The Joomla Versions - * - * @var array - * @deprecated 3.3 Use CFactory::_('Config')->joomla_versions; - */ - public $joomlaVersions = array( - 3 => array('folder_key' => 3, 'xml_version' => 3.9), // only joomla 3 - 3.10 => array('folder_key' => 3, 'xml_version' => 4.0) // legacy joomla 4 - ); - - /** - * The hash placeholder - * - * @var string - * @deprecated 3.3 Use Placefix::h(); - */ - public $hhh = '#' . '#' . '#'; - - /** - * The open bracket placeholder - * - * @var string - * @deprecated 3.3 Use Placefix::b(); - */ - public $bbb = '[' . '[' . '['; - - /** - * The close bracket placeholder - * - * @var string - * @deprecated 3.3 Use Placefix::d(); - */ - public $ddd = ']' . ']' . ']'; - - /** - * The app - * - * @var object - */ - public $app; - - /** - * The Params - * - * @var object - */ - public $params; - - /** - * Add strict field export permissions - * - * @var boolean - */ - public $strictFieldExportPermissions = false; - - /** - * Add text only export options - * - * @var boolean - */ - public $exportTextOnly = false; - - /** - * The global placeholders - * - * @var array - * @deprecated 3.3 Use CFactory::_('Component.Placeholder')->get(); - */ - public $globalPlaceholders = array(); - - /** - * The placeholders - * - * @var array - * @deprecated 3.3 Use CFactory::_('Placeholder')->active[]; - */ - public $placeholders = array(); - - /** - * The Compiler Path - * - * @var object - * @deprecated 3.3 Use CFactory::_('Config')->compiler_path; - */ - public $compilerPath; - - /** - * The JCB Powers Path - * - * @var object - * @deprecated 3.3 Use CFactory::_('Config')->jcb_powers_path; - */ - public $jcbPowersPath; - - /** - * Switch to add assets table fix - * - * @var int - * @deprecated 3.3 Use CFactory::_('Config')->add_assets_table_fix; - */ - public $addAssetsTableFix = 1; - - /** - * Assets table worse case - * - * @var int - * @deprecated 3.3 Use CFactory::_('Config')->access_worse_case; - */ - public $accessWorseCase; - - /** - * Switch to add assets table name fix - * - * @var bool - * @deprecated 3.3 Use CFactory::_('Config')->add_assets_table_name_fix; - */ - public $addAssetsTableNameFix = false; - - /** - * Switch to add custom code placeholders - * - * @var bool - * @deprecated 3.3 Use CFactory::_('Config')->add_placeholders; - */ - public $addPlaceholders = false; - - /** - * Switch to remove line breaks from language strings - * - * @var bool - * @deprecated 3.3 Use CFactory::_('Config')->remove_line_breaks; - */ - public $removeLineBreaks = false; - - /** - * The placeholders for custom code keys - * - * @var array - * @deprecated 3.3 - */ - protected $customCodeKeyPlacholders - = array( - '[' => '[', - ']' => ']', - ',' => ',', - '+' => '+', - '=' => '=' - ); - - /** - * The Component data - * - * @var object - * @deprecated 3.3 Use CFactory::_('Component'); - */ - public $componentData; - - /** - * The Switch to add Powers data - * - * @var boolean - * @deprecated 3.3 Use CFactory::_('Config')->add_power; - */ - public $addPower; - - /** - * The Powers data - * - * @var array - * @deprecated 3.3 Use CFactory::_('Power')->active; - */ - public $powers = array(); - - /** - * The state of all Powers - * - * @var array - * @deprecated 3.3 - */ - public $statePowers = array(); - - /** - * The linked Powers - * - * @var array - */ - public $linkedPowers = array(); - - /** - * The Plugins data - * - * @var array - * @deprecated 3.3 Use CFactory::_('Joomlaplugin.Data')->get(); - */ - public $joomlaPlugins = array(); - - /** - * The Modules data - * - * @var array - * @deprecated 3.3 Use CFactory::_('Joomlamodule.Data')->get(); - */ - public $joomlaModules = array(); - - /** - * The custom script placeholders - we use the (xxx) to avoid detection it should be (***) - * ##################################---> PHP/JS <---#################################### - * - * New Insert Code = /xxx[INSERT<>$$$$]xxx/ /xxx[/INSERT<>$$$$]xxx/ - * New Replace Code = /xxx[REPLACE<>$$$$]xxx/ /xxx[/REPLACE<>$$$$]xxx/ - * - * //////////////////////////////// when JCB adds it back ////////////////////////////////// - * JCB Add Inserted Code = /xxx[INSERTED$$$$]xxx//xx23xx/ /xxx[/INSERTED$$$$]xxx/ - * JCB Add Replaced Code = /xxx[REPLACED$$$$]xxx//xx25xx/ /xxx[/REPLACED$$$$]xxx/ - * - * /////////////////////////////// changeing existing custom code ///////////////////////// - * Update Inserted Code = /xxx[INSERTED<>$$$$]xxx//xx23xx/ /xxx[/INSERTED<>$$$$]xxx/ - * Update Replaced Code = /xxx[REPLACED<>$$$$]xxx//xx25xx/ /xxx[/REPLACED<>$$$$]xxx/ - * - * The custom script placeholders - we use the (==) to avoid detection it should be (--) - * ###################################---> HTML <---##################################### - * - * New Insert Code = $$$$]==> $$$$]==> - * New Replace Code = $$$$]==> $$$$]==> - * - * ///////////////////////////////// when JCB adds it back /////////////////////////////// - * JCB Add Inserted Code = - * JCB Add Replaced Code = - * - * //////////////////////////// changeing existing custom code /////////////////////////// - * Update Inserted Code = $$$$]==> $$$$]==> - * Update Replaced Code = $$$$]==> $$$$]==> - * - * ////////23 is the ID of the code in the system don't change it!!!!!!!!!!!!!!!!!!!!!!!!!! - * - * @var array - * @deprecated 3.3 - */ - protected $customCodePlaceholders - = array( - 1 => 'REPLACE<>$$$$]', - 2 => 'INSERT<>$$$$]', - 3 => 'REPLACED<>$$$$]', - 4 => 'INSERTED<>$$$$]' - ); - - /** - * The custom code to be added - * - * @var array - * @deprecated 3.3 Use CFactory::_('Customcode')->active - */ - public $customCode; - - /** - * The custom code to be added - * - * @var array - * @deprecated 3.3 - */ - protected $customCodeData = array(); - - /** - * The function name memory ids - * - * @var array - * @deprecated 3.3 Use CFactory::_('Customcode')->functionNameMemory - */ - public $functionNameMemory = array(); - - /** - * The custom code for local memory - * - * @var array - * @deprecated 3.3 Use CFactory::_('Customcode')->memory - */ - public $customCodeMemory = array(); - - /** - * The custom code in local files that already exist in system - * - * @var array - * @deprecated 3.3 - */ - protected $existingCustomCode = array(); - - /** - * The custom code in local files this are new - * - * @var array - * @deprecated 3.3 - */ - protected $newCustomCode = array(); - - /** - * The index of code already loaded - * - * @var array - * @deprecated 3.3 - */ - protected $codeAreadyDone = array(); - - /** - * The external code/string to be added - * - * @var array - * @deprecated 3.3 - */ - protected $externalCodeString = array(); - - /** - * The external code/string cutter - * - * @var array - * @deprecated 3.3 - */ - protected $externalCodeCutter = array(); - - /* - * The line numbers Switch - * - * @var boolean - * @deprecated 3.3 Use CFactory::_('Config')->debug_line_nr; - */ - public $debugLinenr = false; - - /* - * The percentage when a language should be added - * - * @var boolean - */ - public $percentageLanguageAdd = 0; - - /** - * The Placholder Language prefix - * - * @var string - * @deprecated 3.3 Use CFactory::_('Config')->lang_prefix; - */ - public $langPrefix; - - /** - * The Language content - * - * @var array - * @deprecated 3.3 - */ - public $langContent = array(); - - /** - * The Languages bucket - * - * @var array - */ - public $languages - = array('components' => array(), 'modules' => array(), - 'plugins' => array()); - - /** - * The Main Languages - * - * @var string - * @deprecated 3.3 Use CFactory::_('Config')->lang_tag; - */ - public $langTag = 'en-GB'; - - /** - * The Multi Languages bucket - * - * @var array - */ - public $multiLangString = array(); - - /** - * The new lang to add - * - * @var array - */ - protected $newLangStrings = array(); - - /** - * The existing lang to update - * - * @var array - */ - protected $existingLangStrings = array(); - - /** - * The Language JS matching check - * - * @var array - * @deprecated 3.3 Use CFactory::_('Language.Extractor')->langMismatch; - */ - public $langMismatch = array(); - - /** - * The Language SC matching check - * - * @var array - * @deprecated 3.3 Use CFactory::_('Language.Extractor')->langMatch; - */ - public $langMatch = array(); - - /** - * The Language string targets - * - * @var array - * @deprecated 3.3 Use CFactory::_('Config')->lang_string_targets; - */ - public $langStringTargets - = array( - 'Joomla' . '.JText._(', - 'JText:' . ':script(', - 'Text:' . ':_(', // namespace and J version will be found - 'Text:' . ':sprintf(', // namespace and J version will be found - 'JustTEXT:' . ':_(' - ); - - /** - * The Component Code Name - * - * @var string - * @deprecated 3.3 Use CFactory::_('Config')->component_code_name; - */ - public $componentCodeName; - - /** - * The Component Context - * - * @var string - * @deprecated 3.3 Use CFactory::_('Config')->component_context; - */ - public $componentContext; - - /** - * The Component Code Name Length - * - * @var int - * @deprecated 3.3 Use CFactory::_('Config')->component_code_name_length; - */ - public $componentCodeNameLength; - - /** - * The Component ID - * - * @var int - * @deprecated 3.3 Use CFactory::_('Config')->component_id; - */ - public $componentID; - - /** - * The current user - * - * @var array - */ - public $user; - - /** - * The database object - * - * @var array - */ - public $db; - - /** - * The Component version - * - * @var string - * @deprecated 3.3 Use CFactory::_('Config')->component_version; - */ - public $component_version; - - /** - * The UIKIT Switch - * - * @var boolean - * @deprecated 3.3 Use CFactory::_('Config')->uikit; - */ - public $uikit = 0; - - /** - * The UIKIT component checker - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Uikit.Comp')->get($key); - */ - public $uikitComp = array(); - - /** - * The FOOTABLE Switch - * - * @var boolean - * @deprecated 3.3 Use CFactory::_('Config')->footable; - */ - public $footable = false; - - /** - * The FOOTABLE Version - * - * @var int - * @deprecated 3.3 Use CFactory::_('Config')->footable_version; - */ - public $footableVersion; - - /** - * The Google Chart Switch per view - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Google.Chart')->get($key); - */ - public $googleChart = []; - - /** - * The Google Chart Switch - * - * @var boolean - * @deprecated 3.3 Use CFactory::_('Config')->google_chart; - */ - public $googlechart = false; - - /** - * The Import & Export Switch - * - * @var boolean - * @deprecated 3.3 Use CFactory::_('Config')->add_eximport; - */ - public $addEximport = false; - - /** - * The Import & Export View - * - * @var array - */ - public $eximportView = array(); - - /** - * The Import & Export Custom Script - * - * @var array - */ - public $importCustomScripts = array(); - - /** - * The Tag & History Switch - * - * @var boolean - * @deprecated 3.3 Use CFactory::_('Config')->set_tag_history; - */ - public $setTagHistory = false; - - /** - * The Joomla Fields Switch - * - * @var boolean - * @deprecated 3.3 Use CFactory::_('Config')->set_joomla_fields; - */ - public $setJoomlaFields = false; - - /** - * The site edit views - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Site.Edit.View')->get($key); - */ - public $siteEditView = []; - - /** - * The admin list view filter type - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($key); - */ - public $adminFilterType = array(); - - /** - * The Language target - * - * @var string - * @deprecated 3.3 Use CFactory::_('Config')->lang_target; - */ - public $lang = 'admin'; - - /** - * The lang keys for extentions - * - * @var array - * @deprecated 3.3 Use CFactory::_('Language.Extractor')->langKeys; - */ - public $langKeys = array(); - - /** - * The Build target Switch - * - * @var string - * @deprecated 3.3 Use CFactory::_('Config')->build_target; - */ - public $target; - - /** - * The unique codes - * - * @var array - * @deprecated 3.3 - */ - public $uniquecodes = array(); - - /** - * The unique keys - * - * @var array - * @deprecated 3.3 - */ - public $uniquekeys = array(); - - /** - * The Add contributors Switch - * - * @var boolean - * @deprecated 3.3 Use CFactory::_('Config')->add_contributors; - */ - public $addContributors = false; - - /** - * The Custom Script Builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Customcode.Dispenser')->hub; - */ - public $customScriptBuilder = array(); - - /** - * The Footable Script Builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Footable.Scripts')->get($key); - */ - public $footableScripts = []; - - /** - * The pathe to the bom file to be used - * - * @var string - * @deprecated 3.3 Use CFactory::_('Config')->bom_path; - */ - public $bomPath; - - /** - * The SQL Tweak of admin views - * - * @var array - * @deprecated 3.3 Use CFactory::_('Registry')->get('builder.sql_tweak'); - */ - public $sqlTweak = []; - - /** - * The validation rules that should be added - * - * @var array - * @deprecated 3.3 Use CFactory::_('Registry')->get('validation.rules'); - */ - public $validationRules = array(); - - /** - * The validation linked to fields - * - * @var array - * @deprecated 3.3 Use CFactory::_('Registry')->get('validation.linked'); - */ - public $validationLinkedFields = array(); - - /** - * The admin views data array - * - * @var array - * @deprecated 3.3 - */ - private $_adminViewData = array(); - - /** - * The field data array - * - * @var array - * @deprecated 3.3 - */ - private $_fieldData = array(); - - /** - * The custom alias builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Custom.Alias')->get($key); - */ - public $customAliasBuilder = []; - - /** - * The field builder type - * - * 1 = StringManipulation - * 2 = SimpleXMLElement - * - * @var int - * @deprecated 3.3 Use CFactory::_('Config')->field_builder_type; - */ - public $fieldBuilderType; - - /** - * Set unique Names - * - * @var array - * @deprecated 3.3 Use CFactory::_('Registry')->get('unique.names'); - */ - public $uniqueNames = array(); - - /** - * Set unique Names - * - * @var array - * @deprecated - */ - protected $uniqueFieldNames = array(); - - /** - * Category other name bucket - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Category.Other.Name')->get($key); - */ - public $catOtherName = array(); - - /** - * The field relations values - * - * @var array - * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Field.Relations')->get($key); - */ - public $fieldRelations = array(); - - /** - * The views default ordering - * - * @var array - */ - public $viewsDefaultOrdering = array(); - - /** - * Default Fields - * - * @var array - * @deprecated 3.3 Use CFactory::_('Config')->default_fields; - */ - public $defaultFields - = array('created', 'created_by', 'modified', 'modified_by', 'published', - 'ordering', 'access', 'version', 'hits', 'id'); - - /** - * The list join fields - * - * @var array - * @deprecate 3.3 Use CFactory::_('Compiler.Builder.List.Join')->get($key); - */ - public $listJoinBuilder = array(); - - /** - * The list head over ride - * - * @var array - * @deprecate 3.3 Use CFactory::_('Compiler.Builder.List.Head.Override')->get($key); - */ - public $listHeadOverRide = array(); - - /** - * The linked admin view tabs - * - * @var array - * @deprecate 3.3 Use CFactory::_('Registry')->get('builder.linked_admin_views'); - */ - public $linkedAdminViews = array(); - - /** - * The custom admin view tabs - * - * @var array - * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Custom.Tabs')->get($key); - */ - public $customTabs = array(); - - /** - * The Add Ajax Switch - * - * @var boolean - * @deprecate 3.3 Use CFactory::_('Config')->add_ajax - */ - public $addAjax = false; - - /** - * The Add Site Ajax Switch - * - * @var boolean - * @deprecate 3.3 Use CFactory::_('Config')->add_site_ajax; - */ - public $addSiteAjax = false; - - /** - * The get Module Script Switch - * - * @var array - * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Get.Module')->get($key); - */ - public $getModule = []; - - /** - * The template data - * - * @var array - * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Template.Data')->get($key); - */ - public $templateData = []; - - /** - * The layout data - * - * @var array - * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Layout.Data')->get($key); - */ - public $layoutData = []; - - /** - * The Encryption Types - * - * @var array - * @deprecated 3.3 Use CFactory::_('Config')->cryption_types; - */ - public $cryptionTypes = array('basic', 'medium', 'whmcs', 'expert'); - - /** - * The WHMCS Encryption Switch - * - * @var boolean - * @deprecated 3.3 Use CFactory::_('Config')->whmcs_encryption; - */ - public $whmcsEncryption = false; - - /** - * The Basic Encryption Switch - * - * @var boolean - * @deprecated 3.3 Use CFactory::_('Config')->basic_encryption; - */ - public $basicEncryption = false; - - /** - * The Medium Encryption Switch - * - * @var boolean - * @deprecated 3.3 Use CFactory::_('Config')->medium_encryption; - */ - public $mediumEncryption = false; - - /** - * The Custom field Switch per view - * - * @var array - * @deprecated 3.3 - */ - public $customFieldScript = array(); - - /** - * The site main get - * - * @var array - * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Site.Main.Get')->get($key); - */ - public $siteMainGet = []; - - /** - * The site dynamic get - * - * @var array - * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Site.Dynamic.Get')->get($key); - */ - public $siteDynamicGet = []; - - /** - * The get AS lookup - * - * @var array - * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Get.As.Lookup')->get($key); - */ - public $getAsLookup = []; - - /** - * The site fields - * - * @var array - * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Site.Fields')->get($key); - */ - public $siteFields = []; - - /** - * The add SQL - * - * @var array - * @deprecate 3.3 Use CFactory::_('Registry')->get('builder.add_sql'); - */ - public $addSQL = []; - - /** - * The update SQL - * - * @var array - * @deprecate 3.3 Use CFactory::_('Registry')->get('builder.update_sql'); - */ - public $updateSQL = []; - - /** - * The data by alias keys - * - * @var array - * @deprecate 3.3 Use CFactory::_('Registry')->get('builder.data_with_alias_keys'); - */ - protected $dataWithAliasKeys = []; - - /** - * The Library Manager - * - * @var array - * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Library.Manager')->get($key); - */ - public $libManager = []; - - /** - * The Libraries - * - * @var array - * @deprecated 3.3 Use CFactory::_('Registry')->get('builder.libraries'); - */ - public $libraries = []; - - /** - * Is minify Enabled - * - * @var int - * @deprecated 3.3 Use CFactory::_('Config')->minify; - */ - public $minify = 0; - - /** - * Is Tidy Enabled - * - * @var bool - * @deprecated 3.3 Use CFactory::_('Config')->tidy; - */ - public $tidy = false; - - /** - * Set Tidy warning once switch - * - * @var bool - * @deprecated 3.3 Use CFactory::_('Config')->set_tidy_warning; - */ - public $setTidyWarning = false; - - /** - * mysql table setting keys - * - * @var array - * @deprecated 3.3 Use CFactory::_('Config')->mysql_table_keys; - */ - public $mysqlTableKeys - = array( - 'engine' => array('default' => 'MyISAM'), - 'charset' => array('default' => 'utf8'), - 'collate' => array('default' => 'utf8_general_ci'), - 'row_format' => array('default' => '') - ); - - /** - * mysql table settings - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Mysql.Table.Setting')->get($key); - */ - public $mysqlTableSetting = []; - - /** - * Constructor - */ - public function __construct() - { - // we do not yet have this set as an option - $config['remove_line_breaks'] - = 2; // 2 is global (use the components value) - // load application - $this->app = JFactory::getApplication(); - // Set the params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Trigger Event: jcb_ce_onBeforeGet - CFactory::_('Event')->trigger('jcb_ce_onBeforeGet', array(&$config, &$this)); - // set the Joomla version @deprecated - $this->joomlaVersion = CFactory::_('Config')->joomla_version; - // set the minfy switch of the JavaScript @deprecated - $this->minify = CFactory::_('Config')->get('minify', 0); - // set the global language @deprecated - $this->langTag = CFactory::_('Config')->get('lang_tag', 'en-GB'); - // also set the helper class langTag (for safeStrings) - ComponentbuilderHelper::$langTag = CFactory::_('Config')->get('lang_tag', 'en-GB'); - // setup the main language array - $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')] = array(); - // check if we have Tidy enabled @deprecated - $this->tidy = CFactory::_('Config')->get('tidy', false); - // set the field type builder @deprecated - $this->fieldBuilderType = CFactory::_('Config')->get('field_builder_type', 2); - // check the field builder type logic - if (!CFactory::_('Config')->get('tidy', false) && CFactory::_('Config')->get('field_builder_type', 2) == 2) - { - // we do not have the tidy extension set fall back to StringManipulation - $this->fieldBuilderType = 1; - // load the sugestion to use string manipulation - $this->app->enqueueMessage( - JText::_('

Field Notice

'), 'Notice' - ); - $this->app->enqueueMessage( - JText::_( - 'Since you do not have Tidy extentsion setup on your system, we could not use the SimpleXMLElement class. We instead used string manipulation to build all your fields, this is a faster method, you must inspect the xml files in your component package to see if you are satisfied with the result.
You can make this method your default by opening the global options of JCB and under the Global tab set the Field Builder Type to string manipulation.' - ), 'Notice' - ); - } - CFactory::_('Config')->set('field_builder_type', $this->fieldBuilderType); - // load the compiler path @deprecated - $this->compilerPath = CFactory::_('Config')->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler'); - // load the jcb powers path @deprecated - $this->jcbPowersPath = CFactory::_('Config')->get('jcb_powers_path', 'libraries/jcb_powers'); - // set the component ID @deprecated - $this->componentID = CFactory::_('Config')->component_id; - // set lang prefix @deprecated - $this->langPrefix = CFactory::_('Config')->lang_prefix; - // set component code name @deprecated - $this->componentCodeName = CFactory::_('Config')->component_code_name; - // set component context @deprecated - $this->componentContext = CFactory::_('Config')->component_context; - // set the component name length @deprecated - $this->componentCodeNameLength = CFactory::_('Config')->component_code_name_length; - // add assets table fix @deprecated - $this->addAssetsTableFix = CFactory::_('Config')->add_assets_table_fix; - // set if language strings line breaks should be removed @deprecated - $this->removeLineBreaks = CFactory::_('Config')->remove_line_breaks; - // set if placeholders should be added to customcode @deprecated - $this->addPlaceholders = CFactory::_('Config')->get('add_placeholders', false); - // set if line numbers should be added to comments @deprecated - $this->debugLinenr = CFactory::_('Config')->get('debug_line_nr', false); - // set if powers should be added to component (default is true) @deprecated - $this->addPower = CFactory::_('Config')->get('add_power', true); - // set the current user - $this->user = JFactory::getUser(); - // Get a db connection. - $this->db = JFactory::getDbo(); - // get global placeholders @deprecated - $this->globalPlaceholders = CFactory::_('Component.Placeholder')->get(); - - // get the custom code from installed files - CFactory::_('Customcode.Extractor')->run(); - - // for plugin event TODO change event api signatures - $component_context = CFactory::_('Config')->component_context; - // Trigger Event: jcb_ce_onBeforeGetComponentData - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeGetComponentData', - array(&$component_context, &$this) - ); - - // get the component data @deprecated - $this->componentData = CFactory::_('Component'); - - // Trigger Event: jcb_ce_onAfterGetComponentData - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterGetComponentData', - array(&$component_context, &$this) - ); - - // make sure we have a version - if (strpos((string) CFactory::_('Component')->component_version, '.') - === false) - { - CFactory::_('Component')->set('component_version ', '1.0.0'); - } - // update the version - if (!CFactory::_('Component')->exists('old_component_version') - && (CFactory::_('Registry')->get('builder.add_sql', null) - || CFactory::_('Registry')->get('builder.update_sql', null))) - { - // set the new version - $version = (array) explode( - '.', (string) CFactory::_('Component')->component_version - ); - // get last key - end($version); - $key = key($version); - // just increment the last - $version[$key]++; - // set the old version - CFactory::_('Component')->set('old_component_version', CFactory::_('Component')->component_version); - // set the new version, and set update switch - CFactory::_('Component')->set('component_version', implode( - '.', $version - )); - } - - // FOR THE HELPER CLASS POWERS - // Utilities String Helper - CFactory::_('Power')->get('1f28cb53-60d9-4db1-b517-3c7dc6b429ef', 1); - // Utilities Array Helper - CFactory::_('Power')->get('0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a', 1); - // Utilities Component Helper - CFactory::_('Power')->get('640b5352-fb09-425f-a26e-cd44eda03f15', 1); - // Utilities Object Helper - CFactory::_('Power')->get('91004529-94a9-4590-b842-e7c6b624ecf5', 1); - // Utilities GetHelper - CFactory::_('Power')->get('db87c339-5bb6-4291-a7ef-2c48ea1b06bc', 1); - // Utilities Json Helper - CFactory::_('Power')->get('4b225c51-d293-48e4-b3f6-5136cf5c3f18', 1); - // Utilities FormHelper - CFactory::_('Power')->get('1198aecf-84c6-45d2-aea8-d531aa4afdfa', 1); - - // load powers *+*+*+*+*+*+*+* - CFactory::_('Power')->load($this->linkedPowers); - // load any other super powers that was found - if (($super_powers = CFactory::_('Power.Extractor')->get_()) !== null) - { - CFactory::_('Power')->load($super_powers); - } - // set the percentage when a language can be added - $this->percentageLanguageAdd = (int) $this->params->get( - 'percentagelanguageadd', 50 - ); - - // Trigger Event: jcb_ce_onBeforeGet - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterGet', array(&$component_context, &$this) - ); - - return true; - } - - /** - * Set the tab/space - * - * @param int $nr The number of tag/space - * - * @return string - * @deprecated 3.3 Use Indent::_($nr); - */ - public function _t($nr) - { - // use global method for conformity - return Indent::_($nr); - } - - /** - * Trigger events - * - * @param string $event The event to trigger - * @param mix $data The values to pass to the event/plugin - * - * @return void - * @deprecated 3.3 Use CFactory::_('Event')->trigger($event, $data); - */ - public function triggerEvent($event, $data) - { - return CFactory::_('Event')->trigger($event, $data); - } - - /** - * get all System Placeholders - * - * @return array The global placeholders - * @deprecated 3.3 Use CFactory::_('Component.Placeholder')->get(); - */ - public function getGlobalPlaceholders() - { - return CFactory::_('Component.Placeholder')->get(); - } - - /** - * get all Component Data - * - * @return oject The component data - * @deprecated 3.3 Use CFactory::_('Component'); - */ - public function getComponentData() - { - return CFactory::_('Component'); - } - - /** - * set the language content values to language content array - * - * @param string $target The target area for the language string - * @param string $language The language key string - * @param string $string The language string - * @param boolean $addPrefix The switch to add langPrefix - * - * @return void - * @deprecated 3.3 Use CFactory::_('Language')->set($target, $language, $string, $addPrefix); - */ - public function setLangContent($target, $language, $string, $addPrefix = false) - { - CFactory::_('Language')->set($target, $language, $string, $addPrefix); - } - - /** - * We need to remove all text breaks from all language strings - * - * @param string $string The language string - * - * @return string - * @deprecated 3.3 - */ - public function fixLangString(&$string) - { - if (CFactory::_('Config')->remove_line_breaks) - { - return trim(str_replace(array(PHP_EOL, "\r", "\n"), '', $string)); - } - - return trim($string); - } - - /** - * Get all Admin View Data - * - * @param int $id The view ID - * - * @return oject The view data - * @deprecated 3.3 Use CFactory::_('Adminview.Data')->get($id); - */ - public function getAdminViewData($id) - { - return CFactory::_('Adminview.Data')->get($id); - } - - /** - * Get all Custom View Data - * - * @param int $id The view ID - * @param string $table The view table - * - * @return oject The view data - * @deprecated 3.3 Use CFactory::_('Customview.Data')->get($id, $table); - */ - public function getCustomViewData($id, $table = 'site_view') - { - return CFactory::_('Customview.Data')->get($id, $table); - } - - /** - * Get all Field Data - * - * @param int $id The field ID - * @param string $name_single The view edit or single name - * @param string $name_list The view list name - * - * @return oject The field data - * @deprecated 3.3 Use CFactory::_('Field.Data')->get($id, $name_single, $name_list); - */ - public function getFieldData($id, $name_single = null, $name_list = null) - { - return CFactory::_('Field.Data')->get($id, $name_single, $name_list); - } - - /** - * set Field details - * - * @param object $field The field object - * @param string $singleViewName The single view name - * @param string $listViewName The list view name - * @param string $amicably The peaceful resolve - * - * @return void - * @deprecated 3.3 Use CFactory::_('Field')->set($field, $singleViewName, $listViewName, $amicably); - */ - public function setFieldDetails(&$field, $singleViewName = null, $listViewName = null, $amicably = '') - { - CFactory::_('Field')->set($field, $singleViewName, $listViewName, $amicably); - } - - /** - * get the list default ordering values - * - * @param string $nameListCode The list view name - * - * @return array - * - */ - public function getListViewDefaultOrdering(&$nameListCode) - { - if (isset($this->viewsDefaultOrdering[$nameListCode]) - && $this->viewsDefaultOrdering[$nameListCode]['add_admin_ordering'] - == 1) - { - foreach ( - $this->viewsDefaultOrdering[$nameListCode]['admin_ordering_fields'] - as $order_field - ) - { - if (($order_field_name = CFactory::_('Field.Database.Name')->get( - $nameListCode, $order_field['field'] - )) !== false) - { - // just the first field is the based ordering state - return array( - 'name' => $order_field_name, - 'direction' => $order_field['direction'] - ); - } - } - } - - // the default - return array( - 'name' => 'a.id', - 'direction' => 'DESC' - ); - } - - /** - * get the field database name and AS prefix - * - * @param string $nameListCode The list view name - * @param int $fieldId The field ID - * @param string $targetArea The area being targeted - * - * @return string - * @deprecated 3.3 Use CFactory::_('Field.Database.Name')->get($nameListCode, $fieldId, $targetArea); - */ - public function getFieldDatabaseName($nameListCode, int $fieldId, $targetArea = 'builder.list') - { - return CFactory::_('Field.Database.Name')->get($nameListCode, $fieldId, $targetArea); - } - - /** - * Get the field's actual type - * - * @param object $field The field object - * - * @return string Success returns field type - * @deprecated 3.3 Use CFactory::_('Field.Type.Name')->get($field); - */ - public function getFieldType(&$field) - { - return CFactory::_('Field.Type.Name')->get($field); - } - - /** - * Get the field's actual name - * - * @param object $field The field object - * @param string $listViewName The list view name - * @param string $amicably The peaceful resolve (for fields in subforms in same view :) - * - * @return string Success returns field name - * @deprecated 3.3 Use CFactory::_('Field.Name')->get($field, $listViewName, $amicably); - */ - public function getFieldName(&$field, $listViewName = null, $amicably = '') - { - return CFactory::_('Field.Name')->get($field, $listViewName, $amicably); - } - - /** - * Count how many times the same field is used per view - * - * @param string $name The name of the field - * @param string $view The name of the view - * - * @return void - * @deprecated Use CFactory::_('Field.Unique.Name')->set($name, $view); - */ - protected function setUniqueNameCounter($name, $view) - { - CFactory::_('Field.Unique.Name')->set($name, $view); - } - - /** - * Naming each field with an unique name - * - * @param string $name The name of the field - * @param string $view The name of the view - * - * @return string the name - * @deprecated - */ - protected function uniqueName($name, $view) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - /** - * Set get Data - * - * @param array $ids The ids of the dynamic get - * @param string $view_code The view code name - * @param string $context The context for events - * - * @return oject the get dynamicGet data - * @deprecated Use CFactory::_('Dynamicget.Data')->get($ids, $view_code, $context); - */ - public function setGetData($ids, $view_code, $context) - { - return CFactory::_('Dynamicget.Data')->get($ids, $view_code, $context); - } - - /** - * Set the script for the customcode dispenser - * - * @param string $script The script - * @param string $first The first key - * @param string|null $second The second key (if not set we use only first key) - * @param string|null $third The third key (if not set we use only first and second key) - * @param array $config The config options - * @param bool $base64 The switch to decode base64 the script - * default: true - * @param bool $dynamic The switch to dynamic update the script - * default: true - * @param bool $add The switch to add to exiting instead of replace - * default: false - * - * @return bool true on success - * @deprecated 3.3 Use CFactory::_('Customcode.Dispenser')->set($script, $first, $second, $third, $config, $base64, $dynamic, $add); - */ - public function setCustomScriptBuilder( - &$script, - string $first, - ?string $second = null, - ?string $third = null, - array $config = array(), - bool $base64 = true, - bool $dynamic = true, - bool $add = false - ): bool - { - return CFactory::_('Customcode.Dispenser')->set($script, $first, $second, $third, $config, $base64, $dynamic, $add); - } - - /** - * get the a script from the custom script builder - * - * @param string $first The first key - * @param string $second The second key - * @param string $prefix The prefix to add in front of the script if found - * @param string $note The switch/note to add to the script - * @param bool $unset The switch to unset the value if found - * @param string $default The switch/string to use as default return if script not found - * @param string $sufix The sufix to add after the script if found - * - * @return mix The string/script if found or the default value if not found - * @deprecated 3.3 Use CFactory::_('Customcode.Dispenser')->get($first, $second, $prefix, $note, $unset, $default, $sufix); - */ - public function getCustomScriptBuilder($first, $second, $prefix = '', - $note = null, $unset = null, $default = null, $sufix = '' - ) - { - return CFactory::_('Customcode.Dispenser')->get($first, $second, $prefix, $note, $unset, $default, $sufix); - } - - /** - * To limit the SQL Demo date build in the views - * - * @param array $settings Tweaking array. - * - * @return void - * @deprecated 3.3 - */ - public function setSqlTweaking($settings) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - /** - * check if an update SQL is needed - * - * @param mix $old The old values - * @param mix $new The new values - * @param string $type The type of values - * @param int $key The id/key where values changed - * @param array $ignore The ids to ignore - * - * @return void - * @deprecated 3.3 Use CFactory::_('Model.Updatesql')->set($old, $new, $type, $key, $ignore); - */ - protected function setUpdateSQL($old, $new, $type, $key = null, - $ignore = null - ) - { - CFactory::_('Model.Updatesql')->set($old, $new, $type, $key, $ignore); - } - - /** - * Set the add sql - * - * @param string $type The type of values - * @param int $item The item id to add - * @param int|null $key The id/key where values changed - * - * @return void - * @deprecated 3.3 - */ - protected function setAddSQL(string $type, int $item, ?int $key = null) - { - // add key if found - if ($key) - { - CFactory::_('Registry')->set('builder.add_sql.' . $type . '.' . $key . '.' . $item, $item); - } - else - { - // convert adminview id to name - if ('adminview' === $type) - { - CFactory::_('Registry')->set('builder.add_sql.' . $type, StringHelper::safe( - $this->getAdminViewData($item)->name_single - )); - } - else - { - CFactory::_('Registry')->set('builder.add_sql.' . $type, $item); - } - } - } - - /** - * Get Item History values - * - * @param string $type The type of item - * @param int $id The item ID - * - * @return object The history - * @deprecated 3.3 Use CFactory::_('History')->get($type, $id); - */ - protected function getHistoryWatch($type, $id) - { - return CFactory::_('History')->get($type, $id); - } - - /** - * Set Item History Watch - * - * @param Object $object The history object - * @param int $action The action to take - * 0 = remove watch - * 1 = add watch - * @param string $type The type of item - * - * @return bool - * @deprecated 3.3 - */ - protected function setHistoryWatch($object, $action) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - /** - * Set Template and Layout Data - * - * @param string $default The content to check - * @param string $view The view code name - * @param boolean $found The proof that something was found - * @param array $templates The option to pass templates keys (to avoid search) - * @param array $layouts The option to pass layout keys (to avoid search) - * - * @return boolean if something was found true - * @deprecated 3.3 Use CFactory::_('Templatelayout.Data')->set($default, $view, $found, $templates, $layouts); - */ - public function setTemplateAndLayoutData($default, $view, $found = false, - $templates = array(), $layouts = array() - ) - { - return CFactory::_('Templatelayout.Data')->set($default, $view, $found, $templates, $layouts); - } - - /** - * Get Data With Alias - * - * @param string $n_ame The alias name - * @param string $table The table where to find the alias - * @param string $view The view code name - * - * @return array The data found with the alias - * @deprecated 3.3 Use CFactory::_('Alias.Data')->get($n_ame, $table, $view); - */ - protected function getDataWithAlias($n_ame, $table, $view) - { - return CFactory::_('Alias.Data')->get($n_ame, $table, $view); - } - - /** - * set Data With Alias Keys - * - * @param string $table The table where to find the alias - * - * @return void - * @deprecated 3.3 - */ - protected function setDataWithAliasKeys($table) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - /** - * Get Media Library Data and store globally - * - * @param string $id the library id - * - * @return bool true on success - * @deprecated 3.3 Use CFactory::_('Library.Data')->get($id); - */ - protected function getMediaLibrary($id) - { - return CFactory::_('Library.Data')->get($id); - } - - /** - * Set Language Place Holders - * - * @param string $content The content - * - * @return string The content with the updated Language place holder - * @deprecated 3.3 Use CFactory::_('Language.Extractor')->engine($content) - */ - public function setLangStrings($content) - { - return CFactory::_('Language.Extractor')->engine($content); - } - - /** - * Set the language String - * - * @param string $string The plan text string (English) - * - * @return string The key language string (all uppercase) - * @deprecated 3.3 Use CFactory::_('Language')->key($string); - */ - public function setLang($string) - { - return CFactory::_('Language')->key($string); - } - - /** - * Set Data Selection of the dynamic get - * - * @param string $method_key The method unique key - * @param string $view_code The code name of the view - * @param string $string The data string - * @param string $asset The asset in question - * @param string $as The as string - * @param int $row_type The row type - * @param string $type The target type (db||view) - * - * @return array the select query - * @deprecated 3.3 Use CFactory::_('Dynamicget.Selection')->get($method_key, $view_code, $string, $asset, $as, $type, $row_type); - */ - public function setDataSelection($method_key, $view_code, $string, $asset, - $as, $row_type, $type - ) - { - return CFactory::_('Dynamicget.Selection')->get( - $method_key, $view_code, $string, $asset, - $as, $type, $row_type); - } - - /** - * Get the View Table Name - * - * @param int $id The admin view in - * - * @return string view code name - * @deprecated 3.3 - */ - public function getViewTableName($id) - { - // Create a new query object. - $query = $this->db->getQuery(true); - $query->select($this->db->quoteName(array('a.name_single'))); - $query->from( - $this->db->quoteName('#__componentbuilder_admin_view', 'a') - ); - $query->where($this->db->quoteName('a.id') . ' = ' . (int) $id); - $this->db->setQuery($query); - - return StringHelper::safe($this->db->loadResult()); - } - - /** - * Build the SQL dump String for a view - * - * @param string $tables The tables to use in build - * @param string $view The target view/table to dump in - * @param int $view_id The id of the target view - * - * @return string on success with the Dump SQL - * @deprecated 3.3 Use CFactory::_('Model.Sqldump')->key($tables, $view, $view_id); - */ - public function buildSqlDump($tables, $view, $view_id) - { - return CFactory::_('Model.Sqldump')->key($tables, $view, $view_id); - } - - /** - * Escape the values for a SQL dump - * - * @param string $value the value to escape - * - * @return string on success with escaped string - * @deprecated 3.3 - */ - public function mysql_escape($value) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - /** - * Creating an uniqueCode - * - * @param string $code The planed code - * - * @return string The unique code - * @deprecated 3.3 use Unique::code($code); - */ - public function uniqueCode($code) - { - return Unique::code($code); - } - - /** - * Creating an unique local key - * - * @param int $size The key size - * - * @return string The unique localkey - * @deprecated 3.3 use Unique::get($size); - */ - public function uniquekey($size, $random = false, - $newBag = "vvvvvvvvvvvvvvvvvvv" - ) - { - return Unique::get($size); - } - - /** - * Check for footable scripts - * - * @param string $content The content to check - * - * @return boolean True if found - * @deprecated 3.3 - */ - public function getFootableScripts($content) - { - if (strpos($content, 'footable') !== false) - { - return true; - } - - return false; - } - - /** - * Check for getModules script - * - * @param string $content The content to check - * - * @return boolean True if found - * @deprecated 3.3 - */ - public function getGetModule($content) - { - if (strpos($content, 'this->getModules(') !== false) - { - return true; - } - - return false; - } - - /** - * Check for get Google Chart script - * - * @param string $content The content to check - * - * @return boolean True if found - * @deprecated 3.3 - */ - public function getGoogleChart($content) - { - if (strpos($content, 'Chartbuilder(') !== false) - { - return true; - } - - return false; - } - - /** - * Set the dynamic values in strings here - * - * @param string $string The content to check - * @param int $debug The switch to debug the update - * We can now at any time debug the - * dynamic build values if it gets broken - * - * @return string - * @deprecated 3.3 Use CFactory::_('Customcode')->update($string, $debug); - */ - public function setDynamicValues($string, $debug = 0) - { - return CFactory::_('Customcode')->update($string, $debug); - } - - /** - * Set the external code string & load it in to string - * - * @param string $string The content to check - * @param int $debug The switch to debug the update - * - * @return string - * @deprecated 3.3 Use CFactory::_('Customcode.External')->set($string, $debug); - */ - public function setExternalCodeString($string, $debug = 0) - { - return CFactory::_('Customcode.External')->set($string, $debug); - } - - /** - * Get the External Code/String - * - * @param string $string The content to check - * @param array $bucket The Placeholders bucket - * - * @return void - * @deprecated 3.3 - */ - protected function getExternalCodeString($target, &$bucket) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - /** - * Cut the External Code/String - * - * @param string $string The content to cut - * @param string $sequence The cutting sequence - * @param string $key The content key - * - * @return string - * @deprecated 3.3 - */ - protected function cutExternalCodeString($string, $sequence, $key) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - - return ''; - } - - /** - * We start set the custom code data & can load it in to string - * - * @param string $string The content to check - * @param int $debug The switch to debug the update - * - * @return string - * @deprecated 3.3 Use CFactory::_('Customcode')->set($string, $debug, $not); - */ - public function setCustomCodeData($string, $debug = 0, $not = null) - { - return CFactory::_('Customcode')->set($string, $debug, $not); - } - - /** - * Insert the custom code into the string - * - * @param string $string The content to check - * @param int $debug The switch to debug the update - * - * @return string on success - * @deprecated 3.3 - */ - protected function insertCustomCode($ids, $string, $debug = 0) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - - return ''; - } - - /** - * Insert the custom code into the string - * - * @param string $string The content to check - * @param int $debug The switch to debug the update - * - * @return string on success - * @deprecated 3.3 - */ - protected function buildCustomCodePlaceholders($item, &$code, $debug = 0) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - - return ''; - } - - /** - * Set a type of placeholder with set of values - * - * @param string $key The main string for placeholder key - * @param array $values The values to add - * - * @return void - * @deprecated 3.3 Use CFactory::_('Placeholder')->setType($key, $values); - */ - public function setThesePlaceHolders($key, $values) - { - // use the new container class - CFactory::_('Placeholder')->setType($key, $values); - } - - /** - * Remove a type of placeholder by main string - * - * @param string $like The main string for placeholder key - * - * @return void - * @deprecated 3.3 Use CFactory::_('Placeholder')->clearType($key); - */ - public function clearFromPlaceHolders($like) - { - // use the new container class - CFactory::_('Placeholder')->clearType($like); - } - - /** - * to unset stuff that are private or protected - * - */ - public function unsetNow($remove) - { - unset($this->$remove); - } - - /** - * Get the other languages - * - * @param array $values The lang strings to get - * - * - * @return void - * - */ - public function getMultiLangStrings($values) - { - // Create a new query object. - $query = $this->db->getQuery(true); - $query->from( - $this->db->quoteName( - '#__componentbuilder_language_translation', 'a' - ) - ); - if (ArrayHelper::check($values)) - { - $query->select( - $this->db->quoteName( - array('a.id', 'a.translation', 'a.source', 'a.components', - 'a.modules', 'a.plugins', 'a.published') - ) - ); - $query->where( - $this->db->quoteName('a.source') . ' IN (' . implode( - ',', array_map( - fn($a) => $this->db->quote($a), $values - ) - ) . ')' - ); - $this->db->setQuery($query); - $this->db->execute(); - if ($this->db->getNumRows()) - { - return $this->db->loadAssocList('source'); - } - } - - return false; - } - - /** - * Set the Current language values to DB - * - * - * @return void - * - */ - public function setLangPlaceholders($strings, int $target_id, - $target = 'components' - ) - { - $counterInsert = 0; - $counterUpdate = 0; - $today = JFactory::getDate()->toSql(); - foreach ( - $this->languages[$target][CFactory::_('Config')->get('lang_tag', 'en-GB')] as $area => $placeholders - ) - { - foreach ($placeholders as $placeholder => $string) - { - // to keep or remove - $remove = false; - // build the translations - if (StringHelper::check($string) - && isset($this->multiLangString[$string])) - { - // make sure we have converted the string to array - if (isset($this->multiLangString[$string]['translation']) - && JsonHelper::check( - $this->multiLangString[$string]['translation'] - )) - { - $this->multiLangString[$string]['translation'] - = json_decode( - (string) $this->multiLangString[$string]['translation'], true - ); - } - // if we have an array continue - if (isset($this->multiLangString[$string]['translation']) - && ArrayHelper::check( - $this->multiLangString[$string]['translation'] - )) - { - // great lets build the multi languages strings - foreach ( - $this->multiLangString[$string]['translation'] as - $translations - ) - { - if (isset($translations['language']) - && isset($translations['translation'])) - { - // build arrays - if (!isset($this->languages[$target][$translations['language']])) - { - $this->languages[$target][$translations['language']] - = array(); - } - if (!isset($this->languages[$target][$translations['language']][$area])) - { - $this->languages[$target][$translations['language']][$area] - = array(); - } - $this->languages[$target][$translations['language']][$area][$placeholder] - = $translations['translation']; - } - } - } - else - { - // remove this string not to be checked again - $remove = true; - } - } - // do the database management - if (StringHelper::check($string) - && ($key = array_search($string, $strings)) !== false) - { - if (isset($this->multiLangString[$string])) - { - // update the existing placeholder in db - $id = $this->multiLangString[$string]['id']; - if (JsonHelper::check( - $this->multiLangString[$string][$target] - )) - { - $targets = (array) json_decode( - (string) $this->multiLangString[$string][$target], true - ); - // check if we should add the target ID - if (in_array($target_id, $targets)) - { - // only skip the update if the string is published and has the target ID - if ($this->multiLangString[$string]['published'] - == 1) - { - continue; - } - } - else - { - $targets[] = $target_id; - } - } - else - { - $targets = array($target_id); - } - // start the bucket for this lang - $this->setUpdateExistingLangStrings( - $id, $target, $targets, 1, $today, $counterUpdate - ); - - $counterUpdate++; - - // load to db - $this->setExistingLangStrings(50); - // remove string if needed - if ($remove) - { - unset($this->multiLangString[$string]); - } - } - else - { - // add the new lang placeholder to the db - if (!isset($this->newLangStrings[$target])) - { - $this->newLangStrings[$target] = array(); - } - $this->newLangStrings[$target][$counterInsert] - = array(); - $this->newLangStrings[$target][$counterInsert][] - = $this->db->quote( - json_encode(array($target_id)) - ); // 'target' - $this->newLangStrings[$target][$counterInsert][] - = $this->db->quote( - $string - ); // 'source' - $this->newLangStrings[$target][$counterInsert][] - = $this->db->quote( - 1 - ); // 'published' - $this->newLangStrings[$target][$counterInsert][] - = $this->db->quote( - $today - ); // 'created' - $this->newLangStrings[$target][$counterInsert][] - = $this->db->quote( - (int) $this->user->id - ); // 'created_by' - $this->newLangStrings[$target][$counterInsert][] - = $this->db->quote( - 1 - ); // 'version' - $this->newLangStrings[$target][$counterInsert][] - = $this->db->quote( - 1 - ); // 'access' - - $counterInsert++; - - // load to db - $this->setNewLangStrings($target, 100); - } - // only set the string once - unset($strings[$key]); - } - } - } - // just to make sure all is done - $this->setExistingLangStrings(); - $this->setNewLangStrings($target); - } - - /** - * store the language placeholders - * - * @param string $target The target extention type - * @param int $when To set when to update - * - * @return void - * - */ - protected function setNewLangStrings($target, $when = 1) - { - if (isset($this->newLangStrings[$target]) - && count( - (array) $this->newLangStrings[$target] - ) >= $when) - { - // Create a new query object. - $query = $this->db->getQuery(true); - $continue = false; - // Insert columns. - $columns = array($target, 'source', 'published', 'created', - 'created_by', 'version', 'access'); - // Prepare the insert query. - $query->insert( - $this->db->quoteName('#__componentbuilder_language_translation') - ); - $query->columns($this->db->quoteName($columns)); - foreach ($this->newLangStrings[$target] as $values) - { - if (count((array) $values) == 7) - { - $query->values(implode(',', $values)); - $continue = true; - } - else - { - // TODO line mismatch... should not happen - } - } - // clear the values array - $this->newLangStrings[$target] = array(); - if (!$continue) - { - return false; // insure we dont continue if no values were loaded - } - // Set the query using our newly populated query object and execute it. - $this->db->setQuery($query); - $this->db->execute(); - } - } - - /** - * update the language placeholders - * - * @param int $when To set when to update - * - * @return void - * - */ - protected function setExistingLangStrings($when = 1) - { - if (count((array) $this->existingLangStrings) >= $when) - { - foreach ($this->existingLangStrings as $values) - { - // Create a new query object. - $query = $this->db->getQuery(true); - // Prepare the update query. - $query->update( - $this->db->quoteName( - '#__componentbuilder_language_translation' - ) - )->set($values['fields'])->where($values['conditions']); - // Set the query using our newly populated query object and execute it. - $this->db->setQuery($query); - $this->db->execute(); - } - // clear the values array - $this->existingLangStrings = array(); - } - } - - /** - * Remove exiting language translation stings - * - * @param int $id To string ID to remove - * - * @return void - * - */ - protected function removeExitingLangString($id) - { - // Create a new query object. - $query = $this->db->getQuery(true); - - // delete all custom keys for user 1001. - $conditions = array( - $this->db->quoteName('id') . ' = ' . (int) $id - ); - - $query->delete( - $this->db->quoteName('#__componentbuilder_language_translation') - ); - $query->where($conditions); - - $this->db->setQuery($query); - $this->db->execute(); - } - - /** - * Function to purge the unused languge strings - * - * @param string $values the active strings - * - * @return void - * - */ - public function purgeLanuageStrings($values, $target_id, - $target = 'components' - ) - { - // the target types are - $target_types = array('components' => 'components', - 'modules' => 'modules', - 'plugins' => 'plugins'); - // make sure we only work with preset targets - if (isset($target_types[$target])) - { - // remove the current target - unset($target_types[$target]); - // Create a new query object. - $query = $this->db->getQuery(true); - $query->from( - $this->db->quoteName( - '#__componentbuilder_language_translation', 'a' - ) - ); - $query->select( - $this->db->quoteName( - array('a.id', 'a.translation', 'a.components', 'a.modules', - 'a.plugins') - ) - ); - // get all string that are not linked to this component - $query->where( - $this->db->quoteName('a.source') . ' NOT IN (' . implode( - ',', array_map( - fn($a) => $this->db->quote($a), $values - ) - ) . ')' - ); - $query->where($this->db->quoteName('a.published') . ' = 1'); - $this->db->setQuery($query); - $this->db->execute(); - if ($this->db->getNumRows()) - { - $counterUpdate = 0; - $otherStrings = $this->db->loadAssocList(); - $today = JFactory::getDate()->toSql(); - foreach ($otherStrings as $item) - { - if (JsonHelper::check($item[$target])) - { - $targets = (array) json_decode((string) $item[$target], true); - // if component is not found ignore this string, and do nothing - if (($key = array_search($target_id, $targets)) - !== false) - { - // first remove the component from the string - unset($targets[$key]); - // check if there are more components - if (ArrayHelper::check($targets)) - { - // just update the string to unlink the current component - $this->setUpdateExistingLangStrings( - $item['id'], $target, $targets, 1, $today, - $counterUpdate - ); - - $counterUpdate++; - - // load to db - $this->setExistingLangStrings(50); - } - // check if this string has been worked on or is linked to other extensions - else - { - // the action (1 = remove, 2 = archive, 0 = do nothing) - $action_with_string = 1; - // now check if it is linked to other extensions - foreach ($target_types as $other_target) - { - // just one linked extension type is enough to stop the search - if ($action_with_string - && JsonHelper::check( - $item[$other_target] - )) - { - $other_targets = (array) json_decode( - (string) $item[$other_target], true - ); - // check if linked to other extensions - if (ArrayHelper::check( - $other_targets - )) - { - $action_with_string - = 0; // do nothing - } - } - } - // check we should just archive or remove string - if ($action_with_string - && JsonHelper::check( - $item['translation'] - )) - { - $translation = json_decode( - (string) $item['translation'], true - ); - if (ArrayHelper::check( - $translation - )) - { - // only archive the item and update the string to unlink the current component - $this->setUpdateExistingLangStrings( - $item['id'], $target, $targets, 2, - $today, $counterUpdate - ); - - $counterUpdate++; - - // load to db - $this->setExistingLangStrings(50); - - $action_with_string - = 2; // we archived it - } - } - // remove the string since no translation found and not linked to any other extensions - if ($action_with_string == 1) - { - $this->removeExitingLangString($item['id']); - } - } - } - } - } - // load to db - $this->setExistingLangStrings(); - } - } - } - - /** - * just to add lang string to the existing Lang Strings array - * - * @return void - * - */ - protected function setUpdateExistingLangStrings($id, $target, $targets, - $published, $today, $counterUpdate - ) - { - // start the bucket for this lang - $this->existingLangStrings[$counterUpdate] = array(); - $this->existingLangStrings[$counterUpdate]['id'] = (int) $id; - $this->existingLangStrings[$counterUpdate]['conditions'] = array(); - $this->existingLangStrings[$counterUpdate]['conditions'][] - = $this->db->quoteName( - 'id' - ) . ' = ' . $this->db->quote($id); - $this->existingLangStrings[$counterUpdate]['fields'] = array(); - $this->existingLangStrings[$counterUpdate]['fields'][] - = $this->db->quoteName( - $target - ) . ' = ' . $this->db->quote(json_encode($targets)); - $this->existingLangStrings[$counterUpdate]['fields'][] - = $this->db->quoteName( - 'published' - ) . ' = ' . $this->db->quote($published); - $this->existingLangStrings[$counterUpdate]['fields'][] - = $this->db->quoteName( - 'modified' - ) . ' = ' . $this->db->quote($today); - $this->existingLangStrings[$counterUpdate]['fields'][] - = $this->db->quoteName( - 'modified_by' - ) . ' = ' . $this->db->quote((int) $this->user->id); - } - - /** - * get the custom code from the system - * - * @param array|null $ids The custom code ides if known - * @param int|null $setLang The set lang switch - * @param int $debug The switch to debug the update - * - * @return void - * @deprecated 3.3 Use CFactory::_('Customcode')->get($ids, $setLang, $debug); - */ - public function getCustomCode(?array $ids = null, bool $setLang = true, int $debug = 0) - { - CFactory::_('Customcode')->get($ids, $setLang, $debug); - } - - /** - * check if we already have these ids in local memory - * - * @return void - * @deprecated 3.3 - */ - protected function checkCustomCodeMemory($ids) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - /** - * get all the powers linkd to this component - * - * @return void - * @deprecated 3.3 Use CFactory::_('Power')->load($guids); - */ - protected function getPowers($guids) - { - CFactory::_('Power')->load($guids); - } - - /** - * get a power linkd to this component - * - * @return mixed - * @deprecated 3.3 Use CFactory::_('Power')->get($guid, $build); - */ - public function getPower($guid, $build = 0) - { - CFactory::_('Power')->get($guid, $build); - } - - /** - * set a power linkd to this component - * - * @return bool - * @deprecated 3.3 - */ - protected function setPower($guid) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - - return false; - } - - /** - * get the Joomla module path - * - * @return string of module path and target site area on success - * @deprecated 3.3 - */ - protected function getModulePath($id) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - - return ''; - } - - /** - * get the Joomla Modules IDs - * - * @return array of IDs on success - * @deprecated 3.3 - */ - protected function getModuleIDs() - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - - return []; - } - - /** - * set the Joomla modules - * - * @return true - * @deprecated 3.3 Use CFactory::_('Joomlamodule.Data')->set($id); - */ - public function setJoomlaModule($id, &$component) - { - return CFactory::_('Joomlamodule.Data')->set($id); - } - - /** - * get the module xml template - * - * @return string - * @deprecated 3.3 - */ - public function getModuleXMLTemplate(&$module) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - /** - * get the module admin custom script field - * - * @return string - * @deprecated 3.3 - */ - public function getModAdminVvvvvvvdm($fieldScriptBucket) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - /** - * get the Joomla plugins IDs - * - * @return array of IDs on success - * @deprecated 3.3 - */ - protected function getPluginIDs() - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - - return []; - } - - /** - * get the Joomla plugin path - * - * @return string of plugin path on success - * @deprecated 3.3 - */ - protected function getPluginPath($id) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - - return ''; - } - - /** - * set the Joomla plugins - * - * @return true - * @deprecated 3.3 Use CFactory::_('Joomlamodule.Data')->set($id); - */ - public function setJoomlaPlugin($id, &$component) - { - return CFactory::_('Joomlaplugin.Data')->set($id); - } - - /** - * get the plugin xml template - * - * @return string - * @deprecated 3.3 - */ - public function getPluginXMLTemplate(&$plugin) - { - $xml = ''; - $xml .= PHP_EOL . ''; - $xml .= PHP_EOL . Indent::_(1) . '' . $plugin->lang_prefix - . ''; - $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('BUILDDATE') . ''; - $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHOR') . ''; - $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHOREMAIL') . ''; - $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHORWEBSITE') . ''; - $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('COPYRIGHT') . ''; - $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('LICENSE') . ''; - $xml .= PHP_EOL . Indent::_(1) . '' . $plugin->plugin_version - . ''; - $xml .= PHP_EOL . Indent::_(1) . '' . $plugin->lang_prefix - . '_XML_DESCRIPTION'; - $xml .= Placefix::_h('MAINXML'); - $xml .= PHP_EOL . ''; - - return $xml; - } - - /** - * store the code - * - * @param int $when To set when to update - * - * @return void - * @deprecated 3.3 - */ - protected function setNewCustomCode($when = 1) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - /** - * store the code - * - * @param int $when To set when to update - * - * @return void - * @deprecated 3.3 - */ - protected function setExistingCustomCode($when = 1) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - /** - * get the custom code from the local files - * - * @param array $paths The local paths to parse - * @param string $today The date for today - * - * @return void - * @deprecated 3.3 Use CFactory::_('Customcode.Extractor')->run(); - */ - protected function customCodeFactory(&$paths, &$today) - { - CFactory::_('Customcode.Extractor')->run(); - } - - /** - * search a file for placeholders and store result - * - * @param array $counter The counter for the arrays - * @param string $file The file path to search - * @param array $searchArray The values to search for - * @param array $placeholders The values to replace in the code being stored - * @param string $today The date for today - * - * @return array on success - * - * @deprecated 3.3 - */ - protected function searchFileContent(&$counter, &$file, &$target, - &$searchArray, &$placeholders, &$today - ) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - - return []; - } - - /** - * Set a hash of a file and/or string - * - * @param string $string The code string - * - * @return string - * @deprecated 3.3 Use CFactory::_('Customcode.Hash')->set($script); - */ - protected function setDynamicHASHING($script) - { - return CFactory::_('Customcode.Hash')->set($script); - } - - /** - * Lock a string with bsae64 (basic) - * - * @param string $string The code string - * - * @return string - * @deprecated 3.3 Use CFactory::_('Customcode.LockBase')->set($script); - */ - protected function setBase64LOCK($script) - { - return CFactory::_('Customcode.LockBase')->set($script); - } - - /** - * Set the JCB GUI code placeholder - * - * @param string $string The code string - * @param array $config The placeholder config values - * - * @return string - * @deprecated 3.3 Use CFactory::_('Customcode.Gui')->set($string, $config); - */ - public function setGuiCodePlaceholder($string, $config) - { - return CFactory::_('Customcode.Gui')->set($string, $config); - } - - /** - * search a code to see if there is already any custom - * code or other reasons not to add the GUI code placeholders - * - * @param string $code The code to check - * - * @return boolean true if GUI code placeholders can be added - * @deprecated 3.3 - */ - protected function canAddGuiCodePlaceholder(&$code) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - - return false; - } - - /** - * search a file for gui code blocks that were updated in the IDE - * - * @param string $file The file path to search - * @param array $placeholders The values to replace in the code being stored - * @param string $today The date for today - * @param string $target The target path type - * - * @return void - * @deprecated 3.3 Use CFactory::_('Customcode.Gui')->search($file, $placeholders, $today, $target); - */ - protected function guiCodeSearch(&$file, &$placeholders, &$today, &$target) - { - CFactory::_('Customcode.Gui')->search($file, $placeholders, $today, $target); - } - - /** - * Check if this line should be added - * - * @param string $replaceKey The key to remove from line - * @param int $type The line type - * @param string $lineContent The line to check - * - * @return bool true on success - * - * @deprecated 3.3 - */ - protected function addLineChecker($replaceKey, $type, $lineContent) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - - return false; - } - - /** - * set the start replace placeholder - * - * @param int $id The comment id - * @param int $commentType The comment type - * @param string $startReplace The main replace string - * - * @return array on success - * - * @deprecated 3.3 - */ - protected function setStartReplace($id, $commentType, $startReplace) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - - return []; - } - - /** - * search for the system id in the line given - * - * @param string $lineContent The file path to search - * @param string $placeholders The values to search for - * @param int $commentType The comment type - * - * @return int on success - * - * @deprecated 3.3 - */ - protected function getSystemID(&$lineContent, $placeholders, $commentType) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - - return null; - } - - /** - * Reverse Engineer the dynamic placeholders (TODO hmmmm this is not ideal) - * - * @param string $string The string to revers - * @param array $placeholders The values to search for - * @param string $target The target path type - * @param int $id The custom code id - * @param string $field The field name - * @param string $table The table name - * - * @return string - * @deprecated 3.3 Use CFactory::_('Placeholder.Reverse')->engine($string, $placeholders, $target, $id, $field, $table); - */ - protected function reversePlaceholders($string, &$placeholders, &$target, - $id = null, $field = 'code', $table = 'custom_code' - ) - { - // use the new container class - CFactory::_('Placeholder.Reverse')->engine($string, $placeholders, $target, $id, $field, $table); - } - - /** - * Set the langs strings for the reveres process - * - * @param string $updateString The string to update - * @param string $string The string to use lang update - * @param string $target The target path type - * - * @return string - * @deprecated 3.3 See $this->reversePlaceholders(); - */ - protected function setReverseLangPlaceholders($updateString, $string, - &$target - ) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - - return ''; - } - - /** - * Update the data with the placeholders - * - * @param string $data The actual data - * @param array $placeholder The placeholders - * @param int $action The action to use - * - * THE ACTION OPTIONS ARE - * 1 -> Just replace (default) - * 2 -> Check if data string has placeholders - * 3 -> Remove placeholders not in data string - * - * @return string - * @deprecated 3.3 Use CFactory::_('Placeholder')->update($data, $placeholder, $action); - */ - public function setPlaceholders($data, &$placeholder, $action = 1) - { - // use the new container class - CFactory::_('Placeholder')->update($data, $placeholder, $action); - } - - /** - * return the placeholders for inserted and replaced code - * - * @param int $type The type of placement - * @param int $id The code id in the system - * - * @return array on success - * @deprecated 3.3 Use CFactory::_('Placeholder')->keys($type, $id); - */ - public function getPlaceHolder($type, $id) - { - return CFactory::_('Placeholder')->keys($type, $id); - } - - /** - * get the local installed path of this component - * - * @return array of paths on success - * @deprecated 3.3 - */ - protected function getLocalInstallPaths() - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - - return []; - } - -} diff --git a/admin/helpers/compiler/b_Structure.php b/admin/helpers/compiler/b_Structure.php deleted file mode 100644 index c5f72982d..000000000 --- a/admin/helpers/compiler/b_Structure.php +++ /dev/null @@ -1,889 +0,0 @@ - - * @gitea Joomla Component Builder - * @github Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Filesystem\File; -use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\GetHelper; -use VDM\Joomla\Utilities\FileHelper; -use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory; - -/** - * Structure class - * @deprecated 3.3 - */ -class Structure extends Get -{ - - /** - * The folder counter - * - * @var int - * @deprecated 3.3 Use CFactory::_('Utilities.Counter')->folder; - */ - public $folderCount = 0; - - /** - * The file counter - * - * @var int - * @deprecated 3.3 Use CFactory::_('Utilities.Counter')->file; - */ - public $fileCount = 0; - - /** - * The page counter - * - * @var int - * @deprecated 3.3 - */ - public $pageCount = 0; - - /** - * The line counter - * - * @var int - * @deprecated 3.3 Use CFactory::_('Utilities.Counter')->line; - */ - public $lineCount = 0; - - /** - * The field counter - * - * @var int - * @deprecated 3.3 - */ - public $fieldCount = 0; - - /** - * The seconds counter - * - * @var int - * @deprecated 3.3 - */ - public $seconds = 0; - - /** - * The actual seconds counter - * - * @var int - * @deprecated 3.3 - */ - public $actualSeconds = 0; - - /** - * The folder seconds counter - * - * @var int - * @deprecated 3.3 - */ - public $folderSeconds = 0; - - /** - * The file seconds counter - * - * @var int - * @deprecated 3.3 - */ - public $fileSeconds = 0; - - /** - * The line seconds counter - * - * @var int - * @deprecated 3.3 - */ - public $lineSeconds = 0; - - /** - * The seconds debugging counter - * - * @var int - * @deprecated 3.3 - */ - public $secondsDebugging = 0; - - /** - * The seconds planning counter - * - * @var int - * @deprecated 3.3 - */ - public $secondsPlanning = 0; - - /** - * The seconds mapping counter - * - * @var int - * @deprecated 3.3 - */ - public $secondsMapping = 0; - - /** - * The seconds office counter - * - * @var int - * @deprecated 3.3 - */ - public $secondsOffice = 0; - - /** - * The total hours counter - * - * @var int - * @deprecated 3.3 - */ - public $totalHours = 0; - - /** - * The debugging hours counter - * - * @var int - * @deprecated 3.3 - */ - public $debuggingHours = 0; - - /** - * The planning hours counter - * - * @var int - * @deprecated 3.3 - */ - public $planningHours = 0; - - /** - * The mapping hours counter - * - * @var int - * @deprecated 3.3 - */ - public $mappingHours = 0; - - /** - * The office hours counter - * - * @var int - * @deprecated 3.3 - */ - public $officeHours = 0; - - /** - * The actual Total Hours counter - * - * @var int - * @deprecated 3.3 - */ - public $actualTotalHours = 0; - - /** - * The actual hours spent counter - * - * @var int - * @deprecated 3.3 - */ - public $actualHoursSpent = 0; - - /** - * The actual days spent counter - * - * @var int - * @deprecated 3.3 - */ - public $actualDaysSpent = 0; - - /** - * The total days counter - * - * @var int - * @deprecated 3.3 - */ - public $totalDays = 0; - - /** - * The actual Total Days counter - * - * @var int - * @deprecated 3.3 - */ - public $actualTotalDays = 0; - - /** - * The project week time counter - * - * @var int - * @deprecated 3.3 - */ - public $projectWeekTime = 0; - - /** - * The project month time counter - * - * @var int - * @deprecated 3.3 - */ - public $projectMonthTime = 0; - - /** - * The template path - * - * @var string - * @deprecated 3.3 Use CFactory::_('Utilities.Paths')->template_path; - */ - public $templatePath; - - /** - * The custom template path - * - * @var string - * @deprecated 3.3 Use CFactory::_('Utilities.Paths')->template_path_custom; - */ - public $templatePathCustom; - - /** - * The Joomla Version Data - * - * @var object - * @deprecated 3.3 Use CFactory::_('Component.Settings') - */ - public $joomlaVersionData; - - /** - * Static File Content - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Content.One')->allActive() - */ - public $fileContentStatic = array(); - - /** - * Extention Custom Fields - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Extension.Custom.Fields')->get($key) - */ - public $extentionCustomfields = array(); - - /** - * Extention Tracking Files Moved - * - * @var array - */ - public $extentionTrackingFilesMoved = array(); - - /** - * The standard folders - * - * @var array - * @deprecated 3.3 - */ - public $stdFolders = array('site', 'admin', 'media'); - - /** - * The standard root files - * - * @var array - * @deprecated 3.3 - */ - public $stdRootFiles - = array('access.xml', 'config.xml', 'controller.php', 'index.html', 'README.txt'); - - /** - * Dynamic File Content - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Content.Multi')->allActive() - */ - public $fileContentDynamic = array(); - - /** - * The Component Sales name - * - * @var string - * @deprecated 3.3 Use CFactory::_('Utilities.Paths')->component_sales_name; - */ - public $componentSalesName; - - /** - * The Component Backup name - * - * @var string - * @deprecated 3.3 Use CFactory::_('Utilities.Paths')->component_backup_name; - */ - public $componentBackupName; - - /** - * The Component Folder name - * - * @var string - * @deprecated 3.3 Use CFactory::_('Utilities.Paths')->component_folder_name; - */ - public $componentFolderName; - - /** - * The Component path - * - * @var string - * @deprecated 3.3 Use CFactory::_('Utilities.Paths')->component_path; - */ - public $componentPath; - - /** - * The Dynamic paths - * - * @var array - * @deprecated 3.3 Use CFactory::_('Registry')->get('dynamic_paths'); - */ - public $dynamicPaths = array(); - - /** - * The not new static items - * - * @var array - * @deprecated 3.3 Use CFactory::_('Registry')->get('files.not.new', []); - */ - public $notNew = array(); - - /** - * Update the file content - * - * @var array - * @deprecated 3.3 Use CFactory::_('Registry')->get('update.file.content'); - */ - public $updateFileContent = array(); - - /** - * The new files - * - * @var array - * @deprecated 3.3 Use CFactory::_('Utilities.Files'); - */ - public $newFiles = array(); - - /** - * The Checkin Switch - * - * @var boolean - */ - public $addCheckin = false; - - /** - * The Move Folders Switch - * - * @var boolean - */ - public $setMoveFolders = false; - - /** - * The array of last modified dates - * - * @var array - * @deprecated 3.3 - */ - protected $lastModifiedDate = array(); - - /** - * The default view switch - * - * @var bool/string - * @deprecated 3.3 Use CFactory::_('Registry')->get('build.dashboard'); - */ - public $dynamicDashboard = false; - - /** - * The default view type - * - * @var string - * @deprecated 3.3 Use CFactory::_('Registry')->get('build.dashboard.type'); - */ - public $dynamicDashboardType; - - /** - * Constructor - */ - public function __construct() - { - // first we run the parent constructor - if (parent::__construct()) - { - // set incase no extra admin folder are loaded - CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_ADMIN_FOLDERS', ''); - // set incase no extra site folder are loaded - CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_SITE_FOLDERS', ''); - // set incase no extra media folder are loaded - CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_MEDIA_FOLDERS', ''); - // set incase no extra admin files are loaded - CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_ADMIN_FILES', ''); - // set incase no extra site files are loaded - CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_SITE_FILES', ''); - // set incase no extra media files are loaded - CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_MEDIA_FILES', ''); - // make sure there is no old build - CFactory::_('Utilities.Folder')->remove(CFactory::_('Utilities.Paths')->component_path); - // load the libraries files/folders and url's - CFactory::_('Library.Structure')->build(); - // load the powers files/folders - CFactory::_('Power.Structure')->build(); - // load the module files/folders and url's - CFactory::_('Joomlamodule.Structure')->build(); - // load the plugin files/folders and url's - CFactory::_('Joomlaplugin.Structure')->build(); - // set the dashboard - CFactory::_('Component.Dashboard')->set(); - // set the component base structure - if (!CFactory::_('Component.Structure')->build()) - { - return false; - } - - // set all single instance folders and files - if (!CFactory::_('Component.Structure.Single')->build()) - { - return false; - } - - // set all the dynamic folders and files - if (!CFactory::_('Component.Structure.Multiple')->build()) - { - return false; - } - - return true; - } - - return false; - } - - /** - * Build the Powers files, folders - * - * @return void - * @deprecated 3.3 Use CFactory::_('Power.Structure')->build(); - */ - private function buildPowers() - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - /** - * Build the Modules files, folders, url's and config - * - * @return void - * @deprecated 3.3 Use CFactory::_('Joomlamodule.Structure')->build(); - */ - private function buildModules() - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - /** - * Build the Plugins files, folders, url's and config - * - * @return void - * @deprecated 3.3 Use CFactory::_('Joomlaplugin.Structure')->build(); - */ - private function buildPlugins() - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - /** - * Create Path if not exist - * - * @return void - * @deprecated 3.3 Use CFactory::_('Utilities.Folder')->create($path); - */ - private function createFolder($path) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - /** - * Build the Libraries files, folders, url's and config - * - * @return void - * @deprecated 3.3 Use CFactory::_('Library.Structure')->build(); - */ - private function setLibraries() - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - /** - * set the dynamic dashboard if set - * - * @return void - * @deprecated 3.3 Use CFactory::_('Component.Dashboard')->set(); - */ - private function setDynamicDashboard() - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - /** - * Write data to file - * - * @return bool true on success - * @deprecated 3.3 - */ - public function writeFile($path, $data) - { - return FileHelper::write($path, $data); - } - - /** - * Build the Initial Folders - * - * @return void - * @deprecated 3.3 Use CFactory::_('Component.Structure')->build(); - */ - private function setFolders() - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - /** - * Set the Static File & Folder - * - * @return boolean - * @deprecated 3.3 Use CFactory::_('Component.Structure.Single')->build(); - */ - private function setStatic() - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - /** - * Set the Dynamic File & Folder - * - * @return boolean - * @deprecated 3.3 Use CFactory::_('Component.Structure.Multiple')->build(); - */ - private function setDynamique() - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - - return false; - } - - /** - * move the fields and Rules - * - * @param array $field The field data - * @param string $path The path to move to - * - * @return void - * - */ - public function moveFieldsRules($field, $path) - { - // check if we have a subform or repeatable field - if ($field['type_name'] === 'subform' - || $field['type_name'] === 'repeatable') - { - // since we could have a custom field or rule inside - $this->moveMultiFieldsRules($field, $path); - } - else - { - // check if this is a custom field that should be moved - if (CFactory::_('Compiler.Builder.Extension.Custom.Fields')->exists($field['type_name'])) - { - $check = md5($path . 'type' . $field['type_name']); - // lets check if we already moved this - if (!isset($this->extentionTrackingFilesMoved[$check])) - { - // check files exist - if (File::exists( - CFactory::_('Utilities.Paths')->component_path . '/admin/models/fields/' - . $field['type_name'] . '.php' - )) - { - // copy the custom field - File::copy( - CFactory::_('Utilities.Paths')->component_path . '/admin/models/fields/' - . $field['type_name'] . '.php', - $path . '/fields/' . $field['type_name'] . '.php' - ); - } - // stop from doing this again. - $this->extentionTrackingFilesMoved[$check] = true; - } - } - // check if this has validation that should be moved - if (CFactory::_('Registry')->get('validation.linked.' . $field['field']) !== null) - { - $check = md5( - $path . 'rule' - . CFactory::_('Registry')->get('validation.linked.' . $field['field']) - ); - // lets check if we already moved this - if (!isset($this->extentionTrackingFilesMoved[$check])) - { - // check files exist - if (File::exists( - CFactory::_('Utilities.Paths')->component_path . '/admin/models/rules/' - . CFactory::_('Registry')->get('validation.linked.' . $field['field']) - . '.php' - )) - { - // copy the custom field - File::copy( - CFactory::_('Utilities.Paths')->component_path . '/admin/models/rules/' - . CFactory::_('Registry')->get('validation.linked.' . $field['field']) - . '.php', $path . '/rules/' - . CFactory::_('Registry')->get('validation.linked.' . $field['field']) - . '.php' - ); - } - // stop from doing this again. - $this->extentionTrackingFilesMoved[$check] = true; - } - } - } - } - - /** - * move the fields and Rules of multi fields - * - * @param array $multi_field The field data - * @param string $path The path to move to - * - * @return void - * - */ - protected function moveMultiFieldsRules($multi_field, $path) - { - // get the fields ids - $ids = array_map( - 'trim', - explode( - ',', - (string) GetHelper::between( - $multi_field['settings']->xml, 'fields="', '"' - ) - ) - ); - if (ArrayHelper::check($ids)) - { - foreach ($ids as $id) - { - // setup the field - $field = array(); - $field['field'] = $id; - CFactory::_('Field')->set($field); - // move field and rules if needed - $this->moveFieldsRules($field, $path); - } - } - } - - /** - * get the created date of the (view) - * - * @param array $view The view values - * - * @return string Last Modified Date - * @deprecated 3.3 Use CFactory::_('Model.Createdate')->get($view); - */ - public function getCreatedDate($view) - { - return CFactory::_('Model.Createdate')->get($view); - } - - /** - * get the last modified date of a MVC (view) - * - * @param array $view The view values - * - * @return string Last Modified Date - * @deprecated 3.3 Use CFactory::_('Model.Modifieddate')->get($view); - */ - public function getLastModifiedDate($view) - { - return CFactory::_('Model.Modifieddate')->get($view); - } - - /** - * Set the Static File & Folder - * - * @param array $target The main target and name - * @param string $type The type in the target - * @param string $fileName The custom file name - * @param array $cofig to add more data to the files info - * - * @return boolean - * @deprecated 3.3 Use CFactory::_('Utilities.Structure')->build($target, $type, $fileName, $config); - */ - public function buildDynamique($target, $type, $fileName = null, $config = null) - { - return CFactory::_('Utilities.Structure')->build($target, $type, $fileName, $config); - } - - /** - * set the Joomla Version Data - * - * @return object The version data - * @deprecated 3.3 - */ - private function setJoomlaVersionData() - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - } - - /** - * Add the dynamic folders - */ - protected function setDynamicFolders() - { - // check if we should add the dynamic folder moving script to the installer script - if (!CFactory::_('Registry')->get('set_move_folders_install_script')) - { - // add the setDynamicF0ld3rs() method to the install scipt.php file - CFactory::_('Registry')->set('set_move_folders_install_script', true); - // set message that this was done (will still add a tutorial link later) - $this->app->enqueueMessage( - JText::_( - '

Dynamic folder(s) were detected.

' - ), 'Notice' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'A method (setDynamicF0ld3rs) was added to the install script.php of this package to insure that the folder(s) are copied into the correct place when this component is installed!' - ), 'Notice' - ); - } - } - - /** - * set the index.html file in a folder path - * - * @param string $path The path to place the index.html file in - * - * @return void - * @deprecated 3.3 Use CFactory::_('Utilities.File')->write($path, $root); - * - */ - private function indexHTML($path, $root = 'component') - { - CFactory::_('Utilities.File')->write($path, $root); - } - - /** - * Update paths with real value - * - * @param string $path The full path - * - * @return string The updated path - * @deprecated 3.3 Use CFactory::_('Utilities.Dynamicpath')->update($path); - */ - protected function updateDynamicPath($path) - { - return CFactory::_('Utilities.Dynamicpath')->update($path); - } - - /** - * Remove folders with files - * - * @param string $dir The path to folder to remove - * @param boolean $ignore The files and folders to ignore - * - * @return boolean True if all is removed - * @deprecated 3.3 Use CFactory::_('Utilities.Folder')->remove($dir, $ignore); - */ - protected function removeFolder($dir, $ignore = false) - { - return CFactory::_('Utilities.Folder')->remove($dir, $ignore); - } - -} diff --git a/admin/helpers/compiler/c_Fields.php b/admin/helpers/compiler/c_Fields.php deleted file mode 100644 index efa8acd1c..000000000 --- a/admin/helpers/compiler/c_Fields.php +++ /dev/null @@ -1,1242 +0,0 @@ - - * @gitea Joomla Component Builder - * @github Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use VDM\Joomla\Utilities\StringHelper; -use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; - -/** - * Compiler class - * @deprecated 3.3 - */ -class Fields extends Structure -{ - - /** - * Metadate Switch - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Meta.Data')->get($key); - */ - public $metadataBuilder = array(); - - /** - * View access Switch - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Access.Switch')->get($key); - */ - public $accessBuilder = array(); - - /** - * edit view tabs counter - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Tab.Counter')->get($key); - */ - public $tabCounter = array(); - - /** - * layout builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Layout')->get($key); - */ - public $layoutBuilder = array(); - - /** - * permissions builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Has.Permissions')->get($key); - */ - public $hasPermissions = array(); - - /** - * used to fix the zero order - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Order.Zero')->get($key); - */ - private $zeroOrderFix = array(); - - /** - * Site field data - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Site.Field.Data')->get($key); - */ - public $siteFieldData = array(); - - /** - * list of fields that are not being escaped - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Do.Not.Escape')->get($key); - */ - public $doNotEscape = array(); - - /** - * list of classes used in the list view for the fields - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.List.Field.Class')->set($key, true); - */ - public $listFieldClass = array(); - - /** - * tags builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Tags')->get($key); - */ - public $tagsBuilder = array(); - - /** - * query builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Database.Tables')->get($key); - */ - public $queryBuilder = array(); - - /** - * unique keys for database field - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Database.Unique.Keys')->get($key); - */ - public $dbUniqueKeys = array(); - - /** - * unique guid swtich - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Database.Unique.Guid')->get($key); - */ - public $dbUniqueGuid = array(); - - /** - * keys for database field - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Database.Keys')->get($key); - */ - public $dbKeys = array(); - - /** - * history builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.History')->get($key); - */ - public $historyBuilder = array(); - - /** - * alias builder - * - * @var array - * @deprecated 3.3 CFactory::_('Compiler.Builder.Alias')->get($key); - */ - public $aliasBuilder = array(); - - /** - * title builder - * - * @var array - * @deprecated 3.3 CFactory::_('Compiler.Builder.Title')->get($key); - */ - public $titleBuilder = array(); - - /** - * list builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Lists')->get($key); - */ - public $listBuilder = array(); - - /** - * custom Builder List - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Custom.List')->get($key); - */ - public $customBuilderList = array(); - - /** - * Hidden Fields Builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Hidden.Fields')->get($key); - */ - public $hiddenFieldsBuilder = array(); - - /** - * INT Field Builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Integer.Fields')->get($key); - */ - public $intFieldsBuilder = array(); - - /** - * Dynamic Fields Builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Dynamic.Fields')->get($key); - */ - public $dynamicfieldsBuilder = array(); - - /** - * Main text Builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Main.Text.Field')->get($key); - */ - public $maintextBuilder = array(); - - /** - * Custom Builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Custom.Field')->get($key); - */ - public $customBuilder = array(); - - /** - * Custom Field Links Builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Custom.Field.Links')->get($key); - */ - public $customFieldLinksBuilder = array(); - - /** - * Set Script for User Switch - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Script.User.Switch')->get($key); - */ - public $setScriptUserSwitch = array(); - - /** - * Set Script for Media Switch - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Script.Media.Switch')->get($key); - */ - public $setScriptMediaSwitch = array(); - - /** - * Category builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Category')->get($key); - */ - public $categoryBuilder = array(); - - /** - * Category Code builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Category.Code')->get($key); - */ - public $catCodeBuilder = array(); - - /** - * Check Box builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Check.Box')->get($key); - */ - public $checkboxBuilder = array(); - - /** - * Json String Builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Json.String')->get($key); - */ - public $jsonStringBuilder = array(); - - /** - * Json String Builder for return values to array - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Json.Item.Array')->get($key); - */ - public $jsonItemBuilderArray = array(); - - /** - * Json Item Builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Json.Item')->get($key); - */ - public $jsonItemBuilder = array(); - - /** - * Base 64 Builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Base.Six.Four')->get($key); - */ - public $base64Builder = array(); - - /** - * Basic Encryption Field Modeling - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Model.Basic.Field')->get($key); - */ - public $basicFieldModeling = array(); - - /** - * WHMCS Encryption Field Modeling - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Model.Whmcs.Field')->get($key); - */ - public $whmcsFieldModeling = array(); - - /** - * Medium Encryption Field Modeling - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Model.Medium.Field')->get($key); - */ - public $mediumFieldModeling = array(); - - /** - * Expert Field Modeling - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Model.Expert.Field')->get($key); - */ - public $expertFieldModeling = array(); - - /** - * Expert Mode Initiator - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Model.Expert.Field.Initiator')->get($key); - */ - public $expertFieldModelInitiator = array(); - - /** - * Get Items Method List String Fix Builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Items.Method.List.String')->get($key); - */ - public $getItemsMethodListStringFixBuilder = array(); - - /** - * Get Items Method Eximport String Fix Builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Items.Method.Eximport.String')->get($key); - */ - public $getItemsMethodEximportStringFixBuilder = array(); - - /** - * Selection Translation Fix Builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Selection.Translation')->get($key); - */ - public $selectionTranslationFixBuilder = array(); - - /** - * Sort Builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Sort')->get($key); - */ - public $sortBuilder = array(); - - /** - * Search Builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Search')->get($key); - */ - public $searchBuilder = array(); - - /** - * Filter Builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Filter')->get($key); - */ - public $filterBuilder = array(); - - /** - * Set Group Control - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Field.Group.Control')->get($key); - */ - public $setGroupControl = array(); - - /** - * Set Field Names - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Field.Names')->get($key); - */ - public $fieldsNames = array(); - - /** - * Default Fields set to publishing - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.New.Publishing.Fields')->set($key); - */ - public $newPublishingFields = array(); - - /** - * Default Fields set to publishing - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Moved.Publishing.Fields')->set($key); - */ - public $movedPublishingFields = array(); - - /** - * set the Field set of a view - * - * @param array $view The view data - * @param string $component The component name - * @param string $nameSingleCode The single view name - * @param string $nameListCode The list view name - * - * @return string The fields set in xml - * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Fieldset')->get(...); - */ - public function setFieldSet(array $view, string $component, string $nameSingleCode, string $nameListCode) - { - return CFactory::_('Compiler.Creator.Fieldset')-> - get($view, $component, $nameSingleCode, $nameListCode); - } - - /** - * build field set using string manipulation - * - * @param array $view The view data - * @param string $component The component name - * @param string $nameSingleCode The single view name - * @param string $nameListCode The list view name - * @param string $langView The language string of the view - * @param string $langViews The language string of the views - * - * @return string The fields set in xml - * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Fieldset.String')->get(...); - */ - protected function stringFieldSet(array $view, string $component, string $nameSingleCode, string $nameListCode, - string $langView, string $langViews): string - { - return CFactory::_('Compiler.Creator.Fieldset.String')->get( - $view, - $component, - $nameSingleCode, - $nameListCode, - $langView, - $langViews - ); - } - - /** - * build field set with simpleXMLElement class - * - * @param array $view The view data - * @param string $component The component name - * @param string $nameSingleCode The single view name - * @param string $nameListCode The list view name - * @param string $langView The language string of the view - * @param string $langViews The language string of the views - * - * @return string The fields set in string xml - * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Fieldset.XML')->get(...); - */ - protected function simpleXMLFieldSet(array $view, string $component, string $nameSingleCode, - string $nameListCode, string $langView, string $langViews): string - { - return CFactory::_('Compiler.Creator.Fieldset.XML')->get( - $view, - $component, - $nameSingleCode, - $nameListCode, - $langView, - $langViews - ); - } - - /** - * Check to see if a view has permissions - * - * @param array $view View details - * @param string $nameSingleCode View Single Code Name - * - * @return boolean true if it has permisssions - * @deprecated 3.3 Use CFactory::_('Adminview.Permission')->check($view, $nameSingleCode); - */ - protected function hasPermissionsSet(&$view, &$nameSingleCode) - { - return CFactory::_('Adminview.Permission')->check($view, $nameSingleCode); - } - - /** - * set Field Names - * - * @param string $view View the field belongs to - * @param string $name The name of the field - * - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Field.Names')->set($view . '.' . $name, $name); - */ - public function setFieldsNames(&$view, &$name) - { - CFactory::_('Compiler.Builder.Field.Names')->set($view . '.' . $name, $name); - } - - /** - * set Dynamic field - * - * @param array $field The field data - * @param array $view The view data - * @param int $viewType The view type - * @param string $langView The language string of the view - * @param string $nameSingleCode The single view name - * @param string $nameListCode The list view name - * @param array $placeholders The place holder and replace values - * @param string $dbkey The the custom table key - * @param boolean $build The switch to set the build option - * - * @return mixed The complete field - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Field.Names')->get(...); - */ - public function setDynamicField(&$field, &$view, &$viewType, &$langView, - &$nameSingleCode, &$nameListCode, &$placeholders, &$dbkey, $build) - { - CFactory::_('Compiler.Creator.Field.Dynamic')->get($field, $view, $viewType, $langView, - $nameSingleCode, $nameListCode, $placeholders, $dbkey, $build); - } - - /** - * build field set - * - * @param array $fields The fields data - * @param string $langView The language string of the view - * @param string $nameSingleCode The single view name - * @param string $nameListCode The list view name - * @param array $placeholders The place holder and replace values - * @param string $dbkey The the custom table key - * @param boolean $build The switch to set the build option - * @param int $return_type The return type 1 = string, 2 = array - * - * @return mixed The complete field in string or array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Fieldset.Dynamic')->get(...); - */ - public function getFieldsetXML(array &$fields, string &$langView, string &$nameSingleCode, - string &$nameListCode, array &$placeholders, string &$dbkey, bool $build = false, - int $returnType = 1) - { - return CFactory::_('Compiler.Creator.Fieldset.Dynamic')->get( - $fields, $langView, $nameSingleCode, - $nameListCode, $placeholders, $dbkey, $build, $returnType - ); - } - - /** - * build field string - * - * @param array $field The field data - * @param array $view The view data - * @param int $viewType The view type - * @param string $langView The language string of the view - * @param string $nameSingleCode The single view name - * @param string $nameListCode The list view name - * @param array $placeholders The place holder and replace values - * @param string $dbkey The the custom table key - * @param boolean $build The switch to set the build option - * - * @return string The complete field in xml-string - * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Field.As.String')->get(...); - */ - public function getFieldXMLString(array &$field, array &$view, int &$viewType, string &$langView, - string &$nameSingleCode, string &$nameListCode, array &$placeholders, string &$dbkey, - bool $build = false): string - { - // get field - return CFactory::_('Compiler.Creator.Field.As.String')->get( - $field, $view, $viewType, $langView, - $nameSingleCode, $nameListCode, $placeholders, $dbkey, $build - ); - } - - /** - * set a field - * - * @param string $setType The set of fields type - * @param array $fieldAttributes The field values - * @param string $name The field name - * @param string $typeName The field type - * @param string $langView The language string of the view - * @param string $nameSingleCode The single view name - * @param string $nameListCode The list view name - * @param array $placeholders The place holder and replace values - * @param array|null $optionArray The option bucket array used to set the field options if needed. - * @param array $custom Used when field is from config - * @param string $taber The tabs to add in layout (only in string manipulation) - * - * @return SimpleXMLElement The field in xml - * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Field.Type')->get(...); - */ - private function setField($setType, &$fieldAttributes, &$name, &$typeName, - &$langView, &$nameSingleCode, &$nameListCode, $placeholders, - &$optionArray, $custom = null, $taber = '' - ) { - return CFactory::_('Compiler.Creator.Field.Type')->get( - $setType, $fieldAttributes, $name, $typeName, - $langView, $nameSingleCode, $nameListCode, $placeholders, - $optionArray, $custom, $taber - ); - } - - /** - * set a field using string manipulation - * - * @param string $setType The set of fields type - * @param array $fieldAttributes The field values - * @param string $name The field name - * @param string $typeName The field type - * @param string $langView The language string of the view - * @param string $nameSingleCode The single view name - * @param string $nameListCode The list view name - * @param array $placeholders The place holder and replace values - * @param array|null $optionArray The option bucket array used to set the field options if needed. - * @param array $custom Used when field is from config - * @param string $taber The tabs to add in layout - * - * @return SimpleXMLElement The field in xml - * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Field.String')->get(...); - */ - protected function stringSetField($setType, &$fieldAttributes, &$name, - &$typeName, &$langView, &$nameSingleCode, &$nameListCode, - $placeholders, &$optionArray, $custom = null, $taber = '') - { - return CFactory::_('Compiler.Creator.Field.String')->get( - $setType, $fieldAttributes, $name, - $typeName, $langView, $nameSingleCode, $nameListCode, - $placeholders, $optionArray, $custom, $taber - ); - } - - /** - * set a field with simpleXMLElement class - * - * @param string $setType The set of fields type - * @param array $fieldAttributes The field values - * @param string $name The field name - * @param string $typeName The field type - * @param string $langView The language string of the view - * @param string $nameSingleCode The single view name - * @param string $nameListCode The list view name - * @param array $placeholders The place holder and replace values - * @param string $optionArray The option bucket array used to set the field options if needed. - * @param array $custom Used when field is from config - * - * @return SimpleXMLElement The field in xml - * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Field.XML')->get(...); - */ - protected function simpleXMLSetField($setType, &$fieldAttributes, &$name, - &$typeName, &$langView, &$nameSingleCode, &$nameListCode, - $placeholders, &$optionArray, $custom = null) - { - return CFactory::_('Compiler.Creator.Field.XML')->get( - $setType, $fieldAttributes, $name, - $typeName, $langView, $nameSingleCode, $nameListCode, - $placeholders, $optionArray, $custom - ); - } - - /** - * set the layout builder - * - * @param string $nameSingleCode The single edit view code name - * @param string $tabName The tab code name - * @param string $name The field code name - * @param array $field The field details - * - * @return void - * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Layout')->set(...); - */ - public function setLayoutBuilder($nameSingleCode, $tabName, $name, &$field) - { - CFactory::_('Compiler.Creator.Layout')->set($nameSingleCode, $tabName, $name, $field); - } - - /** - * build the site field data needed - * - * @param string $view The single edit view code name - * @param string $field The field name - * @param string $set The decoding set this field belongs to - * @param string $type The field type - * - * @return void - * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Site.Field.Data')->set(...); - */ - public function buildSiteFieldData($view, $field, $set, $type) - { - CFactory::_('Compiler.Creator.Site.Field.Data')->set($view, $field, $set, $type); - } - - /** - * set field attributes - * - * @param array $field The field data - * @param int $viewType The view type - * @param string $name The field name - * @param string $typeName The field type - * @param boolean $multiple The switch to set multiple selection option - * @param string $langLabel The language string for field label - * @param string $langView The language string of the view - * @param string $nameListCode The list view name - * @param string $nameSingleCode The single view name - * @param array $placeholders The place holder and replace values - * @param boolean $repeatable The repeatable field switch - * - * @return array The field attributes - * @deprecated 3.3 Use CFactory::_('Field.Attributes')->set(...); - */ - private function setFieldAttributes(&$field, &$viewType, &$name, &$typeName, - &$multiple, &$langLabel, $langView, $nameListCode, $nameSingleCode, - $placeholders, $repeatable = false - ) - { - // set notice that we could not get a valid string from the target - $this->app->enqueueMessage( - JText::sprintf('

%s Warning

', __CLASS__), 'Error' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Use of a deprecated method (%s)!', __METHOD__ - ), 'Error' - ); - - return false; - } - - /** - * set Builders - * - * @param string $langLabel The language string for field label - * @param string $langView The language string of the view - * @param string $nameSingleCode The single view name - * @param string $nameListCode The list view name - * @param string $name The field name - * @param array $view The view data - * @param array $field The field data - * @param string $typeName The field type - * @param bool $multiple The switch to set multiple selection option - * @param array|null $custom The custom field switch - * @param array|null $options The options switch - * - * @return void - * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Builders')->set(...); - */ - public function setBuilders($langLabel, $langView, $nameSingleCode, - $nameListCode, $name, $view, $field, $typeName, $multiple, - $custom = null, $options = null - ): void - { - CFactory::_('Compiler.Creator.Builders')->set($langLabel, $langView, $nameSingleCode, - $nameListCode, $name, $view, $field, $typeName, $multiple, $custom, $options); - } - - /** - * set Custom Field Type File - * - * @param array $data The field complete data set - * @param string $nameListCode The list view code name - * @param string $nameSingleCode The single view code name - * - * @return void - * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Custom.Field.Type.File')->set(...); - */ - public function setCustomFieldTypeFile($data, $nameListCode,$nameSingleCode) - { - CFactory::_('Compiler.Creator.Custom.Field.Type.File')->set($data, $nameListCode,$nameSingleCode); - } - - /** - * This is just to get the code. - * Don't use this to build the field - * - * @param array $custom The field complete data set - * - * @return array with the code - * - */ - public function getCustomFieldCode($custom) - { - // the code bucket - $code_bucket = array( - 'JFORM_TYPE_HEADER' => '', - 'JFORM_TYPE_PHP' => '' - ); - // set tab and break replacements - $tabBreak = array( - '\t' => Indent::_(1), - '\n' => PHP_EOL - ); - // load the other PHP options - foreach (ComponentbuilderHelper::$phpFieldArray as $x) - { - // reset the php bucket - $phpBucket = ''; - // only set if available - if (isset($custom['php' . $x]) - && ArrayHelper::check( - $custom['php' . $x] - )) - { - foreach ($custom['php' . $x] as $line => $code) - { - if (StringHelper::check($code)) - { - $phpBucket .= PHP_EOL . CFactory::_('Placeholder')->update( - $code, $tabBreak - ); - } - } - // check if this is header text - if ('HEADER' === $x) - { - $code_bucket['JFORM_TYPE_HEADER'] - .= PHP_EOL . $phpBucket; - } - else - { - // JFORM_TYPE_PHP <<>> - $code_bucket['JFORM_TYPE_PHP'] - .= PHP_EOL . $phpBucket; - } - } - } - - return $code_bucket; - } - - /** - * set the Filter Field set of a view - * - * @param string $nameSingleCode The single view name - * @param string $nameListCode The list view name - * - * @return string The fields set in xml - * - */ - public function setFieldFilterSet(&$nameSingleCode, &$nameListCode) - { - // check if this is the above/new filter option - if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2) - { - // we first create the file - $target = array('admin' => 'filter_' . $nameListCode); - CFactory::_('Utilities.Structure')->build( - $target, 'filter' - ); - // the search language string - $lang_search = CFactory::_('Config')->lang_prefix . '_FILTER_SEARCH'; - // and to translation - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang_search, 'Search' - . StringHelper::safe($nameListCode, 'w') - ); - // the search description language string - $lang_search_desc = CFactory::_('Config')->lang_prefix . '_FILTER_SEARCH_' - . strtoupper($nameListCode); - // and to translation - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang_search_desc, 'Search the ' - . StringHelper::safe($nameSingleCode, 'w') - . ' items. Prefix with ID: to search for an item by ID.' - ); - // now build the XML - $field_filter_sets = array(); - $field_filter_sets[] = Indent::_(1) . ''; - // we first add the search - $field_filter_sets[] = Indent::_(2) . ''; - // add the published filter if published is not set - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.published')) - { - // the published language string - $lang_published = CFactory::_('Config')->lang_prefix . '_FILTER_PUBLISHED'; - // and to translation - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang_published, 'Status' - ); - // the published description language string - $lang_published_desc = CFactory::_('Config')->lang_prefix . '_FILTER_PUBLISHED_' - . strtoupper($nameListCode); - // and to translation - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang_published_desc, 'Status options for ' - . StringHelper::safe($nameListCode, 'w') - ); - $field_filter_sets[] = Indent::_(2) . ''; - $field_filter_sets[] = Indent::_(3) - . ''; - $field_filter_sets[] = Indent::_(2) . ''; - } - // add the category if found - if (CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.extension") - && CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.filter", 0) >= 1) - { - $field_filter_sets[] = Indent::_(2) . ''; - } - // add the access filter if this view has access - // and if access manually is not set - if (CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode) - && !CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.access')) - { - $field_filter_sets[] = Indent::_(2) . ''; - } - // now add the dynamic fields - if (CFactory::_('Compiler.Builder.Filter')->exists($nameListCode)) - { - foreach (CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as $n => $filter) - { - if ($filter['type'] != 'category') - { - $field_filter_sets[] = Indent::_(2) . 'set("{$nameListCode}.{$n}.class", $filter_class); - - $field_filter_sets[] = Indent::_(3) . 'name="' - . $filter['code'] . '"'; - $field_filter_sets[] = Indent::_(3) . 'label="' - . $filter['label'] . '"'; - - // if this is a multi field - if ($filter['multi'] == 2) - { - $field_filter_sets[] = Indent::_(3) . 'class="multiple' . $filter_class . '"'; - $field_filter_sets[] = Indent::_(3) . 'multiple="true"'; - } - else - { - $field_filter_sets[] = Indent::_(3) . 'multiple="false"'; - } - - $field_filter_sets[] = Indent::_(3) - . 'onchange="this.form.submit();"'; - $field_filter_sets[] = Indent::_(2) . '/>'; - } - } - } - $field_filter_sets[] = Indent::_(2) - . ''; - $field_filter_sets[] = Indent::_(1) . ''; - - // now update the file - return implode(PHP_EOL, $field_filter_sets); - } - - return ''; - } - - /** - * set the Filter List set of a view - * - * @param string $nameSingleCode The single view name - * @param string $nameListCode The list view name - * - * @return string The fields set in xml - * - */ - public function setFieldFilterListSet(&$nameSingleCode, &$nameListCode) - { - // check if this is the above/new filter option - if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2) - { - // keep track of all fields already added - $donelist = array('ordering' => true, 'id' => true); - // now build the XML - $list_sets = array(); - $list_sets[] = Indent::_(1) . ''; - $list_sets[] = Indent::_(2) . 'getListViewDefaultOrdering( - $nameListCode - ); - // set the default ordering - $list_sets[] = Indent::_(3) . 'default="' - . $default_ordering['name'] . ' ' - . $default_ordering['direction'] . '"'; - $list_sets[] = Indent::_(3) . 'validate="options"'; - $list_sets[] = Indent::_(2) . '>'; - $list_sets[] = Indent::_(3) - . ''; - $list_sets[] = Indent::_(3) - . ''; - $list_sets[] = Indent::_(3) - . ''; - // add the published filter if published is not set - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.published')) - { - // add to done list - $donelist['published'] = true; - // add to xml :) - $list_sets[] = Indent::_(3) - . ''; - $list_sets[] = Indent::_(3) - . ''; - } - - // add the rest of the set filters - if (CFactory::_('Compiler.Builder.Sort')->exists($nameListCode)) - { - foreach (CFactory::_('Compiler.Builder.Sort')->get($nameListCode) as $filter) - { - if (!isset($donelist[$filter['code']])) - { - if ($filter['type'] === 'category') - { - $list_sets[] = Indent::_(3) - . ''; - $list_sets[] = Indent::_(3) - . ''; - } - elseif (ArrayHelper::check( - $filter['custom'] - )) - { - $list_sets[] = Indent::_(3) . ''; - $list_sets[] = Indent::_(3) . ''; - } - else - { - $list_sets[] = Indent::_(3) . ''; - $list_sets[] = Indent::_(3) . ''; - } - // do not add again - $donelist[$filter['code']] = true; - } - } - } - - $list_sets[] = Indent::_(3) - . ''; - $list_sets[] = Indent::_(3) - . ''; - $list_sets[] = Indent::_(2) . '' . PHP_EOL; - - $list_sets[] = Indent::_(2) . ''; - $list_sets[] = Indent::_(1) . ''; - - return implode(PHP_EOL, $list_sets); - } - - return ''; - } - - /** - * set Custom Field for Filter - * - * @param string $getOptions The get options php string/code - * @param array $filter The filter details - * - * @return void - * - */ - public function setFilterFieldFile($getOptions, $filter) - { - // make sure it is not already been build - if (!CFactory::_('Compiler.Builder.Content.Multi')-> - isArray('customfilterfield_' . $filter['filter_type'])) - { - // start loading the field type - // $this->fileContentDynamic['customfilterfield_' - // . $filter['filter_type']] - // = array(); - // JPREFIX <>> - CFactory::_('Compiler.Builder.Content.Multi')->set('customfilterfield_' . $filter['filter_type'] . '|JPREFIX', 'J'); - // Type <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set('customfilterfield_' . $filter['filter_type'] . '|Type', - StringHelper::safe( - $filter['filter_type'], 'F' - ) - ); - // type <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set('customfilterfield_' . $filter['filter_type'] . '|type', - StringHelper::safe($filter['filter_type']) - ); - // JFORM_GETOPTIONS_PHP <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set('customfilterfield_' . $filter['filter_type'] . '|JFORM_GETOPTIONS_PHP', - $getOptions - ); - // ADD_BUTTON <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set('customfilterfield_' . $filter['filter_type'] . '|ADD_BUTTON', ''); - // now build the custom filter field type file - $target = array('admin' => 'customfilterfield'); - CFactory::_('Utilities.Structure')->build( - $target, 'fieldlist', - $filter['filter_type'] - ); - } - } - - /** - * set Add Button To List Field (getInput tweak) - * - * @param array $fieldData The field custom data - * - * @return string of getInput class on success empty string otherwise - * @deprecated 3.3 Use CFactory::_('Field.Input.Button')->get($fieldData); - */ - protected function setAddButtonToListField($fieldData) - { - return CFactory::_('Field.Input.Button')->get($fieldData); - } - - /** - * xmlPrettyPrint - * - * @param SimpleXMLElement $xml The XML element containing a node to be output - * @param string $nodename node name of the input xml element to print out. this is done to omit the pretty($xml, $nodename); - */ - public function xmlPrettyPrint($xml, $nodename) - { - return CFactory::_('Utilities.Xml')->pretty($xml, $nodename); - } - - /** - * xmlIndent - * - * @param string $string The XML input - * @param string $char Character or characters to use as the repeated indent - * @param integer $depth number of times to repeat the indent character - * @param boolean $skipfirst Skip the first line of the input. - * @param boolean $skiplast Skip the last line of the input; - * - * @return string XML output - * @deprecated 3.3 Use CFactory::_('Utilities.Xml')->indent(...); - */ - public function xmlIndent($string, $char = ' ', $depth = 0, - $skipfirst = false, $skiplast = false - ) { - return CFactory::_('Utilities.Xml')->indent($string, $char, $depth, $skipfirst, $skiplast); - } -} diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php deleted file mode 100644 index 939754f4f..000000000 --- a/admin/helpers/compiler/e_Interpretation.php +++ /dev/null @@ -1,26830 +0,0 @@ - - * @gitea Joomla Component Builder - * @github Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Filesystem\File; -use Joomla\CMS\Filesystem\Folder; -use VDM\Joomla\FOF\Encrypt\AES; -use VDM\Joomla\Utilities\StringHelper; -use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\ObjectHelper; -use VDM\Joomla\Utilities\GetHelper; -use VDM\Joomla\Utilities\FileHelper; -use VDM\Joomla\Utilities\MathHelper; -use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Minify; - -/** - * Compiler class - * @deprecated 3.3 - */ -class Interpretation extends Fields -{ - - /** - * The global config Field Sets - * - * @var array - */ - public $configFieldSets = array(); - - /** - * The global config Field Sets Custom Fields - * - * @var array - */ - public $configFieldSetsCustomField = array(); - - /** - * The contributors - * - * @var string - */ - public $theContributors = ''; - - /** - * The unistall builder - * - * @var array - */ - public $uninstallBuilder = array(); - - /** - * The update SQL builder - * - * @var array - */ - public $updateSQLBuilder = array(); - - /** - * The List Column Builder - * - * @var array - */ - public $listColnrBuilder = array(); - - /** - * The permissions Builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Permission.Action')->set($action, $nameView, $nameView); - * @deprecated 3.3 or Use CFactory::_('Compiler.Builder.Permission.Global')->set($action, $nameView, $nameView); - */ - public $permissionBuilder = array(); - - /** - * The dashboard permissions builder - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Permission.Dashboard')->add('icon', $key, $value) - */ - public $permissionDashboard = array(); - - /** - * The permissions core - * - * @var array - * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Permission.Core')->set($nameView, $coreTarget, $action); - */ - public $permissionCore = array(); - - /** - * The customs field builder - * - * @var array - */ - public $customFieldBuilder = array(); - - /** - * The category builder - * - * @var array - */ - public $buildCategories = array(); - - /** - * The icon builder - * - * @var array - */ - public $iconBuilder = array(); - - /** - * The validation fix builder - * - * @var array - */ - public $validationFixBuilder = array(); - - /** - * The view script builder - * - * @var array - */ - public $viewScriptBuilder = array(); - - /** - * The target relation control - * - * @var array - */ - public $targetRelationControl = array(); - - /** - * The target control script checker - * - * @var array - */ - public $targetControlsScriptChecker = array(); - - /** - * The router helper - * - * @var array - */ - public $setRouterHelpDone = array(); - - /** - * The other where - * - * @var array - */ - public $otherWhere = array(); - - /** - * The dashboard get custom data - * - * @var array - */ - public $DashboardGetCustomData = array(); - - /** - * The custom admin added - * - * @var array - */ - public $customAdminAdded = array(); - - /** - * Switch to add form to views - * - * @var array - */ - public $addCustomForm = array(); - - /** - * The extensions params - * - * @var array - */ - protected $extensionsParams = array(); - - /** - * The asset rules - * - * @var array - */ - public $assetsRules = array(); - - /** - * View Has Category Request - * - * @var array - */ - protected $hasCatIdRequest = array(); - - /** - * All fields with permissions - * - * @var array - */ - public $permissionFields = array(); - - /** - * Custom Admin View List Link - * - * @var array - */ - protected $customAdminViewListLink = array(); - - /** - * load Tracker of fields to fix - * - * @var array - */ - protected $loadTracker = array(); - - /** - * View Has Id Request - * - * @var array - */ - protected $hasIdRequest = array(); - protected $libwarning = array(); - - /** - * Language message buckets - * - * @var array - */ - public $langNot = array(); - public $langSet = array(); - - /** - * alignment names - * - * @var array - */ - protected $alignmentOptions - = array(1 => 'left', 2 => 'right', 3 => 'fullwidth', 4 => 'above', - 5 => 'under', 6 => 'leftside', 7 => 'rightside'); - - /** - * Constructor - */ - public function __construct() - { - // first we run the parent constructor - if (parent::__construct()) - { - return true; - } - - return false; - } - - /** - * add email helper - */ - public function addEmailHelper() - { - if (CFactory::_('Component')->get('add_email_helper')) - { - // set email helper in place with component name - $component = CFactory::_('Config')->component_code_name; - $Component = CFactory::_('Compiler.Builder.Content.One')->get('Component'); - $target = array('admin' => 'emailer'); - $done = CFactory::_('Utilities.Structure')->build($target, 'emailer', $component); - if ($done) - { - // the text for the file BAKING - CFactory::_('Compiler.Builder.Content.Multi')->set('emailer_' . $component . '|BAKING', ''); // <<-- to insure it gets updated - // return the code need to load the abstract class - return PHP_EOL . "JLoader::register('" . $Component - . "Email', JPATH_COMPONENT_ADMINISTRATOR . '/helpers/" - . $component . "email.php'); "; - } - } - - return ''; - } - - /** - * set the lock license (NOT OKAY) - */ - public function setLockLicense() - { - if (CFactory::_('Component')->get('add_license', 0) == 3) - { - if (!CFactory::_('Compiler.Builder.Content.One')->exists('HELPER_SITE_LICENSE_LOCK')) - { - $_WHMCS = '_' . StringHelper::safe( - $this->uniquekey(10), 'U' - ); - // add it to the system - CFactory::_('Compiler.Builder.Content.One')->set('HELPER_SITE_LICENSE_LOCK', $this->setHelperLicenseLock($_WHMCS, 'site')); - CFactory::_('Compiler.Builder.Content.One')->set('HELPER_LICENSE_LOCK', $this->setHelperLicenseLock($_WHMCS, 'admin')); - CFactory::_('Compiler.Builder.Content.One')->set('LICENSE_LOCKED_INT', $this->setInitLicenseLock($_WHMCS)); - CFactory::_('Compiler.Builder.Content.One')->set('LICENSE_LOCKED_DEFINED', - PHP_EOL . PHP_EOL . 'defined(\'' . $_WHMCS - . '\') or die(JText:' . ':_(\'NIE_REG_NIE\'));'); - } - } - else - { - // don't add it to the system - CFactory::_('Compiler.Builder.Content.One')->set('HELPER_SITE_LICENSE_LOCK', ''); - CFactory::_('Compiler.Builder.Content.One')->set('HELPER_LICENSE_LOCK', ''); - CFactory::_('Compiler.Builder.Content.One')->set('LICENSE_LOCKED_INT', ''); - CFactory::_('Compiler.Builder.Content.One')->set('LICENSE_LOCKED_DEFINED', ''); - } - } - - /** - * set Lock License Per - * - * @param string $view - * @param string $target - */ - public function setLockLicensePer(&$view, $target) - { - if (CFactory::_('Component')->get('add_license', 0) == 3) - { - if (!CFactory::_('Compiler.Builder.Content.Multi')->exists($view . '|BOOLMETHOD')) - { - $boolMethod = 'get' . StringHelper::safe( - $this->uniquekey(3, false, 'ddd'), 'W' - ); - $globalbool = 'set' . StringHelper::safe( - $this->uniquekey(3), 'W' - ); - // add it to the system - CFactory::_('Compiler.Builder.Content.Multi')->set($view . '|LICENSE_LOCKED_SET_BOOL', - $this->setBoolLicenseLock($boolMethod, $globalbool)); - CFactory::_('Compiler.Builder.Content.Multi')->set($view . '|LICENSE_LOCKED_CHECK', - $this->checkStatmentLicenseLocked($boolMethod)); - CFactory::_('Compiler.Builder.Content.Multi')->set($view . '|LICENSE_TABLE_LOCKED_CHECK', - $this->checkStatmentLicenseLocked($boolMethod, '$table')); - CFactory::_('Compiler.Builder.Content.Multi')->set($view . '|BOOLMETHOD', $boolMethod); - } - } - else - { - // don't add it to the system - CFactory::_('Compiler.Builder.Content.Multi')->set($view . '|LICENSE_LOCKED_SET_BOOL', ''); - CFactory::_('Compiler.Builder.Content.Multi')->set($view . '|LICENSE_LOCKED_CHECK', ''); - CFactory::_('Compiler.Builder.Content.Multi')->set($view . '|LICENSE_TABLE_LOCKED_CHECK', ''); - } - } - - /** - * Check statment license locked - * - * @param type $boolMethod - * @param type $thIIS - * - * @return string - */ - public function checkStatmentLicenseLocked($boolMethod, $thIIS = '$this') - { - $statment[] = PHP_EOL . Indent::_(2) . "if (!" . $thIIS . "->" - . $boolMethod . "())"; - $statment[] = Indent::_(2) . "{"; - $statment[] = Indent::_(3) . "\$app = JFactory::getApplication();"; - $statment[] = Indent::_(3) . "\$app->enqueueMessage(JText:" - . ":_('NIE_REG_NIE'), 'error');"; - $statment[] = Indent::_(3) . "\$app->redirect('index.php');"; - $statment[] = Indent::_(3) . "return false;"; - $statment[] = Indent::_(2) . "}"; - - // return the genuine mentod statement - 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 . Indent::_(1) . "/**"; - $bool[] = Indent::_(1) . " * The private bool."; - $bool[] = Indent::_(1) . " **/"; - $bool[] = Indent::_(1) . "private $" . $globalbool . ";"; - $bool[] = PHP_EOL . Indent::_(1) . "/**"; - $bool[] = Indent::_(1) . " * Check if this install has a license."; - $bool[] = Indent::_(1) . " **/"; - $bool[] = Indent::_(1) . "public function " . $boolMethod . "()"; - $bool[] = Indent::_(1) . "{"; - $bool[] = Indent::_(2) . "if(!empty(\$this->" . $globalbool . "))"; - $bool[] = Indent::_(2) . "{"; - $bool[] = Indent::_(3) . "return \$this->" . $globalbool . ";"; - $bool[] = Indent::_(2) . "}"; - $bool[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Get the global params"; - $bool[] = Indent::_(2) . "\$params = JComponentHelper::getParams('com_" - . CFactory::_('Config')->component_code_name . "', true);"; - $bool[] = Indent::_(2) - . "\$whmcs_key = \$params->get('whmcs_key', null);"; - $bool[] = Indent::_(2) . "if (\$whmcs_key)"; - $bool[] = Indent::_(2) . "{"; - $bool[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " load the file"; - $bool[] = Indent::_(3) - . "JLoader::import( 'whmcs', JPATH_ADMINISTRATOR .'/components/com_" - . CFactory::_('Config')->component_code_name . "');"; - $bool[] = Indent::_(3) . "\$the = new WHMCS(\$whmcs_key);"; - $bool[] = Indent::_(3) . "\$this->" . $globalbool . " = \$the->_is;"; - $bool[] = Indent::_(3) . "return \$this->" . $globalbool . ";"; - $bool[] = Indent::_(2) . "}"; - $bool[] = Indent::_(2) . "return false;"; - $bool[] = Indent::_(1) . "}"; - - // return the genuine method statement - return implode(PHP_EOL, $bool); - } - - /** - * set Helper License Lock - * - * @param type $_WHMCS - * @param type $target - * - * @return string - */ - public function setHelperLicenseLock($_WHMCS, $target) - { - $helper[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $helper[] = Indent::_(1) . " * Check if this install has a license."; - $helper[] = Indent::_(1) . " **/"; - $helper[] = Indent::_(1) . "public static function isGenuine()"; - $helper[] = Indent::_(1) . "{"; - $helper[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Get the global params"; - $helper[] = Indent::_(2) - . "\$params = JComponentHelper::getParams('com_" - . CFactory::_('Config')->component_code_name . "', true);"; - $helper[] = Indent::_(2) - . "\$whmcs_key = \$params->get('whmcs_key', null);"; - $helper[] = Indent::_(2) . "if (\$whmcs_key)"; - $helper[] = Indent::_(2) . "{"; - $helper[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " load the file"; - $helper[] = Indent::_(3) - . "JLoader::import( 'whmcs', JPATH_ADMINISTRATOR .'/components/com_" - . CFactory::_('Config')->component_code_name . "');"; - $helper[] = Indent::_(3) . "\$the = new WHMCS(\$whmcs_key);"; - $helper[] = Indent::_(3) . "return \$the->_is;"; - $helper[] = Indent::_(2) . "}"; - $helper[] = Indent::_(2) . "return false;"; - $helper[] = Indent::_(1) . "}"; - - // return the genuine mentod statement - return implode(PHP_EOL, $helper); - } - - /** - * set Init License Lock - * - * @param type $_WHMCS - * - * @return string - */ - public function setInitLicenseLock($_WHMCS) - { - $init[] = PHP_EOL . "if (!defined('" . $_WHMCS . "'))"; - $init[] = "{"; - $init[] = Indent::_(1) . "\$allow = " - . CFactory::_('Compiler.Builder.Content.One')->get('Component') - . "Helper::isGenuine();"; - $init[] = Indent::_(1) . "if (\$allow)"; - $init[] = Indent::_(1) . "{"; - $init[] = Indent::_(2) . "define('" . $_WHMCS . "', 1);"; - $init[] = Indent::_(1) . "}"; - $init[] = "}"; - - // return the initializing statement - return implode(PHP_EOL, $init); - } - - /** - * set WHMCS Cryption - * - * @return string - */ - public function setWHMCSCryption() - { - // make sure we have the correct file - if (CFactory::_('Component')->isString('whmcs_key')) - { - // Get the basic encryption. - $basickey = ComponentbuilderHelper::getCryptKey('basic'); - $key = CFactory::_('Component')->get('whmcs_key'); - - // Get the encryption object. - $basic = new AES($basickey); - if ($basickey && $key === base64_encode( - base64_decode((string) $key, true) - )) - { - // basic decrypt data whmcs_key. - $key = rtrim( - (string) $basic->decryptString($key), "\0" - ); - // set the needed string to connect to whmcs - $key["kasier"] = CFactory::_('Component')->get('whmcs_url', ''); - $key["geheim"] = $key; - $key["onthou"] = 1; - // prep the call info - $theKey = base64_encode(serialize($key)); - // set the script - $encrypt[] = "/**"; - $encrypt[] = "* " . Line::_(__Line__, __Class__) . "WHMCS Class "; - $encrypt[] = "**/"; - $encrypt[] = "class WHMCS"; - $encrypt[] = "{"; - $encrypt[] = Indent::_(1) . "public \$_key = false;"; - $encrypt[] = Indent::_(1) . "public \$_is = false;"; - $encrypt[] = PHP_EOL . Indent::_(1) - . "public function __construct(\$Vk5smi0wjnjb)"; - $encrypt[] = Indent::_(1) . "{"; - $encrypt[] = Indent::_(2) . "// get the session"; - $encrypt[] = Indent::_(2) - . "\$session = JFactory::getSession();"; - $encrypt[] = Indent::_(2) - . "\$V2uekt2wcgwk = \$session->get(\$Vk5smi0wjnjb, null);"; - $encrypt[] = Indent::_(2) - . "\$h4sgrGsqq = \$this->get(\$Vk5smi0wjnjb,\$V2uekt2wcgwk);"; - $encrypt[] = Indent::_(2) - . "if (isset(\$h4sgrGsqq['nuut']) && \$h4sgrGsqq['nuut'] && (isset(\$h4sgrGsqq['status']) && 'Active' === \$h4sgrGsqq['status']) && isset(\$h4sgrGsqq['eiegrendel']) && strlen(\$h4sgrGsqq['eiegrendel']) > 300)"; - $encrypt[] = Indent::_(2) . "{"; - $encrypt[] = Indent::_(3) - . "\$session->set(\$Vk5smi0wjnjb, \$h4sgrGsqq['eiegrendel']);"; - $encrypt[] = Indent::_(2) . "}"; - $encrypt[] = Indent::_(2) - . "if ((isset(\$h4sgrGsqq['status']) && 'Active' === \$h4sgrGsqq['status']) && isset(\$h4sgrGsqq['md5hash']) && strlen(\$h4sgrGsqq['md5hash']) == 32 && isset(\$h4sgrGsqq['customfields']) && strlen(\$h4sgrGsqq['customfields']) > 4)"; - $encrypt[] = Indent::_(2) . "{"; - $encrypt[] = Indent::_(3) - . "\$this->_key = md5(\$h4sgrGsqq['customfields']);"; - $encrypt[] = Indent::_(2) . "}"; - $encrypt[] = Indent::_(2) - . "if ((isset(\$h4sgrGsqq['status']) && 'Active' === \$h4sgrGsqq['status']) && isset(\$h4sgrGsqq['md5hash']) && strlen(\$h4sgrGsqq['md5hash']) == 32 )"; - $encrypt[] = Indent::_(2) . "{"; - $encrypt[] = Indent::_(3) . "\$this->_is = true;"; - $encrypt[] = Indent::_(2) . "}"; - $encrypt[] = Indent::_(1) . "}"; - $encrypt[] = PHP_EOL . Indent::_(1) - . "private function get(\$Vk5smi0wjnjb,\$V2uekt2wcgwk)"; - $encrypt[] = Indent::_(1) . "{"; - $encrypt[] = Indent::_(2) - . "\$Viioj50xuqu2 = unserialize(base64_decode('" . $theKey - . "'));"; - $encrypt[] = Indent::_(2) - . "\$Visqfrd1caus = time() . md5(mt_rand(1000000000, 9999999999) . \$Vk5smi0wjnjb);"; - $encrypt[] = Indent::_(2) . "\$Vo4tezfgcf3e = date(\"Ymd\");"; - $encrypt[] = Indent::_(2) - . "\$Vozblwvfym2f = \$_SERVER['SERVER_NAME'];"; - $encrypt[] = Indent::_(2) - . "\$Vozblwvfym2fdie = isset(\$_SERVER['SERVER_ADDR']) ? \$_SERVER['SERVER_ADDR'] : \$_SERVER['LOCAL_ADDR'];"; - $encrypt[] = Indent::_(2) - . "\$V343jp03dxco = dirname(__FILE__);"; - $encrypt[] = Indent::_(2) - . "\$Vc2rayehw4f0 = unserialize(base64_decode('czozNjoibW9kdWxlcy9zZXJ2ZXJzL2xpY2Vuc2luZy92ZXJpZnkucGhwIjs='));"; - $encrypt[] = Indent::_(2) . "\$Vlpolphukogz = false;"; - $encrypt[] = Indent::_(2) . "if (\$V2uekt2wcgwk) {"; - $encrypt[] = Indent::_(3) . "\$V2uekt2wcgwk = str_replace(\"" - . '".PHP_EOL."' . "\", '', \$V2uekt2wcgwk);"; - $encrypt[] = Indent::_(3) - . "\$Vm5cxjdc43g4 = substr(\$V2uekt2wcgwk, 0, strlen(\$V2uekt2wcgwk) - 32);"; - $encrypt[] = Indent::_(3) - . "\$Vbgx0efeu2sy = substr(\$V2uekt2wcgwk, strlen(\$V2uekt2wcgwk) - 32);"; - $encrypt[] = Indent::_(3) - . "if (\$Vbgx0efeu2sy == md5(\$Vm5cxjdc43g4 . \$Viioj50xuqu2['geheim'])) {"; - $encrypt[] = Indent::_(4) - . "\$Vm5cxjdc43g4 = strrev(\$Vm5cxjdc43g4);"; - $encrypt[] = Indent::_(4) - . "\$Vbgx0efeu2sy = substr(\$Vm5cxjdc43g4, 0, 32);"; - $encrypt[] = Indent::_(4) - . "\$Vm5cxjdc43g4 = substr(\$Vm5cxjdc43g4, 32);"; - $encrypt[] = Indent::_(4) - . "\$Vm5cxjdc43g4 = base64_decode(\$Vm5cxjdc43g4);"; - $encrypt[] = Indent::_(4) - . "\$Vm5cxjdc43g4finding = unserialize(\$Vm5cxjdc43g4);"; - $encrypt[] = Indent::_(4) - . "\$V3qqz0p00fbq = \$Vm5cxjdc43g4finding['dan'];"; - $encrypt[] = Indent::_(4) - . "if (\$Vbgx0efeu2sy == md5(\$V3qqz0p00fbq . \$Viioj50xuqu2['geheim'])) {"; - $encrypt[] = Indent::_(5) - . "\$Vbfbwv2y4kre = date(\"Ymd\", mktime(0, 0, 0, date(\"m\"), date(\"d\") - \$Viioj50xuqu2['onthou'], date(\"Y\")));"; - $encrypt[] = Indent::_(5) - . "if (\$V3qqz0p00fbq > \$Vbfbwv2y4kre) {"; - $encrypt[] = Indent::_(6) . "\$Vlpolphukogz = true;"; - $encrypt[] = Indent::_(6) - . "\$Vwasqoybpyed = \$Vm5cxjdc43g4finding;"; - $encrypt[] = Indent::_(6) - . "\$Vcixw3trerrt = explode(',', \$Vwasqoybpyed['validdomain']);"; - $encrypt[] = Indent::_(6) - . "if (!in_array(\$_SERVER['SERVER_NAME'], \$Vcixw3trerrt)) {"; - $encrypt[] = Indent::_(7) . "\$Vlpolphukogz = false;"; - $encrypt[] = Indent::_(7) - . "\$Vm5cxjdc43g4finding['status'] = \"sleg\";"; - $encrypt[] = Indent::_(7) . "\$Vwasqoybpyed = array();"; - $encrypt[] = Indent::_(6) . "}"; - $encrypt[] = Indent::_(6) - . "\$Vkni3xyhkqzv = explode(',', \$Vwasqoybpyed['validip']);"; - $encrypt[] = Indent::_(6) - . "if (!in_array(\$Vozblwvfym2fdie, \$Vkni3xyhkqzv)) {"; - $encrypt[] = Indent::_(7) . "\$Vlpolphukogz = false;"; - $encrypt[] = Indent::_(7) - . "\$Vm5cxjdc43g4finding['status'] = \"sleg\";"; - $encrypt[] = Indent::_(7) . "\$Vwasqoybpyed = array();"; - $encrypt[] = Indent::_(6) . "}"; - $encrypt[] = Indent::_(6) - . "\$Vckfvnepoaxj = explode(',', \$Vwasqoybpyed['validdirectory']);"; - $encrypt[] = Indent::_(6) - . "if (!in_array(\$V343jp03dxco, \$Vckfvnepoaxj)) {"; - $encrypt[] = Indent::_(7) . "\$Vlpolphukogz = false;"; - $encrypt[] = Indent::_(7) - . "\$Vm5cxjdc43g4finding['status'] = \"sleg\";"; - $encrypt[] = Indent::_(7) . "\$Vwasqoybpyed = array();"; - $encrypt[] = Indent::_(6) . "}"; - $encrypt[] = Indent::_(5) . "}"; - $encrypt[] = Indent::_(4) . "}"; - $encrypt[] = Indent::_(3) . "}"; - $encrypt[] = Indent::_(2) . "}"; - $encrypt[] = Indent::_(2) . "if (!\$Vlpolphukogz) {"; - $encrypt[] = Indent::_(3) . "\$V1u0c4dl3ehp = array("; - $encrypt[] = Indent::_(4) . "'licensekey' => \$Vk5smi0wjnjb,"; - $encrypt[] = Indent::_(4) . "'domain' => \$Vozblwvfym2f,"; - $encrypt[] = Indent::_(4) . "'ip' => \$Vozblwvfym2fdie,"; - $encrypt[] = Indent::_(4) . "'dir' => \$V343jp03dxco,"; - $encrypt[] = Indent::_(3) . ");"; - $encrypt[] = Indent::_(3) - . "if (\$Visqfrd1caus) \$V1u0c4dl3ehp['check_token'] = \$Visqfrd1caus;"; - $encrypt[] = Indent::_(3) . "\$Vdsjeyjmpq2o = '';"; - $encrypt[] = Indent::_(3) - . "foreach (\$V1u0c4dl3ehp AS \$V2sgyscukmgi=>\$V1u00zkzmb1d) {"; - $encrypt[] = Indent::_(4) - . "\$Vdsjeyjmpq2o .= \$V2sgyscukmgi.'='.urlencode(\$V1u00zkzmb1d).'&';"; - $encrypt[] = Indent::_(3) . "}"; - $encrypt[] = Indent::_(3) - . "if (function_exists('curl_exec')) {"; - $encrypt[] = Indent::_(4) . "\$Vdathuqgjyf0 = curl_init();"; - $encrypt[] = Indent::_(4) - . "curl_setopt(\$Vdathuqgjyf0, CURLOPT_URL, \$Viioj50xuqu2['kasier'] . \$Vc2rayehw4f0);"; - $encrypt[] = Indent::_(4) - . "curl_setopt(\$Vdathuqgjyf0, CURLOPT_POST, 1);"; - $encrypt[] = Indent::_(4) - . "curl_setopt(\$Vdathuqgjyf0, CURLOPT_POSTFIELDS, \$Vdsjeyjmpq2o);"; - $encrypt[] = Indent::_(4) - . "curl_setopt(\$Vdathuqgjyf0, CURLOPT_TIMEOUT, 30);"; - $encrypt[] = Indent::_(4) - . "curl_setopt(\$Vdathuqgjyf0, CURLOPT_RETURNTRANSFER, 1);"; - $encrypt[] = Indent::_(4) - . "\$Vqojefyeohg5 = curl_exec(\$Vdathuqgjyf0);"; - $encrypt[] = Indent::_(4) . "curl_close(\$Vdathuqgjyf0);"; - $encrypt[] = Indent::_(3) . "} else {"; - $encrypt[] = Indent::_(4) - . "\$Vrpmu4bvnmkp = fsockopen(\$Viioj50xuqu2['kasier'], 80, \$Vc0t5kmpwkwk, \$Va3g41fnofhu, 5);"; - $encrypt[] = Indent::_(4) . "if (\$Vrpmu4bvnmkp) {"; - $encrypt[] = Indent::_(5) . "\$Vznkm0a0me1y = \"\r" . PHP_EOL - . "\";"; - $encrypt[] = Indent::_(5) - . "\$V2sgyscukmgiop = \"POST \".\$Viioj50xuqu2['kasier'] . \$Vc2rayehw4f0 . \" HTTP/1.0\" . \$Vznkm0a0me1y;"; - $encrypt[] = Indent::_(5) - . "\$V2sgyscukmgiop .= \"Host: \".\$Viioj50xuqu2['kasier'] . \$Vznkm0a0me1y;"; - $encrypt[] = Indent::_(5) - . "\$V2sgyscukmgiop .= \"Content-type: application/x-www-form-urlencoded\" . \$Vznkm0a0me1y;"; - $encrypt[] = Indent::_(5) - . "\$V2sgyscukmgiop .= \"Content-length: \".@strlen(\$Vdsjeyjmpq2o) . \$Vznkm0a0me1y;"; - $encrypt[] = Indent::_(5) - . "\$V2sgyscukmgiop .= \"Connection: close\" . \$Vznkm0a0me1y . \$Vznkm0a0me1y;"; - $encrypt[] = Indent::_(5) - . "\$V2sgyscukmgiop .= \$Vdsjeyjmpq2o;"; - $encrypt[] = Indent::_(5) . "\$Vqojefyeohg5 = '';"; - $encrypt[] = Indent::_(5) - . "@stream_set_timeout(\$Vrpmu4bvnmkp, 20);"; - $encrypt[] = Indent::_(5) - . "@fputs(\$Vrpmu4bvnmkp, \$V2sgyscukmgiop);"; - $encrypt[] = Indent::_(5) - . "\$V2czq24pjexf = @socket_get_status(\$Vrpmu4bvnmkp);"; - $encrypt[] = Indent::_(5) - . "while (!@feof(\$Vrpmu4bvnmkp)&&\$V2czq24pjexf) {"; - $encrypt[] = Indent::_(6) - . "\$Vqojefyeohg5 .= @fgets(\$Vrpmu4bvnmkp, 1024);"; - $encrypt[] = Indent::_(6) - . "\$V2czq24pjexf = @socket_get_status(\$Vrpmu4bvnmkp);"; - $encrypt[] = Indent::_(5) . "}"; - $encrypt[] = Indent::_(5) . "@fclose (\$Vqojefyeohg5);"; - $encrypt[] = Indent::_(4) . "}"; - $encrypt[] = Indent::_(3) . "}"; - $encrypt[] = Indent::_(3) . "if (!\$Vqojefyeohg5) {"; - $encrypt[] = Indent::_(4) - . "\$Vbfbwv2y4kre = date(\"Ymd\", mktime(0, 0, 0, date(\"m\"), date(\"d\") - \$Viioj50xuqu2['onthou'], date(\"Y\")));"; - $encrypt[] = Indent::_(4) - . "if (isset(\$V3qqz0p00fbq) && \$V3qqz0p00fbq > \$Vbfbwv2y4kre) {"; - $encrypt[] = Indent::_(5) - . "\$Vwasqoybpyed = \$Vm5cxjdc43g4finding;"; - $encrypt[] = Indent::_(4) . "} else {"; - $encrypt[] = Indent::_(5) . "\$Vwasqoybpyed = array();"; - $encrypt[] = Indent::_(5) - . "\$Vwasqoybpyed['status'] = \"sleg\";"; - $encrypt[] = Indent::_(5) - . "\$Vwasqoybpyed['description'] = \"Remote Check Failed\";"; - $encrypt[] = Indent::_(5) . "return \$Vwasqoybpyed;"; - $encrypt[] = Indent::_(4) . "}"; - $encrypt[] = Indent::_(3) . "} else {"; - $encrypt[] = Indent::_(4) . "preg_match_all('" - . '/<(.*?)>([^<]+)<\/\\1>/i' - . "', \$Vqojefyeohg5, \$V1ot20wob03f);"; - $encrypt[] = Indent::_(4) . "\$Vwasqoybpyed = array();"; - $encrypt[] = Indent::_(4) - . "foreach (\$V1ot20wob03f[1] AS \$V2sgyscukmgi=>\$V1u00zkzmb1d) {"; - $encrypt[] = Indent::_(5) - . "\$Vwasqoybpyed[\$V1u00zkzmb1d] = \$V1ot20wob03f[2][\$V2sgyscukmgi];"; - $encrypt[] = Indent::_(4) . "}"; - $encrypt[] = Indent::_(3) . "}"; - $encrypt[] = Indent::_(3) . "if (!is_array(\$Vwasqoybpyed)) {"; - $encrypt[] = Indent::_(4) - . "die(\"Invalid License Server Response\");"; - $encrypt[] = Indent::_(3) . "}"; - $encrypt[] = Indent::_(3) - . "if (isset(\$Vwasqoybpyed['md5hash']) && \$Vwasqoybpyed['md5hash']) {"; - $encrypt[] = Indent::_(4) - . "if (\$Vwasqoybpyed['md5hash'] != md5(\$Viioj50xuqu2['geheim'] . \$Visqfrd1caus)) {"; - $encrypt[] = Indent::_(5) - . "\$Vwasqoybpyed['status'] = \"sleg\";"; - $encrypt[] = Indent::_(5) - . "\$Vwasqoybpyed['description'] = \"MD5 Checksum Verification Failed\";"; - $encrypt[] = Indent::_(5) . "return \$Vwasqoybpyed;"; - $encrypt[] = Indent::_(4) . "}"; - $encrypt[] = Indent::_(3) . "}"; - $encrypt[] = Indent::_(3) - . "if (isset(\$Vwasqoybpyed['status']) && \$Vwasqoybpyed['status'] == \"Active\") {"; - $encrypt[] = Indent::_(4) - . "\$Vwasqoybpyed['dan'] = \$Vo4tezfgcf3e;"; - $encrypt[] = Indent::_(4) - . "\$Vqojefyeohg5ing = serialize(\$Vwasqoybpyed);"; - $encrypt[] = Indent::_(4) - . "\$Vqojefyeohg5ing = base64_encode(\$Vqojefyeohg5ing);"; - $encrypt[] = Indent::_(4) - . "\$Vqojefyeohg5ing = md5(\$Vo4tezfgcf3e . \$Viioj50xuqu2['geheim']) . \$Vqojefyeohg5ing;"; - $encrypt[] = Indent::_(4) - . "\$Vqojefyeohg5ing = strrev(\$Vqojefyeohg5ing);"; - $encrypt[] = Indent::_(4) - . "\$Vqojefyeohg5ing = \$Vqojefyeohg5ing . md5(\$Vqojefyeohg5ing . \$Viioj50xuqu2['geheim']);"; - $encrypt[] = Indent::_(4) - . "\$Vqojefyeohg5ing = wordwrap(\$Vqojefyeohg5ing, 80, \"" - . '".PHP_EOL."' . "\", true);"; - $encrypt[] = Indent::_(4) - . "\$Vwasqoybpyed['eiegrendel'] = \$Vqojefyeohg5ing;"; - $encrypt[] = Indent::_(3) . "}"; - $encrypt[] = Indent::_(3) . "\$Vwasqoybpyed['nuut'] = true;"; - $encrypt[] = Indent::_(2) . "}"; - $encrypt[] = Indent::_(2) - . "unset(\$V1u0c4dl3ehp,\$Vqojefyeohg5,\$V1ot20wob03f,\$Viioj50xuqu2['kasier'],\$Viioj50xuqu2['geheim'],\$Vo4tezfgcf3e,\$Vozblwvfym2fdie,\$Viioj50xuqu2['onthou'],\$Vbgx0efeu2sy);"; - $encrypt[] = Indent::_(2) . "return \$Vwasqoybpyed;"; - $encrypt[] = Indent::_(1) . "}"; - $encrypt[] = "}"; - - // return the help methods - return implode(PHP_EOL, $encrypt); - } - } - // give notice of this issue - $this->app->enqueueMessage( - JText::_('

WHMCS Error

'), 'Error' - ); - $this->app->enqueueMessage( - JText::_( - 'The WHMCS class could not be added to this component. You will need to enable the add-on in the Joomla Component area (Add WHMCS)->Yes. If you have done this, then please check that you have your own Basic Encryption set in the global settings of JCB. Then open and save this component again, making sure that your WHMCS settings are still correct.' - ), 'Error' - ); - - return "//" . Line::_(__Line__, __Class__) - . " The WHMCS class could not be added to this component." . PHP_EOL - . "//" . Line::_(__Line__, __Class__) - . " Please note that you will need to enable the add-on in the Joomla Component area (Add WHMCS)->Yes."; - } - - /** - * set Get Crypt Key - * - * @return string - */ - public function setGetCryptKey() - { - // WHMCS_ENCRYPT_FILE - CFactory::_('Compiler.Builder.Content.One')->set('WHMCS_ENCRYPT_FILE', ''); - // check if encryption is ative - if (CFactory::_('Compiler.Builder.Model.Basic.Field')->isActive() - || CFactory::_('Compiler.Builder.Model.Medium.Field')->isActive() - || CFactory::_('Compiler.Builder.Model.Whmcs.Field')->isActive() - || CFactory::_('Component')->get('add_license')) - { - if (CFactory::_('Compiler.Builder.Model.Whmcs.Field')->isActive() - || CFactory::_('Component')->get('add_license')) - { - // set whmcs encrypt file into place - $target = array('admin' => 'whmcs'); - $done = CFactory::_('Utilities.Structure')->build($target, 'whmcs'); - // the text for the file WHMCS_ENCRYPTION_BODY - CFactory::_('Compiler.Builder.Content.Multi')->set('whmcs' . '|WHMCS_ENCRYPTION_BODY', $this->setWHMCSCryption()); - // ENCRYPT_FILE - CFactory::_('Compiler.Builder.Content.One')->set('WHMCS_ENCRYPT_FILE', PHP_EOL . Indent::_(3) . "whmcs.php"); - } - // get component name - $component = CFactory::_('Config')->component_code_name; - // set the getCryptKey function to the helper class - $function = array(); - // start building the getCryptKey function/class method - $function[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $function[] = Indent::_(1) . " * Get The Encryption Keys"; - $function[] = Indent::_(1) . " *"; - $function[] = Indent::_(1) - . " * @param string \$type The type of key"; - $function[] = Indent::_(1) - . " * @param string/bool \$default The return value if no key was found"; - $function[] = Indent::_(1) . " *"; - $function[] = Indent::_(1) . " * @return string On success"; - $function[] = Indent::_(1) . " *"; - $function[] = Indent::_(1) . " **/"; - $function[] = Indent::_(1) - . "public static function getCryptKey(\$type, \$default = false)"; - $function[] = Indent::_(1) . "{"; - $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Get the global params"; - $function[] = Indent::_(2) - . "\$params = JComponentHelper::getParams('com_" . $component - . "', true);"; - // add the basic option - if (CFactory::_('Compiler.Builder.Model.Basic.Field')->isActive()) - { - $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Basic Encryption Type"; - $function[] = Indent::_(2) . "if ('basic' === \$type)"; - $function[] = Indent::_(2) . "{"; - $function[] = Indent::_(3) - . "\$basic_key = \$params->get('basic_key', \$default);"; - $function[] = Indent::_(3) - . "if (self::checkString(\$basic_key))"; - $function[] = Indent::_(3) . "{"; - $function[] = Indent::_(4) . "return \$basic_key;"; - $function[] = Indent::_(3) . "}"; - $function[] = Indent::_(2) . "}"; - } - // add the medium option - if (CFactory::_('Compiler.Builder.Model.Medium.Field')->isActive()) - { - $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Medium Encryption Type"; - $function[] = Indent::_(2) . "if ('medium' === \$type)"; - $function[] = Indent::_(2) . "{"; - $function[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " check if medium key is already loaded."; - $function[] = Indent::_(3) - . "if (self::checkString(self::\$mediumCryptKey))"; - $function[] = Indent::_(3) . "{"; - $function[] = Indent::_(4) - . "return (self::\$mediumCryptKey !== 'none') ? trim(self::\$mediumCryptKey) : \$default;"; - $function[] = Indent::_(3) . "}"; - $function[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " get the path to the medium encryption key."; - $function[] = Indent::_(3) - . "\$medium_key_path = \$params->get('medium_key_path', null);"; - $function[] = Indent::_(3) - . "if (self::checkString(\$medium_key_path))"; - $function[] = Indent::_(3) . "{"; - $function[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " load the key from the file."; - $function[] = Indent::_(4) - . "if (self::getMediumCryptKey(\$medium_key_path))"; - $function[] = Indent::_(4) . "{"; - $function[] = Indent::_(5) - . "return trim(self::\$mediumCryptKey);"; - $function[] = Indent::_(4) . "}"; - $function[] = Indent::_(3) . "}"; - $function[] = Indent::_(2) . "}"; - } - // add the whmcs option - if (CFactory::_('Compiler.Builder.Model.Whmcs.Field')->isActive() - || CFactory::_('Component')->get('add_license')) - { - $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " WHMCS Encryption Type"; - $function[] = Indent::_(2) - . "if ('whmcs' === \$type || 'advanced' === \$type)"; - $function[] = Indent::_(2) . "{"; - $function[] = Indent::_(3) - . "\$key = \$params->get('whmcs_key', \$default);"; - $function[] = Indent::_(3) . "if (self::checkString(\$key))"; - $function[] = Indent::_(3) . "{"; - $function[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " load the file"; - $function[] = Indent::_(4) - . "JLoader::import( 'whmcs', JPATH_COMPONENT_ADMINISTRATOR);"; - $function[] = PHP_EOL . Indent::_(4) - . "\$the = new WHMCS(\$key);"; - $function[] = PHP_EOL . Indent::_(4) . "return \$the->_key;"; - $function[] = Indent::_(3) . "}"; - $function[] = Indent::_(2) . "}"; - } - // end the function - $function[] = PHP_EOL . Indent::_(2) . "return \$default;"; - $function[] = Indent::_(1) . "}"; - // set the getMediumCryptKey class/method - if (CFactory::_('Compiler.Builder.Model.Medium.Field')->isActive()) - { - $function[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $function[] = Indent::_(1) . " * The Medium Encryption Key"; - $function[] = Indent::_(1) . " *"; - $function[] = Indent::_(1) . " * @var string/bool"; - $function[] = Indent::_(1) . " **/"; - $function[] = Indent::_(1) - . "protected static \$mediumCryptKey = false;"; - $function[] = PHP_EOL . Indent::_(1) . "/**"; - $function[] = Indent::_(1) - . " * Get The Medium Encryption Key"; - $function[] = Indent::_(1) . " *"; - $function[] = Indent::_(1) - . " * @param string \$path The path to the medium crypt key folder"; - $function[] = Indent::_(1) . " *"; - $function[] = Indent::_(1) - . " * @return string On success"; - $function[] = Indent::_(1) . " *"; - $function[] = Indent::_(1) . " **/"; - $function[] = Indent::_(1) - . "public static function getMediumCryptKey(\$path)"; - $function[] = Indent::_(1) . "{"; - $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Prep the path a little"; - $function[] = Indent::_(2) - . "\$path = '/'. trim(str_replace('//', '/', \$path), '/');"; - $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Check if folder exist"; - $function[] = Indent::_(2) . "if (!Folder::exists(\$path))"; - $function[] = Indent::_(2) . "{"; - $function[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Lock key."; - $function[] = Indent::_(3) . "self::\$mediumCryptKey = 'none';"; - $function[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Set the error message."; - $function[] = Indent::_(3) - . "JFactory::getApplication()->enqueueMessage(JText::_('" - . CFactory::_('Config')->lang_prefix - . "_CONFIG_MEDIUM_KEY_PATH_ERROR'), 'Error');"; - $function[] = Indent::_(3) . "return false;"; - $function[] = Indent::_(2) . "}"; - $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Create FileName and set file path"; - $function[] = Indent::_(2) - . "\$filePath = \$path.'/.'.md5('medium_crypt_key_file');"; - $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Check if we already have the file set"; - $function[] = Indent::_(2) - . "if ((self::\$mediumCryptKey = @file_get_contents(\$filePath)) !== FALSE)"; - $function[] = Indent::_(2) . "{"; - $function[] = Indent::_(3) . "return true;"; - $function[] = Indent::_(2) . "}"; - $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Set the key for the first time"; - $function[] = Indent::_(2) - . "self::\$mediumCryptKey = self::randomkey(128);"; - $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Open the key file"; - $function[] = Indent::_(2) . "\$fh = @fopen(\$filePath, 'w');"; - $function[] = Indent::_(2) . "if (!is_resource(\$fh))"; - $function[] = Indent::_(2) . "{"; - $function[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Lock key."; - $function[] = Indent::_(3) . "self::\$mediumCryptKey = 'none';"; - $function[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Set the error message."; - $function[] = Indent::_(3) - . "JFactory::getApplication()->enqueueMessage(JText::_('" - . CFactory::_('Config')->lang_prefix - . "_CONFIG_MEDIUM_KEY_PATH_ERROR'), 'Error');"; - $function[] = Indent::_(3) . "return false;"; - $function[] = Indent::_(2) . "}"; - $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Write to the key file"; - $function[] = Indent::_(2) - . "if (!fwrite(\$fh, self::\$mediumCryptKey))"; - $function[] = Indent::_(2) . "{"; - $function[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Close key file."; - $function[] = Indent::_(3) . "fclose(\$fh);"; - $function[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Lock key."; - $function[] = Indent::_(3) . "self::\$mediumCryptKey = 'none';"; - $function[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Set the error message."; - $function[] = Indent::_(3) - . "JFactory::getApplication()->enqueueMessage(JText::_('" - . CFactory::_('Config')->lang_prefix - . "_CONFIG_MEDIUM_KEY_PATH_ERROR'), 'Error');"; - $function[] = Indent::_(3) . "return false;"; - $function[] = Indent::_(2) . "}"; - $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Close key file."; - $function[] = Indent::_(2) . "fclose(\$fh);"; - $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Key is set."; - $function[] = Indent::_(2) . "return true;"; - $function[] = Indent::_(1) . "}"; - } - - // return the help methods - return implode(PHP_EOL, $function); - } - - return ''; - } - - /** - * set Version Controller - */ - public function setVersionController() - { - if (CFactory::_('Component')->isArray('version_update') - || CFactory::_('Compiler.Builder.Update.Mysql')->isActive()) - { - $updateXML = array(); - // add the update server - if (CFactory::_('Component')->get('update_server_target', 3) != 3) - { - $updateXML[] = ''; - } - - // add the dynamic sql switch - $addDynamicSQL = true; - $addActive = true; - if (CFactory::_('Component')->isArray('version_update')) - { - $updates = CFactory::_('Component')->get('version_update'); - foreach ($updates as $nr => &$update) - { - $this->setUpdateXMLSQL($update, $updateXML, $addDynamicSQL); - - if ($update['version'] - == CFactory::_('Component')->get('component_version')) - { - $addActive = false; - } - } - CFactory::_('Component')->set('version_update', $updates); - } - // add the dynamic sql if not already added - if ($addDynamicSQL - && CFactory::_('Compiler.Builder.Update.Mysql')->isActive()) - { - // add the dynamic sql - $this->setDynamicUpdateXMLSQL($updateXML); - } - // add the new active version if needed - if ($addActive && CFactory::_('Compiler.Builder.Update.Mysql')->isActive()) - { - // add the dynamic sql - $this->setDynamicUpdateXMLSQL($updateXML, $addActive); - } - // add the update server file - if (CFactory::_('Component')->get('update_server_target', 3) != 3) - { - $updateXML[] = ''; - // UPDATE_SERVER_XML - $name = substr( - (string) CFactory::_('Component')->get('update_server_url'), - strrpos((string) CFactory::_('Component')->get('update_server_url'), '/') - + 1 - ); - $name = explode('.xml', $name)[0]; - $target = array('admin' => $name); - CFactory::_('Utilities.Structure')->build($target, 'update_server'); - CFactory::_('Compiler.Builder.Content.Multi')->set($name . '|UPDATE_SERVER_XML', implode(PHP_EOL, $updateXML)); - - // set the Update server file name - $this->updateServerFileName = $name; - } - } - // add the update server link to component XML - if (CFactory::_('Component')->get('add_update_server') - && CFactory::_('Component')->isString('update_server_url')) - { - // UPDATESERVER - $updateServer = array(); - $updateServer[] = PHP_EOL . Indent::_(1) . ""; - $updateServer[] = Indent::_(2) - . '' . CFactory::_('Component')->get('update_server_url') - . ''; - $updateServer[] = Indent::_(1) . ''; - // return the array to string - $updateServer = implode(PHP_EOL, $updateServer); - // add update server details to component XML file - CFactory::_('Compiler.Builder.Content.One')->set('UPDATESERVER', $updateServer); - } - else - { - // add update server details to component XML file - CFactory::_('Compiler.Builder.Content.One')->set('UPDATESERVER', ''); - } - // ensure to update Component version data - if (CFactory::_('Compiler.Builder.Update.Mysql')->isActive()) - { - $buket = array(); - $nr = 0; - foreach (CFactory::_('Component')->get('version_update') as $values) - { - $buket['version_update' . $nr] = $values; - $nr++; - } - // update the joomla component table - $newJ = array(); - $newJ['id'] = (int) CFactory::_('Config')->component_id; - $newJ['component_version'] - = CFactory::_('Component')->get('component_version'); - // update the component with the new dynamic SQL - $modelJ = ComponentbuilderHelper::getModel('joomla_component'); - $modelJ->save($newJ); // <-- to insure the history is also updated - // reset the watch here - CFactory::_('History')->get('joomla_component', CFactory::_('Config')->component_id); - - // update the component update table - $newU = array(); - if (CFactory::_('Component')->get('version_update_id', 0) > 0) - { - $newU['id'] = (int) CFactory::_('Component')->get('version_update_id', 0); - } - else - { - $newU['joomla_component'] = (int) CFactory::_('Config')->component_id; - } - $newU['version_update'] = json_encode($buket); - // update the component with the new dynamic SQL - $modelU = ComponentbuilderHelper::getModel('component_updates'); - $modelU->save($newU); // <-- to insure the history is also updated - } - } - - /** - * set Dynamic Update XML SQL - * - * @param array $updateXML - * @param bool $current_version - */ - public function setDynamicUpdateXMLSQL(&$updateXML, $current_version = false - ) - { - // start building the update - $update_ = array(); - if ($current_version) - { - // setup new version - $update_['version'] = CFactory::_('Component')->get('component_version'); - // setup SQL - $update_['mysql'] = ''; - // setup URL - $update_['url'] = 'http://domain.com/demo.zip'; - } - else - { - // setup new version - $update_['version'] = CFactory::_('Component')->get('old_component_version'); - // setup SQL - $update_['mysql'] = trim( - implode(PHP_EOL . PHP_EOL, CFactory::_('Compiler.Builder.Update.Mysql')->allActive()) - ); - // setup URL - if (isset($this->lastupdateURL)) - { - $paceholders = array( - CFactory::_('Component')->get('component_version') => CFactory::_('Component')->get('old_component_version'), - str_replace( - '.', '-', (string) CFactory::_('Component')->get('component_version') - ) => str_replace( - '.', '-', (string) CFactory::_('Component')->get('old_component_version') - ), - str_replace( - '.', '_', (string) CFactory::_('Component')->get('component_version') - ) => str_replace( - '.', '_', (string) CFactory::_('Component')->get('old_component_version') - ), - str_replace( - '.', '', (string) CFactory::_('Component')->get('component_version') - ) => str_replace( - '.', '', (string) CFactory::_('Component')->get('old_component_version') - ) - ); - $update_['url'] = CFactory::_('Placeholder')->update( - $this->lastupdateURL, $paceholders - ); - } - else - { - // setup URL - $update_['url'] = 'http://domain.com/demo.zip'; - } - } - // stop it from being added double - $addDynamicSQL = false; - // add dynamic SQL - $this->setUpdateXMLSQL($update_, $updateXML, $addDynamicSQL); - - CFactory::_('Component')->appendArray('version_update', $update_); - } - - /** - * set Update XML SQL - * - * @param array $update - * @param array $updateXML - * @param boolean $addDynamicSQL - */ - public function setUpdateXMLSQL(&$update, &$updateXML, &$addDynamicSQL) - { - // ensure version naming is correct - $update['version'] = preg_replace('/[^0-9\.]+/', '', (string) $update['version']); - // setup SQL - if (StringHelper::check($update['mysql'])) - { - $update['mysql'] = CFactory::_('Placeholder')->update_( - $update['mysql'] - ); - } - // add dynamic SQL - $force = false; - if ($addDynamicSQL - && CFactory::_('Compiler.Builder.Update.Mysql')->isActive() - && CFactory::_('Component')->get('old_component_version') == $update['version']) - { - $searchMySQL = preg_replace('/\s+/', '', (string) $update['mysql']); - // add the updates to the SQL only if not found - foreach (CFactory::_('Compiler.Builder.Update.Mysql')->allActive() as $search => $query) - { - if (strpos($searchMySQL, $search) === false) - { - $update['mysql'] .= PHP_EOL . PHP_EOL . $query; - } - } - // make sure no unneeded white space is added - $update['mysql'] = trim((string) $update['mysql']); - // update has been added - $addDynamicSQL = false; - } - // setup import files - if ($update['version'] != CFactory::_('Component')->get('component_version')) - { - $name = StringHelper::safe($update['version']); - $target = array('admin' => $name); - CFactory::_('Utilities.Structure')->build($target, 'sql_update', $update['version']); - $_name = preg_replace('/[\.]+/', '_', (string) $update['version']); - CFactory::_('Compiler.Builder.Content.Multi')->set($name . '_' . $_name . '|UPDATE_VERSION_MYSQL', - $update['mysql'] - ); - } - elseif (isset($update['url']) - && StringHelper::check( - $update['url'] - )) - { - $this->lastupdateURL = $update['url']; - } - // add the update server - if (CFactory::_('Component')->get('add_update_server', 3) != 3) - { - // we set the defaults - $u_element = 'com_' . CFactory::_('Config')->component_code_name; - $u_server_type = 'component'; - $u_state = 'stable'; - $u_target_version = '3.*'; - $u_client = null; - // check if we have advance options set - if (isset($update['update_server_adv']) && $update['update_server_adv']) - { - $u_element = (isset($update['update_element']) && strlen((string) $update['update_element']) > 0) - ? $update['update_element'] : $u_element; - $u_server_type = (isset($update['update_server_type']) && strlen((string) $update['update_server_type']) > 0) - ? $update['update_server_type'] : $u_server_type; - $u_state = (isset($update['update_state']) && strlen((string) $update['update_state']) > 0) - ? $update['update_state'] : $u_state; - $u_target_version = (isset($update['update_target_version']) && strlen((string) $update['update_target_version']) > 0) - ? $update['update_target_version'] : $u_target_version; - $u_client = (isset($update['update_client']) && strlen((string) $update['update_client']) > 0) - ? $update['update_client'] : $u_client; - } - // build update xml - $updateXML[] = Indent::_(1) . ""; - $updateXML[] = Indent::_(2) . "" - . CFactory::_('Compiler.Builder.Content.One')->get('Component_name') . ""; - $updateXML[] = Indent::_(2) . "" - . CFactory::_('Compiler.Builder.Content.One')->get('SHORT_DESCRIPTION') . ""; - $updateXML[] = Indent::_(2) . "$u_element"; - $updateXML[] = Indent::_(2) . "$u_server_type"; - // check if we should add the target client value - if ($u_client) - { - $updateXML[] = Indent::_(2) . "$u_client"; - } - $updateXML[] = Indent::_(2) . "" . $update['version'] - . ""; - $updateXML[] = Indent::_(2) . '' . CFactory::_('Compiler.Builder.Content.One')->get('AUTHORWEBSITE') . ''; - $updateXML[] = Indent::_(2) . ""; - if (!isset($update['url']) - || !StringHelper::check( - $update['url'] - )) - { - $update['url'] = 'http://domain.com/demo.zip'; - } - $updateXML[] = Indent::_(3) - . '' . $update['url'] - . ''; - $updateXML[] = Indent::_(2) . ""; - $updateXML[] = Indent::_(2) . ""; - $updateXML[] = Indent::_(3) . "$u_state"; - $updateXML[] = Indent::_(2) . ""; - $updateXML[] = Indent::_(2) . "" - . CFactory::_('Compiler.Builder.Content.One')->get('AUTHOR') - . ""; - $updateXML[] = Indent::_(2) . "" - . CFactory::_('Compiler.Builder.Content.One')->get('AUTHORWEBSITE') . ""; - $updateXML[] = Indent::_(2) - . ''; - $updateXML[] = Indent::_(1) . ""; - } - } - - /** - * no Help - * - * @return string - */ - public function noHelp() - { - $help = array(); - $help[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $help[] = Indent::_(1) . " * Can be used to build help urls."; - $help[] = Indent::_(1) . " **/"; - $help[] = Indent::_(1) . "public static function getHelpUrl(\$view)"; - $help[] = Indent::_(1) . "{"; - $help[] = Indent::_(2) . "return false;"; - $help[] = Indent::_(1) . "}"; - - // return the no help method - return implode(PHP_EOL, $help); - } - - public function checkHelp($nameSingleCode) - { - if ($nameSingleCode == "help_document") - { - // set help file into admin place - $target = array('admin' => 'help'); - $admindone = CFactory::_('Utilities.Structure')->build($target, 'help'); - // set the help file into site place - $target = array('site' => 'help'); - $sitedone = CFactory::_('Utilities.Structure')->build($target, 'help'); - if ($admindone && $sitedone) - { - // HELP - CFactory::_('Compiler.Builder.Content.One')->set('HELP', $this->setHelp(1)); - // HELP_SITE - CFactory::_('Compiler.Builder.Content.One')->set('HELP_SITE', $this->setHelp(2)); - // to make sure the file is updated TODO - CFactory::_('Compiler.Builder.Content.Multi')->set('help' . '|BLABLA', 'blabla'); - - return true; - } - } - - return false; - } - - public function setHelp($location) - { - // set hte help function to the helper class - $target = 'admin_view'; - if ($location == 2) - { - $target = 'site_view'; - } - $help = array(); - $help[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $help[] = Indent::_(1) . " * Load the Component Help URLs."; - $help[] = Indent::_(1) . " **/"; - $help[] = Indent::_(1) . "public static function getHelpUrl(\$view)"; - $help[] = Indent::_(1) . "{"; - $help[] = Indent::_(2) . "\$user = JFactory::getUser();"; - $help[] = Indent::_(2) . "\$groups = \$user->get('groups');"; - $help[] = Indent::_(2) . "\$db = JFactory::getDbo();"; - $help[] = Indent::_(2) . "\$query = \$db->getQuery(true);"; - $help[] = Indent::_(2) - . "\$query->select(array('a.id','a.groups','a.target','a.type','a.article','a.url'));"; - $help[] = Indent::_(2) . "\$query->from('#__" . CFactory::_('Config')->component_code_name - . "_help_document AS a');"; - $help[] = Indent::_(2) . "\$query->where('a." . $target - . " = '.\$db->quote(\$view));"; - $help[] = Indent::_(2) . "\$query->where('a.location = " - . (int) $location . "');"; - $help[] = Indent::_(2) . "\$query->where('a.published = 1');"; - $help[] = Indent::_(2) . "\$db->setQuery(\$query);"; - $help[] = Indent::_(2) . "\$db->execute();"; - $help[] = Indent::_(2) . "if(\$db->getNumRows())"; - $help[] = Indent::_(2) . "{"; - $help[] = Indent::_(3) . "\$helps = \$db->loadObjectList();"; - $help[] = Indent::_(3) . "if (self::checkArray(\$helps))"; - $help[] = Indent::_(3) . "{"; - $help[] = Indent::_(4) . "foreach (\$helps as \$nr => \$help)"; - $help[] = Indent::_(4) . "{"; - $help[] = Indent::_(5) . "if (\$help->target == 1)"; - $help[] = Indent::_(5) . "{"; - $help[] = Indent::_(6) - . "\$targetgroups = json_decode(\$help->groups, true);"; - $help[] = Indent::_(6) - . "if (!array_intersect(\$targetgroups, \$groups))"; - $help[] = Indent::_(6) . "{"; - $help[] = Indent::_(7) . "//" . Line::_(__Line__, __Class__) - . " if user not in those target groups then remove the item"; - $help[] = Indent::_(7) . "unset(\$helps[\$nr]);"; - $help[] = Indent::_(7) . "continue;"; - $help[] = Indent::_(6) . "}"; - $help[] = Indent::_(5) . "}"; - $help[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) - . " set the return type"; - $help[] = Indent::_(5) . "switch (\$help->type)"; - $help[] = Indent::_(5) . "{"; - $help[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__) - . " set joomla article"; - $help[] = Indent::_(6) . "case 1:"; - $help[] = Indent::_(7) - . "return self::loadArticleLink(\$help->article);"; - $help[] = Indent::_(7) . "break;"; - $help[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__) - . " set help text"; - $help[] = Indent::_(6) . "case 2:"; - $help[] = Indent::_(7) . "return self::loadHelpTextLink(\$help->id);"; - $help[] = Indent::_(7) . "break;"; - $help[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__) . " set Link"; - $help[] = Indent::_(6) . "case 3:"; - $help[] = Indent::_(7) . "return \$help->url;"; - $help[] = Indent::_(7) . "break;"; - $help[] = Indent::_(5) . "}"; - $help[] = Indent::_(4) . "}"; - $help[] = Indent::_(3) . "}"; - $help[] = Indent::_(2) . "}"; - $help[] = Indent::_(2) . "return false;"; - $help[] = Indent::_(1) . "}"; - $help[] = PHP_EOL . Indent::_(1) . "/**"; - $help[] = Indent::_(1) . " * Get the Article Link."; - $help[] = Indent::_(1) . " **/"; - $help[] = Indent::_(1) - . "protected static function loadArticleLink(\$id)"; - $help[] = Indent::_(1) . "{"; - $help[] = Indent::_(2) - . "return JURI::root().'index.php?option=com_content&view=article&id='.\$id.'&tmpl=component&layout=modal';"; - $help[] = Indent::_(1) . "}"; - $help[] = PHP_EOL . Indent::_(1) . "/**"; - $help[] = Indent::_(1) . " * Get the Help Text Link."; - $help[] = Indent::_(1) . " **/"; - $help[] = Indent::_(1) - . "protected static function loadHelpTextLink(\$id)"; - $help[] = Indent::_(1) . "{"; - $help[] = Indent::_(2) . "\$token = JSession::getFormToken();"; - $help[] = Indent::_(2) . "return 'index.php?option=com_" - . CFactory::_('Config')->component_code_name - . "&task=help.getText&id=' . (int) \$id . '&token=' . \$token;"; - $help[] = Indent::_(1) . "}"; - - // return the help methods - return implode(PHP_EOL, $help); - } - - public function setHelperExelMethods() - { - if (CFactory::_('Config')->get('add_eximport', false)) - { - // we use the company name set in the GUI - $company_name = CFactory::_('Compiler.Builder.Content.One')->get('COMPANYNAME'); - // start building the xml function - $exel = array(); - $exel[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $exel[] = Indent::_(1) . "* Prepares the xml document"; - $exel[] = Indent::_(1) . "*/"; - $exel[] = Indent::_(1) - . "public static function xls(\$rows, \$fileName = null, \$title = null, \$subjectTab = null, \$creator = '$company_name', \$description = null, \$category = null,\$keywords = null, \$modified = null)"; - $exel[] = Indent::_(1) . "{"; - $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " set the user"; - $exel[] = Indent::_(2) . "\$user = JFactory::getUser();"; - $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " set fileName if not set"; - $exel[] = Indent::_(2) . "if (!\$fileName)"; - $exel[] = Indent::_(2) . "{"; - $exel[] = Indent::_(3) - . "\$fileName = 'exported_'.JFactory::getDate()->format('jS_F_Y');"; - $exel[] = Indent::_(2) . "}"; - $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " set modified if not set"; - $exel[] = Indent::_(2) . "if (!\$modified)"; - $exel[] = Indent::_(2) . "{"; - $exel[] = Indent::_(3) . "\$modified = \$user->name;"; - $exel[] = Indent::_(2) . "}"; - $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " set title if not set"; - $exel[] = Indent::_(2) . "if (!\$title)"; - $exel[] = Indent::_(2) . "{"; - $exel[] = Indent::_(3) . "\$title = 'Book1';"; - $exel[] = Indent::_(2) . "}"; - $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " set tab name if not set"; - $exel[] = Indent::_(2) . "if (!\$subjectTab)"; - $exel[] = Indent::_(2) . "{"; - $exel[] = Indent::_(3) . "\$subjectTab = 'Sheet1';"; - $exel[] = Indent::_(2) . "}"; - $exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " make sure we have the composer classes loaded"; - $exel[] = Indent::_(2) - . "self::composerAutoload('phpspreadsheet');"; - $exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Create new Spreadsheet object"; - $exel[] = Indent::_(2) . "\$spreadsheet = new Spreadsheet();"; - $exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Set document properties"; - $exel[] = Indent::_(2) . "\$spreadsheet->getProperties()"; - $exel[] = Indent::_(3) . "->setCreator(\$creator)"; - $exel[] = Indent::_(3) . "->setCompany('$company_name')"; - $exel[] = Indent::_(3) . "->setLastModifiedBy(\$modified)"; - $exel[] = Indent::_(3) . "->setTitle(\$title)"; - $exel[] = Indent::_(3) . "->setSubject(\$subjectTab);"; - $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " The file type"; - $exel[] = Indent::_(2) . "\$file_type = 'Xls';"; - $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " set description"; - $exel[] = Indent::_(2) . "if (\$description)"; - $exel[] = Indent::_(2) . "{"; - $exel[] = Indent::_(3) - . "\$spreadsheet->getProperties()->setDescription(\$description);"; - $exel[] = Indent::_(2) . "}"; - $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " set keywords"; - $exel[] = Indent::_(2) . "if (\$keywords)"; - $exel[] = Indent::_(2) . "{"; - $exel[] = Indent::_(3) - . "\$spreadsheet->getProperties()->setKeywords(\$keywords);"; - $exel[] = Indent::_(2) . "}"; - $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " set category"; - $exel[] = Indent::_(2) . "if (\$category)"; - $exel[] = Indent::_(2) . "{"; - $exel[] = Indent::_(3) - . "\$spreadsheet->getProperties()->setCategory(\$category);"; - $exel[] = Indent::_(2) . "}"; - $exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Some styles"; - $exel[] = Indent::_(2) . "\$headerStyles = array("; - $exel[] = Indent::_(3) . "'font' => array("; - $exel[] = Indent::_(4) . "'bold' => true,"; - $exel[] = Indent::_(4) . "'color' => array('rgb' => '1171A3'),"; - $exel[] = Indent::_(4) . "'size' => 12,"; - $exel[] = Indent::_(4) . "'name' => 'Verdana'"; - $exel[] = Indent::_(2) . "));"; - $exel[] = Indent::_(2) . "\$sideStyles = array("; - $exel[] = Indent::_(3) . "'font' => array("; - $exel[] = Indent::_(4) . "'bold' => true,"; - $exel[] = Indent::_(4) . "'color' => array('rgb' => '444444'),"; - $exel[] = Indent::_(4) . "'size' => 11,"; - $exel[] = Indent::_(4) . "'name' => 'Verdana'"; - $exel[] = Indent::_(2) . "));"; - $exel[] = Indent::_(2) . "\$normalStyles = array("; - $exel[] = Indent::_(3) . "'font' => array("; - $exel[] = Indent::_(4) . "'color' => array('rgb' => '444444'),"; - $exel[] = Indent::_(4) . "'size' => 11,"; - $exel[] = Indent::_(4) . "'name' => 'Verdana'"; - $exel[] = Indent::_(2) . "));"; - $exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Add some data"; - $exel[] = Indent::_(2) - . "if ((\$size = self::checkArray(\$rows)) !== false)"; - $exel[] = Indent::_(2) . "{"; - $exel[] = Indent::_(3) . "\$i = 1;"; - $exel[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Based on data size we adapt the behaviour."; - $exel[] = Indent::_(3) . "\$xls_mode = 1;"; - $exel[] = Indent::_(3) . "if (\$size > 3000)"; - $exel[] = Indent::_(3) . "{"; - $exel[] = Indent::_(4) . "\$xls_mode = 3;"; - $exel[] = Indent::_(4) . "\$file_type = 'Csv';"; - $exel[] = Indent::_(3) . "}"; - $exel[] = Indent::_(3) . "elseif (\$size > 2000)"; - $exel[] = Indent::_(3) . "{"; - $exel[] = Indent::_(4) . "\$xls_mode = 2;"; - $exel[] = Indent::_(3) . "}"; - $exel[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Set active sheet and get it."; - $exel[] = Indent::_(3) - . "\$active_sheet = \$spreadsheet->setActiveSheetIndex(0);"; - $exel[] = Indent::_(3) . "foreach (\$rows as \$array)"; - $exel[] = Indent::_(3) . "{"; - $exel[] = Indent::_(4) . "\$a = 'A';"; - $exel[] = Indent::_(4) . "foreach (\$array as \$value)"; - $exel[] = Indent::_(4) . "{"; - $exel[] = Indent::_(5) - . "\$active_sheet->setCellValue(\$a.\$i, \$value);"; - $exel[] = Indent::_(5) . "if (\$xls_mode != 3)"; - $exel[] = Indent::_(5) . "{"; - $exel[] = Indent::_(6) . "if (\$i == 1)"; - $exel[] = Indent::_(6) . "{"; - $exel[] = Indent::_(7) - . "\$active_sheet->getColumnDimension(\$a)->setAutoSize(true);"; - $exel[] = Indent::_(7) - . "\$active_sheet->getStyle(\$a.\$i)->applyFromArray(\$headerStyles);"; - $exel[] = Indent::_(7) - . "\$active_sheet->getStyle(\$a.\$i)->getAlignment()->setHorizontal(PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);"; - $exel[] = Indent::_(6) . "}"; - $exel[] = Indent::_(6) . "elseif (\$a === 'A')"; - $exel[] = Indent::_(6) . "{"; - $exel[] = Indent::_(7) - . "\$active_sheet->getStyle(\$a.\$i)->applyFromArray(\$sideStyles);"; - $exel[] = Indent::_(6) . "}"; - $exel[] = Indent::_(6) . "elseif (\$xls_mode == 1)"; - $exel[] = Indent::_(6) . "{"; - $exel[] = Indent::_(7) - . "\$active_sheet->getStyle(\$a.\$i)->applyFromArray(\$normalStyles);"; - $exel[] = Indent::_(6) . "}"; - $exel[] = Indent::_(5) . "}"; - $exel[] = Indent::_(5) . "\$a++;"; - $exel[] = Indent::_(4) . "}"; - $exel[] = Indent::_(4) . "\$i++;"; - $exel[] = Indent::_(3) . "}"; - $exel[] = Indent::_(2) . "}"; - $exel[] = Indent::_(2) . "else"; - $exel[] = Indent::_(2) . "{"; - $exel[] = Indent::_(3) . "return false;"; - $exel[] = Indent::_(2) . "}"; - $exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Rename worksheet"; - $exel[] = Indent::_(2) - . "\$spreadsheet->getActiveSheet()->setTitle(\$subjectTab);"; - $exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Set active sheet index to the first sheet, so Excel opens this as the first sheet"; - $exel[] = Indent::_(2) . "\$spreadsheet->setActiveSheetIndex(0);"; - $exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Redirect output to a client's web browser (Excel5)"; - $exel[] = Indent::_(2) - . "header('Content-Type: application/vnd.ms-excel');"; - $exel[] = Indent::_(2) - . "header('Content-Disposition: attachment;filename=\"' . \$fileName . '.' . strtolower(\$file_type) .'\"');"; - $exel[] = Indent::_(2) . "header('Cache-Control: max-age=0');"; - $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " If you're serving to IE 9, then the following may be needed"; - $exel[] = Indent::_(2) . "header('Cache-Control: max-age=1');"; - $exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " If you're serving to IE over SSL, then the following may be needed"; - $exel[] = Indent::_(2) - . "header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); //" - . Line::_(__Line__, __Class__) . " Date in the past"; - $exel[] = Indent::_(2) - . "header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); //" - . Line::_(__Line__, __Class__) . " always modified"; - $exel[] = Indent::_(2) - . "header ('Cache-Control: cache, must-revalidate'); //" - . Line::_(__Line__, __Class__) . " HTTP/1.1"; - $exel[] = Indent::_(2) . "header ('Pragma: public'); //" - . Line::_(__Line__, __Class__) . " HTTP/1.0"; - $exel[] = PHP_EOL . Indent::_(2) - . "\$writer = IOFactory::createWriter(\$spreadsheet, \$file_type);"; - $exel[] = Indent::_(2) . "\$writer->save('php://output');"; - $exel[] = Indent::_(2) . "jexit();"; - $exel[] = Indent::_(1) . "}"; - $exel[] = PHP_EOL . Indent::_(1) . "/**"; - $exel[] = Indent::_(1) . "* Get CSV Headers"; - $exel[] = Indent::_(1) . "*/"; - $exel[] = Indent::_(1) - . "public static function getFileHeaders(\$dataType)"; - $exel[] = Indent::_(1) . "{"; - $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " make sure we have the composer classes loaded"; - $exel[] = Indent::_(2) - . "self::composerAutoload('phpspreadsheet');"; - $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " get session object"; - $exel[] = Indent::_(2) . "\$session = JFactory::getSession();"; - $exel[] = Indent::_(2) - . "\$package = \$session->get('package', null);"; - $exel[] = Indent::_(2) - . "\$package = json_decode(\$package, true);"; - $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " set the headers"; - $exel[] = Indent::_(2) . "if(isset(\$package['dir']))"; - $exel[] = Indent::_(2) . "{"; - $exel[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " only load first three rows"; - $exel[] = Indent::_(3) - . "\$chunkFilter = new PhpOffice\PhpSpreadsheet\Reader\chunkReadFilter(2,1);"; - $exel[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " identify the file type"; - $exel[] = Indent::_(3) - . "\$inputFileType = IOFactory::identify(\$package['dir']);"; - $exel[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " create the reader for this file type"; - $exel[] = Indent::_(3) - . "\$excelReader = IOFactory::createReader(\$inputFileType);"; - $exel[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " load the limiting filter"; - $exel[] = Indent::_(3) - . "\$excelReader->setReadFilter(\$chunkFilter);"; - $exel[] = Indent::_(3) . "\$excelReader->setReadDataOnly(true);"; - $exel[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " load the rows (only first three)"; - $exel[] = Indent::_(3) - . "\$excelObj = \$excelReader->load(\$package['dir']);"; - $exel[] = Indent::_(3) . "\$headers = array();"; - $exel[] = Indent::_(3) - . "foreach (\$excelObj->getActiveSheet()->getRowIterator() as \$row)"; - $exel[] = Indent::_(3) . "{"; - $exel[] = Indent::_(4) . "if(\$row->getRowIndex() == 1)"; - $exel[] = Indent::_(4) . "{"; - $exel[] = Indent::_(5) - . "\$cellIterator = \$row->getCellIterator();"; - $exel[] = Indent::_(5) - . "\$cellIterator->setIterateOnlyExistingCells(false);"; - $exel[] = Indent::_(5) . "foreach (\$cellIterator as \$cell)"; - $exel[] = Indent::_(5) . "{"; - $exel[] = Indent::_(6) . "if (!is_null(\$cell))"; - $exel[] = Indent::_(6) . "{"; - $exel[] = Indent::_(7) - . "\$headers[\$cell->getColumn()] = \$cell->getValue();"; - $exel[] = Indent::_(6) . "}"; - $exel[] = Indent::_(5) . "}"; - $exel[] = Indent::_(5) . "\$excelObj->disconnectWorksheets();"; - $exel[] = Indent::_(5) . "unset(\$excelObj);"; - $exel[] = Indent::_(5) . "break;"; - $exel[] = Indent::_(4) . "}"; - $exel[] = Indent::_(3) . "}"; - $exel[] = Indent::_(3) . "return \$headers;"; - $exel[] = Indent::_(2) . "}"; - $exel[] = Indent::_(2) . "return false;"; - $exel[] = Indent::_(1) . "}"; - $exel[] = PHP_EOL . Indent::_(1) . "/**"; - $exel[] = Indent::_(1) - . "* Load the Composer Vendor phpspreadsheet"; - $exel[] = Indent::_(1) . "*/"; - $exel[] = Indent::_(1) - . "protected static function composephpspreadsheet()"; - $exel[] = Indent::_(1) . "{"; - $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " load the autoloader for phpspreadsheet"; - $exel[] = Indent::_(2) - . "require_once JPATH_SITE . '/libraries/phpspreadsheet/vendor/autoload.php';"; - $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " do not load again"; - $exel[] = Indent::_(2) - . "self::\$composer['phpspreadsheet'] = true;"; - $exel[] = PHP_EOL . Indent::_(2) . "return true;"; - $exel[] = Indent::_(1) . "}"; - - // return the help methods - return implode(PHP_EOL, $exel); - } - - return ''; - } - - public function setCreateUserHelperMethod($add) - { - if ($add) - { - $method = array(); - $method[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $method[] = Indent::_(1) . " * Greate user and update given table"; - $method[] = Indent::_(1) . " *"; - $method[] = Indent::_(1) - . " * @param array \$credentials Array('name' => string, 'username' => string, 'email' => string, 'password' => string, 'password2' => string)"; - $method[] = Indent::_(1) . " * @param int \$autologin"; - $method[] = Indent::_(1) - . " * @param array \$params Array('useractivation' => int, 'sendpassword' => int, 'allowUserRegistration' => int)"; - $method[] = Indent::_(1) - . " * @param array \$mode 1 = Site Registrations; 0 = Admin Registration; 2 = Custom Helper Method Called registerUser"; - $method[] = Indent::_(1) . " *"; - $method[] = Indent::_(1) - . " * @return int|Error User ID on success, or an error."; - $method[] = Indent::_(1) . " */"; - $method[] = Indent::_(1) - . "public static function createUser(\$credentials, \$autologin = 0,"; - $method[] = Indent::_(2) . "\$params = array("; - $method[] = Indent::_(3) - . "'useractivation' => 0, 'sendpassword' => 1"; - $method[] = Indent::_(2) . "), \$mode = 1"; - $method[] = Indent::_(1) . ")"; - $method[] = Indent::_(1) . "{"; - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Override mode"; - $method[] = Indent::_(2) - . "if (\$mode == 2 && method_exists(__CLASS__, 'registerUser'))"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Update params"; - $method[] = Indent::_(3) . "\$params['autologin'] = \$autologin;"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Now Register User"; - $method[] = Indent::_(3) - . "return self::registerUser(\$credentials, \$params);"; - $method[] = Indent::_(2) . "}"; - $method[] = Indent::_(2) . "elseif (\$mode == 2)"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Fallback to Site Registrations"; - $method[] = Indent::_(3) . "\$mode = 1;"; - $method[] = Indent::_(2) . "}"; - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " load the user component language files if there is an error."; - $method[] = Indent::_(2) . "\$lang = JFactory::getLanguage();"; - $method[] = Indent::_(2) . "\$extension = 'com_users';"; - $method[] = Indent::_(2) . "\$base_dir = JPATH_SITE;"; - $method[] = Indent::_(2) . "\$language_tag = '" . CFactory::_('Config')->get('lang_tag', 'en-GB') - . "';"; - $method[] = Indent::_(2) . "\$reload = true;"; - $method[] = Indent::_(2) - . "\$lang->load(\$extension, \$base_dir, \$language_tag, \$reload);"; - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Load the correct user model."; - $method[] = Indent::_(2) . "if (\$mode == 1) //" . Line::_( - __LINE__,__CLASS__ - ) - . " 1 = Site Registrations"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Load the user site-registration model"; - $method[] = Indent::_(3) - . "\$model = self::getModel('registration', \$base_dir . '/components/' . \$extension, 'Users');"; - $method[] = Indent::_(2) . "}"; - $method[] = Indent::_(2) . "else //" . Line::_(__Line__, __Class__) - . " 0 = Admin Registration"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Load the backend-user model"; - $method[] = Indent::_(3) - . "\$model = self::getModel('user', JPATH_ADMINISTRATOR . '/components/' . \$extension, 'Users');"; - $method[] = Indent::_(2) . "}"; - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Check if we have params/config"; - $method[] = Indent::_(2) . "if (self::checkArray(\$params))"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Make changes to user config"; - $method[] = Indent::_(3) - . "foreach (\$params as \$param => \$set)"; - $method[] = Indent::_(3) . "{"; - $method[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " If you know of a better path, let me know"; - $method[] = Indent::_(4) - . "\$params[\$param] = self::setParams(\$extension, \$param, \$set);"; - $method[] = Indent::_(3) . "}"; - $method[] = Indent::_(2) . "}"; - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Set username to email if not set"; - $method[] = Indent::_(2) - . "if (!isset(\$credentials['username']) || !self::checkString(\$credentials['username']))"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) - . "\$credentials['username'] = \$credentials['email'];"; - $method[] = Indent::_(2) . "}"; - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Lineup new user data array"; - $method[] = Indent::_(2) . "\$data = array("; - $method[] = Indent::_(3) - . "'username' => \$credentials['username'],"; - $method[] = Indent::_(3) . "'name' => \$credentials['name'],"; - $method[] = Indent::_(3) . "'block' => 0 );"; - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Added details based on mode"; - $method[] = Indent::_(2) . "if (\$mode == 1) //" . Line::_( - __LINE__,__CLASS__ - ) - . " 1 = Site-registration mode"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) - . "\$data['email1'] = \$credentials['email'];"; - $method[] = Indent::_(2) . "}"; - $method[] = Indent::_(2) . "else //" . Line::_(__Line__, __Class__) - . " 0 = Admin-registration mode"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) - . "\$data['email'] = \$credentials['email'];"; - $method[] = Indent::_(3) - . "\$data['registerDate'] = JFactory::getDate()->toSql();"; - $method[] = Indent::_(2) . "}"; - - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Check if password was set"; - $method[] = Indent::_(2) - . "if (\$mode == 1 && (!isset(\$credentials['password']) || !isset(\$credentials['password2']) || !self::checkString(\$credentials['password']) || !self::checkString(\$credentials['password2'])))"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Set random password when empty password was submitted,"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " when using the 1 = site-registration mode"; - $method[] = Indent::_(3) - . "\$credentials['password'] = self::randomkey(8);"; - $method[] = Indent::_(3) - . "\$credentials['password2'] = \$credentials['password'];"; - $method[] = Indent::_(2) . "}"; - - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Now Add password if set"; - $method[] = Indent::_(2) - . "if (isset(\$credentials['password']) && isset(\$credentials['password2']) && self::checkString(\$credentials['password']) && self::checkString(\$credentials['password2']))"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) . "if (\$mode == 1) //" . Line::_( - __LINE__,__CLASS__ - ) - . " 1 = Site-registration mode"; - $method[] = Indent::_(3) . "{"; - $method[] = Indent::_(4) - . "\$data['password1'] = \$credentials['password'];"; - $method[] = Indent::_(3) . "}"; - $method[] = Indent::_(3) . "else //" . Line::_(__Line__, __Class__) - . " 0 = Admin-registration mode"; - $method[] = Indent::_(3) . "{"; - $method[] = Indent::_(4) - . "\$data['password'] = \$credentials['password'];"; - $method[] = Indent::_(3) . "}"; - $method[] = Indent::_(3) - . "\$data['password2'] = \$credentials['password2'];"; - $method[] = Indent::_(2) . "}"; - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Load the group/s value if set, only for Admin Registration (\$mode == 0)"; - $method[] = Indent::_(2) - . "if (\$mode == 0 && isset(\$credentials['groups']) && self::checkArray(\$credentials['groups']))"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) - . "\$data['groups'] = \$credentials['groups'];"; - $method[] = Indent::_(2) . "}"; - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Create the new user"; - $method[] = Indent::_(2) . "if (\$mode == 1) //" . Line::_( - __LINE__,__CLASS__ - ) - . " 1 = Site-registration mode"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) . "\$userId = \$model->register(\$data);"; - $method[] = Indent::_(2) . "}"; - $method[] = Indent::_(2) . "else //" . Line::_(__Line__, __Class__) - . " 0 = Admin-registration mode"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) . "\$model->save(\$data);"; - $method[] = Indent::_(3) - . "\$userId = \$model->getState('user.id', 0);"; - $method[] = Indent::_(2) . "}"; - - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Check if we have params"; - $method[] = Indent::_(2) . "if (self::checkArray(\$params))"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Change user params/config back"; - $method[] = Indent::_(3) - . "foreach (\$params as \$param => \$set)"; - $method[] = Indent::_(3) . "{"; - $method[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " If you know of a better path, let me know"; - $method[] = Indent::_(4) - . "self::setParams(\$extension, \$param, \$set);"; - $method[] = Indent::_(3) . "}"; - $method[] = Indent::_(2) . "}"; - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " if user is created"; - $method[] = Indent::_(2) . "if (\$userId > 0)"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Auto Login if Needed"; - $method[] = Indent::_(3) - . "if (\$autologin && isset(\$credentials['password']))"; - $method[] = Indent::_(3) . "{"; - $method[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Try to login"; - $method[] = Indent::_(4) . "try{"; - $method[] = Indent::_(5) - . "JFactory::getApplication()->login(\$credentials);"; - $method[] = Indent::_(4) . "} catch (Exception \$exception){"; - $method[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) - . " Do noting for now, may want to set redirect."; - $method[] = Indent::_(4) . "}"; - $method[] = Indent::_(3) . "}"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Return ID"; - $method[] = Indent::_(3) . "return \$userId;"; - $method[] = Indent::_(2) . "}"; - $method[] = Indent::_(2) . "return \$model->getError();"; - $method[] = Indent::_(1) . "}"; - - $method[] = PHP_EOL . Indent::_(1) - . "public static function setParams(\$component,\$target,\$value)"; - $method[] = Indent::_(1) . "{"; - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Get the params and set the new values"; - $method[] = Indent::_(2) - . "\$params = JComponentHelper::getParams(\$component);"; - $method[] = Indent::_(2) . "\$was = \$params->get(\$target, null);"; - $method[] = Indent::_(2) . "if (\$was != \$value)"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) . "\$params->set(\$target, \$value);"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Get a new database query instance"; - $method[] = Indent::_(3) . "\$db = JFactory::getDBO();"; - $method[] = Indent::_(3) . "\$query = \$db->getQuery(true);"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Build the query"; - $method[] = Indent::_(3) . "\$query->update('#__extensions AS a');"; - $method[] = Indent::_(3) - . "\$query->set('a.params = ' . \$db->quote((string)\$params));"; - $method[] = Indent::_(3) - . "\$query->where('a.element = ' . \$db->quote((string)\$component));"; - $method[] = Indent::_(3); - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Execute the query"; - $method[] = Indent::_(3) . "\$db->setQuery(\$query);"; - $method[] = Indent::_(3) . "\$db->execute();"; - $method[] = Indent::_(2) . "}"; - $method[] = Indent::_(2) . "return \$was;"; - $method[] = Indent::_(1) . "}"; - - $method[] = PHP_EOL . Indent::_(1) . "/**"; - $method[] = Indent::_(1) . " * Update user values"; - $method[] = Indent::_(1) . " */"; - $method[] = Indent::_(1) - . "public static function updateUser(\$new)"; - $method[] = Indent::_(1) . "{"; - $method[] = Indent::_(2) - . "// load the user component language files if there is an error."; - $method[] = Indent::_(2) . "\$lang = JFactory::getLanguage();"; - $method[] = Indent::_(2) . "\$extension = 'com_users';"; - $method[] = Indent::_(2) . "\$base_dir = JPATH_ADMINISTRATOR;"; - $method[] = Indent::_(2) . "\$language_tag = '" . CFactory::_('Config')->get('lang_tag', 'en-GB') - . "';"; - $method[] = Indent::_(2) . "\$reload = true;"; - $method[] = Indent::_(2) - . "\$lang->load(\$extension, \$base_dir, \$language_tag, \$reload);"; - $method[] = Indent::_(2) . "// load the user model"; - $method[] = Indent::_(2) - . "\$model = self::getModel('user', JPATH_ADMINISTRATOR . '/components/com_users', 'Users');"; - $method[] = Indent::_(2) . "// Check if password was set"; - $method[] = Indent::_(2) - . "if (isset(\$new['password']) && isset(\$new['password2']) && self::checkString(\$new['password']) && self::checkString(\$new['password2']))"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) . "// Use the users passwords"; - $method[] = Indent::_(3) . "\$password = \$new['password'];"; - $method[] = Indent::_(3) . "\$password2 = \$new['password2'];"; - $method[] = Indent::_(2) . "}"; - $method[] = Indent::_(2) . "// set username"; - $method[] = Indent::_(2) - . "if (!isset(\$new['username']) || !self::checkString(\$new['username']))"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) - . "\$new['username'] = \$new['email'];"; - $method[] = Indent::_(2) . "}"; - $method[] = Indent::_(2) . "// lineup update user data"; - $method[] = Indent::_(2) . "\$data = array("; - $method[] = Indent::_(3) . "'id' => \$new['id'],"; - $method[] = Indent::_(3) . "'username' => \$new['username'],"; - $method[] = Indent::_(3) . "'name' => \$new['name'],"; - $method[] = Indent::_(3) . "'email' => \$new['email'],"; - $method[] = Indent::_(3) - . "'password' => \$password, // First password field"; - $method[] = Indent::_(3) - . "'password2' => \$password2, // Confirm password field"; - $method[] = Indent::_(3) . "'block' => 0 );"; - $method[] = Indent::_(2) . "// set groups if found"; - $method[] = Indent::_(2) - . "if (isset(\$new['groups']) && self::checkArray(\$new['groups']))"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) . "\$data['groups'] = \$new['groups'];"; - $method[] = Indent::_(2) . "}"; - $method[] = Indent::_(2) . "// register the new user"; - $method[] = Indent::_(2) . "\$done = \$model->save(\$data);"; - $method[] = Indent::_(2) . "// if user is updated"; - $method[] = Indent::_(2) . "if (\$done)"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) . "return \$new['id'];"; - $method[] = Indent::_(2) . "}"; - $method[] = Indent::_(2) . "return \$model->getError();"; - $method[] = Indent::_(1) . "}"; - - // return the help method - return implode(PHP_EOL, $method); - } - - return ''; - } - - public function setAdminViewMenu(&$nameSingleCode, &$view) - { - $xml = ''; - // build the file target values - $target = array('site' => $nameSingleCode); - // build the edit.xml file - if (CFactory::_('Utilities.Structure')->build($target, 'admin_menu')) - { - // set the lang - $lang = StringHelper::safe( - 'com_' . CFactory::_('Config')->component_code_name . '_menu_' - . $nameSingleCode, - 'U' - ); - CFactory::_('Language')->set( - 'adminsys', $lang . '_TITLE', - 'Create ' . $view['settings']->name_single - ); - CFactory::_('Language')->set( - 'adminsys', $lang . '_OPTION', - 'Create ' . $view['settings']->name_single - ); - CFactory::_('Language')->set( - 'adminsys', $lang . '_DESC', - $view['settings']->short_description - ); - //start loading xml - $xml = ''; - $xml .= PHP_EOL . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(2) . ''; - $xml .= PHP_EOL . Indent::_(3) . ''; - $xml .= PHP_EOL . Indent::_(2) . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . ''; - } - else - { - $this->app->enqueueMessage( - JText::sprintf( - '

Site menu for %s was not build.

', - $nameSingleCode - ), 'Warning' - ); - } - - return $xml; - } - - public function setCustomViewMenu(&$view) - { - $xml = ''; - // build the file target values - $target = array('site' => $view['settings']->code); - // build the default.xml file - if (CFactory::_('Utilities.Structure')->build($target, 'menu')) - { - // set the lang - $lang = StringHelper::safe( - 'com_' . CFactory::_('Config')->component_code_name . '_menu_' - . $view['settings']->code, 'U' - ); - CFactory::_('Language')->set( - 'adminsys', $lang . '_TITLE', $view['settings']->name - ); - CFactory::_('Language')->set( - 'adminsys', $lang . '_OPTION', $view['settings']->name - ); - CFactory::_('Language')->set( - 'adminsys', $lang . '_DESC', $view['settings']->description - ); - //start loading xml - $xml = ''; - $xml .= PHP_EOL . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(2) . ''; - $xml .= PHP_EOL . Indent::_(3) . ''; - $xml .= PHP_EOL . Indent::_(2) . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - if (isset($this->hasIdRequest[$view['settings']->code]) - || isset($this->hasCatIdRequest[$view['settings']->code])) - { - $xml .= PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(2) . '
'; - if (isset($this->hasIdRequest[$view['settings']->code]) - && ArrayHelper::check( - $this->hasIdRequest[$view['settings']->code] - )) - { - foreach ( - $this->hasIdRequest[$view['settings']->code] as - $requestFieldXML - ) - { - $xml .= PHP_EOL . Indent::_(3) . $requestFieldXML; - } - } - if (isset($this->hasCatIdRequest[$view['settings']->code]) - && ArrayHelper::check( - $this->hasCatIdRequest[$view['settings']->code] - )) - { - foreach ( - $this->hasCatIdRequest[$view['settings']->code] as - $requestFieldXML - ) - { - $xml .= PHP_EOL . Indent::_(3) . $requestFieldXML; - } - } - $xml .= PHP_EOL . Indent::_(2) . '
'; - $xml .= PHP_EOL . Indent::_(1) . '
'; - } - if (isset($this->frontEndParams) - && isset($this->frontEndParams[$view['settings']->name])) - { - // first we must setup the fields for the page use - $params = $this->setupFrontendParamFields( - $this->frontEndParams[$view['settings']->name], - $view['settings']->code - ); - // now load the fields - if (ArrayHelper::check($params)) - { - $xml .= PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(2) - . '
'; - $xml .= implode(Indent::_(3), $params); - $xml .= PHP_EOL . Indent::_(2) . '
'; - $xml .= PHP_EOL . Indent::_(1) . '
'; - } - } - $xml .= PHP_EOL . '
'; - } - else - { - $this->app->enqueueMessage( - JText::sprintf( - '

Site menu for %s was not build.

', - $view['settings']->code - ), 'Warning' - ); - } - - return $xml; - } - - public function setupFrontendParamFields($params, $view) - { - $keep = array(); - $menuSetter = $view . '_menu'; - foreach ($params as $field) - { - // some switch to see if it should be added to front end params - $target = GetHelper::between( - $field, 'display="', '"' - ); - if (!StringHelper::check($target) - || $target === 'menu') - { - $field = str_replace('display="menu"', '', (string) $field); - // we update fields that have options if not only added to menu - if ($target !== 'menu' - && strpos($field, 'Option Set. -->') !== false - && strpos($field, $menuSetter) === false - && !StringHelper::check($target)) - { - // we add the global option - $field = str_replace( - 'Option Set. -->', - Line::_(__Line__, __Class__) . ' Global & Option Set. -->' - . PHP_EOL . Indent::_(3) . '', $field - ); - // update the default to be global - $field = preg_replace( - '/default=".+"/', 'default=""', $field - ); - // update the default to be filter - $field = preg_replace( - '/filter=".+"/', 'filter="string"', $field - ); - // update required - $field = str_replace( - 'required="true"', 'required="false"', $field - ); - // add to keeper array - $keep[] = $field; - } - else - { - $keep[] = $field; - } - } - } - - return $keep; - } - - public function setCustomViewQuery(&$gets, &$code, $tab = '', $type = 'main' - ) - { - $query = ''; - if (ArrayHelper::check($gets)) - { - $mainAsArray = array(); - $check = 'zzz'; - foreach ($gets as $nr => $the_get) - { - // to insure that there be no double entries of a call - $checker = md5(serialize($the_get) . $code); - if (!isset($this->customViewQueryChecker[CFactory::_('Config')->build_target]) - || !isset($checker, $this->customViewQueryChecker[CFactory::_('Config')->build_target][$checker])) - { - // load this unuiqe key - $this->customViewQueryChecker[CFactory::_('Config')->build_target][$checker] - = true; - if (isset($the_get['selection']['type']) - && StringHelper::check( - $the_get['selection']['type'] - )) - { - $getItem = PHP_EOL . PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "//" . Line::_(__Line__, __Class__) - . " Get from " . $the_get['selection']['table'] - . " as " . $the_get['as']; - // set the selection - $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . $the_get['selection']['select']; - } - else - { - $getItem = PHP_EOL . PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "//" . Line::_(__Line__, __Class__) - . " Get data"; - // set the selection - $getItem .= PHP_EOL . CFactory::_('Placeholder')->update_( - $the_get['selection']['select'] - ); - } - // load the from selection - if (($nr == 0 - && (!isset($the_get['join_field']) - || !StringHelper::check( - $the_get['join_field'] - )) - && (isset($the_get['selection']['type']) - && StringHelper::check( - $the_get['selection']['type'] - ))) - || ($type === 'custom' - && (isset($the_get['selection']['type']) - && StringHelper::check( - $the_get['selection']['type'] - )))) - { - $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . '$query->from(' . $the_get['selection']['from'] - . ');'; - } - elseif (isset($the_get['join_field']) - && StringHelper::check( - $the_get['join_field'] - ) - && isset($the_get['selection']['type']) - && StringHelper::check( - $the_get['selection']['type'] - )) - { - $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "\$query->join('" . $the_get['type']; - $getItem .= "', (" . $the_get['selection']['from']; - $getItem .= ") . ' ON (' . \$db->quoteName('" - . $the_get['on_field']; - $getItem .= "') . ' " . $the_get['operator']; - $getItem .= " ' . \$db->quoteName('" - . $the_get['join_field'] . "') . ')');"; - - $check = current(explode(".", (string) $the_get['on_field'])); - } - - // set the method defaults - if (($default = $this->setCustomViewMethodDefaults($the_get, $code)) !== false) - { - if (($join_field_ = CFactory::_('Compiler.Builder.Site.Dynamic.Get')->get(CFactory::_('Config')->build_target . - '.' . $default['code'] . '.' . $default['as'] . '.' . $default['join_field'])) !== null - && !in_array($check, $mainAsArray)) - { - // load to other query - CFactory::_('Compiler.Builder.Other.Query')->add( - CFactory::_('Config')->build_target . '.' . $default['code'] . '.' . $join_field_ . '.' . $default['valueName'], - $getItem, - false - ); - } - else - { - $mainAsArray[] = $default['as']; - $query .= $getItem; - } - } - } - } - } - - return $query; - } - - public function setCustomViewFieldDecodeFilter(&$get, &$filters, $string, - $removeString, $code, $tab - ) - { - $filter = ''; - // check if filter is set for this field - if (ArrayHelper::check($filters)) - { - foreach ($filters as $field => $ter) - { - // build load counter - $key = md5( - 'setCustomViewFieldDecodeFilter' . $code . $get['key'] - . $string . $ter['table_key'] - ); - // check if we should load this again - if (strpos((string) $get['selection']['select'], (string) $ter['table_key']) - !== false - && !isset($this->loadTracker[$key])) - { - // set the key - $this->loadTracker[$key] = $key; - $as = ''; - $felt = ''; - list($as, $felt) = array_map( - 'trim', explode('.', (string) $ter['table_key']) - ); - if ($get['as'] == $as) - { - switch ($ter['filter_type']) - { - case 4: - // COM_COMPONENTBUILDER_DYNAMIC_GET_USER_GROUPS - $filter .= PHP_EOL . PHP_EOL . Indent::_(1) - . $tab . Indent::_(1) . "//" - . Line::_(__Line__, __Class__) . " filter " - . $as . " based on user groups"; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) - . "\$remove = (count(array_intersect((array) \$this->groups, (array) " - . $string . "->" . $field - . "))) ? false : true;"; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "if (\$remove)"; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "{"; - if ($removeString == $string) - { - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Remove " . $string - . " if user not in groups"; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . $string . " = null;"; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . "return false;"; - } - else - { - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Unset " . $string - . " if user not in groups"; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . "unset(" - . $removeString . ");"; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . "continue;"; - } - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "}"; - break; - case 9: - // COM_COMPONENTBUILDER_DYNAMIC_GET_ARRAY_VALUE - - $filter .= PHP_EOL . PHP_EOL . Indent::_(1) - . $tab . Indent::_(1) . "if (" - . CFactory::_('Compiler.Builder.Content.One')->get('Component') - . "Helper::checkArray(" . $string . "->" - . $field . "))"; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "{"; - - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " do your thing here"; - - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "}"; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "else"; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "{"; - - if ($removeString == $string) - { - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Remove " . $string - . " if not array."; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . $string . " = null;"; - } - else - { - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Unset " . $string - . " if not array."; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . "unset(" - . $removeString . ");"; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . "continue;"; - } - - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "}"; - break; - case 10: - // COM_COMPONENTBUILDER_DYNAMIC_GET_REPEATABLE_VALUE - $filter .= PHP_EOL . PHP_EOL . Indent::_(1) - . $tab . Indent::_(1) . "//" - . Line::_(__Line__, __Class__) . " filter " - . $as . " based on repeatable value"; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "if (" - . CFactory::_('Compiler.Builder.Content.One')->get('Component') - . "Helper::checkString(" . $string . "->" - . $field . "))"; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "{"; - - $filter .= PHP_EOL . Indent::_(2) . $tab - . Indent::_(1) . "\$array = json_decode(" - . $string . "->" . $field . ",true);"; - $filter .= PHP_EOL . Indent::_(2) . $tab - . Indent::_(1) . "if (" - . CFactory::_('Compiler.Builder.Content.One')->get('Component') - . "Helper::checkArray(\$array))"; - $filter .= PHP_EOL . Indent::_(2) . $tab - . Indent::_(1) . "{"; - - $filter .= PHP_EOL . Indent::_(2) . $tab - . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " do your thing here"; - - $filter .= PHP_EOL . Indent::_(2) . $tab - . Indent::_(1) . "}"; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . "else"; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . "{"; - - if ($removeString == $string) - { - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Remove " . $string - . " if not array."; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(3) . $string . " = null;"; - } - else - { - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Unset " . $string - . " if not array."; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(3) . "unset(" - . $removeString . ");"; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(3) . "continue;"; - } - - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . "}"; - - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "}"; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "else"; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "{"; - - if ($removeString == $string) - { - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Remove " . $string - . " if not string."; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . $string . " = null;"; - } - else - { - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Unset " . $string - . " if not string."; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . "unset(" - . $removeString . ");"; - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . "continue;"; - } - - $filter .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "}"; - break; - } - } - } - } - } - - return $filter; - } - - public function setCustomViewFieldDecode(&$get, $checker, $string, $code, - $tab = '' - ) - { - $fieldDecode = ''; - foreach ($checker as $field => $array) - { - // build load counter - $key = md5( - 'setCustomViewFieldDecode' . $code . $get['key'] . $string - . $field - ); - // check if we should load this again - if (strpos((string) $get['selection']['select'], (string) $field) !== false - && !isset($this->loadTracker[$key]) - && ArrayHelper::check($array['decode'])) - { - // set the key - $this->loadTracker[$key] = $key; - // insure it is unique - $array['decode'] = (array) array_unique( - array_reverse((array) $array['decode']) - ); - // now loop the array - foreach ($array['decode'] as $decode) - { - $if = ''; - $decoder = ''; - if ('json' === $decode) - { - $if = PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "if (isset(" . $string . "->" . $field . ") && " - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkJson(" - . $string . "->" . $field . "))" . PHP_EOL - . Indent::_(1) . $tab . Indent::_(1) . "{"; - // json_decode - $decoder = $string . "->" . $field . " = json_decode(" - . $string . "->" . $field . ", true);"; - } - elseif ('base64' === $decode) - { - $if = PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "if (!empty(" . $string . "->" . $field . ") && " - . $string . "->" . $field - . " === base64_encode(base64_decode(" . $string - . "->" . $field . ")))" . PHP_EOL . Indent::_(1) - . $tab . Indent::_(1) . "{"; - // base64_decode - $decoder = $string . "->" . $field . " = base64_decode(" - . $string . "->" . $field . ");"; - } - elseif (strpos((string) $decode, '_encryption') !== false - || 'expert_mode' === $decode) - { - foreach (CFactory::_('Config')->cryption_types as $cryptionType) - { - if ($cryptionType . '_encryption' === $decode - || $cryptionType . '_mode' === $decode) - { - if ('expert' !== $cryptionType) - { - $if = PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "if (!empty(" . $string - . "->" . $field . ") && \$" - . $cryptionType . "key && !is_numeric(" - . $string . "->" . $field . ") && " - . $string . "->" . $field - . " === base64_encode(base64_decode(" - . $string . "->" . $field . ", true)))" - . PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "{"; - // set decryption - $decoder = $string . "->" . $field - . " = rtrim(\$" . $cryptionType - . "->decryptString(" . $string . "->" - . $field . "), " . '"\0"' . ");"; - } - elseif (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field')-> - exists($array['admin_view'] . '.' . $field)) - { - $_placeholder_for_field - = array('[[[field]]]' => $string - . "->" . $field); - $fieldDecode .= CFactory::_('Placeholder')->update( - PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . implode( - PHP_EOL . Indent::_(1) . $tab - . Indent::_(1), - CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field')->get( - $array['admin_view'] . '.' . $field . '.get', ['error']) - ), $_placeholder_for_field - ); - } - // activate site decryption - CFactory::_('Compiler.Builder.Site.Decrypt')->set("{$cryptionType}.{$code}", true); - } - } - } - // check if we have found the details - if (StringHelper::check($if)) - { - // build decoder string - $fieldDecode .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "//" . Line::_(__Line__, __Class__) - . " Check if we can decode " . $field . $if - . PHP_EOL . Indent::_(1) . $tab . Indent::_(2) - . "//" . Line::_(__Line__, __Class__) . " Decode " - . $field; - } - if (StringHelper::check($decoder)) - { - // build decoder string - $fieldDecode .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(2) . $decoder . PHP_EOL . Indent::_(1) - . $tab . Indent::_(1) . "}"; - } - } - } - } - - return $fieldDecode; - } - - public function setCustomViewFieldonContentPrepareChecker(&$get, $checker, - $string, $code, $tab = '' - ) - { - $fieldPrepare = ''; - $runplugins = false; - // set component - $Component = CFactory::_('Compiler.Builder.Content.One')->get('Component'); - // set context - $context = (isset($get['context'])) ? $get['context'] : $code; - $context = 'com_' . CFactory::_('Config')->component_code_name . '.' . $context; - // load parms builder only once - $params = false; - foreach ($checker as $field => $array) - { - // build load counter - $key = md5( - 'setCustomViewFieldonContentPrepareChecker' . $code - . $get['key'] . $string . $field - ); - // check if we should load this again - if (strpos((string) $get['selection']['select'], (string) $field) !== false - && !isset($this->loadTracker[$key])) - { - // set the key - $this->loadTracker[$key] = $key; - // build decoder string - if (!$runplugins) - { - $runplugins = PHP_EOL . $tab . Indent::_(1) . "//" - . Line::_(__Line__, __Class__) - . " Load the JEvent Dispatcher"; - $runplugins .= PHP_EOL . $tab . Indent::_(1) - . "JPluginHelper::importPlugin('content');"; - $runplugins .= PHP_EOL . $tab . Indent::_(1) - . '$this->_dispatcher = JFactory::getApplication();'; - } - if (!$params) - { - $fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_( - 1 - ) . "//" . Line::_(__Line__, __Class__) - . " Check if item has params, or pass whole item."; - $fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_( - 1 - ) . "\$params = (isset(" . $string . "->params) && " - . $Component . "Helper::checkJson(" . $string - . "->params)) ? json_decode(" . $string . "->params) : " - . $string . ";"; - $params = true; - } - $fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "//" . Line::_(__Line__, __Class__) - . " Make sure the content prepare plugins fire on " - . $field; - $fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "\$_" . $field . " = new stdClass();"; - $fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "\$_" . $field . '->text =& ' . $string . '->' . $field - . '; //' . Line::_(__Line__, __Class__) - . ' value must be in text'; - $fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "//" . Line::_(__Line__, __Class__) - . " Since all values are now in text (Joomla Limitation), we also add the field name (" - . $field . ") to context"; - $fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . '$this->_dispatcher->triggerEvent("onContentPrepare", array(\'' - . $context . '.' . $field . '\', &$_' . $field - . ', &$params, 0));'; - } - } - // load dispatcher - if ($runplugins) - { - $this->JEventDispatcher = array(Placefix::_h('DISPATCHER') => $runplugins); - } - - // return content prepare fix - return $fieldPrepare; - } - - public function setCustomViewFieldUikitChecker(&$get, $checker, $string, - $code, $tab = '' - ) - { - $fieldUikit = ''; - foreach ($checker as $field => $array) - { - // build load counter - $key = md5( - 'setCustomViewFieldUikitChecker' . $code . $get['key'] . $string - . $field - ); - // check if we should load this again - if (strpos((string) $get['selection']['select'], (string) $field) !== false - && !isset($this->loadTracker[$key])) - { - // set the key - $this->loadTracker[$key] = $key; - // only load for uikit version 2 (TODO) we may need to add another check here - if (2 == CFactory::_('Config')->uikit || 1 == CFactory::_('Config')->uikit) - { - $fieldUikit .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "//" . Line::_(__Line__, __Class__) . " Checking if " - . $field . " has uikit components that must be loaded."; - $fieldUikit .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "\$this->uikitComp = " - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::getUikitComp(" . $string . "->" - . $field . ",\$this->uikitComp);"; - } - } - } - - // return UIKIT fix - return $fieldUikit; - } - - public function setCustomViewCustomJoin(&$gets, $string, $code, &$asBucket, - $tab = '' - ) - { - if (ArrayHelper::check($gets)) - { - $customJoin = ''; - foreach ($gets as $get) - { - // set the value name $default - if (($default = $this->setCustomViewMethodDefaults($get, $code)) - !== false) - { - if ($this->checkJoint($default, $get, $asBucket)) - { - // build custom join string - $otherJoin = PHP_EOL . Indent::_(1) . Placefix::_h("TAB") - . Indent::_(1) . "//" . Line::_(__LINE__,__CLASS__) - . " set " . $default['valueName'] . " to the " - . Placefix::_h("STRING") . " object."; - $otherJoin .= PHP_EOL . Indent::_(1) . Placefix::_h("TAB") - . Indent::_(1) . Placefix::_h("STRING") . "->" - . $default['valueName'] . " = \$this->get" - . $default['methodName'] . "(" . Placefix::_h("STRING") . "->" - . CFactory::_('Compiler.Builder.Get.As.Lookup')-> - get($get['key'] . '.' . $get['on_field'], 'Error') - . ");"; - $join_field_ = CFactory::_('Compiler.Builder.Site.Dynamic.Get')->get(CFactory::_('Config')->build_target . - '.' . $default['code'] . '.' . $default['as'] . '.' . $default['join_field'], 'ZZZ'); - // load to other join - CFactory::_('Compiler.Builder.Other.Join')->add( - CFactory::_('Config')->build_target . '.' . $default['code'] . '.' . $join_field_ . '.' . $default['valueName'], - $otherJoin, - false - ); - } - else - { - // build custom join string - $customJoin .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "//" . Line::_(__Line__, __Class__) - . " set " . $default['valueName'] . " to the " - . $string . " object."; - $customJoin .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . $string . "->" - . $default['valueName'] . " = \$this->get" - . $default['methodName'] . "(" . $string . "->" - . CFactory::_('Compiler.Builder.Get.As.Lookup')-> - get($get['key'] . '.' . $get['on_field'], 'Error') - . ");"; - } - } - } - - return $customJoin; - } - - return ''; - } - - public function checkJoint(&$default, &$get, &$asBucket) - { - // check if this function is not linked to the main call - list($aJoin) = explode('.', (string) $get['on_field']); - if (ArrayHelper::check($asBucket) && in_array($aJoin, $asBucket)) - { - return false; - } - // default fallback - elseif (CFactory::_('Compiler.Builder.Site.Dynamic.Get')->exists( - CFactory::_('Config')->build_target . '.' . $default['code'] . '.' . - $default['as'] . '.' . $default['join_field'] - )) - { - return true; - } - - return false; - } - - public function setCustomViewFilter(&$filter, &$code, $tab = '') - { - $filters = ''; - if (ArrayHelper::check($filter)) - { - foreach ($filter as $ter) - { - $as = ''; - $field = ''; - $string = ''; - if (strpos((string) $ter['table_key'], '.') !== false) - { - list($as, $field) = array_map( - 'trim', explode('.', (string) $ter['table_key']) - ); - } - $path = $code . '.' . $ter['key'] . '.' . $as . '.' . $field; - switch ($ter['filter_type']) - { - case 1: - // COM_COMPONENTBUILDER_DYNAMIC_GET_ID - $string = PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "\$query->where('" . $ter['table_key'] . " " - . $ter['operator'] . " ' . (int) \$pk);"; - break; - case 2: - // COM_COMPONENTBUILDER_DYNAMIC_GET_USER - $string = PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "\$query->where('" . $ter['table_key'] . " " - . $ter['operator'] . " ' . (int) \$this->userId);"; - break; - case 3: - // COM_COMPONENTBUILDER_DYNAMIC_GET_ACCESS_LEVEL - $string = PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "\$query->where('" . $ter['table_key'] . " " - . $ter['operator'] - . " (' . implode(',', \$this->levels) . ')');"; - break; - case 4: - // COM_COMPONENTBUILDER_DYNAMIC_GET_USER_GROUPS - $decodeChecker = CFactory::_('Compiler.Builder.Site.Field.Data')-> - get('decode.' . $path); - if (ArrayHelper::check($decodeChecker) - || $ter['state_key'] === 'array') - { - // set needed fields to filter after query - CFactory::_('Compiler.Builder.Site.Field.Decode.Filter')-> - set(CFactory::_('Config')->build_target . '.' . $path, $ter); - } - else - { - $string = PHP_EOL . Indent::_(1) . $tab . Indent::_( - 1 - ) . "\$query->where('" . $ter['table_key'] . " " - . $ter['operator'] - . " (' . implode(',', \$this->groups) . ')');"; - } - break; - case 5: - // COM_COMPONENTBUILDER_DYNAMIC_GET_CATEGORIES - $string = PHP_EOL . Indent::_(2) . $tab . "//" - . Line::_(__Line__, __Class__) - . " (TODO) The dynamic category filter is not ready."; - break; - case 6: - // COM_COMPONENTBUILDER_DYNAMIC_GET_TAGS - $string = PHP_EOL . Indent::_(2) . $tab . "//" - . Line::_(__Line__, __Class__) - . " (TODO) The dynamic tags filter is not ready."; - break; - case 7: - // COM_COMPONENTBUILDER_DYNAMIC_GET_DATE - $string = PHP_EOL . Indent::_(2) . $tab . "//" - . Line::_(__Line__, __Class__) - . " (TODO) The dynamic date filter is not ready."; - break; - case 8: - // COM_COMPONENTBUILDER_DYNAMIC_GET_FUNCTIONVAR - if ($ter['operator'] === 'IN' - || $ter['operator'] === 'NOT IN') - { - $string = PHP_EOL . Indent::_(2) . $tab . "//" - . Line::_(__Line__, __Class__) . " Check if " - . $ter['state_key'] - . " is an array with values."; - $string .= PHP_EOL . Indent::_(2) . $tab - . "\$array = " . $ter['state_key'] . ";"; - $string .= PHP_EOL . Indent::_(2) . $tab - . "if (isset(\$array) && " - . CFactory::_('Compiler.Builder.Content.One')->get('Component') - . "Helper::checkArray(\$array))"; - $string .= PHP_EOL . Indent::_(2) . $tab . "{"; - $string .= PHP_EOL . Indent::_(2) . $tab - . Indent::_(1) . "\$query->where('" - . $ter['table_key'] . " " . $ter['operator'] - . " (' . implode(',', \$array) . ')');"; - $string .= PHP_EOL . Indent::_(2) . $tab . "}"; - // check if empty is allowed - if (!isset($ter['empty']) || !$ter['empty']) - { - $string .= PHP_EOL . Indent::_(2) . $tab - . "else"; - $string .= PHP_EOL . Indent::_(2) . $tab . "{"; - $string .= PHP_EOL . Indent::_(2) . $tab - . Indent::_(1) . "return false;"; - $string .= PHP_EOL . Indent::_(2) . $tab . "}"; - } - } - else - { - $string = PHP_EOL . Indent::_(2) . $tab . "//" - . Line::_(__Line__, __Class__) . " Check if " - . $ter['state_key'] - . " is a string or numeric value."; - $string .= PHP_EOL . Indent::_(2) . $tab - . "\$checkValue = " . $ter['state_key'] . ";"; - $string .= PHP_EOL . Indent::_(2) . $tab - . "if (isset(\$checkValue) && " - . CFactory::_('Compiler.Builder.Content.One')->get('Component') - . "Helper::checkString(\$checkValue))"; - $string .= PHP_EOL . Indent::_(2) . $tab . "{"; - $string .= PHP_EOL . Indent::_(2) . $tab - . Indent::_(1) . "\$query->where('" - . $ter['table_key'] . " " . $ter['operator'] - . " ' . \$db->quote(\$checkValue));"; - $string .= PHP_EOL . Indent::_(2) . $tab . "}"; - $string .= PHP_EOL . Indent::_(2) . $tab - . "elseif (is_numeric(\$checkValue))"; - $string .= PHP_EOL . Indent::_(2) . $tab . "{"; - $string .= PHP_EOL . Indent::_(2) . $tab - . Indent::_(1) . "\$query->where('" - . $ter['table_key'] . " " . $ter['operator'] - . " ' . \$checkValue);"; - $string .= PHP_EOL . Indent::_(2) . $tab . "}"; - // check if empty is allowed - if (!isset($ter['empty']) || !$ter['empty']) - { - $string .= PHP_EOL . Indent::_(2) . $tab - . "else"; - $string .= PHP_EOL . Indent::_(2) . $tab . "{"; - $string .= PHP_EOL . Indent::_(2) . $tab - . Indent::_(1) . "return false;"; - $string .= PHP_EOL . Indent::_(2) . $tab . "}"; - } - } - break; - case 9: - case 10: - // COM_COMPONENTBUILDER_DYNAMIC_GET_ARRAY_VALUE - // COM_COMPONENTBUILDER_DYNAMIC_GET_REPEATABLE_VALUE - $string = ""; - // set needed fields to filter after query - CFactory::_('Compiler.Builder.Site.Field.Decode.Filter')-> - set(CFactory::_('Config')->build_target . '.' . $path, $ter); - break; - case 11: - // COM_COMPONENTBUILDER_DYNAMIC_GET_OTHER - if (strpos($as, '(') !== false) - { - // TODO (for now we only fix extra sql methods here) - list($dump, $as) = array_map( - 'trim', explode('(', $as) - ); - $field = trim(str_replace(')', '', $field)); - } - $string = PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "\$query->where('" . $ter['table_key'] . " " - . $ter['operator'] . " " . $ter['state_key'] - . "');"; - break; - } - // only add if the filter is set - if (StringHelper::check($string)) - { - // sort where - if ($as === 'a' || CFactory::_('Compiler.Builder.Site.Main.Get')-> - exists(CFactory::_('Config')->build_target . '.' . $code . '.' . $as)) - { - $filters .= $string; - } - elseif ($as !== 'a') - { - CFactory::_('Compiler.Builder.Other.Filter')-> - set(CFactory::_('Config')->build_target . '.' . $code . '.' . $as . '.' . $field, $string);; - } - } - } - } - - return $filters; - } - - public function setCustomViewGroup(&$group, &$code, $tab = '') - { - $grouping = ''; - if (ArrayHelper::check($group)) - { - foreach ($group as $gr) - { - list($as, $field) = array_map( - 'trim', explode('.', (string) $gr['table_key']) - ); - // set the string - $string = "\$query->group('" . $gr['table_key'] . "');"; - // sort where - if ($as === 'a' || CFactory::_('Compiler.Builder.Site.Main.Get')-> - exists(CFactory::_('Config')->build_target . '.' . $code . '.' . $as)) - { - $grouping .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . $string; - } - else - { - CFactory::_('Compiler.Builder.Other.Group')->set( - CFactory::_('Config')->build_target . '.' . $code . '.' . $as . '.' . $field, - PHP_EOL . Indent::_(2) . $string - ); - } - } - } - - return $grouping; - } - - public function setCustomViewOrder(&$order, &$code, $tab = '') - { - $ordering = ''; - if (ArrayHelper::check($order)) - { - foreach ($order as $or) - { - list($as, $field) = array_map( - 'trim', explode('.', (string) $or['table_key']) - ); - // check if random - if ('RAND' === $or['direction']) - { - // set the string - $string = "\$query->order('RAND()');"; - } - else - { - // set the string - $string = "\$query->order('" . $or['table_key'] . " " - . $or['direction'] . "');"; - } - // sort where - if ($as === 'a' || CFactory::_('Compiler.Builder.Site.Main.Get')-> - exists(CFactory::_('Config')->build_target . '.' . $code . '.' . $as)) - { - $ordering .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . $string; - } - else - { - CFactory::_('Compiler.Builder.Other.Order')->set( - CFactory::_('Config')->build_target . '.' . $code . '.' . $as . '.' . $field, - PHP_EOL . Indent::_(2) . $string - ); - } - } - } - - return $ordering; - } - - public function setCustomViewWhere(&$where, &$code, $tab = '') - { - $wheres = ''; - if (ArrayHelper::check($where)) - { - foreach ($where as $whe) - { - $as = ''; - $field = ''; - $value = ''; - list($as, $field) = array_map( - 'trim', explode('.', (string) $whe['table_key']) - ); - if (is_numeric($whe['value_key'])) - { - $value = " " . $whe['value_key'] . "');"; - } - elseif (strpos((string) $whe['value_key'], '$') !== false) - { - if ($whe['operator'] === 'IN' - || $whe['operator'] === 'NOT IN') - { - $value = " (' . implode(',', " . $whe['value_key'] - . ") . ')');"; - } - else - { - $value = " ' . \$db->quote(" . $whe['value_key'] - . "));"; - } - } - elseif (strpos((string) $whe['value_key'], '.') !== false) - { - if (strpos((string) $whe['value_key'], "'") !== false) - { - $value = " ' . \$db->quote(" . $whe['value_key'] - . "));"; - } - else - { - $value = " " . $whe['value_key'] . "');"; - } - } - elseif (StringHelper::check($whe['value_key'])) - { - $value = " " . $whe['value_key'] . "');"; - } - // only load if there is a value - if (StringHelper::check($value)) - { - $tabe = ''; - if ($as === 'a') - { - $tabe = $tab; - } - // set the string - if ($whe['operator'] === 'IN' - || $whe['operator'] === 'NOT IN') - { - $string = "if (isset(" . $whe['value_key'] . ") && " - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkArray(" - . $whe['value_key'] . "))"; - $string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(1) - . "{"; - $string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(2) - . "//" . Line::_(__Line__, __Class__) . " Get where " - . $whe['table_key'] . " is " . $whe['value_key']; - $string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(2) - . "\$query->where('" . $whe['table_key'] . " " - . $whe['operator'] . $value; - $string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(1) - . "}"; - $string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(1) - . "else"; - $string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(1) - . "{"; - $string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(2) - . "return false;"; - $string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(1) - . "}"; - } - else - { - $string = "//" . Line::_(__Line__, __Class__) - . " Get where " . $whe['table_key'] . " is " - . $whe['value_key']; - $string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(1) - . "\$query->where('" . $whe['table_key'] . " " - . $whe['operator'] . $value; - } - // sort where - if ($as === 'a' || CFactory::_('Compiler.Builder.Site.Main.Get')-> - exists(CFactory::_('Config')->build_target . '.' . $code . '.' . $as)) - { - $wheres .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . $string; - } - elseif ($as !== 'a') - { - CFactory::_('Compiler.Builder.Other.Where')->set( - CFactory::_('Config')->build_target . '.' . $code . '.' . $as . '.' . $field, - PHP_EOL . Indent::_(2) . $string - ); - } - } - } - } - - return $wheres; - } - - public function setCustomViewGlobals(&$global, $string, $as, $tab = '') - { - $globals = ''; - if (ArrayHelper::check($global)) - { - $as = array_unique($as); - foreach ($global as $glo) - { - if (in_array($glo['as'], $as)) - { - switch ($glo['type']) - { - case 1: - // SET STATE - $value = "\$this->setState('" . $glo['as'] . "." - . $glo['name'] . "', " . $string . "->" - . $glo['key'] . ");"; - break; - case 2: - // SET THIS - $value = "\$this->" . $glo['as'] . "_" - . $glo['name'] . " = " . $string . "->" - . $glo['key'] . ";"; - break; - } - // only add if the filter is set - if (StringHelper::check($value)) - { - $globals .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "//" . Line::_(__Line__, __Class__) - . " set the global " . $glo['name'] . " value." - . PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . $value; - } - } - } - } - - return $globals; - } - - /** - * @param $string - * @param string $type - * - * @return mixed - */ - public function removeAsDot($string, $type = '') - { - if (strpos((string) $string, '.') !== false) - { - list($dump, $field) = array_map('trim', explode('.', (string) $string)); - } - else - { - $field = $string; - } - - return $field; - } - - /** - * @param type $view - * @param type $type - */ - public function setUserPermissionCheckAccess($view, $type) - { - if (isset($view['access']) && $view['access'] == 1) - { - switch ($type) - { - case 1: - $userString = '$this->user'; - break; - default: - $userString = '$user'; - break; - } - // check that the default and the redirect page is not the same - if (CFactory::_('Compiler.Builder.Content.One')->exists('SITE_DEFAULT_VIEW') - && CFactory::_('Compiler.Builder.Content.One')->get('SITE_DEFAULT_VIEW') != $view['settings']->code) - { - $redirectMessage = Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) - . " redirect away to the default view if no access allowed."; - $redirectString = "JRoute::_('index.php?option=com_" - . CFactory::_('Config')->component_code_name . "&view=" - . CFactory::_('Compiler.Builder.Content.One')->get('SITE_DEFAULT_VIEW') . "')"; - } - else - { - $redirectMessage = Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " redirect away to the home page if no access allowed."; - $redirectString = 'JURI::root()'; - } - $accessCheck[] = PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " check if this user has permission to access item"; - $accessCheck[] = Indent::_(2) . "if (!" . $userString - . "->authorise('site." . $view['settings']->code - . ".access', 'com_" . CFactory::_('Config')->component_code_name . "'))"; - $accessCheck[] = Indent::_(2) . "{"; - $accessCheck[] = Indent::_(3) - . "\$app = JFactory::getApplication();"; - // set lang - $langKeyWord = CFactory::_('Config')->lang_prefix . '_' - . StringHelper::safe( - 'Not authorised to view ' . $view['settings']->code . '!', - 'U' - ); - CFactory::_('Language')->set( - 'site', $langKeyWord, - 'Not authorised to view ' . $view['settings']->code . '!' - ); - $accessCheck[] = Indent::_(3) . "\$app->enqueueMessage(JText:" - . ":_('" . $langKeyWord . "'), 'error');"; - $accessCheck[] = $redirectMessage; - $accessCheck[] = Indent::_(3) . "\$app->redirect(" . $redirectString - . ");"; - $accessCheck[] = Indent::_(3) . "return false;"; - $accessCheck[] = Indent::_(2) . "}"; - - // return the access check - return implode(PHP_EOL, $accessCheck); - } - - return ''; - } - - /** - * @param $get - * @param $code - * @param string $tab - * @param string $type - * - * @return string - */ - public function setCustomViewGetItem(&$get, &$code, $tab = '', $type = 'main') - { - if (ObjectHelper::check($get)) - { - // set the site decription switches - foreach (CFactory::_('Config')->cryption_types as $cryptionType) - { - CFactory::_('Compiler.Builder.Site.Decrypt')->set("{$cryptionType}.{$code}", false); - } - // start the get Item - $getItem = ''; - // set before item php - if (isset($get->add_php_before_getitem) - && $get->add_php_before_getitem == 1 - && isset($get->php_before_getitem) - && StringHelper::check( - $get->php_before_getitem - )) - { - $getItem .= CFactory::_('Placeholder')->update_( - $get->php_before_getitem - ); - } - // start loadin the get Item - $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "//" - . Line::_(__Line__, __Class__) . " Get a db connection."; - $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "\$db = JFactory::getDbo();"; - $getItem .= PHP_EOL . PHP_EOL . $tab . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Create a new query object."; - $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "\$query = \$db->getQuery(true);"; - // set main get query - $getItem .= $this->setCustomViewQuery($get->main_get, $code, $tab); - // setup filters - if (isset($get->filter)) - { - $getItem .= $this->setCustomViewFilter( - $get->filter, $code, $tab - ); - } - // setup Where - if (isset($get->where)) - { - $getItem .= $this->setCustomViewWhere($get->where, $code, $tab); - } - // setup ordering - if (isset($get->order)) - { - $getItem .= $this->setCustomViewOrder($get->order, $code, $tab); - } - // setup grouping - if (isset($get->group)) - { - $getItem .= $this->setCustomViewGroup($get->group, $code, $tab); - } - // db set query data placeholder - $getItem .= Placefix::_h("DB_SET_QUERY_DATA") ; - // set after item php - if (isset($get->add_php_after_getitem) - && $get->add_php_after_getitem == 1 - && isset($get->php_after_getitem) - && StringHelper::check($get->php_after_getitem)) - { - $getItem .= CFactory::_('Placeholder')->update_( - $get->php_after_getitem - ); - } - // check the getItem string to see if we should still add set query to data - if (strpos($getItem, '$data =') === false) - { - // get ready to get query - $setQuery[Placefix::_h("DB_SET_QUERY_DATA")] = - PHP_EOL . PHP_EOL . $tab . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) - . " Reset the query using our newly populated query object."; - $setQuery[Placefix::_h("DB_SET_QUERY_DATA")] .= - PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "\$db->setQuery(\$query);"; - $setQuery[Placefix::_h("DB_SET_QUERY_DATA")] .= - PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "//" - . Line::_(__Line__, __Class__) - . " Load the results as a stdClass object."; - $setQuery[Placefix::_h("DB_SET_QUERY_DATA")] .= - PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "\$data = \$db->loadObject();"; - // add the db set query to data - } - else - { - // remove our placeholder - $setQuery[Placefix::_h("DB_SET_QUERY_DATA")] = ''; - } - // add the db set query to data - $getItem = str_replace( - array_keys($setQuery), - array_values($setQuery), $getItem - ); - $getItem .= PHP_EOL . PHP_EOL . $tab . Indent::_(2) - . "if (empty(\$data))"; - $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "{"; - if ($type === 'main') - { - $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) - . "\$app = JFactory::getApplication();"; - $langKeyWoord = CFactory::_('Config')->lang_prefix . '_' - . StringHelper::safe( - 'Not found or access denied', 'U' - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $langKeyWoord, 'Not found, or access denied.' - ); - $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) - . " If no data is found redirect to default page and show warning."; - $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) - . "\$app->enqueueMessage(JText:" . ":_('" . $langKeyWoord - . "'), 'warning');"; - if ('site' === CFactory::_('Config')->build_target) - { - // check that the default and the redirect page is not the same - if (CFactory::_('Compiler.Builder.Content.One')->exists('SITE_DEFAULT_VIEW') - && CFactory::_('Compiler.Builder.Content.One')->get('SITE_DEFAULT_VIEW') != $code) - { - $redirectString = "JRoute::_('index.php?option=com_" - . CFactory::_('Config')->component_code_name . "&view=" - . CFactory::_('Compiler.Builder.Content.One')->get('SITE_DEFAULT_VIEW') . "')"; - } - else - { - $redirectString = 'JURI::root()'; - } - $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) - . "\$app->redirect(" . $redirectString . ");"; - } - else - { - $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) - . "\$app->redirect('index.php?option=com_" - . CFactory::_('Config')->component_code_name . "');"; - } - $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) - . "return false;"; - } - else - { - $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) - . "return false;"; - } - $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "}"; - // dispatcher placeholder - $getItem .= Placefix::_h("DISPATCHER") ; - if (ArrayHelper::check($get->main_get)) - { - $asBucket = array(); - foreach ($get->main_get as $main_get) - { - if (isset($main_get['key']) && isset($main_get['as'])) - { - // build path - $path = $code . '.' . $main_get['key'] . '.' . $main_get['as']; - - $decodeChecker = CFactory::_('Compiler.Builder.Site.Field.Data')->get('decode.' . $path); - if (ArrayHelper::check($decodeChecker)) - { - // set decoding of needed fields - $getItem .= $this->setCustomViewFieldDecode( - $main_get, $decodeChecker, '$data', $code, - $tab - ); - } - - $decodeFilter = CFactory::_('Compiler.Builder.Site.Field.Decode.Filter')-> - get(CFactory::_('Config')->build_target . '.' . $path); - if (ArrayHelper::check($decodeFilter)) - { - // also filter fields if needed - $getItem .= $this->setCustomViewFieldDecodeFilter( - $main_get, $decodeFilter, '$data', '$data', - $code, $tab - ); - } - - $contentprepareChecker = CFactory::_('Compiler.Builder.Site.Field.Data')-> - get('textareas.' . $path); - if (ArrayHelper::check($contentprepareChecker)) - { - // set contentprepare checkers on needed fields - $getItem .= $this->setCustomViewFieldonContentPrepareChecker( - $main_get, $contentprepareChecker, '$data', - $code, $tab - ); - } - - $uikitChecker = CFactory::_('Compiler.Builder.Site.Field.Data')->get('uikit.' . $path); - if (ArrayHelper::check($uikitChecker)) - { - // set uikit checkers on needed fields - $getItem .= $this->setCustomViewFieldUikitChecker( - $main_get, $uikitChecker, '$data', $code, - $tab - ); - } - - $asBucket[] = $main_get['as']; - } - } - } - // set the scripts - $Component = CFactory::_('Compiler.Builder.Content.One')->get('Component'); - $script = ''; - foreach (CFactory::_('Config')->cryption_types as $cryptionType) - { - if (CFactory::_('Compiler.Builder.Site.Decrypt')->get("{$cryptionType}.{$code}", false)) - { - if ('expert' !== $cryptionType) - { - $script .= PHP_EOL . PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "//" . Line::_(__Line__, __Class__) - . " Get the " . $cryptionType . " encryption."; - $script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "\$" . $cryptionType . "key = " . $Component - . "Helper::getCryptKey('" . $cryptionType . "');"; - $script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "//" . Line::_(__Line__, __Class__) - . " Get the encryption object."; - $script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "\$" . $cryptionType . " = new Super___99175f6d_dba8_4086_8a65_5c4ec175e61d___Power(\$" - . $cryptionType . "key);"; - } - elseif (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> - exists("{$code}.get")) - { - foreach (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> - get("{$code}.get") as $block) - { - $script .= PHP_EOL . Indent::_(1) . implode( - PHP_EOL . Indent::_(1), $block - ); - } - } - } - } - $getItem = $script . $getItem; - // setup Globals - $getItem .= $this->setCustomViewGlobals( - $get->global, '$data', $asBucket, $tab - ); - // setup the custom gets that returns multipal values - $getItem .= $this->setCustomViewCustomJoin( - $get->custom_get, '$data', $code, $asBucket, $tab - ); - // set calculations - if ($get->addcalculation == 1) - { - $get->php_calculation = (array) explode( - PHP_EOL, (string) CFactory::_('Placeholder')->update_( - $get->php_calculation - ) - ); - $getItem .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . implode( - PHP_EOL . Indent::_(1) . $tab . Indent::_(1), - $get->php_calculation - ); - } - if ($type === 'custom') - { - // return the object - $getItem .= PHP_EOL . PHP_EOL . Indent::_(1) . $tab . Indent::_( - 1 - ) . "//" . Line::_(__Line__, __Class__) - . " return data object."; - $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "return \$data;"; - } - else - { - // set the object - $getItem .= PHP_EOL . PHP_EOL . Indent::_(1) . $tab . Indent::_( - 1 - ) . "//" . Line::_(__Line__, __Class__) - . " set data object to item."; - $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "\$this->_item[\$pk] = \$data;"; - } - // only update if dispacher placholder is found - if (strpos($getItem, (string) Placefix::_h('DISPATCHER')) - !== false) - { - // check if the dispather should be added - if (!isset($this->JEventDispatcher) - || !ArrayHelper::check( - $this->JEventDispatcher - )) - { - $this->JEventDispatcher = array(Placefix::_h('DISPATCHER') => ''); - } - $getItem = str_replace( - array_keys($this->JEventDispatcher), - array_values($this->JEventDispatcher), $getItem - ); - } - - return $getItem; - } - - return PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "//" - . Line::_(__Line__, __Class__) . "add your custom code here."; - } - - public function setCustomViewCustomMethods($main_view, $code) - { - $methods = ''; - // then set the needed custom methods - if (ArrayHelper::check($main_view) - && isset($main_view['settings']) - && ObjectHelper::check($main_view['settings']) - && isset($main_view['settings']->custom_get)) - { - $_dynamic_get = $main_view['settings']->custom_get; - } - elseif (ObjectHelper::check($main_view) - && isset($main_view->custom_get)) - { - $_dynamic_get = $main_view->custom_get; - } - // check if we have an array - if (isset($_dynamic_get) - && ArrayHelper::check( - $_dynamic_get - )) - { - // start dynamic build - foreach ($_dynamic_get as $view) - { - // fix alias to use in code - $view->code = StringHelper::safe($code); - $view->Code = StringHelper::safe( - $view->code, 'F' - ); - $view->CODE = StringHelper::safe( - $view->code, 'U' - ); - $main = ''; - if ($view->gettype == 3) - { - // SITE_GET_ITEM <<>> - $main .= PHP_EOL . PHP_EOL . Indent::_(2) - . "if (!isset(\$this->initSet) || !\$this->initSet)"; - $main .= PHP_EOL . Indent::_(2) . "{"; - $main .= PHP_EOL . Indent::_(3) - . "\$this->user = JFactory::getUser();"; - $main .= PHP_EOL . Indent::_(3) - . "\$this->userId = \$this->user->get('id');"; - $main .= PHP_EOL . Indent::_(3) - . "\$this->guest = \$this->user->get('guest');"; - $main .= PHP_EOL . Indent::_(3) - . "\$this->groups = \$this->user->get('groups');"; - $main .= PHP_EOL . Indent::_(3) - . "\$this->authorisedGroups = \$this->user->getAuthorisedGroups();"; - $main .= PHP_EOL . Indent::_(3) - . "\$this->levels = \$this->user->getAuthorisedViewLevels();"; - $main .= PHP_EOL . Indent::_(3) . "\$this->initSet = true;"; - $main .= PHP_EOL . Indent::_(2) . "}"; - $main .= $this->setCustomViewGetItem( - $view, $view->code, '', 'custom' - ); - $type - = 'mixed item data object on success, false on failure.'; - } - elseif ($view->gettype == 4) - { - $main .= PHP_EOL . PHP_EOL . Indent::_(2) - . "if (!isset(\$this->initSet) || !\$this->initSet)"; - $main .= PHP_EOL . Indent::_(2) . "{"; - $main .= PHP_EOL . Indent::_(3) - . "\$this->user = JFactory::getUser();"; - $main .= PHP_EOL . Indent::_(3) - . "\$this->userId = \$this->user->get('id');"; - $main .= PHP_EOL . Indent::_(3) - . "\$this->guest = \$this->user->get('guest');"; - $main .= PHP_EOL . Indent::_(3) - . "\$this->groups = \$this->user->get('groups');"; - $main .= PHP_EOL . Indent::_(3) - . "\$this->authorisedGroups = \$this->user->getAuthorisedGroups();"; - $main .= PHP_EOL . Indent::_(3) - . "\$this->levels = \$this->user->getAuthorisedViewLevels();"; - $main .= PHP_EOL . Indent::_(3) . "\$this->initSet = true;"; - $main .= PHP_EOL . Indent::_(2) . "}"; - $main .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Get the global params"; - $main .= PHP_EOL . Indent::_(2) - . "\$globalParams = JComponentHelper::getParams('com_" - . CFactory::_('Config')->component_code_name . "', true);"; - // set php before listquery - if (isset($view->add_php_getlistquery) - && $view->add_php_getlistquery == 1 - && isset($view->php_getlistquery) - && StringHelper::check( - $view->php_getlistquery - )) - { - $main .= CFactory::_('Placeholder')->update_( - $view->php_getlistquery - ); - } - // SITE_GET_LIST_QUERY <<>> - $main .= $this->setCustomViewListQuery( - $view, $view->code, false - ); - // set before items php - if (isset($view->add_php_before_getitems) - && $view->add_php_before_getitems == 1 - && isset($view->php_before_getitems) - && StringHelper::check( - $view->php_before_getitems - )) - { - $main .= CFactory::_('Placeholder')->update_( - $view->php_before_getitems - ); - } - // load the object list - $main .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) - . " Reset the query using our newly populated query object."; - $main .= PHP_EOL . Indent::_(2) - . "\$db->setQuery(\$query);"; - $main .= PHP_EOL . Indent::_(2) - . "\$items = \$db->loadObjectList();"; - // set after items php - if (isset($view->add_php_after_getitems) - && $view->add_php_after_getitems == 1 - && isset($view->php_after_getitems) - && StringHelper::check( - $view->php_after_getitems - )) - { - $main .= CFactory::_('Placeholder')->update_( - $view->php_after_getitems - ); - } - $main .= PHP_EOL . PHP_EOL . Indent::_(2) - . "if (empty(\$items))"; - $main .= PHP_EOL . Indent::_(2) . "{"; - $main .= PHP_EOL . Indent::_(3) . "return false;"; - $main .= PHP_EOL . Indent::_(2) . "}"; - // SITE_GET_ITEMS <<>> - $main .= $this->setCustomViewGetItems($view, $view->code); - $main .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " return items"; - $main .= PHP_EOL . Indent::_(2) . "return \$items;"; - $type - = 'mixed An array of objects on success, false on failure.'; - } - // load the main mehtod - $methods .= $this->setMainCustomMehtod( - $main, $view->getcustom, $type - ); - // SITE_CUSTOM_METHODS <<>> - $methods .= $this->setCustomViewCustomItemMethods( - $view, $view->code - ); - } - } - // load uikit get method - if (ArrayHelper::check($main_view) - && isset($main_view['settings'])) - { - $methods .= $this->setUikitGetMethod(); - } - - return $methods; - } - - public function setUikitHelperMethods() - { - // only load for uikit version 2 - if (2 == CFactory::_('Config')->uikit || 1 == CFactory::_('Config')->uikit) - { - // build uikit get method - $ukit = array(); - $ukit[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $ukit[] = Indent::_(1) . " * UIKIT Component Classes"; - $ukit[] = Indent::_(1) . " **/"; - $ukit[] = Indent::_(1) . "public static \$uk_components = array("; - $ukit[] = Indent::_(3) . "'data-uk-grid' => array("; - $ukit[] = Indent::_(4) . "'grid' ),"; - $ukit[] = Indent::_(3) . "'uk-accordion' => array("; - $ukit[] = Indent::_(4) . "'accordion' ),"; - $ukit[] = Indent::_(3) . "'uk-autocomplete' => array("; - $ukit[] = Indent::_(4) . "'autocomplete' ),"; - $ukit[] = Indent::_(3) . "'data-uk-datepicker' => array("; - $ukit[] = Indent::_(4) . "'datepicker' ),"; - $ukit[] = Indent::_(3) . "'uk-form-password' => array("; - $ukit[] = Indent::_(4) . "'form-password' ),"; - $ukit[] = Indent::_(3) . "'uk-form-select' => array("; - $ukit[] = Indent::_(4) . "'form-select' ),"; - $ukit[] = Indent::_(3) . "'data-uk-htmleditor' => array("; - $ukit[] = Indent::_(4) . "'htmleditor' ),"; - $ukit[] = Indent::_(3) . "'data-uk-lightbox' => array("; - $ukit[] = Indent::_(4) . "'lightbox' ),"; - $ukit[] = Indent::_(3) . "'uk-nestable' => array("; - $ukit[] = Indent::_(4) . "'nestable' ),"; - $ukit[] = Indent::_(3) . "'UIkit.notify' => array("; - $ukit[] = Indent::_(4) . "'notify' ),"; - $ukit[] = Indent::_(3) . "'data-uk-parallax' => array("; - $ukit[] = Indent::_(4) . "'parallax' ),"; - $ukit[] = Indent::_(3) . "'uk-search' => array("; - $ukit[] = Indent::_(4) . "'search' ),"; - $ukit[] = Indent::_(3) . "'uk-slider' => array("; - $ukit[] = Indent::_(4) . "'slider' ),"; - $ukit[] = Indent::_(3) . "'uk-slideset' => array("; - $ukit[] = Indent::_(4) . "'slideset' ),"; - $ukit[] = Indent::_(3) . "'uk-slideshow' => array("; - $ukit[] = Indent::_(4) . "'slideshow',"; - $ukit[] = Indent::_(4) . "'slideshow-fx' ),"; - $ukit[] = Indent::_(3) . "'uk-sortable' => array("; - $ukit[] = Indent::_(4) . "'sortable' ),"; - $ukit[] = Indent::_(3) . "'data-uk-sticky' => array("; - $ukit[] = Indent::_(4) . "'sticky' ),"; - $ukit[] = Indent::_(3) . "'data-uk-timepicker' => array("; - $ukit[] = Indent::_(4) . "'timepicker' ),"; - $ukit[] = Indent::_(3) . "'data-uk-tooltip' => array("; - $ukit[] = Indent::_(4) . "'tooltip' ),"; - $ukit[] = Indent::_(3) . "'uk-placeholder' => array("; - $ukit[] = Indent::_(4) . "'placeholder' ),"; - $ukit[] = Indent::_(3) . "'uk-dotnav' => array("; - $ukit[] = Indent::_(4) . "'dotnav' ),"; - $ukit[] = Indent::_(3) . "'uk-slidenav' => array("; - $ukit[] = Indent::_(4) . "'slidenav' ),"; - $ukit[] = Indent::_(3) . "'uk-form' => array("; - $ukit[] = Indent::_(4) . "'form-advanced' ),"; - $ukit[] = Indent::_(3) . "'uk-progress' => array("; - $ukit[] = Indent::_(4) . "'progress' ),"; - $ukit[] = Indent::_(3) . "'upload-drop' => array("; - $ukit[] = Indent::_(4) . "'upload', 'form-file' )"; - $ukit[] = Indent::_(3) . ");"; - $ukit[] = PHP_EOL . Indent::_(1) . "/**"; - $ukit[] = Indent::_(1) . " * Add UIKIT Components"; - $ukit[] = Indent::_(1) . " **/"; - $ukit[] = Indent::_(1) . "public static \$uikit = false;"; - $ukit[] = ""; - $ukit[] = Indent::_(1) . "/**"; - $ukit[] = Indent::_(1) . " * Get UIKIT Components"; - $ukit[] = Indent::_(1) . " **/"; - $ukit[] = Indent::_(1) - . "public static function getUikitComp(\$content,\$classes = array())"; - $ukit[] = Indent::_(1) . "{"; - $ukit[] = Indent::_(2) - . "if (strpos(\$content,'class=\"uk-') !== false)"; - $ukit[] = Indent::_(2) . "{"; - $ukit[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " reset"; - $ukit[] = Indent::_(3) . "\$temp = array();"; - $ukit[] = Indent::_(3) - . "foreach (self::\$uk_components as \$looking => \$add)"; - $ukit[] = Indent::_(3) . "{"; - $ukit[] = Indent::_(4) - . "if (strpos(\$content,\$looking) !== false)"; - $ukit[] = Indent::_(4) . "{"; - $ukit[] = Indent::_(5) . "\$temp[] = \$looking;"; - $ukit[] = Indent::_(4) . "}"; - $ukit[] = Indent::_(3) . "}"; - $ukit[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " make sure uikit is loaded to config"; - $ukit[] = Indent::_(3) - . "if (strpos(\$content,'class=\"uk-') !== false)"; - $ukit[] = Indent::_(3) . "{"; - $ukit[] = Indent::_(4) . "self::\$uikit = true;"; - $ukit[] = Indent::_(3) . "}"; - $ukit[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " sorter"; - $ukit[] = Indent::_(3) . "if (self::checkArray(\$temp))"; - $ukit[] = Indent::_(3) . "{"; - $ukit[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " merger"; - $ukit[] = Indent::_(4) . "if (self::checkArray(\$classes))"; - $ukit[] = Indent::_(4) . "{"; - $ukit[] = Indent::_(5) - . "\$newTemp = array_merge(\$temp,\$classes);"; - $ukit[] = Indent::_(5) . "\$temp = array_unique(\$newTemp);"; - $ukit[] = Indent::_(4) . "}"; - $ukit[] = Indent::_(4) . "return \$temp;"; - $ukit[] = Indent::_(3) . "}"; - $ukit[] = Indent::_(2) . "}"; - $ukit[] = Indent::_(2) . "if (self::checkArray(\$classes))"; - $ukit[] = Indent::_(2) . "{"; - $ukit[] = Indent::_(3) . "return \$classes;"; - $ukit[] = Indent::_(2) . "}"; - $ukit[] = Indent::_(2) . "return false;"; - $ukit[] = Indent::_(1) . "}"; - - // return the help methods - return implode(PHP_EOL, $ukit); - } - - return ''; - } - - public function setUikitGetMethod() - { - $method = ''; - // only load for uikit version 2 - if (2 == CFactory::_('Config')->uikit || 1 == CFactory::_('Config')->uikit) - { - // build uikit get method - $method .= PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $method .= PHP_EOL . Indent::_(1) - . " * Get the uikit needed components"; - $method .= PHP_EOL . Indent::_(1) . " *"; - $method .= PHP_EOL . Indent::_(1) - . " * @return mixed An array of objects on success."; - $method .= PHP_EOL . Indent::_(1) . " *"; - $method .= PHP_EOL . Indent::_(1) . " */"; - $method .= PHP_EOL . Indent::_(1) - . "public function getUikitComp()"; - $method .= PHP_EOL . Indent::_(1) . "{"; - $method .= PHP_EOL . Indent::_(2) - . "if (isset(\$this->uikitComp) && " - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkArray(\$this->uikitComp))"; - $method .= PHP_EOL . Indent::_(2) . "{"; - $method .= PHP_EOL . Indent::_(3) . "return \$this->uikitComp;"; - $method .= PHP_EOL . Indent::_(2) . "}"; - $method .= PHP_EOL . Indent::_(2) . "return false;"; - $method .= PHP_EOL . Indent::_(1) . "}"; - } - - return $method; - } - - public function setMainCustomMehtod(&$body, $nAme, $type) - { - $method = ''; - if (StringHelper::check($body)) - { - // build custom method - $method .= PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $method .= PHP_EOL . Indent::_(1) . " * Custom Method"; - $method .= PHP_EOL . Indent::_(1) . " *"; - $method .= PHP_EOL . Indent::_(1) . " * @return " . $type; - $method .= PHP_EOL . Indent::_(1) . " *"; - $method .= PHP_EOL . Indent::_(1) . " */"; - $method .= PHP_EOL . Indent::_(1) . "public function " . $nAme - . "()"; - $method .= PHP_EOL . Indent::_(1) . "{" . $body; - $method .= PHP_EOL . Indent::_(1) . "}"; - } - - return $method; - } - - public function setCustomViewCustomItemMethods(&$main_get, $code) - { - $methods = ''; - $this->JEventDispatcher = ''; - // first set the needed item/s methods - if (ObjectHelper::check($main_get)) - { - if (isset($main_get->custom_get) - && ArrayHelper::check($main_get->custom_get)) - { - foreach ($main_get->custom_get as $get) - { - // set the site decription switch - foreach (CFactory::_('Config')->cryption_types as $cryptionType) - { - CFactory::_('Compiler.Builder.Site.Decrypt')->set("{$cryptionType}.{$code}", false); - } - // set the method defaults - if (($default = $this->setCustomViewMethodDefaults($get, $code)) !== false) - { - // build custom method - $methods .= PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $methods .= PHP_EOL . Indent::_(1) - . " * Method to get an array of " . $default['name'] - . " Objects."; - $methods .= PHP_EOL . Indent::_(1) . " *"; - $methods .= PHP_EOL . Indent::_(1) - . " * @return mixed An array of " - . $default['name'] - . " Objects on success, false on failure."; - $methods .= PHP_EOL . Indent::_(1) . " *"; - $methods .= PHP_EOL . Indent::_(1) . " */"; - $methods .= PHP_EOL . Indent::_(1) - . "public function get" . $default['methodName'] - . "(\$" . $default['on_field'] . ")"; - $methods .= PHP_EOL . Indent::_(1) . "{" . Placefix::_h("CRYPT") ; - $methods .= PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) - . " Get a db connection."; - $methods .= PHP_EOL . Indent::_(2) - . "\$db = JFactory::getDbo();"; - $methods .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) - . " Create a new query object."; - $methods .= PHP_EOL . Indent::_(2) - . "\$query = \$db->getQuery(true);"; - $methods .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Get from " - . $get['selection']['table'] . " as " - . $default['as']; - $methods .= PHP_EOL . Indent::_(2) - . $get['selection']['select']; - $methods .= PHP_EOL . Indent::_(2) . '$query->from(' - . $get['selection']['from'] . ');'; - // set the string - if ($get['operator'] === 'IN' - || $get['operator'] === 'NOT IN') - { - $methods .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Check if \$" - . $default['on_field'] - . " is an array with values."; - $methods .= PHP_EOL . Indent::_(2) . "\$array = (" - . CFactory::_('Compiler.Builder.Content.One')->get('Component') - . "Helper::checkJson(\$" - . $default['on_field'] - . ", true)) ? json_decode(\$" - . $default['on_field'] . ",true) : \$" - . $default['on_field'] . ";"; - $methods .= PHP_EOL . Indent::_(2) - . "if (isset(\$array) && " - . CFactory::_('Compiler.Builder.Content.One')->get('Component') - . "Helper::checkArray(\$array, true))"; - $methods .= PHP_EOL . Indent::_(2) . "{"; - $methods .= PHP_EOL . Indent::_(3) - . "\$query->where('" . $get['join_field'] . " " - . $get['operator'] - . " (' . implode(',', \$array) . ')');"; - $methods .= PHP_EOL . Indent::_(2) . "}"; - $methods .= PHP_EOL . Indent::_(2) . "else"; - $methods .= PHP_EOL . Indent::_(2) . "{"; - $methods .= PHP_EOL . Indent::_(3) - . "return false;"; - $methods .= PHP_EOL . Indent::_(2) . "}"; - } - else - { - $methods .= PHP_EOL . Indent::_(2) - . "\$query->where('" . $get['join_field'] . " " - . $get['operator'] . " ' . \$db->quote(\$" - . $default['on_field'] . "));"; - } - // check if other queries should be loaded - foreach (CFactory::_('Compiler.Builder.Other.Query')-> - get(CFactory::_('Config')->build_target . '.' . $default['code'] . '.' . $default['as'], []) - as $query) - { - $methods .= $query; - } - // add any other filter that was set - foreach (CFactory::_('Compiler.Builder.Other.Filter')-> - get(CFactory::_('Config')->build_target . '.' . $default['code'] . '.' . $default['as'], []) - as $field => $string) - { - $methods .= $string; - } - // add any other where that was set - foreach (CFactory::_('Compiler.Builder.Other.Where')-> - get(CFactory::_('Config')->build_target . '.' . $default['code'] . '.' . $default['as'], []) - as $field => $string) - { - $methods .= $string; - } - // add any other order that was set - foreach (CFactory::_('Compiler.Builder.Other.Order')-> - get(CFactory::_('Config')->build_target . '.' . $default['code'] . '.' . $default['as'], []) - as $field => $string) - { - $methods .= $string; - } - // add any other grouping that was set - foreach (CFactory::_('Compiler.Builder.Other.Group')-> - get(CFactory::_('Config')->build_target . '.' . $default['code'] . '.' . $default['as'], []) - as $field => $string) - { - $methods .= $string; - } - $methods .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) - . " Reset the query using our newly populated query object."; - $methods .= PHP_EOL . Indent::_(2) - . "\$db->setQuery(\$query);"; - $methods .= PHP_EOL . Indent::_(2) . "\$db->execute();"; - $methods .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) - . " check if there was data returned"; - $methods .= PHP_EOL . Indent::_(2) - . "if (\$db->getNumRows())"; - $methods .= PHP_EOL . Indent::_(2) . "{"; - // set dispatcher placeholder - $methods .= Placefix::_h("DISPATCHER"); - // build path - $path = $default['code'] . '.' . $get['key'] . '.' . $default['as']; - // set decoding of needed fields - $decodeChecker = CFactory::_('Compiler.Builder.Site.Field.Data')->get('decode.' . $path); - // also filter fields if needed - $decodeFilter = CFactory::_('Compiler.Builder.Site.Field.Decode.Filter')-> - get(CFactory::_('Config')->build_target . '.' . $path); - // set uikit checkers on needed fields - $uikitChecker = CFactory::_('Compiler.Builder.Site.Field.Data')->get('uikit.' . $path); - // set content prepare on needed fields - $contentprepareChecker = CFactory::_('Compiler.Builder.Site.Field.Data')-> - get('textareas.' . $path); - // set placeholder values - $placeholders = [ - Placefix::_h('TAB') => Indent::_(2), - Placefix::_h('STRING') => '$item' - ]; - // set joined values - $joinedChecker = CFactory::_('Compiler.Builder.Other.Join')-> - get(CFactory::_('Config')->build_target . '.' . $default['code'] . '.' . $default['as']); - if ($decodeChecker !== null || $uikitChecker !== null - || $decodeFilter !== null || $contentprepareChecker !== null - || $joinedChecker !== null) - { - $decoder = ''; - if ($decodeChecker !== null && ArrayHelper::check($decodeChecker)) - { - // also filter fields if needed - $decoder = $this->setCustomViewFieldDecode( - $get, $decodeChecker, '$item', - $default['code'], Indent::_(2) - ); - } - $decoder_filter = ''; - if ($decodeFilter !== null && ArrayHelper::check($decodeFilter)) - { - $decoder_filter - = $this->setCustomViewFieldDecodeFilter( - $get, $decodeFilter, '$item', '$items[$nr]', - $default['code'], Indent::_(2) - ); - } - $contentprepare = ''; - if ($contentprepareChecker !== null && ArrayHelper::check($contentprepareChecker)) - { - $contentprepare - = $this->setCustomViewFieldonContentPrepareChecker( - $get, $contentprepareChecker, '$item', - $default['code'], Indent::_(2) - ); - } - $uikit = ''; - if ($uikitChecker !== null && ArrayHelper::check($uikitChecker)) - { - $uikit = $this->setCustomViewFieldUikitChecker( - $get, $uikitChecker, '$item', - $default['code'], Indent::_(2) - ); - } - $joine = ''; - if ($joinedChecker !== null && ArrayHelper::check($joinedChecker)) - { - foreach ($joinedChecker as $joinedString) - { - $joine .= CFactory::_('Placeholder')->update( - $joinedString, $placeholders - ); - } - } - if (StringHelper::check($decoder) || StringHelper::check($contentprepare) - || StringHelper::check($uikit) || StringHelper::check($decoder_filter) - || StringHelper::check($joine)) - { - $methods .= PHP_EOL . Indent::_(3) - . "\$items = \$db->loadObjectList();"; - $methods .= PHP_EOL . PHP_EOL . Indent::_(3) - . "//" . Line::_(__Line__, __Class__) - . " Convert the parameter fields into objects."; - $methods .= PHP_EOL . Indent::_(3) - . "foreach (\$items as \$nr => &\$item)"; - $methods .= PHP_EOL . Indent::_(3) . "{"; - if (StringHelper::check($decoder)) - { - $methods .= $decoder; - } - if (StringHelper::check($decoder_filter)) - { - $methods .= $decoder_filter; - } - if (StringHelper::check($contentprepare)) - { - $methods .= $contentprepare; - } - if (StringHelper::check($uikit)) - { - $methods .= $uikit; - } - if (StringHelper::check($joine)) - { - $methods .= $joine; - } - $methods .= PHP_EOL . Indent::_(3) . "}"; - $methods .= PHP_EOL . Indent::_(3) - . "return \$items;"; - } - else - { - $methods .= PHP_EOL . Indent::_(3) - . "return \$db->loadObjectList();"; - } - } - else - { - $methods .= PHP_EOL . Indent::_(3) - . "return \$db->loadObjectList();"; - } - $methods .= PHP_EOL . Indent::_(2) . "}"; - $methods .= PHP_EOL . Indent::_(2) . "return false;"; - $methods .= PHP_EOL . Indent::_(1) . "}"; - - // set the script if it was found - $Component = CFactory::_('Compiler.Builder.Content.One')->get('Component'); - $script = ''; - foreach (CFactory::_('Config')->cryption_types as $cryptionType) - { - if (CFactory::_('Compiler.Builder.Site.Decrypt')->get("{$cryptionType}.{$code}", false)) - { - if ('expert' !== $cryptionType) - { - $script .= PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Get the " - . $cryptionType . " encryption."; - $script .= PHP_EOL . Indent::_(2) . "\$" - . $cryptionType . "key = " . $Component - . "Helper::getCryptKey('" - . $cryptionType . "');"; - $script .= PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) - . " Get the encryption object."; - $script .= PHP_EOL . Indent::_(2) . "\$" - . $cryptionType - . " = new Super___99175f6d_dba8_4086_8a65_5c4ec175e61d___Power(\$" - . $cryptionType . "key);" . PHP_EOL; - } - elseif (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> - exists("{$code}.get")) - { - foreach (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> - exists("{$code}.get") as $block) - { - $script .= PHP_EOL . Indent::_(2) . implode( - PHP_EOL . Indent::_(2), $block - ); - } - } - } - } - $methods = str_replace( - Placefix::_h('CRYPT'), $script, $methods - ); - } - } - // insure the crypt placeholder is removed - if (StringHelper::check($methods)) - { - $methods = str_replace( - Placefix::_h('CRYPT'), '', $methods - ); - } - } - } - // only update if dispacher placholder is found - if (strpos($methods, (string) Placefix::_h('DISPATCHER')) !== false) - { - // check if the dispather should be added - if (!isset($this->JEventDispatcher) - || !ArrayHelper::check($this->JEventDispatcher)) - { - $this->JEventDispatcher = array(Placefix::_h('DISPATCHER') => ''); - } - $methods = str_replace( - array_keys($this->JEventDispatcher), - array_values($this->JEventDispatcher), $methods - ); - } - // insure the crypt placeholder is removed - if (StringHelper::check($methods)) - { - return $methods . PHP_EOL; - } - - return ''; - } - - public function setCustomViewMethodDefaults($get, $code) - { - if (isset($get['key']) && isset($get['as'])) - { - $key = substr( - (string) StringHelper::safe( - preg_replace('/[0-9]+/', '', md5((string) $get['key'])), 'F' - ), 0, 4 - ); - $method['on_field'] = (isset($get['on_field'])) - ? $this->removeAsDot($get['on_field']) : null; - $method['join_field'] = (isset($get['join_field'])) - ? StringHelper::safe( - $this->removeAsDot($get['join_field']) - ) : null; - $method['Join_field'] = (isset($method['join_field'])) - ? StringHelper::safe($method['join_field'], 'F') - : null; - $method['name'] = StringHelper::safe( - $get['selection']['name'], 'F' - ); - $method['code'] = StringHelper::safe($code); - $method['AS'] = StringHelper::safe( - $get['as'], 'U' - ); - $method['as'] = StringHelper::safe( - $get['as'] - ); - $method['valueName'] = $method['on_field'] . $method['Join_field'] - . $method['name'] . $method['AS']; - $method['methodName'] = StringHelper::safe( - $method['on_field'], 'F' - ) . $method['Join_field'] . $method['name'] . $key . '_' - . $method['AS']; - - // return - return $method; - } - - return false; - } - - public function setCustomViewListQuery(&$get, $code, $return = true) - { - if (ObjectHelper::check($get)) - { - if ($get->pagination == 1) - { - $getItem = PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Get a db connection."; - } - else - { - $getItem = PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) - . " Make sure all records load, since no pagination allowed."; - $getItem .= PHP_EOL . Indent::_(2) - . "\$this->setState('list.limit', 0);"; - $getItem .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Get a db connection."; - } - $getItem .= PHP_EOL . Indent::_(2) . "\$db = JFactory::getDbo();"; - $getItem .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Create a new query object."; - $getItem .= PHP_EOL . Indent::_(2) - . "\$query = \$db->getQuery(true);"; - // set main get query - $getItem .= $this->setCustomViewQuery($get->main_get, $code); - // check if there is any custom script - $getItem .= CFactory::_('Customcode.Dispenser')->get( - CFactory::_('Config')->build_target . '_php_getlistquery', $code, '', - PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Filtering.", true - ); - // setup filters - if (isset($get->filter)) - { - $getItem .= $this->setCustomViewFilter($get->filter, $code); - } - // setup where - if (isset($get->where)) - { - $getItem .= $this->setCustomViewWhere($get->where, $code); - } - // setup ordering - if (isset($get->order)) - { - $getItem .= $this->setCustomViewOrder($get->order, $code); - } - // setup grouping - if (isset($get->group)) - { - $getItem .= $this->setCustomViewGroup($get->group, $code); - } - if ($return) - { - // return the query object - $getItem .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " return the query object" - . PHP_EOL . Indent::_(2) . "return \$query;"; - } - - return $getItem; - } - - return PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . "add your custom code here."; - } - - /** - * @param $get - * @param $code - * - * @return string - */ - public function setCustomViewGetItems(&$get, $code) - { - $getItem = ''; - // set the site decrypt switch - foreach (CFactory::_('Config')->cryption_types as $cryptionType) - { - CFactory::_('Compiler.Builder.Site.Decrypt')->set("{$cryptionType}.{$code}", false); - } - // set the component name - $Component = CFactory::_('Compiler.Builder.Content.One')->get('Component'); - // start load the get item - if (ObjectHelper::check($get)) - { - $getItem .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) - . " Insure all item fields are adapted where needed."; - $getItem .= PHP_EOL . Indent::_(2) . "if (" . $Component - . "Helper::checkArray(\$items))"; - $getItem .= PHP_EOL . Indent::_(2) . "{"; - $getItem .= Placefix::_h("DISPATCHER") ; - $getItem .= PHP_EOL . Indent::_(3) - . "foreach (\$items as \$nr => &\$item)"; - $getItem .= PHP_EOL . Indent::_(3) . "{"; - $getItem .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Always create a slug for sef URL's"; - $getItem .= PHP_EOL . Indent::_(4) - . "\$item->slug = (isset(\$item->alias) && isset(\$item->id)) ? \$item->id.':'.\$item->alias : \$item->id;"; - if (isset($get->main_get) - && ArrayHelper::check( - $get->main_get - )) - { - $asBucket = array(); - foreach ($get->main_get as $main_get) - { - // build path - $path = $code . '.' . $main_get['key'] . '.' . $main_get['as']; - - $decodeChecker = CFactory::_('Compiler.Builder.Site.Field.Data')->get('decode.' . $path); - if (ArrayHelper::check($decodeChecker)) - { - // set decoding of needed fields - $getItem .= $this->setCustomViewFieldDecode( - $main_get, $decodeChecker, "\$item", $code, - Indent::_(2) - ); - } - - // also filter fields if needed - $decodeFilter = CFactory::_('Compiler.Builder.Site.Field.Decode.Filter')-> - get(CFactory::_('Config')->build_target . '.' . $path); - if (ArrayHelper::check($decodeFilter)) - { - $getItem .= $this->setCustomViewFieldDecodeFilter( - $main_get, $decodeFilter, "\$item", - '$items[$nr]', $code, Indent::_(2) - ); - } - - $contentprepareChecker = CFactory::_('Compiler.Builder.Site.Field.Data')->get('textareas.' . $path); - if (ArrayHelper::check($contentprepareChecker)) - { - // set contentprepare checkers on needed fields - $getItem .= $this->setCustomViewFieldonContentPrepareChecker( - $main_get, $contentprepareChecker, "\$item", - $code, Indent::_(2) - ); - } - - $uikitChecker = CFactory::_('Compiler.Builder.Site.Field.Data')->get('uikit.' . $path); - if (ArrayHelper::check($uikitChecker)) - { - // set uikit checkers on needed fields - $getItem .= $this->setCustomViewFieldUikitChecker( - $main_get, $uikitChecker, "\$item", $code, - Indent::_(2) - ); - } - - $asBucket[] = $main_get['as']; - } - } - // only update if dispacher placholder is found - if (strpos($getItem, (string) Placefix::_h('DISPATCHER')) - !== false) - { - // check if the dispather should be added - if (!isset($this->JEventDispatcher) - || !ArrayHelper::check( - $this->JEventDispatcher - )) - { - $this->JEventDispatcher = array(Placefix::_h('DISPATCHER') => ''); - } - $getItem = str_replace( - array_keys($this->JEventDispatcher), - array_values($this->JEventDispatcher), $getItem - ); - } - // setup Globals - $getItem .= $this->setCustomViewGlobals( - $get->global, '$item', $asBucket, Indent::_(2) - ); - // setup the custom gets that returns multipal values - $getItem .= $this->setCustomViewCustomJoin( - $get->custom_get, "\$item", $code, $asBucket, Indent::_(2) - ); - // set calculations - if ($get->addcalculation == 1) - { - $get->php_calculation = (array) explode( - PHP_EOL, (string) $get->php_calculation - ); - if (ArrayHelper::check($get->php_calculation)) - { - $_tmp = PHP_EOL . Indent::_(4) . implode( - PHP_EOL . Indent::_(4), $get->php_calculation - ); - $getItem .= CFactory::_('Placeholder')->update_( - $_tmp - ); - } - } - $getItem .= PHP_EOL . Indent::_(3) . "}"; - $getItem .= PHP_EOL . Indent::_(2) . "}"; - // remove empty foreach - if (strlen($getItem) <= 100) - { - $getItem = PHP_EOL; - } - } - - // set the script if found - $script = ''; - foreach (CFactory::_('Config')->cryption_types as $cryptionType) - { - if (CFactory::_('Compiler.Builder.Site.Decrypt')->get("{$cryptionType}.{$code}", false)) - { - if ('expert' !== $cryptionType) - { - $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Get the " . $cryptionType - . " encryption."; - $script .= PHP_EOL . Indent::_(2) . "\$" . $cryptionType - . "key = " . $Component . "Helper::getCryptKey('" - . $cryptionType . "');"; - $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Get the encryption object."; - $script .= PHP_EOL . Indent::_(2) . "\$" . $cryptionType - . " = new Super___99175f6d_dba8_4086_8a65_5c4ec175e61d___Power(\$" . $cryptionType . "key);"; - } - elseif (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> - exists("{$code}.get")) - { - foreach (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> - get("{$code}.get") as $block) - { - $script .= PHP_EOL . Indent::_(2) . implode( - PHP_EOL . Indent::_(2), $block - ); - } - } - } - } - - return $script . $getItem; - } - - /** - * build code for the admin view display method - * - * @param string $nameListCode The list view name - * - * @return string The php to place in view.html.php - * - */ - public function setAdminViewDisplayMethod($nameListCode) - { - $script = ''; - // add the new filter methods for the search toolbar above the list view (2 = topbar) - if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2) - { - $script .= PHP_EOL . Indent::_(2) . "//" - . Line::_( - __LINE__,__CLASS__ - ) . " Load the filter form from xml."; - $script .= PHP_EOL . Indent::_(2) . "\$this->filterForm " - . "= \$this->get('FilterForm');"; - $script .= PHP_EOL . Indent::_(2) . "//" - . Line::_( - __LINE__,__CLASS__ - ) . " Load the active filters."; - $script .= PHP_EOL . Indent::_(2) . "\$this->activeFilters " - . "= \$this->get('ActiveFilters');"; - } - // get the default ordering values - $default_ordering = $this->getListViewDefaultOrdering($nameListCode); - // now add the default ordering - $script .= PHP_EOL . Indent::_(2) . "//" - . Line::_( - __LINE__,__CLASS__ - ) . " Add the list ordering clause."; - $script .= PHP_EOL . Indent::_(2) - . "\$this->listOrder = \$this->escape(\$this->state->get('list.ordering', '" - . $default_ordering['name'] . "'));"; - $script .= PHP_EOL . Indent::_(2) - . "\$this->listDirn = \$this->escape(\$this->state->get('list.direction', '" - . $default_ordering['direction'] . "'));"; - - return $script; - } - - public function setCustomViewDisplayMethod(&$view) - { - $method = ''; - if (isset($view['settings']->main_get) - && ObjectHelper::check($view['settings']->main_get)) - { - - // add events if needed - if ($view['settings']->main_get->gettype == 1 - && ArrayHelper::check( - $view['settings']->main_get->plugin_events - )) - { - // load the dispatcher - $method .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Initialise dispatcher."; - $method .= PHP_EOL . Indent::_(2) - . "\$dispatcher = JEventDispatcher::getInstance();"; - } - if ($view['settings']->main_get->gettype == 1) - { - // for single views - $method .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Initialise variables."; - $method .= PHP_EOL . Indent::_(2) - . "\$this->item = \$this->get('Item');"; - } - elseif ($view['settings']->main_get->gettype == 2) - { - // for list views - $method .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Initialise variables."; - $method .= PHP_EOL . Indent::_(2) - . "\$this->items = \$this->get('Items');"; - // only add if pagination is requered - if ($view['settings']->main_get->pagination == 1) - { - $method .= PHP_EOL . Indent::_(2) - . "\$this->pagination = \$this->get('Pagination');"; - } - } - // add the custom get methods - if (isset($view['settings']->custom_get) - && ArrayHelper::check( - $view['settings']->custom_get - )) - { - foreach ($view['settings']->custom_get as $custom_get) - { - $custom_get_name = str_replace( - 'get', '', (string) $custom_get->getcustom - ); - $method .= PHP_EOL . Indent::_(2) . "\$this->" - . StringHelper::safe($custom_get_name) - . " = \$this->get('" . $custom_get_name . "');"; - } - } - // add custom script - if ($view['settings']->add_php_jview_display == 1) - { - $view['settings']->php_jview_display = (array) explode( - PHP_EOL, (string) $view['settings']->php_jview_display - ); - if (ArrayHelper::check( - $view['settings']->php_jview_display - )) - { - $_tmp = PHP_EOL . Indent::_(2) . implode( - PHP_EOL . Indent::_(2), - $view['settings']->php_jview_display - ); - $method .= CFactory::_('Placeholder')->update_( - $_tmp - ); - } - } - if ('site' === CFactory::_('Config')->build_target) - { - $method .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Set the toolbar"; - $method .= PHP_EOL . Indent::_(2) . "\$this->addToolBar();"; - $method .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " set the document"; - $method .= PHP_EOL . Indent::_(2) - . "\$this->_prepareDocument();"; - } - elseif ('custom_admin' === CFactory::_('Config')->build_target) - { - $method .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) - . " We don't need toolbar in the modal window."; - $method .= PHP_EOL . Indent::_(2) - . "if (\$this->getLayout() !== 'modal')"; - $method .= PHP_EOL . Indent::_(2) . "{"; - $method .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " add the tool bar"; - $method .= PHP_EOL . Indent::_(3) . "\$this->addToolBar();"; - $method .= PHP_EOL . Indent::_(2) . "}"; - $method .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " set the document"; - $method .= PHP_EOL . Indent::_(2) . "\$this->setDocument();"; - } - - $method .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Check for errors."; - $method .= PHP_EOL . Indent::_(2) - . "if (count(\$errors = \$this->get('Errors')))"; - $method .= PHP_EOL . Indent::_(2) . "{"; - $method .= PHP_EOL . Indent::_(3) - . "throw new Exception(implode(PHP_EOL, \$errors), 500);"; - $method .= PHP_EOL . Indent::_(2) . "}"; - // add events if needed - if ($view['settings']->main_get->gettype == 1 - && ArrayHelper::check( - $view['settings']->main_get->plugin_events - )) - { - $method .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Process the content plugins."; - $method .= PHP_EOL . Indent::_(2) . "if (" - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkObject(\$this->item))"; - $method .= PHP_EOL . Indent::_(2) . "{"; - $method .= PHP_EOL . Indent::_(3) - . "JPluginHelper::importPlugin('content');"; - $method .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Setup Event Object."; - $method .= PHP_EOL . Indent::_(3) - . "\$this->item->event = new stdClass;"; - $method .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Check if item has params, or pass global params"; - $method .= PHP_EOL . Indent::_(3) - . "\$params = (isset(\$this->item->params) && " - . CFactory::_('Compiler.Builder.Content.One')->get('Component') - . "Helper::checkJson(\$this->item->params)) ? json_decode(\$this->item->params) : \$this->params;"; - // load the defaults - foreach ( - $view['settings']->main_get->plugin_events as $plugin_event - ) - { - // load the events - if ('onContentPrepare' === $plugin_event) - { - // TODO the onContentPrepare already gets triggered on the fields of its relation - // $method .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " onContentPrepare Event Trigger."; - // $method .= PHP_EOL . Indent::_(2) . "\$dispatcher->trigger('onContentPrepare', array ('com_" . CFactory::_('Config')->component_code_name . ".article', &\$this->item, &\$this->params, 0));"; - } - else - { - $method .= PHP_EOL . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) . " " . $plugin_event - . " Event Trigger."; - $method .= PHP_EOL . Indent::_(3) - . "\$results = \$dispatcher->trigger('" - . $plugin_event . "', array('com_" - . CFactory::_('Config')->component_code_name . "." - . $view['settings']->context - . "', &\$this->item, &\$params, 0));"; - $method .= PHP_EOL . Indent::_(3) - . '$this->item->event->' . $plugin_event - . ' = trim(implode("\n", $results));'; - } - } - $method .= PHP_EOL . Indent::_(2) . "}"; - } - $method .= PHP_EOL . PHP_EOL . Indent::_(2) - . "parent::display(\$tpl);"; - } - - return $method; - } - - public function setPrepareDocument(&$view) - { - // fix just incase we missed it somewhere - $tmp = CFactory::_('Config')->lang_target; - if ('site' === CFactory::_('Config')->build_target) - { - CFactory::_('Config')->lang_target = 'site'; - } - else - { - CFactory::_('Config')->lang_target = 'admin'; - } - - // ensure correct target is set - $TARGET = StringHelper::safe(CFactory::_('Config')->build_target, 'U'); - - // set libraries $TARGET.'_LIBRARIES_LOADER - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_LIBRARIES_LOADER', - $this->setLibrariesLoader($view) - ); - - // set uikit $TARGET.'_UIKIT_LOADER - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_UIKIT_LOADER', - $this->setUikitLoader($view) - ); - - // set Google Charts $TARGET.'_GOOGLECHART_LOADER - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' .$TARGET . '_GOOGLECHART_LOADER', - $this->setGoogleChartLoader($view) - ); - - // set Footable FOOTABLE_LOADER - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_FOOTABLE_LOADER', - $this->setFootableScriptsLoader($view) - ); - - // set metadata DOCUMENT_METADATA - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_DOCUMENT_METADATA', - $this->setDocumentMetadata($view) - ); - - // set custom php scripting DOCUMENT_CUSTOM_PHP - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_DOCUMENT_CUSTOM_PHP', - $this->setDocumentCustomPHP($view) - ); - - // set custom css DOCUMENT_CUSTOM_CSS - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' .$TARGET . '_DOCUMENT_CUSTOM_CSS', - $this->setDocumentCustomCSS($view) - ); - - // set custom javascript DOCUMENT_CUSTOM_JS - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_DOCUMENT_CUSTOM_JS', - $this->setDocumentCustomJS($view) - ); - - // set custom css file VIEWCSS - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_VIEWCSS', - $this->setCustomCSS($view) - ); - - // incase no buttons are found - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_JAVASCRIPT_FOR_BUTTONS', ''); - - // set the custom buttons CUSTOM_BUTTONS - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_CUSTOM_BUTTONS', - $this->setCustomButtons($view) - ); - - // see if we should add get modules to the view.html - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_GET_MODULE', - $this->setGetModules($view, $TARGET) - ); - - // set a JavaScript file if needed - CFactory::_('Compiler.Builder.Content.Multi')->add($view['settings']->code . '|' . $TARGET . '_LIBRARIES_LOADER', - $this->setJavaScriptFile($view, $TARGET), false - ); - // fix just incase we missed it somewhere - CFactory::_('Config')->lang_target = $tmp; - } - - public function setGetModules($view, $TARGET) - { - if (CFactory::_('Compiler.Builder.Get.Module')-> - exists(CFactory::_('Config')->build_target . '.' . $view['settings']->code)) - { - $addModule = array(); - $addModule[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $addModule[] = Indent::_(1) - . " * Get the modules published in a position"; - $addModule[] = Indent::_(1) . " */"; - $addModule[] = Indent::_(1) - . "public function getModules(\$position, \$seperator = '', \$class = '')"; - $addModule[] = Indent::_(1) . "{"; - $addModule[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " set default"; - $addModule[] = Indent::_(2) . "\$found = false;"; - $addModule[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " check if we aleady have these modules loaded"; - $addModule[] = Indent::_(2) - . "if (isset(\$this->setModules[\$position]))"; - $addModule[] = Indent::_(2) . "{"; - $addModule[] = Indent::_(3) . "\$found = true;"; - $addModule[] = Indent::_(2) . "}"; - $addModule[] = Indent::_(2) . "else"; - $addModule[] = Indent::_(2) . "{"; - $addModule[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " this is where you want to load your module position"; - $addModule[] = Indent::_(3) - . "\$modules = JModuleHelper::getModules(\$position);"; - $addModule[] = Indent::_(3) . "if (" - . CFactory::_('Compiler.Builder.Content.One')->get('Component') - . "Helper::checkArray(\$modules, true))"; - $addModule[] = Indent::_(3) . "{"; - $addModule[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " set the place holder"; - $addModule[] = Indent::_(4) - . "\$this->setModules[\$position] = array();"; - $addModule[] = Indent::_(4) . "foreach(\$modules as \$module)"; - $addModule[] = Indent::_(4) . "{"; - $addModule[] = Indent::_(5) - . "\$this->setModules[\$position][] = JModuleHelper::renderModule(\$module);"; - $addModule[] = Indent::_(4) . "}"; - $addModule[] = Indent::_(4) . "\$found = true;"; - $addModule[] = Indent::_(3) . "}"; - $addModule[] = Indent::_(2) . "}"; - $addModule[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " check if modules were found"; - $addModule[] = Indent::_(2) - . "if (\$found && isset(\$this->setModules[\$position]) && " - . CFactory::_('Compiler.Builder.Content.One')->get('Component') - . "Helper::checkArray(\$this->setModules[\$position]))"; - $addModule[] = Indent::_(2) . "{"; - $addModule[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " set class"; - $addModule[] = Indent::_(3) . "if (" - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkString(\$class))"; - $addModule[] = Indent::_(3) . "{"; - $addModule[] = Indent::_(4) - . "\$class = ' class=\"'.\$class.'\" ';"; - $addModule[] = Indent::_(3) . "}"; - $addModule[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " set seperating return values"; - $addModule[] = Indent::_(3) . "switch(\$seperator)"; - $addModule[] = Indent::_(3) . "{"; - $addModule[] = Indent::_(4) . "case 'none':"; - $addModule[] = Indent::_(5) - . "return implode('', \$this->setModules[\$position]);"; - $addModule[] = Indent::_(5) . "break;"; - $addModule[] = Indent::_(4) . "case 'div':"; - $addModule[] = Indent::_(5) - . "return ''.implode('
', \$this->setModules[\$position]).'
';"; - $addModule[] = Indent::_(5) . "break;"; - $addModule[] = Indent::_(4) . "case 'list':"; - $addModule[] = Indent::_(5) - . "return '
  • '.implode('
  • ', \$this->setModules[\$position]).'
  • ';"; - $addModule[] = Indent::_(5) . "break;"; - $addModule[] = Indent::_(4) . "case 'array':"; - $addModule[] = Indent::_(4) . "case 'Array':"; - $addModule[] = Indent::_(5) - . "return \$this->setModules[\$position];"; - $addModule[] = Indent::_(5) . "break;"; - $addModule[] = Indent::_(4) . "default:"; - $addModule[] = Indent::_(5) - . "return implode('
    ', \$this->setModules[\$position]);"; - $addModule[] = Indent::_(5) . "break;"; - $addModule[] = Indent::_(3) . "}"; - $addModule[] = Indent::_(2) . "}"; - $addModule[] = Indent::_(2) . "return false;"; - $addModule[] = Indent::_(1) . "}"; - - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_GET_MODULE_JIMPORT', - PHP_EOL . "use Joomla\CMS\Helper\ModuleHelper as JModuleHelper;" - ); - - return implode(PHP_EOL, $addModule); - } - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_GET_MODULE_JIMPORT', ''); - - return ''; - } - - public function setDocumentCustomPHP(&$view) - { - if ($view['settings']->add_php_document == 1) - { - $view['settings']->php_document = (array) explode( - PHP_EOL, (string) $view['settings']->php_document - ); - if (ArrayHelper::check( - $view['settings']->php_document - )) - { - $_tmp = PHP_EOL . Indent::_(2) . implode( - PHP_EOL . Indent::_(2), $view['settings']->php_document - ); - - return CFactory::_('Placeholder')->update_($_tmp); - } - } - - return ''; - } - - public function setCustomButtons(&$view, $type = 1, $tab = '') - { - // do not validate selection - $validateSelection = 'false'; - // ensure correct target is set - $TARGET = StringHelper::safe(CFactory::_('Config')->build_target, 'U'); - if (1 == $type || 2 == $type) - { - if (1 == $type) - { - $viewCodeName = $view['settings']->code; - } - if (2 == $type) - { - $viewCodeName = $view['settings']->name_single_code; - } - // set the custom buttons CUSTOM_BUTTONS_CONTROLLER - CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|' . $TARGET . '_CUSTOM_BUTTONS_CONTROLLER', ''); - // set the custom buttons CUSTOM_BUTTONS_METHOD - CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|' . $TARGET . '_CUSTOM_BUTTONS_METHOD', ''); - } - elseif (3 == $type) - { - // set the names - $viewCodeName = $view['settings']->name_single_code; - $viewsCodeName = $view['settings']->name_list_code; - // set the custom buttons CUSTOM_BUTTONS_CONTROLLER_LIST - CFactory::_('Compiler.Builder.Content.Multi')->set($viewsCodeName . '|' . $TARGET . '_CUSTOM_BUTTONS_CONTROLLER_LIST', ''); - // set the custom buttons CUSTOM_BUTTONS_METHOD_LIST - CFactory::_('Compiler.Builder.Content.Multi')->set($viewsCodeName . '|' . $TARGET . '_CUSTOM_BUTTONS_METHOD_LIST', ''); - // validate selection - $validateSelection = 'true'; - } - // reset buttons - $buttons = array(); - // if site add buttons to view - if (CFactory::_('Config')->build_target === 'site') - { - // set the custom buttons SITE_TOP_BUTTON - CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|SITE_TOP_BUTTON', ''); - // set the custom buttons SITE_BOTTOM_BUTTON - CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|SITE_BOTTOM_BUTTON', ''); - // load into place - switch ($view['settings']->button_position) - { - case 1: - // set buttons to top right of the view - CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|SITE_TOP_BUTTON', - '
    toolbar->render(); ?>
    ' - ); - break; - case 2: - // set buttons to top left of the view - CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|SITE_TOP_BUTTON', 'toolbar->render(); ?>'); - break; - case 3: - // set buttons to buttom right of the view - CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|SITE_BOTTOM_BUTTON', - '
    toolbar->render(); ?>
    ' - ); - break; - case 4: - // set buttons to buttom left of the view - CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|SITE_BOTTOM_BUTTON', 'toolbar->render(); ?>'); - break; - case 5: - // set buttons to custom placement of the view - CFactory::_('Placeholder')->set_('SITE_TOOLBAR', - 'toolbar->render(); ?>'); - break; - } - } - // add some buttons if custom admin view - elseif (1 == $type) - { - // add this button only if this is not the default view - $dynamic_dashboard = CFactory::_('Registry')->get('build.dashboard', ''); - $dynamic_dashboard_type = CFactory::_('Registry')->get('build.dashboard.type', ''); - if ($dynamic_dashboard_type !== 'custom_admin_views' - || ($dynamic_dashboard_type === 'custom_admin_views' - && $dynamic_dashboard !== $viewCodeName)) - { - $buttons[] = $tab . Indent::_(2) - . "//" . Line::_(__Line__, __Class__) . " add cpanel button"; - $buttons[] = $tab . Indent::_(2) - . "JToolBarHelper::custom('" . $viewCodeName . "." - . "dashboard', 'grid-2', '', 'COM_" - . CFactory::_('Compiler.Builder.Content.One')->get('COMPONENT') - . "_DASH', false);"; - } - } - // check if custom button should be added - if (isset($view['settings']->add_custom_button) - && $view['settings']->add_custom_button == 1) - { - $this->onlyFunctionButton = array(); - $functionNames = array(); - if (isset($view['settings']->custom_buttons) - && ArrayHelper::check( - $view['settings']->custom_buttons - )) - { - foreach ($view['settings']->custom_buttons as $custom_button) - { - // Load to lang - $keyLang = CFactory::_('Config')->lang_prefix . '_' - . StringHelper::safe( - $custom_button['name'], 'U' - ); - $keyCode = StringHelper::safe( - $custom_button['name'] - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $keyLang, $custom_button['name'] - ); - // load the button - if (3 !== $type - && ($custom_button['target'] != 2 - || CFactory::_('Config')->build_target === 'site')) - { - // add cpanel button TODO does not work well on site with permissions - if ($custom_button['target'] == 2 - || CFactory::_('Config')->build_target === 'site') - { - $buttons[] = Indent::_(1) . $tab . Indent::_(1) - . "if (\$this->user->authorise('" - . $viewCodeName - . "." . $keyCode . "', 'com_" - . CFactory::_('Config')->component_code_name . "'))"; - } - else - { - $buttons[] = Indent::_(1) . $tab . Indent::_(1) - . "if (\$this->canDo->get('" . $viewCodeName - . "." - . $keyCode . "'))"; - } - $buttons[] = Indent::_(1) . $tab . Indent::_(1) . "{"; - $buttons[] = Indent::_(1) . $tab . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " add " - . $custom_button['name'] . " button."; - $buttons[] = Indent::_(1) . $tab . Indent::_(2) - . "JToolBarHelper::custom('" . $viewCodeName . "." - . $custom_button['method'] . "', '" - . $custom_button['icomoon'] . " custom-button-" - . strtolower((string) $custom_button['method']) . "', '', '" - . $keyLang - . "', false);"; - $buttons[] = Indent::_(1) . $tab . Indent::_(1) . "}"; - } - // load the list button - elseif (3 == $type && $custom_button['target'] != 1) - { - // This is only for list admin views - if (isset($custom_button['type']) - && $custom_button['type'] == 2) - { - if (!isset($this->onlyFunctionButton[$viewsCodeName])) - { - $this->onlyFunctionButton[$viewsCodeName] - = array(); - } - $this->onlyFunctionButton[$viewsCodeName][] - = Indent::_( - 1 - ) . $tab . "if (\$this->user->authorise('" - . $viewCodeName . "." . $keyCode . "', 'com_" - . CFactory::_('Config')->component_code_name . "'))"; - $this->onlyFunctionButton[$viewsCodeName][] - = Indent::_( - 1 - ) . $tab . "{"; - $this->onlyFunctionButton[$viewsCodeName][] - = Indent::_( - 1 - ) . $tab . Indent::_(1) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " add " . $custom_button['name'] - . " button."; - $this->onlyFunctionButton[$viewsCodeName][] - = Indent::_( - 1 - ) . $tab . Indent::_(1) - . "JToolBarHelper::custom('" . $viewsCodeName - . "." - . $custom_button['method'] . "', '" - . $custom_button['icomoon'] . " custom-button-" - . strtolower((string) $custom_button['method']) - . "', '', '" - . $keyLang . "', false);"; - $this->onlyFunctionButton[$viewsCodeName][] - = Indent::_( - 1 - ) . $tab . "}"; - } - else - { - $buttons[] = Indent::_(1) . $tab . Indent::_(1) - . "if (\$this->user->authorise('" - . $viewCodeName - . "." . $keyCode . "', 'com_" - . CFactory::_('Config')->component_code_name . "'))"; - $buttons[] = Indent::_(1) . $tab . Indent::_(1) - . "{"; - $buttons[] = Indent::_(1) . $tab . Indent::_(2) - . "//" . Line::_(__Line__, __Class__) . " add " - . $custom_button['name'] . " button."; - $buttons[] = Indent::_(1) . $tab . Indent::_(2) - . "JToolBarHelper::custom('" . $viewsCodeName - . "." - . $custom_button['method'] . "', '" - . $custom_button['icomoon'] . " custom-button-" - . strtolower((string) $custom_button['method']) - . "', '', '" - . $keyLang . "', '" . $validateSelection - . "');"; - $buttons[] = Indent::_(1) . $tab . Indent::_(1) - . "}"; - } - } - } - } - // load the model and controller - if (3 == $type) - { - // insure the controller and model strings are added - if (isset($view['settings']->php_controller_list) - && StringHelper::check( - $view['settings']->php_controller_list - ) - && $view['settings']->php_controller_list != '//') - { - // set the custom buttons CUSTOM_BUTTONS_CONTROLLER - CFactory::_('Compiler.Builder.Content.Multi')->set($viewsCodeName . '|' . $TARGET . '_CUSTOM_BUTTONS_CONTROLLER_LIST', - PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( - $view['settings']->php_controller_list - )); - } - // load the model - if (isset($view['settings']->php_model_list) - && StringHelper::check( - $view['settings']->php_model_list - ) - && $view['settings']->php_model_list != '//') - { - // set the custom buttons CUSTOM_BUTTONS_METHOD - CFactory::_('Compiler.Builder.Content.Multi')->set($viewsCodeName . '|' . $TARGET - . '_CUSTOM_BUTTONS_METHOD_LIST', PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( - $view['settings']->php_model_list - )); - } - } - else - { - // insure the controller and model strings are added - if (StringHelper::check( - $view['settings']->php_controller - ) - && $view['settings']->php_controller != '//') - { - // set the custom buttons CUSTOM_BUTTONS_CONTROLLER - CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|' . $TARGET - . '_CUSTOM_BUTTONS_CONTROLLER', PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( - $view['settings']->php_controller - )); - if ('site' === CFactory::_('Config')->build_target) - { - // add the controller for this view - // build the file - $target = array(CFactory::_('Config')->build_target => $viewCodeName); - CFactory::_('Utilities.Structure')->build($target, 'custom_form'); - // GET_FORM_CUSTOM - } - } - // load the model - if (StringHelper::check( - $view['settings']->php_model - ) - && $view['settings']->php_model != '//') - { - // set the custom buttons CUSTOM_BUTTONS_METHOD - CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|' . $TARGET - . '_CUSTOM_BUTTONS_METHOD', PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( - $view['settings']->php_model - ) - ); - } - } - } - // return buttons if they were build - if (ArrayHelper::check($buttons)) - { - // just to check if the submission script is manually added - if (!isset($view['settings']->php_document) - || (ArrayHelper::check( - $view['settings']->php_document - ) - && strpos( - implode(' ', $view['settings']->php_document), - '/submitbutton.js' - ) === false) - || (StringHelper::check( - $view['settings']->php_document - ) - && strpos( - (string) $view['settings']->php_document, - '/submitbutton.js' - ) === false)) - { - // set the custom get form method JAVASCRIPT_FOR_BUTTONS - CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|' . $TARGET - . '_JAVASCRIPT_FOR_BUTTONS', $this->setJavaScriptForButtons() - ); - } - // insure the form is added (only if no form exist) - if (isset($view['settings']->default) - && strpos( - (string) $view['settings']->default, 'addCustomForm[CFactory::_('Config')->build_target][$viewCodeName] - = true; - } - - return PHP_EOL . implode(PHP_EOL, $buttons); - } - - return ''; - } - - public function setJavaScriptForButtons() - { - // add behavior.framework to insure Joomla function is on the page - $script = array(); - $script[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Add the needed Javascript to insure that the buttons work."; - $script[] = Indent::_(2) . "JHtml::_('behavior.framework', true);"; - $script[] = Indent::_(2) - . "\$this->document->addScriptDeclaration(\"Joomla.submitbutton = function(task){if (task == ''){ return false; } else { Joomla.submitform(task); return true; }}\");"; - - // return the script - return PHP_EOL . implode(PHP_EOL, $script); - } - - public function setFunctionOnlyButtons($nameListCode) - { - // return buttons if they were build - if (isset($this->onlyFunctionButton[$nameListCode]) - && ArrayHelper::check( - $this->onlyFunctionButton[$nameListCode] - )) - { - return PHP_EOL . implode( - PHP_EOL, $this->onlyFunctionButton[$nameListCode] - ); - } - - return ''; - } - - public function setCustomCSS(&$view) - { - if ($view['settings']->add_css == 1) - { - if (StringHelper::check($view['settings']->css)) - { - return CFactory::_('Placeholder')->update_( - $view['settings']->css - ); - } - } - - return ''; - } - - public function setDocumentCustomCSS(&$view) - { - if ($view['settings']->add_css_document == 1) - { - $view['settings']->css_document = (array) explode( - PHP_EOL, (string) $view['settings']->css_document - ); - if (ArrayHelper::check( - $view['settings']->css_document - )) - { - $script = PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Set the Custom CSS script to view" . PHP_EOL - . Indent::_(2) . '$this->document->addStyleDeclaration("'; - $cssDocument = PHP_EOL . Indent::_(3) . str_replace( - '"', '\"', implode( - PHP_EOL . Indent::_(3), - $view['settings']->css_document - ) - ); - - return $script . CFactory::_('Placeholder')->update_( - $cssDocument - ) . PHP_EOL . Indent::_(2) . '");'; - } - } - - return ''; - } - - public function setJavaScriptFile(&$view, $TARGET) - { - if ($view['settings']->add_javascript_file == 1 - && StringHelper::check( - $view['settings']->javascript_file - )) - { - // get dates - $created = CFactory::_('Model.Createdate')->get($view); - $modified = CFactory::_('Model.Modifieddate')->get($view); - // add file to view - $target = array(CFactory::_('Config')->build_target => $view['settings']->code); - $config = array(Placefix::_h('CREATIONDATE') => $created, - Placefix::_h('BUILDDATE') => $modified, - Placefix::_h('VERSION') => $view['settings']->version); - CFactory::_('Utilities.Structure')->build($target, 'javascript_file', false, $config); - // set path - if ('site' === CFactory::_('Config')->build_target) - { - $path = '/components/com_' . CFactory::_('Config')->component_code_name - . '/assets/js/' . $view['settings']->code . '.js'; - } - else - { - $path = '/administrator/components/com_' - . CFactory::_('Config')->component_code_name . '/assets/js/' - . $view['settings']->code . '.js'; - } - // add script to file - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET - . '_JAVASCRIPT_FILE', CFactory::_('Placeholder')->update_( - $view['settings']->javascript_file - )); - - // add script to view - return PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Add View JavaScript File" . PHP_EOL . Indent::_(2) - . $this->setIncludeLibScript($path); - } - - return ''; - } - - public function setDocumentCustomJS(&$view) - { - if ($view['settings']->add_js_document == 1) - { - $view['settings']->js_document = (array) explode( - PHP_EOL, (string) $view['settings']->js_document - ); - if (ArrayHelper::check( - $view['settings']->js_document - )) - { - $script = PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Set the Custom JS script to view" . PHP_EOL - . Indent::_(2) . '$this->document->addScriptDeclaration("'; - $jsDocument = PHP_EOL . Indent::_(3) . str_replace( - '"', '\"', implode( - PHP_EOL . Indent::_(3), - $view['settings']->js_document - ) - ); - - return $script . CFactory::_('Placeholder')->update_( - $jsDocument - ) . PHP_EOL . Indent::_(2) . '");'; - } - } - - return ''; - } - - public function setFootableScriptsLoader(&$view) - { - if (CFactory::_('Compiler.Builder.Footable.Scripts')-> - exists(CFactory::_('Config')->build_target . '.' . $view['settings']->code)) - { - return $this->setFootableScripts(false); - } - - return ''; - } - - public function setDocumentMetadata(&$view) - { - if ($view['settings']->main_get->gettype == 1 - && isset($view['metadata']) - && $view['metadata'] == 1) - { - return $this->setMetadataItem(); - } - elseif (isset($view['metadata']) && $view['metadata'] == 1) - { - // lets check if we have a custom get method that has the same name as the view - // if we do then it posibly can be that the metadata is loaded via that method - // and we can load the full metadata structure with its vars - if (isset($view['settings']->custom_get) - && ArrayHelper::check( - $view['settings']->custom_get - )) - { - $found = false; - $searchFor = 'get' . $view['settings']->Code; - foreach ($view['settings']->custom_get as $custom_get) - { - if ($searchFor == $custom_get->getcustom) - { - $found = true; - break; - } - } - // now lets see - if ($found) - { - return $this->setMetadataItem($view['settings']->code); - } - else - { - return $this->setMetadataList(); - } - } - else - { - return $this->setMetadataList(); - } - } - - return ''; - } - - public function setMetadataItem($item = 'item') - { - $meta = array(); - $meta[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " load the meta description"; - $meta[] = Indent::_(2) . "if (isset(\$this->" . $item - . "->metadesc) && \$this->" . $item . "->metadesc)"; - $meta[] = Indent::_(2) . "{"; - $meta[] = Indent::_(3) . "\$this->document->setDescription(\$this->" - . $item . "->metadesc);"; - $meta[] = Indent::_(2) . "}"; - $meta[] = Indent::_(2) - . "elseif (\$this->params->get('menu-meta_description'))"; - $meta[] = Indent::_(2) . "{"; - $meta[] = Indent::_(3) - . "\$this->document->setDescription(\$this->params->get('menu-meta_description'));"; - $meta[] = Indent::_(2) . "}"; - $meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " load the key words if set"; - $meta[] = Indent::_(2) . "if (isset(\$this->" . $item - . "->metakey) && \$this->" . $item . "->metakey)"; - $meta[] = Indent::_(2) . "{"; - $meta[] = Indent::_(3) - . "\$this->document->setMetadata('keywords', \$this->" . $item - . "->metakey);"; - $meta[] = Indent::_(2) . "}"; - $meta[] = Indent::_(2) - . "elseif (\$this->params->get('menu-meta_keywords'))"; - $meta[] = Indent::_(2) . "{"; - $meta[] = Indent::_(3) - . "\$this->document->setMetadata('keywords', \$this->params->get('menu-meta_keywords'));"; - $meta[] = Indent::_(2) . "}"; - $meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " check the robot params"; - $meta[] = Indent::_(2) . "if (isset(\$this->" . $item - . "->robots) && \$this->" . $item . "->robots)"; - $meta[] = Indent::_(2) . "{"; - $meta[] = Indent::_(3) - . "\$this->document->setMetadata('robots', \$this->" . $item - . "->robots);"; - $meta[] = Indent::_(2) . "}"; - $meta[] = Indent::_(2) . "elseif (\$this->params->get('robots'))"; - $meta[] = Indent::_(2) . "{"; - $meta[] = Indent::_(3) - . "\$this->document->setMetadata('robots', \$this->params->get('robots'));"; - $meta[] = Indent::_(2) . "}"; - $meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " check if autor is to be set"; - $meta[] = Indent::_(2) . "if (isset(\$this->" . $item - . "->created_by) && \$this->params->get('MetaAuthor') == '1')"; - $meta[] = Indent::_(2) . "{"; - $meta[] = Indent::_(3) - . "\$this->document->setMetaData('author', \$this->" . $item - . "->created_by);"; - $meta[] = Indent::_(2) . "}"; - $meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " check if metadata is available"; - $meta[] = Indent::_(2) . "if (isset(\$this->" . $item - . "->metadata) && \$this->" . $item . "->metadata)"; - $meta[] = Indent::_(2) . "{"; - $meta[] = Indent::_(3) . "\$mdata = json_decode(\$this->" . $item - . "->metadata,true);"; - $meta[] = Indent::_(3) . "foreach (\$mdata as \$k => \$v)"; - $meta[] = Indent::_(3) . "{"; - $meta[] = Indent::_(4) . "if (\$v)"; - $meta[] = Indent::_(4) . "{"; - $meta[] = Indent::_(5) . "\$this->document->setMetadata(\$k, \$v);"; - $meta[] = Indent::_(4) . "}"; - $meta[] = Indent::_(3) . "}"; - $meta[] = Indent::_(2) . "}"; - - return implode(PHP_EOL, $meta); - } - - public function setMetadataList() - { - $meta = array(); - $meta[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " load the meta description"; - $meta[] = Indent::_(2) - . "if (\$this->params->get('menu-meta_description'))"; - $meta[] = Indent::_(2) . "{"; - $meta[] = Indent::_(3) - . "\$this->document->setDescription(\$this->params->get('menu-meta_description'));"; - $meta[] = Indent::_(2) . "}"; - $meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " load the key words if set"; - $meta[] = Indent::_(2) - . "if (\$this->params->get('menu-meta_keywords'))"; - $meta[] = Indent::_(2) . "{"; - $meta[] = Indent::_(3) - . "\$this->document->setMetadata('keywords', \$this->params->get('menu-meta_keywords'));"; - $meta[] = Indent::_(2) . "}"; - $meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " check the robot params"; - $meta[] = Indent::_(2) . "if (\$this->params->get('robots'))"; - $meta[] = Indent::_(2) . "{"; - $meta[] = Indent::_(3) - . "\$this->document->setMetadata('robots', \$this->params->get('robots'));"; - $meta[] = Indent::_(2) . "}"; - - return implode(PHP_EOL, $meta); - } - - public function setGoogleChartLoader(&$view) - { - if (CFactory::_('Compiler.Builder.Google.Chart')-> - exists(CFactory::_('Config')->build_target . '.' . $view['settings']->code)) - { - $chart = array(); - $chart[] = PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " add the google chart builder class."; - $chart[] = Indent::_(2) - . "require_once JPATH_COMPONENT_ADMINISTRATOR.'/helpers/chartbuilder.php';"; - $chart[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " load the google chart js."; - $chart[] = Indent::_(2) - . "JHtml::_('script', 'media/com_" - . CFactory::_('Config')->component_code_name . "/js/google.jsapi.js', ['version' => 'auto']);"; - $chart[] = Indent::_(2) - . "\$this->document->addScript('https://canvg.googlecode.com/svn/trunk/rgbcolor.js', ['version' => 'auto']);"; - $chart[] = Indent::_(2) - . "\$this->document->addScript('https://canvg.googlecode.com/svn/trunk/canvg.js', ['version' => 'auto']);"; - - return implode(PHP_EOL, $chart); - } - - return ''; - } - - public function setLibrariesLoader($view) - { - // check call sig - if (isset($view['settings']) && isset($view['settings']->code)) - { - $code = $view['settings']->code; - $view_active = true; - } - elseif (isset($view->code_name)) - { - $code = $view->code_name; - $view_active = false; - } - // reset bucket - $setter = ''; - // always load these in - if ($view_active) - { - $setter .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Only load jQuery if needed. (default is true)"; - $setter .= PHP_EOL . Indent::_(2) . "if (\$this->params->get('add_jquery_framework', 1) == 1)"; - $setter .= PHP_EOL . Indent::_(2) . "{"; - $setter .= PHP_EOL . Indent::_(3) . "JHtml::_('jquery.framework');"; - $setter .= PHP_EOL . Indent::_(2) . "}"; - $setter .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Load the header checker class."; - if (CFactory::_('Config')->build_target === 'site') - { - $setter .= PHP_EOL . Indent::_(2) - . "require_once( JPATH_COMPONENT_SITE.'/helpers/headercheck.php' );"; - } - else - { - $setter .= PHP_EOL . Indent::_(2) - . "require_once( JPATH_COMPONENT_ADMINISTRATOR.'/helpers/headercheck.php' );"; - } - $setter .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Initialize the header checker."; - $setter .= PHP_EOL . Indent::_(2) . "\$HeaderCheck = new " - . CFactory::_('Config')->component_code_name . "HeaderCheck;"; - } - // check if this view should get libraries - if (($data = CFactory::_('Compiler.Builder.Library.Manager')-> - get(CFactory::_('Config')->build_target . '.' . $code)) !== null) - { - foreach ($data as $id => $true) - { - // get the library - $library = CFactory::_('Registry')->get("builder.libraries.$id", null); - if (is_object($library) && isset($library->document) - && StringHelper::check($library->document)) - { - $setter .= PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( - str_replace( - '$document->', '$this->document->', - (string) $library->document - ) - ); - } - elseif (is_object($library) - && isset($library->how)) - { - $setter .= $this->setLibraryDocument($id); - } - } - } - // convert back to $document if module call (oops :) - if (!$view_active) - { - return str_replace('$this->document->', '$document->', $setter); - } - - return $setter; - } - - protected function setLibraryDocument($id) - { - // get the library - $library = CFactory::_('Registry')->get("builder.libraries.$id", null); - // make sure we have an object - if (is_object($library)) - { - if (isset($library->how) && 2 == $library->how - && isset($library->conditions) - && ArrayHelper::check( - $library->conditions - )) - { - // build document with the conditions values - $this->setLibraryDocConditions( - $id, $this->setLibraryScripts($id, false) - ); - } - elseif (isset($library->how) && 1 == $library->how) - { - // build document to allways add all files and urls - $this->setLibraryScripts($id); - } - // check if the document was build - if (isset($library->document) - && StringHelper::check( - $library->document - )) - { - return PHP_EOL . PHP_EOL . $library->document; - } - } - - return ''; - } - - protected function setLibraryDocConditions($id, $scripts) - { - // Start script builder for library files - if (!isset($this->libwarning[$id])) - { - // set the warning only once - $this->libwarning[$id] = true; - - // get the library - $library = CFactory::_('Registry')->get("builder.libraries.$id", null); - - $this->app->enqueueMessage( - JText::_('

    Conditional Script Warning

    '), 'Warning' - ); - - // message with name - if (is_object($library) && isset($library->name)) - { - $this->app->enqueueMessage( - JText::sprintf( - 'The conditional script builder for %s is not ready, sorry!', - $library->name - ), 'Warning' - ); - } - else - { - $this->app->enqueueMessage( - JText::_( - 'The conditional script builder for ID:%s is not ready, sorry!', - $id - ), 'Warning' - ); - } - } - } - - protected function setLibraryScripts($id, $buildDoc = true) - { - $scripts = []; - // get the library - $library = CFactory::_('Registry')->get("builder.libraries.$id", null); - // check that we have a library - if (is_object($library)) - { - // load the urls if found - if (isset($library->urls) - && ArrayHelper::check($library->urls)) - { - // set all the files - foreach ($library->urls as $url) - { - // if local path is set, then use it first - if (isset($url['path'])) - { - // update the root path - $path = $this->getScriptRootPath($url['path']); - // load document script - $scripts[md5((string) $url['path'])] = $this->setIncludeLibScript( - $path - ); - // load url also if not building document - if (!$buildDoc) - { - // load document script - $scripts[md5((string) $url['url'])] = $this->setIncludeLibScript( - $url['url'], false - ); - } - } - else - { - // load document script - $scripts[md5((string) $url['url'])] = $this->setIncludeLibScript( - $url['url'], false - ); - } - } - } - // load the local files if found - if (isset($library->files) - && ArrayHelper::check($library->files)) - { - // set all the files - foreach ($library->files as $file) - { - $path = '/' . trim((string) $file['path'], '/'); - // check if path has new file name (has extetion) - $pathInfo = pathinfo($path); - // update the root path - $_path = $this->getScriptRootPath($path); - if (isset($pathInfo['extension']) && $pathInfo['extension']) - { - // load document script - $scripts[md5($path)] = $this->setIncludeLibScript( - $_path, false, $pathInfo - ); - } - else - { - // load document script - $scripts[md5($path . '/' . trim((string) $file['file'], '/'))] - = $this->setIncludeLibScript( - $_path . '/' . trim((string) $file['file'], '/') - ); - } - } - } - // load the local folders if found - if (isset($library->folders) - && ArrayHelper::check( - $library->folders - )) - { - // get all the file paths - $files = []; - foreach ($library->folders as $folder) - { - if (isset($folder['path']) && isset($folder['folder'])) - { - $path = '/' . trim((string)$folder['path'], '/'); - if (isset($folder['rename']) && 1 == $folder['rename']) - { - if ($_paths = FileHelper::getPaths( - CFactory::_('Utilities.Paths')->component_path . $path - )) - { - $files[$path] = $_paths; - } - } - else - { - $path = $path . '/' . trim((string)$folder['folder'], '/'); - if ($_paths = FileHelper::getPaths( - CFactory::_('Utilities.Paths')->component_path . $path - )) - { - $files[$path] = $_paths; - } - } - } - } - // now load the script - if (ArrayHelper::check($files)) - { - foreach ($files as $root => $paths) - { - // update the root path - $_root = $this->getScriptRootPath($root); - // load per path - foreach ($paths as $path) - { - $scripts[md5($root . '/' . trim((string)$path, '/'))] - = $this->setIncludeLibScript( - $_root . '/' . trim((string)$path, '/') - ); - } - } - } - } - } - - // if there was any code added to document then set globally - if ($buildDoc && ArrayHelper::check($scripts)) - { - CFactory::_('Registry')->set("builder.libraries.${id}.document", Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " always load these files." - . PHP_EOL . Indent::_(2) . implode( - PHP_EOL . Indent::_(2), $scripts - ) - ); - - // success - return true; - } - elseif (ArrayHelper::check($scripts)) - { - return $scripts; - } - - return false; - } - - protected function setIncludeLibScript($path, $local = true, - $pathInfo = false - ) - { - // insure we have the path info - if (!$pathInfo) - { - $pathInfo = pathinfo((string) $path); - } - // use the path info to build the script - if (isset($pathInfo['extension']) && $pathInfo['extension']) - { - switch ($pathInfo['extension']) - { - case 'js': - return 'JHtml::_(\'script\', "' . ltrim($path, '/') - . '", [\'version\' => \'auto\']);'; - break; - case 'css': - case 'less': - return 'JHtml::_(\'stylesheet\', "' - . ltrim($path, '/') . '", [\'version\' => \'auto\']);'; - break; - case 'php': - if (strpos((string) $path, 'http') === false) - { - return 'require_once("' . $path . '");'; - } - break; - } - } - - return ''; - } - - protected function getScriptRootPath($root) - { - if (strpos((string) $root, '/media/') !== false - && strpos((string) $root, '/admin/') === false - && strpos((string) $root, '/site/') === false) - { - return str_replace( - '/media/', '/media/com_' . CFactory::_('Config')->component_code_name . '/', (string) $root - ); - } - elseif (strpos((string) $root, '/media/') === false - && strpos((string) $root, '/admin/') !== false - && strpos((string) $root, '/site/') === false) - { - return str_replace( - '/admin/', - '/administrator/components/com_' . CFactory::_('Config')->component_code_name - . '/', (string) $root - ); - } - elseif (strpos((string) $root, '/media/') === false - && strpos((string) $root, '/admin/') === false - && strpos((string) $root, '/site/') !== false) - { - return str_replace( - '/site/', '/components/com_' . CFactory::_('Config')->component_code_name . '/', - (string) $root - ); - } - - return $root; - } - - public function setUikitLoader(&$view) - { - // reset setter - $setter = ''; - // load the defaults needed - if (CFactory::_('Config')->uikit > 0) - { - $setter .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Load uikit options."; - $setter .= PHP_EOL . Indent::_(2) - . "\$uikit = \$this->params->get('uikit_load');"; - $setter .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Set script size."; - $setter .= PHP_EOL . Indent::_(2) - . "\$size = \$this->params->get('uikit_min');"; - $tabV = ""; - // if both versions should be loaded then add some more logic - if (2 == CFactory::_('Config')->uikit) - { - $setter .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Load uikit version."; - $setter .= PHP_EOL . Indent::_(2) - . "\$this->uikitVersion = \$this->params->get('uikit_version', 2);"; - $setter .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Use Uikit Version 2"; - $setter .= PHP_EOL . Indent::_(2) - . "if (2 == \$this->uikitVersion)"; - $setter .= PHP_EOL . Indent::_(2) . "{"; - $tabV = Indent::_(1); - } - } - // load the defaults needed - if (2 == CFactory::_('Config')->uikit || 1 == CFactory::_('Config')->uikit) - { - $setter .= PHP_EOL . $tabV . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Set css style."; - $setter .= PHP_EOL . $tabV . Indent::_(2) - . "\$style = \$this->params->get('uikit_style');"; - - $setter .= PHP_EOL . PHP_EOL . $tabV . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " The uikit css."; - $setter .= PHP_EOL . $tabV . Indent::_(2) - . "if ((!\$HeaderCheck->css_loaded('uikit.min') || \$uikit == 1) && \$uikit != 2 && \$uikit != 3)"; - $setter .= PHP_EOL . $tabV . Indent::_(2) . "{"; - $setter .= PHP_EOL . $tabV . Indent::_(3) - . "JHtml::_('stylesheet', 'media/com_" - . CFactory::_('Config')->component_code_name - . "/uikit-v2/css/uikit'.\$style.\$size.'.css', ['version' => 'auto']);"; - $setter .= PHP_EOL . $tabV . Indent::_(2) . "}"; - $setter .= PHP_EOL . $tabV . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " The uikit js."; - $setter .= PHP_EOL . $tabV . Indent::_(2) - . "if ((!\$HeaderCheck->js_loaded('uikit.min') || \$uikit == 1) && \$uikit != 2 && \$uikit != 3)"; - $setter .= PHP_EOL . $tabV . Indent::_(2) . "{"; - $setter .= PHP_EOL . $tabV . Indent::_(3) - . "JHtml::_('script', 'media/com_" - . CFactory::_('Config')->component_code_name - . "/uikit-v2/js/uikit'.\$size.'.js', ['version' => 'auto']);"; - $setter .= PHP_EOL . $tabV . Indent::_(2) . "}"; - } - // load the components need - if ((2 == CFactory::_('Config')->uikit || 1 == CFactory::_('Config')->uikit) - && ($data_ = CFactory::_('Compiler.Builder.Uikit.Comp')->get($view['settings']->code)) !== null) - { - $setter .= PHP_EOL . PHP_EOL . $tabV . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) - . " Load the script to find all uikit components needed."; - $setter .= PHP_EOL . $tabV . Indent::_(2) . "if (\$uikit != 2)"; - $setter .= PHP_EOL . $tabV . Indent::_(2) . "{"; - $setter .= PHP_EOL . $tabV . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Set the default uikit components in this view."; - $setter .= PHP_EOL . $tabV . Indent::_(3) - . "\$uikitComp = array();"; - foreach ($data_ as $class) - { - $setter .= PHP_EOL . $tabV . Indent::_(3) . "\$uikitComp[] = '" - . $class . "';"; - } - // check content for more needed components - if (CFactory::_('Compiler.Builder.Site.Field.Data')->exists('uikit.' . $view['settings']->code)) - { - $setter .= PHP_EOL . PHP_EOL . $tabV . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) - . " Get field uikit components needed in this view."; - $setter .= PHP_EOL . $tabV . Indent::_(3) - . "\$uikitFieldComp = \$this->get('UikitComp');"; - $setter .= PHP_EOL . $tabV . Indent::_(3) - . "if (isset(\$uikitFieldComp) && " - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkArray(\$uikitFieldComp))"; - $setter .= PHP_EOL . $tabV . Indent::_(3) . "{"; - $setter .= PHP_EOL . $tabV . Indent::_(4) - . "if (isset(\$uikitComp) && " - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkArray(\$uikitComp))"; - $setter .= PHP_EOL . $tabV . Indent::_(4) . "{"; - $setter .= PHP_EOL . $tabV . Indent::_(5) - . "\$uikitComp = array_merge(\$uikitComp, \$uikitFieldComp);"; - $setter .= PHP_EOL . $tabV . Indent::_(5) - . "\$uikitComp = array_unique(\$uikitComp);"; - $setter .= PHP_EOL . $tabV . Indent::_(4) . "}"; - $setter .= PHP_EOL . $tabV . Indent::_(4) . "else"; - $setter .= PHP_EOL . $tabV . Indent::_(4) . "{"; - $setter .= PHP_EOL . $tabV . Indent::_(5) - . "\$uikitComp = \$uikitFieldComp;"; - $setter .= PHP_EOL . $tabV . Indent::_(4) . "}"; - $setter .= PHP_EOL . $tabV . Indent::_(3) . "}"; - } - $setter .= PHP_EOL . $tabV . Indent::_(2) . "}"; - $setter .= PHP_EOL . PHP_EOL . $tabV . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) - . " Load the needed uikit components in this view."; - $setter .= PHP_EOL . $tabV . Indent::_(2) - . "if (\$uikit != 2 && isset(\$uikitComp) && " - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkArray(\$uikitComp))"; - $setter .= PHP_EOL . $tabV . Indent::_(2) . "{"; - $setter .= PHP_EOL . $tabV . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " load just in case."; - $setter .= PHP_EOL . $tabV . Indent::_(3) - . "jimport('joomla.filesystem.file');"; - $setter .= PHP_EOL . $tabV . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " loading..."; - $setter .= PHP_EOL . $tabV . Indent::_(3) - . "foreach (\$uikitComp as \$class)"; - $setter .= PHP_EOL . $tabV . Indent::_(3) . "{"; - $setter .= PHP_EOL . $tabV . Indent::_(4) . "foreach (" - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::\$uk_components[\$class] as \$name)"; - $setter .= PHP_EOL . $tabV . Indent::_(4) . "{"; - $setter .= PHP_EOL . $tabV . Indent::_(5) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " check if the CSS file exists."; - $setter .= PHP_EOL . $tabV . Indent::_(5) - . "if (File::exists(JPATH_ROOT.'/media/com_" - . CFactory::_('Config')->component_code_name - . "/uikit-v2/css/components/'.\$name.\$style.\$size.'.css'))"; - $setter .= PHP_EOL . $tabV . Indent::_(5) . "{"; - $setter .= PHP_EOL . $tabV . Indent::_(6) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " load the css."; - $setter .= PHP_EOL . $tabV . Indent::_(6) - . "JHtml::_('stylesheet', 'media/com_" - . CFactory::_('Config')->component_code_name - . "/uikit-v2/css/components/'.\$name.\$style.\$size.'.css', ['version' => 'auto']);"; - $setter .= PHP_EOL . $tabV . Indent::_(5) . "}"; - $setter .= PHP_EOL . $tabV . Indent::_(5) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " check if the JavaScript file exists."; - $setter .= PHP_EOL . $tabV . Indent::_(5) - . "if (File::exists(JPATH_ROOT.'/media/com_" - . CFactory::_('Config')->component_code_name - . "/uikit-v2/js/components/'.\$name.\$size.'.js'))"; - $setter .= PHP_EOL . $tabV . Indent::_(5) . "{"; - $setter .= PHP_EOL . $tabV . Indent::_(6) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " load the js."; - $setter .= PHP_EOL . $tabV . Indent::_(6) - . "JHtml::_('script', 'media/com_" - . CFactory::_('Config')->component_code_name - . "/uikit-v2/js/components/'.\$name.\$size.'.js', ['version' => 'auto'], ['type' => 'text/javascript', 'async' => 'async']);"; - $setter .= PHP_EOL . $tabV . Indent::_(5) . "}"; - $setter .= PHP_EOL . $tabV . Indent::_(4) . "}"; - $setter .= PHP_EOL . $tabV . Indent::_(3) . "}"; - $setter .= PHP_EOL . $tabV . Indent::_(2) . "}"; - } - elseif ((2 == CFactory::_('Config')->uikit || 1 == CFactory::_('Config')->uikit) - && CFactory::_('Compiler.Builder.Site.Field.Data')->exists('uikit.' . $view['settings']->code)) - { - $setter .= PHP_EOL . PHP_EOL . $tabV . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) - . " Load the needed uikit components in this view."; - $setter .= PHP_EOL . $tabV . Indent::_(2) - . "\$uikitComp = \$this->get('UikitComp');"; - $setter .= PHP_EOL . $tabV . Indent::_(2) - . "if (\$uikit != 2 && isset(\$uikitComp) && " - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkArray(\$uikitComp))"; - $setter .= PHP_EOL . $tabV . Indent::_(2) . "{"; - $setter .= PHP_EOL . $tabV . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " loading..."; - $setter .= PHP_EOL . $tabV . Indent::_(3) - . "foreach (\$uikitComp as \$class)"; - $setter .= PHP_EOL . $tabV . Indent::_(3) . "{"; - $setter .= PHP_EOL . $tabV . Indent::_(4) . "foreach (" - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::\$uk_components[\$class] as \$name)"; - $setter .= PHP_EOL . $tabV . Indent::_(4) . "{"; - $setter .= PHP_EOL . $tabV . Indent::_(5) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " check if the CSS file exists."; - $setter .= PHP_EOL . $tabV . Indent::_(5) - . "if (File::exists(JPATH_ROOT.'/media/com_" - . CFactory::_('Config')->component_code_name - . "/uikit-v2/css/components/'.\$name.\$style.\$size.'.css'))"; - $setter .= PHP_EOL . $tabV . Indent::_(5) . "{"; - $setter .= PHP_EOL . $tabV . Indent::_(6) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " load the css."; - $setter .= PHP_EOL . $tabV . Indent::_(6) - . "JHtml::_('stylesheet', 'media/com_" - . CFactory::_('Config')->component_code_name - . "/uikit-v2/css/components/'.\$name.\$style.\$size.'.css', ['version' => 'auto']);"; - $setter .= PHP_EOL . $tabV . Indent::_(5) . "}"; - $setter .= PHP_EOL . $tabV . Indent::_(5) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " check if the JavaScript file exists."; - $setter .= PHP_EOL . $tabV . Indent::_(5) - . "if (File::exists(JPATH_ROOT.'/media/com_" - . CFactory::_('Config')->component_code_name - . "/uikit-v2/js/components/'.\$name.\$size.'.js'))"; - $setter .= PHP_EOL . $tabV . Indent::_(5) . "{"; - $setter .= PHP_EOL . $tabV . Indent::_(6) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " load the js."; - $setter .= PHP_EOL . $tabV . Indent::_(6) - . "JHtml::_('script', 'media/com_" - . CFactory::_('Config')->component_code_name - . "/uikit-v2/js/components/'.\$name.\$size.'.js', ['version' => 'auto'], ['type' => 'text/javascript', 'async' => 'async']);"; - $setter .= PHP_EOL . $tabV . Indent::_(5) . "}"; - $setter .= PHP_EOL . $tabV . Indent::_(4) . "}"; - $setter .= PHP_EOL . $tabV . Indent::_(3) . "}"; - $setter .= PHP_EOL . $tabV . Indent::_(2) . "}"; - } - // now set the version 3 - if (2 == CFactory::_('Config')->uikit || 3 == CFactory::_('Config')->uikit) - { - if (2 == CFactory::_('Config')->uikit) - { - $setter .= PHP_EOL . Indent::_(2) . "}"; - $setter .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Use Uikit Version 3"; - $setter .= PHP_EOL . Indent::_(2) - . "elseif (3 == \$this->uikitVersion)"; - $setter .= PHP_EOL . Indent::_(2) . "{"; - } - // add version 3 fiels to page - $setter .= PHP_EOL . $tabV . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " The uikit css."; - $setter .= PHP_EOL . $tabV . Indent::_(2) - . "if ((!\$HeaderCheck->css_loaded('uikit.min') || \$uikit == 1) && \$uikit != 2 && \$uikit != 3)"; - $setter .= PHP_EOL . $tabV . Indent::_(2) . "{"; - $setter .= PHP_EOL . $tabV . Indent::_(3) - . "JHtml::_('stylesheet', 'media/com_" - . CFactory::_('Config')->component_code_name - . "/uikit-v3/css/uikit'.\$size.'.css', ['version' => 'auto']);"; - $setter .= PHP_EOL . $tabV . Indent::_(2) . "}"; - $setter .= PHP_EOL . $tabV . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " The uikit js."; - $setter .= PHP_EOL . $tabV . Indent::_(2) - . "if ((!\$HeaderCheck->js_loaded('uikit.min') || \$uikit == 1) && \$uikit != 2 && \$uikit != 3)"; - $setter .= PHP_EOL . $tabV . Indent::_(2) . "{"; - $setter .= PHP_EOL . $tabV . Indent::_(3) - . "JHtml::_('script', 'media/com_" - . CFactory::_('Config')->component_code_name - . "/uikit-v3/js/uikit'.\$size.'.js', ['version' => 'auto']);"; - $setter .= PHP_EOL . $tabV . Indent::_(3) - . "JHtml::_('script', 'media/com_" - . CFactory::_('Config')->component_code_name - . "/uikit-v3/js/uikit-icons'.\$size.'.js', ['version' => 'auto']);"; - $setter .= PHP_EOL . $tabV . Indent::_(2) . "}"; - if (2 == CFactory::_('Config')->uikit) - { - $setter .= PHP_EOL . Indent::_(2) . "}"; - } - } - - return $setter; - } - - public function setCustomViewExtraDisplayMethods(&$view) - { - if ($view['settings']->add_php_jview == 1) - { - return PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( - $view['settings']->php_jview - ); - } - - return ''; - } - - public function setCustomViewBody(&$view) - { - if (StringHelper::check($view['settings']->default)) - { - if ($view['settings']->main_get->gettype == 2 - && $view['settings']->main_get->pagination == 1) - { - // does this view have a custom limitbox position - $has_limitbox = (strpos( - (string) $view['settings']->default, - (string) Placefix::_('LIMITBOX') - ) !== false); - // does this view have a custom pages counter position - $has_pagescounter = (strpos( - (string) $view['settings']->default, - (string) Placefix::_('PAGESCOUNTER') - ) !== false); - // does this view have a custom pages links position - $has_pageslinks = (strpos( - (string) $view['settings']->default, - (string) Placefix::_('PAGESLINKS') - ) !== false); - // does this view have a custom pagination start position - $has_pagination_start = (strpos( - (string) $view['settings']->default, - (string) Placefix::_('PAGINATIONSTART') - ) !== false); - // does this view have a custom pagination end position - $has_pagination_end = (strpos( - (string) $view['settings']->default, - (string) Placefix::_('PAGINATIONEND') - ) !== false); - - // add pagination start - CFactory::_('Placeholder')->add_('PAGINATIONSTART', PHP_EOL - . 'items) && isset($this->pagination) && isset($this->pagination->pagesTotal) && $this->pagination->pagesTotal > 1): ?>'); - CFactory::_('Placeholder')->add_('PAGINATIONSTART', - PHP_EOL . Indent::_(1) . ''); - CFactory::_('Placeholder')->add_('PAGINATIONEND', - PHP_EOL . ''); - - // add limit box - CFactory::_('Placeholder')->set_('LIMITBOX', - 'pagination->getLimitBox(); ?>'); - - // add pages counter - CFactory::_('Placeholder')->set_('PAGESCOUNTER', - 'pagination->getPagesCounter(); ?>'); - - // add pages links - if (CFactory::_('Config')->build_target === 'custom_admin') - { - CFactory::_('Placeholder')->set_('PAGESLINKS', - 'pagination->getListFooter(); ?>'); - } - else - { - CFactory::_('Placeholder')->set_('PAGESLINKS', - 'pagination->getPagesLinks(); ?>'); - } - - // build body - $body = array(); - // Load the default values to the body - $body[] = CFactory::_('Placeholder')->update_( - $view['settings']->default - ); - - // add pagination start - if (!$has_pagination_start) - { - $body[] = CFactory::_('Placeholder')->get_('PAGINATIONSTART'); - } - - if (!$has_limitbox && !$has_pagescounter) - { - $body[] = Indent::_(3) - . '

    pagination->getPagesCounter(); ?> pagination->getLimitBox(); ?>

    '; - } - elseif (!$has_limitbox) - { - $body[] = Indent::_(3) - . '

    pagination->getLimitBox(); ?>

    '; - } - elseif (!$has_pagescounter) - { - $body[] = Indent::_(3) - . '

    pagination->getPagesCounter(); ?>

    '; - } - // add pagination end - if (!$has_pagination_end) - { - $body[] = CFactory::_('Placeholder')->get_('PAGINATIONEND'); - } - - // lets clear the placeholders just in case - CFactory::_('Placeholder')->remove_('LIMITBOX'); - CFactory::_('Placeholder')->remove_('PAGESCOUNTER'); - CFactory::_('Placeholder')->remove_('PAGESLINKS'); - CFactory::_('Placeholder')->remove_('PAGINATIONSTART'); - CFactory::_('Placeholder')->remove_('PAGINATIONEND'); - - // insure the form is added (only if no form exist) - if (strpos((string) $view['settings']->default, 'addCustomForm[CFactory::_('Config')->build_target][$view['settings']->code] - = true; - } - - // return the body - return implode(PHP_EOL, $body); - } - else - { - // insure the form is added (only if no form exist) - if ('site' !== CFactory::_('Config')->build_target - && strpos( - (string) $view['settings']->default, 'addCustomForm[CFactory::_('Config')->build_target][$view['settings']->code] - = true; - } - - return PHP_EOL . CFactory::_('Placeholder')->update_( - $view['settings']->default - ); - } - } - - return ''; - } - - public function setCustomViewForm(&$view, &$gettype, $type) - { - if (isset($this->addCustomForm[CFactory::_('Config')->build_target]) - && isset($this->addCustomForm[CFactory::_('Config')->build_target][$view]) - && $this->addCustomForm[CFactory::_('Config')->build_target][$view]) - { - switch ($type) - { - case 1: - // top - if ('site' === CFactory::_('Config')->build_target) - { - return '' - . PHP_EOL; - } - else - { - if ($gettype == 2) - { - return '' - . PHP_EOL; - } - else - { - return '' - . PHP_EOL; - } - } - break; - case 2: - // bottom - $input = ''; - if ('admin' === CFactory::_('Config')->build_target - && isset($this->customAdminViewListId[$view])) - { - $input = PHP_EOL . Indent::_(1) - . ''; - } - - return $input . PHP_EOL - . '' - . PHP_EOL . "" - . PHP_EOL . ''; - break; - } - } - - return ''; - } - - public function setCustomViewSubmitButtonScript(&$view) - { - if (StringHelper::check($view['settings']->default)) - { - // add the script only if there is none set - if (strpos( - (string) $view['settings']->default, - 'Joomla.submitbutton = function(' - ) === false) - { - $script = array(); - $script[] = PHP_EOL . ""; - - return implode(PHP_EOL, $script); - } - } - - return ''; - } - - public function setCustomViewCodeBody(&$view) - { - if ($view['settings']->add_php_view == 1) - { - $view['settings']->php_view = (array) explode( - PHP_EOL, (string) $view['settings']->php_view - ); - if (ArrayHelper::check($view['settings']->php_view)) - { - $_tmp = PHP_EOL . PHP_EOL . implode( - PHP_EOL, $view['settings']->php_view - ); - - return CFactory::_('Placeholder')->update_($_tmp); - } - } - - return ''; - } - - public function setCustomViewTemplateBody(&$view) - { - if (($data_ = CFactory::_('Compiler.Builder.Template.Data')-> - get(CFactory::_('Config')->build_target . '.' . $view['settings']->code)) !== null) - { - $created = CFactory::_('Model.Createdate')->get($view); - $modified = CFactory::_('Model.Modifieddate')->get($view); - foreach ($data_ as $template => $data) - { - // build the file - $target = [ - CFactory::_('Config')->build_target => $view['settings']->code - ]; - $config = [ - Placefix::_h('CREATIONDATE') => $created, - Placefix::_h('BUILDDATE') => $modified, - Placefix::_h('VERSION') => $view['settings']->version - ]; - CFactory::_('Utilities.Structure')->build($target, 'template', $template, $config); - // set the file data - $TARGET = StringHelper::safe( - CFactory::_('Config')->build_target, 'U' - ); - if (!isset($data['html']) || $data['html'] === null) - { - echo '
    ';
    -					var_dump($data);
    -					exit;
    -				}
    -				// SITE_TEMPLATE_BODY <<>>
    -				CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '_'
    -					. $template . '|' . $TARGET . '_TEMPLATE_BODY', PHP_EOL . CFactory::_('Placeholder')->update_(
    -						$data['html']
    -					));
    -				if (!isset($data['php_view']) || $data['php_view'] === null)
    -				{
    -					echo '
    ';
    -					var_dump($data);
    -					exit;
    -				}
    -				// SITE_TEMPLATE_CODE_BODY <<>>
    -				CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '_'
    -					. $template . '|' . $TARGET . '_TEMPLATE_CODE_BODY',
    -					$this->setTemplateCode($data['php_view'])
    -				);
    -			}
    -		}
    -	}
    -
    -	public function setTemplateCode(&$php)
    -	{
    -		if (StringHelper::check($php))
    -		{
    -			$php_view = (array) explode(PHP_EOL, (string) $php);
    -			if (ArrayHelper::check($php_view))
    -			{
    -				$php_view = PHP_EOL . PHP_EOL . implode(PHP_EOL, $php_view);
    -
    -				return CFactory::_('Placeholder')->update_($php_view);
    -			}
    -		}
    -
    -		return '';
    -	}
    -
    -	public function setCustomViewLayouts()
    -	{
    -		if (($data_ = CFactory::_('Compiler.Builder.Layout.Data')->
    -			get(CFactory::_('Config')->build_target)) !== null)
    -		{
    -			foreach ($data_ as $layout => $data)
    -			{
    -				// build the file
    -				$target = array(CFactory::_('Config')->build_target => $layout);
    -				CFactory::_('Utilities.Structure')->build($target, 'layout');
    -				// set the file data
    -				$TARGET = StringHelper::safe(
    -					CFactory::_('Config')->build_target, 'U'
    -				);
    -				// SITE_LAYOUT_CODE <<>>
    -				$php_view = (array) explode(PHP_EOL, (string) $data['php_view']);
    -				if (ArrayHelper::check($php_view))
    -				{
    -					$php_view = PHP_EOL . PHP_EOL . implode(PHP_EOL, $php_view);
    -					CFactory::_('Compiler.Builder.Content.Multi')->set($layout . '|' . $TARGET . '_LAYOUT_CODE',
    -						CFactory::_('Placeholder')->update_(
    -							$php_view
    -						)
    -					);
    -				}
    -				else
    -				{
    -					CFactory::_('Compiler.Builder.Content.Multi')->set($layout . '|' . $TARGET
    -						. '_LAYOUT_CODE',  '');
    -				}
    -				// SITE_LAYOUT_BODY <<>>
    -				CFactory::_('Compiler.Builder.Content.Multi')->set($layout . '|' . $TARGET . '_LAYOUT_BODY',
    -					PHP_EOL . CFactory::_('Placeholder')->update_(
    -						$data['html']
    -					)
    -				);
    -				// SITE_LAYOUT_HEADER <<>>
    -				CFactory::_('Compiler.Builder.Content.Multi')->set($layout . '|' . $TARGET . '_LAYOUT_HEADER',
    -					(($header = $this->setFileHeader(
    -							str_replace('_', '.', (string) CFactory::_('Config')->build_target) . '.layout',
    -							$layout, false)) !== false) ? PHP_EOL . PHP_EOL . $header : ''
    -				);
    -			}
    -		}
    -	}
    -
    -	public function getReplacementNames()
    -	{
    -		foreach (CFactory::_('Utilities.Files')->toArray() as $type => $files)
    -		{
    -			foreach ($files as $view => $file)
    -			{
    -				if (isset($file['path'])
    -					&& ArrayHelper::check(
    -						$file
    -					))
    -				{
    -					if (File::exists($file['path']))
    -					{
    -						$string            = FileHelper::getContent(
    -							$file['path']
    -						);
    -						$buket['static'][] = $this->getInbetweenStrings(
    -							$string
    -						);
    -					}
    -				}
    -				elseif (ArrayHelper::check($file))
    -				{
    -					foreach ($file as $nr => $doc)
    -					{
    -						if (ArrayHelper::check($doc))
    -						{
    -							if (File::exists($doc['path']))
    -							{
    -								$string
    -									= FileHelper::getContent(
    -									$doc['path']
    -								);
    -								$buket[$view][] = $this->getInbetweenStrings(
    -									$string
    -								);
    -							}
    -						}
    -					}
    -				}
    -			}
    -		}
    -		foreach ($buket as $type => $array)
    -		{
    -			foreach ($array as $replacments)
    -			{
    -				$replacments = array_unique($replacments);
    -				foreach ($replacments as $replacment)
    -				{
    -					if ($type !== 'static')
    -					{
    -						$echos[$replacment] = "#" . "#" . "#" . $replacment
    -							. "#" . "#" . "#
    "; - } - elseif ($type === 'static') - { - $echos[$replacment] = "#" . "#" . "#" . $replacment - . "#" . "#" . "#
    "; - } - } - } - } - - foreach ($echos as $echo) - { - echo $echo . '
    '; - } - } - - public function setMethodGetItem(&$view) - { - $script = ''; - // get the component name - $Component = CFactory::_('Compiler.Builder.Content.One')->get('Component'); - $component = CFactory::_('Compiler.Builder.Content.One')->get('component'); - // go from base64 to string - if (CFactory::_('Compiler.Builder.Base.Six.Four')->exists($view)) - { - foreach (CFactory::_('Compiler.Builder.Base.Six.Four')->get($view) as $baseString) - { - $script .= PHP_EOL . PHP_EOL . Indent::_(3) - . "if (!empty(\$item->" . $baseString - . "))"; // TODO && base64_encode(base64_decode(\$item->".$baseString.", true)) === \$item->".$baseString.")"; - $script .= PHP_EOL . Indent::_(3) . "{"; - $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " base64 Decode " . $baseString . "."; - $script .= PHP_EOL . Indent::_(4) . "\$item->" . $baseString - . " = base64_decode(\$item->" . $baseString . ");"; - $script .= PHP_EOL . Indent::_(3) . "}"; - } - } - // decryption - foreach (CFactory::_('Config')->cryption_types as $cryptionType) - { - if (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field')->exists($view)) - { - if ('expert' !== $cryptionType) - { - $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) . " Get the " . $cryptionType - . " encryption."; - $script .= PHP_EOL . Indent::_(3) . "\$" . $cryptionType - . "key = " . $Component . "Helper::getCryptKey('" - . $cryptionType . "');"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Get the encryption object."; - $script .= PHP_EOL . Indent::_(3) . "\$" . $cryptionType - . " = new Super___99175f6d_dba8_4086_8a65_5c4ec175e61d___Power(\$" . $cryptionType . "key);"; - foreach (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field')->get($view) as $baseString) - { - $script .= PHP_EOL . PHP_EOL . Indent::_(3) - . "if (!empty(\$item->" . $baseString . ") && \$" - . $cryptionType . "key && !is_numeric(\$item->" - . $baseString . ") && \$item->" . $baseString - . " === base64_encode(base64_decode(\$item->" - . $baseString . ", true)))"; - $script .= PHP_EOL . Indent::_(3) . "{"; - $script .= PHP_EOL . Indent::_(4) . "//" - . Line::_(__Line__, __Class__) . " " . $cryptionType - . " decrypt data " . $baseString . "."; - $script .= PHP_EOL . Indent::_(4) . "\$item->" - . $baseString . " = rtrim(\$" . $cryptionType - . "->decryptString(\$item->" . $baseString . "), " - . '"\0"' . ");"; - $script .= PHP_EOL . Indent::_(3) . "}"; - } - } - else - { - if (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> - exists("{$view}.get")) - { - foreach (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> - get("{$view}.get") as $block - ) - { - $script .= PHP_EOL . Indent::_(3) . implode( - PHP_EOL . Indent::_(3), $block - ); - } - } - // set the expert script - foreach (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field')-> - get($view) as $baseString => $opener_) - { - $_placeholder_for_field = array('[[[field]]]' => '$item->' . $baseString); - $script .= CFactory::_('Placeholder')->update( - PHP_EOL . Indent::_(3) . implode( - PHP_EOL . Indent::_(3), $opener_['get'] - ), $_placeholder_for_field - ); - } - } - } - } - // go from json to array - if (CFactory::_('Compiler.Builder.Json.Item')->exists($view)) - { - foreach (CFactory::_('Compiler.Builder.Json.Item')->get($view) as $jsonItem) - { - $script .= PHP_EOL . PHP_EOL . Indent::_(3) - . "if (!empty(\$item->" . $jsonItem . "))"; - $script .= PHP_EOL . Indent::_(3) . "{"; - $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Convert the " . $jsonItem . " field to an array."; - $script .= PHP_EOL . Indent::_(4) . "\$" . $jsonItem - . " = new Registry;"; - $script .= PHP_EOL . Indent::_(4) . "\$" . $jsonItem - . "->loadString(\$item->" . $jsonItem . ");"; - $script .= PHP_EOL . Indent::_(4) . "\$item->" . $jsonItem - . " = \$" . $jsonItem . "->toArray();"; - $script .= PHP_EOL . Indent::_(3) . "}"; - } - } - // go from json to string - if (CFactory::_('Compiler.Builder.Json.String')->exists($view)) - { - $makeArray = ''; - foreach (CFactory::_('Compiler.Builder.Json.String')->get($view) as $jsonString) - { - $script .= PHP_EOL . PHP_EOL . Indent::_(3) - . "if (!empty(\$item->" . $jsonString . "))"; - $script .= PHP_EOL . Indent::_(3) . "{"; - $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " JSON Decode " . $jsonString . "."; - if (CFactory::_('Compiler.Builder.Json.Item.Array')->inArray($jsonString, $view) || - strpos((string) $jsonString, 'group') !== false) - { - $makeArray = ',true'; - } - $script .= PHP_EOL . Indent::_(4) . "\$item->" . $jsonString - . " = json_decode(\$item->" . $jsonString . $makeArray - . ");"; - $script .= PHP_EOL . Indent::_(3) . "}"; - } - } - // add the tag get options - if (CFactory::_('Compiler.Builder.Tags')->exists($view)) - { - $script .= PHP_EOL . PHP_EOL . Indent::_(3) - . "if (!empty(\$item->id))"; - $script .= PHP_EOL . Indent::_(3) . "{"; - $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Get Tag IDs."; - $script .= PHP_EOL . Indent::_(4) . "\$item->tags" - . " = new JHelperTags;"; - $script .= PHP_EOL . Indent::_(4) - . "\$item->tags->getTagIds(\$item->id, 'com_$component.$view');"; - $script .= PHP_EOL . Indent::_(3) . "}"; - } - // add custom php to getitem method - $script .= CFactory::_('Customcode.Dispenser')->get( - 'php_getitem', $view, PHP_EOL . PHP_EOL - ); - - return $script; - } - - public function setCheckboxSave(&$view) - { - $script = ''; - if (CFactory::_('Compiler.Builder.Check.Box')->exists($view)) - { - foreach (CFactory::_('Compiler.Builder.Check.Box')->get($view) as $checkbox) - { - $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Set the empty " . $checkbox - . " item to data"; - $script .= PHP_EOL . Indent::_(2) . "if (!isset(\$data['" - . $checkbox . "']))"; - $script .= PHP_EOL . Indent::_(2) . "{"; - $script .= PHP_EOL . Indent::_(3) . "\$data['" . $checkbox - . "'] = '';"; - $script .= PHP_EOL . Indent::_(2) . "}"; - } - } - - return $script; - } - - public function setMethodItemSave(&$view) - { - $script = ''; - // get component name - $Component = CFactory::_('Compiler.Builder.Content.One')->get('Component'); - $component = CFactory::_('Config')->component_code_name; - // check if there was script added before modeling of data - $script .= CFactory::_('Customcode.Dispenser')->get( - 'php_before_save', $view, PHP_EOL . PHP_EOL - ); - // turn array into JSON string - if (CFactory::_('Compiler.Builder.Json.Item')->exists($view)) - { - foreach (CFactory::_('Compiler.Builder.Json.Item')->get($view) as $jsonItem) - { - $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Set the " . $jsonItem - . " items to data."; - $script .= PHP_EOL . Indent::_(2) . "if (isset(\$data['" - . $jsonItem . "']) && is_array(\$data['" . $jsonItem - . "']))"; - $script .= PHP_EOL . Indent::_(2) . "{"; - $script .= PHP_EOL . Indent::_(3) . "\$" . $jsonItem - . " = new JRegistry;"; - $script .= PHP_EOL . Indent::_(3) . "\$" . $jsonItem - . "->loadArray(\$data['" . $jsonItem . "']);"; - $script .= PHP_EOL . Indent::_(3) . "\$data['" . $jsonItem - . "'] = (string) \$" . $jsonItem . ";"; - $script .= PHP_EOL . Indent::_(2) . "}"; - if (isset($this->permissionFields[$view]) - && isset($this->permissionFields[$view][$jsonItem]) - && ArrayHelper::check( - $this->permissionFields[$view][$jsonItem] - )) - { - $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) - . " Also check permission since the value may be removed due to permissions"; - $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) - . " Then we do not want to clear it out, but simple ignore the empty " - . $jsonItem; - $script .= PHP_EOL . Indent::_(2) - . "elseif (!isset(\$data['" . $jsonItem . "'])"; - // only add permission that are available - foreach ( - $this->permissionFields[$view][$jsonItem] as - $permission_option => $fieldType - ) - { - $script .= PHP_EOL . Indent::_(3) - . "&& JFactory::getUser()->authorise('" . $view - . "." . $permission_option . "." . $jsonItem - . "', 'com_" . $component . "')"; - } - $script .= ")"; - } - else - { - $script .= PHP_EOL . Indent::_(2) - . "elseif (!isset(\$data['" . $jsonItem . "']))"; - } - $script .= PHP_EOL . Indent::_(2) . "{"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Set the empty " . $jsonItem . " to data"; - $script .= PHP_EOL . Indent::_(3) . "\$data['" . $jsonItem - . "'] = '';"; - $script .= PHP_EOL . Indent::_(2) . "}"; - } - } - // turn string into json string - if (CFactory::_('Compiler.Builder.Json.String')->exists($view)) - { - foreach (CFactory::_('Compiler.Builder.Json.String')->get($view) as $jsonString) - { - $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Set the " . $jsonString - . " string to JSON string."; - $script .= PHP_EOL . Indent::_(2) . "if (isset(\$data['" - . $jsonString . "']))"; - $script .= PHP_EOL . Indent::_(2) . "{"; - $script .= PHP_EOL . Indent::_(3) . "\$data['" . $jsonString - . "'] = (string) json_encode(\$data['" . $jsonString - . "']);"; - $script .= PHP_EOL . Indent::_(2) . "}"; - } - } - // turn string into base 64 string - if (CFactory::_('Compiler.Builder.Base.Six.Four')->exists($view)) - { - foreach (CFactory::_('Compiler.Builder.Base.Six.Four')->get($view) as $baseString) - { - $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Set the " . $baseString - . " string to base64 string."; - $script .= PHP_EOL . Indent::_(2) . "if (isset(\$data['" - . $baseString . "']))"; - $script .= PHP_EOL . Indent::_(2) . "{"; - $script .= PHP_EOL . Indent::_(3) . "\$data['" . $baseString - . "'] = base64_encode(\$data['" . $baseString . "']);"; - $script .= PHP_EOL . Indent::_(2) . "}"; - } - } - // turn string into encrypted string - foreach (CFactory::_('Config')->cryption_types as $cryptionType) - { - if (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field')-> - exists($view)) - { - if ('expert' !== $cryptionType) - { - $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Get the " . $cryptionType - . " encryption key."; - $script .= PHP_EOL . Indent::_(2) . "\$" . $cryptionType - . "key = " . $Component . "Helper::getCryptKey('" - . $cryptionType . "');"; - $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Get the encryption object"; - $script .= PHP_EOL . Indent::_(2) . "\$" . $cryptionType - . " = new Super___99175f6d_dba8_4086_8a65_5c4ec175e61d___Power(\$" . $cryptionType . "key);"; - foreach (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field')-> - get($view) as $baseString) - { - $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Encrypt data " - . $baseString . "."; - $script .= PHP_EOL . Indent::_(2) . "if (isset(\$data['" - . $baseString . "']) && \$" . $cryptionType - . "key)"; - $script .= PHP_EOL . Indent::_(2) . "{"; - $script .= PHP_EOL . Indent::_(3) . "\$data['" - . $baseString . "'] = \$" . $cryptionType - . "->encryptString(\$data['" . $baseString . "']);"; - $script .= PHP_EOL . Indent::_(2) . "}"; - } - } - else - { - if (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> - exists("{$view}.save")) - { - foreach (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> - get("{$view}.save") as $block) - { - $script .= PHP_EOL . Indent::_(2) . implode( - PHP_EOL . Indent::_(2), $block - ); - } - } - // set the expert script - foreach (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field')-> - get($view) as $baseString => $locker_) - { - $_placeholder_for_field - = array('[[[field]]]' => "\$data['" - . $baseString . "']"); - $script .= CFactory::_('Placeholder')->update( - PHP_EOL . Indent::_(2) . implode( - PHP_EOL . Indent::_(2), $locker_['save'] - ), $_placeholder_for_field - ); - } - } - } - } - // add custom PHP to the save method - $script .= CFactory::_('Customcode.Dispenser')->get( - 'php_save', $view, PHP_EOL . PHP_EOL - ); - - return $script; - } - - public function setJtableConstructor(&$view) - { - // reset - $oserver = ""; - // set component name - $component = CFactory::_('Config')->component_code_name; - // add the tags observer - if (CFactory::_('Compiler.Builder.Tags')->exists($view)) - { - $oserver .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Adding Tag Options"; - $oserver .= PHP_EOL . Indent::_(2) - . "JTableObserverTags::createObserver(\$this, array('typeAlias' => 'com_" - . $component . "." . $view . "'));"; - } - // add the history/version observer - if (CFactory::_('Compiler.Builder.History')->exists($view)) - { - $oserver .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Adding History Options"; - $oserver .= PHP_EOL . Indent::_(2) - . "JTableObserverContenthistory::createObserver(\$this, array('typeAlias' => 'com_" - . $component . "." . $view . "'));"; - } - - return $oserver; - } - - public function setJtableAliasCategory(&$view) - { - // only add Observers if both title, alias and category is available in view - $code = CFactory::_('Compiler.Builder.Category.Code')->get("{$view}.code"); - if ($code !== null) - { - return ", '" . $code . "' => \$this->" . $code; - } - - return ''; - } - - public function setComponentToContentTypes($action) - { - $script = ''; - if (CFactory::_('Component')->isArray('admin_views')) - { - // set component name - $component = CFactory::_('Config')->component_code_name; - // reset - $dbStuff = array(); - // start loading the content type data - foreach (CFactory::_('Component')->get('admin_views') as $viewData) - { - // set main keys - $view = StringHelper::safe( - $viewData['settings']->name_single - ); - // set list view keys - $views = StringHelper::safe( - $viewData['settings']->name_list - ); - // get this views content type data - $dbStuff[$view] = $this->getContentType($view, $component); - // get the correct views name - $checkViews = CFactory::_('Compiler.Builder.Category.Code')->getString("{$view}.views", $views); - if (ArrayHelper::check($dbStuff[$view]) - && CFactory::_('Compiler.Builder.Category.Code')->exists($view) - && ($checkViews == $views)) - { - $dbStuff[$view . ' category'] - = $this->getCategoryContentType( - $view, $views, $component - ); - } - elseif (!isset($dbStuff[$view]) - || !ArrayHelper::check($dbStuff[$view])) - { - // remove if not array - unset($dbStuff[$view]); - } - } - // build the db insert query - if (ArrayHelper::check($dbStuff)) - { - $taabb = ''; - if ($action === 'update') - { - $taabb = Indent::_(1); - } - $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) . " Get The Database object"; - $script .= PHP_EOL . Indent::_(3) - . "\$db = JFactory::getDbo();"; - foreach ($dbStuff as $name => $tables) - { - if (ArrayHelper::check($tables)) - { - $code = StringHelper::safe($name); - $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) . " Create the " . $name - . " content type object."; - $script .= PHP_EOL . Indent::_(3) . "\$" . $code - . " = new stdClass();"; - foreach ($tables as $table => $data) - { - $script .= PHP_EOL . Indent::_(3) . "\$" . $code - . "->" . $table . " = '" . $data . "';"; - } - if ($action === 'update') - { - // we first load script to check if data exist - $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) . " Check if " - . $name - . " type is already in content_type DB."; - $script .= PHP_EOL . Indent::_(3) . "\$" . $code - . "_id = null;"; - $script .= PHP_EOL . Indent::_(3) - . "\$query = \$db->getQuery(true);"; - $script .= PHP_EOL . Indent::_(3) - . "\$query->select(\$db->quoteName(array('type_id')));"; - $script .= PHP_EOL . Indent::_(3) - . "\$query->from(\$db->quoteName('#__content_types'));"; - $script .= PHP_EOL . Indent::_(3) - . "\$query->where(\$db->quoteName('type_alias') . ' LIKE '. \$db->quote($" - . $code . "->type_alias));"; - $script .= PHP_EOL . Indent::_(3) - . "\$db->setQuery(\$query);"; - $script .= PHP_EOL . Indent::_(3) - . "\$db->execute();"; - } - $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) - . " Set the object into the content types table."; - if ($action === 'update') - { - $script .= PHP_EOL . Indent::_(3) - . "if (\$db->getNumRows())"; - $script .= PHP_EOL . Indent::_(3) . "{"; - $script .= PHP_EOL . Indent::_(4) . "\$" . $code - . "->type_id = \$db->loadResult();"; - $script .= PHP_EOL . Indent::_(4) . "\$" . $code - . "_Updated = \$db->updateObject('#__content_types', \$" - . $code . ", 'type_id');"; - $script .= PHP_EOL . Indent::_(3) . "}"; - $script .= PHP_EOL . Indent::_(3) . "else"; - $script .= PHP_EOL . Indent::_(3) . "{"; - } - $script .= PHP_EOL . Indent::_(3) . $taabb . "\$" - . $code - . "_Inserted = \$db->insertObject('#__content_types', \$" - . $code . ");"; - if ($action === 'update') - { - $script .= PHP_EOL . Indent::_(3) . "}"; - } - } - } - $script .= PHP_EOL . PHP_EOL; - } - } - - return $script; - } - - public function setPostInstallScript() - { - // reset script - $script = $this->setComponentToContentTypes('install'); - - // set the component name - $component = CFactory::_('Config')->component_code_name; - - // add the assets table update for permissions rules - if (isset($this->assetsRules) - && ArrayHelper::check( - $this->assetsRules - )) - { - if (StringHelper::check($script)) - { - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Install the global extenstion assets permission."; - } - else - { - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Install the global extension assets permission."; - $script .= PHP_EOL . Indent::_(3) - . "\$db = JFactory::getDbo();"; - } - $script .= PHP_EOL . Indent::_(3) - . "\$query = \$db->getQuery(true);"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Field to update."; - $script .= PHP_EOL . Indent::_(3) . "\$fields = array("; - $script .= PHP_EOL . Indent::_(4) - . "\$db->quoteName('rules') . ' = ' . \$db->quote('{" . implode( - ',', $this->assetsRules - ) . "}'),"; - $script .= PHP_EOL . Indent::_(3) . ");"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Condition."; - $script .= PHP_EOL . Indent::_(3) . "\$conditions = array("; - $script .= PHP_EOL . Indent::_(4) - . "\$db->quoteName('name') . ' = ' . \$db->quote('com_" - . $component . "')"; - $script .= PHP_EOL . Indent::_(3) . ");"; - $script .= PHP_EOL . Indent::_(3) - . "\$query->update(\$db->quoteName('#__assets'))->set(\$fields)->where(\$conditions);"; - $script .= PHP_EOL . Indent::_(3) . "\$db->setQuery(\$query);"; - $script .= PHP_EOL . Indent::_(3) . "\$allDone = \$db->execute();" - . PHP_EOL; - } - // add the global params for the component global settings - if (isset($this->extensionsParams) - && ArrayHelper::check($this->extensionsParams)) - { - if (StringHelper::check($script)) - { - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Install the global extension params."; - } - else - { - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Install the global extension params."; - $script .= PHP_EOL . Indent::_(3) - . "\$db = JFactory::getDbo();"; - } - $script .= PHP_EOL . Indent::_(3) - . "\$query = \$db->getQuery(true);"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Field to update."; - $script .= PHP_EOL . Indent::_(3) . "\$fields = array("; - $script .= PHP_EOL . Indent::_(4) - . "\$db->quoteName('params') . ' = ' . \$db->quote('{" - . implode(',', $this->extensionsParams) . "}'),"; - $script .= PHP_EOL . Indent::_(3) . ");"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Condition."; - $script .= PHP_EOL . Indent::_(3) . "\$conditions = array("; - $script .= PHP_EOL . Indent::_(4) - . "\$db->quoteName('element') . ' = ' . \$db->quote('com_" - . $component . "')"; - $script .= PHP_EOL . Indent::_(3) . ");"; - $script .= PHP_EOL . Indent::_(3) - . "\$query->update(\$db->quoteName('#__extensions'))->set(\$fields)->where(\$conditions);"; - $script .= PHP_EOL . Indent::_(3) . "\$db->setQuery(\$query);"; - $script .= PHP_EOL . Indent::_(3) . "\$allDone = \$db->execute();" - . PHP_EOL; - } - // add the custom script - $script .= CFactory::_('Customcode.Dispenser')->get( - 'php_postflight', 'install', PHP_EOL . PHP_EOL, null, true - ); - // add the Intelligent Fix script if needed - $script .= $this->getAssetsTableIntelligentInstall(); - // add the component install notice - if (StringHelper::check($script)) - { - $script .= PHP_EOL . Indent::_(3) - . 'echo \''; - $script .= PHP_EOL . Indent::_(4) . ''; - $script .= PHP_EOL . Indent::_(4) . '\';'; - - return $script; - } - - return PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " noting to install."; - } - - public function setPostUpdateScript() - { - // reset script - $script = $this->setComponentToContentTypes('update'); - // add the custom script - $script .= CFactory::_('Customcode.Dispenser')->get( - 'php_postflight', 'update', PHP_EOL . PHP_EOL, null, true - ); - if (CFactory::_('Component')->isArray('admin_views')) - { - $script .= PHP_EOL . Indent::_(3) - . 'echo \''; - $script .= PHP_EOL . Indent::_(4) . ''; - $script .= PHP_EOL . Indent::_(4) . ''; - $script .= PHP_EOL . Indent::_(4) . "

    Upgrade to Version " - . CFactory::_('Compiler.Builder.Content.One')->get('ACTUALVERSION') - . " Was Successful! Let us know if anything is not working as expected.

    ';"; - } - - if (StringHelper::check($script)) - { - return $script; - } - - return PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " noting to update."; - } - - public function setUninstallScript() - { - // reset script - $script = ''; - if (isset($this->uninstallScriptBuilder) - && ArrayHelper::check( - $this->uninstallScriptBuilder - )) - { - $component = CFactory::_('Config')->component_code_name; - // start loading the data to delete - $script .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Get Application object"; - $script .= PHP_EOL . Indent::_(2) - . "\$app = JFactory::getApplication();"; - $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Get The Database object"; - $script .= PHP_EOL . Indent::_(2) . "\$db = JFactory::getDbo();"; - - foreach ( - $this->uninstallScriptBuilder as $viewsCodeName => $typeAlias - ) - { - // set a var value - $view = StringHelper::safe($viewsCodeName); - - // check if it has field relations - if (isset($this->uninstallScriptFields) - && isset($this->uninstallScriptFields[$viewsCodeName])) - { - // First check if data is till in table - $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) - . " Create a new query object."; - $script .= PHP_EOL . Indent::_(2) - . "\$query = \$db->getQuery(true);"; - $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Select ids from fields"; - $script .= PHP_EOL . Indent::_(2) - . "\$query->select(\$db->quoteName('id'));"; - $script .= PHP_EOL . Indent::_(2) - . "\$query->from(\$db->quoteName('#__fields'));"; - $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Where " . $viewsCodeName . " context is found"; - $script .= PHP_EOL . Indent::_(2) - . "\$query->where( \$db->quoteName('context') . ' = '. \$db->quote('" - . $typeAlias . "') );"; - $script .= PHP_EOL . Indent::_(2) - . "\$db->setQuery(\$query);"; - $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Execute query to see if context is found"; - $script .= PHP_EOL . Indent::_(2) . "\$db->execute();"; - $script .= PHP_EOL . Indent::_(2) . "\$" . $view - . "_found = \$db->getNumRows();"; - $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Now check if there were any rows"; - $script .= PHP_EOL . Indent::_(2) . "if (\$" . $view - . "_found)"; - $script .= PHP_EOL . Indent::_(2) . "{"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Since there are load the needed " . $view - . " field ids"; - $script .= PHP_EOL . Indent::_(3) . "\$" . $view - . "_field_ids = \$db->loadColumn();"; - - // Now remove the actual type entry - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Remove " . $viewsCodeName - . " from the field table"; - $script .= PHP_EOL . Indent::_(3) . "\$" . $view - . "_condition = array( \$db->quoteName('context') . ' = '. \$db->quote('" - . $typeAlias . "') );"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Create a new query object."; - $script .= PHP_EOL . Indent::_(3) - . "\$query = \$db->getQuery(true);"; - $script .= PHP_EOL . Indent::_(3) - . "\$query->delete(\$db->quoteName('#__fields'));"; - $script .= PHP_EOL . Indent::_(3) . "\$query->where(\$" - . $view . "_condition);"; - $script .= PHP_EOL . Indent::_(3) - . "\$db->setQuery(\$query);"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Execute the query to remove " . $viewsCodeName - . " items"; - $script .= PHP_EOL . Indent::_(3) . "\$" . $view - . "_done = \$db->execute();"; - $script .= PHP_EOL . Indent::_(3) . "if (\$" . $view - . "_done)"; - $script .= PHP_EOL . Indent::_(3) . "{"; - $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " If successfully remove " . $viewsCodeName - . " add queued success message."; - // TODO lang is not translated - $script .= PHP_EOL . Indent::_(4) - . "\$app->enqueueMessage(JText:" - . ":_('The fields with type (" . $typeAlias - . ") context was removed from the #__fields table'));"; - $script .= PHP_EOL . Indent::_(3) . "}"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Also Remove " . $viewsCodeName . " field values"; - $script .= PHP_EOL . Indent::_(3) . "\$" . $view - . "_condition = array( \$db->quoteName('field_id') . ' IN ('. implode(',', \$" - . $view . "_field_ids) .')');"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Create a new query object."; - $script .= PHP_EOL . Indent::_(3) - . "\$query = \$db->getQuery(true);"; - $script .= PHP_EOL . Indent::_(3) - . "\$query->delete(\$db->quoteName('#__fields_values'));"; - $script .= PHP_EOL . Indent::_(3) . "\$query->where(\$" - . $view . "_condition);"; - $script .= PHP_EOL . Indent::_(3) - . "\$db->setQuery(\$query);"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Execute the query to remove " . $viewsCodeName - . " field values"; - $script .= PHP_EOL . Indent::_(3) . "\$" . $view - . "_done = \$db->execute();"; - $script .= PHP_EOL . Indent::_(3) . "if (\$" . $view - . "_done)"; - $script .= PHP_EOL . Indent::_(3) . "{"; - $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " If successfully remove " . $viewsCodeName - . " add queued success message."; - // TODO lang is not translated - $script .= PHP_EOL . Indent::_(4) - . "\$app->enqueueMessage(JText:" - . ":_('The fields values for " . $viewsCodeName - . " was removed from the #__fields_values table'));"; - $script .= PHP_EOL . Indent::_(3) . "}"; - $script .= PHP_EOL . Indent::_(2) . "}"; - - // First check if data is till in table - $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) - . " Create a new query object."; - $script .= PHP_EOL . Indent::_(2) - . "\$query = \$db->getQuery(true);"; - $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Select ids from field groups"; - $script .= PHP_EOL . Indent::_(2) - . "\$query->select(\$db->quoteName('id'));"; - $script .= PHP_EOL . Indent::_(2) - . "\$query->from(\$db->quoteName('#__fields_groups'));"; - $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Where " . $viewsCodeName . " context is found"; - $script .= PHP_EOL . Indent::_(2) - . "\$query->where( \$db->quoteName('context') . ' = '. \$db->quote('" - . $typeAlias . "') );"; - $script .= PHP_EOL . Indent::_(2) - . "\$db->setQuery(\$query);"; - $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Execute query to see if context is found"; - $script .= PHP_EOL . Indent::_(2) . "\$db->execute();"; - $script .= PHP_EOL . Indent::_(2) . "\$" . $view - . "_found = \$db->getNumRows();"; - $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Now check if there were any rows"; - $script .= PHP_EOL . Indent::_(2) . "if (\$" . $view - . "_found)"; - $script .= PHP_EOL . Indent::_(2) . "{"; - - // Now remove the actual type entry - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Remove " . $viewsCodeName - . " from the field groups table"; - $script .= PHP_EOL . Indent::_(3) . "\$" . $view - . "_condition = array( \$db->quoteName('context') . ' = '. \$db->quote('" - . $typeAlias . "') );"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Create a new query object."; - $script .= PHP_EOL . Indent::_(3) - . "\$query = \$db->getQuery(true);"; - $script .= PHP_EOL . Indent::_(3) - . "\$query->delete(\$db->quoteName('#__fields_groups'));"; - $script .= PHP_EOL . Indent::_(3) . "\$query->where(\$" - . $view . "_condition);"; - $script .= PHP_EOL . Indent::_(3) - . "\$db->setQuery(\$query);"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Execute the query to remove " . $viewsCodeName - . " items"; - $script .= PHP_EOL . Indent::_(3) . "\$" . $view - . "_done = \$db->execute();"; - $script .= PHP_EOL . Indent::_(3) . "if (\$" . $view - . "_done)"; - $script .= PHP_EOL . Indent::_(3) . "{"; - $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " If successfully remove " . $viewsCodeName - . " add queued success message."; - // TODO lang is not translated - $script .= PHP_EOL . Indent::_(4) - . "\$app->enqueueMessage(JText:" - . ":_('The field groups with type (" . $typeAlias - . ") context was removed from the #__fields_groups table'));"; - $script .= PHP_EOL . Indent::_(3) . "}"; - $script .= PHP_EOL . Indent::_(2) . "}"; - } - // First check if data is till in table - $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Create a new query object."; - $script .= PHP_EOL . Indent::_(2) - . "\$query = \$db->getQuery(true);"; - $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Select id from content type table"; - $script .= PHP_EOL . Indent::_(2) - . "\$query->select(\$db->quoteName('type_id'));"; - $script .= PHP_EOL . Indent::_(2) - . "\$query->from(\$db->quoteName('#__content_types'));"; - $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Where " . $viewsCodeName . " alias is found"; - $script .= PHP_EOL . Indent::_(2) - . "\$query->where( \$db->quoteName('type_alias') . ' = '. \$db->quote('" - . $typeAlias . "') );"; - $script .= PHP_EOL . Indent::_(2) . "\$db->setQuery(\$query);"; - $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Execute query to see if alias is found"; - $script .= PHP_EOL . Indent::_(2) . "\$db->execute();"; - $script .= PHP_EOL . Indent::_(2) . "\$" . $view - . "_found = \$db->getNumRows();"; - $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Now check if there were any rows"; - $script .= PHP_EOL . Indent::_(2) . "if (\$" . $view - . "_found)"; - $script .= PHP_EOL . Indent::_(2) . "{"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Since there are load the needed " . $view - . " type ids"; - $script .= PHP_EOL . Indent::_(3) . "\$" . $view - . "_ids = \$db->loadColumn();"; - - // Now remove the actual type entry - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Remove " . $viewsCodeName - . " from the content type table"; - $script .= PHP_EOL . Indent::_(3) . "\$" . $view - . "_condition = array( \$db->quoteName('type_alias') . ' = '. \$db->quote('" - . $typeAlias . "') );"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Create a new query object."; - $script .= PHP_EOL . Indent::_(3) - . "\$query = \$db->getQuery(true);"; - $script .= PHP_EOL . Indent::_(3) - . "\$query->delete(\$db->quoteName('#__content_types'));"; - $script .= PHP_EOL . Indent::_(3) . "\$query->where(\$" . $view - . "_condition);"; - $script .= PHP_EOL . Indent::_(3) . "\$db->setQuery(\$query);"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Execute the query to remove " . $viewsCodeName - . " items"; - $script .= PHP_EOL . Indent::_(3) . "\$" . $view - . "_done = \$db->execute();"; - $script .= PHP_EOL . Indent::_(3) . "if (\$" . $view . "_done)"; - $script .= PHP_EOL . Indent::_(3) . "{"; - $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " If successfully remove " . $viewsCodeName - . " add queued success message."; - // TODO lang is not translated - $script .= PHP_EOL . Indent::_(4) - . "\$app->enqueueMessage(JText:" . ":_('The (" . $typeAlias - . ") type alias was removed from the #__content_type table'));"; - $script .= PHP_EOL . Indent::_(3) . "}"; - - // Now remove the related items from contentitem tag map table - $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) . " Remove " . $viewsCodeName - . " items from the contentitem tag map table"; - $script .= PHP_EOL . Indent::_(3) . "\$" . $view - . "_condition = array( \$db->quoteName('type_alias') . ' = '. \$db->quote('" - . $typeAlias . "') );"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Create a new query object."; - $script .= PHP_EOL . Indent::_(3) - . "\$query = \$db->getQuery(true);"; - $script .= PHP_EOL . Indent::_(3) - . "\$query->delete(\$db->quoteName('#__contentitem_tag_map'));"; - $script .= PHP_EOL . Indent::_(3) . "\$query->where(\$" . $view - . "_condition);"; - $script .= PHP_EOL . Indent::_(3) . "\$db->setQuery(\$query);"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Execute the query to remove " . $viewsCodeName - . " items"; - $script .= PHP_EOL . Indent::_(3) . "\$" . $view - . "_done = \$db->execute();"; - $script .= PHP_EOL . Indent::_(3) . "if (\$" . $view . "_done)"; - $script .= PHP_EOL . Indent::_(3) . "{"; - $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " If successfully remove " . $viewsCodeName - . " add queued success message."; - // TODO lang is not translated - $script .= PHP_EOL . Indent::_(4) - . "\$app->enqueueMessage(JText:" . ":_('The (" . $typeAlias - . ") type alias was removed from the #__contentitem_tag_map table'));"; - $script .= PHP_EOL . Indent::_(3) . "}"; - - // Now remove the related items from ucm content table - $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) . " Remove " . $viewsCodeName - . " items from the ucm content table"; - $script .= PHP_EOL . Indent::_(3) . "\$" . $view - . "_condition = array( \$db->quoteName('core_type_alias') . ' = ' . \$db->quote('" - . $typeAlias . "') );"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Create a new query object."; - $script .= PHP_EOL . Indent::_(3) - . "\$query = \$db->getQuery(true);"; - $script .= PHP_EOL . Indent::_(3) - . "\$query->delete(\$db->quoteName('#__ucm_content'));"; - $script .= PHP_EOL . Indent::_(3) . "\$query->where(\$" . $view - . "_condition);"; - $script .= PHP_EOL . Indent::_(3) . "\$db->setQuery(\$query);"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Execute the query to remove " . $viewsCodeName - . " items"; - $script .= PHP_EOL . Indent::_(3) . "\$" . $view - . "_done = \$db->execute();"; - $script .= PHP_EOL . Indent::_(3) . "if (\$" . $view . "_done)"; - $script .= PHP_EOL . Indent::_(3) . "{"; - $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " If successfully removed " . $viewsCodeName - . " add queued success message."; - // TODO lang is not translated - $script .= PHP_EOL . Indent::_(4) - . "\$app->enqueueMessage(JText:" . ":_('The (" . $typeAlias - . ") type alias was removed from the #__ucm_content table'));"; - $script .= PHP_EOL . Indent::_(3) . "}"; - - // setup the foreach loop of ids - $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) . " Make sure that all the " - . $viewsCodeName . " items are cleared from DB"; - $script .= PHP_EOL . Indent::_(3) . "foreach (\$" . $view - . "_ids as \$" . $view . "_id)"; - $script .= PHP_EOL . Indent::_(3) . "{"; - - // Now remove the related items from ucm base table - $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Remove " . $viewsCodeName - . " items from the ucm base table"; - $script .= PHP_EOL . Indent::_(4) . "\$" . $view - . "_condition = array( \$db->quoteName('ucm_type_id') . ' = ' . \$" - . $view . "_id);"; - $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Create a new query object."; - $script .= PHP_EOL . Indent::_(4) - . "\$query = \$db->getQuery(true);"; - $script .= PHP_EOL . Indent::_(4) - . "\$query->delete(\$db->quoteName('#__ucm_base'));"; - $script .= PHP_EOL . Indent::_(4) . "\$query->where(\$" . $view - . "_condition);"; - $script .= PHP_EOL . Indent::_(4) . "\$db->setQuery(\$query);"; - $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Execute the query to remove " . $viewsCodeName - . " items"; - $script .= PHP_EOL . Indent::_(4) . "\$db->execute();"; - - // Now remove the related items from ucm history table - $script .= PHP_EOL . PHP_EOL . Indent::_(4) . "//" - . Line::_(__Line__, __Class__) . " Remove " . $viewsCodeName - . " items from the ucm history table"; - $script .= PHP_EOL . Indent::_(4) . "\$" . $view - . "_condition = array( \$db->quoteName('ucm_type_id') . ' = ' . \$" - . $view . "_id);"; - $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Create a new query object."; - $script .= PHP_EOL . Indent::_(4) - . "\$query = \$db->getQuery(true);"; - $script .= PHP_EOL . Indent::_(4) - . "\$query->delete(\$db->quoteName('#__ucm_history'));"; - $script .= PHP_EOL . Indent::_(4) . "\$query->where(\$" . $view - . "_condition);"; - $script .= PHP_EOL . Indent::_(4) . "\$db->setQuery(\$query);"; - $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Execute the query to remove " . $viewsCodeName - . " items"; - $script .= PHP_EOL . Indent::_(4) . "\$db->execute();"; - - $script .= PHP_EOL . Indent::_(3) . "}"; - - $script .= PHP_EOL . Indent::_(2) . "}"; - } - - $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " If All related items was removed queued success message."; - // TODO lang is not translated - $script .= PHP_EOL . Indent::_(2) . "\$app->enqueueMessage(JText:" - . ":_('All related items was removed from the #__ucm_base table'));"; - $script .= PHP_EOL . Indent::_(2) . "\$app->enqueueMessage(JText:" - . ":_('All related items was removed from the #__ucm_history table'));"; - // finaly remove the assets from the assets table - $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Remove " . $component . " assets from the assets table"; - $script .= PHP_EOL . Indent::_(2) . "\$" . $component - . "_condition = array( \$db->quoteName('name') . ' LIKE ' . \$db->quote('com_" - . $component . "%') );"; - $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Create a new query object."; - $script .= PHP_EOL . Indent::_(2) - . "\$query = \$db->getQuery(true);"; - $script .= PHP_EOL . Indent::_(2) - . "\$query->delete(\$db->quoteName('#__assets'));"; - $script .= PHP_EOL . Indent::_(2) . "\$query->where(\$" . $component - . "_condition);"; - $script .= PHP_EOL . Indent::_(2) . "\$db->setQuery(\$query);"; - $script .= PHP_EOL . Indent::_(2) . "\$" . $view - . "_done = \$db->execute();"; - $script .= PHP_EOL . Indent::_(2) . "if (\$" . $view . "_done)"; - $script .= PHP_EOL . Indent::_(2) . "{"; - $script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " If successfully removed " . $component - . " add queued success message."; - // TODO lang is not translated - $script .= PHP_EOL . Indent::_(3) . "\$app->enqueueMessage(JText:" - . ":_('All related items was removed from the #__assets table'));"; - $script .= PHP_EOL . Indent::_(2) . "}"; - // done - $script .= PHP_EOL; - } - elseif (CFactory::_('Config')->add_assets_table_fix == 2) - { - // start loading the data to delete (WE NEED THIS) - $script .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Get Application object"; - $script .= PHP_EOL . Indent::_(2) - . "\$app = JFactory::getApplication();"; - $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Get The Database object"; - $script .= PHP_EOL . Indent::_(2) . "\$db = JFactory::getDbo();"; - } - // add the Intelligent Reversal script if needed - $script .= $this->getAssetsTableIntelligentUninstall(); - // add the custom uninstall script - $script .= CFactory::_('Customcode.Dispenser')->get( - 'php_method', 'uninstall', "", null, true, null, PHP_EOL - ); - - return $script; - } - - /** - * build code for the assets table script intelligent fix - * - * @return string The php to place in script.php - * - */ - protected function getAssetsTableIntelligentInstall() - { - // WHY DO WE NEED AN ASSET TABLE FIX? - // https://www.mysqltutorial.org/mysql-varchar/ - // https://stackoverflow.com/a/15227917/1429677 - // https://forums.mysql.com/read.php?24,105964,105964 - // https://github.com/vdm-io/Joomla-Component-Builder/issues/616#issuecomment-741502980 - // 30 actions each +-20 characters with 8 groups - // that makes 4800 characters and the current Joomla - // column size is varchar(5120) - - // check if we should add the intelligent fix treatment for the assets table - if (CFactory::_('Config')->add_assets_table_fix == 2) - { - // get worse case - $access_worse_case = CFactory::_('Config')->get('access_worse_case', 0); - // get the type we will convert to - $data_type = ($access_worse_case > 64000) ? "MEDIUMTEXT" - : "TEXT"; - // the if statement about $rule_length - $codeIF = "\$rule_length <= " . $access_worse_case; - // fix column size - $script = array(); - $script[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) - . " Fix the assets table rules column size"; - $script[] = Indent::_(5) - . '$fix_rules_size = "ALTER TABLE `#__assets` CHANGE `rules` `rules` ' - . $data_type - . ' NOT NULL COMMENT \'JSON encoded access control. Enlarged to ' - . $data_type . ' by JCB\';";'; - $script[] = Indent::_(5) . "\$db->setQuery(\$fix_rules_size);"; - $script[] = Indent::_(5) . "\$db->execute();"; - $codeA = implode(PHP_EOL, $script); - // fixed message - $messageA = Indent::_(5) - . "\$app->enqueueMessage(JText::_('The #__assets table rules column was resized to the " - . $data_type - . " datatype for the components possible large permission rules.'));"; - // do nothing - $codeB = ""; - // fix not needed so ignore - $messageB = ""; - - // done - return $this->getAssetsTableIntelligentCode( - $codeIF, $codeA, $codeB, $messageA, $messageB, 2 - ); - } - - return ''; - } - - /** - * build code for the assets table script intelligent reversal - * - * @return string The php to place in script.php - * - */ - protected function getAssetsTableIntelligentUninstall() - { - // check if we should add the intelligent uninstall treatment for the assets table - if (CFactory::_('Config')->add_assets_table_fix == 2) - { - // the if statement about $rule_length - $codeIF = "\$rule_length < 5120"; - // reverse column size - $script = array(); - $script[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Revert the assets table rules column back to the default"; - $script[] = Indent::_(4) - . '$revert_rule = "ALTER TABLE `#__assets` CHANGE `rules` `rules` varchar(5120) NOT NULL COMMENT \'JSON encoded access control.\';";'; - $script[] = Indent::_(4) . "\$db->setQuery(\$revert_rule);"; - $script[] = Indent::_(4) . "\$db->execute();"; - $codeA = implode(PHP_EOL, $script); - // reverted message - $messageA = Indent::_(4) - . "\$app->enqueueMessage(JText::_('Reverted the #__assets table rules column back to its default size of varchar(5120)'));"; - // do nothing - $codeB = ""; - // not reverted message - $messageB = Indent::_(4) - . "\$app->enqueueMessage(JText::_('Could not revert the #__assets table rules column back to its default size of varchar(5120), since there is still one or more components that still requires the column to be larger.'));"; - - // done - return $this->getAssetsTableIntelligentCode( - $codeIF, $codeA, $codeB, $messageA, $messageB - ); - } - - return ''; - } - - /** - * set code for both install, update and uninstall - * - * @param string $codeIF The IF code to fix this issue - * @param string $codeA The a code to fix this issue - * @param string $codeB The b code to fix this issue - * @param string $messageA The fix a message - * @param string $messageB The fix b message - * - * @return string - * - */ - protected function getAssetsTableIntelligentCode($codeIF, $codeA, $codeB, - $messageA, $messageB, $tab = 1 - ) - { - // reset script - $script = array(); - $script[] = Indent::_($tab) . Indent::_(1) . "//" . Line::_( - __LINE__,__CLASS__ - ) - . " Get the biggest rule column in the assets table at this point."; - $script[] = Indent::_($tab) . Indent::_(1) - . '$get_rule_length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1";'; - $script[] = Indent::_($tab) . Indent::_(1) - . "\$db->setQuery(\$get_rule_length);"; - $script[] = Indent::_($tab) . Indent::_(1) . "if (\$db->execute())"; - $script[] = Indent::_($tab) . Indent::_(1) . "{"; - $script[] = Indent::_($tab) . Indent::_(2) - . "\$rule_length = \$db->loadResult();"; - // https://github.com/joomla/joomla-cms/blob/3.10.0-alpha3/installation/sql/mysql/joomla.sql#L22 - // Checked 1st December 2020 (let us know if this changes) - $script[] = Indent::_($tab) . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) - . " Check the size of the rules column"; - $script[] = Indent::_($tab) . Indent::_(2) . "if (" . $codeIF . ")"; - $script[] = Indent::_($tab) . Indent::_(2) . "{"; - $script[] = $codeA; - $script[] = $messageA; - $script[] = Indent::_($tab) . Indent::_(2) . "}"; - // only ad this if there is a B part - if (StringHelper::check($codeB) - || StringHelper::check($messageB)) - { - $script[] = Indent::_($tab) . Indent::_(2) . "else"; - $script[] = Indent::_($tab) . Indent::_(2) . "{"; - $script[] = $codeB; - $script[] = $messageB; - $script[] = Indent::_($tab) . Indent::_(2) . "}"; - } - $script[] = Indent::_($tab) . Indent::_(1) . "}"; - - // done - return PHP_EOL . implode(PHP_EOL, $script); - } - - public function setMoveFolderScript() - { - if (CFactory::_('Registry')->get('set_move_folders_install_script')) - { - // reset script - $script = array(); - $script[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " We check if we have dynamic folders to copy"; - $script[] = Indent::_(2) - . "\$this->setDynamicF0ld3rs(\$app, \$parent);"; - - // done - return PHP_EOL . implode(PHP_EOL, $script); - } - - return ''; - } - - public function setMoveFolderMethod() - { - if (CFactory::_('Registry')->get('set_move_folders_install_script')) - { - // reset script - $script = array(); - $script[] = Indent::_(1) . "/**"; - $script[] = Indent::_(1) - . " * Method to set/copy dynamic folders into place (use with caution)"; - $script[] = Indent::_(1) . " *"; - $script[] = Indent::_(1) . " * @return void"; - $script[] = Indent::_(1) . " */"; - $script[] = Indent::_(1) - . "protected function setDynamicF0ld3rs(\$app, \$parent)"; - $script[] = Indent::_(1) . "{"; - $script[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " get the instalation path"; - $script[] = Indent::_(2) . "\$installer = \$parent->getParent();"; - $script[] = Indent::_(2) - . "\$installPath = \$installer->getPath('source');"; - $script[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " get all the folders"; - $script[] = Indent::_(2) - . "\$folders = Folder::folders(\$installPath);"; - $script[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " check if we have folders we may want to copy"; - $script[] = Indent::_(2) - . "\$doNotCopy = array('media','admin','site'); // Joomla already deals with these"; - $script[] = Indent::_(2) . "if (count((array) \$folders) > 1)"; - $script[] = Indent::_(2) . "{"; - $script[] = Indent::_(3) . "foreach (\$folders as \$folder)"; - $script[] = Indent::_(3) . "{"; - $script[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Only copy if not a standard folders"; - $script[] = Indent::_(4) . "if (!in_array(\$folder, \$doNotCopy))"; - $script[] = Indent::_(4) . "{"; - $script[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) - . " set the source path"; - $script[] = Indent::_(5) . "\$src = \$installPath.'/'.\$folder;"; - $script[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) - . " set the destination path"; - $script[] = Indent::_(5) . "\$dest = JPATH_ROOT.'/'.\$folder;"; - $script[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) - . " now try to copy the folder"; - $script[] = Indent::_(5) - . "if (!Folder::copy(\$src, \$dest, '', true))"; - $script[] = Indent::_(5) . "{"; - $script[] = Indent::_(6) - . "\$app->enqueueMessage('Could not copy '.\$folder.' folder into place, please make sure destination is writable!', 'error');"; - $script[] = Indent::_(5) . "}"; - $script[] = Indent::_(4) . "}"; - $script[] = Indent::_(3) . "}"; - $script[] = Indent::_(2) . "}"; - $script[] = Indent::_(1) . "}"; - - // done - return PHP_EOL . PHP_EOL . implode(PHP_EOL, $script); - } - - return ''; - } - - public function getContentType($view, $component) - { - // add if history is to be kept or if tags is added - if (CFactory::_('Compiler.Builder.History')->exists($view) - || CFactory::_('Compiler.Builder.Tags')->exists($view)) - { - // reset array - $array = array(); - // set needed defaults - $alias = CFactory::_('Compiler.Builder.Alias')->get($view, 'null'); - $title = CFactory::_('Compiler.Builder.Title')->get($view, 'null'); - $category = CFactory::_('Compiler.Builder.Category.Code')->getString("{$view}.code", 'null'); - $categoryHistory = (CFactory::_('Compiler.Builder.Category.Code')->exists($view)) - ? - '{"sourceColumn": "' . $category - . '","targetTable": "#__categories","targetColumn": "id","displayColumn": "title"},' - : ''; - $Component = StringHelper::safe( - $component, 'F' - ); - $View = StringHelper::safe($view, 'F'); - $maintext = CFactory::_('Compiler.Builder.Main.Text.Field')->get($view, 'null'); - $hiddenFields = CFactory::_('Compiler.Builder.Hidden.Fields')->toString($view, ''); - $dynamicfields = CFactory::_('Compiler.Builder.Dynamic.Fields')->toString($view, ','); - $intFields = CFactory::_('Compiler.Builder.Integer.Fields')->toString($view, ''); - $customfieldlinks = CFactory::_('Compiler.Builder.Custom.Field.Links')->toString($view, ''); - // build uninstall script for content types - $this->uninstallScriptBuilder[$View] = 'com_' . $component . '.' - . $view; - $this->uninstallScriptContent[$view] = $view; - // check if this view has metadata - if (CFactory::_('Compiler.Builder.Meta.Data')->isString($view)) - { - $core_metadata = 'metadata'; - $core_metakey = 'metakey'; - $core_metadesc = 'metadesc'; - } - else - { - $core_metadata = 'null'; - $core_metakey = 'null'; - $core_metadesc = 'null'; - } - // check if view has access - if (CFactory::_('Compiler.Builder.Access.Switch')->exists($view)) - { - $core_access = 'access'; - $accessHistory - = ',{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"}'; - } - else - { - $core_access = 'null'; - $accessHistory = ''; - } - // set the title - $array['type_title'] = $Component . ' ' . $View; - // set the alias - $array['type_alias'] = 'com_' . $component . '.' . $view; - // set the table - $array['table'] = '{"special": {"dbtable": "#__' . $component . '_' - . $view . '","key": "id","type": "' . $View . '","prefix": "' - . $component - . 'Table","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - // set field map - $array['field_mappings'] - = '{"common": {"core_content_item_id": "id","core_title": "' - . $title . '","core_state": "published","core_alias": "' - . $alias - . '","core_created_time": "created","core_modified_time": "modified","core_body": "' - . $maintext - . '","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "' - . $core_access - . '","core_params": "params","core_featured": "null","core_metadata": "' - . $core_metadata - . '","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "' - . $core_metakey . '","core_metadesc": "' . $core_metadesc - . '","core_catid": "' . $category - . '","core_xreference": "null","asset_id": "asset_id"},"special": {' - . $dynamicfields . '}}'; - // set the router class method - $array['router'] = $Component . 'HelperRoute::get' . $View - . 'Route'; - // set content history - $array['content_history_options'] - = '{"formFile": "administrator/components/com_' . $component - . '/models/forms/' . $view - . '.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"' - . $hiddenFields - . '],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering"' - . $intFields . '],"displayLookup": [' . $categoryHistory - . '{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}' - . $accessHistory - . ',{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}' - . $customfieldlinks . ']}'; - - return $array; - } - - return false; - } - - public function getCategoryContentType($view, $views, $component) - { - // get the other view - $otherView = CFactory::_('Compiler.Builder.Category.Code')->getString("{$view}.view", 'error'); - $category = CFactory::_('Compiler.Builder.Category.Code')->getString("{$view}.code", 'error'); - $Component = StringHelper::safe($component, 'F'); - $View = StringHelper::safe($view, 'F'); - // build uninstall script for content types - $this->uninstallScriptBuilder[$View . ' ' . $category] = 'com_' - . $component . '.' . $otherView . '.category'; - $this->uninstallScriptContent[$View . ' ' . $category] = $View . ' ' - . $category; - // set the title - $array['type_title'] = $Component . ' ' . $View . ' ' - . StringHelper::safe($category, 'F'); - // set the alias - $array['type_alias'] = 'com_' . $component . '.' . $otherView - . '.category'; - // set the table - $array['table'] - = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}'; - // set field map - $array['field_mappings'] - = '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}'; - // set the router class method - $array['router'] = $Component . 'HelperRoute::getCategoryRoute'; - // set content history - $array['content_history_options'] - = '{"formFile":"administrator\/components\/com_categories\/models\/forms\/category.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"], "ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version", "hits", "path"],"convertToInt":["publish_up", "publish_down"], "displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}'; - - return $array; - } - - public function setRouterHelp($nameSingleCode, $nameListCode, - $front = false - ) - { - // add if tags is added, also for all front item views - if ((CFactory::_('Compiler.Builder.Tags')->exists($nameSingleCode) - || $front) - && (!in_array($nameSingleCode, $this->setRouterHelpDone))) - { - // insure we load a view only once - $this->setRouterHelpDone[] = $nameSingleCode; - // build view route helper - $View = StringHelper::safe( - $nameSingleCode, 'F' - ); - $routeHelper = array(); - $routeHelper[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $routeHelper[] = Indent::_(1) . " * @param int The route of the " - . $View; - $routeHelper[] = Indent::_(1) . " */"; - if ('category' === $nameSingleCode - || 'categories' === $nameSingleCode) - { - $routeHelper[] = Indent::_(1) . "public static function get" - . $View . "Route(\$id = 0)"; - } - else - { - $routeHelper[] = Indent::_(1) . "public static function get" - . $View . "Route(\$id = 0, \$catid = 0)"; - } - $routeHelper[] = Indent::_(1) . "{"; - $routeHelper[] = Indent::_(2) . "if (\$id > 0)"; - $routeHelper[] = Indent::_(2) . "{"; - $routeHelper[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Initialize the needel array."; - $routeHelper[] = Indent::_(3) . "\$needles = array("; - $routeHelper[] = Indent::_(4) . "'" . $nameSingleCode - . "' => array((int) \$id)"; - $routeHelper[] = Indent::_(3) . ");"; - $routeHelper[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Create the link"; - $routeHelper[] = Indent::_(3) . "\$link = 'index.php?option=com_" - . CFactory::_('Config')->component_code_name . "&view=" . $nameSingleCode - . "&id='. \$id;"; - $routeHelper[] = Indent::_(2) . "}"; - $routeHelper[] = Indent::_(2) . "else"; - $routeHelper[] = Indent::_(2) . "{"; - $routeHelper[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Initialize the needel array."; - $routeHelper[] = Indent::_(3) . "\$needles = array("; - $routeHelper[] = Indent::_(4) . "'" . $nameSingleCode - . "' => array()"; - $routeHelper[] = Indent::_(3) . ");"; - $routeHelper[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Create the link but don't add the id."; - $routeHelper[] = Indent::_(3) . "\$link = 'index.php?option=com_" - . CFactory::_('Config')->component_code_name . "&view=" . $nameSingleCode - . "';"; - $routeHelper[] = Indent::_(2) . "}"; - if ('category' != $nameSingleCode - && 'categories' != $nameSingleCode) - { - $routeHelper[] = Indent::_(2) . "if (\$catid > 1)"; - $routeHelper[] = Indent::_(2) . "{"; - $routeHelper[] = Indent::_(3) - . "\$categories = JCategories::getInstance('" - . CFactory::_('Config')->component_code_name . "." . $nameListCode . "');"; - $routeHelper[] = Indent::_(3) - . "\$category = \$categories->get(\$catid);"; - $routeHelper[] = Indent::_(3) . "if (\$category)"; - $routeHelper[] = Indent::_(3) . "{"; - $routeHelper[] = Indent::_(4) - . "\$needles['category'] = array_reverse(\$category->getPath());"; - $routeHelper[] = Indent::_(4) - . "\$needles['categories'] = \$needles['category'];"; - $routeHelper[] = Indent::_(4) . "\$link .= '&catid='.\$catid;"; - $routeHelper[] = Indent::_(3) . "}"; - $routeHelper[] = Indent::_(2) . "}"; - } - if (isset($this->hasMenuGlobal[$nameSingleCode])) - { - $routeHelper[] = PHP_EOL . Indent::_(2) - . "if (\$item = self::_findItem(\$needles, '" - . $nameSingleCode . "'))"; - } - else - { - $routeHelper[] = PHP_EOL . Indent::_(2) - . "if (\$item = self::_findItem(\$needles))"; - } - $routeHelper[] = Indent::_(2) . "{"; - $routeHelper[] = Indent::_(3) . "\$link .= '&Itemid='.\$item;"; - $routeHelper[] = Indent::_(2) . "}"; - $routeHelper[] = PHP_EOL . Indent::_(2) . "return \$link;"; - $routeHelper[] = Indent::_(1) . "}"; - - return implode(PHP_EOL, $routeHelper); - } - - return ''; - } - - public function routerParseSwitch(&$view, $viewArray = null, - $aliasView = true, $idView = true - ) - { - // reset buckets - $routerSwitch = array(); - $isCategory = ''; - $viewTable = false; - if ($viewArray && ArrayHelper::check($viewArray) - && isset($viewArray['settings']) - && isset($viewArray['settings']->main_get)) - { - // check if we have custom script for this router parse switch case - if (isset($viewArray['settings']->main_get->add_php_router_parse) - && $viewArray['settings']->main_get->add_php_router_parse == 1 - && isset($viewArray['settings']->main_get->php_router_parse) - && StringHelper::check( - $viewArray['settings']->main_get->php_router_parse - )) - { - // load the custom script for the switch based on dynamic get - $routerSwitch[] = PHP_EOL . Indent::_(3) . "case '" . $view - . "':"; - $routerSwitch[] = CFactory::_('Placeholder')->update_( - $viewArray['settings']->main_get->php_router_parse - ); - $routerSwitch[] = Indent::_(4) . "break;"; - - return implode(PHP_EOL, $routerSwitch); - } - // is this a catogory - elseif (isset($viewArray['settings']->main_get->db_table_main) - && $viewArray['settings']->main_get->db_table_main - === 'categories') - { - $isCategory = ', true'; // TODO we will keep an eye on this.... - } - // get the main table name - elseif (isset($viewArray['settings']->main_get->main_get) - && ArrayHelper::check( - $viewArray['settings']->main_get->main_get - )) - { - foreach ($viewArray['settings']->main_get->main_get as $get) - { - if (isset($get['as']) && $get['as'] === 'a') - { - if (isset($get['selection']) - && ArrayHelper::check( - $get['selection'] - ) - && isset($get['selection']['select_gets']) - && ArrayHelper::check( - $get['selection']['select_gets'] - )) - { - if (isset($get['selection']['table'])) - { - $viewTable = str_replace( - '#__' . CFactory::_('Config')->component_code_name . '_', '', - (string) $get['selection']['table'] - ); - } - } - break; - } - } - } - } - // add if tags is added, also for all front item views - if ($aliasView) - { - $routerSwitch[] = PHP_EOL . Indent::_(3) . "case '" . $view . "':"; - $routerSwitch[] = Indent::_(4) . "\$vars['view'] = '" . $view - . "';"; - $routerSwitch[] = Indent::_(4) - . "if (is_numeric(\$segments[\$count-1]))"; - $routerSwitch[] = Indent::_(4) . "{"; - $routerSwitch[] = Indent::_(5) - . "\$vars['id'] = (int) \$segments[\$count-1];"; - $routerSwitch[] = Indent::_(4) . "}"; - $routerSwitch[] = Indent::_(4) . "elseif (\$segments[\$count-1])"; - $routerSwitch[] = Indent::_(4) . "{"; - // we need to get from the table of this views main get the alias so we need the table name - if ($viewTable) - { - $routerSwitch[] = Indent::_(5) . "\$id = \$this->getVar('" - . $viewTable . "', \$segments[\$count-1], 'alias', 'id'" - . $isCategory . ");"; - } - else - { - $routerSwitch[] = Indent::_(5) . "\$id = \$this->getVar('" - . $view . "', \$segments[\$count-1], 'alias', 'id'" - . $isCategory . ");"; - } - $routerSwitch[] = Indent::_(5) . "if(\$id)"; - $routerSwitch[] = Indent::_(5) . "{"; - $routerSwitch[] = Indent::_(6) . "\$vars['id'] = \$id;"; - $routerSwitch[] = Indent::_(5) . "}"; - $routerSwitch[] = Indent::_(4) . "}"; - $routerSwitch[] = Indent::_(4) . "break;"; - } - elseif ($idView) - { - $routerSwitch[] = PHP_EOL . Indent::_(3) . "case '" . $view . "':"; - $routerSwitch[] = Indent::_(4) . "\$vars['view'] = '" . $view - . "';"; - $routerSwitch[] = Indent::_(4) - . "if (is_numeric(\$segments[\$count-1]))"; - $routerSwitch[] = Indent::_(4) . "{"; - $routerSwitch[] = Indent::_(5) - . "\$vars['id'] = (int) \$segments[\$count-1];"; - $routerSwitch[] = Indent::_(4) . "}"; - $routerSwitch[] = Indent::_(4) . "break;"; - } - else - { - $routerSwitch[] = PHP_EOL . Indent::_(3) . "case '" . $view . "':"; - $routerSwitch[] = Indent::_(4) . "\$vars['view'] = '" . $view - . "';"; - $routerSwitch[] = Indent::_(4) . "break;"; - } - - return implode(PHP_EOL, $routerSwitch); - } - - public function routerBuildViews(&$view) - { - if (CFactory::_('Compiler.Builder.Content.One')->exists('ROUTER_BUILD_VIEWS') - && StringHelper::check( - CFactory::_('Compiler.Builder.Content.One')->get('ROUTER_BUILD_VIEWS') - )) - { - return " || \$view === '" . $view . "'"; - } - else - { - return "\$view === '" . $view . "'"; - } - } - - public function setBatchMove($nameSingleCode) - { - // set needed defaults - $category = CFactory::_('Compiler.Builder.Category.Code')->getString("{$nameSingleCode}.code"); - $batchmove = array(); - $VIEW = StringHelper::safe($nameSingleCode, 'U'); - // component helper name - $Helper = CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper'; - // prepare custom script - $customScript = CFactory::_('Customcode.Dispenser')->get( - 'php_batchmove', $nameSingleCode, PHP_EOL . PHP_EOL, null, true - ); - - $batchmove[] = PHP_EOL . Indent::_(1) . "/**"; - $batchmove[] = Indent::_(1) . " * Batch move items to a new category"; - $batchmove[] = Indent::_(1) . " *"; - $batchmove[] = Indent::_(1) - . " * @param integer \$value The new category ID."; - $batchmove[] = Indent::_(1) - . " * @param array \$pks An array of row IDs."; - $batchmove[] = Indent::_(1) - . " * @param array \$contexts An array of item contexts."; - $batchmove[] = Indent::_(1) . " *"; - $batchmove[] = Indent::_(1) - . " * @return boolean True if successful, false otherwise and internal error is set."; - $batchmove[] = Indent::_(1) . " *"; - $batchmove[] = Indent::_(1) . " * @since 12.2"; - $batchmove[] = Indent::_(1) . " */"; - $batchmove[] = Indent::_(1) - . "protected function batchMove(\$values, \$pks, \$contexts)"; - $batchmove[] = Indent::_(1) . "{"; - $batchmove[] = Indent::_(2) . "if (empty(\$this->batchSet))"; - $batchmove[] = Indent::_(2) . "{"; - $batchmove[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Set some needed variables."; - $batchmove[] = Indent::_(3) - . "\$this->user = JFactory::getUser();"; - $batchmove[] = Indent::_(3) - . "\$this->table = \$this->getTable();"; - $batchmove[] = Indent::_(3) - . "\$this->tableClassName = get_class(\$this->table);"; - $batchmove[] = Indent::_(3) . "\$this->canDo = " . $Helper - . "::getActions('" . $nameSingleCode . "');"; - $batchmove[] = Indent::_(2) . "}"; - - $batchmove[] = PHP_EOL . Indent::_(2) . "if (!\$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit') . "') && !\$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.batch') . "'))"; - - $batchmove[] = Indent::_(2) . "{"; - $batchmove[] = Indent::_(3) . "\$this->setError(JText:" - . ":_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));"; - $batchmove[] = Indent::_(3) . "return false;"; - $batchmove[] = Indent::_(2) . "}" . $customScript; - - $batchmove[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " make sure published only updates if user has the permission."; - $batchmove[] = Indent::_(2) - . "if (isset(\$values['published']) && !\$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit.state') . "'))"; - - $batchmove[] = Indent::_(2) . "{"; - $batchmove[] = Indent::_(3) . "unset(\$values['published']);"; - $batchmove[] = Indent::_(2) . "}"; - - $batchmove[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " remove move_copy from array"; - $batchmove[] = Indent::_(2) . "unset(\$values['move_copy']);"; - - if ($category !== null) - { - $batchmove[] = PHP_EOL . Indent::_(2) - . "if (isset(\$values['category']) && (int) \$values['category'] > 0 && !static::checkCategoryId(\$values['category']))"; - $batchmove[] = Indent::_(2) . "{"; - $batchmove[] = Indent::_(3) . "return false;"; - $batchmove[] = Indent::_(2) . "}"; - $batchmove[] = Indent::_(2) - . "elseif (isset(\$values['category']) && (int) \$values['category'] > 0)"; - $batchmove[] = Indent::_(2) . "{"; - $batchmove[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " move the category value to correct field name"; - $batchmove[] = Indent::_(3) . "\$values['" . $category - . "'] = \$values['category'];"; - $batchmove[] = Indent::_(3) . "unset(\$values['category']);"; - $batchmove[] = Indent::_(2) . "}"; - $batchmove[] = Indent::_(2) - . "elseif (isset(\$values['category']))"; - $batchmove[] = Indent::_(2) . "{"; - $batchmove[] = Indent::_(3) . "unset(\$values['category']);"; - $batchmove[] = Indent::_(2) . "}" . PHP_EOL; - } - - $batchmove[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Parent exists so we proceed"; - $batchmove[] = Indent::_(2) . "foreach (\$pks as \$pk)"; - $batchmove[] = Indent::_(2) . "{"; - $batchmove[] = Indent::_(3) . "if (!\$this->user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit') . "', \$contexts[\$pk]))"; - $batchmove[] = Indent::_(3) . "{"; - $batchmove[] = Indent::_(4) . "\$this->setError(JText:" - . ":_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));"; - - $batchmove[] = Indent::_(4) . "return false;"; - $batchmove[] = Indent::_(3) . "}"; - - $batchmove[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Check that the row actually exists"; - $batchmove[] = Indent::_(3) . "if (!\$this->table->load(\$pk))"; - $batchmove[] = Indent::_(3) . "{"; - $batchmove[] = Indent::_(4) - . "if (\$error = \$this->table->getError())"; - $batchmove[] = Indent::_(4) . "{"; - $batchmove[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) - . " Fatal error"; - $batchmove[] = Indent::_(5) . "\$this->setError(\$error);"; - - $batchmove[] = Indent::_(5) . "return false;"; - $batchmove[] = Indent::_(4) . "}"; - $batchmove[] = Indent::_(4) . "else"; - $batchmove[] = Indent::_(4) . "{"; - $batchmove[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) - . " Not fatal error"; - $batchmove[] = Indent::_(5) . "\$this->setError(JText:" - . ":sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', \$pk));"; - $batchmove[] = Indent::_(5) . "continue;"; - $batchmove[] = Indent::_(4) . "}"; - $batchmove[] = Indent::_(3) . "}"; - - $batchmove[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " insert all set values."; - $batchmove[] = Indent::_(3) . "if (" . $Helper - . "::checkArray(\$values))"; - $batchmove[] = Indent::_(3) . "{"; - $batchmove[] = Indent::_(4) . "foreach (\$values as \$key => \$value)"; - $batchmove[] = Indent::_(4) . "{"; - $batchmove[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) - . " Do special action for access."; - $batchmove[] = Indent::_(5) - . "if ('access' === \$key && strlen(\$value) > 0)"; - $batchmove[] = Indent::_(5) . "{"; - $batchmove[] = Indent::_(6) . "\$this->table->\$key = \$value;"; - $batchmove[] = Indent::_(5) . "}"; - $batchmove[] = Indent::_(5) - . "elseif (strlen(\$value) > 0 && isset(\$this->table->\$key))"; - $batchmove[] = Indent::_(5) . "{"; - $batchmove[] = Indent::_(6) . "\$this->table->\$key = \$value;"; - $batchmove[] = Indent::_(5) . "}"; - $batchmove[] = Indent::_(4) . "}"; - $batchmove[] = Indent::_(3) . "}" . PHP_EOL; - - $batchmove[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Check the row."; - $batchmove[] = Indent::_(3) . "if (!\$this->table->check())"; - $batchmove[] = Indent::_(3) . "{"; - $batchmove[] = Indent::_(4) - . "\$this->setError(\$this->table->getError());"; - - $batchmove[] = PHP_EOL . Indent::_(4) . "return false;"; - $batchmove[] = Indent::_(3) . "}"; - - $batchmove[] = PHP_EOL . Indent::_(3) . "if (!empty(\$this->type))"; - $batchmove[] = Indent::_(3) . "{"; - $batchmove[] = Indent::_(4) - . "\$this->createTagsHelper(\$this->tagsObserver, \$this->type, \$pk, \$this->typeAlias, \$this->table);"; - $batchmove[] = Indent::_(3) . "}"; - - $batchmove[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Store the row."; - $batchmove[] = Indent::_(3) . "if (!\$this->table->store())"; - $batchmove[] = Indent::_(3) . "{"; - $batchmove[] = Indent::_(4) - . "\$this->setError(\$this->table->getError());"; - - $batchmove[] = PHP_EOL . Indent::_(4) . "return false;"; - $batchmove[] = Indent::_(3) . "}"; - $batchmove[] = Indent::_(2) . "}"; - - $batchmove[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Clean the cache"; - $batchmove[] = Indent::_(2) . "\$this->cleanCache();"; - - $batchmove[] = PHP_EOL . Indent::_(2) . "return true;"; - $batchmove[] = Indent::_(1) . "}"; - - return PHP_EOL . implode(PHP_EOL, $batchmove); - } - - public function setBatchCopy($nameSingleCode) - { - // set needed defaults - $title = false; - $titles = array(); - // only load alias if set in this view - $alias = CFactory::_('Compiler.Builder.Alias')->get($nameSingleCode); - $category = CFactory::_('Compiler.Builder.Category.Code')->getString("{$nameSingleCode}.code"); - $batchcopy = array(); - $VIEW = StringHelper::safe($nameSingleCode, 'U'); - // component helper name - $Helper = CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper'; - - // only load title if set in this view - if (($customAliasBuilder = CFactory::_('Compiler.Builder.Custom.Alias')->get($nameSingleCode)) !== null) - { - $titles = array_values( - $customAliasBuilder - ); - $title = true; - } - elseif (CFactory::_('Compiler.Builder.Title')->exists($nameSingleCode)) - { - $titles = [CFactory::_('Compiler.Builder.Title')->get($nameSingleCode)]; - $title = true; - } - // se the dynamic title - if ($title) - { - // reset the bucket - $titleData = array(); - // load the dynamic title builder - foreach ($titles as $_title) - { - $titleData[] = "\$this->table->" . $_title; - } - } - // prepare custom script - $customScript = CFactory::_('Customcode.Dispenser')->get( - 'php_batchcopy', $nameSingleCode, PHP_EOL . PHP_EOL, null, true - ); - - $batchcopy[] = PHP_EOL . Indent::_(1) . "/**"; - $batchcopy[] = Indent::_(1) - . " * Batch copy items to a new category or current."; - $batchcopy[] = Indent::_(1) . " *"; - $batchcopy[] = Indent::_(1) - . " * @param integer \$values The new values."; - $batchcopy[] = Indent::_(1) - . " * @param array \$pks An array of row IDs."; - $batchcopy[] = Indent::_(1) - . " * @param array \$contexts An array of item contexts."; - $batchcopy[] = Indent::_(1) . " *"; - $batchcopy[] = Indent::_(1) - . " * @return mixed An array of new IDs on success, boolean false on failure."; - $batchcopy[] = Indent::_(1) . " *"; - $batchcopy[] = Indent::_(1) . " * @since 12.2"; - $batchcopy[] = Indent::_(1) . " */"; - $batchcopy[] = Indent::_(1) - . "protected function batchCopy(\$values, \$pks, \$contexts)"; - $batchcopy[] = Indent::_(1) . "{"; - - $batchcopy[] = Indent::_(2) . "if (empty(\$this->batchSet))"; - $batchcopy[] = Indent::_(2) . "{"; - $batchcopy[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Set some needed variables."; - $batchcopy[] = Indent::_(3) - . "\$this->user = JFactory::getUser();"; - $batchcopy[] = Indent::_(3) - . "\$this->table = \$this->getTable();"; - $batchcopy[] = Indent::_(3) - . "\$this->tableClassName = get_class(\$this->table);"; - $batchcopy[] = Indent::_(3) . "\$this->canDo = " . $Helper - . "::getActions('" . $nameSingleCode . "');"; - $batchcopy[] = Indent::_(2) . "}"; - $batchcopy[] = PHP_EOL . Indent::_(2) . "if (!\$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.create') . "') && !\$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.batch') . "'))"; - $batchcopy[] = Indent::_(2) . "{"; - $batchcopy[] = Indent::_(3) . "return false;"; - $batchcopy[] = Indent::_(2) . "}" . $customScript; - - $batchcopy[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " get list of unique fields"; - $batchcopy[] = Indent::_(2) - . "\$uniqueFields = \$this->getUniqueFields();"; - $batchcopy[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " remove move_copy from array"; - $batchcopy[] = Indent::_(2) . "unset(\$values['move_copy']);"; - - $batchcopy[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " make sure published is set"; - $batchcopy[] = Indent::_(2) . "if (!isset(\$values['published']))"; - $batchcopy[] = Indent::_(2) . "{"; - $batchcopy[] = Indent::_(3) . "\$values['published'] = 0;"; - $batchcopy[] = Indent::_(2) . "}"; - $batchcopy[] = Indent::_(2) - . "elseif (isset(\$values['published']) && !\$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit.state') . "'))"; - $batchcopy[] = Indent::_(2) . "{"; - $batchcopy[] = Indent::_(4) . "\$values['published'] = 0;"; - $batchcopy[] = Indent::_(2) . "}"; - - if ($category) - { - $batchcopy[] = PHP_EOL . Indent::_(2) - . "if (isset(\$values['category']) && (int) \$values['category'] > 0 && !static::checkCategoryId(\$values['category']))"; - $batchcopy[] = Indent::_(2) . "{"; - $batchcopy[] = Indent::_(3) . "return false;"; - $batchcopy[] = Indent::_(2) . "}"; - $batchcopy[] = Indent::_(2) - . "elseif (isset(\$values['category']) && (int) \$values['category'] > 0)"; - $batchcopy[] = Indent::_(2) . "{"; - $batchcopy[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " move the category value to correct field name"; - $batchcopy[] = Indent::_(3) . "\$values['" . $category - . "'] = \$values['category'];"; - $batchcopy[] = Indent::_(3) . "unset(\$values['category']);"; - $batchcopy[] = Indent::_(2) . "}"; - $batchcopy[] = Indent::_(2) - . "elseif (isset(\$values['category']))"; - $batchcopy[] = Indent::_(2) . "{"; - $batchcopy[] = Indent::_(3) . "unset(\$values['category']);"; - $batchcopy[] = Indent::_(2) . "}"; - } - - $batchcopy[] = PHP_EOL . Indent::_(2) . "\$newIds = array();"; - - $batchcopy[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Parent exists so let's proceed"; - $batchcopy[] = Indent::_(2) . "while (!empty(\$pks))"; - $batchcopy[] = Indent::_(2) . "{"; - $batchcopy[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Pop the first ID off the stack"; - $batchcopy[] = Indent::_(3) . "\$pk = array_shift(\$pks);"; - - $batchcopy[] = PHP_EOL . Indent::_(3) . "\$this->table->reset();"; - - $batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " only allow copy if user may edit this item."; - $batchcopy[] = Indent::_(3) . "if (!\$this->user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit') . "', \$contexts[\$pk]))"; - $batchcopy[] = Indent::_(3) . "{"; - $batchcopy[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Not fatal error"; - $batchcopy[] = Indent::_(4) . "\$this->setError(JText:" - . ":sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', \$pk));"; - $batchcopy[] = Indent::_(4) . "continue;"; - $batchcopy[] = Indent::_(3) . "}"; - - $batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Check that the row actually exists"; - $batchcopy[] = Indent::_(3) . "if (!\$this->table->load(\$pk))"; - $batchcopy[] = Indent::_(3) . "{"; - $batchcopy[] = Indent::_(4) - . "if (\$error = \$this->table->getError())"; - $batchcopy[] = Indent::_(4) . "{"; - $batchcopy[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) - . " Fatal error"; - $batchcopy[] = Indent::_(5) . "\$this->setError(\$error);"; - - $batchcopy[] = Indent::_(5) . "return false;"; - $batchcopy[] = Indent::_(4) . "}"; - $batchcopy[] = Indent::_(4) . "else"; - $batchcopy[] = Indent::_(4) . "{"; - $batchcopy[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) - . " Not fatal error"; - $batchcopy[] = Indent::_(5) . "\$this->setError(JText:" - . ":sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', \$pk));"; - $batchcopy[] = Indent::_(5) . "continue;"; - $batchcopy[] = Indent::_(4) . "}"; - $batchcopy[] = Indent::_(3) . "}"; - if ($category && $alias === 'alias' - && ($title && count($titles) == 1 - && in_array('title', $titles))) - { - $batchcopy[] = PHP_EOL . Indent::_(3) . "if (isset(\$values['" - . $category . "']))"; - $batchcopy[] = Indent::_(3) . "{"; - $batchcopy[] = Indent::_(4) - . "static::generateTitle((int) \$values['" . $category - . "'], \$this->table);"; - $batchcopy[] = Indent::_(3) . "}"; - $batchcopy[] = Indent::_(3) . "else"; - $batchcopy[] = Indent::_(3) . "{"; - $batchcopy[] = Indent::_(4) - . "static::generateTitle((int) \$this->table->" . $category - . ", \$this->table);"; - $batchcopy[] = Indent::_(3) . "}"; - } - elseif ($category && $alias && ($title && count($titles) == 1)) - { - $batchcopy[] = PHP_EOL . Indent::_(3) . "if (isset(\$values['" - . $category . "']))"; - $batchcopy[] = Indent::_(3) . "{"; - $batchcopy[] = Indent::_(4) . "list(\$this->table->" . implode( - '', $titles - ) . ", \$this->table->" . $alias - . ") = \$this->generateNewTitle(\$values['" . $category - . "'], \$this->table->" . $alias . ", \$this->table->" - . implode('', $titles) . ");"; - $batchcopy[] = Indent::_(3) . "}"; - $batchcopy[] = Indent::_(3) . "else"; - $batchcopy[] = Indent::_(3) . "{"; - $batchcopy[] = Indent::_(4) . "list(\$this->table->" . implode( - '', $titles - ) . ", \$this->table->" . $alias - . ") = \$this->generateNewTitle(\$this->table->" . $category - . ", \$this->table->" . $alias . ", \$this->table->" . implode( - '', $titles - ) . ");"; - $batchcopy[] = Indent::_(3) . "}"; - } - elseif (!$category && $alias && ($title && count($titles) == 1)) - { - $batchcopy[] = Indent::_(3) . "list(\$this->table->" . implode( - '', $titles - ) . ", \$this->table->" . $alias - . ") = \$this->_generateNewTitle(\$this->table->" . $alias - . ", \$this->table->" . implode('', $titles) . ");"; - } - elseif (!$category && $alias && $title) - { - $batchcopy[] = Indent::_(3) . "list(" . implode(', ', $titleData) - . ", \$this->table->" . $alias - . ") = \$this->_generateNewTitle(\$this->table->" . $alias - . ", array(" . implode(', ', $titleData) . "));"; - } - elseif (!$category && !$alias - && ($title && count($titles) == 1 - && !in_array('user', $titles) - && !in_array( - 'jobnumber', $titles - ))) // TODO [jobnumber] just for one project (not ideal) - { - $batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Only for strings"; - $batchcopy[] = Indent::_(3) . "if (" . $Helper - . "::checkString(\$this->table->" . implode('', $titles) - . ") && !is_numeric(\$this->table->" . implode('', $titles) - . "))"; - $batchcopy[] = Indent::_(3) . "{"; - $batchcopy[] = Indent::_(4) . "\$this->table->" . implode( - '', $titles - ) . " = \$this->generateUnique('" . implode('', $titles) - . "',\$this->table->" . implode('', $titles) . ");"; - $batchcopy[] = Indent::_(3) . "}"; - } - - $batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " insert all set values"; - $batchcopy[] = Indent::_(3) . "if (" . $Helper - . "::checkArray(\$values))"; - $batchcopy[] = Indent::_(3) . "{"; - $batchcopy[] = Indent::_(4) . "foreach (\$values as \$key => \$value)"; - $batchcopy[] = Indent::_(4) . "{"; - $batchcopy[] = Indent::_(5) - . "if (strlen(\$value) > 0 && isset(\$this->table->\$key))"; - $batchcopy[] = Indent::_(5) . "{"; - $batchcopy[] = Indent::_(6) . "\$this->table->\$key = \$value;"; - $batchcopy[] = Indent::_(5) . "}"; - $batchcopy[] = Indent::_(4) . "}"; - $batchcopy[] = Indent::_(3) . "}" . PHP_EOL; - - $batchcopy[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " update all unique fields"; - $batchcopy[] = Indent::_(3) . "if (" . $Helper - . "::checkArray(\$uniqueFields))"; - $batchcopy[] = Indent::_(3) . "{"; - $batchcopy[] = Indent::_(4) - . "foreach (\$uniqueFields as \$uniqueField)"; - $batchcopy[] = Indent::_(4) . "{"; - $batchcopy[] = Indent::_(5) - . "\$this->table->\$uniqueField = \$this->generateUnique(\$uniqueField,\$this->table->\$uniqueField);"; - $batchcopy[] = Indent::_(4) . "}"; - $batchcopy[] = Indent::_(3) . "}"; - - $batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Reset the ID because we are making a copy"; - $batchcopy[] = Indent::_(3) . "\$this->table->id = 0;"; - - $batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " TODO: Deal with ordering?"; - $batchcopy[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " \$this->table->ordering = 1;"; - - $batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Check the row."; - $batchcopy[] = Indent::_(3) . "if (!\$this->table->check())"; - $batchcopy[] = Indent::_(3) . "{"; - $batchcopy[] = Indent::_(4) - . "\$this->setError(\$this->table->getError());"; - - $batchcopy[] = PHP_EOL . Indent::_(4) . "return false;"; - $batchcopy[] = Indent::_(3) . "}"; - - $batchcopy[] = PHP_EOL . Indent::_(3) . "if (!empty(\$this->type))"; - $batchcopy[] = Indent::_(3) . "{"; - $batchcopy[] = Indent::_(4) - . "\$this->createTagsHelper(\$this->tagsObserver, \$this->type, \$pk, \$this->typeAlias, \$this->table);"; - $batchcopy[] = Indent::_(3) . "}"; - - $batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Store the row."; - $batchcopy[] = Indent::_(3) . "if (!\$this->table->store())"; - $batchcopy[] = Indent::_(3) . "{"; - $batchcopy[] = Indent::_(4) - . "\$this->setError(\$this->table->getError());"; - - $batchcopy[] = PHP_EOL . Indent::_(4) . "return false;"; - $batchcopy[] = Indent::_(3) . "}"; - - $batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Get the new item ID"; - $batchcopy[] = Indent::_(3) . "\$newId = \$this->table->get('id');"; - - $batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Add the new ID to the array"; - $batchcopy[] = Indent::_(3) . "\$newIds[\$pk] = \$newId;"; - $batchcopy[] = Indent::_(2) . "}"; - - $batchcopy[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Clean the cache"; - $batchcopy[] = Indent::_(2) . "\$this->cleanCache();"; - - $batchcopy[] = PHP_EOL . Indent::_(2) . "return \$newIds;"; - $batchcopy[] = Indent::_(1) . "}"; - - return PHP_EOL . implode(PHP_EOL, $batchcopy); - } - - public function setAliasTitleFix($nameSingleCode) - { - $fixUnique = array(); - // only load this if these two items are set - if (CFactory::_('Compiler.Builder.Alias')->exists($nameSingleCode) - && (CFactory::_('Compiler.Builder.Title')->exists($nameSingleCode) - || CFactory::_('Compiler.Builder.Custom.Alias')->exists($nameSingleCode))) - { - // set needed defaults - $category = CFactory::_('Compiler.Builder.Category.Code')->getString("{$nameSingleCode}.code"); - $alias = CFactory::_('Compiler.Builder.Alias')->get($nameSingleCode); - $VIEW = StringHelper::safe( - $nameSingleCode, 'U' - ); - // set the title stuff - if (($customAliasBuilder = CFactory::_('Compiler.Builder.Custom.Alias')->get($nameSingleCode)) !== null) - { - $titles = array_values( - $customAliasBuilder - ); - } - else - { - $titles = [CFactory::_('Compiler.Builder.Title')->get($nameSingleCode)]; - } - // start building the fix - $fixUnique[] = PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Alter the " . implode(', ', $titles) - . " for save as copy"; - $fixUnique[] = Indent::_(2) - . "if (\$input->get('task') === 'save2copy')"; - $fixUnique[] = Indent::_(2) . "{"; - $fixUnique[] = Indent::_(3) - . "\$origTable = clone \$this->getTable();"; - $fixUnique[] = Indent::_(3) - . "\$origTable->load(\$input->getInt('id'));"; - // reset the buckets - $ifStatment = array(); - $titleVars = array(); - $titleData = array(); - $titleUpdate = array(); - // load the dynamic title builder - foreach ($titles as $title) - { - $ifStatment[] = "\$data['" . $title . "'] == \$origTable->" - . $title; - $titleVars[] = "\$" . $title; - $titleData[] = "\$data['" . $title . "']"; - $titleUpdate[] = Indent::_(4) . "\$data['" . $title . "'] = \$" - . $title . ";"; - } - $fixUnique[] = PHP_EOL . Indent::_(3) . "if (" . implode( - ' || ', $ifStatment - ) . ")"; - $fixUnique[] = Indent::_(3) . "{"; - if ($category !== null && count((array) $titles) == 1) - { - $fixUnique[] = Indent::_(4) . "list(" . implode('', $titleVars) - . ", \$" . $alias . ") = \$this->generateNewTitle(\$data['" - . $category . "'], \$data['" . $alias . "'], " . implode( - '', $titleData - ) . ");"; - } - elseif (count((array) $titles) == 1) - { - $fixUnique[] = Indent::_(4) . "list(" . implode( - ', ', $titleVars - ) - . ", \$" . $alias . ") = \$this->_generateNewTitle(\$data['" - . $alias . "'], " . implode('', $titleData) . ");"; - } - else - { - $fixUnique[] = Indent::_(4) . "list(" . implode( - ', ', $titleVars - ) - . ", \$" . $alias . ") = \$this->_generateNewTitle(\$data['" - . $alias . "'], array(" . implode(', ', $titleData) . "));"; - } - $fixUnique[] = implode("\n", $titleUpdate); - $fixUnique[] = Indent::_(4) . "\$data['" . $alias . "'] = \$" - . $alias . ";"; - $fixUnique[] = Indent::_(3) . "}"; - $fixUnique[] = Indent::_(3) . "else"; - $fixUnique[] = Indent::_(3) . "{"; - $fixUnique[] = Indent::_(4) . "if (\$data['" . $alias - . "'] == \$origTable->" . $alias . ")"; - $fixUnique[] = Indent::_(4) . "{"; - $fixUnique[] = Indent::_(5) . "\$data['" . $alias . "'] = '';"; - $fixUnique[] = Indent::_(4) . "}"; - $fixUnique[] = Indent::_(3) . "}"; - $fixUnique[] = PHP_EOL . Indent::_(3) . "\$data['published'] = 0;"; - $fixUnique[] = Indent::_(2) . "}"; - $fixUnique[] = PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Automatic handling of " . $alias . " for empty fields"; - $fixUnique[] = Indent::_(2) - . "if (in_array(\$input->get('task'), array('apply', 'save', 'save2new')) && (int) \$input->get('id') == 0)"; - $fixUnique[] = Indent::_(2) . "{"; - $fixUnique[] = Indent::_(3) . "if (\$data['" . $alias - . "'] == null || empty(\$data['" . $alias . "']))"; - $fixUnique[] = Indent::_(3) . "{"; - $fixUnique[] = Indent::_(4) - . "if (JFactory::getConfig()->get('unicodeslugs') == 1)"; - $fixUnique[] = Indent::_(4) . "{"; - $fixUnique[] = Indent::_(5) . "\$data['" . $alias - . "'] = JFilterOutput::stringURLUnicodeSlug(" . implode( - ' . " " . ', $titleData - ) . ");"; - $fixUnique[] = Indent::_(4) . "}"; - $fixUnique[] = Indent::_(4) . "else"; - $fixUnique[] = Indent::_(4) . "{"; - $fixUnique[] = Indent::_(5) . "\$data['" . $alias - . "'] = JFilterOutput::stringURLSafe(" . implode( - ' . " " . ', $titleData - ) . ");"; - $fixUnique[] = Indent::_(4) . "}"; - $fixUnique[] = PHP_EOL . Indent::_(4) - . "\$table = JTable::getInstance('" . $nameSingleCode . "', '" - . CFactory::_('Config')->component_code_name . "Table');"; - if ($category !== null && count($titles) == 1) - { - $fixUnique[] = PHP_EOL . Indent::_(4) - . "if (\$table->load(array('" . $alias . "' => \$data['" - . $alias . "'], '" . $category . "' => \$data['" . $category - . "'])) && (\$table->id != \$data['id'] || \$data['id'] == 0))"; - $fixUnique[] = Indent::_(4) . "{"; - $fixUnique[] = Indent::_(5) . "\$msg = JText:" . ":_('COM_" - . CFactory::_('Compiler.Builder.Content.One')->get('COMPONENT') . "_" . $VIEW . "_SAVE_WARNING');"; - $fixUnique[] = Indent::_(4) . "}"; - $fixUnique[] = PHP_EOL . Indent::_(4) . "list(" . implode( - '', $titleVars - ) . ", \$" . $alias - . ") = \$this->generateNewTitle(\$data['" . $category - . "'], \$data['" . $alias . "'], " . implode('', $titleData) - . ");"; - $fixUnique[] = Indent::_(4) . "\$data['" . $alias . "'] = \$" - . $alias . ";"; - } - else - { - $fixUnique[] = PHP_EOL . Indent::_(4) - . "if (\$table->load(array('" . $alias . "' => \$data['" - . $alias - . "'])) && (\$table->id != \$data['id'] || \$data['id'] == 0))"; - $fixUnique[] = Indent::_(4) . "{"; - $fixUnique[] = Indent::_(5) . "\$msg = JText:" . ":_('COM_" - . CFactory::_('Compiler.Builder.Content.One')->get('COMPONENT') . "_" . $VIEW . "_SAVE_WARNING');"; - $fixUnique[] = Indent::_(4) . "}"; - $fixUnique[] = PHP_EOL . Indent::_(4) . "\$data['" . $alias - . "'] = \$this->_generateNewTitle(\$data['" . $alias - . "']);"; - } - $fixUnique[] = PHP_EOL . Indent::_(4) . "if (isset(\$msg))"; - $fixUnique[] = Indent::_(4) . "{"; - $fixUnique[] = Indent::_(5) - . "JFactory::getApplication()->enqueueMessage(\$msg, 'warning');"; - $fixUnique[] = Indent::_(4) . "}"; - $fixUnique[] = Indent::_(3) . "}"; - $fixUnique[] = Indent::_(2) . "}"; - -// $fixUnique[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Update alias if still empty at this point"; -// $fixUnique[] = Indent::_(2) . "if (\$data['" . $alias . "'] == null || empty(\$data['" . $alias . "']))"; -// $fixUnique[] = Indent::_(2) . "{"; -// $fixUnique[] = Indent::_(3) . "if (JFactory::getConfig()->get('unicodeslugs') == 1)"; -// $fixUnique[] = Indent::_(3) . "{"; -// $fixUnique[] = Indent::_(4) . "\$data['" . $alias . "'] = JFilterOutput::stringURLUnicodeSlug(" . implode(' . " " . ', $titleData) . ");"; -// $fixUnique[] = Indent::_(3) . "}"; -// $fixUnique[] = Indent::_(3) . "else"; -// $fixUnique[] = Indent::_(3) . "{"; -// $fixUnique[] = Indent::_(4) . "\$data['" . $alias . "'] = JFilterOutput::stringURLSafe(" . implode(' . " " . ', $titleData) . ");"; -// $fixUnique[] = Indent::_(3) . "}"; -// $fixUnique[] = Indent::_(2) . "}"; - } - // handel other unique fields - $fixUnique[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Alter the unique field for save as copy"; - $fixUnique[] = Indent::_(2) - . "if (\$input->get('task') === 'save2copy')"; - $fixUnique[] = Indent::_(2) . "{"; - $fixUnique[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Automatic handling of other unique fields"; - $fixUnique[] = Indent::_(3) - . "\$uniqueFields = \$this->getUniqueFields();"; - $fixUnique[] = Indent::_(3) . "if (" - . CFactory::_('Compiler.Builder.Content.One')->get('Component') - . "Helper::checkArray(\$uniqueFields))"; - $fixUnique[] = Indent::_(3) . "{"; - $fixUnique[] = Indent::_(4) - . "foreach (\$uniqueFields as \$uniqueField)"; - $fixUnique[] = Indent::_(4) . "{"; - $fixUnique[] = Indent::_(5) - . "\$data[\$uniqueField] = \$this->generateUnique(\$uniqueField,\$data[\$uniqueField]);"; - $fixUnique[] = Indent::_(4) . "}"; - $fixUnique[] = Indent::_(3) . "}"; - $fixUnique[] = Indent::_(2) . "}"; - - return PHP_EOL . implode(PHP_EOL, $fixUnique); - } - - public function setGenerateNewTitle($nameSingleCode) - { - // if category is added to this view then do nothing - if (CFactory::_('Compiler.Builder.Alias')->exists($nameSingleCode) - && (CFactory::_('Compiler.Builder.Title')->exists($nameSingleCode) - || CFactory::_('Compiler.Builder.Custom.Alias')->exists($nameSingleCode))) - { - // get component name - $Component = CFactory::_('Compiler.Builder.Content.One')->get('Component'); - // rest the new function - $newFunction = array(); - $newFunction[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $newFunction[] = Indent::_(1) - . " * Method to change the title/s & alias."; - $newFunction[] = Indent::_(1) . " *"; - $newFunction[] = Indent::_(1) - . " * @param string \$alias The alias."; - $newFunction[] = Indent::_(1) - . " * @param string/array \$title The title."; - $newFunction[] = Indent::_(1) . " *"; - $newFunction[] = Indent::_(1) - . " * @return array/string Contains the modified title/s and/or alias."; - $newFunction[] = Indent::_(1) . " *"; - $newFunction[] = Indent::_(1) . " */"; - $newFunction[] = Indent::_(1) - . "protected function _generateNewTitle(\$alias, \$title = null)"; - $newFunction[] = Indent::_(1) . "{"; - $newFunction[] = PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Alter the title/s & alias"; - $newFunction[] = Indent::_(2) . "\$table = \$this->getTable();"; - $newFunction[] = PHP_EOL . Indent::_(2) - . "while (\$table->load(array('alias' => \$alias)))"; - $newFunction[] = Indent::_(2) . "{"; - $newFunction[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Check if this is an array of titles"; - $newFunction[] = Indent::_(3) . "if (" . $Component - . "Helper::checkArray(\$title))"; - $newFunction[] = Indent::_(3) . "{"; - $newFunction[] = Indent::_(4) - . "foreach(\$title as \$nr => &\$_title)"; - $newFunction[] = Indent::_(4) . "{"; - $newFunction[] = Indent::_(5) - . "\$_title = StringHelper::increment(\$_title);"; - $newFunction[] = Indent::_(4) . "}"; - $newFunction[] = Indent::_(3) . "}"; - $newFunction[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Make sure we have a title"; - $newFunction[] = Indent::_(3) . "elseif (\$title)"; - $newFunction[] = Indent::_(3) . "{"; - $newFunction[] = Indent::_(4) - . "\$title = StringHelper::increment(\$title);"; - $newFunction[] = Indent::_(3) . "}"; - $newFunction[] = Indent::_(3) - . "\$alias = StringHelper::increment(\$alias, 'dash');"; - $newFunction[] = Indent::_(2) . "}"; - $newFunction[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Check if this is an array of titles"; - $newFunction[] = Indent::_(2) . "if (" . $Component - . "Helper::checkArray(\$title))"; - $newFunction[] = Indent::_(2) . "{"; - $newFunction[] = Indent::_(3) . "\$title[] = \$alias;"; - $newFunction[] = Indent::_(3) . "return \$title;"; - $newFunction[] = Indent::_(2) . "}"; - $newFunction[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Make sure we have a title"; - $newFunction[] = Indent::_(2) . "elseif (\$title)"; - $newFunction[] = Indent::_(2) . "{"; - $newFunction[] = Indent::_(3) . "return array(\$title, \$alias);"; - $newFunction[] = Indent::_(2) . "}"; - $newFunction[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " We only had an alias"; - $newFunction[] = Indent::_(2) . "return \$alias;"; - $newFunction[] = Indent::_(1) . "}"; - - return implode(PHP_EOL, $newFunction); - } - elseif (CFactory::_('Compiler.Builder.Title')->exists($nameSingleCode)) - { - $newFunction = array(); - $newFunction[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $newFunction[] = Indent::_(1) . " * Method to change the title"; - $newFunction[] = Indent::_(1) . " *"; - $newFunction[] = Indent::_(1) - . " * @param string \$title The title."; - $newFunction[] = Indent::_(1) . " *"; - $newFunction[] = Indent::_(1) - . " * @return array Contains the modified title and alias."; - $newFunction[] = Indent::_(1) . " *"; - $newFunction[] = Indent::_(1) . " */"; - $newFunction[] = Indent::_(1) - . "protected function _generateNewTitle(\$title)"; - $newFunction[] = Indent::_(1) . "{"; - $newFunction[] = PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Alter the title"; - $newFunction[] = Indent::_(2) . "\$table = \$this->getTable();"; - $newFunction[] = PHP_EOL . Indent::_(2) - . "while (\$table->load(array('title' => \$title)))"; - $newFunction[] = Indent::_(2) . "{"; - $newFunction[] = Indent::_(3) - . "\$title = StringHelper::increment(\$title);"; - $newFunction[] = Indent::_(2) . "}"; - $newFunction[] = PHP_EOL . Indent::_(2) . "return \$title;"; - $newFunction[] = Indent::_(1) . "}"; - - return implode(PHP_EOL, $newFunction); - } - - return ''; - } - - public function setGenerateNewAlias($nameSingleCode) - { - // make sure this view has an alias - if (CFactory::_('Compiler.Builder.Alias')->exists($nameSingleCode)) - { - // set the title stuff - if (($customAliasBuilder = CFactory::_('Compiler.Builder.Custom.Alias')->get($nameSingleCode)) !== null) - { - $titles = array_values( - $customAliasBuilder - ); - } - elseif (CFactory::_('Compiler.Builder.Title')->exists($nameSingleCode)) - { - $titles = [CFactory::_('Compiler.Builder.Title')->get($nameSingleCode)]; - } - // reset the bucket - $titleData = array(); - // load the dynamic title builder - if (isset($titles) && ArrayHelper::check($titles)) - { - foreach ($titles as $title) - { - $titleData[] = "\$this->" . $title; - } - } - else - { - $titleData - = array("'-'"); // just encase some mad man does not set a title/customAlias (we fall back on the date) - } - // rest the new function - $newFunction = array(); - $newFunction[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $newFunction[] = Indent::_(1) - . " * Generate a valid alias from title / date."; - $newFunction[] = Indent::_(1) - . " * Remains public to be able to check for duplicated alias before saving"; - $newFunction[] = Indent::_(1) . " *"; - $newFunction[] = Indent::_(1) . " * @return string"; - $newFunction[] = Indent::_(1) . " */"; - $newFunction[] = Indent::_(1) . "public function generateAlias()"; - $newFunction[] = Indent::_(1) . "{"; - $newFunction[] = Indent::_(2) . "if (empty(\$this->alias))"; - $newFunction[] = Indent::_(2) . "{"; - $newFunction[] = Indent::_(3) . "\$this->alias = " . implode( - ".' '.", $titleData - ) . ';'; - $newFunction[] = Indent::_(2) . "}"; - $newFunction[] = PHP_EOL . Indent::_(2) - . "\$this->alias = JApplicationHelper::stringURLSafe(\$this->alias);"; - $newFunction[] = PHP_EOL . Indent::_(2) - . "if (trim(str_replace('-', '', \$this->alias)) == '')"; - $newFunction[] = Indent::_(2) . "{"; - $newFunction[] = Indent::_(3) - . "\$this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');"; - $newFunction[] = Indent::_(2) . "}"; - $newFunction[] = PHP_EOL . Indent::_(2) . "return \$this->alias;"; - $newFunction[] = Indent::_(1) . "}"; - - return implode(PHP_EOL, $newFunction); - } - // rest the new function - $newFunction = array(); - $newFunction[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $newFunction[] = Indent::_(1) - . " * This view does not actually have an alias"; - $newFunction[] = Indent::_(1) . " *"; - $newFunction[] = Indent::_(1) . " * @return bool"; - $newFunction[] = Indent::_(1) . " */"; - $newFunction[] = Indent::_(1) . "public function generateAlias()"; - $newFunction[] = Indent::_(1) . "{"; - $newFunction[] = Indent::_(2) . "return false;"; - $newFunction[] = Indent::_(1) . "}"; - - return implode(PHP_EOL, $newFunction); - } - - public function setInstall() - { - if (($database_tables = CFactory::_('Compiler.Builder.Database.Tables')->allActive()) !== []) - { - // set the main db prefix - $component = CFactory::_('Config')->component_code_name; - // start building the db - $db = ''; - foreach ($database_tables as $view => $fields) - { - // cast the object to an array TODO we must update all to use the object - $fields = (array) $fields; - // build the uninstallation array - $this->uninstallBuilder[] = "DROP TABLE IF EXISTS `#__" - . $component . "_" . $view . "`;"; - - // setup the table DB string - $db_ = ''; - $db_ .= "CREATE TABLE IF NOT EXISTS `#__" . $component . "_" - . $view . "` ("; - // check if the table name has changed - if (($old_table_name = CFactory::_('Registry')-> - get('builder.update_sql.table_name.' . $view . '.old', null)) !== null) - { - $key_ = "RENAMETABLE`#__" . $component . "_" . $old_table_name . "`"; - $value_ = "RENAME TABLE `#__" . $component . "_" . $old_table_name . "` to `#__" - . $component . "_" . $view . "`;"; - - CFactory::_('Compiler.Builder.Update.Mysql')->set($key_, $value_); - } - // check if default field was over written - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.id')) - { - $db_ .= PHP_EOL . Indent::_(1) - . "`id` INT(11) NOT NULL AUTO_INCREMENT,"; - } - $db_ .= PHP_EOL . Indent::_(1) - . "`asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.',"; - ksort($fields); - $last_name = 'asset_id'; - foreach ($fields as $field => $data) - { - // cast the object to an array TODO we must update all to use the object - $data = (array) $data; - // set default - $default = $data['default']; - if ($default === 'Other') - { - $default = $data['other']; - } - // to get just null value add EMPTY to other value. - if ($default === 'EMPTY') - { - $default = $data['null_switch']; - } - elseif ($default === 'DATETIME' - || $default === 'CURRENT_TIMESTAMP') - { - $default = $data['null_switch'] . ' DEFAULT ' - . $default; - } - elseif (is_numeric($default)) - { - $default = $data['null_switch'] . " DEFAULT " - . $default; - } - else - { - $default = $data['null_switch'] . " DEFAULT '" - . $default . "'"; - } - - // set the length (lenght) <-- TYPO :: LVDM :: DON'T TOUCH - $length = ''; - if (isset($data['lenght']) && $data['lenght'] === 'Other' - && isset($data['lenght_other']) - && $data['lenght_other'] > 0) - { - $length = '(' . $data['lenght_other'] . ')'; - } - elseif (isset($data['lenght']) && $data['lenght'] > 0) - { - $length = '(' . $data['lenght'] . ')'; - } - // set the field to db - $db_ .= PHP_EOL . Indent::_(1) . "`" . $field . "` " - . $data['type'] . $length . " " . $default . ","; - // check if this a new field that should be added via SQL update - if (CFactory::_('Registry')-> - get('builder.add_sql.field.' . $view . '.' . $data['ID'], null)) - { - // to soon.... - // $key_ = "ALTERTABLE`#__" . $component . "_" . $view . "`ADDCOLUMNIFNOTEXISTS`" . $field . "`"; - // $value_ = "ALTER TABLE `#__" . $component . "_" . $view . "` ADD COLUMN IF NOT EXISTS `" . $field . "` " . $data['type'] - // . length . " " . $default . " AFTER `" . $last_name . "`;"; - $key_ = "ALTERTABLE`#__" . $component . "_" . $view . "`ADD`" . $field . "`"; - $value_ = "ALTER TABLE `#__" . $component . "_" . $view . "` ADD `" . $field . "` " . $data['type'] - . $length . " " . $default . " AFTER `" . $last_name . "`;"; - - CFactory::_('Compiler.Builder.Update.Mysql')->set($key_, $value_); - } - // check if the field has changed name and/or data type and lenght - elseif (CFactory::_('Registry')-> - get('builder.update_sql.field.datatype.' . $view . '.' . $field, null) - || CFactory::_('Registry')-> - get('builder.update_sql.field.lenght.' . $view . '.' . $field, null) - || CFactory::_('Registry')-> - get('builder.update_sql.field.name.' . $view . '.' . $field, null)) - { - // if the name changed - if (($oldName = CFactory::_('Registry')-> - get('builder.update_sql.field.name.' . $view . '.' . $field . '.old', null)) === null) - { - $oldName = $field; - } - - // now set the update SQL - $key_ = "ALTERTABLE`#__" . $component . "_" . $view . "`CHANGE`" . $oldName . "``" - . $field . "`"; - $value_ = "ALTER TABLE `#__" . $component . "_" . $view . "` CHANGE `" . $oldName . "` `" - . $field . "` " . $data['type'] . $length . " " . $default . ";"; - - CFactory::_('Compiler.Builder.Update.Mysql')->set($key_, $value_); - } - // be sure to track the last name used :) - $last_name = $field; - } - // check if default field was overwritten - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.params')) - { - $db_ .= PHP_EOL . Indent::_(1) . "`params` text NULL,"; - } - // check if default field was overwritten - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.published')) - { - $db_ .= PHP_EOL . Indent::_(1) - . "`published` TINYINT(3) NOT NULL DEFAULT 1,"; - } - // check if default field was overwritten - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.created_by')) - { - $db_ .= PHP_EOL . Indent::_(1) - . "`created_by` INT(10) unsigned NOT NULL DEFAULT 0,"; - } - // check if default field was overwritten - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.modified_by')) - { - $db_ .= PHP_EOL . Indent::_(1) - . "`modified_by` INT(10) unsigned NOT NULL DEFAULT 0,"; - } - // check if default field was overwritten - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.created')) - { - $db_ .= PHP_EOL . Indent::_(1) - . "`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',"; - } - // check if default field was overwritten - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.modified')) - { - $db_ .= PHP_EOL . Indent::_(1) - . "`modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',"; - } - // check if default field was overwritten - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.checked_out')) - { - $db_ .= PHP_EOL . Indent::_(1) - . "`checked_out` int(11) unsigned NOT NULL DEFAULT 0,"; - } - // check if default field was overwritten - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.checked_out_time')) - { - $db_ .= PHP_EOL . Indent::_(1) - . "`checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',"; - } - // check if default field was overwritten - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.version')) - { - $db_ .= PHP_EOL . Indent::_(1) - . "`version` INT(10) unsigned NOT NULL DEFAULT 1,"; - } - // check if default field was overwritten - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.hits')) - { - $db_ .= PHP_EOL . Indent::_(1) - . "`hits` INT(10) unsigned NOT NULL DEFAULT 0,"; - } - // check if view has access - if (CFactory::_('Compiler.Builder.Access.Switch')->exists($view) - && !CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.access')) - { - $db_ .= PHP_EOL . Indent::_(1) - . "`access` INT(10) unsigned NOT NULL DEFAULT 0,"; - } - // check if default field was overwritten - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.ordering')) - { - $db_ .= PHP_EOL . Indent::_(1) - . "`ordering` INT(11) NOT NULL DEFAULT 0,"; - } - // check if metadata is added to this view - if (CFactory::_('Compiler.Builder.Meta.Data')->isString($view)) - { - // check if default field was overwritten - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.metakey')) - { - $db_ .= PHP_EOL . Indent::_(1) - . "`metakey` TEXT NOT NULL,"; - } - // check if default field was overwritten - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.metadesc')) - { - $db_ .= PHP_EOL . Indent::_(1) - . "`metadesc` TEXT NOT NULL,"; - } - // check if default field was overwritten - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.metadata')) - { - $db_ .= PHP_EOL . Indent::_(1) - . "`metadata` TEXT NOT NULL,"; - } - } - // TODO (we may want this to be dynamicly set) - $db_ .= PHP_EOL . Indent::_(1) . "PRIMARY KEY (`id`)"; - // check if a key was set for any of the default fields then we should not set it again - $check_keys_set = array(); - if (CFactory::_('Compiler.Builder.Database.Unique.Keys')->exists($view)) - { - foreach (CFactory::_('Compiler.Builder.Database.Unique.Keys')->get($view) as $nr => $key) - { - $db_ .= "," . PHP_EOL . Indent::_(1) - . "UNIQUE KEY `idx_" . $key . "` (`" . $key . "`)"; - $check_keys_set[$key] = $key; - } - } - if (CFactory::_('Compiler.Builder.Database.Keys')->exists($view)) - { - foreach (CFactory::_('Compiler.Builder.Database.Keys')->get($view) as $nr => $key) - { - $db_ .= "," . PHP_EOL . Indent::_(1) - . "KEY `idx_" . $key . "` (`" . $key . "`)"; - $check_keys_set[$key] = $key; - } - } - // check if view has access - if (!isset($check_keys_set['access']) - && CFactory::_('Compiler.Builder.Access.Switch')->exists($view)) - { - $db_ .= "," . PHP_EOL . Indent::_(1) - . "KEY `idx_access` (`access`)"; - } - // check if default field was overwritten - if (!isset($check_keys_set['checked_out'])) - { - $db_ .= "," . PHP_EOL . Indent::_(1) - . "KEY `idx_checkout` (`checked_out`)"; - } - // check if default field was overwritten - if (!isset($check_keys_set['created_by'])) - { - $db_ .= "," . PHP_EOL . Indent::_(1) - . "KEY `idx_createdby` (`created_by`)"; - } - // check if default field was overwritten - if (!isset($check_keys_set['modified_by'])) - { - $db_ .= "," . PHP_EOL . Indent::_(1) - . "KEY `idx_modifiedby` (`modified_by`)"; - } - // check if default field was overwritten - if (!isset($check_keys_set['published'])) - { - $db_ .= "," . PHP_EOL . Indent::_(1) - . "KEY `idx_state` (`published`)"; - } - // easy bucket - $easy = array(); - // get the mysql table settings - foreach ( - CFactory::_('Config')->mysql_table_keys as $_mysqlTableKey => $_mysqlTableVal - ) - { - if (($easy[$_mysqlTableKey] = CFactory::_('Compiler.Builder.Mysql.Table.Setting')-> - get($view . '.' . $_mysqlTableKey)) === null) - { - $easy[$_mysqlTableKey] - = CFactory::_('Config')->mysql_table_keys[$_mysqlTableKey]['default']; - } - } - // add a little fix for the row_format - if (StringHelper::check($easy['row_format'])) - { - $easy['row_format'] = ' ROW_FORMAT=' . $easy['row_format']; - } - // now build db string - $db_ .= PHP_EOL . ") ENGINE=" . $easy['engine'] - . " AUTO_INCREMENT=0 DEFAULT CHARSET=" . $easy['charset'] - . " DEFAULT COLLATE=" . $easy['collate'] - . $easy['row_format'] . ";"; - - // check if this is a new table that should be added via update SQL - if (CFactory::_('Registry')-> - get('builder.add_sql.adminview.' . $view, null)) - { - // build the update array - $key_ = "CREATETABLEIFNOTEXISTS`#__" . $component . "_" . $view . "`"; - CFactory::_('Compiler.Builder.Update.Mysql')->set($key_, $db_); - } - // check if the table row_format has changed - if (StringHelper::check($easy['row_format']) - && CFactory::_('Registry')-> - get('builder.update_sql.table_row_format.' . $view, null)) - { - // build the update array - $key_ = "ALTERTABLE`#__" . $component . "_" . $view . "`" . trim((string) $easy['row_format']); - $value_ = "ALTER TABLE `#__" . $component . "_" . $view . "`" . $easy['row_format'] . ";"; - CFactory::_('Compiler.Builder.Update.Mysql')->set($key_, $value_); - } - // check if the table engine has changed - if (CFactory::_('Registry')-> - get('builder.update_sql.table_engine.' . $view, null)) - { - // build the update array - $key_ = "ALTERTABLE`#__" . $component . "_" . $view . "`ENGINE=" . $easy['engine']; - $value_ = "ALTER TABLE `#__" . $component . "_" . $view . "` ENGINE = " . $easy['engine'] . ";"; - CFactory::_('Compiler.Builder.Update.Mysql')->set($key_, $value_); - } - // check if the table charset OR collation has changed (must be updated together) - if (CFactory::_('Registry')-> - get('builder.update_sql.table_charset.' . $view, null) - || CFactory::_('Registry')-> - get('builder.update_sql.table_collate.' . $view, null)) - { - // build the update array - $key_ = "ALTERTABLE`#__" . $component . "_" . $view . "CONVERTTOCHARACTERSET" - . $easy['charset'] . "COLLATE" . $easy['collate']; - $value_ = "ALTER TABLE `#__" . $component . "_" . $view . "` CONVERT TO CHARACTER SET " - . $easy['charset'] . " COLLATE " . $easy['collate'] . ";"; - - CFactory::_('Compiler.Builder.Update.Mysql')->set($key_, $value_); - } - - // add to main DB string - $db .= $db_ . PHP_EOL . PHP_EOL; - } - // add custom sql dump to the file - if (isset(CFactory::_('Customcode.Dispenser')->hub['sql']) - && ArrayHelper::check( - CFactory::_('Customcode.Dispenser')->hub['sql'] - )) - { - foreach ( - CFactory::_('Customcode.Dispenser')->hub['sql'] as $for => $customSql - ) - { - $placeholders = array(Placefix::_('component') => $component, - Placefix::_('view') => $for); - $db .= CFactory::_('Placeholder')->update( - $customSql, $placeholders - ) . PHP_EOL . PHP_EOL; - } - unset(CFactory::_('Customcode.Dispenser')->hub['sql']); - } - - // WHY DO WE NEED AN ASSET TABLE FIX? - // https://www.mysqltutorial.org/mysql-varchar/ - // https://stackoverflow.com/a/15227917/1429677 - // https://forums.mysql.com/read.php?24,105964,105964 - // https://github.com/vdm-io/Joomla-Component-Builder/issues/616#issuecomment-741502980 - // 30 actions each +-20 characters with 8 groups - // that makes 4800 characters and the current Joomla - // column size is varchar(5120) - - // just a little event tracking in classes - // count actions = setAccessSections - // around line206 (infusion call) - // around line26454 (interpretation function) - // first fix = setInstall - // around line1600 (infusion call) - // around line10063 (interpretation function) - // second fix = setUninstallScript - // around line2161 (infusion call) - // around line8030 (interpretation function) - - // check if this component needs larger rules - // also check if the developer will allow this - // the access actions length must be checked before this - // only add this option if set to SQL fix - if (CFactory::_('Config')->add_assets_table_fix == 1) - { - // 400 actions worse case is larger the 65535 characters - if (CFactory::_('Utilities.Counter')->accessSize > 400) - { - $db .= PHP_EOL; - $db .= PHP_EOL . '--'; - $db .= PHP_EOL - . '--' . Line::_( - __LINE__,__CLASS__ - ) - . ' Always insure this column rules is large enough for all the access control values.'; - $db .= PHP_EOL . '--'; - $db .= PHP_EOL - . "ALTER TABLE `#__assets` CHANGE `rules` `rules` MEDIUMTEXT NOT NULL COMMENT 'JSON encoded access control. Enlarged to MEDIUMTEXT by JCB';"; - } - // smaller then 400 makes TEXT large enough - elseif (CFactory::_('Config')->add_assets_table_fix == 1) - { - $db .= PHP_EOL; - $db .= PHP_EOL . '--'; - $db .= PHP_EOL - . '--' . Line::_( - __LINE__,__CLASS__ - ) - . ' Always insure this column rules is large enough for all the access control values.'; - $db .= PHP_EOL . '--'; - $db .= PHP_EOL - . "ALTER TABLE `#__assets` CHANGE `rules` `rules` TEXT NOT NULL COMMENT 'JSON encoded access control. Enlarged to TEXT by JCB';"; - } - } - - // check if this component needs larger names - // also check if the developer will allow this - // the config length must be checked before this - // only add this option if set to SQL fix - if (CFactory::_('Config')->add_assets_table_fix && CFactory::_('Config')->add_assets_table_name_fix) - { - $db .= PHP_EOL; - $db .= PHP_EOL . '--'; - $db .= PHP_EOL - . '--' . Line::_( - __LINE__,__CLASS__ - ) - . ' Always insure this column name is large enough for long component and view names.'; - $db .= PHP_EOL . '--'; - $db .= PHP_EOL - . "ALTER TABLE `#__assets` CHANGE `name` `name` VARCHAR(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'The unique name for the asset.';"; - } - - return $db; - } - - return ''; - } - - public function setUninstall() - { - $db = ''; - if (CFactory::_('Compiler.Builder.Database.Tables')->isActive()) - { - foreach ($this->uninstallBuilder as $line) - { - $db .= $line . PHP_EOL; - } - } - // add custom sql uninstall dump to the file - if (isset(CFactory::_('Customcode.Dispenser')->hub['sql_uninstall']) - && StringHelper::check( - CFactory::_('Customcode.Dispenser')->hub['sql_uninstall'] - )) - { - $db .= CFactory::_('Placeholder')->update_( - CFactory::_('Customcode.Dispenser')->hub['sql_uninstall'] - ) . PHP_EOL; - unset(CFactory::_('Customcode.Dispenser')->hub['sql_uninstall']); - } - - // check if this component used larger rules - // now revert them back on uninstall - // only add this option if set to SQL fix - if (CFactory::_('Config')->add_assets_table_fix == 1) - { - // https://github.com/joomla/joomla-cms/blob/3.10.0-alpha3/installation/sql/mysql/joomla.sql#L22 - // Checked 1st December 2020 (let us know if this changes) - $db .= PHP_EOL; - $db .= PHP_EOL . '--'; - $db .= PHP_EOL - . '--' . Line::_( - __LINE__,__CLASS__ - ) - . ' Always insure this column rules is reversed to Joomla defaults on uninstall. (as on 1st Dec 2020)'; - $db .= PHP_EOL . '--'; - $db .= PHP_EOL - . "ALTER TABLE `#__assets` CHANGE `rules` `rules` varchar(5120) NOT NULL COMMENT 'JSON encoded access control.';"; - } - - // check if this component used larger names - // now revert them back on uninstall - // only add this option if set to SQL fix - if (CFactory::_('Config')->add_assets_table_fix == 1 && CFactory::_('Config')->add_assets_table_name_fix) - { - // https://github.com/joomla/joomla-cms/blob/3.10.0-alpha3/installation/sql/mysql/joomla.sql#L20 - // Checked 1st December 2020 (let us know if this changes) - $db .= PHP_EOL; - $db .= PHP_EOL . '--'; - $db .= PHP_EOL - . '--' . Line::_( - __LINE__,__CLASS__ - ) - . ' Always insure this column name is reversed to Joomla defaults on uninstall. (as on 1st Dec 2020).'; - $db .= PHP_EOL . '--'; - $db .= PHP_EOL - . "ALTER TABLE `#__assets` CHANGE `name` `name` VARCHAR(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'The unique name for the asset.';"; - } - - return $db; - } - - public function setLangAdmin() - { - // add final list of needed lang strings - $componentName = CFactory::_('Component')->get('name'); - $componentName = JFilterOutput::cleanText($componentName); - // for plugin event TODO change event api signatures - $langContent = CFactory::_('Language')->getTarget('admin'); - $component_context = CFactory::_('Config')->component_context; - // Trigger Event: jcb_ce_onBeforeBuildAdminLang - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeBuildAdminLang', - array(&$component_context, &$langContent, - &$this->langPrefix, &$componentName) - ); - // for plugin event TODO change event api signatures - CFactory::_('Config')->lang_prefix = $this->langPrefix; - CFactory::_('Language')->setTarget('admin', $langContent); - // start loding the defaults - CFactory::_('Language')->set('adminsys', CFactory::_('Config')->lang_prefix, $componentName); - CFactory::_('Language')->set( - 'adminsys', CFactory::_('Config')->lang_prefix . '_CONFIGURATION', - $componentName . ' Configuration' - ); - CFactory::_('Language')->set('admin', CFactory::_('Config')->lang_prefix, $componentName); - CFactory::_('Language')->set('admin', CFactory::_('Config')->lang_prefix . '_BACK', 'Back'); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_DASH', 'Dashboard' - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_VERSION', 'Version' - ); - CFactory::_('Language')->set('admin', CFactory::_('Config')->lang_prefix . '_DATE', 'Date'); - CFactory::_('Language')->set('admin', CFactory::_('Config')->lang_prefix . '_AUTHOR', 'Author'); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_WEBSITE', 'Website' - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_LICENSE', 'License' - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_CONTRIBUTORS', 'Contributors' - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_CONTRIBUTOR', 'Contributor' - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_DASHBOARD', - $componentName . ' Dashboard' - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_SAVE_SUCCESS', - "Great! Item successfully saved." - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_SAVE_WARNING', - "The value already existed so please select another." - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_HELP_MANAGER', "Help" - ); - CFactory::_('Language')->set('admin', CFactory::_('Config')->lang_prefix . '_NEW', "New"); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_CLOSE_NEW', "Close & New" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_CREATE_NEW_S', "Create New %s" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_EDIT_S', "Edit %s" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_KEEP_ORIGINAL_STATE', - "- Keep Original State -" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_KEEP_ORIGINAL_ACCESS', - "- Keep Original Access -" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_KEEP_ORIGINAL_CATEGORY', - "- Keep Original Category -" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_PUBLISHED', 'Published' - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_INACTIVE', 'Inactive' - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_ARCHIVED', 'Archived' - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_TRASHED', 'Trashed' - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_NO_ACCESS_GRANTED', - "No Access Granted!" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_NOT_FOUND_OR_ACCESS_DENIED', - "Not found or access denied!" - ); - if (CFactory::_('Component')->get('add_license') - && CFactory::_('Component')->get('license_type') == 3) - { - CFactory::_('Language')->set( - 'admin', 'NIE_REG_NIE', - "

    License not set for " . $componentName - . ".

    Notify your administrator!
    The license can be obtained from get('whmcs_buy_link') . "' target='_blank'>" - . CFactory::_('Component')->get('companyname') . ".

    " - ); - } - // add the langug files needed to import and export data - if (CFactory::_('Config')->get('add_eximport', false)) - { - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_EXPORT_FAILED', "Export Failed" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_FAILED', "Import Failed" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_TITLE', "Data Importer" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_NO_IMPORT_TYPE_FOUND', - "Import type not found." - ); - CFactory::_('Language')->set( - 'admin', - CFactory::_('Config')->lang_prefix . '_IMPORT_UNABLE_TO_FIND_IMPORT_PACKAGE', - "Package to import not found." - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_ERROR', "Import error." - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_SUCCESS', - "Great! Import successful." - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_MSG_WARNIMPORTFILE', - "Warning, import file error." - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_MSG_NO_FILE_SELECTED', - "No import file selected." - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_MSG_PLEASE_SELECT_A_FILE', - "Please select a file to import." - ); - CFactory::_('Language')->set( - 'admin', - CFactory::_('Config')->lang_prefix . '_IMPORT_MSG_PLEASE_SELECT_ALL_COLUMNS', - "Please link all columns." - ); - CFactory::_('Language')->set( - 'admin', - CFactory::_('Config')->lang_prefix . '_IMPORT_MSG_PLEASE_SELECT_A_DIRECTORY', - "Please enter the file directory." - ); - CFactory::_('Language')->set( - 'admin', - CFactory::_('Config')->lang_prefix . '_IMPORT_MSG_WARNIMPORTUPLOADERROR', - "Warning, import upload error." - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix - . '_IMPORT_MSG_PLEASE_ENTER_A_PACKAGE_DIRECTORY', - "Please enter the file directory." - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix - . '_IMPORT_MSG_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE', - "Path does not have a valid file." - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix - . '_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE', - "Does not have a valid file type." - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_MSG_ENTER_A_URL', - "Please enter a url." - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_MSG_INVALID_URL', - "Invalid url." - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_CONTINUE', "Continue" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_FROM_UPLOAD', "Upload" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_SELECT_FILE', - "Select File" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_UPLOAD_BOTTON', - "Upload File" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_FROM_DIRECTORY', - "Directory" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_SELECT_FILE_DIRECTORY', - "Set the path to file" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_GET_BOTTON', "Get File" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_FROM_URL', "URL" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_SELECT_FILE_URL', - "Enter file URL" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_UPDATE_DATA', - "Import Data" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_FORMATS_ACCEPTED', - "formats accepted" - ); - CFactory::_('Language')->set( - 'admin', - CFactory::_('Config')->lang_prefix . '_IMPORT_LINK_FILE_TO_TABLE_COLUMNS', - "Link File to Table Columns" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_TABLE_COLUMNS', - "Table Columns" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_FILE_COLUMNS', - "File Columns" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_PLEASE_SELECT_COLUMN', - "-- Please Select Column --" - ); - CFactory::_('Language')->set( - 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_IGNORE_COLUMN', - "-- Ignore This Column --" - ); - } - // check if the both array is set - if (CFactory::_('Language')->exist('both')) - { - foreach (CFactory::_('Language')->getTarget('both') as $keylang => $langval) - { - CFactory::_('Language')->set('admin', $keylang, $langval); - } - } - // check if the both admin array is set - if (CFactory::_('Language')->exist('bothadmin')) - { - foreach (CFactory::_('Language')->getTarget('bothadmin') as $keylang => $langval) - { - CFactory::_('Language')->set('admin', $keylang, $langval); - } - } - if (CFactory::_('Language')->exist('admin')) - { - // for plugin event TODO change event api signatures - $langContent = CFactory::_('Language')->getTarget('admin'); - // Trigger Event: jcb_ce_onAfterBuildAdminLang - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterBuildAdminLang', - array(&$component_context, &$langContent, - &$this->langPrefix, &$componentName) - ); - // for plugin event TODO change event api signatures - CFactory::_('Config')->lang_prefix = $this->langPrefix; - // sort the strings - ksort($langContent); - // load to global languages - $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['admin'] - = $langContent; - // remove tmp array - CFactory::_('Language')->setTarget('admin', null); - - return true; - } - - return false; - } - - public function setLangSite() - { - // add final list of needed lang strings - $componentName = CFactory::_('Component')->get('name'); - $componentName = JFilterOutput::cleanText($componentName); - // for plugin event TODO change event api signatures - $langContent = CFactory::_('Language')->getTarget('site'); - $component_context = CFactory::_('Config')->component_context; - // Trigger Event: jcb_ce_onBeforeBuildSiteLang - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeBuildSiteLang', - array(&$component_context, &$langContent, - &$this->langPrefix, &$componentName) - ); - // for plugin event TODO change event api signatures - CFactory::_('Config')->lang_prefix = $this->langPrefix; - CFactory::_('Language')->setTarget('site', $langContent); - // add final list of needed lang strings - CFactory::_('Language')->set('site', CFactory::_('Config')->lang_prefix, $componentName); - // some more defaults - CFactory::_('Language')->set('site', 'JTOOLBAR_APPLY', "Save"); - CFactory::_('Language')->set('site', 'JTOOLBAR_SAVE_AS_COPY', "Save as Copy"); - CFactory::_('Language')->set('site', 'JTOOLBAR_SAVE', "Save & Close"); - CFactory::_('Language')->set('site', 'JTOOLBAR_SAVE_AND_NEW', "Save & New"); - CFactory::_('Language')->set('site', 'JTOOLBAR_CANCEL', "Cancel"); - CFactory::_('Language')->set('site', 'JTOOLBAR_CLOSE', "Close"); - CFactory::_('Language')->set('site', 'JTOOLBAR_HELP', "Help"); - CFactory::_('Language')->set('site', 'JGLOBAL_FIELD_ID_LABEL', "ID"); - CFactory::_('Language')->set( - 'site', 'JGLOBAL_FIELD_ID_DESC', "Record number in the database." - ); - CFactory::_('Language')->set( - 'site', 'JGLOBAL_FIELD_MODIFIED_LABEL', "Modified Date" - ); - CFactory::_('Language')->set( - 'site', 'COM_CONTENT_FIELD_MODIFIED_DESC', - "The last date this item was modified." - ); - CFactory::_('Language')->set( - 'site', 'JGLOBAL_FIELD_MODIFIED_BY_LABEL', "Modified By" - ); - CFactory::_('Language')->set( - 'site', 'JGLOBAL_FIELD_MODIFIED_BY_DESC', - "The user who did the last modification." - ); - CFactory::_('Language')->set('site', CFactory::_('Config')->lang_prefix . '_NEW', "New"); - CFactory::_('Language')->set( - 'site', CFactory::_('Config')->lang_prefix . '_CREATE_NEW_S', "Create New %s" - ); - CFactory::_('Language')->set('site', CFactory::_('Config')->lang_prefix . '_EDIT_S', "Edit %s"); - CFactory::_('Language')->set( - 'site', CFactory::_('Config')->lang_prefix . '_NO_ACCESS_GRANTED', - "No Access Granted!" - ); - CFactory::_('Language')->set( - 'site', CFactory::_('Config')->lang_prefix . '_NOT_FOUND_OR_ACCESS_DENIED', - "Not found or access denied!" - ); - - // check if the both array is set - if (CFactory::_('Language')->exist('both')) - { - foreach (CFactory::_('Language')->getTarget('both') as $keylang => $langval) - { - CFactory::_('Language')->set('site', $keylang, $langval); - } - } - // check if the both site array is set - if (CFactory::_('Language')->exist('bothsite')) - { - foreach (CFactory::_('Language')->getTarget('bothsite') as $keylang => $langval) - { - CFactory::_('Language')->set('site', $keylang, $langval); - } - } - if (CFactory::_('Language')->exist('site')) - { - // for plugin event TODO change event api signatures - $langContent = CFactory::_('Language')->getTarget('site'); - // Trigger Event: jcb_ce_onAfterBuildSiteLang - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterBuildSiteLang', - array(&$component_context, &$langContent, - &$this->langPrefix, &$componentName) - ); - // for plugin event TODO change event api signatures - CFactory::_('Config')->lang_prefix = $this->langPrefix; - // sort the strings - ksort($langContent); - // load to global languages - $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['site'] - = $langContent; - // remove tmp array - CFactory::_('Language')->setTarget('site', null); - - return true; - } - - return false; - } - - public function setLangSiteSys() - { - // add final list of needed lang strings - $componentName = CFactory::_('Component')->get('name'); - $componentName = JFilterOutput::cleanText($componentName); - // for plugin event TODO change event api signatures - $langContent = CFactory::_('Language')->getTarget('sitesys'); - $component_context = CFactory::_('Config')->component_context; - // Trigger Event: jcb_ce_onBeforeBuildSiteSysLang - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeBuildSiteSysLang', - array(&$component_context, &$langContent, - &$this->langPrefix, &$componentName) - ); - // for plugin event TODO change event api signatures - CFactory::_('Config')->lang_prefix = $this->langPrefix; - CFactory::_('Language')->setTarget('sitesys', $langContent); - // add final list of needed lang strings - CFactory::_('Language')->set('sitesys', CFactory::_('Config')->lang_prefix, $componentName); - CFactory::_('Language')->set( - 'sitesys', CFactory::_('Config')->lang_prefix . '_NO_ACCESS_GRANTED', - "No Access Granted!" - ); - CFactory::_('Language')->set( - 'sitesys', CFactory::_('Config')->lang_prefix . '_NOT_FOUND_OR_ACCESS_DENIED', - "Not found or access denied!" - ); - - // check if the both site array is set - if (CFactory::_('Language')->exist('bothsite')) - { - foreach (CFactory::_('Language')->getTarget('bothsite') as $keylang => $langval) - { - CFactory::_('Language')->set('sitesys', $keylang, $langval); - } - } - if (CFactory::_('Language')->exist('sitesys')) - { - // for plugin event TODO change event api signatures - $langContent = CFactory::_('Language')->getTarget('sitesys'); - // Trigger Event: jcb_ce_onAfterBuildSiteSysLang - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterBuildSiteSysLang', - array(&$component_context, &$langContent, - &$this->langPrefix, &$componentName) - ); - // for plugin event TODO change event api signatures - CFactory::_('Config')->lang_prefix = $this->langPrefix; - // sort strings - ksort($langContent); - // load to global languages - $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['sitesys'] - = $langContent; - // remove tmp array - CFactory::_('Language')->setTarget('sitesys', null); - - return true; - } - - return false; - } - - public function setLangAdminSys() - { - // add final list of needed lang strings - $componentName = CFactory::_('Component')->get('name'); - $componentName = JFilterOutput::cleanText($componentName); - // for plugin event TODO change event api signatures - $langContent = CFactory::_('Language')->getTarget('adminsys'); - $component_context = CFactory::_('Config')->component_context; - // Trigger Event: jcb_ce_onBeforeBuildAdminSysLang - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeBuildAdminSysLang', - array(&$component_context, &$langContent, - &$this->langPrefix, &$componentName) - ); - // for plugin event TODO change event api signatures - CFactory::_('Config')->lang_prefix = $this->langPrefix; - CFactory::_('Language')->setTarget('adminsys', $langContent); - // check if the both admin array is set - if (CFactory::_('Language')->exist('bothadmin')) - { - foreach (CFactory::_('Language')->getTarget('bothadmin') as $keylang => $langval) - { - CFactory::_('Language')->set('adminsys', $keylang, $langval); - } - } - if (CFactory::_('Language')->exist('adminsys')) - { - // for plugin event TODO change event api signatures - $langContent = CFactory::_('Language')->getTarget('adminsys'); - // Trigger Event: jcb_ce_onAfterBuildAdminSysLang - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterBuildAdminSysLang', - array(&$component_context, &$langContent, - &$this->langPrefix, &$componentName) - ); - // for plugin event TODO change event api signatures - CFactory::_('Config')->lang_prefix = $this->langPrefix; - // sort strings - ksort($langContent); - // load to global languages - $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['adminsys'] - = $langContent; - // remove tmp array - CFactory::_('Language')->setTarget('adminsys', null); - - return true; - } - - return false; - } - - public function setCustomAdminViewListLink($view, $nameListCode) - { - if (CFactory::_('Component')->isArray('custom_admin_views')) - { - foreach (CFactory::_('Component')->get('custom_admin_views') as $custom_admin_view) - { - if (isset($custom_admin_view['adminviews']) - && ArrayHelper::check( - $custom_admin_view['adminviews'] - )) - { - foreach ($custom_admin_view['adminviews'] as $adminview) - { - if (isset($view['adminview']) - && $view['adminview'] == $adminview) - { - // set the needed keys - $setId = false; - if (ArrayHelper::check( - $custom_admin_view['settings']->main_get->filter - )) - { - foreach ( - $custom_admin_view['settings']->main_get->filter - as $filter - ) - { - if ($filter['filter_type'] == 1 - || '$id' == $filter['state_key']) - { - $setId = true; - } - } - } - // set the needed array values - $set = array( - 'icon' => $custom_admin_view['icomoon'], - 'link' => $custom_admin_view['settings']->code, - 'NAME' => $custom_admin_view['settings']->CODE, - 'name' => $custom_admin_view['settings']->name); - // only load to list if it has id filter - if ($setId) - { - // now load it to the global object for items list - $this->customAdminViewListLink[$nameListCode][] - = $set; - // add to set id for list view if needed - $this->customAdminViewListId[$custom_admin_view['settings']->code] - = true; - } - else - { - // now load it to the global object for tool bar - $this->customAdminDynamicButtons[$nameListCode][] - = $set; - } - // log that it has been added already - $this->customAdminAdded[$custom_admin_view['settings']->code] - = $adminview; - } - } - } - } - } - } - - /** - * set the list body - * - * @param string $nameSingleCode - * @param string $nameListCode - * - * @return string - */ - public function setListBody($nameSingleCode, $nameListCode) - { - if (($items = CFactory::_('Compiler.Builder.Lists')->get($nameListCode)) !== null) - { - // component helper name - $Helper = CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper'; - // make sure the custom links are only added once - $firstTimeBeingAdded = true; - // add the default - $body = "items as \$i => \$item): ?>"; - $body .= PHP_EOL . Indent::_(1) . "user->authorise('core.manage', 'com_checkin') || \$item->checked_out == \$this->user->id || \$item->checked_out == 0;"; - $body .= PHP_EOL . Indent::_(2) - . "\$userChkOut = JFactory::getUser(\$item->checked_out);"; - $body .= PHP_EOL . Indent::_(2) . "\$canDo = " . $Helper - . "::getActions('" . $nameSingleCode . "',\$item,'" - . $nameListCode . "');"; - $body .= PHP_EOL . Indent::_(1) . "?>"; - $body .= PHP_EOL . Indent::_(1) - . ''; - // only load if not overwritten - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.ordering')) - { - $body .= PHP_EOL . Indent::_(2) - . ''; - // check if the item has permissions. - $body .= PHP_EOL . Indent::_(2) . "get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit.state') . "')): ?>"; - $body .= PHP_EOL . Indent::_(3) . "saveOrder)"; - $body .= PHP_EOL . Indent::_(4) . "{"; - $body .= PHP_EOL . Indent::_(5) - . "\$iconClass = ' inactive tip-top" - . '" hasTooltip" title="' - . "' . JHtml::tooltipText('JORDERINGDISABLED');"; - $body .= PHP_EOL . Indent::_(4) . "}"; - $body .= PHP_EOL . Indent::_(3) . "?>"; - $body .= PHP_EOL . Indent::_(3) - . ''; - $body .= PHP_EOL . Indent::_(4) . ''; - $body .= PHP_EOL . Indent::_(3) . ""; - $body .= PHP_EOL . Indent::_(3) - . "saveOrder) : ?>"; - $body .= PHP_EOL . Indent::_(4) - . ''; - $body .= PHP_EOL . Indent::_(3) . ""; - $body .= PHP_EOL . Indent::_(2) . ""; - $body .= PHP_EOL . Indent::_(3) . "⋮"; - $body .= PHP_EOL . Indent::_(2) . ""; - $body .= PHP_EOL . Indent::_(2) . ""; - } - $body .= PHP_EOL . Indent::_(2) . ''; - // check if the item has permissions. - $body .= PHP_EOL . Indent::_(2) . "get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit') . "')): ?>"; - $body .= PHP_EOL . Indent::_(4) - . "checked_out) : ?>"; - $body .= PHP_EOL . Indent::_(5) . ""; - $body .= PHP_EOL . Indent::_(6) - . "id); ?>"; - $body .= PHP_EOL . Indent::_(5) . ""; - $body .= PHP_EOL . Indent::_(6) . "□"; - $body .= PHP_EOL . Indent::_(5) . ""; - $body .= PHP_EOL . Indent::_(4) . ""; - $body .= PHP_EOL . Indent::_(5) - . "id); ?>"; - $body .= PHP_EOL . Indent::_(4) . ""; - $body .= PHP_EOL . Indent::_(2) . ""; - $body .= PHP_EOL . Indent::_(3) . "□"; - $body .= PHP_EOL . Indent::_(2) . ""; - $body .= PHP_EOL . Indent::_(2) . ""; - // check if this view has fields that should not be escaped - $doNotEscape = false; - if (CFactory::_('Compiler.Builder.Do.Not.Escape')->exists($nameListCode)) - { - $doNotEscape = true; - } - // start adding the dynamic - foreach ($items as $item) - { - // check if target is admin list - if (1 == $item['target'] || 3 == $item['target']) - { - // set some defaults - $customAdminViewButtons = ''; - // set the item default class - $itemClass = 'hidden-phone'; - // set the item row - $itemRow = $this->getListItemBuilder( - $item, $nameSingleCode, $nameListCode, $itemClass, $doNotEscape - ); - // check if buttons was already added - if ($firstTimeBeingAdded) // TODO we must improve this to allow more items to be targeted instead of just the first item :) - { - // get custom admin view buttons - $customAdminViewButtons - = $this->getCustomAdminViewButtons($nameListCode); - // make sure the custom admin view buttons are only added once - $firstTimeBeingAdded = false; - } - // add row to body - $body .= PHP_EOL . Indent::_(2) . "getListFieldClass( - $item['code'], $nameListCode, $itemClass - ) . "\">"; - $body .= $itemRow; - $body .= $customAdminViewButtons; - $body .= PHP_EOL . Indent::_(2) . ""; - } - } - // add the defaults - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.published')) - { - $body .= PHP_EOL . Indent::_(2) . ''; - // check if the item has permissions. - $body .= PHP_EOL . Indent::_(2) . "get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit.state') . "')) : ?>"; - $body .= PHP_EOL . Indent::_(4) - . "checked_out) : ?>"; - $body .= PHP_EOL . Indent::_(5) - . ""; - $body .= PHP_EOL . Indent::_(6) - . "published, \$i, '" - . $nameListCode . ".', true, 'cb'); ?>"; - $body .= PHP_EOL . Indent::_(5) . ""; - $body .= PHP_EOL . Indent::_(6) - . "published, \$i, '" - . $nameListCode . ".', false, 'cb'); ?>"; - $body .= PHP_EOL . Indent::_(5) . ""; - $body .= PHP_EOL . Indent::_(4) . ""; - $body .= PHP_EOL . Indent::_(5) - . "published, \$i, '" - . $nameListCode . ".', true, 'cb'); ?>"; - $body .= PHP_EOL . Indent::_(4) . ""; - $body .= PHP_EOL . Indent::_(2) . ""; - $body .= PHP_EOL . Indent::_(3) - . "published, \$i, '" - . $nameListCode . ".', false, 'cb'); ?>"; - $body .= PHP_EOL . Indent::_(2) . ""; - $body .= PHP_EOL . Indent::_(2) . ""; - } - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.id')) - { - $body .= PHP_EOL . Indent::_(2) . ''; - $body .= PHP_EOL . Indent::_(3) . "id; ?>"; - $body .= PHP_EOL . Indent::_(2) . ""; - } - $body .= PHP_EOL . Indent::_(1) . ""; - $body .= PHP_EOL . ""; - - // return the build - return $body; - } - - return ''; - } - - /** - * Get the list item dynamic row - * - * @param array $item The item array - * @param string $nameSingleCode The single view code name - * @param string $nameListCode The list view code name - * @param string $itemClass The table row default class - * @param bool $doNotEscape The do not escape global switch - * @param bool $class The dive class adding switch - * @param string $ref The link referral string - * @param string $escape The escape code name - * @param string $user The user code name - * @param string $refview The override of the referral view code name - * - * @return string of the completer item value for the table row - * - */ - protected function getListItemBuilder($item, $nameSingleCode, - $nameListCode, &$itemClass, $doNotEscape, - $class = true, $ref = null, $escape = '$this->escape', - $user = '$this->user', $refview = null - ) - { - // check if we have relation fields - if (($field_relations = - CFactory::_('Compiler.Builder.Field.Relations')->get($nameListCode . '.' . (int) $item['id'] . '.2')) !== null) - { - // set the fields array - $field = array(); - // use custom code - $useCustomCode - = (isset($field_relations['join_type']) - && $field_relations['join_type'] - == 2 - && isset($field_relations['set']) - && StringHelper::check( - $field_relations['set'] - )); - // load the main list view field - $field['[field=' . (int) $item['id'] . ']'] = $this->getListItem( - $item, $nameSingleCode, $nameListCode, $itemClass, - $doNotEscape,false, $ref, $escape, $user, - $refview - ); - // code name - if (isset($item['code']) && $useCustomCode) - { - $field['$item->{' . (int) $item['id'] . '}'] = '$item->' - . $item['code']; - } - // now load the relations - if (isset($field_relations['joinfields']) - && ArrayHelper::check($field_relations['joinfields'])) - { - foreach ($field_relations['joinfields'] as $join) - { - $blankClass = ''; - if (($join_item = - CFactory::_('Compiler.Builder.List.Join')->get($nameListCode . '.' . (int) $join)) !== null) - { - // code block - $field['[field=' . (int) $join . ']'] - = $this->getListItem( - $join_item, $nameSingleCode, $nameListCode, $blankClass, - $doNotEscape, false, $ref, - $escape, $user, $refview - ); - // code name - if (isset($join_item['code']) - && $useCustomCode) - { - $field['$item->{' . (int) $join . '}'] = '$item->' - . $join_item['code']; - } - } - } - } - // join based on join type - if ($useCustomCode) - { - // custom code - return PHP_EOL . Indent::_(3) . "
    " - . CFactory::_('Placeholder')->update_( - str_replace( - array_keys($field), array_values($field), - (string) $field_relations['set'] - ) - ) . PHP_EOL . Indent::_(3) . "
    "; - } - elseif (isset($field_relations['set']) - && StringHelper::check( - $field_relations['set'] - )) - { - // concatenate - return PHP_EOL . Indent::_(3) . "
    " . implode( - $field_relations['set'], - $field - ) . PHP_EOL . Indent::_(3) . "
    "; - } - - // default - return PHP_EOL . Indent::_(3) . "
    " . implode('', $field) - . PHP_EOL . Indent::_(3) . "
    "; - } - - return $this->getListItem( - $item, $nameSingleCode, $nameListCode, $itemClass, $doNotEscape, - $class, $ref, $escape, $user, $refview - ); - } - - /** - * Get the list item row value - * - * @param array $item The item array - * @param string $nameSingleCode The single view code name - * @param string $nameListCode The list view code name - * @param string $itemClass The table row default class - * @param bool $doNotEscape The do not escape global switch - * @param bool $class The dive class adding switch - * @param string $ref The link referral string - * @param string $escape The escape code name - * @param string $user The user code name - * @param string $refview The override of the referral view code name - * - * @return string of the single item value for the table row - * - */ - protected function getListItem($item, $nameSingleCode, $nameListCode, - &$itemClass, $doNotEscape, $class = true, $ref = null, - $escape = '$this->escape', $user = '$this->user', $refview = null - ) - { - // get list item code - $itemCode = $this->getListItemCode( - $item, $nameListCode, $doNotEscape, $escape - ); - // add default links - $defaultLink = true; - if (StringHelper::check($refview) - && isset($item['custom']) - && isset($item['custom']['view']) - && $refview === $item['custom']['view']) - { - $defaultLink = false; - } - // is this a linked item - if (($item['link'] - || (ArrayHelper::check( - $item['custom'] - ) - && $item['custom']['extends'] === 'user')) - && $defaultLink) - { - // set some defaults - $checkoutTriger = false; - // set the item default class - $itemClass = 'nowrap'; - // get list item link - $itemLink = $this->getListItemLink( - $item, $checkoutTriger, $nameSingleCode, $nameListCode, $ref - ); - // get list item link authority - $itemLinkAuthority = $this->getListItemLinkAuthority( - $item, $nameSingleCode, $nameListCode, $user - ); - - // set item row - return $this->getListItemLinkLogic( - $itemCode, $itemLink, $itemLinkAuthority, $nameListCode, - $checkoutTriger, $class - ); - } - - // return the default (no link) - return PHP_EOL . Indent::_(3) . ""; - } - - /** - * Get the list item link logic - * - * @param string $itemCode The item code string - * @param string $itemLink The item link string - * @param string $itemLinkAuthority The link authority string - * @param string $nameListCode The list view code name - * @param bool $checkoutTriger The check out trigger - * @param bool $class The dive class adding switch - * - * @return string of the complete link logic of row item - * - */ - protected function getListItemLinkLogic($itemCode, $itemLink, - $itemLinkAuthority, $nameListCode, $checkoutTriger, $class = true - ) - { - // build link - $link = ''; - // add class - $tab = ''; - if ($class) - { - $link .= PHP_EOL . Indent::_(3) . '
    '; - $tab = Indent::_(1); - } - // the link logic - $link .= PHP_EOL . $tab . Indent::_(3) . ""; - $link .= PHP_EOL . $tab . Indent::_(4) . ''; - if ($checkoutTriger) - { - $link .= PHP_EOL . $tab . Indent::_(4) - . "checked_out): ?>"; - $link .= PHP_EOL . $tab . Indent::_(5) - . "name, \$item->checked_out_time, '" - . $nameListCode . ".', \$canCheckin); ?>"; - $link .= PHP_EOL . $tab . Indent::_(4) . ""; - } - $link .= PHP_EOL . $tab . Indent::_(3) . ""; - $link .= PHP_EOL . $tab . Indent::_(4) . ""; - $link .= PHP_EOL . $tab . Indent::_(3) . ""; - // add class - if ($class) - { - $link .= PHP_EOL . Indent::_(3) . "
    "; - } - - // return the link logic - return $link; - } - - /** - * Get the custom admin view buttons - * - * @param string $nameListCode The list view code name - * @param string $ref The link referral string - * - * @return string of the custom admin view buttons - * - */ - protected function getCustomAdminViewButtons($nameListCode, $ref = '') - { - $customAdminViewButton = ''; - // check if custom links should be added to this list views - if (isset($this->customAdminViewListLink[$nameListCode]) - && ArrayHelper::check( - $this->customAdminViewListLink[$nameListCode] - )) - { - // start building the links - $customAdminViewButton .= PHP_EOL . Indent::_(3) - . '
    '; - foreach ( - $this->customAdminViewListLink[$nameListCode] as - $customLinkView - ) - { - $customAdminViewButton .= PHP_EOL . Indent::_(3) - . "get('" . $customLinkView['link'] - . ".access')): ?>"; - $customAdminViewButton .= PHP_EOL . Indent::_(4) - . 'get('COMPONENT') . '_' . $customLinkView['NAME'] . "'" - . '); ?>" >'; - $customAdminViewButton .= PHP_EOL . Indent::_(3) - . ""; - $customAdminViewButton .= PHP_EOL . Indent::_(4) - . 'get('COMPONENT') . '_' . $customLinkView['NAME'] - . "'" . '); ?>">'; - $customAdminViewButton .= PHP_EOL . Indent::_(3) - . ""; - } - $customAdminViewButton .= PHP_EOL . Indent::_(3) . '
    '; - } - - return $customAdminViewButton; - } - - /** - * Get the list item code value - * - * @param array $item The item array - * @param string $nameListCode The list view code name - * @param bool $doNotEscape The do not escape global switch - * @param string $escape The escape code name - * - * @return string of the single item code - * - */ - protected function getListItemCode(&$item, $nameListCode, $doNotEscape, - $escape = '$this->escape' - ) - { - // first update the code id needed - if (isset($item['custom']) - && ArrayHelper::check( - $item['custom'] - ) - && isset($item['custom']['table']) - && StringHelper::check($item['custom']['table'])) - { - $item['id_code'] = $item['code']; - if (!$item['multiple']) - { - $item['code'] = $item['code'] . '_' . $item['custom']['text']; - } - } - // check if category - if ($item['type'] === 'category' && !$item['title']) - { - return $escape . '($item->category_title)'; - } - // check if user - elseif ($item['type'] === 'user') - { - return 'JFactory::getUser((int)$item->' . $item['code'] . ')->name'; - } - // check if custom user - elseif (isset($item['custom']) - && ArrayHelper::check( - $item['custom'] - ) - && $item['custom']['extends'] === 'user' - && isset($item['id_code'])) - { - return 'JFactory::getUser((int)$item->' . $item['id_code'] - . ')->name'; - } - // check if translated value is used - elseif (CFactory::_('Compiler.Builder.Selection.Translation')-> - exists($nameListCode . '.' . $item['code'])) - { - return 'JText:' . ':_($item->' . $item['code'] . ')'; - } - elseif (isset($item['custom']) - && ArrayHelper::check( - $item['custom'] - ) - && $item['custom']['text'] === 'user') - { - return 'JFactory::getUser((int)$item->' . $item['code'] . ')->name'; - } - elseif ($doNotEscape) - { - if (CFactory::_('Compiler.Builder.Do.Not.Escape')->exists($nameListCode . '.' . $item['code'])) - { - return '$item->' . $item['code']; - } - } - - // default - return $escape . '($item->' . $item['code'] . ')'; - } - - /** - * Get the list item link - * - * @param array $item The item array - * @param bool $checkoutTriger The checkout trigger switch - * @param string $nameSingleCode The single view code name - * @param string $nameListCode The list view code name - * @param string $ref The link referral string - * - * @return string of the single item link - * - */ - protected function getListItemLink($item, &$checkoutTriger, - $nameSingleCode, $nameListCode, $ref = null - ) - { - // set referal if not set - $referal = ''; - if (!$ref) - { - $ref = '&return=return_here; ?>'; - } - // in linked tab/view so must add ref to default - else - { - $referal = $ref; - } - // if to be linked - if ($item['type'] === 'category' && !$item['title']) - { - // return the link to category - return 'index.php?option=com_categories&task=category.edit&id=' - . $item['code'] . '; ?>&extension=' - . CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension", 'error'); - } - elseif ($item['type'] === 'user' && !$item['title']) - { - // return user link - return 'index.php?option=com_users&task=user.edit&id=' - . $item['code'] . ' ?>'; - } - elseif (isset($item['custom']) - && ArrayHelper::check( - $item['custom'] - ) - && $item['custom']['extends'] != 'user' - && !$item['title'] - && isset($item['id_code'])) - { - // build GUID link - if (isset($item['custom']['id']) && $item['custom']['id'] !== 'id') - { - // link to that linked item - return 'index.php?option=' . $item['custom']['component'] . '&view=' - . $item['custom']['views'] . '&task=' . $item['custom']['view'] - . '.edit&id=' . $item['id_code'] . '_id; ?>' - . $ref; - } - // link to that linked item - return 'index.php?option=' . $item['custom']['component'] . '&view=' - . $item['custom']['views'] . '&task=' . $item['custom']['view'] - . '.edit&id=' . $item['id_code'] . '; ?>' - . $ref; - } - elseif (isset($item['custom']) - && ArrayHelper::check( - $item['custom'] - ) - && $item['custom']['extends'] === 'user' - && !$item['title'] - && isset($item['id_code'])) - { - // return user link - return 'index.php?option=com_users&task=user.edit&id=' - . $item['id_code'] . ' ?>'; - } - // make sure to triger the checkout - $checkoutTriger = true; - - // basic default item link - return '&id=id; ?>' . $referal; - } - - /** - * Get the list item authority - * - * @param array $item The item array - * @param string $nameSingleCode The single view code name - * @param string $nameListCode The list view code name - * @param string $user The user code name - * - * @return string of the single item link authority - * - */ - protected function getListItemLinkAuthority($item, $nameSingleCode, $nameListCode, $user = '$this->user' - ) - { - // if to be linked - if ($item['type'] === 'category' && !$item['title']) - { - // get the other view - $otherView = CFactory::_('Compiler.Builder.Category.Code')->getString("{$nameSingleCode}.view", 'error'); - - // return the authority to category - return $user . "->authorise('core.edit', 'com_" - . CFactory::_('Config')->component_code_name . "." . $otherView - . ".category.' . (int)\$item->" . $item['code'] . ")"; - } - elseif ($item['type'] === 'user' && !$item['title']) - { - // return user authority - return $user . "->authorise('core.edit', 'com_users')"; - } - elseif (isset($item['custom']) - && ArrayHelper::check( - $item['custom'] - ) - && $item['custom']['extends'] != 'user' - && !$item['title'] - && isset($item['id_code'])) - { - // do this with GUID - if (isset($item['custom']['id']) && $item['custom']['id'] !== 'id') - { - return $user . "->authorise('" . CFactory::_('Compiler.Creator.Permission')->getAction($item['custom']['view'], 'core.edit') - . "', 'com_" . CFactory::_('Config')->component_code_name . "." - . $item['custom']['view'] . ".' . (int) \$item->" . $item['id_code'] . "_id)"; - } - else - { - return $user . "->authorise('" . CFactory::_('Compiler.Creator.Permission')->getAction($item['custom']['view'], 'core.edit') - . "', 'com_" . CFactory::_('Config')->component_code_name . "." - . $item['custom']['view'] . ".' . (int) \$item->" . $item['id_code'] . ")"; - } - } - elseif (isset($item['custom']) - && ArrayHelper::check( - $item['custom'] - ) - && $item['custom']['extends'] === 'user' - && !$item['title'] - && isset($item['id_code'])) - { - // return user link - return $user . "->authorise('core.edit', 'com_users')"; - } - - // set core permissions. - return "\$canDo->get('" . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit') . "')"; - } - - /** - * Get the list field class - * - * @param string $name The field code name - * @param string $nameListCode The list view code name - * @param string $default The default - * - * @return string The list field class - * - */ - protected function getListFieldClass($name, $nameListCode, $default = '') - { - return CFactory::_('Compiler.Builder.List.Field.Class')->get($nameListCode . '.' . $name, $default); - } - - /** - * set the default views body - * - * @param string $nameSingleCode - * @param string $nameListCode - * - * @return string - */ - public function setDefaultViewsBody($nameSingleCode, $nameListCode) - { - // set component name - $component = CFactory::_('Config')->component_code_name; - $Component = ucfirst((string) $component); - $COMPONENT = strtoupper((string) $component); - // set uppercase view - $VIEWS = strtoupper($nameListCode); - // build the body - $body = array(); - // check if the filter type is sidebar (1 = sidebar) - if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 1) - { - $body[] = ""; - } - // Trigger Event: jcb_ce_onSetDefaultViewsBodyTop - CFactory::_('Event')->trigger( - 'jcb_ce_onSetDefaultViewsBodyTop', - array(&$this, - &$body, - &$nameSingleCode, - &$nameListCode) - ); - $body[] = "
    \" method=\"post\" name=\"adminForm\" id=\"adminForm\">"; - $body[] = "sidebar)): ?>"; - $body[] = Indent::_(1) - . "
    "; - $body[] = Indent::_(2) . "sidebar; ?>"; - $body[] = Indent::_(1) . "
    "; - $body[] = Indent::_(1) - . "
    "; - $body[] = ""; - $body[] = Indent::_(1) . "
    "; - $body[] = ""; - // Trigger Event: jcb_ce_onSetDefaultViewsFormTop - CFactory::_('Event')->trigger( - 'jcb_ce_onSetDefaultViewsFormTop', - array(&$this, - &$body, - &$nameSingleCode, - &$nameListCode) - ); - // check if the filter type is sidebar (2 = topbar) - if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2) - { - $body[] = "setTemplateAndLayoutData($addTrashHelper, $nameListCode)) - { - $body[] = Indent::_(1) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Add the trash helper layout"; - $body[] = $addTrashHelper; - } - // add the new search toolbar ;) - $body[] = Indent::_(1) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Add the searchtools"; - $body[] = Indent::_(1) - . "echo JLayoutHelper::render('joomla.searchtools.default', array('view' => \$this));"; - $body[] = "?>"; - } - $body[] = "items)): ?>"; - // check if the filter type is sidebar (1 = sidebar) - if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 1) - { - $body[] = Indent::_(1) - . "loadTemplate('toolbar');?>"; - } - $body[] = Indent::_(1) - . "
    "; - $body[] = Indent::_(2) - . ""; - $body[] = Indent::_(1) . "
    "; - $body[] = ""; - // check if the filter type is sidebar (1 = sidebar) - if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 1) - { - $body[] = Indent::_(1) - . "loadTemplate('toolbar');?>"; - } - $body[] = Indent::_(1) . ""; - $body[] = Indent::_(2) - . "loadTemplate('head');?>"; - $body[] = Indent::_(2) - . "loadTemplate('foot');?>"; - $body[] = Indent::_(2) - . "loadTemplate('body');?>"; - $body[] = Indent::_(1) . "
    "; - $body[] = Indent::_(1) . ""; - $body[] = Indent::_(1) - . "canCreate && \$this->canEdit) : ?>"; - $body[] = Indent::_(2) . " JText::_('COM_" . $COMPONENT . "_" - . $VIEWS - . "_BATCH_OPTIONS'),"; - $body[] = Indent::_(4) - . "'footer' => \$this->loadTemplate('batch_footer')"; - $body[] = Indent::_(3) . "),"; - $body[] = Indent::_(3) . "\$this->loadTemplate('batch_body')"; - $body[] = Indent::_(2) . "); ?>"; - $body[] = Indent::_(1) . ""; - // check if the filter type is sidebar (1 = sidebar) - if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 1) - { - $body[] = Indent::_(1) - . "listOrder; ?>\" />"; - $body[] = Indent::_(1) - . "listDirn; ?>\" />"; - } - $body[] = Indent::_(1) - . ""; - $body[] = Indent::_(1) . "
    "; - $body[] = ""; - $body[] = Indent::_(1) - . ""; - $body[] = Indent::_(1) . ""; - // Trigger Event: jcb_ce_onSetDefaultViewsFormBottom - CFactory::_('Event')->trigger( - 'jcb_ce_onSetDefaultViewsFormBottom', - array(&$this, - &$body, - &$nameSingleCode, - &$nameListCode) - ); - $body[] = ""; - // Trigger Event: jcb_ce_onSetDefaultViewsBodyBottom - CFactory::_('Event')->trigger( - 'jcb_ce_onSetDefaultViewsBodyBottom', - array(&$this, - &$body, - &$nameSingleCode, - &$nameListCode) - ); - - return implode(PHP_EOL, $body); - } - - /** - * set the list body table head - * - * @param string $nameSingleCode - * @param string $nameListCode - * - * @return string - */ - public function setListHead($nameSingleCode, $nameListCode) - { - if (($items = CFactory::_('Compiler.Builder.Lists')->get($nameListCode)) !== null) - { - // set the JHtml values based on filter type - $jhtml_sort = "grid.sort"; - $jhtml_sort_icon = ""; - $jhtml_sort_icon_2 = ""; - // for the new filter (2 = topbar) - if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2) - { - $jhtml_sort = "searchtools.sort"; - $jhtml_sort_icon = ""; - $jhtml_sort_icon_2 = ", 'icon-menu-2'"; - } - // main lang prefix - $langView = $this->langPrefix . '_' - . StringHelper::safe($nameSingleCode, 'U'); - // set status lang - $statusLangName = $langView . '_STATUS'; - // set id lang - $idLangName = $langView . '_ID'; - // add to lang array - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $statusLangName, 'Status'); - // add to lang array - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $idLangName, 'Id'); - // set default - $head = ''; - $head .= PHP_EOL . Indent::_(1) - . "canEdit&& \$this->canState): ?>"; - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.ordering')) - { - $head .= PHP_EOL . Indent::_(2) - . ''; - $head .= PHP_EOL . Indent::_(3) - . "listDirn, \$this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'" - . $jhtml_sort_icon_2 . "); ?>"; - $head .= PHP_EOL . Indent::_(2) . ""; - } - $head .= PHP_EOL . Indent::_(2) - . ''; - $head .= PHP_EOL . Indent::_(3) - . ""; - $head .= PHP_EOL . Indent::_(2) . ""; - $head .= PHP_EOL . Indent::_(1) . ""; - $head .= PHP_EOL . Indent::_(2) - . ''; - $head .= PHP_EOL . Indent::_(3) . "▾"; - $head .= PHP_EOL . Indent::_(2) . ""; - $head .= PHP_EOL . Indent::_(2) - . ''; - $head .= PHP_EOL . Indent::_(3) . "■"; - $head .= PHP_EOL . Indent::_(2) . ""; - $head .= PHP_EOL . Indent::_(1) . ""; - // set footer Column number - $this->listColnrBuilder[$nameListCode] = 4; - // build the dynamic fields - foreach ($items as $item) - { - // check if target is admin list - if (1 == $item['target'] || 3 == $item['target']) - { - // check if we have an over-ride - if (($list_head_override = CFactory::_('Compiler.Builder.List.Head.Override')-> - get($nameListCode . '.' . (int) $item['id'])) !== null) - { - $item['lang'] = $list_head_override; - } - $class = 'nowrap hidden-phone'; - if ($item['link']) - { - $class = 'nowrap'; - } - // add sort options if required - if ($item['sort']) - { - // if category - if ($item['type'] === 'category') - { - // only one category per/view allowed at this point - $title = "listDirn, \$this->listOrder); ?>"; - } - // set the custom code - elseif (ArrayHelper::check( - $item['custom'] - )) - { - // keep an eye on this - $title = "listDirn, \$this->listOrder); ?>"; - } - else - { - $title = "listDirn, \$this->listOrder); ?>"; - } - } - else - { - $title = ""; - } - $head .= PHP_EOL . Indent::_(1) . ''; - $head .= PHP_EOL . Indent::_(3) . $title; - $head .= PHP_EOL . Indent::_(1) . ""; - $this->listColnrBuilder[$nameListCode]++; - } - } - // set default - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.published')) - { - $head .= PHP_EOL . Indent::_(1) - . "canState): ?>"; - $head .= PHP_EOL . Indent::_(2) - . ''; - $head .= PHP_EOL . Indent::_(3) - . "listDirn, \$this->listOrder); ?>"; - $head .= PHP_EOL . Indent::_(2) . ""; - $head .= PHP_EOL . Indent::_(1) . ""; - $head .= PHP_EOL . Indent::_(2) - . ''; - $head .= PHP_EOL . Indent::_(3) . ""; - $head .= PHP_EOL . Indent::_(2) . ""; - $head .= PHP_EOL . Indent::_(1) . ""; - } - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.id')) - { - $head .= PHP_EOL . Indent::_(1) - . ''; - $head .= PHP_EOL . Indent::_(3) - . "listDirn, \$this->listOrder); ?>"; - $head .= PHP_EOL . Indent::_(1) . ""; - } - $head .= PHP_EOL . ""; - - return $head; - } - - return ''; - } - - public function setListColnr($nameListCode) - { - if (isset($this->listColnrBuilder[$nameListCode])) - { - return $this->listColnrBuilder[$nameListCode]; - } - - return ''; - } - - /** - * set Tabs Layouts Fields Array - * - * @param string $nameSingleCode The single view name - * - * @return string The array - * - */ - public function getTabLayoutFieldsArray($nameSingleCode) - { - // check if the load build is set for this view - if (CFactory::_('Compiler.Builder.Layout')->exists($nameSingleCode)) - { - $layout_builder = CFactory::_('Compiler.Builder.Layout')->get($nameSingleCode); - $layoutArray = array(); - foreach ($layout_builder as $layout => $alignments) - { - $alignments = (array) $alignments; - // sort the alignments - ksort($alignments); - $alignmentArray = array(); - foreach ($alignments as $alignment => $fields) - { - $fields = (array) $fields; - // sort the fields - ksort($fields); - $fieldArray = array(); - foreach ($fields as $field) - { - // add each field - $fieldArray[] = PHP_EOL . Indent::_(4) . "'" . $field - . "'"; - } - // add the alignemnt key - $alignmentArray[] = PHP_EOL . Indent::_(3) . "'" - . $this->alignmentOptions[$alignment] . "' => array(" - . implode(',', $fieldArray) . PHP_EOL . Indent::_(3) - . ")"; - } - // add the layout key - $layoutArray[] = PHP_EOL . Indent::_(2) . "'" - . StringHelper::safe($layout) - . "' => array(" . implode(',', $alignmentArray) . PHP_EOL - . Indent::_(2) . ")"; - } - - return 'array(' . implode(',', $layoutArray) . PHP_EOL . Indent::_( - 1 - ) . ")"; - } - - return 'array()'; - } - - /** - * set Edit Body - * - * @param array $view The view data - * - * @return string The edit body - * - */ - public function setEditBody(&$view) - { - // set view name - $nameSingleCode = $view['settings']->name_single_code; - // main lang prefix - $langView = $this->langPrefix . '_' - . StringHelper::safe($nameSingleCode, 'U'); - // check if the load build is set for this view - if (CFactory::_('Compiler.Builder.Layout')->exists($nameSingleCode)) - { - // reset the linked keys - $keys = array(); - $linkedViewIdentifier = array(); - // set the linked view tabs - $linkedTab = $this->getEditBodyLinkedAdminViewsTabs( - $view, $nameSingleCode, $keys, $linkedViewIdentifier - ); - // custom tab searching array - $searchTabs = array(); - // reset tab values - $leftside = ''; - $rightside = ''; - $footer = ''; - $header = ''; - $mainwidth = 12; - $sidewidth = 0; - // get the tabs with positions - $tabBucket = $this->getEditBodyTabs( - $nameSingleCode, $langView, $linkedTab, $keys, - $linkedViewIdentifier, $searchTabs, $leftside, $rightside, - $footer, $header, $mainwidth, $sidewidth - ); - // tab counter - $tabCounter = 0; - // check if width is still 12 - $span = ''; - if ($mainwidth != 12) - { - $span = 'span' . $mainwidth; - } - // start building body - $body = PHP_EOL . '
    '; - if (StringHelper::check($span)) - { - $body .= PHP_EOL . Indent::_(1) . '
    '; - } - // now build the dynamic tabs - foreach ($tabBucket as $tabCodeName => $positions) - { - // get lang string - $tabLangName = $positions['lang']; - // build main center position - $main = ''; - $mainbottom = ''; - $this->setEditBodyTabMainCenterPositionDiv( - $main, $mainbottom, $positions - ); - // set acctive tab (must be in side foreach loop to get active tab code name) - if ($tabCounter == 0) - { - $body .= PHP_EOL . PHP_EOL . Indent::_(1) - . " '" - . $tabCodeName . "')); ?>"; - } - // check if custom tab must be added - if (($_customTabHTML = $this->addCustomTabs( - $searchTabs[$tabCodeName], $nameSingleCode, 1 - )) !== false) - { - $body .= $_customTabHTML; - } - // if this is a linked view set permissions - $closeIT = false; - if (ArrayHelper::check($linkedViewIdentifier) - && in_array($tabCodeName, $linkedViewIdentifier)) - { - // get view name - $linkedViewId = array_search( - $tabCodeName, $linkedViewIdentifier - ); - $linkedViewData = CFactory::_('Adminview.Data')->get($linkedViewId); - $linkedCodeName = StringHelper::safe( - $linkedViewData->name_single - ); - // check if the item has permissions. - if (CFactory::_('Compiler.Creator.Permission')->globalExist($linkedCodeName, 'core.access')) - { - $body .= PHP_EOL . PHP_EOL . Indent::_(1) - . "canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($linkedCodeName, 'core.access') . "')) : ?>"; - $closeIT = true; - } - else - { - $body .= PHP_EOL; - } - } - else - { - $body .= PHP_EOL; - } - // start addtab body - $body .= PHP_EOL . Indent::_(1) - . ""; - // add the main - $body .= PHP_EOL . Indent::_(2) - . '
    '; - $body .= $main; - $body .= PHP_EOL . Indent::_(2) . "
    "; - // add main body bottom div if needed - if (strlen((string) $mainbottom) > 0) - { - // add the main bottom - $body .= PHP_EOL . Indent::_(2) - . '
    '; - $body .= $mainbottom; - $body .= PHP_EOL . Indent::_(2) . "
    "; - } - // end addtab body - $body .= PHP_EOL . Indent::_(1) - . ""; - // if we had permissions added - if ($closeIT) - { - $body .= PHP_EOL . Indent::_(1) . ""; - } - // check if custom tab must be added - if (($_customTabHTML = $this->addCustomTabs( - $searchTabs[$tabCodeName], $nameSingleCode, 2 - )) !== false) - { - $body .= $_customTabHTML; - } - // set counter - $tabCounter++; - } - // add option to load forms loaded in via plugins (TODO) we may want to move these tab locations - $body .= PHP_EOL . PHP_EOL . Indent::_(1) - . "ignore_fieldsets = array('details','metadata','vdmmetadata','accesscontrol'); ?>"; - $body .= PHP_EOL . Indent::_(1) . "tab_name = '" - . $nameSingleCode . "Tab'; ?>"; - $body .= PHP_EOL . Indent::_(1) - . ""; - // add the publish and meta data tabs - $body .= $this->getEditBodyPublishMetaTabs( - $nameSingleCode, $langView - ); - // end the tab set - $body .= PHP_EOL . PHP_EOL . Indent::_(1) - . ""; - $body .= PHP_EOL . PHP_EOL . Indent::_(1) . "
    "; - $body .= PHP_EOL . Indent::_(2) - . ''; - $body .= PHP_EOL . Indent::_(2) - . ""; - $body .= PHP_EOL . Indent::_(1) . "
    "; - // close divs - if (StringHelper::check($span)) - { - $body .= PHP_EOL . Indent::_(1) . "
    "; - } - $body .= PHP_EOL . "
    "; - // check if left has been set - if (strlen((string) $leftside) > 0) - { - $left = '
    ' . $leftside - . PHP_EOL . "
    "; - } - else - { - $left = ''; - } - // check if right has been set - if (strlen((string) $rightside) > 0) - { - $right = '
    ' . $rightside - . PHP_EOL . "
    "; - } - else - { - $right = ''; - } - - // set active tab and return - return $header . $left . $body . $right . $footer; - } - - return ''; - } - - /** - * get Edit Body Linked Admin Views - * - * @param array $view The view data - * @param string $nameSingleCode The single view name - * @param array $keys The tabs to add in layout - * @param array $linkedViewIdentifier The linked view identifier - * - * @return array The linked Admin Views tabs - * - */ - protected function getEditBodyLinkedAdminViewsTabs(&$view, - &$nameSingleCode, &$keys, &$linkedViewIdentifier - ) - { - // start linked tabs bucket - $linkedTab = array(); - // check if the view has linked admin view - if (($linkedAdminViews = CFactory::_('Registry')->get('builder.linked_admin_views.' . $nameSingleCode, null)) !== null - && ArrayHelper::check($linkedAdminViews)) - { - foreach ($linkedAdminViews as $linkedView) - { - // when this happens tell me. - if (!isset($view['settings']->tabs[(int) $linkedView['tab']])) - { - echo "Tab Mismatch Oops! Check your linked views in admin view ($nameSingleCode) that they line-up."; - echo '
    ';
    -					var_dump($view['settings']->tabs, $linkedView);
    -					exit;
    -				}
    -				// get the tab name
    -				$tabName = $view['settings']->tabs[(int) $linkedView['tab']];
    -				// update the tab counter
    -				CFactory::_('Compiler.Builder.Tab.Counter')->set($nameSingleCode . '.' . $linkedView['tab'], $tabName);
    -				// add the linked view
    -				$linkedTab[$linkedView['adminview']] = $linkedView['tab'];
    -				// set the keys if values are set
    -				if (StringHelper::check($linkedView['key'])
    -					&& StringHelper::check(
    -						$linkedView['parentkey']
    -					))
    -				{
    -					$keys[$linkedView['adminview']]
    -						= array('key'       => $linkedView['key'],
    -						'parentKey' => $linkedView['parentkey']);
    -				}
    -				else
    -				{
    -					$keys[$linkedView['adminview']] = array('key'       => null,
    -						'parentKey' => null);
    -				}
    -				// set the button switches
    -				if (isset($linkedView['addnew']))
    -				{
    -					$keys[$linkedView['adminview']]['addNewButton']
    -						= (int) $linkedView['addnew'];
    -				}
    -				else
    -				{
    -					$keys[$linkedView['adminview']]['addNewButton'] = 0;
    -				}
    -			}
    -		}
    -
    -		return $linkedTab;
    -	}
    -
    -	/**
    -	 * get Edit Body Tabs
    -	 *
    -	 * @param   string  $nameSingleCode        The single view name
    -	 * @param   string  $langView              The main lang prefix
    -	 * @param   array   $linkedTab             The linked admin view tabs
    -	 * @param   array   $keys                  The tabs to add in layout
    -	 * @param   array   $linkedViewIdentifier  The linked view identifier
    -	 * @param   array   $searchTabs            The tabs to add in layout
    -	 * @param   string  $leftside              The left side html string
    -	 * @param   string  $rightside             The right side html string
    -	 * @param   string  $footer                The footer html string
    -	 * @param   string  $header                The header html string
    -	 * @param   int     $mainwidth             The main width value
    -	 * @param   int     $sidewidth             The side width value
    -	 *
    -	 * @return  array   The linked tabs
    -	 *
    -	 */
    -	protected function getEditBodyTabs(&$nameSingleCode, &$langView,
    -	                                   &$linkedTab, &$keys, &$linkedViewIdentifier, &$searchTabs, &$leftside,
    -	                                   &$rightside, &$footer, &$header, &$mainwidth, &$sidewidth
    -	)
    -	{
    -		// start tabs
    -		$tabs = array();
    -		// sort the tabs based on key order
    -		$tab_counter = (array) CFactory::_('Compiler.Builder.Tab.Counter')->get($nameSingleCode, []);
    -		ksort($tab_counter);
    -		// start tab building loop
    -		foreach ($tab_counter as $tabNr => $tabName)
    -		{
    -			$tabWidth  = 12;
    -			$lrCounter = 0;
    -			// set tab lang
    -			$tabLangName = $langView . '_' . StringHelper::safe(
    -					$tabName, 'U'
    -				);
    -			// set tab code name
    -			$tabCodeName = StringHelper::safe($tabName);
    -			/// set the values to use in search latter
    -			$searchTabs[$tabCodeName] = $tabNr;
    -			// add to lang array
    -			CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $tabLangName, $tabName);
    -			// check if linked view belongs to this tab
    -			$buildLayout  = true;
    -			$linkedViewId = '';
    -			if (ArrayHelper::check($linkedTab))
    -			{
    -				if (($linkedViewId = array_search($tabNr, $linkedTab))
    -					!== false)
    -				{
    -					// don't build (since this is a linked view)
    -					$buildLayout = false;
    -				}
    -			}
    -			// build layout these are actual fields
    -			if ($buildLayout && CFactory::_('Compiler.Builder.Layout')->exists($nameSingleCode . '.' . $tabName))
    -			{
    -				// sort to make sure it loads left first
    -				$alignments = CFactory::_('Compiler.Builder.Layout')->get($nameSingleCode . '.' . $tabName);
    -				ksort($alignments);
    -				foreach ($alignments as $alignment => $names)
    -				{
    -					// set layout code name
    -					$layoutCodeName = $tabCodeName . '_'
    -						. $this->alignmentOptions[$alignment];
    -					// reset each time
    -					$items       = '';
    -					$itemCounter = 0;
    -					// sort the names based on order of keys
    -					$names = (array) $names;
    -					ksort($names);
    -					// build the items array for this alignment
    -					foreach ($names as $nr => $name)
    -					{
    -						if ($itemCounter == 0)
    -						{
    -							$items .= "'" . $name . "'";
    -						}
    -						else
    -						{
    -							$items .= "," . PHP_EOL . Indent::_(1) . "'" . $name
    -								. "'";
    -						}
    -						$itemCounter++;
    -					}
    -					// based on alignment build the layout
    -					switch ($alignment)
    -					{
    -						case 1: // left
    -						case 2: // right
    -							// count
    -							$lrCounter++;
    -							// set as items layout
    -							$this->setLayout(
    -								$nameSingleCode, $layoutCodeName, $items,
    -								'layoutitems'
    -							);
    -							// set the lang to tab
    -							$tabs[$tabCodeName]['lang'] = $tabLangName;
    -							// load the body
    -							if (!isset($tabs[$tabCodeName][(int) $alignment]))
    -							{
    -								$tabs[$tabCodeName][(int) $alignment] = '';
    -							}
    -							$tabs[$tabCodeName][(int) $alignment] .= "";
    -							break;
    -						case 3: // fullwidth
    -							// set as items layout
    -							$this->setLayout(
    -								$nameSingleCode, $layoutCodeName, $items,
    -								'layoutfull'
    -							);
    -							// set the lang to tab
    -							$tabs[$tabCodeName]['lang'] = $tabLangName;
    -							// load the body
    -							if (!isset($tabs[$tabCodeName][(int) $alignment]))
    -							{
    -								$tabs[$tabCodeName][(int) $alignment] = '';
    -							}
    -							$tabs[$tabCodeName][(int) $alignment] .= "";
    -							break;
    -						case 4: // above
    -							// set as title layout
    -							$this->setLayout(
    -								$nameSingleCode, $layoutCodeName, $items,
    -								'layouttitle'
    -							);
    -							// load to header
    -							$header .= PHP_EOL . Indent::_(1)
    -								. "";
    -							break;
    -						case 5: // under
    -							// set as title layout
    -							$this->setLayout(
    -								$nameSingleCode, $layoutCodeName, $items,
    -								'layouttitle'
    -							);
    -							// load to footer
    -							$footer .= PHP_EOL . PHP_EOL
    -								. "
    " . PHP_EOL - . ""; - break; - case 6: // left side - $tabWidth = $tabWidth - 2; - // set as items layout - $this->setLayout( - $nameSingleCode, $layoutCodeName, $items, - 'layoutitems' - ); - // load the body - $leftside .= PHP_EOL . Indent::_(1) - . ""; - break; - case 7: // right side - $tabWidth = $tabWidth - 2; - // set as items layout - $this->setLayout( - $nameSingleCode, $layoutCodeName, $items, - 'layoutitems' - ); - // load the body - $rightside .= PHP_EOL . Indent::_(1) - . ""; - break; - } - } - } - else - { - // set layout code name - $layoutCodeName = $tabCodeName . '_fullwidth'; - // set identifiers - $linkedViewIdentifier[$linkedViewId] = $tabCodeName; - //set function name - $codeName = StringHelper::safe( - $this->uniquekey(3) . $tabCodeName - ); - // set as items layout - $this->setLayout( - $nameSingleCode, $layoutCodeName, $codeName, - 'layoutlinkedview' - ); - // set the lang to tab - $tabs[$tabCodeName]['lang'] = $tabLangName; - // set all the linked view stuff - $this->secondRunAdmin['setLinkedView'][] = array( - 'viewId' => $linkedViewId, - 'nameSingleCode' => $nameSingleCode, - 'codeName' => $codeName, - 'layoutCodeName' => $layoutCodeName, - 'key' => $keys[$linkedViewId]['key'], - 'parentKey' => $keys[$linkedViewId]['parentKey'], - 'addNewButon' => $keys[$linkedViewId]['addNewButton']); - // load the body - if (!isset($tabs[$tabCodeName][3])) - { - $tabs[$tabCodeName][3] = ''; - } - $tabs[$tabCodeName][3] .= ""; - } - // width calculator :) - if ($tabWidth == 8) - { - $mainwidth = 8; - $sidewidth = 2; - } - elseif ($tabWidth == 10 && $mainwidth != 8) - { - $mainwidth = 9; - $sidewidth = 3; - } - $tabs[$tabCodeName]['lr'] = $lrCounter; - } - - return $tabs; - } - - /** - * set Edit Body Main Center Positions Div - * - * @param string $main The main position of this tab - * @param string $mainbottom The main bottom position of this tab - * @param array $positions The build positions of this tab - * - * @return array The linked Admin Views tabs - * - */ - protected function setEditBodyTabMainCenterPositionDiv(&$main, &$mainbottom, - &$positions - ) - { - foreach ($positions as $position => $string) - { - if ($positions['lr'] == 2) - { - switch ($position) - { - case 1: // left - case 2: // right - $main .= PHP_EOL . Indent::_(3) . '
    '; - $main .= PHP_EOL . Indent::_(4) . $string; - $main .= PHP_EOL . Indent::_(3) . '
    '; - break; - } - } - else - { - switch ($position) - { - case 1: // left - case 2: // right - $main .= PHP_EOL . Indent::_(3) - . '
    '; - $main .= PHP_EOL . Indent::_(4) . $string; - $main .= PHP_EOL . Indent::_(3) . '
    '; - break; - } - } - switch ($position) - { - case 3: // fullwidth - $mainbottom .= PHP_EOL . Indent::_(3) - . '
    '; - $mainbottom .= PHP_EOL . Indent::_(4) . $string; - $mainbottom .= PHP_EOL . Indent::_(3) . '
    '; - break; - } - } - } - - /** - * get Edit Body Publish and Meta Tab - * - * @param string $nameSingleCode The single view name - * @param string $langView The main lang prefix - * - * @return string The published and Meta Data Tabs - * - */ - protected function getEditBodyPublishMetaTabs(&$nameSingleCode, &$langView - ) - { - // build the two tabs - $tabs = ''; - // set default publishing tab lang - $tabLangName = $langView . '_PUBLISHING'; - // add to lang array - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $tabLangName, 'Publishing'); - // the default publishing items - $items = array('left' => array(), 'right' => array()); - // Setup the default (custom) fields - // only load (1 => 'left', 2 => 'right') - $fieldsAddedRight = false; - if (CFactory::_('Compiler.Builder.New.Publishing.Fields')->exists($nameSingleCode)) - { - $new_published_fields = CFactory::_('Compiler.Builder.New.Publishing.Fields')->get($nameSingleCode); - foreach ($new_published_fields as $df_alignment => $df_items) - { - foreach ($df_items as $df_order => $df_name) - { - if ($df_alignment == 2 || $df_alignment == 1) - { - $items[$this->alignmentOptions[$df_alignment]][$df_order] - = $df_name; - } - else - { - $this->app->enqueueMessage( - JText::_('

    Field Warning

    '), 'Warning' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Your %s field could not be added, since the %s alignment position is not available in the %s (publishing) tab. Please only target Left or right in the publishing tab.', - $df_name, - $this->alignmentOptions[$df_alignment], - $nameSingleCode - ), 'Warning' - ); - } - } - } - // set switch to trigger notice if custom fields added to right - if (ArrayHelper::check($items['right'])) - { - $fieldsAddedRight = true; - } - } - // load all defaults - $loadDefaultFields = array( - 'left' => array('created', 'created_by', 'modified', - 'modified_by'), - 'right' => array('published', 'ordering', 'access', 'version', - 'hits', 'id') - ); - foreach ($loadDefaultFields as $d_alignment => $defaultFields) - { - foreach ($defaultFields as $defaultField) - { - if (!CFactory::_('Compiler.Builder.Moved.Publishing.Fields')->exists($nameSingleCode . '.' . $defaultField)) - { - if ($defaultField != 'access') - { - $items[$d_alignment][] = $defaultField; - } - elseif ($defaultField === 'access' - && CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode)) - { - $items[$d_alignment][] = $defaultField; - } - } - } - } - // check if metadata is added to this view - if (CFactory::_('Compiler.Builder.Meta.Data')->exists($nameSingleCode)) - { - // set default publishing tab code name - $tabCodeNameLeft = 'publishing'; - $tabCodeNameRight = 'metadata'; - // the default publishing tiems - if (ArrayHelper::check($items['left']) - || ArrayHelper::check($items['right'])) - { - $items_one = ''; - // load the items into one side - if (ArrayHelper::check($items['left'])) - { - $items_one .= "'" . implode( - "'," . PHP_EOL . Indent::_(1) . "'", $items['left'] - ) . "'"; - } - if (ArrayHelper::check($items['right'])) - { - // there is already fields just add these - if (strlen($items_one) > 3) - { - $items_one .= "," . PHP_EOL . Indent::_(1) . "'" - . implode( - "'," . PHP_EOL . Indent::_(1) . "'", - $items['right'] - ) . "'"; - } - // no fields has been added yet - else - { - $items_one .= "'" . implode( - "'," . PHP_EOL . Indent::_(1) . "'", - $items['right'] - ) . "'"; - } - } - // only triger the info notice if there were custom fields targeted to the right alignment position. - if ($fieldsAddedRight) - { - $this->app->enqueueMessage( - JText::_('

    Field Notice

    '), 'Notice' - ); - $this->app->enqueueMessage( - JText::sprintf( - 'Your field/s added to the right alignment position in the %s (publishing) tab was added to the left. Since we have metadata fields on the right. Fields can only be loaded to the right of the publishing tab if there is no metadata fields.', - $nameSingleCode - ), 'Notice' - ); - } - // set the publishing layout - $this->setLayout( - $nameSingleCode, $tabCodeNameLeft, $items_one, - 'layoutpublished' - ); - $items_one = true; - } - else - { - $items_one = false; - } - // set the metadata layout - $this->setLayout( - $nameSingleCode, $tabCodeNameRight, false, 'layoutmetadata' - ); - $items_two = true; - } - else - { - // set default publishing tab code name - $tabCodeNameLeft = 'publishing'; - $tabCodeNameRight = 'publlshing'; - // the default publishing tiems - if (ArrayHelper::check($items['left']) - || ArrayHelper::check($items['right'])) - { - // load left items that remain - if (ArrayHelper::check($items['left'])) - { - // load all items - $items_one = "'" . implode( - "'," . PHP_EOL . Indent::_(1) . "'", $items['left'] - ) . "'"; - // set the publishing layout - $this->setLayout( - $nameSingleCode, $tabCodeNameLeft, $items_one, - 'layoutpublished' - ); - $items_one = true; - } - // load right items that remain - if (ArrayHelper::check($items['right'])) - { - // load all items - $items_two = "'" . implode( - "'," . PHP_EOL . Indent::_(1) . "'", $items['right'] - ) . "'"; - // set the publishing layout - $this->setLayout( - $nameSingleCode, $tabCodeNameRight, $items_two, - 'layoutpublished' - ); - $items_two = true; - } - } - else - { - $items_one = false; - $items_two = false; - } - } - if ($items_one && $items_two) - { - $classs = "span6"; - } - elseif ($items_one || $items_two) - { - $classs = "span12"; - } - // only load this if needed - if ($items_one || $items_two) - { - // check if the item has permissions. - $publishingPerOR = array(); - $allToBeChekcedOR = array('core.edit.created_by', - 'core.edit.created', - 'core.edit.state'); - foreach ($allToBeChekcedOR as $core_permission) - { - // set permissions. - $publishingPerOR[] = "\$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, $core_permission) . "')"; - } - $publishingPerAND = array(); - $allToBeChekcedAND = array('core.delete', 'core.edit.state'); - foreach ($allToBeChekcedAND as $core_permission) - { - // set permissions. - $publishingPerAND[] = "\$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, $core_permission) . "')"; - } - // check if custom tab must be added - if (($_customTabHTML = $this->addCustomTabs( - 15, $nameSingleCode, 1 - )) !== false) - { - $tabs .= $_customTabHTML; - } - // add the AND values to OR - $publishingPerOR[] = '(' . implode(' && ', $publishingPerAND) . ')'; - // now build the complete showhide behaviour for the publishing area - $tabs .= PHP_EOL . PHP_EOL . Indent::_(1) . ""; - // set the default publishing tab - $tabs .= PHP_EOL . Indent::_(1) - . ""; - $tabs .= PHP_EOL . Indent::_(2) - . '
    '; - if ($items_one) - { - $tabs .= PHP_EOL . Indent::_(3) . '
    '; - $tabs .= PHP_EOL . Indent::_(4) - . ""; - $tabs .= PHP_EOL . Indent::_(3) . "
    "; - } - if ($items_two) - { - $tabs .= PHP_EOL . Indent::_(3) . '
    '; - $tabs .= PHP_EOL . Indent::_(4) - . ""; - $tabs .= PHP_EOL . Indent::_(3) . "
    "; - } - $tabs .= PHP_EOL . Indent::_(2) . "
    "; - $tabs .= PHP_EOL . Indent::_(1) - . ""; - $tabs .= PHP_EOL . Indent::_(1) . ""; - // check if custom tab must be added - if (($_customTabHTML = $this->addCustomTabs( - 15, $nameSingleCode, 2 - )) !== false) - { - $tabs .= $_customTabHTML; - } - } - - // make sure we don't load it to a view with the name component (as this will cause conflict with Joomla conventions) - if ($nameSingleCode != 'component' - && CFactory::_('Compiler.Builder.Has.Permissions')->exists($nameSingleCode)) - { - // set permissions tab lang - $tabLangName = $langView . '_PERMISSION'; - // set permissions tab code name - $tabCodeName = 'permissions'; - // add to lang array - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $tabLangName, 'Permissions'); - // set the permissions tab - $tabs .= PHP_EOL . PHP_EOL . Indent::_(1) - . "canDo->get('core.admin')) : ?>"; - $tabs .= PHP_EOL . Indent::_(1) - . ""; - $tabs .= PHP_EOL . Indent::_(2) - . '
    '; - $tabs .= PHP_EOL . Indent::_(3) . '
    '; - $tabs .= PHP_EOL . Indent::_(4) . '
    '; - $tabs .= PHP_EOL . Indent::_(5) . '
    '; - $tabs .= PHP_EOL . Indent::_(5) - . "form->getFieldset('accesscontrol') as \$field): ?>"; - $tabs .= PHP_EOL . Indent::_(6) . "
    "; - $tabs .= PHP_EOL . Indent::_(7) - . "label; echo \$field->input;?>"; - $tabs .= PHP_EOL . Indent::_(6) . "
    "; - $tabs .= PHP_EOL . Indent::_(6) . '
    '; - $tabs .= PHP_EOL . Indent::_(5) . ""; - $tabs .= PHP_EOL . Indent::_(5) . "
    "; - $tabs .= PHP_EOL . Indent::_(4) . "
    "; - $tabs .= PHP_EOL . Indent::_(3) . "
    "; - $tabs .= PHP_EOL . Indent::_(2) . "
    "; - $tabs .= PHP_EOL . Indent::_(1) - . ""; - $tabs .= PHP_EOL . Indent::_(1) . ""; - } - - return $tabs; - } - - protected function addCustomTabs($nr, $name_single, $target) - { - // check if this view is having custom tabs - if (($tabs = CFactory::_('Compiler.Builder.Custom.Tabs')->get($name_single)) !== null - && ArrayHelper::check($tabs)) - { - $html = []; - foreach ($tabs as $customTab) - { - if (ArrayHelper::check($customTab) - && isset($customTab['html'])) - { - if ($customTab['tab'] == $nr - && $customTab['position'] == $target - && isset($customTab['html']) - && StringHelper::check( - $customTab['html'] - )) - { - $html[] = $customTab['html']; - } - } - } - // return if found - if (ArrayHelper::check($html)) - { - return PHP_EOL . implode(PHP_EOL, $html); - } - } - - return false; - } - - public function setFadeInEfect(&$view) - { - // check if we should load the fade in affect - if ($view['settings']->add_fadein == 1) - { - // set view name - $fadein[] = ""; - $fadein[] = "
    component_code_name - . "_loader\" style=\"display: none;\">"; - - return implode(PHP_EOL, $fadein); - } - - return "
    component_code_name . "_loader\">"; - } - - /** - * @param $nameSingleCode - * @param $layoutName - * @param $items - * @param $type - */ - public function setLayout($nameSingleCode, $layoutName, $items, $type) - { - // we check if there is a local override - if (!$this->setLayoutOverride($nameSingleCode, $layoutName, $items)) - { - // first build the layout file - $target = array('admin' => $nameSingleCode); - CFactory::_('Utilities.Structure')->build($target, $type, $layoutName); - // add to front if needed - if (CFactory::_('Config')->lang_target === 'both') - { - $target = array('site' => $nameSingleCode); - CFactory::_('Utilities.Structure')->build($target, $type, $layoutName); - } - if (StringHelper::check($items)) - { - // LAYOUTITEMS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '_' . $layoutName . '|LAYOUTITEMS', $items); - } - else - { - // LAYOUTITEMS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '_' . $layoutName . '|bogus', 'boom'); - } - } - } - - /** - * @param string $nameSingleCode - * @param string $layoutName - * @param string $items - * - * @return boolean true if override was found - */ - protected function setLayoutOverride($nameSingleCode, $layoutName, $items) - { - if (($data = $this->getLayoutOverride($nameSingleCode, $layoutName)) - !== null) - { - // first build the layout file - $target = array('admin' => $nameSingleCode); - CFactory::_('Utilities.Structure')->build($target, 'layoutoverride', $layoutName); - // add to front if needed - if (CFactory::_('Config')->lang_target === 'both') - { - $target = array('site' => $nameSingleCode); - CFactory::_('Utilities.Structure')->build($target, 'layoutoverride', $layoutName); - } - // make sure items is an empty string (should not be needed.. but) - if (!StringHelper::check($items)) - { - $items = ''; - } - // set placeholder - $placeholder = CFactory::_('Placeholder')->active; - $placeholder[Placefix::_h('LAYOUTITEMS')] = $items; - // OVERRIDE_LAYOUT_CODE <<>> - $php_view = (array) explode(PHP_EOL, (string) $data['php_view'] ?? ''); - if (ArrayHelper::check($php_view)) - { - $php_view = PHP_EOL . PHP_EOL . implode(PHP_EOL, $php_view); - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '_' . $layoutName . '|OVERRIDE_LAYOUT_CODE', - CFactory::_('Placeholder')->update( - $php_view, $placeholder - ) - ); - } - else - { - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '_' . $layoutName . '|OVERRIDE_LAYOUT_CODE', ''); - } - // OVERRIDE_LAYOUT_BODY <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '_' . $layoutName . '|OVERRIDE_LAYOUT_BODY', - PHP_EOL . CFactory::_('Placeholder')->update( - $data['html'] ?? '', $placeholder - ) - ); - // OVERRIDE_LAYOUT_HEADER <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '_' . $layoutName . '|OVERRIDE_LAYOUT_HEADER', - (($header = $this->setFileHeader( - 'override.layout', - $layoutName, false) - ) !== false) ? PHP_EOL . PHP_EOL . $header : '' - ); - - // since override was found - return true; - } - - return false; - } - - /** - * @param string $nameSingleCode - * @param string $layoutName - * - * @return array|null the layout data - */ - protected function getLayoutOverride($nameSingleCode, $layoutName): ?array - { - $get_key = null; - // check if there is an override by component name, view name, & layout name - if ($this->setTemplateAndLayoutData( - 'override', $nameSingleCode, false, array(''), - array(CFactory::_('Config')->component_code_name . $nameSingleCode . $layoutName) - )) - { - $get_key = CFactory::_('Config')->component_code_name . $nameSingleCode . $layoutName; - } - // check if there is an override by component name & layout name - elseif ($this->setTemplateAndLayoutData( - 'override', $nameSingleCode, false, array(''), - array(CFactory::_('Config')->component_code_name . $layoutName) - )) - { - $get_key = CFactory::_('Config')->component_code_name . $layoutName; - } - // check if there is an override by view & layout name - elseif ($this->setTemplateAndLayoutData( - 'override', $nameSingleCode, false, array(''), - array($nameSingleCode . $layoutName) - )) - { - $get_key = $nameSingleCode . $layoutName; - } - // check if there is an override by layout name (global layout) - elseif ($this->setTemplateAndLayoutData( - 'override', $nameSingleCode, false, array(''), - array($layoutName) - )) - { - $get_key = $layoutName; - } - - // check if we have a get key - if ($get_key) - { - $data = CFactory::_('Compiler.Builder.Layout.Data')-> - get(CFactory::_('Config')->build_target . '.' . $get_key); - - if ($data === null) - { - var_dump(CFactory::_('Config')->build_target . '.' . $get_key); - var_dump('admin.' .$get_key); - var_dump(CFactory::_('Compiler.Builder.Layout.Data')->get('admin.' .$get_key)); - var_dump('site.' .$get_key); - var_dump(CFactory::_('Compiler.Builder.Layout.Data')->get('site.' . $get_key)); - var_dump('both.' .$get_key); - var_dump(CFactory::_('Compiler.Builder.Layout.Data')->get('both.' . $get_key)); - exit; - } - // remove since we will add the layout now - if (CFactory::_('Config')->lang_target === 'both') - { - CFactory::_('Compiler.Builder.Layout.Data')-> - remove('admin.' . $get_key); - CFactory::_('Compiler.Builder.Layout.Data')-> - remove('site.' . $get_key); - CFactory::_('Compiler.Builder.Layout.Data')-> - remove('both.' . $get_key); - } - else - { - CFactory::_('Compiler.Builder.Layout.Data')-> - remove(CFactory::_('Config')->build_target . '.' . $get_key); - } - - return $data; - } - - return null; - } - - /** - * @param $args - */ - public function setLinkedView($args) - { - /** - * @var $viewId - * @var $nameSingleCode - * @var $codeName - * @var $layoutCodeName - * @var $key - * @var $parentKey - * @var $addNewButon - */ - extract($args, EXTR_PREFIX_SAME, "oops"); - $single = ''; - $name_list_code = ''; - foreach (CFactory::_('Component')->get('admin_views') as $array) - { - if ($array['adminview'] == $viewId) - { - $name_single_code = $array['settings']->name_single_code; - $name_list_code = $array['settings']->name_list_code; - break; - } - } - if (StringHelper::check($name_single_code) - && StringHelper::check($name_list_code)) - { - $head = $this->setListHeadLinked( - $name_single_code, $name_list_code, $addNewButon, - $nameSingleCode - ); - $body = $this->setListBodyLinked( - $name_single_code, $name_list_code, $nameSingleCode - ); - $functionName = StringHelper::safe($codeName, 'F'); - // LAYOUTITEMSTABLE <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '_' . $layoutCodeName . '|LAYOUTITEMSTABLE', - $head . $body - ); - // LAYOUTITEMSHEADER <<>> - $headerscript = '//' . Line::_(__Line__, __Class__) - . ' set the edit URL'; - $headerscript .= PHP_EOL . '$edit = "index.php?option=com_' - . CFactory::_('Config')->component_code_name . '&view=' . $name_list_code - . '&task=' - . $name_single_code . '.edit";'; - $headerscript .= PHP_EOL . '//' . Line::_(__Line__, __Class__) - . ' set a return value'; - $headerscript .= PHP_EOL - . '$return = ($id) ? "index.php?option=com_' - . CFactory::_('Config')->component_code_name . '&view=' . $nameSingleCode - . '&layout=edit&id=" . $id : "";'; - $headerscript .= PHP_EOL . '//' . Line::_(__Line__, __Class__) - . ' check for a return value'; - $headerscript .= PHP_EOL - . '$jinput = JFactory::getApplication()->input;'; - $headerscript .= PHP_EOL - . "if (\$_return = \$jinput->get('return', null, 'base64'))"; - $headerscript .= PHP_EOL . '{'; - $headerscript .= PHP_EOL . Indent::_(1) - . '$return .= "&return=" . $_return;'; - $headerscript .= PHP_EOL . '}'; - $headerscript .= PHP_EOL . '//' . Line::_(__Line__, __Class__) - . ' check if return value was set'; - $headerscript .= PHP_EOL . 'if (' - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper::checkString($return))'; - $headerscript .= PHP_EOL . '{'; - $headerscript .= PHP_EOL . Indent::_(1) . '//' . Line::_( - __LINE__,__CLASS__ - ) . ' set the referral values'; - $headerscript .= PHP_EOL . Indent::_(1) . '$ref = ($id) ? "&ref=' - . $nameSingleCode - . '&refid=" . $id . "&return=" . urlencode(base64_encode($return)) : "&return=" . urlencode(base64_encode($return));'; - $headerscript .= PHP_EOL . '}'; - $headerscript .= PHP_EOL . 'else'; - $headerscript .= PHP_EOL . '{'; - $headerscript .= PHP_EOL . Indent::_(1) . '$ref = ($id) ? "&ref=' - . $nameSingleCode . '&refid=" . $id : "";'; - $headerscript .= PHP_EOL . '}'; - if ($addNewButon > 0) - { - // add the link for new - if ($addNewButon == 1 || $addNewButon == 2) - { - $headerscript .= PHP_EOL . '//' . Line::_(__Line__, __Class__) - . ' set the create new URL'; - $headerscript .= PHP_EOL . '$new = "index.php?option=com_' - . CFactory::_('Config')->component_code_name . '&view=' . $name_list_code - . '&task=' - . $name_single_code . '.edit" . $ref;'; - } - // and the link for close and new - if ($addNewButon == 2 || $addNewButon == 3) - { - $headerscript .= PHP_EOL . '//' . Line::_(__Line__, __Class__) - . ' set the create new and close URL'; - $headerscript .= PHP_EOL - . '$close_new = "index.php?option=com_' - . CFactory::_('Config')->component_code_name . '&view=' . $name_list_code - . '&task=' - . $name_single_code . '.edit";'; - } - $headerscript .= PHP_EOL . '//' . Line::_(__Line__, __Class__) - . ' load the action object'; - $headerscript .= PHP_EOL . '$can = ' - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper::getActions(' . "'" - . $name_single_code . "'" - . ');'; - } - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '_' . $layoutCodeName . '|LAYOUTITEMSHEADER', - $headerscript - ); - // LINKEDVIEWITEMS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->add($nameSingleCode . '|LINKEDVIEWITEMS', - PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Get Linked view data" . PHP_EOL . Indent::_(2) - . "\$this->" . $codeName . " = \$this->get('" . $functionName - . "');", false - ); - // LINKEDVIEWTABLESCRIPTS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|LINKEDVIEWTABLESCRIPTS', $this->setFootableScripts()); - if (strpos((string) $parentKey, '-R>') !== false - || strpos((string) $parentKey, '-A>') !== false) - { - list($parent_key) = explode('-', (string) $parentKey); - } - elseif (strpos((string) $parentKey, '-OR>') !== false) - { - // this is not good... (TODO) - $parent_keys = explode('-OR>', (string) $parentKey); - } - else - { - $parent_key = $parentKey; - } - - if (strpos((string) $key, '-R>') !== false || strpos((string) $key, '-A>') !== false) - { - list($_key) = explode('-', (string) $key); - } - elseif (strpos((string) $key, '-OR>') !== false) - { - $_key = str_replace('-OR>', '', (string) $key); - } - else - { - $_key = $key; - } - // LINKEDVIEWGLOBAL <<>> - if (isset($parent_keys) - && ArrayHelper::check( - $parent_keys - )) - { - $globalKey = array(); - foreach ($parent_keys as $parent_key) - { - $globalKey[$parent_key] - = StringHelper::safe( - $_key . $this->uniquekey(4) - ); - CFactory::_('Compiler.Builder.Content.Multi')->add($nameSingleCode . '|LINKEDVIEWGLOBAL', - PHP_EOL . Indent::_(2) . "\$this->" - . $globalKey[$parent_key] . " = \$item->" . $parent_key . ";", false - ); - } - } - else - { - // set the global key - $globalKey = StringHelper::safe( - $_key . $this->uniquekey(4) - ); - CFactory::_('Compiler.Builder.Content.Multi')->add($nameSingleCode . '|LINKEDVIEWGLOBAL', - PHP_EOL . Indent::_(2) . "\$this->" . $globalKey - . " = \$item->" . $parent_key . ";", false - ); - } - // LINKEDVIEWMETHODS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->add($nameSingleCode . '|LINKEDVIEWMETHODS', - $this->setListQueryLinked( - $name_single_code, $name_list_code, $functionName, $key, $_key, - $parentKey, - $parent_key, $globalKey - ), false - ); - } - else - { - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '_' . $layoutCodeName . '|LAYOUTITEMSTABLE', - 'oops! error.....' - ); - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '_' . $layoutCodeName . '|LAYOUTITEMSHEADER', ''); - } - } - - /** - * @param bool $init - * - * @return string - */ - public function setFootableScripts($init = true) - { - $footable_version = CFactory::_('Config')->get('footable_version', 2); - if (2 == $footable_version) // loading version 2 - { - $foo = PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Add the CSS for Footable."; - $foo .= PHP_EOL . Indent::_(2) - . "JHtml::_('stylesheet', 'media/com_" - . CFactory::_('Config')->component_code_name - . "/footable-v2/css/footable.core.min.css', ['version' => 'auto']);"; - $foo .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Use the Metro Style"; - $foo .= PHP_EOL . Indent::_(2) - . "if (!isset(\$this->fooTableStyle) || 0 == \$this->fooTableStyle)"; - $foo .= PHP_EOL . Indent::_(2) . "{"; - $foo .= PHP_EOL . Indent::_(3) - . "JHtml::_('stylesheet', 'media/com_" - . CFactory::_('Config')->component_code_name - . "/footable-v2/css/footable.metro.min.css', ['version' => 'auto']);"; - $foo .= PHP_EOL . Indent::_(2) . "}"; - $foo .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Use the Legacy Style."; - $foo .= PHP_EOL . Indent::_(2) - . "elseif (isset(\$this->fooTableStyle) && 1 == \$this->fooTableStyle)"; - $foo .= PHP_EOL . Indent::_(2) . "{"; - $foo .= PHP_EOL . Indent::_(3) - . "JHtml::_('stylesheet', 'media/com_" - . CFactory::_('Config')->component_code_name - . "/footable-v2/css/footable.standalone.min.css', ['version' => 'auto']);"; - $foo .= PHP_EOL . Indent::_(2) . "}"; - $foo .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Add the JavaScript for Footable"; - $foo .= PHP_EOL . Indent::_(2) - . "JHtml::_('script', 'media/com_" - . CFactory::_('Config')->component_code_name . "/footable-v2/js/footable.js', ['version' => 'auto']);"; - $foo .= PHP_EOL . Indent::_(2) - . "JHtml::_('script', 'media/com_" - . CFactory::_('Config')->component_code_name - . "/footable-v2/js/footable.sort.js', ['version' => 'auto']);"; - $foo .= PHP_EOL . Indent::_(2) - . "JHtml::_('script', 'media/com_" - . CFactory::_('Config')->component_code_name - . "/footable-v2/js/footable.filter.js', ['version' => 'auto']);"; - $foo .= PHP_EOL . Indent::_(2) - . "JHtml::_('script', 'media/com_" - . CFactory::_('Config')->component_code_name - . "/footable-v2/js/footable.paginate.js', ['version' => 'auto']);"; - if ($init) - { - $foo .= PHP_EOL . PHP_EOL . Indent::_(2) - . '$footable = "jQuery(document).ready(function() { jQuery(function () { jQuery(' - . "'.footable'" . ').footable(); }); jQuery(' - . "'.nav-tabs'" . ').on(' . "'click'" . ', ' . "'li'" - . ', function() { setTimeout(tableFix, 10); }); }); function tableFix() { jQuery(' - . "'.footable'" . ').trigger(' . "'footable_resize'" - . '); }";'; - $foo .= PHP_EOL . Indent::_(2) - . "\$this->document->addScriptDeclaration(\$footable);" - . PHP_EOL; - } - } - elseif (3 == $footable_version) // loading version 3 - { - - $foo = PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Add the CSS for Footable"; - $foo .= PHP_EOL . Indent::_(2) - . "\$this->document->addStyleSheet('https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css');"; - $foo .= PHP_EOL . Indent::_(2) - . "JHtml::_('stylesheet', 'media/com_" - . CFactory::_('Config')->component_code_name - . "/footable-v3/css/footable.standalone.min.css', ['version' => 'auto']);"; - $foo .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Add the JavaScript for Footable (adding all functions)"; - $foo .= PHP_EOL . Indent::_(2) - . "JHtml::_('script', 'media/com_" - . CFactory::_('Config')->component_code_name - . "/footable-v3/js/footable.min.js', ['version' => 'auto']);"; - if ($init) - { - $foo .= PHP_EOL . PHP_EOL . Indent::_(2) - . '$footable = "jQuery(document).ready(function() { jQuery(function () { jQuery(' - . "'.footable'" . ').footable();});});";'; - $foo .= PHP_EOL . Indent::_(2) - . "\$this->document->addScriptDeclaration(\$footable);" - . PHP_EOL; - } - } - - return $foo; - } - - /** - * set the list body of the linked admin view - * - * @param string $nameSingleCode - * @param string $nameListCode - * @param string $refview - * - * @return string - */ - public function setListBodyLinked($nameSingleCode, $nameListCode, - $refview - ) - { - if (($items = CFactory::_('Compiler.Builder.Lists')->get($nameListCode)) !== null) - { - // component helper name - $Helper = CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper'; - $footable_version = CFactory::_('Config')->get('footable_version', 2); - // make sure the custom links are only added once - $firstTimeBeingAdded = true; - $counter = 0; - // add the default - $body = PHP_EOL . ""; - $body .= PHP_EOL . " \$item): ?>"; - $body .= PHP_EOL . Indent::_(1) . "authorise('core.manage', 'com_checkin') || \$item->checked_out == \$user->id || \$item->checked_out == 0;"; - $body .= PHP_EOL . Indent::_(2) - . "\$userChkOut = JFactory::getUser(\$item->checked_out);"; - $body .= PHP_EOL . Indent::_(2) . "\$canDo = " . $Helper - . "::getActions('" . $nameSingleCode . "',\$item,'" - . $nameListCode . "');"; - $body .= PHP_EOL . Indent::_(1) . "?>"; - $body .= PHP_EOL . Indent::_(1) . ''; - // check if this view has fields that should not be escaped - $doNotEscape = false; - if (CFactory::_('Compiler.Builder.Do.Not.Escape')->exists($nameListCode)) - { - $doNotEscape = true; - } - // start adding the dynamic - foreach ($items as $item) - { - // check if target is linked list view - if (1 == $item['target'] || 4 == $item['target']) - { - // set the ref - $ref = ''; - // set some defaults - $customAdminViewButtons = ''; - // set the item row - $itemRow = $this->getListItemBuilder( - $item, $nameSingleCode, $nameListCode, $itemClass, - $doNotEscape, false, $ref, - '$displayData->escape', '$user', $refview - ); - // check if buttons was aready added - if ($firstTimeBeingAdded) // TODO we must improve this to allow more items to be targeted instead of just the first item :) - { - // get custom admin view buttons - $customAdminViewButtons - = $this->getCustomAdminViewButtons( - $nameListCode, $ref - ); - // make sure the custom admin view buttons are only added once - $firstTimeBeingAdded = false; - } - // add row to body - $body .= PHP_EOL . Indent::_(2) . ""; - $body .= $itemRow; - $body .= $customAdminViewButtons; - $body .= PHP_EOL . Indent::_(2) . ""; - // increment counter - $counter++; - } - } - $data_value = (3 == $footable_version) ? 'data-sort-value' - : 'data-value'; - - // add the defaults - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.published')) - { - $counter++; - // add the defaults - $body .= PHP_EOL . Indent::_(2) - . "published == 1): ?>"; - $body .= PHP_EOL . Indent::_(3) . ''; - $body .= PHP_EOL . Indent::_(4) - . 'langPrefix . "_PUBLISHED'" - . '); ?>">'; - $body .= PHP_EOL . Indent::_(5) . 'langPrefix . "_PUBLISHED'" . '); ?>'; - $body .= PHP_EOL . Indent::_(4) . ''; - $body .= PHP_EOL . Indent::_(3) . ''; - - $body .= PHP_EOL . Indent::_(2) - . "published == 0): ?>"; - $body .= PHP_EOL . Indent::_(3) . ''; - $body .= PHP_EOL . Indent::_(4) - . 'langPrefix . "_INACTIVE'" - . '); ?>">'; - $body .= PHP_EOL . Indent::_(5) . 'langPrefix . "_INACTIVE'" . '); ?>'; - $body .= PHP_EOL . Indent::_(4) . ''; - $body .= PHP_EOL . Indent::_(3) . ''; - - $body .= PHP_EOL . Indent::_(2) - . "published == 2): ?>"; - $body .= PHP_EOL . Indent::_(3) . ''; - $body .= PHP_EOL . Indent::_(4) - . 'langPrefix . "_ARCHIVED'" - . '); ?>">'; - $body .= PHP_EOL . Indent::_(5) . 'langPrefix . "_ARCHIVED'" . '); ?>'; - $body .= PHP_EOL . Indent::_(4) . ''; - $body .= PHP_EOL . Indent::_(3) . ''; - - $body .= PHP_EOL . Indent::_(2) - . "published == -2): ?>"; - $body .= PHP_EOL . Indent::_(3) . ''; - $body .= PHP_EOL . Indent::_(4) - . 'langPrefix . "_TRASHED'" - . '); ?>">'; - $body .= PHP_EOL . Indent::_(5) . 'langPrefix . "_TRASHED'" . '); ?>'; - $body .= PHP_EOL . Indent::_(4) . ''; - $body .= PHP_EOL . Indent::_(3) . ''; - $body .= PHP_EOL . Indent::_(2) . ''; - } - - // add the defaults - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.id')) - { - $counter++; - $body .= PHP_EOL . Indent::_(2) - . ''; - $body .= PHP_EOL . Indent::_(3) . "id; ?>"; - $body .= PHP_EOL . Indent::_(2) . ""; - } - $body .= PHP_EOL . Indent::_(1) . ""; - $body .= PHP_EOL . ""; - $body .= PHP_EOL . ""; - if (2 == $footable_version) - { - $body .= PHP_EOL . ''; - $body .= PHP_EOL . Indent::_(1) . ''; - $body .= PHP_EOL . Indent::_(2) . ''; - $body .= PHP_EOL . Indent::_(3) - . ''; - $body .= PHP_EOL . Indent::_(2) . ''; - $body .= PHP_EOL . Indent::_(1) . ''; - $body .= PHP_EOL . ''; - } - $body .= PHP_EOL . ''; - $body .= PHP_EOL . ''; - $body .= PHP_EOL . Indent::_(1) - . '
    '; - $body .= PHP_EOL . Indent::_(2) . ''; - $body .= PHP_EOL . Indent::_(1) . '
    '; - $body .= PHP_EOL . ''; - - // return the build - return $body; - } - - return ''; - } - - /** - * set the list body table head linked admin view - * - * @param string $nameSingleCode - * @param string $nameListCode - * @param bool $addNewButon - * @param string $refview - * - * @return string - */ - public function setListHeadLinked($nameSingleCode, $nameListCode, - $addNewButon, $refview - ) - { - if (($items = CFactory::_('Compiler.Builder.Lists')->get($nameListCode)) !== null) - { - // component helper name - $Helper = CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper'; - $head = ''; - $footable_version = CFactory::_('Config')->get('footable_version', 2); - // only add new button if set - if ($addNewButon > 0) - { - // set permissions. - $accessCheck = "\$can->get('" . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.create') . "')"; - // add a button for new - $head = ''; - // make group button if needed - $tabB = ""; - if ($addNewButon == 2) - { - $head .= PHP_EOL . Indent::_(1) . '
    '; - $tabB = Indent::_(1); - } - // add the new buttons - if ($addNewButon == 1 || $addNewButon == 2) - { - $head .= PHP_EOL . $tabB . Indent::_(1) - . ' langPrefix . "_NEW'" - . '); ?>'; - } - // add the close and new button - if ($addNewButon == 2 || $addNewButon == 3) - { - $head .= PHP_EOL . $tabB . Indent::_(1) - . ' langPrefix . "_CLOSE_NEW'" - . '); ?>'; - } - // close group button if needed - if ($addNewButon == 2) - { - $head .= PHP_EOL . Indent::_(1) . '


    '; - } - else - { - $head .= '

    '; - } - $head .= PHP_EOL . '' . PHP_EOL; - } - $head .= ''; - // set the style for V2 - $metro_blue = (2 == $footable_version) ? ' metro-blue' : ''; - // set the toggle for V3 - $toggle = (3 == $footable_version) - ? ' data-show-toggle="true" data-toggle-column="first"' : ''; - // set paging - $paging = (2 == $footable_version) - ? ' data-page-size="20" data-filter="#filter_' . $nameListCode - . '"' - : ' data-sorting="true" data-paging="true" data-paging-size="20" data-filtering="true"'; - // add html fix for V3 - $htmlFix = (3 == $footable_version) - ? ' data-type="html" data-sort-use="text"' : ''; - $head .= PHP_EOL . ''; - $head .= PHP_EOL . ""; - // main lang prefix - $langView = $this->langPrefix . '_' - . StringHelper::safe($nameSingleCode, 'U'); - // set status lang - $statusLangName = $langView . '_STATUS'; - // set id lang - $idLangName = $langView . '_ID'; - // make sure only first link is used as togeler - $firstLink = true; - // add to lang array - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $statusLangName, 'Status'); - // add to lang array - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $idLangName, 'Id'); - $head .= PHP_EOL . Indent::_(1) . ""; - // set controller for data hiding options - $controller = 1; - // build the dynamic fields - foreach ($items as $item) - { - // check if target is linked list view - if (1 == $item['target'] || 4 == $item['target']) - { - // check if we have an over-ride - if (($list_head_override = CFactory::_('Compiler.Builder.List.Head.Override')-> - get($nameListCode . '.' . (int) $item['id'])) !== null) - { - $item['lang'] = $list_head_override; - } - $setin = (2 == $footable_version) - ? ' data-hide="phone"' : ' data-breakpoints="xs sm"'; - if ($controller > 3) - { - $setin = (2 == $footable_version) - ? ' data-hide="phone,tablet"' - : ' data-breakpoints="xs sm md"'; - } - - if ($controller > 6) - { - $setin = (2 == $footable_version) - ? ' data-hide="all"' : ' data-breakpoints="all"'; - } - - if ($item['link'] && $firstLink) - { - $setin = (2 == $footable_version) - ? ' data-toggle="true"' : ''; - $firstLink = false; - } - $head .= PHP_EOL . Indent::_(2) . ""; - $head .= PHP_EOL . Indent::_(3) . ""; - $head .= PHP_EOL . Indent::_(2) . ""; - $controller++; - } - } - // set some V3 attr - $data_hide = (2 == $footable_version) - ? 'data-hide="phone,tablet"' : 'data-breakpoints="xs sm md"'; - // add the defaults - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.published')) - { - $head .= PHP_EOL . Indent::_(2) . '"; - } - - // add the defaults - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.id')) - { - $data_type = (2 == $footable_version) - ? 'data-type="numeric"' - : 'data-type="number"'; - $head .= PHP_EOL . Indent::_(2) . '"; - } - $head .= PHP_EOL . Indent::_(1) . ""; - $head .= PHP_EOL . ""; - - return $head; - } - - return ''; - } - - /** - * @param $nameSingleCode - * @param $nameListCode - * @param $functionName - * @param $key - * @param $_key - * @param $parentKey - * @param $parent_key - * @param $globalKey - * - * @return string - */ - public function setListQueryLinked($nameSingleCode, $nameListCode, - $functionName, $key, $_key, $parentKey, $parent_key, $globalKey) - { - // check if this view has category added - if (CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.code")) - { - $categoryCodeName = CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.code"); - $addCategory = true; - } - else - { - $addCategory = false; - } - $query = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $query .= PHP_EOL . Indent::_(1) . " * Method to get list data."; - $query .= PHP_EOL . Indent::_(1) . " *"; - $query .= PHP_EOL . Indent::_(1) - . " * @return mixed An array of data items on success, false on failure."; - $query .= PHP_EOL . Indent::_(1) . " */"; - $query .= PHP_EOL . Indent::_(1) . "public function get" . $functionName - . "()"; - $query .= PHP_EOL . Indent::_(1) . "{"; - // setup the query - $query .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Get the user object."; - $query .= PHP_EOL . Indent::_(2) . "\$user = JFactory::getUser();"; - $query .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Create a new query object."; - $query .= PHP_EOL . Indent::_(2) . "\$db = JFactory::getDBO();"; - $query .= PHP_EOL . Indent::_(2) . "\$query = \$db->getQuery(true);"; - $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Select some fields"; - $query .= PHP_EOL . Indent::_(2) . "\$query->select('a.*');"; - // add the category - if ($addCategory) - { - $query .= PHP_EOL . Indent::_(2) - . "\$query->select(\$db->quoteName('c.title','category_title'));"; - } - $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " From the " . CFactory::_('Config')->component_code_name . "_" - . $nameSingleCode - . " table"; - $query .= PHP_EOL . Indent::_(2) . "\$query->from(\$db->quoteName('#__" - . CFactory::_('Config')->component_code_name . "_" . $nameSingleCode . "', 'a'));"; - // add the category - if ($addCategory) - { - $query .= PHP_EOL . Indent::_(2) - . "\$query->join('LEFT', \$db->quoteName('#__categories', 'c') . ' ON (' . \$db->quoteName('a." - . $categoryCodeName - . "') . ' = ' . \$db->quoteName('c.id') . ')');"; - } - // add custom filtering php - $query .= CFactory::_('Customcode.Dispenser')->get( - 'php_getlistquery', $nameSingleCode, PHP_EOL . PHP_EOL - ); - // add the custom fields query - $query .= $this->setCustomQuery($nameListCode, $nameSingleCode); - if (StringHelper::check($globalKey) && $key - && strpos( - (string) $key, '-R>' - ) === false - && strpos((string) $key, '-A>') === false - && strpos((string) $key, '-OR>') === false - && $parentKey - && strpos((string) $parentKey, '-R>') === false - && strpos((string) $parentKey, '-A>') === false - && strpos((string) $parentKey, '-OR>') === false) - { - $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Filter by " . $globalKey . " global."; - $query .= PHP_EOL . Indent::_(2) . "\$" . $globalKey . " = \$this->" - . $globalKey . ";"; - $query .= PHP_EOL . Indent::_(2) . "if (is_numeric(\$" . $globalKey - . " ))"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) . "\$query->where('a." . $key - . " = ' . (int) \$" . $globalKey . " );"; - $query .= PHP_EOL . Indent::_(2) . "}"; - $query .= PHP_EOL . Indent::_(2) . "elseif (is_string(\$" - . $globalKey . "))"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) . "\$query->where('a." . $key - . " = ' . \$db->quote(\$" . $globalKey . "));"; - $query .= PHP_EOL . Indent::_(2) . "}"; - $query .= PHP_EOL . Indent::_(2) . "else"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) . "\$query->where('a." . $key - . " = -5');"; - $query .= PHP_EOL . Indent::_(2) . "}"; - } - elseif (strpos((string) $parentKey, '-OR>') !== false - || strpos((string) $key, '-OR>') !== false) - { - // get both strings - if (strpos((string) $key, '-OR>') !== false) - { - $ORarray = explode('-OR>', (string) $key); - } - else - { - $ORarray = array($key); - } - // make sure we have an array - if (!ArrayHelper::check($globalKey)) - { - $globalKey = array($globalKey); - } - // now load the query (this may be to much... but hey let it write the code :) - foreach ($globalKey as $_globalKey) - { - // now build the query - $ORquery = array('s' => array(), 'i' => array()); - foreach ($ORarray as $ORkey) - { - $ORquery['i'][] = "a." . $ORkey . " = ' . (int) \$" - . $_globalKey; - $ORquery['s'][] = "a." . $ORkey . " = ' . \$db->quote(\$" - . $_globalKey . ")"; - } - $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Filter by " . $_globalKey - . " global."; - $query .= PHP_EOL . Indent::_(2) . "\$" . $_globalKey - . " = \$this->" . $_globalKey . ";"; - $query .= PHP_EOL . Indent::_(2) . "if (is_numeric(\$" - . $_globalKey . " ))"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) . "\$query->where('" . implode( - " . ' OR ", $ORquery['i'] - ) . ", ' OR');"; - $query .= PHP_EOL . Indent::_(2) . "}"; - $query .= PHP_EOL . Indent::_(2) . "elseif (is_string(\$" - . $_globalKey . "))"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) . "\$query->where('" . implode( - " . ' OR ", $ORquery['s'] - ) . ", ' OR');"; - $query .= PHP_EOL . Indent::_(2) . "}"; - $query .= PHP_EOL . Indent::_(2) . "else"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) . "\$query->where('a." . $ORkey - . " = -5');"; - $query .= PHP_EOL . Indent::_(2) . "}"; - } - } - if (CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode)) - { - $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Join over the asset groups."; - $query .= PHP_EOL . Indent::_(2) - . "\$query->select('ag.title AS access_level');"; - $query .= PHP_EOL . Indent::_(2) - . "\$query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');"; - // check if the access field was over ridden - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.access')) - { - // component helper name - $Helper = CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper'; - // load the access filter query code - $query .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) - . " Filter by access level."; - $query .= PHP_EOL . Indent::_(2) - . "\$_access = \$this->getState('filter.access');"; - $query .= PHP_EOL . Indent::_(2) - . "if (\$_access && is_numeric(\$_access))"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) - . "\$query->where('a.access = ' . (int) \$_access);"; - $query .= PHP_EOL . Indent::_(2) . "}"; - $query .= PHP_EOL . Indent::_(2) . "elseif (" - . $Helper . "::checkArray(\$_access))"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) - . " Secure the array for the query"; - $query .= PHP_EOL . Indent::_(3) - . "\$_access = ArrayHelper::toInteger(\$_access);"; - $query .= PHP_EOL . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) . " Filter by the Access Array."; - $query .= PHP_EOL . Indent::_(3) - . "\$query->where('a.access IN (' . implode(',', \$_access) . ')');"; - $query .= PHP_EOL . Indent::_(2) . "}"; - } - // TODO the following will fight against the above access filter - $query .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Implement View Level Access"; - $query .= PHP_EOL . Indent::_(2) - . "if (!\$user->authorise('core.options', 'com_" - . CFactory::_('Config')->component_code_name . "'))"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) - . "\$groups = implode(',', \$user->getAuthorisedViewLevels());"; - $query .= PHP_EOL . Indent::_(3) - . "\$query->where('a.access IN (' . \$groups . ')');"; - $query .= PHP_EOL . Indent::_(2) . "}"; - } - // add dynamic ordering (Linked view) - if (isset($this->viewsDefaultOrdering[$nameListCode]) - && $this->viewsDefaultOrdering[$nameListCode]['add_linked_ordering'] - == 1) - { - foreach ( - $this->viewsDefaultOrdering[$nameListCode]['linked_ordering_fields'] - as $order_field - ) - { - if (($order_field_name = CFactory::_('Field.Database.Name')->get( - $nameListCode, $order_field['field'] - // We Removed This 'listJoinBuilder' as targetArea - // we will keep an eye on this - )) !== false) - { - // default ordering is by publish and ordering - $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_( - __LINE__,__CLASS__ - ) . " Order the results by ordering"; - $query .= PHP_EOL . Indent::_(2) - . "\$query->order('" - . $order_field_name . " " . $order_field['direction'] - . "');"; - } - } - } - else - { - // default ordering is by publish and ordering - $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Order the results by ordering"; - $query .= PHP_EOL . Indent::_(2) - . "\$query->order('a.published ASC');"; - $query .= PHP_EOL . Indent::_(2) - . "\$query->order('a.ordering ASC');"; - } - $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Load the items"; - $query .= PHP_EOL . Indent::_(2) . "\$db->setQuery(\$query);"; - $query .= PHP_EOL . Indent::_(2) . "\$db->execute();"; - $query .= PHP_EOL . Indent::_(2) . "if (\$db->getNumRows())"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) . "\$items = \$db->loadObjectList();"; - // add the fixing strings method - $query .= $this->setGetItemsMethodStringFix( - $nameSingleCode, $nameListCode, - CFactory::_('Compiler.Builder.Content.One')->get('Component'), - Indent::_(1) - ); - // add translations - $query .= $this->setSelectionTranslationFix( - $nameListCode, - CFactory::_('Compiler.Builder.Content.One')->get('Component'), - Indent::_(1) - ); - // filter by child repetable field values - if (StringHelper::check($globalKey) && $key - && strpos( - (string) $key, '-R>' - ) !== false - && strpos((string) $key, '-A>') === false) - { - list($field, $target) = explode('-R>', (string) $key); - $query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Filter by " . $globalKey . " in this Repetable Field"; - $query .= PHP_EOL . Indent::_(3) . "if (" - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkArray(\$items) && isset(\$this->" - . $globalKey . "))"; - $query .= PHP_EOL . Indent::_(3) . "{"; - $query .= PHP_EOL . Indent::_(4) - . "foreach (\$items as \$nr => &\$item)"; - $query .= PHP_EOL . Indent::_(4) . "{"; - $query .= PHP_EOL . Indent::_(5) . "if (isset(\$item->" . $field - . ") && " . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkJson(\$item->" . $field . "))"; - $query .= PHP_EOL . Indent::_(5) . "{"; - $query .= PHP_EOL . Indent::_(6) - . "\$tmpArray = json_decode(\$item->" . $field . ",true);"; - $query .= PHP_EOL . Indent::_(6) . "if (!isset(\$tmpArray['" - . $target . "']) || !" . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkArray(\$tmpArray['" - . $target . "']) || !in_array(\$this->" . $globalKey - . ", \$tmpArray['" . $target . "']))"; - $query .= PHP_EOL . Indent::_(6) . "{"; - $query .= PHP_EOL . Indent::_(7) . "unset(\$items[\$nr]);"; - $query .= PHP_EOL . Indent::_(7) . "continue;"; - $query .= PHP_EOL . Indent::_(6) . "}"; - $query .= PHP_EOL . Indent::_(5) . "}"; - $query .= PHP_EOL . Indent::_(5) . "else"; - $query .= PHP_EOL . Indent::_(5) . "{"; - $query .= PHP_EOL . Indent::_(6) . "unset(\$items[\$nr]);"; - $query .= PHP_EOL . Indent::_(6) . "continue;"; - $query .= PHP_EOL . Indent::_(5) . "}"; - $query .= PHP_EOL . Indent::_(4) . "}"; - $query .= PHP_EOL . Indent::_(3) . "}"; - $query .= PHP_EOL . Indent::_(3) . "else"; - $query .= PHP_EOL . Indent::_(3) . "{"; - $query .= PHP_EOL . Indent::_(4) . "return false;"; - $query .= PHP_EOL . Indent::_(3) . "}"; - } - // filter by child array field values - if (StringHelper::check($globalKey) && $key - && strpos( - (string) $key, '-R>' - ) === false - && strpos((string) $key, '-A>') !== false) - { - $query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Filter by " . $globalKey . " Array Field"; - $query .= PHP_EOL . Indent::_(3) . "\$" . $globalKey . " = \$this->" - . $globalKey . ";"; - $query .= PHP_EOL . Indent::_(3) . "if (" - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkArray(\$items) && \$" . $globalKey - . ")"; - $query .= PHP_EOL . Indent::_(3) . "{"; - $query .= PHP_EOL . Indent::_(4) - . "foreach (\$items as \$nr => &\$item)"; - $query .= PHP_EOL . Indent::_(4) . "{"; - list($bin, $target) = explode('-A>', (string) $key); - if (StringHelper::check($target)) - { - $query .= PHP_EOL . Indent::_(5) . "if (isset(\$item->" . $target - . ") && " . CFactory::_('Compiler.Builder.Content.One')->get('Component') - . "Helper::checkJson(\$item->" . $target . "))"; - $query .= PHP_EOL . Indent::_(5) . "{"; - $query .= PHP_EOL . Indent::_(6) . "\$item->" . $target - . " = json_decode(\$item->" . $target . ", true);"; - $query .= PHP_EOL . Indent::_(5) . "}"; - $query .= PHP_EOL . Indent::_(5) . "elseif (!isset(\$item->" - . $target . ") || !" . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkArray(\$item->" - . $target . "))"; - $query .= PHP_EOL . Indent::_(5) . "{"; - $query .= PHP_EOL . Indent::_(6) . "unset(\$items[\$nr]);"; - $query .= PHP_EOL . Indent::_(6) . "continue;"; - $query .= PHP_EOL . Indent::_(5) . "}"; - $query .= PHP_EOL . Indent::_(5) . "if (!in_array(\$" - . $globalKey . ",\$item->" . $target . "))"; - } - else - { - $query .= PHP_EOL . Indent::_(5) . "if (isset(\$item->" . $_key . ") && " - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkJson(\$item->" . $_key . "))"; - $query .= PHP_EOL . Indent::_(5) . "{"; - $query .= PHP_EOL . Indent::_(6) . "\$item->" . $_key - . " = json_decode(\$item->" . $_key . ", true);"; - $query .= PHP_EOL . Indent::_(5) . "}"; - $query .= PHP_EOL . Indent::_(5) . "elseif (!isset(\$item->" - . $_key . ") || !" . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkArray(\$item->" - . $_key . "))"; - $query .= PHP_EOL . Indent::_(5) . "{"; - $query .= PHP_EOL . Indent::_(6) . "unset(\$items[\$nr]);"; - $query .= PHP_EOL . Indent::_(6) . "continue;"; - $query .= PHP_EOL . Indent::_(5) . "}"; - $query .= PHP_EOL . Indent::_(5) . "if (!in_array(\$" - . $globalKey . ",\$item->" . $_key . "))"; - } - $query .= PHP_EOL . Indent::_(5) . "{"; - $query .= PHP_EOL . Indent::_(6) . "unset(\$items[\$nr]);"; - $query .= PHP_EOL . Indent::_(6) . "continue;"; - $query .= PHP_EOL . Indent::_(5) . "}"; - $query .= PHP_EOL . Indent::_(4) . "}"; - $query .= PHP_EOL . Indent::_(3) . "}"; - $query .= PHP_EOL . Indent::_(3) . "else"; - $query .= PHP_EOL . Indent::_(3) . "{"; - $query .= PHP_EOL . Indent::_(4) . "return false;"; - $query .= PHP_EOL . Indent::_(3) . "}"; - } - // filter by parent repetable field values - if (StringHelper::check($globalKey) && $key - && strpos( - (string) $parentKey, '-R>' - ) !== false - && strpos((string) $parentKey, '-A>') === false) - { - list($bin, $target) = explode('-R>', (string) $parentKey); - $query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Filter by " . $_key . " Repetable Field"; - $query .= PHP_EOL . Indent::_(3) . "\$" . $globalKey - . " = json_decode(\$this->" . $globalKey . ",true);"; - $query .= PHP_EOL . Indent::_(3) . "if (" - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkArray(\$items) && isset(\$" - . $globalKey . ") && " . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkArray(\$" - . $globalKey . "))"; - $query .= PHP_EOL . Indent::_(3) . "{"; - $query .= PHP_EOL . Indent::_(4) - . "foreach (\$items as \$nr => &\$item)"; - $query .= PHP_EOL . Indent::_(4) . "{"; - $query .= PHP_EOL . Indent::_(5) . "if (\$item->" . $_key - . " && isset(\$" . $globalKey . "['" . $target . "']) && " - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkArray(\$" . $globalKey . "['" - . $target . "']))"; - $query .= PHP_EOL . Indent::_(5) . "{"; - $query .= PHP_EOL . Indent::_(6) . "if (!in_array(\$item->" . $_key - . ",\$" . $globalKey . "['" . $target . "']))"; - $query .= PHP_EOL . Indent::_(6) . "{"; - $query .= PHP_EOL . Indent::_(7) . "unset(\$items[\$nr]);"; - $query .= PHP_EOL . Indent::_(7) . "continue;"; - $query .= PHP_EOL . Indent::_(6) . "}"; - $query .= PHP_EOL . Indent::_(5) . "}"; - $query .= PHP_EOL . Indent::_(5) . "else"; - $query .= PHP_EOL . Indent::_(5) . "{"; - $query .= PHP_EOL . Indent::_(6) . "unset(\$items[\$nr]);"; - $query .= PHP_EOL . Indent::_(6) . "continue;"; - $query .= PHP_EOL . Indent::_(5) . "}"; - $query .= PHP_EOL . Indent::_(4) . "}"; - $query .= PHP_EOL . Indent::_(3) . "}"; - $query .= PHP_EOL . Indent::_(3) . "else"; - $query .= PHP_EOL . Indent::_(3) . "{"; - $query .= PHP_EOL . Indent::_(4) . "return false;"; - $query .= PHP_EOL . Indent::_(3) . "}"; - } - // filter by parent array field values - if (StringHelper::check($globalKey) && $key - && strpos( - (string) $parentKey, '-R>' - ) === false - && strpos((string) $parentKey, '-A>') !== false) - { - $query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Filter by " . $globalKey . " Array Field"; - $query .= PHP_EOL . Indent::_(3) . "\$" . $globalKey . " = \$this->" - . $globalKey . ";"; - $query .= PHP_EOL . Indent::_(3) . "if (" - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkArray(\$items) && " - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkArray(\$" . $globalKey . "))"; - $query .= PHP_EOL . Indent::_(3) . "{"; - $query .= PHP_EOL . Indent::_(4) - . "foreach (\$items as \$nr => &\$item)"; - $query .= PHP_EOL . Indent::_(4) . "{"; - list($bin, $target) = explode('-A>', (string) $parentKey); - if (StringHelper::check($target)) - { - $query .= PHP_EOL . Indent::_(5) . "if (\$item->" . $_key - . " && " . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkArray(\$" . $globalKey . "['" - . $target . "']))"; - $query .= PHP_EOL . Indent::_(5) . "{"; - $query .= PHP_EOL . Indent::_(6) . "if (!in_array(\$item->" - . $_key . ",\$" . $globalKey . "['" . $target . "']))"; - } - else - { - $query .= PHP_EOL . Indent::_(5) . "if (\$item->" . $_key . ")"; - $query .= PHP_EOL . Indent::_(5) . "{"; - $query .= PHP_EOL . Indent::_(6) . "if (!in_array(\$item->" - . $_key . ",\$" . $globalKey . "))"; - } - $query .= PHP_EOL . Indent::_(6) . "{"; - $query .= PHP_EOL . Indent::_(7) . "unset(\$items[\$nr]);"; - $query .= PHP_EOL . Indent::_(7) . "continue;"; - $query .= PHP_EOL . Indent::_(6) . "}"; - $query .= PHP_EOL . Indent::_(5) . "}"; - $query .= PHP_EOL . Indent::_(5) . "else"; - $query .= PHP_EOL . Indent::_(5) . "{"; - $query .= PHP_EOL . Indent::_(6) . "unset(\$items[\$nr]);"; - $query .= PHP_EOL . Indent::_(6) . "continue;"; - $query .= PHP_EOL . Indent::_(5) . "}"; - $query .= PHP_EOL . Indent::_(4) . "}"; - $query .= PHP_EOL . Indent::_(3) . "}"; - $query .= PHP_EOL . Indent::_(3) . "else"; - $query .= PHP_EOL . Indent::_(3) . "{"; - $query .= PHP_EOL . Indent::_(4) . "return false;"; - $query .= PHP_EOL . Indent::_(3) . "}"; - } - // add custom php to getitems method after all - $query .= CFactory::_('Customcode.Dispenser')->get( - 'php_getitems_after_all', $nameSingleCode, - PHP_EOL . PHP_EOL . Indent::_(1) - ); - - $query .= PHP_EOL . Indent::_(3) . "return \$items;"; - $query .= PHP_EOL . Indent::_(2) . "}"; - $query .= PHP_EOL . Indent::_(2) . "return false;"; - $query .= PHP_EOL . Indent::_(1) . "}"; - // SELECTIONTRANSLATIONFIXFUNC<<>> - $query .= $this->setSelectionTranslationFixFunc( - $nameListCode, - CFactory::_('Compiler.Builder.Content.One')->get('Component') - ); - - // fixe mothod name clash - $query = str_replace( - 'selectionTranslation(', - 'selectionTranslation' . $functionName . '(', $query - ); - - return $query; - } - - /** - * @param $nameListCode - * - * @return array|string - */ - public function setCustomAdminDynamicButton($nameListCode) - { - $buttons = ''; - if (isset($this->customAdminDynamicButtons[$nameListCode]) - && ArrayHelper::check( - $this->customAdminDynamicButtons[$nameListCode] - )) - { - $buttons = array(); - foreach ( - $this->customAdminDynamicButtons[$nameListCode] as - $custom_button - ) - { - // Load to lang - $keyLang = $this->langPrefix . '_' . $custom_button['NAME']; - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $keyLang, StringHelper::safe( - $custom_button['name'], 'Ww' - ) - ); - // add cpanel button - $buttons[] = Indent::_(2) . "if (\$this->canDo->get('" - . $custom_button['link'] . ".access'))"; - $buttons[] = Indent::_(2) . "{"; - $buttons[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " add " . $custom_button['name'] . " button."; - $buttons[] = Indent::_(3) . "JToolBarHelper::custom('" - . $nameListCode . ".redirectTo" - . StringHelper::safe( - $custom_button['link'], 'F' - ) . "', '" . $custom_button['icon'] . "', '', '" . $keyLang - . "', true);"; - $buttons[] = Indent::_(2) . "}"; - } - if (ArrayHelper::check($buttons)) - { - return implode(PHP_EOL, $buttons); - } - } - - return $buttons; - } - - /** - * @param $nameListCode - * - * @return array|string - */ - public function setCustomAdminDynamicButtonController($nameListCode) - { - $method = ''; - if (isset($this->customAdminDynamicButtons[$nameListCode]) - && ArrayHelper::check( - $this->customAdminDynamicButtons[$nameListCode] - )) - { - $method = array(); - foreach ( - $this->customAdminDynamicButtons[$nameListCode] as - $custom_button - ) - { - // add the custom redirect method - $method[] = PHP_EOL . PHP_EOL . Indent::_(1) - . "public function redirectTo" - . StringHelper::safe( - $custom_button['link'], 'F' - ) . "()"; - $method[] = Indent::_(1) . "{"; - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Check for request forgeries"; - $method[] = Indent::_(2) - . "JSession::checkToken() or die(JText:" - . ":_('JINVALID_TOKEN'));"; - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " check if export is allowed for this user."; - $method[] = Indent::_(2) . "\$user = JFactory::getUser();"; - $method[] = Indent::_(2) . "if (\$user->authorise('" - . $custom_button['link'] . ".access', 'com_" - . CFactory::_('Config')->component_code_name . "'))"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Get the input"; - $method[] = Indent::_(3) - . "\$input = JFactory::getApplication()->input;"; - $method[] = Indent::_(3) - . "\$pks = \$input->post->get('cid', array(), 'array');"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Sanitize the input"; - $method[] = Indent::_(3) - . "\$pks = ArrayHelper::toInteger(\$pks);"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " convert to string"; - $method[] = Indent::_(3) . "\$ids = implode('_', \$pks);"; - $method[] = Indent::_(3) - . "\$this->setRedirect(JRoute::_('index.php?option=com_" - . CFactory::_('Config')->component_code_name . "&view=" - . $custom_button['link'] . "&cid='.\$ids, false));"; - $method[] = Indent::_(3) . "return;"; - $method[] = Indent::_(2) . "}"; - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Redirect to the list screen with error."; - $method[] = Indent::_(2) . "\$message = JText:" . ":_('" - . $this->langPrefix . "_ACCESS_TO_" . $custom_button['NAME'] - . "_FAILED');"; - $method[] = Indent::_(2) - . "\$this->setRedirect(JRoute::_('index.php?option=com_" - . CFactory::_('Config')->component_code_name . "&view=" . $nameListCode - . "', false), \$message, 'error');"; - $method[] = Indent::_(2) . "return;"; - $method[] = Indent::_(1) . "}"; - // add to lang array - $lankey = $this->langPrefix . "_ACCESS_TO_" - . $custom_button['NAME'] . "_FAILED"; - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lankey, - 'Access to ' . $custom_button['link'] . ' was denied.' - ); - } - - return implode(PHP_EOL, $method); - } - - return $method; - } - - /** - * A function that builds get Items Method for model - * - * @param string $nameSingleCode The single view name - * @param string $nameListCode The list view name - * @param array $config The config details to adapt the method being build - * - * @return string - */ - public function setGetItemsModelMethod(&$nameSingleCode, &$nameListCode, - $config - = array('functionName' => 'getExportData', - 'docDesc' => 'Method to get list export data.', - 'type' => 'export') - ) - { - // start the query string - $query = ''; - // check if this is the export method - $isExport = ('export' === $config['type']); - // check if this view has export feature, and or if this is not an export method - if ((isset($this->eximportView[$nameListCode]) - && $this->eximportView[$nameListCode]) - || !$isExport) - { - $query = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $query .= PHP_EOL . Indent::_(1) . " * " . $config['docDesc']; - $query .= PHP_EOL . Indent::_(1) . " *"; - $query .= PHP_EOL . Indent::_(1) - . " * @param array \$pks The ids of the items to get"; - $query .= PHP_EOL . Indent::_(1) - . " * @param JUser \$user The user making the request"; - $query .= PHP_EOL . Indent::_(1) . " *"; - $query .= PHP_EOL . Indent::_(1) - . " * @return mixed An array of data items on success, false on failure."; - $query .= PHP_EOL . Indent::_(1) . " */"; - $query .= PHP_EOL . Indent::_(1) . "public function " - . $config['functionName'] . "(\$pks, \$user = null)"; - $query .= PHP_EOL . Indent::_(1) . "{"; - $query .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " setup the query"; - $query .= PHP_EOL . Indent::_(2) . "if ((\$pks_size = " - . CFactory::_('Compiler.Builder.Content.One')->get('Component') - . "Helper::checkArray(\$pks)) !== false || 'bulk' === \$pks)"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Set a value to know this is " . $config['type'] - . " method. (USE IN CUSTOM CODE TO ALTER OUTCOME)"; - $query .= PHP_EOL . Indent::_(3) . "\$_" . $config['type'] - . " = true;"; - $query .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Get the user object if not set."; - $query .= PHP_EOL . Indent::_(3) . "if (!isset(\$user) || !" - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkObject(\$user))"; - $query .= PHP_EOL . Indent::_(3) . "{"; - $query .= PHP_EOL . Indent::_(4) . "\$user = JFactory::getUser();"; - $query .= PHP_EOL . Indent::_(3) . "}"; - $query .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Create a new query object."; - $query .= PHP_EOL . Indent::_(3) . "\$db = JFactory::getDBO();"; - $query .= PHP_EOL . Indent::_(3) - . "\$query = \$db->getQuery(true);"; - $query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Select some fields"; - $query .= PHP_EOL . Indent::_(3) . "\$query->select('a.*');"; - $query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " From the " . CFactory::_('Config')->component_code_name . "_" - . $nameSingleCode . " table"; - $query .= PHP_EOL . Indent::_(3) - . "\$query->from(\$db->quoteName('#__" - . CFactory::_('Config')->component_code_name . "_" . $nameSingleCode - . "', 'a'));"; - $query .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " The bulk export path"; - $query .= PHP_EOL . Indent::_(3) . "if ('bulk' === \$pks)"; - $query .= PHP_EOL . Indent::_(3) - . "{"; - $query .= PHP_EOL . Indent::_(4) - . "\$query->where('a.id > 0');"; - $query .= PHP_EOL . Indent::_(3) - . "}"; - $query .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " A large array of ID's will not work out well"; - $query .= PHP_EOL . Indent::_(3) . "elseif (\$pks_size > 500)"; - $query .= PHP_EOL . Indent::_(3) - . "{"; - $query .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Use lowest ID"; - $query .= PHP_EOL . Indent::_(4) - . "\$query->where('a.id >= ' . (int) min(\$pks));"; - $query .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Use highest ID"; - $query .= PHP_EOL . Indent::_(4) - . "\$query->where('a.id <= ' . (int) max(\$pks));"; - $query .= PHP_EOL . Indent::_(3) - . "}"; - $query .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " The normal default path"; - $query .= PHP_EOL . Indent::_(3) . "else"; - $query .= PHP_EOL . Indent::_(3) - . "{"; - $query .= PHP_EOL . Indent::_(4) - . "\$query->where('a.id IN (' . implode(',',\$pks) . ')');"; - $query .= PHP_EOL . Indent::_(3) - . "}"; - // add custom filtering php - $query .= CFactory::_('Customcode.Dispenser')->get( - 'php_getlistquery', $nameSingleCode, - PHP_EOL . PHP_EOL . Indent::_(1) - ); - // first check if we export of text only is avalable - if ($this->exportTextOnly) - { - // add switch - $query .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Get global switch to activate text only export"; - $query .= PHP_EOL . Indent::_(3) - . "\$export_text_only = JComponentHelper::getParams('com_" - . CFactory::_('Config')->component_code_name - . "')->get('export_text_only', 0);"; - // first check if we have custom queries - $custom_query = $this->setCustomQuery( - $nameListCode, $nameSingleCode, Indent::_(2), true - ); - } - // if values were returned add the area - if (isset($custom_query) - && StringHelper::check( - $custom_query - )) - { - $query .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Add these queries only if text only is required"; - $query .= PHP_EOL . Indent::_(3) . "if (\$export_text_only)"; - $query .= PHP_EOL . Indent::_(3) . "{"; - // add the custom fields query - $query .= $custom_query; - $query .= PHP_EOL . Indent::_(3) . "}"; - } - // add access levels if the view has access set - if (CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode)) - { - $query .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Implement View Level Access"; - $query .= PHP_EOL . Indent::_(3) - . "if (!\$user->authorise('core.options', 'com_" - . CFactory::_('Config')->component_code_name . "'))"; - $query .= PHP_EOL . Indent::_(3) . "{"; - $query .= PHP_EOL . Indent::_(4) - . "\$groups = implode(',', \$user->getAuthorisedViewLevels());"; - $query .= PHP_EOL . Indent::_(4) - . "\$query->where('a.access IN (' . \$groups . ')');"; - $query .= PHP_EOL . Indent::_(3) . "}"; - } - // add dynamic ordering (Exported data) - if (isset($this->viewsDefaultOrdering[$nameListCode]) - && $this->viewsDefaultOrdering[$nameListCode]['add_admin_ordering'] - == 1) - { - foreach ( - $this->viewsDefaultOrdering[$nameListCode]['admin_ordering_fields'] - as $order_field - ) - { - if (($order_field_name = CFactory::_('Field.Database.Name')->get( - $nameListCode, $order_field['field'] - )) !== false) - { - $query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" - . Line::_( - __LINE__,__CLASS__ - ) . " Order the results by ordering"; - $query .= PHP_EOL . Indent::_(3) - . "\$query->order('" - . $order_field_name . " " - . $order_field['direction'] . "');"; - } - } - } - else - { - $query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" - . Line::_( - __LINE__,__CLASS__ - ) . " Order the results by ordering"; - $query .= PHP_EOL . Indent::_(3) - . "\$query->order('a.ordering ASC');"; - } - $query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Load the items"; - $query .= PHP_EOL . Indent::_(3) . "\$db->setQuery(\$query);"; - $query .= PHP_EOL . Indent::_(3) . "\$db->execute();"; - $query .= PHP_EOL . Indent::_(3) . "if (\$db->getNumRows())"; - $query .= PHP_EOL . Indent::_(3) . "{"; - $query .= PHP_EOL . Indent::_(4) - . "\$items = \$db->loadObjectList();"; - // set the string fixing code - $query .= $this->setGetItemsMethodStringFix( - $nameSingleCode, $nameListCode, - CFactory::_('Compiler.Builder.Content.One')->get('Component'), - Indent::_(2), $isExport, true - ); - // first check if we export of text only is avalable - if ($this->exportTextOnly) - { - $query_translations = $this->setSelectionTranslationFix( - $nameListCode, - CFactory::_('Compiler.Builder.Content.One')->get('Component'), Indent::_(3) - ); - } - // add translations - if (isset($query_translations) - && StringHelper::check($query_translations)) - { - $query .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Add these translation only if text only is required"; - $query .= PHP_EOL . Indent::_(3) . "if (\$export_text_only)"; - $query .= PHP_EOL . Indent::_(3) . "{"; - $query .= $query_translations; - $query .= PHP_EOL . Indent::_(3) . "}"; - } - // add custom php to getItems method after all - $query .= CFactory::_('Customcode.Dispenser')->get( - 'php_getitems_after_all', $nameSingleCode, - PHP_EOL . PHP_EOL . Indent::_(2) - ); - // in privacy export we must return array of arrays - if ('privacy' === $config['type']) - { - $query .= PHP_EOL . Indent::_(4) - . "return json_decode(json_encode(\$items), true);"; - } - else - { - $query .= PHP_EOL . Indent::_(4) . "return \$items;"; - } - $query .= PHP_EOL . Indent::_(3) . "}"; - $query .= PHP_EOL . Indent::_(2) . "}"; - $query .= PHP_EOL . Indent::_(2) . "return false;"; - $query .= PHP_EOL . Indent::_(1) . "}"; - // get the header script - if ($isExport) - { - $header = ComponentbuilderHelper::getDynamicScripts('headers'); - - // add getExImPortHeaders - $query .= CFactory::_('Customcode.Dispenser')->get( - 'php_import_headers', 'import_' . $nameListCode, - PHP_EOL . PHP_EOL, null, true, - // set a default script for those with no custom script - PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( - $header - ) - ); - } - } - - return $query; - } - - public function setControllerEximportMethod($nameSingleCode, - $nameListCode - ) - { - $method = ''; - if (isset($this->eximportView[$nameListCode]) - && $this->eximportView[$nameListCode]) - { - $method = array(); - - // add the export method - $method[] = PHP_EOL . PHP_EOL . Indent::_(1) - . "public function exportData()"; - $method[] = Indent::_(1) . "{"; - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Check for request forgeries"; - $method[] = Indent::_(2) . "JSession::checkToken() or die(JText:" - . ":_('JINVALID_TOKEN'));"; - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " check if export is allowed for this user."; - $method[] = Indent::_(2) . "\$user = JFactory::getUser();"; - $method[] = Indent::_(2) . "if (\$user->authorise('" - . $nameSingleCode . ".export', 'com_" - . CFactory::_('Config')->component_code_name - . "') && \$user->authorise('core.export', 'com_" - . CFactory::_('Config')->component_code_name . "'))"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Get the input"; - $method[] = Indent::_(3) - . "\$input = JFactory::getApplication()->input;"; - $method[] = Indent::_(3) - . "\$pks = \$input->post->get('cid', array(), 'array');"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Sanitize the input"; - $method[] = Indent::_(3) . "\$pks = ArrayHelper::toInteger(\$pks);"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Get the model"; - $method[] = Indent::_(3) . "\$model = \$this->getModel('" - . StringHelper::safe($nameListCode, 'F') - . "');"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " get the data to export"; - $method[] = Indent::_(3) - . "\$data = \$model->getExportData(\$pks);"; - $method[] = Indent::_(3) . "if (" - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkArray(\$data))"; - $method[] = Indent::_(3) . "{"; - $method[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " now set the data to the spreadsheet"; - $method[] = Indent::_(4) . "\$date = JFactory::getDate();"; - $method[] = Indent::_(4) . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::xls(\$data,'" - . StringHelper::safe($nameListCode, 'F') - . "_'.\$date->format('jS_F_Y'),'" - . StringHelper::safe($nameListCode, 'Ww') - . " exported ('.\$date->format('jS F, Y').')','" - . StringHelper::safe($nameListCode, 'w') - . "');"; - $method[] = Indent::_(3) . "}"; - $method[] = Indent::_(2) . "}"; - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Redirect to the list screen with error."; - $method[] = Indent::_(2) . "\$message = JText:" . ":_('" - . $this->langPrefix . "_EXPORT_FAILED');"; - $method[] = Indent::_(2) - . "\$this->setRedirect(JRoute::_('index.php?option=com_" - . CFactory::_('Config')->component_code_name . "&view=" . $nameListCode - . "', false), \$message, 'error');"; - $method[] = Indent::_(2) . "return;"; - $method[] = Indent::_(1) . "}"; - - // add the import method - $method[] = PHP_EOL . PHP_EOL . Indent::_(1) - . "public function importData()"; - $method[] = Indent::_(1) . "{"; - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Check for request forgeries"; - $method[] = Indent::_(2) . "JSession::checkToken() or die(JText:" - . ":_('JINVALID_TOKEN'));"; - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " check if import is allowed for this user."; - $method[] = Indent::_(2) . "\$user = JFactory::getUser();"; - $method[] = Indent::_(2) . "if (\$user->authorise('" - . $nameSingleCode . ".import', 'com_" - . CFactory::_('Config')->component_code_name - . "') && \$user->authorise('core.import', 'com_" - . CFactory::_('Config')->component_code_name . "'))"; - $method[] = Indent::_(2) . "{"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Get the import model"; - $method[] = Indent::_(3) . "\$model = \$this->getModel('" - . StringHelper::safe($nameListCode, 'F') - . "');"; - $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " get the headers to import"; - $method[] = Indent::_(3) - . "\$headers = \$model->getExImPortHeaders();"; - $method[] = Indent::_(3) . "if (" - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkObject(\$headers))"; - $method[] = Indent::_(3) . "{"; - $method[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Load headers to session."; - $method[] = Indent::_(4) . "\$session = JFactory::getSession();"; - $method[] = Indent::_(4) . "\$headers = json_encode(\$headers);"; - $method[] = Indent::_(4) . "\$session->set('" . $nameSingleCode - . "_VDM_IMPORTHEADERS', \$headers);"; - $method[] = Indent::_(4) . "\$session->set('backto_VDM_IMPORT', '" - . $nameListCode . "');"; - $method[] = Indent::_(4) - . "\$session->set('dataType_VDM_IMPORTINTO', '" - . $nameSingleCode . "');"; - $method[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Redirect to import view."; - // add to lang array - $selectImportFileNote = $this->langPrefix - . "_IMPORT_SELECT_FILE_FOR_" - . StringHelper::safe($nameListCode, 'U'); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $selectImportFileNote, - 'Select the file to import data to ' . $nameListCode . '.' - ); - $method[] = Indent::_(4) . "\$message = JText:" . ":_('" - . $selectImportFileNote . "');"; - // if this view has custom script it must have as custom import (model, veiw, controller) - if (isset($this->importCustomScripts[$nameListCode]) - && $this->importCustomScripts[$nameListCode]) - { - $method[] = Indent::_(4) - . "\$this->setRedirect(JRoute::_('index.php?option=com_" - . CFactory::_('Config')->component_code_name . "&view=import_" - . $nameListCode . "', false), \$message);"; - } - else - { - $method[] = Indent::_(4) - . "\$this->setRedirect(JRoute::_('index.php?option=com_" - . CFactory::_('Config')->component_code_name - . "&view=import', false), \$message);"; - } - $method[] = Indent::_(4) . "return;"; - $method[] = Indent::_(3) . "}"; - $method[] = Indent::_(2) . "}"; - $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Redirect to the list screen with error."; - $method[] = Indent::_(2) . "\$message = JText:" . ":_('" - . $this->langPrefix . "_IMPORT_FAILED');"; - $method[] = Indent::_(2) - . "\$this->setRedirect(JRoute::_('index.php?option=com_" - . CFactory::_('Config')->component_code_name . "&view=" . $nameListCode - . "', false), \$message, 'error');"; - $method[] = Indent::_(2) . "return;"; - $method[] = Indent::_(1) . "}"; - - return implode(PHP_EOL, $method); - } - - return $method; - } - - public function setExportButton($nameSingleCode, $nameListCode) - { - $button = ''; - if (isset($this->eximportView[$nameListCode]) - && $this->eximportView[$nameListCode]) - { - // main lang prefix - $langExport = $this->langPrefix . '_' - . StringHelper::safe('Export Data', 'U'); - // add to lang array - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $langExport, 'Export Data'); - $button = array(); - $button[] = PHP_EOL . PHP_EOL . Indent::_(3) - . "if (\$this->canDo->get('core.export') && \$this->canDo->get('" - . $nameSingleCode . ".export'))"; - $button[] = Indent::_(3) . "{"; - $button[] = Indent::_(4) . "JToolBarHelper::custom('" - . $nameListCode . ".exportData', 'download', '', '" - . $langExport . "', true);"; - $button[] = Indent::_(3) . "}"; - - return implode(PHP_EOL, $button); - } - - return $button; - } - - public function setImportButton($nameSingleCode, $nameListCode) - { - $button = ''; - if (isset($this->eximportView[$nameListCode]) - && $this->eximportView[$nameListCode]) - { - // main lang prefix - $langImport = $this->langPrefix . '_' - . StringHelper::safe('Import Data', 'U'); - // add to lang array - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $langImport, 'Import Data'); - $button = array(); - $button[] = PHP_EOL . PHP_EOL . Indent::_(2) - . "if (\$this->canDo->get('core.import') && \$this->canDo->get('" - . $nameSingleCode . ".import'))"; - $button[] = Indent::_(2) . "{"; - $button[] = Indent::_(3) . "JToolBarHelper::custom('" - . $nameListCode . ".importData', 'upload', '', '" - . $langImport - . "', false);"; - $button[] = Indent::_(2) . "}"; - - return implode(PHP_EOL, $button); - } - - return $button; - } - - public function setImportCustomScripts($nameListCode) - { - // setup Ajax files - $target = array('admin' => 'import_' . $nameListCode); - CFactory::_('Utilities.Structure')->build($target, 'customimport'); - // load the custom script to the files - // IMPORT_EXT_METHOD <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|IMPORT_EXT_METHOD', CFactory::_('Customcode.Dispenser')->get( - 'php_import_ext', 'import_' . $nameListCode, PHP_EOL, null, - true - )); - // IMPORT_DISPLAY_METHOD_CUSTOM <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|IMPORT_DISPLAY_METHOD_CUSTOM', CFactory::_('Customcode.Dispenser')->get( - 'php_import_display', 'import_' . $nameListCode, PHP_EOL, - null, - true - )); - // IMPORT_SETDATA_METHOD <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|IMPORT_SETDATA_METHOD', CFactory::_('Customcode.Dispenser')->get( - 'php_import_setdata', 'import_' . $nameListCode, PHP_EOL, - null, - true - )); - // IMPORT_METHOD_CUSTOM <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|IMPORT_METHOD_CUSTOM', CFactory::_('Customcode.Dispenser')->get( - 'php_import', 'import_' . $nameListCode, PHP_EOL, null, - true - )); - // IMPORT_SAVE_METHOD <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|IMPORT_SAVE_METHOD', CFactory::_('Customcode.Dispenser')->get( - 'php_import_save', 'import_' . $nameListCode, PHP_EOL, - null, - true - )); - // IMPORT_DEFAULT_VIEW_CUSTOM <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|IMPORT_DEFAULT_VIEW_CUSTOM', CFactory::_('Customcode.Dispenser')->get( - 'html_import_view', 'import_' . $nameListCode, PHP_EOL, - null, - true - )); - - // insure we have the view placeholders setup - CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|VIEW', 'IMPORT_' . CFactory::_('Placeholder')->get_h('VIEWS')); - CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|View', 'Import_' . CFactory::_('Placeholder')->get_h('views')); - CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|view', 'import_' . CFactory::_('Placeholder')->get_h('views')); - CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|VIEWS', 'IMPORT_' . CFactory::_('Placeholder')->get_h('VIEWS')); - CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|Views', 'Import_' . CFactory::_('Placeholder')->get_h('views')); - CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|views', 'import_' . CFactory::_('Placeholder')->get_h('views')); - - // IMPORT_CUSTOM_CONTROLLER_HEADER <<>> add the header details for the controller - CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|IMPORT_CUSTOM_CONTROLLER_HEADER', $this->setFileHeader( - 'import.custom.controller', - $nameListCode - )); - - // IMPORT_CUSTOM_MODEL_HEADER <<>> add the header details for the model - CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|IMPORT_CUSTOM_MODEL_HEADER', $this->setFileHeader( - 'import.custom.model', - $nameListCode - )); - } - - public function setListQuery(&$nameSingleCode, &$nameListCode) - { - // check if this view has category added - if (CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.code")) - { - $categoryCodeName = CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.code"); - $addCategory = true; - $addCategoryFilter - = CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.filter", 'error'); - } - else - { - $addCategory = false; - $addCategoryFilter = 0; - } - // setup the query - $query = "//" . Line::_(__Line__, __Class__) . " Get the user object."; - $query .= PHP_EOL . Indent::_(2) . "\$user = JFactory::getUser();"; - $query .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Create a new query object."; - $query .= PHP_EOL . Indent::_(2) . "\$db = JFactory::getDBO();"; - $query .= PHP_EOL . Indent::_(2) . "\$query = \$db->getQuery(true);"; - $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Select some fields"; - $query .= PHP_EOL . Indent::_(2) . "\$query->select('a.*');"; - // add the category - if ($addCategory) - { - $query .= PHP_EOL . Indent::_(2) - . "\$query->select(\$db->quoteName('c.title','category_title'));"; - } - $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " From the " . CFactory::_('Config')->component_code_name . "_item table"; - $query .= PHP_EOL . Indent::_(2) . "\$query->from(\$db->quoteName('#__" - . CFactory::_('Config')->component_code_name . "_" . $nameSingleCode . "', 'a'));"; - // add the category - if ($addCategory) - { - $query .= PHP_EOL . Indent::_(2) - . "\$query->join('LEFT', \$db->quoteName('#__categories', 'c') . ' ON (' . \$db->quoteName('a." - . $categoryCodeName - . "') . ' = ' . \$db->quoteName('c.id') . ')');"; - } - // add custom filtering php - $query .= CFactory::_('Customcode.Dispenser')->get( - 'php_getlistquery', $nameSingleCode, PHP_EOL . PHP_EOL - ); - // add the custom fields query - $query .= $this->setCustomQuery($nameListCode, $nameSingleCode); - $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Filter by published state"; - $query .= PHP_EOL . Indent::_(2) - . "\$published = \$this->getState('filter.published');"; - $query .= PHP_EOL . Indent::_(2) . "if (is_numeric(\$published))"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) - . "\$query->where('a.published = ' . (int) \$published);"; - $query .= PHP_EOL . Indent::_(2) . "}"; - $query .= PHP_EOL . Indent::_(2) . "elseif (\$published === '')"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) - . "\$query->where('(a.published = 0 OR a.published = 1)');"; - $query .= PHP_EOL . Indent::_(2) . "}"; - if (CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode)) - { - $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Join over the asset groups."; - $query .= PHP_EOL . Indent::_(2) - . "\$query->select('ag.title AS access_level');"; - $query .= PHP_EOL . Indent::_(2) - . "\$query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');"; - // check if the access field was over ridden - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.access')) - { - // component helper name - $Helper = CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper'; - // load the access filter query code - $query .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) - . " Filter by access level."; - $query .= PHP_EOL . Indent::_(2) - . "\$_access = \$this->getState('filter.access');"; - $query .= PHP_EOL . Indent::_(2) - . "if (\$_access && is_numeric(\$_access))"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) - . "\$query->where('a.access = ' . (int) \$_access);"; - $query .= PHP_EOL . Indent::_(2) . "}"; - $query .= PHP_EOL . Indent::_(2) . "elseif (" - . $Helper . "::checkArray(\$_access))"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) - . " Secure the array for the query"; - $query .= PHP_EOL . Indent::_(3) - . "\$_access = ArrayHelper::toInteger(\$_access);"; - $query .= PHP_EOL . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) . " Filter by the Access Array."; - $query .= PHP_EOL . Indent::_(3) - . "\$query->where('a.access IN (' . implode(',', \$_access) . ')');"; - $query .= PHP_EOL . Indent::_(2) . "}"; - } - // TODO the following will fight against the above access filter - $query .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Implement View Level Access"; - $query .= PHP_EOL . Indent::_(2) - . "if (!\$user->authorise('core.options', 'com_" - . CFactory::_('Config')->component_code_name . "'))"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) - . "\$groups = implode(',', \$user->getAuthorisedViewLevels());"; - $query .= PHP_EOL . Indent::_(3) - . "\$query->where('a.access IN (' . \$groups . ')');"; - $query .= PHP_EOL . Indent::_(2) . "}"; - } - // set the search query - $query .= $this->setSearchQuery($nameListCode); - // set other filters - $query .= $this->setFilterQuery($nameListCode); - // add the category - if ($addCategory && $addCategoryFilter >= 1) - { - $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Filter by a single or group of categories."; - $query .= PHP_EOL . Indent::_(2) . "\$baselevel = 1;"; - $query .= PHP_EOL . Indent::_(2) - . "\$categoryId = \$this->getState('filter.category_id');"; - $query .= PHP_EOL; - $query .= PHP_EOL . Indent::_(2) . "if (is_numeric(\$categoryId))"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) - . "\$cat_tbl = JTable::getInstance('Category', 'JTable');"; - $query .= PHP_EOL . Indent::_(3) . "\$cat_tbl->load(\$categoryId);"; - $query .= PHP_EOL . Indent::_(3) . "\$rgt = \$cat_tbl->rgt;"; - $query .= PHP_EOL . Indent::_(3) . "\$lft = \$cat_tbl->lft;"; - $query .= PHP_EOL . Indent::_(3) - . "\$baselevel = (int) \$cat_tbl->level;"; - $query .= PHP_EOL . Indent::_(3) - . "\$query->where('c.lft >= ' . (int) \$lft)"; - $query .= PHP_EOL . Indent::_(4) - . "->where('c.rgt <= ' . (int) \$rgt);"; - $query .= PHP_EOL . Indent::_(2) . "}"; - $query .= PHP_EOL . Indent::_(2) - . "elseif (is_array(\$categoryId))"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) - . "\$categoryId = ArrayHelper::toInteger(\$categoryId);"; - $query .= PHP_EOL . Indent::_(3) - . "\$categoryId = implode(',', \$categoryId);"; - $query .= PHP_EOL . Indent::_(3) - . "\$query->where('a." . $categoryCodeName - . " IN (' . \$categoryId . ')');"; - $query .= PHP_EOL . Indent::_(2) . "}"; - $query .= PHP_EOL; - } - // setup values for the view ordering - // add dynamic ordering (Admin view) - if (isset($this->viewsDefaultOrdering[$nameListCode]) - && $this->viewsDefaultOrdering[$nameListCode]['add_admin_ordering'] - == 1) - { - // the first is from the state - $order_first = true; - foreach ( - $this->viewsDefaultOrdering[$nameListCode]['admin_ordering_fields'] - as $order_field - ) - { - if (($order_field_name = CFactory::_('Field.Database.Name')->get( - $nameListCode, $order_field['field'] - )) !== false) - { - if ($order_first) - { - // just the first field is based on state - $order_first = false; - $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_( - __LINE__,__CLASS__ - ) . " Add the list ordering clause."; - $query .= PHP_EOL . Indent::_(2) - . "\$orderCol = \$this->state->get('list.ordering', '" - . $order_field_name . "');"; - $query .= PHP_EOL . Indent::_(2) - . "\$orderDirn = \$this->state->get('list.direction', '" - . $order_field['direction'] . "');"; - $query .= PHP_EOL . Indent::_(2) - . "if (\$orderCol != '')"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) - . "\$query->order(\$db->escape(\$orderCol . ' ' . \$orderDirn));"; - $query .= PHP_EOL . Indent::_(2) . "}"; - } - else - { - $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_( - __LINE__,__CLASS__ - ) . " Add a permanent list ordering."; - $query .= PHP_EOL . Indent::_(2) - . "\$query->order(\$db->escape('" - . $order_field_name . " " - . $order_field['direction'] . "'));"; - } - } - } - } - else - { - $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Add the list ordering clause."; - $query .= PHP_EOL . Indent::_(2) - . "\$orderCol = \$this->state->get('list.ordering', 'a.id');"; - $query .= PHP_EOL . Indent::_(2) - . "\$orderDirn = \$this->state->get('list.direction', 'desc');"; - $query .= PHP_EOL . Indent::_(2) . "if (\$orderCol != '')"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) - . "\$query->order(\$db->escape(\$orderCol . ' ' . \$orderDirn));"; - $query .= PHP_EOL . Indent::_(2) . "}"; - } - $query .= PHP_EOL; - $query .= PHP_EOL . Indent::_(2) . "return \$query;"; - - return $query; - } - - public function setSearchQuery($nameListCode) - { - if (CFactory::_('Compiler.Builder.Search')->exists($nameListCode)) - { - // setup the searh options - $search = "'("; - foreach (CFactory::_('Compiler.Builder.Search')->get($nameListCode) as $nr => $array) - { - // array( 'type' => $typeName, 'code' => $name, 'custom' => $custom, 'list' => $field['list']); - if ($nr == 0) - { - $search .= "a." . $array['code'] . " LIKE '.\$search.'"; - if (ArrayHelper::check($array['custom']) - && 1 == $array['list']) - { - $search .= " OR " . $array['custom']['db'] . "." - . $array['custom']['text'] . " LIKE '.\$search.'"; - } - } - else - { - $search .= " OR a." . $array['code'] . " LIKE '.\$search.'"; - if (ArrayHelper::check($array['custom']) - && 1 == $array['list']) - { - $search .= " OR " . $array['custom']['db'] . "." - . $array['custom']['text'] . " LIKE '.\$search.'"; - } - } - } - $search .= ")'"; - // now setup query - $query = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Filter by search."; - $query .= PHP_EOL . Indent::_(2) - . "\$search = \$this->getState('filter.search');"; - $query .= PHP_EOL . Indent::_(2) . "if (!empty(\$search))"; - $query .= PHP_EOL . Indent::_(2) . "{"; - $query .= PHP_EOL . Indent::_(3) - . "if (stripos(\$search, 'id:') === 0)"; - $query .= PHP_EOL . Indent::_(3) . "{"; - $query .= PHP_EOL . Indent::_(4) - . "\$query->where('a.id = ' . (int) substr(\$search, 3));"; - $query .= PHP_EOL . Indent::_(3) . "}"; - $query .= PHP_EOL . Indent::_(3) . "else"; - $query .= PHP_EOL . Indent::_(3) . "{"; - $query .= PHP_EOL . Indent::_(4) - . "\$search = \$db->quote('%' . \$db->escape(\$search) . '%');"; - $query .= PHP_EOL . Indent::_(4) . "\$query->where(" . $search - . ");"; - $query .= PHP_EOL . Indent::_(3) . "}"; - $query .= PHP_EOL . Indent::_(2) . "}"; - $query .= PHP_EOL; - - return $query; - } - - return ''; - } - - public function setCustomQuery($nameListCode, $nameSingleCode, - $tab = '', - $just_text = false - ) - { - if (CFactory::_('Compiler.Builder.Custom.Field')->exists($nameListCode)) - { - $query = ""; - foreach (CFactory::_('Compiler.Builder.Custom.Field')->get($nameListCode) as $filter) - { - // only load this if table is set - if ((CFactory::_('Compiler.Builder.Custom.List')->exists($nameSingleCode . '.' . $filter['code']) - && isset($filter['custom']['table']) - && StringHelper::check($filter['custom']['table']) - && $filter['method'] == 0) - || ($just_text && isset($filter['custom']['table']) - && StringHelper::check($filter['custom']['table']) - && $filter['method'] == 0)) - { - $query .= PHP_EOL . PHP_EOL . Indent::_(2) . $tab . "//" - . Line::_(__Line__, __Class__) . " From the " - . StringHelper::safe( - StringHelper::safe( - $filter['custom']['table'], 'w' - ) - ) . " table."; - // we must add some fix for none ID keys (I know this is horrible... but we need it) - // TODO we assume that all tables in admin has ids - if ($filter['custom']['id'] !== 'id') - { - // we want to at times just have the words and not the ids as well - if ($just_text) - { - $query .= PHP_EOL . Indent::_(2) . $tab - . "\$query->select(\$db->quoteName(['" - . $filter['custom']['db'] . "." - . $filter['custom']['text'] . "','" - . $filter['custom']['db'] . ".id'],['" - . $filter['code'] . "','" - . $filter['code'] . "_id']));"; - } - else - { - $query .= PHP_EOL . Indent::_(2) . $tab - . "\$query->select(\$db->quoteName(['" - . $filter['custom']['db'] . "." - . $filter['custom']['text'] . "','" - . $filter['custom']['db'] . ".id'],['" - . $filter['code'] . "_" . $filter['custom']['text'] - . "','" . $filter['code'] . "_id']));"; - } - } - else - { - // we want to at times just have the words and not the ids as well - if ($just_text) - { - $query .= PHP_EOL . Indent::_(2) . $tab - . "\$query->select(\$db->quoteName('" - . $filter['custom']['db'] . "." - . $filter['custom']['text'] . "','" - . $filter['code'] . "'));"; - } - else - { - $query .= PHP_EOL . Indent::_(2) . $tab - . "\$query->select(\$db->quoteName('" - . $filter['custom']['db'] . "." - . $filter['custom']['text'] . "','" - . $filter['code'] . "_" . $filter['custom']['text'] - . "'));"; - } - } - $query .= PHP_EOL . Indent::_(2) . $tab - . "\$query->join('LEFT', \$db->quoteName('" - . $filter['custom']['table'] . "', '" - . $filter['custom']['db'] - . "') . ' ON (' . \$db->quoteName('a." . $filter['code'] - . "') . ' = ' . \$db->quoteName('" - . $filter['custom']['db'] . "." - . $filter['custom']['id'] . "') . ')');"; - } - // build the field type file - CFactory::_('Compiler.Creator.Custom.Field.Type.File')->set( - $filter, $nameListCode, $nameSingleCode - ); - } - - return $query; - } - } - - /** - * build model filter per/field in the list view - * - * @param string $nameListCode The list view name - * - * @return string The php to place in model to filter - * - */ - public function setFilterQuery($nameListCode) - { - if (CFactory::_('Compiler.Builder.Filter')->exists($nameListCode)) - { - // component helper name - $Helper = CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper'; - // start building the filter query - $filterQuery = ""; - foreach (CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as $filter) - { - // only add for none category fields - if ($filter['type'] != 'category') - { - $filterQuery .= PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Filter by " - . ucwords((string) $filter['code']) . "."; - // we only add multi filter option if new filter type - // and we have multi filter set for this field (2 = topbar) - if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2 - && isset($filter['multi']) - && $filter['multi'] == 2) - { - $filterQuery .= $this->setMultiFilterQuery( - $filter, $Helper - ); - } - else - { - $filterQuery .= $this->setSingleFilterQuery( - $filter, $Helper - ); - } - } - } - - return $filterQuery; - } - - return ''; - } - - /** - * build single filter query - * - * @param array $filter The field/filter - * @param string $Helper The helper name of the component being build - * @param string $a The db table target name (a) - * - * @return string The php to place in model to filter this field - * - */ - protected function setSingleFilterQuery($filter, $Helper, $a = "a") - { - $filterQuery = PHP_EOL . Indent::_(2) . "\$_" - . $filter['code'] . " = \$this->getState('filter." - . $filter['code'] . "');"; - $filterQuery .= PHP_EOL . Indent::_(2) . "if (is_numeric(\$_" - . $filter['code'] . "))"; - $filterQuery .= PHP_EOL . Indent::_(2) . "{"; - $filterQuery .= PHP_EOL . Indent::_(3) . "if (is_float(\$_" - . $filter['code'] . "))"; - $filterQuery .= PHP_EOL . Indent::_(3) . "{"; - $filterQuery .= PHP_EOL . Indent::_(4) - . "\$query->where('" . $a . "." . $filter['code'] - . " = ' . (float) \$_" . $filter['code'] . ");"; - $filterQuery .= PHP_EOL . Indent::_(3) . "}"; - $filterQuery .= PHP_EOL . Indent::_(3) . "else"; - $filterQuery .= PHP_EOL . Indent::_(3) . "{"; - $filterQuery .= PHP_EOL . Indent::_(4) - . "\$query->where('" . $a . "." . $filter['code'] - . " = ' . (int) \$_" . $filter['code'] . ");"; - $filterQuery .= PHP_EOL . Indent::_(3) . "}"; - $filterQuery .= PHP_EOL . Indent::_(2) . "}"; - $filterQuery .= PHP_EOL . Indent::_(2) . "elseif (" - . $Helper . "::checkString(\$_" . $filter['code'] . "))"; - $filterQuery .= PHP_EOL . Indent::_(2) . "{"; - $filterQuery .= PHP_EOL . Indent::_(3) - . "\$query->where('" . $a . "." . $filter['code'] - . " = ' . \$db->quote(\$db->escape(\$_" . $filter['code'] - . ")));"; - $filterQuery .= PHP_EOL . Indent::_(2) . "}"; - - return $filterQuery; - } - - /** - * build multiple filter query - * - * @param array $filter The field/filter - * @param string $Helper The helper name of the component being build - * @param string $a The db table target name (a) - * - * @return string The php to place in model to filter this field - * - */ - protected function setMultiFilterQuery($filter, $Helper, $a = "a") - { - $filterQuery = PHP_EOL . Indent::_(2) . "\$_" - . $filter['code'] . " = \$this->getState('filter." - . $filter['code'] . "');"; - $filterQuery .= PHP_EOL . Indent::_(2) . "if (is_numeric(\$_" - . $filter['code'] . "))"; - $filterQuery .= PHP_EOL . Indent::_(2) . "{"; - $filterQuery .= PHP_EOL . Indent::_(3) . "if (is_float(\$_" - . $filter['code'] . "))"; - $filterQuery .= PHP_EOL . Indent::_(3) . "{"; - $filterQuery .= PHP_EOL . Indent::_(4) - . "\$query->where('" . $a . "." . $filter['code'] - . " = ' . (float) \$_" . $filter['code'] . ");"; - $filterQuery .= PHP_EOL . Indent::_(3) . "}"; - $filterQuery .= PHP_EOL . Indent::_(3) . "else"; - $filterQuery .= PHP_EOL . Indent::_(3) . "{"; - $filterQuery .= PHP_EOL . Indent::_(4) - . "\$query->where('" . $a . "." . $filter['code'] - . " = ' . (int) \$_" . $filter['code'] . ");"; - $filterQuery .= PHP_EOL . Indent::_(3) . "}"; - $filterQuery .= PHP_EOL . Indent::_(2) . "}"; - $filterQuery .= PHP_EOL . Indent::_(2) . "elseif (" - . $Helper . "::checkString(\$_" . $filter['code'] . "))"; - $filterQuery .= PHP_EOL . Indent::_(2) . "{"; - $filterQuery .= PHP_EOL . Indent::_(3) - . "\$query->where('" . $a . "." . $filter['code'] - . " = ' . \$db->quote(\$db->escape(\$_" . $filter['code'] - . ")));"; - $filterQuery .= PHP_EOL . Indent::_(2) . "}"; - $filterQuery .= PHP_EOL . Indent::_(2) . "elseif (" - . $Helper . "::checkArray(\$_" . $filter['code'] . "))"; - $filterQuery .= PHP_EOL . Indent::_(2) . "{"; - - $filterQuery .= PHP_EOL . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) . " Secure the array for the query"; - - $filterQuery .= PHP_EOL . Indent::_(3) . "\$_" . $filter['code'] - . " = array_map( function (\$val) use(&\$db) {"; - $filterQuery .= PHP_EOL . Indent::_(4) . "if (is_numeric(\$val))"; - $filterQuery .= PHP_EOL . Indent::_(4) . "{"; - $filterQuery .= PHP_EOL . Indent::_(5) . "if (is_float(\$val))"; - $filterQuery .= PHP_EOL . Indent::_(5) . "{"; - $filterQuery .= PHP_EOL . Indent::_(6) . "return (float) \$val;"; - $filterQuery .= PHP_EOL . Indent::_(5) . "}"; - $filterQuery .= PHP_EOL . Indent::_(5) . "else"; - $filterQuery .= PHP_EOL . Indent::_(5) . "{"; - $filterQuery .= PHP_EOL . Indent::_(6) . "return (int) \$val;"; - $filterQuery .= PHP_EOL . Indent::_(5) . "}"; - $filterQuery .= PHP_EOL . Indent::_(4) . "}"; - $filterQuery .= PHP_EOL . Indent::_(4) . "elseif (" - . $Helper . "::checkString(\$val))"; - $filterQuery .= PHP_EOL . Indent::_(4) . "{"; - $filterQuery .= PHP_EOL . Indent::_(5) - . "return \$db->quote(\$db->escape(\$val));"; - $filterQuery .= PHP_EOL . Indent::_(4) . "}"; - $filterQuery .= PHP_EOL . Indent::_(3) . "}, \$_" - . $filter['code'] . ");"; - - $filterQuery .= PHP_EOL . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) . " Filter by the " - . ucwords((string) $filter['code']) . " Array."; - - $filterQuery .= PHP_EOL . Indent::_(3) - . "\$query->where('" . $a . "." . $filter['code'] - . " IN (' . implode(',', \$_" . $filter['code'] . ") . ')');"; - $filterQuery .= PHP_EOL . Indent::_(2) . "}"; - - return $filterQuery; - } - - public function buildTheViewScript($viewArray) - { - // set the view name - $nameSingleCode = $viewArray['settings']->name_single_code; - // add conditions to this view - if (isset($viewArray['settings']->conditions) - && ArrayHelper::check( - $viewArray['settings']->conditions - )) - { - // reset defaults - $getValue = array(); - $ifValue = array(); - $targetControls = array(); - $functions = array(); - - foreach ($viewArray['settings']->conditions as $condition) - { - if (isset($condition['match_name']) - && StringHelper::check( - $condition['match_name'] - )) - { - $uniqueVar = $this->uniquekey(7); - $matchName = $condition['match_name'] . '_' - . $uniqueVar; - $targetBehavior = ($condition['target_behavior'] == 1 - || $condition['target_behavior'] == 3) ? 'show' - : 'hide'; - $targetDefault = ($condition['target_behavior'] == 1 - || $condition['target_behavior'] == 3) ? 'hide' - : 'show'; - - // set the realtation if any - if ($condition['target_relation']) - { - // chain to other items of the same target - $relations = $this->getTargetRelationScript( - $viewArray['settings']->conditions, $condition, - $nameSingleCode - ); - if (ArrayHelper::check($relations)) - { - // set behavior and default array - $behaviors[$matchName] = $targetBehavior; - $defaults[$matchName] = $targetDefault; - $toggleSwitch[$matchName] - = ($condition['target_behavior'] - == 1 - || $condition['target_behavior'] == 2) ? true - : false; - // set the type buket - $typeBuket[$matchName] = $condition['match_type']; - // set function array - $functions[$uniqueVar][0] = $matchName; - $matchNames[$matchName] - = $condition['match_name']; - // get the select value - $getValue[$matchName] = $this->getValueScript( - $condition['match_type'], - $condition['match_name'], - $condition['match_extends'], $uniqueVar - ); - // get the options - $options = $this->getOptionsScript( - $condition['match_type'], - $condition['match_options'] - ); - // set the if values - $ifValue[$matchName] = $this->ifValueScript( - $matchName, $condition['match_behavior'], - $condition['match_type'], $options - ); - // set the target controls - $targetControls[$matchName] - = $this->setTargetControlsScript( - $toggleSwitch[$matchName], - $condition['target_field'], $targetBehavior, - $targetDefault, $uniqueVar, $nameSingleCode - ); - - foreach ($relations as $relation) - { - if (StringHelper::check( - $relation['match_name'] - )) - { - $relationName = $relation['match_name'] - . '_' . $uniqueVar; - // set the type buket - $typeBuket[$relationName] - = $relation['match_type']; - // set function array - $functions[$uniqueVar][] = $relationName; - $matchNames[$relationName] - = $relation['match_name']; - // get the relation option - $relationOptions = $this->getOptionsScript( - $relation['match_type'], - $relation['match_options'] - ); - $getValue[$relationName] - = $this->getValueScript( - $relation['match_type'], - $relation['match_name'], - $condition['match_extends'], $uniqueVar - ); - $ifValue[$relationName] - = $this->ifValueScript( - $relationName, - $relation['match_behavior'], - $relation['match_type'], - $relationOptions - ); - } - } - } - } - else - { - // set behavior and default array - $behaviors[$matchName] = $targetBehavior; - $defaults[$matchName] = $targetDefault; - $toggleSwitch[$matchName] - = ($condition['target_behavior'] - == 1 - || $condition['target_behavior'] == 2) ? true - : false; - // set the type buket - $typeBuket[$matchName] = $condition['match_type']; - // set function array - $functions[$uniqueVar][0] = $matchName; - $matchNames[$matchName] = $condition['match_name']; - // get the select value - $getValue[$matchName] = $this->getValueScript( - $condition['match_type'], $condition['match_name'], - $condition['match_extends'], $uniqueVar - ); - // get the options - $options = $this->getOptionsScript( - $condition['match_type'], - $condition['match_options'] - ); - // set the if values - $ifValue[$matchName] = $this->ifValueScript( - $matchName, $condition['match_behavior'], - $condition['match_type'], $options - ); - // set the target controls - $targetControls[$matchName] - = $this->setTargetControlsScript( - $toggleSwitch[$matchName], - $condition['target_field'], $targetBehavior, - $targetDefault, $uniqueVar, $nameSingleCode - ); - } - } - } - // reset buckets - $initial = ''; - $func = ''; - $validation = ''; - $isSet = ''; - $listener = ''; - if (ArrayHelper::check($functions)) - { - // now build the initial script - $initial .= "//" . Line::_(__Line__, __Class__) . " Initial Script" - . PHP_EOL . "jQuery(document).ready(function()"; - $initial .= PHP_EOL . "{"; - foreach ($functions as $function => $matchKeys) - { - $func_call = $this->buildFunctionCall( - $function, $matchKeys, $getValue - ); - $initial .= $func_call['code']; - } - $initial .= "});" . PHP_EOL; - // for modal fields - $modal = ''; - // now build the listener scripts - foreach ($functions as $l_function => $l_matchKeys) - { - $funcCall = ''; - foreach ($l_matchKeys as $l_matchKey) - { - $name = $matchNames[$l_matchKey]; - $matchTypeKey = $typeBuket[$l_matchKey]; - $funcCall = $this->buildFunctionCall( - $l_function, $l_matchKeys, $getValue - ); - - if (CFactory::_('Compiler.Builder.Script.Media.Switch')->inArray($matchTypeKey)) - { - $modal .= $funcCall['code']; - } - else - { - if (CFactory::_('Compiler.Builder.Script.User.Switch')->inArray($matchTypeKey)) - { - $name = $name . '_id'; - } - - $listener .= PHP_EOL . "//" . Line::_( - __LINE__,__CLASS__ - ) . " #jform_" . $name . " listeners for " - . $l_matchKey . " function"; - $listener .= PHP_EOL . "jQuery('#jform_" . $name - . "').on('keyup',function()"; - $listener .= PHP_EOL . "{"; - $listener .= $funcCall['code']; - $listener .= PHP_EOL . "});"; - $listener .= PHP_EOL - . "jQuery('#adminForm').on('change', '#jform_" - . $name . "',function (e)"; - $listener .= PHP_EOL . "{"; - $listener .= PHP_EOL . Indent::_(1) - . "e.preventDefault();"; - $listener .= $funcCall['code']; - $listener .= PHP_EOL . "});" . PHP_EOL; - } - } - } - if (StringHelper::check($modal)) - { - $listener .= PHP_EOL . "window.SqueezeBox.initialize({"; - $listener .= PHP_EOL . Indent::_(1) . "onClose:function(){"; - $listener .= $modal; - $listener .= PHP_EOL . Indent::_(1) . "}"; - $listener .= PHP_EOL . "});" . PHP_EOL; - } - - // now build the function - $func = ''; - $head = ''; - foreach ($functions as $f_function => $f_matchKeys) - { - $map = ''; - // does this function require an array - $addArray = false; - $func_ = $this->buildFunctionCall( - $f_function, $f_matchKeys, $getValue - ); - // set array switch - if ($func_['array']) - { - $addArray = true; - } - $func .= PHP_EOL . "//" . Line::_(__Line__, __Class__) - . " the " . $f_function . " function"; - $func .= PHP_EOL . "function " . $f_function . "("; - $fucounter = 0; - foreach ($f_matchKeys as $fu_matchKey) - { - if (StringHelper::check($fu_matchKey)) - { - if ($fucounter == 0) - { - $func .= $fu_matchKey; - } - else - { - $func .= ',' . $fu_matchKey; - } - $fucounter++; - } - } - $func .= ")"; - $func .= PHP_EOL . "{"; - if ($addArray) - { - foreach ($f_matchKeys as $a_matchKey) - { - $name = $matchNames[$a_matchKey]; - $func .= PHP_EOL . Indent::_(1) . "if (isSet(" - . $a_matchKey . ") && " . $a_matchKey - . ".constructor !== Array)" . PHP_EOL - . Indent::_(1) . "{" . PHP_EOL . Indent::_(2) - . "var temp_" . $f_function . " = " - . $a_matchKey . ";" . PHP_EOL . Indent::_(2) - . "var " . $a_matchKey . " = [];" . PHP_EOL - . Indent::_(2) . $a_matchKey . ".push(temp_" - . $f_function . ");" . PHP_EOL . Indent::_(1) - . "}"; - $func .= PHP_EOL . Indent::_(1) . "else if (!isSet(" - . $a_matchKey . "))" . PHP_EOL . Indent::_(1) - . "{"; - $func .= PHP_EOL . Indent::_(2) . "var " - . $a_matchKey . " = [];"; - $func .= PHP_EOL . Indent::_(1) . "}"; - $func .= PHP_EOL . Indent::_(1) . "var " . $name - . " = " . $a_matchKey . ".some(" . $a_matchKey - . "_SomeFunc);" . PHP_EOL; - - // setup the map function - $map .= PHP_EOL . "//" . Line::_(__Line__, __Class__) - . " the " . $f_function . " Some function"; - $map .= PHP_EOL . "function " . $a_matchKey - . "_SomeFunc(" . $a_matchKey . ")"; - $map .= PHP_EOL . "{"; - $map .= PHP_EOL . Indent::_(1) . "//" - . Line::_(__Line__, __Class__) - . " set the function logic"; - $map .= PHP_EOL . Indent::_(1) . "if ("; - $if = $ifValue[$a_matchKey]; - if (StringHelper::check($if)) - { - $map .= $if; - } - $map .= ")"; - $map .= PHP_EOL . Indent::_(1) . "{"; - $map .= PHP_EOL . Indent::_(2) . "return true;"; - $map .= PHP_EOL . Indent::_(1) . "}" . PHP_EOL - . Indent::_(1) . "return false;"; - $map .= PHP_EOL . "}" . PHP_EOL; - } - $func .= PHP_EOL . PHP_EOL . Indent::_(1) . "//" - . Line::_(__Line__, __Class__) - . " set this function logic"; - $func .= PHP_EOL . Indent::_(1) . "if ("; - // set if counter - $aifcounter = 0; - foreach ($f_matchKeys as $af_matchKey) - { - $name = $matchNames[$af_matchKey]; - if ($aifcounter == 0) - { - $func .= $name; - } - else - { - $func .= ' && ' . $name; - } - $aifcounter++; - } - $func .= ")" . PHP_EOL . Indent::_(1) . "{"; - } - else - { - $func .= PHP_EOL . Indent::_(1) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " set the function logic"; - $func .= PHP_EOL . Indent::_(1) . "if ("; - // set if counter - $ifcounter = 0; - foreach ($f_matchKeys as $f_matchKey) - { - $if = $ifValue[$f_matchKey]; - if (StringHelper::check($if)) - { - if ($ifcounter == 0) - { - $func .= $if; - } - else - { - $func .= ' && ' . $if; - } - $ifcounter++; - } - } - $func .= ")" . PHP_EOL . Indent::_(1) . "{"; - } - // get the controles - $controls = $targetControls[$f_matchKeys[0]]; - // get target behavior and default - $targetBehavior = $behaviors[$f_matchKeys[0]]; - $targetDefault = $defaults[$f_matchKeys[0]]; - // load the target behavior - foreach ($controls as $target => $action) - { - $func .= $action['behavior']; - if (StringHelper::check( - $action[$targetBehavior] - )) - { - $func .= $action[$targetBehavior]; - $head .= $action['requiredVar']; - } - } - // check if this is a toggle switch - if ($toggleSwitch[$f_matchKeys[0]]) - { - $func .= PHP_EOL . Indent::_(1) . "}" . PHP_EOL - . Indent::_(1) . "else" . PHP_EOL . Indent::_(1) - . "{"; - // load the default behavior - foreach ($controls as $target => $action) - { - $func .= $action['default']; - if (StringHelper::check( - $action[$targetDefault] - )) - { - $func .= $action[$targetDefault]; - } - } - } - $func .= PHP_EOL . Indent::_(1) . "}" . PHP_EOL . "}" - . PHP_EOL . $map; - } - // add the needed validation to file - if (isset($this->validationFixBuilder[$nameSingleCode]) - && ArrayHelper::check( - $this->validationFixBuilder[$nameSingleCode] - )) - { - $validation .= PHP_EOL . "// update fields required"; - $validation .= PHP_EOL - . "function updateFieldRequired(name, status) {"; - $validation .= PHP_EOL . Indent::_(1) - . "// check if not_required exist"; - $validation .= PHP_EOL . Indent::_(1) - . "if (jQuery('#jform_not_required').length > 0) {"; - $validation .= PHP_EOL . Indent::_(2) - . "var not_required = jQuery('#jform_not_required').val().split(\",\");"; - $validation .= PHP_EOL . PHP_EOL . Indent::_(2) - . "if(status == 1)"; - $validation .= PHP_EOL . Indent::_(2) . "{"; - $validation .= PHP_EOL . Indent::_(3) - . "not_required.push(name);"; - $validation .= PHP_EOL . Indent::_(2) . "}"; - $validation .= PHP_EOL . Indent::_(2) . "else"; - $validation .= PHP_EOL . Indent::_(2) . "{"; - $validation .= PHP_EOL . Indent::_(3) - . "not_required = removeFieldFromNotRequired(not_required, name);"; - $validation .= PHP_EOL . Indent::_(2) . "}"; - $validation .= PHP_EOL . PHP_EOL . Indent::_(2) - . "jQuery('#jform_not_required').val(fixNotRequiredArray(not_required).toString());"; - $validation .= PHP_EOL . Indent::_(1) . "}"; - $validation .= PHP_EOL . "}" . PHP_EOL; - $validation .= PHP_EOL - . "// remove field from not_required"; - $validation .= PHP_EOL - . "function removeFieldFromNotRequired(array, what) {"; - $validation .= PHP_EOL . Indent::_(1) - . "return array.filter(function(element){"; - $validation .= PHP_EOL . Indent::_(2) - . "return element !== what;"; - $validation .= PHP_EOL . Indent::_(1) . "});"; - $validation .= PHP_EOL . "}" . PHP_EOL; - $validation .= PHP_EOL . "// fix not required array"; - $validation .= PHP_EOL - . "function fixNotRequiredArray(array) {"; - $validation .= PHP_EOL . Indent::_(1) . "var seen = {};"; - $validation .= PHP_EOL . Indent::_(1) - . "return removeEmptyFromNotRequiredArray(array).filter(function(item) {"; - $validation .= PHP_EOL . Indent::_(2) - . "return seen.hasOwnProperty(item) ? false : (seen[item] = true);"; - $validation .= PHP_EOL . Indent::_(1) . "});"; - $validation .= PHP_EOL . "}" . PHP_EOL; - $validation .= PHP_EOL - . "// remove empty from not_required array"; - $validation .= PHP_EOL - . "function removeEmptyFromNotRequiredArray(array) {"; - $validation .= PHP_EOL . Indent::_(1) - . "return array.filter(function (el) {"; - $validation .= PHP_EOL . Indent::_(2) - . "// remove ( 一_一) as well - lol"; - $validation .= PHP_EOL . Indent::_(2) - . "return (el.length > 0 && '一_一' !== el);"; - $validation .= PHP_EOL . Indent::_(1) . "});"; - $validation .= PHP_EOL . "}" . PHP_EOL; - } - // set the isSet function - $isSet = PHP_EOL . "// the isSet function"; - $isSet .= PHP_EOL . "function isSet(val)"; - $isSet .= PHP_EOL . "{"; - $isSet .= PHP_EOL . Indent::_(1) - . "if ((val != undefined) && (val != null) && 0 !== val.length){"; - $isSet .= PHP_EOL . Indent::_(2) . "return true;"; - $isSet .= PHP_EOL . Indent::_(1) . "}"; - $isSet .= PHP_EOL . Indent::_(1) . "return false;"; - $isSet .= PHP_EOL . "}"; - } - // load to this buket - $fileScript = $initial . $func . $validation . $isSet; - $footerScript = $listener; - } - // add custom script to edit form JS file - if (!isset($fileScript)) - { - $fileScript = ''; - } - $fileScript .= CFactory::_('Customcode.Dispenser')->get( - 'view_file', $nameSingleCode, PHP_EOL . PHP_EOL, null, true, '' - ); - // add custom script to footer - if (isset(CFactory::_('Customcode.Dispenser')->hub['view_footer'][$nameSingleCode]) - && StringHelper::check( - CFactory::_('Customcode.Dispenser')->hub['view_footer'][$nameSingleCode] - )) - { - $customFooterScript = PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( - CFactory::_('Customcode.Dispenser')->hub['view_footer'][$nameSingleCode] - ); - if (strpos($customFooterScript, 'name_list_code; - // add custom script to list view JS file - if (($list_fileScript = CFactory::_('Customcode.Dispenser')->get( - 'views_file', $nameSingleCode, PHP_EOL . PHP_EOL, null, true, - false - )) !== false - && StringHelper::check($list_fileScript)) - { - // get dates - $_created = CFactory::_('Model.Createdate')->get($viewArray); - $_modified = CFactory::_('Model.Modifieddate')->get($viewArray); - // add file to view - $_target = array(CFactory::_('Config')->build_target => $nameListCode); - $_config = array(Placefix::_h('CREATIONDATE') => $_created, - Placefix::_h('BUILDDATE') => $_modified, - Placefix::_h('VERSION') => $viewArray['settings']->version); - CFactory::_('Utilities.Structure')->build($_target, 'javascript_file', false, $_config); - // set path - $_path = '/administrator/components/com_' . CFactory::_('Config')->component_code_name - . '/assets/js/' . $nameListCode . '.js'; - // load the file to the list view - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_ADD_JAVASCRIPT_FILE', PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Add List View JavaScript File" . PHP_EOL . Indent::_(2) - . $this->setIncludeLibScript($_path) - ); - } - else - { - $list_fileScript = ''; - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_ADD_JAVASCRIPT_FILE', ''); - } - // minify the script - if (CFactory::_('Config')->get('minify', 0) && isset($list_fileScript) - && StringHelper::check($list_fileScript)) - { - // minify the fileScript javascript - $list_fileScript = Minify::js($list_fileScript); - } - // minify the script - if (CFactory::_('Config')->get('minify', 0) && isset($fileScript) - && StringHelper::check($fileScript)) - { - // minify the fileScript javascript - $fileScript = Minify::js($fileScript); - } - // minify the script - if (CFactory::_('Config')->get('minify', 0) && isset($footerScript) - && StringHelper::check($footerScript)) - { - // minify the footerScript javascript - $footerScript = Minify::js($footerScript); - } - // make sure there is script to add - if (isset($list_fileScript) - && StringHelper::check( - $list_fileScript - )) - { - // load the script - $this->viewScriptBuilder[$nameListCode]['list_fileScript'] - = $list_fileScript; - } - // make sure there is script to add - if (isset($fileScript) - && StringHelper::check( - $fileScript - )) - { - // add the head script if set - if (isset($head) && StringHelper::check($head)) - { - $fileScript = "// Some Global Values" . PHP_EOL . $head - . PHP_EOL . $fileScript; - } - // load the script - $this->viewScriptBuilder[$nameSingleCode]['fileScript'] - = $fileScript; - } - // make sure to add custom footer script if php was found in it, since we canot minfy it with php - if (isset($customFooterScript) - && StringHelper::check( - $customFooterScript - )) - { - if (!isset($footerScript)) - { - $footerScript = ''; - } - $footerScript .= $customFooterScript; - } - // make sure there is script to add - if (isset($footerScript) - && StringHelper::check( - $footerScript - )) - { - // add the needed script tags - $footerScript = PHP_EOL - . PHP_EOL . '"; - $this->viewScriptBuilder[$nameSingleCode]['footerScript'] - = $footerScript; - } - } - - public function buildFunctionCall($function, $matchKeys, $getValue) - { - $initial = ''; - $funcsets = array(); - $array = false; - foreach ($matchKeys as $matchKey) - { - $value = $getValue[$matchKey]; - if ($value['isArray']) - { - $initial .= PHP_EOL . Indent::_(1) . $value['get']; - $funcsets[] = $matchKey; - $array = true; - } - else - { - $initial .= PHP_EOL . Indent::_(1) . $value['get']; - $funcsets[] = $matchKey; - } - } - - // make sure that the function is loaded only once - if (ArrayHelper::check($funcsets)) - { - $initial .= PHP_EOL . Indent::_(1) . $function . "("; - $initial .= implode(',', $funcsets); - $initial .= ");" . PHP_EOL; - } - - return array('code' => $initial, 'array' => $array); - } - - public function getTargetRelationScript($relations, $condition, $view) - { - // reset the buket - $buket = array(); - // convert to name array - foreach ($condition['target_field'] as $targetField) - { - if (ArrayHelper::check($targetField) - && isset($targetField['name'])) - { - $currentTargets[] = $targetField['name']; - } - } - // start the search - foreach ($relations as $relation) - { - // reset found - $found = false; - // chain only none matching fields - if ($relation['match_field'] !== $condition['match_field'] - && $relation['target_relation']) // Made this change to see if it improves the expected result (TODO) - { - if (ArrayHelper::check( - $relation['target_field'] - )) - { - foreach ($relation['target_field'] as $target) - { - if (ArrayHelper::check($target) - && $this->checkRelationControl( - $target['name'], $relation['match_name'], - $condition['match_name'], $view - )) - { - if (in_array($target['name'], $currentTargets)) - { - $this->targetRelationControl[$view][$target['name']] - = array($relation['match_name'], - $condition['match_name']); - $found = true; - break; - } - } - } - if ($found) - { - $buket[] = $relation; - } - } - } - } - - return $buket; - } - - public function checkRelationControl($targetName, $relationMatchName, - $conditionMatchName, $view - ) - { - if (isset($this->targetRelationControl[$view]) - && ArrayHelper::check( - $this->targetRelationControl[$view] - )) - { - if (isset($this->targetRelationControl[$view][$targetName]) - && ArrayHelper::check( - $this->targetRelationControl[$view][$targetName] - )) - { - if (!in_array( - $relationMatchName, - $this->targetRelationControl[$view][$targetName] - ) - || !in_array( - $conditionMatchName, - $this->targetRelationControl[$view][$targetName] - )) - { - return true; - } - } - else - { - return true; - } - } - elseif (!isset($this->targetRelationControl[$view]) - || !ArrayHelper::check( - $this->targetRelationControl[$view] - )) - { - return true; - } - - return false; - } - - public function setTargetControlsScript($toggleSwitch, $targets, - $targetBehavior, $targetDefault, $uniqueVar, $nameSingleCode - ) - { - $bucket = array(); - if (ArrayHelper::check($targets) - && !in_array( - $uniqueVar, $this->targetControlsScriptChecker - )) - { - foreach ($targets as $target) - { - if (ArrayHelper::check($target)) - { - // set the required var - if ($target['required'] === 'yes') - { - $unique = $uniqueVar - . $this->uniquekey(3); - $bucket[$target['name']]['requiredVar'] = "jform_" - . $unique . "_required = false;" . PHP_EOL; - } - else - { - $bucket[$target['name']]['requiredVar'] = ''; - } - // set target type - $targetTypeSufix = ""; - if (CFactory::_('Field.Groups')->check( - $target['type'], 'spacer' - )) - { - // target a class if this is a note or spacer - $targetType = "."; - } - elseif ($target['type'] === 'editor' - || $target['type'] === 'subform') - { - // target the label if editor field - $targetType = "#jform_"; - // since the id is not alway accessable we use the lable TODO (not best way) - $targetTypeSufix = "-lbl"; - } - else - { - // target an id if this is a field - $targetType = "#jform_"; - } - // set the target behavior - $bucket[$target['name']]['behavior'] = PHP_EOL . Indent::_( - 2 - ) . "jQuery('" . $targetType . $target['name'] - . $targetTypeSufix . "').closest('.control-group')." - . $targetBehavior . "();"; - // set the target default - $bucket[$target['name']]['default'] = PHP_EOL . Indent::_(2) - . "jQuery('" . $targetType . $target['name'] - . $targetTypeSufix . "').closest('.control-group')." - . $targetDefault . "();"; - // the hide required function - if ($target['required'] === 'yes') - { - if ($toggleSwitch) - { - $hide = PHP_EOL - . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " remove required attribute from " - . $target['name'] . " field"; - $hide .= PHP_EOL - . Indent::_(2) . "if (!jform_" . $unique - . "_required)"; - $hide .= PHP_EOL - . Indent::_(2) . "{"; - $hide .= PHP_EOL - . Indent::_(3) . "updateFieldRequired('" - . $target['name'] . "',1);"; - $hide .= PHP_EOL - . Indent::_(3) . "jQuery('#jform_" - . $target['name'] - . "').removeAttr('required');"; - $hide .= PHP_EOL - . Indent::_(3) . "jQuery('#jform_" - . $target['name'] - . "').removeAttr('aria-required');"; - $hide .= PHP_EOL - . Indent::_(3) . "jQuery('#jform_" - . $target['name'] - . "').removeClass('required');"; - $hide .= PHP_EOL - . Indent::_(3) . "jform_" . $unique - . "_required = true;"; - $hide .= PHP_EOL - . Indent::_(2) . "}"; - $bucket[$target['name']]['hide'] = $hide; - // the show required function - $show = PHP_EOL - . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " add required attribute to " - . $target['name'] . " field"; - $show .= PHP_EOL - . Indent::_(2) . "if (jform_" . $unique - . "_required)"; - $show .= PHP_EOL - . Indent::_(2) . "{"; - $show .= PHP_EOL - . Indent::_(3) . "updateFieldRequired('" - . $target['name'] . "',0);"; - $show .= PHP_EOL - . Indent::_(3) . "jQuery('#jform_" - . $target['name'] - . "').prop('required','required');"; - $show .= PHP_EOL - . Indent::_(3) . "jQuery('#jform_" - . $target['name'] - . "').attr('aria-required',true);"; - $show .= PHP_EOL - . Indent::_(3) . "jQuery('#jform_" - . $target['name'] . "').addClass('required');"; - $show .= PHP_EOL - . Indent::_(3) . "jform_" . $unique - . "_required = false;"; - $show .= PHP_EOL - . Indent::_(2) . "}"; - $bucket[$target['name']]['show'] = $show; - } - else - { - $hide = PHP_EOL - . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " remove required attribute from " - . $target['name'] . " field"; - $hide .= PHP_EOL - . Indent::_(2) . "updateFieldRequired('" - . $target['name'] . "',1);"; - $hide .= PHP_EOL - . Indent::_(2) . "jQuery('#jform_" - . $target['name'] - . "').removeAttr('required');"; - $hide .= PHP_EOL - . Indent::_(2) . "jQuery('#jform_" - . $target['name'] - . "').removeAttr('aria-required');"; - $hide .= PHP_EOL - . Indent::_(2) . "jQuery('#jform_" - . $target['name'] - . "').removeClass('required');"; - $hide .= PHP_EOL - . Indent::_(2) . "jform_" . $unique - . "_required = true;" . PHP_EOL; - $bucket[$target['name']]['hide'] = $hide; - // the show required function - $show = PHP_EOL - . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " add required attribute to " - . $target['name'] . " field"; - $show .= PHP_EOL - . Indent::_(2) . "updateFieldRequired('" - . $target['name'] . "',0);"; - $show .= PHP_EOL - . Indent::_(2) . "jQuery('#jform_" - . $target['name'] - . "').prop('required','required');"; - $show .= PHP_EOL - . Indent::_(2) . "jQuery('#jform_" - . $target['name'] - . "').attr('aria-required',true);"; - $show .= PHP_EOL - . Indent::_(2) . "jQuery('#jform_" - . $target['name'] . "').addClass('required');"; - $show .= PHP_EOL - . Indent::_(2) . "jform_" . $unique - . "_required = false;" . PHP_EOL; - $bucket[$target['name']]['show'] = $show; - } - // make sure that the axaj and other needed things for this view is loaded - $this->validationFixBuilder[$nameSingleCode][] - = $target['name']; - } - else - { - $bucket[$target['name']]['hide'] = ''; - $bucket[$target['name']]['show'] = ''; - } - } - } - $this->targetControlsScriptChecker[] = $uniqueVar; - } - - return $bucket; - } - - public function ifValueScript($value, $behavior, $type, $options) - { - // reset string - $string = ''; - switch ($behavior) - { - case 1: // Is - // only 4 list/radio/checkboxes - if (CFactory::_('Field.Groups')->check($type, 'list') - || CFactory::_('Field.Groups')->check($type, 'dynamic') - || !CFactory::_('Field.Groups')->check($type)) - { - if (ArrayHelper::check($options)) - { - foreach ($options as $option) - { - if (!is_numeric($option)) - { - if ($option != 'true' && $option != 'false') - { - $option = "'" . $option . "'"; - } - } - if (StringHelper::check($string)) - { - $string .= ' || ' . $value . ' == ' . $option; - } - else - { - $string .= $value . ' == ' . $option; - } - } - } - else - { - $string .= 'isSet(' . $value . ')'; - } - } - break; - case 2: // Is Not - // only 4 list/radio/checkboxes - if (CFactory::_('Field.Groups')->check($type, 'list') - || CFactory::_('Field.Groups')->check($type, 'dynamic') - || !CFactory::_('Field.Groups')->check($type)) - { - if (ArrayHelper::check($options)) - { - foreach ($options as $option) - { - if (!is_numeric($option)) - { - if ($option != 'true' && $option != 'false') - { - $option = "'" . $option . "'"; - } - } - if (StringHelper::check($string)) - { - $string .= ' || ' . $value . ' != ' . $option; - } - else - { - $string .= $value . ' != ' . $option; - } - } - } - else - { - $string .= '!isSet(' . $value . ')'; - } - } - break; - case 3: // Any Selection - // only 4 list/radio/checkboxes/dynamic_list - if (CFactory::_('Field.Groups')->check($type, 'list') - || CFactory::_('Field.Groups')->check($type, 'dynamic') - || !CFactory::_('Field.Groups')->check($type)) - { - if (ArrayHelper::check($options)) - { - foreach ($options as $option) - { - if (!is_numeric($option)) - { - if ($option != 'true' && $option != 'false') - { - $option = "'" . $option . "'"; - } - } - if (StringHelper::check($string)) - { - $string .= ' || ' . $value . ' == ' . $option; - } - else - { - $string .= $value . ' == ' . $option; - } - } - } - else - { - $userFix = ''; - if (CFactory::_('Compiler.Builder.Script.User.Switch')->inArray($type)) - { - // TODO this needs a closer look, a bit buggy - $userFix = " && " . $value . " != 0"; - } - $string .= 'isSet(' . $value . ')' . $userFix; - } - } - break; - case 4: // Active (not empty) - // only 4 text_field - if (CFactory::_('Field.Groups')->check($type, 'text')) - { - $string .= 'isSet(' . $value . ')'; - } - break; - case 5: // Unactive (empty) - // only 4 text_field - if (CFactory::_('Field.Groups')->check($type, 'text')) - { - $string .= '!isSet(' . $value . ')'; - } - break; - case 6: // Key Word All (case-sensitive) - // only 4 text_field - if (CFactory::_('Field.Groups')->check($type, 'text')) - { - if (ArrayHelper::check( - $options['keywords'] - )) - { - foreach ($options['keywords'] as $keyword) - { - if (StringHelper::check($string)) - { - $string .= ' && ' . $value . '.indexOf("' - . $keyword . '") >= 0'; - } - else - { - $string .= $value . '.indexOf("' . $keyword - . '") >= 0'; - } - } - } - if (!StringHelper::check($string)) - { - $string .= $value . ' == "error"'; - } - } - break; - case 7: // Key Word Any (case-sensitive) - // only 4 text_field - if (CFactory::_('Field.Groups')->check($type, 'text')) - { - if (ArrayHelper::check( - $options['keywords'] - )) - { - foreach ($options['keywords'] as $keyword) - { - if (StringHelper::check($string)) - { - $string .= ' || ' . $value . '.indexOf("' - . $keyword . '") >= 0'; - } - else - { - $string .= $value . '.indexOf("' . $keyword - . '") >= 0'; - } - } - } - if (!StringHelper::check($string)) - { - $string .= $value . ' == "error"'; - } - } - break; - case 8: // Key Word All (case-insensitive) - // only 4 text_field - if (CFactory::_('Field.Groups')->check($type, 'text')) - { - if (ArrayHelper::check( - $options['keywords'] - )) - { - foreach ($options['keywords'] as $keyword) - { - $keyword = StringHelper::safe( - $keyword, 'w' - ); - if (StringHelper::check($string)) - { - $string .= ' && ' . $value - . '.toLowerCase().indexOf("' . $keyword - . '") >= 0'; - } - else - { - $string .= $value . '.toLowerCase().indexOf("' - . $keyword . '") >= 0'; - } - } - } - if (!StringHelper::check($string)) - { - $string .= $value . ' == "error"'; - } - } - break; - case 9: // Key Word Any (case-insensitive) - // only 4 text_field - if (CFactory::_('Field.Groups')->check($type, 'text')) - { - if (ArrayHelper::check( - $options['keywords'] - )) - { - foreach ($options['keywords'] as $keyword) - { - $keyword = StringHelper::safe( - $keyword, 'w' - ); - if (StringHelper::check($string)) - { - $string .= ' || ' . $value - . '.toLowerCase().indexOf("' . $keyword - . '") >= 0'; - } - else - { - $string .= $value . '.toLowerCase().indexOf("' - . $keyword . '") >= 0'; - } - } - } - if (!StringHelper::check($string)) - { - $string .= $value . ' == "error"'; - } - } - break; - case 10: // Min Length - // only 4 text_field - if (CFactory::_('Field.Groups')->check($type, 'text')) - { - if (ArrayHelper::check($options)) - { - if ($options['length']) - { - $string .= $value . '.length >= ' - . (int) $options['length']; - } - } - if (!StringHelper::check($string)) - { - $string .= $value . '.length >= 5'; - } - } - break; - case 11: // Max Length - // only 4 text_field - if (CFactory::_('Field.Groups')->check($type, 'text')) - { - if (ArrayHelper::check($options)) - { - if ($options['length']) - { - $string .= $value . '.length <= ' - . (int) $options['length']; - } - } - if (!StringHelper::check($string)) - { - $string .= $value . '.length <= 5'; - } - } - break; - case 12: // Exact Length - // only 4 text_field - if (CFactory::_('Field.Groups')->check($type, 'text')) - { - if (ArrayHelper::check($options)) - { - if ($options['length']) - { - $string .= $value . '.length == ' - . (int) $options['length']; - } - } - if (!StringHelper::check($string)) - { - $string .= $value . '.length == 5'; - } - } - break; - } - if (!StringHelper::check($string)) - { - $string = 0; - } - - return $string; - } - - public function getOptionsScript($type, $options) - { - $buket = array(); - if (StringHelper::check($options)) - { - if (CFactory::_('Field.Groups')->check($type, 'list') - || CFactory::_('Field.Groups')->check($type, 'dynamic') - || !CFactory::_('Field.Groups')->check($type)) - { - $optionsArray = array_map( - 'trim', (array) explode(PHP_EOL, (string) $options) - ); - if (!ArrayHelper::check($optionsArray)) - { - $optionsArray[] = $optionsArray; - } - foreach ($optionsArray as $option) - { - if (strpos($option, '|') !== false) - { - list($option) = array_map( - 'trim', (array) explode('|', $option) - ); - } - if ($option != 'dynamic_list') - { - // add option to return buket - $buket[] = $option; - } - } - } - elseif (CFactory::_('Field.Groups')->check($type, 'text')) - { - // check to get the key words if set - $keywords = GetHelper::between( - $options, 'keywords="', '"' - ); - if (StringHelper::check($keywords)) - { - if (strpos((string) $keywords, ',') !== false) - { - $keywords = array_map( - 'trim', (array) explode(',', (string) $keywords) - ); - foreach ($keywords as $keyword) - { - $buket['keywords'][] = trim($keyword); - } - } - else - { - $buket['keywords'][] = trim((string) $keywords); - } - } - // check to ket string length if set - $length = GetHelper::between( - $options, 'length="', '"' - ); - if (StringHelper::check($length)) - { - $buket['length'] = $length; - } - else - { - $buket['length'] = false; - } - } - } - - return $buket; - } - - public function getValueScript($type, $name, $extends, $unique) - { - $select = ''; - $isArray = false; - $keyName = $name . '_' . $unique; - if ($type === 'checkboxes' || $extends === 'checkboxes') - { - $select = "var " . $keyName . " = [];" . PHP_EOL . Indent::_(1) - . "jQuery('#jform_" . $name - . " input[type=checkbox]').each(function()" . PHP_EOL - . Indent::_(1) . "{" . PHP_EOL . Indent::_(2) - . "if (jQuery(this).is(':checked'))" . PHP_EOL . Indent::_(2) - . "{" . PHP_EOL . Indent::_(3) . $keyName - . ".push(jQuery(this).prop('value'));" . PHP_EOL . Indent::_(2) - . "}" . PHP_EOL . Indent::_(1) . "});"; - $isArray = true; - } - elseif ($type === 'checkbox') - { - $select = 'var ' . $keyName . ' = jQuery("#jform_' . $name - . '").prop(\'checked\');'; - } - elseif ($type === 'radio') - { - $select = 'var ' . $keyName . ' = jQuery("#jform_' . $name - . ' input[type=\'radio\']:checked").val();'; - } - elseif (CFactory::_('Compiler.Builder.Script.User.Switch')->inArray($type)) - { - // this is only since 3.3.4 - $select = 'var ' . $keyName . ' = jQuery("#jform_' . $name - . '_id").val();'; - } - elseif ($type === 'list' - || CFactory::_('Field.Groups')->check( - $type, 'dynamic' - ) - || !CFactory::_('Field.Groups')->check($type)) - { - $select = 'var ' . $keyName . ' = jQuery("#jform_' . $name - . '").val();'; - $isArray = true; - } - elseif (CFactory::_('Field.Groups')->check($type, 'text')) - { - $select = 'var ' . $keyName . ' = jQuery("#jform_' . $name - . '").val();'; - } - - return array('get' => $select, 'isArray' => $isArray); - } - - public function clearValueScript($type, $name, $unique) - { - $clear = ''; - $isArray = false; - $keyName = $name . '_' . $unique; - if ($type === 'text' || $type === 'password' || $type === 'textarea') - { - $clear = "jQuery('#jform_" . $name . "').value = '';"; - } - elseif ($type === 'radio') - { - $clear = "jQuery('#jform_" . $name . "').checked = false;"; - } - elseif ($type === 'checkboxes' || $type === 'checkbox' - || $type === 'checkbox') - { - $clear = "jQuery('#jform_" . $name . "').selectedIndex = -1;"; - } - - return $clear; - } - - public function setViewScript(&$view, $type) - { - if (isset($this->viewScriptBuilder[$view]) - && isset($this->viewScriptBuilder[$view][$type])) - { - return $this->viewScriptBuilder[$view][$type]; - } - - return ''; - } - - public function setValidationFix($view, $Component) - { - $fix = ''; - if (isset($this->validationFixBuilder[$view]) - && ArrayHelper::check( - $this->validationFixBuilder[$view] - )) - { - $fix .= PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $fix .= PHP_EOL . Indent::_(1) - . " * Method to validate the form data."; - $fix .= PHP_EOL . Indent::_(1) . " *"; - $fix .= PHP_EOL . Indent::_(1) - . " * @param JForm \$form The form to validate against."; - $fix .= PHP_EOL . Indent::_(1) - . " * @param array \$data The data to validate."; - $fix .= PHP_EOL . Indent::_(1) - . " * @param string \$group The name of the field group to validate."; - $fix .= PHP_EOL . Indent::_(1) . " *"; - $fix .= PHP_EOL . Indent::_(1) - . " * @return mixed Array of filtered data if valid, false otherwise."; - $fix .= PHP_EOL . Indent::_(1) . " *"; - $fix .= PHP_EOL . Indent::_(1) . " * @see JFormRule"; - $fix .= PHP_EOL . Indent::_(1) . " * @see JFilterInput"; - $fix .= PHP_EOL . Indent::_(1) . " * @since 12.2"; - $fix .= PHP_EOL . Indent::_(1) . " */"; - $fix .= PHP_EOL . Indent::_(1) - . "public function validate(\$form, \$data, \$group = null)"; - $fix .= PHP_EOL . Indent::_(1) . "{"; - $fix .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " check if the not_required field is set"; - $fix .= PHP_EOL . Indent::_(2) - . "if (isset(\$data['not_required']) && " . $Component - . "Helper::checkString(\$data['not_required']))"; - $fix .= PHP_EOL . Indent::_(2) . "{"; - $fix .= PHP_EOL . Indent::_(3) - . "\$requiredFields = (array) explode(',',(string) \$data['not_required']);"; - $fix .= PHP_EOL . Indent::_(3) - . "\$requiredFields = array_unique(\$requiredFields);"; - $fix .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " now change the required field attributes value"; - $fix .= PHP_EOL . Indent::_(3) - . "foreach (\$requiredFields as \$requiredField)"; - $fix .= PHP_EOL . Indent::_(3) . "{"; - $fix .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " make sure there is a string value"; - $fix .= PHP_EOL . Indent::_(4) . "if (" . $Component - . "Helper::checkString(\$requiredField))"; - $fix .= PHP_EOL . Indent::_(4) . "{"; - $fix .= PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__) - . " change to false"; - $fix .= PHP_EOL . Indent::_(5) - . "\$form->setFieldAttribute(\$requiredField, 'required', 'false');"; - $fix .= PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__) - . " also clear the data set"; - $fix .= PHP_EOL . Indent::_(5) . "\$data[\$requiredField] = '';"; - $fix .= PHP_EOL . Indent::_(4) . "}"; - $fix .= PHP_EOL . Indent::_(3) . "}"; - $fix .= PHP_EOL . Indent::_(2) . "}"; - $fix .= PHP_EOL . Indent::_(2) - . "return parent::validate(\$form, \$data, \$group);"; - $fix .= PHP_EOL . Indent::_(1) . "}"; - } - - return $fix; - } - - public function setAjaxToke(&$view) - { - $fix = ''; - if (isset(CFactory::_('Customcode.Dispenser')->hub['token'][$view]) - && CFactory::_('Customcode.Dispenser')->hub['token'][$view]) - { - $fix .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Add Ajax Token"; - $fix .= PHP_EOL . Indent::_(2) - . "\$this->document->addScriptDeclaration(\"var token = '\".JSession::getFormToken().\"';\");"; - } - - return $fix; - } - - public function setRegisterAjaxTask($target) - { - $tasks = ''; - if (isset(CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller']) - && ArrayHelper::check( - CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller'] - )) - { - $taskArray = array(); - foreach ( - CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller'] as $view - ) - { - foreach ($view as $task) - { - $taskArray[$task['task_name']] = $task['task_name']; - } - } - if (ArrayHelper::check($taskArray)) - { - foreach ($taskArray as $name) - { - $tasks .= PHP_EOL . Indent::_(2) . "\$this->registerTask('" - . $name . "', 'ajax');"; - } - } - } - - return $tasks; - } - - public function setAjaxInputReturn($target) - { - $cases = ''; - if (isset(CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller']) - && ArrayHelper::check( - CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller'] - )) - { - $input = array(); - $valueArray = array(); - $ifArray = array(); - $getModel = array(); - $userCheck = array(); - foreach ( - CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller'] as $view - ) - { - foreach ($view as $task) - { - $input[$task['task_name']][] = "\$" - . $task['value_name'] . "Value = \$jinput->get('" - . $task['value_name'] . "', " . $task['input_default'] - . ", '" . $task['input_filter'] . "');"; - $valueArray[$task['task_name']][] = "\$" - . $task['value_name'] . "Value"; - $getModel[$task['task_name']] - = "\$result = \$this->getModel('ajax')->" - . $task['method_name'] . "(" . Placefix::_("valueArray") . ");"; - // check if null or zero is allowed - if (!isset($task['allow_zero']) || 1 != $task['allow_zero']) - { - $ifArray[$task['task_name']][] = "\$" - . $task['value_name'] . "Value"; - } - // see user check is needed - if (!isset($userCheck[$task['task_name']]) - && isset($task['user_check']) - && 1 == $task['user_check']) - { - // add it since this means it was not set, and in the old method we assumed it was inplace - // or it is set and 1 means we still want it inplace - $ifArray[$task['task_name']][] = '$user->id != 0'; - // add it only once - $userCheck[$task['task_name']] = true; - } - } - } - if (ArrayHelper::check($getModel)) - { - foreach ($getModel as $task => $getMethod) - { - $cases .= PHP_EOL . Indent::_(4) . "case '" . $task . "':"; - $cases .= PHP_EOL . Indent::_(5) . "try"; - $cases .= PHP_EOL . Indent::_(5) . "{"; - foreach ($input[$task] as $string) - { - $cases .= PHP_EOL . Indent::_(6) . $string; - } - // set the values - $values = implode(', ', $valueArray[$task]); - // set the values to method - $getMethod = str_replace( - Placefix::_('valueArray'), $values, - $getMethod - ); - // check if we have some values to check - if (isset($ifArray[$task]) - && ArrayHelper::check($ifArray[$task])) - { - // set if string - $ifvalues = implode(' && ', $ifArray[$task]); - // add to case - $cases .= PHP_EOL . Indent::_(6) . "if(" . $ifvalues - . ")"; - $cases .= PHP_EOL . Indent::_(6) . "{"; - $cases .= PHP_EOL . Indent::_(7) . $getMethod; - $cases .= PHP_EOL . Indent::_(6) . "}"; - $cases .= PHP_EOL . Indent::_(6) . "else"; - $cases .= PHP_EOL . Indent::_(6) . "{"; - $cases .= PHP_EOL . Indent::_(7) . "\$result = false;"; - $cases .= PHP_EOL . Indent::_(6) . "}"; - } - else - { - $cases .= PHP_EOL . Indent::_(6) . $getMethod; - } - // continue the build - $cases .= PHP_EOL . Indent::_(6) - . "if(\$callback)"; - $cases .= PHP_EOL . Indent::_(6) . "{"; - $cases .= PHP_EOL . Indent::_(7) - . "echo \$callback . \"(\".json_encode(\$result).\");\";"; - $cases .= PHP_EOL . Indent::_(6) . "}"; - $cases .= PHP_EOL . Indent::_(6) . "elseif(\$returnRaw)"; - $cases .= PHP_EOL . Indent::_(6) . "{"; - $cases .= PHP_EOL . Indent::_(7) - . "echo json_encode(\$result);"; - $cases .= PHP_EOL . Indent::_(6) . "}"; - $cases .= PHP_EOL . Indent::_(6) . "else"; - $cases .= PHP_EOL . Indent::_(6) . "{"; - $cases .= PHP_EOL . Indent::_(7) - . "echo \"(\".json_encode(\$result).\");\";"; - $cases .= PHP_EOL . Indent::_(6) . "}"; - $cases .= PHP_EOL . Indent::_(5) . "}"; - $cases .= PHP_EOL . Indent::_(5) . "catch(Exception \$e)"; - $cases .= PHP_EOL . Indent::_(5) . "{"; - $cases .= PHP_EOL . Indent::_(6) - . "if(\$callback)"; - $cases .= PHP_EOL . Indent::_(6) . "{"; - $cases .= PHP_EOL . Indent::_(7) - . "echo \$callback.\"(\".json_encode(\$e).\");\";"; - $cases .= PHP_EOL . Indent::_(6) . "}"; - $cases .= PHP_EOL . Indent::_(6) - . "elseif(\$returnRaw)"; - $cases .= PHP_EOL . Indent::_(6) . "{"; - $cases .= PHP_EOL . Indent::_(7) - . "echo json_encode(\$e);"; - $cases .= PHP_EOL . Indent::_(6) . "}"; - $cases .= PHP_EOL . Indent::_(6) . "else"; - $cases .= PHP_EOL . Indent::_(6) . "{"; - $cases .= PHP_EOL . Indent::_(7) - . "echo \"(\".json_encode(\$e).\");\";"; - $cases .= PHP_EOL . Indent::_(6) . "}"; - $cases .= PHP_EOL . Indent::_(5) . "}"; - $cases .= PHP_EOL . Indent::_(4) . "break;"; - } - } - } - - return $cases; - } - - public function setAjaxModelMethods($target) - { - $methods = ''; - if (isset(CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_model']) - && ArrayHelper::check( - CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_model'] - )) - { - foreach ( - CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_model'] as $view => - $method - ) - { - $methods .= PHP_EOL . PHP_EOL . Indent::_(1) . "//" - . Line::_(__Line__, __Class__) . " Used in " . $view . PHP_EOL; - $methods .= CFactory::_('Placeholder')->update_( - $method - ); - } - } - - return $methods; - } - - /** - * build filter functions - * - * @param string $nameSingleCode The single view name - * @param string $nameListCode The list view name - * - * @return string The php to place in view.html.php - * - */ - public function setFilterFieldHelper(&$nameSingleCode, &$nameListCode) - { - // the old filter type uses these functions - if (CFactory::_('Compiler.Builder.Filter')->exists($nameListCode)) - { - // set the function or file path (2 = topbar) - $funtion_path = true; - if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2) - { - $funtion_path = false; - } - $function = array(); - // set component name - $component = CFactory::_('Config')->component_code_name; - $Component = ucfirst((string) $component); - foreach (CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as $filter) - { - if ($filter['type'] != 'category' - && ArrayHelper::check($filter['custom']) - && $filter['custom']['extends'] === 'user') - { - // add if this is a function path - if ($funtion_path) - { - $function[] = PHP_EOL . Indent::_(1) - . "protected function getThe" . $filter['function'] - . StringHelper::safe( - $filter['custom']['text'], 'F' - ) . "Selections()"; - $function[] = Indent::_(1) . "{"; - } - $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Get a db connection."; - $function[] = Indent::_(2) . "\$db = JFactory::getDbo();"; - $function[] = PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) - . " Create a new query object."; - $function[] = Indent::_(2) - . "\$query = \$db->getQuery(true);"; - $function[] = PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Select the text."; - $function[] = Indent::_(2) - . "\$query->select(\$db->quoteName(array('a." - . $filter['custom']['id'] . "','a." - . $filter['custom']['text'] . "')));"; - $function[] = Indent::_(2) - . "\$query->from(\$db->quoteName('" - . $filter['custom']['table'] . "', 'a'));"; - $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " get the targeted groups"; - $function[] = Indent::_(2) - . "\$groups= JComponentHelper::getParams('com_" - . $component . "')->get('" . $filter['type'] . "');"; - $function[] = Indent::_(2) - . "if (!empty(\$groups) && count((array) \$groups) > 0)"; - $function[] = Indent::_(2) . "{"; - $function[] = Indent::_(3) - . "\$query->join('LEFT', \$db->quoteName('#__user_usergroup_map', 'group') . ' ON (' . \$db->quoteName('group.user_id') . ' = ' . \$db->quoteName('a.id') . ')');"; - $function[] = Indent::_(3) - . "\$query->where('group.group_id IN (' . implode(',', \$groups) . ')');"; - $function[] = Indent::_(2) . "}"; - $function[] = Indent::_(2) . "\$query->order('a." - . $filter['custom']['text'] . " ASC');"; - $function[] = PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) - . " Reset the query using our newly populated query object."; - $function[] = Indent::_(2) . "\$db->setQuery(\$query);"; - $function[] = PHP_EOL . Indent::_(2) - . "\$results = \$db->loadObjectList();"; - $function[] = Indent::_(2) . "\$_filter = array();"; - // if this is not a multi field - if (!$funtion_path && $filter['multi'] == 1) - { - $function[] = Indent::_(2) - . "\$_filter[] = JHtml::_('select.option', '', '- Select ' . JText:" - . ":_('" . $filter['lang'] . "') . ' -');"; - } - $function[] = Indent::_(2) . "if (\$results)"; - $function[] = Indent::_(2) . "{"; - $function[] = Indent::_(3) - . "foreach (\$results as \$result)"; - $function[] = Indent::_(3) . "{"; - $function[] = Indent::_(4) - . "\$_filter[] = JHtml::_('select.option', \$result->" - . $filter['custom']['id'] . ", \$result->" - . $filter['custom']['text'] . ");"; - $function[] = Indent::_(3) . "}"; - $function[] = Indent::_(2) . "}"; - $function[] = Indent::_(2) . "return \$_filter;"; - // add if this is a function path - if ($funtion_path) - { - $function[] = Indent::_(1) . "}"; - } - - /* else - { - $function[] = PHP_EOL.Indent::_(1) . "protected function getThe".$filter['function'].StringHelper::safe($filter['custom']['text'],'F')."Selections()"; - $function[] = Indent::_(1) . "{"; - $function[] = Indent::_(2) . "//".Line::_(__Line__, __Class__)." Get a db connection."; - $function[] = Indent::_(2) . "\$db = JFactory::getDbo();"; - $function[] = PHP_EOL.Indent::_(2) . "//".Line::_(__Line__, __Class__)." Select the text."; - $function[] = Indent::_(2) . "\$query = \$db->getQuery(true);"; - $function[] = PHP_EOL.Indent::_(2) . "//".Line::_(__Line__, __Class__)." Select the text."; - $function[] = Indent::_(2) . "\$query->select(\$db->quoteName(array('".$filter['custom']['id']."','".$filter['custom']['text']."')));"; - $function[] = Indent::_(2) . "\$query->from(\$db->quoteName('".$filter['custom']['table']."'));"; - $function[] = Indent::_(2) . "\$query->where(\$db->quoteName('published') . ' = 1');"; - $function[] = Indent::_(2) . "\$query->order(\$db->quoteName('".$filter['custom']['text']."') . ' ASC');"; - $function[] = PHP_EOL.Indent::_(2) . "//".Line::_(__Line__, __Class__)." Reset the query using our newly populated query object."; - $function[] = Indent::_(2) . "\$db->setQuery(\$query);"; - $function[] = PHP_EOL.Indent::_(2) . "\$results = \$db->loadObjectList();"; - $function[] = PHP_EOL.Indent::_(2) . "if (\$results)"; - $function[] = Indent::_(2) . "{"; - $function[] = Indent::_(3) . "\$filter = array();"; - $function[] = Indent::_(3) . "\$batch = array();"; - $function[] = Indent::_(3) . "foreach (\$results as \$result)"; - $function[] = Indent::_(3) . "{"; - if ($filter['custom']['text'] === 'user') - { - $function[] = Indent::_(4) . "\$filter[] = JHtml::_('select.option', \$result->".$filter['custom']['text'].", JFactory::getUser(\$result->".$filter['custom']['text'].")->name);"; - $function[] = Indent::_(4) . "\$batch[] = JHtml::_('select.option', \$result->".$filter['custom']['id'].", JFactory::getUser(\$result->".$filter['custom']['text'].")->name);"; - } - else - { - $function[] = Indent::_(4) . "\$filter[] = JHtml::_('select.option', \$result->".$filter['custom']['text'].", \$result->".$filter['custom']['text'].");"; - $function[] = Indent::_(4) . "\$batch[] = JHtml::_('select.option', \$result->".$filter['custom']['id'].", \$result->".$filter['custom']['text'].");"; - } - $function[] = Indent::_(3) . "}"; - $function[] = Indent::_(3) . "return array('filter' => \$filter, 'batch' => \$batch);"; - $function[] = Indent::_(2) . "}"; - $function[] = Indent::_(2) . "return false;"; - $function[] = Indent::_(1) . "}"; - } */ - } - elseif ($filter['type'] != 'category' - && !ArrayHelper::check($filter['custom'])) - { - $translation = false; - if (CFactory::_('Compiler.Builder.Selection.Translation')-> - exists($nameListCode . '.' . $filter['code'])) - { - $translation = true; - } - // add if this is a function path - if ($funtion_path) - { - $function[] = PHP_EOL . Indent::_(1) - . "protected function getThe" . $filter['function'] - . "Selections()"; - $function[] = Indent::_(1) . "{"; - $function[] = Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) - . " Get a db connection."; - } - else - { - $function[] = "//" . Line::_(__Line__, __Class__) - . " Get a db connection."; - } - $function[] = Indent::_(2) . "\$db = JFactory::getDbo();"; - $function[] = PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) - . " Create a new query object."; - $function[] = Indent::_(2) - . "\$query = \$db->getQuery(true);"; - - // check if usergroup as we change to an object query - if ($filter['type'] === 'usergroup') - { - $function[] = PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Select the text."; - $function[] = Indent::_(2) - . "\$query->select(\$db->quoteName('g." - . $filter['code'] . "', 'id'));"; - $function[] = Indent::_(2) - . "\$query->select(\$db->quoteName('ug.title', 'title'));"; - $function[] = Indent::_(2) - . "\$query->from(\$db->quoteName('#__" . $component - . "_" . $filter['database'] . "', 'g'));"; - $function[] = Indent::_(2) - . "\$query->join('LEFT', \$db->quoteName('#__usergroups', 'ug') . ' ON (' . (\$db->quoteName('g." - . $filter['code'] - . "') . ' = ' . \$db->quoteName('ug.id') . ')'));"; - $function[] = Indent::_(2) - . "\$query->order(\$db->quoteName('title') . ' ASC');"; - $function[] = Indent::_(2) - . "\$query->group(\$db->quoteName('ug.id'));"; - $function[] = PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) - . " Reset the query using our newly populated query object."; - $function[] = Indent::_(2) . "\$db->setQuery(\$query);"; - $function[] = PHP_EOL . Indent::_(2) - . "\$_results = \$db->loadObjectList();"; - } - else - { - $function[] = PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Select the text."; - $function[] = Indent::_(2) - . "\$query->select(\$db->quoteName('" - . $filter['code'] . "'));"; - $function[] = Indent::_(2) - . "\$query->from(\$db->quoteName('#__" . $component - . "_" . $filter['database'] . "'));"; - $function[] = Indent::_(2) - . "\$query->order(\$db->quoteName('" - . $filter['code'] . "') . ' ASC');"; - $function[] = PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) - . " Reset the query using our newly populated query object."; - $function[] = Indent::_(2) . "\$db->setQuery(\$query);"; - $function[] = PHP_EOL . Indent::_(2) - . "\$_results = \$db->loadColumn();"; - } - $function[] = Indent::_(2) . "\$_filter = array();"; - // if this is not a multi field - if (!$funtion_path && $filter['multi'] == 1) - { - $function[] = Indent::_(2) - . "\$_filter[] = JHtml::_('select.option', '', '- ' . JText:" - . ":_('" . $filter['lang_select'] . "') . ' -');"; - } - $function[] = PHP_EOL . Indent::_(2) . "if (\$_results)"; - $function[] = Indent::_(2) . "{"; - - // check if translated value is used - if ($funtion_path && $translation) - { - $function[] = Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " get model"; - $function[] = Indent::_(3) - . "\$_model = \$this->getModel();"; - } - elseif ($translation) - { - $function[] = Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " get " . $nameListCode . "model"; - $function[] = Indent::_(3) - . "\$_model = " . $Component . "Helper::getModel('" - . $nameListCode . "');"; - } - // check if usergroup as we change to an object query - if ($filter['type'] !== 'usergroup') - { - $function[] = Indent::_(3) - . "\$_results = array_unique(\$_results);"; - } - $function[] = Indent::_(3) . "foreach (\$_results as \$" - . $filter['code'] . ")"; - $function[] = Indent::_(3) . "{"; - - // check if translated value is used - if ($translation) - { - $function[] = Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Translate the " . $filter['code'] - . " selection"; - $function[] = Indent::_(4) - . "\$_text = \$_model->selectionTranslation(\$" - . $filter['code'] . ",'" . $filter['code'] . "');"; - $function[] = Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Now add the " . $filter['code'] - . " and its text to the options array"; - $function[] = Indent::_(4) - . "\$_filter[] = JHtml::_('select.option', \$" - . $filter['code'] . ", JText:" . ":_(\$_text));"; - } - elseif ($filter['type'] === 'user') - { - $function[] = Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Now add the " . $filter['code'] - . " and its text to the options array"; - $function[] = Indent::_(4) - . "\$_filter[] = JHtml::_('select.option', \$" - . $filter['code'] . ", JFactory::getUser(\$" - . $filter['code'] . ")->name);"; - } - else - { - if ($filter['type'] === 'usergroup') - { - $function[] = Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Now add the " . $filter['code'] - . " and its text to the options array"; - $function[] = Indent::_(4) - . "\$_filter[] = JHtml::_('select.option', \$" - . $filter['code'] . "->id, \$" . $filter['code'] - . "->title);"; - } - else - { - $function[] = Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Now add the " . $filter['code'] - . " and its text to the options array"; - $function[] = Indent::_(4) - . "\$_filter[] = JHtml::_('select.option', \$" - . $filter['code'] . ", \$" . $filter['code'] - . ");"; - } - } - $function[] = Indent::_(3) . "}"; - $function[] = Indent::_(2) . "}"; - $function[] = Indent::_(2) . "return \$_filter;"; - // add if this is a function path - if ($funtion_path) - { - $function[] = Indent::_(1) . "}"; - } - } - // we check if this is a multi field - // and if there is a blank option - // and give a notice that this will cause an issue - elseif (!$funtion_path && $filter['type'] != 'category' - && $filter['multi'] == 2 - && ArrayHelper::check($filter['custom'])) - { - // get the field code - $field_code = $this->getCustomFieldCode( - $filter['custom'] - )['JFORM_TYPE_PHP']; - // check for the [JHtml::_('select.option', '',] code - if (strpos((string) $field_code, "JHtml::_('select.option', '',") - !== false - && strpos((string) $field_code, '($this->multiple === false)') - === false) - { - // for now we just give an error message (don't fix it) - $this->app->enqueueMessage( - JText::_('

    Multi Filter Error

    '), - 'Error' - ); - $field_url - = '"index.php?option=com_componentbuilder&view=fields&task=field.edit&id=' - . $filter['id'] . '" target="_blank"'; - $field_fix - = "
    if (\$this->multiple === false) { // <-- this if statement is needed";
    -						$field_fix .= PHP_EOL . Indent::_(1)
    -							. "\$options[] = JHtml::_('select.option', '', 'Select an option'); // <-- the empty option";
    -						$field_fix .= PHP_EOL . "}
    "; - $this->app->enqueueMessage( - JText::sprintf( - 'We detected that you have an empty option in a custom field (%s) that is used in a multi filter.
    This will cause a problem, you will need to add the following code to it.
    %s', - $field_url, - $filter['code'], - $field_fix - ), 'Error' - ); - } - } - // divert the code to a file if this is not a funtion path - if (!$funtion_path - && ArrayHelper::check( - $function - )) - { - // set the filter file - $this->setFilterFieldFile( - implode(PHP_EOL, $function), $filter - ); - // clear the filter out - $function = array(); - } - } - // if this is a function path, return the function if set - if ($funtion_path && ArrayHelper::check($function)) - { - // return the function - return PHP_EOL . implode(PHP_EOL, $function); - } - } - - return ''; - } - - public function setUniqueFields(&$view) - { - $fields = array(); - $fields[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $fields[] = Indent::_(1) - . " * Method to get the unique fields of this table."; - $fields[] = Indent::_(1) . " *"; - $fields[] = Indent::_(1) - . " * @return mixed An array of field names, boolean false if none is set."; - $fields[] = Indent::_(1) . " *"; - $fields[] = Indent::_(1) . " * @since 3.0"; - $fields[] = Indent::_(1) . " */"; - $fields[] = Indent::_(1) . "protected function getUniqueFields()"; - $fields[] = Indent::_(1) . "{"; - if (CFactory::_('Compiler.Builder.Database.Unique.Keys')->exists($view)) - { - // if guid should also be added - if (CFactory::_('Compiler.Builder.Database.Unique.Guid')->exists($view)) - { - $fields[] = Indent::_(2) . "return array('" . implode( - "','", CFactory::_('Compiler.Builder.Database.Unique.Keys')->get($view) - ) . "', 'guid');"; - } - else - { - $fields[] = Indent::_(2) . "return array('" . implode( - "','", CFactory::_('Compiler.Builder.Database.Unique.Keys')->get($view) - ) . "');"; - } - } - // if only GUID is found - elseif (CFactory::_('Compiler.Builder.Database.Unique.Guid')->exists($view)) - { - $fields[] = Indent::_(2) . "return array('guid');"; - } - else - { - $fields[] = Indent::_(2) . "return false;"; - } - $fields[] = Indent::_(1) . "}"; - - // return the unique fields - return implode(PHP_EOL, $fields); - } - - /** - * build sidebar filter loading scripts - * - * @param string $nameSingleCode The single view name - * @param string $nameListCode The list view name - * - * @return string The php to place in view.html.php - * - */ - public function setFilterFieldSidebarDisplayHelper(&$nameSingleCode, - &$nameListCode - ) - { - // start the filter bucket - $fieldFilters = array(); - // add the default filter - $this->setDefaultSidebarFilterHelper( - $fieldFilters, $nameSingleCode, $nameListCode - ); - // add the category filter stuff - $this->setCategorySidebarFilterHelper($fieldFilters, $nameListCode); - // check if filter fields are added (1 = sidebar) - if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 1 - && CFactory::_('Compiler.Builder.Filter')->exists($nameListCode)) - { - // get component name - $Component = CFactory::_('Compiler.Builder.Content.One')->get('Component'); - // load the rest of the filters - foreach (CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as $filter) - { - if ($filter['type'] != 'category' - && ArrayHelper::check($filter['custom']) - && $filter['custom']['extends'] !== 'user') - { - $CodeName = StringHelper::safe( - $filter['code'] . ' ' . $filter['custom']['text'], 'W' - ); - $codeName = $filter['code'] - . StringHelper::safe( - $filter['custom']['text'], 'F' - ); - $type = StringHelper::safe( - $filter['custom']['type'], 'F' - ); - $fieldFilters[] = PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Set " . $CodeName - . " Selection"; - $fieldFilters[] = Indent::_(2) . "\$this->" . $codeName - . "Options = JFormHelper::loadFieldType('" . $type - . "')->options;"; - $fieldFilters[] = Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " We do some sanitation for " . $CodeName - . " filter"; - $fieldFilters[] = Indent::_(2) . "if (" . $Component - . "Helper::checkArray(\$this->" . $codeName - . "Options) &&"; - $fieldFilters[] = Indent::_(3) . "isset(\$this->" - . $codeName - . "Options[0]->value) &&"; - $fieldFilters[] = Indent::_(3) . "!" . $Component - . "Helper::checkString(\$this->" . $codeName - . "Options[0]->value))"; - $fieldFilters[] = Indent::_(2) . "{"; - $fieldFilters[] = Indent::_(3) . "unset(\$this->" - . $codeName - . "Options[0]);"; - $fieldFilters[] = Indent::_(2) . "}"; - $fieldFilters[] = Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Only load " . $CodeName - . " filter if it has values"; - $fieldFilters[] = Indent::_(2) . "if (" . $Component - . "Helper::checkArray(\$this->" . $codeName - . "Options))"; - $fieldFilters[] = Indent::_(2) . "{"; - $fieldFilters[] = Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " " . $CodeName . " Filter"; - $fieldFilters[] = Indent::_(3) . "JHtmlSidebar::addFilter("; - $fieldFilters[] = Indent::_(4) . "'- Select ' . JText:" - . ":_('" . $filter['lang'] . "') . ' -',"; - $fieldFilters[] = Indent::_(4) . "'filter_" - . $filter['code'] - . "',"; - $fieldFilters[] = Indent::_(4) - . "JHtml::_('select.options', \$this->" . $codeName - . "Options, 'value', 'text', \$this->state->get('filter." - . $filter['code'] . "'))"; - $fieldFilters[] = Indent::_(3) . ");"; - $fieldFilters[] = Indent::_(2) . "}"; - } - elseif ($filter['type'] != 'category') - { - $Codename = StringHelper::safe( - $filter['code'], 'W' - ); - if (isset($filter['custom']) - && ArrayHelper::check($filter['custom']) - && $filter['custom']['extends'] === 'user') - { - $functionName = "\$this->getThe" . $filter['function'] - . StringHelper::safe( - $filter['custom']['text'], 'F' - ) . "Selections();"; - } - else - { - $functionName = "\$this->getThe" . $filter['function'] - . "Selections();"; - } - $fieldFilters[] = PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Set " . $Codename - . " Selection"; - $fieldFilters[] = Indent::_(2) . "\$this->" - . $filter['code'] - . "Options = " . $functionName; - $fieldFilters[] = Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " We do some sanitation for " . $Codename - . " filter"; - $fieldFilters[] = Indent::_(2) . "if (" . $Component - . "Helper::checkArray(\$this->" . $filter['code'] - . "Options) &&"; - $fieldFilters[] = Indent::_(3) . "isset(\$this->" - . $filter['code'] . "Options[0]->value) &&"; - $fieldFilters[] = Indent::_(3) . "!" . $Component - . "Helper::checkString(\$this->" . $filter['code'] - . "Options[0]->value))"; - $fieldFilters[] = Indent::_(2) . "{"; - $fieldFilters[] = Indent::_(3) . "unset(\$this->" - . $filter['code'] . "Options[0]);"; - $fieldFilters[] = Indent::_(2) . "}"; - $fieldFilters[] = Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Only load " . $Codename - . " filter if it has values"; - $fieldFilters[] = Indent::_(2) . "if (" . $Component - . "Helper::checkArray(\$this->" . $filter['code'] - . "Options))"; - $fieldFilters[] = Indent::_(2) . "{"; - $fieldFilters[] = Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " " . $Codename . " Filter"; - $fieldFilters[] = Indent::_(3) . "JHtmlSidebar::addFilter("; - $fieldFilters[] = Indent::_(4) . "'- Select '.JText:" - . ":_('" . $filter['lang'] . "').' -',"; - $fieldFilters[] = Indent::_(4) . "'filter_" - . $filter['code'] - . "',"; - $fieldFilters[] = Indent::_(4) - . "JHtml::_('select.options', \$this->" - . $filter['code'] - . "Options, 'value', 'text', \$this->state->get('filter." - . $filter['code'] . "'))"; - $fieldFilters[] = Indent::_(3) . ");"; - - $fieldFilters[] = Indent::_(2) . "}"; - } - } - } - // did we find filters - if (ArrayHelper::check($fieldFilters)) - { - // return the filter - return PHP_EOL . implode(PHP_EOL, $fieldFilters); - } - - return ''; - } - - /** - * add default filter helper - * - * @param array $filter The batch code array - * @param string $nameSingleCode The single view name - * @param string $nameListCode The list view name - * - * @return void - * - */ - protected function setDefaultSidebarFilterHelper(&$filter, &$nameSingleCode, - &$nameListCode - ) - { - // add the default filters if we are on the old filter paths (1 = sidebar) - if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 1) - { - // set batch - $filter[] = PHP_EOL . Indent::_(2) - . "//" . Line::_(__Line__, __Class__) - . " Only load publish filter if state change is allowed"; - $filter[] = Indent::_(2) - . "if (\$this->canState)"; - $filter[] = Indent::_(2) . "{"; - $filter[] = Indent::_(3) . "JHtmlSidebar::addFilter("; - $filter[] = Indent::_(4) . "JText:" - . ":_('JOPTION_SELECT_PUBLISHED'),"; - $filter[] = Indent::_(4) . "'filter_published',"; - $filter[] = Indent::_(4) - . "JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', \$this->state->get('filter.published'), true)"; - $filter[] = Indent::_(3) . ");"; - $filter[] = Indent::_(2) . "}"; - // check if view has access - if (CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode) - && !CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.access')) - { - $filter[] = PHP_EOL . Indent::_(2) . "JHtmlSidebar::addFilter("; - $filter[] = Indent::_(3) . "JText:" - . ":_('JOPTION_SELECT_ACCESS'),"; - $filter[] = Indent::_(3) . "'filter_access',"; - $filter[] = Indent::_(3) - . "JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', \$this->state->get('filter.access'))"; - $filter[] = Indent::_(2) . ");"; - } - } - } - - /** - * build category sidebar display filter helper - * - * @param array $filter The filter code array - * @param string $nameListCode The list view name - * - * @return void - * - */ - protected function setCategorySidebarFilterHelper(&$filter, &$nameListCode) - { - // add the category filter if we are on the old filter paths (1 = sidebar) - if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 1 - && CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.extension") - && CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.filter", 0) >= 1) - { - // set filter - $filter[] = PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Category Filter."; - $filter[] = Indent::_(2) . "JHtmlSidebar::addFilter("; - $filter[] = Indent::_(3) . "JText:" - . ":_('JOPTION_SELECT_CATEGORY'),"; - $filter[] = Indent::_(3) . "'filter_category_id',"; - $filter[] = Indent::_(3) - . "JHtml::_('select.options', JHtml::_('category.options', '" - . CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension") - . "'), 'value', 'text', \$this->state->get('filter.category_id'))"; - $filter[] = Indent::_(2) . ");"; - } - } - - /** - * build batch loading helper scripts - * - * @param string $nameSingleCode The single view name - * @param string $nameListCode The list view name - * - * @return string The php to place in view.html.php - * - */ - public function setBatchDisplayHelper(&$nameSingleCode, &$nameListCode) - { - // start the batch bucket - $fieldBatch = array(); - // add the default batch - $this->setDefaultBatchHelper($fieldBatch, $nameSingleCode); - // add the category filter stuff - $this->setCategoryBatchHelper($fieldBatch, $nameListCode); - // check if we have other batch options to add - if (CFactory::_('Compiler.Builder.Filter')->exists($nameListCode)) - { - // check if we should add some help to get the values (2 = topbar) - $get_values = false; - if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2) - { - // since the old path is not used, we need to add those values here - $get_values = true; - } - // get component name - $Component = CFactory::_('Compiler.Builder.Content.One')->get('Component'); - // load the rest of the batch options - foreach (CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as $filter) - { - if ($filter['type'] != 'category' - && ArrayHelper::check($filter['custom']) - && $filter['custom']['extends'] !== 'user') - { - $CodeName = StringHelper::safe( - $filter['code'] . ' ' . $filter['custom']['text'], 'W' - ); - $codeName = $filter['code'] - . StringHelper::safe( - $filter['custom']['text'], 'F' - ); - $fieldBatch[] = PHP_EOL . Indent::_(2) - . "//" . Line::_(__Line__, __Class__) - . " Only load " . $CodeName - . " batch if create, edit, and batch is allowed"; - $fieldBatch[] = Indent::_(2) - . "if (\$this->canBatch && \$this->canCreate && \$this->canEdit)"; - $fieldBatch[] = Indent::_(2) . "{"; - // add the get values here - if ($get_values) - { - $type = StringHelper::safe( - $filter['custom']['type'], 'F' - ); - $fieldBatch[] = Indent::_(3) . "//" - . Line::_(__Line__, __Class__) . " Set " . $CodeName - . " Selection"; - $fieldBatch[] = Indent::_(3) . "\$this->" . $codeName - . "Options = JFormHelper::loadFieldType('" . $type - . "')->options;"; - $fieldBatch[] = Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " We do some sanitation for " . $CodeName - . " filter"; - $fieldBatch[] = Indent::_(3) . "if (" . $Component - . "Helper::checkArray(\$this->" . $codeName - . "Options) &&"; - $fieldBatch[] = Indent::_(4) . "isset(\$this->" - . $codeName - . "Options[0]->value) &&"; - $fieldBatch[] = Indent::_(4) . "!" . $Component - . "Helper::checkString(\$this->" . $codeName - . "Options[0]->value))"; - $fieldBatch[] = Indent::_(3) . "{"; - $fieldBatch[] = Indent::_(4) . "unset(\$this->" - . $codeName - . "Options[0]);"; - $fieldBatch[] = Indent::_(3) . "}"; - } - $fieldBatch[] = Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " " . $CodeName . " Batch Selection"; - $fieldBatch[] = Indent::_(3) - . "JHtmlBatch_::addListSelection("; - $fieldBatch[] = Indent::_(4) . "'- Keep Original '.JText:" - . ":_('" . $filter['lang'] . "').' -',"; - $fieldBatch[] = Indent::_(4) . "'batch[" . $filter['code'] - . "]',"; - $fieldBatch[] = Indent::_(4) - . "JHtml::_('select.options', \$this->" . $codeName - . "Options, 'value', 'text')"; - $fieldBatch[] = Indent::_(3) . ");"; - $fieldBatch[] = Indent::_(2) . "}"; - } - elseif ($filter['type'] != 'category') - { - $CodeName = StringHelper::safe( - $filter['code'], 'W' - ); - - $fieldBatch[] = PHP_EOL . Indent::_(2) - . "//" . Line::_(__Line__, __Class__) - . " Only load " . $CodeName - . " batch if create, edit, and batch is allowed"; - $fieldBatch[] = Indent::_(2) - . "if (\$this->canBatch && \$this->canCreate && \$this->canEdit)"; - $fieldBatch[] = Indent::_(2) . "{"; - // add the get values here - if ($get_values) - { - $fieldBatch[] = Indent::_(3) . "//" - . Line::_(__Line__, __Class__) . " Set " . $CodeName - . " Selection"; - $fieldBatch[] = Indent::_(3) . "\$this->" - . $filter['code'] - . "Options = JFormHelper::loadFieldType('" - . $filter['filter_type'] - . "')->options;"; - $fieldBatch[] = Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " We do some sanitation for " . $CodeName - . " filter"; - $fieldBatch[] = Indent::_(3) . "if (" . $Component - . "Helper::checkArray(\$this->" . $filter['code'] - . "Options) &&"; - $fieldBatch[] = Indent::_(4) . "isset(\$this->" - . $filter['code'] . "Options[0]->value) &&"; - $fieldBatch[] = Indent::_(4) . "!" . $Component - . "Helper::checkString(\$this->" . $filter['code'] - . "Options[0]->value))"; - $fieldBatch[] = Indent::_(3) . "{"; - $fieldBatch[] = Indent::_(4) . "unset(\$this->" - . $filter['code'] . "Options[0]);"; - $fieldBatch[] = Indent::_(3) . "}"; - } - $fieldBatch[] = Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " " . $CodeName . " Batch Selection"; - $fieldBatch[] = Indent::_(3) - . "JHtmlBatch_::addListSelection("; - $fieldBatch[] = Indent::_(4) . "'- Keep Original '.JText:" - . ":_('" . $filter['lang'] . "').' -',"; - $fieldBatch[] = Indent::_(4) . "'batch[" . $filter['code'] - . "]',"; - $fieldBatch[] = Indent::_(4) - . "JHtml::_('select.options', \$this->" - . $filter['code'] . "Options, 'value', 'text')"; - $fieldBatch[] = Indent::_(3) . ");"; - $fieldBatch[] = Indent::_(2) . "}"; - } - } - } - // did we find batch options - if (ArrayHelper::check($fieldBatch)) - { - // return the batch - return PHP_EOL . implode(PHP_EOL, $fieldBatch); - } - - return ''; - } - - /** - * add default batch helper - * - * @param array $batch The batch code array - * @param string $nameSingleCode The single view name - * - * @return void - * - */ - protected function setDefaultBatchHelper(&$batch, &$nameSingleCode) - { - // set component name - $COPMONENT = CFactory::_('Component')->get('name_code'); - $COPMONENT = StringHelper::safe( - $COPMONENT, 'U' - ); - // set batch - $batch[] = PHP_EOL . Indent::_(2) - . "//" . Line::_(__Line__, __Class__) - . " Only load published batch if state and batch is allowed"; - $batch[] = Indent::_(2) - . "if (\$this->canState && \$this->canBatch)"; - $batch[] = Indent::_(2) . "{"; - $batch[] = Indent::_(3) . "JHtmlBatch_::addListSelection("; - $batch[] = Indent::_(4) . "JText:" . ":_('COM_" . $COPMONENT - . "_KEEP_ORIGINAL_STATE'),"; - $batch[] = Indent::_(4) . "'batch[published]',"; - $batch[] = Indent::_(4) - . "JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true)"; - $batch[] = Indent::_(3) . ");"; - $batch[] = Indent::_(2) . "}"; - // check if view has access - if (CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode) - && !CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.access')) - { - $batch[] = PHP_EOL . Indent::_(2) - . "//" . Line::_(__Line__, __Class__) - . " Only load access batch if create, edit and batch is allowed"; - $batch[] = Indent::_(2) - . "if (\$this->canBatch && \$this->canCreate && \$this->canEdit)"; - $batch[] = Indent::_(2) . "{"; - $batch[] = Indent::_(3) . "JHtmlBatch_::addListSelection("; - $batch[] = Indent::_(4) . "JText:" . ":_('COM_" . $COPMONENT - . "_KEEP_ORIGINAL_ACCESS'),"; - $batch[] = Indent::_(4) . "'batch[access]',"; - $batch[] = Indent::_(4) - . "JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text')"; - $batch[] = Indent::_(3) . ");"; - $batch[] = Indent::_(2) . "}"; - } - } - - /** - * build category batch helper - * - * @param array $batch The batch code array - * @param string $nameListCode The list view name - * - * @return mixed The php to place in view.html.php - * - */ - protected function setCategoryBatchHelper(&$batch, &$nameListCode) - { - if (CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.extension")) - { - // set component name - $COPMONENT = CFactory::_('Component')->get('name_code'); - $COPMONENT = StringHelper::safe($COPMONENT, 'U'); - // set filter - $batch[] = PHP_EOL . Indent::_(2) - . "if (\$this->canBatch && \$this->canCreate && \$this->canEdit)"; - $batch[] = Indent::_(2) . "{"; - $batch[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Category Batch selection."; - $batch[] = Indent::_(3) . "JHtmlBatch_::addListSelection("; - $batch[] = Indent::_(4) . "JText:" . ":_('COM_" . $COPMONENT - . "_KEEP_ORIGINAL_CATEGORY'),"; - $batch[] = Indent::_(4) . "'batch[category]',"; - $batch[] = Indent::_(4) - . "JHtml::_('select.options', JHtml::_('category.options', '" - . CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension") - . "'), 'value', 'text')"; - $batch[] = Indent::_(3) . ");"; - $batch[] = Indent::_(2) . "}"; - } - } - - public function setRouterCategoryViews($nameSingleCode, $nameListCode) - { - if (CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.extension")) - { - // get the actual extension - $_extension = CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension"); - $_extension = explode('.', (string) $_extension); - // set component name - if (ArrayHelper::check($_extension)) - { - $component = str_replace('com_', '', $_extension[0]); - } - else - { - $component = CFactory::_('Config')->component_code_name; - } - // check if category has another name - $otherViews = CFactory::_('Compiler.Builder.Category.Other.Name')-> - get($nameListCode . '.views', $nameListCode); - $otherView = CFactory::_('Compiler.Builder.Category.Other.Name')-> - get($nameListCode . '.view', $nameSingleCode); - // set the OtherView value - CFactory::_('Compiler.Builder.Content.Multi')->set('category' . $otherView . '|otherview', $otherView); - // load the category helper details in not already loaded - if (!CFactory::_('Compiler.Builder.Content.Multi')->exists('category' . $otherView . '|view')) - { - // lets also set the category helper for this view - $target = array('site' => 'category' . $otherView); - CFactory::_('Utilities.Structure')->build($target, 'category'); - // insure the file gets updated - CFactory::_('Compiler.Builder.Content.Multi')->set('category' . $otherView . '|view', $otherView); - CFactory::_('Compiler.Builder.Content.Multi')->set('category' . $otherView . '|View', ucfirst((string) $otherView)); - CFactory::_('Compiler.Builder.Content.Multi')->set('category' . $otherView . '|views', $otherViews); - CFactory::_('Compiler.Builder.Content.Multi')->set('category' . $otherView . '|Views', ucfirst((string) $otherViews)); - // set script to global helper file - $includeHelper = array(); - $includeHelper[] = "\n//" . Line::_(__Line__, __Class__) - . "Insure this view category file is loaded."; - $includeHelper[] = "\$classname = '" . ucfirst((string) $component) - . ucfirst((string) $otherView) . "Categories';"; - $includeHelper[] = "if (!class_exists(\$classname))"; - $includeHelper[] = "{"; - $includeHelper[] = Indent::_(1) - . "\$path = JPATH_SITE . '/components/com_" . $component - . "/helpers/category" . $otherView . ".php';"; - $includeHelper[] = Indent::_(1) . "if (is_file(\$path))"; - $includeHelper[] = Indent::_(1) . "{"; - $includeHelper[] = Indent::_(2) . "include_once \$path;"; - $includeHelper[] = Indent::_(1) . "}"; - $includeHelper[] = "}"; - CFactory::_('Compiler.Builder.Content.One')->add('CATEGORY_CLASS_TREES', implode("\n", $includeHelper)); - } - // return category view string - if (CFactory::_('Compiler.Builder.Content.One')->exists('ROUTER_CATEGORY_VIEWS') - && StringHelper::check( - CFactory::_('Compiler.Builder.Content.One')->get('ROUTER_CATEGORY_VIEWS') - )) - { - return "," . PHP_EOL . Indent::_(3) . '"' - . CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension") - . '" => "' . $otherView . '"'; - } - else - { - return PHP_EOL . Indent::_(3) . '"' - . CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension") - . '" => "' . $otherView . '"'; - } - } - - return ''; - } - - public function setJcontrollerAllowAdd($nameSingleCode, $nameListCode) - { - $allow = array(); - // set component name - $component = CFactory::_('Config')->component_code_name; - // prepare custom permission script - $customAllow = CFactory::_('Customcode.Dispenser')->get( - 'php_allowadd', $nameSingleCode, '', null, true - ); - // check if item has category - if (0) //CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}")) <-- remove category from check - { - // check if category has another name - $otherViews = CFactory::_('Compiler.Builder.Category.Other.Name')-> - get($nameListCode . '.views', $nameListCode); - $otherView = CFactory::_('Compiler.Builder.Category.Other.Name')-> - get($nameListCode . '.view', $nameSingleCode); - // setup the category script - $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " get the user object"; - $allow[] = Indent::_(2) . "\$user = JFactory::getUser();"; - // check if the item has permissions. - if (CFactory::_('Compiler.Creator.Permission')->globalExist($otherView, 'core.access')) - { - $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Access check."; - $allow[] = Indent::_(2) . "\$access = \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($otherView, 'core.access') - . "', 'com_" . $component . "');"; - $allow[] = Indent::_(2) . "if (!\$access)"; - $allow[] = Indent::_(2) . "{"; - $allow[] = Indent::_(3) . "return false;"; - $allow[] = Indent::_(2) . "}"; - } - $allow[] = Indent::_(2) - . "\$categoryId = ArrayHelper::getValue(\$data, 'catid', \$this->input->getInt('filter_category_id'), 'int');"; - $allow[] = Indent::_(2) . "\$allow = null;"; - $allow[] = PHP_EOL . Indent::_(2) . "if (\$categoryId)"; - $allow[] = Indent::_(2) . "{"; - $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " If the category has been passed in the URL check it."; - $allow[] = Indent::_(3) - . "\$allow = \$user->authorise('core.create', \$this->option . '." - . $otherView . ".category.' . \$categoryId);"; - $allow[] = Indent::_(2) . "}"; - $allow[] = PHP_EOL . Indent::_(2) . "if (\$allow === null)"; - $allow[] = Indent::_(2) . "{"; - // check if the item has permissions. - if (CFactory::_('Compiler.Creator.Permission')->globalExist($nameSingleCode, 'core.access')) - { - // setup the default script - $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " In the absence of better information, revert to the component permissions."; - $allow[] = Indent::_(3) . "return \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.create') - . "', \$this->option);"; - } - else - { - // setup the default script - $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " In the absence of better information, revert to the component permissions."; - $allow[] = Indent::_(3) . "return parent::allowAdd(\$data);"; - } - $allow[] = Indent::_(2) . "}"; - $allow[] = Indent::_(2) . "else"; - $allow[] = Indent::_(2) . "{"; - $allow[] = Indent::_(3) . "return \$allow;"; - $allow[] = Indent::_(2) . "}"; - } - else - { - $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Get user object."; - $allow[] = Indent::_(2) . "\$user = JFactory::getUser();"; - // check if the item has permissions. - if (CFactory::_('Compiler.Creator.Permission')->globalExist($nameSingleCode, 'core.access')) - { - $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Access check."; - $allow[] = Indent::_(2) . "\$access = \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.access') - . "', 'com_" . $component . "');"; - $allow[] = Indent::_(2) . "if (!\$access)"; - $allow[] = Indent::_(2) . "{"; - $allow[] = Indent::_(3) . "return false;"; - $allow[] = Indent::_(2) . "}"; - } - // load custom permission script - $allow[] = $customAllow; - // check if the item has permissions. - if (CFactory::_('Compiler.Creator.Permission')->globalExist($nameSingleCode, 'core.create')) - { - // setup the default script - $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " In the absence of better information, revert to the component permissions."; - $allow[] = Indent::_(2) . "return \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.create') - . "', \$this->option);"; - } - else - { - // setup the default script - $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " In the absence of better information, revert to the component permissions."; - $allow[] = Indent::_(2) . "return parent::allowAdd(\$data);"; - } - } - - return implode(PHP_EOL, $allow); - } - - public function setJcontrollerAllowEdit($nameSingleCode, $nameListCode) - { - $allow = array(); - // set component name - $component = CFactory::_('Config')->component_code_name; - // prepare custom permission script - $customAllow = CFactory::_('Customcode.Dispenser')->get( - 'php_allowedit', $nameSingleCode, '', null, true - ); - if (CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}")) - { - // check if category has another name - $otherViews = CFactory::_('Compiler.Builder.Category.Other.Name')-> - get($nameListCode . '.views', $nameListCode); - $otherView = CFactory::_('Compiler.Builder.Category.Other.Name')-> - get($nameListCode . '.view', $nameSingleCode); - // setup the category script - $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " get user object."; - $allow[] = Indent::_(2) . "\$user = JFactory::getUser();"; - $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " get record id."; - $allow[] = Indent::_(2) - . "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;"; - // load custom permission script - $allow[] = $customAllow; - // check if the item has permissions. - if (CFactory::_('Compiler.Creator.Permission')->globalExist($otherView, 'core.access')) - { - $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Access check."; - $allow[] = Indent::_(2) . "\$access = (\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($otherView, 'core.access') - . "', 'com_" . $component . "." . $otherView - . ".' . (int) \$recordId) && \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($otherView, 'core.access') - . "', 'com_" . $component . "'));"; - $allow[] = Indent::_(2) . "if (!\$access)"; - $allow[] = Indent::_(2) . "{"; - $allow[] = Indent::_(3) . "return false;"; - $allow[] = Indent::_(2) . "}"; - } - $allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)"; - $allow[] = Indent::_(2) . "{"; - $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " The record has been set. Check the record permissions."; - // check if the item has permissions. - $allow[] = Indent::_(3) . "\$permission = \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($otherView, 'core.edit') . "', 'com_" . $component . "." - . $otherView . ".' . (int) \$recordId);"; - $allow[] = Indent::_(3) . "if (!\$permission)"; - $allow[] = Indent::_(3) . "{"; - // check if the item has permissions. - $allow[] = Indent::_(4) . "if (\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($otherView, 'core.edit.own') . "', 'com_" . $component . "." - . $otherView . ".' . \$recordId))"; - $allow[] = Indent::_(4) . "{"; - $allow[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) - . " Fallback on edit.own. Now test the owner is the user."; - $allow[] = Indent::_(5) - . "\$ownerId = (int) isset(\$data['created_by']) ? \$data['created_by'] : 0;"; - $allow[] = Indent::_(5) . "if (empty(\$ownerId))"; - $allow[] = Indent::_(5) . "{"; - $allow[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__) - . " Need to do a lookup from the model."; - $allow[] = Indent::_(6) - . "\$record = \$this->getModel()->getItem(\$recordId);"; - $allow[] = PHP_EOL . Indent::_(6) . "if (empty(\$record))"; - $allow[] = Indent::_(6) . "{"; - $allow[] = Indent::_(7) . "return false;"; - $allow[] = Indent::_(6) . "}"; - $allow[] = Indent::_(6) . "\$ownerId = \$record->created_by;"; - $allow[] = Indent::_(5) . "}"; - $allow[] = PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__) - . " If the owner matches 'me' then do the test."; - $allow[] = Indent::_(5) . "if (\$ownerId == \$user->id)"; - $allow[] = Indent::_(5) . "{"; - // check if the item has permissions. - $allow[] = Indent::_(6) . "if (\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($otherView, 'core.edit.own') . "', 'com_" . $component . "'))"; - $allow[] = Indent::_(6) . "{"; - $allow[] = Indent::_(7) . "return true;"; - $allow[] = Indent::_(6) . "}"; - $allow[] = Indent::_(5) . "}"; - $allow[] = Indent::_(4) . "}"; - $allow[] = Indent::_(4) . "return false;"; - $allow[] = Indent::_(3) . "}"; -// $allow[] = PHP_EOL.Indent::_(3) . "\$categoryId = (int) isset(\$data['catid']) ? \$data['catid']: \$this->getModel()->getItem(\$recordId)->catid;"; <-- remove category from check -// $allow[] = PHP_EOL.Indent::_(3) . "if (\$categoryId)"; -// $allow[] = Indent::_(3) . "{"; -// $allow[] = Indent::_(4) . "//".Line::_(__Line__, __Class__)." The category has been set. Check the category permissions."; -// $allow[] = Indent::_(4) . "\$catpermission = \$user->authorise('core.edit', \$this->option . '.".$otherView.".category.' . \$categoryId);"; -// $allow[] = Indent::_(4) . "if (!\$catpermission && !is_null(\$catpermission))"; -// $allow[] = Indent::_(4) . "{"; -// $allow[] = Indent::_(5) . "return false;"; -// $allow[] = Indent::_(4) . "}"; -// $allow[] = Indent::_(3) . "}"; - $allow[] = Indent::_(2) . "}"; - if (CFactory::_('Compiler.Creator.Permission')->globalExist($otherView, 'core.edit')) - { - $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Since there is no permission, revert to the component permissions."; - $allow[] = Indent::_(2) . "return \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($otherView, 'core.edit') . "', \$this->option);"; - } - else - { - $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Since there is no permission, revert to the component permissions."; - $allow[] = Indent::_(2) - . "return parent::allowEdit(\$data, \$key);"; - } - } - else - { - // setup the category script - $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " get user object."; - $allow[] = Indent::_(2) . "\$user = JFactory::getUser();"; - $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " get record id."; - $allow[] = Indent::_(2) - . "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;"; - // load custom permission script - $allow[] = $customAllow; - // check if the item has permissions. - if (CFactory::_('Compiler.Creator.Permission')->actionExist($nameSingleCode, 'core.access')) - { - $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Access check."; - $allow[] = Indent::_(2) . "\$access = (\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.access') . "', 'com_" . $component . "." - . $nameSingleCode - . ".' . (int) \$recordId) && \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.access') . "', 'com_" . $component . "'));"; - $allow[] = Indent::_(2) . "if (!\$access)"; - $allow[] = Indent::_(2) . "{"; - $allow[] = Indent::_(3) . "return false;"; - $allow[] = Indent::_(2) . "}"; - } - $allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)"; - $allow[] = Indent::_(2) . "{"; - $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " The record has been set. Check the record permissions."; - // check if the item has permissions. - $allow[] = Indent::_(3) . "\$permission = \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit') . "', 'com_" . $component . "." - . $nameSingleCode . ".' . (int) \$recordId);"; - $allow[] = Indent::_(3) . "if (!\$permission)"; - $allow[] = Indent::_(3) . "{"; - // check if the item has permissions. - $allow[] = Indent::_(4) . "if (\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.own') . "', 'com_" . $component . "." - . $nameSingleCode . ".' . \$recordId))"; - $allow[] = Indent::_(4) . "{"; - $allow[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) - . " Now test the owner is the user."; - $allow[] = Indent::_(5) - . "\$ownerId = (int) isset(\$data['created_by']) ? \$data['created_by'] : 0;"; - $allow[] = Indent::_(5) . "if (empty(\$ownerId))"; - $allow[] = Indent::_(5) . "{"; - $allow[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__) - . " Need to do a lookup from the model."; - $allow[] = Indent::_(6) - . "\$record = \$this->getModel()->getItem(\$recordId);"; - $allow[] = PHP_EOL . Indent::_(6) . "if (empty(\$record))"; - $allow[] = Indent::_(6) . "{"; - $allow[] = Indent::_(7) . "return false;"; - $allow[] = Indent::_(6) . "}"; - $allow[] = Indent::_(6) . "\$ownerId = \$record->created_by;"; - $allow[] = Indent::_(5) . "}"; - $allow[] = PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__) - . " If the owner matches 'me' then allow."; - $allow[] = Indent::_(5) . "if (\$ownerId == \$user->id)"; - $allow[] = Indent::_(5) . "{"; - // check if the item has permissions. - $allow[] = Indent::_(6) . "if (\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit.own') . "', 'com_" . $component . "'))"; - $allow[] = Indent::_(6) . "{"; - $allow[] = Indent::_(7) . "return true;"; - $allow[] = Indent::_(6) . "}"; - $allow[] = Indent::_(5) . "}"; - $allow[] = Indent::_(4) . "}"; - $allow[] = Indent::_(4) . "return false;"; - $allow[] = Indent::_(3) . "}"; - $allow[] = Indent::_(2) . "}"; - if (CFactory::_('Compiler.Creator.Permission')->globalExist($nameSingleCode, 'core.edit')) - { - $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Since there is no permission, revert to the component permissions."; - $allow[] = Indent::_(2) . "return \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit') . "', \$this->option);"; - } - else - { - $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Since there is no permission, revert to the component permissions."; - $allow[] = Indent::_(2) - . "return parent::allowEdit(\$data, \$key);"; - } - } - - return implode(PHP_EOL, $allow); - } - - public function setJmodelAdminGetForm($nameSingleCode, $nameListCode) - { - // set component name - $component = CFactory::_('Config')->component_code_name; - // allways load these - $getForm = array(); - $getForm[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " check if xpath was set in options"; - $getForm[] = Indent::_(2) . "\$xpath = false;"; - $getForm[] = Indent::_(2) . "if (isset(\$options['xpath']))"; - $getForm[] = Indent::_(2) . "{"; - $getForm[] = Indent::_(3) . "\$xpath = \$options['xpath'];"; - $getForm[] = Indent::_(3) . "unset(\$options['xpath']);"; - $getForm[] = Indent::_(2) . "}"; - $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " check if clear form was set in options"; - $getForm[] = Indent::_(2) . "\$clear = false;"; - $getForm[] = Indent::_(2) . "if (isset(\$options['clear']))"; - $getForm[] = Indent::_(2) . "{"; - $getForm[] = Indent::_(3) . "\$clear = \$options['clear'];"; - $getForm[] = Indent::_(3) . "unset(\$options['clear']);"; - $getForm[] = Indent::_(2) . "}"; - $getForm[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Get the form."; - $getForm[] = Indent::_(2) . "\$form = \$this->loadForm('com_" - . $component . "." . $nameSingleCode . "', '" . $nameSingleCode - . "', \$options, \$clear, \$xpath);"; - $getForm[] = PHP_EOL . Indent::_(2) . "if (empty(\$form))"; - $getForm[] = Indent::_(2) . "{"; - $getForm[] = Indent::_(3) . "return false;"; - $getForm[] = Indent::_(2) . "}"; - // load license locker - if (CFactory::_('Component')->get('add_license') && CFactory::_('Component')->get('license_type') == 3 - && CFactory::_('Compiler.Builder.Content.Multi')->exists($nameSingleCode . '|BOOLMETHOD')) - { - $getForm[] = $this->checkStatmentLicenseLocked( - CFactory::_('Compiler.Builder.Content.Multi')->get($nameSingleCode . '|BOOLMETHOD', '') - ); - } - if (0) //CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}")) <-- remove category from check - { - // check if category has another name - $otherViews = CFactory::_('Compiler.Builder.Category.Other.Name')-> - get($nameListCode . '.views', $nameListCode); - $otherView = CFactory::_('Compiler.Builder.Category.Other.Name')-> - get($nameListCode . '.view', $nameSingleCode); - // setup the category script - $getForm[] = PHP_EOL . Indent::_(2) - . "\$jinput = JFactory::getApplication()->input;"; - $getForm[] = PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) - . " The front end calls this model and uses a_id to avoid id clashes so we need to check for that first."; - $getForm[] = Indent::_(2) . "if (\$jinput->get('a_id'))"; - $getForm[] = Indent::_(2) . "{"; - $getForm[] = Indent::_(3) - . "\$id = \$jinput->get('a_id', 0, 'INT');"; - $getForm[] = Indent::_(2) . "}"; - $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " The back end uses id so we use that the rest of the time and set it to 0 by default."; - $getForm[] = Indent::_(2) . "else"; - $getForm[] = Indent::_(2) . "{"; - $getForm[] = Indent::_(3) . "\$id = \$jinput->get('id', 0, 'INT');"; - $getForm[] = Indent::_(2) . "}"; - $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Determine correct permissions to check."; - $getForm[] = Indent::_(2) . "if (\$this->getState('" - . $nameSingleCode . ".id'))"; - $getForm[] = Indent::_(2) . "{"; - $getForm[] = Indent::_(3) . "\$id = \$this->getState('" - . $nameSingleCode . ".id');"; - $getForm[] = PHP_EOL . Indent::_(3) . "\$catid = 0;"; - $getForm[] = Indent::_(3) - . "if (isset(\$this->getItem(\$id)->catid))"; - $getForm[] = Indent::_(3) . "{"; - $getForm[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " set category id"; - $getForm[] = Indent::_(4) - . "\$catid = \$this->getItem(\$id)->catid;"; - $getForm[] = PHP_EOL . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Existing record. Can only edit in selected categories."; - $getForm[] = Indent::_(4) - . "\$form->setFieldAttribute('catid', 'action', 'core.edit');"; - $getForm[] = PHP_EOL . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) - . " Existing record. Can only edit own items in selected categories."; - $getForm[] = Indent::_(4) - . "\$form->setFieldAttribute('catid', 'action', 'core.edit.own');"; - $getForm[] = Indent::_(3) . "}"; - $getForm[] = Indent::_(2) . "}"; - $getForm[] = Indent::_(2) . "else"; - $getForm[] = Indent::_(2) . "{"; - $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " New record. Can only create in selected categories."; - $getForm[] = Indent::_(3) - . "\$form->setFieldAttribute('catid', 'action', 'core.create');"; - $getForm[] = Indent::_(2) . "}"; - $getForm[] = PHP_EOL . Indent::_(2) - . "\$user = JFactory::getUser();"; - $getForm[] = PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Check for existing item."; - $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Modify the form based on Edit State access controls."; - // get the other view - $otherView = CFactory::_('Compiler.Builder.Category.Code')->getString("{$nameSingleCode}.view", 'error'); - // check if the item has permissions. - $getForm[] = Indent::_(2) - . "if (\$id != 0 && (!\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.state') - . "', 'com_" . $component . "." - . $nameSingleCode . ".' . (int) \$id))"; - $getForm[] = Indent::_(3) - . "|| (isset(\$catid) && \$catid != 0 && !\$user->authorise('core.edit.state', 'com_" - . $component . "." . $otherView - . ".category.' . (int) \$catid))"; - $getForm[] = Indent::_(3) - . "|| (\$id == 0 && !\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.state') - . "', 'com_" . $component . "')))"; - $getForm[] = Indent::_(2) . "{"; - $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Disable fields for display."; - $getForm[] = Indent::_(3) - . "\$form->setFieldAttribute('ordering', 'disabled', 'true');"; - $getForm[] = Indent::_(3) - . "\$form->setFieldAttribute('published', 'disabled', 'true');"; - $getForm[] = PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Disable fields while saving."; - $getForm[] = Indent::_(3) - . "\$form->setFieldAttribute('ordering', 'filter', 'unset');"; - $getForm[] = Indent::_(3) - . "\$form->setFieldAttribute('published', 'filter', 'unset');"; - $getForm[] = Indent::_(2) . "}"; - } - else - { - $getForm[] = PHP_EOL . Indent::_(2) - . "\$jinput = JFactory::getApplication()->input;"; - $getForm[] = PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) - . " The front end calls this model and uses a_id to avoid id clashes so we need to check for that first."; - $getForm[] = Indent::_(2) . "if (\$jinput->get('a_id'))"; - $getForm[] = Indent::_(2) . "{"; - $getForm[] = Indent::_(3) - . "\$id = \$jinput->get('a_id', 0, 'INT');"; - $getForm[] = Indent::_(2) . "}"; - $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " The back end uses id so we use that the rest of the time and set it to 0 by default."; - $getForm[] = Indent::_(2) . "else"; - $getForm[] = Indent::_(2) . "{"; - $getForm[] = Indent::_(3) . "\$id = \$jinput->get('id', 0, 'INT');"; - $getForm[] = Indent::_(2) . "}"; - $getForm[] = PHP_EOL . Indent::_(2) - . "\$user = JFactory::getUser();"; - $getForm[] = PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Check for existing item."; - $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Modify the form based on Edit State access controls."; - // check if the item has permissions. - $getForm[] = Indent::_(2) - . "if (\$id != 0 && (!\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.state') . "', 'com_" . $component . "." - . $nameSingleCode . ".' . (int) \$id))"; - $getForm[] = Indent::_(3) - . "|| (\$id == 0 && !\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.state') . "', 'com_" . $component - . "')))"; - $getForm[] = Indent::_(2) . "{"; - $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Disable fields for display."; - $getForm[] = Indent::_(3) - . "\$form->setFieldAttribute('ordering', 'disabled', 'true');"; - $getForm[] = Indent::_(3) - . "\$form->setFieldAttribute('published', 'disabled', 'true');"; - $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Disable fields while saving."; - $getForm[] = Indent::_(3) - . "\$form->setFieldAttribute('ordering', 'filter', 'unset');"; - $getForm[] = Indent::_(3) - . "\$form->setFieldAttribute('published', 'filter', 'unset');"; - $getForm[] = Indent::_(2) . "}"; - } - $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " If this is a new item insure the greated by is set."; - $getForm[] = Indent::_(2) . "if (0 == \$id)"; - $getForm[] = Indent::_(2) . "{"; - $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Set the created_by to this user"; - $getForm[] = Indent::_(3) - . "\$form->setValue('created_by', null, \$user->id);"; - $getForm[] = Indent::_(2) . "}"; - $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Modify the form based on Edit Creaded By access controls."; - // check if the item has permissions. - if (CFactory::_('Compiler.Creator.Permission')->actionExist($nameSingleCode, 'core.edit.created_by')) - { - $getForm[] = Indent::_(2) . "if (\$id != 0 && (!\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.created_by') - . "', 'com_" . $component . "." . $nameSingleCode . ".' . (int) \$id))"; - $getForm[] = Indent::_(3) . "|| (\$id == 0 && !\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.created_by') - . "', 'com_" . $component . "')))"; - } - else - { - $getForm[] = Indent::_(2) - . "if (!\$user->authorise('core.edit.created_by', 'com_" . $component . "'))"; - } - $getForm[] = Indent::_(2) . "{"; - $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Disable fields for display."; - $getForm[] = Indent::_(3) - . "\$form->setFieldAttribute('created_by', 'disabled', 'true');"; - $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Disable fields for display."; - $getForm[] = Indent::_(3) - . "\$form->setFieldAttribute('created_by', 'readonly', 'true');"; - $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Disable fields while saving."; - $getForm[] = Indent::_(3) - . "\$form->setFieldAttribute('created_by', 'filter', 'unset');"; - $getForm[] = Indent::_(2) . "}"; - $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Modify the form based on Edit Creaded Date access controls."; - // check if the item has permissions. - if (CFactory::_('Compiler.Creator.Permission')->actionExist($nameSingleCode, 'core.edit.created')) - { - $getForm[] = Indent::_(2) . "if (\$id != 0 && (!\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.created') - . "', 'com_" . $component . "." . $nameSingleCode . ".' . (int) \$id))"; - $getForm[] = Indent::_(3) . "|| (\$id == 0 && !\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.created') - . "', 'com_" . $component . "')))"; - } - else - { - $getForm[] = Indent::_(2) - . "if (!\$user->authorise('core.edit.created', 'com_" - . $component . "'))"; - } - $getForm[] = Indent::_(2) . "{"; - $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Disable fields for display."; - $getForm[] = Indent::_(3) - . "\$form->setFieldAttribute('created', 'disabled', 'true');"; - $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Disable fields while saving."; - $getForm[] = Indent::_(3) - . "\$form->setFieldAttribute('created', 'filter', 'unset');"; - $getForm[] = Indent::_(2) . "}"; - // check if the item has access permissions. - if (CFactory::_('Compiler.Creator.Permission')->actionExist($nameSingleCode, 'core.edit.access')) - { - $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Modify the form based on Edit Access 'access' controls."; - $getForm[] = Indent::_(2) . "if (\$id != 0 && (!\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.access') - . "', 'com_" . $component . "." . $nameSingleCode . ".' . (int) \$id))"; - $getForm[] = Indent::_(3) . "|| (\$id == 0 && !\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.access') - . "', 'com_" . $component . "')))"; - $getForm[] = Indent::_(2) . "{"; - $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Disable fields for display."; - $getForm[] = Indent::_(3) - . "\$form->setFieldAttribute('access', 'disabled', 'true');"; - $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Disable fields while saving."; - $getForm[] = Indent::_(3) - . "\$form->setFieldAttribute('access', 'filter', 'unset');"; - $getForm[] = Indent::_(2) . "}"; - } - // handel the fields permissions - if (isset($this->permissionFields[$nameSingleCode]) - && ArrayHelper::check( - $this->permissionFields[$nameSingleCode] - )) - { - foreach ( - $this->permissionFields[$nameSingleCode] as $fieldName => - $permission_options - ) - { - foreach ( - $permission_options as $permission_option => $fieldType - ) - { - switch ($permission_option) - { - case 'edit': - $this->setPermissionEditFields( - $getForm, $nameSingleCode, $fieldName, - $fieldType, $component - ); - break; - case 'access': - $this->setPermissionAccessFields( - $getForm, $nameSingleCode, $fieldName, - $fieldType, $component - ); - break; - case 'view': - $this->setPermissionViewFields( - $getForm, $nameSingleCode, $fieldName, - $fieldType, $component - ); - break; - case 'edit.own': - case 'access.own': - // this must still be build (TODO) - break; - } - } - } - } - // add the redirect trick to set the field of origin - $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Only load these values if no id is found"; - $getForm[] = Indent::_(2) . "if (0 == \$id)"; - $getForm[] = Indent::_(2) . "{"; - $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Set redirected view name"; - $getForm[] = Indent::_(3) - . "\$redirectedView = \$jinput->get('ref', null, 'STRING');"; - $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Set field name (or fall back to view name)"; - $getForm[] = Indent::_(3) - . "\$redirectedField = \$jinput->get('field', \$redirectedView, 'STRING');"; - $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Set redirected view id"; - $getForm[] = Indent::_(3) - . "\$redirectedId = \$jinput->get('refid', 0, 'INT');"; - $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Set field id (or fall back to redirected view id)"; - $getForm[] = Indent::_(3) - . "\$redirectedValue = \$jinput->get('field_id', \$redirectedId, 'INT');"; - $getForm[] = Indent::_(3) - . "if (0 != \$redirectedValue && \$redirectedField)"; - $getForm[] = Indent::_(3) . "{"; - $getForm[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Now set the local-redirected field default value"; - $getForm[] = Indent::_(4) - . "\$form->setValue(\$redirectedField, null, \$redirectedValue);"; - $getForm[] = Indent::_(3) . "}"; - // load custom script if found - $getForm[] = Indent::_(2) . "}" . CFactory::_('Customcode.Dispenser')->get( - 'php_getform', $nameSingleCode, PHP_EOL - ); - // setup the default script - $getForm[] = Indent::_(2) . "return \$form;"; - - return implode(PHP_EOL, $getForm); - } - - protected function setPermissionEditFields(&$allow, $nameSingleCode, - $fieldName, $fieldType, $component - ) - { - // only for fields that can be edited - if (!CFactory::_('Field.Groups')->check($fieldType, 'spacer')) - { - $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Modify the form based on Edit " - . StringHelper::safe($fieldName, 'W') - . " access controls."; - $allow[] = Indent::_(2) . "if (\$id != 0 && (!\$user->authorise('" - . $nameSingleCode . ".edit." . $fieldName . "', 'com_" - . $component . "." . $nameSingleCode . ".' . (int) \$id))"; - $allow[] = Indent::_(3) . "|| (\$id == 0 && !\$user->authorise('" - . $nameSingleCode . ".edit." . $fieldName . "', 'com_" - . $component . "')))"; - $allow[] = Indent::_(2) . "{"; - $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Disable fields for display."; - $allow[] = Indent::_(3) . "\$form->setFieldAttribute('" . $fieldName - . "', 'disabled', 'true');"; - $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Disable fields for display."; - $allow[] = Indent::_(3) . "\$form->setFieldAttribute('" . $fieldName - . "', 'readonly', 'true');"; - if ('radio' === $fieldType || 'repeatable' === $fieldType) - { - $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Disable radio button for display."; - $allow[] = Indent::_(3) - . "\$class = \$form->getFieldAttribute('" . $fieldName - . "', 'class', '');"; - $allow[] = Indent::_(3) . "\$form->setFieldAttribute('" - . $fieldName . "', 'class', \$class.' disabled no-click');"; - } - $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " If there is no value continue."; - $allow[] = Indent::_(3) . "if (!\$form->getValue('" . $fieldName - . "'))"; - $allow[] = Indent::_(3) . "{"; - $allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Disable fields while saving."; - $allow[] = Indent::_(4) . "\$form->setFieldAttribute('" . $fieldName - . "', 'filter', 'unset');"; - $allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Disable fields while saving."; - $allow[] = Indent::_(4) . "\$form->setFieldAttribute('" . $fieldName - . "', 'required', 'false');"; - $allow[] = Indent::_(3) . "}"; - $allow[] = Indent::_(2) . "}"; - } - } - - protected function setPermissionAccessFields(&$allow, $nameSingleCode, - $fieldName, $fieldType, $component - ) - { - $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Modify the from the form based on " - . StringHelper::safe($fieldName, 'W') - . " access controls."; - $allow[] = Indent::_(2) . "if (\$id != 0 && (!\$user->authorise('" - . $nameSingleCode . ".access." . $fieldName . "', 'com_" - . $component . "." . $nameSingleCode . ".' . (int) \$id))"; - $allow[] = Indent::_(3) . "|| (\$id == 0 && !\$user->authorise('" - . $nameSingleCode . ".access." . $fieldName . "', 'com_" - . $component . "')))"; - $allow[] = Indent::_(2) . "{"; - $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Remove the field"; - $allow[] = Indent::_(3) . "\$form->removeField('" . $fieldName . "');"; - $allow[] = Indent::_(2) . "}"; - } - - protected function setPermissionViewFields(&$allow, $nameSingleCode, - $fieldName, $fieldType, $component - ) - { - if (CFactory::_('Field.Groups')->check($fieldType, 'spacer')) - { - $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Modify the form based on View " - . StringHelper::safe($fieldName, 'W') - . " access controls."; - $allow[] = Indent::_(2) . "if (\$id != 0 && (!\$user->authorise('" - . $nameSingleCode . ".view." . $fieldName . "', 'com_" - . $component . "." . $nameSingleCode . ".' . (int) \$id))"; - $allow[] = Indent::_(3) . "|| (\$id == 0 && !\$user->authorise('" - . $nameSingleCode . ".view." . $fieldName . "', 'com_" - . $component . "')))"; - $allow[] = Indent::_(2) . "{"; - $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Remove the field"; - $allow[] = Indent::_(3) . "\$form->removeField('" . $fieldName - . "');"; - $allow[] = Indent::_(2) . "}"; - } - else - { - $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Modify the form based on View " - . StringHelper::safe($fieldName, 'W') - . " access controls."; - $allow[] = Indent::_(2) . "if (\$id != 0 && (!\$user->authorise('" - . $nameSingleCode . ".view." . $fieldName . "', 'com_" - . $component . "." . $nameSingleCode . ".' . (int) \$id))"; - $allow[] = Indent::_(3) . "|| (\$id == 0 && !\$user->authorise('" - . $nameSingleCode . ".view." . $fieldName . "', 'com_" - . $component . "')))"; - $allow[] = Indent::_(2) . "{"; - $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Make the field hidded."; - $allow[] = Indent::_(3) . "\$form->setFieldAttribute('" . $fieldName - . "', 'type', 'hidden');"; - $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " If there is no value continue."; - $allow[] = Indent::_(3) . "if (!(\$val = \$form->getValue('" - . $fieldName . "')))"; - $allow[] = Indent::_(3) . "{"; - $allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Disable fields while saving."; - $allow[] = Indent::_(4) . "\$form->setFieldAttribute('" . $fieldName - . "', 'filter', 'unset');"; - $allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Disable fields while saving."; - $allow[] = Indent::_(4) . "\$form->setFieldAttribute('" . $fieldName - . "', 'required', 'false');"; - $allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Make sure"; - $allow[] = Indent::_(4) . "\$form->setValue('" . $fieldName - . "', null, '');"; - $allow[] = Indent::_(3) . "}"; - $allow[] = Indent::_(3) . "elseif (" . ucfirst((string) $component) - . "Helper::checkArray(\$val))"; - $allow[] = Indent::_(3) . "{"; - $allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " We have to unset then (TODO)"; - $allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Hiddend field can not handel array value"; - $allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Even if we convert to json we get an error"; - $allow[] = Indent::_(4) . "\$form->removeField('" . $fieldName - . "');"; - $allow[] = Indent::_(3) . "}"; - $allow[] = Indent::_(2) . "}"; - } - } - - public function setJmodelAdminAllowEdit($nameSingleCode, $nameListCode) - { - $allow = array(); - // set component name - $component = CFactory::_('Config')->component_code_name; - // prepare custom permission script - $customAllow = CFactory::_('Customcode.Dispenser')->get( - 'php_allowedit', $nameSingleCode, Indent::_(2) - . "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;" - . PHP_EOL - ); - // check if the item has permissions. - if (CFactory::_('Compiler.Creator.Permission')->actionExist($nameSingleCode, 'core.edit')) - { - $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Check specific edit permission then general edit permission."; - $allow[] = Indent::_(2) . "\$user = JFactory::getUser();"; - // load custom permission script - $allow[] = $customAllow; - $allow[] = Indent::_(2) . "return \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit') - . "', 'com_" . $component . "." . $nameSingleCode - . ".'. ((int) isset(\$data[\$key]) ? \$data[\$key] : 0)) or \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit') - . "', 'com_" . $component . "');"; - } - else - { - $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Check specific edit permission then general edit permission."; - if (StringHelper::check($customAllow)) - { - $allow[] = Indent::_(2) . "\$user = JFactory::getUser();"; - } - // load custom permission script - $allow[] = $customAllow; - $allow[] = Indent::_(2) - . "return JFactory::getUser()->authorise('core.edit', 'com_" - . $component . "." . $nameSingleCode - . ".'. ((int) isset(\$data[\$key]) ? \$data[\$key] : 0)) or parent::allowEdit(\$data, \$key);"; - } - - return implode(PHP_EOL, $allow); - } - - public function setJmodelAdminCanDelete($nameSingleCode, $nameListCode) - { - $allow = array(); - // set component name - $component = CFactory::_('Config')->component_code_name; - if (0) //CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}")) <-- remove category from check - { - // check if category has another name - $otherViews = CFactory::_('Compiler.Builder.Category.Other.Name')-> - get($nameListCode . '.views', $nameListCode); - $otherView = CFactory::_('Compiler.Builder.Category.Other.Name')-> - get($nameListCode . '.view', $nameSingleCode); - // setup the category script - $allow[] = PHP_EOL . Indent::_(2) . "if (!empty(\$record->id))"; - $allow[] = Indent::_(2) . "{"; - $allow[] = Indent::_(3) . "if (\$record->published != -2)"; - $allow[] = Indent::_(3) . "{"; - $allow[] = Indent::_(4) . "return;"; - $allow[] = Indent::_(3) . "}"; - $allow[] = PHP_EOL . Indent::_(3) . "\$user = JFactory::getUser();"; - $allow[] = Indent::_(3) - . "\$allow = \$user->authorise('core.delete', 'com_" - . $component . "." . $otherView - . ".category.' . (int) \$record->catid);"; - // check if the item has permissions. - $allow[] = PHP_EOL . Indent::_(3) . "if (\$allow)"; - $allow[] = Indent::_(3) . "{"; - $allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " The record has been set. Check the record permissions."; - $allow[] = Indent::_(4) . "return \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($otherView, 'core.delete') . "', 'com_" . $component . "." - . $otherView . ".' . (int) \$record->id);"; - $allow[] = Indent::_(3) . "}"; - } - else - { - // setup the default script - $allow[] = PHP_EOL . Indent::_(2) . "if (!empty(\$record->id))"; - $allow[] = Indent::_(2) . "{"; - $allow[] = Indent::_(3) . "if (\$record->published != -2)"; - $allow[] = Indent::_(3) . "{"; - $allow[] = Indent::_(4) . "return;"; - $allow[] = Indent::_(3) . "}"; - // check if the item has permissions. - $allow[] = PHP_EOL . Indent::_(3) - . "\$user = JFactory::getUser();"; - $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " The record has been set. Check the record permissions."; - $allow[] = Indent::_(3) . "return \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.delete') . "', 'com_" . $component . "." - . $nameSingleCode . ".' . (int) \$record->id);"; - $allow[] = Indent::_(2) . "}"; - $allow[] = Indent::_(2) . "return false;"; - } - - return implode(PHP_EOL, $allow); - } - - public function setJmodelAdminCanEditState($nameSingleCode, - $nameListCode - ) - { - $allow = array(); - // set component name - $component = CFactory::_('Config')->component_code_name; - if (0) //CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}")) <-- remove category from check - { - // check if category has another name - $otherViews = CFactory::_('Compiler.Builder.Category.Other.Name')-> - get($nameListCode . '.views', $nameListCode); - $otherView = CFactory::_('Compiler.Builder.Category.Other.Name')-> - get($nameListCode . '.view', $nameSingleCode); - - $allow[] = PHP_EOL . Indent::_(2) . "\$user = JFactory::getUser();"; - $allow[] = Indent::_(2) - . "\$recordId = (!empty(\$record->id)) ? \$record->id : 0;"; - $allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)"; - $allow[] = Indent::_(2) . "{"; - $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " The record has been set. Check the record permissions."; - // check if the item has permissions. - $allow[] = Indent::_(3) . "\$permission = \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.state') . "', 'com_" . $component . "." - . $nameSingleCode . ".' . (int) \$recordId);"; - $allow[] = Indent::_(3) - . "if (!\$permission && !is_null(\$permission))"; - $allow[] = Indent::_(3) . "{"; - $allow[] = Indent::_(4) . "return false;"; - $allow[] = Indent::_(3) . "}"; - $allow[] = Indent::_(2) . "}"; - // setup the category script - $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Check against the category."; - $allow[] = Indent::_(2) . "if (!empty(\$record->catid))"; - $allow[] = Indent::_(2) . "{"; - $allow[] = Indent::_(3) - . "\$catpermission = \$user->authorise('core.edit.state', 'com_" - . $component . "." . $otherView - . ".category.' . (int) \$record->catid);"; - $allow[] = Indent::_(3) - . "if (!\$catpermission && !is_null(\$catpermission))"; - $allow[] = Indent::_(3) . "{"; - $allow[] = Indent::_(4) . "return false;"; - $allow[] = Indent::_(3) . "}"; - $allow[] = Indent::_(2) . "}"; - if (CFactory::_('Compiler.Creator.Permission')->actionExist($nameSingleCode, 'core.edit.state')) - { - $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " In the absence of better information, revert to the component permissions."; - $allow[] = Indent::_(2) . "return \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.state') - . "', 'com_" . $component . "');"; - } - else - { - $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " In the absence of better information, revert to the component permissions."; - $allow[] = Indent::_(2) - . "return parent::canEditState(\$record);"; - } - } - else - { - // setup the default script - $allow[] = PHP_EOL . Indent::_(2) . "\$user = JFactory::getUser();"; - $allow[] = Indent::_(2) - . "\$recordId = (!empty(\$record->id)) ? \$record->id : 0;"; - $allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)"; - $allow[] = Indent::_(2) . "{"; - $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " The record has been set. Check the record permissions."; - // check if the item has permissions. - $allow[] = Indent::_(3) . "\$permission = \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.state') - . "', 'com_" . $component . "." . $nameSingleCode . ".' . (int) \$recordId);"; - $allow[] = Indent::_(3) - . "if (!\$permission && !is_null(\$permission))"; - $allow[] = Indent::_(3) . "{"; - $allow[] = Indent::_(4) . "return false;"; - $allow[] = Indent::_(3) . "}"; - $allow[] = Indent::_(2) . "}"; - if (CFactory::_('Compiler.Creator.Permission')->globalExist($nameSingleCode, 'core.edit.state')) - { - $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " In the absence of better information, revert to the component permissions."; - $allow[] = Indent::_(2) . "return \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit.state') . "', 'com_" . $component - . "');"; - } - else - { - $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " In the absence of better information, revert to the component permissions."; - $allow[] = Indent::_(2) - . "return parent::canEditState(\$record);"; - } - } - - return implode(PHP_EOL, $allow); - } - - public function setJviewListCanDo($nameSingleCode, $nameListCode) - { - $allow = array(); - // set component name - $component = CFactory::_('Config')->component_code_name; - // check if the item has permissions for edit. - $allow[] = PHP_EOL . Indent::_(2) - . "\$this->canEdit = \$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit') - . "');"; - // check if the item has permissions for edit state. - $allow[] = Indent::_(2) . "\$this->canState = \$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit.state') - . "');"; - // check if the item has permissions for create. - $allow[] = Indent::_(2) . "\$this->canCreate = \$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.create') . "');"; - // check if the item has permissions for delete. - $allow[] = Indent::_(2) . "\$this->canDelete = \$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.delete') . "');"; - // check if the item has permissions for batch. - if (CFactory::_('Compiler.Creator.Permission')->globalExist($nameSingleCode, 'core.batch')) - { - $allow[] = Indent::_(2) . "\$this->canBatch = (\$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.batch') - . "') && \$this->canDo->get('core.batch'));"; - } - else - { - $allow[] = Indent::_(2) - . "\$this->canBatch = \$this->canDo->get('core.batch');"; - } - - return implode(PHP_EOL, $allow); - } - - public function setFieldSetAccessControl(&$view) - { - $access = ''; - if ($view != 'component') - { - // set component name - $component = CFactory::_('Config')->component_code_name; - // set label - $label = 'Permissions in relation to this ' . $view; - // set the access fieldset - $access = ""; - $access .= PHP_EOL . Indent::_(1) - . '
    '; - $access .= PHP_EOL . Indent::_(2) . ""; - $access .= PHP_EOL . Indent::_(2) . ''; - $access .= PHP_EOL . Indent::_(2) . ""; - $access .= PHP_EOL . Indent::_(2) . ''; - $access .= PHP_EOL . Indent::_(1) . '
    '; - } - - // return access field set - return $access; - } - - /** - * set the filter fields - * - * @param string $nameSingleCode The single view name - * @param string $nameListCode The list view name - * - * @return string The code for the filter fields array - * - */ - public function setFilterFieldsArray(&$nameSingleCode, &$nameListCode) - { - // keep track of all fields already added - $donelist = array('id' => true, 'search' => true, - 'published' => true, 'access' => true, - 'created_by' => true, 'modified_by' => true); - // default filter fields - $fields = "'a.id','id'"; - $fields .= "," . PHP_EOL . Indent::_(4) . "'a.published','published'"; - if (CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode)) - { - $fields .= "," . PHP_EOL . Indent::_(4) . "'a.access','access'"; - } - $fields .= "," . PHP_EOL . Indent::_(4) . "'a.ordering','ordering'"; - $fields .= "," . PHP_EOL . Indent::_(4) . "'a.created_by','created_by'"; - $fields .= "," . PHP_EOL . Indent::_(4) - . "'a.modified_by','modified_by'"; - - // add the rest of the set filters - if (CFactory::_('Compiler.Builder.Filter')->exists($nameListCode)) - { - foreach (CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as $filter) - { - if (!isset($donelist[$filter['code']])) - { - $fields .= $this->getFilterFieldCode( - $filter - ); - $donelist[$filter['code']] = true; - } - } - } - // add the rest of the set filters - if (CFactory::_('Compiler.Builder.Sort')->exists($nameListCode)) - { - foreach (CFactory::_('Compiler.Builder.Sort')->get($nameListCode) as $filter) - { - if (!isset($donelist[$filter['code']])) - { - $fields .= $this->getFilterFieldCode( - $filter - ); - $donelist[$filter['code']] = true; - } - } - } - - return $fields; - } - - /** - * Add the code of the filter field array - * - * @param array $filter The field/filter array - * - * @return string The code for the filter array - * - */ - protected function getFilterFieldCode(&$filter) - { - // add the category stuff (may still remove these) TODO - if ($filter['type'] === 'category') - { - $field = "," . PHP_EOL . Indent::_(4) - . "'c.title','category_title'"; - $field .= "," . PHP_EOL . Indent::_(4) - . "'c.id', 'category_id'"; - if ($filter['code'] != 'category') - { - $field .= "," . PHP_EOL . Indent::_(4) . "'a." - . $filter['code'] . "','" . $filter['code'] - . "'"; - } - } - else - { - // check if custom field is set - if (ArrayHelper::check( - $filter['custom'] - ) - && isset($filter['custom']['db']) - && StringHelper::check( - $filter['custom']['db'] - ) - && isset($filter['custom']['text']) - && StringHelper::check( - $filter['custom']['text'] - )) - { - $field = "," . PHP_EOL . Indent::_(4) . "'" - . $filter['custom']['db'] . "." - . $filter['custom']['text'] . "','" . $filter['code'] - . "'"; - } - else - { - $field = "," . PHP_EOL . Indent::_(4) . "'a." - . $filter['code'] . "','" . $filter['code'] - . "'"; - } - } - - return $field; - } - - /** - * set the sotred ids - * - * @param string $nameSingleCode The single view name - * @param string $nameListCode The list view name - * - * @return string The code for the populate state - * - */ - public function setStoredId(&$nameSingleCode, &$nameListCode) - { - // set component name - $Component = ucwords((string) CFactory::_('Config')->component_code_name); - // keep track of all fields already added - $donelist = array('id' => true, 'search' => true, - 'published' => true, 'access' => true, - 'created_by' => true, 'modified_by' => true); - // set the defaults first - $stored = "//" . Line::_(__Line__, __Class__) . " Compile the store id."; - $stored .= PHP_EOL . Indent::_(2) - . "\$id .= ':' . \$this->getState('filter.id');"; - $stored .= PHP_EOL . Indent::_(2) - . "\$id .= ':' . \$this->getState('filter.search');"; - // add this if not already added - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.published')) - { - $stored .= PHP_EOL . Indent::_(2) - . "\$id .= ':' . \$this->getState('filter.published');"; - } - // add if view calls for it, and not already added - if (CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode) - && !CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.access')) - { - // the side bar option is single - if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 1) - { - $stored .= PHP_EOL . Indent::_(2) - . "\$id .= ':' . \$this->getState('filter.access');"; - } - else - { - // top bar selection can result in - // an array due to multi selection - $stored .= $this->getStoredIdCodeMulti('access', $Component); - } - } - $stored .= PHP_EOL . Indent::_(2) - . "\$id .= ':' . \$this->getState('filter.ordering');"; - // add this if not already added - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.created_by')) - { - $stored .= PHP_EOL . Indent::_(2) - . "\$id .= ':' . \$this->getState('filter.created_by');"; - } - // add this if not already added - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.modified_by')) - { - $stored .= PHP_EOL . Indent::_(2) - . "\$id .= ':' . \$this->getState('filter.modified_by');"; - } - // add the rest of the set filters - if (CFactory::_('Compiler.Builder.Filter')->exists($nameListCode)) - { - foreach (CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as $filter) - { - if (!isset($donelist[$filter['code']])) - { - $stored .= $this->getStoredIdCode( - $filter, $nameListCode, $Component - ); - $donelist[$filter['code']] = true; - } - } - } - // add the rest of the set filters - if (CFactory::_('Compiler.Builder.Sort')->exists($nameListCode)) - { - foreach (CFactory::_('Compiler.Builder.Sort')->get($nameListCode) as $filter) - { - if (!isset($donelist[$filter['code']])) - { - $stored .= $this->getStoredIdCode( - $filter, $nameListCode, $Component - ); - $donelist[$filter['code']] = true; - } - } - } - - return $stored; - } - - /** - * Add the code of the stored ids - * - * @param array $filter The field/filter array - * @param string $nameListCode The list view name - * @param string $Component The Component name - * - * @return string The code for the stored IDs - * - */ - protected function getStoredIdCode(&$filter, &$nameListCode, &$Component) - { - if ($filter['type'] === 'category') - { - // the side bar option is single (1 = sidebar) - if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 1) - { - $stored = PHP_EOL . Indent::_(2) - . "\$id .= ':' . \$this->getState('filter.category');"; - $stored .= PHP_EOL . Indent::_(2) - . "\$id .= ':' . \$this->getState('filter.category_id');"; - if ($filter['code'] != 'category') - { - $stored .= PHP_EOL . Indent::_(2) - . "\$id .= ':' . \$this->getState('filter." - . $filter['code'] . "');"; - } - } - else - { - $stored = $this->getStoredIdCodeMulti('category', $Component); - $stored .= $this->getStoredIdCodeMulti( - 'category_id', $Component - ); - if ($filter['code'] != 'category') - { - $stored .= $this->getStoredIdCodeMulti( - $filter['code'], $Component - ); - } - } - } - else - { - // check if this is the topbar filter, and multi option (2 = topbar) - if (isset($filter['multi']) && $filter['multi'] == 2 - && CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2) - { - // top bar selection can result in - // an array due to multi selection - $stored = $this->getStoredIdCodeMulti( - $filter['code'], $Component - ); - } - else - { - $stored = PHP_EOL . Indent::_(2) - . "\$id .= ':' . \$this->getState('filter." - . $filter['code'] . "');"; - } - } - - return $stored; - } - - /** - * Add the code of the stored multi ids - * - * @param string $key The key field name - * @param string $Component The Component name - * - * @return string The code for the stored IDs - * - */ - protected function getStoredIdCodeMulti($key, &$Component) - { - // top bar selection can result in - // an array due to multi selection - $stored = PHP_EOL . Indent::_(2) - . "//" . Line::_(__Line__, __Class__) - . " Check if the value is an array"; - $stored .= PHP_EOL . Indent::_(2) - . "\$_" . $key . " = \$this->getState('filter." - . $key . "');"; - $stored .= PHP_EOL . Indent::_(2) - . "if (" . $Component . "Helper::checkArray(\$_" - . $key . "))"; - $stored .= PHP_EOL . Indent::_(2) - . "{"; - $stored .= PHP_EOL . Indent::_(3) - . "\$id .= ':' . implode(':', \$_" . $key . ");"; - $stored .= PHP_EOL . Indent::_(2) - . "}"; - $stored .= PHP_EOL . Indent::_(2) - . "//" . Line::_(__Line__, __Class__) - . " Check if this is only an number or string"; - $stored .= PHP_EOL . Indent::_(2) - . "elseif (is_numeric(\$_" . $key . ")"; - $stored .= PHP_EOL . Indent::_(2) - . " || " . $Component . "Helper::checkString(\$_" . $key . "))"; - $stored .= PHP_EOL . Indent::_(2) - . "{"; - $stored .= PHP_EOL . Indent::_(3) - . "\$id .= ':' . \$_" . $key . ";"; - $stored .= PHP_EOL . Indent::_(2) - . "}"; - - return $stored; - } - - public function setAddToolBar(&$view) - { - // set view name - $nameSingleCode = $view['settings']->name_single_code; - // check type - if ($view['settings']->type == 2) - { - // set lang strings - $viewNameLang_readonly = $this->langPrefix . '_' - . StringHelper::safe( - $view['settings']->name_single . ' readonly', 'U' - ); - // load to lang - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $viewNameLang_readonly, - $view['settings']->name_single . ' :: Readonly' - ); - - // build toolbar - $toolBar - = "JFactory::getApplication()->input->set('hidemainmenu', true);"; - $toolBar .= PHP_EOL . Indent::_(2) . "JToolBarHelper::title(JText:" - . ":_('" . $viewNameLang_readonly . "'), '" . $nameSingleCode - . "');"; - $toolBar .= PHP_EOL . Indent::_(2) . "JToolBarHelper::cancel('" - . $nameSingleCode . ".cancel', 'JTOOLBAR_CLOSE');"; - } - else - { - // set lang strings - $viewNameLang_new = $this->langPrefix . '_' - . StringHelper::safe( - $view['settings']->name_single . ' New', 'U' - ); - $viewNameLang_edit = $this->langPrefix . '_' - . StringHelper::safe( - $view['settings']->name_single . ' Edit', 'U' - ); - // load to lang - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $viewNameLang_new, - 'A New ' . $view['settings']->name_single - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $viewNameLang_edit, - 'Editing the ' . $view['settings']->name_single - ); - // build toolbar - $toolBar - = "JFactory::getApplication()->input->set('hidemainmenu', true);"; - $toolBar .= PHP_EOL . Indent::_(2) - . "\$user = JFactory::getUser();"; - $toolBar .= PHP_EOL . Indent::_(2) . "\$userId = \$user->id;"; - $toolBar .= PHP_EOL . Indent::_(2) - . "\$isNew = \$this->item->id == 0;"; - $toolBar .= PHP_EOL . PHP_EOL . Indent::_(2) - . "JToolbarHelper::title( JText:" . ":_(\$isNew ? '" - . $viewNameLang_new . "' : '" . $viewNameLang_edit - . "'), 'pencil-2 article-add');"; - $toolBar .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Built the actions for new and existing records."; - $toolBar .= PHP_EOL . Indent::_(2) . "if (" - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkString(\$this->referral))"; - $toolBar .= PHP_EOL . Indent::_(2) . "{"; - $toolBar .= PHP_EOL . Indent::_(3) . "if (\$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.create') . "') && \$isNew)"; - $toolBar .= PHP_EOL . Indent::_(3) . "{"; - $toolBar .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " We can create the record."; - $toolBar .= PHP_EOL . Indent::_(4) . "JToolBarHelper::save('" - . $nameSingleCode . ".save', 'JTOOLBAR_SAVE');"; - $toolBar .= PHP_EOL . Indent::_(3) . "}"; - $toolBar .= PHP_EOL . Indent::_(3) - . "elseif (\$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit') - . "'))"; - $toolBar .= PHP_EOL . Indent::_(3) . "{"; - $toolBar .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " We can save the record."; - $toolBar .= PHP_EOL . Indent::_(4) . "JToolBarHelper::save('" - . $nameSingleCode . ".save', 'JTOOLBAR_SAVE');"; - $toolBar .= PHP_EOL . Indent::_(3) . "}"; - $toolBar .= PHP_EOL . Indent::_(3) . "if (\$isNew)"; - $toolBar .= PHP_EOL . Indent::_(3) . "{"; - $toolBar .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Do not creat but cancel."; - $toolBar .= PHP_EOL . Indent::_(4) . "JToolBarHelper::cancel('" - . $nameSingleCode . ".cancel', 'JTOOLBAR_CANCEL');"; - $toolBar .= PHP_EOL . Indent::_(3) . "}"; - $toolBar .= PHP_EOL . Indent::_(3) . "else"; - $toolBar .= PHP_EOL . Indent::_(3) . "{"; - $toolBar .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " We can close it."; - $toolBar .= PHP_EOL . Indent::_(4) . "JToolBarHelper::cancel('" - . $nameSingleCode . ".cancel', 'JTOOLBAR_CLOSE');"; - $toolBar .= PHP_EOL . Indent::_(3) . "}"; - $toolBar .= PHP_EOL . Indent::_(2) . "}"; - $toolBar .= PHP_EOL . Indent::_(2) . "else"; - $toolBar .= PHP_EOL . Indent::_(2) . "{"; - $toolBar .= PHP_EOL . Indent::_(3) . "if (\$isNew)"; - $toolBar .= PHP_EOL . Indent::_(3) . "{"; - $toolBar .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " For new records, check the create permission."; - $toolBar .= PHP_EOL . Indent::_(4) . "if (\$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.create') . "'))"; - $toolBar .= PHP_EOL . Indent::_(4) . "{"; - $toolBar .= PHP_EOL . Indent::_(5) . "JToolBarHelper::apply('" - . $nameSingleCode . ".apply', 'JTOOLBAR_APPLY');"; - $toolBar .= PHP_EOL . Indent::_(5) . "JToolBarHelper::save('" - . $nameSingleCode . ".save', 'JTOOLBAR_SAVE');"; - $toolBar .= PHP_EOL . Indent::_(5) . "JToolBarHelper::custom('" - . $nameSingleCode - . ".save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);"; - $toolBar .= PHP_EOL . Indent::_(4) . "};"; - $toolBar .= PHP_EOL . Indent::_(4) . "JToolBarHelper::cancel('" - . $nameSingleCode . ".cancel', 'JTOOLBAR_CANCEL');"; - $toolBar .= PHP_EOL . Indent::_(3) . "}"; - $toolBar .= PHP_EOL . Indent::_(3) . "else"; - $toolBar .= PHP_EOL . Indent::_(3) . "{"; - $toolBar .= PHP_EOL . Indent::_(4) . "if (\$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit') . "'))"; - $toolBar .= PHP_EOL . Indent::_(4) . "{"; - $toolBar .= PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__) - . " We can save the new record"; - $toolBar .= PHP_EOL . Indent::_(5) . "JToolBarHelper::apply('" - . $nameSingleCode . ".apply', 'JTOOLBAR_APPLY');"; - $toolBar .= PHP_EOL . Indent::_(5) . "JToolBarHelper::save('" - . $nameSingleCode . ".save', 'JTOOLBAR_SAVE');"; - $toolBar .= PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__) - . " We can save this record, but check the create permission to see"; - $toolBar .= PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__) - . " if we can return to make a new one."; - $toolBar .= PHP_EOL . Indent::_(5) . "if (\$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.create') . "'))"; - $toolBar .= PHP_EOL . Indent::_(5) . "{"; - $toolBar .= PHP_EOL . Indent::_(6) . "JToolBarHelper::custom('" - . $nameSingleCode - . ".save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);"; - $toolBar .= PHP_EOL . Indent::_(5) . "}"; - $toolBar .= PHP_EOL . Indent::_(4) . "}"; - if (CFactory::_('Compiler.Creator.Permission')->globalExist($nameSingleCode, 'core.edit')) - { - if (CFactory::_('Compiler.Builder.History')->exists($nameSingleCode)) - { - $toolBar .= PHP_EOL . Indent::_(4) - . "\$canVersion = (\$this->canDo->get('core.version') && \$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.version') - . "'));"; - $toolBar .= PHP_EOL . Indent::_(4) - . "if (\$this->state->params->get('save_history', 1) && \$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit') - . "') && \$canVersion)"; - $toolBar .= PHP_EOL . Indent::_(4) . "{"; - $toolBar .= PHP_EOL . Indent::_(5) - . "JToolbarHelper::versions('com_" - . CFactory::_('Config')->component_code_name . "." . $nameSingleCode - . "', \$this->item->id);"; - $toolBar .= PHP_EOL . Indent::_(4) . "}"; - } - } - else - { - if (CFactory::_('Compiler.Builder.History')->exists($nameSingleCode)) - { - $toolBar .= PHP_EOL . Indent::_(4) - . "\$canVersion = (\$this->canDo->get('core.version') && \$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.version') . "'));"; - $toolBar .= PHP_EOL . Indent::_(4) - . "if (\$this->state->params->get('save_history', 1) && \$this->canDo->get('core.edit') && \$canVersion)"; - $toolBar .= PHP_EOL . Indent::_(4) . "{"; - $toolBar .= PHP_EOL . Indent::_(5) - . "JToolbarHelper::versions('com_" - . CFactory::_('Config')->component_code_name . "." . $nameSingleCode - . "', \$this->item->id);"; - $toolBar .= PHP_EOL . Indent::_(4) . "}"; - } - } - $toolBar .= PHP_EOL . Indent::_(4) . "if (\$this->canDo->get('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.create') . "'))"; - $toolBar .= PHP_EOL . Indent::_(4) . "{"; - $toolBar .= PHP_EOL . Indent::_(5) . "JToolBarHelper::custom('" - . $nameSingleCode - . ".save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);"; - $toolBar .= PHP_EOL . Indent::_(4) . "}"; - // add custom buttons - $toolBar .= $this->setCustomButtons($view, 2, Indent::_(2)); - $toolBar .= PHP_EOL . Indent::_(4) . "JToolBarHelper::cancel('" - . $nameSingleCode . ".cancel', 'JTOOLBAR_CLOSE');"; - $toolBar .= PHP_EOL . Indent::_(3) . "}"; - $toolBar .= PHP_EOL . Indent::_(2) . "}"; - $toolBar .= PHP_EOL . Indent::_(2) . "JToolbarHelper::divider();"; - $toolBar .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " set help url for this view if found"; - $toolBar .= PHP_EOL . Indent::_(2) . "\$this->help_url = " - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::getHelpUrl('" . $nameSingleCode - . "');"; - $toolBar .= PHP_EOL . Indent::_(2) . "if (" - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkString(\$this->help_url))"; - $toolBar .= PHP_EOL . Indent::_(2) . "{"; - $toolBar .= PHP_EOL . Indent::_(3) . "JToolbarHelper::help('" - . $this->langPrefix . "_HELP_MANAGER', false, \$this->help_url);"; - $toolBar .= PHP_EOL . Indent::_(2) . "}"; - } - - return $toolBar; - } - - /** - * set the populate state code - * - * @param string $nameSingleCode The single view name - * @param string $nameListCode The list view name - * - * @return string The code for the populate state - * - */ - public function setPopulateState(&$nameSingleCode, &$nameListCode) - { - // reset bucket - $state = ''; - // keep track of all fields already added - $donelist = array(); - // we must add the formSubmited code if new above filters is used (2 = topbar) - $new_filter = false; - if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2) - { - $state .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" - . Line::_(__Line__, __Class__) . " Check if the form was submitted"; - $state .= PHP_EOL . Indent::_(2) . "\$formSubmited" - . " = \$app->input->post->get('form_submited');"; - $new_filter = true; - } - // add the default populate states (this must be added first) - $state .= $this->setDefaultPopulateState($nameSingleCode, $new_filter); - // add the filters - if (CFactory::_('Compiler.Builder.Filter')->exists($nameListCode)) - { - foreach (CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as $filter) - { - if (!isset($donelist[$filter['code']])) - { - $state .= $this->getPopulateStateFilterCode( - $filter, $new_filter - ); - $donelist[$filter['code']] = true; - } - } - } - // add the rest of the set filters - if (CFactory::_('Compiler.Builder.Sort')->exists($nameListCode)) - { - foreach (CFactory::_('Compiler.Builder.Sort')->get($nameListCode) as $filter) - { - if (!isset($donelist[$filter['code']])) - { - $state .= $this->getPopulateStateFilterCode( - $filter, $new_filter - ); - $donelist[$filter['code']] = true; - } - } - } - - return $state; - } - - /** - * Add the code of the filter in the populate state - * - * @param array $filter The field/filter array - * @param bool $newFilter The switch to use the new filter - * @param string $extra The defaults/extra options of the filter - * - * @return string The code for the populate state - * - */ - protected function getPopulateStateFilterCode(&$filter, $newFilter, - $extra = '' - ) - { - $state = ''; - // add category stuff (may still remove these) TODO - if (isset($filter['type']) && $filter['type'] === 'category') - { - $state .= PHP_EOL . PHP_EOL . Indent::_(2) - . "\$category = \$app->getUserStateFromRequest(\$this->context . '.filter.category', 'filter_category');"; - $state .= PHP_EOL . Indent::_(2) - . "\$this->setState('filter.category', \$category);"; - $state .= PHP_EOL . PHP_EOL . Indent::_(2) - . "\$categoryId = \$this->getUserStateFromRequest(\$this->context . '.filter.category_id', 'filter_category_id');"; - $state .= PHP_EOL . Indent::_(2) - . "\$this->setState('filter.category_id', \$categoryId);"; - } - // always add the default filter - $state .= PHP_EOL . PHP_EOL . Indent::_(2) . "\$" . $filter['code'] - . " = \$this->getUserStateFromRequest(\$this->context . '.filter." - . $filter['code'] . "', 'filter_" . $filter['code'] - . "'" . $extra . ");"; - if ($newFilter) - { - // add the new filter option - $state .= PHP_EOL . Indent::_(2) - . "if (\$formSubmited)"; - $state .= PHP_EOL . Indent::_(2) . "{"; - $state .= PHP_EOL . Indent::_(3) . "\$" . $filter['code'] - . " = \$app->input->post->get('" . $filter['code'] . "');"; - $state .= PHP_EOL . Indent::_(3) - . "\$this->setState('filter." . $filter['code'] - . "', \$" . $filter['code'] . ");"; - $state .= PHP_EOL . Indent::_(2) . "}"; - } - else - { - // the old filter option - $state .= PHP_EOL . Indent::_(2) - . "\$this->setState('filter." . $filter['code'] - . "', \$" . $filter['code'] . ");"; - } - - return $state; - } - - /** - * set the default populate state code - * - * @param string $nameSingleCode The single view name - * @param bool $newFilter The switch to use the new filter - * - * @return string The state code added - * - */ - protected function setDefaultPopulateState(&$nameSingleCode, $newFilter) - { - $state = ''; - // start filter - $filter = array('type' => 'text'); - // if access is not set add its default filter here - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.access')) - { - $filter['code'] = "access"; - $state .= $this->getPopulateStateFilterCode( - $filter, $newFilter, ", 0, 'int'" - ); - } - // if published is not set add its default filter here - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.published')) - { - $filter['code'] = "published"; - $state .= $this->getPopulateStateFilterCode( - $filter, false, ", ''" - ); - } - // if created_by is not set add its default filter here - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.created_by')) - { - $filter['code'] = "created_by"; - $state .= $this->getPopulateStateFilterCode( - $filter, false, ", ''" - ); - } - // if created is not set add its default filter here - if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.created')) - { - $filter['code'] = "created"; - $state .= $this->getPopulateStateFilterCode( - $filter, false - ); - } - - // the sorting defaults are always added - $filter['code'] = "sorting"; - $state .= $this->getPopulateStateFilterCode( - $filter, false, ", 0, 'int'" - ); - // the search defaults are always added - $filter['code'] = "search"; - $state .= $this->getPopulateStateFilterCode($filter, false); - - return $state; - } - - /** - * set the sorted field array for the getSortFields method - * - * @param string $nameSingleCode The single view name - * - * @return string The array/string of fields to add to the getSortFields method - * - */ - public function setSortFields(&$nameListCode) - { - // keep track of all fields already added - $donelist = array('ordering', 'published'); - // set the default first - $fields = "return array("; - $fields .= PHP_EOL . Indent::_(3) . "'a.ordering' => JText:" - . ":_('JGRID_HEADING_ORDERING')"; - $fields .= "," . PHP_EOL . Indent::_(3) . "'a.published' => JText:" - . ":_('JSTATUS')"; - - // add the rest of the set filters - if (CFactory::_('Compiler.Builder.Sort')->exists($nameListCode)) - { - foreach (CFactory::_('Compiler.Builder.Sort')->get($nameListCode) as $filter) - { - if (!in_array($filter['code'], $donelist)) - { - if ($filter['type'] === 'category') - { - $fields .= "," . PHP_EOL . Indent::_(3) - . "'category_title' => JText:" . ":_('" - . $filter['lang'] . "')"; - } - elseif (ArrayHelper::check( - $filter['custom'] - )) - { - $fields .= "," . PHP_EOL . Indent::_(3) . "'" - . $filter['custom']['db'] . "." - . $filter['custom']['text'] . "' => JText:" . ":_('" - . $filter['lang'] . "')"; - } - else - { - $fields .= "," . PHP_EOL . Indent::_(3) . "'a." - . $filter['code'] . "' => JText:" . ":_('" - . $filter['lang'] . "')"; - } - } - } - } - $fields .= "," . PHP_EOL . Indent::_(3) . "'a.id' => JText:" - . ":_('JGRID_HEADING_ID')"; - $fields .= PHP_EOL . Indent::_(2) . ");"; - - // return fields - return $fields; - } - - public function setCheckinCall() - { - $call = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Check in items"; - $call .= PHP_EOL . Indent::_(2) . "\$this->checkInNow();" . PHP_EOL; - - return $call; - } - - public function setAutoCheckin($view, $component) - { - $checkin = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $checkin .= PHP_EOL . Indent::_(1) - . " * Build an SQL query to checkin all items left checked out longer then a set time."; - $checkin .= PHP_EOL . Indent::_(1) . " *"; - $checkin .= PHP_EOL . Indent::_(1) . " * @return a bool"; - $checkin .= PHP_EOL . Indent::_(1) . " *"; - $checkin .= PHP_EOL . Indent::_(1) . " */"; - $checkin .= PHP_EOL . Indent::_(1) . "protected function checkInNow()"; - $checkin .= PHP_EOL . Indent::_(1) . "{"; - $checkin .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " Get set check in time"; - $checkin .= PHP_EOL . Indent::_(2) - . "\$time = JComponentHelper::getParams('com_" . $component - . "')->get('check_in');"; - $checkin .= PHP_EOL . PHP_EOL . Indent::_(2) . "if (\$time)"; - $checkin .= PHP_EOL . Indent::_(2) . "{"; - $checkin .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Get a db connection."; - $checkin .= PHP_EOL . Indent::_(3) . "\$db = JFactory::getDbo();"; - $checkin .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Reset query."; - $checkin .= PHP_EOL . Indent::_(3) . "\$query = \$db->getQuery(true);"; - $checkin .= PHP_EOL . Indent::_(3) . "\$query->select('*');"; - $checkin .= PHP_EOL . Indent::_(3) - . "\$query->from(\$db->quoteName('#__" . $component . "_" . $view - . "'));"; - $checkin .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Only select items that are checked out."; - $checkin .= PHP_EOL . Indent::_(3) - . "\$query->where(\$db->quoteName('checked_out') . '!=0');"; - Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " Query only to see if we have a rows"; - $checkin .= PHP_EOL . Indent::_(3) . "\$db->setQuery(\$query, 0, 1);"; - $checkin .= PHP_EOL . Indent::_(3) . "\$db->execute();"; - $checkin .= PHP_EOL . Indent::_(3) . "if (\$db->getNumRows())"; - $checkin .= PHP_EOL . Indent::_(3) . "{"; - $checkin .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Get Yesterdays date."; - $checkin .= PHP_EOL . Indent::_(4) - . "\$date = JFactory::getDate()->modify(\$time)->toSql();"; - $checkin .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Reset query."; - $checkin .= PHP_EOL . Indent::_(4) . "\$query = \$db->getQuery(true);"; - $checkin .= PHP_EOL . PHP_EOL . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Fields to update."; - $checkin .= PHP_EOL . Indent::_(4) . "\$fields = array("; - $checkin .= PHP_EOL . Indent::_(5) - . "\$db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'',"; - $checkin .= PHP_EOL . Indent::_(5) - . "\$db->quoteName('checked_out') . '=0'"; - $checkin .= PHP_EOL . Indent::_(4) . ");"; - $checkin .= PHP_EOL . PHP_EOL . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Conditions for which records should be updated."; - $checkin .= PHP_EOL . Indent::_(4) . "\$conditions = array("; - $checkin .= PHP_EOL . Indent::_(5) - . "\$db->quoteName('checked_out') . '!=0', "; - $checkin .= PHP_EOL . Indent::_(5) - . "\$db->quoteName('checked_out_time') . '<\''.\$date.'\''"; - $checkin .= PHP_EOL . Indent::_(4) . ");"; - $checkin .= PHP_EOL . PHP_EOL . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Check table."; - $checkin .= PHP_EOL . Indent::_(4) - . "\$query->update(\$db->quoteName('#__" . $component . "_" . $view - . "'))->set(\$fields)->where(\$conditions); "; - $checkin .= PHP_EOL . PHP_EOL . Indent::_(4) - . "\$db->setQuery(\$query);"; - $checkin .= PHP_EOL . PHP_EOL . Indent::_(4) . "\$db->execute();"; - $checkin .= PHP_EOL . Indent::_(3) . "}"; - $checkin .= PHP_EOL . Indent::_(2) . "}"; - $checkin .= PHP_EOL . PHP_EOL . Indent::_(2) . "return false;"; - $checkin .= PHP_EOL . Indent::_(1) . "}"; - - return $checkin; - } - - public function setGetItemsMethodStringFix($nameSingleCode, $nameListCode, - $Component, $tab = '', $export = false, $all = false) - { - // add the fix if this view has the need for it - $fix = ''; - $forEachStart = ''; - $fix_access = ''; - // encryption switches - foreach (CFactory::_('Config')->cryption_types as $cryptionType) - { - ${$cryptionType . 'Crypt'} = false; - } - $component = StringHelper::safe($Component); - // check if the item has permissions. - if (CFactory::_('Compiler.Creator.Permission')->actionExist($nameSingleCode, 'core.access')) - { - $fix_access = PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) - . " Remove items the user can't access."; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "\$access = (\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.access') - . "', 'com_" . $component . "." . $nameSingleCode - . ".' . (int) \$item->id) && \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.access') - . "', 'com_" . $component . "'));"; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "if (!\$access)"; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "{"; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) - . "unset(\$items[\$nr]);"; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) - . "continue;"; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "}" - . PHP_EOL; - } - // add the tags if needed - if (CFactory::_('Compiler.Builder.Tags')->exists($nameSingleCode)) - { - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//" - . Line::_( - __LINE__,__CLASS__ - ) . " Add the tags"; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "\$item->tags = new JHelperTags;"; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "\$item->tags->getTagIds("; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) - . "\$item->id, 'com_" - . CFactory::_('Compiler.Builder.Content.One')->get('component') . ".$nameSingleCode'"; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . ");"; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "if (\$item->tags->tags)"; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "{"; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) - . "\$item->tags = implode(', ',"; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) - . "\$item->tags->getTagNames("; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(6) - . "explode(',', \$item->tags->tags)"; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) . ")"; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) . ");"; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "}"; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "else"; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "{"; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) - . "\$item->tags = '';"; - $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "}"; - } - // get the correct array - if ($export || $all) - { - $action_ = 'Eximport'; - } - else - { - $action_ = 'List'; - } - // load the relations before modeling - if (($field_relations = - CFactory::_('Compiler.Builder.Field.Relations')->get($nameListCode)) !== null) - { - foreach ($field_relations as $field_id => $fields) - { - foreach ($fields as $area => $field) - { - if ($area == 1 && isset($field['code'])) - { - $fix .= $this->setModelFieldRelation( - $field, $nameListCode, $tab - ); - } - } - } - } - // open the values - if (CFactory::_("Compiler.Builder.Items.Method.{$action_}.String")->exists($nameSingleCode)) - { - foreach (CFactory::_("Compiler.Builder.Items.Method.{$action_}.String")-> - get($nameSingleCode) as $item) - { - switch ($item['method']) - { - case 1: - // JSON_STRING_ENCODE - $decode = 'json_decode'; - $suffix_decode = ', true'; - break; - case 2: - // BASE_SIXTY_FOUR - $decode = 'base64_decode'; - $suffix_decode = ''; - break; - case 3: - // BASIC_ENCRYPTION_LOCALKEY - $decode = '$basic->decryptString'; - $basicCrypt = true; - $suffix_decode = ''; - break; - case 4: - // WHMCS_ENCRYPTION_WHMCS - $decode = '$whmcs->decryptString'; - $whmcsCrypt = true; - $suffix_decode = ''; - break; - case 5: - // MEDIUM_ENCRYPTION_LOCALFILE - $decode = '$medium->decryptString'; - $mediumCrypt = true; - $suffix_decode = ''; - break; - case 6: - // EXPERT_ENCRYPTION - $expertCrypt = true; - break; - default: - // JSON_ARRAY_ENCODE - $decode = 'json_decode'; - $suffix_decode = ', true'; - // fallback on json - $item['method'] = 1; - break; - } - - if ($item['type'] === 'usergroup' && !$export - && $item['method'] != 6) - { - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) . " decode " . $item['name']; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "\$" - . $item['name'] . "Array = " . $decode . "(\$item->" - . $item['name'] . $suffix_decode . ");"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "if (" . $Component . "Helper::checkArray(\$" - . $item['name'] . "Array))"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "{"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) . "\$" - . $item['name'] . "Names = array();"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) - . "foreach (\$" . $item['name'] . "Array as \$" - . $item['name'] . ")"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) . "{"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) . "\$" - . $item['name'] . "Names[] = " . $Component - . "Helper::getGroupName(\$" . $item['name'] . ");"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) . "}"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) - . "\$item->" . $item['name'] . " = implode(', ', \$" - . $item['name'] . "Names);"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "}"; - } - /* elseif ($item['type'] === 'usergroup' && $export) - { - $fix .= PHP_EOL.Indent::_(1).$tab.Indent::_(3) . "//".Line::_(__Line__, __Class__)." decode ".$item['name']; - $fix .= PHP_EOL.Indent::_(1).$tab.Indent::_(3) . "\$".$item['name']."Array = ".$decode."(\$item->".$item['name'].$suffix_decode.");"; - $fix .= PHP_EOL.Indent::_(1).$tab.Indent::_(3) . "if (".$Component."Helper::checkArray(\$".$item['name']."Array))"; - $fix .= PHP_EOL.Indent::_(1).$tab.Indent::_(3) . "{"; - $fix .= PHP_EOL.Indent::_(1).$tab.Indent::_(4) . "\$item->".$item['name']." = implode('|',\$".$item['name']."Array);"; - $fix .= PHP_EOL.Indent::_(1).$tab.Indent::_(3) . "}"; - } */ - elseif ($item['translation'] && !$export - && $item['method'] != 6) - { - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) . " decode " . $item['name']; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "\$" - . $item['name'] . "Array = " . $decode . "(\$item->" - . $item['name'] . $suffix_decode . ");"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "if (" . $Component . "Helper::checkArray(\$" - . $item['name'] . "Array))"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "{"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) . "\$" - . $item['name'] . "Names = array();"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) - . "foreach (\$" . $item['name'] . "Array as \$" - . $item['name'] . ")"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) . "{"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) . "\$" - . $item['name'] . "Names[] = JText:" - . ":_(\$this->selectionTranslation(\$" . $item['name'] - . ", '" . $item['name'] . "'));"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) . "}"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) - . "\$item->" . $item['name'] . " = implode(', ', \$" - . $item['name'] . "Names);"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "}"; - } - else - { - if ($item['method'] == 2 || $item['method'] == 3 || $item['method'] == 4 - || $item['method'] == 5 || $item['method'] == 6) - { - // expert mode (dev must do it all) - if ($item['method'] == 6) - { - $_placeholder_for_field - = array('[[[field]]]' => "\$item->" . $item['name']); - $fix .= CFactory::_('Placeholder')->update( - PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . implode(PHP_EOL . Indent::_(1) . $tab . Indent::_(3), - CFactory::_('Compiler.Builder.Model.Expert.Field')->get( - $nameSingleCode . '.' . $item['name'] . '.get', [] - ) - ), $_placeholder_for_field - ); - } - else - { - $taber = ''; - if ($item['method'] == 3) - { - $taber = Indent::_(1); - $fix .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(3) - . "if (\$basickey && !is_numeric(\$item->" - . $item['name'] . ") && \$item->" - . $item['name'] - . " === base64_encode(base64_decode(\$item->" - . $item['name'] . ", true)))"; - $fix .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(3) . "{"; - } - elseif ($item['method'] == 5) - { - $taber = Indent::_(1); - $fix .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(3) - . "if (\$mediumkey && !is_numeric(\$item->" - . $item['name'] . ") && \$item->" - . $item['name'] - . " === base64_encode(base64_decode(\$item->" - . $item['name'] . ", true)))"; - $fix .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(3) . "{"; - } - elseif ($item['method'] == 4) - { - $taber = Indent::_(1); - $fix .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(3) - . "if (\$whmcskey && !is_numeric(\$item->" - . $item['name'] . ") && \$item->" - . $item['name'] - . " === base64_encode(base64_decode(\$item->" - . $item['name'] . ", true)))"; - $fix .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(3) . "{"; - } - if ($item['method'] == 3 || $item['method'] == 4 - || $item['method'] == 5) - { - $fix .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " decrypt " . $item['name']; - } - else - { - $fix .= PHP_EOL . Indent::_(1) . $tab . $taber - . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " decode " . $item['name']; - } - $fix .= PHP_EOL . Indent::_(1) . $tab . $taber - . Indent::_(3) . "\$item->" . $item['name'] - . " = " . $decode . "(\$item->" . $item['name'] - . ");"; - - if ($item['method'] == 3 || $item['method'] == 4 - || $item['method'] == 5) - { - $fix .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(3) . "}"; - } - } - } - else - { - if ($export && $item['type'] === 'repeatable') - { - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "//" . Line::_(__Line__, __Class__) - . " decode repeatable " . $item['name']; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "\$" . $item['name'] . "Array = " . $decode - . "(\$item->" . $item['name'] . $suffix_decode - . ");"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "if (" . $Component . "Helper::checkArray(\$" - . $item['name'] . "Array))"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "{"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) - . "\$bucket" . $item['name'] . " = array();"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) - . "foreach (\$" . $item['name'] . "Array as \$" - . $item['name'] . "FieldName => \$" - . $item['name'] . ")"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) - . "{"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) - . "if (" . $Component . "Helper::checkArray(\$" - . $item['name'] . "))"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) - . "{"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(6) - . "\$bucket" . $item['name'] . "[] = \$" - . $item['name'] - . "FieldName . '<||VDM||>' . implode('<|VDM|>',\$" - . $item['name'] . ");"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) - . "}"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) - . "}"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) - . "//" . Line::_(__Line__, __Class__) - . " make sure the bucket has values."; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) - . "if (" . $Component - . "Helper::checkArray(\$bucket" . $item['name'] - . "))"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) - . "{"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) - . "//" . Line::_(__Line__, __Class__) - . " clear the repeatable field."; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) - . "unset(\$item->" . $item['name'] . ");"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) - . "//" . Line::_(__Line__, __Class__) - . " set repeatable field for export."; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) - . "\$item->" . $item['name'] - . " = implode('<|||VDM|||>',\$bucket" - . $item['name'] . ");"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) - . "//" . Line::_(__Line__, __Class__) - . " unset the bucket."; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) - . "unset(\$bucket" . $item['name'] . ");"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) - . "}"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "}"; - } - elseif ($item['method'] == 1 && !$export) - { - // TODO we check if this works well. - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "//" . Line::_(__Line__, __Class__) . " convert " - . $item['name']; - if (isset($item['custom']['table'])) - { - // check if this is a local table - if (strpos( - (string) $item['custom']['table'], - '#__' . CFactory::_('Config')->component_code_name . '_' - ) !== false) - { - $keyTableNAme = str_replace( - '#__' . CFactory::_('Config')->component_code_name . '_', - '', (string) $item['custom']['table'] - ); - } - else - { - $keyTableNAme = $item['custom']['table']; - } - $fix .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(3) . "\$item->" . $item['name'] - . " = " . $Component - . "Helper::jsonToString(\$item->" - . $item['name'] . ", ', ', '" - . $keyTableNAme . "', '" - . $item['custom']['id'] . "', '" - . $item['custom']['text'] . "');"; - } - else - { - $fix .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(3) . "\$item->" . $item['name'] - . " = " . $Component - . "Helper::jsonToString(\$item->" - . $item['name'] . ", ', ', '" - . $item['name'] . "');"; - } - } - else - { - if (!$export) - { - // For those we have not cached yet. - $fix .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " convert " . $item['name']; - $fix .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(3) . "\$item->" . $item['name'] - . " = " . $Component - . "Helper::jsonToString(\$item->" - . $item['name'] . ");"; - } - } - } - } - } - } - /* // set translation (TODO) would be nice to cut down on double loops.. - if (!$export && CFactory::_('Compiler.Builder.Selection.Translation')->exists($nameListCode)) - { - foreach (CFactory::_('Compiler.Builder.Selection.Translation')->get($nameListCode) as $name => $values) - { - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " convert " . $name; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "\$item->" . $name . " = \$this->selectionTranslation(\$item->" . $name . ", '" . $name . "');"; - } - } */ - // load the relations after modeling - if (($field_relations = - CFactory::_('Compiler.Builder.Field.Relations')->get($nameListCode)) !== null) - { - foreach ($field_relations as $fields) - { - foreach ($fields as $area => $field) - { - if ($area == 3 && isset($field['code'])) - { - $fix .= $this->setModelFieldRelation( - $field, $nameListCode, $tab - ); - } - } - } - } - // close the foreach if needed - if (StringHelper::check($fix) || StringHelper::check($fix_access) || $export || $all) - { - // start the loop - $forEachStart = PHP_EOL . PHP_EOL . Indent::_(1) . $tab . Indent::_( - 1 - ) . "//" . Line::_(__Line__, __Class__) - . " Set values to display correctly."; - $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "if (" . $Component . "Helper::checkArray(\$items))"; - $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "{"; - // do not add to export since it is already done - if (!$export) - { - $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) - . "//" . Line::_(__Line__, __Class__) - . " Get the user object if not set."; - $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) - . "if (!isset(\$user) || !" - . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::checkObject(\$user))"; - $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) - . "{"; - $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "\$user = JFactory::getUser();"; - $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) - . "}"; - } - // the permissional acttion switch - $hasPermissional = false; - // add the permissional removal of values the user has not right to view or access - if ($this->strictFieldExportPermissions - && isset($this->permissionFields[$nameSingleCode]) - && ArrayHelper::check( - $this->permissionFields[$nameSingleCode] - )) - { - foreach ( - $this->permissionFields[$nameSingleCode] as $fieldName => - $permission_options - ) - { - if (!$hasPermissional) - { - foreach ( - $permission_options as $permission_option => - $fieldType - ) - { - if (!$hasPermissional) - { - switch ($permission_option) - { - case 'access': - case 'view': - $hasPermissional = true; - break; - } - } - } - } - } - // add the notes and get the global switch - if ($hasPermissional) - { - $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_( - 2 - ) . "//" . Line::_(__Line__, __Class__) - . " Get global permissional control activation. (default is inactive)"; - $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_( - 2 - ) - . "\$strict_permission_per_field = JComponentHelper::getParams('com_" - . $component - . "')->get('strict_permission_per_field', 0);" - . PHP_EOL; - } - } - $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) - . "foreach (\$items as \$nr => &\$item)"; - $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) . "{"; - // add the access options - $forEachStart .= $fix_access; - // add the permissional removal of values the user has not right to view or access - if ($hasPermissional) - { - $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "//" . Line::_(__Line__, __Class__) - . " use permissional control if globally set."; - $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "if (\$strict_permission_per_field)"; - $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "{"; - foreach ( - $this->permissionFields[$nameSingleCode] as $fieldName => - $permission_options - ) - { - foreach ( - $permission_options as $permission_option => $fieldType - ) - { - switch ($permission_option) - { - case 'access': - case 'view': - $forEachStart .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(4) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " set " . $permission_option - . " permissional control for " . $fieldName - . " value."; - $forEachStart .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(4) . "if (isset(\$item->" - . $fieldName . ") && (!\$user->authorise('" - . $nameSingleCode . "." - . $permission_option . "." . $fieldName - . "', 'com_" . $component . "." - . $nameSingleCode - . ".' . (int) \$item->id)"; - $forEachStart .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(5) . "|| !\$user->authorise('" - . $nameSingleCode . "." - . $permission_option . "." . $fieldName - . "', 'com_" . $component . "')))"; - $forEachStart .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(4) . "{"; - $forEachStart .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(5) . "//" . Line::_( - __LINE__,__CLASS__ - ) - . " We JUST empty the value (do you have a better idea)"; - $forEachStart .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(5) . "\$item->" . $fieldName - . " = '';"; - $forEachStart .= PHP_EOL . Indent::_(1) . $tab - . Indent::_(4) . "}"; - break; - } - } - } - $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "}"; - } - // remove these values if export - if ($export) - { - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) - . " unset the values we don't want exported."; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "unset(\$item->asset_id);"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "unset(\$item->checked_out);"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "unset(\$item->checked_out_time);"; - } - - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) . "}"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "}"; - if ($export) - { - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "//" - . Line::_(__Line__, __Class__) . " Add headers to items array."; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "\$headers = \$this->getExImPortHeaders();"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "if (" - . $Component . "Helper::checkObject(\$headers))"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "{"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) - . "array_unshift(\$items,\$headers);"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "}"; - } - } - - // add custom php to getitems method - $fix .= CFactory::_('Customcode.Dispenser')->get( - 'php_getitems', $nameSingleCode, PHP_EOL . PHP_EOL . $tab - ); - - // load the encryption object if needed - $script = ''; - foreach (CFactory::_('Config')->cryption_types as $cryptionType) - { - if (${$cryptionType . 'Crypt'}) - { - if ('expert' !== $cryptionType) - { - $script .= PHP_EOL . PHP_EOL . Indent::_(1) . $tab - . Indent::_(1) . "//" . Line::_(__Line__, __Class__) - . " Get the " . $cryptionType . " encryption key."; - $script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "\$" . $cryptionType . "key = " . $Component - . "Helper::getCryptKey('" . $cryptionType . "');"; - $script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "//" . Line::_(__Line__, __Class__) - . " Get the encryption object."; - $script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "\$" . $cryptionType . " = new Super___99175f6d_dba8_4086_8a65_5c4ec175e61d___Power(\$" - . $cryptionType . "key);"; - } - elseif (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> - exists("{$nameSingleCode}.get")) - { - foreach (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> - get("{$nameSingleCode}.get") as $block) - { - $script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . implode( - PHP_EOL . Indent::_(1) . $tab . Indent::_(1), $block - ); - } - } - } - } - - // add the encryption script - return $script . $forEachStart . $fix; - } - - /** - * Build headers for the various files - * - * @param string $context The name of the context - * @param string $codeName The view, views, or layout code name - * @param string $default The default to return if none is found - * - * @return string The php to place in the header - * - */ - public function setFileHeader($context, $codeName, $default = '') - { - // set the defaults - $headers = array(); - switch ($context) - { - case 'admin.component': - case 'site.component': - case 'site.view': - case 'site.views'; - case 'admin.layout'; - case 'override.layout'; - case 'custom.admin.layout'; - case 'site.layout'; - case 'dashboard.view'; - case 'dashboard.view.html'; - break; - case 'site.view.model': - case 'custom.admin.view.model': - $headers[] = 'use Joomla\CMS\MVC\Model\ItemModel;'; - $headers[] = 'use Joomla\Utilities\ArrayHelper;'; - break; - case 'admin.views.model': - case 'custom.admin.views.model': - case 'site.views.model': - case 'ajax.admin.model': - case 'ajax.site.model': - case 'dashboard.model': - $headers[] = 'use Joomla\CMS\MVC\Model\ListModel;'; - $headers[] = 'use Joomla\Utilities\ArrayHelper;'; - break; - case 'admin.helper': - case 'site.helper': - $headers[] = 'use Joomla\CMS\Filesystem\File;'; - $headers[] = 'use Joomla\CMS\Language\Language;'; - $headers[] = 'use Joomla\Registry\Registry;'; - $headers[] = 'use Joomla\String\StringHelper;'; - $headers[] = 'use Joomla\Utilities\ArrayHelper;'; - // $headers[] = 'use VDM\Joomla\Utilities;'; - // load the internal custom headers - $this->setHelperClassHeader($headers, $codeName); - break; - case 'admin.view.model': - case 'site.admin.view.model': - $headers[] = 'use Joomla\CMS\MVC\Model\AdminModel;'; - $headers[] = 'use Joomla\Registry\Registry;'; - $headers[] = 'use Joomla\String\StringHelper;'; - $headers[] = 'use Joomla\Utilities\ArrayHelper;'; - break; - case 'admin.view': - case 'custom.admin.view': - case 'custom.admin.views': - case 'site.admin.view': - $headers[] - = 'JHtml::addIncludePath(JPATH_COMPONENT.\'/helpers/html\');'; - $headers[] = 'JHtml::_(\'behavior.formvalidator\');'; - $headers[] = 'JHtml::_(\'formbehavior.chosen\', \'select\');'; - $headers[] = 'JHtml::_(\'behavior.keepalive\');'; - break; - case 'admin.views': - $headers[] = 'JHtml::_(\'behavior.multiselect\');'; - $headers[] = 'JHtml::_(\'dropdown.init\');'; - // add more headers if the new filter option is used - $this->setChosenMultiSelectionHeaders($headers, $codeName); - $headers[] = 'JHtml::_(\'formbehavior.chosen\', \'select\');'; - break; - case 'admin.view.html': - case 'admin.views.html': - case 'site.admin.view.html': - case 'site.view.html': - case 'site.views.html': - case 'custom.admin.view.html': - case 'custom.admin.views.html': - $headers[] = 'use Joomla\CMS\MVC\View\HtmlView;'; - // load the file class if uikit is being loaded - if ((2 == CFactory::_('Config')->uikit || 1 == CFactory::_('Config')->uikit) - && CFactory::_('Compiler.Builder.Uikit.Comp')->exists($codeName)) - { - $headers[] = 'use Joomla\CMS\Filesystem\File;'; - } - break; - case 'admin.view.controller': - case 'site.admin.view.controller': - case 'site.view.controller': - $headers[] = 'use Joomla\CMS\MVC\Controller\FormController;'; - $headers[] = 'use Joomla\Utilities\ArrayHelper;'; - break; - case 'custom.admin.view.controller': - case 'import.custom.controller': - case 'import.controller': - $headers[] = 'use Joomla\CMS\MVC\Controller\BaseController;'; - $headers[] = 'use Joomla\Utilities\ArrayHelper;'; - break; - case 'import.custom.model': - case 'import.model': - $headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;'; - $headers[] = 'use Joomla\CMS\Filesystem\File;'; - $headers[] = 'use Joomla\CMS\Filesystem\Folder;'; - $headers[] = 'use Joomla\Utilities\ArrayHelper;'; - $headers[] = 'use PhpOffice\PhpSpreadsheet\IOFactory;'; - break; - case 'admin.views.controller': - case 'custom.admin.views.controller': - case 'dashboard.controller': - $headers[] = 'use Joomla\CMS\MVC\Controller\AdminController;'; - $headers[] = 'use Joomla\Utilities\ArrayHelper;'; - break; - default: - $headers[] = 'use Joomla\Utilities\ArrayHelper;'; - break; - } - // for plugin event TODO change event api signatures - $component_context = CFactory::_('Config')->component_context; - // Trigger Event: jcb_ce_setClassHeader - CFactory::_('Event')->trigger( - 'jcb_ce_setClassHeader', - array(&$component_context, &$context, &$codeName, - &$headers) - ); - // check if headers were added - if (ArrayHelper::check($headers)) - { - // return the headers - return CFactory::_('Placeholder')->update_(implode(PHP_EOL, $headers)); - } - - return $default; - } - - /** - * set Helper Dynamic Headers - * - * @param array $headers The headers array - * @param string $target_client - * - * @return void - */ - protected function setHelperClassHeader(&$headers, $target_client) - { - // add only to admin client - if ('admin' === $target_client && CFactory::_('Config')->get('add_eximport', false)) - { - $headers[] = 'use PhpOffice\PhpSpreadsheet\IOFactory;'; - $headers[] = 'use PhpOffice\PhpSpreadsheet\Spreadsheet;'; - $headers[] = 'use PhpOffice\PhpSpreadsheet\Writer\Xlsx;'; - } - } - - /** - * Build chosen multi selection headers for the view - * - * @param array $headers The headers array - * @param string $nameListCode The list view name - * - * @return void - * - */ - protected function setChosenMultiSelectionHeaders(&$headers, $nameListCode) - { - // check that the filter type is the new filter option (2 = topbar) - if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2) - { - // add category switch - $add_category = false; - if (CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.extension") - && CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.filter", 0) >= 1) - { - // is found so add it - $add_category = true; - } - // add accessLevels switch - $add_access_levels = false; - if (CFactory::_('Compiler.Builder.Access.Switch.List')->exists($nameListCode)) - { - // is found so add it - $add_access_levels = true; - } - // check if this view have filters - if (CFactory::_('Compiler.Builder.Filter')->exists($nameListCode)) - { - foreach (CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as $filter) - { - // we need this only for filters that are multi - if (isset($filter['multi']) && $filter['multi'] == 2) - { - // if this is a category we should make sure it must be added - if (!$add_category && $filter['type'] === 'category') - { - continue; - } - elseif ($add_category && $filter['type'] === 'category') - { - // already added here so no need to add again - $add_category = false; - } - // check if this was an access field - elseif ($filter['type'] === 'accesslevel') - { - // already added here so no need to add again - $add_access_levels = false; - } - // add the header - $headers[] - = 'JHtml::_(\'formbehavior.chosen\', \'.multiple' - . $filter['class'] - . '\', null, array(\'placeholder_text_multiple\' => \'- \' . JText::_(\'' - . $filter['lang_select'] . '\') . \' -\'));'; - } - elseif ($add_category && $filter['type'] === 'category') - { - // add the header - $headers[] - = 'JHtml::_(\'formbehavior.chosen\', \'.multipleCategories' - . '\', null, array(\'placeholder_text_multiple\' => \'- \' . JText::_(\'' - . $filter['lang_select'] . '\') . \' -\'));'; - // already added here so no need to add again - $add_category = false; - } - } - } - // add category if not already added - if ($add_category) - { - // add the header - $headers[] - = 'JHtml::_(\'formbehavior.chosen\', \'.multipleCategories' - . '\', null, array(\'placeholder_text_multiple\' => \'- \' . JText::_(\'' - . CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.name", 'error') - . '\') . \' -\'));'; - } - // add accessLevels if not already added - if ($add_access_levels) - { - // set the language strings for selection - $filter_name_select = 'Select Access'; - $filter_name_select_lang = $this->langPrefix . '_FILTER_' - . StringHelper::safe( - $filter_name_select, 'U' - ); - // and to translation - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $filter_name_select_lang, $filter_name_select - ); - // add the header - $headers[] - = 'JHtml::_(\'formbehavior.chosen\', \'.multipleAccessLevels' - . '\', null, array(\'placeholder_text_multiple\' => \'- \' . JText::_(\'' - . $filter_name_select_lang . '\') . \' -\'));'; - } - } - } - - protected function setModelFieldRelation($item, $nameListCode, $tab) - { - $fix = ''; - // set fields - $field = array(); - // set list field name - $field['$item->{' . (int) $item['listfield'] . '}'] = '$item->' - . $item['code']; - // load joint field names - if (isset($item['joinfields']) - && ArrayHelper::check( - $item['joinfields'] - )) - { - foreach ($item['joinfields'] as $join) - { - $field['$item->{' . (int) $join . '}'] = '$item->' - . CFactory::_('Compiler.Builder.List.Join')->get($nameListCode . '.' . (int) $join . '.code', 'error'); - } - } - // set based on join_type - if ($item['join_type'] == 2) - { - // code - $code = (array) explode( - PHP_EOL, str_replace( - array_keys($field), array_values($field), (string) $item['set'] - ) - ); - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . implode( - PHP_EOL . Indent::_(1) . $tab . Indent::_(3), $code - ); - } - else - { - // concatenate - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) . " concatenate these fields"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "\$item->" - . $item['code'] . ' = ' . implode( - " . '" . str_replace("'", ''', (string) $item['set']) . "' . ", - $field - ) . ';'; - } - - return CFactory::_('Placeholder')->update_($fix); - } - - public function setSelectionTranslationFix($views, $Component, $tab = '') - { - // add the fix if this view has the need for it - $fix = ''; - if (CFactory::_('Compiler.Builder.Selection.Translation')->exists($views)) - { - $fix .= PHP_EOL . PHP_EOL . Indent::_(1) . $tab . Indent::_(1) - . "//" . Line::_(__Line__, __Class__) - . " set selection value to a translatable value"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "if (" - . $Component . "Helper::checkArray(\$items))"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "{"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) - . "foreach (\$items as \$nr => &\$item)"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) . "{"; - foreach (CFactory::_('Compiler.Builder.Selection.Translation')-> - get($views) as $name => $values) - { - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//" - . Line::_(__Line__, __Class__) . " convert " . $name; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) - . "\$item->" . $name - . " = \$this->selectionTranslation(\$item->" . $name . ", '" - . $name . "');"; - } - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) . "}"; - $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "}" - . PHP_EOL; - } - - return $fix; - } - - public function setSelectionTranslationFixFunc($views, $Component) - { - // add the fix if this view has the need for it - $fix = ''; - if (CFactory::_('Compiler.Builder.Selection.Translation')->exists($views)) - { - $fix .= PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $fix .= PHP_EOL . Indent::_(1) - . " * Method to convert selection values to translatable string."; - $fix .= PHP_EOL . Indent::_(1) . " *"; - $fix .= PHP_EOL . Indent::_(1) . " * @return translatable string"; - $fix .= PHP_EOL . Indent::_(1) . " */"; - $fix .= PHP_EOL . Indent::_(1) - . "public function selectionTranslation(\$value,\$name)"; - $fix .= PHP_EOL . Indent::_(1) . "{"; - foreach (CFactory::_('Compiler.Builder.Selection.Translation')-> - get($views) as $name => $values) - { - if (ArrayHelper::check($values)) - { - $fix .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Array of " . $name . " language strings"; - $fix .= PHP_EOL . Indent::_(2) . "if (\$name === '" - . $name . "')"; - $fix .= PHP_EOL . Indent::_(2) . "{"; - $fix .= PHP_EOL . Indent::_(3) . "\$" . $name - . "Array = array("; - $counter = 0; - foreach ($values as $value => $translang) - { - // only add quotes to strings - if (StringHelper::check($value)) - { - $key = "'" . $value . "'"; - } - else - { - if ($value == '') - { - $value = 0; - } - $key = $value; - } - if ($counter == 0) - { - $fix .= PHP_EOL . Indent::_(4) . $key . " => '" - . $translang . "'"; - } - else - { - $fix .= "," . PHP_EOL . Indent::_(4) . $key - . " => '" . $translang . "'"; - } - $counter++; - } - $fix .= PHP_EOL . Indent::_(3) . ");"; - $fix .= PHP_EOL . Indent::_(3) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Now check if value is found in this array"; - $fix .= PHP_EOL . Indent::_(3) . "if (isset(\$" . $name - . "Array[\$value]) && " . $Component - . "Helper::checkString(\$" . $name . "Array[\$value]))"; - $fix .= PHP_EOL . Indent::_(3) . "{"; - $fix .= PHP_EOL . Indent::_(4) . "return \$" . $name - . "Array[\$value];"; - $fix .= PHP_EOL . Indent::_(3) . "}"; - $fix .= PHP_EOL . Indent::_(2) . "}"; - } - } - $fix .= PHP_EOL . Indent::_(2) . "return \$value;"; - $fix .= PHP_EOL . Indent::_(1) . "}"; - } - - return $fix; - } - - public function setRouterCase($viewsCodeName) - { - if (strlen((string) $viewsCodeName) > 0) - { - $router = PHP_EOL . Indent::_(2) . "case '" . $viewsCodeName . "':"; - $router .= PHP_EOL . Indent::_(3) - . "\$id = explode(':', \$segments[\$count-1]);"; - $router .= PHP_EOL . Indent::_(3) . "\$vars['id'] = (int) \$id[0];"; - $router .= PHP_EOL . Indent::_(3) . "\$vars['view'] = '" - . $viewsCodeName - . "';"; - $router .= PHP_EOL . Indent::_(2) . "break;"; - - return $router; - } - - return ''; - } - - public function setComponentImageType($path) - { - $type = ComponentbuilderHelper::imageInfo($path); - if ($type) - { - $imagePath = CFactory::_('Utilities.Paths')->component_path . '/admin/assets/images'; - // move the image to its place - File::copy( - JPATH_SITE . '/' . $path, - $imagePath . '/vdm-component.' . $type - ); - // now set the type to global for re-use - $this->componentImageType = $type; - - // return image type - return $type; - } - $this->componentImageType = 'jpg'; - - return 'jpg'; - } - - public function setDashboardIconAccess() - { - return CFactory::_('Compiler.Builder.Permission.Dashboard')->build(); - } - - public function setDashboardIcons() - { - if (CFactory::_('Component')->isArray('admin_views')) - { - $icons = ''; - $counter = 0; - $catArray = array(); - foreach (CFactory::_('Component')->get('admin_views') as $view) - { - $name_single = StringHelper::safe( - $view['settings']->name_single - ); - $name_list = StringHelper::safe( - $view['settings']->name_list - ); - - $icons .= $this->addCustomDashboardIcons($view, $counter); - if (isset($view['dashboard_add']) - && $view['dashboard_add'] == 1) - { - $type = ComponentbuilderHelper::imageInfo( - $view['settings']->icon_add - ); - if ($type) - { - $type = $type . "."; - // icon builder loader - $this->iconBuilder[$type . $name_single . ".add"] - = $view['settings']->icon_add; - } - else - { - $type = 'png.'; - } - if ($counter == 0) - { - $icons .= "'" . $type . $name_single . ".add'"; - } - else - { - $icons .= ", '" . $type . $name_single . ".add'"; - } - // build lang - $langName = 'Add ' - . StringHelper::safe( - $view['settings']->name_single, 'W' - ) . '

    '; - $langKey = $this->langPrefix . '_DASHBOARD_' - . StringHelper::safe( - $view['settings']->name_single, 'U' - ) . '_ADD'; - // add to lang - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $langKey, $langName); - $counter++; - } - if (isset($view['dashboard_list']) - && $view['dashboard_list'] == 1) - { - $type = ComponentbuilderHelper::imageInfo( - $view['settings']->icon - ); - if ($type) - { - $type = $type . "."; - // icon builder loader - $this->iconBuilder[$type . $name_list] - = $view['settings']->icon; - } - else - { - $type = 'png.'; - } - if ($counter == 0) - { - $icons .= "'" . $type . $name_list . "'"; - } - else - { - $icons .= ", '" . $type . $name_list . "'"; - } - // build lang - $langName = StringHelper::safe( - $view['settings']->name_list, 'W' - ) . '

    '; - $langKey = $this->langPrefix . '_DASHBOARD_' - . StringHelper::safe( - $view['settings']->name_list, 'U' - ); - // add to lang - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $langKey, $langName); - $counter++; - } - // dashboard link to category on dashboard is build here - if (CFactory::_('Compiler.Builder.Category')->exists("{$name_list}.code")) - { - $catCode = CFactory::_('Compiler.Builder.Category')->get("{$name_list}.code"); - - // check if category has another name - $otherViews = CFactory::_('Compiler.Builder.Category.Other.Name')-> - get($name_list . '.views', $name_list); - $otherNames = CFactory::_('Compiler.Builder.Category.Other.Name')-> - get($name_list . '.name'); - if ($otherNames !== null) - { - // build lang - $langName = StringHelper::safe( - $otherNames, 'W' - ); - } - else - { - // build lang - $langName = 'Categories For
    ' - . StringHelper::safe( - $otherViews, 'W' - ); - } - // only load this category once - if (!in_array($otherViews, $catArray)) - { - // set the extension key string, new convention (more stable) - $_key_extension = str_replace( - '.', '_po0O0oq_', - (string) CFactory::_('Compiler.Builder.Category')->get("{$name_list}.extension", 'error') - ); - - // add to lang - $langKey = $this->langPrefix . '_DASHBOARD_' - . StringHelper::safe( - $otherViews, 'U' - ) . '_' . StringHelper::safe( - $catCode, 'U' - ); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $langKey, $langName); - // get image type - $type = ComponentbuilderHelper::imageInfo( - $view['settings']->icon_category - ); - if ($type) - { - $type = $type . "."; - // icon builder loader - $this->iconBuilder[$type . $otherViews . "." - . $catCode] - = $view['settings']->icon_category; - } - else - { - $type = 'png.'; - } - if ($counter == 0) - { - $icons .= "'" . $type . $otherViews . "." . $catCode - . '_qpo0O0oqp_' . $_key_extension . "'"; - } - else - { - $icons .= ", '" . $type . $otherViews . "." - . $catCode . '_qpo0O0oqp_' . $_key_extension - . "'"; - } - $counter++; - // make sure we add a category only once - $catArray[] = $otherViews; - } - } - } - if (isset($this->lastCustomDashboardIcon) - && ArrayHelper::check( - $this->lastCustomDashboardIcon - )) - { - foreach ($this->lastCustomDashboardIcon as $icon) - { - $icons .= $icon; - } - unset($this->lastCustomDashboardIcon); - } - if (isset($this->iconBuilder) - && ArrayHelper::check( - $this->iconBuilder - )) - { - $imagePath = CFactory::_('Utilities.Paths')->component_path - . '/admin/assets/images/icons'; - foreach ($this->iconBuilder as $icon => $path) - { - $array_buket = explode('.', (string) $icon); - if (count((array) $array_buket) == 3) - { - list($type, $name, $action) = $array_buket; - } - else - { - list($type, $name) = $array_buket; - $action = false; - } - // set the new image name - if ($action) - { - $imageName = $name . '_' . $action . '.' . $type; - } - else - { - $imageName = $name . '.' . $type; - } - // move the image to its place - File::copy( - JPATH_SITE . '/' . $path, $imagePath . '/' . $imageName - ); - } - } - - return $icons; - } - - return false; - } - - public function setDashboardModelMethods() - { - if (CFactory::_('Component')->isString('php_dashboard_methods')) - { - // get hte value - $php_dashboard_methods = CFactory::_('Component')->get('php_dashboard_methods'); - // get all the mothods that should load date to the view - $this->DashboardGetCustomData - = GetHelper::allBetween( - $php_dashboard_methods, - 'public function get', '()' - ); - - // return the methods - return PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( - $php_dashboard_methods - ); - } - - return ''; - } - - public function setDashboardGetCustomData() - { - if (isset($this->DashboardGetCustomData) - && ArrayHelper::check( - $this->DashboardGetCustomData - )) - { - // gets array reset - $gets = array(); - // set dashboard gets - foreach ($this->DashboardGetCustomData as $get) - { - $string = StringHelper::safe($get); - $gets[] = "\$this->" . $string . " = \$this->get('" . $get - . "');"; - } - - // return the gets - return PHP_EOL . Indent::_(2) . implode( - PHP_EOL . Indent::_(2), $gets - ); - } - - return ''; - } - - public function setDashboardDisplayData() - { - // display array reset - $display = array(); - $mainAccordianName = 'cPanel'; - $builder = array(); - $tab = Indent::_(1); - $loadTabs = false; - // check if we have custom tabs - if (CFactory::_('Component')->isArray('dashboard_tab')) - { - // build the tabs and accordians - foreach (CFactory::_('Component')->get('dashboard_tab') as $data) - { - $builder[$data['name']][$data['header']] - = CFactory::_('Placeholder')->update_( - $data['html'] - ); - } - // since we have custom tabs we must load the tab structure around the cpanel - $display[] = '
    '; - $display[] = Indent::_(1) . '
    '; - $display[] = Indent::_(1) - . " 'cpanel')); ?>"; - $display[] = PHP_EOL . Indent::_(2) - . ""; - $display[] = Indent::_(2) . '
    '; - // set the tab to insure correct spacing - $tab = Indent::_(3); - // change the name of the main tab - $mainAccordianName = 'Control Panel'; - $loadTabs = true; - } - else - { - $display[] = '
    '; - } - // set dashboard display - $display[] = $tab . '
    '; - $display[] = $tab . Indent::_(1) - . " 'main')); ?>"; - $display[] = $tab . Indent::_(2) - . ""; - $display[] = $tab . Indent::_(3) - . "loadTemplate('main');?>"; - $display[] = $tab . Indent::_(2) - . ""; - $display[] = $tab . Indent::_(1) - . ""; - $display[] = $tab . "
    "; - $display[] = $tab . '
    '; - $display[] = $tab . Indent::_(1) - . " 'vdm')); ?>"; - $display[] = $tab . Indent::_(2) - . "get('COMPANYNAME') - . "', 'vdm'); ?>"; - $display[] = $tab . Indent::_(3) - . "loadTemplate('vdm');?>"; - $display[] = $tab . Indent::_(2) - . ""; - $display[] = $tab . Indent::_(1) - . ""; - $display[] = $tab . "
    "; - - if ($loadTabs) - { - $display[] = Indent::_(2) . "
    "; - $display[] = Indent::_(2) - . ""; - // load the new tabs - foreach ($builder as $tabname => $accordians) - { - $alias = StringHelper::safe($tabname); - $display[] = PHP_EOL . Indent::_(2) - . ""; - $display[] = Indent::_(2) . '
    '; - $display[] = $tab . '
    '; - $display[] = $tab . Indent::_(1) - . " '" . $alias - . "_one')); ?>"; - $slidecounter = 1; - foreach ($accordians as $accordianname => $html) - { - $ac_alias = StringHelper::safe( - $accordianname - ); - $counterName = StringHelper::safe( - $slidecounter - ); - $tempName = $alias . '_' . $ac_alias; - $display[] = $tab . Indent::_(2) - . ""; - $display[] = $tab . Indent::_(3) - . "loadTemplate('" . $tempName - . "');?>"; - $display[] = $tab . Indent::_(2) - . ""; - $slidecounter++; - // build the template file - $target = array('custom_admin' => CFactory::_('Config')->component_code_name); - CFactory::_('Utilities.Structure')->build($target, 'template', $tempName); - // set the file data - $TARGET = StringHelper::safe( - CFactory::_('Config')->build_target, 'U' - ); - // SITE_TEMPLATE_BODY <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '_' . $tempName . '|CUSTOM_ADMIN_TEMPLATE_BODY', PHP_EOL . $html); - // SITE_TEMPLATE_CODE_BODY <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '_' . $tempName . '|CUSTOM_ADMIN_TEMPLATE_CODE_BODY', ''); - } - $display[] = $tab . Indent::_(1) - . ""; - $display[] = $tab . "
    "; - $display[] = Indent::_(2) . "
    "; - $display[] = Indent::_(2) - . ""; - } - - $display[] = PHP_EOL . Indent::_(1) - . ""; - $display[] = Indent::_(1) . "
    "; - } - $display[] = "
    "; - - // return the display - return PHP_EOL . implode(PHP_EOL, $display); - } - - public function addCustomDashboardIcons(&$view, &$counter) - { - $icon = ''; - if (CFactory::_('Component')->isArray('custom_admin_views')) - { - foreach (CFactory::_('Component')->get('custom_admin_views') as $nr => $menu) - { - if (!isset($this->customAdminAdded[$menu['settings']->code]) - && isset($menu['dashboard_list']) - && $menu['dashboard_list'] == 1 - && $menu['before'] == $view['adminview']) - { - $type = ComponentbuilderHelper::imageInfo( - $menu['settings']->icon - ); - if ($type) - { - $type = $type . "."; - // icon builder loader - $this->iconBuilder[$type . $menu['settings']->code] - = $menu['settings']->icon; - } - else - { - $type = 'png.'; - } - // build lang - $langName = $menu['settings']->name . '

    '; - $langKey = $this->langPrefix . '_DASHBOARD_' - . $menu['settings']->CODE; - // add to lang - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $langKey, $langName); - // set icon - if ($counter == 0) - { - $counter++; - $icon .= "'" . $type . $menu['settings']->code . "'"; - } - else - { - $counter++; - $icon .= ", '" . $type . $menu['settings']->code . "'"; - } - } - elseif (!isset($this->customAdminAdded[$menu['settings']->code]) - && isset($menu['dashboard_list']) - && $menu['dashboard_list'] == 1 - && empty($menu['before'])) - { - $type = ComponentbuilderHelper::imageInfo( - $menu['settings']->icon - ); - if ($type) - { - $type = $type . "."; - // icon builder loader - $this->iconBuilder[$type . $menu['settings']->code] - = $menu['settings']->icon; - } - else - { - $type = 'png.'; - } - // build lang - $langName = $menu['settings']->name . '

    '; - $langKey = $this->langPrefix . '_DASHBOARD_' - . $menu['settings']->CODE; - // add to lang - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $langKey, $langName); - // set icon - $this->lastCustomDashboardIcon[$nr] = ", '" . $type - . $menu['settings']->code . "'"; - } - } - } - // see if we should have custom menus - if (CFactory::_('Component')->isArray('custommenus')) - { - foreach (CFactory::_('Component')->get('custommenus') as $nr => $menu) - { - $nr = $nr + 100; - $nameList = StringHelper::safe( - $menu['name_code'] - ); - $nameUpper = StringHelper::safe( - $menu['name_code'], 'U' - ); - if (isset($menu['dashboard_list']) - && $menu['dashboard_list'] == 1 - && $view['adminview'] == $menu['before']) - { - $type = ComponentbuilderHelper::imageInfo( - 'images/' . $menu['icon'] - ); - if ($type) - { - // icon builder loader - $this->iconBuilder[$type . "." . $nameList] = 'images/' - . $menu['icon']; - } - else - { - $type = 'png'; - } - // build lang - $langName = $menu['name'] . '

    '; - $langKey = $this->langPrefix . '_DASHBOARD_' . $nameUpper; - // add to lang - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $langKey, $langName); - - // if this is a link build the icon values with pipe - if (isset($menu['link']) - && StringHelper::check($menu['link'])) - { - // set icon - if ($counter == 0) - { - $counter++; - $icon .= "'" . $type . "||" . $nameList . "||" - . $menu['link'] . "'"; - } - else - { - $counter++; - $icon .= ", '" . $type . "||" . $nameList . "||" - . $menu['link'] . "'"; - } - } - else - { - // set icon - if ($counter == 0) - { - $counter++; - $icon .= "'" . $type . "." . $nameList . "'"; - } - else - { - $counter++; - $icon .= ", '" . $type . "." . $nameList . "'"; - } - } - } - elseif (isset($menu['dashboard_list']) - && $menu['dashboard_list'] == 1 - && empty($menu['before'])) - { - $type = ComponentbuilderHelper::imageInfo( - 'images/' . $menu['icon'] - ); - if ($type) - { - // icon builder loader - $this->iconBuilder[$type . "." . $nameList] = 'images/' - . $menu['icon']; - } - else - { - $type = 'png'; - } - // build lang - $langName = $menu['name'] . '

    '; - $langKey = $this->langPrefix . '_DASHBOARD_' . $nameUpper; - // add to lang - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $langKey, $langName); - - // if this is a link build the icon values with pipe - if (isset($menu['link']) - && StringHelper::check($menu['link'])) - { - // set icon - $this->lastCustomDashboardIcon[$nr] = ", '" . $type - . "||" . $nameList . "||" . $menu['link'] . "'"; - } - else - { - // set icon - $this->lastCustomDashboardIcon[$nr] = ", '" . $type - . "." . $nameList . "'"; - } - } - } - } - - return $icon; - } - - public function setSubMenus() - { - if (CFactory::_('Component')->isArray('admin_views')) - { - $menus = ''; - // main lang prefix - $lang = $this->langPrefix . '_SUBMENU'; - // set the code name - $codeName = CFactory::_('Config')->component_code_name; - // set default dashboard - if (!CFactory::_('Registry')->get('build.dashboard')) - { - $menus .= "JHtmlSidebar::addEntry(JText:" . ":_('" . $lang - . "_DASHBOARD'), 'index.php?option=com_" . $codeName - . "&view=" . $codeName . "', \$submenu === '" . $codeName - . "');"; - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DASHBOARD', 'Dashboard' - ); - } - $catArray = array(); - // loop over all the admin views - foreach (CFactory::_('Component')->get('admin_views') as $view) - { - // set custom menu - $menus .= $this->addCustomSubMenu( - $view, $codeName, $lang - ); - $nameSingleCode = $view['settings']->name_single_code; - $nameListCode = $view['settings']->name_list_code; - $nameUpper = StringHelper::safe( - $view['settings']->name_list, 'U' - ); - // check if view is set to be in the sub-menu - if (isset($view['submenu']) && $view['submenu'] == 1) - { - // setup access defaults - $tab = ""; - // check if the item has permissions. - if (CFactory::_('Compiler.Creator.Permission')->globalExist($nameSingleCode, 'core.access')) - { - $menus .= PHP_EOL . Indent::_(2) - . "if (\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.access') - . "', 'com_" . $codeName - . "') && \$user->authorise('" . $nameSingleCode - . ".submenu', 'com_" . $codeName . "'))"; - $menus .= PHP_EOL . Indent::_(2) . "{"; - // add tab to lines to follow - $tab = Indent::_(1); - } - $menus .= PHP_EOL . Indent::_(2) . $tab - . "JHtmlSidebar::addEntry(JText:" . ":_('" . $lang . "_" - . $nameUpper . "'), 'index.php?option=com_" . $codeName - . "&view=" . $nameListCode . "', \$submenu === '" - . $nameListCode . "');"; - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . "_" . $nameUpper, - $view['settings']->name_list - ); - // check if category has another name - $otherViews = CFactory::_('Compiler.Builder.Category.Other.Name')-> - get($nameListCode . '.views', $nameListCode); - // first check if category sub-menu should be added - // then check if view has category, if true add sub-menu for it - if ($view['settings']->add_category_submenu == 1 - && CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.extension") - && !in_array($otherViews, $catArray)) - { - // get the extension array - $_extension_array = (array) explode( - '.', - (string) CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension") - ); - // set the menu selection - if (isset($_extension_array[1])) - { - $_menu = "categories." . trim($_extension_array[1]); - } - else - { - $_menu = "categories"; - } - // now load the menus - $menus .= PHP_EOL . Indent::_(2) . $tab - . "JHtmlSidebar::addEntry(JText:" . ":_('" - . CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.name", 'error') - . "'), 'index.php?option=com_categories&view=categories&extension=" - . CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension") - . "', \$submenu === '" . $_menu . "');"; - // make sure we add a category only once - $catArray[] = $otherViews; - } - // check if the item has permissions. - if (CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.access')) - { - $menus .= PHP_EOL . Indent::_(2) . "}"; - } - } - // set the Joomla custom fields options - if (isset($view['joomla_fields']) - && $view['joomla_fields'] == 1) - { - $menus .= PHP_EOL . Indent::_(2) - . "if (JComponentHelper::isEnabled('com_fields'))"; - $menus .= PHP_EOL . Indent::_(2) . "{"; - $menus .= PHP_EOL . Indent::_(3) - . "JHtmlSidebar::addEntry(JText:" . ":_('" . $lang . "_" - . $nameUpper - . "_FIELDS'), 'index.php?option=com_fields&context=com_" - . $codeName . "." . $nameSingleCode - . "', \$submenu === 'fields.fields');"; - $menus .= PHP_EOL . Indent::_(3) - . "JHtmlSidebar::addEntry(JText:" . ":_('" . $lang . "_" - . $nameUpper - . "_FIELDS_GROUPS'), 'index.php?option=com_fields&view=groups&context=com_" - . $codeName . "." . $nameSingleCode - . "', \$submenu === 'fields.groups');"; - $menus .= PHP_EOL . Indent::_(2) . "}"; - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . "_" . $nameUpper . "_FIELDS", - $view['settings']->name_list . ' Fields' - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, - $lang . "_" . $nameUpper . "_FIELDS_GROUPS", - $view['settings']->name_list . ' Field Groups' - ); - // build uninstall script for fields - $this->uninstallScriptBuilder[$nameSingleCode] = 'com_' - . $codeName . '.' . $nameSingleCode; - $this->uninstallScriptFields[$nameSingleCode] - = $nameSingleCode; - } - } - if (isset($this->lastCustomSubMenu) - && ArrayHelper::check($this->lastCustomSubMenu)) - { - foreach ($this->lastCustomSubMenu as $menu) - { - $menus .= $menu; - } - unset($this->lastCustomSubMenu); - } - - return $menus; - } - - return false; - } - - public function addCustomSubMenu(&$view, &$codeName, &$lang) - { - // see if we should have custom menus - $custom = ''; - if (CFactory::_('Component')->isArray('custom_admin_views')) - { - foreach (CFactory::_('Component')->get('custom_admin_views') as $nr => $menu) - { - if (!isset($this->customAdminAdded[$menu['settings']->code])) - { - if (($_custom = $this->setCustomAdminSubMenu( - $view, $codeName, $lang, $nr, $menu, 'customView' - )) !== false) - { - $custom .= $_custom; - } - } - } - } - if (CFactory::_('Component')->isArray('custommenus')) - { - foreach (CFactory::_('Component')->get('custommenus') as $nr => $menu) - { - if (($_custom = $this->setCustomAdminSubMenu( - $view, $codeName, $lang, $nr, $menu, 'customMenu' - )) !== false) - { - $custom .= $_custom; - } - } - } - - return $custom; - } - - public function setCustomAdminSubMenu(&$view, &$codeName, &$lang, &$nr, - &$menu, $type - ) - { - if ($type === 'customMenu') - { - $name = $menu['name']; - $nameSingle = StringHelper::safe($menu['name']); - $nameList = StringHelper::safe($menu['name']); - $nameUpper = StringHelper::safe( - $menu['name'], 'U' - ); - } - elseif ($type === 'customView') - { - $name = $menu['settings']->name; - $nameSingle = $menu['settings']->code; - $nameList = $menu['settings']->code; - $nameUpper = $menu['settings']->CODE; - } - if (isset($menu['submenu']) && $menu['submenu'] == 1 - && $view['adminview'] == $menu['before']) - { - // setup access defaults - $tab = ""; - $custom = ''; - // check if the item has permissions. - if (CFactory::_('Compiler.Creator.Permission')->globalExist($nameSingle, 'core.access')) - { - $custom .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Access control (" . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingle, 'core.access') . " && " - . $nameSingle . ".submenu)."; - $custom .= PHP_EOL . Indent::_(2) . "if (\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingle, 'core.access') . "', 'com_" . $codeName - . "') && \$user->authorise('" . $nameSingle - . ".submenu', 'com_" . $codeName . "'))"; - $custom .= PHP_EOL . Indent::_(2) . "{"; - // add tab to lines to follow - $tab = Indent::_(1); - } - else - { - $custom .= PHP_EOL . Indent::_(2) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " Access control (" . $nameSingle . ".submenu)."; - $custom .= PHP_EOL . Indent::_(2) . "if (\$user->authorise('" - . $nameSingle . ".submenu', 'com_" . $codeName . "'))"; - $custom .= PHP_EOL . Indent::_(2) . "{"; - // add tab to lines to follow - $tab = Indent::_(1); - } - if (isset($menu['link']) - && StringHelper::check( - $menu['link'] - )) - { - - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_' . $nameUpper, $name - ); - // add custom menu - $custom .= PHP_EOL . Indent::_(2) . $tab - . "JHtmlSidebar::addEntry(JText:" . ":_('" . $lang . "_" - . $nameUpper . "'), '" . $menu['link'] - . "', \$submenu === '" . $nameList . "');"; - } - else - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_' . $nameUpper, $name - ); - // add custom menu - $custom .= PHP_EOL . Indent::_(2) . $tab - . "JHtmlSidebar::addEntry(JText:" . ":_('" . $lang . "_" - . $nameUpper . "'), 'index.php?option=com_" . $codeName - . "&view=" . $nameList . "', \$submenu === '" . $nameList - . "');"; - } - // check if the item has permissions. - $custom .= PHP_EOL . Indent::_(2) . "}"; - - return $custom; - } - elseif (isset($menu['submenu']) && $menu['submenu'] == 1 - && empty($menu['before'])) - { - // setup access defaults - $tab = ""; - $nameSingle = StringHelper::safe($name); - $this->lastCustomSubMenu[$nr] = ''; - // check if the item has permissions. - if (CFactory::_('Compiler.Creator.Permission')->globalExist($nameSingle, 'core.access')) - { - $this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2) - . "if (\$user->authorise('" . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingle, 'core.access') - . "', 'com_" . $codeName . "') && \$user->authorise('" - . $nameSingle . ".submenu', 'com_" . $codeName . "'))"; - $this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2) . "{"; - // add tab to lines to follow - $tab = Indent::_(1); - } - else - { - $this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2) - . "if (\$user->authorise('" . $nameSingle - . ".submenu', 'com_" . $codeName . "'))"; - $this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2) . "{"; - // add tab to lines to follow - $tab = Indent::_(1); - } - if (isset($menu['link']) - && StringHelper::check( - $menu['link'] - )) - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_' . $nameUpper, $name - ); - // add custom menu - $this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2) . $tab - . "JHtmlSidebar::addEntry(JText:" . ":_('" . $lang . "_" - . $nameUpper . "'), '" . $menu['link'] - . "', \$submenu === '" . $nameList . "');"; - } - else - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_' . $nameUpper, $name - ); - // add custom menu - $this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2) . $tab - . "JHtmlSidebar::addEntry(JText:" . ":_('" . $lang . "_" - . $nameUpper . "'), 'index.php?option=com_" . $codeName - . "&view=" . $nameList . "', \$submenu === '" . $nameList - . "');"; - } - // check if the item has permissions. - $this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2) . "}"; - } - - return false; - } - - public function setMainMenus() - { - if (CFactory::_('Component')->isArray('admin_views')) - { - $menus = ''; - // main lang prefix - $lang = $this->langPrefix . '_MENU'; - // set the code name - $codeName = CFactory::_('Config')->component_code_name; - // default prefix is none - $prefix = ''; - // check if local is set - if (CFactory::_('Component')->isNumeric('add_menu_prefix')) - { - // set main menu prefix switch - $addPrefix = CFactory::_('Component')->get('add_menu_prefix'); - if ($addPrefix == 1 && CFactory::_('Component')->isString('menu_prefix')) - { - $prefix = trim((string) CFactory::_('Component')->get('menu_prefix')) . ' '; - } - } - else - { - // set main menu prefix switch - $addPrefix = $this->params->get('add_menu_prefix', 1); - if ($addPrefix == 1) - { - $prefix = trim((string) $this->params->get('menu_prefix', '»')) - . ' '; - } - } - // add the prefix - if ($addPrefix == 1) - { - CFactory::_('Language')->set( - 'adminsys', $lang, $prefix . CFactory::_('Component')->get('name') - ); - } - else - { - CFactory::_('Language')->set( - 'adminsys', $lang, CFactory::_('Component')->get('name') - ); - } - // loop over the admin views - foreach (CFactory::_('Component')->get('admin_views') as $view) - { - // set custom menu - $menus .= $this->addCustomMainMenu($view, $codeName, $lang); - if (isset($view['mainmenu']) && $view['mainmenu'] == 1) - { - $nameList = StringHelper::safe( - $view['settings']->name_list - ); - $nameUpper = StringHelper::safe( - $view['settings']->name_list, 'U' - ); - $menus .= PHP_EOL . Indent::_(3) . '' . $lang - . '_' . $nameUpper . ''; - CFactory::_('Language')->set( - 'adminsys', $lang . '_' . $nameUpper, - $view['settings']->name_list - ); - } - } - if (isset($this->lastCustomMainMenu) - && ArrayHelper::check( - $this->lastCustomMainMenu - )) - { - foreach ($this->lastCustomMainMenu as $menu) - { - $menus .= $menu; - } - unset($this->lastCustomMainMenu); - } - - return $menus; - } - - return false; - } - - public function addCustomMainMenu(&$view, &$codeName, &$lang) - { - $customMenu = ''; - // see if we should have custom admin views - if (CFactory::_('Component')->isArray('custom_admin_views')) - { - foreach (CFactory::_('Component')->get('custom_admin_views') as $nr => $menu) - { - if (!isset($this->customAdminAdded[$menu['settings']->code])) - { - if (isset($menu['mainmenu']) && $menu['mainmenu'] == 1 - && $view['adminview'] == $menu['before']) - { - CFactory::_('Language')->set( - 'adminsys', $lang . '_' . $menu['settings']->CODE, - $menu['settings']->name - ); - // add custom menu - $customMenu .= PHP_EOL . Indent::_(3) - . '' . $lang . '_' - . $menu['settings']->CODE . ''; - } - elseif (isset($menu['mainmenu']) && $menu['mainmenu'] == 1 - && empty($menu['before'])) - { - CFactory::_('Language')->set( - 'adminsys', $lang . '_' . $menu['settings']->CODE, - $menu['settings']->name - ); - // add custom menu - $this->lastCustomMainMenu[$nr] = PHP_EOL . Indent::_(3) - . '' . $lang . '_' - . $menu['settings']->CODE . ''; - } - } - } - } - // see if we should have custom menus - if (CFactory::_('Component')->isArray('custommenus')) - { - foreach (CFactory::_('Component')->get('custommenus') as $nr => $menu) - { - $nr = $nr + 100; - if (isset($menu['mainmenu']) && $menu['mainmenu'] == 1 - && $view['adminview'] == $menu['before']) - { - if (isset($menu['link']) - && StringHelper::check($menu['link'])) - { - $nameList = StringHelper::safe( - $menu['name'] - ); - $nameUpper = StringHelper::safe( - $menu['name'], 'U' - ); - CFactory::_('Language')->set( - 'adminsys', $lang . '_' . $nameUpper, $menu['name'] - ); - // sanitize url - if (strpos((string) $menu['link'], 'http') === false) - { - $menu['link'] = str_replace( - '/administrator/index.php?', '', (string) $menu['link'] - ); - $menu['link'] = str_replace( - 'administrator/index.php?', '', $menu['link'] - ); - // check if the index is still there - if (strpos($menu['link'], 'index.php?') !== false) - { - $menu['link'] = str_replace( - '/index.php?', '', $menu['link'] - ); - $menu['link'] = str_replace( - 'index.php?', '', $menu['link'] - ); - } - } - // urlencode - $menu['link'] = htmlspecialchars( - (string) $menu['link'], ENT_XML1, 'UTF-8' - ); - // add custom menu - $customMenu .= PHP_EOL . Indent::_(3) . '' . $lang . '_' . $nameUpper - . ''; - } - else - { - $nameList = StringHelper::safe( - $menu['name_code'] - ); - $nameUpper = StringHelper::safe( - $menu['name_code'], 'U' - ); - CFactory::_('Language')->set( - 'adminsys', $lang . '_' . $nameUpper, $menu['name'] - ); - // add custom menu - $customMenu .= PHP_EOL . Indent::_(3) - . '' . $lang . '_' . $nameUpper - . ''; - } - } - elseif (isset($menu['mainmenu']) && $menu['mainmenu'] == 1 - && empty($menu['before'])) - { - if (isset($menu['link']) - && StringHelper::check($menu['link'])) - { - $nameList = StringHelper::safe( - $menu['name'] - ); - $nameUpper = StringHelper::safe( - $menu['name'], 'U' - ); - CFactory::_('Language')->set( - 'adminsys', $lang . '_' . $nameUpper, $menu['name'] - ); - // sanitize url - if (strpos((string) $menu['link'], 'http') === false) - { - $menu['link'] = str_replace( - '/administrator/index.php?', '', (string) $menu['link'] - ); - $menu['link'] = str_replace( - 'administrator/index.php?', '', $menu['link'] - ); - // check if the index is still there - if (strpos($menu['link'], 'index.php?') !== false) - { - $menu['link'] = str_replace( - '/index.php?', '', $menu['link'] - ); - $menu['link'] = str_replace( - 'index.php?', '', $menu['link'] - ); - } - } - // urlencode - $menu['link'] = htmlspecialchars( - (string) $menu['link'], ENT_XML1, 'UTF-8' - ); - // add custom menu - $this->lastCustomMainMenu[$nr] = PHP_EOL . Indent::_(3) - . '' . $lang - . '_' . $nameUpper . ''; - } - else - { - $nameList = StringHelper::safe( - $menu['name_code'] - ); - $nameUpper = StringHelper::safe( - $menu['name_code'], 'U' - ); - CFactory::_('Language')->set( - 'adminsys', $lang . '_' . $nameUpper, $menu['name'] - ); - // add custom menu - $this->lastCustomMainMenu[$nr] = PHP_EOL . Indent::_(3) - . '' . $lang . '_' . $nameUpper - . ''; - } - } - } - } - - return $customMenu; - } - - public function setConfigFieldsets($timer = 0) - { - // main lang prefix - $lang = $this->langPrefix . '_CONFIG'; - // for plugin event TODO change event api signatures - $component_context = CFactory::_('Config')->component_context; - if (1 == $timer) // this is before the admin views are build - { - // start loading Global params - $autorName = StringHelper::html( - CFactory::_('Component')->get('author') - ); - $autorEmail = StringHelper::html( - CFactory::_('Component')->get('email') - ); - $this->extensionsParams[] = '"autorName":"' . $autorName - . '","autorEmail":"' . $autorEmail . '"'; - // set the custom fields - if (CFactory::_('Component')->isArray('config')) - { - // set component code name - $component = CFactory::_('Config')->component_code_name; - $nameSingleCode = 'config'; - $nameListCode = 'configs'; - // set place holders - $placeholders = array(); - $placeholders[Placefix::_h('component')] - = CFactory::_('Config')->component_code_name; - $placeholders[Placefix::_h('Component')] - = StringHelper::safe( - CFactory::_('Component')->get('name_code'), 'F' - ); - $placeholders[Placefix::_h('COMPONENT')] - = StringHelper::safe( - CFactory::_('Component')->get('name_code'), 'U' - ); - $placeholders[Placefix::_h('view')] - = $nameSingleCode; - $placeholders[Placefix::_h('views')] - = $nameListCode; - $placeholders[Placefix::_('component')] - = CFactory::_('Config')->component_code_name; - $placeholders[Placefix::_('Component')] - = $placeholders[Placefix::_h('Component')]; - $placeholders[Placefix::_('COMPONENT')] - = $placeholders[Placefix::_h('COMPONENT')]; - $placeholders[Placefix::_('view')] - = $nameSingleCode; - $placeholders[Placefix::_('views')] - = $nameListCode; - // load the global placeholders - foreach (CFactory::_('Component.Placeholder')->get() as $globalPlaceholder => $gloabalValue) - { - $placeholders[$globalPlaceholder] = $gloabalValue; - } - $view = []; - $viewType = 0; - // set the custom table key - $dbkey = 'g'; - // TODO: change plubin signature - $config_ = CFactory::_('Component')->get('config'); - // Trigger Event: jcb_ce_onBeforeSetConfigFieldsets - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeSetConfigFieldsets', - array(&$component_context, &$timer, - &$this->configFieldSets, - &$this->configFieldSetsCustomField, - &$config_, - &$this->extensionsParams, &$placeholders) - ); - // update global values - CFactory::_('Component')->set('config', $config_); - // build the config fields - foreach ($config_ as $field) - { - // get the xml string - $xmlField = CFactory::_('Compiler.Creator.Field.As.String')->get( - $field, $view, $viewType, $lang, $nameSingleCode, - $nameListCode, $placeholders, $dbkey, false - ); - - // make sure the xml is set and a string - if (isset($xmlField) - && StringHelper::check( - $xmlField - )) - { - $this->configFieldSetsCustomField[$field['tabname']][] - = $xmlField; - // set global params to db on install - $fieldName = StringHelper::safe( - CFactory::_('Placeholder')->update( - GetHelper::between( - $xmlField, 'name="', '"' - ), $placeholders - ) - ); - $fieldDefault = CFactory::_('Placeholder')->update( - GetHelper::between( - $xmlField, 'default="', '"' - ), $placeholders - ); - if (isset($field['custom_value']) - && StringHelper::check( - $field['custom_value'] - )) - { - // add array if found - if ((strpos((string) $field['custom_value'], '["') !== false) - && (strpos((string) $field['custom_value'], '"]') - !== false)) - { - // load the Global checkin defautls - $this->extensionsParams[] = '"' . $fieldName - . '":' . $field['custom_value']; - } - else - { - // load the Global checkin defautls - $this->extensionsParams[] = '"' . $fieldName - . '":"' . $field['custom_value'] . '"'; - } - } - elseif (StringHelper::check( - $fieldDefault - )) - { - // load the Global checkin defautls - $this->extensionsParams[] = '"' . $fieldName . '":"' - . $fieldDefault . '"'; - } - } - } - } - // first run we must set the globals - $this->setGlobalConfigFieldsets($lang, $autorName, $autorEmail); - $this->setSiteControlConfigFieldsets($lang); - } - elseif (2 == $timer) // this is after the admin views are build - { - // for plugin event TODO change event api signatures - $placeholders = CFactory::_('Placeholder')->active; - $config_ = CFactory::_('Component')->get('config'); - // Trigger Event: jcb_ce_onBeforeSetConfigFieldsets - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeSetConfigFieldsets', - array(&$component_context, &$timer, - &$this->configFieldSets, - &$this->configFieldSetsCustomField, - &$config_, &$this->extensionsParams, - &$placeholders) - ); - // update global values - CFactory::_('Component')->set('config', $config_); - // these field sets can only be added after admin view is build - $this->setGroupControlConfigFieldsets($lang); - // these can be added anytime really (but looks best after groups - $this->setUikitConfigFieldsets($lang); - $this->setGooglechartConfigFieldsets($lang); - $this->setEmailHelperConfigFieldsets($lang); - $this->setEncryptionConfigFieldsets($lang); - // these are the coustom settings - $this->setCustomControlConfigFieldsets($lang); - } - // for plugin event TODO change event api signatures - $placeholders = CFactory::_('Placeholder')->active; - // Trigger Event: jcb_ce_onAfterSetConfigFieldsets - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterSetConfigFieldsets', - array(&$component_context, &$timer, &$this->configFieldSets, - &$this->configFieldSetsCustomField, &$this->extensionsParams, - &$this->frontEndParams, &$placeholders) - ); - } - - public function setSiteControlConfigFieldsets($lang) - { - $front_end = array(); - // do quick build of front-end views - if (CFactory::_('Component')->isArray('site_views')) - { - // load the names only to link the page params - foreach (CFactory::_('Component')->get('site_views') as $siteView) - { - // now load the view name to the front-end array - $front_end[] = $siteView['settings']->name; - } - } - - // add frontend view stuff including menus - if (isset($this->configFieldSetsCustomField) - && ArrayHelper::check( - $this->configFieldSetsCustomField - )) - { - foreach ($this->configFieldSetsCustomField as $tab => &$tabFields) - { - $tabCode = StringHelper::safe($tab) - . '_custom_config'; - $tabUpper = StringHelper::safe($tab, 'U'); - $tabLower = StringHelper::safe($tab); - // load the request id setters for menu views - $viewRequest = 'name="' . $tabLower . '_request_id'; - foreach ($tabFields as $et => $id_field) - { - if (strpos((string) $id_field, $viewRequest) !== false) - { - $this->setRequestValues( - $tabLower, $id_field, $viewRequest, 'id', - 'hasIdRequest' - ); - unset($tabFields[$et]); - } - elseif (strpos((string) $id_field, '_request_id') !== false) - { - // not loaded to a tab "view" name - $_viewRequest = GetHelper::between( - $id_field, 'name="', '_request_id' - ); - $searchIdKe = 'name="' . $_viewRequest - . '_request_id'; - $this->setRequestValues( - $_viewRequest, $id_field, $searchIdKe, 'id', - 'hasIdRequest' - ); - unset($tabFields[$et]); - } - } - // load the request catid setters for menu views - $viewRequestC = 'name="' . $tabLower . '_request_catid'; - foreach ($tabFields as $ci => $catid_field) - { - if (strpos((string) $catid_field, $viewRequestC) !== false) - { - - $this->setRequestValues( - $tabLower, $catid_field, $viewRequestC, 'catid', - 'hasCatIdRequest' - ); - unset($tabFields[$ci]); - } - elseif (strpos((string) $catid_field, '_request_catid') !== false) - { - // not loaded to a tab "view" name - $_viewRequestC = GetHelper::between( - $catid_field, 'name="', '_request_catid' - ); - $searchCatidKe = 'name="' . $_viewRequestC - . '_request_catid'; - $this->setRequestValues( - $_viewRequestC, $catid_field, $searchCatidKe, - 'catid', 'hasCatIdRequest' - ); - unset($tabFields[$ci]); - } - } - // load the global menu setters for single fields - $menuSetter = $tabLower . '_menu'; - $pageSettings = array(); - foreach ($tabFields as $ct => $field) - { - if (strpos((string) $field, $menuSetter) !== false) - { - // set the values needed to insure route is done correclty - $this->hasMenuGlobal[$tabLower] = $menuSetter; - } - elseif (strpos((string) $field, '_menu"') !== false) - { - // not loaded to a tab "view" name - $_tabLower = GetHelper::between( - $field, 'name="', '_menu"' - ); - // set the values needed to insure route is done correclty - $this->hasMenuGlobal[$_tabLower] = $_tabLower . '_menu'; - } - else - { - $pageSettings[$ct] = $field; - } - } - // insure we load the needed params - if (in_array($tab, $front_end)) - { - $this->frontEndParams[$tab] = $pageSettings; - } - } - } - } - - protected function setRequestValues($view, $field, $search, $target, $store) - { - $key = GetHelper::between($field, $search, '"'); - if (!StringHelper::check($key)) - { - // is not having special var - $key = $target; - // update field - $field = str_replace($search . '"', 'name="' . $key . '"', (string) $field); - } - else - { - // update field - $field = str_replace( - $search . $key . '"', 'name="' . $key . '"', (string) $field - ); - } - if (!isset($this->{$store}[$view])) - { - $this->{$store}[$view] = array(); - } - // set the values needed for view requests to be made - $this->{$store}[$view][$key] = $field; - } - - public function setCustomControlConfigFieldsets($lang) - { - // add custom new global fields set - if (isset($this->configFieldSetsCustomField) - && ArrayHelper::check( - $this->configFieldSetsCustomField - )) - { - foreach ($this->configFieldSetsCustomField as $tab => $tabFields) - { - $tabCode = StringHelper::safe($tab) - . '_custom_config'; - $tabUpper = StringHelper::safe($tab, 'U'); - $tabLower = StringHelper::safe($tab); - // remove display targeted fields - $bucket = array(); - foreach ($tabFields as $tabField) - { - $display = GetHelper::between( - $tabField, 'display="', '"' - ); - if (!StringHelper::check($display) - || $display === 'config') - { - // remove this display since it is not used in Joomla - $bucket[] = str_replace( - 'display="config"', '', (string) $tabField - ); - } - } - // only add the tab if it has values - if (ArrayHelper::check($bucket)) - { - // setup lang - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_' . $tabUpper, $tab - ); - // start field set - $this->configFieldSets[] = Indent::_(1) . "configFieldSets[] = Indent::_(2) . 'name="' - . $tabCode . '"'; - $this->configFieldSets[] = Indent::_(2) . 'label="' . $lang - . '_' . $tabUpper . '">'; - // set the fields - $this->configFieldSets[] = implode("", $bucket); - // close field set - $this->configFieldSets[] = Indent::_(1) . ""; - } - // remove after loading - unset($this->configFieldSetsCustomField[$tab]); - } - } - } - - public function setGroupControlConfigFieldsets($lang) - { - // start loading Group control params if needed - if (CFactory::_('Compiler.Builder.Field.Group.Control')->isActive()) - { - // start building field set for config - $this->configFieldSets[] = Indent::_(1) . "configFieldSets[] = Indent::_(2) . 'name="group_config"'; - $this->configFieldSets[] = Indent::_(2) . 'label="' . $lang - . '_GROUPS_LABEL"'; - $this->configFieldSets[] = Indent::_(2) . 'description="' . $lang - . '_GROUPS_DESC">'; - // setup lang - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_GROUPS_LABEL', "Target Groups" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_GROUPS_DESC', - "The Parameters for the targeted groups are set here." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_TARGET_GROUP_DESC', - "Set the group/s being targeted by this user type." - ); - - foreach (CFactory::_('Compiler.Builder.Field.Group.Control')->allActive() as $selector => $label) - { - $this->configFieldSets[] = Indent::_(2) . 'configFieldSets[] = Indent::_(3) . 'type="usergroup"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $label - . '"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' - . $lang . '_TARGET_GROUP_DESC"'; - $this->configFieldSets[] = Indent::_(3) . 'multiple="true"'; - $this->configFieldSets[] = Indent::_(2) . "/>"; - // set params defaults - $this->extensionsParams[] = '"' . $selector . '":["2"]'; - } - // add custom Target Groups fields - if (isset($this->configFieldSetsCustomField['Target Groups']) - && ArrayHelper::check( - $this->configFieldSetsCustomField['Target Groups'] - )) - { - $this->configFieldSets[] = implode( - "", $this->configFieldSetsCustomField['Target Groups'] - ); - unset($this->configFieldSetsCustomField['Target Groups']); - } - // close that fieldse - $this->configFieldSets[] = Indent::_(1) . ""; - } - } - - /** - * @param $lang - * @param $autorName - * @param $autorEmail - */ - public function setGlobalConfigFieldsets($lang, $autorName, $autorEmail) - { - // set component name - $component = CFactory::_('Config')->component_code_name; - - // start building field set for config - $this->configFieldSets[] = 'configFieldSets[] = Indent::_(2) - . 'addrulepath="/administrator/components/com_' . $component - . '/models/rules"'; - $this->configFieldSets[] = Indent::_(2) - . 'addfieldpath="/administrator/components/com_' . $component - . '/models/fields"'; - $this->configFieldSets[] = Indent::_(2) . 'name="global_config"'; - $this->configFieldSets[] = Indent::_(2) . 'label="' . $lang - . '_GLOBAL_LABEL"'; - $this->configFieldSets[] = Indent::_(2) . 'description="' . $lang - . '_GLOBAL_DESC">'; - // setup lang - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_GLOBAL_LABEL', "Global"); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_GLOBAL_DESC', "The Global Parameters" - ); - // add auto checkin if required - if (CFactory::_('Config')->get('add_checkin', false)) - { - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . 'name="check_in"'; - $this->configFieldSets[] = Indent::_(3) . 'type="list"'; - $this->configFieldSets[] = Indent::_(3) . 'default="0"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $lang - . '_CHECK_TIMER_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' . $lang - . '_CHECK_TIMER_DESC">'; - $this->configFieldSets[] = Indent::_(3) . 'configFieldSets[] = Indent::_(4) . 'value="-5 hours">' - . $lang . '_CHECK_TIMER_OPTION_ONE'; - $this->configFieldSets[] = Indent::_(3) . 'configFieldSets[] = Indent::_(4) . 'value="-12 hours">' - . $lang . '_CHECK_TIMER_OPTION_TWO'; - $this->configFieldSets[] = Indent::_(3) . 'configFieldSets[] = Indent::_(4) . 'value="-1 day">' . $lang - . '_CHECK_TIMER_OPTION_THREE'; - $this->configFieldSets[] = Indent::_(3) . 'configFieldSets[] = Indent::_(4) . 'value="-2 day">' . $lang - . '_CHECK_TIMER_OPTION_FOUR'; - $this->configFieldSets[] = Indent::_(3) . 'configFieldSets[] = Indent::_(4) . 'value="-1 week">' . $lang - . '_CHECK_TIMER_OPTION_FIVE'; - $this->configFieldSets[] = Indent::_(3) . 'configFieldSets[] = Indent::_(4) . 'value="0">' . $lang - . '_CHECK_TIMER_OPTION_SIX'; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) - . ''; - // setup lang - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHECK_TIMER_LABEL', "Check in timer" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHECK_TIMER_DESC', - "Set the intervals for the auto checkin fuction of tables that checks out the items to an user." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHECK_TIMER_OPTION_ONE', - "Every five hours" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHECK_TIMER_OPTION_TWO', - "Every twelve hours" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHECK_TIMER_OPTION_THREE', "Once a day" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHECK_TIMER_OPTION_FOUR', - "Every second day" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHECK_TIMER_OPTION_FIVE', "Once a week" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHECK_TIMER_OPTION_SIX', "Never" - ); - // load the Global checkin defautls - $this->extensionsParams[] = '"check_in":"-1 day"'; - } - // set history control - if (CFactory::_('Config')->get('set_tag_history', false)) - { - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . 'name="save_history"'; - $this->configFieldSets[] = Indent::_(3) . 'type="radio"'; - $this->configFieldSets[] = Indent::_(3) - . 'class="btn-group btn-group-yesno"'; - $this->configFieldSets[] = Indent::_(3) . 'default="1"'; - $this->configFieldSets[] = Indent::_(3) - . 'label="JGLOBAL_SAVE_HISTORY_OPTIONS_LABEL"'; - $this->configFieldSets[] = Indent::_(3) - . 'description="JGLOBAL_SAVE_HISTORY_OPTIONS_DESC"'; - $this->configFieldSets[] = Indent::_(3) . ">"; - $this->configFieldSets[] = Indent::_(3) - . ''; - $this->configFieldSets[] = Indent::_(3) - . ''; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . 'name="history_limit"'; - $this->configFieldSets[] = Indent::_(3) . 'type="text"'; - $this->configFieldSets[] = Indent::_(3) . 'filter="integer"'; - $this->configFieldSets[] = Indent::_(3) - . 'label="JGLOBAL_HISTORY_LIMIT_OPTIONS_LABEL"'; - $this->configFieldSets[] = Indent::_(3) - . 'description="JGLOBAL_HISTORY_LIMIT_OPTIONS_DESC"'; - $this->configFieldSets[] = Indent::_(3) . 'default="10"'; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) - . ''; - // load the Global checkin defautls - $this->extensionsParams[] - = '"save_history":"1","history_limit":"10"'; - } - // add custom global fields - if (isset($this->configFieldSetsCustomField['Global']) - && ArrayHelper::check( - $this->configFieldSetsCustomField['Global'] - )) - { - $this->configFieldSets[] = implode( - "", $this->configFieldSetsCustomField['Global'] - ); - unset($this->configFieldSetsCustomField['Global']); - } - // set the author details - $this->configFieldSets[] = Indent::_(2) . 'configFieldSets[] = Indent::_(3) . 'type="spacer"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $lang - . '_AUTHOR"'; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . 'configFieldSets[] = Indent::_(3) . 'type="text"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $lang - . '_AUTHOR_NAME_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' . $lang - . '_AUTHOR_NAME_DESC"'; - $this->configFieldSets[] = Indent::_(3) . 'size="60"'; - $this->configFieldSets[] = Indent::_(3) . 'default="' . $autorName - . '"'; - $this->configFieldSets[] = Indent::_(3) . 'readonly="true"'; - $this->configFieldSets[] = Indent::_(3) . 'class="readonly"'; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . 'configFieldSets[] = Indent::_(3) . 'type="email"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $lang - . '_AUTHOR_EMAIL_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' . $lang - . '_AUTHOR_EMAIL_DESC"'; - $this->configFieldSets[] = Indent::_(3) . 'size="60"'; - $this->configFieldSets[] = Indent::_(3) . 'default="' . $autorEmail - . '"'; - $this->configFieldSets[] = Indent::_(3) . 'readonly="true"'; - $this->configFieldSets[] = Indent::_(3) . 'class="readonly"'; - $this->configFieldSets[] = Indent::_(2) . "/>"; - // setup lang - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_AUTHOR', "Author Info"); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_AUTHOR_NAME_LABEL', "Author Name" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_AUTHOR_NAME_DESC', - "The name of the author of this component." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_AUTHOR_EMAIL_LABEL', "Author Email" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_AUTHOR_EMAIL_DESC', - "The email address of the author of this component." - ); - // set if contributors were added - $langCont = $lang . '_CONTRIBUTOR'; - if (CFactory::_('Config')->get('add_contributors', false) - && CFactory::_('Component')->isArray('contributors')) - { - foreach ( - CFactory::_('Component')->get('contributors') as $counter => $contributor - ) - { - // make sure we dont use 0 - $counter++; - // get the word for this number - $COUNTER = StringHelper::safe($counter, 'U'); - // set the dynamic values - $cbTitle = htmlspecialchars( - (string) $contributor['title'], ENT_XML1, 'UTF-8' - ); - $cbName = htmlspecialchars( - (string) $contributor['name'], ENT_XML1, 'UTF-8' - ); - $cbEmail = htmlspecialchars( - (string) $contributor['email'], ENT_XML1, 'UTF-8' - ); - $cbWebsite = htmlspecialchars( - (string) $contributor['website'], ENT_XML1, 'UTF-8' - ); // StringHelper::html($contributor['website']); - // load to the $fieldsets - $this->configFieldSets[] = Indent::_(2) - . ''; - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="spacer"'; - $this->configFieldSets[] = Indent::_(3) . 'class="text"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $langCont - . '_' . $COUNTER . '"'; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="text"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $langCont - . '_TITLE_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' - . $langCont . '_TITLE_DESC"'; - $this->configFieldSets[] = Indent::_(3) . 'size="60"'; - $this->configFieldSets[] = Indent::_(3) . 'default="' . $cbTitle - . '"'; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="text"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $langCont - . '_NAME_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' - . $langCont . '_NAME_DESC"'; - $this->configFieldSets[] = Indent::_(3) . 'size="60"'; - $this->configFieldSets[] = Indent::_(3) . 'default="' . $cbName - . '"'; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="email"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $langCont - . '_EMAIL_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' - . $langCont . '_EMAIL_DESC"'; - $this->configFieldSets[] = Indent::_(3) . 'size="60"'; - $this->configFieldSets[] = Indent::_(3) . 'default="' . $cbEmail - . '"'; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="url"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $langCont - . '_LINK_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' - . $langCont . '_LINK_DESC"'; - $this->configFieldSets[] = Indent::_(3) . 'size="60"'; - $this->configFieldSets[] = Indent::_(3) . 'default="' - . $cbWebsite . '"'; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="list"'; - $this->configFieldSets[] = Indent::_(3) . 'default="' - . (int) $contributor['use'] . '"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $langCont - . '_USE_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' - . $langCont . '_USE_DESC">'; - $this->configFieldSets[] = Indent::_(3) . ''; - $this->configFieldSets[] = Indent::_(3) . ''; - $this->configFieldSets[] = Indent::_(3) . ''; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="list"'; - $this->configFieldSets[] = Indent::_(3) . 'default="' - . (int) $contributor['show'] . '"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $langCont - . '_SHOW_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' - . $langCont . '_SHOW_DESC">'; - $this->configFieldSets[] = Indent::_(3) . ''; - $this->configFieldSets[] = Indent::_(3) . ''; - $this->configFieldSets[] = Indent::_(3) . ''; - $this->configFieldSets[] = Indent::_(3) . ''; - $this->configFieldSets[] = Indent::_(2) . ""; - // add the contributor - $this->theContributors .= PHP_EOL . Indent::_(1) . "@" - . strtolower((string) $contributor['title']) . Indent::_(2) - . $contributor['name'] . ' <' . $contributor['website'] - . '>'; - // setup lang - $Counter = StringHelper::safe($counter, 'Ww'); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $langCont . '_' . $COUNTER, - "Contributor " . $Counter - ); - // load the Global checkin defautls - $this->extensionsParams[] = '"titleContributor' . $counter - . '":"' . $cbTitle . '"'; - $this->extensionsParams[] = '"nameContributor' . $counter - . '":"' . $cbName . '"'; - $this->extensionsParams[] = '"emailContributor' . $counter - . '":"' . $cbEmail . '"'; - $this->extensionsParams[] = '"linkContributor' . $counter - . '":"' . $cbWebsite . '"'; - $this->extensionsParams[] = '"useContributor' . $counter . '":"' - . (int) $contributor['use'] . '"'; - $this->extensionsParams[] = '"showContributor' . $counter - . '":"' . (int) $contributor['show'] . '"'; - } - } - // add more contributors if required - if (1 == CFactory::_('Component')->get('emptycontributors', 0)) - { - if (isset($counter)) - { - $min = $counter + 1; - unset($counter); - } - else - { - $min = 1; - } - $max = $min + CFactory::_('Component')->get('number') - 1; - $moreContributerFields = range($min, $max, 1); - foreach ($moreContributerFields as $counter) - { - $COUNTER = StringHelper::safe($counter, 'U'); - - $this->configFieldSets[] = Indent::_(2) - . ''; - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="spacer"'; - $this->configFieldSets[] = Indent::_(3) . 'class="text"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $langCont - . '_' . $COUNTER . '"'; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="text"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $langCont - . '_TITLE_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' - . $langCont . '_TITLE_DESC"'; - $this->configFieldSets[] = Indent::_(3) . 'size="60"'; - $this->configFieldSets[] = Indent::_(3) . 'default=""'; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="text"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $langCont - . '_NAME_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' - . $langCont . '_NAME_DESC"'; - $this->configFieldSets[] = Indent::_(3) . 'size="60"'; - $this->configFieldSets[] = Indent::_(3) . 'default=""'; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="email"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $langCont - . '_EMAIL_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' - . $langCont . '_EMAIL_DESC"'; - $this->configFieldSets[] = Indent::_(3) . 'size="60"'; - $this->configFieldSets[] = Indent::_(3) . 'default=""'; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="url"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $langCont - . '_LINK_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' - . $langCont . '_LINK_DESC"'; - $this->configFieldSets[] = Indent::_(3) . 'size="60"'; - $this->configFieldSets[] = Indent::_(3) . 'default=""'; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="list"'; - $this->configFieldSets[] = Indent::_(3) . 'default="0"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $langCont - . '_USE_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' - . $langCont . '_USE_DESC">'; - $this->configFieldSets[] = Indent::_(3) . ''; - $this->configFieldSets[] = Indent::_(3) . ''; - $this->configFieldSets[] = Indent::_(3) . ''; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="list"'; - $this->configFieldSets[] = Indent::_(3) . 'default="0"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $langCont - . '_SHOW_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' - . $langCont . '_SHOW_DESC">'; - $this->configFieldSets[] = Indent::_(3) . ''; - $this->configFieldSets[] = Indent::_(3) . ''; - $this->configFieldSets[] = Indent::_(3) . ''; - $this->configFieldSets[] = Indent::_(3) . ''; - $this->configFieldSets[] = Indent::_(2) . ""; - // setup lang - $Counter = StringHelper::safe($counter, 'Ww'); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $langCont . '_' . $COUNTER, - "Contributor " . $Counter - ); - } - } - if (CFactory::_('Config')->get('add_contributors', false) - || CFactory::_('Component')->get('emptycontributors', 0) == 1) - { - // setup lang - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $langCont . '_TITLE_LABEL', "Contributor Job Title" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $langCont . '_TITLE_DESC', - "The job title that best describes the contributor's relationship to this component." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $langCont . '_NAME_LABEL', "Contributor Name" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $langCont . '_NAME_DESC', - "The name of this contributor." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $langCont . '_EMAIL_LABEL', "Contributor Email" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $langCont . '_EMAIL_DESC', - "The email of this contributor." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $langCont . '_LINK_LABEL', "Contributor Website" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $langCont . '_LINK_DESC', - "The link to this contributor's website." - ); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $langCont . '_USE_LABEL', "Use"); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $langCont . '_USE_DESC', - "How should we link to this contributor." - ); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $langCont . '_USE_NONE', "None"); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $langCont . '_USE_EMAIL', "Email" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $langCont . '_USE_WWW', "Website" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $langCont . '_SHOW_LABEL', "Show" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $langCont . '_SHOW_DESC', - "Select where you want this contributor's details to show in the component." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $langCont . '_SHOW_NONE', "Hide" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $langCont . '_SHOW_BACK', "Back-end" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $langCont . '_SHOW_FRONT', "Front-end" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $langCont . '_SHOW_ALL', "Both Front & Back-end" - ); - } - // close that fieldset - $this->configFieldSets[] = Indent::_(1) . ""; - } - - public function setUikitConfigFieldsets($lang) - { - if (CFactory::_('Config')->uikit > 0) - { - // main lang prefix - $lang = $lang . ''; - // start building field set for uikit functions - $this->configFieldSets[] = Indent::_(1) . "configFieldSets[] = Indent::_(2) . 'name="uikit_config"'; - $this->configFieldSets[] = Indent::_(2) . 'label="' . $lang - . '_UIKIT_LABEL"'; - $this->configFieldSets[] = Indent::_(2) . 'description="' . $lang - . '_UIKIT_DESC">'; - // set tab lang - if (1 == CFactory::_('Config')->uikit) - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_UIKIT_LABEL', "Uikit2 Settings" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_UIKIT_DESC', "The Parameters for the uikit are set here.
    Uikit is a lightweight and modular front-end framework -for developing fast and powerful web interfaces. For more info visit https://getuikit.com/v2/" - ); - } - elseif (2 == CFactory::_('Config')->uikit) - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_UIKIT_LABEL', - "Uikit2 and Uikit3 Settings" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_UIKIT_DESC', "The Parameters for the uikit are set here.
    Uikit is a lightweight and modular front-end framework -for developing fast and powerful web interfaces. For more info visit version 2 or version 3" - ); - } - elseif (3 == CFactory::_('Config')->uikit) - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_UIKIT_LABEL', "Uikit3 Settings" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_UIKIT_DESC', "The Parameters for the uikit are set here.
    Uikit is a lightweight and modular front-end framework -for developing fast and powerful web interfaces. For more info visit https://getuikit.com/" - ); - } - - // set field lang - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_JQUERY_LOAD_LABEL', "Load Joomla jQuery" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_JQUERY_LOAD_DESC', - "Would you like to load the Joomla jQuery Framework?" - ); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_JQUERY_LOAD', "Load jQuery"); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_JQUERY_REMOVE', "Remove jQuery"); - - // set the field - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="radio"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $lang - . '_JQUERY_LOAD_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' . $lang - . '_JQUERY_LOAD_DESC"'; - $this->configFieldSets[] = Indent::_(3) - . 'class="btn-group btn-group-yesno"'; - $this->configFieldSets[] = Indent::_(3) . 'default="">'; - $this->configFieldSets[] = Indent::_(3) . ''; - $this->configFieldSets[] = Indent::_(3) . '"'; - $this->configFieldSets[] = Indent::_(3) . '"'; - $this->configFieldSets[] = Indent::_(2) . ""; - // set params defaults - $this->extensionsParams[] = '"add_jquery_framework":"1"'; - - // add version selection - if (2 == CFactory::_('Config')->uikit) - { - // set field lang - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_UIKIT_VERSION_LABEL', - "Uikit Versions" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_UIKIT_VERSION_DESC', - "Select what version you would like to use" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_UIKIT_V2', "Version 2" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_UIKIT_V3', "Version 3" - ); - // set the field - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="radio"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $lang - . '_UIKIT_VERSION_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' - . $lang . '_UIKIT_VERSION_DESC"'; - $this->configFieldSets[] = Indent::_(3) - . 'class="btn-group btn-group-yesno"'; - $this->configFieldSets[] = Indent::_(3) . 'default="2">'; - $this->configFieldSets[] = Indent::_(3) . ''; - $this->configFieldSets[] = Indent::_(3) . '"'; - $this->configFieldSets[] = Indent::_(3) . '"'; - $this->configFieldSets[] = Indent::_(2) . ""; - // set params defaults - $this->extensionsParams[] = '"uikit_version":"2"'; - } - - // set field lang - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_UIKIT_LOAD_LABEL', "Loading Options" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_UIKIT_LOAD_DESC', - "Set the uikit loading option." - ); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_AUTO_LOAD', "Auto"); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_FORCE_LOAD', "Force"); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_DONT_LOAD', "Not"); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_ONLY_EXTRA', "Only Extra" - ); - // set the field - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="radio"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $lang - . '_UIKIT_LOAD_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' . $lang - . '_UIKIT_LOAD_DESC"'; - $this->configFieldSets[] = Indent::_(3) - . 'class="btn-group btn-group-yesno"'; - $this->configFieldSets[] = Indent::_(3) . 'default="">'; - $this->configFieldSets[] = Indent::_(3) . ''; - $this->configFieldSets[] = Indent::_(3) . '"'; - $this->configFieldSets[] = Indent::_(3) . '"'; - if (2 == CFactory::_('Config')->uikit || 1 == CFactory::_('Config')->uikit) - { - $this->configFieldSets[] = Indent::_(3) . '"'; - } - $this->configFieldSets[] = Indent::_(3) . '"'; - $this->configFieldSets[] = Indent::_(2) . ""; - // set params defaults - $this->extensionsParams[] = '"uikit_load":"1"'; - - // set field lang - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_UIKIT_MIN_LABEL', "Load Minified" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_UIKIT_MIN_DESC', - "Should the minified version of uikit files be loaded?" - ); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_YES', "Yes"); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_NO', "No"); - // set the field - $this->configFieldSets[] = Indent::_(2) . 'configFieldSets[] = Indent::_(3) . 'type="radio"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $lang - . '_UIKIT_MIN_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' . $lang - . '_UIKIT_MIN_DESC"'; - $this->configFieldSets[] = Indent::_(3) - . 'class="btn-group btn-group-yesno"'; - $this->configFieldSets[] = Indent::_(3) . 'default="">'; - $this->configFieldSets[] = Indent::_(3) . ''; - $this->configFieldSets[] = Indent::_(3) . '"'; - $this->configFieldSets[] = Indent::_(3) . '"'; - $this->configFieldSets[] = Indent::_(2) . ""; - // set params defaults - $this->extensionsParams[] = '"uikit_min":""'; - - if (2 == CFactory::_('Config')->uikit || 1 == CFactory::_('Config')->uikit) - { - // set field lang - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_UIKIT_STYLE_LABEL', "css Style" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_UIKIT_STYLE_DESC', - "Set the css style that should be used." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_FLAT_LOAD', "Flat" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_ALMOST_FLAT_LOAD', "Almost Flat" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_GRADIANT_LOAD', "Gradient" - ); - // set the field - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="radio"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $lang - . '_UIKIT_STYLE_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' - . $lang . '_UIKIT_STYLE_DESC"'; - $this->configFieldSets[] = Indent::_(3) - . 'class="btn-group btn-group-yesno"'; - if (2 == CFactory::_('Config')->uikit) - { - $this->configFieldSets[] = Indent::_(3) - . 'showon="uikit_version:2"'; - } - $this->configFieldSets[] = Indent::_(3) . 'default="">'; - $this->configFieldSets[] = Indent::_(3) . ''; - $this->configFieldSets[] = Indent::_(3) . '"'; - $this->configFieldSets[] = Indent::_(3) - . '"'; - $this->configFieldSets[] = Indent::_(3) - . '"'; - $this->configFieldSets[] = Indent::_(2) . ""; - // set params defaults - $this->extensionsParams[] = '"uikit_style":""'; - } - // add custom Uikit Settings fields - if (isset($this->configFieldSetsCustomField['Uikit Settings']) - && ArrayHelper::check( - $this->configFieldSetsCustomField['Uikit Settings'] - )) - { - $this->configFieldSets[] = implode( - "", $this->configFieldSetsCustomField['Uikit Settings'] - ); - unset($this->configFieldSetsCustomField['Uikit Settings']); - } - // close that fieldset - $this->configFieldSets[] = Indent::_(1) . ""; - } - } - - public function setEmailHelperConfigFieldsets($lang) - { - if (CFactory::_('Component')->get('add_email_helper')) - { - // main lang prefix - $lang = $lang . ''; - // set main lang string - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_MAIL_CONFIGURATION', "Mail Configuration" - ); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_DKIM', "DKIM"); - // start building field set for email helper functions - $this->configFieldSets[] = PHP_EOL . Indent::_(1) . "configFieldSets[] = Indent::_(2) - . "name=\"mail_configuration_custom_config\""; - $this->configFieldSets[] = Indent::_(2) . "label=\"" . $lang - . "_MAIL_CONFIGURATION\">"; - // add custom Mail Configurations - if (isset($this->configFieldSetsCustomField['Mail Configuration']) - && ArrayHelper::check( - $this->configFieldSetsCustomField['Mail Configuration'] - )) - { - $this->configFieldSets[] = implode( - "", $this->configFieldSetsCustomField['Mail Configuration'] - ); - unset($this->configFieldSetsCustomField['Mail Configuration']); - } - else - { - // set all the laguage strings - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_MAILONLINE_LABEL', "Mailer Status" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_MAILONLINE_DESCRIPTION', - "Warning this will stop all emails from going out." - ); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_ON', "On"); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_OFF', "Off"); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_MAILER_LABEL', "Mailer" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_MAILER_DESCRIPTION', - "Select what mailer you would like to use to send emails." - ); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_GLOBAL', "Global"); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_PHP_MAIL', "PHP Mail" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SENDMAIL', "Sendmail" - ); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_SMTP', "SMTP"); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_EMAILFROM_LABEL', " From Email" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_EMAILFROM_DESCRIPTION', - "The global email address that will be used to send system email." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_EMAILFROM_HINT', "Email Address Here" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_FROMNAME_LABEL', "From Name" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_FROMNAME_DESCRIPTION', - "Text displayed in the header "From:" field when sending a site email. Usually the site name." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_FROMNAME_HINT', "From Name Here" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_EMAILREPLY_LABEL', " Reply to Email" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_EMAILREPLY_DESCRIPTION', - "The global email address that will be used to set as the reply email. (leave blank for none)" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_EMAILREPLY_HINT', - "Email Address Here" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_REPLYNAME_LABEL', "Reply to Name" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_REPLYNAME_DESCRIPTION', - "Text displayed in the header "Reply To:" field when replying to the site email. Usually the the person that receives the response. (leave blank for none)" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_REPLYNAME_HINT', "Reply Name Here" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SENDMAIL_LABEL', "Sendmail Path" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SENDMAIL_DESCRIPTION', - "Enter the path to the sendmail program directory on your host server." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SENDMAIL_HINT', "/usr/sbin/sendmail" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SMTPAUTH_LABEL', - "SMTP Authentication" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SMTPAUTH_DESCRIPTION', - "Select yes if your SMTP host requires SMTP Authentication." - ); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_YES', "Yes"); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_NO', "No"); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SMTPSECURE_LABEL', "SMTP Security" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SMTPSECURE_DESCRIPTION', - "Select the security model that your SMTP server uses." - ); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_NONE', "None"); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_SSL', "SSL"); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_TLS', "TLS"); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SMTPPORT_LABEL', "SMTP Port" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SMTPPORT_DESCRIPTION', - "Enter the port number of your SMTP server. Use 25 for most unsecured servers and 465 for most secure servers." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SMTPPORT_HINT', "25" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SMTPUSER_LABEL', "SMTP Username" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SMTPUSER_DESCRIPTION', - "Enter the username for access to the SMTP host." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SMTPUSER_HINT', "email@demo.com" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SMTPPASS_LABEL', "SMTP Password" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SMTPPASS_DESCRIPTION', - "Enter the password for access to the SMTP host." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SMTPHOST_LABEL', "SMTP Host" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SMTPHOST_DESCRIPTION', - "Enter the name of the SMTP host." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SMTPHOST_HINT', "localhost" - ); - - // set the mailer fields - $this->configFieldSets[] = PHP_EOL . Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"radio\""; - $this->configFieldSets[] = Indent::_(3) . "name=\"mailonline\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_MAILONLINE_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_MAILONLINE_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) - . "class=\"btn-group btn-group-yesno\""; - $this->configFieldSets[] = Indent::_(3) . "default=\"1\">"; - $this->configFieldSets[] = Indent::_(3) . ""; - $this->configFieldSets[] = Indent::_(3) - . ""; - $this->configFieldSets[] = Indent::_(3) - . ""; - $this->configFieldSets[] = Indent::_(2) . "
    "; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"list\""; - $this->configFieldSets[] = Indent::_(3) . "name=\"mailer\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_MAILER_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_MAILER_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) - . "class=\"list_class\""; - $this->configFieldSets[] = Indent::_(3) . "multiple=\"false\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"WORD\""; - $this->configFieldSets[] = Indent::_(3) . "required=\"true\""; - $this->configFieldSets[] = Indent::_(3) . "default=\"global\">"; - $this->configFieldSets[] = Indent::_(3) . ""; - $this->configFieldSets[] = Indent::_(3) - . ""; - $this->configFieldSets[] = Indent::_(3) - . ""; - $this->configFieldSets[] = Indent::_(3) - . ""; - $this->configFieldSets[] = Indent::_(3) - . ""; - $this->configFieldSets[] = Indent::_(2) . "
    "; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) . "name=\"emailfrom\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_EMAILFROM_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"60\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"150\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_EMAILFROM_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"STRING\""; - $this->configFieldSets[] = Indent::_(3) . "validate=\"email\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add email address here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_EMAILFROM_HINT\""; - $this->configFieldSets[] = Indent::_(3) - . "showon=\"mailer:smtp,sendmail,default\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) . "name=\"fromname\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_FROMNAME_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"60\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"150\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_FROMNAME_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"STRING\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add some name here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_FROMNAME_HINT\""; - $this->configFieldSets[] = Indent::_(3) - . "showon=\"mailer:smtp,sendmail,default\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) . "name=\"replyto\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_EMAILREPLY_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"60\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"150\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_EMAILREPLY_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"STRING\""; - $this->configFieldSets[] = Indent::_(3) . "validate=\"email\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add email address here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_EMAILREPLY_HINT\""; - $this->configFieldSets[] = Indent::_(3) - . "showon=\"mailer:smtp,sendmail,default\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"replytoname\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_REPLYNAME_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"60\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"150\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_REPLYNAME_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"STRING\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add some name here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_REPLYNAME_HINT\""; - $this->configFieldSets[] = Indent::_(3) - . "showon=\"mailer:smtp,sendmail,default\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) . "name=\"sendmail\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_SENDMAIL_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"60\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"150\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_SENDMAIL_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "required=\"false\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"PATH\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add path to you local sendmail here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_SENDMAIL_HINT\""; - $this->configFieldSets[] = Indent::_(3) - . "showon=\"mailer:sendmail\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"radio\""; - $this->configFieldSets[] = Indent::_(3) . "name=\"smtpauth\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_SMTPAUTH_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_SMTPAUTH_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) - . "class=\"btn-group btn-group-yesno\""; - $this->configFieldSets[] = Indent::_(3) . "default=\"0\""; - $this->configFieldSets[] = Indent::_(3) - . "showon=\"mailer:smtp\">"; - $this->configFieldSets[] = Indent::_(3) . ""; - $this->configFieldSets[] = Indent::_(3) - . ""; - $this->configFieldSets[] = Indent::_(3) - . ""; - $this->configFieldSets[] = Indent::_(2) . "
    "; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"list\""; - $this->configFieldSets[] = Indent::_(3) . "name=\"smtpsecure\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_SMTPSECURE_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_SMTPSECURE_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) - . "class=\"list_class\""; - $this->configFieldSets[] = Indent::_(3) . "multiple=\"false\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"WORD\""; - $this->configFieldSets[] = Indent::_(3) . "default=\"none\""; - $this->configFieldSets[] = Indent::_(3) - . "showon=\"mailer:smtp\">"; - $this->configFieldSets[] = Indent::_(3) . ""; - $this->configFieldSets[] = Indent::_(3) - . ""; - $this->configFieldSets[] = Indent::_(3) - . ""; - $this->configFieldSets[] = Indent::_(3) - . ""; - $this->configFieldSets[] = Indent::_(2) . "
    "; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) . "name=\"smtpport\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_SMTPPORT_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"60\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"150\""; - $this->configFieldSets[] = Indent::_(3) . "default=\"25\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_SMTPPORT_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"INT\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add the port number of your SMTP server here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_SMTPPORT_HINT\""; - $this->configFieldSets[] = Indent::_(3) - . "showon=\"mailer:smtp\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) . "name=\"smtpuser\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_SMTPUSER_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"60\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"150\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_SMTPUSER_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"STRING\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add the username for SMTP server here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_SMTPUSER_HINT\""; - $this->configFieldSets[] = Indent::_(3) - . "showon=\"mailer:smtp\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"password\""; - $this->configFieldSets[] = Indent::_(3) . "name=\"smtppass\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_SMTPPASS_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"60\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_SMTPPASS_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"raw\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add the password for SMTP server here.\""; - $this->configFieldSets[] = Indent::_(3) - . "showon=\"mailer:smtp\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) . "name=\"smtphost\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_SMTPHOST_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"60\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"150\""; - $this->configFieldSets[] = Indent::_(3) - . "default=\"localhost\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_SMTPHOST_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"STRING\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add the name of the SMTP host here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_SMTPHOST_HINT\""; - $this->configFieldSets[] = Indent::_(3) - . "showon=\"mailer:smtp\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - } - // close that fieldset - $this->configFieldSets[] = Indent::_(1) . ""; - - // start dkim field set - $this->configFieldSets[] = Indent::_(1) . "configFieldSets[] = Indent::_(2) - . "name=\"dkim_custom_config\""; - $this->configFieldSets[] = Indent::_(2) . "label=\"" . $lang - . "_DKIM\">"; - // add custom DKIM fields - if (isset($this->configFieldSetsCustomField['DKIM']) - && ArrayHelper::check( - $this->configFieldSetsCustomField['DKIM'] - )) - { - $this->configFieldSets[] = implode( - "", $this->configFieldSetsCustomField['DKIM'] - ); - unset($this->configFieldSetsCustomField['DKIM']); - } - else - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_LABEL', "Enable DKIM" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_DESCRIPTION', - "Set this option to Yes if you want to sign your emails using DKIM." - ); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_YES', "Yes"); - CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $lang . '_NO', "No"); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_DOMAIN_LABEL', "Domain" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_DOMAIN_DESCRIPTION', - "Set the domain. Eg. domain.com" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_DOMAIN_HINT', "domain.com" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_SELECTOR_LABEL', "Selector" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_SELECTOR_DESCRIPTION', - "Set your DKIM/DNS selector." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_SELECTOR_HINT', "vdm" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_PASSPHRASE_LABEL', "Passphrase" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_PASSPHRASE_DESCRIPTION', - "Enter your passphrase here." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_IDENTITY_LABEL', "Identity" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_IDENTITY_DESCRIPTION', - "Set DKIM identity. This can be in the format of an email address 'you@yourdomain.com' typically used as the source of the email." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_IDENTITY_HINT', - "you@yourdomain.com" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_PRIVATE_KEY_LABEL', - "Private key" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_PRIVATE_KEY_DESCRIPTION', - "set private key" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_PUBLIC_KEY_LABEL', "Public key" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_PUBLIC_KEY_DESCRIPTION', - "set public key" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_NOTE_DKIM_USE_LABEL', - "Server Configuration" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_NOTE_DKIM_USE_DESCRIPTION', "

    Using the below details, you need to configure your DNS by adding a TXT record on your domain:

    -" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_KEY_LABEL', "Key" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_KEY_DESCRIPTION', - "This is the KEY to use in the DNS record." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_KEY_HINT', "vdm._domainkey" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_VALUE_LABEL', "Value" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_VALUE_DESCRIPTION', - "This is the TXT value to use in the DNS. Replace the PUBLICKEY with your public key." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_DKIM_VALUE_HINT', - "v=DKIM1;k=rsa;g=*;s=email;h=sha1;t=s;p=PUBLICKEY" - ); - - - $this->configFieldSets[] = PHP_EOL . Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"radio\""; - $this->configFieldSets[] = Indent::_(3) . "name=\"dkim\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_DKIM_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_DKIM_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) - . "class=\"btn-group btn-group-yesno\""; - $this->configFieldSets[] = Indent::_(3) . "default=\"0\""; - $this->configFieldSets[] = Indent::_(3) . "required=\"true\">"; - $this->configFieldSets[] = Indent::_(3) . ""; - $this->configFieldSets[] = Indent::_(3) - . ""; - $this->configFieldSets[] = Indent::_(3) - . ""; - $this->configFieldSets[] = Indent::_(2) . "
    "; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"dkim_domain\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_DKIM_DOMAIN_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"60\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"150\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_DKIM_DOMAIN_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"STRING\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add DKIM Domain here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_DKIM_DOMAIN_HINT\""; - $this->configFieldSets[] = Indent::_(3) . "showon=\"dkim:1\""; - $this->configFieldSets[] = Indent::_(3) - . "onchange=\"vdm_dkim();\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"dkim_selector\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_DKIM_SELECTOR_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"60\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"150\""; - $this->configFieldSets[] = Indent::_(3) . "default=\"vdm\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_DKIM_SELECTOR_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"STRING\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add DKIM/DNS selector here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_DKIM_SELECTOR_HINT\""; - $this->configFieldSets[] = Indent::_(3) . "showon=\"dkim:1\""; - $this->configFieldSets[] = Indent::_(3) - . "onchange=\"vdm_dkim();\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"password\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"dkim_passphrase\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_DKIM_PASSPHRASE_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"60\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_DKIM_PASSPHRASE_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"raw\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add passphrase here.\""; - $this->configFieldSets[] = Indent::_(3) . "showon=\"dkim:1\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"dkim_identity\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_DKIM_IDENTITY_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"60\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"150\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_DKIM_IDENTITY_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"raw\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add DKIM Identity here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_DKIM_IDENTITY_HINT\""; - $this->configFieldSets[] = Indent::_(3) . "showon=\"dkim:1\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"textarea\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"dkim_private_key\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_DKIM_PRIVATE_KEY_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "rows=\"15\""; - $this->configFieldSets[] = Indent::_(3) . "cols=\"5\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_DKIM_PRIVATE_KEY_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) - . "class=\"input-xxlarge span12\""; - $this->configFieldSets[] = Indent::_(3) . "showon=\"dkim:1\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"textarea\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"dkim_public_key\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_DKIM_PUBLIC_KEY_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "rows=\"5\""; - $this->configFieldSets[] = Indent::_(3) . "cols=\"5\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_DKIM_PUBLIC_KEY_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) - . "class=\"input-xxlarge span12\""; - $this->configFieldSets[] = Indent::_(3) . "showon=\"dkim:1\""; - $this->configFieldSets[] = Indent::_(3) - . "onchange=\"vdm_dkim();\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) - . ""; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) . "name=\"dkim_key\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_DKIM_KEY_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"40\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"150\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_DKIM_KEY_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"STRING\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add KEY here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_DKIM_KEY_HINT\""; - $this->configFieldSets[] = Indent::_(3) . "showon=\"dkim:1\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) . "name=\"dkim_value\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_DKIM_VALUE_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"80\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"350\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" - . $lang . "_DKIM_VALUE_DESCRIPTION\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"STRING\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add TXT record here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_DKIM_VALUE_HINT\""; - $this->configFieldSets[] = Indent::_(3) . "showon=\"dkim:1\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - } - // close that fieldset - $this->configFieldSets[] = Indent::_(1) . ""; - } - } - - public function setGooglechartConfigFieldsets($lang) - { - if (CFactory::_('Config')->get('google_chart', false)) - { - $this->configFieldSets[] = PHP_EOL . Indent::_(1) . "configFieldSets[] = Indent::_(2) - . "name=\"googlechart_config\""; - $this->configFieldSets[] = Indent::_(2) . "label=\"" . $lang - . "_CHART_SETTINGS_LABEL\""; - $this->configFieldSets[] = Indent::_(2) . "description=\"" . $lang - . "_CHART_SETTINGS_DESC\">"; - $this->configFieldSets[] = Indent::_(2); - $this->configFieldSets[] = Indent::_(2) - . ""; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"color\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"admin_chartbackground\""; - $this->configFieldSets[] = Indent::_(3) . "default=\"#F7F7FA\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_CHARTBACKGROUND_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" . $lang - . "_CHARTBACKGROUND_DESC\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"admin_mainwidth\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_MAINWIDTH_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"20\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"50\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" . $lang - . "_MAINWIDTH_DESC\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"INT\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add area width here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_MAINWIDTH_HINT\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) - . ""; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"admin_chartareatop\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_CHARTAREATOP_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"20\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"50\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" . $lang - . "_CHARTAREATOP_DESC\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"INT\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add top spacing here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_CHARTAREATOP_HINT\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"admin_chartarealeft\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_CHARTAREALEFT_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"20\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"50\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" . $lang - . "_CHARTAREALEFT_DESC\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"INT\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add left spacing here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_CHARTAREALEFT_HINT\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"admin_chartareawidth\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_CHARTAREAWIDTH_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"20\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"50\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" . $lang - . "_CHARTAREAWIDTH_DESC\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"INT\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add chart width here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_CHARTAREAWIDTH_HINT\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) - . ""; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"color\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"admin_legendtextstylefontcolor\""; - $this->configFieldSets[] = Indent::_(3) . "default=\"#63B1F2\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_LEGENDTEXTSTYLEFONTCOLOR_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" . $lang - . "_LEGENDTEXTSTYLEFONTCOLOR_DESC\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"admin_legendtextstylefontsize\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_LEGENDTEXTSTYLEFONTSIZE_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"20\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"50\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" . $lang - . "_LEGENDTEXTSTYLEFONTSIZE_DESC\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"INT\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add size of the legend here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_LEGENDTEXTSTYLEFONTSIZE_HINT\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) - . ""; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"color\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"admin_vaxistextstylefontcolor\""; - $this->configFieldSets[] = Indent::_(3) . "default=\"#63B1F2\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_VAXISTEXTSTYLEFONTCOLOR_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" . $lang - . "_VAXISTEXTSTYLEFONTCOLOR_DESC\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) - . ""; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"color\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"admin_haxistextstylefontcolor\""; - $this->configFieldSets[] = Indent::_(3) . "default=\"#63B1F2\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_HAXISTEXTSTYLEFONTCOLOR_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" . $lang - . "_HAXISTEXTSTYLEFONTCOLOR_DESC\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"color\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"admin_haxistitletextstylefontcolor\""; - $this->configFieldSets[] = Indent::_(3) . "default=\"#63B1F2\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_HAXISTITLETEXTSTYLEFONTCOLOR_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" . $lang - . "_HAXISTITLETEXTSTYLEFONTCOLOR_DESC\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2); - $this->configFieldSets[] = Indent::_(2) - . ""; - $this->configFieldSets[] = Indent::_(2); - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"color\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"site_chartbackground\""; - $this->configFieldSets[] = Indent::_(3) . "default=\"#F7F7FA\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_CHARTBACKGROUND_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" . $lang - . "_CHARTBACKGROUND_DESC\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) . "name=\"site_mainwidth\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_MAINWIDTH_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"20\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"50\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" . $lang - . "_MAINWIDTH_DESC\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"INT\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add area width here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_MAINWIDTH_HINT\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) - . ""; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"site_chartareatop\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_CHARTAREATOP_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"20\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"50\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" . $lang - . "_CHARTAREATOP_DESC\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"INT\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add top spacing here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_CHARTAREATOP_HINT\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"site_chartarealeft\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_CHARTAREALEFT_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"20\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"50\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" . $lang - . "_CHARTAREALEFT_DESC\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"INT\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add left spacing here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_CHARTAREALEFT_HINT\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"site_chartareawidth\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_CHARTAREAWIDTH_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"20\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"50\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" . $lang - . "_CHARTAREAWIDTH_DESC\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"INT\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add chart width here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_CHARTAREAWIDTH_HINT\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) - . ""; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"color\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"site_legendtextstylefontcolor\""; - $this->configFieldSets[] = Indent::_(3) . "default=\"#63B1F2\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_LEGENDTEXTSTYLEFONTCOLOR_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" . $lang - . "_LEGENDTEXTSTYLEFONTCOLOR_DESC\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"text\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"site_legendtextstylefontsize\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_LEGENDTEXTSTYLEFONTSIZE_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "size=\"20\""; - $this->configFieldSets[] = Indent::_(3) . "maxlength=\"50\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" . $lang - . "_LEGENDTEXTSTYLEFONTSIZE_DESC\""; - $this->configFieldSets[] = Indent::_(3) . "class=\"text_area\""; - $this->configFieldSets[] = Indent::_(3) . "filter=\"INT\""; - $this->configFieldSets[] = Indent::_(3) - . "message=\"Error! Please add size of the legend here.\""; - $this->configFieldSets[] = Indent::_(3) . "hint=\"" . $lang - . "_LEGENDTEXTSTYLEFONTSIZE_HINT\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) - . ""; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"color\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"site_vaxistextstylefontcolor\""; - $this->configFieldSets[] = Indent::_(3) . "default=\"#63B1F2\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_VAXISTEXTSTYLEFONTCOLOR_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" . $lang - . "_VAXISTEXTSTYLEFONTCOLOR_DESC\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) - . ""; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"color\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"site_haxistextstylefontcolor\""; - $this->configFieldSets[] = Indent::_(3) . "default=\"#63B1F2\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_HAXISTEXTSTYLEFONTCOLOR_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" . $lang - . "_HAXISTEXTSTYLEFONTCOLOR_DESC\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - $this->configFieldSets[] = Indent::_(2) . ""; - $this->configFieldSets[] = Indent::_(2) . "configFieldSets[] = Indent::_(3) . "type=\"color\""; - $this->configFieldSets[] = Indent::_(3) - . "name=\"site_haxistitletextstylefontcolor\""; - $this->configFieldSets[] = Indent::_(3) . "default=\"#63B1F2\""; - $this->configFieldSets[] = Indent::_(3) . "label=\"" . $lang - . "_HAXISTITLETEXTSTYLEFONTCOLOR_LABEL\""; - $this->configFieldSets[] = Indent::_(3) . "description=\"" . $lang - . "_HAXISTITLETEXTSTYLEFONTCOLOR_DESC\""; - $this->configFieldSets[] = Indent::_(2) . "/>"; - - // add custom Encryption Settings fields - if (isset($this->configFieldSetsCustomField['Chart Settings']) - && ArrayHelper::check( - $this->configFieldSetsCustomField['Chart Settings'] - )) - { - $this->configFieldSets[] = implode( - "", $this->configFieldSetsCustomField['Chart Settings'] - ); - unset($this->configFieldSetsCustomField['Chart Settings']); - } - - $this->configFieldSets[] = Indent::_(1) . ""; - - // set params defaults - $this->extensionsParams[] - = '"admin_chartbackground":"#F7F7FA","admin_mainwidth":"1000","admin_chartareatop":"20","admin_chartarealeft":"20","admin_chartareawidth":"170","admin_legendtextstylefontcolor":"10","admin_legendtextstylefontsize":"20","admin_vaxistextstylefontcolor":"#63B1F2","admin_haxistextstylefontcolor":"#63B1F2","admin_haxistitletextstylefontcolor":"#63B1F2","site_chartbackground":"#F7F7FA","site_mainwidth":"1000","site_chartareatop":"20","site_chartarealeft":"20","site_chartareawidth":"170","site_legendtextstylefontcolor":"10","site_legendtextstylefontsize":"20","site_vaxistextstylefontcolor":"#63B1F2","site_haxistextstylefontcolor":"#63B1F2","site_haxistitletextstylefontcolor":"#63B1F2"'; - - // set field lang - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHART_SETTINGS_LABEL', "Chart Settings" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHART_SETTINGS_DESC', - "The Google Chart Display Settings Are Made Here." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_ADMIN_CHART_NOTE_LABEL', "Admin Settings" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_ADMIN_CHART_NOTE_DESC', - "The following settings are used on the back-end of the site called (admin)." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SITE_CHART_NOTE_LABEL', "Site Settings" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_SITE_CHART_NOTE_DESC', - "The following settings are used on the front-end of the site called (site)." - ); - - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHARTAREALEFT_DESC', - "Set in pixels the spacing from the left of the chart area to the beginning of the chart it self. Please don't add the px sign" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHARTAREALEFT_HINT', "170" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHARTAREALEFT_LABEL', "Left Spacing" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHARTAREATOP_DESC', - "Set in pixels the spacing from the top of the chart area to the beginning of the chart it self. Please don't add the px sign" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHARTAREATOP_HINT', "20" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHARTAREATOP_LABEL', "Top Spacing" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHARTAREAWIDTH_DESC', - "Set in % the width of the chart it self inside the chart area. Please don't add the % sign" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHARTAREAWIDTH_HINT', "60" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHARTAREAWIDTH_LABEL', "Chart Width" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHARTBACKGROUND_DESC', - "Select the chart background color here." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_CHARTBACKGROUND_LABEL', - "Chart Background" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_HAXISTEXTSTYLEFONTCOLOR_DESC', - "Select the horizontal axis font color." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_HAXISTEXTSTYLEFONTCOLOR_LABEL', - "hAxis Font Color" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_HAXISTITLETEXTSTYLEFONTCOLOR_DESC', - "Select the horizontal axis title's font color." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_HAXISTITLETEXTSTYLEFONTCOLOR_LABEL', - "hAxis Title Font Color" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_LEGENDTEXTSTYLEFONTCOLOR_DESC', - "Select the legend font color." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_LEGENDTEXTSTYLEFONTCOLOR_LABEL', - "Legend Font Color" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_LEGENDTEXTSTYLEFONTSIZE_DESC', - "Set in pixels the font size of the legend" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_LEGENDTEXTSTYLEFONTSIZE_HINT', "10" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_LEGENDTEXTSTYLEFONTSIZE_LABEL', - "Legend Font Size" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_MAINWIDTH_DESC', - "Set the width of the entire chart area" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_MAINWIDTH_HINT', "1000" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_MAINWIDTH_LABEL', "Chart Area Width" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_VAXISTEXTSTYLEFONTCOLOR_DESC', - "Select the vertical axis font color." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_VAXISTEXTSTYLEFONTCOLOR_LABEL', - "vAxis Font Color" - ); - } - } - - /** - * @param $lang - */ - public function setEncryptionConfigFieldsets($lang) - { - // enable the loading of dynamic field sets - $dynamicAddFields = array(); - // Add encryption if needed - if (CFactory::_('Config')->basic_encryption - || CFactory::_('Config')->whmcs_encryption - || CFactory::_('Config')->medium_encryption - || CFactory::_('Component')->get('add_license') - || (isset($this->configFieldSetsCustomField['Encryption Settings']) - && ArrayHelper::check( - $this->configFieldSetsCustomField['Encryption Settings'] - ))) - { - $dynamicAddFields[] = "Encryption Settings"; - // start building field set for encryption functions - $this->configFieldSets[] = Indent::_(1) . "configFieldSets[] = Indent::_(2) - . 'name="encryption_config"'; - $this->configFieldSets[] = Indent::_(2) . 'label="' . $lang - . '_ENCRYPTION_LABEL"'; - $this->configFieldSets[] = Indent::_(2) . 'description="' . $lang - . '_ENCRYPTION_DESC">'; - - // set tab lang - if ((CFactory::_('Config')->basic_encryption - || CFactory::_('Config')->medium_encryption - || CFactory::_('Config')->whmcs_encryption) - && CFactory::_('Component')->get('add_license') - && CFactory::_('Component')->get('license_type', 0) == 3) - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_ENCRYPTION_LABEL', - "License & Encryption Settings" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_ENCRYPTION_DESC', - "The license & encryption keys are set here." - ); - // add the next dynamic option - $dynamicAddFields[] = "License & Encryption Settings"; - } - elseif ((CFactory::_('Config')->basic_encryption - || CFactory::_('Config')->medium_encryption - || CFactory::_('Config')->whmcs_encryption) - && CFactory::_('Component')->get('add_license') - && CFactory::_('Component')->get('license_type', 0) == 2) - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_ENCRYPTION_LABEL', - "Update & Encryption Settings" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_ENCRYPTION_DESC', - "The update & encryption keys are set here." - ); - // add the next dynamic option - $dynamicAddFields[] = "Update & Encryption Settings"; - } - elseif (CFactory::_('Component')->get('add_license') - && CFactory::_('Component')->get('license_type', 0) == 3) - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_ENCRYPTION_LABEL', "License Settings" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_ENCRYPTION_DESC', - "The license key is set here." - ); - // add the next dynamic option - $dynamicAddFields[] = "License Settings"; - } - elseif (CFactory::_('Component')->get('add_license') - && CFactory::_('Component')->get('license_type', 0) == 2) - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_ENCRYPTION_LABEL', "Update Settings" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_ENCRYPTION_DESC', - "The update key is set here." - ); - // add the next dynamic option - $dynamicAddFields[] = "Update Settings"; - } - else - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_ENCRYPTION_LABEL', - "Encryption Settings" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_ENCRYPTION_DESC', - "The encryption key for the field encryption is set here." - ); - } - - if (CFactory::_('Config')->basic_encryption) - { - // set field lang - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_BASIC_KEY_LABEL', "Basic Key" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_BASIC_KEY_DESC', - "Set the basic local key here." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_BASIC_KEY_NOTE_LABEL', - "Basic Encryption" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_BASIC_KEY_NOTE_DESC', - "When using the basic encryption please use set a 32 character passphrase.
    Never change this passphrase once it is set! DATA WILL GET CORRUPTED IF YOU DO!" - ); - // set the field - $this->configFieldSets[] = Indent::_(2) - . ''; - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="text"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $lang - . '_BASIC_KEY_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' - . $lang . '_BASIC_KEY_DESC"'; - $this->configFieldSets[] = Indent::_(3) . 'size="60"'; - $this->configFieldSets[] = Indent::_(3) . 'default=""'; - $this->configFieldSets[] = Indent::_(2) . "/>"; - } - if (CFactory::_('Config')->medium_encryption) - { - // set field lang - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_MEDIUM_KEY_LABEL', - "Medium Key (Path)" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_MEDIUM_KEY_DESC', - "Set the full path to where the key file must be stored. Make sure it is behind the root folder of your website, so that it is not public accessible." - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_MEDIUM_KEY_NOTE_LABEL', - "Medium Encryption" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_MEDIUM_KEY_NOTE_DESC', - "When using the medium encryption option, the system generates its own key and stores it in a file at the folder/path you set here.
    Never change this key once it is set, or remove the key file! DATA WILL GET CORRUPTED IF YOU DO! Also make sure the full path to where the the key file should be stored, is behind the root folder of your website/system, so that it is not public accessible. Making a backup of this key file over a secure connection is recommended!" - ); - // set the field - $this->configFieldSets[] = Indent::_(2) - . ''; - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="text"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $lang - . '_MEDIUM_KEY_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' - . $lang . '_MEDIUM_KEY_DESC"'; - $this->configFieldSets[] = Indent::_(3) . 'size="160"'; - $this->configFieldSets[] = Indent::_(3) . 'filter="PATH"'; - $this->configFieldSets[] = Indent::_(3) - . 'hint="/home/user/hiddenfolder123/"'; - $this->configFieldSets[] = Indent::_(3) . 'default=""'; - $this->configFieldSets[] = Indent::_(2) . "/>"; - // set some error message if the path does not exist - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_MEDIUM_KEY_PATH_ERROR', - "Medium key path (for encryption of various fields) does not exist, or is not writable. Please check the path and update it in the global option of this component." - ); - } - if (CFactory::_('Config')->whmcs_encryption - || CFactory::_('Component')->get('add_license')) - { - // set field lang label and description - if (CFactory::_('Component')->get('add_license') - && CFactory::_('Component')->get('license_type', 0) == 3) - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_LABEL', - CFactory::_('Component')->get('companyname', '') . " License Key" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_DESC', - "Add the license key you recieved from " - . CFactory::_('Component')->get('companyname', '') . " here." - ); - } - elseif (CFactory::_('Component')->get('add_license') - && CFactory::_('Component')->get('license_type', 0) == 2) - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_LABEL', - CFactory::_('Component')->get('companyname', '') . " Update Key" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_DESC', - "Add the update key you recieved from " - . CFactory::_('Component')->get('companyname', '') . " here." - ); - } - else - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_LABEL', - CFactory::_('Component')->get('companyname', '') . " Key" - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_DESC', - "Add the key you recieved from " - . CFactory::_('Component')->get('companyname', '') . " here." - ); - } - // ajust the notice based on license - if (CFactory::_('Component')->get('license_type',0) == 3) - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_NOTE_LABEL', - "Your " . CFactory::_('Component')->get('companyname','') - . " License Key" - ); - } - elseif (CFactory::_('Component')->get('license_type',0) == 2) - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_NOTE_LABEL', - "Your " . CFactory::_('Component')->get('companyname','') - . " Update Key" - ); - } - else - { - if (CFactory::_('Config')->whmcs_encryption) - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_NOTE_LABEL', - "Your " . CFactory::_('Component')->get('companyname','') - . " Field Encryption Key" - ); - } - else - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_NOTE_LABEL', - "Your " . CFactory::_('Component')->get('companyname','') . " Key" - ); - } - } - // add the description based on global settings - if (CFactory::_('Config')->whmcs_encryption) - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_NOTE_DESC', - "You need to get this key from get('whmcs_buy_link','') - . "' target='_blank'>" - . CFactory::_('Component')->get('companyname','') - . ".
    When using the " - . CFactory::_('Component')->get('companyname','') - . " field encryption you can never change this key once it is set! DATA WILL GET CORRUPTED IF YOU DO!" - ); - } - else - { - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, $lang . '_WHMCS_KEY_NOTE_DESC', - "You need to get this key from get('whmcs_buy_link','') - . "' target='_blank'>" - . CFactory::_('Component')->get('companyname','') . "." - ); - } - // set the fields - $this->configFieldSets[] = Indent::_(2) - . ''; - $this->configFieldSets[] = Indent::_(2) - . 'configFieldSets[] = Indent::_(3) . 'type="text"'; - $this->configFieldSets[] = Indent::_(3) . 'label="' . $lang - . '_WHMCS_KEY_LABEL"'; - $this->configFieldSets[] = Indent::_(3) . 'description="' - . $lang . '_WHMCS_KEY_DESC"'; - $this->configFieldSets[] = Indent::_(3) . 'size="60"'; - $this->configFieldSets[] = Indent::_(3) . 'default=""'; - $this->configFieldSets[] = Indent::_(2) . "/>"; - } - // load the dynamic field sets - foreach ($dynamicAddFields as $dynamicAddField) - { - // add custom Encryption Settings fields - if (isset($this->configFieldSetsCustomField[$dynamicAddField]) - && ArrayHelper::check( - $this->configFieldSetsCustomField[$dynamicAddField] - )) - { - $this->configFieldSets[] = implode( - "", $this->configFieldSetsCustomField[$dynamicAddField] - ); - unset($this->configFieldSetsCustomField[$dynamicAddField]); - } - } - // close that fieldset - $this->configFieldSets[] = Indent::_(1) . ""; - } - } - - public function setAccessSectionsCategory($nameSingleCode, $nameListCode) - { - $component = ''; - // check if view has category - $otherViews = CFactory::_('Compiler.Builder.Category.Code')->getString("{$nameSingleCode}.views"); - if ($otherViews !== null && $otherViews == $nameListCode) - { - $component .= PHP_EOL . Indent::_(1) - . '
    '; - $component .= PHP_EOL . Indent::_(2) - . ''; - $component .= PHP_EOL . Indent::_(2) - . ''; - $component .= PHP_EOL . Indent::_(2) - . ''; - $component .= PHP_EOL . Indent::_(2) - . ''; - $component .= PHP_EOL . Indent::_(2) - . ''; - $component .= PHP_EOL . Indent::_(1) . "
    "; - } - - return $component; - } - - public function setAccessSectionsJoomlaFields() - { - $component = ''; - // set all the core field permissions - $component .= PHP_EOL . Indent::_(1) . '
    '; - $component .= PHP_EOL . Indent::_(2) - . ''; - $component .= PHP_EOL . Indent::_(2) - . ''; - $component .= PHP_EOL . Indent::_(2) - . ''; - $component .= PHP_EOL . Indent::_(2) - . ''; - $component .= PHP_EOL . Indent::_(2) - . ''; - $component .= PHP_EOL . Indent::_(2) - . ''; - $component .= PHP_EOL . Indent::_(1) . '
    '; - $component .= PHP_EOL . Indent::_(1) . '
    '; - $component .= PHP_EOL . Indent::_(2) - . ''; - $component .= PHP_EOL . Indent::_(2) - . ''; - $component .= PHP_EOL . Indent::_(2) - . ''; - $component .= PHP_EOL . Indent::_(2) - . ''; - $component .= PHP_EOL . Indent::_(1) . '
    '; - - return $component; - } - - public function setAccessSections() - { - // access size counter - CFactory::_('Utilities.Counter')->accessSize = 12; // ;) - - // Get the default fields - $default_fields = CFactory::_('Config')->default_fields; - - // for plugin event TODO change event api signatures - $component_context = CFactory::_('Config')->component_context; - // Trigger Event: jcb_ce_onBeforeBuildAccessSections - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeBuildAccessSections', - array(&$component_context, &$this) - ); - CFactory::_('Compiler.Builder.Permission.Component')->add('->HEAD<-', [ - 'name' => 'core.admin', - 'title' => 'JACTION_ADMIN', - 'description' => 'JACTION_ADMIN_COMPONENT_DESC' - ], true); - CFactory::_('Compiler.Builder.Permission.Component')->add('->HEAD<-', [ - 'name' => 'core.options', - 'title' => 'JACTION_OPTIONS', - 'description' => 'JACTION_OPTIONS_COMPONENT_DESC' - ], true); - CFactory::_('Compiler.Builder.Permission.Component')->add('->HEAD<-', [ - 'name' => 'core.manage', - 'title' => 'JACTION_MANAGE', - 'description' => 'JACTION_MANAGE_COMPONENT_DESC' - ], true); - if (CFactory::_('Config')->get('add_eximport', false)) - { - $exportTitle = $this->langPrefix . '_' - . StringHelper::safe('Export Data', 'U'); - $exportDesc = $this->langPrefix . '_' - . StringHelper::safe('Export Data', 'U') - . '_DESC'; - CFactory::_('Language')->set('bothadmin', $exportTitle, 'Export Data'); - CFactory::_('Language')->set( - 'bothadmin', $exportDesc, - ' Allows users in this group to export data.' - ); - CFactory::_('Compiler.Builder.Permission.Component')->add('->HEAD<-', [ - 'name' => 'core.export', - 'title' => $exportTitle, - 'description' => $exportDesc - ], true); - // the size needs increase - CFactory::_('Utilities.Counter')->accessSize++; - $importTitle = $this->langPrefix . '_' - . StringHelper::safe('Import Data', 'U'); - $importDesc = $this->langPrefix . '_' - . StringHelper::safe('Import Data', 'U') - . '_DESC'; - CFactory::_('Language')->set('bothadmin', $importTitle, 'Import Data'); - CFactory::_('Language')->set( - 'bothadmin', $importDesc, - ' Allows users in this group to import data.' - ); - CFactory::_('Compiler.Builder.Permission.Component')->add('->HEAD<-', [ - 'name' => 'core.import', - 'title' => $importTitle, - 'description' => $importDesc - ], true); - // the size needs increase - CFactory::_('Utilities.Counter')->accessSize++; - } - // version permission - $batchTitle = $this->langPrefix . '_' - . StringHelper::safe('Use Batch', 'U'); - $batchDesc = $this->langPrefix . '_' - . StringHelper::safe('Use Batch', 'U') . '_DESC'; - CFactory::_('Language')->set('bothadmin', $batchTitle, 'Use Batch'); - CFactory::_('Language')->set( - 'bothadmin', $batchDesc, - ' Allows users in this group to use batch copy/update method.' - ); - CFactory::_('Compiler.Builder.Permission.Component')->add('->HEAD<-', [ - 'name' => 'core.batch', - 'title' => $batchTitle, - 'description' => $batchDesc - ], true); - // version permission - $importTitle = $this->langPrefix . '_' - . StringHelper::safe('Edit Versions', 'U'); - $importDesc = $this->langPrefix . '_' - . StringHelper::safe('Edit Versions', 'U') - . '_DESC'; - CFactory::_('Language')->set('bothadmin', $importTitle, 'Edit Version'); - CFactory::_('Language')->set( - 'bothadmin', $importDesc, - ' Allows users in this group to edit versions.' - ); - CFactory::_('Compiler.Builder.Permission.Component')->add('->HEAD<-', [ - 'name' => 'core.version', - 'title' => $importTitle, - 'description' => $importDesc - ], true); - // set the defaults - CFactory::_('Compiler.Builder.Permission.Component')->add('->HEAD<-', [ - 'name' => 'core.create', - 'title' => 'JACTION_CREATE', - 'description' => 'JACTION_CREATE_COMPONENT_DESC' - ], true); - CFactory::_('Compiler.Builder.Permission.Component')->add('->HEAD<-', [ - 'name' => 'core.delete', - 'title' => 'JACTION_DELETE', - 'description' => 'JACTION_DELETE_COMPONENT_DESC' - ], true); - CFactory::_('Compiler.Builder.Permission.Component')->add('->HEAD<-', [ - 'name' => 'core.edit', - 'title' => 'JACTION_EDIT', - 'description' => 'JACTION_EDIT_COMPONENT_DESC' - ], true); - CFactory::_('Compiler.Builder.Permission.Component')->add('->HEAD<-', [ - 'name' => 'core.edit.state', - 'title' => 'JACTION_EDITSTATE', - 'description' => 'JACTION_ACCESS_EDITSTATE_DESC' - ], true); - CFactory::_('Compiler.Builder.Permission.Component')->add('->HEAD<-', [ - 'name' => 'core.edit.own', - 'title' => 'JACTION_EDITOWN', - 'description' => 'JACTION_EDITOWN_COMPONENT_DESC' - ], true); - // set the Joomla fields - if (CFactory::_('Config')->get('set_joomla_fields', false)) - { - CFactory::_('Compiler.Builder.Permission.Component')->add('->HEAD<-', [ - 'name' => 'core.edit.value', - 'title' => 'JACTION_EDITVALUE', - 'description' => 'JACTION_EDITVALUE_COMPONENT_DESC' - ], true); - // the size needs increase - CFactory::_('Utilities.Counter')->accessSize++; - } - // new custom created by permissions - $created_byTitle = $this->langPrefix . '_' - . StringHelper::safe('Edit Created By', 'U'); - $created_byDesc = $this->langPrefix . '_' - . StringHelper::safe('Edit Created By', 'U') - . '_DESC'; - CFactory::_('Language')->set('bothadmin', $created_byTitle, 'Edit Created By'); - CFactory::_('Language')->set( - 'bothadmin', $created_byDesc, - ' Allows users in this group to edit created by.' - ); - CFactory::_('Compiler.Builder.Permission.Component')->add('->HEAD<-', [ - 'name' => 'core.edit.created_by', - 'title' => $created_byTitle, - 'description' => $created_byDesc - ], true); - // new custom created date permissions - $createdTitle = $this->langPrefix . '_' - . StringHelper::safe('Edit Created Date', 'U'); - $createdDesc = $this->langPrefix . '_' - . StringHelper::safe('Edit Created Date', 'U') - . '_DESC'; - CFactory::_('Language')->set('bothadmin', $createdTitle, 'Edit Created Date'); - CFactory::_('Language')->set( - 'bothadmin', $createdDesc, - ' Allows users in this group to edit created date.' - ); - CFactory::_('Compiler.Builder.Permission.Component')->add('->HEAD<-', [ - 'name' => 'core.edit.created', - 'title' => $createdTitle, - 'description' => $createdDesc - ], true); - - // set the menu controller lookup - $menuControllers = ['access', 'submenu', 'dashboard_list', 'dashboard_add']; - // set the custom admin views permissions - if (CFactory::_('Component')->isArray('custom_admin_views')) - { - foreach ( - CFactory::_('Component')->get('custom_admin_views') as $custom_admin_view - ) - { - // new custom permissions to access this view - $customAdminName = $custom_admin_view['settings']->name; - $customAdminCode = $custom_admin_view['settings']->code; - $customAdminTitle = $this->langPrefix . '_' - . StringHelper::safe( - $customAdminName . ' Access', 'U' - ); - $customAdminDesc = $this->langPrefix . '_' - . StringHelper::safe( - $customAdminName . ' Access', 'U' - ) . '_DESC'; - $sortKey = StringHelper::safe( - $customAdminName . ' Access' - ); - CFactory::_('Language')->set( - 'bothadmin', $customAdminTitle, $customAdminName . ' Access' - ); - CFactory::_('Language')->set( - 'bothadmin', $customAdminDesc, - ' Allows the users in this group to access ' - . StringHelper::safe($customAdminName, 'w') - . '.' - ); - CFactory::_('Compiler.Builder.Permission.Component')->set($sortKey, [ - 'name' => "$customAdminCode.access", - 'title' => $customAdminTitle, - 'description' => $customAdminDesc - ]); - // the size needs increase - CFactory::_('Utilities.Counter')->accessSize++; - // add the custom permissions to use the buttons of this view - $this->addCustomButtonPermissions( - $custom_admin_view['settings'], $customAdminName, - $customAdminCode - ); - // add menu controll view that has menus options - foreach ($menuControllers as $menuController) - { - // add menu controll view that has menus options - if (isset($custom_admin_view[$menuController]) - && $custom_admin_view[$menuController]) - { - $targetView_ = 'views.'; - if ($menuController === 'dashboard_add') - { - $targetView_ = 'view.'; - } - // menucontroller - $menucontrollerView['action'] = $targetView_ - . $menuController; - $menucontrollerView['implementation'] = '2'; - if (isset($custom_admin_view['settings']->permissions) - && ArrayHelper::check( - $custom_admin_view['settings']->permissions - )) - { - array_push( - $custom_admin_view['settings']->permissions, - $menucontrollerView - ); - } - else - { - $custom_admin_view['settings']->permissions - = array(); - $custom_admin_view['settings']->permissions[] - = $menucontrollerView; - } - unset($menucontrollerView); - } - } - CFactory::_('Compiler.Creator.Permission')->set( - $custom_admin_view, $customAdminCode, $customAdminCode, - $menuControllers, 'customAdmin' - ); - } - } - // set the site views permissions - if (CFactory::_('Component')->isArray('site_views')) - { - foreach (CFactory::_('Component')->get('site_views') as $site_view) - { - // new custom permissions to access this view - $siteName = $site_view['settings']->name; - $siteCode = $site_view['settings']->code; - $siteTitle = $this->langPrefix . '_' - . StringHelper::safe( - $siteName . ' Access Site', 'U' - ); - $siteDesc = $this->langPrefix . '_' - . StringHelper::safe( - $siteName . ' Access Site', 'U' - ) . '_DESC'; - $sortKey = StringHelper::safe( - $siteName . ' Access Site' - ); - if (isset($site_view['access']) && $site_view['access'] == 1) - { - CFactory::_('Language')->set( - 'bothadmin', $siteTitle, $siteName . ' (Site) Access' - ); - CFactory::_('Language')->set( - 'bothadmin', $siteDesc, - ' Allows the users in this group to access site ' - . StringHelper::safe($siteName, 'w') - . '.' - ); - CFactory::_('Compiler.Builder.Permission.Component')->set($sortKey, [ - 'name' => "site.$siteCode.access", - 'title' => $siteTitle, - 'description' => $siteDesc - ]); - // the size needs increase - CFactory::_('Utilities.Counter')->accessSize++; - // check if this site view requires access rule to default to public - if (isset($site_view['public_access']) - && $site_view['public_access'] == 1) - { - // we use one as public group (TODO we see if we run into any issues) - $this->assetsRules[] = '"site.' . $siteCode - . '.access":{"1":1}'; - } - } - // add the custom permissions to use the buttons of this view - $this->addCustomButtonPermissions( - $site_view['settings'], $siteName, $siteCode - ); - } - } - if (CFactory::_('Component')->isArray('admin_views')) - { - foreach (CFactory::_('Component')->get('admin_views') as $view) - { - // set view name - $nameView = StringHelper::safe( - $view['settings']->name_single - ); - $nameViews = StringHelper::safe( - $view['settings']->name_list - ); - // add custom tab permissions if found - if (($tabs_ = CFactory::_('Compiler.Builder.Custom.Tabs')->get($nameView)) !== null - && ArrayHelper::check($tabs_)) - { - foreach ($tabs_ as $_customTab) - { - if (isset($_customTab['permission']) - && $_customTab['permission'] == 1) - { - CFactory::_('Compiler.Builder.Permission.Component')->set($_customTab['sortKey'], [ - 'name' => $_customTab['view'] . '.' . $_customTab['code'] . '.viewtab', - 'title' => $_customTab['lang_permission'], - 'description' => $_customTab['lang_permission_desc'] - ]); - // the size needs increase - CFactory::_('Utilities.Counter')->accessSize++; - } - } - } - // add the custom permissions to use the buttons of this view - $this->addCustomButtonPermissions( - $view['settings'], $view['settings']->name_single, $nameView - ); - if ($nameView != 'component') - { - // add menu controll view that has menus options - foreach ($menuControllers as $menuController) - { - // add menu controll view that has menus options - if (isset($view[$menuController]) - && $view[$menuController]) - { - $targetView_ = 'views.'; - if ($menuController === 'dashboard_add') - { - $targetView_ = 'view.'; - } - // menucontroller - $menucontrollerView['action'] = $targetView_ . $menuController; - $menucontrollerView['implementation'] = '2'; - if (isset($view['settings']->permissions) - && ArrayHelper::check( - $view['settings']->permissions - )) - { - array_push( - $view['settings']->permissions, - $menucontrollerView - ); - } - else - { - $view['settings']->permissions = array(); - $view['settings']->permissions[] = $menucontrollerView; - } - unset($menucontrollerView); - } - } - // check if there are fields - if (ArrayHelper::check( - $view['settings']->fields - )) - { - // field permission options - $permission_options = array(1 => 'edit', 2 => 'access', 3 => 'view'); - // check the fields for their permission settings - foreach ($view['settings']->fields as $field) - { - // see if field require permissions to be set - if (isset($field['permission']) - && ArrayHelper::check( - $field['permission'] - )) - { - if (ArrayHelper::check( - $field['settings']->properties - )) - { - $fieldType = CFactory::_('Field.Type.Name')->get($field); - $fieldName = CFactory::_('Field.Name')->get( - $field, $nameViews - ); - // loop the permission options - foreach ($field['permission'] as $permission_id) - { - // set the permission key word - $permission_option = $permission_options[(int) $permission_id]; - // reset the bucket - $fieldView = array(); - // set the permission for this field - $fieldView['action'] = 'view.' . $permission_option . '.' . $fieldName; - $fieldView['implementation'] = '3'; - // check if persmissions was already set - if (isset($view['settings']->permissions) - && ArrayHelper::check( - $view['settings']->permissions - )) - { - array_push( - $view['settings']->permissions, - $fieldView - ); - } - else - { - $view['settings']->permissions = array(); - $view['settings']->permissions[] - = $fieldView; - } - // ensure that no default field get loaded - if (!in_array( - $fieldName, $default_fields - )) - { - // make sure the array is set - if (!isset($this->permissionFields[$nameView]) - || !ArrayHelper::check( - $this->permissionFields[$nameView] - )) - { - $this->permissionFields[$nameView] - = array(); - } - if (!isset($this->permissionFields[$nameView][$fieldName]) - || !ArrayHelper::check( - $this->permissionFields[$nameView][$fieldName] - )) - { - $this->permissionFields[$nameView][$fieldName] - = array(); - } - // load to global field permission set - $this->permissionFields[$nameView][$fieldName][$permission_option] - = $fieldType; - } - } - } - } - } - } - CFactory::_('Compiler.Creator.Permission')->set( - $view, $nameView, $nameViews, $menuControllers - ); - } - } - - // Trigger Event: jcb_ce_onAfterBuildAccessSections - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterBuildAccessSections', - array(&$component_context, &$this) - ); - - /// now build the section - $component = CFactory::_('Compiler.Builder.Permission.Component')->build(); - // add views to the component section - $component .= CFactory::_('Compiler.Builder.Permission.Views')->build(); - - // remove the fix, is not needed - if (CFactory::_('Utilities.Counter')->accessSize < 30) - { - // since we have less than 30 actions - // we do not need the fix for this component - $this->addAssetsTableFix = 0; - CFactory::_('Config')->set('add_assets_table_fix', $this->addAssetsTableFix); - } - else - { - // get the worst case column size required (can be worse I know) - // access/action size x 20 characters x 8 groups - $character_length = (int) MathHelper::bc( - 'mul', CFactory::_('Utilities.Counter')->accessSize, 20, 0 - ); - // set worse case - CFactory::_('Config')->set('access_worse_case', (int) MathHelper::bc( - 'mul', $character_length, 8, 0 - )); - } - - // return the build - return $component; - } - - return false; - } - - protected function addCustomButtonPermissions($settings, $nameView, $code) - { - // add the custom permissions to use the buttons of this view - if (isset($settings->custom_buttons) - && ArrayHelper::check($settings->custom_buttons)) - { - foreach ($settings->custom_buttons as $custom_buttons) - { - $customButtonName = $custom_buttons['name']; - $customButtonCode = StringHelper::safe( - $customButtonName - ); - $customButtonTitle = $this->langPrefix . '_' - . StringHelper::safe( - $nameView . ' ' . $customButtonName . ' Button Access', - 'U' - ); - $customButtonDesc = $this->langPrefix . '_' - . StringHelper::safe( - $nameView . ' ' . $customButtonName . ' Button Access', - 'U' - ) . '_DESC'; - $sortButtonKey = StringHelper::safe( - $nameView . ' ' . $customButtonName . ' Button Access' - ); - CFactory::_('Language')->set( - 'bothadmin', $customButtonTitle, - $nameView . ' ' . $customButtonName . ' Button Access' - ); - CFactory::_('Language')->set( - 'bothadmin', $customButtonDesc, - ' Allows the users in this group to access the ' - . StringHelper::safe($customButtonName, 'w') - . ' button.' - ); - CFactory::_('Compiler.Builder.Permission.Component')->set($sortButtonKey, [ - 'name' => "$code.$customButtonCode", - 'title' => $customButtonTitle, - 'description' => $customButtonDesc - ]); - // the size needs increase - CFactory::_('Utilities.Counter')->accessSize++; - } - } - } - - /** - * Set the permissions - * - * @param array $view View details - * @param string $nameView View Single Code Name - * @param string $nameViews View List Code Name - * @param array $menuControllers Menu Controllers - * @param string $type Type of permissions area - * - * @return void - * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Permission')->set($view, $nameView, $nameViews, $menuControllers, $type); - */ - public function buildPermissions(&$view, $nameView, $nameViews, $menuControllers, $type = 'admin' - ) - { - CFactory::_('Compiler.Creator.Permission')->set($view, $nameView, $nameViews, $menuControllers, $type); - } - - public function getInbetweenStrings($str, $start = '#' . '#' . '#', - $end = '#' . '#' . '#' - ) - { - $matches = array(); - $regex = "/$start([a-zA-Z0-9_]*)$end/"; - preg_match_all($regex, (string) $str, $matches); - - return $matches[1]; - } - - public function getModCode(&$module) - { - // get component helper string - $Helper = CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper'; - $component = CFactory::_('Compiler.Builder.Content.One')->get('component'); - $_helper = ''; - // get libraries code - $libraries = array(Placefix::_('MOD_LIBRARIES') => $this->getModLibCode($module)); - $code = CFactory::_('Placeholder')->update($module->mod_code, $libraries); - // check if component helper class should be added - if (strpos((string) $code, $Helper . '::') !== false - && strpos( - (string) $code, - "/components/com_" . $component . "/helpers/" . $component - . ".php" - ) === false) - { - $_helper = '//' . Line::_(__Line__, __Class__) - . ' Include the component helper functions only once'; - $_helper .= PHP_EOL . "JLoader::register('" . $Helper - . "', JPATH_ADMINISTRATOR . '/components/com_" . $component - . "/helpers/" . $component . ".php');"; - } - - return CFactory::_('Placeholder')->update($_helper . PHP_EOL . $code . PHP_EOL, CFactory::_('Compiler.Builder.Content.One')->allActive()); - } - - public function getModDefault(&$module, &$key) - { - // first add the header - $default = PHP_EOL . $module->default_header . PHP_EOL . '?>'; - // add any css from the fields - $default .= CFactory::_('Customcode.Dispenser')->get( - 'css_views', $key, PHP_EOL . '' . PHP_EOL - ); - // now add the body - $default .= PHP_EOL . $module->default . PHP_EOL; - // add any JavaScript from the fields - $default .= CFactory::_('Customcode.Dispenser')->get( - 'views_footer', $key, - PHP_EOL . '' . PHP_EOL - ); - - // return the default content for the model default area - return CFactory::_('Placeholder')->update($default, CFactory::_('Compiler.Builder.Content.One')->allActive()); - } - - public function setModTemplates(&$module) - { - if (($data_ = CFactory::_('Compiler.Builder.Template.Data')-> - get(CFactory::_('Config')->build_target . '.' . $module->code_name)) !== null) - { - foreach ($data_ as $template => $data) - { - $header = $data['php_view'] ?? ''; - $body = $data['html'] ?? ''; - $default = PHP_EOL . $header . PHP_EOL . '?>'; - $default .= PHP_EOL . $body; - $TARGET = StringHelper::safe("MODDEFAULT_{$template}", 'U'); - CFactory::_('Compiler.Builder.Content.Multi')->set($module->key . '|' . $TARGET, - CFactory::_('Placeholder')->update( - $default, CFactory::_('Compiler.Builder.Content.One')->allActive() - ) - ); - } - } - } - - public function getModHelperCode(&$module) - { - return - CFactory::_('Placeholder')->update($module->class_helper_header . PHP_EOL . - $module->class_helper_type . $module->class_helper_name . PHP_EOL - . '{' . PHP_EOL . - $module->class_helper_code . PHP_EOL . - "}" . PHP_EOL, CFactory::_('Compiler.Builder.Content.One')->allActive()); - } - - public function getModLibCode(&$module) - { - $setter = ''; - if (($data_ = CFactory::_('Compiler.Builder.Library.Manager')-> - get($module->key . '.' . $module->code_name)) !== null) - { - $setter .= '//' . Line::_(__Line__, __Class__) - . 'get the document object'; - $setter .= PHP_EOL . '$document = JFactory::getDocument();'; - foreach ($data_ as $id => $true) - { - // get the library - $library = CFactory::_('Registry')->get("builder.libraries.$id", null); - if (is_object($library) - && isset($library->document) - && StringHelper::check( - $library->document - )) - { - $setter .= PHP_EOL . $library->document; - } - elseif (is_object($library) - && isset($library->how)) - { - $setter .= $this->setLibraryDocument($id); - } - } - } - // check if we have string - if (StringHelper::check($setter)) - { - return CFactory::_('Placeholder')->update( CFactory::_('Placeholder')->update_( - str_replace( - '$this->document->', '$document->', - implode( - PHP_EOL, - array_map( - 'trim', - (array) explode(PHP_EOL, $setter) - ) - ) - ) - ), CFactory::_('Compiler.Builder.Content.One')->allActive()); - } - - return ''; - } - - public function getModuleMainXML(&$module) - { - // set the custom table key - $dbkey = 'yyy'; - // build the xml - $xml = ''; - // search if we must add the component path - $add_component_path = false; - // build the config fields - $config_fields = array(); - if (isset($module->config_fields) - && ArrayHelper::check( - $module->config_fields - )) - { - $add_scripts_field = true; - foreach ($module->config_fields as $field_name => $fieldsets) - { - foreach ($fieldsets as $fieldset => $fields) - { - // get the field set - $xmlFields = $this->getExtensionFieldsetXML( - $module, $fields, $dbkey - ); - // check if the custom script field must be set - if ($add_scripts_field && $module->add_scripts_field) - { - // get the custom script field - $xmlFields .= PHP_EOL . Indent::_(2) - . ""; - // don't add it again - $add_scripts_field = false; - } - // make sure the xml is set and a string - if (isset($xmlFields) - && StringHelper::check($xmlFields)) - { - $config_fields[$field_name . $fieldset] = $xmlFields; - } - $dbkey++; - // check if the fieldset path requiers component paths - if (!$add_component_path - && isset( - $module->fieldsets_paths[$field_name . $fieldset] - ) - && $module->fieldsets_paths[$field_name . $fieldset] - == 1) - { - $add_component_path = true; - } - } - } - } - // switch to add the language xml - $addLang = array(); - // now build the language files - if (CFactory::_('Language')->exist($module->key)) - { - // for plugin event TODO change event api signatures - $langContent = CFactory::_('Language')->getTarget($module->key); - // Trigger Event: jcb_ce_onBeforeBuildModuleLang - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeBuildModuleLang', - array(&$component_context, &$module, - &$langContent, &$module->lang_prefix, &$module->official_name) - ); - // get other languages - $values = array_unique($langContent); - // get the other lang strings if there is any - $this->multiLangString = $this->getMultiLangStrings($values); - // start the modules language bucket (must rest every time) - $this->languages['modules'] = array(); - $this->languages['modules'][CFactory::_('Config')->get('lang_tag', 'en-GB')] = array(); - $this->languages['modules'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['all'] - = $langContent; - CFactory::_('Language')->setTarget($module->key, null); - // update insert the current lang in to DB - $this->setLangPlaceholders($values, $module->id, 'modules'); - // remove old unused language strings - $this->purgeLanuageStrings($values, $module->id, 'modules'); - $total = count($values); - unset($values); - // for plugin event TODO change event api signatures - $component_context = CFactory::_('Config')->component_context; - // Trigger Event: jcb_ce_onBeforeBuildModuleLangFiles - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeBuildModuleLangFiles', - array(&$component_context, &$module, - &$this->languages['modules'], - &$this->langTag) - ); - // for plugin event TODO change event api signatures - CFactory::_('Config')->lang_tag = $this->langTag; - // now we insert the values into the files - if (ArrayHelper::check($this->languages['modules'])) - { - foreach ($this->languages['modules'] as $tag => $areas) - { - // trim the tag - $tag = trim($tag); - foreach ($areas as $area => $languageStrings) - { - $file_name = $tag . '.' . $module->file_name . '.ini'; - // check if language should be added - if ($this->shouldLanguageBeAdded( - $tag, $languageStrings, $total, - $file_name - )) - { - $lang = array_map( - fn($langstring, $placeholder) => $placeholder . '="' . $langstring . '"', - array_values($languageStrings), - array_keys($languageStrings) - ); - // set path - $path = $module->folder_path . '/language/' . $tag . '/'; - // create path if not exist - if (!Folder::exists($path)) - { - Folder::create($path); - // count the folder created - CFactory::_('Utilities.Counter')->folder++; - } - // add to language files (for now we add all to both TODO) - CFactory::_('Utilities.File')->write( - $path . $file_name, - implode(PHP_EOL, $lang) - ); - CFactory::_('Utilities.File')->write( - $path . $tag . '.' . $module->file_name - . '.sys.ini', - implode(PHP_EOL, $lang) - ); - // set the line counter - CFactory::_('Utilities.Counter')->line += count( - (array) $lang - ); - unset($lang); - // trigger to add language - $addLang[$tag] = $tag; - } - } - } - } - } - // get all files and folders in module folder - $files = Folder::files($module->folder_path); - $folders = Folder::folders($module->folder_path); - // the files/folders to ignore - $ignore = array('sql', 'language', 'script.php', - $module->file_name . '.xml', - $module->file_name . '.php'); - // should the scriptfile be added - if ($module->add_install_script) - { - $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(1) - . 'script.php'; - } - // should the sql install be added - if ($module->add_sql) - { - $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(2) . ''; - $xml .= PHP_EOL . Indent::_(3) - . 'sql/mysql/install.sql'; - $xml .= PHP_EOL . Indent::_(2) . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - } - // should the sql uninstall be added - if ($module->add_sql_uninstall) - { - $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(2) . ''; - $xml .= PHP_EOL . Indent::_(3) - . 'sql/mysql/uninstall.sql'; - $xml .= PHP_EOL . Indent::_(2) . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - } - // should the language xml be added - if (ArrayHelper::check($addLang)) - { - $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(1) - . ''; - // load all the language files to xml - foreach ($addLang as $addTag) - { - $xml .= PHP_EOL . Indent::_(2) . '' . $addTag . '/' . $addTag . '.' - . $module->file_name . '.ini'; - $xml .= PHP_EOL . Indent::_(2) . '' . $addTag . '/' . $addTag . '.' - . $module->file_name . '.sys.ini'; - } - $xml .= PHP_EOL . Indent::_(1) . ''; - } - // add the module files - $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(2) . '' . $module->file_name - . '.php'; - // add other files found - if (ArrayHelper::check($files)) - { - foreach ($files as $file) - { - // only add what is not ignored - if (!in_array($file, $ignore)) - { - $xml .= PHP_EOL . Indent::_(2) . '' . $file - . ''; - } - } - } - // add language folder - if (ArrayHelper::check($addLang)) - { - $xml .= PHP_EOL . Indent::_(2) . 'language'; - } - // add sql folder - if ($module->add_sql || $module->add_sql_uninstall) - { - $xml .= PHP_EOL . Indent::_(2) . 'sql'; - } - // add other files found - if (ArrayHelper::check($folders)) - { - foreach ($folders as $folder) - { - // only add what is not ignored - if (!in_array($folder, $ignore)) - { - $xml .= PHP_EOL . Indent::_(2) . '' . $folder - . ''; - } - } - } - $xml .= PHP_EOL . Indent::_(1) . ''; - // now add the Config Params if needed - if (ArrayHelper::check($config_fields)) - { - $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; - // only add if part of the component field types path is required - if ($add_component_path) - { - // add path to module rules and custom fields - $xml .= PHP_EOL . Indent::_(1) . ''; - } - else - { - $xml .= PHP_EOL . Indent::_(1) . ''; - } - // add the fields - foreach ($module->config_fields as $field_name => $fieldsets) - { - $xml .= PHP_EOL . Indent::_(1) . ''; - foreach ($fieldsets as $fieldset => $fields) - { - // default to the field set name - $label = $fieldset; - if (isset($module->fieldsets_label[$field_name . $fieldset])) - { - $label = $module->fieldsets_label[$field_name . $fieldset]; - } - // add path to module rules and custom fields - if (isset($module->fieldsets_paths[$field_name . $fieldset]) - && ($module->fieldsets_paths[$field_name . $fieldset] == 2 - || $module->fieldsets_paths[$field_name . $fieldset] == 3)) - { - if ($module->target == 2) - { - if (!isset($module->add_rule_path[$field_name . $fieldset])) - { - $module->add_rule_path[$field_name . $fieldset] = - '/administrator/modules/' - . $module->file_name . '/rules'; - } - - if (!isset($module->add_field_path[$field_name . $fieldset])) - { - $module->add_field_path[$field_name . $fieldset] = - '/administrator/modules/' - . $module->file_name . '/fields'; - } - } - else - { - if (!isset($module->add_rule_path[$field_name . $fieldset])) - { - $module->add_rule_path[$field_name . $fieldset] = - '/modules/' . $module->file_name - . '/rules'; - } - - if (!isset($module->add_field_path[$field_name . $fieldset])) - { - $module->add_field_path[$field_name . $fieldset] = - '/modules/' . $module->file_name - . '/fields'; - } - } - } - // add path to module rules and custom fields - if (isset($module->add_rule_path[$field_name . $fieldset]) - || isset($module->add_field_path[$field_name . $fieldset])) - { - - $xml .= PHP_EOL . Indent::_(1) . ''; - - $xml .= PHP_EOL . Indent::_(1) . '
    add_rule_path[$field_name . $fieldset])) - { - $xml .= PHP_EOL . Indent::_(2) - . 'addrulepath="' . $module->add_rule_path[$field_name . $fieldset] . '"'; - } - - if (isset($module->add_field_path[$field_name . $fieldset])) - { - $xml .= PHP_EOL . Indent::_(2) - . 'addfieldpath="' . $module->add_field_path[$field_name . $fieldset] . '"'; - } - - $xml .= PHP_EOL . Indent::_(1) . '>'; - } - else - { - $xml .= PHP_EOL . Indent::_(1) . '
    '; - } - // load the fields - if (isset($config_fields[$field_name . $fieldset])) - { - $xml .= $config_fields[$field_name . $fieldset]; - unset($config_fields[$field_name . $fieldset]); - } - $xml .= PHP_EOL . Indent::_(1) . '
    '; - } - $xml .= PHP_EOL . Indent::_(1) . ''; - } - $xml .= PHP_EOL . Indent::_(1) . ''; - } - // set update server if found - if ($module->add_update_server) - { - $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(2) - . '' . $module->update_server_url - . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - } - - return $xml; - } - - public function getPluginMainClass(&$plugin) - { - return CFactory::_('Placeholder')->update( - PHP_EOL . $plugin->head . PHP_EOL . - $plugin->comment . PHP_EOL . 'class ' . - $plugin->class_name . ' extends ' . - $plugin->extends . PHP_EOL . '{' . PHP_EOL . - $plugin->main_class_code . PHP_EOL . - "}" . PHP_EOL, - CFactory::_('Compiler.Builder.Content.One')->allActive() - ); - } - - public function getPluginMainXML(&$plugin) - { - // set the custom table key - $dbkey = 'yy'; - // build the xml - $xml = ''; - // search if we must add the component path - $add_component_path = false; - // build the config fields - $config_fields = array(); - if (isset($plugin->config_fields) - && ArrayHelper::check( - $plugin->config_fields - )) - { - foreach ($plugin->config_fields as $field_name => $fieldsets) - { - foreach ($fieldsets as $fieldset => $fields) - { - // get the field set - $xmlFields = $this->getExtensionFieldsetXML( - $plugin, $fields, $dbkey - ); - // make sure the xml is set and a string - if (isset($xmlFields) - && StringHelper::check($xmlFields)) - { - $config_fields[$field_name . $fieldset] = $xmlFields; - } - $dbkey++; - // check if the fieldset path requiers component paths - if (!$add_component_path - && isset( - $plugin->fieldsets_paths[$field_name . $fieldset] - ) - && $plugin->fieldsets_paths[$field_name . $fieldset] - == 1) - { - $add_component_path = true; - } - } - } - } - // switch to add the language xml - $addLang = array(); - // now build the language files - if (CFactory::_('Language')->exist($plugin->key)) - { - // for plugin event TODO change event api signatures - $langContent = CFactory::_('Language')->getTarget($plugin->key); - $component_context = CFactory::_('Config')->component_context; - // Trigger Event: jcb_ce_onBeforeBuildPluginLang - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeBuildPluginLang', - array(&$component_context, &$plugin, - &$langContent, - &$plugin->lang_prefix, &$plugin->official_name) - ); - // get other languages - $values = array_unique($langContent); - // get the other lang strings if there is any - $this->multiLangString = $this->getMultiLangStrings($values); - // start the plugins language bucket (must rest every time) - $this->languages['plugins'] = array(); - $this->languages['plugins'][CFactory::_('Config')->get('lang_tag', 'en-GB')] = array(); - $this->languages['plugins'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['all'] - = $langContent; - CFactory::_('Language')->setTarget($plugin->key, null); - // update insert the current lang in to DB - $this->setLangPlaceholders($values, $plugin->id, 'plugins'); - // remove old unused language strings - $this->purgeLanuageStrings($values, $plugin->id, 'plugins'); - $total = count($values); - unset($values); - // Trigger Event: jcb_ce_onBeforeBuildPluginLangFiles - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeBuildPluginLangFiles', - array(&$component_context, &$plugin, - &$this->languages['plugins'], - &$this->langTag) - ); - // for plugin event TODO change event api signatures - CFactory::_('Config')->lang_tag = $this->langTag; - // now we insert the values into the files - if (ArrayHelper::check($this->languages['plugins'])) - { - foreach ($this->languages['plugins'] as $tag => $areas) - { - // trim the tag - $tag = trim($tag); - foreach ($areas as $area => $languageStrings) - { - $file_name = $tag . '.plg_' . strtolower((string) $plugin->group) - . '_' - . strtolower((string) $plugin->code_name) . '.ini'; - // check if language should be added - if ($this->shouldLanguageBeAdded( - $tag, $languageStrings, $total, - $file_name - )) - { - $lang = array_map( - fn($langstring, $placeholder) => $placeholder . '="' . $langstring . '"', - array_values($languageStrings), - array_keys($languageStrings) - ); - // set path - $path = $plugin->folder_path . '/language/' . $tag - . '/'; - // create path if not exist - if (!Folder::exists($path)) - { - Folder::create($path); - // count the folder created - CFactory::_('Utilities.Counter')->folder++; - } - // add to language file - CFactory::_('Utilities.File')->write( - $path . $file_name, - implode(PHP_EOL, $lang) - ); - CFactory::_('Utilities.File')->write( - $path . $tag . '.plg_' . strtolower( - (string) $plugin->group - ) - . '_' - . strtolower((string) $plugin->code_name) . '.sys.ini', - implode(PHP_EOL, $lang) - ); - // set the line counter - CFactory::_('Utilities.Counter')->line += count( - (array) $lang - ); - unset($lang); - // trigger to add language - $addLang[$tag] = $tag; - } - } - } - } - } - // get all files and folders in plugin folder - $files = Folder::files($plugin->folder_path); - $folders = Folder::folders($plugin->folder_path); - // the files/folders to ignore - $ignore = array('sql', 'language', 'script.php', - $plugin->file_name . '.xml', - $plugin->file_name . '.php'); - // should the scriptfile be added - if ($plugin->add_install_script) - { - $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(1) - . 'script.php'; - } - // should the sql install be added - if ($plugin->add_sql) - { - $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(2) . ''; - $xml .= PHP_EOL . Indent::_(3) - . 'sql/mysql/install.sql'; - $xml .= PHP_EOL . Indent::_(2) . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - } - // should the sql uninstall be added - if ($plugin->add_sql_uninstall) - { - $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(2) . ''; - $xml .= PHP_EOL . Indent::_(3) - . 'sql/mysql/uninstall.sql'; - $xml .= PHP_EOL . Indent::_(2) . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - } - // should the language xml be added - if (ArrayHelper::check($addLang)) - { - $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - // load all the language files to xml - foreach ($addLang as $addTag) - { - $xml .= PHP_EOL . Indent::_(2) . '' . $addTag . '/' . $addTag . '.plg_' - . strtolower((string) $plugin->group) . '_' . strtolower( - (string) $plugin->code_name - ) . '.ini'; - $xml .= PHP_EOL . Indent::_(2) . '' . $addTag . '/' . $addTag . '.plg_' - . strtolower((string) $plugin->group) . '_' . strtolower( - (string) $plugin->code_name - ) . '.sys.ini'; - } - $xml .= PHP_EOL . Indent::_(1) . ''; - } - // add the plugin files - $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(2) . '' . $plugin->file_name - . '.php'; - // add other files found - if (ArrayHelper::check($files)) - { - foreach ($files as $file) - { - // only add what is not ignored - if (!in_array($file, $ignore)) - { - $xml .= PHP_EOL . Indent::_(2) . '' . $file - . ''; - } - } - } - // add language folder - if (ArrayHelper::check($addLang)) - { - $xml .= PHP_EOL . Indent::_(2) . 'language'; - } - // add sql folder - if ($plugin->add_sql || $plugin->add_sql_uninstall) - { - $xml .= PHP_EOL . Indent::_(2) . 'sql'; - } - // add other files found - if (ArrayHelper::check($folders)) - { - foreach ($folders as $folder) - { - // only add what is not ignored - if (!in_array($folder, $ignore)) - { - $xml .= PHP_EOL . Indent::_(2) . '' . $folder - . ''; - } - } - } - $xml .= PHP_EOL . Indent::_(1) . ''; - // now add the Config Params if needed - if (ArrayHelper::check($config_fields)) - { - $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; - // only add if part of the component field types path is required - if ($add_component_path) - { - // add path to plugin rules and custom fields - $xml .= PHP_EOL . Indent::_(1) . ''; - } - else - { - $xml .= PHP_EOL . Indent::_(1) . ''; - } - // add the fields - foreach ($plugin->config_fields as $field_name => $fieldsets) - { - $xml .= PHP_EOL . Indent::_(1) . ''; - foreach ($fieldsets as $fieldset => $fields) - { - // default to the field set name - $label = $fieldset; - if (isset($plugin->fieldsets_label[$field_name . $fieldset])) - { - $label = $plugin->fieldsets_label[$field_name . $fieldset]; - } - // add path to plugin rules and custom fields - if (isset($plugin->fieldsets_paths[$field_name . $fieldset]) - && ($plugin->fieldsets_paths[$field_name . $fieldset] == 2 - || $plugin->fieldsets_paths[$field_name . $fieldset] == 3)) - { - if (!isset($plugin->add_rule_path[$field_name . $fieldset])) - { - $plugin->add_rule_path[$field_name . $fieldset] = - '/plugins/' . strtolower((string) $plugin->group - ) . '/' . strtolower((string) $plugin->code_name) - . '/rules'; - } - - if (!isset($plugin->add_field_path[$field_name . $fieldset])) - { - $plugin->add_field_path[$field_name . $fieldset] = - '/plugins/' . strtolower((string) $plugin->group - ) . '/' . strtolower((string) $plugin->code_name) - . '/fields'; - } - } - // add path to plugin rules and custom fields - if (isset($plugin->add_rule_path[$field_name . $fieldset]) - || isset($plugin->add_field_path[$field_name . $fieldset])) - { - $xml .= PHP_EOL . Indent::_(1) . ''; - - $xml .= PHP_EOL . Indent::_(1) . '
    add_rule_path[$field_name . $fieldset])) - { - $xml .= PHP_EOL . Indent::_(2) - . 'addrulepath="' . $plugin->add_rule_path[$field_name . $fieldset] . '"'; - } - - if (isset($plugin->add_field_path[$field_name . $fieldset])) - { - $xml .= PHP_EOL . Indent::_(2) - . 'addfieldpath="' . $plugin->add_field_path[$field_name . $fieldset] . '"'; - } - - $xml .= PHP_EOL . Indent::_(1) . '>'; - } - else - { - $xml .= PHP_EOL . Indent::_(1) . '
    '; - } - // load the fields - if (isset($config_fields[$field_name . $fieldset])) - { - $xml .= $config_fields[$field_name . $fieldset]; - unset($config_fields[$field_name . $fieldset]); - } - $xml .= PHP_EOL . Indent::_(1) . '
    '; - } - $xml .= PHP_EOL . Indent::_(1) . ''; - } - $xml .= PHP_EOL . Indent::_(1) . ''; - } - // set update server if found - if ($plugin->add_update_server) - { - $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - $xml .= PHP_EOL . Indent::_(2) - . '' . $plugin->update_server_url - . ''; - $xml .= PHP_EOL . Indent::_(1) . ''; - } - - return $xml; - } - - public function getPowerCode(&$power) - { - $code = array(); - // set the name space - $code[] = 'namespace ' . $power->_namespace . ';' . PHP_EOL; - // check if we have header data - if (StringHelper::check($power->head)) - { - $code[] = PHP_EOL . $power->head; - } - // add description if set - if (StringHelper::check($power->description)) - { - // check if this is escaped - if (strpos((string) $power->description, '/*') === false) - { - // make this description escaped - $power->description = '/**' . PHP_EOL . ' * ' . implode(PHP_EOL . ' * ', explode(PHP_EOL, (string) $power->description)) . PHP_EOL . ' */'; - } - $code[] = PHP_EOL . $power->description; - } - // build power declaration - $declaration = $power->type . ' ' . $power->class_name; - // check if we have extends - if (StringHelper::check($power->extends_name)) - { - $declaration .= ' extends ' . $power->extends_name; - } - // check if we have implements - if (ArrayHelper::check($power->implement_names)) - { - $declaration .= ' implements ' . implode(', ', $power->implement_names); - } - $code[] = $declaration; - $code[] = '{'; - // add the main code if set - if (StringHelper::check($power->main_class_code)) - { - $code[] = $power->main_class_code; - } - $code[] = '}' . PHP_EOL . PHP_EOL; - - return CFactory::_('Placeholder')->update(implode(PHP_EOL, $code), CFactory::_('Compiler.Builder.Content.One')->allActive()); - } - - /** - * build field set for an extention - * - * @param object $extension The extention object - * @param array $fields The fields to build - * @param string $dbkey The database key - * - * @return string The fields set in xml - * - */ - public function getExtensionFieldsetXML(&$extension, &$fields, $dbkey = 'zz') - { - // get global placeholders - $placeholder = CFactory::_('Component.Placeholder')->get(); - // build the fieldset - return CFactory::_('Compiler.Creator.Fieldset.Dynamic')->get( - $fields, $extension->lang_prefix, $extension->key, $extension->key, - $placeholder, $dbkey - ); - } - - /** - * check if a translation should be added - * - * @return bool - * - */ - public function shouldLanguageBeAdded(&$tag, &$languageStrings, &$total, &$file_name) - { - // only log messages for none CFactory::_('Config')->get('lang_tag', 'en-GB') translations - if (CFactory::_('Config')->get('lang_tag', 'en-GB') !== $tag) - { - $langStringNr = count($languageStrings); - $langStringSum = MathHelper::bc( - 'mul', $langStringNr, 100 - ); - $percentage = MathHelper::bc( - 'div', $langStringSum, $total - ); - $stringNAme = ($langStringNr == 1) ? '(string ' - . $tag . ' translated)' - : '(strings ' . $tag . ' translated)'; - // force load if debug lines are added - if (!CFactory::_('Config')->get('debug_line_nr', false)) - { - // check if we should install this translation - if ($percentage < $this->percentageLanguageAdd) - { - // dont add - $this->langNot[$file_name] = '' - . $total . '(total ' - . CFactory::_('Config')->get('lang_tag', 'en-GB') . ' strings) only ' - . $langStringNr . '' . $stringNAme - . ' = ' . $percentage; - - return false; - } - } - // show if it was added as well - $this->langSet[$file_name] = '' - . $total . '(total ' - . CFactory::_('Config')->get('lang_tag', 'en-GB') . ' strings) and ' - . $langStringNr . '' . $stringNAme . ' = ' - . $percentage; - } - - return true; - } - -} diff --git a/admin/helpers/compiler/f_Infusion.php b/admin/helpers/compiler/f_Infusion.php deleted file mode 100644 index 11088496d..000000000 --- a/admin/helpers/compiler/f_Infusion.php +++ /dev/null @@ -1,2235 +0,0 @@ - - * @gitea Joomla Component Builder - * @github Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Filesystem\File; -use Joomla\CMS\Filesystem\Folder; -use VDM\Joomla\Utilities\StringHelper; -use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\ObjectHelper; -use VDM\Joomla\Utilities\FileHelper; -use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Minify; - -/** - * Infusion class - * @deprecated 3.3 - */ -class Infusion extends Interpretation -{ - - public $langFiles = array(); - - /** - * Switch to remove site folder - * - * @var bool - * @deprecated 3.3 Use CFactory::_('Config')->remove_site_folder; - */ - public $removeSiteFolder = false; - - /** - * Switch to remove site edit folder - * - * @var bool - * @deprecated 3.3 Use CFactory::_('Config')->remove_site_edit_folder; - */ - public $removeSiteEditFolder = true; - - /** - * Constructor - */ - public function __construct() - { - // first we run the perent constructor - if (parent::__construct()) - { - // infuse the data into the structure - return $this->buildFileContent(); - } - - return false; - } - - /** - * Build the content for the structure - * - * - * @return boolean on success - * - */ - protected function buildFileContent() - { - if (CFactory::_('Component')->isArray('admin_views')) - { - // for plugin event TODO change event api signatures - $placeholders = CFactory::_('Placeholder')->active; - $fileContentStatic = CFactory::_('Compiler.Builder.Content.One')->allActive(); - $fileContentDynamic = CFactory::_('Compiler.Builder.Content.Multi')->allActive(); - $component_context = CFactory::_('Config')->component_context; - // Trigger Event: jcb_ce_onBeforeBuildFilesContent - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeBuildFilesContent', - array(&$component_context, &$this->componentData, - &$fileContentStatic, &$fileContentDynamic, - &$placeholders, &$this->hhh) - ); - unset($fileContentStatic); - unset($fileContentDynamic); - unset($placeholders); - - // COMPONENT - CFactory::_('Compiler.Builder.Content.One')->set('COMPONENT', CFactory::_('Placeholder')->get('COMPONENT')); - - // Component - CFactory::_('Compiler.Builder.Content.One')->set('Component', CFactory::_('Placeholder')->get('Component')); - - // component - CFactory::_('Compiler.Builder.Content.One')->set('component', CFactory::_('Placeholder')->get('component')); - - // COMPANYNAME - $companyname = CFactory::_('Component')->get('companyname'); - CFactory::_('Compiler.Builder.Content.One')->set('COMPANYNAME', trim( - (string) JFilterOutput::cleanText($companyname) - )); - - // CREATIONDATE - CFactory::_('Compiler.Builder.Content.One')->set('CREATIONDATE', - JFactory::getDate(CFactory::_('Component')->get('created'))->format( - 'jS F, Y' - )); - CFactory::_('Compiler.Builder.Content.One')->set('GLOBALCREATIONDATE', - CFactory::_('Compiler.Builder.Content.One')->get('CREATIONDATE')); - - // BUILDDATE - CFactory::_('Compiler.Builder.Content.One')->set('BUILDDATE', JFactory::getDate( - CFactory::_('Config')->get('build_date', 'now'))->format('jS F, Y')); - CFactory::_('Compiler.Builder.Content.One')->set('GLOBALBUILDDATE', - CFactory::_('Compiler.Builder.Content.One')->get('BUILDDATE')); - - // AUTHOR - $author = CFactory::_('Component')->get('author'); - CFactory::_('Compiler.Builder.Content.One')->set('AUTHOR', trim( - (string) JFilterOutput::cleanText($author) - )); - - // AUTHOREMAIL - CFactory::_('Compiler.Builder.Content.One')->set('AUTHOREMAIL', trim((string) CFactory::_('Component')->get('email', ''))); - - // AUTHORWEBSITE - CFactory::_('Compiler.Builder.Content.One')->set('AUTHORWEBSITE', trim((string) CFactory::_('Component')->get('website', ''))); - - // COPYRIGHT - CFactory::_('Compiler.Builder.Content.One')->set('COPYRIGHT', trim((string) CFactory::_('Component')->get('copyright', ''))); - - // LICENSE - CFactory::_('Compiler.Builder.Content.One')->set('LICENSE', trim((string) CFactory::_('Component')->get('license', ''))); - - // VERSION - CFactory::_('Compiler.Builder.Content.One')->set('VERSION', trim((string) CFactory::_('Component')->get('component_version', ''))); - // set the actual global version - CFactory::_('Compiler.Builder.Content.One')->set('ACTUALVERSION', CFactory::_('Compiler.Builder.Content.One')->get('VERSION')); - - // do some Tweaks to the version based on selected options - if (strpos((string) CFactory::_('Compiler.Builder.Content.One')->get('VERSION'), '.') !== false) - { - $versionArray = explode( - '.', (string) CFactory::_('Compiler.Builder.Content.One')->get('VERSION') - ); - } - // load only first two values - if (isset($versionArray) - && ArrayHelper::check( - $versionArray - ) && CFactory::_('Component')->get('mvc_versiondate', 0) == 2) - { - CFactory::_('Compiler.Builder.Content.One')->set('VERSION', $versionArray[0] . '.' . $versionArray[1] . '.x'); - } - // load only the first value - elseif (isset($versionArray) - && ArrayHelper::check( - $versionArray - ) && CFactory::_('Component')->get('mvc_versiondate', 0) == 3) - { - CFactory::_('Compiler.Builder.Content.One')->set('VERSION', $versionArray[0] . '.x.x'); - } - unset($versionArray); - - // set the global version in case - CFactory::_('Compiler.Builder.Content.One')->set('GLOBALVERSION', CFactory::_('Compiler.Builder.Content.One')->get('VERSION')); - - // set the joomla target xml version - CFactory::_('Compiler.Builder.Content.One')->set('XMLVERSION', CFactory::_('Config')->joomla_versions[CFactory::_('Config')->joomla_version]['xml_version']); - - // Component_name - $name = CFactory::_('Component')->get('name'); - CFactory::_('Compiler.Builder.Content.One')->set('Component_name', JFilterOutput::cleanText($name)); - - // SHORT_DISCRIPTION - $short_description = CFactory::_('Component')->get('short_description'); - CFactory::_('Compiler.Builder.Content.One')->set('SHORT_DESCRIPTION', trim( - (string) JFilterOutput::cleanText( - $short_description - ) - )); - - // DESCRIPTION - CFactory::_('Compiler.Builder.Content.One')->set('DESCRIPTION', trim((string) CFactory::_('Component')->get('description'))); - - // COMP_IMAGE_TYPE - CFactory::_('Compiler.Builder.Content.One')->set('COMP_IMAGE_TYPE', $this->setComponentImageType(CFactory::_('Component')->get('image'))); - - // ACCESS_SECTIONS - CFactory::_('Compiler.Builder.Content.One')->set('ACCESS_SECTIONS', $this->setAccessSections()); - - // CONFIG_FIELDSETS - $keepLang = CFactory::_('Config')->lang_target; - CFactory::_('Config')->lang_target = 'admin'; - - // start loading the category tree scripts - CFactory::_('Compiler.Builder.Content.One')->set('CATEGORY_CLASS_TREES', ''); - // run the field sets for first time - $this->setConfigFieldsets(1); - CFactory::_('Config')->lang_target = $keepLang; - - // ADMINJS - CFactory::_('Compiler.Builder.Content.One')->set('ADMINJS', - CFactory::_('Placeholder')->update_( - CFactory::_('Customcode.Dispenser')->hub['component_js'] - )); - // SITEJS - CFactory::_('Compiler.Builder.Content.One')->set('SITEJS', - CFactory::_('Placeholder')->update_( - CFactory::_('Customcode.Dispenser')->hub['component_js'] - )); - - // ADMINCSS - CFactory::_('Compiler.Builder.Content.One')->set('ADMINCSS', - CFactory::_('Placeholder')->update_( - CFactory::_('Customcode.Dispenser')->hub['component_css_admin'] - )); - // SITECSS - CFactory::_('Compiler.Builder.Content.One')->set('SITECSS', - CFactory::_('Placeholder')->update_( - CFactory::_('Customcode.Dispenser')->hub['component_css_site'] - )); - - // CUSTOM_HELPER_SCRIPT - CFactory::_('Compiler.Builder.Content.One')->set('CUSTOM_HELPER_SCRIPT', - CFactory::_('Placeholder')->update_( - CFactory::_('Customcode.Dispenser')->hub['component_php_helper_admin'] - )); - - // BOTH_CUSTOM_HELPER_SCRIPT - CFactory::_('Compiler.Builder.Content.One')->set('BOTH_CUSTOM_HELPER_SCRIPT', - CFactory::_('Placeholder')->update_( - CFactory::_('Customcode.Dispenser')->hub['component_php_helper_both'] - )); - - // ADMIN_GLOBAL_EVENT_HELPER - if (!CFactory::_('Compiler.Builder.Content.One')->exists('ADMIN_GLOBAL_EVENT')) - { - CFactory::_('Compiler.Builder.Content.One')->set('ADMIN_GLOBAL_EVENT', ''); - } - if (!CFactory::_('Compiler.Builder.Content.One')->exists('ADMIN_GLOBAL_EVENT_HELPER')) - { - CFactory::_('Compiler.Builder.Content.One')->set('ADMIN_GLOBAL_EVENT_HELPER', ''); - } - // now load the data for the global event if needed - if (CFactory::_('Component')->get('add_admin_event', 0) == 1) - { - // ADMIN_GLOBAL_EVENT - CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT', PHP_EOL . PHP_EOL . '// Trigger the Global Admin Event'); - CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT', - PHP_EOL . CFactory::_('Compiler.Builder.Content.One')->get('Component') - . 'Helper::globalEvent($document);'); - // ADMIN_GLOBAL_EVENT_HELPER - CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER', PHP_EOL . PHP_EOL . Indent::_(1) . '/**'); - CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER', - PHP_EOL . Indent::_(1) - . '* The Global Admin Event Method.'); - CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER', PHP_EOL . Indent::_(1) . '**/'); - CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER', - PHP_EOL . Indent::_(1) - . 'public static function globalEvent($document)'); - CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER', PHP_EOL . Indent::_(1) . '{'); - CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER', - PHP_EOL . CFactory::_('Placeholder')->update_( - CFactory::_('Customcode.Dispenser')->hub['component_php_admin_event'] - )); - CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER', PHP_EOL . Indent::_(1) . '}'); - } - - // now load the readme file if needed - if (CFactory::_('Component')->get('addreadme', 0) == 1) - { - CFactory::_('Compiler.Builder.Content.One')->add('EXSTRA_ADMIN_FILES', - PHP_EOL . Indent::_(3) - . "README.txt"); - } - - // HELPER_CREATEUSER - CFactory::_('Compiler.Builder.Content.One')->add('HELPER_CREATEUSER', - $this->setCreateUserHelperMethod( - CFactory::_('Component')->get('creatuserhelper') - )); - - // HELP - CFactory::_('Compiler.Builder.Content.One')->set('HELP', $this->noHelp()); - // HELP_SITE - CFactory::_('Compiler.Builder.Content.One')->set('HELP_SITE', $this->noHelp()); - - // build route parse switch - CFactory::_('Compiler.Builder.Content.One')->set('ROUTER_PARSE_SWITCH', ''); - // build route views - CFactory::_('Compiler.Builder.Content.One')->set('ROUTER_BUILD_VIEWS', ''); - - // add the helper emailer if set - CFactory::_('Compiler.Builder.Content.One')->set('HELPER_EMAIL', $this->addEmailHelper()); - - // load the global placeholders - foreach (CFactory::_('Component.Placeholder')->get() as $globalPlaceholder => - $gloabalValue - ) - { - CFactory::_('Compiler.Builder.Content.One')->set($globalPlaceholder, $gloabalValue); - } - - // reset view array - $viewarray = array(); - $site_edit_view_array = array(); - // start dynamic build - foreach (CFactory::_('Component')->get('admin_views') as $view) - { - // set the target - CFactory::_('Config')->build_target = 'admin'; - CFactory::_('Config')->lang_target = 'admin'; - - // set local names - $nameSingleCode = $view['settings']->name_single_code; - $nameListCode = $view['settings']->name_list_code; - - // set the view placeholders - $this->setViewPlaceholders($view['settings']); - - // set site edit view array - if (isset($view['edit_create_site_view']) - && is_numeric( - $view['edit_create_site_view'] - ) - && $view['edit_create_site_view'] > 0) - { - $site_edit_view_array[] = Indent::_(4) . "'" - . $nameSingleCode . "'"; - CFactory::_('Config')->lang_target = 'both'; - // insure site view does not get removed - CFactory::_('Config')->remove_site_edit_folder = false; - } - // check if help is being loaded - $this->checkHelp($nameSingleCode); - // set custom admin view list links - $this->setCustomAdminViewListLink( - $view, $nameListCode - ); - - // set view array - $viewarray[] = Indent::_(4) . "'" - . $nameSingleCode . "' => '" - . $nameListCode . "'"; - // set the view names - if (isset($view['settings']->name_single) - && $view['settings']->name_single != 'null') - { - // set license per view if needed - $this->setLockLicensePer( - $nameSingleCode, CFactory::_('Config')->build_target - ); - $this->setLockLicensePer( - $nameListCode, CFactory::_('Config')->build_target - ); - - // for plugin event TODO change event api signatures - $placeholders = CFactory::_('Placeholder')->active; - $fileContentStatic = CFactory::_('Compiler.Builder.Content.One')->allActive(); - $fileContentDynamic = CFactory::_('Compiler.Builder.Content.Multi')->allActive(); - // Trigger Event: jcb_ce_onBeforeBuildAdminEditViewContent - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeBuildAdminEditViewContent', - array(&$component_context, &$view, - &$nameSingleCode, - &$nameListCode, - &$fileContentStatic, - &$fileContentDynamic[$nameSingleCode], - &$placeholders, &$this->hhh) - ); - unset($fileContentStatic); - unset($fileContentDynamic); - unset($placeholders); - - // FIELDSETS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|FIELDSETS', - CFactory::_('Compiler.Creator.Fieldset')->get( - $view, - CFactory::_('Config')->component_code_name, - $nameSingleCode, - $nameListCode - ) - ); - - // ACCESSCONTROL <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|ACCESSCONTROL', $this->setFieldSetAccessControl( - $nameSingleCode - )); - - // LINKEDVIEWITEMS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|LINKEDVIEWITEMS', ''); - - // ADDTOOLBAR <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|ADDTOOLBAR', $this->setAddToolBar($view)); - - // set the script for this view - $this->buildTheViewScript($view); - - // VIEW_SCRIPT - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|VIEW_SCRIPT', $this->setViewScript( - $nameSingleCode, 'fileScript' - )); - - // EDITBODYSCRIPT - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|EDITBODYSCRIPT', $this->setViewScript( - $nameSingleCode, 'footerScript' - )); - - // AJAXTOKE <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|AJAXTOKE', $this->setAjaxToke( - $nameSingleCode - )); - - // DOCUMENT_CUSTOM_PHP <<>> - if ($phpDocument = CFactory::_('Customcode.Dispenser')->get( - 'php_document', $nameSingleCode, - PHP_EOL, null, true, - false - )) - { - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|DOCUMENT_CUSTOM_PHP', str_replace( - '$document->', '$this->document->', (string) $phpDocument - )); - // clear some memory - unset($phpDocument); - } - else - { - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|DOCUMENT_CUSTOM_PHP', ''); - } - // LINKEDVIEWTABLESCRIPTS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|LINKEDVIEWTABLESCRIPTS', ''); - - // VALIDATEFIX <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|VALIDATIONFIX', $this->setValidationFix( - $nameSingleCode, - CFactory::_('Compiler.Builder.Content.One')->get('Component') - )); - - // EDITBODY <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|EDITBODY', $this->setEditBody($view)); - - // EDITBODYFADEIN <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|EDITBODYFADEIN', $this->setFadeInEfect($view)); - - // JTABLECONSTRUCTOR <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JTABLECONSTRUCTOR', $this->setJtableConstructor( - $nameSingleCode - )); - - // JTABLEALIASCATEGORY <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JTABLEALIASCATEGORY', $this->setJtableAliasCategory( - $nameSingleCode - )); - - // METHOD_GET_ITEM <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|METHOD_GET_ITEM', $this->setMethodGetItem( - $nameSingleCode - )); - - // LINKEDVIEWGLOBAL <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|LINKEDVIEWGLOBAL', ''); - - // LINKEDVIEWMETHODS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|LINKEDVIEWMETHODS', ''); - - // JMODELADMIN_BEFORE_DELETE <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JMODELADMIN_BEFORE_DELETE', CFactory::_('Customcode.Dispenser')->get( - 'php_before_delete', - $nameSingleCode, PHP_EOL - )); - - // JMODELADMIN_AFTER_DELETE <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JMODELADMIN_AFTER_DELETE', CFactory::_('Customcode.Dispenser')->get( - 'php_after_delete', $nameSingleCode, - PHP_EOL . PHP_EOL - )); - - // JMODELADMIN_BEFORE_DELETE <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JMODELADMIN_BEFORE_PUBLISH', CFactory::_('Customcode.Dispenser')->get( - 'php_before_publish', - $nameSingleCode, PHP_EOL - )); - - // JMODELADMIN_AFTER_DELETE <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JMODELADMIN_AFTER_PUBLISH', CFactory::_('Customcode.Dispenser')->get( - 'php_after_publish', - $nameSingleCode, PHP_EOL . PHP_EOL - )); - - // CHECKBOX_SAVE <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|CHECKBOX_SAVE', $this->setCheckboxSave( - $nameSingleCode - )); - - // METHOD_ITEM_SAVE <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|METHOD_ITEM_SAVE', $this->setMethodItemSave( - $nameSingleCode - )); - - // POSTSAVEHOOK <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|POSTSAVEHOOK', CFactory::_('Customcode.Dispenser')->get( - 'php_postsavehook', $nameSingleCode, - PHP_EOL, null, - true, PHP_EOL . Indent::_(2) . "return;", - PHP_EOL . PHP_EOL . Indent::_(2) . "return;" - )); - - // VIEWCSS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|VIEWCSS', CFactory::_('Customcode.Dispenser')->get( - 'css_view', $nameSingleCode, '', - null, true - )); - - // add css to front end - if (isset($view['edit_create_site_view']) - && is_numeric($view['edit_create_site_view']) - && $view['edit_create_site_view'] > 0) - { - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|SITE_VIEWCSS', CFactory::_('Compiler.Builder.Content.Multi')->get($nameSingleCode . '|VIEWCSS', '')); - // check if we should add a create menu - if ($view['edit_create_site_view'] == 2) - { - // SITE_MENU_XML <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|SITE_MENU_XML', $this->setAdminViewMenu( - $nameSingleCode, $view - )); - } - // SITE_ADMIN_VIEW_CONTROLLER_HEADER <<>> add the header details for the controller - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|SITE_ADMIN_VIEW_CONTROLLER_HEADER', $this->setFileHeader( - 'site.admin.view.controller', - $nameSingleCode - )); - // SITE_ADMIN_VIEW_MODEL_HEADER <<>> add the header details for the model - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|SITE_ADMIN_VIEW_MODEL_HEADER', $this->setFileHeader( - 'site.admin.view.model', - $nameSingleCode - )); - // SITE_ADMIN_VIEW_HTML_HEADER <<>> add the header details for the view - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|SITE_ADMIN_VIEW_HTML_HEADER', $this->setFileHeader( - 'site.admin.view.html', - $nameSingleCode - )); - // SITE_ADMIN_VIEW_HEADER <<>> add the header details for the view - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|SITE_ADMIN_VIEW_HEADER', $this->setFileHeader( - 'site.admin.view', - $nameSingleCode - )); - } - - // TABLAYOUTFIELDSARRAY <<>> add the tab layout fields array to the model - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|TABLAYOUTFIELDSARRAY', $this->getTabLayoutFieldsArray( - $nameSingleCode - )); - - // ADMIN_VIEW_CONTROLLER_HEADER <<>> add the header details for the controller - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|ADMIN_VIEW_CONTROLLER_HEADER', $this->setFileHeader( - 'admin.view.controller', - $nameSingleCode - )); - // ADMIN_VIEW_MODEL_HEADER <<>> add the header details for the model - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|ADMIN_VIEW_MODEL_HEADER', $this->setFileHeader( - 'admin.view.model', $nameSingleCode - )); - // ADMIN_VIEW_HTML_HEADER <<>> add the header details for the view - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|ADMIN_VIEW_HTML_HEADER', $this->setFileHeader( - 'admin.view.html', $nameSingleCode - )); - // ADMIN_VIEW_HEADER <<>> add the header details for the view - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|ADMIN_VIEW_HEADER', $this->setFileHeader( - 'admin.view', $nameSingleCode - )); - - // for plugin event TODO change event api signatures - $placeholders = CFactory::_('Placeholder')->active; - $fileContentStatic = CFactory::_('Compiler.Builder.Content.One')->allActive(); - $fileContentDynamic = CFactory::_('Compiler.Builder.Content.Multi')->allActive(); - // Trigger Event: jcb_ce_onAfterBuildAdminEditViewContent - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterBuildAdminEditViewContent', - array(&$component_context, &$view, - &$nameSingleCode, - &$nameListCode, - &$fileContentStatic, - &$fileContentDynamic[$nameSingleCode], - &$placeholders, &$this->hhh) - ); - unset($fileContentStatic); - unset($fileContentDynamic); - unset($placeholders); - } - // set the views names - if (isset($view['settings']->name_list) - && $view['settings']->name_list != 'null') - { - CFactory::_('Config')->lang_target = 'admin'; - - // ICOMOON <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ICOMOON', $view['icomoon']); - - // for plugin event TODO change event api signatures - $placeholders = CFactory::_('Placeholder')->active; - $fileContentStatic = CFactory::_('Compiler.Builder.Content.One')->allActive(); - $fileContentDynamic = CFactory::_('Compiler.Builder.Content.Multi')->allActive(); - // Trigger Event: jcb_ce_onBeforeBuildAdminListViewContent - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeBuildAdminListViewContent', - array(&$component_context, &$view, - &$nameSingleCode, - &$nameListCode, - &$fileContentStatic, - &$fileContentDynamic[$nameListCode], - &$placeholders, &$this->hhh) - ); - unset($fileContentStatic); - unset($fileContentDynamic); - unset($placeholders); - - // set the export/import option - if (isset($view['port']) && $view['port'] - || 1 == $view['settings']->add_custom_import) - { - $this->eximportView[$nameListCode] = true; - if (1 == $view['settings']->add_custom_import) - { - // this view has custom import scripting - $this->importCustomScripts[$nameListCode] - = true; - // set all custom scripts - $this->setImportCustomScripts( - $nameListCode - ); - } - } - else - { - $this->eximportView[$nameListCode] - = false; - } - - // set Auto check in function - if (isset($view['checkin']) && $view['checkin'] == 1) - { - // AUTOCHECKIN <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|AUTOCHECKIN', $this->setAutoCheckin( - $nameSingleCode, - CFactory::_('Config')->component_code_name - )); - // CHECKINCALL <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|CHECKINCALL', $this->setCheckinCall()); - } - else - { - // AUTOCHECKIN <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|AUTOCHECKIN', ''); - // CHECKINCALL <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|CHECKINCALL', ''); - } - // admin list file contnet - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_JAVASCRIPT_FILE', $this->setViewScript( - $nameListCode, 'list_fileScript' - )); - // ADMIN_CUSTOM_BUTTONS_LIST - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_CUSTOM_BUTTONS_LIST', $this->setCustomButtons($view, 3, Indent::_(1))); - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_CUSTOM_FUNCTION_ONLY_BUTTONS_LIST', $this->setFunctionOnlyButtons( - $nameListCode - )); - - // GET_ITEMS_METHOD_STRING_FIX <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|GET_ITEMS_METHOD_STRING_FIX', $this->setGetItemsMethodStringFix( - $nameSingleCode, - $nameListCode, - CFactory::_('Compiler.Builder.Content.One')->get('Component') - )); - - // GET_ITEMS_METHOD_AFTER_ALL <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|GET_ITEMS_METHOD_AFTER_ALL', CFactory::_('Customcode.Dispenser')->get( - 'php_getitems_after_all', - $nameSingleCode, PHP_EOL - )); - - // SELECTIONTRANSLATIONFIX <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|SELECTIONTRANSLATIONFIX', $this->setSelectionTranslationFix( - $nameListCode, - CFactory::_('Compiler.Builder.Content.One')->get('Component') - )); - - // SELECTIONTRANSLATIONFIXFUNC <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|SELECTIONTRANSLATIONFIXFUNC', $this->setSelectionTranslationFixFunc( - $nameListCode, - CFactory::_('Compiler.Builder.Content.One')->get('Component') - )); - - // FILTER_FIELDS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|FILTER_FIELDS', $this->setFilterFieldsArray( - $nameSingleCode, - $nameListCode - )); - - // STOREDID <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|STOREDID', $this->setStoredId( - $nameSingleCode, $nameListCode - )); - - // POPULATESTATE <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|POPULATESTATE', $this->setPopulateState( - $nameSingleCode, $nameListCode - )); - - // SORTFIELDS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|SORTFIELDS', $this->setSortFields( - $nameListCode - )); - - // CATEGORY_VIEWS - CFactory::_('Compiler.Builder.Content.One')->add('ROUTER_CATEGORY_VIEWS', - $this->setRouterCategoryViews( - $nameSingleCode, - $nameListCode - )); - - // FILTERFIELDDISPLAYHELPER <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|FILTERFIELDDISPLAYHELPER', $this->setFilterFieldSidebarDisplayHelper( - $nameSingleCode, - $nameListCode - )); - - // BATCHDISPLAYHELPER <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|BATCHDISPLAYHELPER', $this->setBatchDisplayHelper( - $nameSingleCode, - $nameListCode - )); - - // FILTERFUNCTIONS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|FILTERFUNCTIONS', $this->setFilterFieldHelper( - $nameSingleCode, - $nameListCode - )); - - // FIELDFILTERSETS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set('filter_' . $nameListCode . '|FIELDFILTERSETS', - $this->setFieldFilterSet( - $nameSingleCode, - $nameListCode - )); - - // FIELDLISTSETS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set('filter_' . $nameListCode . '|FIELDLISTSETS', - $this->setFieldFilterListSet( - $nameSingleCode, - $nameListCode - )); - - // LISTQUERY <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|LISTQUERY', $this->setListQuery( - $nameSingleCode, - $nameListCode - )); - - // MODELEXPORTMETHOD <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|MODELEXPORTMETHOD', $this->setGetItemsModelMethod( - $nameSingleCode, - $nameListCode - )); - - // MODELEXIMPORTMETHOD <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|CONTROLLEREXIMPORTMETHOD', $this->setControllerEximportMethod( - $nameSingleCode, - $nameListCode - )); - - // EXPORTBUTTON <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|EXPORTBUTTON', $this->setExportButton( - $nameSingleCode, - $nameListCode - )); - - // IMPORTBUTTON <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|IMPORTBUTTON', $this->setImportButton( - $nameSingleCode, - $nameListCode - )); - - // VIEWS_DEFAULT_BODY <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|VIEWS_DEFAULT_BODY', $this->setDefaultViewsBody( - $nameSingleCode, - $nameListCode - )); - - // LISTHEAD <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|LISTHEAD', $this->setListHead( - $nameSingleCode, - $nameListCode - )); - - // LISTBODY <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|LISTBODY', $this->setListBody( - $nameSingleCode, - $nameListCode - )); - - // LISTCOLNR <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|LISTCOLNR', $this->setListColnr( - $nameListCode - )); - - // JVIEWLISTCANDO <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|JVIEWLISTCANDO', $this->setJviewListCanDo( - $nameSingleCode, - $nameListCode - )); - - // VIEWSCSS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|VIEWSCSS', CFactory::_('Customcode.Dispenser')->get( - 'css_views', $nameSingleCode, '', - null, true - )); - - // ADMIN_DIPLAY_METHOD <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_DIPLAY_METHOD', $this->setAdminViewDisplayMethod( - $nameListCode - )); - - // VIEWS_FOOTER_SCRIPT <<>> - $scriptNote = PHP_EOL . '//' . Line::_(__Line__, __Class__) - . ' ' . $nameListCode - . ' footer script'; - if (($footerScript = CFactory::_('Customcode.Dispenser')->get( - 'views_footer', $nameSingleCode, '', - $scriptNote, true, - false, PHP_EOL - )) !== false - && StringHelper::check($footerScript)) - { - // only minfy if no php is added to the footer script - if (CFactory::_('Config')->get('minify', 0) - && strpos((string) $footerScript, 'set($nameListCode . '|VIEWS_FOOTER_SCRIPT', PHP_EOL . '"); - // clear some memory - unset($footerScript); - } - else - { - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|VIEWS_FOOTER_SCRIPT', ''); - } - - // ADMIN_VIEWS_CONTROLLER_HEADER <<>> add the header details for the controller - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_VIEWS_CONTROLLER_HEADER', $this->setFileHeader( - 'admin.views.controller', - $nameListCode - )); - // ADMIN_VIEWS_MODEL_HEADER <<>> add the header details for the model - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_VIEWS_MODEL_HEADER', $this->setFileHeader( - 'admin.views.model', $nameListCode - )); - // ADMIN_VIEWS_HTML_HEADER <<>> add the header details for the views - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_VIEWS_HTML_HEADER', $this->setFileHeader( - 'admin.views.html', $nameListCode - )); - // ADMIN_VIEWS_HEADER <<>> add the header details for the views - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_VIEWS_HEADER', $this->setFileHeader( - 'admin.views', $nameListCode - )); - - // for plugin event TODO change event api signatures - $placeholders = CFactory::_('Placeholder')->active; - $fileContentStatic = CFactory::_('Compiler.Builder.Content.One')->allActive(); - $fileContentDynamic = CFactory::_('Compiler.Builder.Content.Multi')->allActive(); - // Trigger Event: jcb_ce_onAfterBuildAdminListViewContent - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterBuildAdminListViewContent', - array(&$component_context, &$view, - &$nameSingleCode, - &$nameListCode, - &$fileContentStatic, - &$fileContentDynamic[$nameListCode], - &$placeholders, &$this->hhh) - ); - unset($fileContentStatic); - unset($fileContentDynamic); - unset($placeholders); - } - - // set u fields used in batch - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|UNIQUEFIELDS', $this->setUniqueFields( - $nameSingleCode - )); - - // TITLEALIASFIX <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|TITLEALIASFIX', $this->setAliasTitleFix( - $nameSingleCode - )); - - // GENERATENEWTITLE <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|GENERATENEWTITLE', $this->setGenerateNewTitle( - $nameSingleCode - )); - - // GENERATENEWALIAS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|GENERATENEWALIAS', $this->setGenerateNewAlias( - $nameSingleCode - )); - - // MODEL_BATCH_COPY <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|MODEL_BATCH_COPY', $this->setBatchCopy($nameSingleCode)); - - // MODEL_BATCH_MOVE <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|MODEL_BATCH_MOVE', $this->setBatchMove($nameSingleCode)); - - // BATCH_ONCLICK_CANCEL_SCRIPT <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|BATCH_ONCLICK_CANCEL_SCRIPT', ''); // TODO <-- must still be build - - // JCONTROLLERFORM_ALLOWADD <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JCONTROLLERFORM_ALLOWADD', $this->setJcontrollerAllowAdd( - $nameSingleCode, - $nameListCode - )); - - // JCONTROLLERFORM_BEFORECANCEL <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JCONTROLLERFORM_BEFORECANCEL', CFactory::_('Customcode.Dispenser')->get( - 'php_before_cancel', $nameSingleCode, - PHP_EOL, null, false, - '' - )); - - // JCONTROLLERFORM_AFTERCANCEL <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JCONTROLLERFORM_AFTERCANCEL', CFactory::_('Customcode.Dispenser')->get( - 'php_after_cancel', $nameSingleCode, - PHP_EOL, null, false, - '' - )); - - // JCONTROLLERFORM_ALLOWEDIT <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JCONTROLLERFORM_ALLOWEDIT', $this->setJcontrollerAllowEdit( - $nameSingleCode, - $nameListCode - )); - - // JMODELADMIN_GETFORM <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JMODELADMIN_GETFORM', $this->setJmodelAdminGetForm( - $nameSingleCode, - $nameListCode - )); - - // JMODELADMIN_ALLOWEDIT <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JMODELADMIN_ALLOWEDIT', $this->setJmodelAdminAllowEdit( - $nameSingleCode, - $nameListCode - )); - - // JMODELADMIN_CANDELETE <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JMODELADMIN_CANDELETE', $this->setJmodelAdminCanDelete( - $nameSingleCode, - $nameListCode - )); - - // JMODELADMIN_CANEDITSTATE <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JMODELADMIN_CANEDITSTATE', $this->setJmodelAdminCanEditState( - $nameSingleCode, - $nameListCode - )); - - // set custom admin view Toolbare buttons - // CUSTOM_ADMIN_DYNAMIC_BUTTONS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|CUSTOM_ADMIN_DYNAMIC_BUTTONS', $this->setCustomAdminDynamicButton( - $nameListCode - )); - // CUSTOM_ADMIN_DYNAMIC_BUTTONS_CONTROLLER <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|CUSTOM_ADMIN_DYNAMIC_BUTTONS_CONTROLLER', $this->setCustomAdminDynamicButtonController( - $nameListCode - )); - - // set helper router - CFactory::_('Compiler.Builder.Content.One')->add('ROUTEHELPER', - $this->setRouterHelp( - $nameSingleCode, - $nameListCode - )); - - if (isset($view['edit_create_site_view']) - && is_numeric( - $view['edit_create_site_view'] - ) - && $view['edit_create_site_view'] > 0) - { - // add needed router stuff for front edit views - CFactory::_('Compiler.Builder.Content.One')->add('ROUTER_PARSE_SWITCH', - $this->routerParseSwitch( - $nameSingleCode, null, false - )); - CFactory::_('Compiler.Builder.Content.One')->add('ROUTER_BUILD_VIEWS', - $this->routerBuildViews( - $nameSingleCode - )); - } - - // ACCESS_SECTIONS - CFactory::_('Compiler.Builder.Content.One')->add('ACCESS_SECTIONS', - $this->setAccessSectionsCategory( - $nameSingleCode, - $nameListCode - )); - // set the Joomla Fields ACCESS section if needed - if (isset($view['joomla_fields']) - && $view['joomla_fields'] == 1) - { - CFactory::_('Compiler.Builder.Content.One')->add('ACCESS_SECTIONS', $this->setAccessSectionsJoomlaFields()); - } - - // for plugin event TODO change event api signatures - $placeholders = CFactory::_('Placeholder')->active; - $fileContentStatic = CFactory::_('Compiler.Builder.Content.One')->allActive(); - $fileContentDynamic = CFactory::_('Compiler.Builder.Content.Multi')->allActive(); - // Trigger Event: jcb_ce_onAfterBuildAdminViewContent - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterBuildAdminViewContent', - array(&$component_context, &$view, - &$nameSingleCode, - &$nameListCode, - &$fileContentStatic, - &$fileContentDynamic, &$placeholders, - &$this->hhh) - ); - unset($fileContentStatic); - unset($fileContentDynamic); - unset($placeholders); - } - - // all fields stored in database - CFactory::_('Compiler.Builder.Content.One')->set('ALL_COMPONENT_FIELDS', CFactory::_('Compiler.Builder.Component.Fields')->varExport(null, 1)); - - // setup the layouts - $this->setCustomViewLayouts(); - - // setup custom_admin_views and all needed stuff for the site - if (CFactory::_('Component')->isArray('custom_admin_views')) - { - CFactory::_('Config')->build_target = 'custom_admin'; - CFactory::_('Config')->lang_target = 'admin'; - // start dynamic build - foreach (CFactory::_('Component')->get('custom_admin_views') as $view) - { - // for single views - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SView', $view['settings']->Code); - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|sview', $view['settings']->code); - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SVIEW', $view['settings']->CODE); - // for list views - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SViews', $view['settings']->Code); - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|sviews', $view['settings']->code); - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SVIEWS', $view['settings']->CODE); - // add to lang array - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, - CFactory::_('Config')->lang_prefix . '_' . $view['settings']->CODE, - $view['settings']->name - ); - CFactory::_('Language')->set( - CFactory::_('Config')->lang_target, - CFactory::_('Config')->lang_prefix . '_' . $view['settings']->CODE - . '_DESC', $view['settings']->description - ); - // ICOMOON <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|ICOMOON', $view['icomoon']); - - // set placeholders - CFactory::_('Placeholder')->set('SView', $view['settings']->Code); - CFactory::_('Placeholder')->set('sview', $view['settings']->code); - CFactory::_('Placeholder')->set('SVIEW', $view['settings']->CODE); - - CFactory::_('Placeholder')->set('SViews', $view['settings']->Code); - CFactory::_('Placeholder')->set('sviews', $view['settings']->code); - CFactory::_('Placeholder')->set('SVIEWS', $view['settings']->CODE); - - // for plugin event TODO change event api signatures - $placeholders = CFactory::_('Placeholder')->active; - $fileContentStatic = CFactory::_('Compiler.Builder.Content.One')->allActive(); - $fileContentDynamic = CFactory::_('Compiler.Builder.Content.Multi')->allActive(); - // Trigger Event: jcb_ce_onBeforeBuildCustomAdminViewContent - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeBuildCustomAdminViewContent', - array(&$component_context, &$view, - &$view['settings']->code, - &$fileContentStatic, - &$fileContentDynamic[$view['settings']->code], - &$placeholders, &$this->hhh) - ); - unset($fileContentStatic); - unset($fileContentDynamic); - unset($placeholders); - - // set license per view if needed - $this->setLockLicensePer( - $view['settings']->code, CFactory::_('Config')->build_target - ); - - // check if this custom admin view is the default view - if (CFactory::_('Registry')->get('build.dashboard.type', '') === 'custom_admin_views' - && CFactory::_('Registry')->get('build.dashboard', '') === $view['settings']->code) - { - // HIDEMAINMENU <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|HIDEMAINMENU', ''); - } - else - { - // HIDEMAINMENU <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|HIDEMAINMENU', PHP_EOL . Indent::_(2) . '//' . Line::_( - __LINE__,__CLASS__ - ) . " hide the main menu" - . PHP_EOL . Indent::_(2) - . "\$this->app->input->set('hidemainmenu', true);"); - } - - if ($view['settings']->main_get->gettype == 1) - { - // CUSTOM_ADMIN_BEFORE_GET_ITEM <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_BEFORE_GET_ITEM', CFactory::_('Customcode.Dispenser')->get( - CFactory::_('Config')->build_target . '_php_before_getitem', - $view['settings']->code, '', null, true - )); - - // CUSTOM_ADMIN_GET_ITEM <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_GET_ITEM', $this->setCustomViewGetItem( - $view['settings']->main_get, - $view['settings']->code, Indent::_(2) - )); - - // CUSTOM_ADMIN_AFTER_GET_ITEM <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_AFTER_GET_ITEM', CFactory::_('Customcode.Dispenser')->get( - CFactory::_('Config')->build_target . '_php_after_getitem', - $view['settings']->code, '', null, true - )); - } - elseif ($view['settings']->main_get->gettype == 2) - { - // CUSTOM_ADMIN_GET_LIST_QUERY <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_GET_LIST_QUERY', $this->setCustomViewListQuery( - $view['settings']->main_get, $view['settings']->code - )); - - // CUSTOM_ADMIN_CUSTOM_BEFORE_LIST_QUERY <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_CUSTOM_BEFORE_LIST_QUERY', CFactory::_('Customcode.Dispenser')->get( - CFactory::_('Config')->build_target . '_php_getlistquery', - $view['settings']->code, PHP_EOL, null, true - )); - - // CUSTOM_ADMIN_BEFORE_GET_ITEMS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_BEFORE_GET_ITEMS', CFactory::_('Customcode.Dispenser')->get( - CFactory::_('Config')->build_target . '_php_before_getitems', - $view['settings']->code, PHP_EOL, null, true - )); - - // CUSTOM_ADMIN_GET_ITEMS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_GET_ITEMS', $this->setCustomViewGetItems( - $view['settings']->main_get, $view['settings']->code - )); - - // CUSTOM_ADMIN_AFTER_GET_ITEMS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_AFTER_GET_ITEMS', CFactory::_('Customcode.Dispenser')->get( - CFactory::_('Config')->build_target . '_php_after_getitems', - $view['settings']->code, PHP_EOL, null, true - )); - } - - // CUSTOM_ADMIN_CUSTOM_METHODS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_CUSTOM_METHODS', $this->setCustomViewCustomItemMethods( - $view['settings']->main_get, $view['settings']->code - )); - CFactory::_('Compiler.Builder.Content.Multi')->add($view['settings']->code . '|CUSTOM_ADMIN_CUSTOM_METHODS', - $this->setCustomViewCustomMethods( - $view, $view['settings']->code - ). false - ); - // CUSTOM_ADMIN_DIPLAY_METHOD <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_DIPLAY_METHOD', $this->setCustomViewDisplayMethod($view)); - // set document details - $this->setPrepareDocument($view); - // CUSTOM_ADMIN_EXTRA_DIPLAY_METHODS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_EXTRA_DIPLAY_METHODS', $this->setCustomViewExtraDisplayMethods($view)); - // CUSTOM_ADMIN_CODE_BODY <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_CODE_BODY', $this->setCustomViewCodeBody($view)); - // CUSTOM_ADMIN_BODY <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_BODY', $this->setCustomViewBody($view)); - // CUSTOM_ADMIN_SUBMITBUTTON_SCRIPT <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_SUBMITBUTTON_SCRIPT', $this->setCustomViewSubmitButtonScript($view)); - - // setup the templates - $this->setCustomViewTemplateBody($view); - - // set the site form if needed - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_TOP_FORM', $this->setCustomViewForm( - $view['settings']->code, - $view['settings']->main_get->gettype, 1 - )); - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_BOTTOM_FORM', $this->setCustomViewForm( - $view['settings']->code, - $view['settings']->main_get->gettype, 2 - )); - - // set headers based on the main get type - if ($view['settings']->main_get->gettype == 1) - { - // CUSTOM_ADMIN_VIEW_CONTROLLER_HEADER <<>> add the header details for the controller - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_VIEW_CONTROLLER_HEADER', $this->setFileHeader( - 'custom.admin.view.controller', - $view['settings']->code - )); - // CUSTOM_ADMIN_VIEW_MODEL_HEADER <<>> add the header details for the model - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_VIEW_MODEL_HEADER', $this->setFileHeader( - 'custom.admin.view.model', $view['settings']->code - )); - // CUSTOM_ADMIN_VIEW_HTML_HEADER <<>> add the header details for the view - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_VIEW_HTML_HEADER', $this->setFileHeader( - 'custom.admin.view.html', $view['settings']->code - )); - // CUSTOM_ADMIN_VIEW_HEADER <<>> add the header details for the view - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_VIEW_HEADER', $this->setFileHeader( - 'custom.admin.view', $view['settings']->code - )); - } - elseif ($view['settings']->main_get->gettype == 2) - { - // CUSTOM_ADMIN_VIEWS_CONTROLLER_HEADER <<>> add the header details for the controller - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_VIEWS_CONTROLLER_HEADER', $this->setFileHeader( - 'custom.admin.views.controller', - $view['settings']->code - )); - // CUSTOM_ADMIN_VIEWS_MODEL_HEADER <<>> add the header details for the model - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_VIEWS_MODEL_HEADER', $this->setFileHeader( - 'custom.admin.views.model', $view['settings']->code - )); - // CUSTOM_ADMIN_VIEWS_HTML_HEADER <<>> add the header details for the view - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_VIEWS_HTML_HEADER', $this->setFileHeader( - 'custom.admin.views.html', $view['settings']->code - )); - // CUSTOM_ADMIN_VIEWS_HEADER <<>> add the header details for the view - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_VIEWS_HEADER', $this->setFileHeader( - 'custom.admin.views', $view['settings']->code - )); - } - - // for plugin event TODO change event api signatures - $placeholders = CFactory::_('Placeholder')->active; - $fileContentStatic = CFactory::_('Compiler.Builder.Content.One')->allActive(); - $fileContentDynamic = CFactory::_('Compiler.Builder.Content.Multi')->allActive(); - // Trigger Event: jcb_ce_onAfterBuildCustomAdminViewContent - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterBuildCustomAdminViewContent', - array(&$component_context, &$view, - &$view['settings']->code, - &$fileContentStatic, - &$fileContentDynamic[$view['settings']->code], - &$placeholders, &$this->hhh) - ); - unset($fileContentStatic); - unset($fileContentDynamic); - unset($placeholders); - } - - // setup the layouts - $this->setCustomViewLayouts(); - } - - // ADMIN_HELPER_CLASS_HEADER - CFactory::_('Compiler.Builder.Content.One')->set('ADMIN_HELPER_CLASS_HEADER', - $this->setFileHeader( - 'admin.helper', 'admin' - )); - - // ADMIN_COMPONENT_HEADER - CFactory::_('Compiler.Builder.Content.One')->set('ADMIN_COMPONENT_HEADER', - $this->setFileHeader( - 'admin.component', 'admin' - )); - - // SITE_HELPER_CLASS_HEADER - CFactory::_('Compiler.Builder.Content.One')->set('SITE_HELPER_CLASS_HEADER', - $this->setFileHeader( - 'site.helper', 'site' - )); - - // SITE_COMPONENT_HEADER - CFactory::_('Compiler.Builder.Content.One')->set('SITE_COMPONENT_HEADER', - $this->setFileHeader( - 'site.component', 'site' - )); - - // HELPER_EXEL - CFactory::_('Compiler.Builder.Content.One')->set('HELPER_EXEL', $this->setHelperExelMethods()); - - // VIEWARRAY - CFactory::_('Compiler.Builder.Content.One')->set('VIEWARRAY', PHP_EOL . implode("," . PHP_EOL, $viewarray)); - - // CUSTOM_ADMIN_EDIT_VIEW_ARRAY - CFactory::_('Compiler.Builder.Content.One')->set('SITE_EDIT_VIEW_ARRAY', PHP_EOL . implode("," . PHP_EOL, $site_edit_view_array)); - - // MAINMENUS - CFactory::_('Compiler.Builder.Content.One')->set('MAINMENUS', $this->setMainMenus()); - - // SUBMENU - CFactory::_('Compiler.Builder.Content.One')->set('SUBMENU', $this->setSubMenus()); - - // GET_CRYPT_KEY - CFactory::_('Compiler.Builder.Content.One')->set('GET_CRYPT_KEY', $this->setGetCryptKey()); - - // set the license locker - $this->setLockLicense(); - - // CONTRIBUTORS - CFactory::_('Compiler.Builder.Content.One')->set('CONTRIBUTORS', $this->theContributors); - - // INSTALL - CFactory::_('Compiler.Builder.Content.One')->set('INSTALL', $this->setInstall()); - - // UNINSTALL - CFactory::_('Compiler.Builder.Content.One')->set('UNINSTALL', $this->setUninstall()); - - // UPDATE_VERSION_MYSQL - $this->setVersionController(); - - // only set these if default dashboard it used - if (!CFactory::_('Registry')->get('build.dashboard')) - { - // DASHBOARDVIEW - CFactory::_('Compiler.Builder.Content.One')->set('DASHBOARDVIEW', CFactory::_('Config')->component_code_name); - - // DASHBOARDICONS - CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '|DASHBOARDICONS', $this->setDashboardIcons()); - - // DASHBOARDICONACCESS - CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '|DASHBOARDICONACCESS', $this->setDashboardIconAccess()); - - // DASH_MODEL_METHODS - CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '|DASH_MODEL_METHODS', $this->setDashboardModelMethods()); - - // DASH_GET_CUSTOM_DATA - CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '|DASH_GET_CUSTOM_DATA', $this->setDashboardGetCustomData()); - - // DASH_DISPLAY_DATA - CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '|DASH_DISPLAY_DATA', $this->setDashboardDisplayData()); - - // DASH_VIEW_HEADER - CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '|DASH_VIEW_HEADER', $this->setFileHeader('dashboard.view', 'dashboard')); - // DASH_VIEW_HTML_HEADER - CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '|DASH_VIEW_HTML_HEADER', $this->setFileHeader('dashboard.view.html', 'dashboard')); - // DASH_MODEL_HEADER - CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '|DASH_MODEL_HEADER', $this->setFileHeader('dashboard.model', 'dashboard')); - // DASH_CONTROLLER_HEADER - CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '|DASH_CONTROLLER_HEADER', $this->setFileHeader('dashboard.controller', 'dashboard')); - } - else - { - // DASHBOARDVIEW - CFactory::_('Compiler.Builder.Content.One')->set('DASHBOARDVIEW', CFactory::_('Registry')->get('build.dashboard')); - } - - // add import - if (CFactory::_('Config')->get('add_eximport', false)) - { - // setup import files - $target = array('admin' => 'import'); - CFactory::_('Utilities.Structure')->build($target, 'import'); - // IMPORT_EXT_METHOD <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set('import' . '|IMPORT_EXT_METHOD', PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( - ComponentbuilderHelper::getDynamicScripts('ext') - )); - // IMPORT_SETDATA_METHOD <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set('import' . '|IMPORT_SETDATA_METHOD', PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( - ComponentbuilderHelper::getDynamicScripts('setdata') - )); - // IMPORT_SAVE_METHOD <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set('import' . '|IMPORT_SAVE_METHOD', PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( - ComponentbuilderHelper::getDynamicScripts('save') - )); - // IMPORT_CONTROLLER_HEADER <<>> add the header details for the controller - CFactory::_('Compiler.Builder.Content.Multi')->set('import' . '|IMPORT_CONTROLLER_HEADER', $this->setFileHeader( - 'import.controller', 'import' - )); - // IMPORT_MODEL_HEADER <<>> add the header details for the model - CFactory::_('Compiler.Builder.Content.Multi')->set('import' . '|IMPORT_MODEL_HEADER', $this->setFileHeader( - 'import.model', 'import' - )); - } - - // ensure that the ajax model and controller is set if needed - if (CFactory::_('Config')->get('add_ajax', false)) - { - // setup Ajax files - $target = array('admin' => 'ajax'); - CFactory::_('Utilities.Structure')->build($target, 'ajax'); - // set the controller - CFactory::_('Compiler.Builder.Content.Multi')->set('ajax' . '|REGISTER_AJAX_TASK', $this->setRegisterAjaxTask('admin')); - CFactory::_('Compiler.Builder.Content.Multi')->set('ajax' . '|AJAX_INPUT_RETURN', $this->setAjaxInputReturn('admin')); - // set the model header - CFactory::_('Compiler.Builder.Content.Multi')->set('ajax' . '|AJAX_ADMIN_MODEL_HEADER', $this->setFileHeader('ajax.admin.model', 'ajax')); - // set the module - CFactory::_('Compiler.Builder.Content.Multi')->set('ajax' . '|AJAX_MODEL_METHODS', $this->setAjaxModelMethods('admin')); - } - - // ensure that the site ajax model and controller is set if needed - if (CFactory::_('Config')->get('add_site_ajax', false)) - { - // setup Ajax files - $target = array('site' => 'ajax'); - CFactory::_('Utilities.Structure')->build($target, 'ajax'); - // set the controller - CFactory::_('Compiler.Builder.Content.Multi')->set('ajax' . '|REGISTER_SITE_AJAX_TASK', $this->setRegisterAjaxTask('site')); - CFactory::_('Compiler.Builder.Content.Multi')->set('ajax' . '|AJAX_SITE_INPUT_RETURN', $this->setAjaxInputReturn('site')); - // set the model header - CFactory::_('Compiler.Builder.Content.Multi')->set('ajax' . '|AJAX_SITE_MODEL_HEADER', $this->setFileHeader('ajax.site.model', 'ajax')); - // set the module - CFactory::_('Compiler.Builder.Content.Multi')->set('ajax' . '|AJAX_SITE_MODEL_METHODS', $this->setAjaxModelMethods('site')); - } - - // build the validation rules - if (($validationRules = CFactory::_('Registry')->_('validation.rules')) !== null) - { - foreach ($validationRules as $rule => $_php) - { - // setup rule file - $target = array('admin' => 'a_rule_zi'); - CFactory::_('Utilities.Structure')->build($target, 'rule', $rule); - // set the JFormRule Name - CFactory::_('Compiler.Builder.Content.Multi')->set('a_rule_zi_' . $rule . '|Name', ucfirst((string) $rule)); - // set the JFormRule PHP - CFactory::_('Compiler.Builder.Content.Multi')->set('a_rule_zi_' . $rule . '|VALIDATION_RULE_METHODS', PHP_EOL . $_php); - } - } - - // run the second run if needed - if (isset($this->secondRunAdmin) - && ArrayHelper::check($this->secondRunAdmin)) - { - // start dynamic build - foreach ($this->secondRunAdmin as $function => $arrays) - { - if (ArrayHelper::check($arrays) - && StringHelper::check($function)) - { - foreach ($arrays as $array) - { - $this->{$function}($array); - } - } - } - } - - // CONFIG_FIELDSETS - $keepLang = CFactory::_('Config')->lang_target; - CFactory::_('Config')->lang_target = 'admin'; - // run field sets for second time - $this->setConfigFieldsets(2); - CFactory::_('Config')->lang_target = $keepLang; - - // setup front-views and all needed stuff for the site - if (CFactory::_('Component')->isArray('site_views')) - { - CFactory::_('Config')->build_target = 'site'; - // start dynamic build - foreach (CFactory::_('Component')->get('site_views') as $view) - { - // for list views - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SViews', $view['settings']->Code); - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|sviews', $view['settings']->code); - // for single views - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SView', $view['settings']->Code); - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|sview', $view['settings']->code); - - // set placeholders - CFactory::_('Placeholder')->set('SView', $view['settings']->Code); - CFactory::_('Placeholder')->set('sview', $view['settings']->code); - CFactory::_('Placeholder')->set('SVIEW', $view['settings']->CODE); - - CFactory::_('Placeholder')->set('SViews', $view['settings']->Code); - CFactory::_('Placeholder')->set('sviews', $view['settings']->code); - CFactory::_('Placeholder')->set('SVIEWS', $view['settings']->CODE); - - // for plugin event TODO change event api signatures - $placeholders = CFactory::_('Placeholder')->active; - $fileContentStatic = CFactory::_('Compiler.Builder.Content.One')->allActive(); - $fileContentDynamic = CFactory::_('Compiler.Builder.Content.Multi')->allActive(); - // Trigger Event: jcb_ce_onBeforeBuildSiteViewContent - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeBuildSiteViewContent', - array(&$component_context, &$view, - &$view['settings']->code, - &$fileContentStatic, - &$fileContentDynamic[$view['settings']->code], - &$placeholders, &$this->hhh) - ); - unset($fileContentStatic); - unset($fileContentDynamic); - unset($placeholders); - - // set license per view if needed - $this->setLockLicensePer( - $view['settings']->code, CFactory::_('Config')->build_target - ); - - // set the site default view - if (isset($view['default_view']) - && $view['default_view'] == 1) - { - CFactory::_('Compiler.Builder.Content.One')->set('SITE_DEFAULT_VIEW', $view['settings']->code); - } - // add site menu - if (isset($view['menu']) && $view['menu'] == 1) - { - // SITE_MENU_XML <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_MENU_XML', $this->setCustomViewMenu($view)); - } - - // insure the needed route helper is loaded - CFactory::_('Compiler.Builder.Content.One')->add('ROUTEHELPER', - $this->setRouterHelp( - $view['settings']->code, $view['settings']->code, true - )); - // build route details - CFactory::_('Compiler.Builder.Content.One')->add('ROUTER_PARSE_SWITCH', - $this->routerParseSwitch( - $view['settings']->code, $view - )); - CFactory::_('Compiler.Builder.Content.One')->add('ROUTER_BUILD_VIEWS', $this->routerBuildViews($view['settings']->code)); - - if ($view['settings']->main_get->gettype == 1) - { - // set user permission access check USER_PERMISSION_CHECK_ACCESS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|USER_PERMISSION_CHECK_ACCESS', $this->setUserPermissionCheckAccess($view, 1)); - - // SITE_BEFORE_GET_ITEM <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_BEFORE_GET_ITEM', CFactory::_('Customcode.Dispenser')->get( - CFactory::_('Config')->build_target . '_php_before_getitem', - $view['settings']->code, '', null, true - )); - - // SITE_GET_ITEM <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_GET_ITEM', $this->setCustomViewGetItem( - $view['settings']->main_get, - $view['settings']->code, Indent::_(2) - )); - - // SITE_AFTER_GET_ITEM <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_AFTER_GET_ITEM', CFactory::_('Customcode.Dispenser')->get( - CFactory::_('Config')->build_target . '_php_after_getitem', - $view['settings']->code, '', null, true - )); - } - elseif ($view['settings']->main_get->gettype == 2) - { - // set user permission access check USER_PERMISSION_CHECK_ACCESS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|USER_PERMISSION_CHECK_ACCESS', $this->setUserPermissionCheckAccess($view, 2)); - // SITE_GET_LIST_QUERY <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_GET_LIST_QUERY', $this->setCustomViewListQuery( - $view['settings']->main_get, $view['settings']->code - )); - - // SITE_BEFORE_GET_ITEMS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_BEFORE_GET_ITEMS', CFactory::_('Customcode.Dispenser')->get( - CFactory::_('Config')->build_target . '_php_before_getitems', - $view['settings']->code, PHP_EOL, null, true - )); - - // SITE_GET_ITEMS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_GET_ITEMS', $this->setCustomViewGetItems( - $view['settings']->main_get, $view['settings']->code - )); - - // SITE_AFTER_GET_ITEMS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_AFTER_GET_ITEMS', CFactory::_('Customcode.Dispenser')->get( - CFactory::_('Config')->build_target . '_php_after_getitems', - $view['settings']->code, PHP_EOL, null, true - )); - } - // add to lang array - CFactory::_('Language')->set( - 'site', - CFactory::_('Config')->lang_prefix . '_' . $view['settings']->CODE, - $view['settings']->name - ); - CFactory::_('Language')->set( - 'site', - CFactory::_('Config')->lang_prefix . '_' . $view['settings']->CODE - . '_DESC', $view['settings']->description - ); - // SITE_CUSTOM_METHODS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_CUSTOM_METHODS', $this->setCustomViewCustomItemMethods( - $view['settings']->main_get, $view['settings']->code - )); - CFactory::_('Compiler.Builder.Content.Multi')->add($view['settings']->code . '|SITE_CUSTOM_METHODS', - $this->setCustomViewCustomMethods( - $view, $view['settings']->code - ), false - ); - // SITE_DIPLAY_METHOD <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_DIPLAY_METHOD', $this->setCustomViewDisplayMethod($view)); - // set document details - $this->setPrepareDocument($view); - // SITE_EXTRA_DIPLAY_METHODS <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_EXTRA_DIPLAY_METHODS', $this->setCustomViewExtraDisplayMethods($view)); - // SITE_CODE_BODY <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_CODE_BODY', $this->setCustomViewCodeBody($view)); - // SITE_BODY <<>> - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_BODY', $this->setCustomViewBody($view)); - - // setup the templates - $this->setCustomViewTemplateBody($view); - - // set the site form if needed - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_TOP_FORM', $this->setCustomViewForm( - $view['settings']->code, - $view['settings']->main_get->gettype, 1 - )); - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_BOTTOM_FORM', $this->setCustomViewForm( - $view['settings']->code, - $view['settings']->main_get->gettype, 2 - )); - - // set headers based on the main get type - if ($view['settings']->main_get->gettype == 1) - { - // insure the controller headers are added - if (StringHelper::check( - $view['settings']->php_controller - ) - && $view['settings']->php_controller != '//') - { - // SITE_VIEW_CONTROLLER_HEADER <<>> add the header details for the model - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_VIEW_CONTROLLER_HEADER', $this->setFileHeader( - 'site.view.controller', $view['settings']->code - )); - } - // SITE_VIEW_MODEL_HEADER <<>> add the header details for the model - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_VIEW_MODEL_HEADER', $this->setFileHeader( - 'site.view.model', $view['settings']->code - )); - // SITE_VIEW_HTML_HEADER <<>> add the header details for the view - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_VIEW_HTML_HEADER', $this->setFileHeader( - 'site.view.html', $view['settings']->code - )); - // SITE_VIEW_HEADER <<>> add the header details for the view - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_VIEW_HEADER', $this->setFileHeader( - 'site.view', $view['settings']->code - )); - } - elseif ($view['settings']->main_get->gettype == 2) - { - // insure the controller headers are added - if (StringHelper::check( - $view['settings']->php_controller - ) - && $view['settings']->php_controller != '//') - { - // SITE_VIEW_CONTROLLER_HEADER <<>> add the header details for the model - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_VIEW_CONTROLLER_HEADER', $this->setFileHeader( - 'site.views.controller', $view['settings']->code - )); - } - // SITE_VIEWS_MODEL_HEADER <<>> add the header details for the model - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_VIEWS_MODEL_HEADER', $this->setFileHeader( - 'site.views.model', $view['settings']->code - )); - // SITE_VIEWS_HTML_HEADER <<>> add the header details for the view - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_VIEWS_HTML_HEADER', $this->setFileHeader( - 'site.views.html', $view['settings']->code - )); - // SITE_VIEWS_HEADER <<>> add the header details for the view - CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_VIEWS_HEADER', $this->setFileHeader( - 'site.views', $view['settings']->code - )); - } - - // for plugin event TODO change event api signatures - $placeholders = CFactory::_('Placeholder')->active; - $fileContentStatic = CFactory::_('Compiler.Builder.Content.One')->allActive(); - $fileContentDynamic = CFactory::_('Compiler.Builder.Content.Multi')->allActive(); - // Trigger Event: jcb_ce_onAfterBuildSiteViewContent - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterBuildSiteViewContent', - array(&$component_context, &$view, - &$view['settings']->code, - &$fileContentStatic, - &$fileContentDynamic[$view['settings']->code], - &$placeholders, &$this->hhh) - ); - unset($fileContentStatic); - unset($fileContentDynamic); - unset($placeholders); - } - - // setup the layouts - $this->setCustomViewLayouts(); - } - else - { - // clear all site folder since none is needed - CFactory::_('Config')->remove_site_folder = true; - } - // load the site statics - if (!CFactory::_('Config')->remove_site_folder || !CFactory::_('Config')->remove_site_edit_folder) - { - CFactory::_('Config')->build_target = 'site'; - // if no default site view was set, the redirect to root - if (!CFactory::_('Compiler.Builder.Content.One')->exists('SITE_DEFAULT_VIEW')) - { - CFactory::_('Compiler.Builder.Content.One')->set('SITE_DEFAULT_VIEW', ''); - } - // set site custom script to helper class - // SITE_CUSTOM_HELPER_SCRIPT - CFactory::_('Compiler.Builder.Content.One')->set('SITE_CUSTOM_HELPER_SCRIPT', - CFactory::_('Placeholder')->update_( - CFactory::_('Customcode.Dispenser')->hub['component_php_helper_site'] - )); - // SITE_GLOBAL_EVENT_HELPER - if (!CFactory::_('Compiler.Builder.Content.One')->exists('SITE_GLOBAL_EVENT')) - { - CFactory::_('Compiler.Builder.Content.One')->set('SITE_GLOBAL_EVENT', ''); - } - if (!CFactory::_('Compiler.Builder.Content.One')->exists('SITE_GLOBAL_EVENT_HELPER')) - { - CFactory::_('Compiler.Builder.Content.One')->set('SITE_GLOBAL_EVENT_HELPER', ''); - } - // now load the data for the global event if needed - if (CFactory::_('Component')->get('add_site_event', 0) == 1) - { - CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT', PHP_EOL . PHP_EOL . '// Trigger the Global Site Event'); - CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT', - PHP_EOL . CFactory::_('Compiler.Builder.Content.One')->get('Component') - . 'Helper::globalEvent($document);'); - // SITE_GLOBAL_EVENT_HELPER - CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER', PHP_EOL . PHP_EOL . Indent::_(1) . '/**'); - CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER', - PHP_EOL . Indent::_(1) - . '* The Global Site Event Method.'); - CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER', PHP_EOL . Indent::_(1) . '**/'); - CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER', - PHP_EOL . Indent::_(1) - . 'public static function globalEvent($document)'); - CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER', PHP_EOL . Indent::_(1) . '{'); - CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER', - PHP_EOL . CFactory::_('Placeholder')->update_( - CFactory::_('Customcode.Dispenser')->hub['component_php_site_event'] - )); - CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER', PHP_EOL . Indent::_(1) . '}'); - } - } - - // PREINSTALLSCRIPT - CFactory::_('Compiler.Builder.Content.One')->add('PREINSTALLSCRIPT', - CFactory::_('Customcode.Dispenser')->get( - 'php_preflight', 'install', PHP_EOL, null, true - )); - - // PREUPDATESCRIPT - CFactory::_('Compiler.Builder.Content.One')->add('PREUPDATESCRIPT', - CFactory::_('Customcode.Dispenser')->get( - 'php_preflight', 'update', PHP_EOL, null, true - )); - - // POSTINSTALLSCRIPT - CFactory::_('Compiler.Builder.Content.One')->add('POSTINSTALLSCRIPT', $this->setPostInstallScript()); - - // POSTUPDATESCRIPT - CFactory::_('Compiler.Builder.Content.One')->add('POSTUPDATESCRIPT', $this->setPostUpdateScript()); - - // UNINSTALLSCRIPT - CFactory::_('Compiler.Builder.Content.One')->add('UNINSTALLSCRIPT', $this->setUninstallScript()); - - // MOVEFOLDERSSCRIPT - CFactory::_('Compiler.Builder.Content.One')->set('MOVEFOLDERSSCRIPT', $this->setMoveFolderScript()); - - // MOVEFOLDERSMETHOD - CFactory::_('Compiler.Builder.Content.One')->set('MOVEFOLDERSMETHOD', $this->setMoveFolderMethod()); - - // HELPER_UIKIT - CFactory::_('Compiler.Builder.Content.One')->set('HELPER_UIKIT', $this->setUikitHelperMethods()); - - // CONFIG_FIELDSETS - CFactory::_('Compiler.Builder.Content.One')->set('CONFIG_FIELDSETS', implode(PHP_EOL, $this->configFieldSets)); - - // check if this has been set - if (!CFactory::_('Compiler.Builder.Content.One')->exists('ROUTER_BUILD_VIEWS') - || !StringHelper::check( - CFactory::_('Compiler.Builder.Content.One')->get('ROUTER_BUILD_VIEWS') - )) - { - CFactory::_('Compiler.Builder.Content.One')->set('ROUTER_BUILD_VIEWS', 0); - } - else - { - CFactory::_('Compiler.Builder.Content.One')->set('ROUTER_BUILD_VIEWS', '(' . CFactory::_('Compiler.Builder.Content.One')->get('ROUTER_BUILD_VIEWS') . ')'); - } - - // README - if (CFactory::_('Component')->get('addreadme')) - { - CFactory::_('Compiler.Builder.Content.One')->set('README', CFactory::_('Component')->get('readme')); - } - - // CHANGELOG - if (($changelog = CFactory::_('Component')->get('changelog')) !== null) - { - CFactory::_('Compiler.Builder.Content.One')->set('CHANGELOG', $changelog); - } - - // Infuse POWERS - CFactory::_('Power.Infusion')->set(); - - // tweak system to set stuff to the module domain - $_backup_target = CFactory::_('Config')->build_target; - $_backup_lang = CFactory::_('Config')->lang_target; - $_backup_langPrefix = CFactory::_('Config')->lang_prefix; - // infuse module data if set - if (CFactory::_('Joomlamodule.Data')->exists()) - { - foreach (CFactory::_('Joomlamodule.Data')->get() as $module) - { - if (ObjectHelper::check($module)) - { - // Trigger Event: jcb_ce_onBeforeInfuseModuleData - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeInfuseModuleData', - array(&$component_context, &$module, &$this) - ); - CFactory::_('Config')->build_target = $module->key; - CFactory::_('Config')->lang_target = $module->key; - $this->langPrefix = $module->lang_prefix; - CFactory::_('Config')->set('lang_prefix', $module->lang_prefix); - // MODCODE - CFactory::_('Compiler.Builder.Content.Multi')->set($module->key . '|MODCODE', $this->getModCode($module)); - // DYNAMICGET - CFactory::_('Compiler.Builder.Content.Multi')->set($module->key . '|DYNAMICGETS', $this->setCustomViewCustomMethods( - $module, $module->key - )); - // HELPERCODE - if ($module->add_class_helper >= 1) - { - CFactory::_('Compiler.Builder.Content.Multi')->set($module->key . '|HELPERCODE', $this->getModHelperCode($module)); - } - // MODDEFAULT - CFactory::_('Compiler.Builder.Content.Multi')->set($module->key . '|MODDEFAULT', $this->getModDefault($module, $module->key)); - // MODDEFAULT_XXX - $this->setModTemplates($module); - // only add install script if needed - if ($module->add_install_script) - { - // INSTALLCLASS - CFactory::_('Compiler.Builder.Content.Multi')->set($module->key . '|INSTALLCLASS', CFactory::_('Extension.InstallScript')->get($module)); - } - // FIELDSET - if (isset($module->form_files) - && ArrayHelper::check( - $module->form_files - )) - { - foreach ($module->form_files as $file => $files) - { - foreach ($files as $field_name => $fieldsets) - { - foreach ($fieldsets as $fieldset => $fields) - { - // FIELDSET_ . $file.$field_name.$fieldset - CFactory::_('Compiler.Builder.Content.Multi')->set($module->key . - '|FIELDSET_' . $file . $field_name . $fieldset, - $this->getExtensionFieldsetXML( - $module, $fields - ) - ); - } - } - } - } - // MAINXML - CFactory::_('Compiler.Builder.Content.Multi')->set($module->key . '|MAINXML', $this->getModuleMainXML($module)); - // Trigger Event: jcb_ce_onAfterInfuseModuleData - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterInfuseModuleData', - array(&$component_context, &$module, &$this) - ); - } - } - } - // infuse plugin data if set - if (CFactory::_('Joomlaplugin.Data')->exists()) - { - foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin) - { - if (ObjectHelper::check($plugin)) - { - // Trigger Event: jcb_ce_onBeforeInfusePluginData - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeInfusePluginData', - array(&$component_context, &$plugin, &$this) - ); - CFactory::_('Config')->build_target = $plugin->key; - CFactory::_('Config')->lang_target = $plugin->key; - $this->langPrefix = $plugin->lang_prefix; - CFactory::_('Config')->set('lang_prefix', $plugin->lang_prefix); - // MAINCLASS - CFactory::_('Compiler.Builder.Content.Multi')->set($plugin->key . '|MAINCLASS', $this->getPluginMainClass($plugin)); - // only add install script if needed - if ($plugin->add_install_script) - { - // INSTALLCLASS - CFactory::_('Compiler.Builder.Content.Multi')->set($plugin->key . '|INSTALLCLASS', CFactory::_('Extension.InstallScript')->get($plugin)); - } - // FIELDSET - if (isset($plugin->form_files) - && ArrayHelper::check( - $plugin->form_files - )) - { - foreach ($plugin->form_files as $file => $files) - { - foreach ($files as $field_name => $fieldsets) - { - foreach ($fieldsets as $fieldset => $fields) - { - // FIELDSET_ . $file.$field_name.$fieldset - CFactory::_('Compiler.Builder.Content.Multi')->set($plugin->key . - '|FIELDSET_' . $file . $field_name . $fieldset, - $this->getExtensionFieldsetXML( - $plugin, $fields - ) - ); - } - } - } - } - // MAINXML - CFactory::_('Compiler.Builder.Content.Multi')->set($plugin->key . '|MAINXML', $this->getPluginMainXML($plugin)); - // Trigger Event: jcb_ce_onAfterInfusePluginData - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterInfusePluginData', - array(&$component_context, &$plugin, &$this) - ); - } - } - } - // rest globals - CFactory::_('Config')->build_target = $_backup_target; - CFactory::_('Config')->lang_target = $_backup_lang; - $this->langPrefix = $_backup_langPrefix; - CFactory::_('Config')->set('lang_prefix', $_backup_langPrefix); - // for plugin event TODO change event api signatures - $placeholders = CFactory::_('Placeholder')->active; - $fileContentStatic = CFactory::_('Compiler.Builder.Content.One')->allActive(); - $fileContentDynamic = CFactory::_('Compiler.Builder.Content.Multi')->allActive(); - // Trigger Event: jcb_ce_onAfterBuildFilesContent - CFactory::_('Event')->trigger( - 'jcb_ce_onAfterBuildFilesContent', - array(&$component_context, &$this->componentData, - &$fileContentStatic, &$fileContentDynamic, - &$placeholders, &$this->hhh) - ); - unset($fileContentStatic); - unset($fileContentDynamic); - unset($placeholders); - - return true; - } - - return false; - } - - /** - * Set the view place holders to global scope - * - * @param object $view The view settings - * - * @ return void - */ - protected function setViewPlaceholders(&$view) - { - // just to be safe, lets clear previous view placeholders - CFactory::_('Placeholder')->clearType('view'); - CFactory::_('Placeholder')->clearType('views'); - - // VIEW <<>> - if (isset($view->name_single) && $view->name_single != 'null') - { - // set main keys - $nameSingleCode = $view->name_single_code; - $name_single_uppercase = StringHelper::safe( - $view->name_single, 'U' - ); - $name_single_first_uppercase = StringHelper::safe( - $view->name_single, 'F' - ); - - // set some place holder for the views - CFactory::_('Placeholder')->set('view', $nameSingleCode); - CFactory::_('Placeholder')->set('View', $name_single_first_uppercase); - CFactory::_('Placeholder')->set('VIEW', $name_single_uppercase); - } - - // VIEWS <<>> - if (isset($view->name_list) && $view->name_list != 'null') - { - $nameListCode = $view->name_list_code; - $name_list_uppercase = StringHelper::safe( - $view->name_list, 'U' - ); - $name_list_first_uppercase = StringHelper::safe( - $view->name_list, 'F' - ); - - // set some place holder for the views - CFactory::_('Placeholder')->set('views', $nameListCode); - CFactory::_('Placeholder')->set('Views', $name_list_first_uppercase); - CFactory::_('Placeholder')->set('VIEWS', $name_list_uppercase); - } - - // view <<>> - if (isset($nameSingleCode)) - { - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|view', $nameSingleCode); - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|VIEW', $name_single_uppercase); - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|View', $name_single_first_uppercase); - - if (isset($nameListCode)) - { - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|view', $nameSingleCode); - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|VIEW', $name_single_uppercase); - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|View', $name_single_first_uppercase); - } - } - - // views <<>> - if (isset($nameListCode)) - { - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|views', $nameListCode); - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|VIEWS', $name_list_uppercase); - CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|Views', $name_list_first_uppercase); - - if (isset($nameSingleCode)) - { - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|views', $nameListCode); - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|VIEWS', $name_list_uppercase); - CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|Views', $name_list_first_uppercase); - } - } - } - - /** - * Build the language values and insert into file - * - * @return boolean on success - * - */ - public function setLangFileData() - { - // reset values - $values = array(); - $mainLangLoader = array(); - // check the admin lang is set - if ($this->setLangAdmin()) - { - $values[] = array_values( - $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['admin'] - ); - $mainLangLoader['admin'] = count( - $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['admin'] - ); - } - // check the admin system lang is set - if ($this->setLangAdminSys()) - { - $values[] = array_values( - $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['adminsys'] - ); - $mainLangLoader['adminsys'] = count( - $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['adminsys'] - ); - } - // check the site lang is set - if ((!CFactory::_('Config')->remove_site_folder || !CFactory::_('Config')->remove_site_edit_folder) - && $this->setLangSite()) - { - $values[] = array_values( - $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['site'] - ); - $mainLangLoader['site'] = count( - $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['site'] - ); - } - // check the site system lang is set - if ((!CFactory::_('Config')->remove_site_folder || !CFactory::_('Config')->remove_site_edit_folder) - && $this->setLangSiteSys()) - { - $values[] = array_values( - $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['sitesys'] - ); - $mainLangLoader['sitesys'] = count( - $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['sitesys'] - ); - } - $values = array_unique(ArrayHelper::merge($values)); - // get the other lang strings if there is any - $this->multiLangString = $this->getMultiLangStrings($values); - // update insert the current lang in to DB - $this->setLangPlaceholders($values, CFactory::_('Config')->component_id); - // remove old unused language strings - $this->purgeLanuageStrings($values, CFactory::_('Config')->component_id); - // path to INI file - $getPAth = CFactory::_('Utilities.Paths')->template_path . '/en-GB.com_admin.ini'; - // for plugin event TODO change event api signatures - $component_context = CFactory::_('Config')->component_context; - // Trigger Event: jcb_ce_onBeforeBuildAllLangFiles - CFactory::_('Event')->trigger( - 'jcb_ce_onBeforeBuildAllLangFiles', - array(&$component_context, &$this->languages['components'], - &$this->langTag) - ); - // for plugin event TODO change event api signatures - CFactory::_('Config')->lang_tag = $this->langTag; - // now we insert the values into the files - if (ArrayHelper::check($this->languages['components'])) - { - // rest xml array - $langXML = array(); - foreach ($this->languages['components'] as $tag => $areas) - { - // trim the tag - $tag = trim((string) $tag); - foreach ($areas as $area => $languageStrings) - { - // set naming convention - $p = 'admin'; - $t = ''; - if (strpos((string) $area, 'site') !== false) - { - if (CFactory::_('Config')->remove_site_folder - && CFactory::_('Config')->remove_site_edit_folder) - { - continue; - } - $p = 'site'; - } - if (strpos((string) $area, 'sys') !== false) - { - $t = '.sys'; - } - // build the file name - $file_name = $tag . '.com_' . CFactory::_('Config')->component_code_name . $t - . '.ini'; - // check if language should be added - if ($this->shouldLanguageBeAdded( - $tag, $languageStrings, $mainLangLoader[$area], - $file_name - )) - { - // build the path to place the lang file - $path = CFactory::_('Utilities.Paths')->component_path . '/' . $p . '/language/' - . $tag . '/'; - if (!Folder::exists($path)) - { - Folder::create($path); - // count the folder created - CFactory::_('Utilities.Counter')->folder++; - } - // move the file to its place - File::copy($getPAth, $path . $file_name); - // count the file created - CFactory::_('Utilities.Counter')->file++; - // add content to it - $lang = array_map( - fn($langstring, $placeholder) => $placeholder . '="' . $langstring . '"', - array_values($languageStrings), - array_keys($languageStrings) - ); - // add to language file - CFactory::_('Utilities.File')->write( - $path . $file_name, implode(PHP_EOL, $lang) - ); - // set the line counter - CFactory::_('Utilities.Counter')->line += count( - (array) $lang - ); - unset($lang); - // build xml strings - if (!isset($langXML[$p])) - { - $langXML[$p] = array(); - } - $langXML[$p][] = 'language/' - . $tag . '/' . $file_name . ''; - } - } - } - // load the lang xml - if (ArrayHelper::check($langXML)) - { - $replace = array(); - if (isset($langXML['admin']) - && ArrayHelper::check($langXML['admin'])) - { - $replace[Placefix::_h('ADMIN_LANGUAGES')] - = implode(PHP_EOL . Indent::_(3), $langXML['admin']); - } - if ((!CFactory::_('Config')->remove_site_folder || !CFactory::_('Config')->remove_site_edit_folder) - && isset($langXML['site']) - && ArrayHelper::check($langXML['site'])) - { - $replace[Placefix::_h('SITE_LANGUAGES')] - = implode(PHP_EOL . Indent::_(2), $langXML['site']); - } - // build xml path - $xmlPath = CFactory::_('Utilities.Paths')->component_path . '/' . CFactory::_('Config')->component_code_name - . '.xml'; - // get the content in xml - $componentXML = FileHelper::getContent( - $xmlPath - ); - // update the xml content - $componentXML = CFactory::_('Placeholder')->update($componentXML, $replace); - // store the values back to xml - CFactory::_('Utilities.File')->write($xmlPath, $componentXML); - } - } - } - -} diff --git a/admin/helpers/componentbuilder.php b/admin/helpers/componentbuilder.php deleted file mode 100644 index 32ea59243..000000000 --- a/admin/helpers/componentbuilder.php +++ /dev/null @@ -1,6727 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// add the autoloader for the composer classes -$composer_autoloader = JPATH_LIBRARIES . '/phpseclib3/vendor/autoload.php'; -if (file_exists($composer_autoloader)) -{ - require_once $composer_autoloader; -} - -// register this component namespace -spl_autoload_register(function ($class) { - // project-specific base directories and namespace prefix - $search = [ - 'libraries/jcb_powers/VDM.Joomla.Openai' => 'VDM\\Joomla\\Openai', - 'libraries/jcb_powers/VDM.Joomla.Gitea' => 'VDM\\Joomla\\Gitea', - 'libraries/jcb_powers/VDM.Joomla.FOF' => 'VDM\\Joomla\\FOF', - 'libraries/jcb_powers/VDM.Joomla' => 'VDM\\Joomla', - 'libraries/jcb_powers/VDM.Minify' => 'VDM\\Minify', - 'libraries/jcb_powers/VDM.Psr' => 'VDM\\Psr' - ]; - // Start the search and load if found - $found = false; - $found_base_dir = ""; - $found_len = 0; - foreach ($search as $base_dir => $prefix) - { - // does the class use the namespace prefix? - $len = strlen($prefix); - if (strncmp($prefix, $class, $len) === 0) - { - // we have a match so load the values - $found = true; - $found_base_dir = $base_dir; - $found_len = $len; - // done here - break; - } - } - // check if we found a match - if (!$found) - { - // not found so move to the next registered autoloader - return; - } - // get the relative class name - $relative_class = substr($class, $found_len); - // replace the namespace prefix with the base directory, replace namespace - // separators with directory separators in the relative class name, append - // with .php - $file = JPATH_ROOT . '/' . $found_base_dir . '/src' . str_replace('\\', '/', $relative_class) . '.php'; - // if the file exists, require it - if (file_exists($file)) - { - require $file; - } -}); - -use Joomla\CMS\Filesystem\File; -use Joomla\CMS\Language\Language; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; -use PhpOffice\PhpSpreadsheet\IOFactory; -use PhpOffice\PhpSpreadsheet\Spreadsheet; -use PhpOffice\PhpSpreadsheet\Writer\Xlsx; -use VDM\Joomla\Utilities; -use Joomla\Archive\Archive; -use Joomla\CMS\Filesystem\Folder; -use Joomla\CMS\Filesystem\Path; -use VDM\Joomla\Componentbuilder\Compiler\Factory; -use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; -use VDM\Joomla\Utilities\GetHelper; -use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; -use VDM\Joomla\Utilities\JsonHelper; -use VDM\Joomla\Utilities\FileHelper; -use VDM\Joomla\Utilities\ObjectHelper; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\FieldHelper; -use VDM\Joomla\Utilities\Base64Helper; -use VDM\Joomla\FOF\Encrypt\AES; -use VDM\Joomla\Utilities\FormHelper; - -/** - * Componentbuilder component helper. - */ -abstract class ComponentbuilderHelper -{ - /** - * Adding the utilities trait to this class - * - * @deprecated 4.0 - Check the trait methods for details, a legacy implementation - */ - use Utilities; - - /** - * get the Component Code Name - */ - public static $ComponentCodeName = 'componentbuilder'; - - /** - * Composer Switch - * - * @var array - */ - protected static $composer = array(); - - /** - * The Global Admin Event Method. - **/ - public static function globalEvent($document) - { - // the Session keeps track of all data related to the current session of this user - self::loadSession(); - } - - - /** - * Just to Add the OPEN AI api to JCB (soon) - * Factory - **/ - - /** - * Locked Libraries (we can not have these change) - **/ - public static $libraryNames = array(1 => 'No Library', 2 => 'Bootstrap v4', 3 => 'Uikit v3', 4 => 'Uikit v2', 5 => 'FooTable v2', 6 => 'FooTable v3'); - - /** - * Array of php fields Allowed (16) - **/ - public static $phpFieldArray = array('', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'x', 'HEADER'); - - /** - * The global params - **/ - protected static $params = false; - - /** - * The global updater - **/ - protected static $globalUpdater = array(); - - /** - * The local company details - **/ - protected static $localCompany = array(); - - /** - * The excluded powers - **/ - protected static $exPowers= array(); - - /** - * The snippet paths - **/ - public static $snippetPath = 'https://raw.githubusercontent.com/vdm-io/Joomla-Component-Builder-Snippets/master/'; - public static $snippetsPath = 'https://api.github.com/repos/vdm-io/Joomla-Component-Builder-Snippets/git/trees/master'; - - /** - * The VDM packages paths - **/ - public static $vdmGithubPackageUrl = "https://github.com/vdm-io/JCB-Packages/raw/master/"; - public static $vdmGithubPackagesUrl = "https://api.github.com/repos/vdm-io/JCB-Packages/git/trees/master"; - - /** - * The JCB packages paths - **/ - public static $jcbGithubPackageUrl = "https://github.com/vdm-io/JCB-Community-Packages/raw/master/"; - public static $jcbGithubPackagesUrl = "https://api.github.com/repos/vdm-io/JCB-Community-Packages/git/trees/master"; - - /** - * The bolerplate paths - **/ - public static $bolerplatePath = 'https://raw.githubusercontent.com/vdm-io/boilerplate/jcb/'; - public static $bolerplateAPI = 'https://api.github.com/repos/vdm-io/boilerplate/git/trees/jcb'; - - /** - * The array of constant paths - * - * JPATH_SITE is meant to represent the root path of the JSite application, - * just as JPATH_ADMINISTRATOR is mean to represent the root path of the JAdministrator application. - * - * JPATH_BASE is the root path for the current requested application.... so if you are in the administrator application: - * - * JPATH_BASE == JPATH_ADMINISTRATOR - * - * If you are in the site application: - * - * JPATH_BASE == JPATH_SITE - * - * If you are in the installation application: - * - * JPATH_BASE == JPATH_INSTALLATION. - * - * JPATH_ROOT is the root path for the Joomla install and does not depend upon any application. - * - * @var array - */ - public static $constantPaths = array( - // The path to the administrator folder. - 'JPATH_ADMINISTRATOR' => JPATH_ADMINISTRATOR, - // The path to the installed Joomla! site, or JPATH_ROOT/administrator if executed from the backend. - 'JPATH_BASE' => JPATH_BASE, - // The path to the cache folder. - 'JPATH_CACHE' => JPATH_CACHE, - // The path to the administration folder of the current component being executed. - 'JPATH_COMPONENT_ADMINISTRATOR' => JPATH_COMPONENT_ADMINISTRATOR, - // The path to the site folder of the current component being executed. - 'JPATH_COMPONENT_SITE' => JPATH_COMPONENT_SITE, - // The path to the current component being executed. - 'JPATH_COMPONENT' => JPATH_COMPONENT, - // The path to folder containing the configuration.php file. - 'JPATH_CONFIGURATION' => JPATH_CONFIGURATION, - // The path to the installation folder. - 'JPATH_INSTALLATION' => JPATH_INSTALLATION, - // The path to the libraries folder. - 'JPATH_LIBRARIES' => JPATH_LIBRARIES, - // The path to the plugins folder. - 'JPATH_PLUGINS' => JPATH_PLUGINS, - // The path to the installed Joomla! site. - 'JPATH_ROOT' => JPATH_ROOT, - // The path to the installed Joomla! site. - 'JPATH_SITE' => JPATH_SITE, - // The path to the templates folder. - 'JPATH_THEMES' => JPATH_THEMES - ); - - /** - * get the class method or property - * - * @input int The method/property ID - * @input string The target type - * - * @returns string on success - **/ - public static function getClassCode($id, $type) - { - if ('property' === $type || 'method' === $type) - { - // Get a db connection. - $db = JFactory::getDbo(); - // Get user object - $user = JFactory::getUser(); - // Create a new query object. - $query = $db->getQuery(true); - // get method - if ('method' === $type) - { - $query->select($db->quoteName(array('a.comment','a.name','a.visibility','a.arguments','a.code'))); - } - // get property - elseif ('property' === $type) - { - $query->select($db->quoteName(array('a.comment','a.name','a.visibility','a.default'))); - } - $query->from($db->quoteName('#__componentbuilder_class_' . $type,'a')); - $query->where($db->quoteName('a.id') . ' = ' . (int) $id); - // Implement View Level Access - if (!$user->authorise('core.options', 'com_componentbuilder')) - { - $columns = $db->getTableColumns('#__componentbuilder_class_' . $type); - if(isset($columns['access'])) - { - $groups = implode(',', $user->getAuthorisedViewLevels()); - $query->where('a.access IN (' . $groups . ')'); - } - } - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - // get the code - $code = $db->loadObject(); - // combine method values - $combinded = array(); - // add comment if set - if (UtilitiesStringHelper::check($code->comment)) - { - $comment = array_map('trim', (array) explode(PHP_EOL, base64_decode($code->comment))); - $combinded[] = "\t" . implode(PHP_EOL . "\t ", $comment); - } - // build method - if ('method' === $type) - { - // set the method signature - if (UtilitiesStringHelper::check($code->arguments)) - { - $combinded[] = "\t" . $code->visibility . ' function ' . $code->name . '(' . base64_decode($code->arguments) . ')'; - } - else - { - $combinded[] = "\t" . $code->visibility . ' function ' . $code->name . '()'; - } - // set the method code - $combinded[] = "\t" . "{"; - // add code if set - if (UtilitiesStringHelper::check(trim($code->code))) - { - $combinded[] = base64_decode($code->code); - } - else - { - $combinded[] = "\t\t// add your code here"; - } - $combinded[] = "\t" . "}"; - } - else - { - if (UtilitiesStringHelper::check($code->default)) - { - $code->default = base64_decode($code->default); - if (is_int($code->default)) - { - // set the class property - $combinded[] = "\t" . $code->visibility . ' $' . $code->name . ' = ' . (int) $code->default . ';'; - } - elseif (is_float($code->default)) - { - // set the class property - $combinded[] = "\t" . $code->visibility . ' $' . $code->name . ' = ' . (float) $code->default . ';'; - } - elseif (('false' === $code->default || 'true' === $code->default) - || (UtilitiesStringHelper::check($code->default) && (strpos($code->default, 'array(') !== false || strpos($code->default, '"') !== false))) - { - // set the class property - $combinded[] = "\t" . $code->visibility . ' $' . $code->name . ' = ' . $code->default . ';'; - } - elseif (UtilitiesStringHelper::check($code->default) && strpos($code->default, '"') === false) - { - // set the class property - $combinded[] = "\t" . $code->visibility . ' $' . $code->name . ' = "' . $code->default . '";'; - } - else - { - // set the class property - $combinded[] = "\t" . $code->visibility . ' $' . $code->name . ';'; - } - } - else - { - // set the class property - $combinded[] = "\t" . $code->visibility . ' $' . $code->name . ';'; - } - } - // return the code - return implode(PHP_EOL, $combinded); - } - } - return false; - } - - /** - * extract Boilerplate Class Extends - * - * @input string The class as a string - * @input string The type of class/extension - * - * @returns string on success - **/ - public static function extractBoilerplateClassExtends(&$class, $type) - { - if (($strings = GetHelper::allBetween($class, 'class ', '}')) !== false && UtilitiesArrayHelper::check($strings)) - { - foreach ($strings as $string) - { - if (($extends = GetHelper::between($string, 'extends ', '{')) !== false && UtilitiesStringHelper::check($extends)) - { - return trim($extends); - } - } - } - return false; - } - - /** - * extract Boilerplate Class Header - * - * @input string The class as a string - * @input string The class being extended - * @input string The type of class/extension - * - * @returns string on success - **/ - public static function extractBoilerplateClassHeader(&$class, $extends, $type) - { - if (($string = GetHelper::between($class, "defined('_JEXEC')", 'extends ' . $extends)) !== false && UtilitiesStringHelper::check($string)) - { - $headArray = explode(PHP_EOL, $string); - if (UtilitiesArrayHelper::check($headArray) && count($headArray) > 3) - { - // remove first since it still has the [or die;] string in it - array_shift($headArray); - // remove the last since it has the class declaration - array_pop($headArray); - // at this point we have the class comment still in as part of the header, lets remove that - $last = count($headArray); - while ($last > 0) - { - $last--; - if (isset($headArray[$last]) && strpos($headArray[$last], '*') !== false) - { - unset($headArray[$last]); - } - else - { - // moment the comment stops, we break out - $last = 0; - } - } - // make sure we only return if we have values - if (UtilitiesArrayHelper::check($headArray)) - { - return implode(PHP_EOL, $headArray); - } - } - } - return false; - } - - /** - * extract Boilerplate Class Comment - * - * @input string The class as a string - * @input string The class being extended - * @input string The type of class/extension - * - * @returns string on success - **/ - public static function extractBoilerplateClassComment(&$class, $extends, $type) - { - if (($string = GetHelper::between($class, "defined('_JEXEC')", 'extends ' . $extends)) !== false && UtilitiesStringHelper::check($string)) - { - $headArray = explode(PHP_EOL, $string); - if (UtilitiesArrayHelper::check($headArray) && count($headArray) > 3) - { - $comment = array(); - // remove the last since it has the class declaration - array_pop($headArray); - // at this point we have the class comment still in as part of the header, lets remove that - $last = count($headArray); - while ($last > 0) - { - $last--; - if (isset($headArray[$last]) && strpos($headArray[$last], '*') !== false) - { - $comment[$last] = $headArray[$last]; - } - else - { - // moment the comment stops, we break out - $last = 0; - } - } - // make sure we only return if we have values - if (UtilitiesArrayHelper::check($comment)) - { - // set the correct order - ksort($comment); - $replace = array('Foo' => '[[[Plugin_name]]]', '[PACKAGE_NAME]' => '[[[Plugin]]]', '1.0.0' => '[[[plugin.version]]]', '1.0' => '[[[plugin.version]]]'); - // now update with JCB placeholders - return str_replace(array_keys($replace), array_values($replace), implode(PHP_EOL, $comment)); - } - } - } - return false; - } - - /** - * extract Boilerplate Class Properties & Methods - * - * @input string The class as a string - * @input string The class being extended - * @input string The type of class/extension - * @input int The plugin groups - * - * @returns string on success - **/ - public static function extractBoilerplateClassPropertiesMethods(&$class, $extends, $type, $plugin_group = null) - { - $bucket = array('property' => array(), 'method' => array()); - // get the class code, and remove the head - $codeArrayTmp = explode('extends ' . $extends, $class); - // make sure we have the correct result - if (UtilitiesArrayHelper::check($codeArrayTmp) && count($codeArrayTmp) == 2) - { - // the triggers - $triggers = array('public' => 1, 'protected' => 2, 'private' => 3); - $codeArray = explode(PHP_EOL, $codeArrayTmp[1]); - unset($codeArrayTmp); - // clean the code - self::cleanBoilerplateCode($codeArray); - // temp bucket - $name = null; - $arg = null; - $target = null; - $visibility = null; - $tmp = array(); - $comment = array(); - // load method - $loadCode = function (&$bucket, &$target, &$name, &$arg, &$visibility, &$tmp, &$comment) use($type, $plugin_group){ - $_tmp = array( - 'name' => $name, - 'visibility' => $visibility, - 'extension_type' => $type - ); - // build filter - $filters = array('extension_type' => $type); - // add more data based on target - if ('method' === $target && UtilitiesArrayHelper::check($tmp)) - { - // clean the code - self::cleanBoilerplateCode($tmp); - // only load if there are values - if (UtilitiesArrayHelper::check($tmp, true)) - { - $_tmp['code'] = implode(PHP_EOL, $tmp); - } - else - { - $_tmp['code'] = ''; - } - // load arguments only if set - if (UtilitiesStringHelper::check($arg)) - { - $_tmp['arguments'] = $arg; - } - } - elseif ('property' === $target) - { - // load default only if set - if (UtilitiesStringHelper::check($arg)) - { - $_tmp['default'] = $arg; - } - } - // load comment only if set - if (UtilitiesArrayHelper::check($comment, true)) - { - $_tmp['comment'] = implode(PHP_EOL, $comment); - } - // load the group target - if ($plugin_group) - { - $_tmp['joomla_plugin_group'] = $plugin_group; - $filters['joomla_plugin_group'] = $plugin_group; - } - // load the local values - if (($locals = self::getLocalBoilerplate($name, $target, $type, $filters)) !== false) - { - foreach ($locals as $key => $value) - { - $_tmp[$key] = $value; - } - } - else - { - $_tmp['id'] = 0; - $_tmp['published'] = 1; - $_tmp['version'] = 1; - } - // store the data based on target - $bucket[$target][] = $_tmp; - }; - // now we start loading - foreach($codeArray as $line) - { - if ($visibility && $target && $name && strpos($line, '/**') !== false) - { - $loadCode($bucket, $target, $name, $arg, $visibility, $tmp, $comment); - // reset loop buckets - $name = null; - $arg = null; - $target = null; - $visibility = null; - $tmp = array(); - $comment = array(); - } - // load the comment before method/property - if (!$visibility && !$target && !$name && strpos($line, '*') !== false) - { - $comment[] = rtrim($line); - } - else - { - if (!$visibility && !$target && !$name) - { - // get the line values - $lineArray = array_values(array_map('trim', preg_split('/\s+/', trim($line)))); - // check if we are at the main line - if (isset($lineArray[0]) && isset($triggers[$lineArray[0]])) - { - $visibility = $lineArray[0]; - if (strpos($line, 'function') !== false) - { - $target = 'method'; - // get the name - $name = trim(GetHelper::between($line, 'function ', '(')); - // get the arguments - $arg = trim(GetHelper::between($line, ' ' . $name . '(', ')')); - } - else - { - $target = 'property'; - if (strpos($line, '=') !== false) - { - // get the name - $name = trim(GetHelper::between($line, '$', '=')); - // get the default - $arg = trim(GetHelper::between($line, '=', ';')); - } - else - { - // get the name - $name = trim(GetHelper::between($line, '$', ';')); - } - } - } - } - else - { - $tmp[] = rtrim($line); - } - } - } - // check if a last method is still around - if ($visibility && $target && $name) - { - $loadCode($bucket, $target, $name, $arg, $visibility, $tmp, $comment); - // reset loop buckets - $name = null; - $arg = null; - $target = null; - $visibility = null; - $tmp = array(); - $comment = array(); - } - return $bucket; - } - return false; - } - - protected static function getLocalBoilerplate($name, $table, $extension_type, $filters = array()) - { - if ('property' === $table || 'method' === $table) - { - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - // get method - $query->select($db->quoteName(array('a.id','a.published','a.version'))); - $query->from($db->quoteName('#__componentbuilder_class_' . $table,'a')); - $query->where($db->quoteName('a.name') . ' = ' . $db->quote($name)); - $query->where($db->quoteName('a.extension_type') . ' = ' . $db->quote($extension_type)); - // add more filters - if (UtilitiesArrayHelper::check($filters)) - { - foreach($filters as $where => $value) - { - if (is_numeric($value)) - { - $query->where($db->quoteName('a.' . $where) . ' = ' . $value); - } - else - { - $query->where($db->quoteName('a.' . $where) . ' = ' . $db->quote($value)); - } - } - } - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - // get the code - return $db->loadAssoc(); - } - } - return false; - } - - protected static function cleanBoilerplateCode(&$code) - { - // remove the first lines until a { is found - $key = 0; - $found = false; - while (!$found) - { - if (isset($code[$key])) - { - if (strpos($code[$key], '{') !== false) - { - unset($code[$key]); - // only remove the first } found - $found = true; - } - // remove empty lines - elseif (!UtilitiesStringHelper::check(trim($code[$key]))) - { - unset($code[$key]); - } - } - // check next line - $key++; - // stop loop at line 30 (really this should never happen) - if ($key > 30) - { - $found = true; - } - } - // reset all keys - $code = array_values($code); - // remove last lines until } - $last = count($code); - while ($last > 0) - { - $last--; - if (isset($code[$last])) - { - if (strpos($code[$last], '}') !== false) - { - unset($code[$last]); - // only remove the first } found - $last = 0; - } - // remove empty lines - elseif (!UtilitiesStringHelper::check(trim($code[$last]))) - { - unset($code[$last]); - } - } - } - } - - /* - * Get the Array of Existing Validation Rule Names - * - * @return array - */ - public static function getExistingValidationRuleNames($lowercase = false) - { - // get the items - $items = self::get('_existing_validation_rules_VDM', null); - if (!$items) - { - // load the file class - jimport('joomla.filesystem.file'); - jimport('joomla.filesystem.folder'); - // set the path to the form validation rules - $path = JPATH_LIBRARIES . '/src/Form/Rule'; - // check if the path exist - if (!Folder::exists($path)) - { - return false; - } - // we must first store the current working directory - $joomla = getcwd(); - // go to that folder - chdir($path); - // load all the files in this path - $items = Folder::files('.', '\.php', true, true); - // change back to Joomla working directory - chdir($joomla); - // make sure we have an array - if (!UtilitiesArrayHelper::check($items)) - { - return false; - } - // remove the Rule.php from the name - $items = array_map( function ($name) { - return str_replace(array('./','Rule.php'), '', $name); - }, $items); - // store the names for next run - self::set('_existing_validation_rules_VDM', json_encode($items)); - } - // make sure it is no longer json - if (JsonHelper::check($items)) - { - $items = json_decode($items, true); - } - // check if the names should be all lowercase - if ($lowercase) - { - $items = array_map( function($item) { - return strtolower($item); - }, $items); - } - return $items; - } - - /** - * Get the snippet contributor details - * - * @param string $filename The file name - * @param string $type The type of file - * - * @return array On success the contributor details - * - */ - public static function getContributorDetails($filename, $type = 'snippet') - { - // start loading the contributor details - $contributor = array(); - // get the path & content - switch ($type) - { - case 'snippet': - $path = self::$snippetPath.$filename; - // get the file if available - $content = FileHelper::getContent($path); - if (JsonHelper::check($content)) - { - $content = json_decode($content, true); - } - break; - default: - // only allow types that are being targeted - return false; - break; - } - // see if we have content and all needed details - if (isset($content) && UtilitiesArrayHelper::check($content) - && isset($content['contributor_company']) - && isset($content['contributor_name']) - && isset($content['contributor_email']) - && isset($content['contributor_website'])) - { - // got the details from file - return array('contributor_company' => $content['contributor_company'] ,'contributor_name' => $content['contributor_name'], 'contributor_email' => $content['contributor_email'], 'contributor_website' => $content['contributor_website'], 'origin' => 'file'); - } - // get the global settings - if (!ObjectHelper::check(self::$params)) - { - self::$params = JComponentHelper::getParams('com_componentbuilder'); - } - // get the global company details - if (!UtilitiesArrayHelper::check(self::$localCompany)) - { - // Set the person sharing information (default VDM ;) - self::$localCompany['company'] = self::$params->get('export_company', 'Vast Development Method'); - self::$localCompany['owner'] = self::$params->get('export_owner', 'Llewellyn van der Merwe'); - self::$localCompany['email'] = self::$params->get('export_email', 'joomla@vdm.io'); - self::$localCompany['website'] = self::$params->get('export_website', 'https://www.vdm.io/'); - } - // default global - return array('contributor_company' => self::$localCompany['company'] ,'contributor_name' => self::$localCompany['owner'], 'contributor_email' => self::$localCompany['email'], 'contributor_website' => self::$localCompany['website'], 'origin' => 'global'); - } - - /** - * Get the library files - * - * @param int $id The library id to target - * - * @return array On success the array of files that belong to this library - * - */ - public static function getLibraryFiles($id) - { - // get the library files, folders, and urls - $files = array(); - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('b.name','a.addurls','a.addfolders','a.addfiles'))); - $query->from($db->quoteName('#__componentbuilder_library_files_folders_urls','a')); - $query->join('LEFT', $db->quoteName('#__componentbuilder_library', 'b') . ' ON (' . $db->quoteName('a.library') . ' = ' . $db->quoteName('b.id') . ')'); - $query->where($db->quoteName('a.library') . ' = ' . (int) $id); - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - // prepare the files - $result = $db->loadObject(); - // first we load the URLs - if (JsonHelper::check($result->addurls)) - { - // convert to array - $result->addurls = json_decode($result->addurls, true); - // set urls - if (UtilitiesArrayHelper::check($result->addurls)) - { - // build media folder path - $mediaPath = '/media/' . strtolower( preg_replace('/\s+/', '-', UtilitiesStringHelper::safe($result->name, 'filename', ' ', false))); - // load the urls - foreach($result->addurls as $url) - { - if (isset($url['url']) && UtilitiesStringHelper::check($url['url'])) - { - // set the path if needed - if (isset($url['type']) && $url['type'] > 1) - { - $fileName = basename($url['url']); - // build sub path - if (strpos($fileName, '.js') !== false) - { - $path = '/js'; - } - elseif (strpos($fileName, '.css') !== false) - { - $path = '/css'; - } - else - { - $path = ''; - } - // set the path to library file - $url['path'] = $mediaPath . $path . '/' . $fileName; // we need this for later - } - // if local path is set, then use it first - if (isset($url['path'])) - { - // load document script - $files[md5($url['path'])] = '(' . JText::_('URL') . ') ' . basename($url['url']) . ' - ' . JText::_('COM_COMPONENTBUILDER_LOCAL'); - } - // check if link must be added - if (isset($url['url']) && ((isset($url['type']) && $url['type'] == 1) || (isset($url['type']) && $url['type'] == 3) || !isset($url['type']))) - { - // load url also if not building document - $files[md5($url['url'])] = '(' . JText::_('URL') . ') ' . basename($url['url']) . ' - ' . JText::_('COM_COMPONENTBUILDER_LINK'); - } - } - } - } - } - // load the local files - if (JsonHelper::check($result->addfiles)) - { - // convert to array - $result->addfiles = json_decode($result->addfiles, true); - // set files - if (UtilitiesArrayHelper::check($result->addfiles)) - { - foreach($result->addfiles as $file) - { - if (isset($file['file']) && isset($file['path'])) - { - $path = '/'.trim($file['path'], '/'); - // check if path has new file name (has extetion) - $pathInfo = pathinfo($path); - if (isset($pathInfo['extension']) && $pathInfo['extension']) - { - // load document script - $files[md5($path)] = '(' . JText::_('COM_COMPONENTBUILDER_FILE') . ') ' . $file['file']; - } - else - { - // load document script - $files[md5($path.'/'.trim($file['file'],'/'))] = '(' . JText::_('COM_COMPONENTBUILDER_FILE') . ') ' . $file['file']; - } - } - } - } - } - // load the files in the folder - if (JsonHelper::check($result->addfolders)) - { - // convert to array - $result->addfolders = json_decode($result->addfolders, true); - // set folder - if (UtilitiesArrayHelper::check($result->addfolders)) - { - // get the global settings - if (!ObjectHelper::check(self::$params)) - { - self::$params = JComponentHelper::getParams('com_componentbuilder'); - } - // reset bucket - $bucket = array(); - // get custom folder path - $customPath = '/'.trim(self::$params->get('custom_folder_path', JPATH_COMPONENT_ADMINISTRATOR.'/custom'), '/'); - // get all the file paths - foreach ($result->addfolders as $folder) - { - if (isset($folder['path']) && isset($folder['folder'])) - { - $_path = '/'.trim($folder['path'], '/'); - $customFolder = '/'.trim($folder['folder'], '/'); - if (isset($folder['rename']) && 1 == $folder['rename']) - { - if ($_paths = FileHelper::getPaths($customPath.$customFolder)) - { - $bucket[$_path] = $_paths; - } - } - else - { - $path = $_path.$customFolder; - if ($_paths = FileHelper::getPaths($customPath.$customFolder)) - { - $bucket[$path] = $_paths; - } - } - } - } - // now load the script - if (UtilitiesArrayHelper::check($bucket)) - { - foreach ($bucket as $root => $paths) - { - // load per path - foreach($paths as $path) - { - $files[md5($root.'/'.trim($path, '/'))] = '(' . JText::_('COM_COMPONENTBUILDER_FOLDER') . ') ' . basename($path) . ' - ' . basename($root); - } - } - } - } - } - // return files if found - if (UtilitiesArrayHelper::check($files)) - { - return $files; - } - } - return false; - } - - /** - * Fix the path to work in the JCB script <-- (main issue here) - * Since we need / slash in all paths, for the JCB script even if it is Windows - * and since MS works with both forward and back slashes - * we just convert all slashes to forward slashes - * - * THIS is just my hack (fix) if you know a better way! speak-up! - * - * @param mix $values the array of paths or the path as a string - * @param array $targets paths to target - * - * @return string - * - */ - public static function fixPath(&$values, $targets = array()) - { - // if multiple to gets searched and fixed - if (UtilitiesArrayHelper::check($values) && UtilitiesArrayHelper::check($targets)) - { - foreach ($targets as $target) - { - if (isset($values[$target]) && strpos($values[$target], '\\') !== false) - { - $values[$target] = str_replace('\\', '/', $values[$target]); - } - } - } - // if just a string - elseif (UtilitiesStringHelper::check($values) && strpos($values, '\\') !== false) - { - $values = str_replace('\\', '/', $values); - } - } - - /** - * get all component IDs - */ - public static function getComponentIDs() - { - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__componentbuilder_joomla_component')); - $query->where($db->quoteName('published') . ' >= 1'); // do not backup trash - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - return $db->loadColumn(); - } - return false; - } - - /** - * Autoloader - */ - public static function autoLoader($type = 'compiler') - { - // load the type classes - if ('smart' !== $type) - { - foreach (glob(JPATH_ADMINISTRATOR."/components/com_componentbuilder/helpers/".$type."/*.php") as $autoFile) - { - require_once $autoFile; - } - } - // load only if compiler - if ('compiler' === $type) - { - // import the Joomla librarys - jimport('joomla.application.component.modellist'); - } - // load only if smart - if ('smart' === $type) - { - // import the Joomla libraries - jimport('joomla.application.component.modellist'); - } - // load this for all - jimport('joomla.application'); - } - - /** - * The dynamic builder of views, tables and fields - **/ - public static function dynamicBuilder(&$data, $type) - { - self::autoLoader('extrusion'); - $extruder = new Extrusion($data); - } - - /* - * Convert repeatable field to subform - * - * @param array $item The array to convert - * @param string $name The main field name - * - * @return array - */ - public static function convertRepeatable($item, $name) - { - // continue only if we have an array - if (UtilitiesArrayHelper::check($item)) - { - $bucket = array(); - foreach ($item as $key => $values) - { - foreach ($values as $nr => $value) - { - if (!isset($bucket[$name . $nr]) || !UtilitiesArrayHelper::check($bucket[$name . $nr])) - { - $bucket[$name . $nr] = array(); - } - $bucket[$name . $nr][$key] = $value; - } - } - return $bucket; - } - return $item; - } - - /* - * Convert repeatable field to subform - * - * @param object $item The item to update - * @param array $searcher The fields to check and update - * @param array $updater To update the local table - * - * @return void - */ - public static function convertRepeatableFields($object, $searcher, $updater = array()) - { - // update the repeatable fields - foreach ($searcher as $key => $sleutel) - { - if (isset($object->{$key})) - { - $isJson = false; - if (JsonHelper::check($object->{$key})) - { - $object->{$key} = json_decode($object->{$key}, true); - $isJson = true; - } - // check if this is old values for repeatable fields - if (UtilitiesArrayHelper::check($object->{$key}) && isset($object->{$key}[$sleutel])) - { - // load it back - $object->{$key} = self::convertRepeatable($object->{$key}, $key); - // add to global updater - if ( - UtilitiesArrayHelper::check($object->{$key}) && UtilitiesArrayHelper::check($updater) && - ( - ( isset($updater['table']) && isset($updater['val']) && isset($updater['key']) ) || - ( isset($updater['unique']) && isset($updater['unique'][$key]) && isset($updater['unique'][$key]['table']) && isset($updater['unique'][$key]['val']) && isset($updater['unique'][$key]['key']) ) - ) - ) - { - $_key = null; - $_value = null; - $_table = null; - // check if we have unique id table for this repeatable/subform field - if ( isset($updater['unique']) && isset($updater['unique'][$key]) && isset($updater['unique'][$key]['table']) && isset($updater['unique'][$key]['val']) && isset($updater['unique'][$key]['key']) ) - { - $_key = $updater['unique'][$key]['key']; - $_value = $updater['unique'][$key]['val']; - $_table = $updater['unique'][$key]['table']; - } - elseif ( isset($updater['table']) && isset($updater['val']) && isset($updater['key']) ) - { - $_key = $updater['key']; - $_value = $updater['val']; - $_table = $updater['table']; - } - // continue only if values are valid - if (UtilitiesStringHelper::check($_table) && UtilitiesStringHelper::check($_key) && $_value > 0) - { - // set target table & item - $target = trim($_table) . '.' . trim($_key) . '.' . trim($_value); - if (!isset(self::$globalUpdater[$target])) - { - self::$globalUpdater[$target] = new stdClass; - self::$globalUpdater[$target]->{$_key} = (int) $_value; - } - // load the new subform values to global updater - self::$globalUpdater[$target]->{$key} = json_encode($object->{$key}); - } - } - } - // no set back to json if came in as json - if ($isJson && UtilitiesArrayHelper::check($object->{$key})) - { - $object->{$key} = json_encode($object->{$key}); - } - // remove if not json or array - elseif (!UtilitiesArrayHelper::check($object->{$key}) && !JsonHelper::check($object->{$key})) - { - unset($object->{$key}); - } - } - } - return $object; - } - - /** - * Run Global Updater if any are set - * - * @return void - * - */ - public static function runGlobalUpdater() - { - // check if any updates are set to run - if (UtilitiesArrayHelper::check(self::$globalUpdater)) - { - // get the database object - $db = JFactory::getDbo(); - foreach (self::$globalUpdater as $tableKeyID => $object) - { - // get the table - $table = explode('.', $tableKeyID); - // update the item - $db->updateObject('#__componentbuilder_' . (string) $table[0] , $object, (string) $table[1]); - } - // rest updater - self::$globalUpdater = array(); - } - } - - /** - * Copy Any Item (only use for direct database copying) - * - * @param int $id The item to copy - * @param string $table The table and model to copy from and with - * @param array $config The values that should change - * - * @return boolean True if success - * - */ - public static function copyItem($id, $type, $config = array()) - { - // only continue if we have an id - if ((int) $id > 0) - { - // get the model - $model = self::getModel($type); - $app = \JFactory::getApplication(); - // get item - if ($item = $model->getItem($id)) - { - // update values that should change - if (UtilitiesArrayHelper::check($config)) - { - foreach($config as $key => $value) - { - if (isset($item->{$key})) - { - $item->{$key} = $value; - } - } - } - // clone the object - $data = array(); - foreach ($item as $key => $value) - { - $data[$key] = $value; - } - // reset some values - $data['id'] = 0; - $data['version'] = 1; - if (isset($data['tags'])) - { - $data['tags'] = null; - } - if (isset($data['associations'])) - { - $data['associations'] = array(); - } - // remove some unneeded values - unset($data['params']); - unset($data['asset_id']); - unset($data['checked_out']); - unset($data['checked_out_time']); - // Attempt to save the data. - if ($model->save($data)) - { - return true; - } - } - } - return false; - } - - /** - * the basic localkey - **/ - protected static $localkey = false; - - /** - * get the localkey - **/ - public static function getLocalKey() - { - if (!self::$localkey) - { - // get the basic key - self::$localkey = md5(self::getCryptKey('basic', 'localKey34fdWEkl')); - } - return self::$localkey; - } - - /** - * indent HTML - */ - public static function indent($html) - { - // load the class - require_once JPATH_ADMINISTRATOR.'/components/com_componentbuilder/helpers/indenter.php'; - // set new indenter - $indenter = new Indenter(); - // return indented html - return $indenter->indent($html); - } - - public static function checkFileType($file, $sufix) - { - // now check if the file ends with the sufix - return $sufix === "" || ($sufix == substr(strrchr($file, "."), -strlen($sufix))); - } - - public static function imageInfo($path, $request = 'type') - { - // set image - $image = JPATH_SITE.'/'.$path; - // check if exists - if (file_exists($image) && $result = @getimagesize($image)) - { - // return type request - switch ($request) - { - case 'width': - return $result[0]; - break; - case 'height': - return $result[1]; - break; - case 'type': - $extensions = array( - IMAGETYPE_GIF => "gif", - IMAGETYPE_JPEG => "jpg", - IMAGETYPE_PNG => "png", - IMAGETYPE_SWF => "swf", - IMAGETYPE_PSD => "psd", - IMAGETYPE_BMP => "bmp", - IMAGETYPE_TIFF_II => "tiff", - IMAGETYPE_TIFF_MM => "tiff", - IMAGETYPE_JPC => "jpc", - IMAGETYPE_JP2 => "jp2", - IMAGETYPE_JPX => "jpx", - IMAGETYPE_JB2 => "jb2", - IMAGETYPE_SWC => "swc", - IMAGETYPE_IFF => "iff", - IMAGETYPE_WBMP => "wbmp", - IMAGETYPE_XBM => "xbm", - IMAGETYPE_ICO => "ico" - ); - return $extensions[$result[2]]; - break; - case 'attr': - return $result[3]; - break; - case 'all': - default: - return $result; - break; - } - } - return false; - } - - /** - * set the session defaults if not set - **/ - protected static function setSessionDefaults() - { - // noting for now - return true; - } - - /** - * check if it is a new hash - **/ - public static function newHash($hash, $name = 'backup', $type = 'hash', $key = '', $fileType = 'txt') - { - // make sure we have a hash - if (UtilitiesStringHelper::check($hash)) - { - // first get the file path - $path_filename = FileHelper::getPath('path', $name.$type, $fileType, $key, JPATH_COMPONENT_ADMINISTRATOR); - // set as read if not already set - if ($content = FileHelper::getContent($path_filename, false)) - { - if ($hash == $content) - { - return false; - } - } - // set the hash - return FileHelper::write($path_filename, $hash); - } - return false; - } - - protected static $pkOwnerSearch = array( - 'company' => 'COM_COMPONENTBUILDER_DTCOMPANYDTDDSDD', - 'owner' => 'COM_COMPONENTBUILDER_DTOWNERDTDDSDD', - 'email' => 'COM_COMPONENTBUILDER_DTEMAILDTDDSDD', - 'website' => 'COM_COMPONENTBUILDER_DTWEBSITEDTDDSDD', - 'license' => 'COM_COMPONENTBUILDER_DTLICENSEDTDDSDD', - 'copyright' => 'COM_COMPONENTBUILDER_DTCOPYRIGHTDTDDSDD' - ); - - /** - * get the JCB package owner details display - **/ - public static function getPackageOwnerDetailsDisplay(&$info, $trust = false) - { - $hasOwner = false; - $ownerDetails = ''; - $ownerDetails .= '
    '; - // load the list items - foreach (self::$pkOwnerSearch as $key => $dd) - { - if ($value = self::getPackageOwnerValue($key, $info)) - { - $ownerDetails .= JText::sprintf($dd, $value); - // check if we have a owner/source name - if (('owner' === $key || 'company' === $key) && !$hasOwner) - { - $hasOwner = true; - $owner = $value; - } - } - } - $ownerDetails .= '
    '; - - // provide some details to how the user can get a key - if ($hasOwner && isset($info['getKeyFrom']['buy_link']) && UtilitiesStringHelper::check($info['getKeyFrom']['buy_link'])) - { - $ownerDetails .= '
    '; - $ownerDetails .= JText::sprintf('COM_COMPONENTBUILDER_BGET_THE_KEY_FROMB_A_SSA', 'class="btn btn-primary" href="'.$info['getKeyFrom']['buy_link'].'" target="_blank" title="get a key from '.$owner.'"', $owner); - } - // add more custom links - elseif ($hasOwner && isset($info['getKeyFrom']['buy_links']) && UtilitiesArrayHelper::check($info['getKeyFrom']['buy_links'])) - { - $buttons = array(); - foreach ($info['getKeyFrom']['buy_links'] as $keyName => $link) - { - $buttons[] = JText::sprintf('COM_COMPONENTBUILDER_BGET_THE_KEY_FROM_SB_FOR_A_SSA', $owner, 'class="btn btn-primary" href="'.$link.'" target="_blank" title="get a key from '.$owner.'"', $keyName); - } - $ownerDetails .= '
    '; - $ownerDetails .= implode('
    ', $buttons); - } - // return the owner details - if (!$hasOwner) - { - $ownerDetails = '

    ' . JText::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS_NOT_FOUND') . '

    '; - if (!$trust) - { - $ownerDetails .= '

    ' . JText::_('COM_COMPONENTBUILDER_BE_CAUTIOUS_DO_NOT_CONTINUE_UNLESS_YOU_TRUST_THE_ORIGIN_OF_THIS_PACKAGE') . '

    '; - } - } - return '
    '.$ownerDetails.'
    '; - } - - public static function getPackageOwnerValue($key, &$info) - { - $source = (isset($info['source']) && isset($info['source'][$key])) ? 'source' : ((isset($info['getKeyFrom']) && isset($info['getKeyFrom'][$key])) ? 'getKeyFrom' : false); - if ($source && UtilitiesStringHelper::check($info[$source][$key])) - { - return $info[$source][$key]; - } - return false; - } - - /** - * get the JCB package component key status - **/ - public static function getPackageComponentsKeyStatus(&$info) - { - // check the package key status - if (!isset($info['key'])) - { - if (isset($info['getKeyFrom']) && isset($info['getKeyFrom']['owner'])) - { - // this just confirms it for older packages - $info['key'] = true; - } - else - { - // this just confirms it for older packages - $info['key'] = false; - } - } - return $info['key']; - } - - protected static $compOwnerSearch = array( - 'ul' => array ( - 'companyname' => 'COM_COMPONENTBUILDER_ICOMPANYI_BSB', - 'author' => 'COM_COMPONENTBUILDER_IAUTHORI_BSB', - 'email' => 'COM_COMPONENTBUILDER_IEMAILI_BSB', - 'website' => 'COM_COMPONENTBUILDER_IWEBSITEI_BSB', - ), - 'other' => array( - 'license' => 'COM_COMPONENTBUILDER_HFOUR_CLASSNAVHEADERLICENSEHFOURPSP', - 'copyright' => 'COM_COMPONENTBUILDER_HFOUR_CLASSNAVHEADERCOPYRIGHTHFOURPSP' - ) - ); - - /** - * get the JCB package component details display - **/ - public static function getPackageComponentsDetailsDisplay(&$info) - { - // check if these components need a key - $needKey = self::getPackageComponentsKeyStatus($info); - if (isset($info['name']) && UtilitiesArrayHelper::check($info['name'])) - { - $cAmount = count((array) $info['name']); - $class2 = ($cAmount == 1) ? 'span12' : 'span6'; - $counter = 1; - $display = array(); - foreach ($info['name'] as $key => $value) - { - // set the name - $name= $value . ' v' . $info['component_version'][$key]; - if ($cAmount > 1 && $counter == 3) - { - $display[] = '
    '; - $counter = 1; - } - if ($cAmount > 1 && $counter == 1) - { - $display[] = '
    '; - } - $display[] = '
    '; - $display[] = '

    '; - $display[] = $name; - if ($needKey) - { - $display[] = ' - ' . JText::sprintf('COM_COMPONENTBUILDER_PAIDLOCKED') . ''; - } - else - { - $display[] = ' - ' . JText::sprintf('COM_COMPONENTBUILDER_FREEOPEN') . ''; - } - $display[] = '

    '; - $display[] = $info['short_description'][$key]; - $display[] = '

    '; - $display[] = '
      '; - // load the list items - foreach (self::$compOwnerSearch['ul'] as $li => $value) - { - if (isset($info[$li]) && isset($info[$li][$key])) - { - $display[] = '
    • '.JText::sprintf($value, $info[$li][$key]).'
    • '; - } - } - $display[] = '
    '; - // if we have a source link we add it - if (isset($info['joomla_source_link']) && UtilitiesArrayHelper::check($info['joomla_source_link']) && isset($info['joomla_source_link'][$key]) && UtilitiesStringHelper::check($info['joomla_source_link'][$key])) - { - $display[] = 'source code'; - } - // load other - foreach (self::$compOwnerSearch['other'] as $other => $value) - { - if (isset($info[$other]) && isset($info[$other][$key])) - { - $display[] = JText::sprintf($value, $info[$other][$key]); - } - } - $display[] = '
    '; - - $counter++; - } - // close the div if needed - if ($cAmount > 1) - { - $display[] = '
    '; - } - return implode("\n",$display); - } - return '
    '.JText::_('COM_COMPONENTBUILDER_NO_COMPONENT_DETAILS_FOUND_SO_IT_IS_NOT_SAFE_TO_CONTINUE').'
    '; - } - - /** - * get the database table columns - **/ - public static function getDbTableColumns($tableName, $as, $type) - { - // Get a db connection. - $db = JFactory::getDbo(); - // get the columns - $columns = $db->getTableColumns("#__" . $tableName); - // set the type (multi or single) - $unique = ''; - if (1 == $type) - { - $unique = UtilitiesStringHelper::safe($tableName) . '_'; - } - if (UtilitiesArrayHelper::check($columns)) - { - // build the return string - $tableColumns = array(); - foreach ($columns as $column => $typeCast) - { - $tableColumns[] = $as . "." . $column . ' AS ' . $unique . $column; - } - return implode("\n", $tableColumns); - } - return false; - } - - /** - * get the view table columns - **/ - public static function getViewTableColumns($admin_view, $as, $type) - { - // Get a db connection. - $db = JFactory::getDbo(); - - // Create a new query object. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('a.addfields', 'b.name_single'))); - $query->from($db->quoteName('#__componentbuilder_admin_fields', 'a')); - $query->join('LEFT', $db->quoteName('#__componentbuilder_admin_view', 'b') . ' ON (' . $db->quoteName('a.admin_view') . ' = ' . $db->quoteName('b.id') . ')'); - $query->where($db->quoteName('b.published') . ' = 1'); - $query->where($db->quoteName('a.admin_view') . ' = ' . (int) $admin_view); - - // Reset the query using our newly populated query object. - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - $result = $db->loadObject(); - $tableName = ''; - if (1 == $type) - { - $tableName = UtilitiesStringHelper::safe($result->name_single) . '_'; - } - $addfields = json_decode($result->addfields, true); - if (UtilitiesArrayHelper::check($addfields)) - { - // reset all buckets - $field = array(); - $fields = array(); - // get data - foreach ($addfields as $nr => $value) - { - $tmp = self::getFieldNameAndType((int) $value['field']); - if (UtilitiesArrayHelper::check($tmp)) - { - $field[$nr] = $tmp; - } - // insure it is set to alias if needed - if (isset($value['alias']) && $value['alias'] == 1) - { - $field[$nr]['name'] = 'alias'; - } - // remove a field that is not being stored in the database - if (!isset($value['list']) || $value['list'] == 2) - { - unset($field[$nr]); - } - } - // add the basic defaults - $fields[] = $as . ".id AS " . $tableName . "id"; - $fields[] = $as . ".asset_id AS " . $tableName . "asset_id"; - // load data - foreach ($field as $n => $f) - { - if (UtilitiesArrayHelper::check($f)) - { - $fields[] = $as . "." . $f['name'] . " AS " . $tableName . $f['name']; - } - } - // add the basic defaults - $fields[] = $as . ".published AS " . $tableName . "published"; - $fields[] = $as . ".created_by AS " . $tableName . "created_by"; - $fields[] = $as . ".modified_by AS " . $tableName . "modified_by"; - $fields[] = $as . ".created AS " . $tableName . "created"; - $fields[] = $as . ".modified AS " . $tableName . "modified"; - $fields[] = $as . ".version AS " . $tableName . "version"; - $fields[] = $as . ".hits AS " . $tableName . "hits"; - if (0) // TODO access is not set here but per/view in the form linking this admin view to which these field belong to the components (boooo I know but that is the case and so we can't ever really know at this point if this view has access set) - { - $fields[] = $as . ".access AS " . $tableName . "access"; - } - $fields[] = $as . ".ordering AS " . $tableName . "ordering"; - // return the field of this view - return implode("\n", $fields); - } - } - return false; - } - - public static function getFieldNameAndType($id, $spacers = false) - { - // Get a db connection. - $db = JFactory::getDbo(); - - // Create a new query object. - $query = $db->getQuery(true); - - // Order it by the ordering field. - $query->select($db->quoteName(array('a.name', 'a.xml'))); - $query->select($db->quoteName(array('c.name'), array('type_name'))); - $query->from('#__componentbuilder_field AS a'); - $query->join('LEFT', $db->quoteName('#__componentbuilder_fieldtype', 'c') . ' ON (' . $db->quoteName('a.fieldtype') . ' = ' . $db->quoteName('c.id') . ')'); - $query->where($db->quoteName('a.id') . ' = '. $db->quote($id)); - - // Reset the query using our newly populated query object. - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - // Load the results as a list of stdClass objects (see later for more options on retrieving data). - $field = $db->loadObject(); - // load the values form params - $field->xml = json_decode($field->xml); - $field->type_name = self::safeTypeName($field->type_name); - $load = true; - // if category then name must be catid (only one per view) - if ($field->type_name === 'category') - { - $name = 'catid'; - } - // if tag is set then enable all tag options for this view (only one per view) - elseif ($field->type_name === 'tag') - { - $name = 'tags'; - } - // don't add spacers or notes - elseif (!$spacers && ($field->type_name == 'spacer' || $field->type_name == 'note')) - { - // make sure the name is unique - return false; - } - else - { - $name = self::safeFieldName(GetHelper::between($field->xml,'name="','"')); - } - - // use field core name only if not found in xml - if (!UtilitiesStringHelper::check($name)) - { - $name = self::safeFieldName($field->name); - } - return array('name' => $name, 'type' => $field->type_name); - } - return false; - } - - /** - * validate that a placeholder is unique - **/ - public static function validateUniquePlaceholder($id, $name, $bool = false) - { - // make sure no padding is set - $name = preg_replace("/[^A-Za-z0-9_]/", '', $name); - // this list may grow as we find more cases that break the compiler (just open an issue on github) - if (in_array($name, array('component', 'view', 'views'))) - { - // check if we must return boolean - if (!$bool) - { - return array ( - 'message' => JText::_('COM_COMPONENTBUILDER_SORRY_THIS_PLACEHOLDER_IS_ALREADY_IN_USE_IN_THE_COMPILER'), - 'status' => 'danger'); - } - return false; - } - // add the padding (needed) - $name = '[[[' . trim($name) . ']]]'; - if (self::placeholderIsSet($id, $name)) - { - // check if we must return boolean - if (!$bool) - { - return array ( - 'message' => JText::_('COM_COMPONENTBUILDER_SORRY_THIS_PLACEHOLDER_IS_ALREADY_IN_USE'), - 'status' => 'danger'); - } - return false; - } - // check if we must return boolean - if (!$bool) - { - return array ( - 'name' => $name, - 'message' => JText::_('COM_COMPONENTBUILDER_GREAT_THIS_PLACEHOLDER_WILL_WORK'), - 'status' => 'success'); - } - return true; - } - - /** - * search for placeholder in table - **/ - protected static function placeholderIsSet($id, $name) - { - // query the table for result array - if (($results = self::getPlaceholderTarget($id, $name)) !== false) - { - // check if we must continue the search - foreach ($results as $_id => $target) - { - if ($name === $target) - { - return true; - } - } - } - return false; - } - - /** - * get placeholder target - **/ - protected static function getPlaceholderTarget($id, $name) - { - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id', 'target'))); - $query->from($db->quoteName('#__componentbuilder_placeholder')); - $query->where($db->quoteName('target') . ' = '. $db->quote($name)); - // check if we have id - if (is_numeric($id)) - { - $query->where($db->quoteName('id') . ' <> ' . (int) $id); - } - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - return $db->loadAssocList('id', 'target'); - } - return false; - } - - /** - * Powers to exclude - **/ - public static function excludePowers($id) - { - // first check if this power set is already found - if (!isset(self::$exPowers[$id])) - { - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('a.id'))); - $query->from($db->quoteName('#__componentbuilder_power', 'a')); - $query->join('LEFT', $db->quoteName('#__componentbuilder_power', 'b') . ' ON (' . $db->quoteName('a.name') . ' = ' . $db->quoteName('b.name') . ' AND ' . $db->quoteName('a.namespace') . ' = ' . $db->quoteName('b.namespace') . ')'); - $query->where($db->quoteName('b.id') . ' = ' . (int) $id); - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - self::$exPowers[$id] = $db->loadColumn(); - } - // all ways add itself aswell - self::$exPowers[$id][] = $id; - } - // if found return - if (isset(self::$exPowers[$id])) - { - return self::$exPowers[$id]; - } - return false; - } - /** - * The array of dynamic content - * - * @var array - */ - protected static array $dynamicContent = [ - // The banners by size (width - height) - 'banner' => [ - '728-90' => [ - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/banner/joomla-heart-wide.gif', - 'hash' => 'f857e3a38facaeac9eba3cffa912b620', - 'html' => 'Joomla! Volunteers Portal'], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/banner/JCM_2010_120x600.png', - 'hash' => '5389cf3be8569cb3f6793e8bd4013d19', - 'html' => 'Joomla! Community Magazine | Because community matters...'], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/banner/tlwebdesign_jcb_sponsor_728_90.png', - 'hash' => 'd19be1f9f5b2049ff901096aafc246be', - 'html' => 'tlwebdesign a JCB sponsor | Because community matters...'], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/banner/vdm_jcb_sponsor_728_90.gif', - 'hash' => '84478dfa0cd880395815e0ee026812a4', - 'html' => 'VDM a JCB sponsor | Because community matters...'], - [ - 'url' => 'https://cms-experts.org/images/banners/agerix/agerix-loves-jcb-728-90.gif', - 'hash' => 'b24c0726aa809cdcc04bcffe7e1e1529', - 'html' => 'Agerix a JCB sponsor | Because community matters...'] - ], - '160-600' => [ - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/banner/joomla-heart-tall.gif', - 'hash' => '9a75e4929b86c318128b53cf78251678', - 'html' => 'Joomla! Volunteers Portal'], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/banner/JCM_2010_120x600.png', - 'hash' => '5389cf3be8569cb3f6793e8bd4013d19', - 'html' => 'Joomla! Community Magazine | Because community matters...'] - ] - ], - // The build-gif by size (width - height) - 'builder-gif' => [ - // original gif ;) - '480-272' => [ - [ - 'url' => 'https://www.joomlacomponentbuilder.com/images/builder/original.gif', - 'hash' => '676e37a949add8f4573381195cd1061c', - 'html' => '' - ] - ], - // new gif artwork since 2021 - '480-540' => [ - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/1.gif', - 'hash' => 'ce6e36456fa794ba95d981547b2f54f8', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/2.gif', - 'hash' => '0a54dbc393359747e33db90cabb1e2d7', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/3.gif', - 'hash' => '4e5498713ff69a64a0a79dbf620372a3', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/4.gif', - 'hash' => '3554ffab2a6df95a116fd9f0db63925c', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/5.gif', - 'hash' => '08f0cdf188593eca65c6dafd7af27ef9', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/6.gif', - 'hash' => '103b46a7ac3fcb974e25d06f417a4e87', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/7.gif', - 'hash' => 'ffa8547099b7286f89ab7ff5a140dd90', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/8.gif', - 'hash' => '316df780f9e4ce81200a65d3c4303c41', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/9.gif', - 'hash' => '9ab6ba78b6e63a285fdef2ff5e447c93', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/10.gif', - 'hash' => 'cd9abaa1cb95f51a70916da6b70614f2', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/11.gif', - 'hash' => 'cfe53095b5249618e2348223b89262b9', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/12.gif', - 'hash' => '15a6690647d5160d67c80ce4dd1f5602', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/13.gif', - 'hash' => '2f77562e92c8a3b7c47664c98f551fe8', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/14.gif', - 'hash' => '46db15517ef5bd063be85134e1cc575d', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/15.gif', - 'hash' => 'e6c96eff157ea648ceb1583f2cc22544', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/16.gif', - 'hash' => '76010b7d1f99952eb9645df660467ae8', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/17.gif', - 'hash' => '021219ddd72d8fcfc7f80bd4a874d651', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/18.gif', - 'hash' => '383af3179d4ae27301c1292e630d7155', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/19.gif', - 'hash' => '8537e6d7be93447241b521f851e8a61d', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/20.gif', - 'hash' => '10d96f70e3d43086a925b00a7dc0022e', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/21.gif', - 'hash' => '161de9865b171b44039353b8d50491d3', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/22.gif', - 'hash' => '6a2354e43eb97d278d74bb2c12890988', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/23.gif', - 'hash' => '2cb6e2f9562a8dc8eef6d5d8d1a84f5e', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/24.gif', - 'hash' => '745b3fb5e16515689132432bf02ab1b4', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '] - ] - ] - ]; - - /** - * get the dynamic content array size - * - * @param string $type The type of content - * @param string $size The size of the content - * - * @return int on success number of items in array type,size - * - */ - public static function getDynamicContentSize(string $type, string $size): int - { - if (isset(self::$dynamicContent[$type]) && isset(self::$dynamicContent[$type][$size]) - && ($nr = UtilitiesArrayHelper::check(self::$dynamicContent[$type][$size]))) - { - return $nr; - } - return 0; - } - - /** - * get the dynamic content - * - * @param string $type The type of content - * @param string $size The size of the content - * @param mixed $default The default to return - * @param int $try Retry tracker (when bigger then array size it stops) - * @param mixed $getter The specific getter number (not zero based) - * - * @return string on success html string - * - */ - public static function getDynamicContent(string $type, string $size, $default = '', int $try = 1, $getter = null) - { - if (($nr = self::getDynamicContentSize($type, $size)) !== 0) - { - // use specific getter - if ($getter) - { - $get = --$getter; - } - // get the random getter number - elseif ($nr > 1) - { - $get = (int) rand(0, --$nr); - } - else - { - $get = 0; - } - // get the current target if found - if (isset(self::$dynamicContent[$type][$size][$get])) - { - $target = self::$dynamicContent[$type][$size][$get]; - // set file name - $file_name = basename($target['url']); - // set the local path (in admin area so when the component uninstall these images get removed as well) - $path = JPATH_ROOT . "/administrator/components/com_componentbuilder/assets/images/$type/$file_name"; - // check if file exist or if it changed - if (($image_data = FileHelper::getContent($path, false)) === false || - md5($image_data) !== $target['hash']) - { - // since the file does not exist or has changed (so we have a new hash) - // therefore we download it to validate - if (($image_data = FileHelper::getContent($target['url'], false)) !== false && - md5($image_data) === $target['hash']) - { - // create the JCB type path if it does not exist - if (!Folder::exists(JPATH_ROOT . "/administrator/components/com_componentbuilder/assets/images/$type")) - { - Folder::create(JPATH_ROOT . "/administrator/components/com_componentbuilder/assets/images/$type"); - } - // only set the image if the data match the hash - FileHelper::write($path, $image_data); - } - // we retry array size times (unless specific getter is used) - elseif ($try <= $nr && !$getter) - { - // the first time around failed so we try again (the size of the array times) - return self::getDynamicContent($type, $size, $default, ++$try); - } - } - // return found content - return str_replace('[[[ROOT-URL]]]', JURI::root(), $target['html']); - } - } - 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 - **/ - public static $session = array(); - - /** - * the Butler Assistant - **/ - protected static $localSession = array(); - - /** - * start a session if not already set, and load with data - **/ - public static function loadSession() - { - if (!isset(self::$session) || !ObjectHelper::check(self::$session)) - { - self::$session = JFactory::getSession(); - } - // set the defaults - self::setSessionDefaults(); - } - - /** - * give Session more to keep - **/ - public static function set($key, $value) - { - if (!isset(self::$session) || !ObjectHelper::check(self::$session)) - { - self::$session = JFactory::getSession(); - } - // set to local memory to speed up program - self::$localSession[$key] = $value; - // load to session for later use - return self::$session->set($key, self::$localSession[$key]); - } - - /** - * get info from Session - **/ - public static function get($key, $default = null) - { - if (!isset(self::$session) || !ObjectHelper::check(self::$session)) - { - self::$session = JFactory::getSession(); - } - // check if in local memory - if (!isset(self::$localSession[$key])) - { - // set to local memory to speed up program - self::$localSession[$key] = self::$session->get($key, $default); - } - return self::$localSession[$key]; - } - - - /** - * get field type properties - * - * @return array on success - * - */ - public static function getFieldTypeProperties($value, $type, $settings = array(), $xml = null, $dbDefaults = false) - { - // Get a db connection. - $db = JFactory::getDbo(); - - // Create a new query object. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('properties', 'short_description', 'description'))); - // load database default values - if ($dbDefaults) - { - $query->select($db->quoteName(array('datadefault', 'datadefault_other', 'datalenght', 'datalenght_other', 'datatype', 'has_defaults', 'indexes', 'null_switch', 'store'))); - } - $query->from($db->quoteName('#__componentbuilder_fieldtype')); - $query->where($db->quoteName('published') . ' = 1'); - $query->where($db->quoteName($type) . ' = '. $value); - - // Reset the query using our newly populated query object. - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - $result = $db->loadObject(); - $properties = json_decode($result->properties, true); - $field = array( - 'subform' => array(), - 'nameListOptions' => array(), - 'php' => array(), - 'values' => " '
    '; - $head .= PHP_EOL . Indent::_(3) . ""; - $head .= PHP_EOL . Indent::_(2) . "'; - $head .= PHP_EOL . Indent::_(3) . ""; - $head .= PHP_EOL . Indent::_(2) . "
    ', - 'short_description' => $result->short_description, - 'description' => $result->description); - // number pointer - $nr = 0; - // php tracker (we must try to load alteast 17 rows - $phpTracker = array(); - // force load all properties - $forceAll = false; - if ($xml && strpos($xml, '..__FORCE_LOAD_ALL_PROPERTIES__..') !== false) - { - $forceAll = true; - } - // value to check since there are false and null values even 0 in the values returned - $confirmation = '8qvZHoyuFYQqpj0YQbc6F3o5DhBlmS-_-a8pmCZfOVSfANjkmV5LG8pCdAY2JNYu6cB'; - // set the headers - $field['values_description'] .= ''; - foreach ($properties as $property) - { - $example = (isset($property['example']) && UtilitiesStringHelper::check($property['example'])) ? $property['example'] : ''; - $field['values_description'] .= ''; - // check if we should load the value - $value = FieldHelper::getValue($xml, $property['name'], $confirmation); - // check if this is a php field - $addPHP = false; - if (strpos($property['name'], 'type_php') !== false) - { - $addPHP = true; - // set the line number - $phpLine = (int) preg_replace('/[^0-9]/', '', $property['name']); - // set the key - $phpKey = trim(preg_replace('/[0-9]+/', '', $property['name']), '_'); - // start array if not already set - if (!isset($field['php'][$phpKey])) - { - $field['php'][$phpKey] = array(); - $field['php'][$phpKey]['value'] = array(); - $field['php'][$phpKey]['desc'] = $property['description']; - // start tracker - $phpTracker[$phpKey] = 1; - } - } - // was the settings for the property passed - if(UtilitiesArrayHelper::check($settings) && isset($settings[$property['name']])) - { - // add the xml values - $field['values'] .= PHP_EOL . "\t" . $property['name'] . '="'. $settings[$property['name']] . '" '; - // add the json values - if ($addPHP) - { - $field['php'][$phpKey]['value'][$phpLine] = $settings[$property['name']]; - $phpTracker[$phpKey]++; - } - else - { - $field['subform']['properties'.$nr] = array('name' => $property['name'], 'value' => $settings[$property['name']], 'desc' => $property['description']); - } - } - elseif ($forceAll || !$xml || $confirmation !== $value) - { - // add the xml values - $field['values'] .= PHP_EOL."\t" . $property['name'] . '="' . ($confirmation !== $value) ? $value : $example .'" '; - // add the json values - if ($addPHP) - { - $field['php'][$phpKey]['value'][$phpLine] = ($confirmation !== $value) ? $value : $example; - $phpTracker[$phpKey]++; - } - else - { - $field['subform']['properties' . $nr] = array('name' => $property['name'], 'value' => ($confirmation !== $value) ? $value : $example, 'desc' => $property['description']); - } - } - // add the name List Options - if (!$addPHP) - { - $field['nameListOptions'][$property['name']] = $property['name']; - } - // increment the number - $nr++; - } - // check if all php is loaded using the tracker - if (UtilitiesStringHelper::check($xml) && isset($phpTracker) && UtilitiesArrayHelper::check($phpTracker)) - { - foreach ($phpTracker as $phpKey => $start) - { - if ($start < 30) - { - // we must search for more code in the xml just incase - foreach(range(2, 30) as $t_nr) - { - $get_ = $phpKey . '_' . $t_nr; - if (!isset($field['php'][$phpKey]['value'][$t_nr]) && ($value = FieldHelper::getValue($xml, $get_, $confirmation)) !== $confirmation) - { - $field['php'][$phpKey]['value'][$t_nr] = $value; - } - } - } - } - } - $field['values'] .= PHP_EOL . "/>"; - $field['values_description'] .= '
    ' . JText::_('COM_COMPONENTBUILDER_PROPERTY') . '' . JText::_('COM_COMPONENTBUILDER_EXAMPLE') . '' . JText::_('COM_COMPONENTBUILDER_DESCRIPTION') . '
    ' . $property['name'] . '' . $example . '' . $property['description'] . '
    '; - // load the database defaults if set and wanted - if ($dbDefaults && isset($result->has_defaults) && $result->has_defaults == 1) - { - $field['database'] = array( - 'datatype' => $result->datatype, - 'datadefault' => $result->datadefault, - 'datadefault_other' => $result->datadefault_other, - 'datalenght' => $result->datalenght, - 'datalenght_other' => $result->datalenght_other, - 'indexes' => $result->indexes, - 'null_switch' => $result->null_switch, - 'store' => $result->store - ); - } - // return found field options - return $field; - } - return false; - } - - /** - * Get a field value from the XML stored string - * - * @param string $xml The xml string of the field - * @param string $get The value key to get from the string - * @param string $confirmation The value to confirm found value - * - * @return string The field value from xml - * @deprecated 3.3 Use FieldHelper::getValue($xml, $get, $confirmation); - */ - public static function getValueFromXMLstring(&$xml, &$get, $confirmation = '') - { - return FieldHelper::getValue($xml, $get, $confirmation); - } - - - /** - * get field types properties - * - * @return array on success - * - */ - public static function getFieldTypesProperties($targets = array(), $filter = array(), $exclude = array(), $type = 'id', $operator = 'IN') - { - // Get a db connection. - $db = JFactory::getDbo(); - - // Create a new query object. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id','properties'))); - $query->from($db->quoteName('#__componentbuilder_fieldtype')); - $query->where($db->quoteName('published') . ' = 1'); - // make sure we have ids (or get all) - if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator) - { - $query->where($db->quoteName($type) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","',$targets) . '")'); - } - else - { - $query->where($db->quoteName($type) . ' ' . $operator . ' (' . implode(',',$targets) . ')'); - } - // Reset the query using our newly populated query object. - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - $_types = array(); - $_properties = array(); - $types = $db->loadObjectList('id'); - foreach ($types as $id => $type) - { - $properties = json_decode($type->properties); - foreach ($properties as $property) - { - if (!isset($_types[$id])) - { - $_types[$id] = array(); - } - // add if no objection is found - $add = true; - // check if we have exclude - if (UtilitiesArrayHelper::check($exclude) && in_array($property->name, $exclude)) - { - continue; - } - // check if we have filter - if (UtilitiesArrayHelper::check($filter)) - { - foreach($filter as $key => $val) - { - if (!isset($property->$key) || $property->$key != $val) - { - $add = false; - } - } - } - // now add the property - if ($add) - { - $_types[$id][$property->name] = array('name' => ucfirst($property->name), 'example' => $property->example, 'description' => $property->description); - // set mandatory - if (isset($property->mandatory) && $property->mandatory == 1) - { - $_types[$id][$property->name]['mandatory'] = true; - } - else - { - $_types[$id][$property->name]['mandatory'] = false; - } - // set translatable - if (isset($property->translatable) && $property->translatable == 1) - { - $_types[$id][$property->name]['translatable'] = true; - } - else - { - $_types[$id][$property->name]['translatable'] = false; - } - $_properties[$property->name] = $_types[$id][$property->name]['name']; - } - } - } - - // return found types & properties - return array('types' => $_types, 'properties' => $_properties); - } - return false; - } - - - /** - * Remove folders with files - * - * @param string $path The path to folder to remove - * @param array|null $ignore The folders and files to ignore and not remove - * - * @return bool True if all are removed - */ - public static function removeFolder(string $path, ?array $ignore = null): bool - { - if (!Folder::exists($path)) - { - return false; - } - - $it = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS); - $files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST); - - // Prepare a base path without trailing slash for comparison - $basePath = rtrim($path, '/'); - - foreach ($files as $fileinfo) - { - $filePath = $fileinfo->getRealPath(); - - if (self::removeFolderShouldIgnore($basePath, $filePath, $ignore)) - { - continue; - } - - if ($fileinfo->isDir()) - { - Folder::delete($filePath); - } - else - { - File::delete($filePath); - } - } - - // Delete the root folder if ignore not set - if (!UtilitiesArrayHelper::check($ignore)) - { - return Folder::delete($path); - } - - return true; - } - - /** - * Check if the current path should be ignored. - * - * @param string $basePath The base directory path - * @param string $filePath The current file or directory path - * @param array|null $ignore List of items to ignore - * - * @return boolean True if the path should be ignored - * @since 3.2.0 - */ - protected static function removeFolderShouldIgnore(string $basePath, string $filePath, ?array $ignore = null): bool - { - if (!$ignore || !UtilitiesArrayHelper::check($ignore)) - { - return false; - } - - foreach ($ignore as $item) - { - if (strpos($filePath, $basePath . '/' . $item) !== false) - { - return true; - } - } - - return false; - } - - /** - * The github access token - **/ - protected static $gitHubAccessToken = ""; - - /** - * The github repo get data errors - **/ - public static $githubRepoDataErrors = array(); - - /** - * get the github repo file list - * - * @return array on success - * - */ - public static function getGithubRepoFileList($type, $target) - { - // get the repo data - if (($repoData = self::getGithubRepoData($type, $target, 'tree')) !== false) - { - return $repoData->tree; - } - return false; - } - - /** - * get the github repo file list - * - * @return array on success - * - */ - public static function getGithubRepoData($type, $url, $target = null, $return_type = 'object') - { - // always reset errors per/request - self::$githubRepoDataErrors = array(); - // get the current Packages (public) - if ('nomemory' === $type || !$repoData = self::get($type)) - { - // add the token if not already added - $_url = self::setGithubToken($url); - // check if the url exist - if (self::urlExists($_url)) - { - // get the data from github - if (($repoData = FileHelper::getContent($_url)) !== false && JsonHelper::check($repoData)) - { - $github_returned = json_decode($repoData); - if (UtilitiesStringHelper::check($target) && - ( (ObjectHelper::check($github_returned) && isset($github_returned->{$target}) && UtilitiesArrayHelper::check($github_returned->{$target})) || - (UtilitiesArrayHelper::check($github_returned) && isset($github_returned[$target]) && UtilitiesArrayHelper::check($github_returned[$target])) )) - { - if ('nomemory' !== $type) - { - // remember to set it - self::set($type, $repoData); - } - } - elseif (!UtilitiesStringHelper::check($target) && (UtilitiesArrayHelper::check($github_returned) || (ObjectHelper::check($github_returned) && !isset($github_returned->message)))) - { - if ('nomemory' !== $type) - { - // remember to set it - self::set($type, $repoData); - } - } - // check if we have error message from github - elseif (($errorMessage = self::githubErrorHandeler(array('error' => null), $github_returned, $type)) !== false) - { - if (isset($errorMessage['error']) && UtilitiesStringHelper::check($errorMessage['error'])) - { - // set the error in the application - JFactory::getApplication()->enqueueMessage($errorMessage['error'], 'Error'); - // set the error also in the class encase it is and Ajax call - self::$githubRepoDataErrors[] = $errorMessage['error']; - } - return false; - } - elseif (UtilitiesStringHelper::check($target)) - { - // setup error string - $error = JText::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DID_NOT_RETURN_S_DATA', $url, $target); - // set the error in the application - JFactory::getApplication()->enqueueMessage($error, 'Error'); - // set the error also in the class encase it is and Ajax call - self::$githubRepoDataErrors[] = $error; - // we are done here - return false; - } - elseif ('nomemory' !== $type) - { - // setup error string - $error = JText::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DID_NOT_RETURN_S_DATA', $url, $type); - // set the error in the application - JFactory::getApplication()->enqueueMessage($error, 'Error'); - // set the error also in the class encase it is and Ajax call - self::$githubRepoDataErrors[] = $error; - // we are done here - return false; - } - else - { - // setup error string - $error = JText::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DID_NOT_RETURN_VALID_DATA', $url, $type); - // set the error in the application - JFactory::getApplication()->enqueueMessage($error, 'Error'); - // set the error also in the class encase it is and Ajax call - self::$githubRepoDataErrors[] = $error; - // we are done here - return false; - } - } - else - { - // setup error string - $error = JText::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DOES_NOT_RETURN_ANY_DATA', $url); - // set the error in the application - JFactory::getApplication()->enqueueMessage($error, 'Error'); - // set the error also in the class encase it is and Ajax call - self::$githubRepoDataErrors[] = $error; - // we are done here - return false; - } - } - else - { - // setup error string - $error = JText::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DOES_NOT_EXIST', $url); - // set the error in the application - JFactory::getApplication()->enqueueMessage($error, 'Error'); - // set the error also in the class encase it is and Ajax call - self::$githubRepoDataErrors[] = $error; - // we are done here - return false; - } - } - // check if we could find packages - if (isset($repoData) && JsonHelper::check($repoData)) - { - if ('object' === $return_type) - { - return json_decode($repoData); - } - elseif ('array' === $return_type) - { - return json_decode($repoData, true); - } - return $repoData; - } - return false; - } - - /** - * get the github error messages - * - * @return array of errors on success - * - */ - protected static function githubErrorHandeler($message, &$github, $type) - { - if (ObjectHelper::check($github) && isset($github->message) && UtilitiesStringHelper::check($github->message)) - { - // set the message - $errorMessage = $github->message; - // add the documentation URL - if (isset($github->documentation_url) && UtilitiesStringHelper::check($github->documentation_url)) - { - $errorMessage = $errorMessage . '
    ' . $github->documentation_url; - } - // check the message - if (strpos($errorMessage, 'Authenticated') !== false) - { - if ('nomemory' === $type) - { - $type = 'data'; - } - // add little more help if it is an access token issue - $errorMessage = JText::sprintf('COM_COMPONENTBUILDER_SBR_YOU_CAN_ADD_A_BGITHUB_ACCESS_TOKENB_TO_COMPONENTBUILDER_GLOBAL_OPTIONS_TO_MAKE_AUTHENTICATED_REQUESTS_TO_GITHUB_AN_ACCESS_TOKEN_WITH_ONLY_PUBLIC_ACCESS_WILL_DO_TO_RETRIEVE_S', $errorMessage, $type); - } - // set error notice - $message['error'] = $errorMessage; - // we have error message - return $message; - } - return false; - } - - /** - * set the github token - * - * @return array of errors on success - * - */ - protected static function setGithubToken($url) - { - // first check if token already set - if (strpos($url, 'access_token=') !== false) - { - // make sure the token is loaded - if (!UtilitiesStringHelper::check(self::$gitHubAccessToken)) - { - // get the global settings - if (!ObjectHelper::check(self::$params)) - { - self::$params = JComponentHelper::getParams('com_componentbuilder'); - } - self::$gitHubAccessToken = self::$params->get('github_access_token', null); - } - // make sure the token is loaded at this point - if (UtilitiesStringHelper::check(self::$gitHubAccessToken)) - { - $url .= '&access_token=' . self::$gitHubAccessToken; - } - } - return $url; - } - - - /** - * 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 - if ($fieldName) - { - $fieldNames = array( - 'php_import_display' => 'display', - 'php_import_setdata' => 'setdata', - 'php_import_save' => 'save', - 'html_import_view' => 'view', - 'php_import' => 'import', - 'php_import_ext' => 'ext', - 'php_import_headers' => 'headers' - ); - // first check if the field name is found - if (isset($fieldNames[$type])) - { - $type = $fieldNames[$type]; - } - else - { - return ''; - } - } - $script = array(); - if ('display' === $type) - { - // set the display script - $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'][] = 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"; - $script['setdata'][] = self::_t(3) . "[[[-#-#-Component]]]Helper::composerAutoload('phpspreadsheet');"; - $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) . "if ((\$column = \$jinput->getString(\$header, false)) !== false ||"; - $script['setdata'][] = self::_t(5) . "(\$column = \$jinput->getString(strtolower(\$header), false)) !== false)"; - $script['setdata'][] = self::_t(4) . "{"; - $script['setdata'][] = self::_t(5) . "\$data['target_headers'][\$header] = \$column;"; - $script['setdata'][] = self::_t(4) . "}"; - $script['setdata'][] = self::_t(4) . "else"; - $script['setdata'][] = self::_t(4) . "{"; - $script['setdata'][] = self::_t(5) . "\$data['target_headers'][\$header] = null;"; - $script['setdata'][] = self::_t(4) . "}"; - $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 = IOFactory::identify(\$package['dir']);"; - $script['setdata'][] = self::_t(4) . "\$excelReader = 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'][] = 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'][] = 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'][] = 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'][] = ""; - $script['view'][] = PHP_EOL . "
    "; - $script['view'][] = "
    \" method=\"post\" name=\"adminForm\" id=\"adminForm\" class=\"form-horizontal form-validate\">"; - $script['view'][] = ""; - $script['view'][] = PHP_EOL . self::_t(1) . "sidebar)) : ?>"; - $script['view'][] = self::_t(2) . "
    "; - $script['view'][] = self::_t(3) . "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'][] = 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(3) . ""; - $script['view'][] = self::_t(3) . "
    "; - $script['view'][] = self::_t(4) . ""; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(5) . ""; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(3) . "
    "; - $script['view'][] = self::_t(3) . "headerList as \$name => \$title): ?>"; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(5) . ""; - $script['view'][] = self::_t(5) . "
    "; - $script['view'][] = self::_t(6) . ""; - $script['view'][] = self::_t(5) . "
    "; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(3) . ""; - $script['view'][] = self::_t(3) . "
    "; - $script['view'][] = self::_t(4) . "\" onclick=\"Joomla.continueImport()\" />"; - $script['view'][] = self::_t(3) . "
    "; - $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(4) . ""; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(5) . ""; - $script['view'][] = self::_t(5) . "
    "; - $script['view'][] = self::_t(6) . ""; - $script['view'][] = self::_t(5) . "
    "; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(5) . "\" onclick=\"Joomla.submitbutton()\" />    (.csv .xls .ods)"; - $script['view'][] = self::_t(4) . "
    "; - $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(4) . ""; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(5) . ""; - $script['view'][] = self::_t(5) . "
    "; - $script['view'][] = self::_t(6) . "state->get('import.directory'); ?>\" />"; - $script['view'][] = self::_t(5) . "
    "; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(5) . "\" onclick=\"Joomla.submitbutton3()\" />    (.csv .xls .ods)"; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(2) . ""; - $script['view'][] = ""; - $script['view'][] = PHP_EOL . self::_t(2) . ""; - $script['view'][] = self::_t(3) . "
    "; - $script['view'][] = self::_t(4) . ""; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(5) . ""; - $script['view'][] = self::_t(5) . "
    "; - $script['view'][] = self::_t(6) . ""; - $script['view'][] = self::_t(5) . "
    "; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(5) . "\" onclick=\"Joomla.submitbutton4()\" />    (.csv .xls .ods)"; - $script['view'][] = self::_t(4) . "
    "; - $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'][] = 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'][] = 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'][] = 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(PHP_EOL, $script[$type])); - } - return false; - } - - /** - * Field Grouping https://docs.joomla.org/Form_field - * @deprecated 3.3 - **/ - protected static $fieldGroups = array( - 'default' => array( - 'accesslevel', 'cachehandler', 'calendar', 'captcha', 'category', 'checkbox', 'checkboxes', 'chromestyle', - 'color', 'combo', 'componentlayout', 'contentlanguage', 'contenttype', 'databaseconnection', 'components', - 'editor', 'editors', 'email', 'file', 'file', 'filelist', 'folderlist', 'groupedlist', 'headertag', 'helpsite', 'hidden', 'imagelist', - 'integer', 'language', 'list', 'media', 'menu', 'modal_menu', 'menuitem', 'meter', 'modulelayout', 'moduleorder', 'moduleposition', - 'moduletag', 'note', 'number', 'password', 'plugins', 'predefinedlist', 'radio', 'range', 'repeatable', 'rules', - 'sessionhandler', 'spacer', 'sql', 'subform', 'tag', 'tel', 'templatestyle', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup' - ), - 'plain' => array( - 'cachehandler', 'calendar', 'checkbox', 'chromestyle', 'color', 'componentlayout', 'contenttype', 'editor', 'editors', 'captcha', - 'email', 'file', 'headertag', 'helpsite', 'hidden', 'integer', 'language', 'media', 'menu', 'modal_menu', 'menuitem', 'meter', 'modulelayout', 'templatestyle', - 'moduleorder', 'moduletag', 'number', 'password', 'range', 'rules', 'tag', 'tel', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup' - ), - 'option' => array( - 'accesslevel', 'category', 'checkboxes', 'combo', 'contentlanguage', 'databaseconnection', 'components', - 'filelist', 'folderlist', 'imagelist', 'list', 'plugins', 'predefinedlist', 'radio', 'sessionhandler', 'sql', 'groupedlist' - ), - 'text' => array( - 'calendar', 'color', 'editor', 'email', 'number', 'password', 'range', 'tel', 'text', 'textarea', 'url' - ), - 'list' => array( - 'checkbox', 'checkboxes', 'list', 'radio', 'groupedlist', 'combo' - ), - 'dynamic' => array( - 'category', 'file', 'filelist', 'folderlist', 'headertag', 'imagelist', 'integer', 'media', 'meter', 'rules', 'tag', 'timezone', 'user' - ), - 'spacer' => array( - 'note', 'spacer' - ), - 'special' => array( - 'contentlanguage', 'moduleposition', 'plugin', 'repeatable', 'subform' - ), - 'search' => array( - 'editor', 'email', 'tel', 'text', 'textarea', 'url', 'subform' - ) - ); - - /** - * Field Checker - * - * @param string $type The field type - * @param boolean $option The field grouping - * - * @return boolean if the field was found - * @deprecated 3.3 Use Factory::_('Field.Groups')->check($type, $option); - */ - public static function fieldCheck($type, $option = 'default') - { - return Factory::_('Field.Groups')->check($type, $option); - } - - /** - * get the field types id -> name of a group or groups - * - * @return array ids of the spacer field types - * @deprecated 3.3 Use Factory::_('Field.Groups')->types($groups); - */ - public static function getFieldTypesByGroup($groups = array()) - { - return Factory::_('Field.Groups')->types($groups); - } - - /** - * get the field types IDs of a group or groups - * - * @return array ids of the spacer field types - * @deprecated 3.3 Use Factory::_('Field.Groups')->typesIds($groups); - */ - public static function getFieldTypesIdsByGroup($groups = array()) - { - return Factory::_('Field.Groups')->typesIds($groups); - } - - /** - * get the spacer IDs - * - * @return array ids of the spacer field types - * @deprecated 3.3 Use Factory::_('Field.Groups')->spacerIds(); - */ - public static function getSpacerIds() - { - return Factory::_('Field.Groups')->spacerIds(); - } - - - /** - * open base64 string if stored as base64 - * - * @param string $data The base64 string - * @param string $key We store the string with that suffix :) - * @param string $default The default switch - * - * @return string The opened string - * @deprecated 3.3 Use Base64Helper::open($data, $key, $default); - */ - public static function openValidBase64($data, $key = '__.o0=base64=Oo.__', $default = 'string') - { - return Base64Helper::open($data, $key, $default); - } - - /** - * prepare base64 string for url - * - * @deprecate Use urlencode(); - */ - public static function base64_urlencode($string, $encode = false) - { - if ($encode) - { - $string = base64_encode($string); - } - return str_replace(array('+', '/'), array('-', '_'), $string); - } - - /** - * prepare base64 string form url - * - * @deprecate - */ - public static function base64_urldecode($string, $decode = false) - { - $string = str_replace(array('-', '_'), array('+', '/'), $string); - if ($decode) - { - $string = base64_decode($string); - } - return $string; - } - - - /** - * Get the file path or url - * - * @param string $type The (url/path) type to return - * @param string $target The Params Target name (if set) - * @param string $default The default path if not set in Params (fallback path) - * @param bool $createIfNotSet The switch to create the folder if not found - * - * @return string On success the path or url is returned based on the type requested - * - */ - public static function getFolderPath($type = 'path', $target = 'folderpath', $default = '', $createIfNotSet = true) - { - // make sure to always have a string/path - if(!UtilitiesStringHelper::check($default)) - { - $default = JPATH_SITE . '/images/'; - } - // get the global settings - if (!ObjectHelper::check(self::$params)) - { - self::$params = JComponentHelper::getParams('com_componentbuilder'); - } - $folderPath = self::$params->get($target, $default); - // create the folder if it does not exist - if ($createIfNotSet && !Folder::exists($folderPath)) - { - Folder::create($folderPath); - } - // return the url - if ('url' === $type) - { - if (strpos($folderPath, JPATH_SITE) !== false) - { - $folderPath = trim( str_replace( JPATH_SITE, '', $folderPath), '/'); - return JURI::root() . $folderPath . '/'; - } - // since the path is behind the root folder of the site, return only the root url (may be used to build the link) - return JURI::root(); - } - // sanitize the path - return '/' . trim( $folderPath, '/' ) . '/'; - } - - - /** - * the Crypt objects - **/ - protected static $CRYPT = array(); - - /** - * the Cipher MODE switcher (list of ciphers) - **/ - protected static $setCipherMode = array( - 'AES' => true, - 'Rijndael' => true, - 'Twofish' => false, // can but not good idea - 'Blowfish' => false, // can but not good idea - 'RC4' => false, // nope - 'RC2' => false, // can but not good idea - 'TripleDES' => false, // can but not good idea - 'DES' => true - ); - - /** - * get the Crypt object - * - * @return object on success with Crypt power - **/ - public static function crypt($type, $mode = null) - { - // set key based on mode - if ($mode) - { - $key = $type . $mode; - } - else - { - $key = $type; - } - // check if it was already set - if (isset(self::$CRYPT[$key]) && ObjectHelper::check(self::$CRYPT[$key])) - { - return self::$CRYPT[$key]; - } - // make sure we have the composer classes loaded - self::composerAutoload('phpseclib'); - // build class name - $CLASS = '\phpseclib\Crypt\\' . $type; - // make sure we have the phpseclib classes - if (!class_exists($CLASS)) - { - // class not in place so send out error - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_BSB_LIBRARYCLASS_IS_NOT_AVAILABLE_THIS_LIBRARYCLASS_SHOULD_HAVE_BEEN_ADDED_TO_YOUR_BLIBRARIESPHPSECLIBVENDORB_FOLDER_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFO', $CLASS), 'Error'); - return false; - } - // does this crypt class use mode - if ($mode && isset(self::$setCipherMode[$type]) && self::$setCipherMode[$type]) - { - switch ($mode) - { - case 'CTR': - self::$CRYPT[$key] = new $CLASS('ctr'); - break; - case 'ECB': - self::$CRYPT[$key] = new $CLASS('ecb'); - break; - case 'CBC': - self::$CRYPT[$key] = new $CLASS('cbc'); - break; - case 'CBC3': - self::$CRYPT[$key] = new $CLASS('cbc3'); - break; - case 'CFB': - self::$CRYPT[$key] = new $CLASS('cfb'); - break; - case 'CFB8': - self::$CRYPT[$key] = new $CLASS('cfb8'); - break; - case 'OFB': - self::$CRYPT[$key] = new $CLASS('ofb'); - break; - case 'GCM': - self::$CRYPT[$key] = new $CLASS('gcm'); - break; - case 'STREAM': - self::$CRYPT[$key] = new $CLASS('stream'); - break; - default: - // No valid mode has been specified - JFactory::getApplication()->enqueueMessage(JText::_('COM_COMPONENTBUILDER_NO_VALID_MODE_HAS_BEEN_SPECIFIED'), 'Error'); - return false; - break; - } - } - else - { - // set the default - self::$CRYPT[$key] = new $CLASS(); - } - // return the object - return self::$CRYPT[$key]; - } - - /** - * Move File to Server - * - * @param string $localPath The local path to the file - * @param string $fileName The the actual file name - * @param int $serverID The server local id to use - * @param int $protocol The server protocol to use - * @param string $permission The permission validation area - * - * @return bool true on success - **/ - public static function moveToServer($localPath, $fileName, $serverID, $protocol = null, $permission = 'core.export') - { - // get the server - if ($server = self::getServer( (int) $serverID, $protocol, $permission)) - { - // use the FTP protocol - if (1 == $server->jcb_protocol) - { - // now move the file - if (!$server->store($localPath, $fileName)) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_SERVER', $fileName, $server->jcb_remote_server_name[(int) $serverID]), 'Error'); - return false; - } - // close the connection - $server->quit(); - } - // use the SFTP protocol - elseif (2 == $server->jcb_protocol) - { - // get the remote path - $remote_path = '/' . trim($server->jcb_remote_server_path[(int) $serverID], '/') . '/' . $fileName; - // now move the file - if (!$server->put($remote_path, FileHelper::getContent($localPath, null))) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_PATH_ON_BSB_SERVER', $fileName, $server->jcb_remote_server_path[(int) $serverID], $server->jcb_remote_server_name[(int) $serverID]), 'Error'); - return false; - } - } - return true; - } - return false; - } - - /** - * the SFTP objects - **/ - protected static $sftp = array(); - - /** - * the FTP objects - **/ - protected static $ftp = array(); - - /** - * get the server object - * - * @param int $serverID The server local id to use - * @param int $protocol The server protocol to use - * @param string $permission The permission validation area - * - * @return object on success server object - **/ - public static function getServer($serverID, $protocol = null, $permission = 'core.export') - { - // if not protocol is given get it (sad I know) - if (!$protocol) - { - $protocol = self::getVar('server', (int) $serverID, 'id', 'protocol'); - } - // return the server object - switch ($protocol) - { - case 1: // FTP - return self::getFtp($serverID, $permission); - break; - case 2: // SFTP - return self::getSftp($serverID, $permission); - break; - } - return false; - } - - /** - * get the sftp object - * - * @param int $serverID The server local id to use - * @param string $permission The permission validation area - * - * @return object on success with sftp power - **/ - public static function getSftp($serverID, $permission = 'core.export') - { - // check if we have a server with that id - if ($server = self::getServerDetails($serverID, 2, $permission)) - { - // check if it was already set - if (!isset(self::$sftp[$server->cache]) || !ObjectHelper::check(self::$sftp[$server->cache])) - { - // make sure we have the composer classes loaded - self::composerAutoload('phpseclib'); - // make sure we have the phpseclib classes - if (!class_exists('\phpseclib\Net\SFTP')) - { - // class not in place so send out error - JFactory::getApplication()->enqueueMessage(JText::_('COM_COMPONENTBUILDER_THE_BPHPSECLIBNETSFTPB_LIBRARYCLASS_IS_NOT_AVAILABLE_THIS_LIBRARYCLASS_SHOULD_HAVE_BEEN_ADDED_TO_YOUR_BLIBRARIESVDM_IOVENDORB_FOLDER_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFO'), 'Error'); - return false; - } - // insure the port is set - $server->port = (isset($server->port) && is_numeric($server->port) && $server->port > 0) ? (int) $server->port : 22; - // open the connection - self::$sftp[$server->cache] = new phpseclib\Net\SFTP($server->host, $server->port); - // heads-up on protocol - self::$sftp[$server->cache]->jcb_protocol = 2; // SFTP <-- if called not knowing what type of protocol is being used - // now login based on authentication type - switch($server->authentication) - { - case 1: // password - if (!self::$sftp[$server->cache]->login($server->username, $server->password)) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_LOGIN_TO_BSB_HAS_FAILED_PLEASE_CHECK_THAT_YOUR_DETAILS_ARE_CORRECT', $server->name), 'Error'); - unset(self::$sftp[$server->cache]); - return false; - } - break; - case 2: // private key file - if (ObjectHelper::check(self::crypt('RSA'))) - { - // check if we have a passprase - if (UtilitiesStringHelper::check($server->secret)) - { - self::crypt('RSA')->setPassword($server->secret); - } - // now load the key file - if (!self::crypt('RSA')->loadKey(FileHelper::getContent($server->private, null))) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_PRIVATE_KEY_FILE_COULD_NOT_BE_LOADEDFOUND_FOR_BSB_SERVER', $server->name), 'Error'); - unset(self::$sftp[$server->cache]); - return false; - } - // now login - if (!self::$sftp[$server->cache]->login($server->username, self::crypt('RSA'))) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_LOGIN_TO_BSB_HAS_FAILED_PLEASE_CHECK_THAT_YOUR_DETAILS_ARE_CORRECT', $server->name), 'Error'); - unset(self::$sftp[$server->cache]); - return false; - } - } - break; - case 3: // both password and private key file - if (ObjectHelper::check(self::crypt('RSA'))) - { - // check if we have a passphrase - if (UtilitiesStringHelper::check($server->secret)) - { - self::crypt('RSA')->setPassword($server->secret); - } - // now load the key file - if (!self::crypt('RSA')->loadKey(FileHelper::getContent($server->private, null))) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_PRIVATE_KEY_FILE_COULD_NOT_BE_LOADEDFOUND_FOR_BSB_SERVER', $server->name), 'Error'); - unset(self::$sftp[$server->cache]); - return false; - } - // now login - if (!self::$sftp[$server->cache]->login($server->username, $server->password, self::crypt('RSA'))) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_LOGIN_TO_BSB_HAS_FAILED_PLEASE_CHECK_THAT_YOUR_DETAILS_ARE_CORRECT', $server->name), 'Error'); - unset(self::$sftp[$server->cache]); - return false; - } - } - break; - case 4: // private key field - if (ObjectHelper::check(self::crypt('RSA'))) - { - // check if we have a passprase - if (UtilitiesStringHelper::check($server->secret)) - { - self::crypt('RSA')->setPassword($server->secret); - } - // now load the key field - if (!self::crypt('RSA')->loadKey($server->private_key)) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_PRIVATE_KEY_FIELD_COULD_NOT_BE_LOADED_FOR_BSB_SERVER', $server->name), 'Error'); - unset(self::$sftp[$server->cache]); - return false; - } - // now login - if (!self::$sftp[$server->cache]->login($server->username, self::crypt('RSA'))) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_LOGIN_TO_BSB_HAS_FAILED_PLEASE_CHECK_THAT_YOUR_DETAILS_ARE_CORRECT', $server->name), 'Error'); - unset(self::$sftp[$server->cache]); - return false; - } - } - break; - case 5: // both password and private key field - if (ObjectHelper::check(self::crypt('RSA'))) - { - // check if we have a passphrase - if (UtilitiesStringHelper::check($server->secret)) - { - self::crypt('RSA')->setPassword($server->secret); - } - // now load the key file - if (!self::crypt('RSA')->loadKey($server->private_key)) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_PRIVATE_KEY_FIELD_COULD_NOT_BE_LOADED_FOR_BSB_SERVER', $server->name), 'Error'); - unset(self::$sftp[$server->cache]); - return false; - } - // now login - if (!self::$sftp[$server->cache]->login($server->username, $server->password, self::crypt('RSA'))) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_LOGIN_TO_BSB_HAS_FAILED_PLEASE_CHECK_THAT_YOUR_DETAILS_ARE_CORRECT', $server->name), 'Error'); - unset(self::$sftp[$server->cache]); - return false; - } - } - break; - } - } - // only continue if object is set - if (isset(self::$sftp[$server->cache]) && ObjectHelper::check(self::$sftp[$server->cache])) - { - // set the unique buckets - if (!isset(self::$sftp[$server->cache]->jcb_remote_server_name)) - { - self::$sftp[$server->cache]->jcb_remote_server_name = array(); - self::$sftp[$server->cache]->jcb_remote_server_path = array(); - } - // always set the name and remote server path - self::$sftp[$server->cache]->jcb_remote_server_name[$serverID] = $server->name; - self::$sftp[$server->cache]->jcb_remote_server_path[$serverID] = (UtilitiesStringHelper::check($server->path) && $server->path !== '/') ? $server->path : ''; - // return the sftp object - return self::$sftp[$server->cache]; - } - } - return false; - } - - /** - * get the JClientFtp object - * - * @param int $serverID The server local id to use - * @param string $permission The permission validation area - * - * @return object on success with ftp power - **/ - public static function getFtp($serverID, $permission) - { - // check if we have a server with that id - if ($server = self::getServerDetails($serverID, 1, $permission)) - { - // check if we already have the server instance - if (isset(self::$ftp[$server->cache]) && self::$ftp[$server->cache] instanceof JClientFtp) - { - // always set the name and remote server path - self::$ftp[$server->cache]->jcb_remote_server_name[$serverID] = $server->name; - // if still connected we are ready to go - if (self::$ftp[$server->cache]->isConnected()) - { - // return the FTP instance - return self::$ftp[$server->cache]; - } - // check if we can reinitialise the server - if (self::$ftp[$server->cache]->reinit()) - { - // return the FTP instance - return self::$ftp[$server->cache]; - } - } - // make sure we have a string and it is not default or empty - if (UtilitiesStringHelper::check($server->signature)) - { - // turn into variables - parse_str($server->signature); // because of this I am using strange variable naming to avoid any collisions. - // set options - if (isset($options) && UtilitiesArrayHelper::check($options)) - { - foreach ($options as $o__p0t1on => $vAln3) - { - if ('timeout' === $o__p0t1on) - { - $options[$o__p0t1on] = (int) $vAln3; - } - if ('type' === $o__p0t1on) - { - $options[$o__p0t1on] = (string) $vAln3; - } - } - } - else - { - $options = array(); - } - // get ftp object - if (isset($host) && $host != 'HOSTNAME' && isset($port) && $port != 'PORT_INT' && isset($username) && $username != 'user@name.com' && isset($password) && $password != 'password') - { - // load for reuse - self::$ftp[$server->cache] = JClientFtp::getInstance($host, $port, $options, $username, $password); - } - else - { - // load error to indicate signature was in error - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_FTP_SIGNATURE_FOR_BSB_WAS_NOT_WELL_FORMED_PLEASE_CHECK_YOUR_SIGNATURE_DETAILS', $server->name), 'Error'); - return false; - } - // check if we are connected - if (self::$ftp[$server->cache] instanceof JClientFtp && self::$ftp[$server->cache]->isConnected()) - { - // heads-up on protocol - self::$ftp[$server->cache]->jcb_protocol = 1; // FTP <-- if called not knowing what type of protocol is being used - // set the unique buckets - if (!isset(self::$ftp[$server->cache]->jcb_remote_server_name)) - { - self::$ftp[$server->cache]->jcb_remote_server_name = array(); - } - // always set the name and remote server path - self::$ftp[$server->cache]->jcb_remote_server_name[$serverID] = $server->name; - // return the FTP instance - return self::$ftp[$server->cache]; - } - // reset since we have no connection - unset(self::$ftp[$server->cache]); - } - // load error to indicate signature was in error - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_FTP_CONNECTION_FOR_BSB_COULD_NOT_BE_MADE_PLEASE_CHECK_YOUR_SIGNATURE_DETAILS', $server->name), 'Error'); - } - return false; - } - - /** - * get the server details - * - * @param int $serverID The server local id to use - * @param int $protocol The server protocol to use - * @param string $permission The permission validation area - * - * @return object on success with server details - **/ - public static function getServerDetails($serverID, $protocol = 2, $permission = 'core.export') - { - // check if this user has permission to access items - if (!JFactory::getUser()->authorise($permission, 'com_componentbuilder')) - { - // set message to inform the user that permission was denied - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_ACCESS_THE_SERVER_DETAILS_BS_DENIEDB_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFO', UtilitiesStringHelper::safe($permission, 'w')), 'Error'); - return false; - } - // now insure we have correct values - if (is_int($serverID) && is_int($protocol)) - { - // Get a db connection - $db = JFactory::getDbo(); - // start the query - $query = $db->getQuery(true); - // select based to protocol - if (2 == $protocol) - { - // SFTP - $query->select($db->quoteName(array('name','authentication','username','host','password','path','port','private','private_key','secret'))); - // cache builder - $cache = array('authentication','username','host','password','port','private','private_key','secret'); - } - else - { - // FTP - $query->select($db->quoteName(array('name','signature'))); - // cache builder - $cache = array('signature'); - } - $query->from($db->quoteName('#__componentbuilder_server')); - $query->where($db->quoteName('id') . ' = ' . (int) $serverID); - $query->where($db->quoteName('protocol') . ' = ' . (int) $protocol); - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - $server = $db->loadObject(); - // Get the basic encryption. - $basickey = self::getCryptKey('basic', 'Th1sMnsTbL0ck@d'); - // Get the encryption object. - $basic = new AES($basickey, 128); - // start cache keys - $keys = array(); - // unlock the needed fields - foreach($server as $name => &$value) - { - // unlock the needed fields - if ($name !== 'name' && !empty($value) && $basickey && !is_numeric($value) && $value === base64_encode(base64_decode($value, true))) - { - // basic decrypt of data - $value = rtrim($basic->decryptString($value), "\0"); - } - // build cache (keys) for lower connection latency - if (in_array($name, $cache)) - { - $keys[] = $value; - } - } - // check if cache keys were found - if (UtilitiesArrayHelper::check($keys)) - { - // now set cache - $server->cache = md5(implode('', $keys)); - } - else - { - // default is ID - $server->cache = $serverID; - } - // return the server details - return $server; - } - } - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_SERVER_DETAILS_FOR_BID_SB_COULD_NOT_BE_RETRIEVED', $serverID), 'Error'); - return false; - } - - /** - * Load the Composer Vendor phpseclib - */ - protected static function composephpseclib() - { - // load the autoloader for phpseclib - require_once JPATH_SITE . '/libraries/phpseclib/vendor/autoload.php'; - // do not load again - self::$composer['phpseclib'] = true; - - return true; - } - - - /** - * the locker - * - * @var array - **/ - protected static $locker = array(); - - /** - * the dynamic replacement salt - * - * @var array - **/ - protected static $globalSalt = array(); - - /** - * the timer - * - * @var object - **/ - protected static $keytimer; - - /** - * To Lock string - * - * @param string $string The string/array to lock - * @param string $key The custom key to use - * @param int $salt The switch to add salt and type of salt - * @param int $dynamic The dynamic replacement array of salt build string - * @param int $urlencode The switch to control url encoding - * - * @return string Encrypted String - * - **/ - public static function lock($string, $key = null, $salt = 2, $dynamic = null, $urlencode = true) - { - // get the global settings - if (!$key || !UtilitiesStringHelper::check($key)) - { - // set temp timer - $timer = 2; - // if we have a timer use it - if ($salt > 0) - { - $timer = $salt; - } - // set the default key - $key = self::salt($timer, $dynamic); - // try getting the system key - if (method_exists(get_called_class(), "getCryptKey")) - { - // try getting the medium key first the fall back to basic, and then default - $key = self::getCryptKey('medium', self::getCryptKey('basic', $key)); - } - } - // check if we have a salt timer - if ($salt > 0) - { - $key .= self::salt($salt, $dynamic); - } - // get the locker settings - if (!isset(self::$locker[$key]) || !ObjectHelper::check(self::$locker[$key])) - { - self::$locker[$key] = new AES($key, 128); - } - // convert array or object to string - if (UtilitiesArrayHelper::check($string) || ObjectHelper::check($string)) - { - $string = serialize($string); - } - // prep for url - if ($urlencode && method_exists(get_called_class(), "base64_urlencode")) - { - return self::base64_urlencode(self::$locker[$key]->encryptString($string)); - } - return self::$locker[$key]->encryptString($string); - } - - /** - * To un-Lock string - * - * @param string $string The string to unlock - * @param string $key The custom key to use - * @param int $salt The switch to add salt and type of salt - * @param int $dynamic The dynamic replacement array of salt build string - * @param int $urlencode The switch to control url decoding - * - * @return string Decrypted String - * - **/ - public static function unlock($string, $key = null, $salt = 2, $dynamic = null, $urlencode = true) - { - // get the global settings - if (!$key || !UtilitiesStringHelper::check($key)) - { - // set temp timer - $timer = 2; - // if we have a timer use it - if ($salt > 0) - { - $timer = $salt; - } - // set the default key - $key = self::salt($timer, $dynamic); - // try getting the system key - if (method_exists(get_called_class(), "getCryptKey")) - { - // try getting the medium key first the fall back to basic, and then default - $key = self::getCryptKey('medium', self::getCryptKey('basic', $key)); - } - } - // check if we have a salt timer - if ($salt > 0) - { - $key .= self::salt($salt, $dynamic); - } - // get the locker settings - if (!isset(self::$locker[$key]) || !ObjectHelper::check(self::$locker[$key])) - { - self::$locker[$key] = new AES($key, 128); - } - // make sure we have real base64 - if ($urlencode && method_exists(get_called_class(), "base64_urldecode")) - { - $string = self::base64_urldecode($string); - } - // basic decrypt string. - if (!empty($string) && !is_numeric($string) && $string === base64_encode(base64_decode($string, true))) - { - $string = rtrim(self::$locker[$key]->decryptString($string), "\0"); - // convert serial string to array - if (self::is_serial($string)) - { - $string = unserialize($string); - } - } - return $string; - } - - /** - * The Salt - * - * @param int $type The type of length the salt should be valid - * @param int $dynamic The dynamic replacement array of salt build string - * - * @return string - * - **/ - public static function salt($type = 1, $dynamic = null) - { - // get dynamic replacement salt - $dynamic = self::getDynamicSalt($dynamic); - // get the key timer - if (!ObjectHelper::check(self::$keytimer)) - { - // load the date time object - self::$keytimer = new DateTime; - // set the correct time stamp - $vdmLocalTime = new DateTimeZone('Africa/Windhoek'); - self::$keytimer->setTimezone($vdmLocalTime); - } - // set type - if ($type == 2) - { - // hour - $format = 'Y-m-d \o\n ' . self::periodFix(self::$keytimer->format('H')); - } - elseif ($type == 3) - { - // day - $format = 'Y-m-' . self::periodFix(self::$keytimer->format('d')); - } - elseif ($type == 4) - { - // month - $format = 'Y-' . self::periodFix(self::$keytimer->format('m')); - } - else - { - // minute - $format = 'Y-m-d \o\n H:' . self::periodFix(self::$keytimer->format('i')); - } - // get key - if (UtilitiesArrayHelper::check($dynamic)) - { - return md5(str_replace(array_keys($dynamic), array_values($dynamic), self::$keytimer->format($format) . ' @ VDM.I0')); - } - return md5(self::$keytimer->format($format) . ' @ VDM.I0'); - } - - /** - * The function to insure the salt is valid within the given period (third try) - * - * @param int $main The main number - */ - protected static function periodFix($main) - { - return round($main / 3) * 3; - } - - /** - * Check if a string is serialized - * - * @param string $string - * - * @return Boolean - * - */ - public static function is_serial($string) - { - return (@unserialize($string) !== false); - } - - /** - * Get dynamic replacement salt - */ - public static function getDynamicSalt($dynamic = null) - { - // load global if not manually set - if (!UtilitiesArrayHelper::check($dynamic)) - { - return self::getGlobalSalt(); - } - // return manual values if set - else - { - return $dynamic; - } - } - - /** - * The random or dynamic secret salt - */ - public static function getSecretSalt($string = null, $size = 9) - { - // set the string - if (!$string) - { - // get random string - $string = self::randomkey($size); - } - // convert string to array - $string = UtilitiesStringHelper::safe($string); - // convert string to array - $array = str_split($string); - // insure only unique values are used - $array = array_unique($array); - // set the size - $size = ($size <= count($array)) ? $size : count($array); - // down size the - return array_slice($array, 0, $size); - } - - /** - * Get global replacement salt - */ - public static function getGlobalSalt() - { - // load from memory if found - if (!UtilitiesArrayHelper::check(self::$globalSalt)) - { - // get the global settings - if (!ObjectHelper::check(self::$params)) - { - self::$params = JComponentHelper::getParams('com_componentbuilder'); - } - // check if we have a global dynamic replacement array available (format --> ' 1->!,3->E,4->A') - $tmp = self::$params->get('dynamic_salt', null); - if (UtilitiesStringHelper::check($tmp) && strpos($tmp, ',') !== false && strpos($tmp, '->') !== false) - { - $salt = array_map('trim', (array) explode(',', $tmp)); - if (UtilitiesArrayHelper::check($salt )) - { - foreach($salt as $replace) - { - $dynamic = array_map('trim', (array) explode('->', $replace)); - if (isset($dynamic[0]) && isset($dynamic[1])) - { - self::$globalSalt[$dynamic[0]] = $dynamic[1]; - } - } - } - } - } - // return global if found - if (UtilitiesArrayHelper::check(self::$globalSalt)) - { - return self::$globalSalt; - } - // return default as fail safe - return array('1' => '!', '3' => 'E', '4' => 'A'); - } - - /** - * Close public protocol - */ - public static function closePublicProtocol($id, $public) - { - // get secret salt - $secretSalt = self::getSecretSalt(self::salt(1,array('4' => 'R','1' => 'E','2' => 'G','7' => 'J','8' => 'A'))); - // get the key - $key = self::salt(1, $secretSalt); - // get secret salt - $secret = self::getSecretSalt(); - // set the secret - $close['SECRET'] = self::lock($secret, $key, 1, array('1' => 's', '3' => 'R', '4' => 'D')); - // get the key - $key = self::salt(1, $secret); - // get the public key - $close['PUBLIC'] = self::lock($public, $key, 1, array('1' => '!', '3' => 'E', '4' => 'A')); - // get secret salt - $secretSalt = self::getSecretSalt($public); - // get the key - $key = self::salt(1, $secretSalt); - // get the ID - $close['ID'] = self::unlock($id, $key, 1, array('1' => 'i', '3' => 'e', '4' => 'B')); - // return closed values - return $close; - } - - /** - * Open public protocol - */ - public static function openPublicProtocol($SECRET, $ID, $PUBLIC) - { - // get secret salt - $secretSalt = self::getSecretSalt(self::salt(1,array('4' => 'R','1' => 'E','2' => 'G','7' => 'J','8' => 'A'))); - // get the key - $key = self::salt(1, $secretSalt); - // get the $SECRET - $SECRET = self::unlock($SECRET, $key, 1, array('1' => 's', '3' => 'R', '4' => 'D')); - // get the key - $key = self::salt(1, $SECRET); - // get the public key - $open['public'] = self::unlock($PUBLIC, $key, 1, array('1' => '!', '3' => 'E', '4' => 'A')); - // get secret salt - $secretSalt = self::getSecretSalt($open['public']); - // get the key - $key = self::salt(1, $secretSalt); - // get the ID - $open['id'] = self::unlock($ID, $key, 1, array('1' => 'i', '3' => 'e', '4' => 'B')); - // return opened values - return $open; - } - - /** - * Workers to load tasks - * - * @var array - */ - protected static $worker = array(); - - /** - * Set a worker dynamic URLs - * - * @var array - */ - protected static $workerURL = array(); - - /** - * Set a worker dynamic HEADERs - * - * @var array - */ - protected static $workerHEADER = array(); - - /** - * Curl Error Notice - * - * @var bool - */ - protected static $curlErrorLoaded = false; - - /** - * check if a worker has more work - * - * @param string $function The function to target to perform the task - * - * @return bool - * - */ - public static function hasWork(&$function) - { - if (isset(self::$worker[$function]) && UtilitiesArrayHelper::check(self::$worker[$function])) - { - return count( (array) self::$worker[$function]); - } - return false; - } - - /** - * Set a worker url - * - * @param string $function The function to target to perform the task - * @param string $url The url of where the task is to be performed - * - * @return void - * - */ - public static function setWorkerUrl(&$function, &$url) - { - // set the URL if found - if (UtilitiesStringHelper::check($url)) - { - // make sure task function url is up - self::$workerURL[$function] = $url; - } - } - - /** - * Set a worker headers - * - * @param string $function The function to target to perform the task - * @param array $headers The headers needed for these workers/function - * - * @return void - * - */ - public static function setWorkerHeaders(&$function, &$headers) - { - // set the Headers if found - if (UtilitiesArrayHelper::check($headers)) - { - // make sure task function headers are set - self::$workerHEADER[$function] = $headers; - } - } - - /** - * Set a worker that needs to perform a task - * - * @param mixed $data The data to pass to the task - * @param string $function The function to target to perform the task - * @param string $url The url of where the task is to be performed - * @param array $headers The headers needed for these workers/function - * - * @return void - * - */ - public static function setWorker($data, $function, $url = null, $headers = null) - { - // make sure task function is up - if (!isset(self::$worker[$function])) - { - self::$worker[$function] = array(); - } - // load the task - self::$worker[$function][] = self::lock($data); - // set the Headers if found - if ($headers && !isset(self::$workerHEADER[$function])) - { - self::setWorkerHeaders($function, $headers); - } - // set the URL if found - if ($url && !isset(self::$workerURL[$function])) - { - self::setWorkerUrl($function, $url); - } - } - - /** - * Run set Workers - * - * @param string $function The function to target to perform the task - * @param string $perTask The amount of task per worker - * @param function $callback The option to do a call back when task is completed - * @param int $threadSize The size of the thread - * - * @return bool true On success - * - */ - public static function runWorker($function, $perTask = 50, $callback = null, $threadSize = 20) - { - // set task - $task = self::lock($function); - // build headers - $headers = array('VDM-TASK: ' .$task); - // build dynamic headers - if (isset(self::$workerHEADER[$function]) && UtilitiesArrayHelper::check(self::$workerHEADER[$function])) - { - foreach (self::$workerHEADER[$function] as $header) - { - $headers[] = $header; - } - } - // build worker options - $options = array(); - // make sure worker is up - if (isset(self::$worker[$function]) && UtilitiesArrayHelper::check(self::$worker[$function])) - { - // this load method is for each - if (1 == $perTask) - { - // working with a string = 1 - $headers[] = 'VDM-VALUE-TYPE: ' .self::lock(1); - // now load the options - foreach (self::$worker[$function] as $data) - { - $options[] = array(CURLOPT_HTTPHEADER => $headers, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => 'VDM_DATA='. $data); - } - } - // this load method is for bundles - else - { - // working with an array = 2 - $headers[] = 'VDM-VALUE-TYPE: ' .self::lock(2); - // now load the options - $work = array_chunk(self::$worker[$function], $perTask); - foreach ($work as $data) - { - $options[] = array(CURLOPT_HTTPHEADER => $headers, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => 'VDM_DATA='. implode('___VDM___', $data)); - } - } - // relieve worker of task/function - self::$worker[$function] = array(); - } - // do the execution - if (UtilitiesArrayHelper::check($options)) - { - if (isset(self::$workerURL[$function])) - { - $url = self::$workerURL[$function]; - } - else - { - $url = JURI::root() . '/index.php?option=com_componentbuilder&task=api.worker'; - } - return self::curlMultiExec($url, $options, $callback, $threadSize); - } - return false; - } - - /** - * Do a multi curl execution of tasks - * - * @param string $url The url of where the task is to be performed - * @param array $_options The array of curl options/headers to set - * @param function $callback The option to do a call back when task is completed - * @param int $threadSize The size of the thread - * - * @return bool true On success - * - */ - public static function curlMultiExec(&$url, &$_options, $callback = null, $threadSize = 20) - { - // make sure we have curl available - if (!function_exists('curl_version')) - { - if (!self::$curlErrorLoaded) - { - // set the notice - JFactory::getApplication()->enqueueMessage(JText::_('COM_COMPONENTBUILDER_HTWOCURL_NOT_FOUNDHTWOPPLEASE_SETUP_CURL_ON_YOUR_SYSTEM_OR_BCOMPONENTBUILDERB_WILL_NOT_FUNCTION_CORRECTLYP'), 'Error'); - // load the notice only once - self::$curlErrorLoaded = true; - } - return false; - } - // make sure we have an url - if (UtilitiesStringHelper::check($url)) - { - // make sure the thread size isn't greater than the # of _options - $threadSize = (count($_options) < $threadSize) ? count($_options) : $threadSize; - // set the options - $options = array(); - $options[CURLOPT_URL] = $url; - $options[CURLOPT_USERAGENT] = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12'; - $options[CURLOPT_RETURNTRANSFER] = TRUE; - $options[CURLOPT_SSL_VERIFYPEER] = FALSE; - // start multi threading :) - $handle = curl_multi_init(); - // start the first batch of requests - for ($i = 0; $i < $threadSize; $i++) - { - if (isset($_options[$i])) - { - $ch = curl_init(); - foreach ($_options[$i] as $curlopt => $string) - { - $options[$curlopt] = $string; - } - curl_setopt_array($ch, $options); - curl_multi_add_handle($handle, $ch); - } - } - // we wait for all the calls to finish (should not take long) - do { - while(($execrun = curl_multi_exec($handle, $working)) == CURLM_CALL_MULTI_PERFORM); - if($execrun != CURLM_OK) - break; - // a request was just completed -- find out which one - while($done = curl_multi_info_read($handle)) - { - if (is_callable($callback)) - { - // $info = curl_getinfo($done['handle']); - // request successful. process output using the callback function. - $output = curl_multi_getcontent($done['handle']); - $callback($output); - } - $key = $i + 1; - if(isset($_options[$key])) - { - // start a new request (it's important to do this before removing the old one) - $ch = curl_init(); $i++; - // add options - foreach ($_options[$key] as $curlopt => $string) - { - $options[$curlopt] = $string; - } - curl_setopt_array($ch, $options); - curl_multi_add_handle($handle, $ch); - // remove options again - foreach ($_options[$key] as $curlopt => $string) - { - unset($options[$curlopt]); - } - } - // remove the curl handle that just completed - curl_multi_remove_handle($handle, $done['handle']); - } - // stop wasting CPU cycles and rest for a couple ms - usleep(10000); - } while ($working); - // close the curl multi thread - curl_multi_close($handle); - // okay done - return true; - } - return false; - } - - /** - * Get an edit button - * - * @param int $item The item to edit - * @param string $view The type of item to edit - * @param string $views The list view controller name - * @param string $ref The return path - * @param string $component The component these views belong to - * @param string $headsup The message to show on click of button - * - * @return string On success the full html link - * - */ - public static function getEditButton(&$item, $view, $views, $ref = '', $component = 'com_componentbuilder', $headsup = 'COM_COMPONENTBUILDER_ALL_UNSAVED_WORK_ON_THIS_PAGE_WILL_BE_LOST_ARE_YOU_SURE_YOU_WANT_TO_CONTINUE') - { - // get URL - $url = self::getEditURL($item, $view, $views, $ref, $component); - // check if we found any - if (UtilitiesStringHelper::check($url)) - { - // get the global settings - if (!ObjectHelper::check(self::$params)) - { - self::$params = JComponentHelper::getParams('com_componentbuilder'); - } - // get UIKIT version - $uikit = self::$params->get('uikit_version', 2); - // check that we have the ID - if (ObjectHelper::check($item) && isset($item->id)) - { - // check if the checked_out is available - if (isset($item->checked_out)) - { - $checked_out = (int) $item->checked_out; - } - else - { - $checked_out = self::getVar($view, $item->id, 'id', 'checked_out', '=', str_replace('com_', '', $component)); - } - } - elseif (UtilitiesArrayHelper::check($item) && isset($item['id'])) - { - // check if the checked_out is available - if (isset($item['checked_out'])) - { - $checked_out = (int) $item['checked_out']; - } - else - { - $checked_out = self::getVar($view, $item['id'], 'id', 'checked_out', '=', str_replace('com_', '', $component)); - } - } - elseif (is_numeric($item) && $item > 0) - { - $checked_out = self::getVar($view, $item, 'id', 'checked_out', '=', str_replace('com_', '', $component)); - } - // set the link title - $title = UtilitiesStringHelper::safe(JText::_('COM_COMPONENTBUILDER_EDIT') . ' ' . $view, 'W'); - // check that there is a check message - if (UtilitiesStringHelper::check($headsup)) - { - if (3 == $uikit) - { - $href = 'onclick="UIkit.modal.confirm(\''.JText::_($headsup).'\').then( function(){ window.location.href = \'' . $url . '\' } )" href="javascript:void(0)"'; - } - else - { - $href = 'onclick="UIkit2.modal.confirm(\''.JText::_($headsup).'\', function(){ window.location.href = \'' . $url . '\' })" href="javascript:void(0)"'; - } - } - else - { - $href = 'href="' . $url . '"'; - } - // return UIKIT version 3 - if (3 == $uikit) - { - // check if it is checked out - if (isset($checked_out) && $checked_out > 0) - { - // is this user the one who checked it out - if ($checked_out == JFactory::getUser()->id) - { - return ' '; - } - return ' '; - } - // return normal edit link - return ' '; - } - // check if it is checked out (return UIKIT version 2) - if (isset($checked_out) && $checked_out > 0) - { - // is this user the one who checked it out - if ($checked_out == JFactory::getUser()->id) - { - return ' '; - } - return ' '; - } - // return normal edit link - return ' '; - } - return ''; - } - - /** - * Get an edit text button - * - * @param string $text The button text - * @param int $item The item to edit - * @param string $view The type of item to edit - * @param string $views The list view controller name - * @param string $ref The return path - * @param string $component The component these views belong to - * @param string $headsup The message to show on click of button - * - * @return string On success the full html link - * - */ - public static function getEditTextButton($text, &$item, $view, $views, $ref = '', $component = 'com_componentbuilder', $jRoute = true, $class = 'uk-button', $headsup = 'COM_COMPONENTBUILDER_ALL_UNSAVED_WORK_ON_THIS_PAGE_WILL_BE_LOST_ARE_YOU_SURE_YOU_WANT_TO_CONTINUE') - { - // make sure we have text - if (!UtilitiesStringHelper::check($text)) - { - return self::getEditButton($item, $view, $views, $ref, $component, $headsup); - } - // get URL - $url = self::getEditURL($item, $view, $views, $ref, $component, $jRoute); - // check if we found any - if (UtilitiesStringHelper::check($url)) - { - // get the global settings - if (!ObjectHelper::check(self::$params)) - { - self::$params = JComponentHelper::getParams('com_componentbuilder'); - } - // get UIKIT version - $uikit = self::$params->get('uikit_version', 2); - // check that we have the ID - if (ObjectHelper::check($item) && isset($item->id)) - { - // check if the checked_out is available - if (isset($item->checked_out)) - { - $checked_out = (int) $item->checked_out; - } - else - { - $checked_out = self::getVar($view, $item->id, 'id', 'checked_out', '=', str_replace('com_', '', $component)); - } - } - elseif (UtilitiesArrayHelper::check($item) && isset($item['id'])) - { - // check if the checked_out is available - if (isset($item['checked_out'])) - { - $checked_out = (int) $item['checked_out']; - } - else - { - $checked_out = self::getVar($view, $item['id'], 'id', 'checked_out', '=', str_replace('com_', '', $component)); - } - } - elseif (is_numeric($item) && $item > 0) - { - $checked_out = self::getVar($view, $item, 'id', 'checked_out', '=', str_replace('com_', '', $component)); - } - // set the link title - $title = UtilitiesStringHelper::safe(JText::_('COM_COMPONENTBUILDER_EDIT') . ' ' . $view, 'W'); - // check that there is a check message - if (UtilitiesStringHelper::check($headsup)) - { - if (3 == $uikit) - { - $href = 'onclick="UIkit.modal.confirm(\''.JText::_($headsup).'\').then( function(){ window.location.href = \'' . $url . '\' } )" href="javascript:void(0)"'; - } - else - { - $href = 'onclick="UIkit2.modal.confirm(\''.JText::_($headsup).'\', function(){ window.location.href = \'' . $url . '\' })" href="javascript:void(0)"'; - } - } - else - { - $href = 'href="' . $url . '"'; - } - // return UIKIT version 3 - if (3 == $uikit) - { - // check if it is checked out - if (isset($checked_out) && $checked_out > 0) - { - // is this user the one who checked it out - if ($checked_out == JFactory::getUser()->id) - { - return ' ' . $text . ''; - } - return ' ' . $text . ''; - } - // return normal edit link - return ' ' . $text . ''; - } - // check if it is checked out (return UIKIT version 2) - if (isset($checked_out) && $checked_out > 0) - { - // is this user the one who checked it out - if ($checked_out == JFactory::getUser()->id) - { - return ' ' . $text . ''; - } - return ' ' . $text . ''; - } - // return normal edit link - return ' ' . $text . ''; - } - return ''; - } - - /** - * Get the edit URL - * - * @param int $item The item to edit - * @param string $view The type of item to edit - * @param string $views The list view controller name - * @param string $ref The return path - * @param string $component The component these views belong to - * @param bool $jRoute The switch to add use JRoute or not - * - * @return string On success the edit url - * - */ - public static function getEditURL(&$item, $view, $views, $ref = '', $component = 'com_componentbuilder', $jRoute = true) - { - // build record - $record = new stdClass(); - // check if user can edit - if (self::canEditItem($record, $item, $view, $views, $component)) - { - // set the edit link - if ($jRoute) - { - return JRoute::_("index.php?option=" . $component . "&view=" . $views . "&task=" . $view . ".edit&id=" . $record->id . $ref); - } - return "index.php?option=" . $component . "&view=" . $views . "&task=" . $view . ".edit&id=" . $record->id . $ref; - } - return false; - } - - /** - * Can Edit (either any, or own) - * - * @param int $item The item to edit - * @param string $view The type of item to edit - * @param string $views The list view controller name - * @param string $component The component these views belong to - * - * @return bool if user can edit returns true els - * - */ - public static function allowEdit(&$item, $view, $views, $component = 'com_componentbuilder') - { - // build record - $record = new stdClass(); - return self::canEditItem($record, $item, $view, $views, $component); - } - - - /** - * Can Edit (either any, or own) - * - * @param int $item The item to edit - * @param string $view The type of item to edit - * @param string $views The list view controller name - * @param string $component The component these views belong to - * - * @return bool if user can edit returns true els - * - */ - protected static function canEditItem(&$record, &$item, $view, $views, $component = 'com_componentbuilder') - { - // make sure the user has access to view - if (!JFactory::getUser()->authorise($view. '.access', $component)) - { - return false; - } - // we start with false. - $can_edit = false; - // check that we have the ID - if (ObjectHelper::check($item) && isset($item->id)) - { - $record->id = (int) $item->id; - // check if created_by is available - if (isset($item->created_by) && $item->created_by > 0) - { - $record->created_by = (int) $item->created_by; - } - } - elseif (UtilitiesArrayHelper::check($item) && isset($item['id'])) - { - $record->id = (int) $item['id']; - // check if created_by is available - if (isset($item['created_by']) && $item['created_by'] > 0) - { - $record->created_by = (int) $item['created_by']; - } - } - elseif (is_numeric($item)) - { - $record->id = (int) $item; - } - // check ID - if (isset($record->id) && $record->id > 0) - { - // get user action permission to edit - $action = self::getActions($view, $record, $views, 'edit', str_replace('com_', '', $component)); - // check if the view permission is set - if (($can_edit = $action->get($view . '.edit', 'none-set')) === 'none-set') - { - // fall back on the core permission then (this can be an issue) - $can_edit = ($action->get('core.edit', false) || $action->get('core.edit.own', false)); - } - } - return $can_edit; - } - - /** - * set subform type table - * - * @param array $head The header names - * @param array $rows The row values - * @param string $idName The prefix to the table id - * - * @return string - * - */ - public static function setSubformTable($head, $rows, $idName) - { - $table[] = "
    "; - $table[] = "\t
    "; - $table[] = "\t\t
    "; - $table[] = "\t\t\t"; - $table[] = "\t\t\t\t"; - $table[] = "\t\t\t\t\t"; - $table[] = "\t\t\t\t\t\t"; - $table[] = "\t\t\t\t\t"; - $table[] = "\t\t\t\t"; - $table[] = "\t\t\t\t"; - foreach ($rows as $row) - { - $table[] = "\t\t\t\t\t"; - $table[] = "\t\t\t\t\t\t" . $row; - $table[] = "\t\t\t\t\t"; - } - $table[] = "\t\t\t\t"; - $table[] = "\t\t\t
    " . implode("", $head) . "
    "; - $table[] = "\t\t
    "; - $table[] = "\t
    "; - $table[] = "
    "; - // return the table - return implode("\n", $table); - } - - - /** - * Change to nice fancy date - */ - public static function fancyDate($date, $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($date)) - { - $date = strtotime($date); - } - return date('jS \o\f F Y',$date); - } - - /** - * get date based in period past - */ - public static function fancyDynamicDate($date, $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($date)) - { - $date = strtotime($date); - } - // older then year - $lastyear = date("Y", strtotime("-1 year")); - $tragetyear = date("Y", $date); - if ($tragetyear <= $lastyear) - { - return date('m/d/y', $date); - } - // same day - $yesterday = strtotime("-1 day"); - if ($date > $yesterday) - { - return date('g:i A', $date); - } - // just month day - return date('M j', $date); - } - - /** - * Change to nice fancy day time and date - */ - public static function fancyDayTimeDate($time, $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($time)) - { - $time = strtotime($time); - } - return date('D ga jS \o\f F Y',$time); - } - - /** - * Change to nice fancy time and date - */ - public static function fancyDateTime($time, $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($time)) - { - $time = strtotime($time); - } - return date('(G:i) jS \o\f F Y',$time); - } - - /** - * Change to nice hour:minutes time - */ - public static function fancyTime($time, $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($time)) - { - $time = strtotime($time); - } - return date('G:i',$time); - } - - /** - * set the date day as Sunday through Saturday - */ - public static function setDayName($date, $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($date)) - { - $date = strtotime($date); - } - return date('l', $date); - } - - /** - * set the date month as January through December - */ - public static function setMonthName($date, $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($date)) - { - $date = strtotime($date); - } - return date('F', $date); - } - - /** - * set the date day as 1st - */ - public static function setDay($date, $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($date)) - { - $date = strtotime($date); - } - return date('jS', $date); - } - - /** - * set the date month as 5 - */ - public static function setMonth($date, $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($date)) - { - $date = strtotime($date); - } - return date('n', $date); - } - - /** - * set the date year as 2004 (for charts) - */ - public static function setYear($date, $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($date)) - { - $date = strtotime($date); - } - return date('Y', $date); - } - - /** - * set the date as 2004/05 (for charts) - */ - public static function setYearMonth($date, $spacer = '/', $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($date)) - { - $date = strtotime($date); - } - return date('Y' . $spacer . 'm', $date); - } - - /** - * set the date as 2004/05/03 (for charts) - */ - public static function setYearMonthDay($date, $spacer = '/', $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($date)) - { - $date = strtotime($date); - } - return date('Y' . $spacer . 'm' . $spacer . 'd', $date); - } - - /** - * set the date as 03/05/2004 - */ - public static function setDayMonthYear($date, $spacer = '/', $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($date)) - { - $date = strtotime($date); - } - return date('d' . $spacer . 'm' . $spacer . 'Y', $date); - } - - /** - * Check if string is a valid time stamp - */ - public static function isValidTimeStamp($timestamp) - { - return ((int) $timestamp === $timestamp) - && ($timestamp <= PHP_INT_MAX) - && ($timestamp >= ~PHP_INT_MAX); - } - - /** - * Check if string is a valid date - * https://www.php.net/manual/en/function.checkdate.php#113205 - */ - public static function isValidateDate($date, $format = 'Y-m-d H:i:s') - { - $d = DateTime::createFromFormat($format, $date); - return $d && $d->format($format) == $date; - } - - - /** - * The subform layouts - **/ - protected static $subformLayouts = false; - - /** - * get the subform layout - * - * @input string The view name - * @input string The string name - * - * @returns string on success - **/ - public static function getSubformLayout($view, $field, $default = 'repeatablejcb') - { - // get global values - if (self::$subformLayouts === false) - { - self::$subformLayouts = JComponentHelper::getParams('com_componentbuilder')->get('subform_layouts', false); - } - // check what we found (else) return default - if (ObjectHelper::check(self::$subformLayouts)) - { - // looking for - $target = $view . '.' . $field; - foreach (self::$subformLayouts as $subform) - { - if ($target === $subform->view_field) - { - return $subform->layout; - } - elseif ('default' === $subform->view_field) - { - $default = $subform->layout; - } - } - } - return $default; - } - - - /** - * Check if a row already exist - * - * @param string $table The table from which to get the variable - * @param array $where The value where - * @param string $main The component in which the table is found - * - * @return int the id, or false - * - */ - public static function checkExist($table, $where, $what = 'id', $operator = '=', $main = 'componentbuilder') - { - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - $query->select($db->quoteName(array($what))); - if (empty($table)) - { - $query->from($db->quoteName('#__'.$main)); - } - else - { - $query->from($db->quoteName('#__'.$main.'_'.$table)); - } - if (UtilitiesArrayHelper::check($where)) - { - foreach ($where as $key => $value) - { - if (is_numeric($value)) - { - if (is_float($value + 0)) - { - $query->where($db->quoteName($key) . ' ' . $operator . ' ' . (float) $value); - } - else - { - $query->where($db->quoteName($key) . ' ' . $operator . ' ' . (int) $value); - } - } - elseif (is_bool($value)) - { - $query->where($db->quoteName($key) . ' ' . $operator . ' ' . (bool) $value); - } - // we do not allow arrays at this point - elseif (!UtilitiesArrayHelper::check($value)) - { - $query->where($db->quoteName($key) . ' ' . $operator . ' ' . $db->quote( (string) $value)); - } - else - { - return false; - } - } - } - else - { - return false; - } - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - return $db->loadResult(); - } - return false; - } - - - /** - * Load the Composer Vendors - */ - public static function composerAutoload($target) - { - // insure we load the composer vendor only once - if (!isset(self::$composer[$target])) - { - // get the function name - $functionName = self::safeString('compose' . $target); - // check if method exist - if (method_exists(__CLASS__, $functionName)) - { - return self::{$functionName}(); - } - return false; - } - return self::$composer[$target]; - } - - /** - * Load the Component xml manifest. - */ - public static function manifest() - { - $manifestUrl = JPATH_ADMINISTRATOR."/components/com_componentbuilder/componentbuilder.xml"; - return simplexml_load_file($manifestUrl); - } - - /** - * Joomla version object - */ - protected static $JVersion; - - /** - * set/get Joomla version - */ - public static function jVersion() - { - // check if set - if (!self::checkObject(self::$JVersion)) - { - self::$JVersion = new JVersion(); - } - return self::$JVersion; - } - - /** - * Load the Contributors details. - */ - public static function getContributors() - { - // get params - $params = JComponentHelper::getParams('com_componentbuilder'); - // start contributors array - $contributors = array(); - // get all Contributors (max 20) - $searchArray = range('0','20'); - foreach($searchArray as $nr) - { - if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 1 || $params->get("showContributor".$nr) == 3)) - { - // set link based of selected option - if($params->get("useContributor".$nr) == 1) - { - $link_front = ''; - $link_back = ''; - } - elseif($params->get("useContributor".$nr) == 2) - { - $link_front = ''; - $link_back = ''; - } - else - { - $link_front = ''; - $link_back = ''; - } - $contributors[$nr]['title'] = self::htmlEscape($params->get("titleContributor".$nr)); - $contributors[$nr]['name'] = $link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back; - } - } - return $contributors; - } - - /** - * Load the Component Help URLs. - **/ - public static function getHelpUrl($view) - { - $user = JFactory::getUser(); - $groups = $user->get('groups'); - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $query->select(array('a.id','a.groups','a.target','a.type','a.article','a.url')); - $query->from('#__componentbuilder_help_document AS a'); - $query->where('a.admin_view = '.$db->quote($view)); - $query->where('a.location = 1'); - $query->where('a.published = 1'); - $db->setQuery($query); - $db->execute(); - if($db->getNumRows()) - { - $helps = $db->loadObjectList(); - if (self::checkArray($helps)) - { - foreach ($helps as $nr => $help) - { - if ($help->target == 1) - { - $targetgroups = json_decode($help->groups, true); - if (!array_intersect($targetgroups, $groups)) - { - // if user not in those target groups then remove the item - unset($helps[$nr]); - continue; - } - } - // set the return type - switch ($help->type) - { - // set joomla article - case 1: - return self::loadArticleLink($help->article); - break; - // set help text - case 2: - return self::loadHelpTextLink($help->id); - break; - // set Link - case 3: - return $help->url; - break; - } - } - } - } - return false; - } - - /** - * Get the Article Link. - **/ - protected static function loadArticleLink($id) - { - return JURI::root().'index.php?option=com_content&view=article&id='.$id.'&tmpl=component&layout=modal'; - } - - /** - * Get the Help Text Link. - **/ - protected static function loadHelpTextLink($id) - { - $token = JSession::getFormToken(); - return 'index.php?option=com_componentbuilder&task=help.getText&id=' . (int) $id . '&token=' . $token; - } - - /** - * Configure the Linkbar. - */ - public static function addSubmenu($submenu) - { - // load user for access menus - $user = JFactory::getUser(); - // load the submenus to sidebar - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_DASHBOARD'), 'index.php?option=com_componentbuilder&view=componentbuilder', $submenu === 'componentbuilder'); - // Access control (compiler.submenu). - if ($user->authorise('compiler.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_COMPILER'), 'index.php?option=com_componentbuilder&view=compiler', $submenu === 'compiler'); - } - if ($user->authorise('joomla_component.access', 'com_componentbuilder') && $user->authorise('joomla_component.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_JOOMLA_COMPONENTS'), 'index.php?option=com_componentbuilder&view=joomla_components', $submenu === 'joomla_components'); - } - if ($user->authorise('joomla_module.access', 'com_componentbuilder') && $user->authorise('joomla_module.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_JOOMLA_MODULES'), 'index.php?option=com_componentbuilder&view=joomla_modules', $submenu === 'joomla_modules'); - } - if ($user->authorise('joomla_plugin.access', 'com_componentbuilder') && $user->authorise('joomla_plugin.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_JOOMLA_PLUGINS'), 'index.php?option=com_componentbuilder&view=joomla_plugins', $submenu === 'joomla_plugins'); - } - if ($user->authorise('power.access', 'com_componentbuilder') && $user->authorise('power.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_POWERS'), 'index.php?option=com_componentbuilder&view=powers', $submenu === 'powers'); - } - // Access control (search.access && search.submenu). - if ($user->authorise('search.access', 'com_componentbuilder') && $user->authorise('search.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_SEARCH'), 'index.php?option=com_componentbuilder&view=search', $submenu === 'search'); - } - if ($user->authorise('admin_view.access', 'com_componentbuilder') && $user->authorise('admin_view.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_ADMIN_VIEWS'), 'index.php?option=com_componentbuilder&view=admin_views', $submenu === 'admin_views'); - } - if ($user->authorise('custom_admin_view.access', 'com_componentbuilder') && $user->authorise('custom_admin_view.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_CUSTOM_ADMIN_VIEWS'), 'index.php?option=com_componentbuilder&view=custom_admin_views', $submenu === 'custom_admin_views'); - } - if ($user->authorise('site_view.access', 'com_componentbuilder') && $user->authorise('site_view.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_SITE_VIEWS'), 'index.php?option=com_componentbuilder&view=site_views', $submenu === 'site_views'); - } - if ($user->authorise('template.access', 'com_componentbuilder') && $user->authorise('template.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_TEMPLATES'), 'index.php?option=com_componentbuilder&view=templates', $submenu === 'templates'); - } - if ($user->authorise('layout.access', 'com_componentbuilder') && $user->authorise('layout.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_LAYOUTS'), 'index.php?option=com_componentbuilder&view=layouts', $submenu === 'layouts'); - } - if ($user->authorise('dynamic_get.access', 'com_componentbuilder') && $user->authorise('dynamic_get.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_DYNAMIC_GETS'), 'index.php?option=com_componentbuilder&view=dynamic_gets', $submenu === 'dynamic_gets'); - } - if ($user->authorise('custom_code.access', 'com_componentbuilder') && $user->authorise('custom_code.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_CUSTOM_CODES'), 'index.php?option=com_componentbuilder&view=custom_codes', $submenu === 'custom_codes'); - } - if ($user->authorise('placeholder.access', 'com_componentbuilder') && $user->authorise('placeholder.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_PLACEHOLDERS'), 'index.php?option=com_componentbuilder&view=placeholders', $submenu === 'placeholders'); - } - if ($user->authorise('library.access', 'com_componentbuilder') && $user->authorise('library.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_LIBRARIES'), 'index.php?option=com_componentbuilder&view=libraries', $submenu === 'libraries'); - } - if ($user->authorise('snippet.access', 'com_componentbuilder') && $user->authorise('snippet.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_SNIPPETS'), 'index.php?option=com_componentbuilder&view=snippets', $submenu === 'snippets'); - } - // Access control (get_snippets.submenu). - if ($user->authorise('get_snippets.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_GET_SNIPPETS'), 'index.php?option=com_componentbuilder&view=get_snippets', $submenu === 'get_snippets'); - } - if ($user->authorise('validation_rule.access', 'com_componentbuilder') && $user->authorise('validation_rule.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_VALIDATION_RULES'), 'index.php?option=com_componentbuilder&view=validation_rules', $submenu === 'validation_rules'); - } - if ($user->authorise('field.access', 'com_componentbuilder') && $user->authorise('field.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_FIELDS'), 'index.php?option=com_componentbuilder&view=fields', $submenu === 'fields'); - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_FIELD_FIELDS_CATEGORIES'), 'index.php?option=com_categories&view=categories&extension=com_componentbuilder.field', $submenu === 'categories.field'); - } - if ($user->authorise('fieldtype.access', 'com_componentbuilder') && $user->authorise('fieldtype.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_FIELDTYPES'), 'index.php?option=com_componentbuilder&view=fieldtypes', $submenu === 'fieldtypes'); - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_FIELDTYPE_FIELDTYPES_CATEGORIES'), 'index.php?option=com_categories&view=categories&extension=com_componentbuilder.fieldtype', $submenu === 'categories.fieldtype'); - } - if ($user->authorise('language_translation.access', 'com_componentbuilder') && $user->authorise('language_translation.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_LANGUAGE_TRANSLATIONS'), 'index.php?option=com_componentbuilder&view=language_translations', $submenu === 'language_translations'); - } - if ($user->authorise('language.access', 'com_componentbuilder') && $user->authorise('language.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_LANGUAGES'), 'index.php?option=com_componentbuilder&view=languages', $submenu === 'languages'); - } - if ($user->authorise('server.access', 'com_componentbuilder') && $user->authorise('server.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_SERVERS'), 'index.php?option=com_componentbuilder&view=servers', $submenu === 'servers'); - } - if ($user->authorise('help_document.access', 'com_componentbuilder') && $user->authorise('help_document.submenu', 'com_componentbuilder')) - { - JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_HELP_DOCUMENTS'), 'index.php?option=com_componentbuilder&view=help_documents', $submenu === 'help_documents'); - } - } - - /** - * UIKIT Component Classes - **/ - public static $uk_components = array( - 'data-uk-grid' => array( - 'grid' ), - 'uk-accordion' => array( - 'accordion' ), - 'uk-autocomplete' => array( - 'autocomplete' ), - 'data-uk-datepicker' => array( - 'datepicker' ), - 'uk-form-password' => array( - 'form-password' ), - 'uk-form-select' => array( - 'form-select' ), - 'data-uk-htmleditor' => array( - 'htmleditor' ), - 'data-uk-lightbox' => array( - 'lightbox' ), - 'uk-nestable' => array( - 'nestable' ), - 'UIkit.notify' => array( - 'notify' ), - 'data-uk-parallax' => array( - 'parallax' ), - 'uk-search' => array( - 'search' ), - 'uk-slider' => array( - 'slider' ), - 'uk-slideset' => array( - 'slideset' ), - 'uk-slideshow' => array( - 'slideshow', - 'slideshow-fx' ), - 'uk-sortable' => array( - 'sortable' ), - 'data-uk-sticky' => array( - 'sticky' ), - 'data-uk-timepicker' => array( - 'timepicker' ), - 'data-uk-tooltip' => array( - 'tooltip' ), - 'uk-placeholder' => array( - 'placeholder' ), - 'uk-dotnav' => array( - 'dotnav' ), - 'uk-slidenav' => array( - 'slidenav' ), - 'uk-form' => array( - 'form-advanced' ), - 'uk-progress' => array( - 'progress' ), - 'upload-drop' => array( - 'upload', 'form-file' ) - ); - - /** - * Add UIKIT Components - **/ - public static $uikit = false; - - /** - * Get UIKIT Components - **/ - public static function getUikitComp($content,$classes = array()) - { - if (strpos($content,'class="uk-') !== false) - { - // reset - $temp = array(); - foreach (self::$uk_components as $looking => $add) - { - if (strpos($content,$looking) !== false) - { - $temp[] = $looking; - } - } - // make sure uikit is loaded to config - if (strpos($content,'class="uk-') !== false) - { - self::$uikit = true; - } - // sorter - if (self::checkArray($temp)) - { - // merger - if (self::checkArray($classes)) - { - $newTemp = array_merge($temp,$classes); - $temp = array_unique($newTemp); - } - return $temp; - } - } - if (self::checkArray($classes)) - { - return $classes; - } - return false; - } - - /** - * Prepares the xml document - */ - public static function xls($rows, $fileName = null, $title = null, $subjectTab = null, $creator = 'Vast Development Method', $description = null, $category = null,$keywords = null, $modified = null) - { - // set the user - $user = JFactory::getUser(); - // set fileName if not set - if (!$fileName) - { - $fileName = 'exported_'.JFactory::getDate()->format('jS_F_Y'); - } - // set modified if not set - if (!$modified) - { - $modified = $user->name; - } - // set title if not set - if (!$title) - { - $title = 'Book1'; - } - // set tab name if not set - if (!$subjectTab) - { - $subjectTab = 'Sheet1'; - } - - // make sure we have the composer classes loaded - self::composerAutoload('phpspreadsheet'); - - // Create new Spreadsheet object - $spreadsheet = new Spreadsheet(); - - // Set document properties - $spreadsheet->getProperties() - ->setCreator($creator) - ->setCompany('Vast Development Method') - ->setLastModifiedBy($modified) - ->setTitle($title) - ->setSubject($subjectTab); - // The file type - $file_type = 'Xls'; - // set description - if ($description) - { - $spreadsheet->getProperties()->setDescription($description); - } - // set keywords - if ($keywords) - { - $spreadsheet->getProperties()->setKeywords($keywords); - } - // set category - if ($category) - { - $spreadsheet->getProperties()->setCategory($category); - } - - // Some styles - $headerStyles = array( - 'font' => array( - 'bold' => true, - 'color' => array('rgb' => '1171A3'), - 'size' => 12, - 'name' => 'Verdana' - )); - $sideStyles = array( - 'font' => array( - 'bold' => true, - 'color' => array('rgb' => '444444'), - 'size' => 11, - 'name' => 'Verdana' - )); - $normalStyles = array( - 'font' => array( - 'color' => array('rgb' => '444444'), - 'size' => 11, - 'name' => 'Verdana' - )); - - // Add some data - if (($size = self::checkArray($rows)) !== false) - { - $i = 1; - - // Based on data size we adapt the behaviour. - $xls_mode = 1; - if ($size > 3000) - { - $xls_mode = 3; - $file_type = 'Csv'; - } - elseif ($size > 2000) - { - $xls_mode = 2; - } - - // Set active sheet and get it. - $active_sheet = $spreadsheet->setActiveSheetIndex(0); - foreach ($rows as $array) - { - $a = 'A'; - foreach ($array as $value) - { - $active_sheet->setCellValue($a.$i, $value); - if ($xls_mode != 3) - { - if ($i == 1) - { - $active_sheet->getColumnDimension($a)->setAutoSize(true); - $active_sheet->getStyle($a.$i)->applyFromArray($headerStyles); - $active_sheet->getStyle($a.$i)->getAlignment()->setHorizontal(PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - } - elseif ($a === 'A') - { - $active_sheet->getStyle($a.$i)->applyFromArray($sideStyles); - } - elseif ($xls_mode == 1) - { - $active_sheet->getStyle($a.$i)->applyFromArray($normalStyles); - } - } - $a++; - } - $i++; - } - } - else - { - return false; - } - - // Rename worksheet - $spreadsheet->getActiveSheet()->setTitle($subjectTab); - - // Set active sheet index to the first sheet, so Excel opens this as the first sheet - $spreadsheet->setActiveSheetIndex(0); - - // Redirect output to a client's web browser (Excel5) - header('Content-Type: application/vnd.ms-excel'); - header('Content-Disposition: attachment;filename="' . $fileName . '.' . strtolower($file_type) .'"'); - header('Cache-Control: max-age=0'); - // If you're serving to IE 9, then the following may be needed - header('Cache-Control: max-age=1'); - - // If you're serving to IE over SSL, then the following may be needed - header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past - header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified - header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1 - header ('Pragma: public'); // HTTP/1.0 - - $writer = IOFactory::createWriter($spreadsheet, $file_type); - $writer->save('php://output'); - jexit(); - } - - /** - * Get CSV Headers - */ - public static function getFileHeaders($dataType) - { - // make sure we have the composer classes loaded - self::composerAutoload('phpspreadsheet'); - // get session object - $session = JFactory::getSession(); - $package = $session->get('package', null); - $package = json_decode($package, true); - // set the headers - if(isset($package['dir'])) - { - // only load first three rows - $chunkFilter = new PhpOffice\PhpSpreadsheet\Reader\chunkReadFilter(2,1); - // identify the file type - $inputFileType = IOFactory::identify($package['dir']); - // create the reader for this file type - $excelReader = IOFactory::createReader($inputFileType); - // load the limiting filter - $excelReader->setReadFilter($chunkFilter); - $excelReader->setReadDataOnly(true); - // load the rows (only first three) - $excelObj = $excelReader->load($package['dir']); - $headers = array(); - foreach ($excelObj->getActiveSheet()->getRowIterator() as $row) - { - if($row->getRowIndex() == 1) - { - $cellIterator = $row->getCellIterator(); - $cellIterator->setIterateOnlyExistingCells(false); - foreach ($cellIterator as $cell) - { - if (!is_null($cell)) - { - $headers[$cell->getColumn()] = $cell->getValue(); - } - } - $excelObj->disconnectWorksheets(); - unset($excelObj); - break; - } - } - return $headers; - } - return false; - } - - /** - * Load the Composer Vendor phpspreadsheet - */ - protected static function composephpspreadsheet() - { - // load the autoloader for phpspreadsheet - require_once JPATH_SITE . '/libraries/phpspreadsheet/vendor/autoload.php'; - // do not load again - self::$composer['phpspreadsheet'] = true; - - return true; - } - - public static function isPublished($id,$type) - { - if ($type == 'raw') - { - $type = 'item'; - } - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $query->select(array('a.published')); - $query->from('#__componentbuilder_'.$type.' AS a'); - $query->where('a.id = '. (int) $id); - $query->where('a.published = 1'); - $db->setQuery($query); - $db->execute(); - $found = $db->getNumRows(); - if($found) - { - return true; - } - return false; - } - - public static function getGroupName($id) - { - $db = JFactory::getDBO(); - $query = $db->getQuery(true); - $query->select(array('a.title')); - $query->from('#__usergroups AS a'); - $query->where('a.id = '. (int) $id); - $db->setQuery($query); - $db->execute(); - $found = $db->getNumRows(); - if($found) - { - return $db->loadResult(); - } - return $id; - } - - /** - * Get the action permissions - * - * @param string $view The related view name - * @param int $record The item to act upon - * @param string $views The related list view name - * @param mixed $target Only get this permission (like edit, create, delete) - * @param string $component The target component - * @param object $user The user whose permissions we are loading - * - * @return object The JObject of permission/authorised actions - * - */ - public static function getActions($view, &$record = null, $views = null, $target = null, $component = 'componentbuilder', $user = 'null') - { - // load the user if not given - if (!self::checkObject($user)) - { - // get the user object - $user = JFactory::getUser(); - } - // load the JObject - $result = new JObject; - // make view name safe (just incase) - $view = self::safeString($view); - if (self::checkString($views)) - { - $views = self::safeString($views); - } - // get all actions from component - $actions = JAccess::getActionsFromFile( - JPATH_ADMINISTRATOR . '/components/com_' . $component . '/access.xml', - "/access/section[@name='component']/" - ); - // if non found then return empty JObject - if (empty($actions)) - { - return $result; - } - // get created by if not found - if (self::checkObject($record) && !isset($record->created_by) && isset($record->id)) - { - $record->created_by = self::getVar($view, $record->id, 'id', 'created_by', '=', $component); - } - // set actions only set in component settings - $componentActions = array('core.admin', 'core.manage', 'core.options', 'core.export'); - // check if we have a target - $checkTarget = false; - if ($target) - { - // convert to an array - if (self::checkString($target)) - { - $target = array($target); - } - // check if we are good to go - if (self::checkArray($target)) - { - $checkTarget = true; - } - } - // loop the actions and set the permissions - foreach ($actions as $action) - { - // check target action filter - if ($checkTarget && self::filterActions($view, $action->name, $target)) - { - continue; - } - // set to use component default - $fallback = true; - // reset permission per/action - $permission = false; - $catpermission = false; - // set area - $area = 'comp'; - // check if the record has an ID and the action is item related (not a component action) - if (self::checkObject($record) && isset($record->id) && $record->id > 0 && !in_array($action->name, $componentActions) && - (strpos($action->name, 'core.') !== false || strpos($action->name, $view . '.') !== false)) - { - // we are in item - $area = 'item'; - // The record has been set. Check the record permissions. - $permission = $user->authorise($action->name, 'com_' . $component . '.' . $view . '.' . (int) $record->id); - // if no permission found, check edit own - if (!$permission) - { - // With edit, if the created_by matches current user then dig deeper. - if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) - { - // the correct target - $coreCheck = (array) explode('.', $action->name); - // check that we have both local and global access - if ($user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component . '.' . $view . '.' . (int) $record->id) && - $user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component)) - { - // allow edit - $result->set($action->name, true); - // set not to use global default - // because we already validated it - $fallback = false; - } - else - { - // do not allow edit - $result->set($action->name, false); - $fallback = false; - } - } - } - elseif (self::checkString($views) && isset($record->catid) && $record->catid > 0) - { - // we are in item - $area = 'category'; - // set the core check - $coreCheck = explode('.', $action->name); - $core = $coreCheck[0]; - // make sure we use the core. action check for the categories - if (strpos($action->name, $view) !== false && strpos($action->name, 'core.') === false ) - { - $coreCheck[0] = 'core'; - $categoryCheck = implode('.', $coreCheck); - } - else - { - $categoryCheck = $action->name; - } - // The record has a category. Check the category permissions. - $catpermission = $user->authorise($categoryCheck, 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid); - if (!$catpermission && !is_null($catpermission)) - { - // With edit, if the created_by matches current user then dig deeper. - if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) - { - // check that we have both local and global access - if ($user->authorise('core.edit.own', 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid) && - $user->authorise($core . '.edit.own', 'com_' . $component)) - { - // allow edit - $result->set($action->name, true); - // set not to use global default - // because we already validated it - $fallback = false; - } - else - { - // do not allow edit - $result->set($action->name, false); - $fallback = false; - } - } - } - } - } - // if allowed then fallback on component global settings - if ($fallback) - { - // if item/category blocks access then don't fall back on global - if ((($area === 'item') && !$permission) || (($area === 'category') && !$catpermission)) - { - // do not allow - $result->set($action->name, false); - } - // Finally remember the global settings have the final say. (even if item allow) - // The local item permissions can block, but it can't open and override of global permissions. - // Since items are created by users and global permissions is set by system admin. - else - { - $result->set($action->name, $user->authorise($action->name, 'com_' . $component)); - } - } - } - return $result; - } - - /** - * Filter the action permissions - * - * @param string $action The action to check - * @param array $targets The array of target actions - * - * @return boolean true if action should be filtered out - * - */ - protected static function filterActions(&$view, &$action, &$targets) - { - foreach ($targets as $target) - { - if (strpos($action, $view . '.' . $target) !== false || - strpos($action, 'core.' . $target) !== false) - { - return false; - break; - } - } - return true; - } - - /** - * Get any component's model - */ - public static function getModel($name, $path = JPATH_COMPONENT_ADMINISTRATOR, $Component = 'Componentbuilder', $config = array()) - { - // fix the name - $name = self::safeString($name); - // full path to models - $fullPathModels = $path . '/models'; - // load the model file - JModelLegacy::addIncludePath($fullPathModels, $Component . 'Model'); - // make sure the table path is loaded - if (!isset($config['table_path']) || !self::checkString($config['table_path'])) - { - // This is the JCB default path to tables in Joomla 3.x - $config['table_path'] = JPATH_ADMINISTRATOR . '/components/com_' . strtolower($Component) . '/tables'; - } - // get instance - $model = JModelLegacy::getInstance($name, $Component . 'Model', $config); - // if model not found (strange) - if ($model == false) - { - jimport('joomla.filesystem.file'); - // get file path - $filePath = $path . '/' . $name . '.php'; - $fullPathModel = $fullPathModels . '/' . $name . '.php'; - // check if it exists - if (File::exists($filePath)) - { - // get the file - require_once $filePath; - } - elseif (File::exists($fullPathModel)) - { - // get the file - require_once $fullPathModel; - } - // build class names - $modelClass = $Component . 'Model' . $name; - if (class_exists($modelClass)) - { - // initialize the model - return new $modelClass($config); - } - } - return $model; - } - - /** - * Add to asset Table - */ - public static function setAsset($id, $table, $inherit = true) - { - $parent = JTable::getInstance('Asset'); - $parent->loadByName('com_componentbuilder'); - - $parentId = $parent->id; - $name = 'com_componentbuilder.'.$table.'.'.$id; - $title = ''; - - $asset = JTable::getInstance('Asset'); - $asset->loadByName($name); - - // Check for an error. - $error = $asset->getError(); - - if ($error) - { - return false; - } - else - { - // Specify how a new or moved node asset is inserted into the tree. - if ($asset->parent_id != $parentId) - { - $asset->setLocation($parentId, 'last-child'); - } - - // Prepare the asset to be stored. - $asset->parent_id = $parentId; - $asset->name = $name; - $asset->title = $title; - // get the default asset rules - $rules = self::getDefaultAssetRules('com_componentbuilder', $table, $inherit); - if ($rules instanceof JAccessRules) - { - $asset->rules = (string) $rules; - } - - if (!$asset->check() || !$asset->store()) - { - JFactory::getApplication()->enqueueMessage($asset->getError(), 'warning'); - return false; - } - else - { - // Create an asset_id or heal one that is corrupted. - $object = new stdClass(); - - // Must be a valid primary key value. - $object->id = $id; - $object->asset_id = (int) $asset->id; - - // Update their asset_id to link to the asset table. - return JFactory::getDbo()->updateObject('#__componentbuilder_'.$table, $object, 'id'); - } - } - return false; - } - - /** - * Gets the default asset Rules for a component/view. - */ - protected static function getDefaultAssetRules($component, $view, $inherit = true) - { - // if new or inherited - $assetId = 0; - // Only get the actual item rules if not inheriting - if (!$inherit) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - // check that there is a value - if ($db->getNumRows()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - } - } - // get asset rules - $result = JAccess::getAssetRules($assetId); - if ($result instanceof JAccessRules) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($view !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - elseif ($inherit) - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count((array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules($_result); - // return filtered rules - return $rules; - } - } - return $result; - } - - /** - * xmlAppend - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement - * - * @return void - * @deprecated 3.3 Use FormHelper::append($xml, $node); - */ - public static function xmlAppend(&$xml, $node) - { - FormHelper::append($xml, $node); - } - - /** - * xmlComment - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param string $comment The comment to inject - * - * @return void - * @deprecated 3.3 Use FormHelper::comment($xml, $comment); - */ - public static function xmlComment(&$xml, $comment) - { - FormHelper::comment($xml, $comment); - } - - /** - * xmlAddAttributes - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param array $attributes The attributes to apply to the XML element - * - * @return null - * @deprecated 3.3 Use FormHelper::attributes($xml, $attributes); - */ - public static function xmlAddAttributes(&$xml, $attributes = array()) - { - FormHelper::attributes($xml, $attributes); - } - - /** - * xmlAddOptions - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param array $options The options to apply to the XML element - * - * @return void - * @deprecated 3.3 Use FormHelper::options($xml, $options); - */ - public static function xmlAddOptions(&$xml, $options = array()) - { - FormHelper::options($xml, $options); - } - - /** - * get the field object - * - * @param array $attributes The array of attributes - * @param string $default The default of the field - * @param array $options The options to apply to the XML element - * - * @return object - * @deprecated 3.3 Use FormHelper::field($attributes, $default, $options); - */ - public static function getFieldObject(&$attributes, $default = '', $options = null) - { - return FormHelper::field($attributes, $default, $options); - } - - /** - * get the field xml - * - * @param array $attributes The array of attributes - * @param array $options The options to apply to the XML element - * - * @return object - * @deprecated 3.3 Use FormHelper::xml($attributes, $options); - */ - public static function getFieldXML(&$attributes, $options = null) - { - return FormHelper::xml($attributes, $options); - } - - /** - * Render Bool Button - * - * @param array $args All the args for the button - * 0) name - * 1) additional (options class) // not used at this time - * 2) default - * 3) yes (name) - * 4) no (name) - * - * @return string The input html of the button - * - */ - public static function renderBoolButton() - { - $args = func_get_args(); - // check if there is additional button class - $additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time - // button attributes - $buttonAttributes = array( - 'type' => 'radio', - 'name' => isset($args[0]) ? self::htmlEscape($args[0]) : 'bool_button', - 'label' => isset($args[0]) ? self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool Button', // not seen anyway - 'class' => 'btn-group', - 'filter' => 'INT', - 'default' => isset($args[2]) ? (int) $args[2] : 0); - // set the button options - $buttonOptions = array( - '1' => isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES', - '0' => isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO'); - // return the input - return self::getFieldObject($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input; - } - - /** - * Check if we are connected - * Thanks https://stackoverflow.com/a/4860432/1429677 - * - * @returns bool true on success - */ - public static function isConnected() - { - // If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right? - $connected = @fsockopen("www.example.com", 80); - // website, port (try 80 or 443) - if ($connected) - { - //action when connected - $is_conn = true; - fclose($connected); - } - else - { - //action in connection failure - $is_conn = false; - } - return $is_conn; - } - - // typo sorry! - public static function sorten($string, $length = 40, $addTip = true) - { - return self::shorten($string, $length, $addTip); - } - - /** - * Get The Encryption Keys - * - * @param string $type The type of key - * @param string/bool $default The return value if no key was found - * - * @return string On success - * - **/ - public static function getCryptKey($type, $default = false) - { - // Get the global params - $params = JComponentHelper::getParams('com_componentbuilder', true); - // Basic Encryption Type - if ('basic' === $type) - { - $basic_key = $params->get('basic_key', $default); - if (self::checkString($basic_key)) - { - return $basic_key; - } - } - - return $default; - } -} diff --git a/admin/helpers/componentbuilderemail.php b/admin/helpers/componentbuilderemail.php deleted file mode 100644 index d5da051da..000000000 --- a/admin/helpers/componentbuilderemail.php +++ /dev/null @@ -1,461 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Componentbuilder component email helper - */ -abstract class ComponentbuilderEmail -{ - /** - * The active recipient - * - * @var activeRecipient (array) - */ - public static $active = array(); - - /** - * Configuraiton object - * - * @var JConfig - */ - public static $config = null; - - /** - * Mailer object - * - * @var JMail - */ - public static $mailer = null; - - /** - * Custom Headers - * - * @var array - */ - protected static $header = array(); - - /** - * Get a configuration object - * - */ - public static function getConfig() - { - if (!self::$config) - { - self::$config = JComponentHelper::getParams('com_componentbuilder'); - } - - return self::$config; - } - - /** - * Returns the global mailer object, only creating it if it doesn't already exist. - * - */ - public static function getMailerInstance() - { - if (!self::$mailer) - { - self::$mailer = self::createMailer(); - } - - return self::$mailer; - } - - /** - * Check that a string looks like an email address. - * @param string $address The email address to check - * @param string|callable $patternselect A selector for the validation pattern to use : - * * `auto` Pick best pattern automatically; - * * `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0, PHP >= 5.3.2, 5.2.14; - * * `pcre` Use old PCRE implementation; - * * `php` Use PHP built-in FILTER_VALIDATE_EMAIL; - * * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements. - * * `noregex` Don't use a regex: super fast, really dumb. - * Alternatively you may pass in a callable to inject your own validator, for example: - * PHPMailer::validateAddress('user@example.com', function($address) { - * return (strpos($address, '@') !== false); - * }); - * You can also set the PHPMailer::$validator static to a callable, allowing built-in methods to use your validator. - * @return boolean - * @static - * @access public - */ - public static function validateAddress($address, $patternselect = null) - { - return self::getMailerInstance()->validateAddress($address, $patternselect); - } - - /** - * Get a mailer object. - * - * Returns the global {@link JMail} object, only creating it if it doesn't already exist. - * - * @return JMail object - * - * @see JMail - */ - public static function getMailer() - { - if (!self::$mailer) - { - self::$mailer = self::createMailer(); - } - - $copy = clone self::$mailer; - - return $copy; - } - - /** - * Create a mailer object - * - * @return JMail object - * - * @see JMail - */ - protected static function createMailer() - { - // set component params - $conf = self::getConfig(); - - // now load the mailer - $mailer = $conf->get('mailer', 'global'); - - // Create a JMail object - $mail = JMail::getInstance(); - - // check if set to global - if ('global' == $mailer) - { - // get the global details - $globalConf = JFactory::getConfig(); - - $mailer = $globalConf->get('mailer'); - $smtpauth = ($globalConf->get('smtpauth') == 0) ? null : 1; - $smtpuser = $globalConf->get('smtpuser'); - $smtppass = $globalConf->get('smtppass'); - $smtphost = $globalConf->get('smtphost'); - $smtpsecure = $globalConf->get('smtpsecure'); - $smtpport = $globalConf->get('smtpport'); - $sendmail = $globalConf->get('sendmail'); - $mailfrom = $globalConf->get('mailfrom'); - $fromname = $globalConf->get('fromname'); - $replyto = $globalConf->get('replyto'); - $replytoname = $globalConf->get('replytoname'); - } - else - { - $smtpauth = ($conf->get('smtpauth') == 0) ? null : 1; - $smtpuser = $conf->get('smtpuser'); - $smtppass = $conf->get('smtppass'); - $smtphost = $conf->get('smtphost'); - $smtpsecure = $conf->get('smtpsecure'); - $smtpport = $conf->get('smtpport'); - $sendmail = $conf->get('sendmail'); - $mailfrom = $conf->get('emailfrom'); - $fromname = $conf->get('fromname'); - $replyto = $conf->get('replyto'); - $replytoname = $conf->get('replytoname'); - } - - // Set global sender - $mail->setSender(array($mailfrom, $fromname)); - - // set the global reply-to if found - if ($replyto && $replytoname) - { - $mail->ClearReplyTos(); - $mail->addReplyTo($replyto, $replytoname); - } - - // Default mailer is to use PHP's mail function - switch ($mailer) - { - case 'smtp': - // set the SMTP option - $mail->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport); - break; - - case 'sendmail': - // set the sendmail option - $mail->useSendmail($sendmail); - $mail->IsSendmail(); - break; - - default: - $mail->IsMail(); - break; - } - - return $mail; - } - - /** - * Set a Mail custom header. - * - * @return void - */ - public static function setHeader($target, $value) - { - // set the header - self::$header[$target] = $value; - } - - /** - * Send an email - * - * @return bool on success - * - */ - public static function send($recipient, $subject, $body, $textonly, $mode = 0, $bounce_email = null, $idsession = null, $mailreply = null, $replyname = null , $mailfrom = null, $fromname = null, $cc = null, $bcc = null, $attachment = null, $embeded = null , $embeds = null) - { - // Get a JMail instance - $mail = self::getMailer(); - - // set component params - $conf = self::getConfig(); - - // set if we have override - if ($mailfrom && $fromname) - { - $mail->setSender(array($mailfrom, $fromname)); - } - - // load the bounce email as sender if set - if (!is_null($bounce_email)) - { - $mail->Sender = $bounce_email; - } - - // Add tag to email to identify it - if (!is_null($idsession)) - { - $mail->addCustomHeader('X-VDMmethodID:'.$idsession); - } - - // set headers if found - if (isset(self::$header) && is_array(self::$header) && count((array)self::$header) > 0) - { - foreach (self::$header as $_target => $_value) - { - $mail->addCustomHeader($_target.':'.$_value); - } - } - - // set the subject & Body - $mail->setSubject($subject); - $mail->setBody($body); - - // Are we sending the email as HTML? - if ($mode) - { - $mail->IsHTML(true); - $mail->AltBody = $textonly; - } - - //embed images - if ($embeded) - { - if(ComponentbuilderHelper::checkArray($embeds)) - { - foreach($embeds as $embed) - { - $mail->AddEmbeddedImage($embed->Path,$embed->FileName); - } - } - } - - $mail->addRecipient($recipient); - $mail->addCC($cc); - $mail->addBCC($bcc); - $mail->addAttachment($attachment); - - // Take care of reply email addresses - if (is_array($mailreply)) - { - $mail->ClearReplyTos(); - $numReplyTo = count((array)$mailreply); - for ($i=0; $i < $numReplyTo; $i++) - { - $mail->addReplyTo($mailreply[$i], $replyname[$i]); - } - } - elseif (!empty($mailreply)) - { - $mail->ClearReplyTos(); - $mail->addReplyTo($mailreply, $replyname); - } - - // check if we can add the DKIM to email - if ($conf->get('enable_dkim')) - { - if (!empty($conf->get('dkim_domain')) && !empty($conf->get('dkim_selector')) && !empty($conf->get('dkim_private')) && !empty($conf->get('dkim_public'))) - { - $mail->DKIM_domain = $conf->get('dkim_domain'); - $mail->DKIM_selector = $conf->get('dkim_selector'); - $mail->DKIM_identity = $conf->get('dkim_identity'); - $mail->DKIM_passphrase = $conf->get('dkim_passphrase'); - - $tmp = tempnam(sys_get_temp_dir(), 'VDM'); - $h = fopen($tmp, 'w'); - fwrite($h, $conf->get('dkim_private')); - fclose($h); - $mail->DKIM_private = $tmp; - } - } - - $sendmail = $mail->Send(); - - if ($conf->get('enable_dkim') && !empty($conf->get('dkim_domain')) && !empty($conf->get('dkim_selector')) && !empty($conf->get('dkim_private')) && !empty($conf->get('dkim_public'))) - { - @unlink($tmp); - } - - if (method_exists('ComponentbuilderHelper','storeMessage')) - { - // if we have active recipient details - if (isset(self::$active[$recipient])) - { - // store the massage if the method is set - ComponentbuilderHelper::storeMessage($sendmail, self::$active[$recipient], $subject, $body, $textonly, $mode, 'email'); - // clear memory - unset(self::$active[$recipient]); - } - else - { - // store the massage if the method is set - ComponentbuilderHelper::storeMessage($sendmail, $recipient, $subject, $body, $textonly, $mode, 'email'); - } - } - - return $sendmail; - } - - /** - * Set html text (in a row) and subject (as title) to a email table. - * do not use

    instead use
    - * in your html that you pass to this method - * since it is a table row it does not - * work well with paragraphs - * - * @return string on success - * - */ - public static function setBasicBody($html, $subject) - { - $body = array(); - $body[] = ""; - $body[] = ""; - $body[] = ""; - $body[] = ""; - $body[] = ""; - $body[] = "" . $subject . ""; - $body[] = ""; - $body[] = ""; - $body[] = ""; - $body[] = ""; - $body[] = $html; - $body[] = ""; - $body[] = ""; - - return implode("\n", $body); - } - - /** - * Set html text (in a row) and subject (as title) to a email table. - * do not use

    instead use
    - * in your html that you pass to this method - * since it is a table row it does not - * work well with paragraphs - * - * @return string on success - * - */ - public static function setTableBody($html, $subject) - { - $body = array(); - $body[] = ""; - $body[] = ""; - $body[] = ""; - $body[] = ""; - $body[] = ""; - $body[] = "" . $subject . ""; - $body[] = ""; - $body[] = ""; - $body[] = ""; - $body[] = ""; - $body[] = "\n"; - $body[] = ""; - $body[] = ""; - $body[] = ""; - $body[] = ""; - $body[] = "
    "; - $body[] = ""; - $body[] = ""; - $body[] = ""; - $body[] = ""; - $body[] = ""; - $body[] = "
    "; - $body[] = ""; - $body[] = ""; - $body[] = ""; - $body[] = ""; - $body[] = ""; - $body[] = "
    "; - $body[] = $html; - $body[] = "
    "; - $body[] = ""; - $body[] = "
    "; - $body[] = ""; - $body[] = "
    "; - $body[] = ""; - $body[] = ""; - $body[] = ""; - - return implode("\n", $body); - } -} diff --git a/admin/helpers/extrusion/a_mapping.php b/admin/helpers/extrusion/a_mapping.php deleted file mode 100644 index d5149def1..000000000 --- a/admin/helpers/extrusion/a_mapping.php +++ /dev/null @@ -1,420 +0,0 @@ - - @my wife Roline van der Merwe - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - - Builds Complex Joomla Components - -/-----------------------------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use VDM\Joomla\Utilities\StringHelper; -use VDM\Joomla\Utilities\JsonHelper; -use VDM\Joomla\Utilities\GetHelper; -use VDM\Joomla\Utilities\ArrayHelper; - -/** - * Mapping class - */ -class Mapping -{ - /** - * Some default fields - */ - protected $buildcompsql; - public $id; - public $name_code; - public $addadmin_views; - public $addSql = array(); - public $source = array(); - public $sql = array(); - - /** - * The map of the needed fields and views - */ - public $map; - - /** - * The app to load messages mostly - */ - public $app; - - /** - * The needed set of keys needed to set - */ - protected $setting = array('id' => 'default', 'buildcompsql' => 'base64', 'name_code' => 'safeString'); - - /** - * The needed set of keys needed to set - */ - protected $notRequiered = array('id', 'asset_id', 'published', - 'created_by', 'modified_by', 'created', 'modified', 'checked_out','checked_out_time', - 'version', 'hits', 'access', 'ordering', - 'metakey', 'metadesc', 'metadata', 'params'); - - /** - * The datatypes and it linked field types (basic) - * (TODO) We may need to set this dynamicly - */ - protected $dataTypes = array( 'VARCHAR' => 'Text', 'CHAR' => 'Text', - 'MEDIUMTEXT' => 'Textarea', 'LONGTEXT' => 'Textarea', - 'TEXT' => 'Textarea', 'DATETIME' => 'Calendar', - 'DATE' => 'Text', 'TIME' => 'Text', 'TINYINT' => 'Text', - 'BIGINT' => 'Text', 'INT' => 'Text', 'FLOAT' => 'Text', - 'DECIMAL' => 'Text', 'DOUBLE' => 'Text'); - - /** - * The datasize identifiers - */ - protected $dataSize = array( - 'CHAR', 'VARCHAR', 'INT', 'TINYINT', - 'BIGINT', 'FLOAT', 'DECIMAL', 'DOUBLE'); - - /** - * The default identifiers - */ - protected $defaults = array(0, 1, "CURRENT_TIMESTAMP", "DATETIME"); // Other - - /** - * The sizes identifiers - */ - protected $sizes = array("1", "7", "10", "11", "50", "64", "100", "255", "1024", "2048"); // Other - - - /** - * Constructor - */ - public function __construct($data = false) - { - // set the app to insure messages can be set - $this->app = JFactory::getApplication(); - // check that we have data - if (ArrayHelper::check($data)) - { - // make sure we have an id - if (isset($data['id']) && $data['id'] > 0) - { - if (isset($data['buildcomp']) && 1 == $data['buildcomp'] && isset($data['buildcompsql'])) - { - foreach ($data as $key => $value) - { - if (isset($this->setting[$key])) - { - switch($this->setting[$key]) - { - case 'base64': - // set needed value - $this->$key = base64_decode((string) $value); - break; - case 'json': - // set needed value - $this->$key = json_decode((string) $value, true); - break; - case 'safeString': - // set needed value - $this->$key = StringHelper::check($value); - break; - default : - $this->$key = $value; - break; - } - } - } - // get linked admin views - $addadmin_views = GetHelper::var('component_admin_views', $data['id'], 'joomla_component', 'addadmin_views'); - if (JsonHelper::check($addadmin_views)) - { - $this->addadmin_views = json_decode((string)$addadmin_views, true); - } - // set the map of the views needed - if ($this->setMap()) - { - return true; - } - $this->app->enqueueMessage( - JText::_('No "CREATE TABLE.." were found, please check your sql.'), - 'Error' - ); - return false; - } - return false; // not set so just return without any error - } - $this->app->enqueueMessage( - JText::_('Please try again, this error usualy happens if it is a new component, beacues we need a component ID to do this build with your sql dump.'), - 'Error' - ); - return false; - } - $this->app->enqueueMessage( - JText::_('Could not find the data needed to continue.'), - 'Error' - ); - return false; - } - - /** - * The mapping function - * To Map the views and fields that are needed - */ - protected function setMap() - { - // start parsing the sql dump data - $queries = JDatabaseDriver::splitSql($this->buildcompsql); - if (ArrayHelper::check($queries)) - { - foreach ($queries as $query) - { - // only use create table queries - if (strpos($query, 'CREATE TABLE IF NOT EXISTS') !== false || - strpos($query, 'CREATE TABLE') !== false) - { - if ($tableName = $this->getTableName($query)) - { - // now get the fields/columns of this view/table - if ($fields = $this->getFields($query)) - { - // make sure it is all lower case from here on - $tableName = strtolower($tableName); - $this->map[$tableName] = $fields; - } - } - else - { - continue; - } - } - // get the insert data if set - if (strpos($query, 'INSERT INTO `') !== false) - { - if ($tableName = $this->getTableName($query)) - { - $this->addSql[$tableName] = 1; - $this->source[$tableName] = 2; - $this->sql[$tableName] = $query; - } - } - } - // check if the mapping was done - if (ArrayHelper::check($this->map)) - { - return true; - } - } - return false; - } - - /** - * Get the table name - */ - protected function getTableName(&$query) - { - if (strpos($query, '`#__') !== false) - { - // get table name - $tableName = GetHelper::between($query, '`#__', "`"); - } - elseif (strpos($query, "'#__") !== false) - { - // get table name - $tableName = GetHelper::between($query, "'#__", "'"); - } - // if it still was not found - if (!isset($tableName) || !ComponentbuilderHelper::checkString($tableName)) - { - // skip this query - return false; - } - // clean the table name (so only view name remain) - if (strpos($tableName, $this->name_code) !== false) - { - $tableName = trim(str_replace($this->name_code, '', $tableName), '_'); - } - // if found - if (ComponentbuilderHelper::checkString($tableName)) - { - return $tableName; - } - // skip this query - return false; - } - - /** - * Get the field details - */ - protected function getFields(&$query) - { - $rows = array_map('trim', explode(PHP_EOL, $query)); - $fields = array(); - foreach ($rows as $row) - { - // make sure we have a lower case string - $row = strtoupper($row); - $field = array(); - $name = ''; - if (0 === strpos($row, '`')) - { - // get field name - $name = GetHelper::between($row, '`', '`'); - } - if (0 === strpos($row, "'")) - { - // get field name - $name = GetHelper::between($row, "'", "'"); - } - // check if the name was found - if (ComponentbuilderHelper::checkString($name)) - { - // insure we have the name in lower case from here on - $name = strtolower($name); - // only continue if field is requered - if (in_array($name, $this->notRequiered)) - { - continue; - } - // check if the field type is found - if ($fieldType = $this->getType($row, $field, $name)) - { - $field['row'] = $row; - $field['name'] = $name; - $field['label'] = StringHelper::check($name, 'W'); - $field['fieldType'] = $fieldType; - $field['size'] = $this->getSize($row, $field); - $field['sizeOther'] = ''; - if (!in_array($field['size'], $this->sizes)) - { - if (ComponentbuilderHelper::checkString($field['size'])) - { - $field['sizeOther'] = $field['size']; - $field['size'] = 'Other'; - } - } - $field['default'] = $this->getDefault($row); - $field['defaultOther'] = ''; - if (!in_array($field['default'], $this->defaults)) - { - if (ComponentbuilderHelper::checkString($field['default'])) - { - $field['defaultOther'] = $field['default']; - $field['default'] = 'Other'; - } - } - $field['null'] = $this->getNullValue($row, $field); - // check if field is a key - $field['key'] = $this->getKeyStatus($rows, $name); - // load to fields - $fields[] = $field; - } - } - } - if (ArrayHelper::check($fields)) - { - return $fields; - } - return false; - } - - /** - * Get the field types - */ - protected function getType($row, &$field, &$name) - { - // first remove field name - $row = str_replace($name, '', $row); - // get the data type first - foreach ($this->dataTypes as $type => $fieldType) - { - if (strpos($row, $type) !== false) - { - $field['dataType'] = $type; - return $fieldType; - } - } - return false; - } - - /** - * Get the field size - */ - protected function getSize(&$row, $field) - { - if (in_array($field['dataType'], $this->dataSize)) - { - return GetHelper::between($row, $field['dataType'].'(', ')'); - } - return ''; - } - - /** - * Get the field default - */ - protected function getDefault(&$row) - { - // get default value - if (strpos($row, 'DEFAULT "') !== false) // to sure it this is correct... - { - return GetHelper::between($row, 'DEFAULT "', '"'); - } - // get default value - if (strpos($row, "DEFAULT '") !== false) - { - return GetHelper::between($row, "DEFAULT '", "'"); - } - return ''; - } - - /** - * Get the field Null Value - */ - protected function getNullValue(&$row, &$field) - { - // get the result of null - if (strpos($row, 'NOT NULL') !== false) - { - return 'NOT NULL'; - } - if (strpos($row, 'DEFAULT NULL') !== false) - { - $field['default'] = 'NULL'; - return ''; - } - return 'NULL'; - } - - /** - * Get the field key status - */ - protected function getKeyStatus(&$rows, &$name) - { - // get the data type first - foreach ($rows as $row) - { - if (strpos($row, 'UNIQUE KEY ') !== false && stripos($row, $name) !== false) - { - return 1; - } - if ((strpos($row, 'PRIMARY KEY ') !== false && stripos($row, $name) !== false) || (strpos($row, 'KEY ') !== false && stripos($row, $name) !== false)) - { - return 2; - } - } - return 0; - } -} diff --git a/admin/helpers/extrusion/b_builder.php b/admin/helpers/extrusion/b_builder.php deleted file mode 100644 index 81e145cc0..000000000 --- a/admin/helpers/extrusion/b_builder.php +++ /dev/null @@ -1,294 +0,0 @@ - - @my wife Roline van der Merwe - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - - Builds Complex Joomla Components - -/-----------------------------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory; -use VDM\Joomla\Utilities\StringHelper; -use VDM\Joomla\Utilities\GetHelper; - -/** - * Builder class - */ -class Builder extends Mapping -{ - /** - * Some default fields - */ - public $user; - public $today; - public $db; - public $views = array(); - public $admin_fields = array(); - protected $fields = array(); - protected $title = array(); - protected $description = array(); - protected $alias = array(); - protected $list = array(); - - /** - * Field that should not be used in name, alias, disc, and list view - * (TODO) We may need to set this dynamicly - */ - protected $avoidList = array('not_required'); - - /*** - * Constructor - */ - public function __construct(&$data) - { - // first we run the perent constructor - if (parent::__construct($data)) - { - // always reset the building values if found - $data['buildcomp'] = 0; - $data['buildcompsql'] = ''; - // set some globals - $this->db = JFactory::getDbo(); - $this->user = JFactory::getUser(); - $this->today = JFactory::getDate()->toSql(); - - // no start the building of the views and fields - if ($this->setBuild()) - { - return true; - } - } - return false; - } - - /** - * The building function - * To build the views and fields that are needed - */ - protected function setBuild() - { - foreach ($this->map as $view => $fields) - { - // set this field with all its needed data - foreach ($fields as $field) - { - $this->setField($view, $field); - } - // set this view with all its needed data - $this->setView($view); - } - return true; - } - - /** - * The building function for views - */ - protected function setView(&$name) - { - // set the view object - $object = new stdClass(); - $object->system_name = StringHelper::check($name, 'W') . ' (dynamic build)'; - $object->name_single = $name; - $object->name_list = $name. 's'; - $object->short_description = $name. ' view (dynamic build)'; - $object->type = 1; - $object->description = $name. ' view (dynamic build)'; - $object->add_fadein = 1; - $object->add_sql = (isset($this->addSql[$name])) ? $this->addSql[$name]: 0; - $object->source = (isset($this->source[$name])) ? $this->source[$name]: 0; - $object->sql = (isset($this->sql[$name])) ? base64_encode($this->sql[$name]): ''; - $object->addpermissions = '{"action":["view.edit","view.edit.own","view.edit.state","view.create","view.delete","view.access"],"implementation":["3","3","3","3","3","3"]}'; - $object->created = $this->today; - $object->created_by = $this->user->id; - $object->published = 1; - // add to data base - if ($this->db->insertObject('#__componentbuilder_admin_view', $object)) - { - // make sure the access of asset is set - $id = $this->db->insertid(); - ComponentbuilderHelper::setAsset($id, 'admin_view'); - // load the views - $this->views[] = $id; - // load the admin view fields - return $this->addFields($name, $id); - } - return false; - } - - /** - * Add the fields to the view - */ - protected function addFields(&$view, &$view_id) - { - if (isset($this->fields[$view])) - { - // set some defaults - $addField = array (); - $fixLink = (isset($this->title[$view])) ? 0 : 1; - // build the field data... hmmm - foreach ($this->fields[$view] as $nr => $id) - { - $alignment = 1; - if ($nr % 2 == 0) - { - $alignment = 2; - } - // some defaults - $isTitle = (isset($this->title[$view]) && $this->title[$view] == $id) ? 1 : 0; - $isAlias = (isset($this->alias[$view]) && $this->alias[$view] == $id) ? 1 : 0; - $isList = ($key = array_search($id, $this->list[$view])) ? 1 : 0; - $isLink = ($isTitle) ? 1 : (($isList && $fixLink) ? 1 : 0); - if ($isLink) - { - $fixLink = 0; - } - // load the field values - $addField['addfields'.$nr]['field'] = $id; - $addField['addfields'.$nr]['list'] = $isList; - $addField['addfields'.$nr]['order_list'] = ($key) ? $key : 0; - $addField['addfields'.$nr]['title'] = $isTitle; - $addField['addfields'.$nr]['alias'] = $isAlias; - $addField['addfields'.$nr]['sort'] = $isList; - $addField['addfields'.$nr]['search'] = $isList; - $addField['addfields'.$nr]['filter'] = $isList; - $addField['addfields'.$nr]['link'] = $isLink; - $addField['addfields'.$nr]['tab'] = 1; - $addField['addfields'.$nr]['alignment'] = ($isTitle || $isAlias) ? 4 : $alignment; - $addField['addfields'.$nr]['order_edit'] = $nr; - $addField['addfields'.$nr]['permission'] = 0; - } - - // set the field object - $object = new stdClass(); - $object->admin_view = $view_id; - $object->addfields = json_encode($addField, JSON_FORCE_OBJECT); - $object->created = $this->today; - $object->created_by = $this->user->id; - $object->published = 1; - // add to data base - return $this->db->insertObject('#__componentbuilder_admin_fields', $object); - } - return false; - } - - /** - * The building function for fields - */ - protected function setField(&$view, &$field) - { - if ($fieldType = CFactory::_('Field.Type.Name')->get($field['fieldType'])) - { - // set the field object - $object = new stdClass(); - $object->name = $field['label'] . ' (dynamic build)'; - $object->fieldtype = $fieldType; - $object->datatype = $field['dataType']; - $object->indexes = $field['key']; - $object->null_switch = $field['null']; - $object->datalenght = $field['size']; - $object->datalenght_other = $field['sizeOther']; - $object->datadefault = $field['default']; - $object->datadefault_other = $field['defaultOther']; - $object->created = $this->today; - $object->created_by = $this->user->id; - $object->published = 1; - $object->store = 0; - $object->xml = $this->setFieldXML($field, $fieldType); - // add to data base - if ($this->db->insertObject('#__componentbuilder_field', $object)) - { - // make sure the access of asset is set - $id = $this->db->insertid(); - ComponentbuilderHelper::setAsset($id, 'field'); - // check if any field for this field was already set, if not set array - if (!isset($this->fields[$view])) - { - $this->fields[$view] = array(); - } - // load the field - $this->fields[$view][] = $id; - - if (!isset($this->list[$view])) - { - $this->list[$view] = array(); - } - // insure that some fields are avoided - if (!in_array($field['name'], $this->avoidList)) - { - // set the name/title field if found - if (!isset($this->title[$view]) && (stripos($field['name'], 'name') !== false || stripos($field['name'], 'title') !== false)) - { - $this->title[$view] = $id; - $this->list[$view][] = $id; - } - // set the alias field if found - elseif (!isset($this->alias[$id]) && stripos($field['name'], 'alias') !== false) - { - $this->alias[$view] = $id; - } - // set the alias field if found - elseif (!isset($this->description[$id]) && stripos($field['name'], 'desc') !== false) - { - $this->description[$view] = $id; - $this->list[$view][] = $id; - } - elseif ('Text' == $field['fieldType'] && count($this->list[$view]) < 5) - { - $this->list[$view][] = $id; - } - } - return true; - } - } - return false; - } - - /** - * get the field type id from system - */ - protected function getFieldType($fieldName) - { - // load the field settings - return GetHelper::var('fieldtype', $fieldName, 'name', 'id'); - } - - /** - * The building function for field xml - */ - protected function setFieldXML(&$field, $fieldId) - { - // load the field settings - $settings = array(); - $settings['name'] = $field['name']; - $settings['description'] = 'The '.strtolower($field['label']) . ' is set here.'; - $settings['message'] = "Error! Please add some ".strtolower($field['label'])." here."; - $settings['label'] = $field['label']; - $settings['default'] = ($field['default'] == 'Other') ? $field['defaultOther'] : $field['default']; - $settings['hint'] = $field['label'] .' Here!'; - // okay set the xml field values - if ($fieldOptions = ComponentbuilderHelper::getFieldTypeProperties($fieldId, 'id', $settings)) - { - return json_encode($fieldOptions['values']); - } - return ''; - } -} diff --git a/admin/helpers/extrusion/c_extrusion.php b/admin/helpers/extrusion/c_extrusion.php deleted file mode 100644 index 718858cbf..000000000 --- a/admin/helpers/extrusion/c_extrusion.php +++ /dev/null @@ -1,111 +0,0 @@ - - @my wife Roline van der Merwe - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - - Builds Complex Joomla Components - -/-----------------------------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use VDM\Joomla\Utilities\GetHelper; -use VDM\Joomla\Utilities\ArrayHelper; - -/** - * Extrusion class - */ -class Extrusion extends Builder -{ - /*** - * Constructor - */ - public function __construct(&$data) - { - // first we run the perent constructor - if (parent::__construct($data)) - { - // link the view data to the component - if ($this->setAdminViews($data['id'])) - { - $this->app->enqueueMessage( - JText::_('All the fields and views from your sql dump has been created and linked to this component.'), - 'Success' - ); - return true; - } - } - return false; - } - - /** - * link the build views to the component - */ - protected function setAdminViews(&$component_id) - { - // check if views were set - if (ArrayHelper::check($this->views)) - { - $count = 0; - if (ArrayHelper::check($this->addadmin_views)) - { - $count = (int) count((array)$this->addadmin_views) + 3; - } - // set the admin view data linking - foreach ($this->views as $nr => $id) - { - $pointer = $count + $nr; - $this->addadmin_views['addadmin_views'.$pointer]['adminview'] = $id; - $this->addadmin_views['addadmin_views'.$pointer]['icomoon'] = 'joomla'; - $this->addadmin_views['addadmin_views'.$pointer]['mainmenu'] = 1; - $this->addadmin_views['addadmin_views'.$pointer]['dashboard_add'] = 1; - $this->addadmin_views['addadmin_views'.$pointer]['dashboard_list'] = 1; - $this->addadmin_views['addadmin_views'.$pointer]['submenu'] = 1; - $this->addadmin_views['addadmin_views'.$pointer]['checkin'] = 1; - $this->addadmin_views['addadmin_views'.$pointer]['history'] = 1; - $this->addadmin_views['addadmin_views'.$pointer]['metadata'] = 1; - $this->addadmin_views['addadmin_views'.$pointer]['access'] = 1; - $this->addadmin_views['addadmin_views'.$pointer]['port'] = 1; - $this->addadmin_views['addadmin_views'.$pointer]['edit_create_site_view'] = 0; - $this->addadmin_views['addadmin_views'.$pointer]['order'] = $pointer + 1; - } - } - if (isset($this->addadmin_views) && ArrayHelper::check($this->addadmin_views)) - { - // set the field object - $object = new stdClass(); - $object->joomla_component = $component_id; - $object->addadmin_views = json_encode($this->addadmin_views, JSON_FORCE_OBJECT); - $object->created = $this->today; - $object->created_by = $this->user->id; - $object->published = 1; - // check if it is already set - if ($item_id = GetHelper::var('component_admin_views', $component_id, 'joomla_component', 'id')) - { - // set ID - $object->id = (int) $item_id; - return $this->db->updateObject('#__componentbuilder_component_admin_views', $object, 'id'); - } - // add to data base - return $this->db->insertObject('#__componentbuilder_component_admin_views', $object); - } - return false; - } -} diff --git a/admin/helpers/headercheck.php b/admin/helpers/headercheck.php deleted file mode 100644 index 707708464..000000000 --- a/admin/helpers/headercheck.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -class componentbuilderHeaderCheck -{ - function js_loaded($script_name) - { - // UIkit check point - if (strpos($script_name,'uikit') !== false) - { - $app = JFactory::getApplication(); - $getTemplateName = $app->getTemplate('template')->template; - - if (strpos($getTemplateName,'yoo') !== false) - { - return true; - } - } - - $document = JFactory::getDocument(); - $head_data = $document->getHeadData(); - foreach (array_keys($head_data['scripts']) as $script) - { - if (stristr($script, $script_name)) - { - return true; - } - } - - return false; - } - - function css_loaded($script_name) - { - // UIkit check point - if (strpos($script_name,'uikit') !== false) - { - $app = JFactory::getApplication(); - $getTemplateName = $app->getTemplate('template')->template; - - if (strpos($getTemplateName,'yoo') !== false) - { - return true; - } - } - - $document = JFactory::getDocument(); - $head_data = $document->getHeadData(); - - foreach (array_keys($head_data['styleSheets']) as $script) - { - if (stristr($script, $script_name)) - { - return true; - } - } - - return false; - } -} \ No newline at end of file diff --git a/admin/helpers/html/batch_.php b/admin/helpers/html/batch_.php deleted file mode 100644 index d35e20b21..000000000 --- a/admin/helpers/html/batch_.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('JPATH_PLATFORM') or die; - -/** - * Utility class to render a list view batch selection options - * - * @since 3.0 - */ -abstract class JHtmlBatch_ -{ - /** - * ListSelection - * - * @var array - * @since 3.0 - */ - protected static $ListSelection = array(); - - /** - * Render the batch selection options. - * - * @return string The necessary HTML to display the batch selection options - * - * @since 3.0 - */ - public static function render() - { - // Collect display data - $data = new stdClass; - $data->ListSelection = static::getListSelection(); - - // Create a layout object and ask it to render the batch selection options - $layout = new JLayoutFile('batchselection'); - $batchHtml = $layout->render($data); - - return $batchHtml; - } - - /** - * Method to add a list selection to the batch modal - * - * @param string $label Label for the menu item. - * @param string $name Name for the filter. Also used as id. - * @param string $options Options for the select field. - * @param bool $noDefault Don't the label as the empty option - * - * @return void - * - * @since 3.0 - */ - public static function addListSelection($label, $name, $options, $noDefault = false) - { - array_push(static::$ListSelection, array('label' => $label, 'name' => $name, 'options' => $options, 'noDefault' => $noDefault)); - } - - /** - * Returns an array of all ListSelection - * - * @return array - * - * @since 3.0 - */ - public static function getListSelection() - { - return static::$ListSelection; - } -} diff --git a/admin/helpers/indenter.php b/admin/helpers/indenter.php deleted file mode 100644 index 575896cd0..000000000 --- a/admin/helpers/indenter.php +++ /dev/null @@ -1,204 +0,0 @@ - - @github Joomla Component Builder - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - - Builds Complex Joomla Components - -/-----------------------------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * @link https://github.com/gajus/dindent for the canonical source repository - * @license https://github.com/gajus/dindent/blob/master/LICENSE BSD 3-Clause - */ -class Indenter { - private - $log = array(), - $options = array( - 'indentation_character' => ' ' - ), - $inline_elements = array('b', 'big', 'i', 'small', 'tt', 'abbr', 'acronym', 'cite', 'code', 'dfn', 'em', 'kbd', 'strong', 'samp', 'var', 'a', 'bdo', 'br', 'img', 'span', 'sub', 'sup'), - $temporary_replacements_script = array(), - $temporary_replacements_inline = array(); - - const ELEMENT_TYPE_BLOCK = 0; - const ELEMENT_TYPE_INLINE = 1; - - const MATCH_INDENT_NO = 0; - const MATCH_INDENT_DECREASE = 1; - const MATCH_INDENT_INCREASE = 2; - const MATCH_DISCARD = 3; - - /** - * @param array $options - */ - public function __construct (array $options = array()) { - foreach ($options as $name => $value) { - if (!array_key_exists($name, $this->options)) { - throw new Exception\InvalidArgumentException('Unrecognized option.'); - } - - $this->options[$name] = $value; - } - } - - /** - * @param string $element_name Element name, e.g. "b". - * @param ELEMENT_TYPE_BLOCK|ELEMENT_TYPE_INLINE $type - * @return null - */ - public function setElementType ($element_name, $type) { - if ($type === static::ELEMENT_TYPE_BLOCK) { - $this->inline_elements = array_diff($this->inline_elements, array($element_name)); - } else if ($type === static::ELEMENT_TYPE_INLINE) { - $this->inline_elements[] = $element_name; - } else { - throw new Exception\InvalidArgumentException('Unrecognized element type.'); - } - - $this->inline_elements = array_unique($this->inline_elements); - } - - /** - * @param string $input HTML input. - * @return string Indented HTML. - */ - public function indent ($input) { - $this->log = array(); - - // Dindent does not indent ', $input); - } - } - - // Removing double whitespaces to make the source code easier to read. - // With exception of

    / CSS white-space changing the default behaviour, double whitespace is meaningless in HTML output.
    -        // This reason alone is sufficient not to use Dindent in production.
    -        $input = str_replace("\t", '', $input);
    -        $input = preg_replace('/\s{2,}/', ' ', $input);
    -
    -        // Remove inline elements and replace them with text entities.
    -        if (preg_match_all('/<(' . implode('|', $this->inline_elements) . ')[^>]*>(?:[^<]*)<\/\1>/', $input, $matches)) {
    -            $this->temporary_replacements_inline = $matches[0];
    -            foreach ($matches[0] as $i => $match) {
    -                $input = str_replace($match, 'ᐃ' . ($i + 1) . 'ᐃ', $input);
    -            }
    -        }
    -
    -        $subject = $input;
    -
    -        $output = '';
    -
    -        $next_line_indentation_level = 0;
    -
    -        do {
    -            $indentation_level = $next_line_indentation_level;
    -
    -            $patterns = array(
    -                // block tag
    -                '/^(<([a-z]+)(?:[^>]*)>(?:[^<]*)<\/(?:\2)>)/' => static::MATCH_INDENT_NO,
    -                // DOCTYPE
    -                '/^]*)>/' => static::MATCH_INDENT_NO,
    -                // tag with implied closing
    -                '/^<(input|link|meta|base|br|img|hr)([^>]*)>/' => static::MATCH_INDENT_NO,
    -                // opening tag
    -                '/^<[^\/]([^>]*)>/' => static::MATCH_INDENT_INCREASE,
    -                // closing tag
    -                '/^<\/([^>]*)>/' => static::MATCH_INDENT_DECREASE,
    -                // self-closing tag
    -                '/^<(.+)\/>/' => static::MATCH_INDENT_DECREASE,
    -                // whitespace
    -                '/^(\s+)/' => static::MATCH_DISCARD,
    -                // text node
    -                '/([^<]+)/' => static::MATCH_INDENT_NO
    -            );
    -            $rules = array('NO', 'DECREASE', 'INCREASE', 'DISCARD');
    -
    -            foreach ($patterns as $pattern => $rule) {
    -                if ($match = preg_match($pattern, $subject, $matches)) {
    -                    $this->log[] = array(
    -                        'rule' => $rules[$rule],
    -                        'pattern' => $pattern,
    -                        'subject' => $subject,
    -                        'match' => $matches[0]
    -                    );
    -
    -                    $subject = mb_substr($subject, mb_strlen($matches[0]));
    -
    -                    if ($rule === static::MATCH_DISCARD) {
    -                        break;
    -                    }
    -
    -                    if ($rule === static::MATCH_INDENT_NO) {
    -
    -                    } else if ($rule === static::MATCH_INDENT_DECREASE) {
    -                        $next_line_indentation_level--;
    -                        $indentation_level--;
    -                    } else {
    -                        $next_line_indentation_level++;
    -                    }
    -
    -                    if ($indentation_level < 0) {
    -                        $indentation_level = 0;
    -                    }
    -
    -                    $output .= str_repeat($this->options['indentation_character'], $indentation_level) . $matches[0] . "\n";
    -
    -                    break;
    -                }
    -            }
    -        } while ($match);
    -
    -        $interpreted_input = '';
    -        foreach ($this->log as $e) {
    -            $interpreted_input .= $e['match'];
    -        }
    -
    -        if ($interpreted_input !== $input) {
    -            throw new Exception\RuntimeException('Did not reproduce the exact input.');
    -        }
    -
    -        $output = preg_replace('/(<(\w+)[^>]*>)\s*(<\/\2>)/', '\\1\\3', $output);
    -
    -        foreach ($this->temporary_replacements_script as $i => $original) {
    -            $output = str_replace('', $original, $output);
    -        }
    -
    -        foreach ($this->temporary_replacements_inline as $i => $original) {
    -            $output = str_replace('ᐃ' . ($i + 1) . 'ᐃ', $original, $output);
    -        }
    -
    -        return trim($output);
    -    }
    -
    -    /**
    -     * Debugging utility. Get log for the last indent operation.
    -     *
    -     * @return array
    -     */
    -    public function getLog () {
    -        return $this->log;
    -    }
    -}
    diff --git a/admin/language/en-GB/en-GB.com_componentbuilder.ini b/admin/language/en-GB/en-GB.com_componentbuilder.ini
    index 64e38e12e..99ba588e7 100644
    --- a/admin/language/en-GB/en-GB.com_componentbuilder.ini
    +++ b/admin/language/en-GB/en-GB.com_componentbuilder.ini
    @@ -42,6 +42,9 @@ COM_COMPONENTBUILDER_ADMINS_CUSTOM_TABS_EDIT_STATE="Admins Custom Tabs Edit Stat
     COM_COMPONENTBUILDER_ADMINS_CUSTOM_TABS_EDIT_STATE_DESC="Allows the users in this group to update the state of the admin custom tabs"
     COM_COMPONENTBUILDER_ADMINS_CUSTOM_TABS_EDIT_VERSION="Admins Custom Tabs Edit Version"
     COM_COMPONENTBUILDER_ADMINS_CUSTOM_TABS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version admins custom tabs"
    +COM_COMPONENTBUILDER_ADMINS_CUSTOM_TABS_EMPTYSTATE_BUTTON_ADD="Add your first admin custom tabs"
    +COM_COMPONENTBUILDER_ADMINS_CUSTOM_TABS_EMPTYSTATE_CONTENT=""
    +COM_COMPONENTBUILDER_ADMINS_CUSTOM_TABS_EMPTYSTATE_TITLE="No admins custom tabs have been created yet."
     COM_COMPONENTBUILDER_ADMINS_CUSTOM_TABS_N_ITEMS_ARCHIVED="%s Admins Custom Tabs archived."
     COM_COMPONENTBUILDER_ADMINS_CUSTOM_TABS_N_ITEMS_ARCHIVED_1="%s Admin Custom Tabs archived."
     COM_COMPONENTBUILDER_ADMINS_CUSTOM_TABS_N_ITEMS_CHECKED_IN_0="No Admin Custom Tabs successfully checked in."
    @@ -91,6 +94,9 @@ COM_COMPONENTBUILDER_ADMINS_FIELDS_CONDITIONS_EDIT_STATE="Admins Fields Conditio
     COM_COMPONENTBUILDER_ADMINS_FIELDS_CONDITIONS_EDIT_STATE_DESC="Allows the users in this group to update the state of the admin fields conditions"
     COM_COMPONENTBUILDER_ADMINS_FIELDS_CONDITIONS_EDIT_VERSION="Admins Fields Conditions Edit Version"
     COM_COMPONENTBUILDER_ADMINS_FIELDS_CONDITIONS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version admins fields conditions"
    +COM_COMPONENTBUILDER_ADMINS_FIELDS_CONDITIONS_EMPTYSTATE_BUTTON_ADD="Add your first admin fields conditions"
    +COM_COMPONENTBUILDER_ADMINS_FIELDS_CONDITIONS_EMPTYSTATE_CONTENT=""
    +COM_COMPONENTBUILDER_ADMINS_FIELDS_CONDITIONS_EMPTYSTATE_TITLE="No admins fields conditions have been created yet."
     COM_COMPONENTBUILDER_ADMINS_FIELDS_CONDITIONS_N_ITEMS_ARCHIVED="%s Admins Fields Conditions archived."
     COM_COMPONENTBUILDER_ADMINS_FIELDS_CONDITIONS_N_ITEMS_ARCHIVED_1="%s Admin Fields Conditions archived."
     COM_COMPONENTBUILDER_ADMINS_FIELDS_CONDITIONS_N_ITEMS_CHECKED_IN_0="No Admin Fields Conditions successfully checked in."
    @@ -126,6 +132,9 @@ COM_COMPONENTBUILDER_ADMINS_FIELDS_EDIT_STATE="Admins Fields Edit State"
     COM_COMPONENTBUILDER_ADMINS_FIELDS_EDIT_STATE_DESC="Allows the users in this group to update the state of the admin fields"
     COM_COMPONENTBUILDER_ADMINS_FIELDS_EDIT_VERSION="Admins Fields Edit Version"
     COM_COMPONENTBUILDER_ADMINS_FIELDS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version admins fields"
    +COM_COMPONENTBUILDER_ADMINS_FIELDS_EMPTYSTATE_BUTTON_ADD="Add your first admin fields"
    +COM_COMPONENTBUILDER_ADMINS_FIELDS_EMPTYSTATE_CONTENT=""
    +COM_COMPONENTBUILDER_ADMINS_FIELDS_EMPTYSTATE_TITLE="No admins fields have been created yet."
     COM_COMPONENTBUILDER_ADMINS_FIELDS_N_ITEMS_ARCHIVED="%s Admins Fields archived."
     COM_COMPONENTBUILDER_ADMINS_FIELDS_N_ITEMS_ARCHIVED_1="%s Admin Fields archived."
     COM_COMPONENTBUILDER_ADMINS_FIELDS_N_ITEMS_CHECKED_IN_0="No Admin Fields successfully checked in."
    @@ -168,6 +177,9 @@ COM_COMPONENTBUILDER_ADMINS_FIELDS_RELATIONS_EDIT_STATE="Admins Fields Relations
     COM_COMPONENTBUILDER_ADMINS_FIELDS_RELATIONS_EDIT_STATE_DESC="Allows the users in this group to update the state of the admin fields relations"
     COM_COMPONENTBUILDER_ADMINS_FIELDS_RELATIONS_EDIT_VERSION="Admins Fields Relations Edit Version"
     COM_COMPONENTBUILDER_ADMINS_FIELDS_RELATIONS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version admins fields relations"
    +COM_COMPONENTBUILDER_ADMINS_FIELDS_RELATIONS_EMPTYSTATE_BUTTON_ADD="Add your first admin fields relations"
    +COM_COMPONENTBUILDER_ADMINS_FIELDS_RELATIONS_EMPTYSTATE_CONTENT=""
    +COM_COMPONENTBUILDER_ADMINS_FIELDS_RELATIONS_EMPTYSTATE_TITLE="No admins fields relations have been created yet."
     COM_COMPONENTBUILDER_ADMINS_FIELDS_RELATIONS_N_ITEMS_ARCHIVED="%s Admins Fields Relations archived."
     COM_COMPONENTBUILDER_ADMINS_FIELDS_RELATIONS_N_ITEMS_ARCHIVED_1="%s Admin Fields Relations archived."
     COM_COMPONENTBUILDER_ADMINS_FIELDS_RELATIONS_N_ITEMS_CHECKED_IN_0="No Admin Fields Relations successfully checked in."
    @@ -199,6 +211,7 @@ COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_CREATED_DATE_DESC="The date this Admin Cu
     COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_CREATED_DATE_LABEL="Created Date"
     COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_EDIT="Editing the Admin Custom Tabs"
     COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_ERROR_UNIQUE_ALIAS="Another Admin Custom Tabs has the same alias."
    +COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Admin Custom Tabs has the same alias ."
     COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_HTML_HINT="// Add the tab HTML here. To access php values methodname->value; ?>"
     COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_HTML_LABEL="HTML"
     COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_ID="Id"
    @@ -254,6 +267,7 @@ COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_CREATED_DATE_DESC="The date this Ad
     COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_CREATED_DATE_LABEL="Created Date"
     COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_EDIT="Editing the Admin Fields Conditions"
     COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_ERROR_UNIQUE_ALIAS="Another Admin Fields Conditions has the same alias."
    +COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Admin Fields Conditions has the same alias ."
     COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_EXACT_LENGTH_ONLY_4_TEXT_FIELD="Exact Length (only 4 text_field)"
     COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_HIDE_ONLY="Hide Only"
     COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_HIDE_TOGGLE="Hide Toggle"
    @@ -306,6 +320,7 @@ COM_COMPONENTBUILDER_ADMIN_FIELDS_DEFAULT="Default"
     COM_COMPONENTBUILDER_ADMIN_FIELDS_EDIT="Editing the Admin Fields"
     COM_COMPONENTBUILDER_ADMIN_FIELDS_EDITING="Editing"
     COM_COMPONENTBUILDER_ADMIN_FIELDS_ERROR_UNIQUE_ALIAS="Another Admin Fields has the same alias."
    +COM_COMPONENTBUILDER_ADMIN_FIELDS_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Admin Fields has the same alias ."
     COM_COMPONENTBUILDER_ADMIN_FIELDS_FIELD="Field"
     COM_COMPONENTBUILDER_ADMIN_FIELDS_FIELDS="Fields"
     COM_COMPONENTBUILDER_ADMIN_FIELDS_FIELD_DESCRIPTION="Select a field"
    @@ -357,6 +372,7 @@ COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_CREATED_DATE_LABEL="Created Date"
     COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_CUSTOM_RAQUO_CODE="Custom » Code"
     COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_EDIT="Editing the Admin Fields Relations"
     COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_ERROR_UNIQUE_ALIAS="Another Admin Fields Relations has the same alias."
    +COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Admin Fields Relations has the same alias ."
     COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_ID="Id"
     COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_JOINFIELDS="Joinfields"
     COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_JOINFIELDS_DESCRIPTION="Select the target join fields."
    @@ -433,6 +449,9 @@ COM_COMPONENTBUILDER_ADMIN_VIEWS_EDIT_STATE="Admin Views Edit State"
     COM_COMPONENTBUILDER_ADMIN_VIEWS_EDIT_STATE_DESC="Allows the users in this group to update the state of the admin view"
     COM_COMPONENTBUILDER_ADMIN_VIEWS_EDIT_VERSION="Admin Views Edit Version"
     COM_COMPONENTBUILDER_ADMIN_VIEWS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version admin views"
    +COM_COMPONENTBUILDER_ADMIN_VIEWS_EMPTYSTATE_BUTTON_ADD="Add your first admin view"
    +COM_COMPONENTBUILDER_ADMIN_VIEWS_EMPTYSTATE_CONTENT=""
    +COM_COMPONENTBUILDER_ADMIN_VIEWS_EMPTYSTATE_TITLE="No admin views have been created yet."
     COM_COMPONENTBUILDER_ADMIN_VIEWS_EXPORT="Admin Views Export"
     COM_COMPONENTBUILDER_ADMIN_VIEWS_EXPORT_DESC="Allows the users in this group to export export admin views"
     COM_COMPONENTBUILDER_ADMIN_VIEWS_IMPORT="Admin Views Import"
    @@ -667,6 +686,7 @@ COM_COMPONENTBUILDER_ADMIN_VIEW_ENVELOPE="Envelope"
     COM_COMPONENTBUILDER_ADMIN_VIEW_ENVELOPE_OPENED="Envelope Opened"
     COM_COMPONENTBUILDER_ADMIN_VIEW_EQUALIZER="Equalizer"
     COM_COMPONENTBUILDER_ADMIN_VIEW_ERROR_UNIQUE_ALIAS="Another Admin View has the same alias."
    +COM_COMPONENTBUILDER_ADMIN_VIEW_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Admin View has the same alias ."
     COM_COMPONENTBUILDER_ADMIN_VIEW_EUCJPMS_BIN_CHARSET_EUCJPMS="eucjpms_bin (charset = eucjpms)"
     COM_COMPONENTBUILDER_ADMIN_VIEW_EUCJPMS_JAPANESE_CI_CHARSET_EUCJPMS="eucjpms_japanese_ci (charset = eucjpms)"
     COM_COMPONENTBUILDER_ADMIN_VIEW_EUCJPMS_UJIS_FOR_WINDOWS_JAPANESE_MOST_SUITABLE_COLLATION_EUCJPMS_JAPANESE_CI="eucjpms - UJIS for Windows Japanese (most suitable collation = eucjpms_japanese_ci)"
    @@ -1043,9 +1063,10 @@ COM_COMPONENTBUILDER_ADMIN_VIEW_SMILEY_NEUTRAL="Smiley Neutral"
     COM_COMPONENTBUILDER_ADMIN_VIEW_SMILEY_NEUTRAL_2="Smiley Neutral 2"
     COM_COMPONENTBUILDER_ADMIN_VIEW_SMILEY_SAD="Smiley Sad"
     COM_COMPONENTBUILDER_ADMIN_VIEW_SMILEY_SAD_2="Smiley Sad 2"
    -COM_COMPONENTBUILDER_ADMIN_VIEW_SOURCEMAP_DESCRIPTION="Map the Source to this view's fields.
    // First Table Map.
    SourceField => viewField
    // Other Tables Map.
    firstTableKeySourceField == keySourceField
    SourceField => viewField" +COM_COMPONENTBUILDER_ADMIN_VIEW_SOURCEMAP_DESCRIPTION="Map the Source to this view's fields.
    // First Table Map.
    SourceField => viewField
    // Other Tables Map.
    firstTableKeySourceField == keySourceField
    SourceField => viewField
    // Remember to add all fields that has no default value, and is not null." COM_COMPONENTBUILDER_ADMIN_VIEW_SOURCEMAP_HINT="SourceField => viewField" COM_COMPONENTBUILDER_ADMIN_VIEW_SOURCEMAP_LABEL="Source Map" +COM_COMPONENTBUILDER_ADMIN_VIEW_SOURCEMAP_MESSAGE="Please review the Source Map selection, as it appears that certain mandatory fields have been excluded from the (MySQL -> Tables -> Source Map) selection. These specific fields are designated as 'not null' and lack default values. This oversight may lead to errors when installing your component on Joomla 5 and above. To address this issue, you are presented with a few options:

    1. Assign a default value to the field. This can be done within the specific field settings under the Database Tab.
    2. Modify the field's Null Switch to 'NULL'. This adjustment also takes place in the field settings.3. Alternatively, you could add these fields into the MySQL -> Tables -> Source Map selection. This inclusion ensures that all necessary data parameters are correctly mapped in the MySQL (dump) and available during the Joomla component installation process.

    By taking one of these actions, you will prevent potential installation errors and ensure compatibility with the requirements of Joomla 5 and above." COM_COMPONENTBUILDER_ADMIN_VIEW_SOURCE_LABEL="Select MySql Source" COM_COMPONENTBUILDER_ADMIN_VIEW_SQL_DESCRIPTION="Add your MySQL here!" COM_COMPONENTBUILDER_ADMIN_VIEW_SQL_HINT="// Add MySQL Table Dump Here" @@ -1283,9 +1304,10 @@ COM_COMPONENTBUILDER_ALIGNMENT="Alignment" COM_COMPONENTBUILDER_ALL="All" COM_COMPONENTBUILDER_ALLOWS_YOU_TO_OVERRIDE_THE_BUILD_DATE_BY_SELECTING_A_DATE_MANUALLY_FROM_THE_CALENDER="Allows you to override the build date by selecting a date manually from the calender." COM_COMPONENTBUILDER_ALL_FOUND_INSTANCES_IN_S_WHERE_REPLACED="All found instances in %s where replaced" -COM_COMPONENTBUILDER_ALL_IS_GOOD_PLEASE_CHECK_AGAIN_LATTER="All is good, please check again latter." +COM_COMPONENTBUILDER_ALL_IS_GOOD_PLEASE_CHECK_AGAIN_LATER="All is good, please check again later" COM_COMPONENTBUILDER_ALL_IS_GOOD_THERE_IS_NO_NOTICE_AT_THIS_TIME="All is good, there is no notice at this time." COM_COMPONENTBUILDER_ALL_OF_THESE_PACKAGES_ARE_A_FULLY_DEVELOPEDMAPPED_COMPONENTS_FOR_JCB_THEY_CAN_BE_SEEN_AS_DEMO_CONTENT_OR_BASE_IMAGES_FROM_WHICH_TO_START_YOUR_PROJECTBR_ALWAYS_MAKE_SURE_YOU_ARE_ON_THE_LATEST_VERSION_OF_JCB_BEFORE_IMPORTING_ANY_OF_THESE_PACKAGES_SHOULD_ANY_OF_THEM_FAIL_TO_IMPORT_A_S_PLEASE_LET_US_KNOWA="All of these packages are a fully developed/mapped components for JCB. They can be seen as demo content, or base images from which to start your project.
    Always make sure you are on the latest version of JCB before importing any of these packages, should any of them fail to import please let us know." +COM_COMPONENTBUILDER_ALL_THE_FIELDS_AND_VIEWS_FROM_YOUR_SQL_DUMP_HAS_BEEN_CREATED_AND_LINKED_TO_THIS_COMPONENT="All the fields and views from your sql dump has been created and linked to this component." COM_COMPONENTBUILDER_ALL_THE_LANGUAGES_FOUND_IN_JOOMLA_WERE_SUCCESSFULLY_IMPORTED="All the languages found in Joomla were successfully imported." COM_COMPONENTBUILDER_ALL_UNSAVED_WORK_ON_THIS_PAGE_WILL_BE_LOST_ARE_YOU_SURE_YOU_WANT_TO_CONTINUE="All unsaved work on this page will be lost, are you sure you want to continue?" COM_COMPONENTBUILDER_ALREADY_SELECTED_TRY_ANOTHER="Already selected, try another." @@ -1310,7 +1332,7 @@ COM_COMPONENTBUILDER_AUTHOR_NAME="Author Name" COM_COMPONENTBUILDER_AUTHOR_WEBSITE="Author Website" COM_COMPONENTBUILDER_AUTO_CHECKIN="Auto Check-in" COM_COMPONENTBUILDER_AVAILABLE_LIBRARIES="Available Libraries" -COM_COMPONENTBUILDER_A_METHOD_SETDYNAMICFZEROLDTHREERS_WAS_ADDED_TO_THE_INSTALL_BSCRIPTPHPB_OF_THIS_PACKAGE_TO_INSURE_THAT_THE_FOLDERS_ARE_COPIED_INTO_THE_CORRECT_PLACE_WHEN_THIS_COMPONENT_IS_INSTALLED="A method (setDynamicF0ld3rs) was added to the install script.php of this package to insure that the folder(s) are copied into the correct place when this component is installed!" +COM_COMPONENTBUILDER_A_METHOD_S_WAS_ADDED_TO_THE_INSTALL_BSB_OF_THIS_PACKAGE_TO_INSURE_THAT_THE_FOLDERS_ARE_COPIED_INTO_THE_CORRECT_PLACE_WHEN_THIS_COMPONENT_IS_INSTALLED="A method (%s) was added to the install %s of this package to insure that the folder(s) are copied into the correct place when this component is installed!" COM_COMPONENTBUILDER_A_S_SPAN_CLASSICONFLAG_SPANREPORT_BROKEN_PACKAGEA=" Report Broken Package" COM_COMPONENTBUILDER_BACK="Back" COM_COMPONENTBUILDER_BACKUP="Backup" @@ -1328,7 +1350,6 @@ COM_COMPONENTBUILDER_BECOME_A_CONTRIBUTOR="Become a Contributor" COM_COMPONENTBUILDER_BEHAVIOUR="Behaviour" COM_COMPONENTBUILDER_BEHIND="Behind" COM_COMPONENTBUILDER_BEHIND_MEANS_YOUR_BLOCAL_SNIPPETB_WITH_THE_SAME_NAME_LIBRARY_AND_TYPE_HAS_A_BOLDER_MODIFIED_DATEB_THEN_THE_COMMUNITY_SNIPPET_WITH_THE_SAME_NAME_LIBRARY_AND_TYPE="Behind means your local snippet (with the same name, library and type) has a older modified date then the community snippet (with the same name, library and type)." -COM_COMPONENTBUILDER_BETA_RELEASE="Beta Release" COM_COMPONENTBUILDER_BE_A_PART_OF_JCB="Be a Part of JCB" COM_COMPONENTBUILDER_BE_CAUTIOUS_DO_NOT_CONTINUE_UNLESS_YOU_TRUST_THE_ORIGIN_OF_THIS_PACKAGE="Be cautious! Do not continue unless you trust the origin of this package!" COM_COMPONENTBUILDER_BFIELD_TYPEB_IDS_MISMATCH_IN_BSB="Field type id:%s mismatch in %s." @@ -1382,6 +1403,9 @@ COM_COMPONENTBUILDER_CLASS_EXTENDINGS_EDIT_STATE="Class Extendings Edit State" COM_COMPONENTBUILDER_CLASS_EXTENDINGS_EDIT_STATE_DESC="Allows the users in this group to update the state of the class extends" COM_COMPONENTBUILDER_CLASS_EXTENDINGS_EDIT_VERSION="Class Extendings Edit Version" COM_COMPONENTBUILDER_CLASS_EXTENDINGS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version class extendings" +COM_COMPONENTBUILDER_CLASS_EXTENDINGS_EMPTYSTATE_BUTTON_ADD="Add your first class extends" +COM_COMPONENTBUILDER_CLASS_EXTENDINGS_EMPTYSTATE_CONTENT="The classes being extended" +COM_COMPONENTBUILDER_CLASS_EXTENDINGS_EMPTYSTATE_TITLE="No class extendings have been created yet." COM_COMPONENTBUILDER_CLASS_EXTENDINGS_N_ITEMS_ARCHIVED="%s Class Extendings archived." COM_COMPONENTBUILDER_CLASS_EXTENDINGS_N_ITEMS_ARCHIVED_1="%s Class Extends archived." COM_COMPONENTBUILDER_CLASS_EXTENDINGS_N_ITEMS_CHECKED_IN_0="No Class Extends successfully checked in." @@ -1413,6 +1437,7 @@ COM_COMPONENTBUILDER_CLASS_EXTENDS_CREATED_DATE_LABEL="Created Date" COM_COMPONENTBUILDER_CLASS_EXTENDS_DETAILS="Details" COM_COMPONENTBUILDER_CLASS_EXTENDS_EDIT="Editing the Class Extends" COM_COMPONENTBUILDER_CLASS_EXTENDS_ERROR_UNIQUE_ALIAS="Another Class Extends has the same alias." +COM_COMPONENTBUILDER_CLASS_EXTENDS_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Class Extends has the same alias ." COM_COMPONENTBUILDER_CLASS_EXTENDS_EXTENSION_TYPE_DESCRIPTION="The type this class_extends belongs to." COM_COMPONENTBUILDER_CLASS_EXTENDS_EXTENSION_TYPE_LABEL="Type" COM_COMPONENTBUILDER_CLASS_EXTENDS_HEAD_DESCRIPTION="The class header to add any header values can be added." @@ -1462,6 +1487,9 @@ COM_COMPONENTBUILDER_CLASS_METHODS_EDIT_STATE="Class Methods Edit State" COM_COMPONENTBUILDER_CLASS_METHODS_EDIT_STATE_DESC="Allows the users in this group to update the state of the class method" COM_COMPONENTBUILDER_CLASS_METHODS_EDIT_VERSION="Class Methods Edit Version" COM_COMPONENTBUILDER_CLASS_METHODS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version class methods" +COM_COMPONENTBUILDER_CLASS_METHODS_EMPTYSTATE_BUTTON_ADD="Add your first class method" +COM_COMPONENTBUILDER_CLASS_METHODS_EMPTYSTATE_CONTENT="Class Methods" +COM_COMPONENTBUILDER_CLASS_METHODS_EMPTYSTATE_TITLE="No class methods have been created yet." COM_COMPONENTBUILDER_CLASS_METHODS_EXPORT="Class Methods Export" COM_COMPONENTBUILDER_CLASS_METHODS_EXPORT_DESC="Allows the users in this group to export export class methods" COM_COMPONENTBUILDER_CLASS_METHODS_IMPORT="Class Methods Import" @@ -1501,6 +1529,7 @@ COM_COMPONENTBUILDER_CLASS_METHOD_CREATED_DATE_LABEL="Created Date" COM_COMPONENTBUILDER_CLASS_METHOD_DETAILS="Details" COM_COMPONENTBUILDER_CLASS_METHOD_EDIT="Editing the Class Method" COM_COMPONENTBUILDER_CLASS_METHOD_ERROR_UNIQUE_ALIAS="Another Class Method has the same alias." +COM_COMPONENTBUILDER_CLASS_METHOD_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Class Method has the same alias ." COM_COMPONENTBUILDER_CLASS_METHOD_EXTENSION_TYPE_DESCRIPTION="The type this class_method belongs to." COM_COMPONENTBUILDER_CLASS_METHOD_EXTENSION_TYPE_LABEL="Type" COM_COMPONENTBUILDER_CLASS_METHOD_GUID_DESCRIPTION="Globally Unique Identifier" @@ -1559,6 +1588,9 @@ COM_COMPONENTBUILDER_CLASS_PROPERTIES_EDIT_STATE="Class Properties Edit State" COM_COMPONENTBUILDER_CLASS_PROPERTIES_EDIT_STATE_DESC="Allows the users in this group to update the state of the class property" COM_COMPONENTBUILDER_CLASS_PROPERTIES_EDIT_VERSION="Class Properties Edit Version" COM_COMPONENTBUILDER_CLASS_PROPERTIES_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version class properties" +COM_COMPONENTBUILDER_CLASS_PROPERTIES_EMPTYSTATE_BUTTON_ADD="Add your first class property" +COM_COMPONENTBUILDER_CLASS_PROPERTIES_EMPTYSTATE_CONTENT="Class Properties" +COM_COMPONENTBUILDER_CLASS_PROPERTIES_EMPTYSTATE_TITLE="No class properties have been created yet." COM_COMPONENTBUILDER_CLASS_PROPERTIES_EXPORT="Class Properties Export" COM_COMPONENTBUILDER_CLASS_PROPERTIES_EXPORT_DESC="Allows the users in this group to export export class properties" COM_COMPONENTBUILDER_CLASS_PROPERTIES_IMPORT="Class Properties Import" @@ -1598,6 +1630,7 @@ COM_COMPONENTBUILDER_CLASS_PROPERTY_DEFAULT_MESSAGE="Error! Please add default v COM_COMPONENTBUILDER_CLASS_PROPERTY_DETAILS="Details" COM_COMPONENTBUILDER_CLASS_PROPERTY_EDIT="Editing the Class Property" COM_COMPONENTBUILDER_CLASS_PROPERTY_ERROR_UNIQUE_ALIAS="Another Class Property has the same alias." +COM_COMPONENTBUILDER_CLASS_PROPERTY_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Class Property has the same alias ." COM_COMPONENTBUILDER_CLASS_PROPERTY_EXTENSION_TYPE_DESCRIPTION="The type this class_property belongs to." COM_COMPONENTBUILDER_CLASS_PROPERTY_EXTENSION_TYPE_LABEL="Type" COM_COMPONENTBUILDER_CLASS_PROPERTY_GUID_DESCRIPTION="Globally Unique Identifier" @@ -1639,6 +1672,7 @@ COM_COMPONENTBUILDER_CLONE="Clone" COM_COMPONENTBUILDER_CLONE_FAILED="Clone failed!" COM_COMPONENTBUILDER_CLOSE_NEW="Close & New" COM_COMPONENTBUILDER_CODE="Code" +COM_COMPONENTBUILDER_CODESTRINGS="code/strings" COM_COMPONENTBUILDER_COMMUNITY_PACKAGES="Community Packages" COM_COMPONENTBUILDER_COMPANY="Company" COM_COMPONENTBUILDER_COMPANY_NAME="Company Name" @@ -1686,6 +1720,9 @@ COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS_EDIT_STATE="Components Admin Views E COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS_EDIT_STATE_DESC="Allows the users in this group to update the state of the component admin views" COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS_EDIT_VERSION="Components Admin Views Edit Version" COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version components admin views" +COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS_EMPTYSTATE_BUTTON_ADD="Add your first component admin views" +COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS_EMPTYSTATE_TITLE="No components admin views have been created yet." COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS_N_ITEMS_ARCHIVED="%s Components Admin Views archived." COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS_N_ITEMS_ARCHIVED_1="%s Component Admin Views archived." COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS_N_ITEMS_CHECKED_IN_0="No Component Admin Views successfully checked in." @@ -1729,6 +1766,9 @@ COM_COMPONENTBUILDER_COMPONENTS_CONFIG_EDIT_STATE="Components Config Edit State" COM_COMPONENTBUILDER_COMPONENTS_CONFIG_EDIT_STATE_DESC="Allows the users in this group to update the state of the component config" COM_COMPONENTBUILDER_COMPONENTS_CONFIG_EDIT_VERSION="Components Config Edit Version" COM_COMPONENTBUILDER_COMPONENTS_CONFIG_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version components config" +COM_COMPONENTBUILDER_COMPONENTS_CONFIG_EMPTYSTATE_BUTTON_ADD="Add your first component config" +COM_COMPONENTBUILDER_COMPONENTS_CONFIG_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_COMPONENTS_CONFIG_EMPTYSTATE_TITLE="No components config have been created yet." COM_COMPONENTBUILDER_COMPONENTS_CONFIG_N_ITEMS_ARCHIVED="%s Components Config archived." COM_COMPONENTBUILDER_COMPONENTS_CONFIG_N_ITEMS_ARCHIVED_1="%s Component Config archived." COM_COMPONENTBUILDER_COMPONENTS_CONFIG_N_ITEMS_CHECKED_IN_0="No Component Config successfully checked in." @@ -1771,6 +1811,9 @@ COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_MENUS_EDIT_STATE="Components Custom COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_MENUS_EDIT_STATE_DESC="Allows the users in this group to update the state of the component custom admin menus" COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_MENUS_EDIT_VERSION="Components Custom Admin Menus Edit Version" COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_MENUS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version components custom admin menus" +COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_MENUS_EMPTYSTATE_BUTTON_ADD="Add your first component custom admin menus" +COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_MENUS_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_MENUS_EMPTYSTATE_TITLE="No components custom admin menus have been created yet." COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_MENUS_N_ITEMS_ARCHIVED="%s Components Custom Admin Menus archived." COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_MENUS_N_ITEMS_ARCHIVED_1="%s Component Custom Admin Menus archived." COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_MENUS_N_ITEMS_CHECKED_IN_0="No Component Custom Admin Menus successfully checked in." @@ -1813,6 +1856,9 @@ COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_VIEWS_EDIT_STATE="Components Custom COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_VIEWS_EDIT_STATE_DESC="Allows the users in this group to update the state of the component custom admin views" COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_VIEWS_EDIT_VERSION="Components Custom Admin Views Edit Version" COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_VIEWS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version components custom admin views" +COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_VIEWS_EMPTYSTATE_BUTTON_ADD="Add your first component custom admin views" +COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_VIEWS_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_VIEWS_EMPTYSTATE_TITLE="No components custom admin views have been created yet." COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_VIEWS_N_ITEMS_ARCHIVED="%s Components Custom Admin Views archived." COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_VIEWS_N_ITEMS_ARCHIVED_1="%s Component Custom Admin Views archived." COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_VIEWS_N_ITEMS_CHECKED_IN_0="No Component Custom Admin Views successfully checked in." @@ -1855,6 +1901,9 @@ COM_COMPONENTBUILDER_COMPONENTS_DASHBOARD_EDIT_STATE="Components Dashboard Edit COM_COMPONENTBUILDER_COMPONENTS_DASHBOARD_EDIT_STATE_DESC="Allows the users in this group to update the state of the component dashboard" COM_COMPONENTBUILDER_COMPONENTS_DASHBOARD_EDIT_VERSION="Components Dashboard Edit Version" COM_COMPONENTBUILDER_COMPONENTS_DASHBOARD_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version components dashboard" +COM_COMPONENTBUILDER_COMPONENTS_DASHBOARD_EMPTYSTATE_BUTTON_ADD="Add your first component dashboard" +COM_COMPONENTBUILDER_COMPONENTS_DASHBOARD_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_COMPONENTS_DASHBOARD_EMPTYSTATE_TITLE="No components dashboard have been created yet." COM_COMPONENTBUILDER_COMPONENTS_DASHBOARD_N_ITEMS_ARCHIVED="%s Components Dashboard archived." COM_COMPONENTBUILDER_COMPONENTS_DASHBOARD_N_ITEMS_ARCHIVED_1="%s Component Dashboard archived." COM_COMPONENTBUILDER_COMPONENTS_DASHBOARD_N_ITEMS_CHECKED_IN_0="No Component Dashboard successfully checked in." @@ -1897,6 +1946,9 @@ COM_COMPONENTBUILDER_COMPONENTS_FILES_FOLDERS_EDIT_STATE="Components Files Fold COM_COMPONENTBUILDER_COMPONENTS_FILES_FOLDERS_EDIT_STATE_DESC="Allows the users in this group to update the state of the component files folders" COM_COMPONENTBUILDER_COMPONENTS_FILES_FOLDERS_EDIT_VERSION="Components Files Folders Edit Version" COM_COMPONENTBUILDER_COMPONENTS_FILES_FOLDERS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version components files folders" +COM_COMPONENTBUILDER_COMPONENTS_FILES_FOLDERS_EMPTYSTATE_BUTTON_ADD="Add your first component files & folders" +COM_COMPONENTBUILDER_COMPONENTS_FILES_FOLDERS_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_COMPONENTS_FILES_FOLDERS_EMPTYSTATE_TITLE="No components files & folders have been created yet." COM_COMPONENTBUILDER_COMPONENTS_FILES_FOLDERS_N_ITEMS_ARCHIVED="%s Components Files & Folders archived." COM_COMPONENTBUILDER_COMPONENTS_FILES_FOLDERS_N_ITEMS_ARCHIVED_1="%s Component Files & Folders archived." COM_COMPONENTBUILDER_COMPONENTS_FILES_FOLDERS_N_ITEMS_CHECKED_IN_0="No Component Files & Folders successfully checked in." @@ -1939,6 +1991,9 @@ COM_COMPONENTBUILDER_COMPONENTS_MODULES_EDIT_STATE="Components Modules Edit Stat COM_COMPONENTBUILDER_COMPONENTS_MODULES_EDIT_STATE_DESC="Allows the users in this group to update the state of the component modules" COM_COMPONENTBUILDER_COMPONENTS_MODULES_EDIT_VERSION="Components Modules Edit Version" COM_COMPONENTBUILDER_COMPONENTS_MODULES_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version components modules" +COM_COMPONENTBUILDER_COMPONENTS_MODULES_EMPTYSTATE_BUTTON_ADD="Add your first component modules" +COM_COMPONENTBUILDER_COMPONENTS_MODULES_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_COMPONENTS_MODULES_EMPTYSTATE_TITLE="No components modules have been created yet." COM_COMPONENTBUILDER_COMPONENTS_MODULES_N_ITEMS_ARCHIVED="%s Components Modules archived." COM_COMPONENTBUILDER_COMPONENTS_MODULES_N_ITEMS_ARCHIVED_1="%s Component Modules archived." COM_COMPONENTBUILDER_COMPONENTS_MODULES_N_ITEMS_CHECKED_IN_0="No Component Modules successfully checked in." @@ -1981,6 +2036,9 @@ COM_COMPONENTBUILDER_COMPONENTS_MYSQL_TWEAKS_EDIT_STATE="Components Mysql Tweaks COM_COMPONENTBUILDER_COMPONENTS_MYSQL_TWEAKS_EDIT_STATE_DESC="Allows the users in this group to update the state of the component mysql tweaks" COM_COMPONENTBUILDER_COMPONENTS_MYSQL_TWEAKS_EDIT_VERSION="Components Mysql Tweaks Edit Version" COM_COMPONENTBUILDER_COMPONENTS_MYSQL_TWEAKS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version components mysql tweaks" +COM_COMPONENTBUILDER_COMPONENTS_MYSQL_TWEAKS_EMPTYSTATE_BUTTON_ADD="Add your first component mysql tweaks" +COM_COMPONENTBUILDER_COMPONENTS_MYSQL_TWEAKS_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_COMPONENTS_MYSQL_TWEAKS_EMPTYSTATE_TITLE="No components mysql tweaks have been created yet." COM_COMPONENTBUILDER_COMPONENTS_MYSQL_TWEAKS_N_ITEMS_ARCHIVED="%s Components mysql Tweaks archived." COM_COMPONENTBUILDER_COMPONENTS_MYSQL_TWEAKS_N_ITEMS_ARCHIVED_1="%s Component mysql Tweaks archived." COM_COMPONENTBUILDER_COMPONENTS_MYSQL_TWEAKS_N_ITEMS_CHECKED_IN_0="No Component mysql Tweaks successfully checked in." @@ -2023,6 +2081,9 @@ COM_COMPONENTBUILDER_COMPONENTS_PLACEHOLDERS_EDIT_STATE="Components Placeholders COM_COMPONENTBUILDER_COMPONENTS_PLACEHOLDERS_EDIT_STATE_DESC="Allows the users in this group to update the state of the component placeholders" COM_COMPONENTBUILDER_COMPONENTS_PLACEHOLDERS_EDIT_VERSION="Components Placeholders Edit Version" COM_COMPONENTBUILDER_COMPONENTS_PLACEHOLDERS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version components placeholders" +COM_COMPONENTBUILDER_COMPONENTS_PLACEHOLDERS_EMPTYSTATE_BUTTON_ADD="Add your first component placeholders" +COM_COMPONENTBUILDER_COMPONENTS_PLACEHOLDERS_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_COMPONENTS_PLACEHOLDERS_EMPTYSTATE_TITLE="No components placeholders have been created yet." COM_COMPONENTBUILDER_COMPONENTS_PLACEHOLDERS_N_ITEMS_ARCHIVED="%s Components Placeholders archived." COM_COMPONENTBUILDER_COMPONENTS_PLACEHOLDERS_N_ITEMS_ARCHIVED_1="%s Component Placeholders archived." COM_COMPONENTBUILDER_COMPONENTS_PLACEHOLDERS_N_ITEMS_CHECKED_IN_0="No Component Placeholders successfully checked in." @@ -2065,6 +2126,9 @@ COM_COMPONENTBUILDER_COMPONENTS_PLUGINS_EDIT_STATE="Components Plugins Edit Stat COM_COMPONENTBUILDER_COMPONENTS_PLUGINS_EDIT_STATE_DESC="Allows the users in this group to update the state of the component plugins" COM_COMPONENTBUILDER_COMPONENTS_PLUGINS_EDIT_VERSION="Components Plugins Edit Version" COM_COMPONENTBUILDER_COMPONENTS_PLUGINS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version components plugins" +COM_COMPONENTBUILDER_COMPONENTS_PLUGINS_EMPTYSTATE_BUTTON_ADD="Add your first component plugins" +COM_COMPONENTBUILDER_COMPONENTS_PLUGINS_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_COMPONENTS_PLUGINS_EMPTYSTATE_TITLE="No components plugins have been created yet." COM_COMPONENTBUILDER_COMPONENTS_PLUGINS_N_ITEMS_ARCHIVED="%s Components Plugins archived." COM_COMPONENTBUILDER_COMPONENTS_PLUGINS_N_ITEMS_ARCHIVED_1="%s Component Plugins archived." COM_COMPONENTBUILDER_COMPONENTS_PLUGINS_N_ITEMS_CHECKED_IN_0="No Component Plugins successfully checked in." @@ -2084,6 +2148,51 @@ COM_COMPONENTBUILDER_COMPONENTS_PLUGINS_N_ITEMS_UNFEATURED="%s Components Plugin COM_COMPONENTBUILDER_COMPONENTS_PLUGINS_N_ITEMS_UNFEATURED_1="%s Component Plugins unfeatured." COM_COMPONENTBUILDER_COMPONENTS_PLUGINS_N_ITEMS_UNPUBLISHED="%s Components Plugins unpublished." COM_COMPONENTBUILDER_COMPONENTS_PLUGINS_N_ITEMS_UNPUBLISHED_1="%s Component Plugins unpublished." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS="Components Routers" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_ACCESS="Components Routers Access" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_ACCESS_DESC="Allows the users in this group to access access components routers" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_BATCH_OPTIONS="Batch process the selected Components Routers" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_BATCH_TIP="All changes will be applied to all selected Components Routers" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_BATCH_USE="Components Routers Batch Use" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_BATCH_USE_DESC="Allows the users in this group to use batch copy/update method of batch components routers" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_CREATE="Components Routers Create" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_CREATE_DESC="Allows the users in this group to create create components routers" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_DELETE="Components Routers Delete" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_DELETE_DESC="Allows the users in this group to delete delete components routers" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT="Components Routers Edit" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_CREATED_BY="Components Routers Edit Created By" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by components routers" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_CREATED_DATE="Components Routers Edit Created Date" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created components routers" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_DESC="Allows the users in this group to edit the component router" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_OWN="Components Routers Edit Own" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_OWN_DESC="Allows the users in this group to edit edit own components routers created by them" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_STATE="Components Routers Edit State" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_STATE_DESC="Allows the users in this group to update the state of the component router" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_VERSION="Components Routers Edit Version" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version components routers" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EMPTYSTATE_BUTTON_ADD="Add your first component router" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EMPTYSTATE_CONTENT="The component site router." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EMPTYSTATE_TITLE="No components routers have been created yet." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_N_ITEMS_ARCHIVED="%s Components Routers archived." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_N_ITEMS_ARCHIVED_1="%s Component Router archived." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_N_ITEMS_CHECKED_IN_0="No Component Router successfully checked in." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_N_ITEMS_CHECKED_IN_1="%d Component Router successfully checked in." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_N_ITEMS_CHECKED_IN_MORE="%d Components Routers successfully checked in." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_N_ITEMS_DELETED="%s Components Routers deleted." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_N_ITEMS_DELETED_1="%s Component Router deleted." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_N_ITEMS_FAILED_PUBLISHING="%s Components Routers failed publishing." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_N_ITEMS_FAILED_PUBLISHING_1="%s Component Router failed publishing." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_N_ITEMS_FEATURED="%s Components Routers featured." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_N_ITEMS_FEATURED_1="%s Component Router featured." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_N_ITEMS_PUBLISHED="%s Components Routers published." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_N_ITEMS_PUBLISHED_1="%s Component Router published." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_N_ITEMS_TRASHED="%s Components Routers trashed." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_N_ITEMS_TRASHED_1="%s Component Router trashed." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_N_ITEMS_UNFEATURED="%s Components Routers unfeatured." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_N_ITEMS_UNFEATURED_1="%s Component Router unfeatured." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_N_ITEMS_UNPUBLISHED="%s Components Routers unpublished." +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_N_ITEMS_UNPUBLISHED_1="%s Component Router unpublished." COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS="Components Site Views" COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS_ACCESS="Components Site Views Access" COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS_ACCESS_DESC="Allows the users in this group to access access components site views" @@ -2107,6 +2216,9 @@ COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS_EDIT_STATE="Components Site Views Edi COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS_EDIT_STATE_DESC="Allows the users in this group to update the state of the component site views" COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS_EDIT_VERSION="Components Site Views Edit Version" COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version components site views" +COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS_EMPTYSTATE_BUTTON_ADD="Add your first component site views" +COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS_EMPTYSTATE_TITLE="No components site views have been created yet." COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS_N_ITEMS_ARCHIVED="%s Components Site Views archived." COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS_N_ITEMS_ARCHIVED_1="%s Component Site Views archived." COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS_N_ITEMS_CHECKED_IN_0="No Component Site Views successfully checked in." @@ -2149,6 +2261,9 @@ COM_COMPONENTBUILDER_COMPONENTS_UPDATES_EDIT_STATE="Components Updates Edit Stat COM_COMPONENTBUILDER_COMPONENTS_UPDATES_EDIT_STATE_DESC="Allows the users in this group to update the state of the component updates" COM_COMPONENTBUILDER_COMPONENTS_UPDATES_EDIT_VERSION="Components Updates Edit Version" COM_COMPONENTBUILDER_COMPONENTS_UPDATES_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version components updates" +COM_COMPONENTBUILDER_COMPONENTS_UPDATES_EMPTYSTATE_BUTTON_ADD="Add your first component updates" +COM_COMPONENTBUILDER_COMPONENTS_UPDATES_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_COMPONENTS_UPDATES_EMPTYSTATE_TITLE="No components updates have been created yet." COM_COMPONENTBUILDER_COMPONENTS_UPDATES_N_ITEMS_ARCHIVED="%s Components Updates archived." COM_COMPONENTBUILDER_COMPONENTS_UPDATES_N_ITEMS_ARCHIVED_1="%s Component Updates archived." COM_COMPONENTBUILDER_COMPONENTS_UPDATES_N_ITEMS_CHECKED_IN_0="No Component Updates successfully checked in." @@ -2261,6 +2376,7 @@ COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_ENVELOPE="Envelope" COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_ENVELOPE_OPENED="Envelope Opened" COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_EQUALIZER="Equalizer" COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_ERROR_UNIQUE_ALIAS="Another Component Admin Views has the same alias." +COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Component Admin Views has the same alias ." COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_EXIT="Exit" COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_EXPAND="Expand" COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_EXPAND_2="Expand 2" @@ -2459,6 +2575,7 @@ COM_COMPONENTBUILDER_COMPONENT_CONFIG_CUSTOM_VALUE_HINT="Custom Value Here" COM_COMPONENTBUILDER_COMPONENT_CONFIG_CUSTOM_VALUE_LABEL="Custom Value" COM_COMPONENTBUILDER_COMPONENT_CONFIG_EDIT="Editing the Component Config" COM_COMPONENTBUILDER_COMPONENT_CONFIG_ERROR_UNIQUE_ALIAS="Another Component Config has the same alias." +COM_COMPONENTBUILDER_COMPONENT_CONFIG_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Component Config has the same alias ." COM_COMPONENTBUILDER_COMPONENT_CONFIG_FIELD="Field" COM_COMPONENTBUILDER_COMPONENT_CONFIG_FIELD_DESCRIPTION="Select a field" COM_COMPONENTBUILDER_COMPONENT_CONFIG_FIELD_LABEL="Field" @@ -2499,6 +2616,7 @@ COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_DASHBOARD_LIST_DESCRIPTION="Se COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_DASHBOARD_LIST_LABEL="Dashboard (list of records)" COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_EDIT="Editing the Component Custom Admin Menus" COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_ERROR_UNIQUE_ALIAS="Another Component Custom Admin Menus has the same alias." +COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Component Custom Admin Menus has the same alias ." COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_ICON_DESCRIPTION="Add the icon to the image folder and select it here (128 x 128px)" COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_ICON_LABEL="Icon" COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_ID="Id" @@ -2624,6 +2742,7 @@ COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_ENVELOPE="Envelope" COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_ENVELOPE_OPENED="Envelope Opened" COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_EQUALIZER="Equalizer" COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_ERROR_UNIQUE_ALIAS="Another Component Custom Admin Views has the same alias." +COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Component Custom Admin Views has the same alias ." COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_EXIT="Exit" COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_EXPAND="Expand" COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_EXPAND_2="Expand 2" @@ -2807,6 +2926,7 @@ COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_DASHBOARD="Dashboard" COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_DASHBOARD_TAB_LABEL="Dashboard Tabs" COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_EDIT="Editing the Component Dashboard" COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_ERROR_UNIQUE_ALIAS="Another Component Dashboard has the same alias." +COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Component Dashboard has the same alias ." COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_HEADER_DESCRIPTION="Enter Header Here" COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_HEADER_HINT="Header Here" COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_HEADER_LABEL="Header" @@ -2857,6 +2977,7 @@ COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_CREATED_DATE_DESC="The date this Co COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_CREATED_DATE_LABEL="Created Date" COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_EDIT="Editing the Component Files & Folders" COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_ERROR_UNIQUE_ALIAS="Another Component Files & Folders has the same alias." +COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Component Files & Folders has the same alias ." COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_FILE="File" COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_FILEPATH_DESCRIPTION="Full System Path" COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_FILEPATH_HINT="/home/user/folder/file.php" @@ -2919,6 +3040,7 @@ COM_COMPONENTBUILDER_COMPONENT_MODULES_CREATED_DATE_DESC="The date this Componen COM_COMPONENTBUILDER_COMPONENT_MODULES_CREATED_DATE_LABEL="Created Date" COM_COMPONENTBUILDER_COMPONENT_MODULES_EDIT="Editing the Component Modules" COM_COMPONENTBUILDER_COMPONENT_MODULES_ERROR_UNIQUE_ALIAS="Another Component Modules has the same alias." +COM_COMPONENTBUILDER_COMPONENT_MODULES_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Component Modules has the same alias ." COM_COMPONENTBUILDER_COMPONENT_MODULES_EXPORT_ONLY="Export (only)" COM_COMPONENTBUILDER_COMPONENT_MODULES_ID="Id" COM_COMPONENTBUILDER_COMPONENT_MODULES_JOOMLA_COMPONENT_DESCRIPTION="Select a Joomla Component" @@ -2961,6 +3083,7 @@ COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_CREATED_DATE_DESC="The date this Com COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_CREATED_DATE_LABEL="Created Date" COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_EDIT="Editing the Component mysql Tweaks" COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_ERROR_UNIQUE_ALIAS="Another Component mysql Tweaks has the same alias." +COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Component mysql Tweaks has the same alias ." COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_ID="Id" COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_IDS_DESCRIPTION="if id option selected" COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_IDS_HINT="// 1 => 500 or 1,2,3,4 or 1 => 4,20,40 => 90" @@ -3000,6 +3123,7 @@ COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_CREATED_DATE_LABEL="Created Date" COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_DETAILS="Details" COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_EDIT="Editing the Component Placeholders" COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_ERROR_UNIQUE_ALIAS="Another Component Placeholders has the same alias." +COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Component Placeholders has the same alias ." COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_ID="Id" COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_JOOMLA_COMPONENT_DESCRIPTION="Select a Joomla Component" COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_JOOMLA_COMPONENT_LABEL="Component" @@ -3038,6 +3162,7 @@ COM_COMPONENTBUILDER_COMPONENT_PLUGINS_CREATED_DATE_DESC="The date this Componen COM_COMPONENTBUILDER_COMPONENT_PLUGINS_CREATED_DATE_LABEL="Created Date" COM_COMPONENTBUILDER_COMPONENT_PLUGINS_EDIT="Editing the Component Plugins" COM_COMPONENTBUILDER_COMPONENT_PLUGINS_ERROR_UNIQUE_ALIAS="Another Component Plugins has the same alias." +COM_COMPONENTBUILDER_COMPONENT_PLUGINS_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Component Plugins has the same alias ." COM_COMPONENTBUILDER_COMPONENT_PLUGINS_EXPORT_ONLY="Export (only)" COM_COMPONENTBUILDER_COMPONENT_PLUGINS_ID="Id" COM_COMPONENTBUILDER_COMPONENT_PLUGINS_JOOMLA_COMPONENT_DESCRIPTION="Select a Joomla Component" @@ -3063,6 +3188,60 @@ COM_COMPONENTBUILDER_COMPONENT_PLUGINS_TARGET_DESCRIPTION="Association" COM_COMPONENTBUILDER_COMPONENT_PLUGINS_TARGET_LABEL="Target" COM_COMPONENTBUILDER_COMPONENT_PLUGINS_VERSION_DESC="A count of the number of times this Component Plugins has been revised." COM_COMPONENTBUILDER_COMPONENT_PLUGINS_VERSION_LABEL="Version" +COM_COMPONENTBUILDER_COMPONENT_ROUTER="Component Router" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_BASIC="Basic" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_CODE="Code" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_CONSTRUCTOR_AFTER_PARENT_CODE_DESCRIPTION="Here you can add the code to use in the constructor after parent class is called." +COM_COMPONENTBUILDER_COMPONENT_ROUTER_CONSTRUCTOR_AFTER_PARENT_CODE_LABEL="Constructor After Parent
    Code" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_CONSTRUCTOR_BEFORE_PARENT_CODE_DESCRIPTION="Here you can add the code to use in the constructor before parent class is called." +COM_COMPONENTBUILDER_COMPONENT_ROUTER_CONSTRUCTOR_BEFORE_PARENT_CODE_LABEL="Constructor Before Parent
    Code" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_CONSTRUCTOR_BEFORE_PARENT_MANUAL_DESCRIPTION="Setup the site views router configuration for this component." +COM_COMPONENTBUILDER_COMPONENT_ROUTER_CONSTRUCTOR_BEFORE_PARENT_MANUAL_LABEL="Manual Setup of View Configuration" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_CREATED_BY_DESC="The user that created this Component Router." +COM_COMPONENTBUILDER_COMPONENT_ROUTER_CREATED_BY_LABEL="Created By" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_CREATED_DATE_DESC="The date this Component Router was created." +COM_COMPONENTBUILDER_COMPONENT_ROUTER_CREATED_DATE_LABEL="Created Date" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_DEFAULT="Default" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_DETAILS="Details" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_EDIT="Editing the Component Router" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_ERROR_UNIQUE_ALIAS="Another Component Router has the same alias." +COM_COMPONENTBUILDER_COMPONENT_ROUTER_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Component Router has the same alias ." +COM_COMPONENTBUILDER_COMPONENT_ROUTER_ID="Id" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_JOOMLA_COMPONENT_DESCRIPTION="Select a Joomla Component" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_JOOMLA_COMPONENT_LABEL="Component" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_MANUAL="Manual" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_METHODS_CODE_DESCRIPTION="Here you can add the methods to add to the router class." +COM_COMPONENTBUILDER_COMPONENT_ROUTER_METHODS_CODE_LABEL="Methods
    Code" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_MODE_CONSTRUCTOR_AFTER_PARENT_DESCRIPTION="You can set your router constructor after parent mode here for only Joomla 4 and above." +COM_COMPONENTBUILDER_COMPONENT_ROUTER_MODE_CONSTRUCTOR_AFTER_PARENT_LABEL="Router Mode
    [constructor_after_parent]" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_MODE_CONSTRUCTOR_BEFORE_PARENT_DESCRIPTION="You can set your router constructor before parent mode here for only Joomla 4 and above." +COM_COMPONENTBUILDER_COMPONENT_ROUTER_MODE_CONSTRUCTOR_BEFORE_PARENT_LABEL="Router Mode
    [constructor_before_parent]" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_MODE_METHODS_DESCRIPTION="You can set your router methods mode here for only Joomla 4 and above." +COM_COMPONENTBUILDER_COMPONENT_ROUTER_MODE_METHODS_LABEL="Router Mode
    [methods]" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_MODIFIED_BY_DESC="The last user that modified this Component Router." +COM_COMPONENTBUILDER_COMPONENT_ROUTER_MODIFIED_BY_LABEL="Modified By" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_MODIFIED_DATE_DESC="The date this Component Router was modified." +COM_COMPONENTBUILDER_COMPONENT_ROUTER_MODIFIED_DATE_LABEL="Modified Date" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_NEW="A New Component Router" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_NONE="None" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_NOTE_MODE_CONSTRUCTOR_BEFORE_PARENT_MANUAL_DESCRIPTION="This feature is not yet ready (SOON)" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_NOTE_MODE_CONSTRUCTOR_BEFORE_PARENT_MANUAL_LABEL="Manual Mode" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_NOTE_ROUTER_SETTINGS_ADVANCE_DESCRIPTION="

    The RouterView class in Joomla is designed to manage the routing process, translating human-readable URLs into query variables and vice versa. This functionality is crucial for creating search engine friendly (SEF) URLs and ensuring that requests within the Joomla application are directed to the appropriate components and views.

    Key Responsibilities

    • URL Building: Converts query information into SEF URLs. This process involves taking the query parameters associated with a particular route and constructing a URL that is both user-friendly and optimized for search engines.
    • URL Parsing: Interprets SEF URLs back into query parameters. When a request is made to Joomla with an SEF URL, the RouterView class parses this URL to determine the component, view, and other request variables required to fulfill the request.

    How to Use RouterView in a 3rd Party Extension

    To leverage the RouterView class in a 3rd party Joomla extension, follow these steps:

    1. Extend RouterView: Create a new router class in your component that extends RouterView. This class will define the routing rules specific to your component.
    2. Define Routes: Within your router class, define routes by mapping URL patterns to query parameters. This involves specifying how URL segments correspond to the component’s views and tasks.
    3. Register the Router: Ensure that Joomla is aware of your custom router by registering it with the application. This is typically done within the component’s entry point file.

    Benefits of Using RouterView

    • SEO Optimization: By enabling the creation of human-readable URLs, RouterView helps improve the SEO of your Joomla site.
    • Improved User Experience: SEF URLs are easier for users to understand and remember, enhancing the overall user experience.
    • Flexibility: Custom routers allow for granular control over URL structure, making it possible to tailor URLs to match the needs of your extension and its audience.

    The basic structure of a custom router class for a Joomla 3rd party extension highlights the need to implement the build and parse methods, which handle the conversion between query parameters and SEF URLs.

    " +COM_COMPONENTBUILDER_COMPONENT_ROUTER_NOTE_ROUTER_SETTINGS_ADVANCE_LABEL="Understanding the Site RouterView Class." +COM_COMPONENTBUILDER_COMPONENT_ROUTER_NOTE_ROUTER_SETTINGS_DESCRIPTION="Extending the `RouterView` class in a Joomla 3rd party extension enables developers to intricately manage and customize URLs, significantly enhancing user navigation and SEO. This approach allows for defining clean, search-engine-friendly routes for component views, dynamic handling of query variables, and seamless integration with Joomla's menu system for automatic route adjustments. Additionally, it supports the implementation of custom routing rules, including support for multilingual sites, and sophisticated error handling and redirects. By leveraging `RouterView`, developers can craft a more intuitive and efficient URL structure, ensuring a smoother user experience and improved visibility on search engines." +COM_COMPONENTBUILDER_COMPONENT_ROUTER_NOTE_ROUTER_SETTINGS_LABEL="Site Router Settings" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_ORDERING_LABEL="Ordering" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_PERMISSION="Permissions" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_PUBLISHING="Publishing" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_ROUTER_SETTINGS_DETAILS_SWITCH_LABEL="Documentation" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Component Router to customise the alias." +COM_COMPONENTBUILDER_COMPONENT_ROUTER_SETTINGS="Settings" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_SITEVIEW="Siteview" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_SITEVIEW_DESCRIPTION="Select a site view" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_SITEVIEW_LABEL="View" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_STATUS="Status" +COM_COMPONENTBUILDER_COMPONENT_ROUTER_VERSION_DESC="A count of the number of times this Component Router has been revised." +COM_COMPONENTBUILDER_COMPONENT_ROUTER_VERSION_LABEL="Version" COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS="Component Site Views" COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_ACCESS_DESCRIPTION="Select if this view
    should use access." COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_ACCESS_LABEL="Add Access" @@ -3078,6 +3257,7 @@ COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_DEFAULT_VIEW_DESCRIPTION="Select only COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_DEFAULT_VIEW_LABEL="Default View" COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_EDIT="Editing the Component Site Views" COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_ERROR_UNIQUE_ALIAS="Another Component Site Views has the same alias." +COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Component Site Views has the same alias ." COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_ID="Id" COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_JOOMLA_COMPONENT_DESCRIPTION="Select a Joomla Component" COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_JOOMLA_COMPONENT_LABEL="Component" @@ -3121,6 +3301,7 @@ COM_COMPONENTBUILDER_COMPONENT_UPDATES_CREATED_DATE_DESC="The date this Componen COM_COMPONENTBUILDER_COMPONENT_UPDATES_CREATED_DATE_LABEL="Created Date" COM_COMPONENTBUILDER_COMPONENT_UPDATES_EDIT="Editing the Component Updates" COM_COMPONENTBUILDER_COMPONENT_UPDATES_ERROR_UNIQUE_ALIAS="Another Component Updates has the same alias." +COM_COMPONENTBUILDER_COMPONENT_UPDATES_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Component Updates has the same alias ." COM_COMPONENTBUILDER_COMPONENT_UPDATES_ID="Id" COM_COMPONENTBUILDER_COMPONENT_UPDATES_JOOMLA_COMPONENT_DESCRIPTION="Select a Joomla Component" COM_COMPONENTBUILDER_COMPONENT_UPDATES_JOOMLA_COMPONENT_LABEL="Component" @@ -3199,7 +3380,7 @@ COM_COMPONENTBUILDER_CONFIG_AUTHOR_NAME_DESC="The name of the author of this com COM_COMPONENTBUILDER_CONFIG_AUTHOR_NAME_LABEL="Author Name" COM_COMPONENTBUILDER_CONFIG_AUTO_BACKUP="Auto Backup" COM_COMPONENTBUILDER_CONFIG_AUTO_LOAD="Auto" -COM_COMPONENTBUILDER_CONFIG_BACKUPCRONJOB_NOTE_DESCRIPTION="You can run a cronjob that will backup all your components as they are mapped in JCB.

    USE THE FOLLOWING: loading...

    Please note that if your Joomla website has a Firewall installed, it will not allow cronjob via direct URL (most of the time), you will then need to adapt the cornjob request to look like a browser. For more info please read https://stackoverflow.com/a/31597823/1429677" +COM_COMPONENTBUILDER_CONFIG_BACKUPCRONJOB_NOTE_DESCRIPTION="You can run a cronjob that will backup all your components as they are mapped in JCB.

    USE THE FOLLOWING: loading...

    Please note that if your Joomla website has a Firewall installed, it will not allow cronjob via direct URL (most of the time), you will then need to adapt the cornjob request to look like a browser. For more info please read https://stackoverflow.com/a/31597823/1429677" COM_COMPONENTBUILDER_CONFIG_BACKUPCRONJOB_NOTE_LABEL="Backup JCB Mapped Components" COM_COMPONENTBUILDER_CONFIG_BACKUP_DESCRIPTION="Should the zipped package of the component be moved to the local backup and remote sales server? This is only applicable if this component has those values set." COM_COMPONENTBUILDER_CONFIG_BACKUP_EMAIL_DESCRIPTION="Enter the email where the backup key should be send. It will only send an email if a key change is detected, and not on every backup." @@ -3324,7 +3505,7 @@ COM_COMPONENTBUILDER_CONFIG_EVERY_MINUTE="Every Minute" COM_COMPONENTBUILDER_CONFIG_EVERY_SESSION="Every Session" COM_COMPONENTBUILDER_CONFIG_EVERY_WEEK="Every Week" COM_COMPONENTBUILDER_CONFIG_EXPANSION="Expansion" -COM_COMPONENTBUILDER_CONFIG_EXPANSIONCRONJOB_NOTE_DESCRIPTION="You must run a cronjob that will trigger the expansion events for JCB.

    USE THE FOLLOWING: loading...

    Please note that if your Joomla website has a Firewall installed, it will not allow cronjob via direct URL (most of the time), you will then need to adapt the cornjob request to look like a browser. For more info please read https://stackoverflow.com/a/31597823/1429677" +COM_COMPONENTBUILDER_CONFIG_EXPANSIONCRONJOB_NOTE_DESCRIPTION="You must run a cronjob that will trigger the expansion events for JCB.

    USE THE FOLLOWING: loading...

    Please note that if your Joomla website has a Firewall installed, it will not allow cronjob via direct URL (most of the time), you will then need to adapt the cornjob request to look like a browser. For more info please read https://stackoverflow.com/a/31597823/1429677" COM_COMPONENTBUILDER_CONFIG_EXPANSIONCRONJOB_NOTE_LABEL="Expansion Cronjob" COM_COMPONENTBUILDER_CONFIG_EXPANSION_DESCRIPTION="Properties for this field" COM_COMPONENTBUILDER_CONFIG_EXPANSION_LABEL="Expansion" @@ -3423,6 +3604,10 @@ COM_COMPONENTBUILDER_CONFIG_MENU_PREFIX_LABEL="Prefix
    Check out thes COM_COMPONENTBUILDER_CONFIG_MENU_PREFIX_MESSAGE="Error! Please add some text here." COM_COMPONENTBUILDER_CONFIG_MINIFY_DESCRIPTION="Should the JavaScript be minified when compiled." COM_COMPONENTBUILDER_CONFIG_MINIFY_LABEL="Minify JS" +COM_COMPONENTBUILDER_CONFIG_NAMESPACE_PREFIX_DESCRIPTION="Add the namespace prefix. Like your company name in a code formate. So it will have no spaces and starting with an uppercase letter, and only be alphabetical characters.
    Example: VastDevelopmentMethod
    This will be used as a prefix to namespacing when targeting Joomla 4 and above." +COM_COMPONENTBUILDER_CONFIG_NAMESPACE_PREFIX_HINT="VastDevelopmentMethod" +COM_COMPONENTBUILDER_CONFIG_NAMESPACE_PREFIX_LABEL="Namespace Prefix" +COM_COMPONENTBUILDER_CONFIG_NAMESPACE_PREFIX_MESSAGE="Error! Please add namespace prefix here." COM_COMPONENTBUILDER_CONFIG_NEVER_UPDATE="Never update" COM_COMPONENTBUILDER_CONFIG_NO="No" COM_COMPONENTBUILDER_CONFIG_NONE="None" @@ -3438,7 +3623,7 @@ COM_COMPONENTBUILDER_CONFIG_NOTE_DEVELOPMENT_METHOD_DEFAULT_DESCRIPTION="

    This COM_COMPONENTBUILDER_CONFIG_NOTE_DEVELOPMENT_METHOD_DEFAULT_LABEL="Default Development Method" COM_COMPONENTBUILDER_CONFIG_NOTE_DEVELOPMENT_METHOD_EXPANSION_DESCRIPTION="

    This method adds easy compile and install of multiple components to the current Joomla system. This automated action is called expansion.

    Expansion can be achieved in two ways.

    Button Expansion Option

    The first and most common way is to click on any of the Run Expansion buttons found at the top of some of the JCB admin views.

    Cronjob Expansion Option

    The second is by running a cronjob as explained bellow the area of selection in this tab. So you do not need to manually compile and install the selected components any more, the system does all that automatically for you. The latency of the workflow is based on your cronjob frequency and the size of your component.

    Expansion is pause for a component in a few ways, one by actually checking out/opening the Joomla Component view of the component in JCB, or changing the state to unpublish, archive or trashed, or simply remove if from the list below.

    The Expansion method is there to speedup development testing.

    Below you should set the behaviour of a selected set of components that will be auto build and installed when the expansion module is run.

    " COM_COMPONENTBUILDER_CONFIG_NOTE_DEVELOPMENT_METHOD_EXPANSION_LABEL="Expansion Development Method" -COM_COMPONENTBUILDER_CONFIG_NOTE_DKIM_USE_DESCRIPTION="

    Using the below details, you need to configure your DNS by adding a TXT record on your domain:

    " +COM_COMPONENTBUILDER_CONFIG_NOTE_DKIM_USE_DESCRIPTION="

    Using the below details, you need to configure your DNS by adding a TXT record on your domain:

    " COM_COMPONENTBUILDER_CONFIG_NOTE_DKIM_USE_LABEL="Server Configuration" COM_COMPONENTBUILDER_CONFIG_NOTE_GIT_FOLDER_PATH_DESCRIPTION="You must set the folder where all the components should be deployed for git. You will have to still do your git commit and other git commands yourself. Each component will create their own folder inside this git folder." COM_COMPONENTBUILDER_CONFIG_NOTE_GIT_FOLDER_PATH_LABEL="Adding git to your compiler method" @@ -3546,6 +3731,7 @@ COM_COMPONENTBUILDER_CONTRIBUTORS="Contributors" COM_COMPONENTBUILDER_COPYRIGHT="Copyright" COM_COMPONENTBUILDER_COPYRIGHT_S="Copyright: %s" COM_COMPONENTBUILDER_COULD_NOT_CLEAR_THE_TMP_FOLDER="Could not clear the tmp folder!" +COM_COMPONENTBUILDER_COULD_NOT_FIND_THE_DATA_NEEDED_TO_CONTINUE="Could not find the data needed to continue." COM_COMPONENTBUILDER_COULD_NOT_INSTALL_COMPONENT="Could not install component!" COM_COMPONENTBUILDER_COULD_NOT_INSTALL_EXTENSIONS="Could not install extensions!" COM_COMPONENTBUILDER_COULD_NOT_INSTALL_MODULE="Could not install module!" @@ -3577,6 +3763,9 @@ COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEWS_EDIT_STATE="Custom Admin Views Edit Stat COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEWS_EDIT_STATE_DESC="Allows the users in this group to update the state of the custom admin view" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEWS_EDIT_VERSION="Custom Admin Views Edit Version" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEWS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version custom admin views" +COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEWS_EMPTYSTATE_BUTTON_ADD="Add your first custom admin view" +COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEWS_EMPTYSTATE_CONTENT="The custom admin views used in a component is build here" +COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEWS_EMPTYSTATE_TITLE="No custom admin views have been created yet." COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEWS_EXPORT="Custom Admin Views Export" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEWS_EXPORT_DESC="Allows the users in this group to export export custom admin views" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEWS_IMPORT="Custom Admin Views Import" @@ -3612,8 +3801,8 @@ COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_JAVASCRIPT_FILE_LABEL="Add JavaScript COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_JS_DOCUMENT_LABEL="Add JS (custom document script)" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_PHP_AJAX_LABEL="Add PHP (AJAX)" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_PHP_DOCUMENT_LABEL="Add PHP (custom document script)" -COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_PHP_JVIEW_DISPLAY_LABEL="Add PHP (custom JViewLegacy display)" -COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_PHP_JVIEW_LABEL="Add PHP (custom JViewLegacy methods)" +COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_PHP_JVIEW_DISPLAY_LABEL="Add PHP (custom HtmlView display)" +COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_PHP_JVIEW_LABEL="Add PHP (custom HtmlView methods)" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_PHP_VIEW_LABEL="Add PHP (custom view script)" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_AJAX_INPUT_LABEL="Ajax Input" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ALLOW_ZERO_DESCRIPTION="null & zero values" @@ -3723,6 +3912,7 @@ COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ENVELOPE="Envelope" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ENVELOPE_OPENED="Envelope Opened" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_EQUALIZER="Equalizer" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ERROR_UNIQUE_ALIAS="Another Custom Admin View has the same alias." +COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Custom Admin View has the same alias ." COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_EXIT="Exit" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_EXPAND="Expand" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_EXPAND_2="Expand 2" @@ -4003,6 +4193,9 @@ COM_COMPONENTBUILDER_CUSTOM_CODES_EDIT_STATE="Custom Codes Edit State" COM_COMPONENTBUILDER_CUSTOM_CODES_EDIT_STATE_DESC="Allows the users in this group to update the state of the custom code" COM_COMPONENTBUILDER_CUSTOM_CODES_EDIT_VERSION="Custom Codes Edit Version" COM_COMPONENTBUILDER_CUSTOM_CODES_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version custom codes" +COM_COMPONENTBUILDER_CUSTOM_CODES_EMPTYSTATE_BUTTON_ADD="Add your first custom code" +COM_COMPONENTBUILDER_CUSTOM_CODES_EMPTYSTATE_CONTENT="Custom code added during development" +COM_COMPONENTBUILDER_CUSTOM_CODES_EMPTYSTATE_TITLE="No custom codes have been created yet." COM_COMPONENTBUILDER_CUSTOM_CODES_EXPORT="Custom Codes Export" COM_COMPONENTBUILDER_CUSTOM_CODES_EXPORT_DESC="Allows the users in this group to export export custom codes" COM_COMPONENTBUILDER_CUSTOM_CODES_IMPORT="Custom Codes Import" @@ -4040,6 +4233,7 @@ COM_COMPONENTBUILDER_CUSTOM_CODE_CREATED_DATE_LABEL="Created Date" COM_COMPONENTBUILDER_CUSTOM_CODE_DETAILS="Details" COM_COMPONENTBUILDER_CUSTOM_CODE_EDIT="Editing the Custom Code" COM_COMPONENTBUILDER_CUSTOM_CODE_ERROR_UNIQUE_ALIAS="Another Custom Code has the same alias." +COM_COMPONENTBUILDER_CUSTOM_CODE_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Custom Code has the same alias ." COM_COMPONENTBUILDER_CUSTOM_CODE_FROM_LINE_DESCRIPTION="The line from where to start adding the code." COM_COMPONENTBUILDER_CUSTOM_CODE_FROM_LINE_HINT="Only Numbers" COM_COMPONENTBUILDER_CUSTOM_CODE_FROM_LINE_LABEL="From Line (Zero based)" @@ -4059,6 +4253,7 @@ COM_COMPONENTBUILDER_CUSTOM_CODE_HTML="HTML" COM_COMPONENTBUILDER_CUSTOM_CODE_ID="Id" COM_COMPONENTBUILDER_CUSTOM_CODE_INSERTION="Insertion" COM_COMPONENTBUILDER_CUSTOM_CODE_JCB_MANUAL="JCB (manual)" +COM_COMPONENTBUILDER_CUSTOM_CODE_JOOMLA_VERSION_LABEL="Joomla Version" COM_COMPONENTBUILDER_CUSTOM_CODE_MODIFIED_BY_DESC="The last user that modified this Custom Code." COM_COMPONENTBUILDER_CUSTOM_CODE_MODIFIED_BY_LABEL="Modified By" COM_COMPONENTBUILDER_CUSTOM_CODE_MODIFIED_DATE_DESC="The date this Custom Code was modified." @@ -4153,6 +4348,7 @@ COM_COMPONENTBUILDER_DTEMAILDTDDSDD="
    Email
    %s
    " COM_COMPONENTBUILDER_DTLICENSEDTDDSDD="
    License
    %s
    " COM_COMPONENTBUILDER_DTOWNERDTDDSDD="
    Owner
    %s
    " COM_COMPONENTBUILDER_DTWEBSITEDTDDSDD="
    Website
    %s
    " +COM_COMPONENTBUILDER_DYNAMIC_BUTTON_ERROR="Dynamic Button Error" COM_COMPONENTBUILDER_DYNAMIC_GET="Dynamic Get" COM_COMPONENTBUILDER_DYNAMIC_GETS="Dynamic Gets" COM_COMPONENTBUILDER_DYNAMIC_GETS_ACCESS="Dynamic Gets Access" @@ -4177,6 +4373,9 @@ COM_COMPONENTBUILDER_DYNAMIC_GETS_EDIT_STATE="Dynamic Gets Edit State" COM_COMPONENTBUILDER_DYNAMIC_GETS_EDIT_STATE_DESC="Allows the users in this group to update the state of the dynamic get" COM_COMPONENTBUILDER_DYNAMIC_GETS_EDIT_VERSION="Dynamic Gets Edit Version" COM_COMPONENTBUILDER_DYNAMIC_GETS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version dynamic gets" +COM_COMPONENTBUILDER_DYNAMIC_GETS_EMPTYSTATE_BUTTON_ADD="Add your first dynamic get" +COM_COMPONENTBUILDER_DYNAMIC_GETS_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_DYNAMIC_GETS_EMPTYSTATE_TITLE="No dynamic gets have been created yet." COM_COMPONENTBUILDER_DYNAMIC_GETS_EXPORT="Dynamic Gets Export" COM_COMPONENTBUILDER_DYNAMIC_GETS_EXPORT_DESC="Allows the users in this group to export export dynamic gets" COM_COMPONENTBUILDER_DYNAMIC_GETS_IMPORT="Dynamic Gets Import" @@ -4214,7 +4413,7 @@ COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_BEFORE_GETITEMS_LABEL="Add PHP (before COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_BEFORE_GETITEM_LABEL="Add PHP (before getting the Item)" COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_GETLISTQUERY_LABEL="Add PHP (getListQuery - JModelList)" COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_ROUTER_PARSE_DESCRIPTION="The option to override the default JCB implementation of the router parse method for the related view where this dynamicGet is added." -COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_ROUTER_PARSE_LABEL="Add PHP (parse Method) - in Router" +COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_ROUTER_PARSE_LABEL="Add PHP (parse Method) - in Joomla 3 Router" COM_COMPONENTBUILDER_DYNAMIC_GET_ARRAY_VALUE="Array Value" COM_COMPONENTBUILDER_DYNAMIC_GET_ASCENDING="Ascending" COM_COMPONENTBUILDER_DYNAMIC_GET_AS_LABEL="AS" @@ -4251,6 +4450,7 @@ COM_COMPONENTBUILDER_DYNAMIC_GET_EMPTY_LABEL="Allow" COM_COMPONENTBUILDER_DYNAMIC_GET_EQUAL="equal" COM_COMPONENTBUILDER_DYNAMIC_GET_EQUAL_OR_NOT="equal or not" COM_COMPONENTBUILDER_DYNAMIC_GET_ERROR_UNIQUE_ALIAS="Another Dynamic Get has the same alias." +COM_COMPONENTBUILDER_DYNAMIC_GET_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Dynamic Get has the same alias ." COM_COMPONENTBUILDER_DYNAMIC_GET_F="f" COM_COMPONENTBUILDER_DYNAMIC_GET_FF="ff" COM_COMPONENTBUILDER_DYNAMIC_GET_FILTER_DESCRIPTION="Here you can add filters to the query." @@ -4374,7 +4574,9 @@ COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_GETLISTQUERY_DESCRIPTION="Add PHP Here that COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_GETLISTQUERY_LABEL="PHP getListQuery Method
    used to add custom filtering values." COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_ROUTER_PARSE_DESCRIPTION="Add your PHP here! [Do not add the php tags]
    Add the php code to override the default JCB implementation of the router parse method for the related view where this dynamicGet is added." COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_ROUTER_PARSE_HINT="// PHP Here that should run in the parse Method -> switch | (array) $segments - the segments of the URL to parse | (array) $vars - the URL attributes to be used by the application." -COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_ROUTER_PARSE_LABEL="PHP" +COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_ROUTER_PARSE_LABEL="PHP (only for Joomla 3)" +COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_ROUTER_PARSE_NOTICE_DESCRIPTION="For Joomla 4 and above we move the router related settings to the the Component Site Router area. This can be found in the Joomla Components list view, next to the [add site views button] you will see a button that opens this new Site Router view." +COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_ROUTER_PARSE_NOTICE_LABEL="Joomla 4++" COM_COMPONENTBUILDER_DYNAMIC_GET_PLEASE_SELECT="Please select" COM_COMPONENTBUILDER_DYNAMIC_GET_PLUGIN_EVENTS_DESCRIPTION="Select the content plugin events you would like to add to the page that uses this dynamic get. Please note that the onContentPrepare event is added to all textarea and editor field types by default, so no need to add it again." COM_COMPONENTBUILDER_DYNAMIC_GET_PLUGIN_EVENTS_LABEL="Content Plugin Events
    All events added here can
    be accessed in the $this->item->event object.
    " @@ -4521,6 +4723,9 @@ COM_COMPONENTBUILDER_FIELDS_EDIT_STATE="Fields Edit State" COM_COMPONENTBUILDER_FIELDS_EDIT_STATE_DESC="Allows the users in this group to update the state of the field" COM_COMPONENTBUILDER_FIELDS_EDIT_VERSION="Fields Edit Version" COM_COMPONENTBUILDER_FIELDS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version fields" +COM_COMPONENTBUILDER_FIELDS_EMPTYSTATE_BUTTON_ADD="Add your first field" +COM_COMPONENTBUILDER_FIELDS_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_FIELDS_EMPTYSTATE_TITLE="No fields have been created yet." COM_COMPONENTBUILDER_FIELDS_EXPORT="Fields Export" COM_COMPONENTBUILDER_FIELDS_EXPORT_DESC="Allows the users in this group to export export fields" COM_COMPONENTBUILDER_FIELDS_IMPORT="Fields Import" @@ -4569,6 +4774,9 @@ COM_COMPONENTBUILDER_FIELDTYPES_EDIT_STATE="Fieldtypes Edit State" COM_COMPONENTBUILDER_FIELDTYPES_EDIT_STATE_DESC="Allows the users in this group to update the state of the fieldtype" COM_COMPONENTBUILDER_FIELDTYPES_EDIT_VERSION="Fieldtypes Edit Version" COM_COMPONENTBUILDER_FIELDTYPES_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version fieldtypes" +COM_COMPONENTBUILDER_FIELDTYPES_EMPTYSTATE_BUTTON_ADD="Add your first fieldtype" +COM_COMPONENTBUILDER_FIELDTYPES_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_FIELDTYPES_EMPTYSTATE_TITLE="No fieldtypes have been created yet." COM_COMPONENTBUILDER_FIELDTYPES_EXPORT="Fieldtypes Export" COM_COMPONENTBUILDER_FIELDTYPES_EXPORT_DESC="Allows the users in this group to export export fieldtypes" COM_COMPONENTBUILDER_FIELDTYPES_IMPORT="Fieldtypes Import" @@ -4637,6 +4845,7 @@ COM_COMPONENTBUILDER_FIELDTYPE_DOUBLE="DOUBLE" COM_COMPONENTBUILDER_FIELDTYPE_EDIT="Editing the Fieldtype" COM_COMPONENTBUILDER_FIELDTYPE_ELEVEN="11" COM_COMPONENTBUILDER_FIELDTYPE_ERROR_UNIQUE_ALIAS="Another Fieldtype has the same alias." +COM_COMPONENTBUILDER_FIELDTYPE_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Fieldtype has the same alias ." COM_COMPONENTBUILDER_FIELDTYPE_EXAMPLE_DESCRIPTION="Text Area" COM_COMPONENTBUILDER_FIELDTYPE_EXAMPLE_HINT="Value/Example Here" COM_COMPONENTBUILDER_FIELDTYPE_EXAMPLE_LABEL="Value/Example" @@ -4767,6 +4976,7 @@ COM_COMPONENTBUILDER_FIELD_DOUBLE="DOUBLE" COM_COMPONENTBUILDER_FIELD_EDIT="Editing the Field" COM_COMPONENTBUILDER_FIELD_ELEVEN="11" COM_COMPONENTBUILDER_FIELD_ERROR_UNIQUE_ALIAS="Another Field has the same alias." +COM_COMPONENTBUILDER_FIELD_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Field has the same alias ." COM_COMPONENTBUILDER_FIELD_EXPERT_MODE_CUSTOM="Expert Mode - Custom" COM_COMPONENTBUILDER_FIELD_FIELDS_CATEGORIES="Fields Categories" COM_COMPONENTBUILDER_FIELD_FIELDTYPE_DESCRIPTION="Set the field type" @@ -4868,6 +5078,7 @@ COM_COMPONENTBUILDER_FIELD_XML="Xml" COM_COMPONENTBUILDER_FIELD_YES="Yes" COM_COMPONENTBUILDER_FIELD_ZERO="0" COM_COMPONENTBUILDER_FILE="File" +COM_COMPONENTBUILDER_FILE_BSB_COULD_NOT_BE_STORED="File %s could not be stored!" COM_COMPONENTBUILDER_FILE_BSB_COULD_NOT_BE_UNLOCKED="File %s could not be unlocked!" COM_COMPONENTBUILDER_FILE_BSB_WAS_MOVED_TO_BSB="File %s was moved to %s" COM_COMPONENTBUILDER_FILE_BSB_WAS_NOT_MOVED_TO_BSB="File %s was not moved to %s" @@ -4909,6 +5120,8 @@ COM_COMPONENTBUILDER_FILTER_INDEXES_TYPE_ASCENDING="Indexes Type ascending" COM_COMPONENTBUILDER_FILTER_INDEXES_TYPE_DESCENDING="Indexes Type descending" COM_COMPONENTBUILDER_FILTER_JOOMLA_PLUGIN_GROUP_ASCENDING="Joomla Plugin Group ascending" COM_COMPONENTBUILDER_FILTER_JOOMLA_PLUGIN_GROUP_DESCENDING="Joomla Plugin Group descending" +COM_COMPONENTBUILDER_FILTER_JOOMLA_VERSION_ASCENDING="Joomla Version ascending" +COM_COMPONENTBUILDER_FILTER_JOOMLA_VERSION_DESCENDING="Joomla Version descending" COM_COMPONENTBUILDER_FILTER_LANGUAGE_TAG_ASCENDING="Language Tag ascending" COM_COMPONENTBUILDER_FILTER_LANGUAGE_TAG_DESCENDING="Language Tag descending" COM_COMPONENTBUILDER_FILTER_LIBRARY_ASCENDING="Library ascending" @@ -4954,6 +5167,7 @@ COM_COMPONENTBUILDER_FILTER_PUBLISHED_COMPONENTS_MODULES="Status options for com COM_COMPONENTBUILDER_FILTER_PUBLISHED_COMPONENTS_MYSQL_TWEAKS="Status options for components mysql tweaks" COM_COMPONENTBUILDER_FILTER_PUBLISHED_COMPONENTS_PLACEHOLDERS="Status options for components placeholders" COM_COMPONENTBUILDER_FILTER_PUBLISHED_COMPONENTS_PLUGINS="Status options for components plugins" +COM_COMPONENTBUILDER_FILTER_PUBLISHED_COMPONENTS_ROUTERS="Status options for components routers" COM_COMPONENTBUILDER_FILTER_PUBLISHED_COMPONENTS_SITE_VIEWS="Status options for components site views" COM_COMPONENTBUILDER_FILTER_PUBLISHED_COMPONENTS_UPDATES="Status options for components updates" COM_COMPONENTBUILDER_FILTER_PUBLISHED_CUSTOM_ADMIN_VIEWS="Status options for custom admin views" @@ -5003,6 +5217,7 @@ COM_COMPONENTBUILDER_FILTER_SEARCH_COMPONENTS_MODULES="Search the component modu COM_COMPONENTBUILDER_FILTER_SEARCH_COMPONENTS_MYSQL_TWEAKS="Search the component mysql tweaks items. Prefix with ID: to search for an item by ID." COM_COMPONENTBUILDER_FILTER_SEARCH_COMPONENTS_PLACEHOLDERS="Search the component placeholders items. Prefix with ID: to search for an item by ID." COM_COMPONENTBUILDER_FILTER_SEARCH_COMPONENTS_PLUGINS="Search the component plugins items. Prefix with ID: to search for an item by ID." +COM_COMPONENTBUILDER_FILTER_SEARCH_COMPONENTS_ROUTERS="Search the component router items. Prefix with ID: to search for an item by ID." COM_COMPONENTBUILDER_FILTER_SEARCH_COMPONENTS_SITE_VIEWS="Search the component site views items. Prefix with ID: to search for an item by ID." COM_COMPONENTBUILDER_FILTER_SEARCH_COMPONENTS_UPDATES="Search the component updates items. Prefix with ID: to search for an item by ID." COM_COMPONENTBUILDER_FILTER_SEARCH_CUSTOM_ADMIN_VIEWS="Search the custom admin view items. Prefix with ID: to search for an item by ID." @@ -5033,7 +5248,6 @@ COM_COMPONENTBUILDER_FILTER_SEARCH_SNIPPETS="Search the snippet items. Prefix wi COM_COMPONENTBUILDER_FILTER_SEARCH_SNIPPET_TYPES="Search the snippet type items. Prefix with ID: to search for an item by ID." COM_COMPONENTBUILDER_FILTER_SEARCH_TEMPLATES="Search the template items. Prefix with ID: to search for an item by ID." COM_COMPONENTBUILDER_FILTER_SEARCH_VALIDATION_RULES="Search the validation rule items. Prefix with ID: to search for an item by ID." -COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS="Select Access" COM_COMPONENTBUILDER_FILTER_SELECT_ADD_CUSTOM_BUTTONS="Select Add Custom Buttons" COM_COMPONENTBUILDER_FILTER_SELECT_ADD_CUSTOM_IMPORT="Select Add Custom Import" COM_COMPONENTBUILDER_FILTER_SELECT_ADD_PHP_AJAX="Select Add PHP (AJAX)" @@ -5062,6 +5276,9 @@ COM_COMPONENTBUILDER_FILTER_SELECT_MODELLING_METHOD="Select Modelling Method" COM_COMPONENTBUILDER_FILTER_SELECT_NAME="Select Name" COM_COMPONENTBUILDER_FILTER_SELECT_NULL_SWITCH="Select Null Switch" COM_COMPONENTBUILDER_FILTER_SELECT_PROTOCOL="Select Protocol" +COM_COMPONENTBUILDER_FILTER_SELECT_ROUTER_MODECONSTRUCTOR_AFTER_PARENT="Select Router Mode[constructor_after_parent]" +COM_COMPONENTBUILDER_FILTER_SELECT_ROUTER_MODECONSTRUCTOR_BEFORE_PARENT="Select Router Mode[constructor_before_parent]" +COM_COMPONENTBUILDER_FILTER_SELECT_ROUTER_MODEMETHODS="Select Router Mode[methods]" COM_COMPONENTBUILDER_FILTER_SELECT_SITE_VIEWS="Select Site Views" COM_COMPONENTBUILDER_FILTER_SELECT_SUPER_POWER="Select Super Power" COM_COMPONENTBUILDER_FILTER_SELECT_TARGET="Select Target" @@ -5176,6 +5393,9 @@ COM_COMPONENTBUILDER_HELP_DOCUMENTS_EDIT_STATE="Help Documents Edit State" COM_COMPONENTBUILDER_HELP_DOCUMENTS_EDIT_STATE_DESC="Allows the users in this group to update the state of the help document" COM_COMPONENTBUILDER_HELP_DOCUMENTS_EDIT_VERSION="Help Documents Edit Version" COM_COMPONENTBUILDER_HELP_DOCUMENTS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version help documents" +COM_COMPONENTBUILDER_HELP_DOCUMENTS_EMPTYSTATE_BUTTON_ADD="Add your first help document" +COM_COMPONENTBUILDER_HELP_DOCUMENTS_EMPTYSTATE_CONTENT="The help documentation of this component" +COM_COMPONENTBUILDER_HELP_DOCUMENTS_EMPTYSTATE_TITLE="No help documents have been created yet." COM_COMPONENTBUILDER_HELP_DOCUMENTS_EXPORT="Help Documents Export" COM_COMPONENTBUILDER_HELP_DOCUMENTS_EXPORT_DESC="Allows the users in this group to export export help documents" COM_COMPONENTBUILDER_HELP_DOCUMENTS_IMPORT="Help Documents Import" @@ -5216,6 +5436,7 @@ COM_COMPONENTBUILDER_HELP_DOCUMENT_CREATED_DATE_LABEL="Created Date" COM_COMPONENTBUILDER_HELP_DOCUMENT_DETAILS="Details" COM_COMPONENTBUILDER_HELP_DOCUMENT_EDIT="Editing the Help Document" COM_COMPONENTBUILDER_HELP_DOCUMENT_ERROR_UNIQUE_ALIAS="Another Help Document has the same alias." +COM_COMPONENTBUILDER_HELP_DOCUMENT_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Help Document has the same alias ." COM_COMPONENTBUILDER_HELP_DOCUMENT_GROUPS_DESCRIPTION="Select a group/s" COM_COMPONENTBUILDER_HELP_DOCUMENT_GROUPS_LABEL="Group/s" COM_COMPONENTBUILDER_HELP_DOCUMENT_ID="Id" @@ -5264,18 +5485,27 @@ COM_COMPONENTBUILDER_HI="Hi" COM_COMPONENTBUILDER_HIDE_ONLY="Hide Only" COM_COMPONENTBUILDER_HIDE_TOGGLE="Hide Toggle" COM_COMPONENTBUILDER_HOW_TO_GET_A_S_FREE_KEYSA_FROM_VDM="How to get free keys from VDM." +COM_COMPONENTBUILDER_HR_HTHREEASSETS_TABLE_NOTICEHTHREE="

    Assets Table Notice

    " +COM_COMPONENTBUILDER_HR_HTHREEASSETS_TABLE_WARNINGHTHREE="

    Assets Table Warning

    " +COM_COMPONENTBUILDER_HR_HTHREECONDITIONAL_SCRIPT_WARNINGHTHREE="

    Conditional Script Warning

    " COM_COMPONENTBUILDER_HR_HTHREECUSTOM_CODES_WARNINGHTHREE="

    Custom Codes Warning

    " +COM_COMPONENTBUILDER_HR_HTHREECUSTOM_CODE_WARNINGHTHREE="

    Custom Code Warning

    " COM_COMPONENTBUILDER_HR_HTHREECZEROMPZERONTHREENT_ISSUE_FOUNDHTHREEPTHE_PATH_S_COULD_NOT_BE_USEDP="

    c0mp0n3nt issue found

    The path (%s) could not be used.

    " COM_COMPONENTBUILDER_HR_HTHREEDASHBOARD_ERRORHTHREE="

    Dashboard Error

    " -COM_COMPONENTBUILDER_HR_HTHREEDYNAMIC_BUTTON_ERRORHTHREE="

    Dynamic Button Error

    " COM_COMPONENTBUILDER_HR_HTHREEDYNAMIC_FOLDERS_WERE_DETECTEDHTHREE="

    Dynamic folder(s) were detected.

    " COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_ERRORHTHREE="

    External Code Error

    " COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_NOTICEHTHREE="

    External Code Notice

    " COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_WARNINGHTHREE="

    External Code Warning

    " COM_COMPONENTBUILDER_HR_HTHREEFIELD_NOTICEHTHREE="

    Field Notice

    " +COM_COMPONENTBUILDER_HR_HTHREEFIELD_WARNINGHTHREE="

    Field Warning

    " COM_COMPONENTBUILDER_HR_HTHREEFILE_PATH_ERRORHTHREE="

    File Path Error

    " COM_COMPONENTBUILDER_HR_HTHREEFOLDER_PATH_ERRORHTHREE="

    Folder Path Error

    " +COM_COMPONENTBUILDER_HR_HTHREELANGUAGE_NOTICEHTHREE="

    Language Notice

    " +COM_COMPONENTBUILDER_HR_HTHREELANGUAGE_WARNINGHTHREE="

    Language Warning

    " +COM_COMPONENTBUILDER_HR_HTHREEMULTI_FILTER_ERRORHTHREE="

    Multi Filter Error

    " +COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE="

    %s Warning

    " COM_COMPONENTBUILDER_HR_HTHREETIDY_ERRORHTHREE="

    Tidy Error

    " +COM_COMPONENTBUILDER_HR_HTHREEWHMCS_ERRORHTHREE="

    WHMCS Error

    " COM_COMPONENTBUILDER_HTHREEPLACEHOLDER_REMOVEDHTHREEPBTHISB_CUSTOM_CODE_CAN_ONLY_BE_USED_IN_BOTHERB_CUSTOM_CODE_NOT_IN_IT_SELF_SINCE_THAT_WILL_CAUSE_A_INFINITE_LOOP_IN_THE_COMPILERP="

    Placeholder Removed!

    This custom code can only be used in other custom code, not in it self! Since that will cause a infinite loop in the compiler.

    " COM_COMPONENTBUILDER_HTHREESHTHREEPCUSTOM_CODE_CAN_ONLY_BE_USED_IN_OTHER_CUSTOM_CODE_IF_SET_AS_BJCB_MANUALB_YOU_CAN_NOT_ADD_THEM_TO_EMHASH_AUTOMATIONEM_CODE_AT_THIS_POINTP="

    %s

    Custom code can only be used in other custom code if set as JCB (manual), you can not add them to Hash (Automation) code at this point.

    " COM_COMPONENTBUILDER_HTHREES_NAMESPACE_ERROR_SHTHREEPYOU_MUST_ATLEAST_HAVE_TWO_SECTIONS_IN_YOUR_NAMESPACE_YOU_JUST_HAVE_ONE_S_THIS_IS_AN_UNACCEPTABLE_ACTION_PLEASE_SEE_A_HREFS_PSRFOURA_FOR_MORE_INFOPPTHIS_S_WAS_THEREFORE_REMOVED_A_HREFSCLICK_HEREA_TO_FIX_THIS_ISSUEP="

    %s namespace error (%s)

    You must at-least have two sections in your namespace, you just have one (%s). This is an unacceptable action, please see psr-4 for more info.

    This %s was therefore removed, click here to fix this issue.

    " @@ -5391,7 +5621,6 @@ COM_COMPONENTBUILDER_JCB_INVEST_IN_SUCCESS="JCB: Invest in Success" COM_COMPONENTBUILDER_JCB_INVEST_IN_THE_COMMUNITY="JCB: Invest in the Community" COM_COMPONENTBUILDER_JCB_INVEST_IN_THE_FUTURE="JCB: Invest in the Future" COM_COMPONENTBUILDER_JCB_INVEST_IN_YOUR_FUTURE="JCB: Invest in Your Future" -COM_COMPONENTBUILDER_JCB_IS_NOT_YET_FULLY_READY_FOR_JOOMLA_FOUR_BUT_WITH_YOUR_HELP_WE_CAN_MAKE_THE_TRANSITION_FASTER_SHOW_YOUR_SUPPORT_BY_MAKING_A_DONATION_TODAY_AND_HELP_US_BRING_JCB_TO_THE_NEXT_LEVELBR_BR_BYOUR_COMPONENT_WILL_STILL_ONLY_BE_COMPILED_FOR_JOOMLA_THREEB="JCB is not yet fully ready for Joomla 4, but with your help, we can make the transition faster. Show your support by making a donation today and help us bring JCB to the next level.

    Your component will still only be compiled for Joomla 3" COM_COMPONENTBUILDER_JCB_LOWERS_DEVELOPMENT_STRESS="JCB Lowers Development Stress" COM_COMPONENTBUILDER_JCB_NEEDS_YOU="JCB Needs You" COM_COMPONENTBUILDER_JCB_OFFERS_A_STRONGER_SOLUTION="JCB Offers a Stronger Solution" @@ -5453,6 +5682,9 @@ COM_COMPONENTBUILDER_JOOMLA_COMPONENTS_EDIT_STATE="Joomla Components Edit State" COM_COMPONENTBUILDER_JOOMLA_COMPONENTS_EDIT_STATE_DESC="Allows the users in this group to update the state of the joomla component" COM_COMPONENTBUILDER_JOOMLA_COMPONENTS_EDIT_VERSION="Joomla Components Edit Version" COM_COMPONENTBUILDER_JOOMLA_COMPONENTS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version joomla components" +COM_COMPONENTBUILDER_JOOMLA_COMPONENTS_EMPTYSTATE_BUTTON_ADD="Add your first joomla component" +COM_COMPONENTBUILDER_JOOMLA_COMPONENTS_EMPTYSTATE_CONTENT="The Joomla components list" +COM_COMPONENTBUILDER_JOOMLA_COMPONENTS_EMPTYSTATE_TITLE="No joomla components have been created yet." COM_COMPONENTBUILDER_JOOMLA_COMPONENTS_N_ITEMS_ARCHIVED="%s Joomla Components archived." COM_COMPONENTBUILDER_JOOMLA_COMPONENTS_N_ITEMS_ARCHIVED_1="%s Joomla Component archived." COM_COMPONENTBUILDER_JOOMLA_COMPONENTS_N_ITEMS_CHECKED_IN_0="No Joomla Component successfully checked in." @@ -5497,6 +5729,8 @@ COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_LICENSE_DESCRIPTION="Add the option to COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_LICENSE_LABEL="Add WHMCS
    (license add-on)" COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_MENU_PREFIX_DESCRIPTION="Would you like to add a prefix to the Joomla menu name of this component" COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_MENU_PREFIX_LABEL="Add Menu Prefix" +COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_NAMESPACE_PREFIX_DESCRIPTION="Override the namespace prefix, or use the global value found under the component builder global option under the compiler tab." +COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_NAMESPACE_PREFIX_LABEL="Add Namespace Prefix" COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_HELPER_ADMIN_LABEL="Add PHP (helper_admin Class)" COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_HELPER_BOTH_LABEL="Add PHP (helper Classes - Both admin & site)" COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_HELPER_SITE_LABEL="Add PHP (helper_site Class)" @@ -5606,6 +5840,7 @@ COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EMAIL_MESSAGE="Error! Please author email COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EMPTYCONTRIBUTORS_DESCRIPTION="Set if a list of empty contributor fields should be added." COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EMPTYCONTRIBUTORS_LABEL="Empty Contributor Fields" COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ERROR_UNIQUE_ALIAS="Another Joomla Component has the same alias." +COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Joomla Component has the same alias ." COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EXPORT_BUY_LINK_DESCRIPTION="Enter link where your JCB package key can be bought." COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EXPORT_BUY_LINK_HINT="http://www.example.com/buy-keys" COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EXPORT_BUY_LINK_LABEL="Buy Link
    (to get key)" @@ -5659,6 +5894,10 @@ COM_COMPONENTBUILDER_JOOMLA_COMPONENT_MODIFIED_LABEL="Modified Date" COM_COMPONENTBUILDER_JOOMLA_COMPONENT_MVC_VERSIONDATE_DESCRIPTION="Here you can tweak the way JCB implements versions in the code commenting of your component." COM_COMPONENTBUILDER_JOOMLA_COMPONENT_MVC_VERSIONDATE_LABEL="Version Options" COM_COMPONENTBUILDER_JOOMLA_COMPONENT_MYSQL="MySQL" +COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NAMESPACE_PREFIX_DESCRIPTION="Add the namespace prefix. Like your company name in a code formate. So it will have no spaces and starting with an uppercase letter, and only be alphabetical characters.
    Example: VastDevelopmentMethod
    This will be used as a prefix to namespacing when targeting Joomla 4 and above." +COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NAMESPACE_PREFIX_HINT="VastDevelopmentMethod" +COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NAMESPACE_PREFIX_LABEL="Namespace Prefix" +COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NAMESPACE_PREFIX_MESSAGE="Error! Please add namespace prefix here." COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NAME_CODE_DESCRIPTION="Add Name in Code Here" COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NAME_CODE_HINT="codename" COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NAME_CODE_LABEL="Name in Code
    Naming Conventions" @@ -5703,7 +5942,7 @@ COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NOTE_ON_CUSTOM_ADMIN_VIEWS_DESCRIPTION="Do COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NOTE_ON_CUSTOM_ADMIN_VIEWS_LABEL="Setting Custom Admin Views" COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NOTE_ON_SITE_VIEWS_DESCRIPTION="Do not add the same view twice it will not work. Please watch this tutorial for more help." COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NOTE_ON_SITE_VIEWS_LABEL="Setting Site Views" -COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NOTE_README_DESCRIPTION="

    Need help, visit Markdown-Cheatsheet

    # ###Component_name### (###VERSION###)

    ###DESCRIPTION###

    # Build Details

    + *Company*: [###COMPANYNAME###](###AUTHORWEBSITE###)
    + *Author*: [###AUTHOR###](mailto:###AUTHOREMAIL###)
    + *Name*: [###Component_name###](###AUTHORWEBSITE###)
    + *First Build*: ###CREATIONDATE###
    + *Last Build*: ###BUILDDATE###
    + *Version*: ###VERSION###
    + *Copyright*: ###COPYRIGHT###
    + *License*: ###LICENSE###

    ## Build Time

    **###totalHours### Hours** or **###totalDays### Eight Hour Days** (actual time the author saved -
    due to [Automated Component Builder](https://www.joomlacomponentbuilder.com))

    > (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**,
    > never making one mistake or taking any coffee break.)

    + *Line count*: **###LINE_COUNT###**
    + *File count*: **###FILE_COUNT###**
    + *Folder count*: **###FOLDER_COUNT###**

    **###actualHoursSpent### Hours** or **###actualDaysSpent### Eight Hour Days** (the actual time the author spent)

    > (with the following break down:
    > **debugging @###debuggingHours###hours** = codingtime / 4;
    > **planning @###planningHours###hours** = codingtime / 7;
    > **mapping @###mappingHours###hours** = codingtime / 10;
    > **office @###officeHours###hours** = codingtime / 6;)

    **###actualTotalHours### Hours** or **###actualTotalDays### Eight Hour Days**
    (a total of the realistic time frame for this project)

    > (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**,
    > with the normal everyday realities at the office, that includes the component planning, mapping & debugging.)

    Project duration: **###projectWeekTime### weeks** or **###projectMonthTime### months**

    > This **component** was build with a Joomla [Automated Component Builder](https://www.joomlacomponentbuilder.com).
    > Developed by [Llewellyn van der Merwe](mailto:joomla@vdm.io)

    ## Donations

    If you want to support this project, please consider donating:
    * Open Collective: [Joomla-Component-Builder](https://opencollective.com/Joomla-Component-Builder)
    " +COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NOTE_README_DESCRIPTION="

    Need help, visit Markdown-Cheatsheet

    # ###Component_name### (###VERSION###)

    ###DESCRIPTION###

    # Build Details

    + *Company*: [###COMPANYNAME###](###AUTHORWEBSITE###)
    + *Author*: [###AUTHOR###](mailto:###AUTHOREMAIL###)
    + *Name*: [###Component_name###](###AUTHORWEBSITE###)
    + *First Build*: ###CREATIONDATE###
    + *Last Build*: ###BUILDDATE###
    + *Version*: ###VERSION###
    + *Copyright*: ###COPYRIGHT###
    + *License*: ###LICENSE###

    ## Build Time

    **###totalHours### Hours** or **###totalDays### Eight Hour Days** (actual time the author saved -
    due to [Automated Component Builder](https://www.joomlacomponentbuilder.com))

    > (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**,
    > never making one mistake or taking any coffee break.)

    + *Line count*: **###LINE_COUNT###**
    + *File count*: **###FILE_COUNT###**
    + *Folder count*: **###FOLDER_COUNT###**

    **###actualHoursSpent### Hours** or **###actualDaysSpent### Eight Hour Days** (the actual time the author spent)

    > (with the following break down:
    > **debugging @###debuggingHours###hours** = codingtime / 4;
    > **planning @###planningHours###hours** = codingtime / 7;
    > **mapping @###mappingHours###hours** = codingtime / 10;
    > **office @###officeHours###hours** = codingtime / 6;)

    **###actualTotalHours### Hours** or **###actualTotalDays### Eight Hour Days**
    (a total of the realistic time frame for this project)

    > (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**,
    > with the normal everyday realities at the office, that includes the component planning, mapping & debugging.)

    Project duration: **###projectWeekTime### weeks** or **###projectMonthTime### months**

    > This **component** was build with a Joomla [Automated Component Builder](https://www.joomlacomponentbuilder.com).
    > Developed by [Llewellyn van der Merwe](mailto:joomla@vdm.io)

    ## Donations

    If you want to support this project, please consider donating:
    * Open Collective: [Joomla-Component-Builder](https://opencollective.com/Joomla-Component-Builder)
    " COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NOTE_README_LABEL="Demo README (with all place-holders)" COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NOTE_UPDATE_SERVER_NOTE_FTP_DESCRIPTION="During compilation the file will be moved to the server. You still need to point the above update server url to the xml file location on your server for it to work correctly." COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NOTE_UPDATE_SERVER_NOTE_FTP_LABEL="Select the server used for your update server." @@ -5742,6 +5981,7 @@ COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_PREFLIGHT_UPDATE_DESCRIPTION="PHP scri COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_PREFLIGHT_UPDATE_LABEL="PHP Preflight (update)" COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_SITE_EVENT_DESCRIPTION="PHP script for the global helper site event method." COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_SITE_EVENT_LABEL="Global Helper Site Event (method)" +COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PREFERRED_JOOMLA_VERSION_LABEL="Preferred Joomla Version" COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PUBLISHING="Publishing" COM_COMPONENTBUILDER_JOOMLA_COMPONENT_README="Readme" COM_COMPONENTBUILDER_JOOMLA_COMPONENT_README_LABEL="README.md" @@ -5822,6 +6062,7 @@ COM_COMPONENTBUILDER_JOOMLA_COMPONENT_WHMCS_URL_MESSAGE="Error! Please add websi COM_COMPONENTBUILDER_JOOMLA_COMPONENT_YES="Yes" COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ZIP="ZIP" COM_COMPONENTBUILDER_JOOMLA_FIELDS="Joomla fields" +COM_COMPONENTBUILDER_JOOMLA_FIVE="Joomla 5" COM_COMPONENTBUILDER_JOOMLA_FOUR="Joomla 4" COM_COMPONENTBUILDER_JOOMLA_MODULE="Joomla Module" COM_COMPONENTBUILDER_JOOMLA_MODULES="Joomla Modules" @@ -5849,6 +6090,9 @@ COM_COMPONENTBUILDER_JOOMLA_MODULES_EDIT_STATE="Joomla Modules Edit State" COM_COMPONENTBUILDER_JOOMLA_MODULES_EDIT_STATE_DESC="Allows the users in this group to update the state of the joomla module" COM_COMPONENTBUILDER_JOOMLA_MODULES_EDIT_VERSION="Joomla Modules Edit Version" COM_COMPONENTBUILDER_JOOMLA_MODULES_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version joomla modules" +COM_COMPONENTBUILDER_JOOMLA_MODULES_EMPTYSTATE_BUTTON_ADD="Add your first joomla module" +COM_COMPONENTBUILDER_JOOMLA_MODULES_EMPTYSTATE_CONTENT="Joomla Modules" +COM_COMPONENTBUILDER_JOOMLA_MODULES_EMPTYSTATE_TITLE="No joomla modules have been created yet." COM_COMPONENTBUILDER_JOOMLA_MODULES_EXPORT="Joomla Modules Export" COM_COMPONENTBUILDER_JOOMLA_MODULES_EXPORT_DESC="Allows the users in this group to export export joomla modules" COM_COMPONENTBUILDER_JOOMLA_MODULES_FILES_FOLDERS_URLS="Joomla Modules Files, Folders & URLs" @@ -5874,6 +6118,9 @@ COM_COMPONENTBUILDER_JOOMLA_MODULES_FILES_FOLDERS_URLS_EDIT_STATE="Joomla Module COM_COMPONENTBUILDER_JOOMLA_MODULES_FILES_FOLDERS_URLS_EDIT_STATE_DESC="Allows the users in this group to update the state of the joomla module files folders urls" COM_COMPONENTBUILDER_JOOMLA_MODULES_FILES_FOLDERS_URLS_EDIT_VERSION="Joomla Modules Files Folders Urls Edit Version" COM_COMPONENTBUILDER_JOOMLA_MODULES_FILES_FOLDERS_URLS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version joomla modules files folders urls" +COM_COMPONENTBUILDER_JOOMLA_MODULES_FILES_FOLDERS_URLS_EMPTYSTATE_BUTTON_ADD="Add your first joomla module files, folders & urls" +COM_COMPONENTBUILDER_JOOMLA_MODULES_FILES_FOLDERS_URLS_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_JOOMLA_MODULES_FILES_FOLDERS_URLS_EMPTYSTATE_TITLE="No joomla modules files, folders & urls have been created yet." COM_COMPONENTBUILDER_JOOMLA_MODULES_FILES_FOLDERS_URLS_N_ITEMS_ARCHIVED="%s Joomla Modules Files, Folders & URLs archived." COM_COMPONENTBUILDER_JOOMLA_MODULES_FILES_FOLDERS_URLS_N_ITEMS_ARCHIVED_1="%s Joomla Module Files, Folders & URLs archived." COM_COMPONENTBUILDER_JOOMLA_MODULES_FILES_FOLDERS_URLS_N_ITEMS_CHECKED_IN_0="No Joomla Module Files, Folders & URLs successfully checked in." @@ -5939,6 +6186,9 @@ COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES_EDIT_STATE="Joomla Modules Updates E COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES_EDIT_STATE_DESC="Allows the users in this group to update the state of the joomla module updates" COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES_EDIT_VERSION="Joomla Modules Updates Edit Version" COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version joomla modules updates" +COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES_EMPTYSTATE_BUTTON_ADD="Add your first joomla module updates" +COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES_EMPTYSTATE_TITLE="No joomla modules updates have been created yet." COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES_N_ITEMS_ARCHIVED="%s Joomla Modules Updates archived." COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES_N_ITEMS_ARCHIVED_1="%s Joomla Module Updates archived." COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES_N_ITEMS_CHECKED_IN_0="No Joomla Module Updates successfully checked in." @@ -6004,6 +6254,7 @@ COM_COMPONENTBUILDER_JOOMLA_MODULE_DESCRIPTION_LABEL="Description" COM_COMPONENTBUILDER_JOOMLA_MODULE_DYNAMIC_INTEGRATION="Dynamic Integration" COM_COMPONENTBUILDER_JOOMLA_MODULE_EDIT="Editing the Joomla Module" COM_COMPONENTBUILDER_JOOMLA_MODULE_ERROR_UNIQUE_ALIAS="Another Joomla Module has the same alias." +COM_COMPONENTBUILDER_JOOMLA_MODULE_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Joomla Module has the same alias ." COM_COMPONENTBUILDER_JOOMLA_MODULE_FIELD="Field" COM_COMPONENTBUILDER_JOOMLA_MODULE_FIELDSET_DESCRIPTION="Leave default if you don't know what this should be" COM_COMPONENTBUILDER_JOOMLA_MODULE_FIELDSET_HINT="basic" @@ -6037,6 +6288,7 @@ COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_CREATED_DATE_LABEL="Create COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_DEFAULT_LINK="Default (link)" COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_EDIT="Editing the Joomla Module Files, Folders & URLs" COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_ERROR_UNIQUE_ALIAS="Another Joomla Module Files, Folders & URLs has the same alias." +COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Joomla Module Files, Folders & URLs has the same alias ." COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_FILE="File" COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_FILEPATH_DESCRIPTION="Full System Path" COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_FILEPATH_HINT="/home/user/folder/file.php" @@ -6199,6 +6451,7 @@ COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_CREATED_DATE_DESC="The date this Joom COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_CREATED_DATE_LABEL="Created Date" COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_EDIT="Editing the Joomla Module Updates" COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_ERROR_UNIQUE_ALIAS="Another Joomla Module Updates has the same alias." +COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Joomla Module Updates has the same alias ." COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_ID="Id" COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_JOOMLA_MODULE_LABEL="Joomla Modules" COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_MODIFIED_BY_DESC="The last user that modified this Joomla Module Updates." @@ -6264,6 +6517,9 @@ COM_COMPONENTBUILDER_JOOMLA_PLUGINS_EDIT_STATE="Joomla Plugins Edit State" COM_COMPONENTBUILDER_JOOMLA_PLUGINS_EDIT_STATE_DESC="Allows the users in this group to update the state of the joomla plugin" COM_COMPONENTBUILDER_JOOMLA_PLUGINS_EDIT_VERSION="Joomla Plugins Edit Version" COM_COMPONENTBUILDER_JOOMLA_PLUGINS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version joomla plugins" +COM_COMPONENTBUILDER_JOOMLA_PLUGINS_EMPTYSTATE_BUTTON_ADD="Add your first joomla plugin" +COM_COMPONENTBUILDER_JOOMLA_PLUGINS_EMPTYSTATE_CONTENT="Joomla Plugins" +COM_COMPONENTBUILDER_JOOMLA_PLUGINS_EMPTYSTATE_TITLE="No joomla plugins have been created yet." COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS="Joomla Plugins Files, Folders & URLs" COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS_ACCESS="Joomla Plugins Files Folders Urls Access" COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS_ACCESS_DESC="Allows the users in this group to access access joomla plugins files folders urls" @@ -6287,6 +6543,9 @@ COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS_EDIT_STATE="Joomla Plugin COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS_EDIT_STATE_DESC="Allows the users in this group to update the state of the joomla plugin files folders urls" COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS_EDIT_VERSION="Joomla Plugins Files Folders Urls Edit Version" COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version joomla plugins files folders urls" +COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS_EMPTYSTATE_BUTTON_ADD="Add your first joomla plugin files, folders & urls" +COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS_EMPTYSTATE_TITLE="No joomla plugins files, folders & urls have been created yet." COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS_N_ITEMS_ARCHIVED="%s Joomla Plugins Files, Folders & URLs archived." COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS_N_ITEMS_ARCHIVED_1="%s Joomla Plugin Files, Folders & URLs archived." COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS_N_ITEMS_CHECKED_IN_0="No Joomla Plugin Files, Folders & URLs successfully checked in." @@ -6350,6 +6609,9 @@ COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EDIT_STATE="Joomla Plugins Updates E COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EDIT_STATE_DESC="Allows the users in this group to update the state of the joomla plugin updates" COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EDIT_VERSION="Joomla Plugins Updates Edit Version" COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version joomla plugins updates" +COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EMPTYSTATE_BUTTON_ADD="Add your first joomla plugin updates" +COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_EMPTYSTATE_TITLE="No joomla plugins updates have been created yet." COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_N_ITEMS_ARCHIVED="%s Joomla Plugins Updates archived." COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_N_ITEMS_ARCHIVED_1="%s Joomla Plugin Updates archived." COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_N_ITEMS_CHECKED_IN_0="No Joomla Plugin Updates successfully checked in." @@ -6403,6 +6665,7 @@ COM_COMPONENTBUILDER_JOOMLA_PLUGIN_DESCRIPTION_LABEL="Description" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_DYNAMIC_INTEGRATION="Dynamic Integration" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_EDIT="Editing the Joomla Plugin" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ERROR_UNIQUE_ALIAS="Another Joomla Plugin has the same alias." +COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Joomla Plugin has the same alias ." COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELD="Field" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDSET_DESCRIPTION="Leave default if you don't know what this should be" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDSET_HINT="basic" @@ -6436,6 +6699,7 @@ COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_CREATED_DATE_LABEL="Create COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_DEFAULT_LINK="Default (link)" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_EDIT="Editing the Joomla Plugin Files, Folders & URLs" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_ERROR_UNIQUE_ALIAS="Another Joomla Plugin Files, Folders & URLs has the same alias." +COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Joomla Plugin Files, Folders & URLs has the same alias ." COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_FILE="File" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_FILEPATH_DESCRIPTION="Full System Path" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_FILEPATH_HINT="/home/user/folder/file.php" @@ -6507,6 +6771,9 @@ COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUPS_BATCH_USE="Joomla Plugin Groups Batch COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUPS_BATCH_USE_DESC="Allows the users in this group to use batch copy/update method of batch joomla plugin groups" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUPS_EDIT_VERSION="Joomla Plugin Groups Edit Version" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUPS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version joomla plugin groups" +COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUPS_EMPTYSTATE_BUTTON_ADD="Add your first joomla plugin group" +COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUPS_EMPTYSTATE_CONTENT="The Joomla Plugin Groups" +COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUPS_EMPTYSTATE_TITLE="No joomla plugin groups have been created yet." COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUPS_N_ITEMS_ARCHIVED="%s Joomla Plugin Groups archived." COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUPS_N_ITEMS_ARCHIVED_1="%s Joomla Plugin Group archived." COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUPS_N_ITEMS_CHECKED_IN_0="No Joomla Plugin Group successfully checked in." @@ -6534,6 +6801,7 @@ COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_CREATED_DATE_LABEL="Created Date" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_DETAILS="Details" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_EDIT="Editing the Joomla Plugin Group" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_ERROR_UNIQUE_ALIAS="Another Joomla Plugin Group has the same alias." +COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Joomla Plugin Group has the same alias ." COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_ID="Id" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_MODIFIED_BY_DESC="The last user that modified this Joomla Plugin Group." COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_MODIFIED_BY_LABEL="Modified By" @@ -6651,6 +6919,7 @@ COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_CREATED_DATE_DESC="The date this Joom COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_CREATED_DATE_LABEL="Created Date" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_EDIT="Editing the Joomla Plugin Updates" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_ERROR_UNIQUE_ALIAS="Another Joomla Plugin Updates has the same alias." +COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Joomla Plugin Updates has the same alias ." COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_ID="Id" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_JOOMLA_PLUGIN_LABEL="Joomla Plugins" COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_MODIFIED_BY_DESC="The last user that modified this Joomla Plugin Updates." @@ -6723,6 +6992,9 @@ COM_COMPONENTBUILDER_LANGUAGES_EDIT_STATE="Languages Edit State" COM_COMPONENTBUILDER_LANGUAGES_EDIT_STATE_DESC="Allows the users in this group to update the state of the language" COM_COMPONENTBUILDER_LANGUAGES_EDIT_VERSION="Languages Edit Version" COM_COMPONENTBUILDER_LANGUAGES_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version languages" +COM_COMPONENTBUILDER_LANGUAGES_EMPTYSTATE_BUTTON_ADD="Add your first language" +COM_COMPONENTBUILDER_LANGUAGES_EMPTYSTATE_CONTENT="A list of languages." +COM_COMPONENTBUILDER_LANGUAGES_EMPTYSTATE_TITLE="No languages have been created yet." COM_COMPONENTBUILDER_LANGUAGES_EXPORT="Languages Export" COM_COMPONENTBUILDER_LANGUAGES_EXPORT_DESC="Allows the users in this group to export export languages" COM_COMPONENTBUILDER_LANGUAGES_IMPORT="Languages Import" @@ -6757,6 +7029,7 @@ COM_COMPONENTBUILDER_LANGUAGE_CREATED_DATE_LABEL="Created Date" COM_COMPONENTBUILDER_LANGUAGE_DETAILS="Details" COM_COMPONENTBUILDER_LANGUAGE_EDIT="Editing the Language" COM_COMPONENTBUILDER_LANGUAGE_ERROR_UNIQUE_ALIAS="Another Language has the same alias." +COM_COMPONENTBUILDER_LANGUAGE_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Language has the same alias ." COM_COMPONENTBUILDER_LANGUAGE_ID="Id" COM_COMPONENTBUILDER_LANGUAGE_LANGTAG_DESCRIPTION="Enter the language tag – example: en-GB for English (UK). This should be the exact prefix used for the language installed or to be installed." COM_COMPONENTBUILDER_LANGUAGE_LANGTAG_HINT="en-GB" @@ -6798,6 +7071,9 @@ COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS_EDIT_STATE="Language Translations Edi COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS_EDIT_STATE_DESC="Allows the users in this group to update the state of the language translation" COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS_EDIT_VERSION="Language Translations Edit Version" COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version language translations" +COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS_EMPTYSTATE_BUTTON_ADD="Add your first language translation" +COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS_EMPTYSTATE_CONTENT="A list of language translations." +COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS_EMPTYSTATE_TITLE="No language translations have been created yet." COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS_EXPORT="Language Translations Export" COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS_EXPORT_DESC="Allows the users in this group to export export language translations" COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS_IMPORT="Language Translations Import" @@ -6831,6 +7107,7 @@ COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_CREATED_DATE_LABEL="Created Date" COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_DETAILS="Details" COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_EDIT="Editing the Language Translation" COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_ERROR_UNIQUE_ALIAS="Another Language Translation has the same alias." +COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Language Translation has the same alias ." COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_ID="Id" COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_LANGUAGE="Language" COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_LANGUAGE_LABEL="Language" @@ -6880,6 +7157,9 @@ COM_COMPONENTBUILDER_LAYOUTS_EDIT_STATE="Layouts Edit State" COM_COMPONENTBUILDER_LAYOUTS_EDIT_STATE_DESC="Allows the users in this group to update the state of the layout" COM_COMPONENTBUILDER_LAYOUTS_EDIT_VERSION="Layouts Edit Version" COM_COMPONENTBUILDER_LAYOUTS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version layouts" +COM_COMPONENTBUILDER_LAYOUTS_EMPTYSTATE_BUTTON_ADD="Add your first layout" +COM_COMPONENTBUILDER_LAYOUTS_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_LAYOUTS_EMPTYSTATE_TITLE="No layouts have been created yet." COM_COMPONENTBUILDER_LAYOUTS_EXPORT="Layouts Export" COM_COMPONENTBUILDER_LAYOUTS_EXPORT_DESC="Allows the users in this group to export export layouts" COM_COMPONENTBUILDER_LAYOUTS_IMPORT="Layouts Import" @@ -6928,6 +7208,7 @@ COM_COMPONENTBUILDER_LAYOUT_DYNAMIC_VALUES_DESCRIPTION="Only use dynamic get val COM_COMPONENTBUILDER_LAYOUT_DYNAMIC_VALUES_LABEL="Dynamic Values" COM_COMPONENTBUILDER_LAYOUT_EDIT="Editing the Layout" COM_COMPONENTBUILDER_LAYOUT_ERROR_UNIQUE_ALIAS="Another Layout has the same alias." +COM_COMPONENTBUILDER_LAYOUT_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Layout has the same alias ." COM_COMPONENTBUILDER_LAYOUT_GET_SNIPPETS_BUTTON_ACCESS="Layout Get Snippets Button Access" COM_COMPONENTBUILDER_LAYOUT_GET_SNIPPETS_BUTTON_ACCESS_DESC="Allows the users in this group to access the get snippets button." COM_COMPONENTBUILDER_LAYOUT_ID="Id" @@ -6996,6 +7277,9 @@ COM_COMPONENTBUILDER_LIBRARIES_CONFIG_EDIT_STATE="Libraries Config Edit State" COM_COMPONENTBUILDER_LIBRARIES_CONFIG_EDIT_STATE_DESC="Allows the users in this group to update the state of the library config" COM_COMPONENTBUILDER_LIBRARIES_CONFIG_EDIT_VERSION="Libraries Config Edit Version" COM_COMPONENTBUILDER_LIBRARIES_CONFIG_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version libraries config" +COM_COMPONENTBUILDER_LIBRARIES_CONFIG_EMPTYSTATE_BUTTON_ADD="Add your first library config" +COM_COMPONENTBUILDER_LIBRARIES_CONFIG_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_LIBRARIES_CONFIG_EMPTYSTATE_TITLE="No libraries config have been created yet." COM_COMPONENTBUILDER_LIBRARIES_CONFIG_N_ITEMS_ARCHIVED="%s Libraries Config archived." COM_COMPONENTBUILDER_LIBRARIES_CONFIG_N_ITEMS_ARCHIVED_1="%s Library Config archived." COM_COMPONENTBUILDER_LIBRARIES_CONFIG_N_ITEMS_CHECKED_IN_0="No Library Config successfully checked in." @@ -7029,6 +7313,9 @@ COM_COMPONENTBUILDER_LIBRARIES_EDIT_STATE="Libraries Edit State" COM_COMPONENTBUILDER_LIBRARIES_EDIT_STATE_DESC="Allows the users in this group to update the state of the library" COM_COMPONENTBUILDER_LIBRARIES_EDIT_VERSION="Libraries Edit Version" COM_COMPONENTBUILDER_LIBRARIES_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version libraries" +COM_COMPONENTBUILDER_LIBRARIES_EMPTYSTATE_BUTTON_ADD="Add your first library" +COM_COMPONENTBUILDER_LIBRARIES_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_LIBRARIES_EMPTYSTATE_TITLE="No libraries have been created yet." COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS="Libraries Files, Folders & URLs" COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS_ACCESS="Libraries Files Folders Urls Access" COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS_ACCESS_DESC="Allows the users in this group to access access libraries files folders urls" @@ -7052,6 +7339,9 @@ COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS_EDIT_STATE="Libraries Files Fo COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS_EDIT_STATE_DESC="Allows the users in this group to update the state of the library files folders urls" COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS_EDIT_VERSION="Libraries Files Folders Urls Edit Version" COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version libraries files folders urls" +COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS_EMPTYSTATE_BUTTON_ADD="Add your first library files, folders & urls" +COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS_EMPTYSTATE_TITLE="No libraries files, folders & urls have been created yet." COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS_N_ITEMS_ARCHIVED="%s Libraries Files, Folders & URLs archived." COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS_N_ITEMS_ARCHIVED_1="%s Library Files, Folders & URLs archived." COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS_N_ITEMS_CHECKED_IN_0="No Library Files, Folders & URLs successfully checked in." @@ -7112,6 +7402,7 @@ COM_COMPONENTBUILDER_LIBRARY_CONFIG_CUSTOM_VALUE_HINT="Custom Value Here" COM_COMPONENTBUILDER_LIBRARY_CONFIG_CUSTOM_VALUE_LABEL="Custom Value" COM_COMPONENTBUILDER_LIBRARY_CONFIG_EDIT="Editing the Library Config" COM_COMPONENTBUILDER_LIBRARY_CONFIG_ERROR_UNIQUE_ALIAS="Another Library Config has the same alias." +COM_COMPONENTBUILDER_LIBRARY_CONFIG_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Library Config has the same alias ." COM_COMPONENTBUILDER_LIBRARY_CONFIG_FIELD="Field" COM_COMPONENTBUILDER_LIBRARY_CONFIG_FIELD_DESCRIPTION="Select a field" COM_COMPONENTBUILDER_LIBRARY_CONFIG_FIELD_LABEL="Field" @@ -7145,6 +7436,7 @@ COM_COMPONENTBUILDER_LIBRARY_DESCRIPTION_LABEL="Description" COM_COMPONENTBUILDER_LIBRARY_DESCRIPTION_MESSAGE="Error! Please add description here." COM_COMPONENTBUILDER_LIBRARY_EDIT="Editing the Library" COM_COMPONENTBUILDER_LIBRARY_ERROR_UNIQUE_ALIAS="Another Library has the same alias." +COM_COMPONENTBUILDER_LIBRARY_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Library has the same alias ." COM_COMPONENTBUILDER_LIBRARY_EXACT_LENGTH_ONLY_4_TEXT_FIELD="Exact Length (only 4 text_field)" COM_COMPONENTBUILDER_LIBRARY_EXCLUDE="exclude" COM_COMPONENTBUILDER_LIBRARY_FIELD_OPTIONS_HINT="Options here" @@ -7170,6 +7462,7 @@ COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_CREATED_DATE_LABEL="Created Date COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_DEFAULT_LINK="Default (link)" COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_EDIT="Editing the Library Files, Folders & URLs" COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_ERROR_UNIQUE_ALIAS="Another Library Files, Folders & URLs has the same alias." +COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Library Files, Folders & URLs has the same alias ." COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_FILE="File" COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_FILEPATH_DESCRIPTION="Full System Path" COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_FILEPATH_HINT="/home/user/folder/file.php" @@ -7359,7 +7652,6 @@ COM_COMPONENTBUILDER_NONE="None" COM_COMPONENTBUILDER_NONE_DB="None DB" COM_COMPONENTBUILDER_NONE_FOUND="None found" COM_COMPONENTBUILDER_NONE_SELECTED="None selected" -COM_COMPONENTBUILDER_NOTICE_BOARD="Notice Board" COM_COMPONENTBUILDER_NOTRANSLATION="no-translation" COM_COMPONENTBUILDER_NOT_FOUND_OR_ACCESS_DENIED="Not found, or access denied." COM_COMPONENTBUILDER_NOT_SAVED="Not saved!" @@ -7371,9 +7663,11 @@ COM_COMPONENTBUILDER_NO_COMPONENTS_FOUND="No Components Found" COM_COMPONENTBUILDER_NO_COMPONENTS_WERE_SELECTED_PLEASE_MAKE_A_SELECTION_AND_TRY_AGAIN="No components were selected, please make a selection and try again!" COM_COMPONENTBUILDER_NO_COMPONENT_DETAILS_FOUND_SO_IT_IS_NOT_SAFE_TO_CONTINUE="No component details found, so it is not safe to continue!" COM_COMPONENTBUILDER_NO_COMPONENT_WAS_SELECTED_PLEASE_MAKE_A_SELECTION_OF_ONE_COMPONENT_AND_TRY_AGAIN="No component was selected, please make a selection of one component and try again!" +COM_COMPONENTBUILDER_NO_CREATE_TABLE_WERE_FOUND_PLEASE_CHECK_YOUR_SQL="No "CREATE TABLE.." were found, please check your sql." COM_COMPONENTBUILDER_NO_CRONJOB_PATH_FOUND_FOR_S="No cronjob path found for (%s)" COM_COMPONENTBUILDER_NO_CRONJOB_PATH_FOUND_SINCE_INCORRECT_TYPE_REQUESTED="No cronjob path found since incorrect type requested." COM_COMPONENTBUILDER_NO_DESCRIPTION_FOUND="No description found." +COM_COMPONENTBUILDER_NO_FIELDS_WHERE_SELECTED="No fields where selected!" COM_COMPONENTBUILDER_NO_FILES_LINKED="No Files Linked" COM_COMPONENTBUILDER_NO_FOUND="No Found" COM_COMPONENTBUILDER_NO_INSTANCES_WHERE_FOUND_IN_S="No instances where found in %s" @@ -7440,6 +7734,9 @@ COM_COMPONENTBUILDER_PLACEHOLDERS_EDIT_STATE="Placeholders Edit State" COM_COMPONENTBUILDER_PLACEHOLDERS_EDIT_STATE_DESC="Allows the users in this group to update the state of the placeholder" COM_COMPONENTBUILDER_PLACEHOLDERS_EDIT_VERSION="Placeholders Edit Version" COM_COMPONENTBUILDER_PLACEHOLDERS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version placeholders" +COM_COMPONENTBUILDER_PLACEHOLDERS_EMPTYSTATE_BUTTON_ADD="Add your first placeholder" +COM_COMPONENTBUILDER_PLACEHOLDERS_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_PLACEHOLDERS_EMPTYSTATE_TITLE="No placeholders have been created yet." COM_COMPONENTBUILDER_PLACEHOLDERS_EXPORT="Placeholders Export" COM_COMPONENTBUILDER_PLACEHOLDERS_EXPORT_DESC="Allows the users in this group to export export placeholders" COM_COMPONENTBUILDER_PLACEHOLDERS_IMPORT="Placeholders Import" @@ -7474,6 +7771,7 @@ COM_COMPONENTBUILDER_PLACEHOLDER_CREATED_DATE_LABEL="Created Date" COM_COMPONENTBUILDER_PLACEHOLDER_DETAILS="Details" COM_COMPONENTBUILDER_PLACEHOLDER_EDIT="Editing the Placeholder" COM_COMPONENTBUILDER_PLACEHOLDER_ERROR_UNIQUE_ALIAS="Another Placeholder has the same alias." +COM_COMPONENTBUILDER_PLACEHOLDER_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Placeholder has the same alias ." COM_COMPONENTBUILDER_PLACEHOLDER_ID="Id" COM_COMPONENTBUILDER_PLACEHOLDER_MODIFIED_BY_DESC="The last user that modified this Placeholder." COM_COMPONENTBUILDER_PLACEHOLDER_MODIFIED_BY_LABEL="Modified By" @@ -7500,12 +7798,13 @@ COM_COMPONENTBUILDER_PLACEHOLDER_VERSION_LABEL="Version" COM_COMPONENTBUILDER_PLACES_ACROSS_JCB_WHERE_THIS_S_IS_LINKED="Places across JCB where this %s is linked." COM_COMPONENTBUILDER_PLEASE_ADD_FILES_TO_S="Please add files to (%s)" COM_COMPONENTBUILDER_PLEASE_ADD_FOLDERS_TO_S="Please add folders to (%s)" -COM_COMPONENTBUILDER_PLEASE_CHECK_AGAIN_LATTER="Please check again latter." +COM_COMPONENTBUILDER_PLEASE_CHECK_AGAIN_LATER="Please check again later" COM_COMPONENTBUILDER_PLEASE_CHECK_AGAIN_SOON_ANDOR_FOLLOW_THE_PROGRESS_ON_SGITVDMDEVA="Please check again soon! and/or follow the progress on %sgit.vdm.dev." COM_COMPONENTBUILDER_PLEASE_FIRST_MAKE_A_SELECTION_FROM_THE_LIST="Please first make a selection from the list." COM_COMPONENTBUILDER_PLEASE_NOTE_THAT_THIS_PACKAGE_BHAS_NOB_CHECKSUM_VALIDATION="Please note that this package has no checksum validation!" COM_COMPONENTBUILDER_PLEASE_SELECT_A_COMPONENT_THAT_YOU_WOULD_LIKE_TO_COMPILE="Please select a component that you would like to compile." COM_COMPONENTBUILDER_PLEASE_TRY_AGAIN_LATER="Please try again later" +COM_COMPONENTBUILDER_PLEASE_TRY_AGAIN_THIS_ERROR_USUALY_HAPPENS_IF_IT_IS_A_NEW_COMPONENT_BEACUES_WE_NEED_A_COMPONENT_ID_TO_DO_THIS_BUILD_WITH_YOUR_SQL_DUMP="Please try again, this error usualy happens if it is a new component, beacues we need a component ID to do this build with your sql dump." COM_COMPONENTBUILDER_PLEASE_WAIT="Please wait!" COM_COMPONENTBUILDER_PLEASE_WAIT_LOADING="Please wait, loading" COM_COMPONENTBUILDER_PLUGIN="Plugin" @@ -7538,6 +7837,9 @@ COM_COMPONENTBUILDER_POWERS_EDIT_STATE="Powers Edit State" COM_COMPONENTBUILDER_POWERS_EDIT_STATE_DESC="Allows the users in this group to update the state of the power" COM_COMPONENTBUILDER_POWERS_EDIT_VERSION="Powers Edit Version" COM_COMPONENTBUILDER_POWERS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version powers" +COM_COMPONENTBUILDER_POWERS_EMPTYSTATE_BUTTON_ADD="Add your first power" +COM_COMPONENTBUILDER_POWERS_EMPTYSTATE_CONTENT="Superpowers of Component Builder" +COM_COMPONENTBUILDER_POWERS_EMPTYSTATE_TITLE="No powers have been created yet." COM_COMPONENTBUILDER_POWERS_NAME="Name" COM_COMPONENTBUILDER_POWERS_N_ITEMS_ARCHIVED="%s Powers archived." COM_COMPONENTBUILDER_POWERS_N_ITEMS_ARCHIVED_1="%s Power archived." @@ -7590,6 +7892,7 @@ COM_COMPONENTBUILDER_POWER_DESCRIPTION_HINT="Add Description Here" COM_COMPONENTBUILDER_POWER_DESCRIPTION_LABEL="Description" COM_COMPONENTBUILDER_POWER_EDIT="Editing the Power" COM_COMPONENTBUILDER_POWER_ERROR_UNIQUE_ALIAS="Another Power has the same alias." +COM_COMPONENTBUILDER_POWER_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Power has the same alias ." COM_COMPONENTBUILDER_POWER_EXTENDS_CUSTOM_DESCRIPTION="The custom class, this class should extend" COM_COMPONENTBUILDER_POWER_EXTENDS_CUSTOM_LABEL="Extends - Custom" COM_COMPONENTBUILDER_POWER_EXTENDS_CUSTOM_MESSAGE="Error! Please add the custom class, this class should extend." @@ -7685,6 +7988,7 @@ COM_COMPONENTBUILDER_POWER_VERSION_DESC="A count of the number of times this Pow COM_COMPONENTBUILDER_POWER_VERSION_LABEL="Version" COM_COMPONENTBUILDER_POWER_YES="Yes" COM_COMPONENTBUILDER_PPOWER_BGUIDSB_NOT_FOUNDP="

    Power guid:%s not found!

    " +COM_COMPONENTBUILDER_PRE_RELEASE="Pre Release" COM_COMPONENTBUILDER_PROPERTIES="Properties" COM_COMPONENTBUILDER_PROPERTIESBR_SMALLHERE_YOU_CAN_SET_THE_PROPERTIES_FOR_THIS_FIELDSMALL="Properties
    Here you can set the properties for this field." COM_COMPONENTBUILDER_PROPERTY="Property" @@ -7696,7 +8000,6 @@ COM_COMPONENTBUILDER_PS_NAMING_MISMATCH_ERROR_SPPTHE_S_NAME_IS_BSB_AND_THE_ENDIN COM_COMPONENTBUILDER_PUBLIC_ACCESS="Public Access" COM_COMPONENTBUILDER_PUBLISHED="Published" COM_COMPONENTBUILDER_PUBLISHING="Publishing" -COM_COMPONENTBUILDER_README="Readme" COM_COMPONENTBUILDER_READY_TO_COMPILE_A_COMPONENT="Ready to compile a component" COM_COMPONENTBUILDER_REFRESH="Refresh" COM_COMPONENTBUILDER_REGEX_SEARCH="Regex Search" @@ -7707,11 +8010,13 @@ COM_COMPONENTBUILDER_REPLACE="Replace" COM_COMPONENTBUILDER_REPLACED_WITH="replaced with" COM_COMPONENTBUILDER_REPLACE_PROCESS_COMPLETE="replace process complete" COM_COMPONENTBUILDER_REPORT_AN_ISSUE_BSB="Report an issue: %s" +COM_COMPONENTBUILDER_REQUIRED_FIELDS_MISSING_IN_THE_BMYSQL_TABLES_SOURCE_MAPB_SELECTIONBR_S="Required fields missing in the MySQL -> Tables -> Source Map selection:
    %s" COM_COMPONENTBUILDER_REQUIRES_THE_VALUE_ENTERED_BE_ONE_OF_THE_OPTIONS_IN_AN_ELEMENT_OF_TYPEQUOTLISTQUOT_THAT_IS_THAT_THE_ELEMENT_IS_A_SELECT_LIST="Requires the value entered be one of the options in an element of type="list": that is, that the element is a select list." COM_COMPONENTBUILDER_REQUIRES_THE_VALUE_TO_BE_A_TELEPHONE_NUMBER_COMPLYING_WITH_THE_STANDARDS_OF_NANPA_ITUT_TRECEONE_HUNDRED_AND_SIXTY_FOUR_OR_IETF_RFCFOUR_THOUSAND_NINE_HUNDRED_AND_THIRTY_THREE="Requires the value to be a Telephone number complying with the standards of nanpa, ITU-T T-REC-E.164 or ietf rfc4933." COM_COMPONENTBUILDER_REQUIRES_THE_VALUE_TO_BE_THE_SAME_AS_THAT_HELD_IN_THE_FIELD_NAMED_QUOTFIELDQUOT_EGS="Requires the value to be the same as that held in the field named "field", eg:%s" COM_COMPONENTBUILDER_RESET="Reset" COM_COMPONENTBUILDER_RESET_FAILED="Reset Failed!" +COM_COMPONENTBUILDER_REVERTED_THE_B_ASSETSB_TABLE_RULES_COLUMN_BACK_TO_ITS_DEFAULT_SIZE_OF_VARCHARFIVE_THOUSAND_ONE_HUNDRED_AND_TWENTY="Reverted the #__assets table rules column back to its default size of varchar(5120)" COM_COMPONENTBUILDER_REVERT_ALL_AHEAD_SNIPPETS="Revert All Ahead Snippets" COM_COMPONENTBUILDER_RIGHT_IN_TAB="Right in Tab" COM_COMPONENTBUILDER_RIGHT_OF_TABS="Right of Tabs" @@ -7781,6 +8086,9 @@ COM_COMPONENTBUILDER_SERVERS_EDIT_STATE="Servers Edit State" COM_COMPONENTBUILDER_SERVERS_EDIT_STATE_DESC="Allows the users in this group to update the state of the server" COM_COMPONENTBUILDER_SERVERS_EDIT_VERSION="Servers Edit Version" COM_COMPONENTBUILDER_SERVERS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version servers" +COM_COMPONENTBUILDER_SERVERS_EMPTYSTATE_BUTTON_ADD="Add your first server" +COM_COMPONENTBUILDER_SERVERS_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_SERVERS_EMPTYSTATE_TITLE="No servers have been created yet." COM_COMPONENTBUILDER_SERVERS_EXPORT="Servers Export" COM_COMPONENTBUILDER_SERVERS_EXPORT_DESC="Allows the users in this group to export export servers" COM_COMPONENTBUILDER_SERVERS_IMPORT="Servers Import" @@ -7817,6 +8125,7 @@ COM_COMPONENTBUILDER_SERVER_CREATED_DATE_LABEL="Created Date" COM_COMPONENTBUILDER_SERVER_DETAILS="Details" COM_COMPONENTBUILDER_SERVER_EDIT="Editing the Server" COM_COMPONENTBUILDER_SERVER_ERROR_UNIQUE_ALIAS="Another Server has the same alias." +COM_COMPONENTBUILDER_SERVER_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Server has the same alias ." COM_COMPONENTBUILDER_SERVER_FTP="FTP" COM_COMPONENTBUILDER_SERVER_HOST_DESCRIPTION="Add the server host name/IP here" COM_COMPONENTBUILDER_SERVER_HOST_HINT="yourhost.com" @@ -7921,6 +8230,9 @@ COM_COMPONENTBUILDER_SITE_VIEWS_EDIT_STATE="Site Views Edit State" COM_COMPONENTBUILDER_SITE_VIEWS_EDIT_STATE_DESC="Allows the users in this group to update the state of the site view" COM_COMPONENTBUILDER_SITE_VIEWS_EDIT_VERSION="Site Views Edit Version" COM_COMPONENTBUILDER_SITE_VIEWS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version site views" +COM_COMPONENTBUILDER_SITE_VIEWS_EMPTYSTATE_BUTTON_ADD="Add your first site view" +COM_COMPONENTBUILDER_SITE_VIEWS_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_SITE_VIEWS_EMPTYSTATE_TITLE="No site views have been created yet." COM_COMPONENTBUILDER_SITE_VIEWS_EXPORT="Site Views Export" COM_COMPONENTBUILDER_SITE_VIEWS_EXPORT_DESC="Allows the users in this group to export export site views" COM_COMPONENTBUILDER_SITE_VIEWS_IMPORT="Site Views Import" @@ -7956,8 +8268,8 @@ COM_COMPONENTBUILDER_SITE_VIEW_ADD_JAVASCRIPT_FILE_LABEL="Add JavaScript (file)" COM_COMPONENTBUILDER_SITE_VIEW_ADD_JS_DOCUMENT_LABEL="Add JS (custom document script)" COM_COMPONENTBUILDER_SITE_VIEW_ADD_PHP_AJAX_LABEL="Add PHP (AJAX)" COM_COMPONENTBUILDER_SITE_VIEW_ADD_PHP_DOCUMENT_LABEL="Add PHP (custom document script)" -COM_COMPONENTBUILDER_SITE_VIEW_ADD_PHP_JVIEW_DISPLAY_LABEL="Add PHP (custom JViewLegacy display)" -COM_COMPONENTBUILDER_SITE_VIEW_ADD_PHP_JVIEW_LABEL="Add PHP (custom JViewLegacy methods)" +COM_COMPONENTBUILDER_SITE_VIEW_ADD_PHP_JVIEW_DISPLAY_LABEL="Add PHP (custom HtmlView display)" +COM_COMPONENTBUILDER_SITE_VIEW_ADD_PHP_JVIEW_LABEL="Add PHP (custom HtmlView methods)" COM_COMPONENTBUILDER_SITE_VIEW_ADD_PHP_VIEW_LABEL="Add PHP (custom view script)" COM_COMPONENTBUILDER_SITE_VIEW_AJAX_INPUT_LABEL="Ajax Input" COM_COMPONENTBUILDER_SITE_VIEW_ALLOW_ZERO_DESCRIPTION="null & zero values" @@ -8072,6 +8384,7 @@ COM_COMPONENTBUILDER_SITE_VIEW_ENVELOPE="Envelope" COM_COMPONENTBUILDER_SITE_VIEW_ENVELOPE_OPENED="Envelope Opened" COM_COMPONENTBUILDER_SITE_VIEW_EQUALIZER="Equalizer" COM_COMPONENTBUILDER_SITE_VIEW_ERROR_UNIQUE_ALIAS="Another Site View has the same alias." +COM_COMPONENTBUILDER_SITE_VIEW_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Site View has the same alias ." COM_COMPONENTBUILDER_SITE_VIEW_EXIT="Exit" COM_COMPONENTBUILDER_SITE_VIEW_EXPAND="Expand" COM_COMPONENTBUILDER_SITE_VIEW_EXPAND_2="Expand 2" @@ -8351,6 +8664,9 @@ COM_COMPONENTBUILDER_SNIPPETS_EDIT_STATE="Snippets Edit State" COM_COMPONENTBUILDER_SNIPPETS_EDIT_STATE_DESC="Allows the users in this group to update the state of the snippet" COM_COMPONENTBUILDER_SNIPPETS_EDIT_VERSION="Snippets Edit Version" COM_COMPONENTBUILDER_SNIPPETS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version snippets" +COM_COMPONENTBUILDER_SNIPPETS_EMPTYSTATE_BUTTON_ADD="Add your first snippet" +COM_COMPONENTBUILDER_SNIPPETS_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_SNIPPETS_EMPTYSTATE_TITLE="No snippets have been created yet." COM_COMPONENTBUILDER_SNIPPETS_EXPORT="Snippets Export" COM_COMPONENTBUILDER_SNIPPETS_EXPORT_DESC="Allows the users in this group to export export snippets" COM_COMPONENTBUILDER_SNIPPETS_IMPORT="Snippets Import" @@ -8404,6 +8720,7 @@ COM_COMPONENTBUILDER_SNIPPET_DESCRIPTION_LABEL="Description" COM_COMPONENTBUILDER_SNIPPET_DETAILS="Details" COM_COMPONENTBUILDER_SNIPPET_EDIT="Editing the Snippet" COM_COMPONENTBUILDER_SNIPPET_ERROR_UNIQUE_ALIAS="Another Snippet has the same alias." +COM_COMPONENTBUILDER_SNIPPET_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Snippet has the same alias ." COM_COMPONENTBUILDER_SNIPPET_GET_SNIPPETS_BUTTON_ACCESS="Snippet Get Snippets Button Access" COM_COMPONENTBUILDER_SNIPPET_GET_SNIPPETS_BUTTON_ACCESS_DESC="Allows the users in this group to access the get snippets button." COM_COMPONENTBUILDER_SNIPPET_GUID_DESCRIPTION="Globally Unique Identifier" @@ -8456,6 +8773,9 @@ COM_COMPONENTBUILDER_SNIPPET_TYPES_EDIT_STATE="Snippet Types Edit State" COM_COMPONENTBUILDER_SNIPPET_TYPES_EDIT_STATE_DESC="Allows the users in this group to update the state of the snippet type" COM_COMPONENTBUILDER_SNIPPET_TYPES_EDIT_VERSION="Snippet Types Edit Version" COM_COMPONENTBUILDER_SNIPPET_TYPES_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version snippet types" +COM_COMPONENTBUILDER_SNIPPET_TYPES_EMPTYSTATE_BUTTON_ADD="Add your first snippet type" +COM_COMPONENTBUILDER_SNIPPET_TYPES_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_SNIPPET_TYPES_EMPTYSTATE_TITLE="No snippet types have been created yet." COM_COMPONENTBUILDER_SNIPPET_TYPES_N_ITEMS_ARCHIVED="%s Snippet Types archived." COM_COMPONENTBUILDER_SNIPPET_TYPES_N_ITEMS_ARCHIVED_1="%s Snippet Type archived." COM_COMPONENTBUILDER_SNIPPET_TYPES_N_ITEMS_CHECKED_IN_0="No Snippet Type successfully checked in." @@ -8487,6 +8807,7 @@ COM_COMPONENTBUILDER_SNIPPET_TYPE_DESCRIPTION_MESSAGE="Error! Please add descrip COM_COMPONENTBUILDER_SNIPPET_TYPE_DETAILS="Details" COM_COMPONENTBUILDER_SNIPPET_TYPE_EDIT="Editing the Snippet Type" COM_COMPONENTBUILDER_SNIPPET_TYPE_ERROR_UNIQUE_ALIAS="Another Snippet Type has the same alias." +COM_COMPONENTBUILDER_SNIPPET_TYPE_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Snippet Type has the same alias ." COM_COMPONENTBUILDER_SNIPPET_TYPE_ID="Id" COM_COMPONENTBUILDER_SNIPPET_TYPE_LABEL="Type" COM_COMPONENTBUILDER_SNIPPET_TYPE_MODIFIED_BY_DESC="The last user that modified this Snippet Type." @@ -8602,6 +8923,9 @@ COM_COMPONENTBUILDER_TEMPLATES_EDIT_STATE="Templates Edit State" COM_COMPONENTBUILDER_TEMPLATES_EDIT_STATE_DESC="Allows the users in this group to update the state of the template" COM_COMPONENTBUILDER_TEMPLATES_EDIT_VERSION="Templates Edit Version" COM_COMPONENTBUILDER_TEMPLATES_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version templates" +COM_COMPONENTBUILDER_TEMPLATES_EMPTYSTATE_BUTTON_ADD="Add your first template" +COM_COMPONENTBUILDER_TEMPLATES_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_TEMPLATES_EMPTYSTATE_TITLE="No templates have been created yet." COM_COMPONENTBUILDER_TEMPLATES_EXPORT="Templates Export" COM_COMPONENTBUILDER_TEMPLATES_EXPORT_DESC="Allows the users in this group to export export templates" COM_COMPONENTBUILDER_TEMPLATES_IMPORT="Templates Import" @@ -8650,6 +8974,7 @@ COM_COMPONENTBUILDER_TEMPLATE_DYNAMIC_VALUES_DESCRIPTION="Only use dynamic get v COM_COMPONENTBUILDER_TEMPLATE_DYNAMIC_VALUES_LABEL="Dynamic Values" COM_COMPONENTBUILDER_TEMPLATE_EDIT="Editing the Template" COM_COMPONENTBUILDER_TEMPLATE_ERROR_UNIQUE_ALIAS="Another Template has the same alias." +COM_COMPONENTBUILDER_TEMPLATE_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Template has the same alias ." COM_COMPONENTBUILDER_TEMPLATE_GET_SNIPPETS_BUTTON_ACCESS="Template Get Snippets Button Access" COM_COMPONENTBUILDER_TEMPLATE_GET_SNIPPETS_BUTTON_ACCESS_DESC="Allows the users in this group to access the get snippets button." COM_COMPONENTBUILDER_TEMPLATE_ID="Id" @@ -8736,6 +9061,7 @@ COM_COMPONENTBUILDER_THE_COMPONENT_MODULES="The component modules" COM_COMPONENTBUILDER_THE_COMPONENT_MYSQL_TWEAKS="The component mysql tweaks" COM_COMPONENTBUILDER_THE_COMPONENT_PLACEHOLDERS="The component placeholders" COM_COMPONENTBUILDER_THE_COMPONENT_PLUGINS="The component plugins" +COM_COMPONENTBUILDER_THE_COMPONENT_SITE_ROUTER="The component site router" COM_COMPONENTBUILDER_THE_COMPONENT_SITE_VIEWS="The component site views" COM_COMPONENTBUILDER_THE_COMPONENT_UPDATES="The component updates" COM_COMPONENTBUILDER_THE_COMPONENT_WITH_ALL_LINKED_ADMIN_VIEWS_FIELDS_LINKED_TO_ADMIN_VIEWS_CUSTOM_ADMIN_VIEWS_SITE_VIEWS_TEMPLATES_AND_LAYOUTS_WERE_CLONED_SUCCESSFUL="The Component with all linked admin views, fields linked to admin views, custom admin views, site views, templates and layouts were cloned successful!" @@ -8821,6 +9147,7 @@ COM_COMPONENTBUILDER_TYPE_COMPONENT_MODULES="Component Modules" COM_COMPONENTBUILDER_TYPE_COMPONENT_MYSQL_TWEAKS="Component mysql Tweaks" COM_COMPONENTBUILDER_TYPE_COMPONENT_PLACEHOLDERS="Component Placeholders" COM_COMPONENTBUILDER_TYPE_COMPONENT_PLUGINS="Component Plugins" +COM_COMPONENTBUILDER_TYPE_COMPONENT_ROUTER="Component Router" COM_COMPONENTBUILDER_TYPE_COMPONENT_SITE_VIEWS="Component Site Views" COM_COMPONENTBUILDER_TYPE_COMPONENT_UPDATES="Component Updates" COM_COMPONENTBUILDER_TYPE_CUSTOM_ADMIN_VIEW="Custom Admin View" @@ -8893,6 +9220,9 @@ COM_COMPONENTBUILDER_VALIDATION_RULES_EDIT_STATE="Validation Rules Edit State" COM_COMPONENTBUILDER_VALIDATION_RULES_EDIT_STATE_DESC="Allows the users in this group to update the state of the validation rule" COM_COMPONENTBUILDER_VALIDATION_RULES_EDIT_VERSION="Validation Rules Edit Version" COM_COMPONENTBUILDER_VALIDATION_RULES_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version validation rules" +COM_COMPONENTBUILDER_VALIDATION_RULES_EMPTYSTATE_BUTTON_ADD="Add your first validation rule" +COM_COMPONENTBUILDER_VALIDATION_RULES_EMPTYSTATE_CONTENT="" +COM_COMPONENTBUILDER_VALIDATION_RULES_EMPTYSTATE_TITLE="No validation rules have been created yet." COM_COMPONENTBUILDER_VALIDATION_RULES_EXPORT="Validation Rules Export" COM_COMPONENTBUILDER_VALIDATION_RULES_EXPORT_DESC="Allows the users in this group to export export validation rules" COM_COMPONENTBUILDER_VALIDATION_RULES_IMPORT="Validation Rules Import" @@ -8924,6 +9254,7 @@ COM_COMPONENTBUILDER_VALIDATION_RULE_CREATED_DATE_DESC="The date this Validation COM_COMPONENTBUILDER_VALIDATION_RULE_CREATED_DATE_LABEL="Created Date" COM_COMPONENTBUILDER_VALIDATION_RULE_EDIT="Editing the Validation Rule" COM_COMPONENTBUILDER_VALIDATION_RULE_ERROR_UNIQUE_ALIAS="Another Validation Rule has the same alias." +COM_COMPONENTBUILDER_VALIDATION_RULE_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Validation Rule has the same alias ." COM_COMPONENTBUILDER_VALIDATION_RULE_EXTENDS_FORMRULE="Extends FormRule" COM_COMPONENTBUILDER_VALIDATION_RULE_ID="Id" COM_COMPONENTBUILDER_VALIDATION_RULE_INHERIT_DESCRIPTION="Select an existing validation rule that you would like to adapt." @@ -8978,11 +9309,16 @@ COM_COMPONENTBUILDER_WE_FAILED_TO_MOVE_BSB="We failed to move %s!" COM_COMPONENTBUILDER_WE_FOUND_DYNAMIC_CODE_BALL_IN_ONE_LINEB_AND_IGNORED_IT_PLEASE_REVIEW_S_FOR_MORE_DETAILS="We found dynamic code all in one line, and ignored it! Please review (%s) for more details!" COM_COMPONENTBUILDER_WE_FOUND_SOME_INSTANCES_IN_S="We found some instances in %s" COM_COMPONENTBUILDER_WE_SUCCESSFULLY_MOVED_BSB="We successfully moved %s!" +COM_COMPONENTBUILDER_WE_WHERE_WAS_UNABLE_TO_TRANSFER_THE_COMPONENT_TO_THE_GIT_REPOSITORY="We where was unable to transfer the component to the git repository:" +COM_COMPONENTBUILDER_WE_WHERE_WAS_UNABLE_TO_TRANSFER_THE_COMPONENT_ZIP_FILE_TO_THE_BACKUP_FOLDER="We where was unable to transfer the component ZIP file to the backup folder:" +COM_COMPONENTBUILDER_WE_WHERE_WAS_UNABLE_TO_TRANSFER_THE_S_MODULE_TO_THE_GIT_REPOSITORY="We where was unable to transfer the (%s) module to the git repository:" +COM_COMPONENTBUILDER_WE_WHERE_WAS_UNABLE_TO_TRANSFER_THE_S_MODULE_ZIP_FILE_TO_THE_BACKUP_FOLDER="We where was unable to transfer the (%s) module zip file to the backup folder:" +COM_COMPONENTBUILDER_WE_WHERE_WAS_UNABLE_TO_TRANSFER_THE_S_PLUGIN_TO_THE_GIT_REPOSITORY="We where was unable to transfer the (%s) plugin to the git repository:" +COM_COMPONENTBUILDER_WE_WHERE_WAS_UNABLE_TO_TRANSFER_THE_S_PLUGIN_ZIP_FILE_TO_THE_BACKUP_FOLDER="We where was unable to transfer the (%s) plugin zip file to the backup folder:" COM_COMPONENTBUILDER_WHAT_VERSION_OF_JOOMLA_WOULD_YOU_LIKE_TO_TARGET="What version of Joomla would you like to target." COM_COMPONENTBUILDER_WHICH_TYPE_OF_INDENTATION_WOULD_YOU_LIKE_TO_USE_PLEASE_NOTE_THAT_THIS_DOES_NOT_YET_IMPACT_THE_STATIC_TEMPLATES="Which type of indentation would you like to use? Please note that this does not yet impact the static templates." COM_COMPONENTBUILDER_WHILE_WE_DOWNLOAD_ALL_TWENTY_SIX_COMPILER_GIF_ANIMATIONS_RANDOMLY_USED_IN_THE_COMPILER_GUI_DURING_COMPILATION="While we download all 26 compiler GIF animations randomly used in the compiler GUI during compilation" COM_COMPONENTBUILDER_WHOLE_WORD="Whole Word" -COM_COMPONENTBUILDER_WIKI="Wiki" COM_COMPONENTBUILDER_WITH="with" COM_COMPONENTBUILDER_WITHOUT_SUFFICIENT_SUPPORT_THE_FUTURE_OF_JOOMLA_COMPONENT_BUILDER_JCB_IS_IN_JEOPARDY_AS_A_VITAL_TOOL_FOR_PHP_PROGRAMMERS_IT_IS_CRUCIAL_TO_ENSURE_ITS_CONTINUED_DEVELOPMENT_AND_MAINTENANCE_BY_MAKING_A_BFINANCIAL_CONTRIBUTIONB_NO_MATTER_HOW_SMALL_YOU_ARE_HELPING_TO_SAFEGUARD_THE_FUTURE_OF_THIS_OPENSOURCE_PROJECT_NEGLECTING_TO_SUPPORT_JCB_COULD_RESULT_IN_ITS_DECLINE_AND_LOSS_AS_A_RESOURCE_FOR_THE_COMMUNITY="Without sufficient support, the future of Joomla Component Builder (JCB) is in jeopardy. As a vital tool for PHP programmers, it is crucial to ensure its continued development and maintenance. By making a financial contribution, no matter how small, you are helping to safeguard the future of this open-source project. Neglecting to support JCB could result in its decline and loss as a resource for the community." COM_COMPONENTBUILDER_WOULD_YOU_LIKE_TO_DO_A_REVERSE_SEARCH="Would you like to do a reverse search?" @@ -8993,6 +9329,8 @@ COM_COMPONENTBUILDER_YES="Yes" COM_COMPONENTBUILDER_YES_UPDATE_ALL="Yes! Update ALL" COM_COMPONENTBUILDER_YOUR_ARE_ABOUT_TO_UPDATE_BALLB_VALUES_THAT_CAN_BE_FOUND_IN_THE_DATABASE="Your are about to update ALL values that can be found in the database." COM_COMPONENTBUILDER_YOUR_ARE_ABOUT_TO_UPDATE_ROW="Your are about to update row" +COM_COMPONENTBUILDER_YOUR_COMPONENT_WILL_BE_COMPILED_TO_WORK_IN_JOOMLA_FIVE="Your component will be compiled to work in Joomla 5" +COM_COMPONENTBUILDER_YOUR_COMPONENT_WILL_BE_COMPILED_TO_WORK_IN_JOOMLA_FOUR="Your component will be compiled to work in Joomla 4" COM_COMPONENTBUILDER_YOUR_COMPONENT_WILL_BE_COMPILED_TO_WORK_IN_JOOMLA_THREE="Your component will be compiled to work in Joomla 3" COM_COMPONENTBUILDER_YOUR_DATA_IS_ENCRYPTED_WITH_A_AES_TWO_HUNDRED_AND_FIFTY_SIX_BIT_ENCRYPTION_USING_THE_ABOVE_THIRTY_TWO_CHARACTER_KEY="Your data is encrypted with a AES 256 bit encryption using the above 32 character key." COM_COMPONENTBUILDER_YOU_ARE_CURRENTLY_VIEWING_THE_TRASHED_ITEMS="You are currently viewing the trashed items." diff --git a/admin/language/en-GB/en-GB.com_componentbuilder.sys.ini b/admin/language/en-GB/en-GB.com_componentbuilder.sys.ini index b1d0e533b..bd4bdf763 100644 --- a/admin/language/en-GB/en-GB.com_componentbuilder.sys.ini +++ b/admin/language/en-GB/en-GB.com_componentbuilder.sys.ini @@ -391,6 +391,26 @@ COM_COMPONENTBUILDER_COMPONENTS_PLUGINS_EDIT_STATE="Components Plugins Edit Stat COM_COMPONENTBUILDER_COMPONENTS_PLUGINS_EDIT_STATE_DESC="Allows the users in this group to update the state of the component plugins" COM_COMPONENTBUILDER_COMPONENTS_PLUGINS_EDIT_VERSION="Components Plugins Edit Version" COM_COMPONENTBUILDER_COMPONENTS_PLUGINS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version components plugins" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_ACCESS="Components Routers Access" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_ACCESS_DESC="Allows the users in this group to access access components routers" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_BATCH_USE="Components Routers Batch Use" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_BATCH_USE_DESC="Allows the users in this group to use batch copy/update method of batch components routers" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_CREATE="Components Routers Create" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_CREATE_DESC="Allows the users in this group to create create components routers" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_DELETE="Components Routers Delete" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_DELETE_DESC="Allows the users in this group to delete delete components routers" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT="Components Routers Edit" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_CREATED_BY="Components Routers Edit Created By" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by components routers" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_CREATED_DATE="Components Routers Edit Created Date" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created components routers" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_DESC="Allows the users in this group to edit the component router" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_OWN="Components Routers Edit Own" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_OWN_DESC="Allows the users in this group to edit edit own components routers created by them" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_STATE="Components Routers Edit State" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_STATE_DESC="Allows the users in this group to update the state of the component router" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_VERSION="Components Routers Edit Version" +COM_COMPONENTBUILDER_COMPONENTS_ROUTERS_EDIT_VERSION_DESC="Allows the users in this group to edit versions of version components routers" COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS_ACCESS="Components Site Views Access" COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS_ACCESS_DESC="Allows the users in this group to access access components site views" COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS_BATCH_USE="Components Site Views Batch Use" @@ -947,6 +967,7 @@ COM_COMPONENTBUILDER_MENU_ADMIN_VIEWS="Admin Views" COM_COMPONENTBUILDER_MENU_COMPILER="Compiler" COM_COMPONENTBUILDER_MENU_CUSTOM_ADMIN_VIEWS="Custom Admin Views" COM_COMPONENTBUILDER_MENU_CUSTOM_CODES="Custom Codes" +COM_COMPONENTBUILDER_MENU_DASHBOARD="Dashboard" COM_COMPONENTBUILDER_MENU_DYNAMIC_GETS="Dynamic Gets" COM_COMPONENTBUILDER_MENU_FIELDS="Fields" COM_COMPONENTBUILDER_MENU_FIELDTYPES="Fieldtypes" diff --git a/admin/layouts/admin_custom_tabs/publishing.php b/admin/layouts/admin_custom_tabs/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/admin_custom_tabs/publishing.php +++ b/admin/layouts/admin_custom_tabs/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_custom_tabs/publlshing.php b/admin/layouts/admin_custom_tabs/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/admin_custom_tabs/publlshing.php +++ b/admin/layouts/admin_custom_tabs/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_custom_tabs/tabs_above.php b/admin/layouts/admin_custom_tabs/tabs_above.php index 4e0068392..afffd1d7b 100644 --- a/admin/layouts/admin_custom_tabs/tabs_above.php +++ b/admin/layouts/admin_custom_tabs/tabs_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'admin_view' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/admin_custom_tabs/tabs_fullwidth.php b/admin/layouts/admin_custom_tabs/tabs_fullwidth.php index 8cdb42655..cffa07619 100644 --- a/admin/layouts/admin_custom_tabs/tabs_fullwidth.php +++ b/admin/layouts/admin_custom_tabs/tabs_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'tabs' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_fields/fields_above.php b/admin/layouts/admin_fields/fields_above.php index 4e0068392..afffd1d7b 100644 --- a/admin/layouts/admin_fields/fields_above.php +++ b/admin/layouts/admin_fields/fields_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'admin_view' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/admin_fields/fields_fullwidth.php b/admin/layouts/admin_fields/fields_fullwidth.php index ac1636573..d85fe0d5b 100644 --- a/admin/layouts/admin_fields/fields_fullwidth.php +++ b/admin/layouts/admin_fields/fields_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'addfields' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_fields/publishing.php b/admin/layouts/admin_fields/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/admin_fields/publishing.php +++ b/admin/layouts/admin_fields/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_fields/publlshing.php b/admin/layouts/admin_fields/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/admin_fields/publlshing.php +++ b/admin/layouts/admin_fields/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_fields_conditions/conditions_above.php b/admin/layouts/admin_fields_conditions/conditions_above.php index 4e0068392..afffd1d7b 100644 --- a/admin/layouts/admin_fields_conditions/conditions_above.php +++ b/admin/layouts/admin_fields_conditions/conditions_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'admin_view' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/admin_fields_conditions/conditions_fullwidth.php b/admin/layouts/admin_fields_conditions/conditions_fullwidth.php index 6a98583c7..dd7bde844 100644 --- a/admin/layouts/admin_fields_conditions/conditions_fullwidth.php +++ b/admin/layouts/admin_fields_conditions/conditions_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'addconditions' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_fields_conditions/publishing.php b/admin/layouts/admin_fields_conditions/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/admin_fields_conditions/publishing.php +++ b/admin/layouts/admin_fields_conditions/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_fields_conditions/publlshing.php b/admin/layouts/admin_fields_conditions/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/admin_fields_conditions/publlshing.php +++ b/admin/layouts/admin_fields_conditions/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_fields_relations/publishing.php b/admin/layouts/admin_fields_relations/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/admin_fields_relations/publishing.php +++ b/admin/layouts/admin_fields_relations/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_fields_relations/publlshing.php b/admin/layouts/admin_fields_relations/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/admin_fields_relations/publlshing.php +++ b/admin/layouts/admin_fields_relations/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_fields_relations/relations_above.php b/admin/layouts/admin_fields_relations/relations_above.php index 4e0068392..afffd1d7b 100644 --- a/admin/layouts/admin_fields_relations/relations_above.php +++ b/admin/layouts/admin_fields_relations/relations_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'admin_view' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/admin_fields_relations/relations_fullwidth.php b/admin/layouts/admin_fields_relations/relations_fullwidth.php index f90e77fef..6793953c2 100644 --- a/admin/layouts/admin_fields_relations/relations_fullwidth.php +++ b/admin/layouts/admin_fields_relations/relations_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'addrelations' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_view/css_fullwidth.php b/admin/layouts/admin_view/css_fullwidth.php index 253eb58bd..142f5bba8 100644 --- a/admin/layouts/admin_view/css_fullwidth.php +++ b/admin/layouts/admin_view/css_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -32,7 +32,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'css_views' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_view/custom_buttons_fullwidth.php b/admin/layouts/admin_view/custom_buttons_fullwidth.php index 4d465133a..eab18477a 100644 --- a/admin/layouts/admin_view/custom_buttons_fullwidth.php +++ b/admin/layouts/admin_view/custom_buttons_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -32,7 +32,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'php_model_list' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_view/custom_buttons_left.php b/admin/layouts/admin_view/custom_buttons_left.php index 0f09a8578..f344834ef 100644 --- a/admin/layouts/admin_view/custom_buttons_left.php +++ b/admin/layouts/admin_view/custom_buttons_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'custom_button' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_view/custom_import_fullwidth.php b/admin/layouts/admin_view/custom_import_fullwidth.php index 45e9c641c..d8aca1a86 100644 --- a/admin/layouts/admin_view/custom_import_fullwidth.php +++ b/admin/layouts/admin_view/custom_import_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -38,7 +38,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'php_import_ext' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_view/details_above.php b/admin/layouts/admin_view/details_above.php index 87bb562cb..67ff5e648 100644 --- a/admin/layouts/admin_view/details_above.php +++ b/admin/layouts/admin_view/details_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'system_name' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/admin_view/details_fullwidth.php b/admin/layouts/admin_view/details_fullwidth.php index 4c12d1b6e..e869fba14 100644 --- a/admin/layouts/admin_view/details_fullwidth.php +++ b/admin/layouts/admin_view/details_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_linked_to_notice' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_view/details_left.php b/admin/layouts/admin_view/details_left.php index ac95961ad..f5ca85708 100644 --- a/admin/layouts/admin_view/details_left.php +++ b/admin/layouts/admin_view/details_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'icon_category' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_view/details_right.php b/admin/layouts/admin_view/details_right.php index cc8a1136b..f7234c8da 100644 --- a/admin/layouts/admin_view/details_right.php +++ b/admin/layouts/admin_view/details_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,7 +31,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'add_fadein' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_view/details_under.php b/admin/layouts/admin_view/details_under.php index 68af44f9c..48a7d40a0 100644 --- a/admin/layouts/admin_view/details_under.php +++ b/admin/layouts/admin_view/details_under.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'not_required' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/admin_view/fields_fullwidth.php b/admin/layouts/admin_view/fields_fullwidth.php index c0c5e3d13..d6e20e393 100644 --- a/admin/layouts/admin_view/fields_fullwidth.php +++ b/admin/layouts/admin_view/fields_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_create_edit_display' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_view/fields_left.php b/admin/layouts/admin_view/fields_left.php index 06e630cfb..3191e40bd 100644 --- a/admin/layouts/admin_view/fields_left.php +++ b/admin/layouts/admin_view/fields_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -35,7 +35,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'add_category_submenu' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_view/fields_right.php b/admin/layouts/admin_view/fields_right.php index fe2333e2d..94ef878da 100644 --- a/admin/layouts/admin_view/fields_right.php +++ b/admin/layouts/admin_view/fields_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_create_edit_buttons' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_view/javascript_fullwidth.php b/admin/layouts/admin_view/javascript_fullwidth.php index 4730f04a4..30ff5f7fe 100644 --- a/admin/layouts/admin_view/javascript_fullwidth.php +++ b/admin/layouts/admin_view/javascript_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -36,7 +36,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'javascript_views_footer' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_view/mysql_fullwidth.php b/admin/layouts/admin_view/mysql_fullwidth.php index e49958274..3fcdbcf34 100644 --- a/admin/layouts/admin_view/mysql_fullwidth.php +++ b/admin/layouts/admin_view/mysql_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'sql' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_view/mysql_left.php b/admin/layouts/admin_view/mysql_left.php index 10141576d..eec6c83b5 100644 --- a/admin/layouts/admin_view/mysql_left.php +++ b/admin/layouts/admin_view/mysql_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -35,7 +35,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'addtables' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_view/php_fullwidth.php b/admin/layouts/admin_view/php_fullwidth.php index 7f3e7e491..183793e89 100644 --- a/admin/layouts/admin_view/php_fullwidth.php +++ b/admin/layouts/admin_view/php_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -69,7 +69,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'php_document' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_view/publishing.php b/admin/layouts/admin_view/publishing.php index 97a901504..d4d7b688e 100644 --- a/admin/layouts/admin_view/publishing.php +++ b/admin/layouts/admin_view/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_view/publlshing.php b/admin/layouts/admin_view/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/admin_view/publlshing.php +++ b/admin/layouts/admin_view/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/admin_view/settings_fullwidth.php b/admin/layouts/admin_view/settings_fullwidth.php index 99653b635..58ff9ad11 100644 --- a/admin/layouts/admin_view/settings_fullwidth.php +++ b/admin/layouts/admin_view/settings_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -35,7 +35,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'addlinked_views' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/batchselection.php b/admin/layouts/batchselection.php deleted file mode 100644 index 7e45fe25a..000000000 --- a/admin/layouts/batchselection.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('JPATH_BASE') or die; - -JHtmlBehavior::core(); -$divWrapper = range(1,120,2); -$counter = 0; -?> -ListSelection) : ?> -
    - ListSelection as $ListSelection) : ?> -
    -
    - - -
    -
    - -
    -
    - - - -
    -
    -
    - - -
    -
    - \ No newline at end of file diff --git a/admin/layouts/class_extends/details_fullwidth.php b/admin/layouts/class_extends/details_fullwidth.php index f7dc8078c..adfbbecce 100644 --- a/admin/layouts/class_extends/details_fullwidth.php +++ b/admin/layouts/class_extends/details_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'head' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/class_extends/details_left.php b/admin/layouts/class_extends/details_left.php index 978f1cc38..ff6aed905 100644 --- a/admin/layouts/class_extends/details_left.php +++ b/admin/layouts/class_extends/details_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'extension_type' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/class_extends/details_right.php b/admin/layouts/class_extends/details_right.php index 19e2f8dbb..34a1d9194 100644 --- a/admin/layouts/class_extends/details_right.php +++ b/admin/layouts/class_extends/details_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'comment' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/class_extends/publishing.php b/admin/layouts/class_extends/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/class_extends/publishing.php +++ b/admin/layouts/class_extends/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/class_extends/publlshing.php b/admin/layouts/class_extends/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/class_extends/publlshing.php +++ b/admin/layouts/class_extends/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/class_method/details_fullwidth.php b/admin/layouts/class_method/details_fullwidth.php index 8551ba464..fba840a7f 100644 --- a/admin/layouts/class_method/details_fullwidth.php +++ b/admin/layouts/class_method/details_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'code' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/class_method/details_left.php b/admin/layouts/class_method/details_left.php index c6ec62819..99da1792e 100644 --- a/admin/layouts/class_method/details_left.php +++ b/admin/layouts/class_method/details_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'joomla_plugin_group' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/class_method/details_right.php b/admin/layouts/class_method/details_right.php index 19e2f8dbb..34a1d9194 100644 --- a/admin/layouts/class_method/details_right.php +++ b/admin/layouts/class_method/details_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'comment' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/class_method/publishing.php b/admin/layouts/class_method/publishing.php index 97a901504..d4d7b688e 100644 --- a/admin/layouts/class_method/publishing.php +++ b/admin/layouts/class_method/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/class_method/publlshing.php b/admin/layouts/class_method/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/class_method/publlshing.php +++ b/admin/layouts/class_method/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/class_property/details_left.php b/admin/layouts/class_property/details_left.php index 042b458dd..32f319a2a 100644 --- a/admin/layouts/class_property/details_left.php +++ b/admin/layouts/class_property/details_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'joomla_plugin_group' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/class_property/details_right.php b/admin/layouts/class_property/details_right.php index 19e2f8dbb..34a1d9194 100644 --- a/admin/layouts/class_property/details_right.php +++ b/admin/layouts/class_property/details_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'comment' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/class_property/publishing.php b/admin/layouts/class_property/publishing.php index 97a901504..d4d7b688e 100644 --- a/admin/layouts/class_property/publishing.php +++ b/admin/layouts/class_property/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/class_property/publlshing.php b/admin/layouts/class_property/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/class_property/publlshing.php +++ b/admin/layouts/class_property/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_admin_views/clone_left.php b/admin/layouts/component_admin_views/clone_left.php index 25c4eb0c1..8a38d6136 100644 --- a/admin/layouts/component_admin_views/clone_left.php +++ b/admin/layouts/component_admin_views/clone_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'clone_me' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_admin_views/publishing.php b/admin/layouts/component_admin_views/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/component_admin_views/publishing.php +++ b/admin/layouts/component_admin_views/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_admin_views/publlshing.php b/admin/layouts/component_admin_views/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/component_admin_views/publlshing.php +++ b/admin/layouts/component_admin_views/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_admin_views/views_above.php b/admin/layouts/component_admin_views/views_above.php index cf841da92..09b3c3a4b 100644 --- a/admin/layouts/component_admin_views/views_above.php +++ b/admin/layouts/component_admin_views/views_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'joomla_component' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/component_admin_views/views_fullwidth.php b/admin/layouts/component_admin_views/views_fullwidth.php index 1673841f2..6332f0c61 100644 --- a/admin/layouts/component_admin_views/views_fullwidth.php +++ b/admin/layouts/component_admin_views/views_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'addadmin_views' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_config/clone_left.php b/admin/layouts/component_config/clone_left.php index 25c4eb0c1..8a38d6136 100644 --- a/admin/layouts/component_config/clone_left.php +++ b/admin/layouts/component_config/clone_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'clone_me' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_config/options_above.php b/admin/layouts/component_config/options_above.php index cf841da92..09b3c3a4b 100644 --- a/admin/layouts/component_config/options_above.php +++ b/admin/layouts/component_config/options_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'joomla_component' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/component_config/options_fullwidth.php b/admin/layouts/component_config/options_fullwidth.php index f05e0e794..8919d4426 100644 --- a/admin/layouts/component_config/options_fullwidth.php +++ b/admin/layouts/component_config/options_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'addconfig' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_config/publishing.php b/admin/layouts/component_config/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/component_config/publishing.php +++ b/admin/layouts/component_config/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_config/publlshing.php b/admin/layouts/component_config/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/component_config/publlshing.php +++ b/admin/layouts/component_config/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_custom_admin_menus/clone_left.php b/admin/layouts/component_custom_admin_menus/clone_left.php index 25c4eb0c1..8a38d6136 100644 --- a/admin/layouts/component_custom_admin_menus/clone_left.php +++ b/admin/layouts/component_custom_admin_menus/clone_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'clone_me' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_custom_admin_menus/menus_above.php b/admin/layouts/component_custom_admin_menus/menus_above.php index cf841da92..09b3c3a4b 100644 --- a/admin/layouts/component_custom_admin_menus/menus_above.php +++ b/admin/layouts/component_custom_admin_menus/menus_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'joomla_component' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/component_custom_admin_menus/menus_fullwidth.php b/admin/layouts/component_custom_admin_menus/menus_fullwidth.php index bbc75d620..425a92730 100644 --- a/admin/layouts/component_custom_admin_menus/menus_fullwidth.php +++ b/admin/layouts/component_custom_admin_menus/menus_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'addcustommenus' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_custom_admin_menus/publishing.php b/admin/layouts/component_custom_admin_menus/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/component_custom_admin_menus/publishing.php +++ b/admin/layouts/component_custom_admin_menus/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_custom_admin_menus/publlshing.php b/admin/layouts/component_custom_admin_menus/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/component_custom_admin_menus/publlshing.php +++ b/admin/layouts/component_custom_admin_menus/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_custom_admin_views/clone_left.php b/admin/layouts/component_custom_admin_views/clone_left.php index 25c4eb0c1..8a38d6136 100644 --- a/admin/layouts/component_custom_admin_views/clone_left.php +++ b/admin/layouts/component_custom_admin_views/clone_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'clone_me' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_custom_admin_views/publishing.php b/admin/layouts/component_custom_admin_views/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/component_custom_admin_views/publishing.php +++ b/admin/layouts/component_custom_admin_views/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_custom_admin_views/publlshing.php b/admin/layouts/component_custom_admin_views/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/component_custom_admin_views/publlshing.php +++ b/admin/layouts/component_custom_admin_views/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_custom_admin_views/views_above.php b/admin/layouts/component_custom_admin_views/views_above.php index cf841da92..09b3c3a4b 100644 --- a/admin/layouts/component_custom_admin_views/views_above.php +++ b/admin/layouts/component_custom_admin_views/views_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'joomla_component' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/component_custom_admin_views/views_fullwidth.php b/admin/layouts/component_custom_admin_views/views_fullwidth.php index 6a4ad5855..e5083cf91 100644 --- a/admin/layouts/component_custom_admin_views/views_fullwidth.php +++ b/admin/layouts/component_custom_admin_views/views_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'addcustom_admin_views' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_dashboard/clone_left.php b/admin/layouts/component_dashboard/clone_left.php index 25c4eb0c1..8a38d6136 100644 --- a/admin/layouts/component_dashboard/clone_left.php +++ b/admin/layouts/component_dashboard/clone_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'clone_me' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_dashboard/dashboard_above.php b/admin/layouts/component_dashboard/dashboard_above.php index cf841da92..09b3c3a4b 100644 --- a/admin/layouts/component_dashboard/dashboard_above.php +++ b/admin/layouts/component_dashboard/dashboard_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'joomla_component' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/component_dashboard/dashboard_fullwidth.php b/admin/layouts/component_dashboard/dashboard_fullwidth.php index aade82bb5..866aa8776 100644 --- a/admin/layouts/component_dashboard/dashboard_fullwidth.php +++ b/admin/layouts/component_dashboard/dashboard_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,7 +31,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'dashboard_tab' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_dashboard/publishing.php b/admin/layouts/component_dashboard/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/component_dashboard/publishing.php +++ b/admin/layouts/component_dashboard/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_dashboard/publlshing.php b/admin/layouts/component_dashboard/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/component_dashboard/publlshing.php +++ b/admin/layouts/component_dashboard/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_files_folders/advance_fullwidth.php b/admin/layouts/component_files_folders/advance_fullwidth.php index 5fd19b54f..01e66ad5b 100644 --- a/admin/layouts/component_files_folders/advance_fullwidth.php +++ b/admin/layouts/component_files_folders/advance_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_constant_paths' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_files_folders/basic_above.php b/admin/layouts/component_files_folders/basic_above.php index cf841da92..09b3c3a4b 100644 --- a/admin/layouts/component_files_folders/basic_above.php +++ b/admin/layouts/component_files_folders/basic_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'joomla_component' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/component_files_folders/basic_fullwidth.php b/admin/layouts/component_files_folders/basic_fullwidth.php index 62e58dc11..a8d86936d 100644 --- a/admin/layouts/component_files_folders/basic_fullwidth.php +++ b/admin/layouts/component_files_folders/basic_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -32,7 +32,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'addfolders' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_files_folders/clone_left.php b/admin/layouts/component_files_folders/clone_left.php index 25c4eb0c1..8a38d6136 100644 --- a/admin/layouts/component_files_folders/clone_left.php +++ b/admin/layouts/component_files_folders/clone_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'clone_me' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_files_folders/publishing.php b/admin/layouts/component_files_folders/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/component_files_folders/publishing.php +++ b/admin/layouts/component_files_folders/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_files_folders/publlshing.php b/admin/layouts/component_files_folders/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/component_files_folders/publlshing.php +++ b/admin/layouts/component_files_folders/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_modules/clone_left.php b/admin/layouts/component_modules/clone_left.php index 25c4eb0c1..8a38d6136 100644 --- a/admin/layouts/component_modules/clone_left.php +++ b/admin/layouts/component_modules/clone_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'clone_me' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_modules/modules_above.php b/admin/layouts/component_modules/modules_above.php index cf841da92..09b3c3a4b 100644 --- a/admin/layouts/component_modules/modules_above.php +++ b/admin/layouts/component_modules/modules_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'joomla_component' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/component_modules/modules_fullwidth.php b/admin/layouts/component_modules/modules_fullwidth.php index 41348c16e..456e8e5c1 100644 --- a/admin/layouts/component_modules/modules_fullwidth.php +++ b/admin/layouts/component_modules/modules_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'addjoomla_modules' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_modules/publishing.php b/admin/layouts/component_modules/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/component_modules/publishing.php +++ b/admin/layouts/component_modules/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_modules/publlshing.php b/admin/layouts/component_modules/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/component_modules/publlshing.php +++ b/admin/layouts/component_modules/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_mysql_tweaks/clone_left.php b/admin/layouts/component_mysql_tweaks/clone_left.php index 25c4eb0c1..8a38d6136 100644 --- a/admin/layouts/component_mysql_tweaks/clone_left.php +++ b/admin/layouts/component_mysql_tweaks/clone_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'clone_me' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_mysql_tweaks/mysql_tweaks_above.php b/admin/layouts/component_mysql_tweaks/mysql_tweaks_above.php index cf841da92..09b3c3a4b 100644 --- a/admin/layouts/component_mysql_tweaks/mysql_tweaks_above.php +++ b/admin/layouts/component_mysql_tweaks/mysql_tweaks_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'joomla_component' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/component_mysql_tweaks/mysql_tweaks_fullwidth.php b/admin/layouts/component_mysql_tweaks/mysql_tweaks_fullwidth.php index c8066789a..e9656d216 100644 --- a/admin/layouts/component_mysql_tweaks/mysql_tweaks_fullwidth.php +++ b/admin/layouts/component_mysql_tweaks/mysql_tweaks_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'sql_tweak' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_mysql_tweaks/publishing.php b/admin/layouts/component_mysql_tweaks/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/component_mysql_tweaks/publishing.php +++ b/admin/layouts/component_mysql_tweaks/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_mysql_tweaks/publlshing.php b/admin/layouts/component_mysql_tweaks/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/component_mysql_tweaks/publlshing.php +++ b/admin/layouts/component_mysql_tweaks/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_placeholders/clone_left.php b/admin/layouts/component_placeholders/clone_left.php index 25c4eb0c1..8a38d6136 100644 --- a/admin/layouts/component_placeholders/clone_left.php +++ b/admin/layouts/component_placeholders/clone_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'clone_me' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_placeholders/details_above.php b/admin/layouts/component_placeholders/details_above.php index cf841da92..09b3c3a4b 100644 --- a/admin/layouts/component_placeholders/details_above.php +++ b/admin/layouts/component_placeholders/details_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'joomla_component' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/component_placeholders/details_fullwidth.php b/admin/layouts/component_placeholders/details_fullwidth.php index fd57fc4a6..6a34d4721 100644 --- a/admin/layouts/component_placeholders/details_fullwidth.php +++ b/admin/layouts/component_placeholders/details_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'addplaceholders' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_placeholders/publishing.php b/admin/layouts/component_placeholders/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/component_placeholders/publishing.php +++ b/admin/layouts/component_placeholders/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_placeholders/publlshing.php b/admin/layouts/component_placeholders/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/component_placeholders/publlshing.php +++ b/admin/layouts/component_placeholders/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_plugins/clone_left.php b/admin/layouts/component_plugins/clone_left.php index 25c4eb0c1..8a38d6136 100644 --- a/admin/layouts/component_plugins/clone_left.php +++ b/admin/layouts/component_plugins/clone_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'clone_me' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_plugins/plugins_above.php b/admin/layouts/component_plugins/plugins_above.php index cf841da92..09b3c3a4b 100644 --- a/admin/layouts/component_plugins/plugins_above.php +++ b/admin/layouts/component_plugins/plugins_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'joomla_component' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/component_plugins/plugins_fullwidth.php b/admin/layouts/component_plugins/plugins_fullwidth.php index 77bd19357..c4488405c 100644 --- a/admin/layouts/component_plugins/plugins_fullwidth.php +++ b/admin/layouts/component_plugins/plugins_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'addjoomla_plugins' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_plugins/publishing.php b/admin/layouts/component_plugins/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/component_plugins/publishing.php +++ b/admin/layouts/component_plugins/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_plugins/publlshing.php b/admin/layouts/component_plugins/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/component_plugins/publlshing.php +++ b/admin/layouts/component_plugins/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/helpers/extrusion/index.html b/admin/layouts/component_router/index.html similarity index 100% rename from admin/helpers/extrusion/index.html rename to admin/layouts/component_router/index.html diff --git a/admin/layouts/component_router/publishing.php b/admin/layouts/component_router/publishing.php new file mode 100644 index 000000000..5537d3a21 --- /dev/null +++ b/admin/layouts/component_router/publishing.php @@ -0,0 +1,46 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'title', + 'created', + 'created_by', + 'modified', + 'modified_by' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: []; + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/component_router/publlshing.php b/admin/layouts/component_router/publlshing.php new file mode 100644 index 000000000..051a5b14f --- /dev/null +++ b/admin/layouts/component_router/publlshing.php @@ -0,0 +1,47 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'published', + 'ordering', + 'access', + 'version', + 'hits', + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: []; + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/component_router/settings_above.php b/admin/layouts/component_router/settings_above.php new file mode 100644 index 000000000..09b3c3a4b --- /dev/null +++ b/admin/layouts/component_router/settings_above.php @@ -0,0 +1,52 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: [ + 'joomla_component' +]; + +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; + +?> + +
    + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?> + +
    + diff --git a/admin/layouts/component_router/settings_fullwidth.php b/admin/layouts/component_router/settings_fullwidth.php new file mode 100644 index 000000000..7eb63d4ef --- /dev/null +++ b/admin/layouts/component_router/settings_fullwidth.php @@ -0,0 +1,54 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'router_settings_details_switch', + 'note_router_settings', + 'note_router_settings_advance', + 'mode_constructor_before_parent', + 'note_mode_constructor_before_parent_manual', + 'constructor_before_parent_code', + 'constructor_before_parent_manual', + 'mode_constructor_after_parent', + 'constructor_after_parent_code', + 'mode_methods', + 'methods_code' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: []; + +?> + +
    + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
    + diff --git a/admin/layouts/component_site_views/clone_left.php b/admin/layouts/component_site_views/clone_left.php index 25c4eb0c1..8a38d6136 100644 --- a/admin/layouts/component_site_views/clone_left.php +++ b/admin/layouts/component_site_views/clone_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'clone_me' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_site_views/publishing.php b/admin/layouts/component_site_views/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/component_site_views/publishing.php +++ b/admin/layouts/component_site_views/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_site_views/publlshing.php b/admin/layouts/component_site_views/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/component_site_views/publlshing.php +++ b/admin/layouts/component_site_views/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_site_views/views_above.php b/admin/layouts/component_site_views/views_above.php index cf841da92..09b3c3a4b 100644 --- a/admin/layouts/component_site_views/views_above.php +++ b/admin/layouts/component_site_views/views_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'joomla_component' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/component_site_views/views_fullwidth.php b/admin/layouts/component_site_views/views_fullwidth.php index 89afa4ba2..a5f0ce5d2 100644 --- a/admin/layouts/component_site_views/views_fullwidth.php +++ b/admin/layouts/component_site_views/views_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'addsite_views' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_updates/clone_left.php b/admin/layouts/component_updates/clone_left.php index 25c4eb0c1..8a38d6136 100644 --- a/admin/layouts/component_updates/clone_left.php +++ b/admin/layouts/component_updates/clone_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'clone_me' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_updates/publishing.php b/admin/layouts/component_updates/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/component_updates/publishing.php +++ b/admin/layouts/component_updates/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_updates/publlshing.php b/admin/layouts/component_updates/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/component_updates/publlshing.php +++ b/admin/layouts/component_updates/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/component_updates/updates_above.php b/admin/layouts/component_updates/updates_above.php index cf841da92..09b3c3a4b 100644 --- a/admin/layouts/component_updates/updates_above.php +++ b/admin/layouts/component_updates/updates_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'joomla_component' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/component_updates/updates_fullwidth.php b/admin/layouts/component_updates/updates_fullwidth.php index ccf6866f5..f1705d2a3 100644 --- a/admin/layouts/component_updates/updates_fullwidth.php +++ b/admin/layouts/component_updates/updates_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'version_update' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/custom_admin_view/custom_buttons_fullwidth.php b/admin/layouts/custom_admin_view/custom_buttons_fullwidth.php index 554de9d8c..dcd156c9f 100644 --- a/admin/layouts/custom_admin_view/custom_buttons_fullwidth.php +++ b/admin/layouts/custom_admin_view/custom_buttons_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'php_model' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/custom_admin_view/custom_buttons_left.php b/admin/layouts/custom_admin_view/custom_buttons_left.php index 0f09a8578..f344834ef 100644 --- a/admin/layouts/custom_admin_view/custom_buttons_left.php +++ b/admin/layouts/custom_admin_view/custom_buttons_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'custom_button' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/custom_admin_view/details_above.php b/admin/layouts/custom_admin_view/details_above.php index 019a14081..c52a26190 100644 --- a/admin/layouts/custom_admin_view/details_above.php +++ b/admin/layouts/custom_admin_view/details_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,21 +25,29 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'system_name', 'context' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/custom_admin_view/details_fullwidth.php b/admin/layouts/custom_admin_view/details_fullwidth.php index 8c0c8e83e..f852f1976 100644 --- a/admin/layouts/custom_admin_view/details_fullwidth.php +++ b/admin/layouts/custom_admin_view/details_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'default' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/custom_admin_view/details_left.php b/admin/layouts/custom_admin_view/details_left.php index df266c7f1..b70b12b40 100644 --- a/admin/layouts/custom_admin_view/details_left.php +++ b/admin/layouts/custom_admin_view/details_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_add_php_language_string' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/custom_admin_view/details_right.php b/admin/layouts/custom_admin_view/details_right.php index c97f5422e..8c304600a 100644 --- a/admin/layouts/custom_admin_view/details_right.php +++ b/admin/layouts/custom_admin_view/details_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -32,7 +32,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_snippet_usage' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/custom_admin_view/details_rightside.php b/admin/layouts/custom_admin_view/details_rightside.php index d7ea40a77..1c42273f1 100644 --- a/admin/layouts/custom_admin_view/details_rightside.php +++ b/admin/layouts/custom_admin_view/details_rightside.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -32,7 +32,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'dynamic_values' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/custom_admin_view/details_under.php b/admin/layouts/custom_admin_view/details_under.php index 68af44f9c..48a7d40a0 100644 --- a/admin/layouts/custom_admin_view/details_under.php +++ b/admin/layouts/custom_admin_view/details_under.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'not_required' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/custom_admin_view/javascript_css_fullwidth.php b/admin/layouts/custom_admin_view/javascript_css_fullwidth.php index 2d215335d..914c35d49 100644 --- a/admin/layouts/custom_admin_view/javascript_css_fullwidth.php +++ b/admin/layouts/custom_admin_view/javascript_css_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -36,7 +36,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'css' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/custom_admin_view/linked_components_fullwidth.php b/admin/layouts/custom_admin_view/linked_components_fullwidth.php index 4c12d1b6e..e869fba14 100644 --- a/admin/layouts/custom_admin_view/linked_components_fullwidth.php +++ b/admin/layouts/custom_admin_view/linked_components_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_linked_to_notice' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/custom_admin_view/php_fullwidth.php b/admin/layouts/custom_admin_view/php_fullwidth.php index deb10e126..225852048 100644 --- a/admin/layouts/custom_admin_view/php_fullwidth.php +++ b/admin/layouts/custom_admin_view/php_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -39,7 +39,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'php_jview' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/custom_admin_view/publishing.php b/admin/layouts/custom_admin_view/publishing.php index 97a901504..d4d7b688e 100644 --- a/admin/layouts/custom_admin_view/publishing.php +++ b/admin/layouts/custom_admin_view/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/custom_admin_view/publlshing.php b/admin/layouts/custom_admin_view/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/custom_admin_view/publlshing.php +++ b/admin/layouts/custom_admin_view/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/custom_code/details_above.php b/admin/layouts/custom_code/details_above.php index 68ce3e65c..69fe8a217 100644 --- a/admin/layouts/custom_code/details_above.php +++ b/admin/layouts/custom_code/details_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,22 +25,31 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'target', 'system_name', + 'joomla_version', 'function_name' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/custom_code/details_fullwidth.php b/admin/layouts/custom_code/details_fullwidth.php index 2e431c66e..a30bbf9d0 100644 --- a/admin/layouts/custom_code/details_fullwidth.php +++ b/admin/layouts/custom_code/details_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -32,7 +32,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_placeholders_explained' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/custom_code/details_left.php b/admin/layouts/custom_code/details_left.php index 3e3621fab..9b993223f 100644 --- a/admin/layouts/custom_code/details_left.php +++ b/admin/layouts/custom_code/details_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -32,7 +32,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'hashtarget' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/custom_code/details_right.php b/admin/layouts/custom_code/details_right.php index 2e65f13a0..f77b85151 100644 --- a/admin/layouts/custom_code/details_right.php +++ b/admin/layouts/custom_code/details_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,7 +31,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'hashendtarget' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/custom_code/details_under.php b/admin/layouts/custom_code/details_under.php index 68af44f9c..48a7d40a0 100644 --- a/admin/layouts/custom_code/details_under.php +++ b/admin/layouts/custom_code/details_under.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'not_required' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/custom_code/publishing.php b/admin/layouts/custom_code/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/custom_code/publishing.php +++ b/admin/layouts/custom_code/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/custom_code/publlshing.php b/admin/layouts/custom_code/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/custom_code/publlshing.php +++ b/admin/layouts/custom_code/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/dynamic_get/abacus_fullwidth.php b/admin/layouts/dynamic_get/abacus_fullwidth.php index 3ab1f0e03..141378f5e 100644 --- a/admin/layouts/dynamic_get/abacus_fullwidth.php +++ b/admin/layouts/dynamic_get/abacus_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,7 +31,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'php_calculation' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/dynamic_get/abacus_left.php b/admin/layouts/dynamic_get/abacus_left.php index bbf798601..bd70e2b4d 100644 --- a/admin/layouts/dynamic_get/abacus_left.php +++ b/admin/layouts/dynamic_get/abacus_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'addcalculation' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/dynamic_get/custom_script_fullwidth.php b/admin/layouts/dynamic_get/custom_script_fullwidth.php index d529430e0..1329a098e 100644 --- a/admin/layouts/dynamic_get/custom_script_fullwidth.php +++ b/admin/layouts/dynamic_get/custom_script_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -37,10 +37,11 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'add_php_after_getitems', 'php_after_getitems', 'add_php_router_parse', + 'php_router_parse_notice', 'php_router_parse' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/dynamic_get/joint_fullwidth.php b/admin/layouts/dynamic_get/joint_fullwidth.php index d1c05074c..97d34ce7e 100644 --- a/admin/layouts/dynamic_get/joint_fullwidth.php +++ b/admin/layouts/dynamic_get/joint_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'join_db_table' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/dynamic_get/main_above.php b/admin/layouts/dynamic_get/main_above.php index d15037af5..ab6b9b49f 100644 --- a/admin/layouts/dynamic_get/main_above.php +++ b/admin/layouts/dynamic_get/main_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,23 +25,31 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'name', 'gettype', 'getcustom', 'pagination' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/dynamic_get/main_fullwidth.php b/admin/layouts/dynamic_get/main_fullwidth.php index dd170b76d..da272a298 100644 --- a/admin/layouts/dynamic_get/main_fullwidth.php +++ b/admin/layouts/dynamic_get/main_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_linked_to_notice' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/dynamic_get/main_left.php b/admin/layouts/dynamic_get/main_left.php index 48761754b..7ae83eded 100644 --- a/admin/layouts/dynamic_get/main_left.php +++ b/admin/layouts/dynamic_get/main_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'db_selection' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/dynamic_get/main_right.php b/admin/layouts/dynamic_get/main_right.php index a504903ec..e690956a9 100644 --- a/admin/layouts/dynamic_get/main_right.php +++ b/admin/layouts/dynamic_get/main_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'plugin_events' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/dynamic_get/main_under.php b/admin/layouts/dynamic_get/main_under.php index 68af44f9c..48a7d40a0 100644 --- a/admin/layouts/dynamic_get/main_under.php +++ b/admin/layouts/dynamic_get/main_under.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'not_required' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/dynamic_get/publishing.php b/admin/layouts/dynamic_get/publishing.php index 97a901504..d4d7b688e 100644 --- a/admin/layouts/dynamic_get/publishing.php +++ b/admin/layouts/dynamic_get/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/dynamic_get/publlshing.php b/admin/layouts/dynamic_get/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/dynamic_get/publlshing.php +++ b/admin/layouts/dynamic_get/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/dynamic_get/tweak_fullwidth.php b/admin/layouts/dynamic_get/tweak_fullwidth.php index 9d340c48d..70057419a 100644 --- a/admin/layouts/dynamic_get/tweak_fullwidth.php +++ b/admin/layouts/dynamic_get/tweak_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'global' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/field/database_fullwidth.php b/admin/layouts/field/database_fullwidth.php index f3dde1361..687fa8639 100644 --- a/admin/layouts/field/database_fullwidth.php +++ b/admin/layouts/field/database_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_database_settings_needed' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/field/database_left.php b/admin/layouts/field/database_left.php index c312abeba..572766f3a 100644 --- a/admin/layouts/field/database_left.php +++ b/admin/layouts/field/database_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'datadefault_other' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/field/database_right.php b/admin/layouts/field/database_right.php index 644649025..83cad5930 100644 --- a/admin/layouts/field/database_right.php +++ b/admin/layouts/field/database_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -39,7 +39,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'on_get_model_field' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/field/publishing.php b/admin/layouts/field/publishing.php index 97a901504..d4d7b688e 100644 --- a/admin/layouts/field/publishing.php +++ b/admin/layouts/field/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/field/publlshing.php b/admin/layouts/field/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/field/publlshing.php +++ b/admin/layouts/field/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/field/scripts_left.php b/admin/layouts/field/scripts_left.php index 726f3fe4a..92871f516 100644 --- a/admin/layouts/field/scripts_left.php +++ b/admin/layouts/field/scripts_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -32,7 +32,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'css_views' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/field/scripts_right.php b/admin/layouts/field/scripts_right.php index 8ff91e5f2..f82c18539 100644 --- a/admin/layouts/field/scripts_right.php +++ b/admin/layouts/field/scripts_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -32,7 +32,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'javascript_views_footer' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/field/set_properties_above.php b/admin/layouts/field/set_properties_above.php index a899861d3..aac2690a7 100644 --- a/admin/layouts/field/set_properties_above.php +++ b/admin/layouts/field/set_properties_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,22 +25,30 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'fieldtype', 'name', 'catid' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/field/set_properties_fullwidth.php b/admin/layouts/field/set_properties_fullwidth.php index 77f331121..4494f8fd5 100644 --- a/admin/layouts/field/set_properties_fullwidth.php +++ b/admin/layouts/field/set_properties_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_filter_information' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/field/set_properties_under.php b/admin/layouts/field/set_properties_under.php index 68af44f9c..48a7d40a0 100644 --- a/admin/layouts/field/set_properties_under.php +++ b/admin/layouts/field/set_properties_under.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'not_required' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/field/type_info_fullwidth.php b/admin/layouts/field/type_info_fullwidth.php index c310d8d68..e5217965f 100644 --- a/admin/layouts/field/type_info_fullwidth.php +++ b/admin/layouts/field/type_info_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'xml' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/fieldtype/database_defaults_left.php b/admin/layouts/fieldtype/database_defaults_left.php index b0ea19849..ca15dc16b 100644 --- a/admin/layouts/fieldtype/database_defaults_left.php +++ b/admin/layouts/fieldtype/database_defaults_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'datadefault_other' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/fieldtype/database_defaults_right.php b/admin/layouts/fieldtype/database_defaults_right.php index 0f650d05d..8d7ea329f 100644 --- a/admin/layouts/fieldtype/database_defaults_right.php +++ b/admin/layouts/fieldtype/database_defaults_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_whmcs_encryption' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/fieldtype/details_above.php b/admin/layouts/fieldtype/details_above.php index 4b44cd601..ab3745d7b 100644 --- a/admin/layouts/fieldtype/details_above.php +++ b/admin/layouts/fieldtype/details_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'name' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/fieldtype/details_fullwidth.php b/admin/layouts/fieldtype/details_fullwidth.php index e150a3b3e..7ca9ace90 100644 --- a/admin/layouts/fieldtype/details_fullwidth.php +++ b/admin/layouts/fieldtype/details_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,7 +31,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'not_required' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/fieldtype/details_left.php b/admin/layouts/fieldtype/details_left.php index 0e67b869b..62cc7ca8d 100644 --- a/admin/layouts/fieldtype/details_left.php +++ b/admin/layouts/fieldtype/details_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'short_description' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/fieldtype/details_right.php b/admin/layouts/fieldtype/details_right.php index 37215496b..aefe7858d 100644 --- a/admin/layouts/fieldtype/details_right.php +++ b/admin/layouts/fieldtype/details_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'description' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/fieldtype/fields_fullwidth.php b/admin/layouts/fieldtype/fields_fullwidth.php index badb9937b..993848a0b 100644 --- a/admin/layouts/fieldtype/fields_fullwidth.php +++ b/admin/layouts/fieldtype/fields_fullwidth.php @@ -9,25 +9,32 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\ArrayHelper; + // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // set the defaults $items = $displayData->vycfields; -$user = JFactory::getUser(); +$user = Factory::getApplication()->getIdentity(); $id = $displayData->item->id; // set the edit URL $edit = "index.php?option=com_componentbuilder&view=fields&task=field.edit"; // set a return value $return = ($id) ? "index.php?option=com_componentbuilder&view=fieldtype&layout=edit&id=" . $id : ""; // check for a return value -$jinput = JFactory::getApplication()->input; +$jinput = Factory::getApplication()->input; if ($_return = $jinput->get('return', null, 'base64')) { $return .= "&return=" . $_return; } // check if return value was set -if (ComponentbuilderHelper::checkString($return)) +if (StringHelper::check($return)) { // set the referral values $ref = ($id) ? "&ref=fieldtype&refid=" . $id . "&return=" . urlencode(base64_encode($return)) : "&return=" . urlencode(base64_encode($return)); @@ -47,40 +54,40 @@ $can = ComponentbuilderHelper::getActions('field');
    get('field.create')): ?>
    - - + +


    - + @@ -88,7 +95,9 @@ $can = ComponentbuilderHelper::getActions('field'); $item): ?> authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); $canDo = ComponentbuilderHelper::getActions('field',$item,'fields'); ?> @@ -96,7 +105,7 @@ $can = ComponentbuilderHelper::getActions('field'); get('field.edit')): ?> escape($item->name); ?>checked_out): ?> - name, $item->checked_out_time, 'fields.', $canCheckin); ?> + name, $item->checked_out_time, 'fields.', $canCheckin); ?> escape($item->name); ?> @@ -106,16 +115,16 @@ $can = ComponentbuilderHelper::getActions('field'); escape($item->fieldtype_name); ?> published == 1): ?> published == 0): ?> published == 2): ?> published == -2): ?> @@ -158,7 +167,7 @@ $can = ComponentbuilderHelper::getActions('field');
    - + - + - + - + - + - + - + - + - +
    - datatype); ?> + datatype); ?> - indexes); ?> + indexes); ?> - null_switch); ?> + null_switch); ?> - store); ?> + store); ?> authorise('core.edit', 'com_componentbuilder.field.category.' . (int)$item->catid)): ?> @@ -126,26 +135,26 @@ $can = ComponentbuilderHelper::getActions('field'); - - + + - - + + - - + + - - + +
    - +
    diff --git a/admin/layouts/fieldtype/publishing.php b/admin/layouts/fieldtype/publishing.php index 97a901504..d4d7b688e 100644 --- a/admin/layouts/fieldtype/publishing.php +++ b/admin/layouts/fieldtype/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/fieldtype/publlshing.php b/admin/layouts/fieldtype/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/fieldtype/publlshing.php +++ b/admin/layouts/fieldtype/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/help_document/details_above.php b/admin/layouts/help_document/details_above.php index 5d8ed3d98..9bae47536 100644 --- a/admin/layouts/help_document/details_above.php +++ b/admin/layouts/help_document/details_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,21 +25,29 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'title', 'alias' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/help_document/details_fullwidth.php b/admin/layouts/help_document/details_fullwidth.php index 2d71a04d6..e08ee7cd4 100644 --- a/admin/layouts/help_document/details_fullwidth.php +++ b/admin/layouts/help_document/details_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'content' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/help_document/details_left.php b/admin/layouts/help_document/details_left.php index f72ddc06e..1c5009c9a 100644 --- a/admin/layouts/help_document/details_left.php +++ b/admin/layouts/help_document/details_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'site_view' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/help_document/details_right.php b/admin/layouts/help_document/details_right.php index 5dcfa71db..dba647511 100644 --- a/admin/layouts/help_document/details_right.php +++ b/admin/layouts/help_document/details_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,7 +31,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'article' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/help_document/details_under.php b/admin/layouts/help_document/details_under.php index 68af44f9c..48a7d40a0 100644 --- a/admin/layouts/help_document/details_under.php +++ b/admin/layouts/help_document/details_under.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'not_required' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/help_document/publishing.php b/admin/layouts/help_document/publishing.php index 09643bbaa..4fe93f9a4 100644 --- a/admin/layouts/help_document/publishing.php +++ b/admin/layouts/help_document/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -32,7 +32,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/help_document/publlshing.php b/admin/layouts/help_document/publlshing.php index cb41f62bc..18c91dedc 100644 --- a/admin/layouts/help_document/publlshing.php +++ b/admin/layouts/help_document/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/jcbnoticeboardpro.php b/admin/layouts/jcbnoticeboardpro.php index 1d0e53a8c..31cdf40de 100644 --- a/admin/layouts/jcbnoticeboardpro.php +++ b/admin/layouts/jcbnoticeboardpro.php @@ -9,14 +9,22 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ + + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + // No direct access to this file -defined('JPATH_BASE') or die('Restricted access'); +defined('JPATH_BASE') or die; ?>
    - -
    .
    + +
    .
    diff --git a/admin/layouts/jcbnoticeboardtabs.php b/admin/layouts/jcbnoticeboardtabs.php index 6a6ca9fbe..0e27e6030 100644 --- a/admin/layouts/jcbnoticeboardtabs.php +++ b/admin/layouts/jcbnoticeboardtabs.php @@ -9,21 +9,29 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ + + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + // No direct access to this file -defined('JPATH_BASE') or die('Restricted access'); +defined('JPATH_BASE') or die; ?> -
    - $displayData['active'] . '-noticeboard')) ?> - - -
    - - - -
    - - +
    + $displayData['active'] . '-noticeboard')); ?> + + +
    + + + +
    + +
    diff --git a/admin/layouts/jcbnoticeboardvdm.php b/admin/layouts/jcbnoticeboardvdm.php index 04dec6150..b7d86e150 100644 --- a/admin/layouts/jcbnoticeboardvdm.php +++ b/admin/layouts/jcbnoticeboardvdm.php @@ -9,14 +9,22 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ + + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + // No direct access to this file -defined('JPATH_BASE') or die('Restricted access'); +defined('JPATH_BASE') or die; ?>
    - -
    .
    + +
    .
    diff --git a/admin/layouts/jcbsupportmessage.php b/admin/layouts/jcbsupportmessage.php index 1aaa5a707..52a97477b 100644 --- a/admin/layouts/jcbsupportmessage.php +++ b/admin/layouts/jcbsupportmessage.php @@ -9,20 +9,28 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ + + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + // No direct access to this file -defined('JPATH_BASE') or die('Restricted access'); +defined('JPATH_BASE') or die; // Different support requests/appreciation $support = [ - JText::_("COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BUILDER_JCB_IS_A_CRUCIAL_TOOL_FOR_PHP_PROGRAMMERS_WHO_USE_JOOMLA_TO_EARN_A_LIVING_BY_MAKING_A_BFINANCIAL_DONATIONB_YOU_CAN_SUPPORT_THE_GROWTH_AND_CONTINUITY_OF_THIS_VITAL_RESOURCE_AND_ENSURE_ITS_RELEVANCE_FOR_YEARS_TO_COME_YOUR_CONTRIBUTION_NO_MATTER_HOW_BIG_OR_SMALL_WILL_BE_DEEPLY_APPRECIATED_BY_THE_PROJECTS_TEAM_AND_THE_WIDER_COMMUNITY"), - JText::_("COM_COMPONENTBUILDER_THE_CONTINUED_SUPPORT_OF_INDIVIDUALS_LIKE_YOU_HAS_ALLOWED_JOOMLA_COMPONENT_BUILDER_JCB_TO_THRIVE_FOR_SEVEN_YEARS_SINCE_GOING_PUBLIC_YOUR_CONTRIBUTIONS_HAVE_BEEN_CRUCIAL_IN_ENSURING_THE_GROWTH_AND_RELEVANCE_OF_THIS_VITAL_TOOL_FOR_PHP_PROGRAMMERS_THANK_YOU_FOR_YOUR_SUPPORT_AND_FOR_BEING_A_PART_OF_JCBS_JOURNEY"), - JText::_("COM_COMPONENTBUILDER_SUPPORT_JOOMLA_COMPONENT_BUILDER_JCB_WITH_A_BFINANCIAL_DONATIONB_TO_SHOW_GRATITUDE_FOR_THE_TIME_AND_EFFORT_SAVED_IN_YOUR_DEVELOPMENT_PROCESS_YOUR_CONTRIBUTION_NO_MATTER_THE_SIZE_WILL_BE_APPRECIATED_BY_THE_PROJECTS_TEAM_AND_THE_WIDER_COMMUNITY_HELP_ENSURE_THE_GROWTH_AND_RELEVANCE_OF_THIS_ESSENTIAL_TOOL"), - JText::_("COM_COMPONENTBUILDER_INVEST_IN_THE_FUTURE_OF_JOOMLA_COMPONENT_BUILDER_JCB_BY_MAKING_A_BFINANCIAL_DONATIONB_SUPPORT_THE_NECESSARY_DEVELOPMENT_AND_MAINTENANCE_OF_THIS_OPENSOURCE_PROJECT_ENSURING_ITS_CONTINUED_GROWTH_AND_RELEVANCE_FOR_THE_COMMUNITY_YOUR_CONTRIBUTION_WILL_HELP_SECURE_THE_FUTURE_OF_THIS_VITAL_TOOL_FOR_PHP_PROGRAMMERS"), - JText::_("COM_COMPONENTBUILDER_INVEST_IN_THE_FUTURE_OF_JOOMLA_COMPONENT_BUILDER_JCB_BY_MAKING_A_BFINANCIAL_CONTRIBUTIONB_NO_MATTER_HOW_SMALL_THE_CONTINUAL_SUPPORT_OF_ALL_THOSE_USING_THE_TOOL_WILL_BE_MORE_THAN_ENOUGH_TO_ENSURE_ITS_CONTINUED_GROWTH_AND_RELEVANCE_BY_INVESTING_IN_THIS_OPENSOURCE_PROJECT_YOU_ARE_SECURING_ITS_FUTURE_AS_A_VITAL_TOOL_FOR_PHP_PROGRAMMERS"), - JText::_("COM_COMPONENTBUILDER_WE_EXTEND_OUR_GRATITUDE_TO_ALL_THOSE_WHO_SUPPORT_JOOMLA_COMPONENT_BUILDER_JCB_WHETHER_AS_A_HOBBY_OR_AS_A_PART_OF_THEIR_BUSINESS_YOUR_CONTRIBUTIONS_WHETHER_FINANCIAL_OR_IN_THE_FORM_OF_ACTIVE_INVOLVEMENT_HAVE_HAD_A_SIGNIFICANT_IMPACT_ON_ENSURING_THE_GROWTH_AND_RELEVANCE_OF_THIS_VITAL_TOOL_FOR_PHP_PROGRAMMERS_WE_HIGHLY_VALUE_THE_DEDICATION_OF_HOBBYISTS_AND_THE_COMMITMENT_OF_COMPANIES_WHO_SUPPORT_JCB_AS_THEY_HAVE_ALLOWED_THE_PROJECT_TO_CONTINUE_ITS_DEVELOPMENT_AND_MAINTENANCE_PROVIDING_VALUABLE_RESOURCES_FOR_THE_COMMUNITY_WE_ARE_GRATEFUL_FOR_YOUR_CONTRIBUTIONS_NO_MATTER_HOW_SMALL_AND_THANK_YOU_FOR_BEING_A_PART_OF_THE_POSITIVE_IMPACT_THAT_JCB_HAS_ON_THE_PHP_PROGRAMMING_COMMUNITY"), - JText::_("COM_COMPONENTBUILDER_WITHOUT_SUFFICIENT_SUPPORT_THE_FUTURE_OF_JOOMLA_COMPONENT_BUILDER_JCB_IS_IN_JEOPARDY_AS_A_VITAL_TOOL_FOR_PHP_PROGRAMMERS_IT_IS_CRUCIAL_TO_ENSURE_ITS_CONTINUED_DEVELOPMENT_AND_MAINTENANCE_BY_MAKING_A_BFINANCIAL_CONTRIBUTIONB_NO_MATTER_HOW_SMALL_YOU_ARE_HELPING_TO_SAFEGUARD_THE_FUTURE_OF_THIS_OPENSOURCE_PROJECT_NEGLECTING_TO_SUPPORT_JCB_COULD_RESULT_IN_ITS_DECLINE_AND_LOSS_AS_A_RESOURCE_FOR_THE_COMMUNITY"), - JText::_("COM_COMPONENTBUILDER_WE_EXTEND_OUR_HEARTFELT_APPRECIATION_TO_THOSE_WHO_HAVE_SUPPORTED_THE_JOOMLA_COMPONENT_BUILDER_JCB_PROJECT_OVER_THE_YEARS_YOUR_CONTRIBUTIONS_NO_MATTER_HOW_BIG_OR_SMALL_HAVE_BEEN_INSTRUMENTAL_IN_ENSURING_ITS_GROWTH_AND_RELEVANCE_AS_A_VITAL_TOOL_FOR_PHP_PROGRAMMERS_SEVEN_YEARS_AFTER_GOING_PUBLIC_JCB_IS_STILL_HERE_TODAY_BECAUSE_OF_THE_SUPPORT_OF_INDIVIDUALS_LIKE_YOU_WHO_BELIEVE_IN_THE_IMPORTANCE_OF_THIS_OPENSOURCE_PROJECT_YOUR_GENEROSITY_HAS_ALLOWED_THE_PROJECT_TO_CONTINUE_ITS_DEVELOPMENT_AND_MAINTENANCE_PROVIDING_VALUABLE_RESOURCES_FOR_THE_COMMUNITY_THANK_YOU_FOR_YOUR_UNWAVERING_SUPPORT_AND_FOR_BEING_A_PART_OF_JCBS_JOURNEY"), - JText::_("COM_COMPONENTBUILDER_WE_EXTEND_OUR_SINCERE_APPRECIATION_TO_THE_COMPANIES_WHO_USE_JOOMLA_COMPONENT_BUILDER_JCB_AND_SUPPORT_THE_PROJECT_YOUR_CONTRIBUTIONS_WHETHER_FINANCIAL_OR_IN_THE_FORM_OF_ACTIVE_INVOLVEMENT_HAVE_BEEN_INSTRUMENTAL_IN_ENSURING_THE_GROWTH_AND_RELEVANCE_OF_THIS_VITAL_TOOL_FOR_PHP_PROGRAMMERS_YOUR_SUPPORT_HAS_ALLOWED_JCB_TO_CONTINUE_ITS_DEVELOPMENT_AND_MAINTENANCE_PROVIDING_VALUABLE_RESOURCES_FOR_THE_COMMUNITY_THANK_YOU_FOR_YOUR_UNWAVERING_COMMITMENT_TO_THE_PROJECT_AND_FOR_BEING_A_PART_OF_JCBS_JOURNEY") + Text::_("COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BUILDER_JCB_IS_A_CRUCIAL_TOOL_FOR_PHP_PROGRAMMERS_WHO_USE_JOOMLA_TO_EARN_A_LIVING_BY_MAKING_A_BFINANCIAL_DONATIONB_YOU_CAN_SUPPORT_THE_GROWTH_AND_CONTINUITY_OF_THIS_VITAL_RESOURCE_AND_ENSURE_ITS_RELEVANCE_FOR_YEARS_TO_COME_YOUR_CONTRIBUTION_NO_MATTER_HOW_BIG_OR_SMALL_WILL_BE_DEEPLY_APPRECIATED_BY_THE_PROJECTS_TEAM_AND_THE_WIDER_COMMUNITY"), + Text::_("COM_COMPONENTBUILDER_THE_CONTINUED_SUPPORT_OF_INDIVIDUALS_LIKE_YOU_HAS_ALLOWED_JOOMLA_COMPONENT_BUILDER_JCB_TO_THRIVE_FOR_SEVEN_YEARS_SINCE_GOING_PUBLIC_YOUR_CONTRIBUTIONS_HAVE_BEEN_CRUCIAL_IN_ENSURING_THE_GROWTH_AND_RELEVANCE_OF_THIS_VITAL_TOOL_FOR_PHP_PROGRAMMERS_THANK_YOU_FOR_YOUR_SUPPORT_AND_FOR_BEING_A_PART_OF_JCBS_JOURNEY"), + Text::_("COM_COMPONENTBUILDER_SUPPORT_JOOMLA_COMPONENT_BUILDER_JCB_WITH_A_BFINANCIAL_DONATIONB_TO_SHOW_GRATITUDE_FOR_THE_TIME_AND_EFFORT_SAVED_IN_YOUR_DEVELOPMENT_PROCESS_YOUR_CONTRIBUTION_NO_MATTER_THE_SIZE_WILL_BE_APPRECIATED_BY_THE_PROJECTS_TEAM_AND_THE_WIDER_COMMUNITY_HELP_ENSURE_THE_GROWTH_AND_RELEVANCE_OF_THIS_ESSENTIAL_TOOL"), + Text::_("COM_COMPONENTBUILDER_INVEST_IN_THE_FUTURE_OF_JOOMLA_COMPONENT_BUILDER_JCB_BY_MAKING_A_BFINANCIAL_DONATIONB_SUPPORT_THE_NECESSARY_DEVELOPMENT_AND_MAINTENANCE_OF_THIS_OPENSOURCE_PROJECT_ENSURING_ITS_CONTINUED_GROWTH_AND_RELEVANCE_FOR_THE_COMMUNITY_YOUR_CONTRIBUTION_WILL_HELP_SECURE_THE_FUTURE_OF_THIS_VITAL_TOOL_FOR_PHP_PROGRAMMERS"), + Text::_("COM_COMPONENTBUILDER_INVEST_IN_THE_FUTURE_OF_JOOMLA_COMPONENT_BUILDER_JCB_BY_MAKING_A_BFINANCIAL_CONTRIBUTIONB_NO_MATTER_HOW_SMALL_THE_CONTINUAL_SUPPORT_OF_ALL_THOSE_USING_THE_TOOL_WILL_BE_MORE_THAN_ENOUGH_TO_ENSURE_ITS_CONTINUED_GROWTH_AND_RELEVANCE_BY_INVESTING_IN_THIS_OPENSOURCE_PROJECT_YOU_ARE_SECURING_ITS_FUTURE_AS_A_VITAL_TOOL_FOR_PHP_PROGRAMMERS"), + Text::_("COM_COMPONENTBUILDER_WE_EXTEND_OUR_GRATITUDE_TO_ALL_THOSE_WHO_SUPPORT_JOOMLA_COMPONENT_BUILDER_JCB_WHETHER_AS_A_HOBBY_OR_AS_A_PART_OF_THEIR_BUSINESS_YOUR_CONTRIBUTIONS_WHETHER_FINANCIAL_OR_IN_THE_FORM_OF_ACTIVE_INVOLVEMENT_HAVE_HAD_A_SIGNIFICANT_IMPACT_ON_ENSURING_THE_GROWTH_AND_RELEVANCE_OF_THIS_VITAL_TOOL_FOR_PHP_PROGRAMMERS_WE_HIGHLY_VALUE_THE_DEDICATION_OF_HOBBYISTS_AND_THE_COMMITMENT_OF_COMPANIES_WHO_SUPPORT_JCB_AS_THEY_HAVE_ALLOWED_THE_PROJECT_TO_CONTINUE_ITS_DEVELOPMENT_AND_MAINTENANCE_PROVIDING_VALUABLE_RESOURCES_FOR_THE_COMMUNITY_WE_ARE_GRATEFUL_FOR_YOUR_CONTRIBUTIONS_NO_MATTER_HOW_SMALL_AND_THANK_YOU_FOR_BEING_A_PART_OF_THE_POSITIVE_IMPACT_THAT_JCB_HAS_ON_THE_PHP_PROGRAMMING_COMMUNITY"), + Text::_("COM_COMPONENTBUILDER_WITHOUT_SUFFICIENT_SUPPORT_THE_FUTURE_OF_JOOMLA_COMPONENT_BUILDER_JCB_IS_IN_JEOPARDY_AS_A_VITAL_TOOL_FOR_PHP_PROGRAMMERS_IT_IS_CRUCIAL_TO_ENSURE_ITS_CONTINUED_DEVELOPMENT_AND_MAINTENANCE_BY_MAKING_A_BFINANCIAL_CONTRIBUTIONB_NO_MATTER_HOW_SMALL_YOU_ARE_HELPING_TO_SAFEGUARD_THE_FUTURE_OF_THIS_OPENSOURCE_PROJECT_NEGLECTING_TO_SUPPORT_JCB_COULD_RESULT_IN_ITS_DECLINE_AND_LOSS_AS_A_RESOURCE_FOR_THE_COMMUNITY"), + Text::_("COM_COMPONENTBUILDER_WE_EXTEND_OUR_HEARTFELT_APPRECIATION_TO_THOSE_WHO_HAVE_SUPPORTED_THE_JOOMLA_COMPONENT_BUILDER_JCB_PROJECT_OVER_THE_YEARS_YOUR_CONTRIBUTIONS_NO_MATTER_HOW_BIG_OR_SMALL_HAVE_BEEN_INSTRUMENTAL_IN_ENSURING_ITS_GROWTH_AND_RELEVANCE_AS_A_VITAL_TOOL_FOR_PHP_PROGRAMMERS_SEVEN_YEARS_AFTER_GOING_PUBLIC_JCB_IS_STILL_HERE_TODAY_BECAUSE_OF_THE_SUPPORT_OF_INDIVIDUALS_LIKE_YOU_WHO_BELIEVE_IN_THE_IMPORTANCE_OF_THIS_OPENSOURCE_PROJECT_YOUR_GENEROSITY_HAS_ALLOWED_THE_PROJECT_TO_CONTINUE_ITS_DEVELOPMENT_AND_MAINTENANCE_PROVIDING_VALUABLE_RESOURCES_FOR_THE_COMMUNITY_THANK_YOU_FOR_YOUR_UNWAVERING_SUPPORT_AND_FOR_BEING_A_PART_OF_JCBS_JOURNEY"), + Text::_("COM_COMPONENTBUILDER_WE_EXTEND_OUR_SINCERE_APPRECIATION_TO_THE_COMPANIES_WHO_USE_JOOMLA_COMPONENT_BUILDER_JCB_AND_SUPPORT_THE_PROJECT_YOUR_CONTRIBUTIONS_WHETHER_FINANCIAL_OR_IN_THE_FORM_OF_ACTIVE_INVOLVEMENT_HAVE_BEEN_INSTRUMENTAL_IN_ENSURING_THE_GROWTH_AND_RELEVANCE_OF_THIS_VITAL_TOOL_FOR_PHP_PROGRAMMERS_YOUR_SUPPORT_HAS_ALLOWED_JCB_TO_CONTINUE_ITS_DEVELOPMENT_AND_MAINTENANCE_PROVIDING_VALUABLE_RESOURCES_FOR_THE_COMMUNITY_THANK_YOU_FOR_YOUR_UNWAVERING_COMMITMENT_TO_THE_PROJECT_AND_FOR_BEING_A_PART_OF_JCBS_JOURNEY") ]; // build the support message @@ -30,36 +38,36 @@ $support_message = $support[random_int(0, 8)]; // the button titles $titles = [ - JText::_("COM_COMPONENTBUILDER_JCB_ENABLES_PHP_DEVELOPMENT"), - JText::_("COM_COMPONENTBUILDER_JCB_SUPPORTS_OPENSOURCE"), - JText::_("COM_COMPONENTBUILDER_JCB_SAVES_TIME"), - JText::_("COM_COMPONENTBUILDER_JCB_IMPROVES_WORKFLOW"), - JText::_("COM_COMPONENTBUILDER_JCB_EMPOWERS_PHP_DEVELOPERS"), - JText::_("COM_COMPONENTBUILDER_JCB_STREAMLINES_DEVELOPMENT"), - JText::_("COM_COMPONENTBUILDER_JCB_PROMOTES_EFFICIENCY"), - JText::_("COM_COMPONENTBUILDER_JCB_ENHANCES_PRODUCTIVITY"), - JText::_("COM_COMPONENTBUILDER_JCB_INCREASES_REVENUE"), - JText::_("COM_COMPONENTBUILDER_JCB_REDUCES_DEVELOPMENT_COSTS"), - JText::_("COM_COMPONENTBUILDER_JCB_SUPPORTS_THE_PHP_COMMUNITY"), - JText::_("COM_COMPONENTBUILDER_JCB_IMPROVES_PHP_DEVELOPMENT"), - JText::_("COM_COMPONENTBUILDER_JCB_HELPS_GROW_BUSINESSES"), - JText::_("COM_COMPONENTBUILDER_JCB_SUPPORTS_PHP_INNOVATION"), - JText::_("COM_COMPONENTBUILDER_JCB_CONTRIBUTES_TO_OPENSOURCE"), - JText::_("COM_COMPONENTBUILDER_JCB_PROVIDES_A_BETTER_EXPERIENCE"), - JText::_("COM_COMPONENTBUILDER_JCB_OFFERS_MORE_FEATURES"), - JText::_("COM_COMPONENTBUILDER_JCB_INCREASES_DEVELOPMENT_SPEED"), - JText::_("COM_COMPONENTBUILDER_JCB_IMPROVES_USER_EXPERIENCE"), - JText::_("COM_COMPONENTBUILDER_JCB_INCREASES_USER_SATISFACTION"), - JText::_("COM_COMPONENTBUILDER_JCB_LOWERS_DEVELOPMENT_STRESS"), - JText::_("COM_COMPONENTBUILDER_JCB_PROMOTES_GOODWILL"), - JText::_("COM_COMPONENTBUILDER_JCB_OFFERS_A_STRONGER_SOLUTION"), - JText::_("COM_COMPONENTBUILDER_JCB_SUPPORTS_A_WORTHY_CAUSE"), - JText::_("COM_COMPONENTBUILDER_JCB_BUILDS_A_BETTER_FUTURE"), - JText::_("COM_COMPONENTBUILDER_JCB_FOSTERS_A_STRONG_COMMUNITY"), - JText::_("COM_COMPONENTBUILDER_JCB_IMPROVES_PHPS_REPUTATION"), - JText::_("COM_COMPONENTBUILDER_JCB_SUPPORTS_A_THRIVING_ECOSYSTEM"), - JText::_("COM_COMPONENTBUILDER_JCB_HELPS_PHP_THRIVE"), - JText::_("COM_COMPONENTBUILDER_JCB_INVESTS_IN_PHPS_SUCCESS") + Text::_("COM_COMPONENTBUILDER_JCB_ENABLES_PHP_DEVELOPMENT"), + Text::_("COM_COMPONENTBUILDER_JCB_SUPPORTS_OPENSOURCE"), + Text::_("COM_COMPONENTBUILDER_JCB_SAVES_TIME"), + Text::_("COM_COMPONENTBUILDER_JCB_IMPROVES_WORKFLOW"), + Text::_("COM_COMPONENTBUILDER_JCB_EMPOWERS_PHP_DEVELOPERS"), + Text::_("COM_COMPONENTBUILDER_JCB_STREAMLINES_DEVELOPMENT"), + Text::_("COM_COMPONENTBUILDER_JCB_PROMOTES_EFFICIENCY"), + Text::_("COM_COMPONENTBUILDER_JCB_ENHANCES_PRODUCTIVITY"), + Text::_("COM_COMPONENTBUILDER_JCB_INCREASES_REVENUE"), + Text::_("COM_COMPONENTBUILDER_JCB_REDUCES_DEVELOPMENT_COSTS"), + Text::_("COM_COMPONENTBUILDER_JCB_SUPPORTS_THE_PHP_COMMUNITY"), + Text::_("COM_COMPONENTBUILDER_JCB_IMPROVES_PHP_DEVELOPMENT"), + Text::_("COM_COMPONENTBUILDER_JCB_HELPS_GROW_BUSINESSES"), + Text::_("COM_COMPONENTBUILDER_JCB_SUPPORTS_PHP_INNOVATION"), + Text::_("COM_COMPONENTBUILDER_JCB_CONTRIBUTES_TO_OPENSOURCE"), + Text::_("COM_COMPONENTBUILDER_JCB_PROVIDES_A_BETTER_EXPERIENCE"), + Text::_("COM_COMPONENTBUILDER_JCB_OFFERS_MORE_FEATURES"), + Text::_("COM_COMPONENTBUILDER_JCB_INCREASES_DEVELOPMENT_SPEED"), + Text::_("COM_COMPONENTBUILDER_JCB_IMPROVES_USER_EXPERIENCE"), + Text::_("COM_COMPONENTBUILDER_JCB_INCREASES_USER_SATISFACTION"), + Text::_("COM_COMPONENTBUILDER_JCB_LOWERS_DEVELOPMENT_STRESS"), + Text::_("COM_COMPONENTBUILDER_JCB_PROMOTES_GOODWILL"), + Text::_("COM_COMPONENTBUILDER_JCB_OFFERS_A_STRONGER_SOLUTION"), + Text::_("COM_COMPONENTBUILDER_JCB_SUPPORTS_A_WORTHY_CAUSE"), + Text::_("COM_COMPONENTBUILDER_JCB_BUILDS_A_BETTER_FUTURE"), + Text::_("COM_COMPONENTBUILDER_JCB_FOSTERS_A_STRONG_COMMUNITY"), + Text::_("COM_COMPONENTBUILDER_JCB_IMPROVES_PHPS_REPUTATION"), + Text::_("COM_COMPONENTBUILDER_JCB_SUPPORTS_A_THRIVING_ECOSYSTEM"), + Text::_("COM_COMPONENTBUILDER_JCB_HELPS_PHP_THRIVE"), + Text::_("COM_COMPONENTBUILDER_JCB_INVESTS_IN_PHPS_SUCCESS") ]; // build the support button @@ -67,39 +75,39 @@ $support_titles = $titles[random_int(0, 29)]; // the button names $button_names = [ - JText::_("COM_COMPONENTBUILDER_DONATE_TO_JCB"), - JText::_("COM_COMPONENTBUILDER_SUPPORT_JCB_TODAY"), - JText::_("COM_COMPONENTBUILDER_CONTRIBUTE_TO_JCB"), - JText::_("COM_COMPONENTBUILDER_INVEST_IN_JCB"), - JText::_("COM_COMPONENTBUILDER_GIVE_TO_JCB"), - JText::_("COM_COMPONENTBUILDER_JOIN_JCBS_MISSION"), - JText::_("COM_COMPONENTBUILDER_HELP_JCB_GROW"), - JText::_("COM_COMPONENTBUILDER_BE_A_PART_OF_JCB"), - JText::_("COM_COMPONENTBUILDER_JCB_NEEDS_YOU"), - JText::_("COM_COMPONENTBUILDER_BECOME_A_CONTRIBUTOR"), - JText::_("COM_COMPONENTBUILDER_EMPOWER_JCB"), - JText::_("COM_COMPONENTBUILDER_JCB_INVEST_IN_IMPACT"), - JText::_("COM_COMPONENTBUILDER_JOIN_JCBS_COMMUNITY"), - JText::_("COM_COMPONENTBUILDER_MAKE_A_DIFFERENCE_WITH_JCB"), - JText::_("COM_COMPONENTBUILDER_JCB_YOUR_SUPPORT_MATTERS"), - JText::_("COM_COMPONENTBUILDER_JCB_INVEST_IN_THE_FUTURE"), - JText::_("COM_COMPONENTBUILDER_JOIN_JCBS_JOURNEY"), - JText::_("COM_COMPONENTBUILDER_JCB_YOUR_SUPPORT_COUNTS"), - JText::_("COM_COMPONENTBUILDER_EMPOWER_THE_FUTURE_WITH_JCB"), - JText::_("COM_COMPONENTBUILDER_JCB_YOUR_CONTRIBUTION_MATTERS"), - JText::_("COM_COMPONENTBUILDER_JCB_INVEST_IN_PROGRESS"), - JText::_("COM_COMPONENTBUILDER_JOIN_JCBS_VISION"), - JText::_("COM_COMPONENTBUILDER_ELEVATE_JCB_TODAY"), - JText::_("COM_COMPONENTBUILDER_JCB_INVEST_IN_CHANGE"), - JText::_("COM_COMPONENTBUILDER_JCB_YOUR_DONATION_MATTERS"), - JText::_("COM_COMPONENTBUILDER_JCB_BE_THE_CHANGE"), - JText::_("COM_COMPONENTBUILDER_JOIN_JCBS_SUCCESS"), - JText::_("COM_COMPONENTBUILDER_JCB_INVEST_IN_SUCCESS"), - JText::_("COM_COMPONENTBUILDER_JCB_YOUR_SUPPORT_IS_KEY"), - JText::_("COM_COMPONENTBUILDER_JCB_INVEST_IN_THE_COMMUNITY"), - JText::_("COM_COMPONENTBUILDER_JCB_YOUR_SUPPORT_MATTERS_MOST"), - JText::_("COM_COMPONENTBUILDER_JCB_INVEST_IN_YOUR_FUTURE"), - JText::_("COM_COMPONENTBUILDER_JCB_INVEST_IN_PROGRESS_TODAY") + Text::_("COM_COMPONENTBUILDER_DONATE_TO_JCB"), + Text::_("COM_COMPONENTBUILDER_SUPPORT_JCB_TODAY"), + Text::_("COM_COMPONENTBUILDER_CONTRIBUTE_TO_JCB"), + Text::_("COM_COMPONENTBUILDER_INVEST_IN_JCB"), + Text::_("COM_COMPONENTBUILDER_GIVE_TO_JCB"), + Text::_("COM_COMPONENTBUILDER_JOIN_JCBS_MISSION"), + Text::_("COM_COMPONENTBUILDER_HELP_JCB_GROW"), + Text::_("COM_COMPONENTBUILDER_BE_A_PART_OF_JCB"), + Text::_("COM_COMPONENTBUILDER_JCB_NEEDS_YOU"), + Text::_("COM_COMPONENTBUILDER_BECOME_A_CONTRIBUTOR"), + Text::_("COM_COMPONENTBUILDER_EMPOWER_JCB"), + Text::_("COM_COMPONENTBUILDER_JCB_INVEST_IN_IMPACT"), + Text::_("COM_COMPONENTBUILDER_JOIN_JCBS_COMMUNITY"), + Text::_("COM_COMPONENTBUILDER_MAKE_A_DIFFERENCE_WITH_JCB"), + Text::_("COM_COMPONENTBUILDER_JCB_YOUR_SUPPORT_MATTERS"), + Text::_("COM_COMPONENTBUILDER_JCB_INVEST_IN_THE_FUTURE"), + Text::_("COM_COMPONENTBUILDER_JOIN_JCBS_JOURNEY"), + Text::_("COM_COMPONENTBUILDER_JCB_YOUR_SUPPORT_COUNTS"), + Text::_("COM_COMPONENTBUILDER_EMPOWER_THE_FUTURE_WITH_JCB"), + Text::_("COM_COMPONENTBUILDER_JCB_YOUR_CONTRIBUTION_MATTERS"), + Text::_("COM_COMPONENTBUILDER_JCB_INVEST_IN_PROGRESS"), + Text::_("COM_COMPONENTBUILDER_JOIN_JCBS_VISION"), + Text::_("COM_COMPONENTBUILDER_ELEVATE_JCB_TODAY"), + Text::_("COM_COMPONENTBUILDER_JCB_INVEST_IN_CHANGE"), + Text::_("COM_COMPONENTBUILDER_JCB_YOUR_DONATION_MATTERS"), + Text::_("COM_COMPONENTBUILDER_JCB_BE_THE_CHANGE"), + Text::_("COM_COMPONENTBUILDER_JOIN_JCBS_SUCCESS"), + Text::_("COM_COMPONENTBUILDER_JCB_INVEST_IN_SUCCESS"), + Text::_("COM_COMPONENTBUILDER_JCB_YOUR_SUPPORT_IS_KEY"), + Text::_("COM_COMPONENTBUILDER_JCB_INVEST_IN_THE_COMMUNITY"), + Text::_("COM_COMPONENTBUILDER_JCB_YOUR_SUPPORT_MATTERS_MOST"), + Text::_("COM_COMPONENTBUILDER_JCB_INVEST_IN_YOUR_FUTURE"), + Text::_("COM_COMPONENTBUILDER_JCB_INVEST_IN_PROGRESS_TODAY") ]; // build the support button diff --git a/admin/layouts/joomla_component/admin_views_fullwidth.php b/admin/layouts/joomla_component/admin_views_fullwidth.php index 49ecdf8a6..5ae6488c2 100644 --- a/admin/layouts/joomla_component/admin_views_fullwidth.php +++ b/admin/layouts/joomla_component/admin_views_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_display_component_admin_views' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_component/custom_admin_views_fullwidth.php b/admin/layouts/joomla_component/custom_admin_views_fullwidth.php index 0b1cc116a..054b10525 100644 --- a/admin/layouts/joomla_component/custom_admin_views_fullwidth.php +++ b/admin/layouts/joomla_component/custom_admin_views_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_display_component_custom_admin_views' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_component/dash_install_fullwidth.php b/admin/layouts/joomla_component/dash_install_fullwidth.php index 7eccffe1f..8272f233d 100644 --- a/admin/layouts/joomla_component/dash_install_fullwidth.php +++ b/admin/layouts/joomla_component/dash_install_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -38,7 +38,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'php_method_uninstall' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_component/dash_install_left.php b/admin/layouts/joomla_component/dash_install_left.php index 636e104f9..900a1c137 100644 --- a/admin/layouts/joomla_component/dash_install_left.php +++ b/admin/layouts/joomla_component/dash_install_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'dashboard_type' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_component/dash_install_right.php b/admin/layouts/joomla_component/dash_install_right.php index 510a9183e..07cf56910 100644 --- a/admin/layouts/joomla_component/dash_install_right.php +++ b/admin/layouts/joomla_component/dash_install_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,7 +31,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_botton_component_dashboard' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_component/details_above.php b/admin/layouts/joomla_component/details_above.php index 6cbed1d15..d47075ea0 100644 --- a/admin/layouts/joomla_component/details_above.php +++ b/admin/layouts/joomla_component/details_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,21 +25,30 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'system_name', + 'preferred_joomla_version', 'add_powers' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/joomla_component/details_left.php b/admin/layouts/joomla_component/details_left.php index 9ddb7a9a8..403760712 100644 --- a/admin/layouts/joomla_component/details_left.php +++ b/admin/layouts/joomla_component/details_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -40,7 +40,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'description' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_component/details_right.php b/admin/layouts/joomla_component/details_right.php index 2015302da..8c3b5140d 100644 --- a/admin/layouts/joomla_component/details_right.php +++ b/admin/layouts/joomla_component/details_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -42,7 +42,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'copyright' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_component/details_under.php b/admin/layouts/joomla_component/details_under.php index 68af44f9c..48a7d40a0 100644 --- a/admin/layouts/joomla_component/details_under.php +++ b/admin/layouts/joomla_component/details_under.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'not_required' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/joomla_component/dynamic_build_beta_fullwidth.php b/admin/layouts/joomla_component/dynamic_build_beta_fullwidth.php index 8f152abbf..1430ba013 100644 --- a/admin/layouts/joomla_component/dynamic_build_beta_fullwidth.php +++ b/admin/layouts/joomla_component/dynamic_build_beta_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,7 +31,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'buildcompsql' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_component/dynamic_integration_left.php b/admin/layouts/joomla_component/dynamic_integration_left.php index f1b7da7e0..9ea5a572c 100644 --- a/admin/layouts/joomla_component/dynamic_integration_left.php +++ b/admin/layouts/joomla_component/dynamic_integration_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -43,7 +43,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'git_folder_path' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_component/dynamic_integration_right.php b/admin/layouts/joomla_component/dynamic_integration_right.php index 36d48a06f..23843ac7c 100644 --- a/admin/layouts/joomla_component/dynamic_integration_right.php +++ b/admin/layouts/joomla_component/dynamic_integration_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'crowdin_account_api_key' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_component/libs_helpers_fullwidth.php b/admin/layouts/joomla_component/libs_helpers_fullwidth.php index 4bb7292fb..749374ecb 100644 --- a/admin/layouts/joomla_component/libs_helpers_fullwidth.php +++ b/admin/layouts/joomla_component/libs_helpers_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -48,7 +48,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'css_site' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_component/metadata.php b/admin/layouts/joomla_component/metadata.php index 47d8b22df..a1ff7c388 100644 --- a/admin/layouts/joomla_component/metadata.php +++ b/admin/layouts/joomla_component/metadata.php @@ -9,8 +9,10 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +use Joomla\CMS\Language\Text; + // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; $form = $displayData->getForm(); @@ -20,7 +22,7 @@ $fieldSets = $form->getFieldsets('metadata'); $fieldSet) : ?> description) && trim($fieldSet->description)) : ?> -

    escape(JText::_($fieldSet->description)); ?>

    +

    escape(Text::_($fieldSet->description)); ?>

    getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'assets_table_fix' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_component/publishing.php b/admin/layouts/joomla_component/publishing.php index 0375c1a3a..d7bc0c393 100644 --- a/admin/layouts/joomla_component/publishing.php +++ b/admin/layouts/joomla_component/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -40,7 +40,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_component/readme_left.php b/admin/layouts/joomla_component/readme_left.php index 767d64d89..ef139ee3c 100644 --- a/admin/layouts/joomla_component/readme_left.php +++ b/admin/layouts/joomla_component/readme_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'readme' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_component/readme_right.php b/admin/layouts/joomla_component/readme_right.php index 8d81512fc..a123b7ec2 100644 --- a/admin/layouts/joomla_component/readme_right.php +++ b/admin/layouts/joomla_component/readme_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_readme' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_component/settings_fullwidth.php b/admin/layouts/joomla_component/settings_fullwidth.php index f8b075556..ce706bc13 100644 --- a/admin/layouts/joomla_component/settings_fullwidth.php +++ b/admin/layouts/joomla_component/settings_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -26,14 +26,14 @@ $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields $fields = $displayData->get($fields_tab_layout) ?: array( - 'spacer_hr_7', + 'spacer_hr_8', 'note_on_contributors', 'addcontributors', 'emptycontributors', 'number' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_component/settings_left.php b/admin/layouts/joomla_component/settings_left.php index 55a1ee310..4fbbe76bb 100644 --- a/admin/layouts/joomla_component/settings_left.php +++ b/admin/layouts/joomla_component/settings_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -35,7 +35,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_add_config' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_component/settings_right.php b/admin/layouts/joomla_component/settings_right.php index 9b45ab209..539523b70 100644 --- a/admin/layouts/joomla_component/settings_right.php +++ b/admin/layouts/joomla_component/settings_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -28,19 +28,22 @@ $fields_tab_layout = 'fields_' . $layout_path_array[1]; $fields = $displayData->get($fields_tab_layout) ?: array( 'note_component_files_folders', 'spacer_hr_4', + 'add_namespace_prefix', + 'namespace_prefix', + 'spacer_hr_5', 'add_menu_prefix', 'menu_prefix', - 'spacer_hr_5', + 'spacer_hr_6', 'to_ignore_note', 'toignore', - 'spacer_hr_6', + 'spacer_hr_7', 'jcb_export_package_note', 'export_key', 'joomla_source_link', 'export_buy_link' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_component/site_views_fullwidth.php b/admin/layouts/joomla_component/site_views_fullwidth.php index 5ea3ff9a1..223e8067b 100644 --- a/admin/layouts/joomla_component/site_views_fullwidth.php +++ b/admin/layouts/joomla_component/site_views_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_display_component_site_views' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module/code_fullwidth.php b/admin/layouts/joomla_module/code_fullwidth.php index 7ba3cd28c..c62d366f4 100644 --- a/admin/layouts/joomla_module/code_fullwidth.php +++ b/admin/layouts/joomla_module/code_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'mod_code' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module/code_left.php b/admin/layouts/joomla_module/code_left.php index 224902240..12dfd1018 100644 --- a/admin/layouts/joomla_module/code_left.php +++ b/admin/layouts/joomla_module/code_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'custom_get' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module/code_right.php b/admin/layouts/joomla_module/code_right.php index 8a59d48d4..2fde4bf07 100644 --- a/admin/layouts/joomla_module/code_right.php +++ b/admin/layouts/joomla_module/code_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_mod_file_options' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module/dynamic_integration_left.php b/admin/layouts/joomla_module/dynamic_integration_left.php index c35d75f98..0f17ae60f 100644 --- a/admin/layouts/joomla_module/dynamic_integration_left.php +++ b/admin/layouts/joomla_module/dynamic_integration_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -37,7 +37,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'sales_server' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module/forms_fields_fullwidth.php b/admin/layouts/joomla_module/forms_fields_fullwidth.php index 7de237af2..b091370a8 100644 --- a/admin/layouts/joomla_module/forms_fields_fullwidth.php +++ b/admin/layouts/joomla_module/forms_fields_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'fields' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module/helper_fullwidth.php b/admin/layouts/joomla_module/helper_fullwidth.php index ebfea4515..258b9603e 100644 --- a/admin/layouts/joomla_module/helper_fullwidth.php +++ b/admin/layouts/joomla_module/helper_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'class_helper_code' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module/helper_left.php b/admin/layouts/joomla_module/helper_left.php index ff4aab6f6..7cbbe1ad3 100644 --- a/admin/layouts/joomla_module/helper_left.php +++ b/admin/layouts/joomla_module/helper_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'add_class_helper' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module/helper_right.php b/admin/layouts/joomla_module/helper_right.php index 0778bbd69..660e3d64d 100644 --- a/admin/layouts/joomla_module/helper_right.php +++ b/admin/layouts/joomla_module/helper_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'add_class_helper_header' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module/html_above.php b/admin/layouts/joomla_module/html_above.php index 85fb585df..3efdf278d 100644 --- a/admin/layouts/joomla_module/html_above.php +++ b/admin/layouts/joomla_module/html_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,22 +25,30 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'system_name', 'module_version', 'target' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/joomla_module/html_fullwidth.php b/admin/layouts/joomla_module/html_fullwidth.php index 84d9224f9..d6f350ef7 100644 --- a/admin/layouts/joomla_module/html_fullwidth.php +++ b/admin/layouts/joomla_module/html_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,7 +31,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'not_required' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module/html_left.php b/admin/layouts/joomla_module/html_left.php index 5e6a487b9..a0060b874 100644 --- a/admin/layouts/joomla_module/html_left.php +++ b/admin/layouts/joomla_module/html_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_add_php_language_string' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module/html_right.php b/admin/layouts/joomla_module/html_right.php index f7e79a421..f25450071 100644 --- a/admin/layouts/joomla_module/html_right.php +++ b/admin/layouts/joomla_module/html_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,7 +31,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_snippet_usage' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module/mysql_fullwidth.php b/admin/layouts/joomla_module/mysql_fullwidth.php index acde25167..bd6f06ad9 100644 --- a/admin/layouts/joomla_module/mysql_fullwidth.php +++ b/admin/layouts/joomla_module/mysql_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -32,7 +32,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'sql_uninstall' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module/publishing.php b/admin/layouts/joomla_module/publishing.php index 97a901504..d4d7b688e 100644 --- a/admin/layouts/joomla_module/publishing.php +++ b/admin/layouts/joomla_module/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module/publlshing.php b/admin/layouts/joomla_module/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/joomla_module/publlshing.php +++ b/admin/layouts/joomla_module/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module/readme_left.php b/admin/layouts/joomla_module/readme_left.php index 767d64d89..ef139ee3c 100644 --- a/admin/layouts/joomla_module/readme_left.php +++ b/admin/layouts/joomla_module/readme_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'readme' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module/script_file_fullwidth.php b/admin/layouts/joomla_module/script_file_fullwidth.php index 8c37a873c..06e47d901 100644 --- a/admin/layouts/joomla_module/script_file_fullwidth.php +++ b/admin/layouts/joomla_module/script_file_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -42,7 +42,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'php_method_uninstall' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module_files_folders_urls/advance_fullwidth.php b/admin/layouts/joomla_module_files_folders_urls/advance_fullwidth.php index 5fd19b54f..01e66ad5b 100644 --- a/admin/layouts/joomla_module_files_folders_urls/advance_fullwidth.php +++ b/admin/layouts/joomla_module_files_folders_urls/advance_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_constant_paths' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module_files_folders_urls/basic_above.php b/admin/layouts/joomla_module_files_folders_urls/basic_above.php index 91f5cad4c..508f4ebe0 100644 --- a/admin/layouts/joomla_module_files_folders_urls/basic_above.php +++ b/admin/layouts/joomla_module_files_folders_urls/basic_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'joomla_module' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/joomla_module_files_folders_urls/basic_fullwidth.php b/admin/layouts/joomla_module_files_folders_urls/basic_fullwidth.php index 5026c32d6..7d87174d9 100644 --- a/admin/layouts/joomla_module_files_folders_urls/basic_fullwidth.php +++ b/admin/layouts/joomla_module_files_folders_urls/basic_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'addfolders' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module_files_folders_urls/publishing.php b/admin/layouts/joomla_module_files_folders_urls/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/joomla_module_files_folders_urls/publishing.php +++ b/admin/layouts/joomla_module_files_folders_urls/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module_files_folders_urls/publlshing.php b/admin/layouts/joomla_module_files_folders_urls/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/joomla_module_files_folders_urls/publlshing.php +++ b/admin/layouts/joomla_module_files_folders_urls/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module_updates/publishing.php b/admin/layouts/joomla_module_updates/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/joomla_module_updates/publishing.php +++ b/admin/layouts/joomla_module_updates/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module_updates/publlshing.php b/admin/layouts/joomla_module_updates/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/joomla_module_updates/publlshing.php +++ b/admin/layouts/joomla_module_updates/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_module_updates/updates_above.php b/admin/layouts/joomla_module_updates/updates_above.php index 91f5cad4c..508f4ebe0 100644 --- a/admin/layouts/joomla_module_updates/updates_above.php +++ b/admin/layouts/joomla_module_updates/updates_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'joomla_module' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/joomla_module_updates/updates_fullwidth.php b/admin/layouts/joomla_module_updates/updates_fullwidth.php index ccf6866f5..f1705d2a3 100644 --- a/admin/layouts/joomla_module_updates/updates_fullwidth.php +++ b/admin/layouts/joomla_module_updates/updates_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'version_update' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin/code_above.php b/admin/layouts/joomla_plugin/code_above.php index 8af6e74c1..fffd30b55 100644 --- a/admin/layouts/joomla_plugin/code_above.php +++ b/admin/layouts/joomla_plugin/code_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,21 +25,29 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'system_name', 'plugin_version' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/joomla_plugin/code_fullwidth.php b/admin/layouts/joomla_plugin/code_fullwidth.php index 7b0382906..f6c5446f8 100644 --- a/admin/layouts/joomla_plugin/code_fullwidth.php +++ b/admin/layouts/joomla_plugin/code_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -32,7 +32,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'not_required' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin/code_left.php b/admin/layouts/joomla_plugin/code_left.php index 6bbaf6c61..770da6a8f 100644 --- a/admin/layouts/joomla_plugin/code_left.php +++ b/admin/layouts/joomla_plugin/code_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_plugin' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin/code_right.php b/admin/layouts/joomla_plugin/code_right.php index cce180871..f8abc809f 100644 --- a/admin/layouts/joomla_plugin/code_right.php +++ b/admin/layouts/joomla_plugin/code_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'method_selection' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin/dynamic_integration_left.php b/admin/layouts/joomla_plugin/dynamic_integration_left.php index c35d75f98..0f17ae60f 100644 --- a/admin/layouts/joomla_plugin/dynamic_integration_left.php +++ b/admin/layouts/joomla_plugin/dynamic_integration_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -37,7 +37,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'sales_server' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin/forms_fields_fullwidth.php b/admin/layouts/joomla_plugin/forms_fields_fullwidth.php index 7de237af2..b091370a8 100644 --- a/admin/layouts/joomla_plugin/forms_fields_fullwidth.php +++ b/admin/layouts/joomla_plugin/forms_fields_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'fields' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin/mysql_fullwidth.php b/admin/layouts/joomla_plugin/mysql_fullwidth.php index acde25167..bd6f06ad9 100644 --- a/admin/layouts/joomla_plugin/mysql_fullwidth.php +++ b/admin/layouts/joomla_plugin/mysql_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -32,7 +32,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'sql_uninstall' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin/publishing.php b/admin/layouts/joomla_plugin/publishing.php index 97a901504..d4d7b688e 100644 --- a/admin/layouts/joomla_plugin/publishing.php +++ b/admin/layouts/joomla_plugin/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin/publlshing.php b/admin/layouts/joomla_plugin/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/joomla_plugin/publlshing.php +++ b/admin/layouts/joomla_plugin/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin/readme_left.php b/admin/layouts/joomla_plugin/readme_left.php index 767d64d89..ef139ee3c 100644 --- a/admin/layouts/joomla_plugin/readme_left.php +++ b/admin/layouts/joomla_plugin/readme_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'readme' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin/script_file_fullwidth.php b/admin/layouts/joomla_plugin/script_file_fullwidth.php index 8c37a873c..06e47d901 100644 --- a/admin/layouts/joomla_plugin/script_file_fullwidth.php +++ b/admin/layouts/joomla_plugin/script_file_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -42,7 +42,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'php_method_uninstall' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin_files_folders_urls/advance_fullwidth.php b/admin/layouts/joomla_plugin_files_folders_urls/advance_fullwidth.php index 5fd19b54f..01e66ad5b 100644 --- a/admin/layouts/joomla_plugin_files_folders_urls/advance_fullwidth.php +++ b/admin/layouts/joomla_plugin_files_folders_urls/advance_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_constant_paths' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin_files_folders_urls/basic_above.php b/admin/layouts/joomla_plugin_files_folders_urls/basic_above.php index 0aa6bd601..3e1f0e2b1 100644 --- a/admin/layouts/joomla_plugin_files_folders_urls/basic_above.php +++ b/admin/layouts/joomla_plugin_files_folders_urls/basic_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'joomla_plugin' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/joomla_plugin_files_folders_urls/basic_fullwidth.php b/admin/layouts/joomla_plugin_files_folders_urls/basic_fullwidth.php index 5026c32d6..7d87174d9 100644 --- a/admin/layouts/joomla_plugin_files_folders_urls/basic_fullwidth.php +++ b/admin/layouts/joomla_plugin_files_folders_urls/basic_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'addfolders' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin_files_folders_urls/publishing.php b/admin/layouts/joomla_plugin_files_folders_urls/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/joomla_plugin_files_folders_urls/publishing.php +++ b/admin/layouts/joomla_plugin_files_folders_urls/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin_files_folders_urls/publlshing.php b/admin/layouts/joomla_plugin_files_folders_urls/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/joomla_plugin_files_folders_urls/publlshing.php +++ b/admin/layouts/joomla_plugin_files_folders_urls/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin_group/details_left.php b/admin/layouts/joomla_plugin_group/details_left.php index 10724a9ed..83d570681 100644 --- a/admin/layouts/joomla_plugin_group/details_left.php +++ b/admin/layouts/joomla_plugin_group/details_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'name' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin_group/details_right.php b/admin/layouts/joomla_plugin_group/details_right.php index 5e8f3f7a9..f6a3b9fc7 100644 --- a/admin/layouts/joomla_plugin_group/details_right.php +++ b/admin/layouts/joomla_plugin_group/details_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'class_extends' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin_group/publishing.php b/admin/layouts/joomla_plugin_group/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/joomla_plugin_group/publishing.php +++ b/admin/layouts/joomla_plugin_group/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin_group/publlshing.php b/admin/layouts/joomla_plugin_group/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/joomla_plugin_group/publlshing.php +++ b/admin/layouts/joomla_plugin_group/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin_updates/publishing.php b/admin/layouts/joomla_plugin_updates/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/joomla_plugin_updates/publishing.php +++ b/admin/layouts/joomla_plugin_updates/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin_updates/publlshing.php b/admin/layouts/joomla_plugin_updates/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/joomla_plugin_updates/publlshing.php +++ b/admin/layouts/joomla_plugin_updates/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/joomla_plugin_updates/updates_above.php b/admin/layouts/joomla_plugin_updates/updates_above.php index 0aa6bd601..3e1f0e2b1 100644 --- a/admin/layouts/joomla_plugin_updates/updates_above.php +++ b/admin/layouts/joomla_plugin_updates/updates_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'joomla_plugin' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/joomla_plugin_updates/updates_fullwidth.php b/admin/layouts/joomla_plugin_updates/updates_fullwidth.php index ccf6866f5..f1705d2a3 100644 --- a/admin/layouts/joomla_plugin_updates/updates_fullwidth.php +++ b/admin/layouts/joomla_plugin_updates/updates_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'version_update' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/language/details_left.php b/admin/layouts/language/details_left.php index 10724a9ed..83d570681 100644 --- a/admin/layouts/language/details_left.php +++ b/admin/layouts/language/details_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'name' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/language/details_right.php b/admin/layouts/language/details_right.php index 5c45f24bd..244a1e9b0 100644 --- a/admin/layouts/language/details_right.php +++ b/admin/layouts/language/details_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'langtag' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/language/publishing.php b/admin/layouts/language/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/language/publishing.php +++ b/admin/layouts/language/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/language/publlshing.php b/admin/layouts/language/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/language/publlshing.php +++ b/admin/layouts/language/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/language_translation/details_fullwidth.php b/admin/layouts/language_translation/details_fullwidth.php index 46179d851..87ac3e2fb 100644 --- a/admin/layouts/language_translation/details_fullwidth.php +++ b/admin/layouts/language_translation/details_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'plugins' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/language_translation/publishing.php b/admin/layouts/language_translation/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/language_translation/publishing.php +++ b/admin/layouts/language_translation/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/language_translation/publlshing.php b/admin/layouts/language_translation/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/language_translation/publlshing.php +++ b/admin/layouts/language_translation/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/layout/custom_script_fullwidth.php b/admin/layouts/layout/custom_script_fullwidth.php index edba69106..106b05f32 100644 --- a/admin/layouts/layout/custom_script_fullwidth.php +++ b/admin/layouts/layout/custom_script_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'php_view' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/layout/details_fullwidth.php b/admin/layouts/layout/details_fullwidth.php index 4bc5550c6..ca78c4bd3 100644 --- a/admin/layouts/layout/details_fullwidth.php +++ b/admin/layouts/layout/details_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'layout' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/layout/details_left.php b/admin/layouts/layout/details_left.php index 876f27db5..520ed7b0f 100644 --- a/admin/layouts/layout/details_left.php +++ b/admin/layouts/layout/details_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_add_php_language_string' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/layout/details_right.php b/admin/layouts/layout/details_right.php index f7e79a421..f25450071 100644 --- a/admin/layouts/layout/details_right.php +++ b/admin/layouts/layout/details_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,7 +31,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_snippet_usage' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/layout/details_rightside.php b/admin/layouts/layout/details_rightside.php index 466f72e12..ee79fb78f 100644 --- a/admin/layouts/layout/details_rightside.php +++ b/admin/layouts/layout/details_rightside.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'dynamic_values' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/layout/details_under.php b/admin/layouts/layout/details_under.php index 68af44f9c..48a7d40a0 100644 --- a/admin/layouts/layout/details_under.php +++ b/admin/layouts/layout/details_under.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'not_required' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/layout/publishing.php b/admin/layouts/layout/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/layout/publishing.php +++ b/admin/layouts/layout/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/layout/publlshing.php b/admin/layouts/layout/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/layout/publlshing.php +++ b/admin/layouts/layout/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/library/behaviour_above.php b/admin/layouts/library/behaviour_above.php index e1a453bf9..f8367f55a 100644 --- a/admin/layouts/library/behaviour_above.php +++ b/admin/layouts/library/behaviour_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,23 +25,31 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'name', 'target', 'how', 'type' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/library/behaviour_fullwidth.php b/admin/layouts/library/behaviour_fullwidth.php index 0e3318e96..bc8f1f151 100644 --- a/admin/layouts/library/behaviour_fullwidth.php +++ b/admin/layouts/library/behaviour_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'php_setdocument' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/library/behaviour_left.php b/admin/layouts/library/behaviour_left.php index d2e6922bd..71366ad82 100644 --- a/admin/layouts/library/behaviour_left.php +++ b/admin/layouts/library/behaviour_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'libraries' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/library/behaviour_right.php b/admin/layouts/library/behaviour_right.php index 37215496b..aefe7858d 100644 --- a/admin/layouts/library/behaviour_right.php +++ b/admin/layouts/library/behaviour_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'description' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/library/behaviour_under.php b/admin/layouts/library/behaviour_under.php index 68af44f9c..48a7d40a0 100644 --- a/admin/layouts/library/behaviour_under.php +++ b/admin/layouts/library/behaviour_under.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'not_required' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/library/config_fullwidth.php b/admin/layouts/library/config_fullwidth.php index 03f0a08a7..cac693c62 100644 --- a/admin/layouts/library/config_fullwidth.php +++ b/admin/layouts/library/config_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -32,7 +32,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_display_library_config' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/library/files_folders_urls_fullwidth.php b/admin/layouts/library/files_folders_urls_fullwidth.php index 3f3f9ac75..79990f330 100644 --- a/admin/layouts/library/files_folders_urls_fullwidth.php +++ b/admin/layouts/library/files_folders_urls_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,7 +31,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_display_library_files_folders_urls' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/library/linked_fullwidth.php b/admin/layouts/library/linked_fullwidth.php index 4c12d1b6e..e869fba14 100644 --- a/admin/layouts/library/linked_fullwidth.php +++ b/admin/layouts/library/linked_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_linked_to_notice' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/library/publishing.php b/admin/layouts/library/publishing.php index 97a901504..d4d7b688e 100644 --- a/admin/layouts/library/publishing.php +++ b/admin/layouts/library/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/library/publlshing.php b/admin/layouts/library/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/library/publlshing.php +++ b/admin/layouts/library/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/library_config/publishing.php b/admin/layouts/library_config/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/library_config/publishing.php +++ b/admin/layouts/library_config/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/library_config/publlshing.php b/admin/layouts/library_config/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/library_config/publlshing.php +++ b/admin/layouts/library_config/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/library_config/tweaks_above.php b/admin/layouts/library_config/tweaks_above.php index 91cb40ee7..09617c590 100644 --- a/admin/layouts/library_config/tweaks_above.php +++ b/admin/layouts/library_config/tweaks_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'library' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/library_config/tweaks_fullwidth.php b/admin/layouts/library_config/tweaks_fullwidth.php index f05e0e794..8919d4426 100644 --- a/admin/layouts/library_config/tweaks_fullwidth.php +++ b/admin/layouts/library_config/tweaks_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'addconfig' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/library_files_folders_urls/advance_fullwidth.php b/admin/layouts/library_files_folders_urls/advance_fullwidth.php index 5fd19b54f..01e66ad5b 100644 --- a/admin/layouts/library_files_folders_urls/advance_fullwidth.php +++ b/admin/layouts/library_files_folders_urls/advance_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_constant_paths' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/library_files_folders_urls/basic_above.php b/admin/layouts/library_files_folders_urls/basic_above.php index 91cb40ee7..09617c590 100644 --- a/admin/layouts/library_files_folders_urls/basic_above.php +++ b/admin/layouts/library_files_folders_urls/basic_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'library' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/library_files_folders_urls/basic_fullwidth.php b/admin/layouts/library_files_folders_urls/basic_fullwidth.php index 5026c32d6..7d87174d9 100644 --- a/admin/layouts/library_files_folders_urls/basic_fullwidth.php +++ b/admin/layouts/library_files_folders_urls/basic_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'addfolders' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/library_files_folders_urls/publishing.php b/admin/layouts/library_files_folders_urls/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/library_files_folders_urls/publishing.php +++ b/admin/layouts/library_files_folders_urls/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/library_files_folders_urls/publlshing.php b/admin/layouts/library_files_folders_urls/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/library_files_folders_urls/publlshing.php +++ b/admin/layouts/library_files_folders_urls/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/placeholder/details_fullwidth.php b/admin/layouts/placeholder/details_fullwidth.php index 71cab66d0..4d159f01f 100644 --- a/admin/layouts/placeholder/details_fullwidth.php +++ b/admin/layouts/placeholder/details_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_placeholders_placedin' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/placeholder/details_left.php b/admin/layouts/placeholder/details_left.php index 0baf316e5..1c3ed3183 100644 --- a/admin/layouts/placeholder/details_left.php +++ b/admin/layouts/placeholder/details_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'target' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/placeholder/details_right.php b/admin/layouts/placeholder/details_right.php index 76c8df47c..3f413a5d8 100644 --- a/admin/layouts/placeholder/details_right.php +++ b/admin/layouts/placeholder/details_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'value' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/placeholder/publishing.php b/admin/layouts/placeholder/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/placeholder/publishing.php +++ b/admin/layouts/placeholder/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/placeholder/publlshing.php b/admin/layouts/placeholder/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/placeholder/publlshing.php +++ b/admin/layouts/placeholder/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/power/code_above.php b/admin/layouts/power/code_above.php index cf6f7cec8..749431179 100644 --- a/admin/layouts/power/code_above.php +++ b/admin/layouts/power/code_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,22 +25,30 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'system_name', 'type', 'power_version' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/power/code_fullwidth.php b/admin/layouts/power/code_fullwidth.php index d96752827..6716eb21d 100644 --- a/admin/layouts/power/code_fullwidth.php +++ b/admin/layouts/power/code_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -35,7 +35,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'not_required' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/power/code_left.php b/admin/layouts/power/code_left.php index 85ed07e9f..598444752 100644 --- a/admin/layouts/power/code_left.php +++ b/admin/layouts/power/code_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -36,7 +36,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'add_head' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/power/code_right.php b/admin/layouts/power/code_right.php index 31be74664..a6599627d 100644 --- a/admin/layouts/power/code_right.php +++ b/admin/layouts/power/code_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,7 +31,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'namespace_details' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/power/composer_fullwidth.php b/admin/layouts/power/composer_fullwidth.php index be49af6e3..4f85f2ac6 100644 --- a/admin/layouts/power/composer_fullwidth.php +++ b/admin/layouts/power/composer_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'composer' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/power/licensing_fullwidth.php b/admin/layouts/power/licensing_fullwidth.php index 56e874540..fb7d82503 100644 --- a/admin/layouts/power/licensing_fullwidth.php +++ b/admin/layouts/power/licensing_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'licensing_template' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/power/publishing.php b/admin/layouts/power/publishing.php index 97a901504..d4d7b688e 100644 --- a/admin/layouts/power/publishing.php +++ b/admin/layouts/power/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/power/publlshing.php b/admin/layouts/power/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/power/publlshing.php +++ b/admin/layouts/power/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/power/super_power_left.php b/admin/layouts/power/super_power_left.php index 8b1e5cc6c..b136a4f3b 100644 --- a/admin/layouts/power/super_power_left.php +++ b/admin/layouts/power/super_power_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'approved_paths' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/power/super_power_right.php b/admin/layouts/power/super_power_right.php index e0dac78ab..9e97c0eec 100644 --- a/admin/layouts/power/super_power_right.php +++ b/admin/layouts/power/super_power_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_approved_paths' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/repeatablejcb.php b/admin/layouts/repeatablejcb.php index 1140563ac..467ab47c8 100644 --- a/admin/layouts/repeatablejcb.php +++ b/admin/layouts/repeatablejcb.php @@ -9,8 +9,16 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ + + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + // No direct access to this file -defined('JPATH_BASE') or die('Restricted access'); +defined('JPATH_BASE') or die; /** * Make thing clear @@ -30,8 +38,8 @@ defined('JPATH_BASE') or die('Restricted access'); extract($displayData); // Add script -JHtml::_('jquery.ui', array('core', 'sortable')); -JHtml::_('script', 'system/subform-repeatable.js', array('version' => 'auto', 'relative' => true)); +Html::_('jquery.ui', array('core', 'sortable')); +Html::_('script', 'system/subform-repeatable.js', array('version' => 'auto', 'relative' => true)); $sublayout = 'sectionjcb'; @@ -49,7 +57,7 @@ $sublayout = 'sectionjcb';
    @@ -57,7 +65,7 @@ $sublayout = 'sectionjcb'; $form) : - echo JLayoutHelper::render( + echo LayoutHelper::render( $sublayout, array( 'form' => $form, @@ -76,7 +84,7 @@ $sublayout = 'sectionjcb'; array('<', '>'), array('SUBFORMLT', 'SUBFORMGT'), trim( - JLayoutHelper::render( + LayoutHelper::render( $sublayout, array( 'form' => $tmpl, diff --git a/admin/layouts/rows.php b/admin/layouts/rows.php index 5379aea33..81b696d7f 100644 --- a/admin/layouts/rows.php +++ b/admin/layouts/rows.php @@ -9,8 +9,16 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ + + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + // No direct access to this file -defined('JPATH_BASE') or die('Restricted access'); +defined('JPATH_BASE') or die; $headers = $displayData['headers']; $items = $displayData['items']; diff --git a/admin/layouts/sectionjcb.php b/admin/layouts/sectionjcb.php index d4c471711..f0051e980 100644 --- a/admin/layouts/sectionjcb.php +++ b/admin/layouts/sectionjcb.php @@ -9,8 +9,16 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ + + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + // No direct access to this file -defined('JPATH_BASE') or die('Restricted access'); +defined('JPATH_BASE') or die; /** * Make thing clear @@ -32,17 +40,17 @@ extract($displayData);
    - + - + - + diff --git a/admin/layouts/server/details_above.php b/admin/layouts/server/details_above.php index c3294693f..57c1b1dd0 100644 --- a/admin/layouts/server/details_above.php +++ b/admin/layouts/server/details_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,21 +25,29 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'name', 'protocol' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/server/details_fullwidth.php b/admin/layouts/server/details_fullwidth.php index bf273a8fd..63c7a21b0 100644 --- a/admin/layouts/server/details_fullwidth.php +++ b/admin/layouts/server/details_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -32,7 +32,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'not_required' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/server/details_left.php b/admin/layouts/server/details_left.php index e62eb25c4..2197086e3 100644 --- a/admin/layouts/server/details_left.php +++ b/admin/layouts/server/details_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -32,7 +32,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'path' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/server/details_right.php b/admin/layouts/server/details_right.php index 650fb35b5..6ad2bee77 100644 --- a/admin/layouts/server/details_right.php +++ b/admin/layouts/server/details_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'secret' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/server/linked_components_fullwidth.php b/admin/layouts/server/linked_components_fullwidth.php index 403302ea3..ab7bbb4d2 100644 --- a/admin/layouts/server/linked_components_fullwidth.php +++ b/admin/layouts/server/linked_components_fullwidth.php @@ -9,251 +9,21 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + // No direct access to this file -defined('_JEXEC') or die('Restricted access'); -use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\StringHelper; +defined('_JEXEC') or die; // set the defaults $items = $displayData->vymlinked_components; -$user = JFactory::getUser(); +$user = Factory::getApplication()->getIdentity(); $id = $displayData->item->id; -// set the edit URL -$edit = "index.php?option=com_componentbuilder&view=joomla_components&task=joomla_component.edit"; -// set a return value -$return = ($id) ? "index.php?option=com_componentbuilder&view=server&layout=edit&id=" . $id : ""; -// check for a return value -$jinput = JFactory::getApplication()->input; -if ($_return = $jinput->get('return', null, 'base64')) -{ - $return .= "&return=" . $_return; -} -// check if return value was set -if (ComponentbuilderHelper::checkString($return)) -{ - // set the referral values - $ref = ($id) ? "&ref=server&refid=" . $id . "&return=" . urlencode(base64_encode($return)) : "&return=" . urlencode(base64_encode($return)); -} -else -{ - $ref = ($id) ? "&ref=server&refid=" . $id : ""; -} + ?>
    - - - - - - - - - - - - - - $item): ?> - authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('joomla_component',$item,'joomla_components'); - ?> - - - - - - published == 1): ?> - - published == 0): ?> - - published == 2): ?> - - published == -2): ?> - - - - - - -
    - - - - - - - - - - - -
    -
    - get('joomla_component.edit')): ?> - escape($item->system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'joomla_components.', $canCheckin); ?> - - - escape($item->system_name); ?> - - - escape($item->component_version); ?> -
    - return_here is set - if (!isset($this->return_here)) - { - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - } - // setup the buttons - if (!isset($_buttons) || !ArrayHelper::check($_buttons)) - { - $_buttons = array(); - $_buttons[0] = array( - array( - 'view' => 'component_admin_views', - 'views' => 'components_admin_views', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_ADMIN_VIEWS'), - 'icon' => 'stack'), - array( - 'view' => 'component_custom_admin_views', - 'views' => 'components_custom_admin_views', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_CUSTOM_ADMIN_VIEWS'), - 'icon' => 'screen'), - array( - 'view' => 'component_site_views', - 'views' => 'components_site_views', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_SITE_VIEWS'), - 'icon' => 'palette'), - array( - 'view' => 'component_config', - 'views' => 'components_config', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_CONFIG'), - 'icon' => 'options') - ); - $_buttons[1] = array( - array( - 'view' => 'component_placeholders', - 'views' => 'components_placeholders', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_PLACEHOLDERS'), - 'icon' => 'search'), - array( - 'view' => 'component_updates', - 'views' => 'components_updates', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_UPDATES'), - 'icon' => 'database'), - array( - 'view' => 'component_mysql_tweaks', - 'views' => 'components_mysql_tweaks', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_MYSQL_TWEAKS'), - 'icon' => 'screwdriver'), - array( - 'view' => 'component_files_folders', - 'views' => 'components_files_folders', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_FILES_FOLDERS'), - 'icon' => 'briefcase') - ); - $_buttons[2] = array( - array( - 'view' => 'component_custom_admin_menus', - 'views' => 'components_custom_admin_menus', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_CUSTOM_ADMIN_MENUS'), - 'icon' => 'plus'), - array( - 'view' => 'component_dashboard', - 'views' => 'components_dashboard', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_DASHBOARD'), - 'icon' => 'dashboard'), - array( - 'view' => 'component_modules', - 'views' => 'components_modules', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_MODULES'), - 'icon' => 'cube'), - array( - 'view' => 'component_plugins', - 'views' => 'components_plugins', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_PLUGINS'), - 'icon' => 'power-cord') - ); - } - ?> -
    - - get($_button['view'].'.edit') && ($id = ComponentbuilderHelper::getVar($_button['view'], $item->id, 'joomla_component', 'id')) !== false): ?> - - get($_button['view'].'.create')): ?> - - - -
    -
    -
    - escape($item->name_code); ?> -
    -
    - - get($_button['view'].'.edit') && ($id = ComponentbuilderHelper::getVar($_button['view'], $item->id, 'joomla_component', 'id')) !== false): ?> - - get($_button['view'].'.create')): ?> - - - -
    -
    -
    - escape($item->short_description); ?> -
    -
    - - get($_button['view'].'.edit') && ($id = ComponentbuilderHelper::getVar($_button['view'], $item->id, 'joomla_component', 'id')) !== false): ?> - - get($_button['view'].'.create')): ?> - - - -
    -
    -
    escape($item->companyname); ?>
    - author)) : ?> - escape($item->author); ?>
    - - email) && StringHelper::check($item->author)) : ?> - - escape($item->email); ?> - -
    - - website) && StringHelper::check($item->author)) : ?> - - escape($item->website); ?> - - -
    -
    - - - - - - - - - - - - - - - - - id; ?> -
    - -
    - -
    - +oops! error.....
    diff --git a/admin/layouts/server/publishing.php b/admin/layouts/server/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/server/publishing.php +++ b/admin/layouts/server/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/server/publlshing.php b/admin/layouts/server/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/server/publlshing.php +++ b/admin/layouts/server/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/site_view/custom_buttons_fullwidth.php b/admin/layouts/site_view/custom_buttons_fullwidth.php index fef43f97c..37e24bfba 100644 --- a/admin/layouts/site_view/custom_buttons_fullwidth.php +++ b/admin/layouts/site_view/custom_buttons_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -32,7 +32,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'php_model' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/site_view/custom_buttons_left.php b/admin/layouts/site_view/custom_buttons_left.php index a4498e425..418577dac 100644 --- a/admin/layouts/site_view/custom_buttons_left.php +++ b/admin/layouts/site_view/custom_buttons_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'add_custom_button' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/site_view/custom_buttons_right.php b/admin/layouts/site_view/custom_buttons_right.php index ec870325d..796368450 100644 --- a/admin/layouts/site_view/custom_buttons_right.php +++ b/admin/layouts/site_view/custom_buttons_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'button_position' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/site_view/details_above.php b/admin/layouts/site_view/details_above.php index 019a14081..c52a26190 100644 --- a/admin/layouts/site_view/details_above.php +++ b/admin/layouts/site_view/details_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,21 +25,29 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'system_name', 'context' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/site_view/details_fullwidth.php b/admin/layouts/site_view/details_fullwidth.php index 8c0c8e83e..f852f1976 100644 --- a/admin/layouts/site_view/details_fullwidth.php +++ b/admin/layouts/site_view/details_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'default' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/site_view/details_left.php b/admin/layouts/site_view/details_left.php index df266c7f1..b70b12b40 100644 --- a/admin/layouts/site_view/details_left.php +++ b/admin/layouts/site_view/details_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_add_php_language_string' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/site_view/details_right.php b/admin/layouts/site_view/details_right.php index f7e79a421..f25450071 100644 --- a/admin/layouts/site_view/details_right.php +++ b/admin/layouts/site_view/details_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,7 +31,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_snippet_usage' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/site_view/details_rightside.php b/admin/layouts/site_view/details_rightside.php index d7ea40a77..1c42273f1 100644 --- a/admin/layouts/site_view/details_rightside.php +++ b/admin/layouts/site_view/details_rightside.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -32,7 +32,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'dynamic_values' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/site_view/details_under.php b/admin/layouts/site_view/details_under.php index 68af44f9c..48a7d40a0 100644 --- a/admin/layouts/site_view/details_under.php +++ b/admin/layouts/site_view/details_under.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,20 +25,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'not_required' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/site_view/javascript_css_fullwidth.php b/admin/layouts/site_view/javascript_css_fullwidth.php index af32af44d..3c09567ad 100644 --- a/admin/layouts/site_view/javascript_css_fullwidth.php +++ b/admin/layouts/site_view/javascript_css_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -36,7 +36,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'css' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/site_view/linked_components_fullwidth.php b/admin/layouts/site_view/linked_components_fullwidth.php index 4c12d1b6e..e869fba14 100644 --- a/admin/layouts/site_view/linked_components_fullwidth.php +++ b/admin/layouts/site_view/linked_components_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_linked_to_notice' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/site_view/php_fullwidth.php b/admin/layouts/site_view/php_fullwidth.php index deb10e126..225852048 100644 --- a/admin/layouts/site_view/php_fullwidth.php +++ b/admin/layouts/site_view/php_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -39,7 +39,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'php_jview' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/site_view/publishing.php b/admin/layouts/site_view/publishing.php index 97a901504..d4d7b688e 100644 --- a/admin/layouts/site_view/publishing.php +++ b/admin/layouts/site_view/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/site_view/publlshing.php b/admin/layouts/site_view/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/site_view/publlshing.php +++ b/admin/layouts/site_view/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/snippet/contributor_fullwidth.php b/admin/layouts/snippet/contributor_fullwidth.php index 775ce5c44..3f246cb50 100644 --- a/admin/layouts/snippet/contributor_fullwidth.php +++ b/admin/layouts/snippet/contributor_fullwidth.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'note_contributor_details' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/snippet/contributor_left.php b/admin/layouts/snippet/contributor_left.php index e60f6bd57..f90791c65 100644 --- a/admin/layouts/snippet/contributor_left.php +++ b/admin/layouts/snippet/contributor_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'contributor_website' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/snippet/contributor_right.php b/admin/layouts/snippet/contributor_right.php index 6c4cbc3ef..05b38546b 100644 --- a/admin/layouts/snippet/contributor_right.php +++ b/admin/layouts/snippet/contributor_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -30,7 +30,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'contributor_email' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/snippet/details_above.php b/admin/layouts/snippet/details_above.php index c32593c09..5e18db8c8 100644 --- a/admin/layouts/snippet/details_above.php +++ b/admin/layouts/snippet/details_above.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -25,22 +25,30 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'name', 'url', 'library' -); +]; -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; + +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
    +
    setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
    diff --git a/admin/layouts/snippet/details_left.php b/admin/layouts/snippet/details_left.php index ad9163876..da45b40f8 100644 --- a/admin/layouts/snippet/details_left.php +++ b/admin/layouts/snippet/details_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -32,7 +32,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'usage' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/snippet/details_right.php b/admin/layouts/snippet/details_right.php index 722eb549b..1b76bb54d 100644 --- a/admin/layouts/snippet/details_right.php +++ b/admin/layouts/snippet/details_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'snippet' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/snippet/publishing.php b/admin/layouts/snippet/publishing.php index 97a901504..d4d7b688e 100644 --- a/admin/layouts/snippet/publishing.php +++ b/admin/layouts/snippet/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/snippet/publlshing.php b/admin/layouts/snippet/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/snippet/publlshing.php +++ b/admin/layouts/snippet/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/snippet_type/details_left.php b/admin/layouts/snippet_type/details_left.php index 10724a9ed..83d570681 100644 --- a/admin/layouts/snippet_type/details_left.php +++ b/admin/layouts/snippet_type/details_left.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'name' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/snippet_type/details_right.php b/admin/layouts/snippet_type/details_right.php index 37215496b..aefe7858d 100644 --- a/admin/layouts/snippet_type/details_right.php +++ b/admin/layouts/snippet_type/details_right.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -29,7 +29,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'description' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/snippet_type/publishing.php b/admin/layouts/snippet_type/publishing.php index 24144d6d4..5537d3a21 100644 --- a/admin/layouts/snippet_type/publishing.php +++ b/admin/layouts/snippet_type/publishing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -33,7 +33,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'modified_by' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/snippet_type/publlshing.php b/admin/layouts/snippet_type/publlshing.php index 7ac64fe22..051a5b14f 100644 --- a/admin/layouts/snippet_type/publlshing.php +++ b/admin/layouts/snippet_type/publlshing.php @@ -10,7 +10,7 @@ */ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -34,7 +34,7 @@ $fields = $displayData->get($fields_tab_layout) ?: array( 'id' ); -$hiddenFields = $displayData->get('hidden_fields') ?: array(); +$hiddenFields = $displayData->get('hidden_fields') ?: []; ?> diff --git a/admin/layouts/table.php b/admin/layouts/table.php index b526bfa0a..bc9c68912 100644 --- a/admin/layouts/table.php +++ b/admin/layouts/table.php @@ -9,18 +9,27 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -// No direct access to this file -defined('JPATH_BASE') or die('Restricted access'); + + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; use VDM\Joomla\Utilities\StringHelper; +// No direct access to this file +defined('JPATH_BASE') or die; + $table_id = (isset($displayData['id'])) ? $displayData['id'] : StringHelper::random(7); $name = (isset($displayData['name'])) ? $displayData['name'] : false; $table_class = (isset($displayData['table_class'])) ? $displayData['table_class'] : 'uk-table'; -$headers = (isset($displayData['headers'])) ? $displayData['headers'] : [JText::_('COM_COMPONENTBUILDER_NO'), JText::_('COM_COMPONENTBUILDER_HEADERS'), JText::_('COM_COMPONENTBUILDER_FOUND')]; +$table_container_class = (isset($displayData['table_container_class'])) ? $displayData['table_container_class'] : 'uk-overflow-auto'; +$headers = (isset($displayData['headers'])) ? $displayData['headers'] : [Text::_('COM_COMPONENTBUILDER_NO'), Text::_('COM_COMPONENTBUILDER_HEADERS'), Text::_('COM_COMPONENTBUILDER_FOUND')]; $items = (isset($displayData['items'])) ? $displayData['items'] : 6; ?> -
    +
    @@ -54,7 +63,7 @@ $items = (isset($displayData['items'])) ? $displayData['items'] : 6; - $headers, 'items' => $items]); ?> + $headers, 'items' => $items]); ?>
    @@ -64,8 +73,8 @@ $items = (isset($displayData['items'])) ? $displayData['items'] : 6; if (!isset($displayData['init']) || $displayData['init']) : ?> '; + $text[] = ""; + $text[] = '
    '; + $text[] = '
    '; + $text[] = '
    '; + // build the help text + $text[] = '

    '.$document->title."

    "; + $text[] = str_replace(array_keys($images),array_values($images),$document->content); + // end template + $text[] = '


    '; + $text[] = '
    '; + $text[] = ""; + $text[] = ""; + + return implode("\n",$text); + } + return false; + } +} diff --git a/admin/src/Controller/Help_documentController.php b/admin/src/Controller/Help_documentController.php new file mode 100644 index 000000000..96552ba38 --- /dev/null +++ b/admin/src/Controller/Help_documentController.php @@ -0,0 +1,343 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Help_document Form Controller + * + * @since 1.6 + */ +class Help_documentController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_HELP_DOCUMENT'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'help_documents'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('help_document.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return $user->authorise('help_document.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('help_document.access', 'com_componentbuilder.help_document.' . (int) $recordId) && $user->authorise('help_document.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('help_document.edit', 'com_componentbuilder.help_document.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('help_document.edit.own', 'com_componentbuilder.help_document.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('help_document.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('help_document.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Help_document', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=help_documents' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + return; + } +} diff --git a/admin/src/Controller/Help_documentsController.php b/admin/src/Controller/Help_documentsController.php new file mode 100644 index 000000000..82d278deb --- /dev/null +++ b/admin/src/Controller/Help_documentsController.php @@ -0,0 +1,119 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Help_documents Admin Controller + * + * @since 1.6 + */ +class Help_documentsController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_HELP_DOCUMENTS'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Help_document', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } + + public function exportData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if export is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('help_document.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) + { + // Get the input + $input = Factory::getApplication()->input; + $pks = $input->post->get('cid', array(), 'array'); + // Sanitize the input + $pks = ArrayHelper::toInteger($pks); + // Get the model + $model = $this->getModel('Help_documents'); + // get the data to export + $data = $model->getExportData($pks); + if (UtilitiesArrayHelper::check($data)) + { + // now set the data to the spreadsheet + $date = Factory::getDate(); + ComponentbuilderHelper::xls($data,'Help_documents_'.$date->format('jS_F_Y'),'Help documents exported ('.$date->format('jS F, Y').')','help documents'); + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=help_documents', false), $message, 'error'); + return; + } + + + public function importData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if import is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('help_document.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) + { + // Get the import model + $model = $this->getModel('Help_documents'); + // get the headers to import + $headers = $model->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + // Load headers to session. + $session = Factory::getSession(); + $headers = json_encode($headers); + $session->set('help_document_VDM_IMPORTHEADERS', $headers); + $session->set('backto_VDM_IMPORT', 'help_documents'); + $session->set('dataType_VDM_IMPORTINTO', 'help_document'); + // Redirect to import view. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_HELP_DOCUMENTS'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=import', false), $message); + return; + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=help_documents', false), $message, 'error'); + return; + } +} \ No newline at end of file diff --git a/admin/src/Controller/ImportController.php b/admin/src/Controller/ImportController.php new file mode 100644 index 000000000..da2865991 --- /dev/null +++ b/admin/src/Controller/ImportController.php @@ -0,0 +1,64 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Import Base Controller + * + * @since 1.6 + */ +class ImportController extends BaseController +{ + /** + * Import an spreadsheet. + * + * @return void + */ + public function import() + { + // Check for request forgeries + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + $model = $this->getModel('import'); + if ($model->import()) + { + $cache = Factory::getCache('mod_menu'); + $cache->clean(); + // TODO: Reset the users acl here as well to kill off any missing bits + } + + $app = Factory::getApplication(); + $redirect_url = $app->getUserState('com_componentbuilder.redirect_url'); + if (empty($redirect_url)) + { + $redirect_url = Route::_('index.php?option=com_componentbuilder&view=import', false); + } + else + { + // wipe out the user state when we're going to redirect + $app->setUserState('com_componentbuilder.redirect_url', ''); + $app->setUserState('com_componentbuilder.message', ''); + $app->setUserState('com_componentbuilder.extension_message', ''); + } + $this->setRedirect($redirect_url); + } +} diff --git a/admin/src/Controller/Import_joomla_componentsimportController.php b/admin/src/Controller/Import_joomla_componentsimportController.php new file mode 100644 index 000000000..59c5de64b --- /dev/null +++ b/admin/src/Controller/Import_joomla_componentsimportController.php @@ -0,0 +1,65 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Componentbuilder\Package\Factory as PackageFactory; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Import_joomla_components Base Controller + * + * @since 1.6 + */ +class Import_joomla_componentsimportController extends BaseController +{ + /** + * Import an spreadsheet. + * + * @return void + */ + public function import() + { + // Check for request forgeries + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + $model = $this->getModel('Import_joomla_components'); + if ($model->import()) + { + $cache = Factory::getCache('mod_menu'); + $cache->clean(); + // TODO: Reset the users acl here as well to kill off any missing bits + } + + $app = Factory::getApplication(); + $redirect_url = $app->getUserState('com_componentbuilder.redirect_url'); + if (empty($redirect_url)) + { + $redirect_url = Route::_('index.php?option=com_componentbuilder&view=import_joomla_components', false); + } + else + { + // wipe out the user state when we're going to redirect + $app->setUserState('com_componentbuilder.redirect_url', ''); + $app->setUserState('com_componentbuilder.message', ''); + $app->setUserState('com_componentbuilder.extension_message', ''); + } + $this->setRedirect($redirect_url); + } +} diff --git a/admin/src/Controller/Import_language_translationsimportController.php b/admin/src/Controller/Import_language_translationsimportController.php new file mode 100644 index 000000000..5bfc2f58e --- /dev/null +++ b/admin/src/Controller/Import_language_translationsimportController.php @@ -0,0 +1,64 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Import_language_translations Base Controller + * + * @since 1.6 + */ +class Import_language_translationsimportController extends BaseController +{ + /** + * Import an spreadsheet. + * + * @return void + */ + public function import() + { + // Check for request forgeries + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + $model = $this->getModel('Import_language_translations'); + if ($model->import()) + { + $cache = Factory::getCache('mod_menu'); + $cache->clean(); + // TODO: Reset the users acl here as well to kill off any missing bits + } + + $app = Factory::getApplication(); + $redirect_url = $app->getUserState('com_componentbuilder.redirect_url'); + if (empty($redirect_url)) + { + $redirect_url = Route::_('index.php?option=com_componentbuilder&view=import_language_translations', false); + } + else + { + // wipe out the user state when we're going to redirect + $app->setUserState('com_componentbuilder.redirect_url', ''); + $app->setUserState('com_componentbuilder.message', ''); + $app->setUserState('com_componentbuilder.extension_message', ''); + } + $this->setRedirect($redirect_url); + } +} diff --git a/admin/src/Controller/Joomla_componentController.php b/admin/src/Controller/Joomla_componentController.php new file mode 100644 index 000000000..e11b951b9 --- /dev/null +++ b/admin/src/Controller/Joomla_componentController.php @@ -0,0 +1,404 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_component Form Controller + * + * @since 1.6 + */ +class Joomla_componentController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'joomla_components'; + + public function refresh() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if import is allowed for this user. + $user = Factory::getUser(); + if ($user->authorise('joomla_component.import_jcb_packages', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) + { + $session = Factory::getSession(); + $session->set('backto_VDM_IMPORT', 'joomla_components'); + $session->set('dataType_VDM_IMPORTINTO', 'smart_package'); + // clear the session + ComponentbuilderHelper::set('vdmGithubPackages', null); + ComponentbuilderHelper::set('communityGithubPackages', null); + // Redirect to import view. + $message = Text::_('COM_COMPONENTBUILDER_YOU_CAN_NOW_SELECT_THE_COMPONENT_BZIPB_PACKAGE_YOU_WOULD_LIKE_TO_IMPORTBR_SMALLPLEASE_NOTE_THAT_SMART_COMPONENT_IMPORT_ONLY_WORKS_WITH_THE_FOLLOWING_FORMAT_BZIPBSMALL'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=import_joomla_components&target=smartPackage', false), $message); + return; + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_IMPORT_A_COMPONENT_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_HELP'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); + return; + } + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('joomla_component.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return $user->authorise('joomla_component.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('joomla_component.access', 'com_componentbuilder.joomla_component.' . (int) $recordId) && $user->authorise('joomla_component.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('joomla_component.edit', 'com_componentbuilder.joomla_component.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('joomla_component.edit.own', 'com_componentbuilder.joomla_component.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('joomla_component.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('joomla_component.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Joomla_component', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_components' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + // get the state object (Joomla\CMS\Object\CMSObject) + $state = $model->get('state'); + // if we save2copy we need to also copy linked tables found! + if ($state->task === 'save2copy' && $state->{'joomla_component.new'}) + { + // get new ID + $newID = $state->{'joomla_component.id'}; + // get old ID + $oldID = $this->input->get('id', 0, 'INT'); + // linked tables to update + $_tablesArray = array( + 'component_admin_views' => 'joomla_component', + 'component_site_views' => 'joomla_component', + 'component_custom_admin_views' => 'joomla_component', + 'component_updates' => 'joomla_component', + 'component_mysql_tweaks' => 'joomla_component', + 'component_custom_admin_menus' => 'joomla_component', + 'component_config' => 'joomla_component', + 'component_dashboard' => 'joomla_component', + 'component_files_folders' => 'joomla_component', + 'component_placeholders' => 'joomla_component', + 'custom_code' => 'component', + 'component_router' => 'joomla_component' + ); + foreach($_tablesArray as $_updateTable => $_key) + { + // get the linked ID + if ($_value = GetHelper::var($_updateTable, $oldID, $_key, 'id')) + { + // copy fields to new linked table + ComponentbuilderHelper::copyItem(/*id->*/ $_value, /*table->*/ $_updateTable, /*change->*/ array($_key => $newID)); + } + } + } + + return; + } +} diff --git a/admin/src/Controller/Joomla_componentsController.php b/admin/src/Controller/Joomla_componentsController.php new file mode 100644 index 000000000..9a259d7a4 --- /dev/null +++ b/admin/src/Controller/Joomla_componentsController.php @@ -0,0 +1,520 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Componentbuilder\Package\Factory as PackageFactory; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_components Admin Controller + * + * @since 1.6 + */ +class Joomla_componentsController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_COMPONENTS'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Joomla_component', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } + + public function exportData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if export is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('joomla_component.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) + { + // Get the input + $input = Factory::getApplication()->input; + $pks = $input->post->get('cid', array(), 'array'); + // Sanitize the input + $pks = ArrayHelper::toInteger($pks); + // Get the model + $model = $this->getModel('Joomla_components'); + // get the data to export + $data = $model->getExportData($pks); + if (UtilitiesArrayHelper::check($data)) + { + // now set the data to the spreadsheet + $date = Factory::getDate(); + ComponentbuilderHelper::xls($data,'Joomla_components_'.$date->format('jS_F_Y'),'Joomla components exported ('.$date->format('jS F, Y').')','joomla components'); + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); + return; + } + + + public function importData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if import is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('joomla_component.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) + { + // Get the import model + $model = $this->getModel('Joomla_components'); + // get the headers to import + $headers = $model->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + // Load headers to session. + $session = Factory::getSession(); + $headers = json_encode($headers); + $session->set('joomla_component_VDM_IMPORTHEADERS', $headers); + $session->set('backto_VDM_IMPORT', 'joomla_components'); + $session->set('dataType_VDM_IMPORTINTO', 'joomla_component'); + // Redirect to import view. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_JOOMLA_COMPONENTS'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=import_joomla_components', false), $message); + return; + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); + return; + } + + + /** + * Run the Expansion + * + * @return void + */ + public function runExpansion() + { + // Check for request forgeries + Session::checkToken() or \jexit(Text::_('JINVALID_TOKEN')); + // check if user has the right + $user = Factory::getUser(); + // set page redirect + $redirect_url = \JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false); + // set massage + $message = Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE'); + // check if this user has the right to run expansion + if($user->authorise('joomla_components.run_expansion', 'com_componentbuilder')) + { + // set massage + $message = Text::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB'); + // run expansion via API + $result = ComponentbuilderHelper::getFileContents(\JUri::root() . 'index.php?option=com_componentbuilder&task=api.expand'); + // is there a message returned + if (!is_numeric($result) && StringHelper::check($result)) + { + $this->setRedirect($redirect_url, $result); + return true; + } + elseif (is_numeric($result) && 1 == $result) + { + $message = Text::_('COM_COMPONENTBUILDER_BTHE_EXPANSION_WAS_SUCCESSFULLYB_TO_SEE_MORE_INFORMATION_CHANGE_THE_BRETURN_OPTIONS_FOR_BUILDB_TO_BDISPLAY_MESSAGEB_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TABB'); + $this->setRedirect($redirect_url, $message, 'message'); + return true; + } + } + $this->setRedirect($redirect_url, $message, 'error'); + return false; + } + + + /** + * Clear tmp folder + * + * @return true on success + */ + public function clearTmp() + { + // Check for request forgeries + Session::checkToken() or \jexit(Text::_('JINVALID_TOKEN')); + // check if user has the right + $user = Factory::getUser(); + // set page redirect + $redirect_url = Route::_('index.php?option=com_componentbuilder&view=joomla_components', false); + $message = Text::_('COM_COMPONENTBUILDER_COULD_NOT_CLEAR_THE_TMP_FOLDER'); + if($user->authorise('joomla_components.clear_tmp', 'com_componentbuilder') && $user->authorise('core.manage', 'com_componentbuilder')) + { + // get the model + $model = $this->getModel('compiler'); + // get tmp folder + $comConfig = Factory::getConfig(); + $tmp = $comConfig->get('tmp_path'); + if ($model->emptyFolder($tmp)) + { + $message = Text::_('COM_COMPONENTBUILDER_BTHE_TMP_FOLDER_HAS_BEEN_CLEAR_SUCCESSFULLYB'); + $this->setRedirect($redirect_url, $message, 'message'); + // get application + $app = Factory::getApplication(); + // wipe out the user c-m-p since we are done with them all + $app->setUserState('com_componentbuilder.component_folder_name', ''); + $app->setUserState('com_componentbuilder.modules_folder_name', ''); + $app->setUserState('com_componentbuilder.plugins_folder_name', ''); + $app->setUserState('com_componentbuilder.success_message', ''); + + return true; + } + } + $this->setRedirect($redirect_url, $message, 'error'); + return false; + } + + public function smartImport() + { + // check if import is allowed for this user. + $user = Factory::getUser(); + if ($user->authorise('joomla_component.import_jcb_packages', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) + { + $session = Factory::getSession(); + $session->set('backto_VDM_IMPORT', 'joomla_components'); + $session->set('dataType_VDM_IMPORTINTO', 'smart_package'); + // Redirect to import view. + $message = Text::_('COM_COMPONENTBUILDER_YOU_CAN_NOW_SELECT_THE_COMPONENT_BZIPB_PACKAGE_YOU_WOULD_LIKE_TO_IMPORTBR_SMALLPLEASE_NOTE_THAT_SMART_COMPONENT_IMPORT_ONLY_WORKS_WITH_THE_FOLLOWING_FORMAT_BZIPBSMALL'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=import_joomla_components&target=smartPackage', false), $message); + return; + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_IMPORT_A_COMPONENT_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_HELP'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); + return; + } + + public function smartExport() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // Get the model + $model = $this->getModel('Joomla_components'); + // check if export is allowed for this user. + $model->user = Factory::getUser(); + if ($model->user->authorise('joomla_component.export_jcb_packages', 'com_componentbuilder') && $model->user->authorise('core.export', 'com_componentbuilder')) + { + // Get the input + $input = Factory::getApplication()->input; + $pks = $input->post->get('cid', array(), 'array'); + // Sanitize the input + ArrayHelper::toInteger($pks); + // check if there is any selections + if (!JCBArrayHelper::check($pks)) + { + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_NO_COMPONENTS_WERE_SELECTED_PLEASE_MAKE_A_SELECTION_AND_TRY_AGAIN'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); + return; + } + // set auto loader + ComponentbuilderHelper::autoLoader('smart'); + // get the data to export + if ($model->getSmartExport($pks)) + { + // set the key string + if (StringHelper::check($model->key) && strlen($model->key) == 32) + { + $keyNotice = '

    ' . Text::sprintf('COM_COMPONENTBUILDER_THE_PACKAGE_KEY_IS_CODESCODE', $model->key) . '

    '; + $keyNotice .= '

    ' . Text::_('COM_COMPONENTBUILDER_YOUR_DATA_IS_ENCRYPTED_WITH_A_AES_TWO_HUNDRED_AND_FIFTY_SIX_BIT_ENCRYPTION_USING_THE_ABOVE_THIRTY_TWO_CHARACTER_KEY') . '

    '; + + // set the package owner info + if (PackageFactory::_('Display.Details')->hasOwner($model->info)) + { + $ownerDetails = PackageFactory::_('Display.Details')->owner($model->info, true); + } + else + { + $ownerDetails = '

    ' . Text::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_NOT_SET') . '

    '; + $ownerDetails .= '

    ' . Text::_('COM_COMPONENTBUILDER_TO_CHANGE_THE_PACKAGE_OWNER_DEFAULTS_OPEN_THE_BJCB_GLOBAL_OPTIONSB_GO_TO_THE_BCOMPANYB_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE') . '

    '; + $ownerDetails .= '

    ' . Text::_('COM_COMPONENTBUILDER_YOU_SHOULD_ADD_THE_CORRECT_OWNER_DETAILS') . '

    '; + $ownerDetails .= '

    ' . Text::_('COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_BIMPORT_PROCESSB_BEFORE_ADDING_THE_KEY_THIS_WAY_IF_THE_USERDEV_BDOES_NOTB_HAVE_THE_KEY_THEY_CAN_SEE_BWHERE_TO_GET_ITB') . '

    '; + } + } + else + { + $keyNotice = '

    ' . Text::_('COM_COMPONENTBUILDER_THIS_PACKAGE_HAS_NO_KEY') . '

    '; + $ownerDetails = '

    ' . Text::_('COM_COMPONENTBUILDER_THAT_MEANS_ANYONE_WHO_HAS_THIS_PACKAGE_CAN_INSTALL_IT_INTO_JCB_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_BSETTINGSB_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_BEXPORT_KEYB') . '

    '; + } + // Redirect to the list screen with success. + $message = array(); + $message[] = '

    ' . Text::_('COM_COMPONENTBUILDER_EXPORT_COMPLETED') . '

    '; + $message[] = '

    ' . Text::sprintf('COM_COMPONENTBUILDER_PATH_TO_THE_ZIPPED_PACKAGE_IS_CODESCODE_BR_S_S', $model->zipPath, $keyNotice, $ownerDetails) . '

    '; + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_components', false), implode('', $message), 'Success'); + return; + } + else + { + if (StringHelper::check($model->packagePath)) + { + // clear all if not successful + ComponentbuilderHelper::removeFolder($model->packagePath); + } + if (StringHelper::check($model->zipPath)) + { + // clear all if not successful + File::delete($model->zipPath); + } + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_EXPORT_FAILED_PLEASE_TRY_AGAIN_LATTER'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); + return; + } + + public function backup() + { + // get params first + if (!isset($this->params) || !ObjectHelper::check($this->params)) + { + $this->params = ComponentHelper::getParams('com_componentbuilder'); + } + // Get the model + $model = componentbuilderHelper::getModel('joomla_components', JPATH_ADMINISTRATOR . '/components/com_componentbuilder'); + // set user + $model->user = $this->getApiUser(); + // make sure to set active type (adding this script from custom code :) + $model->activeType = 'manualBackup'; + // check if export is allowed for this user. (we need this sorry) + if ($model->user->authorise('joomla_component.export_jcb_packages', 'com_componentbuilder') && $model->user->authorise('core.export', 'com_componentbuilder')) + { + // get all component IDs to backup + $pks = componentbuilderHelper::getComponentIDs(); + // set auto loader + ComponentbuilderHelper::autoLoader('smart'); + // manual backup message + $backupNotice = []; + // get the data to export + if (UtilitiesArrayHelper::check($pks) && $model->getSmartExport($pks)) + { + $backupNotice[] = Text::_('COM_COMPONENTBUILDER_BACKUP_WAS_DONE_SUCCESSFULLY'); + $backupNoticeStatus = 'Success'; + // set the key string + if (StringHelper::check($model->key) && strlen($model->key) == 32) + { + $textNotice = array(); + $keyNotice = '

    ' . Text::sprintf('COM_COMPONENTBUILDER_THE_PACKAGE_KEY_IS_CODESCODE', $model->key) . '

    '; + $keyNotice .= '

    ' . Text::_('COM_COMPONENTBUILDER_YOUR_DATA_IS_ENCRYPTED_WITH_A_AES_TWO_HUNDRED_AND_FIFTY_SIX_BIT_ENCRYPTION_USING_THE_ABOVE_THIRTY_TWO_CHARACTER_KEY') . '

    '; + $textNotice[] = Text::sprintf('COM_COMPONENTBUILDER_THE_PACKAGE_KEY_IS_S', $model->key); + // set the package owner info + if ((isset($model->info['getKeyFrom']['company']) && StringHelper::check($model->info['getKeyFrom']['company'])) || (isset($model->info['getKeyFrom']['owner']) && StringHelper::check($model->info['getKeyFrom']['owner']))) + { + $ownerDetails = '

    ' . Text::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS') . '

    '; + $textNotice[] = '# ' . Text::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS'); + $ownerDetails .= '
      '; + if (isset($model->info['getKeyFrom']['company']) && StringHelper::check($model->info['getKeyFrom']['company'])) + { + $ownerDetails .= '
    • ' . Text::sprintf('COM_COMPONENTBUILDER_EMCOMPANYEM_BSB', $model->info['getKeyFrom']['company']) . '
    • '; + $textNotice[] = '- ' . Text::sprintf('COM_COMPONENTBUILDER_COMPANY_S', $model->info['getKeyFrom']['company']); + } + // add value only if set + if (isset($model->info['getKeyFrom']['owner']) && StringHelper::check($model->info['getKeyFrom']['owner'])) + { + $ownerDetails .= '
    • ' . Text::sprintf('COM_COMPONENTBUILDER_EMOWNEREM_BSB', $model->info['getKeyFrom']['owner']) . '
    • '; + $textNotice[] = '- ' . Text::sprintf('COM_COMPONENTBUILDER_OWNER_S', $model->info['getKeyFrom']['owner']); + } + // add value only if set + if (isset($model->info['getKeyFrom']['website']) && StringHelper::check($model->info['getKeyFrom']['website'])) + { + $ownerDetails .= '
    • ' . Text::sprintf('COM_COMPONENTBUILDER_EMWEBSITEEM_BSB', $model->info['getKeyFrom']['website']) . '
    • '; + $textNotice[] = '- ' . Text::sprintf('COM_COMPONENTBUILDER_WEBSITE_S', $model->info['getKeyFrom']['website']); + } + // add value only if set + if (isset($model->info['getKeyFrom']['email']) && StringHelper::check($model->info['getKeyFrom']['email'])) + { + $ownerDetails .= '
    • ' . Text::sprintf('COM_COMPONENTBUILDER_EMEMAILEM_BSB', $model->info['getKeyFrom']['email']) . '
    • '; + $textNotice[] = '- ' . Text::sprintf('COM_COMPONENTBUILDER_EMAIL_S', $model->info['getKeyFrom']['email']); + } + // add value only if set + if (isset($model->info['getKeyFrom']['license']) && StringHelper::check($model->info['getKeyFrom']['license'])) + { + $ownerDetails .= '
    • ' . Text::sprintf('COM_COMPONENTBUILDER_EMLICENSEEM_BSB', $model->info['getKeyFrom']['license']) . '
    • '; + $textNotice[] = '- ' . Text::sprintf('COM_COMPONENTBUILDER_LICENSE_S', $model->info['getKeyFrom']['license']); + } + // add value only if set + if (isset($model->info['getKeyFrom']['copyright']) && StringHelper::check($model->info['getKeyFrom']['copyright'])) + { + $ownerDetails .= '
    • ' . Text::sprintf('COM_COMPONENTBUILDER_EMCOPYRIGHTEM_BSB', $model->info['getKeyFrom']['copyright']) . '
    • '; + $textNotice[] = '- ' . Text::sprintf('COM_COMPONENTBUILDER_COPYRIGHT_S', $model->info['getKeyFrom']['copyright']); + } + $ownerDetails .= '
    '; + $backupNotice[] = Text::_('COM_COMPONENTBUILDER_OWNER_DETAILS_WAS_SET'); + } + else + { + $ownerDetails = '

    ' . Text::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_NOT_SET') . '

    '; + $textNotice[] = '# ' . Text::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS'); + $ownerDetails .= Text::_('COM_COMPONENTBUILDER_TO_CHANGE_THE_PACKAGE_OWNER_DEFAULTS_OPEN_THE_BJCB_GLOBAL_OPTIONSB_GO_TO_THE_BCOMPANYB_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE') . '
    '; + $textNotice[] = Text::_('COM_COMPONENTBUILDER_TO_CHANGE_THE_PACKAGE_OWNER_DEFAULTS_OPEN_THE_JCB_GLOBAL_OPTIONS_GO_TO_THE_COMPANY_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE'); + $ownerDetails .= '

    ' . Text::_('COM_COMPONENTBUILDER_YOU_SHOULD_ADD_THE_CORRECT_OWNER_DETAILS') . '

    '; + $textNotice[] = '## ' . Text::_('COM_COMPONENTBUILDER_YOU_SHOULD_ADD_THE_CORRECT_OWNER_DETAILS'); + $ownerDetails .= Text::_('COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_BIMPORT_PROCESSB_BEFORE_ADDING_THE_KEY_THIS_WAY_IF_THE_USERDEV_BDOES_NOTB_HAVE_THE_KEY_THEY_CAN_SEE_BWHERE_TO_GET_ITB') . '
    '; + $textNotice[] = Text::_('COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_IMPORT_PROCESS_BEFORE_ADDING_THE_KEY_THIS_WAY_IF_THE_USERDEV_DOES_NOT_HAVE_THE_KEY_THEY_CAN_SEE_WHERE_TO_GET_IT'); + $backupNotice[] = Text::_('COM_COMPONENTBUILDER_CHECK_YOUR_OWNER_DETAILS_IT_HAS_NOT_BEEN_SET_OPEN_THE_JCB_GLOBAL_OPTIONS_GO_TO_THE_COMPANY_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE'); + } + } + else + { + $keyNotice = '

    ' . Text::_('COM_COMPONENTBUILDER_THIS_PACKAGE_HAS_NO_KEY') . '

    '; + $textNotice[] = '# ' . Text::_('COM_COMPONENTBUILDER_THIS_PACKAGE_HAS_NO_KEY'); + $ownerDetails = Text::_('COM_COMPONENTBUILDER_THAT_MEANS_ANYONE_WHO_HAS_THIS_PACKAGE_CAN_INSTALL_IT_INTO_JCB_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_BSETTINGSB_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_BEXPORT_KEYB') . '
    '; + $textNotice[] = Text::_('COM_COMPONENTBUILDER_THAT_MEANS_ANYONE_WHO_HAS_THIS_PACKAGE_CAN_INSTALL_IT_INTO_JCB_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_SETTINGS_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_EXPORT_KEY'); + $backupNotice[] = Text::_('COM_COMPONENTBUILDER_NO_KEYS_WERE_FOUND_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_SETTINGS_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_EXPORT_KEY'); + } + // get email + if ($email = $this->params->get('backup_email', null)) + { + // plain text + $plainText = implode("\n", $textNotice); + // set hash to track changes + $hashTracker = md5($plainText); + if (ComponentbuilderHelper::newHash($hashTracker)) + { + // Build final massage. + $message = $keyNotice . $ownerDetails . '
    HASH: ' . $hashTracker . ''; + // set the subject + $subject = Text::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BUILDER_BACKUP_KEY'); + // email the message + componentbuilderEmail::send($email, $subject, componentbuilderEmail::setTableBody($message, $subject), $plainText, 1); + $backupNotice[] = Text::_('COM_COMPONENTBUILDER_EMAIL_WITH_THE_NEW_KEY_WAS_SENT'); + } + else + { + $backupNotice[] = Text::_('COM_COMPONENTBUILDER_KEY_HAS_NOT_CHANGED'); + } + } + } + else + { + $backupNotice[] = Text::_('COM_COMPONENTBUILDER_BACKUP_FAILED_PLEASE_TRY_AGAIN_IF_THE_ERROR_CONTINUE_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR'); + $backupNoticeStatus = 'Error'; + if (StringHelper::check($model->packagePath)) + { + // clear all if not successful + ComponentbuilderHelper::removeFolder($model->packagePath); + } + if (StringHelper::check($model->zipPath)) + { + // clear all if not successful + File::delete($model->zipPath); + } + } + // quite only if auto backup (adding this script from custom code :) + if ('backup' === $model->activeType) + { + echo "# " . $backupNoticeStatus . "\n" .implode("\n", $backupNotice); + // clear session + Factory::getApplication()->getSession()->destroy(); + jexit(); + } + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_components', false), implode("
    ", $backupNotice), $backupNoticeStatus); + return; + } + // quite only if auto backup (adding this script from custom code :) + if ('backup' === $model->activeType) + { + echo "# Error\n" . Text::_('COM_COMPONENTBUILDER_ACCESS_DENIED'); + // clear session + Factory::getApplication()->getSession()->destroy(); + jexit(); + } + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_components', false), Text::_('COM_COMPONENTBUILDER_ACCESS_DENIED'), 'Error'); + return; + } + + public function cloner() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // Get the model + $model = $this->getModel('Joomla_components'); + // check if export is allowed for this user. + $model->user = Factory::getUser(); + if ($model->user->authorise('joomla_component.clone', 'com_componentbuilder') && $model->user->authorise('core.copy', 'com_componentbuilder')) + { + // Get the input + $input = Factory::getApplication()->input; + $pks = $input->post->get('cid', array(), 'array'); + // Sanitize the input + ArrayHelper::toInteger($pks); + // check if there is any selections + if (!JCBArrayHelper::check($pks)) + { + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_NO_COMPONENT_WAS_SELECTED_PLEASE_MAKE_A_SELECTION_OF_ONE_COMPONENT_AND_TRY_AGAIN'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); + return; + } + // only one component allowed at this time + elseif (count( (array) $pks) !== 1) + { + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_ONLY_ONE_COMPONENT_CAN_BE_CLONED_AT_A_TIME_PLEASE_SELECT_ONE_AND_TRY_AGAIN'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); + return; + } + // set the active type + $model->activeType = 'clone'; + // clone the component and the views and the fields... everything linked to the component. + if ($model->cloner($pks)) + { + // clone was successful + $message = Text::_('COM_COMPONENTBUILDER_THE_COMPONENT_WITH_ALL_LINKED_ADMIN_VIEWS_FIELDS_LINKED_TO_ADMIN_VIEWS_CUSTOM_ADMIN_VIEWS_SITE_VIEWS_TEMPLATES_AND_LAYOUTS_WERE_CLONED_SUCCESSFUL'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message); + return; + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_CLONE_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); + return; + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_CLONE_A_COMPONENT_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_HELP'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); + return; + } + + protected function getApiUser() + { + // admin area does not have API user, only front-end (so we fallback on login user) + return Factory::getUser(); + } + +} \ No newline at end of file diff --git a/admin/src/Controller/Joomla_moduleController.php b/admin/src/Controller/Joomla_moduleController.php new file mode 100644 index 000000000..9451d4790 --- /dev/null +++ b/admin/src/Controller/Joomla_moduleController.php @@ -0,0 +1,370 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_module Form Controller + * + * @since 1.6 + */ +class Joomla_moduleController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_MODULE'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'joomla_modules'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('joomla_module.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return $user->authorise('joomla_module.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('joomla_module.access', 'com_componentbuilder.joomla_module.' . (int) $recordId) && $user->authorise('joomla_module.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('joomla_module.edit', 'com_componentbuilder.joomla_module.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('joomla_module.edit.own', 'com_componentbuilder.joomla_module.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('joomla_module.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('joomla_module.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Joomla_module', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_modules' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + // get the state object (Joomla\CMS\Object\CMSObject) + $state = $model->get('state'); + // if we save2copy we need to also copy linked tables found! + if ($state->task === 'save2copy' && $state->{'joomla_plugin.new'}) + { + // get new ID + $newID = $state->{'joomla_module.id'}; + // get old ID + $oldID = $this->input->get('id', 0, 'INT'); + // linked tables to update + $_tablesArray = array( + 'joomla_module_updates' => 'joomla_module', + 'joomla_module_files_folders_urls' => 'joomla_module' + ); + foreach($_tablesArray as $_updateTable => $_key) + { + // get the linked ID + if ($_value = GetHelper::var($_updateTable, $oldID, $_key, 'id')) + { + // copy fields to new linked table + ComponentbuilderHelper::copyItem(/*id->*/ $_value, /*table->*/ $_updateTable, /*change->*/ array($_key => $newID)); + } + } + } + + + return; + } +} diff --git a/admin/src/Controller/Joomla_module_files_folders_urlsController.php b/admin/src/Controller/Joomla_module_files_folders_urlsController.php new file mode 100644 index 000000000..6ea082ccd --- /dev/null +++ b/admin/src/Controller/Joomla_module_files_folders_urlsController.php @@ -0,0 +1,343 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_module_files_folders_urls Form Controller + * + * @since 1.6 + */ +class Joomla_module_files_folders_urlsController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'joomla_modules_files_folders_urls'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('joomla_module_files_folders_urls.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return $user->authorise('joomla_module_files_folders_urls.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('joomla_module_files_folders_urls.access', 'com_componentbuilder.joomla_module_files_folders_urls.' . (int) $recordId) && $user->authorise('joomla_module_files_folders_urls.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('joomla_module_files_folders_urls.edit', 'com_componentbuilder.joomla_module_files_folders_urls.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('joomla_module_files_folders_urls.edit.own', 'com_componentbuilder.joomla_module_files_folders_urls.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('joomla_module_files_folders_urls.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('joomla_module_files_folders_urls.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Joomla_module_files_folders_urls', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_modules_files_folders_urls' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + return; + } +} diff --git a/admin/src/Controller/Joomla_module_updatesController.php b/admin/src/Controller/Joomla_module_updatesController.php new file mode 100644 index 000000000..a4ba336b7 --- /dev/null +++ b/admin/src/Controller/Joomla_module_updatesController.php @@ -0,0 +1,363 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_module_updates Form Controller + * + * @since 1.6 + */ +class Joomla_module_updatesController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'joomla_modules_updates'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('joomla_module_updates.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return $user->authorise('joomla_module_updates.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('joomla_module_updates.access', 'com_componentbuilder.joomla_module_updates.' . (int) $recordId) && $user->authorise('joomla_module_updates.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('joomla_module_updates.edit', 'com_componentbuilder.joomla_module_updates.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('joomla_module_updates.edit.own', 'com_componentbuilder.joomla_module_updates.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('joomla_module_updates.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('joomla_module_updates.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Joomla_module_updates', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_modules_updates' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + // update the component version to match the updated last version + if (isset($validData['joomla_plugin']) && is_numeric($validData['joomla_plugin']) && $validData['joomla_plugin'] > 0) + { + $objectUpdate = new \stdClass(); + $objectUpdate->id = (int) $validData['joomla_plugin']; + if (isset($validData['version_update']) && UtilitiesArrayHelper::check($validData['version_update']) + && ($plugin_version = end($validData['version_update'])['version']) + && StringHelper::check($plugin_version)) + { + $objectUpdate->plugin_version = $plugin_version; + } + // be sure to update the table if we have a value + if (isset($objectUpdate->plugin_version)) + { + Factory::getDbo()->updateObject('#__componentbuilder_joomla_plugin', $objectUpdate, 'id'); + } + } + + return; + } +} diff --git a/admin/src/Controller/Joomla_modulesController.php b/admin/src/Controller/Joomla_modulesController.php new file mode 100644 index 000000000..164e53c0e --- /dev/null +++ b/admin/src/Controller/Joomla_modulesController.php @@ -0,0 +1,128 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_modules Admin Controller + * + * @since 1.6 + */ +class Joomla_modulesController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_MODULES'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Joomla_module', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } + + public function exportData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if export is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('joomla_module.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) + { + // Get the input + $input = Factory::getApplication()->input; + $pks = $input->post->get('cid', array(), 'array'); + // Sanitize the input + $pks = ArrayHelper::toInteger($pks); + // Get the model + $model = $this->getModel('Joomla_modules'); + // get the data to export + $data = $model->getExportData($pks); + if (UtilitiesArrayHelper::check($data)) + { + // now set the data to the spreadsheet + $date = Factory::getDate(); + ComponentbuilderHelper::xls($data,'Joomla_modules_'.$date->format('jS_F_Y'),'Joomla modules exported ('.$date->format('jS F, Y').')','joomla modules'); + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_modules', false), $message, 'error'); + return; + } + + + public function importData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if import is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('joomla_module.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) + { + // Get the import model + $model = $this->getModel('Joomla_modules'); + // get the headers to import + $headers = $model->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + // Load headers to session. + $session = Factory::getSession(); + $headers = json_encode($headers); + $session->set('joomla_module_VDM_IMPORTHEADERS', $headers); + $session->set('backto_VDM_IMPORT', 'joomla_modules'); + $session->set('dataType_VDM_IMPORTINTO', 'joomla_module'); + // Redirect to import view. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_JOOMLA_MODULES'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=import', false), $message); + return; + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_modules', false), $message, 'error'); + return; + } + + public function getSnippets() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // redirect to the import snippets custom admin view + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=get_snippets', false)); + return; + } +} \ No newline at end of file diff --git a/admin/src/Controller/Joomla_modules_files_folders_urlsController.php b/admin/src/Controller/Joomla_modules_files_folders_urlsController.php new file mode 100644 index 000000000..6b3e91c86 --- /dev/null +++ b/admin/src/Controller/Joomla_modules_files_folders_urlsController.php @@ -0,0 +1,54 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_modules_files_folders_urls Admin Controller + * + * @since 1.6 + */ +class Joomla_modules_files_folders_urlsController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_MODULES_FILES_FOLDERS_URLS'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Joomla_module_files_folders_urls', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } +} \ No newline at end of file diff --git a/admin/src/Controller/Joomla_modules_updatesController.php b/admin/src/Controller/Joomla_modules_updatesController.php new file mode 100644 index 000000000..a8d49c0aa --- /dev/null +++ b/admin/src/Controller/Joomla_modules_updatesController.php @@ -0,0 +1,54 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_modules_updates Admin Controller + * + * @since 1.6 + */ +class Joomla_modules_updatesController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Joomla_module_updates', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } +} \ No newline at end of file diff --git a/admin/src/Controller/Joomla_pluginController.php b/admin/src/Controller/Joomla_pluginController.php new file mode 100644 index 000000000..315388be0 --- /dev/null +++ b/admin/src/Controller/Joomla_pluginController.php @@ -0,0 +1,370 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_plugin Form Controller + * + * @since 1.6 + */ +class Joomla_pluginController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'joomla_plugins'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('joomla_plugin.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return $user->authorise('joomla_plugin.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('joomla_plugin.access', 'com_componentbuilder.joomla_plugin.' . (int) $recordId) && $user->authorise('joomla_plugin.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('joomla_plugin.edit', 'com_componentbuilder.joomla_plugin.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('joomla_plugin.edit.own', 'com_componentbuilder.joomla_plugin.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('joomla_plugin.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('joomla_plugin.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Joomla_plugin', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_plugins' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + // get the state object (Joomla\CMS\Object\CMSObject) + $state = $model->get('state'); + // if we save2copy we need to also copy linked tables found! + if ($state->task === 'save2copy' && $state->{'joomla_plugin.new'}) + { + // get new ID + $newID = $state->{'joomla_plugin.id'}; + // get old ID + $oldID = $this->input->get('id', 0, 'INT'); + // linked tables to update + $_tablesArray = array( + 'joomla_plugin_updates' => 'joomla_plugin', + 'joomla_plugin_files_folders_urls' => 'joomla_plugin' + ); + foreach($_tablesArray as $_updateTable => $_key) + { + // get the linked ID + if ($_value = GetHelper::var($_updateTable, $oldID, $_key, 'id')) + { + // copy fields to new linked table + ComponentbuilderHelper::copyItem(/*id->*/ $_value, /*table->*/ $_updateTable, /*change->*/ array($_key => $newID)); + } + } + } + + + return; + } +} diff --git a/admin/src/Controller/Joomla_plugin_files_folders_urlsController.php b/admin/src/Controller/Joomla_plugin_files_folders_urlsController.php new file mode 100644 index 000000000..8590af03a --- /dev/null +++ b/admin/src/Controller/Joomla_plugin_files_folders_urlsController.php @@ -0,0 +1,343 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_plugin_files_folders_urls Form Controller + * + * @since 1.6 + */ +class Joomla_plugin_files_folders_urlsController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'joomla_plugins_files_folders_urls'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('joomla_plugin_files_folders_urls.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return $user->authorise('joomla_plugin_files_folders_urls.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('joomla_plugin_files_folders_urls.access', 'com_componentbuilder.joomla_plugin_files_folders_urls.' . (int) $recordId) && $user->authorise('joomla_plugin_files_folders_urls.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('joomla_plugin_files_folders_urls.edit', 'com_componentbuilder.joomla_plugin_files_folders_urls.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('joomla_plugin_files_folders_urls.edit.own', 'com_componentbuilder.joomla_plugin_files_folders_urls.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('joomla_plugin_files_folders_urls.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('joomla_plugin_files_folders_urls.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Joomla_plugin_files_folders_urls', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_plugins_files_folders_urls' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + return; + } +} diff --git a/admin/src/Controller/Joomla_plugin_groupController.php b/admin/src/Controller/Joomla_plugin_groupController.php new file mode 100644 index 000000000..b9be75528 --- /dev/null +++ b/admin/src/Controller/Joomla_plugin_groupController.php @@ -0,0 +1,336 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_plugin_group Form Controller + * + * @since 1.6 + */ +class Joomla_plugin_groupController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'joomla_plugin_groups'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('joomla_plugin_group.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return parent::allowAdd($data); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('core.edit', 'com_componentbuilder.joomla_plugin_group.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('core.edit.own', 'com_componentbuilder.joomla_plugin_group.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('core.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return parent::allowEdit($data, $key); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Joomla_plugin_group', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_plugin_groups' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + return; + } +} diff --git a/admin/src/Controller/Joomla_plugin_groupsController.php b/admin/src/Controller/Joomla_plugin_groupsController.php new file mode 100644 index 000000000..eeb79b1a7 --- /dev/null +++ b/admin/src/Controller/Joomla_plugin_groupsController.php @@ -0,0 +1,54 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_plugin_groups Admin Controller + * + * @since 1.6 + */ +class Joomla_plugin_groupsController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUPS'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Joomla_plugin_group', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } +} \ No newline at end of file diff --git a/admin/src/Controller/Joomla_plugin_updatesController.php b/admin/src/Controller/Joomla_plugin_updatesController.php new file mode 100644 index 000000000..5b08f8bc0 --- /dev/null +++ b/admin/src/Controller/Joomla_plugin_updatesController.php @@ -0,0 +1,363 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_plugin_updates Form Controller + * + * @since 1.6 + */ +class Joomla_plugin_updatesController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'joomla_plugins_updates'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('joomla_plugin_updates.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return $user->authorise('joomla_plugin_updates.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('joomla_plugin_updates.access', 'com_componentbuilder.joomla_plugin_updates.' . (int) $recordId) && $user->authorise('joomla_plugin_updates.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('joomla_plugin_updates.edit', 'com_componentbuilder.joomla_plugin_updates.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('joomla_plugin_updates.edit.own', 'com_componentbuilder.joomla_plugin_updates.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('joomla_plugin_updates.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('joomla_plugin_updates.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Joomla_plugin_updates', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=joomla_plugins_updates' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + // update the component version to match the updated last version + if (isset($validData['joomla_plugin']) && is_numeric($validData['joomla_plugin']) && $validData['joomla_plugin'] > 0) + { + $objectUpdate = new \stdClass(); + $objectUpdate->id = (int) $validData['joomla_plugin']; + if (isset($validData['version_update']) && UtilitiesArrayHelper::check($validData['version_update']) + && ($plugin_version = end($validData['version_update'])['version']) + && StringHelper::check($plugin_version)) + { + $objectUpdate->plugin_version = $plugin_version; + } + // be sure to update the table if we have a value + if (isset($objectUpdate->plugin_version)) + { + Factory::getDbo()->updateObject('#__componentbuilder_joomla_plugin', $objectUpdate, 'id'); + } + } + + return; + } +} diff --git a/admin/src/Controller/Joomla_pluginsController.php b/admin/src/Controller/Joomla_pluginsController.php new file mode 100644 index 000000000..b9e80e112 --- /dev/null +++ b/admin/src/Controller/Joomla_pluginsController.php @@ -0,0 +1,148 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_plugins Admin Controller + * + * @since 1.6 + */ +class Joomla_pluginsController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_PLUGINS'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Joomla_plugin', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } + + + /** + * Run the Expansion + * + * @return void + */ + public function runExpansion() + { + // Check for request forgeries + Session::checkToken() or \jexit(Text::_('JINVALID_TOKEN')); + // check if user has the right + $user = Factory::getUser(); + // set page redirect + $redirect_url = \JRoute::_('index.php?option=com_componentbuilder&view=joomla_plugins', false); + // set massage + $message = Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE'); + // check if this user has the right to run expansion + if($user->authorise('joomla_plugins.run_expansion', 'com_componentbuilder')) + { + // set massage + $message = Text::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB'); + // run expansion via API + $result = ComponentbuilderHelper::getFileContents(\JUri::root() . 'index.php?option=com_componentbuilder&task=api.expand'); + // is there a message returned + if (!is_numeric($result) && StringHelper::check($result)) + { + $this->setRedirect($redirect_url, $result); + return true; + } + elseif (is_numeric($result) && 1 == $result) + { + $message = Text::_('COM_COMPONENTBUILDER_BTHE_EXPANSION_WAS_SUCCESSFULLYB_TO_SEE_MORE_INFORMATION_CHANGE_THE_BRETURN_OPTIONS_FOR_BUILDB_TO_BDISPLAY_MESSAGEB_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TABB'); + $this->setRedirect($redirect_url, $message, 'message'); + return true; + } + } + $this->setRedirect($redirect_url, $message, 'error'); + return false; + } + + + /** + * get Boilerplate + * + * @return boolean + */ + public function getBoilerplate() + { + // Check for request forgeries + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + // check if user has the right + $user = Factory::getUser(); + // set page redirect + $redirect_url = \JRoute::_('index.php?option=com_componentbuilder&view=joomla_plugins', false); + // set massage + $message = Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_GET_BOILERPLATE_MODULE'); + // check if this user has the right to run expansion + if($user->authorise('joomla_plugin.get_boilerplate', 'com_componentbuilder')) + { + // set massage + $message = Text::_('COM_COMPONENTBUILDER_GETTING_JOOMLA_PLUGIN_BOILERPLATE_FAILED_IF_THE_ISSUE_CONTINUES_INFORM_YOUR_SYSTEM_ADMINISTRATOR'); + // Get the model + $model = $this->getModel('joomla_plugins'); + // check if there is any selections + if (!$model->getBoilerplate()) + { + $message = '' . Text::_('COM_COMPONENTBUILDER_GETTING_JOOMLA_PLUGIN_BOILERPLATE_WAS_SUCCESSFULLY') . ''; + $this->setRedirect($redirect_url, $message, 'message'); + return true; + } + } + $this->setRedirect($redirect_url, $message, 'error'); + return false; + } + + public function openClassMethods() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // redirect to the libraries + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=class_methods', false)); + return; + } + + public function openClassProperties() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // redirect to the libraries + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=class_properties', false)); + return; + } +} \ No newline at end of file diff --git a/admin/src/Controller/Joomla_plugins_files_folders_urlsController.php b/admin/src/Controller/Joomla_plugins_files_folders_urlsController.php new file mode 100644 index 000000000..036f628ea --- /dev/null +++ b/admin/src/Controller/Joomla_plugins_files_folders_urlsController.php @@ -0,0 +1,54 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_plugins_files_folders_urls Admin Controller + * + * @since 1.6 + */ +class Joomla_plugins_files_folders_urlsController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Joomla_plugin_files_folders_urls', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } +} \ No newline at end of file diff --git a/admin/src/Controller/Joomla_plugins_updatesController.php b/admin/src/Controller/Joomla_plugins_updatesController.php new file mode 100644 index 000000000..de42a6042 --- /dev/null +++ b/admin/src/Controller/Joomla_plugins_updatesController.php @@ -0,0 +1,54 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_plugins_updates Admin Controller + * + * @since 1.6 + */ +class Joomla_plugins_updatesController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Joomla_plugin_updates', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } +} \ No newline at end of file diff --git a/admin/src/Controller/LanguageController.php b/admin/src/Controller/LanguageController.php new file mode 100644 index 000000000..9421c4a40 --- /dev/null +++ b/admin/src/Controller/LanguageController.php @@ -0,0 +1,343 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Language Form Controller + * + * @since 1.6 + */ +class LanguageController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_LANGUAGE'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'languages'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('language.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return $user->authorise('language.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('language.access', 'com_componentbuilder.language.' . (int) $recordId) && $user->authorise('language.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('language.edit', 'com_componentbuilder.language.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('language.edit.own', 'com_componentbuilder.language.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('language.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('language.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Language', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=languages' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + return; + } +} diff --git a/admin/src/Controller/Language_translationController.php b/admin/src/Controller/Language_translationController.php new file mode 100644 index 000000000..d24c9b872 --- /dev/null +++ b/admin/src/Controller/Language_translationController.php @@ -0,0 +1,343 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Language_translation Form Controller + * + * @since 1.6 + */ +class Language_translationController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'language_translations'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('language_translation.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return $user->authorise('language_translation.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('language_translation.access', 'com_componentbuilder.language_translation.' . (int) $recordId) && $user->authorise('language_translation.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('language_translation.edit', 'com_componentbuilder.language_translation.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('language_translation.edit.own', 'com_componentbuilder.language_translation.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('language_translation.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('language_translation.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Language_translation', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=language_translations' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + return; + } +} diff --git a/admin/src/Controller/Language_translationsController.php b/admin/src/Controller/Language_translationsController.php new file mode 100644 index 000000000..47e29dfdc --- /dev/null +++ b/admin/src/Controller/Language_translationsController.php @@ -0,0 +1,119 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Language_translations Admin Controller + * + * @since 1.6 + */ +class Language_translationsController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Language_translation', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } + + public function exportData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if export is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('language_translation.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) + { + // Get the input + $input = Factory::getApplication()->input; + $pks = $input->post->get('cid', array(), 'array'); + // Sanitize the input + $pks = ArrayHelper::toInteger($pks); + // Get the model + $model = $this->getModel('Language_translations'); + // get the data to export + $data = $model->getExportData($pks); + if (UtilitiesArrayHelper::check($data)) + { + // now set the data to the spreadsheet + $date = Factory::getDate(); + ComponentbuilderHelper::xls($data,'Language_translations_'.$date->format('jS_F_Y'),'Language translations exported ('.$date->format('jS F, Y').')','language translations'); + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=language_translations', false), $message, 'error'); + return; + } + + + public function importData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if import is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('language_translation.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) + { + // Get the import model + $model = $this->getModel('Language_translations'); + // get the headers to import + $headers = $model->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + // Load headers to session. + $session = Factory::getSession(); + $headers = json_encode($headers); + $session->set('language_translation_VDM_IMPORTHEADERS', $headers); + $session->set('backto_VDM_IMPORT', 'language_translations'); + $session->set('dataType_VDM_IMPORTINTO', 'language_translation'); + // Redirect to import view. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_LANGUAGE_TRANSLATIONS'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=import_language_translations', false), $message); + return; + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=language_translations', false), $message, 'error'); + return; + } +} \ No newline at end of file diff --git a/admin/src/Controller/LanguagesController.php b/admin/src/Controller/LanguagesController.php new file mode 100644 index 000000000..b9c72e0a7 --- /dev/null +++ b/admin/src/Controller/LanguagesController.php @@ -0,0 +1,146 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Languages Admin Controller + * + * @since 1.6 + */ +class LanguagesController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_LANGUAGES'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Language', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } + + public function exportData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if export is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('language.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) + { + // Get the input + $input = Factory::getApplication()->input; + $pks = $input->post->get('cid', array(), 'array'); + // Sanitize the input + $pks = ArrayHelper::toInteger($pks); + // Get the model + $model = $this->getModel('Languages'); + // get the data to export + $data = $model->getExportData($pks); + if (UtilitiesArrayHelper::check($data)) + { + // now set the data to the spreadsheet + $date = Factory::getDate(); + ComponentbuilderHelper::xls($data,'Languages_'.$date->format('jS_F_Y'),'Languages exported ('.$date->format('jS F, Y').')','languages'); + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=languages', false), $message, 'error'); + return; + } + + + public function importData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if import is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('language.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) + { + // Get the import model + $model = $this->getModel('Languages'); + // get the headers to import + $headers = $model->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + // Load headers to session. + $session = Factory::getSession(); + $headers = json_encode($headers); + $session->set('language_VDM_IMPORTHEADERS', $headers); + $session->set('backto_VDM_IMPORT', 'languages'); + $session->set('dataType_VDM_IMPORTINTO', 'language'); + // Redirect to import view. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_LANGUAGES'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=import', false), $message); + return; + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=languages', false), $message, 'error'); + return; + } + + public function buildLanguages() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if user has the right + $user = Factory::getUser(); + if($user->authorise('core.create', 'com_componentbuilder')) + { + // get the model + $model = $this->getModel('languages'); + if ($model->buildLanguages()) + { + // set success message + $message = '

    '.Text::_('COM_COMPONENTBUILDER_IMPORT_SUCCESS').'

    '; + $message .= '

    '.Text::_('COM_COMPONENTBUILDER_ALL_THE_LANGUAGES_FOUND_IN_JOOMLA_WERE_SUCCESSFULLY_IMPORTED').'

    '; + // set redirect + $redirect_url = Route::_('index.php?option=com_componentbuilder&view=languages', false); + $this->setRedirect($redirect_url, $message); + return true; + } + } + // set redirect + $redirect_url = Route::_('index.php?option=com_componentbuilder&view=languages', false); + $this->setRedirect($redirect_url); + return false; + } +} \ No newline at end of file diff --git a/admin/src/Controller/LayoutController.php b/admin/src/Controller/LayoutController.php new file mode 100644 index 000000000..3f7c600bc --- /dev/null +++ b/admin/src/Controller/LayoutController.php @@ -0,0 +1,343 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Layout Form Controller + * + * @since 1.6 + */ +class LayoutController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_LAYOUT'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'layouts'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('layout.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return parent::allowAdd($data); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('layout.access', 'com_componentbuilder.layout.' . (int) $recordId) && $user->authorise('layout.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('core.edit', 'com_componentbuilder.layout.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('core.edit.own', 'com_componentbuilder.layout.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('core.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return parent::allowEdit($data, $key); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Layout', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=layouts' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + return; + } +} diff --git a/admin/src/Controller/LayoutsController.php b/admin/src/Controller/LayoutsController.php new file mode 100644 index 000000000..9bbf893ae --- /dev/null +++ b/admin/src/Controller/LayoutsController.php @@ -0,0 +1,128 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Layouts Admin Controller + * + * @since 1.6 + */ +class LayoutsController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_LAYOUTS'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Layout', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } + + public function exportData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if export is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('layout.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) + { + // Get the input + $input = Factory::getApplication()->input; + $pks = $input->post->get('cid', array(), 'array'); + // Sanitize the input + $pks = ArrayHelper::toInteger($pks); + // Get the model + $model = $this->getModel('Layouts'); + // get the data to export + $data = $model->getExportData($pks); + if (UtilitiesArrayHelper::check($data)) + { + // now set the data to the spreadsheet + $date = Factory::getDate(); + ComponentbuilderHelper::xls($data,'Layouts_'.$date->format('jS_F_Y'),'Layouts exported ('.$date->format('jS F, Y').')','layouts'); + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=layouts', false), $message, 'error'); + return; + } + + + public function importData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if import is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('layout.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) + { + // Get the import model + $model = $this->getModel('Layouts'); + // get the headers to import + $headers = $model->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + // Load headers to session. + $session = Factory::getSession(); + $headers = json_encode($headers); + $session->set('layout_VDM_IMPORTHEADERS', $headers); + $session->set('backto_VDM_IMPORT', 'layouts'); + $session->set('dataType_VDM_IMPORTINTO', 'layout'); + // Redirect to import view. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_LAYOUTS'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=import', false), $message); + return; + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=layouts', false), $message, 'error'); + return; + } + + public function getSnippets() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // redirect to the import snippets custom admin view + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=get_snippets', false)); + return; + } +} \ No newline at end of file diff --git a/admin/src/Controller/LibrariesController.php b/admin/src/Controller/LibrariesController.php new file mode 100644 index 000000000..86a15a656 --- /dev/null +++ b/admin/src/Controller/LibrariesController.php @@ -0,0 +1,63 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Libraries Admin Controller + * + * @since 1.6 + */ +class LibrariesController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_LIBRARIES'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Library', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } + + public function getSnippets() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // redirect to the import snippets custom admin view + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=get_snippets', false)); + return; + } +} \ No newline at end of file diff --git a/admin/src/Controller/Libraries_configController.php b/admin/src/Controller/Libraries_configController.php new file mode 100644 index 000000000..8450cb77b --- /dev/null +++ b/admin/src/Controller/Libraries_configController.php @@ -0,0 +1,54 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Libraries_config Admin Controller + * + * @since 1.6 + */ +class Libraries_configController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_LIBRARIES_CONFIG'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Library_config', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } +} \ No newline at end of file diff --git a/admin/src/Controller/Libraries_files_folders_urlsController.php b/admin/src/Controller/Libraries_files_folders_urlsController.php new file mode 100644 index 000000000..ba6768181 --- /dev/null +++ b/admin/src/Controller/Libraries_files_folders_urlsController.php @@ -0,0 +1,54 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Libraries_files_folders_urls Admin Controller + * + * @since 1.6 + */ +class Libraries_files_folders_urlsController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Library_files_folders_urls', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } +} \ No newline at end of file diff --git a/admin/src/Controller/LibraryController.php b/admin/src/Controller/LibraryController.php new file mode 100644 index 000000000..dbadb6029 --- /dev/null +++ b/admin/src/Controller/LibraryController.php @@ -0,0 +1,369 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Library Form Controller + * + * @since 1.6 + */ +class LibraryController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_LIBRARY'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'libraries'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('library.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return $user->authorise('library.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('library.access', 'com_componentbuilder.library.' . (int) $recordId) && $user->authorise('library.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('library.edit', 'com_componentbuilder.library.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('library.edit.own', 'com_componentbuilder.library.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('library.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('library.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Library', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=libraries' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + // get the state object (Joomla\CMS\Object\CMSObject) + $state = $model->get('state'); + // if we save2copy we need to also copy linked tables found! + if ($state->task === 'save2copy' && $state->{'library.new'}) + { + // get new ID + $newID = $state->{'library.id'}; + // get old ID + $oldID = $this->input->get('id', 0, 'INT'); + // linked tables to update + $_tablesArray = array( + 'library_config', + 'library_files_folders_urls' + ); + foreach($_tablesArray as $_updateTable) + { + // get the linked ID + if ($_value = GetHelper::var($_updateTable, $oldID, 'library', 'id')) + { + // copy fields to new linked table + ComponentbuilderHelper::copyItem(/*id->*/ $_value, /*table->*/ $_updateTable, /*change->*/ array('library' => $newID)); + } + } + } + + return; + } +} diff --git a/admin/src/Controller/Library_configController.php b/admin/src/Controller/Library_configController.php new file mode 100644 index 000000000..24cc43a5c --- /dev/null +++ b/admin/src/Controller/Library_configController.php @@ -0,0 +1,343 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Library_config Form Controller + * + * @since 1.6 + */ +class Library_configController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_LIBRARY_CONFIG'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'libraries_config'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('library_config.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return $user->authorise('library_config.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('library_config.access', 'com_componentbuilder.library_config.' . (int) $recordId) && $user->authorise('library_config.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('library_config.edit', 'com_componentbuilder.library_config.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('library_config.edit.own', 'com_componentbuilder.library_config.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('library_config.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('library_config.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Library_config', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=libraries_config' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + return; + } +} diff --git a/admin/src/Controller/Library_files_folders_urlsController.php b/admin/src/Controller/Library_files_folders_urlsController.php new file mode 100644 index 000000000..0365f8e37 --- /dev/null +++ b/admin/src/Controller/Library_files_folders_urlsController.php @@ -0,0 +1,343 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Library_files_folders_urls Form Controller + * + * @since 1.6 + */ +class Library_files_folders_urlsController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'libraries_files_folders_urls'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('library_files_folders_urls.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return $user->authorise('library_files_folders_urls.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('library_files_folders_urls.access', 'com_componentbuilder.library_files_folders_urls.' . (int) $recordId) && $user->authorise('library_files_folders_urls.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('library_files_folders_urls.edit', 'com_componentbuilder.library_files_folders_urls.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('library_files_folders_urls.edit.own', 'com_componentbuilder.library_files_folders_urls.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('library_files_folders_urls.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('library_files_folders_urls.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Library_files_folders_urls', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=libraries_files_folders_urls' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + return; + } +} diff --git a/admin/src/Controller/PlaceholderController.php b/admin/src/Controller/PlaceholderController.php new file mode 100644 index 000000000..fd5e49765 --- /dev/null +++ b/admin/src/Controller/PlaceholderController.php @@ -0,0 +1,343 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Placeholder Form Controller + * + * @since 1.6 + */ +class PlaceholderController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_PLACEHOLDER'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'placeholders'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('placeholder.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return $user->authorise('placeholder.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('placeholder.access', 'com_componentbuilder.placeholder.' . (int) $recordId) && $user->authorise('placeholder.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('placeholder.edit', 'com_componentbuilder.placeholder.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('placeholder.edit.own', 'com_componentbuilder.placeholder.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('placeholder.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('placeholder.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Placeholder', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=placeholders' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + return; + } +} diff --git a/admin/src/Controller/PlaceholdersController.php b/admin/src/Controller/PlaceholdersController.php new file mode 100644 index 000000000..bff3f1ef9 --- /dev/null +++ b/admin/src/Controller/PlaceholdersController.php @@ -0,0 +1,119 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Placeholders Admin Controller + * + * @since 1.6 + */ +class PlaceholdersController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_PLACEHOLDERS'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Placeholder', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } + + public function exportData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if export is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('placeholder.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) + { + // Get the input + $input = Factory::getApplication()->input; + $pks = $input->post->get('cid', array(), 'array'); + // Sanitize the input + $pks = ArrayHelper::toInteger($pks); + // Get the model + $model = $this->getModel('Placeholders'); + // get the data to export + $data = $model->getExportData($pks); + if (UtilitiesArrayHelper::check($data)) + { + // now set the data to the spreadsheet + $date = Factory::getDate(); + ComponentbuilderHelper::xls($data,'Placeholders_'.$date->format('jS_F_Y'),'Placeholders exported ('.$date->format('jS F, Y').')','placeholders'); + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=placeholders', false), $message, 'error'); + return; + } + + + public function importData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if import is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('placeholder.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) + { + // Get the import model + $model = $this->getModel('Placeholders'); + // get the headers to import + $headers = $model->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + // Load headers to session. + $session = Factory::getSession(); + $headers = json_encode($headers); + $session->set('placeholder_VDM_IMPORTHEADERS', $headers); + $session->set('backto_VDM_IMPORT', 'placeholders'); + $session->set('dataType_VDM_IMPORTINTO', 'placeholder'); + // Redirect to import view. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_PLACEHOLDERS'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=import', false), $message); + return; + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=placeholders', false), $message, 'error'); + return; + } +} \ No newline at end of file diff --git a/admin/src/Controller/PowerController.php b/admin/src/Controller/PowerController.php new file mode 100644 index 000000000..4ca682822 --- /dev/null +++ b/admin/src/Controller/PowerController.php @@ -0,0 +1,400 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Componentbuilder\Power\Factory as PowerFactory; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Power Form Controller + * + * @since 1.6 + */ +class PowerController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_POWER'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'powers'; + + public function resetPowers() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + + // get Item posted + $item = $this->input->post->get('jform', array(), 'array'); + + // check if user has the right + $user = Factory::getUser(); + + // set default error message + $message = '

    ' . Text::_('COM_COMPONENTBUILDER_PERMISSION_DENIED') . '

    '; + $message .= '

    ' . Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RESET_THIS_POWER') . '

    '; + $status = 'error'; + $success = false; + + // load the ID + $id = $item['id'] ?? null; + $guid = $item['guid'] ?? null; + + // check if there is any selections + if ($id === null || $guid === null) + { + // set error message + $message = '

    ' . Text::_('COM_COMPONENTBUILDER_NOT_SAVED') . '

    '; + $message .= '

    ' . Text::_('COM_COMPONENTBUILDER_YOU_MUST_FIRST_SAVE_THE_POWER_BEFORE_YOU_CAN_USE_THIS_FEATURE') . '

    '; + } + elseif($user->authorise('power.reset', 'com_componentbuilder')) + { + if (PowerFactory::_('Superpower')->reset([$guid])) + { + // set success message + $message = '

    '.Text::_('COM_COMPONENTBUILDER_SUCCESS').'

    '; + $message .= '

    '.Text::_('COM_COMPONENTBUILDER_THE_POWER_HAS_SUCCESSFULLY_BEEN_RESET').'

    '; + $status = 'success'; + $success = true; + } + else + { + $message = '

    ' . Text::_('COM_COMPONENTBUILDER_RESET_FAILED') . '

    '; + $message .= '

    ' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THIS_POWER_HAS_FAILED') . '

    '; + } + } + + // set redirect + $redirect_url = Route::_( + 'index.php?option=com_componentbuilder&view=power' + . $this->getRedirectToItemAppend($id), $success + ); + + $this->setRedirect($redirect_url, $message, $status); + + return $success; + } + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('power.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return $user->authorise('power.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('power.access', 'com_componentbuilder.power.' . (int) $recordId) && $user->authorise('power.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('power.edit', 'com_componentbuilder.power.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('power.edit.own', 'com_componentbuilder.power.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('power.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('power.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Power', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=powers' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + return; + } +} diff --git a/admin/src/Controller/PowersController.php b/admin/src/Controller/PowersController.php new file mode 100644 index 000000000..937633ec7 --- /dev/null +++ b/admin/src/Controller/PowersController.php @@ -0,0 +1,176 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Power\Factory as PowerFactory; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Powers Admin Controller + * + * @since 1.6 + */ +class PowersController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_POWERS'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Power', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } + + + /** + * Run the Expansion + * + * @return void + */ + public function runExpansion() + { + // Check for request forgeries + Session::checkToken() or \jexit(Text::_('JINVALID_TOKEN')); + // check if user has the right + $user = Factory::getUser(); + // set page redirect + $redirect_url = \JRoute::_('index.php?option=com_componentbuilder&view=powers', false); + // set massage + $message = Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE'); + // check if this user has the right to run expansion + if($user->authorise('powers.run_expansion', 'com_componentbuilder')) + { + // set massage + $message = Text::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB'); + // run expansion via API + $result = ComponentbuilderHelper::getFileContents(\JUri::root() . 'index.php?option=com_componentbuilder&task=api.expand'); + // is there a message returned + if (!is_numeric($result) && StringHelper::check($result)) + { + $this->setRedirect($redirect_url, $result); + return true; + } + elseif (is_numeric($result) && 1 == $result) + { + $message = Text::_('COM_COMPONENTBUILDER_BTHE_EXPANSION_WAS_SUCCESSFULLYB_TO_SEE_MORE_INFORMATION_CHANGE_THE_BRETURN_OPTIONS_FOR_BUILDB_TO_BDISPLAY_MESSAGEB_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TABB'); + $this->setRedirect($redirect_url, $message, 'message'); + return true; + } + } + $this->setRedirect($redirect_url, $message, 'error'); + return false; + } + + public function initPowers() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + + // check if user has the right + $user = Factory::getUser(); + + // set default error message + $message = '

    ' . Text::_('COM_COMPONENTBUILDER_PERMISSION_DENIED') . '

    '; + $message .= '

    ' . Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_INITIALIZE_POWERS') . '

    '; + $status = 'error'; + $success = false; + + if($user->authorise('power.init', 'com_componentbuilder')) + { + if (PowerFactory::_('Superpower')->init()) + { + // set success message + $message = '

    ' . Text::_('COM_COMPONENTBUILDER_SUCCESSFULLY_INITIALIZED_ALL_REMOTE_POWERS') . '

    '; + $message .= '

    ' . Text::_('COM_COMPONENTBUILDER_THE_LOCAL_DATABASE_POWERS_HAS_SUCCESSFULLY_BEEN_SYNCED_WITH_THE_REMOTE_REPOSITORIES') . '

    '; + + $status = 'success'; + $success = true; + } + else + { + $message = '

    ' . Text::_('COM_COMPONENTBUILDER_INITIALIZATION_FAILED') . '

    '; + $message .= '

    ' . Text::_('COM_COMPONENTBUILDER_THE_INITIALIZATION_OF_THIS_POWERS_HAS_FAILED') . '

    '; + } + } + + // set redirect + $redirect_url = Route::_('index.php?option=com_componentbuilder&view=powers', $success); + $this->setRedirect($redirect_url, $message, $status); + + return $success; + } + + public function resetPowers() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + + // get IDS of the selected powers + $pks = $this->input->post->get('cid', [], 'array'); + + // Sanitize the input + ArrayHelper::toInteger($pks); + + // check if there is any selections + if ($pks == []) + { + // set error message + $message = '

    '.Text::_('COM_COMPONENTBUILDER_NO_SELECTION_DETECTED').'

    '; + $message .= '

    '.Text::_('COM_COMPONENTBUILDER_PLEASE_FIRST_MAKE_A_SELECTION_FROM_THE_LIST').'

    '; + // set redirect + $redirect_url = Route::_('index.php?option=com_componentbuilder&view=powers', false); + $this->setRedirect($redirect_url, $message, 'error'); + return false; + } + + // check if user has the right + $user = Factory::getUser(); + if($user->authorise('power.reset', 'com_componentbuilder')) + { + // set success message + $message = '

    '.Text::_('COM_COMPONENTBUILDER_THIS_RESET_FEATURE_IS_STILL_UNDER_DEVELOPMENT').'

    '; + $message .= '

    '.Text::sprintf('COM_COMPONENTBUILDER_PLEASE_CHECK_AGAIN_SOON_ANDOR_FOLLOW_THE_PROGRESS_ON_SGITVDMDEVA', '').'

    '; + // set redirect + $redirect_url = Route::_('index.php?option=com_componentbuilder&view=powers', false); + $this->setRedirect($redirect_url, $message); + return true; + } + // set redirect + $redirect_url = Route::_('index.php?option=com_componentbuilder&view=powers', false); + $this->setRedirect($redirect_url); + return false; + } +} \ No newline at end of file diff --git a/admin/src/Controller/SearchController.php b/admin/src/Controller/SearchController.php new file mode 100644 index 000000000..69e3d423f --- /dev/null +++ b/admin/src/Controller/SearchController.php @@ -0,0 +1,66 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Search Base Controller + * + * @since 1.6 + */ +class SearchController extends BaseController +{ + /** + * The context for storing internal data, e.g. record. + * + * @var string + * @since 1.6 + */ + protected $context = 'search'; + + /** + * The URL view item variable. + * + * @var string + * @since 1.6 + */ + protected $view_item = 'search'; + + /** + * Adds option to redirect back to the dashboard. + * + * @return void + * @since 3.0 + */ + public function dashboard(): void + { + $this->setRedirect(Route::_('index.php?option=com_componentbuilder', false)); + } + + public function openCompiler() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // redirect to the libraries + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=compiler', false)); + return; + } +} diff --git a/admin/src/Controller/ServerController.php b/admin/src/Controller/ServerController.php new file mode 100644 index 000000000..e28b31bc7 --- /dev/null +++ b/admin/src/Controller/ServerController.php @@ -0,0 +1,343 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Server Form Controller + * + * @since 1.6 + */ +class ServerController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_SERVER'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'servers'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('server.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return $user->authorise('server.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('server.access', 'com_componentbuilder.server.' . (int) $recordId) && $user->authorise('server.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('server.edit', 'com_componentbuilder.server.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('server.edit.own', 'com_componentbuilder.server.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('server.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('server.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Server', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=servers' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + return; + } +} diff --git a/admin/src/Controller/ServersController.php b/admin/src/Controller/ServersController.php new file mode 100644 index 000000000..cb56b145e --- /dev/null +++ b/admin/src/Controller/ServersController.php @@ -0,0 +1,119 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Servers Admin Controller + * + * @since 1.6 + */ +class ServersController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_SERVERS'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Server', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } + + public function exportData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if export is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('server.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) + { + // Get the input + $input = Factory::getApplication()->input; + $pks = $input->post->get('cid', array(), 'array'); + // Sanitize the input + $pks = ArrayHelper::toInteger($pks); + // Get the model + $model = $this->getModel('Servers'); + // get the data to export + $data = $model->getExportData($pks); + if (UtilitiesArrayHelper::check($data)) + { + // now set the data to the spreadsheet + $date = Factory::getDate(); + ComponentbuilderHelper::xls($data,'Servers_'.$date->format('jS_F_Y'),'Servers exported ('.$date->format('jS F, Y').')','servers'); + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=servers', false), $message, 'error'); + return; + } + + + public function importData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if import is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('server.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) + { + // Get the import model + $model = $this->getModel('Servers'); + // get the headers to import + $headers = $model->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + // Load headers to session. + $session = Factory::getSession(); + $headers = json_encode($headers); + $session->set('server_VDM_IMPORTHEADERS', $headers); + $session->set('backto_VDM_IMPORT', 'servers'); + $session->set('dataType_VDM_IMPORTINTO', 'server'); + // Redirect to import view. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_SERVERS'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=import', false), $message); + return; + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=servers', false), $message, 'error'); + return; + } +} \ No newline at end of file diff --git a/admin/src/Controller/Site_viewController.php b/admin/src/Controller/Site_viewController.php new file mode 100644 index 000000000..ac26300bd --- /dev/null +++ b/admin/src/Controller/Site_viewController.php @@ -0,0 +1,343 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Site_view Form Controller + * + * @since 1.6 + */ +class Site_viewController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_SITE_VIEW'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'site_views'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('site_view.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return parent::allowAdd($data); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('site_view.access', 'com_componentbuilder.site_view.' . (int) $recordId) && $user->authorise('site_view.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('core.edit', 'com_componentbuilder.site_view.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('core.edit.own', 'com_componentbuilder.site_view.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('core.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return parent::allowEdit($data, $key); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Site_view', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=site_views' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + return; + } +} diff --git a/admin/src/Controller/Site_viewsController.php b/admin/src/Controller/Site_viewsController.php new file mode 100644 index 000000000..dd88c9104 --- /dev/null +++ b/admin/src/Controller/Site_viewsController.php @@ -0,0 +1,128 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Site_views Admin Controller + * + * @since 1.6 + */ +class Site_viewsController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_SITE_VIEWS'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Site_view', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } + + public function exportData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if export is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('site_view.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) + { + // Get the input + $input = Factory::getApplication()->input; + $pks = $input->post->get('cid', array(), 'array'); + // Sanitize the input + $pks = ArrayHelper::toInteger($pks); + // Get the model + $model = $this->getModel('Site_views'); + // get the data to export + $data = $model->getExportData($pks); + if (UtilitiesArrayHelper::check($data)) + { + // now set the data to the spreadsheet + $date = Factory::getDate(); + ComponentbuilderHelper::xls($data,'Site_views_'.$date->format('jS_F_Y'),'Site views exported ('.$date->format('jS F, Y').')','site views'); + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=site_views', false), $message, 'error'); + return; + } + + + public function importData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if import is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('site_view.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) + { + // Get the import model + $model = $this->getModel('Site_views'); + // get the headers to import + $headers = $model->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + // Load headers to session. + $session = Factory::getSession(); + $headers = json_encode($headers); + $session->set('site_view_VDM_IMPORTHEADERS', $headers); + $session->set('backto_VDM_IMPORT', 'site_views'); + $session->set('dataType_VDM_IMPORTINTO', 'site_view'); + // Redirect to import view. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_SITE_VIEWS'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=import', false), $message); + return; + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=site_views', false), $message, 'error'); + return; + } + + public function getSnippets() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // redirect to the import snippets custom admin view + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=get_snippets', false)); + return; + } +} \ No newline at end of file diff --git a/admin/src/Controller/SnippetController.php b/admin/src/Controller/SnippetController.php new file mode 100644 index 000000000..c7e0dbc7b --- /dev/null +++ b/admin/src/Controller/SnippetController.php @@ -0,0 +1,343 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Snippet Form Controller + * + * @since 1.6 + */ +class SnippetController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_SNIPPET'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'snippets'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('snippet.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return parent::allowAdd($data); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('snippet.access', 'com_componentbuilder.snippet.' . (int) $recordId) && $user->authorise('snippet.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('core.edit', 'com_componentbuilder.snippet.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('core.edit.own', 'com_componentbuilder.snippet.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('core.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return parent::allowEdit($data, $key); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Snippet', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=snippets' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + return; + } +} diff --git a/admin/src/Controller/Snippet_typeController.php b/admin/src/Controller/Snippet_typeController.php new file mode 100644 index 000000000..17fe7b651 --- /dev/null +++ b/admin/src/Controller/Snippet_typeController.php @@ -0,0 +1,343 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Snippet_type Form Controller + * + * @since 1.6 + */ +class Snippet_typeController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_SNIPPET_TYPE'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'snippet_types'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('snippet_type.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return $user->authorise('snippet_type.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('snippet_type.access', 'com_componentbuilder.snippet_type.' . (int) $recordId) && $user->authorise('snippet_type.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('snippet_type.edit', 'com_componentbuilder.snippet_type.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('snippet_type.edit.own', 'com_componentbuilder.snippet_type.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('snippet_type.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('snippet_type.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Snippet_type', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=snippet_types' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + return; + } +} diff --git a/admin/src/Controller/Snippet_typesController.php b/admin/src/Controller/Snippet_typesController.php new file mode 100644 index 000000000..7e36f0c9c --- /dev/null +++ b/admin/src/Controller/Snippet_typesController.php @@ -0,0 +1,54 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Snippet_types Admin Controller + * + * @since 1.6 + */ +class Snippet_typesController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_SNIPPET_TYPES'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Snippet_type', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } +} \ No newline at end of file diff --git a/admin/src/Controller/SnippetsController.php b/admin/src/Controller/SnippetsController.php new file mode 100644 index 000000000..4321f8799 --- /dev/null +++ b/admin/src/Controller/SnippetsController.php @@ -0,0 +1,192 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Snippets Admin Controller + * + * @since 1.6 + */ +class SnippetsController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_SNIPPETS'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Snippet', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } + + public function exportData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if export is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('snippet.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) + { + // Get the input + $input = Factory::getApplication()->input; + $pks = $input->post->get('cid', array(), 'array'); + // Sanitize the input + $pks = ArrayHelper::toInteger($pks); + // Get the model + $model = $this->getModel('Snippets'); + // get the data to export + $data = $model->getExportData($pks); + if (UtilitiesArrayHelper::check($data)) + { + // now set the data to the spreadsheet + $date = Factory::getDate(); + ComponentbuilderHelper::xls($data,'Snippets_'.$date->format('jS_F_Y'),'Snippets exported ('.$date->format('jS F, Y').')','snippets'); + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=snippets', false), $message, 'error'); + return; + } + + + public function importData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if import is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('snippet.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) + { + // Get the import model + $model = $this->getModel('Snippets'); + // get the headers to import + $headers = $model->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + // Load headers to session. + $session = Factory::getSession(); + $headers = json_encode($headers); + $session->set('snippet_VDM_IMPORTHEADERS', $headers); + $session->set('backto_VDM_IMPORT', 'snippets'); + $session->set('dataType_VDM_IMPORTINTO', 'snippet'); + // Redirect to import view. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_SNIPPETS'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=import', false), $message); + return; + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=snippets', false), $message, 'error'); + return; + } + + public function getSnippets() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // redirect to the import snippets custom admin view + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=get_snippets', false)); + return; + } + + public function shareSnippets() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // Get the model + $model = $this->getModel('snippets'); + // check if import is allowed for this user. + $model->user = Factory::getUser(); + if ($model->user->authorise('snippet.import', 'com_componentbuilder') && $model->user->authorise('core.export', 'com_componentbuilder')) + { + // Get the input + $input = Factory::getApplication()->input; + $pks = $input->post->get('cid', array(), 'array'); + // Sanitize the input + JArrayHelper::toInteger($pks); + // check if there is any selections + if (!UtilitiesArrayHelper::check($pks)) + { + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_NO_SNIPPETS_WERE_SELECTED_PLEASE_MAKE_A_SELECTION_AND_TRY_AGAIN'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=snippets', false), $message, 'error'); + return; + } + // set auto loader + ComponentbuilderHelper::autoLoader('smart'); + // get the data to export + if ($model->shareSnippets($pks)) + { + // Message of successful build + if (count($pks) > 1) + { + $message = '

    ' . Text::_('COM_COMPONENTBUILDER_THE_SNIPPETS_WERE_SUCCESSFULLY_EXPORTED') . '

    '; + $message .= '

    ' . Text::sprintf('COM_COMPONENTBUILDER_TO_SHARE_THESE_SNIPPETS_WITH_THE_REST_OF_THE_JCB_COMMUNITY'); + } + else + { + $message = '

    ' . Text::_('COM_COMPONENTBUILDER_THE_SNIPPET_WAS_SUCCESSFULLY_EXPORTED') . '

    '; + $message .= '

    ' . Text::sprintf('COM_COMPONENTBUILDER_TO_SHARE_THIS_SNIPPET_WITH_THE_REST_OF_THE_JCB_COMMUNITY'); + } + $message .= Text::sprintf('COM_COMPONENTBUILDER_YOU_WILL_NEED_TO_KNOW_HOW_S_WORKS_BASIC_YOU_WILL_ALSO_NEED_A_S_ACCOUNT_AND_KNOW_HOW_TO_MAKE_A_PULL_REQUEST_ON_GITHUB', + 'git', + 'github.com') . '

    '; + + $message .= '

    ' . Text::_('COM_COMPONENTBUILDER_NEED_HELP') . '

    '; + $message .= ''; + $message .= '

    ' . Text::_('COM_COMPONENTBUILDER_ZIPPED_FILE_LOCATION') . '

    '; + $message .= '

    ' . Text::sprintf('COM_COMPONENTBUILDER_PATH_CODESCODE', $model->zipPath). '

    '; + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=snippets', false), $message); + return; + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_SHARE_THE_SNIPPETS_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_HELP'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=snippets', false), $message, 'error'); + return; + } +} \ No newline at end of file diff --git a/admin/src/Controller/TemplateController.php b/admin/src/Controller/TemplateController.php new file mode 100644 index 000000000..cc2f54048 --- /dev/null +++ b/admin/src/Controller/TemplateController.php @@ -0,0 +1,343 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Template Form Controller + * + * @since 1.6 + */ +class TemplateController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_TEMPLATE'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'templates'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('template.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return parent::allowAdd($data); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('template.access', 'com_componentbuilder.template.' . (int) $recordId) && $user->authorise('template.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('core.edit', 'com_componentbuilder.template.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('core.edit.own', 'com_componentbuilder.template.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('core.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return parent::allowEdit($data, $key); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Template', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=templates' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + return; + } +} diff --git a/admin/src/Controller/TemplatesController.php b/admin/src/Controller/TemplatesController.php new file mode 100644 index 000000000..1809b65d6 --- /dev/null +++ b/admin/src/Controller/TemplatesController.php @@ -0,0 +1,128 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Templates Admin Controller + * + * @since 1.6 + */ +class TemplatesController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_TEMPLATES'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Template', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } + + public function exportData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if export is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('template.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) + { + // Get the input + $input = Factory::getApplication()->input; + $pks = $input->post->get('cid', array(), 'array'); + // Sanitize the input + $pks = ArrayHelper::toInteger($pks); + // Get the model + $model = $this->getModel('Templates'); + // get the data to export + $data = $model->getExportData($pks); + if (UtilitiesArrayHelper::check($data)) + { + // now set the data to the spreadsheet + $date = Factory::getDate(); + ComponentbuilderHelper::xls($data,'Templates_'.$date->format('jS_F_Y'),'Templates exported ('.$date->format('jS F, Y').')','templates'); + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=templates', false), $message, 'error'); + return; + } + + + public function importData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if import is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('template.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) + { + // Get the import model + $model = $this->getModel('Templates'); + // get the headers to import + $headers = $model->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + // Load headers to session. + $session = Factory::getSession(); + $headers = json_encode($headers); + $session->set('template_VDM_IMPORTHEADERS', $headers); + $session->set('backto_VDM_IMPORT', 'templates'); + $session->set('dataType_VDM_IMPORTINTO', 'template'); + // Redirect to import view. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_TEMPLATES'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=import', false), $message); + return; + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=templates', false), $message, 'error'); + return; + } + + public function getSnippets() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // redirect to the import snippets custom admin view + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=get_snippets', false)); + return; + } +} \ No newline at end of file diff --git a/admin/src/Controller/Validation_ruleController.php b/admin/src/Controller/Validation_ruleController.php new file mode 100644 index 000000000..1bfa172b2 --- /dev/null +++ b/admin/src/Controller/Validation_ruleController.php @@ -0,0 +1,343 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Validation_rule Form Controller + * + * @since 1.6 + */ +class Validation_ruleController extends FormController +{ + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_VALIDATION_RULE'; + + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * The URL view list variable. + * + * @var string + * @since 1.6 + */ + protected $view_list = 'validation_rules'; + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = []) + { + // Get user object. + $user = $this->app->getIdentity(); + // Access check. + $access = $user->authorise('validation_rule.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + + // In the absence of better information, revert to the component permissions. + return $user->authorise('validation_rule.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = [], $key = 'id') + { + // get user object. + $user = $this->app->getIdentity(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('validation_rule.access', 'com_componentbuilder.validation_rule.' . (int) $recordId) && $user->authorise('validation_rule.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('validation_rule.edit', 'com_componentbuilder.validation_rule.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('validation_rule.edit.own', 'com_componentbuilder.validation_rule.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('validation_rule.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('validation_rule.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string) $ref . '&refid='. (int) $refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string) $ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Validation_rule', '', []); + + // Preset the redirect + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=validation_rules' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && Uri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && Uri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + Route::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string) $this->ref . '&layout=edit&id=' . (int) $this->refid; + + // Redirect to the item screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string) $this->ref; + + // Redirect to the list screen. + $this->setRedirect( + Route::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param BaseDatabaseModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(BaseDatabaseModel $model, $validData = []) + { + return; + } +} diff --git a/admin/src/Controller/Validation_rulesController.php b/admin/src/Controller/Validation_rulesController.php new file mode 100644 index 000000000..ec5ec52d1 --- /dev/null +++ b/admin/src/Controller/Validation_rulesController.php @@ -0,0 +1,161 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Controller; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Validation_rules Admin Controller + * + * @since 1.6 + */ +class Validation_rulesController extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER_VALIDATION_RULES'; + + /** + * Proxy for getModel. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * + * @since 1.6 + */ + public function getModel($name = 'Validation_rule', $prefix = 'Administrator', $config = ['ignore_request' => true]) + { + return parent::getModel($name, $prefix, $config); + } + + public function exportData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if export is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('validation_rule.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder')) + { + // Get the input + $input = Factory::getApplication()->input; + $pks = $input->post->get('cid', array(), 'array'); + // Sanitize the input + $pks = ArrayHelper::toInteger($pks); + // Get the model + $model = $this->getModel('Validation_rules'); + // get the data to export + $data = $model->getExportData($pks); + if (UtilitiesArrayHelper::check($data)) + { + // now set the data to the spreadsheet + $date = Factory::getDate(); + ComponentbuilderHelper::xls($data,'Validation_rules_'.$date->format('jS_F_Y'),'Validation rules exported ('.$date->format('jS F, Y').')','validation rules'); + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_EXPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=validation_rules', false), $message, 'error'); + return; + } + + + public function importData() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + // check if import is allowed for this user. + $user = Factory::getApplication()->getIdentity(); + if ($user->authorise('validation_rule.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) + { + // Get the import model + $model = $this->getModel('Validation_rules'); + // get the headers to import + $headers = $model->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + // Load headers to session. + $session = Factory::getSession(); + $headers = json_encode($headers); + $session->set('validation_rule_VDM_IMPORTHEADERS', $headers); + $session->set('backto_VDM_IMPORT', 'validation_rules'); + $session->set('dataType_VDM_IMPORTINTO', 'validation_rule'); + // Redirect to import view. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_VALIDATION_RULES'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=import', false), $message); + return; + } + } + // Redirect to the list screen with error. + $message = Text::_('COM_COMPONENTBUILDER_IMPORT_FAILED'); + $this->setRedirect(Route::_('index.php?option=com_componentbuilder&view=validation_rules', false), $message, 'error'); + return; + } + + + /** + * Run the Expansion + * + * @return void + */ + public function runExpansion() + { + // Check for request forgeries + Session::checkToken() or \jexit(Text::_('JINVALID_TOKEN')); + // check if user has the right + $user = Factory::getUser(); + // set page redirect + $redirect_url = \JRoute::_('index.php?option=com_componentbuilder&view=validation_rules', false); + // set massage + $message = Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RUN_THE_EXPANSION_MODULE'); + // check if this user has the right to run expansion + if($user->authorise('validation_rules.run_expansion', 'com_componentbuilder')) + { + // set massage + $message = Text::_('COM_COMPONENTBUILDER_EXPANSION_FAILED_PLEASE_CHECK_YOUR_SETTINGS_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TAB'); + // run expansion via API + $result = ComponentbuilderHelper::getFileContents(\JUri::root() . 'index.php?option=com_componentbuilder&task=api.expand'); + // is there a message returned + if (!is_numeric($result) && StringHelper::check($result)) + { + $this->setRedirect($redirect_url, $result); + return true; + } + elseif (is_numeric($result) && 1 == $result) + { + $message = Text::_('COM_COMPONENTBUILDER_BTHE_EXPANSION_WAS_SUCCESSFULLYB_TO_SEE_MORE_INFORMATION_CHANGE_THE_BRETURN_OPTIONS_FOR_BUILDB_TO_BDISPLAY_MESSAGEB_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_DEVELOPMENT_METHOD_TABB'); + $this->setRedirect($redirect_url, $message, 'message'); + return true; + } + } + $this->setRedirect($redirect_url, $message, 'error'); + return false; + } + +} \ No newline at end of file diff --git a/admin/models/fields/index.html b/admin/src/Controller/index.html similarity index 100% rename from admin/models/fields/index.html rename to admin/src/Controller/index.html diff --git a/admin/src/Extension/ComponentbuilderComponent.php b/admin/src/Extension/ComponentbuilderComponent.php new file mode 100644 index 000000000..9bfd94e30 --- /dev/null +++ b/admin/src/Extension/ComponentbuilderComponent.php @@ -0,0 +1,75 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Extension; + +use Joomla\CMS\Association\AssociationServiceInterface; +use Joomla\CMS\Association\AssociationServiceTrait; +use Joomla\CMS\Categories\CategoryServiceInterface; +use Joomla\CMS\Categories\CategoryServiceTrait; +use Joomla\CMS\Component\Router\RouterServiceInterface; +use Joomla\CMS\Component\Router\RouterServiceTrait; +use Joomla\CMS\Extension\BootableExtensionInterface; +use Joomla\CMS\Extension\MVCComponent; +use Joomla\CMS\Factory; +use Joomla\CMS\Fields\FieldsServiceInterface; +use Joomla\CMS\Form\Form; +use Joomla\CMS\HTML\HTMLRegistryAwareTrait; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Tag\TagServiceInterface; +use Joomla\CMS\Tag\TagServiceTrait; +use Joomla\CMS\User\UserFactoryInterface; +// (soon) use VDM\Component\Componentbuilder\Administrator\Service\HTML\AdministratorService; +use Psr\Container\ContainerInterface; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Component class for com_componentbuilder + * + * @since 4.0 + */ +class ComponentbuilderComponent extends MVCComponent implements + BootableExtensionInterface, + CategoryServiceInterface, + RouterServiceInterface +{ + use AssociationServiceTrait; + use HTMLRegistryAwareTrait; + use RouterServiceTrait; + use CategoryServiceTrait, TagServiceTrait { + CategoryServiceTrait::getTableNameForSection insteadof TagServiceTrait; + CategoryServiceTrait::getStateColumnForSection insteadof TagServiceTrait; + } + + /** + * Booting the extension. This is the function to set up the environment of the extension like + * registering new class loaders, etc. + * + * If required, some initial set up can be done from services of the container, eg. + * registering HTML services. + * + * @param ContainerInterface $container The container + * + * @return void + * + * @since 4.0.0 + */ + public function boot(ContainerInterface $container) + { + // (soon) $this->getRegistry()->register('componentbuilderadministrator', new AdministratorService()); + } + + // will fix these soon + protected function getTableNameForSection(string $section = null){} + public function countItems(array $items, string $section){} + +} diff --git a/admin/models/forms/index.html b/admin/src/Extension/index.html similarity index 100% rename from admin/models/forms/index.html rename to admin/src/Extension/index.html diff --git a/admin/src/Field/AdminsviewsField.php b/admin/src/Field/AdminsviewsField.php new file mode 100644 index 000000000..54fbe7dc4 --- /dev/null +++ b/admin/src/Field/AdminsviewsField.php @@ -0,0 +1,64 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Adminsviews Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class AdminsviewsField extends ListField +{ + /** + * The adminsviews field type. + * + * @var string + */ + public $type = 'Adminsviews'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.system_name'),array('id','adminviews_system_name'))); + $query->from($db->quoteName('#__componentbuilder_admin_view', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->order('a.system_name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->adminviews_system_name); + } + } + + return $options; + } +} diff --git a/admin/src/Field/AdminviewfolderlistField.php b/admin/src/Field/AdminviewfolderlistField.php new file mode 100644 index 000000000..ce6372fde --- /dev/null +++ b/admin/src/Field/AdminviewfolderlistField.php @@ -0,0 +1,69 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Adminviewfolderlist Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class AdminviewfolderlistField extends ListField +{ + /** + * The adminviewfolderlist field type. + * + * @var string + */ + public $type = 'Adminviewfolderlist'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // get custom folder files + $localfolders = []; + $localfolders[] = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/views'; + $localfolders[] = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/src/View'; + // set the default + $options = []; + // now check if there are files in the folder + foreach ($localfolders as $localfolder) + { + if (is_dir($localfolder) && $folders = \Joomla\Filesystem\Folder::folders($localfolder)) + { + if ($this->multiple === false) + { + $options[] = Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_SELECT_AN_ADMIN_VIEW')); + } + foreach ($folders as $folder) + { + $options[] = Html::_('select.option', $folder, StringHelper::safe($folder, 'W')); + } + } + } + return $options; + } +} diff --git a/admin/src/Field/AdminviewsField.php b/admin/src/Field/AdminviewsField.php new file mode 100644 index 000000000..f4df5aaf6 --- /dev/null +++ b/admin/src/Field/AdminviewsField.php @@ -0,0 +1,65 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Adminviews Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class AdminviewsField extends ListField +{ + /** + * The adminviews field type. + * + * @var string + */ + public $type = 'Adminviews'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + $db = Factory::getDBO(); +$query = $db->getQuery(true); +$query->select($db->quoteName(array('a.id','a.system_name'),array('id','adminview_system_name'))); +$query->from($db->quoteName('#__componentbuilder_admin_view', 'a')); +$query->where($db->quoteName('a.published') . ' >= 1'); +$query->order('a.system_name ASC'); +$db->setQuery((string)$query); +$items = $db->loadObjectList(); +$options = array(); +if ($items) +{ + $options[] = Html::_('select.option', '', 'Select an option'); + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->adminview_system_name); + } +} + +return $options; + } +} diff --git a/admin/src/Field/AdminviewsfilteraddcustombuttonField.php b/admin/src/Field/AdminviewsfilteraddcustombuttonField.php new file mode 100644 index 000000000..c7364d836 --- /dev/null +++ b/admin/src/Field/AdminviewsfilteraddcustombuttonField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Adminviewsfilteraddcustombutton Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class AdminviewsfilteraddcustombuttonField extends ListField +{ + /** + * The adminviewsfilteraddcustombutton field type. + * + * @var string + */ + public $type = 'Adminviewsfilteraddcustombutton'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('add_custom_button')); + $query->from($db->quoteName('#__componentbuilder_admin_view')); + $query->order($db->quoteName('add_custom_button') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_ADD_CUSTOM_BUTTONS') . ' -'); + + if ($_results) + { + // get admin_viewsmodel + $_model = ComponentbuilderHelper::getModel('admin_views'); + $_results = array_unique($_results); + foreach ($_results as $add_custom_button) + { + // Translate the add_custom_button selection + $_text = $_model->selectionTranslation($add_custom_button,'add_custom_button'); + // Now add the add_custom_button and its text to the options array + $_filter[] = Html::_('select.option', $add_custom_button, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/AdminviewsfilteraddcustomimportField.php b/admin/src/Field/AdminviewsfilteraddcustomimportField.php new file mode 100644 index 000000000..934871506 --- /dev/null +++ b/admin/src/Field/AdminviewsfilteraddcustomimportField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Adminviewsfilteraddcustomimport Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class AdminviewsfilteraddcustomimportField extends ListField +{ + /** + * The adminviewsfilteraddcustomimport field type. + * + * @var string + */ + public $type = 'Adminviewsfilteraddcustomimport'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('add_custom_import')); + $query->from($db->quoteName('#__componentbuilder_admin_view')); + $query->order($db->quoteName('add_custom_import') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_ADD_CUSTOM_IMPORT') . ' -'); + + if ($_results) + { + // get admin_viewsmodel + $_model = ComponentbuilderHelper::getModel('admin_views'); + $_results = array_unique($_results); + foreach ($_results as $add_custom_import) + { + // Translate the add_custom_import selection + $_text = $_model->selectionTranslation($add_custom_import,'add_custom_import'); + // Now add the add_custom_import and its text to the options array + $_filter[] = Html::_('select.option', $add_custom_import, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/AdminviewsfilteraddfadeinField.php b/admin/src/Field/AdminviewsfilteraddfadeinField.php new file mode 100644 index 000000000..1f27ceb87 --- /dev/null +++ b/admin/src/Field/AdminviewsfilteraddfadeinField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Adminviewsfilteraddfadein Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class AdminviewsfilteraddfadeinField extends ListField +{ + /** + * The adminviewsfilteraddfadein field type. + * + * @var string + */ + public $type = 'Adminviewsfilteraddfadein'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('add_fadein')); + $query->from($db->quoteName('#__componentbuilder_admin_view')); + $query->order($db->quoteName('add_fadein') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_FADE_IN_AFFECT') . ' -'); + + if ($_results) + { + // get admin_viewsmodel + $_model = ComponentbuilderHelper::getModel('admin_views'); + $_results = array_unique($_results); + foreach ($_results as $add_fadein) + { + // Translate the add_fadein selection + $_text = $_model->selectionTranslation($add_fadein,'add_fadein'); + // Now add the add_fadein and its text to the options array + $_filter[] = Html::_('select.option', $add_fadein, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/AdminviewsfilteraddphpajaxField.php b/admin/src/Field/AdminviewsfilteraddphpajaxField.php new file mode 100644 index 000000000..c3056b7dd --- /dev/null +++ b/admin/src/Field/AdminviewsfilteraddphpajaxField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Adminviewsfilteraddphpajax Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class AdminviewsfilteraddphpajaxField extends ListField +{ + /** + * The adminviewsfilteraddphpajax field type. + * + * @var string + */ + public $type = 'Adminviewsfilteraddphpajax'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('add_php_ajax')); + $query->from($db->quoteName('#__componentbuilder_admin_view')); + $query->order($db->quoteName('add_php_ajax') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_ADD_PHP_AJAX') . ' -'); + + if ($_results) + { + // get admin_viewsmodel + $_model = ComponentbuilderHelper::getModel('admin_views'); + $_results = array_unique($_results); + foreach ($_results as $add_php_ajax) + { + // Translate the add_php_ajax selection + $_text = $_model->selectionTranslation($add_php_ajax,'add_php_ajax'); + // Now add the add_php_ajax and its text to the options array + $_filter[] = Html::_('select.option', $add_php_ajax, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/AdminviewsfiltertypeField.php b/admin/src/Field/AdminviewsfiltertypeField.php new file mode 100644 index 000000000..de896330c --- /dev/null +++ b/admin/src/Field/AdminviewsfiltertypeField.php @@ -0,0 +1,77 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Adminviewsfiltertype Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class AdminviewsfiltertypeField extends ListField +{ + /** + * The adminviewsfiltertype field type. + * + * @var string + */ + public $type = 'Adminviewsfiltertype'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('type')); + $query->from($db->quoteName('#__componentbuilder_admin_view')); + $query->order($db->quoteName('type') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + + if ($_results) + { + // get admin_viewsmodel + $_model = ComponentbuilderHelper::getModel('admin_views'); + $_results = array_unique($_results); + foreach ($_results as $type) + { + // Translate the type selection + $_text = $_model->selectionTranslation($type,'type'); + // Now add the type and its text to the options array + $_filter[] = Html::_('select.option', $type, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/AdminviewsreadonlyField.php b/admin/src/Field/AdminviewsreadonlyField.php new file mode 100644 index 000000000..5938e25b5 --- /dev/null +++ b/admin/src/Field/AdminviewsreadonlyField.php @@ -0,0 +1,64 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Adminviewsreadonly Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class AdminviewsreadonlyField extends ListField +{ + /** + * The adminviewsreadonly field type. + * + * @var string + */ + public $type = 'Adminviewsreadonly'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + $db = Factory::getDBO(); +$query = $db->getQuery(true); +$query->select($db->quoteName(array('a.id','a.system_name'),array('id','admin_view_system_name'))); +$query->from($db->quoteName('#__componentbuilder_admin_view', 'a')); +$query->order('a.system_name ASC'); +$db->setQuery((string)$query); +$items = $db->loadObjectList(); +$options = array(); +if ($items) +{ + $options[] = Html::_('select.option', '', 'Select an option'); + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->admin_view_system_name); + } +} + +return $options; + } +} diff --git a/admin/src/Field/AliasbuilderField.php b/admin/src/Field/AliasbuilderField.php new file mode 100644 index 000000000..2a5b4602e --- /dev/null +++ b/admin/src/Field/AliasbuilderField.php @@ -0,0 +1,108 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\ArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Aliasbuilder Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class AliasbuilderField extends ListField +{ + /** + * The aliasbuilder field type. + * + * @var string + */ + public $type = 'Aliasbuilder'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // load the db object + $db = Factory::getDBO(); + // get the input from url + $jinput = Factory::getApplication()->input; + // get the id + $adminView = $jinput->getInt('id', 0); + // rest the fields ids + $fieldIds = array(); + if (is_numeric($adminView) && $adminView >= 1) + { + // get all the fields linked to the admin view + if ($addFields = ComponentbuilderHelper::getVar('admin_fields', (int) $adminView, 'admin_view', 'addfields')) + { + if (JsonHelper::check($addFields)) + { + $addFields = json_decode($addFields, true); + if (ArrayHelper::check($addFields)) + { + foreach($addFields as $addField) + { + if (isset($addField['field']) && (!isset($addField['alias']) || 1 != $addField['alias'])) + { + $fieldIds[] = (int) $addField['field']; + } + } + } + } + } + } + // filter by fields linked + if (ArrayHelper::check($fieldIds)) + { + // get list of field types that does not work in list views (note, spacer) + $spacers = ComponentbuilderHelper::getSpacerIds(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name','b.name'),array('id','name','type'))); + $query->from($db->quoteName('#__componentbuilder_field', 'a')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_fieldtype', 'b') . ' ON (' . $db->quoteName('a.fieldtype') . ' = ' . $db->quoteName('b.id') . ')'); + $query->where($db->quoteName('a.published') . ' >= 1'); + // only load these fields + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $fieldIds) . ')'); + // none of these field types + if (ArrayHelper::check($spacers)) + { + $query->where($db->quoteName('a.fieldtype') . ' NOT IN (' . implode(',', $spacers) . ')'); + } + $query->order('a.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->name . ' [' . $item->type . ']'); + } + return $options; + } + } + return array(Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_ADD_MORE_FIELDS_TO_THIS_ADMIN_VIEW'))); + } +} diff --git a/admin/src/Field/ArticlesField.php b/admin/src/Field/ArticlesField.php new file mode 100644 index 000000000..2031fb914 --- /dev/null +++ b/admin/src/Field/ArticlesField.php @@ -0,0 +1,64 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Articles Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class ArticlesField extends ListField +{ + /** + * The articles field type. + * + * @var string + */ + public $type = 'Articles'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.title','a.alias'),array('id','article_title','alias'))); + $query->from($db->quoteName('#__content', 'a')); + $query->where($db->quoteName('a.state') . ' = 1'); + $query->order('a.title ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select an Article'); + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->article_title . ' (' . $item->alias . ')'); + } + } + return $options; + } +} diff --git a/admin/src/Field/ClassextendingsfilterextensiontypeField.php b/admin/src/Field/ClassextendingsfilterextensiontypeField.php new file mode 100644 index 000000000..7b4fc91ca --- /dev/null +++ b/admin/src/Field/ClassextendingsfilterextensiontypeField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Classextendingsfilterextensiontype Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class ClassextendingsfilterextensiontypeField extends ListField +{ + /** + * The classextendingsfilterextensiontype field type. + * + * @var string + */ + public $type = 'Classextendingsfilterextensiontype'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('extension_type')); + $query->from($db->quoteName('#__componentbuilder_class_extends')); + $query->order($db->quoteName('extension_type') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_TYPE') . ' -'); + + if ($_results) + { + // get class_extendingsmodel + $_model = ComponentbuilderHelper::getModel('class_extendings'); + $_results = array_unique($_results); + foreach ($_results as $extension_type) + { + // Translate the extension_type selection + $_text = $_model->selectionTranslation($extension_type,'extension_type'); + // Now add the extension_type and its text to the options array + $_filter[] = Html::_('select.option', $extension_type, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/ClassextendsField.php b/admin/src/Field/ClassextendsField.php new file mode 100644 index 000000000..595472bcc --- /dev/null +++ b/admin/src/Field/ClassextendsField.php @@ -0,0 +1,183 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Classextends Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class ClassextendsField extends ListField +{ + /** + * The classextends field type. + * + * @var string + */ + public $type = 'Classextends'; + + /** + * Override to add new button + * + * @return string The field input markup. + * + * @since 3.2 + */ + protected function getInput() + { + // see if we should add buttons + $set_button = $this->getAttribute('button'); + // get html + $html = parent::getInput(); + // if true set button + if ($set_button === 'true') + { + $button = array(); + $script = array(); + $button_code_name = $this->getAttribute('name'); + // get the input from url + $app = Factory::getApplication(); + $jinput = $app->input; + // get the view name & id + $values = $jinput->getArray(array( + 'id' => 'int', + 'view' => 'word' + )); + // check if new item + $ref = ''; + $refJ = ''; + if (!is_null($values['id']) && strlen($values['view'])) + { + // only load referral if not new item. + $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; + $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; + // get the return value. + $_uri = (string) \Joomla\CMS\Uri\Uri::getInstance(); + $_return = urlencode(base64_encode($_uri)); + // load return value. + $ref .= '&return=' . $_return; + $refJ .= '&return=' . $_return; + } + // get button label + $button_label = trim($button_code_name); + $button_label = preg_replace('/_+/', ' ', $button_label); + $button_label = preg_replace('/\s+/', ' ', $button_label); + $button_label = preg_replace("/[^A-Za-z ]/", '', $button_label); + $button_label = ucfirst(strtolower($button_label)); + // get user object + $user = Factory::getApplication()->getIdentity(); + // only add if user allowed to create class_extends + if ($user->authorise('class_extends.create', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build Create button + $button[] = ' + '; + } + // only add if user allowed to edit class_extends + if ($user->authorise('class_extends.edit', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build edit button + $button[] = ''; + // build script + $script[] = " + document.addEventListener('DOMContentLoaded', function() { + document.getElementById('jform_".$button_code_name."').addEventListener('change', function(e) { + e.preventDefault(); + let ".$button_code_name."Value = this.value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + let ".$button_code_name."Value = document.getElementById('jform_".$button_code_name."').value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + function ".$button_code_name."Button(value) { + var createButton = document.getElementById('".$button_code_name."Create'); + var editButton = document.getElementById('".$button_code_name."Edit'); + if (value > 0) { + // hide the create button + createButton.style.display = 'none'; + // show edit button + editButton.style.display = 'block'; + let url = 'index.php?option=com_componentbuilder&view=class_extendings&task=class_extends.edit&id='+value+'".$refJ."'; + editButton.setAttribute('href', url); + } else { + // show the create button + createButton.style.display = 'block'; + // hide edit button + editButton.style.display = 'none'; + } + }"; + } + // check if button was created for class_extends field. + if (is_array($button) && count($button) > 0) + { + // Load the needed script. + $document = Factory::getApplication()->getDocument(); + $document->addScriptDeclaration(implode(' ',$script)); + // return the button attached to input field. + return '
    ' .$html . implode('',$button).'
    '; + } + } + return $html; + } + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get the user object. + $user = Factory::getApplication()->getIdentity(); + // Get the databse object. + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name'),array('id','class_extends_name'))); + $query->from($db->quoteName('#__componentbuilder_class_extends', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->order('a.name ASC'); + // Implement View Level Access (if set in table) + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $columns = $db->getTableColumns('#__componentbuilder_class_extends'); + if(isset($columns['access'])) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + } + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select a class'); + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->class_extends_name); + } + } + return $options; + } +} diff --git a/admin/src/Field/ClassmethodsfilterextensiontypeField.php b/admin/src/Field/ClassmethodsfilterextensiontypeField.php new file mode 100644 index 000000000..45d55574a --- /dev/null +++ b/admin/src/Field/ClassmethodsfilterextensiontypeField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Classmethodsfilterextensiontype Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class ClassmethodsfilterextensiontypeField extends ListField +{ + /** + * The classmethodsfilterextensiontype field type. + * + * @var string + */ + public $type = 'Classmethodsfilterextensiontype'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('extension_type')); + $query->from($db->quoteName('#__componentbuilder_class_method')); + $query->order($db->quoteName('extension_type') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_TYPE') . ' -'); + + if ($_results) + { + // get class_methodsmodel + $_model = ComponentbuilderHelper::getModel('class_methods'); + $_results = array_unique($_results); + foreach ($_results as $extension_type) + { + // Translate the extension_type selection + $_text = $_model->selectionTranslation($extension_type,'extension_type'); + // Now add the extension_type and its text to the options array + $_filter[] = Html::_('select.option', $extension_type, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/ClassmethodsfiltervisibilityField.php b/admin/src/Field/ClassmethodsfiltervisibilityField.php new file mode 100644 index 000000000..2be91ef07 --- /dev/null +++ b/admin/src/Field/ClassmethodsfiltervisibilityField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Classmethodsfiltervisibility Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class ClassmethodsfiltervisibilityField extends ListField +{ + /** + * The classmethodsfiltervisibility field type. + * + * @var string + */ + public $type = 'Classmethodsfiltervisibility'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('visibility')); + $query->from($db->quoteName('#__componentbuilder_class_method')); + $query->order($db->quoteName('visibility') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_VISIBILITY') . ' -'); + + if ($_results) + { + // get class_methodsmodel + $_model = ComponentbuilderHelper::getModel('class_methods'); + $_results = array_unique($_results); + foreach ($_results as $visibility) + { + // Translate the visibility selection + $_text = $_model->selectionTranslation($visibility,'visibility'); + // Now add the visibility and its text to the options array + $_filter[] = Html::_('select.option', $visibility, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/ClasspowersField.php b/admin/src/Field/ClasspowersField.php new file mode 100644 index 000000000..dd7068905 --- /dev/null +++ b/admin/src/Field/ClasspowersField.php @@ -0,0 +1,204 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Classpowers Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class ClasspowersField extends ListField +{ + /** + * The classpowers field type. + * + * @var string + */ + public $type = 'Classpowers'; + + /** + * Override to add new button + * + * @return string The field input markup. + * + * @since 3.2 + */ + protected function getInput() + { + // see if we should add buttons + $set_button = $this->getAttribute('button'); + // get html + $html = parent::getInput(); + // if true set button + if ($set_button === 'true') + { + $button = array(); + $script = array(); + $button_code_name = $this->getAttribute('name'); + // get the input from url + $app = Factory::getApplication(); + $jinput = $app->input; + // get the view name & id + $values = $jinput->getArray(array( + 'id' => 'int', + 'view' => 'word' + )); + // check if new item + $ref = ''; + $refJ = ''; + if (!is_null($values['id']) && strlen($values['view'])) + { + // only load referral if not new item. + $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; + $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; + // get the return value. + $_uri = (string) \Joomla\CMS\Uri\Uri::getInstance(); + $_return = urlencode(base64_encode($_uri)); + // load return value. + $ref .= '&return=' . $_return; + $refJ .= '&return=' . $_return; + } + // get button label + $button_label = trim($button_code_name); + $button_label = preg_replace('/_+/', ' ', $button_label); + $button_label = preg_replace('/\s+/', ' ', $button_label); + $button_label = preg_replace("/[^A-Za-z ]/", '', $button_label); + $button_label = ucfirst(strtolower($button_label)); + // get user object + $user = Factory::getApplication()->getIdentity(); + // only add if user allowed to create power + if ($user->authorise('power.create', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build Create button + $button[] = ' + '; + } + // only add if user allowed to edit power + if ($user->authorise('power.edit', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build edit button + $button[] = ''; + // build script + $script[] = " + document.addEventListener('DOMContentLoaded', function() { + document.getElementById('jform_".$button_code_name."').addEventListener('change', function(e) { + e.preventDefault(); + let ".$button_code_name."Value = this.value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + let ".$button_code_name."Value = document.getElementById('jform_".$button_code_name."').value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + function ".$button_code_name."Button(value) { + var createButton = document.getElementById('".$button_code_name."Create'); + var editButton = document.getElementById('".$button_code_name."Edit'); + if (value > 0) { + // hide the create button + createButton.style.display = 'none'; + // show edit button + editButton.style.display = 'block'; + let url = 'index.php?option=com_componentbuilder&view=powers&task=power.edit&id='+value+'".$refJ."'; + editButton.setAttribute('href', url); + } else { + // show the create button + createButton.style.display = 'block'; + // hide edit button + editButton.style.display = 'none'; + } + }"; + } + // check if button was created for power field. + if (is_array($button) && count($button) > 0) + { + // Load the needed script. + $document = Factory::getApplication()->getDocument(); + $document->addScriptDeclaration(implode(' ',$script)); + // return the button attached to input field. + return '
    ' .$html . implode('',$button).'
    '; + } + } + return $html; + } + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get the user object. + $user = Factory::getApplication()->getIdentity(); + // Get the databse object. + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.guid','a.name','a.system_name','a.type','a.power_version'),array('guid','extends_name','system_name','type','version'))); + $query->from($db->quoteName('#__componentbuilder_power', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->where('(' . $db->quoteName('a.type') . ' = ' . $db->quote('class') . ' OR ' . $db->quoteName('a.type') . ' = ' . $db->quote('abstract class') . ')'); + $query->order('a.name ASC'); + $query->order('a.type ASC'); + // Implement View Level Access (if set in table) + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $columns = $db->getTableColumns('#__componentbuilder_power'); + if(isset($columns['access'])) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + } + // get the input + $jinput = Factory::getApplication()->input; + // get the id + $power_id = $jinput->getInt('id', 0); + // if we have an id we remove all classes of the same namespace and name + if ($power_id > 0 && ($exclude_powers = ComponentbuilderHelper::excludePowers($power_id)) !== false) + { + $query->where('a.id NOT IN (' . implode(',', $exclude_powers) . ')'); + } + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + // if none was found, we add this to set an alternative to set custom + if (!$items) + { + $options[] = Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_NONE_FOUND')); + } + if ($items) + { + if ($this->multiple === false) + { + $options[] = Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_SELECT_AN_OPTION')); + } + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->guid, $item->system_name . ' [' . $item->type . ' ' . $item->extends_name . '] (v' . $item->version . ')'); + } + } + // set the other option to enter text + $options[] = Html::_('select.option', -1, Text::_('COM_COMPONENTBUILDER_SET_CUSTOM')); + return $options; + } +} diff --git a/admin/src/Field/ClasspropertiesfilterextensiontypeField.php b/admin/src/Field/ClasspropertiesfilterextensiontypeField.php new file mode 100644 index 000000000..986ac4b81 --- /dev/null +++ b/admin/src/Field/ClasspropertiesfilterextensiontypeField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Classpropertiesfilterextensiontype Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class ClasspropertiesfilterextensiontypeField extends ListField +{ + /** + * The classpropertiesfilterextensiontype field type. + * + * @var string + */ + public $type = 'Classpropertiesfilterextensiontype'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('extension_type')); + $query->from($db->quoteName('#__componentbuilder_class_property')); + $query->order($db->quoteName('extension_type') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_TYPE') . ' -'); + + if ($_results) + { + // get class_propertiesmodel + $_model = ComponentbuilderHelper::getModel('class_properties'); + $_results = array_unique($_results); + foreach ($_results as $extension_type) + { + // Translate the extension_type selection + $_text = $_model->selectionTranslation($extension_type,'extension_type'); + // Now add the extension_type and its text to the options array + $_filter[] = Html::_('select.option', $extension_type, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/ClasspropertiesfiltervisibilityField.php b/admin/src/Field/ClasspropertiesfiltervisibilityField.php new file mode 100644 index 000000000..f06fb61f6 --- /dev/null +++ b/admin/src/Field/ClasspropertiesfiltervisibilityField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Classpropertiesfiltervisibility Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class ClasspropertiesfiltervisibilityField extends ListField +{ + /** + * The classpropertiesfiltervisibility field type. + * + * @var string + */ + public $type = 'Classpropertiesfiltervisibility'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('visibility')); + $query->from($db->quoteName('#__componentbuilder_class_property')); + $query->order($db->quoteName('visibility') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_VISIBILITY') . ' -'); + + if ($_results) + { + // get class_propertiesmodel + $_model = ComponentbuilderHelper::getModel('class_properties'); + $_results = array_unique($_results); + foreach ($_results as $visibility) + { + // Translate the visibility selection + $_text = $_model->selectionTranslation($visibility,'visibility'); + // Now add the visibility and its text to the options array + $_filter[] = Html::_('select.option', $visibility, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/ComponentadminmenusField.php b/admin/src/Field/ComponentadminmenusField.php new file mode 100644 index 000000000..871f2b573 --- /dev/null +++ b/admin/src/Field/ComponentadminmenusField.php @@ -0,0 +1,109 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentadminmenus Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class ComponentadminmenusField extends ListField +{ + /** + * The componentadminmenus field type. + * + * @var string + */ + public $type = 'Componentadminmenus'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // load the db opbject + $db = Factory::getDBO(); + // get the input from url + $jinput = Factory::getApplication()->input; + // get the id + $ID = $jinput->getInt('id', 0); + // rest the fields ids + $viewids = array(); + if (is_numeric($ID) && $ID >= 1) + { + // get the joomla component ID + $joomlacomponent = ComponentbuilderHelper::getVar('component_custom_admin_menus', (int) $ID, 'id', 'joomla_component'); + } + else + { + // get the joomla component ID + $joomlacomponent = $jinput->getInt('refid', 0); + } + if (is_numeric($joomlacomponent) && $joomlacomponent >= 1) + { + // get all the admin views linked to the joomla component + if ($addAdminViews = ComponentbuilderHelper::getVar('component_admin_views', (int) $joomlacomponent, 'joomla_component', 'addadmin_views')) + { + if (ComponentbuilderHelper::checkJson($addAdminViews)) + { + $addAdminViews = json_decode($addAdminViews, true); + if (ComponentbuilderHelper::checkArray($addAdminViews)) + { + foreach($addAdminViews as $addAdminView) + { + if (isset($addAdminView['adminview'])) + { + $viewids[] = (int) $addAdminView['adminview']; + } + } + } + } + } + } + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.system_name'),array('id','name'))); + $query->from($db->quoteName('#__componentbuilder_admin_view', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + // filter by fields linked + if (ComponentbuilderHelper::checkArray($viewids)) + { + // only load these fields + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $viewids) . ')'); + } + $query->order('a.system_name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select an option'); + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->name); + } + } + + return $options; + } +} diff --git a/admin/src/Field/ComponentadminviewsField.php b/admin/src/Field/ComponentadminviewsField.php new file mode 100644 index 000000000..243d94c52 --- /dev/null +++ b/admin/src/Field/ComponentadminviewsField.php @@ -0,0 +1,109 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentadminviews Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class ComponentadminviewsField extends ListField +{ + /** + * The componentadminviews field type. + * + * @var string + */ + public $type = 'Componentadminviews'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // load the db opbject + $db = Factory::getDBO(); + // get the input from url + $jinput = Factory::getApplication()->input; + // get the id + $ID = $jinput->getInt('id', 0); + // rest the fields ids + $viewids = array(); + if (is_numeric($ID) && $ID >= 1) + { + // get the joomla component ID + $joomlacomponent = ComponentbuilderHelper::getVar('component_mysql_tweaks', (int) $ID, 'id', 'joomla_component'); + } + else + { + // get the joomla component ID + $joomlacomponent = $jinput->getInt('refid', 0); + } + if (is_numeric($joomlacomponent) && $joomlacomponent >= 1) + { + // get all the admin views linked to the joomla component + if ($addAdminViews = ComponentbuilderHelper::getVar('component_admin_views', (int) $joomlacomponent, 'joomla_component', 'addadmin_views')) + { + if (ComponentbuilderHelper::checkJson($addAdminViews)) + { + $addAdminViews = json_decode($addAdminViews, true); + if (ComponentbuilderHelper::checkArray($addAdminViews)) + { + foreach($addAdminViews as $addAdminView) + { + if (isset($addAdminView['adminview'])) + { + $viewids[] = (int) $addAdminView['adminview']; + } + } + } + } + } + } + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.system_name'),array('id','name'))); + $query->from($db->quoteName('#__componentbuilder_admin_view', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + // filter by fields linked + if (ComponentbuilderHelper::checkArray($viewids)) + { + // only load these fields + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $viewids) . ')'); + } + $query->order('a.system_name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select an option'); + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->name); + } + } + + return $options; + } +} diff --git a/admin/src/Field/ComponentsroutersfiltermodeconstructorafterparentField.php b/admin/src/Field/ComponentsroutersfiltermodeconstructorafterparentField.php new file mode 100644 index 000000000..06456b89e --- /dev/null +++ b/admin/src/Field/ComponentsroutersfiltermodeconstructorafterparentField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentsroutersfiltermodeconstructorafterparent Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class ComponentsroutersfiltermodeconstructorafterparentField extends ListField +{ + /** + * The componentsroutersfiltermodeconstructorafterparent field type. + * + * @var string + */ + public $type = 'Componentsroutersfiltermodeconstructorafterparent'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('mode_constructor_after_parent')); + $query->from($db->quoteName('#__componentbuilder_component_router')); + $query->order($db->quoteName('mode_constructor_after_parent') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_ROUTER_MODECONSTRUCTOR_AFTER_PARENT') . ' -'); + + if ($_results) + { + // get components_routersmodel + $_model = ComponentbuilderHelper::getModel('components_routers'); + $_results = array_unique($_results); + foreach ($_results as $mode_constructor_after_parent) + { + // Translate the mode_constructor_after_parent selection + $_text = $_model->selectionTranslation($mode_constructor_after_parent,'mode_constructor_after_parent'); + // Now add the mode_constructor_after_parent and its text to the options array + $_filter[] = Html::_('select.option', $mode_constructor_after_parent, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/ComponentsroutersfiltermodeconstructorbeforeparentField.php b/admin/src/Field/ComponentsroutersfiltermodeconstructorbeforeparentField.php new file mode 100644 index 000000000..8a813625d --- /dev/null +++ b/admin/src/Field/ComponentsroutersfiltermodeconstructorbeforeparentField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentsroutersfiltermodeconstructorbeforeparent Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class ComponentsroutersfiltermodeconstructorbeforeparentField extends ListField +{ + /** + * The componentsroutersfiltermodeconstructorbeforeparent field type. + * + * @var string + */ + public $type = 'Componentsroutersfiltermodeconstructorbeforeparent'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('mode_constructor_before_parent')); + $query->from($db->quoteName('#__componentbuilder_component_router')); + $query->order($db->quoteName('mode_constructor_before_parent') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_ROUTER_MODECONSTRUCTOR_BEFORE_PARENT') . ' -'); + + if ($_results) + { + // get components_routersmodel + $_model = ComponentbuilderHelper::getModel('components_routers'); + $_results = array_unique($_results); + foreach ($_results as $mode_constructor_before_parent) + { + // Translate the mode_constructor_before_parent selection + $_text = $_model->selectionTranslation($mode_constructor_before_parent,'mode_constructor_before_parent'); + // Now add the mode_constructor_before_parent and its text to the options array + $_filter[] = Html::_('select.option', $mode_constructor_before_parent, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/ComponentsroutersfiltermodemethodsField.php b/admin/src/Field/ComponentsroutersfiltermodemethodsField.php new file mode 100644 index 000000000..2346ab127 --- /dev/null +++ b/admin/src/Field/ComponentsroutersfiltermodemethodsField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentsroutersfiltermodemethods Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class ComponentsroutersfiltermodemethodsField extends ListField +{ + /** + * The componentsroutersfiltermodemethods field type. + * + * @var string + */ + public $type = 'Componentsroutersfiltermodemethods'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('mode_methods')); + $query->from($db->quoteName('#__componentbuilder_component_router')); + $query->order($db->quoteName('mode_methods') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_ROUTER_MODEMETHODS') . ' -'); + + if ($_results) + { + // get components_routersmodel + $_model = ComponentbuilderHelper::getModel('components_routers'); + $_results = array_unique($_results); + foreach ($_results as $mode_methods) + { + // Translate the mode_methods selection + $_text = $_model->selectionTranslation($mode_methods,'mode_methods'); + // Now add the mode_methods and its text to the options array + $_filter[] = Html::_('select.option', $mode_methods, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/CustomadminviewsField.php b/admin/src/Field/CustomadminviewsField.php new file mode 100644 index 000000000..967cebcb8 --- /dev/null +++ b/admin/src/Field/CustomadminviewsField.php @@ -0,0 +1,64 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Customadminviews Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class CustomadminviewsField extends ListField +{ + /** + * The customadminviews field type. + * + * @var string + */ + public $type = 'Customadminviews'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.system_name'),array('id','customadminview_system_name'))); + $query->from($db->quoteName('#__componentbuilder_custom_admin_view', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->order('a.system_name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select an option'); + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->customadminview_system_name); + } + } + return $options; + } +} diff --git a/admin/src/Field/CustomadminviewsfilteraddcustombuttonField.php b/admin/src/Field/CustomadminviewsfilteraddcustombuttonField.php new file mode 100644 index 000000000..031bfa7c7 --- /dev/null +++ b/admin/src/Field/CustomadminviewsfilteraddcustombuttonField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Customadminviewsfilteraddcustombutton Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class CustomadminviewsfilteraddcustombuttonField extends ListField +{ + /** + * The customadminviewsfilteraddcustombutton field type. + * + * @var string + */ + public $type = 'Customadminviewsfilteraddcustombutton'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('add_custom_button')); + $query->from($db->quoteName('#__componentbuilder_custom_admin_view')); + $query->order($db->quoteName('add_custom_button') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_ADD_CUSTOM_BUTTONS') . ' -'); + + if ($_results) + { + // get custom_admin_viewsmodel + $_model = ComponentbuilderHelper::getModel('custom_admin_views'); + $_results = array_unique($_results); + foreach ($_results as $add_custom_button) + { + // Translate the add_custom_button selection + $_text = $_model->selectionTranslation($add_custom_button,'add_custom_button'); + // Now add the add_custom_button and its text to the options array + $_filter[] = Html::_('select.option', $add_custom_button, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/CustomadminviewsfilteraddphpajaxField.php b/admin/src/Field/CustomadminviewsfilteraddphpajaxField.php new file mode 100644 index 000000000..a1e8d04bd --- /dev/null +++ b/admin/src/Field/CustomadminviewsfilteraddphpajaxField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Customadminviewsfilteraddphpajax Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class CustomadminviewsfilteraddphpajaxField extends ListField +{ + /** + * The customadminviewsfilteraddphpajax field type. + * + * @var string + */ + public $type = 'Customadminviewsfilteraddphpajax'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('add_php_ajax')); + $query->from($db->quoteName('#__componentbuilder_custom_admin_view')); + $query->order($db->quoteName('add_php_ajax') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_ADD_PHP_AJAX') . ' -'); + + if ($_results) + { + // get custom_admin_viewsmodel + $_model = ComponentbuilderHelper::getModel('custom_admin_views'); + $_results = array_unique($_results); + foreach ($_results as $add_php_ajax) + { + // Translate the add_php_ajax selection + $_text = $_model->selectionTranslation($add_php_ajax,'add_php_ajax'); + // Now add the add_php_ajax and its text to the options array + $_filter[] = Html::_('select.option', $add_php_ajax, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/CustomcodesfiltercommenttypeField.php b/admin/src/Field/CustomcodesfiltercommenttypeField.php new file mode 100644 index 000000000..2225857bc --- /dev/null +++ b/admin/src/Field/CustomcodesfiltercommenttypeField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Customcodesfiltercommenttype Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class CustomcodesfiltercommenttypeField extends ListField +{ + /** + * The customcodesfiltercommenttype field type. + * + * @var string + */ + public $type = 'Customcodesfiltercommenttype'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('comment_type')); + $query->from($db->quoteName('#__componentbuilder_custom_code')); + $query->order($db->quoteName('comment_type') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_COMMENT_TYPE_USED_IN_PLACEHOLDER') . ' -'); + + if ($_results) + { + // get custom_codesmodel + $_model = ComponentbuilderHelper::getModel('custom_codes'); + $_results = array_unique($_results); + foreach ($_results as $comment_type) + { + // Translate the comment_type selection + $_text = $_model->selectionTranslation($comment_type,'comment_type'); + // Now add the comment_type and its text to the options array + $_filter[] = Html::_('select.option', $comment_type, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/CustomcodesfiltertargetField.php b/admin/src/Field/CustomcodesfiltertargetField.php new file mode 100644 index 000000000..014bcc58e --- /dev/null +++ b/admin/src/Field/CustomcodesfiltertargetField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Customcodesfiltertarget Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class CustomcodesfiltertargetField extends ListField +{ + /** + * The customcodesfiltertarget field type. + * + * @var string + */ + public $type = 'Customcodesfiltertarget'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('target')); + $query->from($db->quoteName('#__componentbuilder_custom_code')); + $query->order($db->quoteName('target') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_TARGET') . ' -'); + + if ($_results) + { + // get custom_codesmodel + $_model = ComponentbuilderHelper::getModel('custom_codes'); + $_results = array_unique($_results); + foreach ($_results as $target) + { + // Translate the target selection + $_text = $_model->selectionTranslation($target,'target'); + // Now add the target and its text to the options array + $_filter[] = Html::_('select.option', $target, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/CustomcodesfiltertypeField.php b/admin/src/Field/CustomcodesfiltertypeField.php new file mode 100644 index 000000000..7156cf562 --- /dev/null +++ b/admin/src/Field/CustomcodesfiltertypeField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Customcodesfiltertype Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class CustomcodesfiltertypeField extends ListField +{ + /** + * The customcodesfiltertype field type. + * + * @var string + */ + public $type = 'Customcodesfiltertype'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('type')); + $query->from($db->quoteName('#__componentbuilder_custom_code')); + $query->order($db->quoteName('type') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_ADD_TYPE') . ' -'); + + if ($_results) + { + // get custom_codesmodel + $_model = ComponentbuilderHelper::getModel('custom_codes'); + $_results = array_unique($_results); + foreach ($_results as $type) + { + // Translate the type selection + $_text = $_model->selectionTranslation($type,'type'); + // Now add the type and its text to the options array + $_filter[] = Html::_('select.option', $type, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/CustomfilelistField.php b/admin/src/Field/CustomfilelistField.php new file mode 100644 index 000000000..8d579e2eb --- /dev/null +++ b/admin/src/Field/CustomfilelistField.php @@ -0,0 +1,68 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Customfilelist Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class CustomfilelistField extends ListField +{ + /** + * The customfilelist field type. + * + * @var string + */ + public $type = 'Customfilelist'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // get custom folder files + $localfolder = ComponentHelper::getParams('com_componentbuilder')->get('custom_folder_path', JPATH_COMPONENT_ADMINISTRATOR.'/custom'); + // set the default + $options[] = Html::_('select.option', '', Text::sprintf('COM_COMPONENTBUILDER_PLEASE_ADD_FILES_TO_S',$localfolder)); + // inport all needed classes + jimport('joomla.filesystem.file'); + jimport('joomla.filesystem.folder'); + // setup the folder if it does not exist + if (!JFolder::exists($localfolder)) + { + JFolder::create($localfolder); + } + // now check if there are files in the folder + if ($files = JFolder::files($localfolder)) + { + $options = array(); + foreach ($files as $file) + { + $options[] = Html::_('select.option', $file, $file); + } + } + return $options; + } +} diff --git a/admin/src/Field/CustomfolderlistField.php b/admin/src/Field/CustomfolderlistField.php new file mode 100644 index 000000000..584091f69 --- /dev/null +++ b/admin/src/Field/CustomfolderlistField.php @@ -0,0 +1,68 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Customfolderlist Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class CustomfolderlistField extends ListField +{ + /** + * The customfolderlist field type. + * + * @var string + */ + public $type = 'Customfolderlist'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // get custom folder folder + $localfolder = ComponentHelper::getParams('com_componentbuilder')->get('custom_folder_path', JPATH_COMPONENT_ADMINISTRATOR.'/custom'); + // set the default + $options[] = Html::_('select.option', '', Text::sprintf('COM_COMPONENTBUILDER_PLEASE_ADD_FOLDERS_TO_S',$localfolder)); + // import all needed classes + jimport('joomla.filesystem.file'); + jimport('joomla.filesystem.folder'); + // setup the folder if it does not exist + if (!JFolder::exists($localfolder)) + { + JFolder::create($localfolder); + } + // now check if there are files in the folder + if ($folders = JFolder::folders($localfolder)) + { + $options = array(); + foreach ($folders as $folder) + { + $options[] = Html::_('select.option', $folder, $folder); + } + } + return $options; + } +} diff --git a/admin/src/Field/CustomgetsField.php b/admin/src/Field/CustomgetsField.php new file mode 100644 index 000000000..c24dd8188 --- /dev/null +++ b/admin/src/Field/CustomgetsField.php @@ -0,0 +1,66 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Customgets Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class CustomgetsField extends ListField +{ + /** + * The customgets field type. + * + * @var string + */ + public $type = 'Customgets'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name','a.gettype'),array('id','custom_get_name','type'))); + $query->from($db->quoteName('#__componentbuilder_dynamic_get', 'a')); + $query->where($db->quoteName('a.published') . ' = 1'); + $query->where('( '.$db->quoteName('a.gettype') . ' = 3 OR ' . $db->quoteName('a.gettype') . ' = 4 )'); + $query->order('a.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $model = ComponentbuilderHelper::getModel('dynamic_gets'); + foreach($items as $item) + { + $type = $model->selectionTranslation($item->type,'gettype'); + $options[] = Html::_('select.option', $item->id, $item->custom_get_name . ' (' . Text::_($type) . ')' ); + } + } + return $options; + } +} diff --git a/admin/src/Field/DbtablesField.php b/admin/src/Field/DbtablesField.php new file mode 100644 index 000000000..24ab85eca --- /dev/null +++ b/admin/src/Field/DbtablesField.php @@ -0,0 +1,68 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Dbtables Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class DbtablesField extends ListField +{ + /** + * The dbtables field type. + * + * @var string + */ + public $type = 'Dbtables'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // get db object + $db = Factory::getDBO(); + // get all tables + $tables= $db->getTableList(); + // get config + $config = Factory::getConfig(); + $dbprefix = \version_compare(JVERSION,'3.0','lt') ? $config->getValue('config.dbprefix') : $config->get('dbprefix'); + $options = array(); + $options[] = Html::_('select.option', '', 'Select an option'); + for ($i=0; $i < count($tables); $i++) + { + //only tables with primary key + $db->setQuery('SHOW FIELDS FROM `'.$tables[$i].'` WHERE LOWER( `Key` ) = \'pri\''); + if ($db->loadResult()) + { + $key = $i+1; + $options[$key] = new \stdClass; + $options[$key]->value = str_replace($dbprefix, '', $tables[$i]); + $options[$key]->text = $tables[$i]; + } + } + return $options; + } +} diff --git a/admin/src/Field/DynamicdashboardField.php b/admin/src/Field/DynamicdashboardField.php new file mode 100644 index 000000000..9642da4db --- /dev/null +++ b/admin/src/Field/DynamicdashboardField.php @@ -0,0 +1,114 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Dynamicdashboard Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class DynamicdashboardField extends ListField +{ + /** + * The dynamicdashboard field type. + * + * @var string + */ + public $type = 'Dynamicdashboard'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // load the db opbject + $db = Factory::getDBO(); + // get the input from url + $jinput = Factory::getApplication()->input; + // get the id + $ID = $jinput->getInt('id', 0); + // set the targets + $targets = ['adminview' => 'admin_view', 'customadminview' => 'custom_admin_view']; + $t = ['adminview' => 'A', 'customadminview' => 'C']; + // rest the options + $options = []; + // reset the custom admin views array + $views = false; + if (is_numeric($ID) && $ID >= 1) + { + // get the linked back-end views + foreach ($targets as $target => $view) + { + if ($result = GetHelper::var('component_'.$view.'s', (int) $ID, 'joomla_component', 'add'.$view.'s')) + { + $views[$target] = $result; + } + } + } + else + { + // not linked so there is none available + return [Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_YOU_MUST_FIRST_LINK_AN_ADMIN_OR_A_CUSTOM_ADMIN_VIEW_TO_THIS_COMPONENT_THEN_YOU_CAN_SELECT_IT_HERE'))]; + } + // check if we found any values + if (ArrayHelper::check($views)) + { + foreach ($targets as $target => $view) + { + if (isset($views[$target]) && JsonHelper::check($views[$target])) + { + // convert to an array + $value = json_decode($views[$target], true); + $type = StringHelper::safe($view, 'w'); + if (ArrayHelper::check($value)) + { + foreach ($value as $_view) + { + if (isset($_view[$target]) && is_numeric($_view[$target])) + { + // set the view to the selections if found + if ($name = GetHelper::var($view, (int) $_view[$target], 'id', 'system_name')) + { + $options[] = Html::_('select.option', $t[$target].'_'.$_view[$target], $name.' ['.$type.']'); + } + } + } + } + } + } + } + // return found options + if (ArrayHelper::check($options)) + { + array_unshift($options , Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_SELECT_AN_OPTION'))); + return $options; + } + // not linked so there is none available + return [Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_YOU_MUST_FIRST_LINK_AN_ADMIN_OR_A_CUSTOM_ADMIN_VIEW_TO_THIS_COMPONENT_THEN_YOU_CAN_SELECT_IT_HERE'))]; + } +} diff --git a/admin/src/Field/DynamicgetField.php b/admin/src/Field/DynamicgetField.php new file mode 100644 index 000000000..9d4a55a72 --- /dev/null +++ b/admin/src/Field/DynamicgetField.php @@ -0,0 +1,172 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Dynamicget Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class DynamicgetField extends ListField +{ + /** + * The dynamicget field type. + * + * @var string + */ + public $type = 'Dynamicget'; + + /** + * Override to add new button + * + * @return string The field input markup. + * + * @since 3.2 + */ + protected function getInput() + { + // see if we should add buttons + $set_button = $this->getAttribute('button'); + // get html + $html = parent::getInput(); + // if true set button + if ($set_button === 'true') + { + $button = array(); + $script = array(); + $button_code_name = $this->getAttribute('name'); + // get the input from url + $app = Factory::getApplication(); + $jinput = $app->input; + // get the view name & id + $values = $jinput->getArray(array( + 'id' => 'int', + 'view' => 'word' + )); + // check if new item + $ref = ''; + $refJ = ''; + if (!is_null($values['id']) && strlen($values['view'])) + { + // only load referral if not new item. + $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; + $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; + // get the return value. + $_uri = (string) \Joomla\CMS\Uri\Uri::getInstance(); + $_return = urlencode(base64_encode($_uri)); + // load return value. + $ref .= '&return=' . $_return; + $refJ .= '&return=' . $_return; + } + // get button label + $button_label = trim($button_code_name); + $button_label = preg_replace('/_+/', ' ', $button_label); + $button_label = preg_replace('/\s+/', ' ', $button_label); + $button_label = preg_replace("/[^A-Za-z ]/", '', $button_label); + $button_label = ucfirst(strtolower($button_label)); + // get user object + $user = Factory::getApplication()->getIdentity(); + // only add if user allowed to create dynamic_get + if ($user->authorise('dynamic_get.create', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build Create button + $button[] = ' + '; + } + // only add if user allowed to edit dynamic_get + if ($user->authorise('dynamic_get.edit', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build edit button + $button[] = ''; + // build script + $script[] = " + document.addEventListener('DOMContentLoaded', function() { + document.getElementById('jform_".$button_code_name."').addEventListener('change', function(e) { + e.preventDefault(); + let ".$button_code_name."Value = this.value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + let ".$button_code_name."Value = document.getElementById('jform_".$button_code_name."').value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + function ".$button_code_name."Button(value) { + var createButton = document.getElementById('".$button_code_name."Create'); + var editButton = document.getElementById('".$button_code_name."Edit'); + if (value > 0) { + // hide the create button + createButton.style.display = 'none'; + // show edit button + editButton.style.display = 'block'; + let url = 'index.php?option=com_componentbuilder&view=dynamic_gets&task=dynamic_get.edit&id='+value+'".$refJ."'; + editButton.setAttribute('href', url); + } else { + // show the create button + createButton.style.display = 'block'; + // hide edit button + editButton.style.display = 'none'; + } + }"; + } + // check if button was created for dynamic_get field. + if (is_array($button) && count($button) > 0) + { + // Load the needed script. + $document = Factory::getApplication()->getDocument(); + $document->addScriptDeclaration(implode(' ',$script)); + // return the button attached to input field. + return '
    ' .$html . implode('',$button).'
    '; + } + } + return $html; + } + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name','a.gettype'),array('id','dynamic_get_name','type'))); + $query->from($db->quoteName('#__componentbuilder_dynamic_get', 'a')); + $query->where($db->quoteName('a.published') . ' = 1'); +$query->order('a.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select an option'); + $model = ComponentbuilderHelper::getModel('dynamic_gets'); + foreach($items as $item) + { + $type = $model->selectionTranslation($item->type,'gettype'); + $options[] = Html::_('select.option', $item->id, $item->dynamic_get_name . ' (' . Text::_($type) . ')' ); + } + } + return $options; + } +} diff --git a/admin/src/Field/DynamicgetsField.php b/admin/src/Field/DynamicgetsField.php new file mode 100644 index 000000000..bc93ee6af --- /dev/null +++ b/admin/src/Field/DynamicgetsField.php @@ -0,0 +1,65 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Dynamicgets Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class DynamicgetsField extends ListField +{ + /** + * The dynamicgets field type. + * + * @var string + */ + public $type = 'Dynamicgets'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name','a.gettype'),array('id','dynamic_get_name','type'))); + $query->from($db->quoteName('#__componentbuilder_dynamic_get', 'a')); + $query->where($db->quoteName('a.published') . ' = 1'); +$query->order('a.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $model = ComponentbuilderHelper::getModel('dynamic_gets'); + foreach($items as $item) + { + $type = $model->selectionTranslation($item->type,'gettype'); + $options[] = Html::_('select.option', $item->id, $item->dynamic_get_name . ' (' . Text::_($type) . ')' ); + } + } + return $options; + } +} diff --git a/admin/src/Field/DynamicgetsfiltergettypeField.php b/admin/src/Field/DynamicgetsfiltergettypeField.php new file mode 100644 index 000000000..e4588ef66 --- /dev/null +++ b/admin/src/Field/DynamicgetsfiltergettypeField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Dynamicgetsfiltergettype Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class DynamicgetsfiltergettypeField extends ListField +{ + /** + * The dynamicgetsfiltergettype field type. + * + * @var string + */ + public $type = 'Dynamicgetsfiltergettype'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('gettype')); + $query->from($db->quoteName('#__componentbuilder_dynamic_get')); + $query->order($db->quoteName('gettype') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_GETTYPE') . ' -'); + + if ($_results) + { + // get dynamic_getsmodel + $_model = ComponentbuilderHelper::getModel('dynamic_gets'); + $_results = array_unique($_results); + foreach ($_results as $gettype) + { + // Translate the gettype selection + $_text = $_model->selectionTranslation($gettype,'gettype'); + // Now add the gettype and its text to the options array + $_filter[] = Html::_('select.option', $gettype, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/DynamicgetsfiltermainsourceField.php b/admin/src/Field/DynamicgetsfiltermainsourceField.php new file mode 100644 index 000000000..44f882e78 --- /dev/null +++ b/admin/src/Field/DynamicgetsfiltermainsourceField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Dynamicgetsfiltermainsource Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class DynamicgetsfiltermainsourceField extends ListField +{ + /** + * The dynamicgetsfiltermainsource field type. + * + * @var string + */ + public $type = 'Dynamicgetsfiltermainsource'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('main_source')); + $query->from($db->quoteName('#__componentbuilder_dynamic_get')); + $query->order($db->quoteName('main_source') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_MAIN_SOURCE') . ' -'); + + if ($_results) + { + // get dynamic_getsmodel + $_model = ComponentbuilderHelper::getModel('dynamic_gets'); + $_results = array_unique($_results); + foreach ($_results as $main_source) + { + // Translate the main_source selection + $_text = $_model->selectionTranslation($main_source,'main_source'); + // Now add the main_source and its text to the options array + $_filter[] = Html::_('select.option', $main_source, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/ExistingvalidationrulesField.php b/admin/src/Field/ExistingvalidationrulesField.php new file mode 100644 index 000000000..e52c37c69 --- /dev/null +++ b/admin/src/Field/ExistingvalidationrulesField.php @@ -0,0 +1,58 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Existingvalidationrules Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class ExistingvalidationrulesField extends ListField +{ + /** + * The existingvalidationrules field type. + * + * @var string + */ + public $type = 'Existingvalidationrules'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // get the existing validation rules names + if ($items = ComponentbuilderHelper::getExistingValidationRuleNames()) + { + // load the items + $options = array(Html::_('select.option', '', 'Select an option')); + foreach($items as $item) + { + $options[] = Html::_('select.option', $item, ComponentbuilderHelper::safeString($item, 'Ww')); + } + return $options; + } + return array(Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_NO_VALIDATION_RULES_FOUND'))); + } +} diff --git a/admin/src/Field/FieldsField.php b/admin/src/Field/FieldsField.php new file mode 100644 index 000000000..23459a838 --- /dev/null +++ b/admin/src/Field/FieldsField.php @@ -0,0 +1,77 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Fields Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class FieldsField extends ListField +{ + /** + * The fields field type. + * + * @var string + */ + public $type = 'Fields'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id', 'a.name', 'a.xml', 'b.name'), array('id', 'field_name', 'xml', 'type'))); + $query->from($db->quoteName('#__componentbuilder_field', 'a')); + $query->join('LEFT', '#__componentbuilder_fieldtype AS b ON b.id = a.fieldtype'); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->order('a.name ASC'); + $db->setQuery((string) $query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select an option'); + foreach($items as $item) + { + // get the field name (TODO this could slow down the system so we will need to improve on this) + if (isset($item->xml) && ComponentbuilderHelper::checkJson($item->xml)) + { + $field_xml = json_decode($item->xml); + $field_name = ComponentbuilderHelper::getBetween($field_xml,'name="','"'); + $field_name = ComponentbuilderHelper::safeFieldName($field_name); + $options[] = Html::_('select.option', $item->id, $item->field_name . ' [ ' . $field_name . ' - ' . $item->type . ' ]'); + } + else + { + $options[] = Html::_('select.option', $item->id, $item->field_name . ' [ empty - ' . $item->type . ' ]'); + } + } + } + + return $options; + } +} diff --git a/admin/src/Field/FieldsfilterdatatypeField.php b/admin/src/Field/FieldsfilterdatatypeField.php new file mode 100644 index 000000000..3b58915c4 --- /dev/null +++ b/admin/src/Field/FieldsfilterdatatypeField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Fieldsfilterdatatype Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class FieldsfilterdatatypeField extends ListField +{ + /** + * The fieldsfilterdatatype field type. + * + * @var string + */ + public $type = 'Fieldsfilterdatatype'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('datatype')); + $query->from($db->quoteName('#__componentbuilder_field')); + $query->order($db->quoteName('datatype') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_DATA_TYPE') . ' -'); + + if ($_results) + { + // get fieldsmodel + $_model = ComponentbuilderHelper::getModel('fields'); + $_results = array_unique($_results); + foreach ($_results as $datatype) + { + // Translate the datatype selection + $_text = $_model->selectionTranslation($datatype,'datatype'); + // Now add the datatype and its text to the options array + $_filter[] = Html::_('select.option', $datatype, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/FieldsfilterindexesField.php b/admin/src/Field/FieldsfilterindexesField.php new file mode 100644 index 000000000..7baec9343 --- /dev/null +++ b/admin/src/Field/FieldsfilterindexesField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Fieldsfilterindexes Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class FieldsfilterindexesField extends ListField +{ + /** + * The fieldsfilterindexes field type. + * + * @var string + */ + public $type = 'Fieldsfilterindexes'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('indexes')); + $query->from($db->quoteName('#__componentbuilder_field')); + $query->order($db->quoteName('indexes') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_INDEXES_TYPE') . ' -'); + + if ($_results) + { + // get fieldsmodel + $_model = ComponentbuilderHelper::getModel('fields'); + $_results = array_unique($_results); + foreach ($_results as $indexes) + { + // Translate the indexes selection + $_text = $_model->selectionTranslation($indexes,'indexes'); + // Now add the indexes and its text to the options array + $_filter[] = Html::_('select.option', $indexes, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/FieldsfilternullswitchField.php b/admin/src/Field/FieldsfilternullswitchField.php new file mode 100644 index 000000000..01afaf496 --- /dev/null +++ b/admin/src/Field/FieldsfilternullswitchField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Fieldsfilternullswitch Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class FieldsfilternullswitchField extends ListField +{ + /** + * The fieldsfilternullswitch field type. + * + * @var string + */ + public $type = 'Fieldsfilternullswitch'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('null_switch')); + $query->from($db->quoteName('#__componentbuilder_field')); + $query->order($db->quoteName('null_switch') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_NULL_SWITCH') . ' -'); + + if ($_results) + { + // get fieldsmodel + $_model = ComponentbuilderHelper::getModel('fields'); + $_results = array_unique($_results); + foreach ($_results as $null_switch) + { + // Translate the null_switch selection + $_text = $_model->selectionTranslation($null_switch,'null_switch'); + // Now add the null_switch and its text to the options array + $_filter[] = Html::_('select.option', $null_switch, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/FieldsfilterstoreField.php b/admin/src/Field/FieldsfilterstoreField.php new file mode 100644 index 000000000..7482f6890 --- /dev/null +++ b/admin/src/Field/FieldsfilterstoreField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Fieldsfilterstore Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class FieldsfilterstoreField extends ListField +{ + /** + * The fieldsfilterstore field type. + * + * @var string + */ + public $type = 'Fieldsfilterstore'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('store')); + $query->from($db->quoteName('#__componentbuilder_field')); + $query->order($db->quoteName('store') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_MODELLING_METHOD') . ' -'); + + if ($_results) + { + // get fieldsmodel + $_model = ComponentbuilderHelper::getModel('fields'); + $_results = array_unique($_results); + foreach ($_results as $store) + { + // Translate the store selection + $_text = $_model->selectionTranslation($store,'store'); + // Now add the store and its text to the options array + $_filter[] = Html::_('select.option', $store, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/FieldtypesField.php b/admin/src/Field/FieldtypesField.php new file mode 100644 index 000000000..b91a6d154 --- /dev/null +++ b/admin/src/Field/FieldtypesField.php @@ -0,0 +1,171 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Fieldtypes Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class FieldtypesField extends ListField +{ + /** + * The fieldtypes field type. + * + * @var string + */ + public $type = 'Fieldtypes'; + + /** + * Override to add new button + * + * @return string The field input markup. + * + * @since 3.2 + */ + protected function getInput() + { + // see if we should add buttons + $set_button = $this->getAttribute('button'); + // get html + $html = parent::getInput(); + // if true set button + if ($set_button === 'true') + { + $button = array(); + $script = array(); + $button_code_name = $this->getAttribute('name'); + // get the input from url + $app = Factory::getApplication(); + $jinput = $app->input; + // get the view name & id + $values = $jinput->getArray(array( + 'id' => 'int', + 'view' => 'word' + )); + // check if new item + $ref = ''; + $refJ = ''; + if (!is_null($values['id']) && strlen($values['view'])) + { + // only load referral if not new item. + $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; + $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; + // get the return value. + $_uri = (string) \Joomla\CMS\Uri\Uri::getInstance(); + $_return = urlencode(base64_encode($_uri)); + // load return value. + $ref .= '&return=' . $_return; + $refJ .= '&return=' . $_return; + } + // get button label + $button_label = trim($button_code_name); + $button_label = preg_replace('/_+/', ' ', $button_label); + $button_label = preg_replace('/\s+/', ' ', $button_label); + $button_label = preg_replace("/[^A-Za-z ]/", '', $button_label); + $button_label = ucfirst(strtolower($button_label)); + // get user object + $user = Factory::getApplication()->getIdentity(); + // only add if user allowed to create fieldtype + if ($user->authorise('fieldtype.create', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build Create button + $button[] = ' + '; + } + // only add if user allowed to edit fieldtype + if ($user->authorise('fieldtype.edit', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build edit button + $button[] = ''; + // build script + $script[] = " + document.addEventListener('DOMContentLoaded', function() { + document.getElementById('jform_".$button_code_name."').addEventListener('change', function(e) { + e.preventDefault(); + let ".$button_code_name."Value = this.value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + let ".$button_code_name."Value = document.getElementById('jform_".$button_code_name."').value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + function ".$button_code_name."Button(value) { + var createButton = document.getElementById('".$button_code_name."Create'); + var editButton = document.getElementById('".$button_code_name."Edit'); + if (value > 0) { + // hide the create button + createButton.style.display = 'none'; + // show edit button + editButton.style.display = 'block'; + let url = 'index.php?option=com_componentbuilder&view=fieldtypes&task=fieldtype.edit&id='+value+'".$refJ."'; + editButton.setAttribute('href', url); + } else { + // show the create button + createButton.style.display = 'block'; + // hide edit button + editButton.style.display = 'none'; + } + }"; + } + // check if button was created for fieldtype field. + if (is_array($button) && count($button) > 0) + { + // Load the needed script. + $document = Factory::getApplication()->getDocument(); + $document->addScriptDeclaration(implode(' ',$script)); + // return the button attached to input field. + return '
    ' .$html . implode('',$button).'
    '; + } + } + return $html; + } + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + $db = Factory::getDBO(); +$query = $db->getQuery(true); +$query->select($db->quoteName(array('a.id','a.name'),array('id','fieldtype_name'))); +$query->from($db->quoteName('#__componentbuilder_fieldtype', 'a')); +$query->where($db->quoteName('a.published') . ' = 1'); +$query->order('a.name ASC'); +$db->setQuery((string)$query); +$items = $db->loadObjectList(); +$options = array(); +if ($items) +{ + $options[] = Html::_('select.option', '', 'Select an option'); + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->fieldtype_name); + } +} + +return $options; + } +} diff --git a/admin/src/Field/FilebehaviourField.php b/admin/src/Field/FilebehaviourField.php new file mode 100644 index 000000000..057aa10a4 --- /dev/null +++ b/admin/src/Field/FilebehaviourField.php @@ -0,0 +1,61 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Filebehaviour Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class FilebehaviourField extends ListField +{ + /** + * The filebehaviour field type. + * + * @var string + */ + public $type = 'Filebehaviour'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // get the input from url + $jinput = Factory::getApplication()->input; + // get the library id + $libID = $jinput->getInt('id', 0); + $options[] = Html::_('select.option', '1', Text::_('COM_COMPONENTBUILDER_ALWAYS_ADD')); + // add build in option for some libraries + $buildin = array(3 => 'Uikit v3', 4 => 'Uikit v2', 5 => 'FooTable v2', 6 => 'FooTable v3'); + if (isset($buildin[$libID])) + { + $options[] = Html::_('select.option', '4', Text::_('COM_COMPONENTBUILDER_BUILDIN')); + } + $options[] = Html::_('select.option', '2', Text::_('COM_COMPONENTBUILDER_CONDITIONS')); + $options[] = Html::_('select.option', '3', Text::_('COM_COMPONENTBUILDER_CUSTOM_SCRIPT')); + $options[] = Html::_('select.option', '0', Text::_('COM_COMPONENTBUILDER_DO_NOT_ADD')); + return $options; + } +} diff --git a/admin/src/Field/HelpdocumentsfilterlocationField.php b/admin/src/Field/HelpdocumentsfilterlocationField.php new file mode 100644 index 000000000..ba2e8c937 --- /dev/null +++ b/admin/src/Field/HelpdocumentsfilterlocationField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Helpdocumentsfilterlocation Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class HelpdocumentsfilterlocationField extends ListField +{ + /** + * The helpdocumentsfilterlocation field type. + * + * @var string + */ + public $type = 'Helpdocumentsfilterlocation'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('location')); + $query->from($db->quoteName('#__componentbuilder_help_document')); + $query->order($db->quoteName('location') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_LOCATION') . ' -'); + + if ($_results) + { + // get help_documentsmodel + $_model = ComponentbuilderHelper::getModel('help_documents'); + $_results = array_unique($_results); + foreach ($_results as $location) + { + // Translate the location selection + $_text = $_model->selectionTranslation($location,'location'); + // Now add the location and its text to the options array + $_filter[] = Html::_('select.option', $location, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/HelpdocumentsfiltertypeField.php b/admin/src/Field/HelpdocumentsfiltertypeField.php new file mode 100644 index 000000000..a4cea67b6 --- /dev/null +++ b/admin/src/Field/HelpdocumentsfiltertypeField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Helpdocumentsfiltertype Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class HelpdocumentsfiltertypeField extends ListField +{ + /** + * The helpdocumentsfiltertype field type. + * + * @var string + */ + public $type = 'Helpdocumentsfiltertype'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('type')); + $query->from($db->quoteName('#__componentbuilder_help_document')); + $query->order($db->quoteName('type') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_TYPE') . ' -'); + + if ($_results) + { + // get help_documentsmodel + $_model = ComponentbuilderHelper::getModel('help_documents'); + $_results = array_unique($_results); + foreach ($_results as $type) + { + // Translate the type selection + $_text = $_model->selectionTranslation($type,'type'); + // Now add the type and its text to the options array + $_filter[] = Html::_('select.option', $type, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/InterfacepowersField.php b/admin/src/Field/InterfacepowersField.php new file mode 100644 index 000000000..4d3209003 --- /dev/null +++ b/admin/src/Field/InterfacepowersField.php @@ -0,0 +1,199 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Interfacepowers Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class InterfacepowersField extends ListField +{ + /** + * The interfacepowers field type. + * + * @var string + */ + public $type = 'Interfacepowers'; + + /** + * Override to add new button + * + * @return string The field input markup. + * + * @since 3.2 + */ + protected function getInput() + { + // see if we should add buttons + $set_button = $this->getAttribute('button'); + // get html + $html = parent::getInput(); + // if true set button + if ($set_button === 'true') + { + $button = array(); + $script = array(); + $button_code_name = $this->getAttribute('name'); + // get the input from url + $app = Factory::getApplication(); + $jinput = $app->input; + // get the view name & id + $values = $jinput->getArray(array( + 'id' => 'int', + 'view' => 'word' + )); + // check if new item + $ref = ''; + $refJ = ''; + if (!is_null($values['id']) && strlen($values['view'])) + { + // only load referral if not new item. + $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; + $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; + // get the return value. + $_uri = (string) \Joomla\CMS\Uri\Uri::getInstance(); + $_return = urlencode(base64_encode($_uri)); + // load return value. + $ref .= '&return=' . $_return; + $refJ .= '&return=' . $_return; + } + // get button label + $button_label = trim($button_code_name); + $button_label = preg_replace('/_+/', ' ', $button_label); + $button_label = preg_replace('/\s+/', ' ', $button_label); + $button_label = preg_replace("/[^A-Za-z ]/", '', $button_label); + $button_label = ucfirst(strtolower($button_label)); + // get user object + $user = Factory::getApplication()->getIdentity(); + // only add if user allowed to create power + if ($user->authorise('power.create', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build Create button + $button[] = ' + '; + } + // only add if user allowed to edit power + if ($user->authorise('power.edit', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build edit button + $button[] = ''; + // build script + $script[] = " + document.addEventListener('DOMContentLoaded', function() { + document.getElementById('jform_".$button_code_name."').addEventListener('change', function(e) { + e.preventDefault(); + let ".$button_code_name."Value = this.value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + let ".$button_code_name."Value = document.getElementById('jform_".$button_code_name."').value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + function ".$button_code_name."Button(value) { + var createButton = document.getElementById('".$button_code_name."Create'); + var editButton = document.getElementById('".$button_code_name."Edit'); + if (value > 0) { + // hide the create button + createButton.style.display = 'none'; + // show edit button + editButton.style.display = 'block'; + let url = 'index.php?option=com_componentbuilder&view=powers&task=power.edit&id='+value+'".$refJ."'; + editButton.setAttribute('href', url); + } else { + // show the create button + createButton.style.display = 'block'; + // hide edit button + editButton.style.display = 'none'; + } + }"; + } + // check if button was created for power field. + if (is_array($button) && count($button) > 0) + { + // Load the needed script. + $document = Factory::getApplication()->getDocument(); + $document->addScriptDeclaration(implode(' ',$script)); + // return the button attached to input field. + return '
    ' .$html . implode('',$button).'
    '; + } + } + return $html; + } + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get the user object. + $user = Factory::getApplication()->getIdentity(); + // Get the databse object. + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.guid','a.name','a.system_name','a.type','a.power_version'),array('guid','implements_name','system_name','type','version'))); + $query->from($db->quoteName('#__componentbuilder_power', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->where($db->quoteName('a.type') . ' = ' . $db->quote('interface')); + $query->order('a.name ASC'); + $query->order('a.type ASC'); + // Implement View Level Access (if set in table) + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $columns = $db->getTableColumns('#__componentbuilder_power'); + if(isset($columns['access'])) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + } + // get the input + $jinput = Factory::getApplication()->input; + // get the id + $power_id = $jinput->getInt('id', 0); + // if we have an id we remove all classes of the same namespace and name + if ($power_id > 0 && ($exclude_powers = ComponentbuilderHelper::excludePowers($power_id)) !== false) + { + $query->where('a.id NOT IN (' . implode(',', $exclude_powers) . ')'); + } + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + // set the other option to enter text + $options[] = Html::_('select.option', -1, Text::_('COM_COMPONENTBUILDER_SET_CUSTOM')); + if ($items) + { + if ($this->multiple === false) + { + $options[] = Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_SELECT_AN_OPTION')); + } + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->guid, $item->system_name . ' (v' . $item->version . ') [' . $item->type . ' ' . $item->implements_name . ']'); + } + } + return $options; + } +} diff --git a/admin/src/Field/JoinfieldsField.php b/admin/src/Field/JoinfieldsField.php new file mode 100644 index 000000000..4f227be30 --- /dev/null +++ b/admin/src/Field/JoinfieldsField.php @@ -0,0 +1,116 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joinfields Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class JoinfieldsField extends ListField +{ + /** + * The joinfields field type. + * + * @var string + */ + public $type = 'Joinfields'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // load the db opbject + $db = Factory::getDBO(); + // get the input from url + $jinput = Factory::getApplication()->input; + // get the id + $ID = $jinput->getInt('id', 0); + // rest the fields ids + $fieldIds = array(); + if (is_numeric($ID) && $ID >= 1) + { + // get the admin view ID + $adminView = ComponentbuilderHelper::getVar('admin_fields_relations', (int) $ID, 'id', 'admin_view'); + } + else + { + // get the admin view ID + $adminView = $jinput->getInt('refid', 0); + } + if (is_numeric($adminView) && $adminView >= 1) + { + // get all the fields linked to the admin view + if ($addFields = ComponentbuilderHelper::getVar('admin_fields', (int) $adminView, 'admin_view', 'addfields')) + { + if (ComponentbuilderHelper::checkJson($addFields)) + { + $addFields = json_decode($addFields, true); + if (ComponentbuilderHelper::checkArray($addFields)) + { + foreach($addFields as $addField) + { + if (isset($addField['field']) && (!isset($addField['list']) || ($addField['list'] != 1 && $addField['list'] != 2))) + { + $fieldIds[] = (int) $addField['field']; + } + } + } + } + } + // filter by fields linked + if (ComponentbuilderHelper::checkArray($fieldIds)) + { + // get list of field types that does not work in list views (note, spacer) + $spacers = ComponentbuilderHelper::getSpacerIds(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name','t.name'),array('id','name','type'))); + $query->from($db->quoteName('#__componentbuilder_field', 'a')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_fieldtype', 't') . ' ON (' . $db->quoteName('a.fieldtype') . ' = ' . $db->quoteName('t.id') . ')'); + $query->where($db->quoteName('a.published') . ' >= 1'); + // only load these fields + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $fieldIds) . ')'); + // none of these field types + if (ComponentbuilderHelper::checkArray($spacers)) + { + $query->where($db->quoteName('a.fieldtype') . ' NOT IN (' . implode(',', $spacers) . ')'); + } + $query->order('a.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->name . ' [' . $item->type . ']'); + } + } + return $options; + } + } + return array(Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_ADD_MORE_FIELDS_TO_THIS_ADMIN_VIEW'))); + } +} diff --git a/admin/src/Field/JoomlacomponentField.php b/admin/src/Field/JoomlacomponentField.php new file mode 100644 index 000000000..c7240638d --- /dev/null +++ b/admin/src/Field/JoomlacomponentField.php @@ -0,0 +1,171 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomlacomponent Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class JoomlacomponentField extends ListField +{ + /** + * The joomlacomponent field type. + * + * @var string + */ + public $type = 'Joomlacomponent'; + + /** + * Override to add new button + * + * @return string The field input markup. + * + * @since 3.2 + */ + protected function getInput() + { + // see if we should add buttons + $set_button = $this->getAttribute('button'); + // get html + $html = parent::getInput(); + // if true set button + if ($set_button === 'true') + { + $button = array(); + $script = array(); + $button_code_name = $this->getAttribute('name'); + // get the input from url + $app = Factory::getApplication(); + $jinput = $app->input; + // get the view name & id + $values = $jinput->getArray(array( + 'id' => 'int', + 'view' => 'word' + )); + // check if new item + $ref = ''; + $refJ = ''; + if (!is_null($values['id']) && strlen($values['view'])) + { + // only load referral if not new item. + $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; + $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; + // get the return value. + $_uri = (string) \Joomla\CMS\Uri\Uri::getInstance(); + $_return = urlencode(base64_encode($_uri)); + // load return value. + $ref .= '&return=' . $_return; + $refJ .= '&return=' . $_return; + } + // get button label + $button_label = trim($button_code_name); + $button_label = preg_replace('/_+/', ' ', $button_label); + $button_label = preg_replace('/\s+/', ' ', $button_label); + $button_label = preg_replace("/[^A-Za-z ]/", '', $button_label); + $button_label = ucfirst(strtolower($button_label)); + // get user object + $user = Factory::getApplication()->getIdentity(); + // only add if user allowed to create joomla_component + if ($user->authorise('joomla_component.create', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build Create button + $button[] = ' + '; + } + // only add if user allowed to edit joomla_component + if ($user->authorise('joomla_component.edit', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build edit button + $button[] = ''; + // build script + $script[] = " + document.addEventListener('DOMContentLoaded', function() { + document.getElementById('jform_".$button_code_name."').addEventListener('change', function(e) { + e.preventDefault(); + let ".$button_code_name."Value = this.value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + let ".$button_code_name."Value = document.getElementById('jform_".$button_code_name."').value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + function ".$button_code_name."Button(value) { + var createButton = document.getElementById('".$button_code_name."Create'); + var editButton = document.getElementById('".$button_code_name."Edit'); + if (value > 0) { + // hide the create button + createButton.style.display = 'none'; + // show edit button + editButton.style.display = 'block'; + let url = 'index.php?option=com_componentbuilder&view=joomla_components&task=joomla_component.edit&id='+value+'".$refJ."'; + editButton.setAttribute('href', url); + } else { + // show the create button + createButton.style.display = 'block'; + // hide edit button + editButton.style.display = 'none'; + } + }"; + } + // check if button was created for joomla_component field. + if (is_array($button) && count($button) > 0) + { + // Load the needed script. + $document = Factory::getApplication()->getDocument(); + $document->addScriptDeclaration(implode(' ',$script)); + // return the button attached to input field. + return '
    ' .$html . implode('',$button).'
    '; + } + } + return $html; + } + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.system_name'),array('id','component_system_name'))); + $query->from($db->quoteName('#__componentbuilder_joomla_component', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->order('a.system_name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select an option'); + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->component_system_name); + } + } + + return $options; + } +} diff --git a/admin/src/Field/JoomlacomponentsField.php b/admin/src/Field/JoomlacomponentsField.php new file mode 100644 index 000000000..ca52a42fc --- /dev/null +++ b/admin/src/Field/JoomlacomponentsField.php @@ -0,0 +1,64 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomlacomponents Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class JoomlacomponentsField extends ListField +{ + /** + * The joomlacomponents field type. + * + * @var string + */ + public $type = 'Joomlacomponents'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.system_name'),array('id','components_system_name'))); + $query->from($db->quoteName('#__componentbuilder_joomla_component', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->order('a.system_name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->components_system_name); + } + } + + return $options; + } +} diff --git a/admin/src/Field/JoomlacomponentsfilterauthorField.php b/admin/src/Field/JoomlacomponentsfilterauthorField.php new file mode 100644 index 000000000..a276e46d0 --- /dev/null +++ b/admin/src/Field/JoomlacomponentsfilterauthorField.php @@ -0,0 +1,73 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomlacomponentsfilterauthor Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class JoomlacomponentsfilterauthorField extends ListField +{ + /** + * The joomlacomponentsfilterauthor field type. + * + * @var string + */ + public $type = 'Joomlacomponentsfilterauthor'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('author')); + $query->from($db->quoteName('#__componentbuilder_joomla_component')); + $query->order($db->quoteName('author') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $author) + { + // Now add the author and its text to the options array + $_filter[] = Html::_('select.option', $author, $author); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/JoomlacomponentsfiltercompanynameField.php b/admin/src/Field/JoomlacomponentsfiltercompanynameField.php new file mode 100644 index 000000000..c13ca3a57 --- /dev/null +++ b/admin/src/Field/JoomlacomponentsfiltercompanynameField.php @@ -0,0 +1,73 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomlacomponentsfiltercompanyname Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class JoomlacomponentsfiltercompanynameField extends ListField +{ + /** + * The joomlacomponentsfiltercompanyname field type. + * + * @var string + */ + public $type = 'Joomlacomponentsfiltercompanyname'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('companyname')); + $query->from($db->quoteName('#__componentbuilder_joomla_component')); + $query->order($db->quoteName('companyname') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $companyname) + { + // Now add the companyname and its text to the options array + $_filter[] = Html::_('select.option', $companyname, $companyname); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/JoomlamodulesField.php b/admin/src/Field/JoomlamodulesField.php new file mode 100644 index 000000000..a2e25b615 --- /dev/null +++ b/admin/src/Field/JoomlamodulesField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomlamodules Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class JoomlamodulesField extends ListField +{ + /** + * The joomlamodules field type. + * + * @var string + */ + public $type = 'Joomlamodules'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get the user object. + $user = Factory::getApplication()->getIdentity(); + // Get the databse object. + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.system_name'),array('id','joomla_module_system_name'))); + $query->from($db->quoteName('#__componentbuilder_joomla_module', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->order('a.system_name ASC'); + // Implement View Level Access (if set in table) + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $columns = $db->getTableColumns('#__componentbuilder_joomla_module'); + if(isset($columns['access'])) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + } + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select a module'); + foreach($items as $item) + { + // set a full class name + $options[] = Html::_('select.option', $item->id, $item->joomla_module_system_name); + } + } + return $options; + } +} diff --git a/admin/src/Field/JoomlamodulesfiltertargetField.php b/admin/src/Field/JoomlamodulesfiltertargetField.php new file mode 100644 index 000000000..7aac03a63 --- /dev/null +++ b/admin/src/Field/JoomlamodulesfiltertargetField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomlamodulesfiltertarget Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class JoomlamodulesfiltertargetField extends ListField +{ + /** + * The joomlamodulesfiltertarget field type. + * + * @var string + */ + public $type = 'Joomlamodulesfiltertarget'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('target')); + $query->from($db->quoteName('#__componentbuilder_joomla_module')); + $query->order($db->quoteName('target') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_TARGET_AREA') . ' -'); + + if ($_results) + { + // get joomla_modulesmodel + $_model = ComponentbuilderHelper::getModel('joomla_modules'); + $_results = array_unique($_results); + foreach ($_results as $target) + { + // Translate the target selection + $_text = $_model->selectionTranslation($target,'target'); + // Now add the target and its text to the options array + $_filter[] = Html::_('select.option', $target, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/JoomlaplugingroupsField.php b/admin/src/Field/JoomlaplugingroupsField.php new file mode 100644 index 000000000..6de71d3f0 --- /dev/null +++ b/admin/src/Field/JoomlaplugingroupsField.php @@ -0,0 +1,183 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomlaplugingroups Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class JoomlaplugingroupsField extends ListField +{ + /** + * The joomlaplugingroups field type. + * + * @var string + */ + public $type = 'Joomlaplugingroups'; + + /** + * Override to add new button + * + * @return string The field input markup. + * + * @since 3.2 + */ + protected function getInput() + { + // see if we should add buttons + $set_button = $this->getAttribute('button'); + // get html + $html = parent::getInput(); + // if true set button + if ($set_button === 'true') + { + $button = array(); + $script = array(); + $button_code_name = $this->getAttribute('name'); + // get the input from url + $app = Factory::getApplication(); + $jinput = $app->input; + // get the view name & id + $values = $jinput->getArray(array( + 'id' => 'int', + 'view' => 'word' + )); + // check if new item + $ref = ''; + $refJ = ''; + if (!is_null($values['id']) && strlen($values['view'])) + { + // only load referral if not new item. + $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; + $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; + // get the return value. + $_uri = (string) \Joomla\CMS\Uri\Uri::getInstance(); + $_return = urlencode(base64_encode($_uri)); + // load return value. + $ref .= '&return=' . $_return; + $refJ .= '&return=' . $_return; + } + // get button label + $button_label = trim($button_code_name); + $button_label = preg_replace('/_+/', ' ', $button_label); + $button_label = preg_replace('/\s+/', ' ', $button_label); + $button_label = preg_replace("/[^A-Za-z ]/", '', $button_label); + $button_label = ucfirst(strtolower($button_label)); + // get user object + $user = Factory::getApplication()->getIdentity(); + // only add if user allowed to create joomla_plugin_group + if ($user->authorise('core.create', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build Create button + $button[] = ' + '; + } + // only add if user allowed to edit joomla_plugin_group + if ($user->authorise('core.edit', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build edit button + $button[] = ''; + // build script + $script[] = " + document.addEventListener('DOMContentLoaded', function() { + document.getElementById('jform_".$button_code_name."').addEventListener('change', function(e) { + e.preventDefault(); + let ".$button_code_name."Value = this.value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + let ".$button_code_name."Value = document.getElementById('jform_".$button_code_name."').value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + function ".$button_code_name."Button(value) { + var createButton = document.getElementById('".$button_code_name."Create'); + var editButton = document.getElementById('".$button_code_name."Edit'); + if (value > 0) { + // hide the create button + createButton.style.display = 'none'; + // show edit button + editButton.style.display = 'block'; + let url = 'index.php?option=com_componentbuilder&view=joomla_plugin_groups&task=joomla_plugin_group.edit&id='+value+'".$refJ."'; + editButton.setAttribute('href', url); + } else { + // show the create button + createButton.style.display = 'block'; + // hide edit button + editButton.style.display = 'none'; + } + }"; + } + // check if button was created for joomla_plugin_group field. + if (is_array($button) && count($button) > 0) + { + // Load the needed script. + $document = Factory::getApplication()->getDocument(); + $document->addScriptDeclaration(implode(' ',$script)); + // return the button attached to input field. + return '
    ' .$html . implode('',$button).'
    '; + } + } + return $html; + } + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get the user object. + $user = Factory::getApplication()->getIdentity(); + // Get the databse object. + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name'),array('id','joomla_plugin_group_name'))); + $query->from($db->quoteName('#__componentbuilder_joomla_plugin_group', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->order('a.name ASC'); + // Implement View Level Access (if set in table) + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $columns = $db->getTableColumns('#__componentbuilder_joomla_plugin_group'); + if(isset($columns['access'])) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + } + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select a group'); + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->joomla_plugin_group_name); + } + } + return $options; + } +} diff --git a/admin/src/Field/JoomlapluginsField.php b/admin/src/Field/JoomlapluginsField.php new file mode 100644 index 000000000..57b74eb98 --- /dev/null +++ b/admin/src/Field/JoomlapluginsField.php @@ -0,0 +1,80 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomlaplugins Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class JoomlapluginsField extends ListField +{ + /** + * The joomlaplugins field type. + * + * @var string + */ + public $type = 'Joomlaplugins'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get the user object. + $user = Factory::getApplication()->getIdentity(); + // Get the databse object. + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.system_name','a.name','b.name','c.name'),array('id','plugin_system_name','name','class_extends_name','joomla_plugin_group_name'))); + $query->from($db->quoteName('#__componentbuilder_joomla_plugin', 'a')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_class_extends', 'b') . ' ON (' . $db->quoteName('a.class_extends') . ' = ' . $db->quoteName('b.id') . ')'); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_plugin_group', 'c') . ' ON (' . $db->quoteName('a.joomla_plugin_group') . ' = ' . $db->quoteName('c.id') . ')'); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->order('a.system_name ASC'); + // Implement View Level Access (if set in table) + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $columns = $db->getTableColumns('#__componentbuilder_joomla_plugin'); + if(isset($columns['access'])) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + } + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select a plugin'); + foreach($items as $item) + { + // set a full class name + $options[] = Html::_('select.option', $item->id, '( ' . $item->plugin_system_name . ' ) class Plg' . ucfirst($item->joomla_plugin_group_name) . $item->name . ' extends ' . $item->class_extends_name); + } + } + return $options; + } +} diff --git a/admin/src/Field/LangField.php b/admin/src/Field/LangField.php new file mode 100644 index 000000000..299888044 --- /dev/null +++ b/admin/src/Field/LangField.php @@ -0,0 +1,85 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Lang Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class LangField extends ListField +{ + /** + * The lang field type. + * + * @var string + */ + public $type = 'Lang'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.langtag','a.name'),array('langtag','language_name'))); + $query->from($db->quoteName('#__componentbuilder_language', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->order('a.langtag ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + // add the main language + $main_lang = trim(ComponentHelper::getParams('com_componentbuilder')->get('language', 'en-GB')); + // make sure the main language is added + $wasAdded = false; + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select an option'); + foreach($items as $item) + { + $item->langtag = trim($item->langtag); + $options[] = Html::_('select.option', $item->langtag, $item->language_name . ' (' .$item->langtag.')'); + if ($main_lang === $item->langtag) + { + $wasAdded = true; + } + } + } + // now add it if not already added (it must default to $main_lang) + if (!$wasAdded) + { + if ('en-GB' === $main_lang) + { + $options[] = Html::_('select.option', $main_lang, 'English GB (' . $main_lang . ')'); + } + else + { + $options[] = Html::_('select.option', $main_lang, 'Main Language (' . $main_lang . ')'); + } + } + return $options; + } +} diff --git a/admin/src/Field/LayoutsfilteraddphpviewField.php b/admin/src/Field/LayoutsfilteraddphpviewField.php new file mode 100644 index 000000000..21b259ff1 --- /dev/null +++ b/admin/src/Field/LayoutsfilteraddphpviewField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Layoutsfilteraddphpview Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class LayoutsfilteraddphpviewField extends ListField +{ + /** + * The layoutsfilteraddphpview field type. + * + * @var string + */ + public $type = 'Layoutsfilteraddphpview'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('add_php_view')); + $query->from($db->quoteName('#__componentbuilder_layout')); + $query->order($db->quoteName('add_php_view') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_ADD_PHP_CUSTOM_VIEW_SCRIPT') . ' -'); + + if ($_results) + { + // get layoutsmodel + $_model = ComponentbuilderHelper::getModel('layouts'); + $_results = array_unique($_results); + foreach ($_results as $add_php_view) + { + // Translate the add_php_view selection + $_text = $_model->selectionTranslation($add_php_view,'add_php_view'); + // Now add the add_php_view and its text to the options array + $_filter[] = Html::_('select.option', $add_php_view, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/LibconfigfieldField.php b/admin/src/Field/LibconfigfieldField.php new file mode 100644 index 000000000..75e43d093 --- /dev/null +++ b/admin/src/Field/LibconfigfieldField.php @@ -0,0 +1,99 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Libconfigfield Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class LibconfigfieldField extends ListField +{ + /** + * The libconfigfield field type. + * + * @var string + */ + public $type = 'Libconfigfield'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // load the db object + $db = Factory::getDBO(); + // get the input from url + $jinput = Factory::getApplication()->input; + // get the id + $ID = $jinput->getInt('id', 0); + // rest the fields ids + $fieldIds = array(); + if (is_numeric($ID) && $ID >= 1) + { + // get all the fields linked to the library config + if ($addconfig = ComponentbuilderHelper::getVar('library_config', (int) $ID, 'library', 'addconfig')) + { + if (ComponentbuilderHelper::checkJson($addconfig)) + { + $addconfig = json_decode($addconfig, true); + if (ComponentbuilderHelper::checkArray($addconfig)) + { + foreach($addconfig as $field) + { + if (isset($field['field'])) + { + $fieldIds[] = (int) $field['field']; + } + } + } + } + } + } + // check if we have ids, since we should not show any fields that are not part of this config + if (ComponentbuilderHelper::checkArray($fieldIds)) + { + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name'),array('id','name'))); + $query->from($db->quoteName('#__componentbuilder_field', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + // only load these fields + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $fieldIds) . ')'); + $query->order('a.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select an option'); + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->name); + } + return $options; + } + } + return array(Html::_('select.option', '', 'No config fields linked')); + } +} diff --git a/admin/src/Field/LibrariesField.php b/admin/src/Field/LibrariesField.php new file mode 100644 index 000000000..4cdeca162 --- /dev/null +++ b/admin/src/Field/LibrariesField.php @@ -0,0 +1,171 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Libraries Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class LibrariesField extends ListField +{ + /** + * The libraries field type. + * + * @var string + */ + public $type = 'Libraries'; + + /** + * Override to add new button + * + * @return string The field input markup. + * + * @since 3.2 + */ + protected function getInput() + { + // see if we should add buttons + $set_button = $this->getAttribute('button'); + // get html + $html = parent::getInput(); + // if true set button + if ($set_button === 'true') + { + $button = array(); + $script = array(); + $button_code_name = $this->getAttribute('name'); + // get the input from url + $app = Factory::getApplication(); + $jinput = $app->input; + // get the view name & id + $values = $jinput->getArray(array( + 'id' => 'int', + 'view' => 'word' + )); + // check if new item + $ref = ''; + $refJ = ''; + if (!is_null($values['id']) && strlen($values['view'])) + { + // only load referral if not new item. + $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; + $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; + // get the return value. + $_uri = (string) \Joomla\CMS\Uri\Uri::getInstance(); + $_return = urlencode(base64_encode($_uri)); + // load return value. + $ref .= '&return=' . $_return; + $refJ .= '&return=' . $_return; + } + // get button label + $button_label = trim($button_code_name); + $button_label = preg_replace('/_+/', ' ', $button_label); + $button_label = preg_replace('/\s+/', ' ', $button_label); + $button_label = preg_replace("/[^A-Za-z ]/", '', $button_label); + $button_label = ucfirst(strtolower($button_label)); + // get user object + $user = Factory::getApplication()->getIdentity(); + // only add if user allowed to create library + if ($user->authorise('library.create', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build Create button + $button[] = ' + '; + } + // only add if user allowed to edit library + if ($user->authorise('library.edit', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build edit button + $button[] = ''; + // build script + $script[] = " + document.addEventListener('DOMContentLoaded', function() { + document.getElementById('jform_".$button_code_name."').addEventListener('change', function(e) { + e.preventDefault(); + let ".$button_code_name."Value = this.value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + let ".$button_code_name."Value = document.getElementById('jform_".$button_code_name."').value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + function ".$button_code_name."Button(value) { + var createButton = document.getElementById('".$button_code_name."Create'); + var editButton = document.getElementById('".$button_code_name."Edit'); + if (value > 0) { + // hide the create button + createButton.style.display = 'none'; + // show edit button + editButton.style.display = 'block'; + let url = 'index.php?option=com_componentbuilder&view=libraries&task=library.edit&id='+value+'".$refJ."'; + editButton.setAttribute('href', url); + } else { + // show the create button + createButton.style.display = 'block'; + // hide edit button + editButton.style.display = 'none'; + } + }"; + } + // check if button was created for library field. + if (is_array($button) && count($button) > 0) + { + // Load the needed script. + $document = Factory::getApplication()->getDocument(); + $document->addScriptDeclaration(implode(' ',$script)); + // return the button attached to input field. + return '
    ' .$html . implode('',$button).'
    '; + } + } + return $html; + } + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name'),array('id','libraries_name'))); + $query->from($db->quoteName('#__componentbuilder_library', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->where($db->quoteName('a.target') . ' = 1'); + $query->order('a.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->libraries_name); + } + } + + return $options; + } +} diff --git a/admin/src/Field/LibrariesfiltertargetField.php b/admin/src/Field/LibrariesfiltertargetField.php new file mode 100644 index 000000000..318207c9a --- /dev/null +++ b/admin/src/Field/LibrariesfiltertargetField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Librariesfiltertarget Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class LibrariesfiltertargetField extends ListField +{ + /** + * The librariesfiltertarget field type. + * + * @var string + */ + public $type = 'Librariesfiltertarget'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('target')); + $query->from($db->quoteName('#__componentbuilder_library')); + $query->order($db->quoteName('target') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_TARGET_FOLDER') . ' -'); + + if ($_results) + { + // get librariesmodel + $_model = ComponentbuilderHelper::getModel('libraries'); + $_results = array_unique($_results); + foreach ($_results as $target) + { + // Translate the target selection + $_text = $_model->selectionTranslation($target,'target'); + // Now add the target and its text to the options array + $_filter[] = Html::_('select.option', $target, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/LibrariesfiltertypeField.php b/admin/src/Field/LibrariesfiltertypeField.php new file mode 100644 index 000000000..afb8c1b47 --- /dev/null +++ b/admin/src/Field/LibrariesfiltertypeField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Librariesfiltertype Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class LibrariesfiltertypeField extends ListField +{ + /** + * The librariesfiltertype field type. + * + * @var string + */ + public $type = 'Librariesfiltertype'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('type')); + $query->from($db->quoteName('#__componentbuilder_library')); + $query->order($db->quoteName('type') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_TYPE_BEHAVIOR') . ' -'); + + if ($_results) + { + // get librariesmodel + $_model = ComponentbuilderHelper::getModel('libraries'); + $_results = array_unique($_results); + foreach ($_results as $type) + { + // Translate the type selection + $_text = $_model->selectionTranslation($type,'type'); + // Now add the type and its text to the options array + $_filter[] = Html::_('select.option', $type, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/LibrariesxField.php b/admin/src/Field/LibrariesxField.php new file mode 100644 index 000000000..bb8f6a90c --- /dev/null +++ b/admin/src/Field/LibrariesxField.php @@ -0,0 +1,179 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Librariesx Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class LibrariesxField extends ListField +{ + /** + * The librariesx field type. + * + * @var string + */ + public $type = 'Librariesx'; + + /** + * Override to add new button + * + * @return string The field input markup. + * + * @since 3.2 + */ + protected function getInput() + { + // see if we should add buttons + $set_button = $this->getAttribute('button'); + // get html + $html = parent::getInput(); + // if true set button + if ($set_button === 'true') + { + $button = array(); + $script = array(); + $button_code_name = $this->getAttribute('name'); + // get the input from url + $app = Factory::getApplication(); + $jinput = $app->input; + // get the view name & id + $values = $jinput->getArray(array( + 'id' => 'int', + 'view' => 'word' + )); + // check if new item + $ref = ''; + $refJ = ''; + if (!is_null($values['id']) && strlen($values['view'])) + { + // only load referral if not new item. + $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; + $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; + // get the return value. + $_uri = (string) \Joomla\CMS\Uri\Uri::getInstance(); + $_return = urlencode(base64_encode($_uri)); + // load return value. + $ref .= '&return=' . $_return; + $refJ .= '&return=' . $_return; + } + // get button label + $button_label = trim($button_code_name); + $button_label = preg_replace('/_+/', ' ', $button_label); + $button_label = preg_replace('/\s+/', ' ', $button_label); + $button_label = preg_replace("/[^A-Za-z ]/", '', $button_label); + $button_label = ucfirst(strtolower($button_label)); + // get user object + $user = Factory::getApplication()->getIdentity(); + // only add if user allowed to create library + if ($user->authorise('library.create', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build Create button + $button[] = ' + '; + } + // only add if user allowed to edit library + if ($user->authorise('library.edit', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build edit button + $button[] = ''; + // build script + $script[] = " + document.addEventListener('DOMContentLoaded', function() { + document.getElementById('jform_".$button_code_name."').addEventListener('change', function(e) { + e.preventDefault(); + let ".$button_code_name."Value = this.value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + let ".$button_code_name."Value = document.getElementById('jform_".$button_code_name."').value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + function ".$button_code_name."Button(value) { + var createButton = document.getElementById('".$button_code_name."Create'); + var editButton = document.getElementById('".$button_code_name."Edit'); + if (value > 0) { + // hide the create button + createButton.style.display = 'none'; + // show edit button + editButton.style.display = 'block'; + let url = 'index.php?option=com_componentbuilder&view=libraries&task=library.edit&id='+value+'".$refJ."'; + editButton.setAttribute('href', url); + } else { + // show the create button + createButton.style.display = 'block'; + // hide edit button + editButton.style.display = 'none'; + } + }"; + } + // check if button was created for library field. + if (is_array($button) && count($button) > 0) + { + // Load the needed script. + $document = Factory::getApplication()->getDocument(); + $document->addScriptDeclaration(implode(' ',$script)); + // return the button attached to input field. + return '
    ' .$html . implode('',$button).'
    '; + } + } + return $html; + } + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // get the input from url + $jinput = Factory::getApplication()->input; + // get the library id + $libID = $jinput->getInt('id', 0); + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name'),array('id','libraries_name'))); + $query->from($db->quoteName('#__componentbuilder_library', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->where($db->quoteName('a.target') . ' = 1'); + if ($libID > 0) + { + $query->where($db->quoteName('a.id') . ' != ' . (int) $libID); + } + $query->order('a.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->libraries_name); + } + } + + return $options; + } +} diff --git a/admin/src/Field/LibraryField.php b/admin/src/Field/LibraryField.php new file mode 100644 index 000000000..b75a6f7a6 --- /dev/null +++ b/admin/src/Field/LibraryField.php @@ -0,0 +1,172 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Library Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class LibraryField extends ListField +{ + /** + * The library field type. + * + * @var string + */ + public $type = 'Library'; + + /** + * Override to add new button + * + * @return string The field input markup. + * + * @since 3.2 + */ + protected function getInput() + { + // see if we should add buttons + $set_button = $this->getAttribute('button'); + // get html + $html = parent::getInput(); + // if true set button + if ($set_button === 'true') + { + $button = array(); + $script = array(); + $button_code_name = $this->getAttribute('name'); + // get the input from url + $app = Factory::getApplication(); + $jinput = $app->input; + // get the view name & id + $values = $jinput->getArray(array( + 'id' => 'int', + 'view' => 'word' + )); + // check if new item + $ref = ''; + $refJ = ''; + if (!is_null($values['id']) && strlen($values['view'])) + { + // only load referral if not new item. + $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; + $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; + // get the return value. + $_uri = (string) \Joomla\CMS\Uri\Uri::getInstance(); + $_return = urlencode(base64_encode($_uri)); + // load return value. + $ref .= '&return=' . $_return; + $refJ .= '&return=' . $_return; + } + // get button label + $button_label = trim($button_code_name); + $button_label = preg_replace('/_+/', ' ', $button_label); + $button_label = preg_replace('/\s+/', ' ', $button_label); + $button_label = preg_replace("/[^A-Za-z ]/", '', $button_label); + $button_label = ucfirst(strtolower($button_label)); + // get user object + $user = Factory::getApplication()->getIdentity(); + // only add if user allowed to create library + if ($user->authorise('library.create', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build Create button + $button[] = ' + '; + } + // only add if user allowed to edit library + if ($user->authorise('library.edit', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build edit button + $button[] = ''; + // build script + $script[] = " + document.addEventListener('DOMContentLoaded', function() { + document.getElementById('jform_".$button_code_name."').addEventListener('change', function(e) { + e.preventDefault(); + let ".$button_code_name."Value = this.value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + let ".$button_code_name."Value = document.getElementById('jform_".$button_code_name."').value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + function ".$button_code_name."Button(value) { + var createButton = document.getElementById('".$button_code_name."Create'); + var editButton = document.getElementById('".$button_code_name."Edit'); + if (value > 0) { + // hide the create button + createButton.style.display = 'none'; + // show edit button + editButton.style.display = 'block'; + let url = 'index.php?option=com_componentbuilder&view=libraries&task=library.edit&id='+value+'".$refJ."'; + editButton.setAttribute('href', url); + } else { + // show the create button + createButton.style.display = 'block'; + // hide edit button + editButton.style.display = 'none'; + } + }"; + } + // check if button was created for library field. + if (is_array($button) && count($button) > 0) + { + // Load the needed script. + $document = Factory::getApplication()->getDocument(); + $document->addScriptDeclaration(implode(' ',$script)); + // return the button attached to input field. + return '
    ' .$html . implode('',$button).'
    '; + } + } + return $html; + } + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name'),array('id','library_name'))); + $query->from($db->quoteName('#__componentbuilder_library', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->where($db->quoteName('a.type') . ' = 1'); + $query->order('a.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select an option'); + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->library_name); + } + } + + return $options; + } +} diff --git a/admin/src/Field/LibraryfilesField.php b/admin/src/Field/LibraryfilesField.php new file mode 100644 index 000000000..0ffaa222f --- /dev/null +++ b/admin/src/Field/LibraryfilesField.php @@ -0,0 +1,64 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Libraryfiles Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class LibraryfilesField extends ListField +{ + /** + * The libraryfiles field type. + * + * @var string + */ + public $type = 'Libraryfiles'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // get the input from url + $jinput = Factory::getApplication()->input; + // get the library id + $id = $jinput->getInt('id', 0); + // get custom the files + $files = ComponentbuilderHelper::getLibraryFiles($id); + // set the default + $options[] = Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_NO_FILES_LINKED')); + // now check if there are files in the folder + if (ComponentbuilderHelper::checkArray($files)) + { + $options = array(); + foreach ($files as $file => $name) + { + $options[] = Html::_('select.option', $file, $name); + } + } + return $options; + } +} diff --git a/admin/src/Field/LibraryreadonlyField.php b/admin/src/Field/LibraryreadonlyField.php new file mode 100644 index 000000000..a74166c28 --- /dev/null +++ b/admin/src/Field/LibraryreadonlyField.php @@ -0,0 +1,63 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Libraryreadonly Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class LibraryreadonlyField extends ListField +{ + /** + * The libraryreadonly field type. + * + * @var string + */ + public $type = 'Libraryreadonly'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name'),array('id','library_name'))); + $query->from($db->quoteName('#__componentbuilder_library', 'a')); + $query->order('a.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select an option'); + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->library_name); + } + } + return $options; + } +} diff --git a/admin/src/Field/ListfieldsField.php b/admin/src/Field/ListfieldsField.php new file mode 100644 index 000000000..a64f00958 --- /dev/null +++ b/admin/src/Field/ListfieldsField.php @@ -0,0 +1,122 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Listfields Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class ListfieldsField extends ListField +{ + /** + * The listfields field type. + * + * @var string + */ + public $type = 'Listfields'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // load the db opbject + $db = Factory::getDBO(); + // get the input from url + $jinput = Factory::getApplication()->input; + // get the id + $ID = $jinput->getInt('id', 0); + // rest the fields ids + $fieldIds = array(); + if (is_numeric($ID) && $ID >= 1) + { + // get the admin view ID + $adminView = ComponentbuilderHelper::getVar('admin_fields_relations', (int) $ID, 'id', 'admin_view'); + } + else + { + // get the admin view ID + $adminView = $jinput->getInt('refid', 0); + } + // make sure we have the admin view ID + if (is_numeric($adminView) && $adminView >= 1) + { + // get all the fields linked to the admin view + if ($addFields = ComponentbuilderHelper::getVar('admin_fields', (int) $adminView, 'admin_view', 'addfields')) + { + if (ComponentbuilderHelper::checkJson($addFields)) + { + $addFields = json_decode($addFields, true); + if (ComponentbuilderHelper::checkArray($addFields)) + { + foreach($addFields as $addField) + { + if (isset($addField['field']) && isset($addField['list']) && $addField['list'] == 1) + { + $fieldIds[] = (int) $addField['field']; + } + } + } + } + } + // filter by fields linked + if (ComponentbuilderHelper::checkArray($fieldIds)) + { + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name', 'a.xml', 'b.name'),array('id','name', 'xml', 'type'))); + $query->from($db->quoteName('#__componentbuilder_field', 'a')); + $query->join('LEFT', '#__componentbuilder_fieldtype AS b ON b.id = a.fieldtype'); + $query->where($db->quoteName('a.published') . ' >= 1'); + // only load these fields + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $fieldIds) . ')'); + $query->order('a.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_SELECT_AN_OPTION')); + foreach($items as $item) + { + // get the field name (TODO this could slow down the system so we will need to improve on this) + if (isset($item->xml) && ComponentbuilderHelper::checkJson($item->xml)) + { + $field_xml = json_decode($item->xml); + $field_name = ComponentbuilderHelper::getBetween($field_xml,'name="','"'); + $field_name = ComponentbuilderHelper::safeFieldName($field_name); + $options[] = Html::_('select.option', $item->id, $item->name . ' [ ' . $field_name . ' - ' . $item->type . ' ]'); + } + else + { + $options[] = Html::_('select.option', $item->id, $item->name . ' [ empty - ' . $item->type . ' ]'); + } + } + } + return $options; + } + } + return false; + } +} diff --git a/admin/src/Field/MaingetsField.php b/admin/src/Field/MaingetsField.php new file mode 100644 index 000000000..5254aa53a --- /dev/null +++ b/admin/src/Field/MaingetsField.php @@ -0,0 +1,172 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Maingets Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class MaingetsField extends ListField +{ + /** + * The maingets field type. + * + * @var string + */ + public $type = 'Maingets'; + + /** + * Override to add new button + * + * @return string The field input markup. + * + * @since 3.2 + */ + protected function getInput() + { + // see if we should add buttons + $set_button = $this->getAttribute('button'); + // get html + $html = parent::getInput(); + // if true set button + if ($set_button === 'true') + { + $button = array(); + $script = array(); + $button_code_name = $this->getAttribute('name'); + // get the input from url + $app = Factory::getApplication(); + $jinput = $app->input; + // get the view name & id + $values = $jinput->getArray(array( + 'id' => 'int', + 'view' => 'word' + )); + // check if new item + $ref = ''; + $refJ = ''; + if (!is_null($values['id']) && strlen($values['view'])) + { + // only load referral if not new item. + $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; + $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; + // get the return value. + $_uri = (string) \Joomla\CMS\Uri\Uri::getInstance(); + $_return = urlencode(base64_encode($_uri)); + // load return value. + $ref .= '&return=' . $_return; + $refJ .= '&return=' . $_return; + } + // get button label + $button_label = trim($button_code_name); + $button_label = preg_replace('/_+/', ' ', $button_label); + $button_label = preg_replace('/\s+/', ' ', $button_label); + $button_label = preg_replace("/[^A-Za-z ]/", '', $button_label); + $button_label = ucfirst(strtolower($button_label)); + // get user object + $user = Factory::getApplication()->getIdentity(); + // only add if user allowed to create dynamic_get + if ($user->authorise('dynamic_get.create', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build Create button + $button[] = ' + '; + } + // only add if user allowed to edit dynamic_get + if ($user->authorise('dynamic_get.edit', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build edit button + $button[] = ''; + // build script + $script[] = " + document.addEventListener('DOMContentLoaded', function() { + document.getElementById('jform_".$button_code_name."').addEventListener('change', function(e) { + e.preventDefault(); + let ".$button_code_name."Value = this.value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + let ".$button_code_name."Value = document.getElementById('jform_".$button_code_name."').value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + function ".$button_code_name."Button(value) { + var createButton = document.getElementById('".$button_code_name."Create'); + var editButton = document.getElementById('".$button_code_name."Edit'); + if (value > 0) { + // hide the create button + createButton.style.display = 'none'; + // show edit button + editButton.style.display = 'block'; + let url = 'index.php?option=com_componentbuilder&view=dynamic_gets&task=dynamic_get.edit&id='+value+'".$refJ."'; + editButton.setAttribute('href', url); + } else { + // show the create button + createButton.style.display = 'block'; + // hide edit button + editButton.style.display = 'none'; + } + }"; + } + // check if button was created for dynamic_get field. + if (is_array($button) && count($button) > 0) + { + // Load the needed script. + $document = Factory::getApplication()->getDocument(); + $document->addScriptDeclaration(implode(' ',$script)); + // return the button attached to input field. + return '
    ' .$html . implode('',$button).'
    '; + } + } + return $html; + } + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name','a.gettype'),array('id','main_get_name','type'))); + $query->from($db->quoteName('#__componentbuilder_dynamic_get', 'a')); + $query->where($db->quoteName('a.published') . ' = 1'); + $query->where('( '.$db->quoteName('a.gettype') . ' = 1 OR ' . $db->quoteName('a.gettype') . ' = 2 )'); + $query->order('a.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $model = ComponentbuilderHelper::getModel('dynamic_gets'); + foreach($items as $item) + { + $type = $model->selectionTranslation($item->type,'gettype'); + $options[] = Html::_('select.option', $item->id, $item->main_get_name . ' (' . Text::_($type) . ')' ); + } + } + return $options; + } +} diff --git a/admin/src/Field/MatchfieldField.php b/admin/src/Field/MatchfieldField.php new file mode 100644 index 000000000..3ced3487e --- /dev/null +++ b/admin/src/Field/MatchfieldField.php @@ -0,0 +1,110 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Matchfield Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class MatchfieldField extends ListField +{ + /** + * The matchfield field type. + * + * @var string + */ + public $type = 'Matchfield'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // load the db opbject + $db = Factory::getDBO(); + // get the input from url + $jinput = Factory::getApplication()->input; + // get the id + $ID = $jinput->getInt('id', 0); + // rest the fields ids + $fieldIds = array(); + if (is_numeric($ID) && $ID >= 1) + { + // get the admin view ID + $adminView = ComponentbuilderHelper::getVar('admin_fields_conditions', (int) $ID, 'id', 'admin_view'); + } + else + { + // get the admin view ID + $adminView = $jinput->getInt('refid', 0); + } + if (is_numeric($adminView) && $adminView >= 1) + { + // get all the fields linked to the admin view + if ($addFields = ComponentbuilderHelper::getVar('admin_fields', (int) $adminView, 'admin_view', 'addfields')) + { + if (ComponentbuilderHelper::checkJson($addFields)) + { + $addFields = json_decode($addFields, true); + if (ComponentbuilderHelper::checkArray($addFields)) + { + foreach($addFields as $addField) + { + if (isset($addField['field'])) + { + $fieldIds[] = (int) $addField['field']; + } + } + } + } + } + } + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name','t.name'),array('id','name','type'))); + $query->from($db->quoteName('#__componentbuilder_field', 'a')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_fieldtype', 't') . ' ON (' . $db->quoteName('a.fieldtype') . ' = ' . $db->quoteName('t.id') . ')'); + $query->where($db->quoteName('a.published') . ' >= 1'); + // filter by fields linked + if (ComponentbuilderHelper::checkArray($fieldIds)) + { + // only load these fields + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $fieldIds) . ')'); + } + $query->order('a.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select an option'); + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->name . ' [' . $item->type . ']'); + } + } + + return $options; + } +} diff --git a/admin/src/Field/NamespacesField.php b/admin/src/Field/NamespacesField.php new file mode 100644 index 000000000..bc7bca1ec --- /dev/null +++ b/admin/src/Field/NamespacesField.php @@ -0,0 +1,96 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Namespaces Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class NamespacesField extends ListField +{ + /** + * The namespaces field type. + * + * @var string + */ + public $type = 'Namespaces'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get the user object. + $user = Factory::getApplication()->getIdentity(); + // Get the databse object. + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.guid','a.name','a.namespace','a.type','a.power_version'),array('guid','use_name','namespace','type','version'))); + $query->from($db->quoteName('#__componentbuilder_power', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->order('a.name ASC'); + $query->order('a.type ASC'); + // Implement View Level Access (if set in table) + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $columns = $db->getTableColumns('#__componentbuilder_power'); + if(isset($columns['access'])) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + } + // get the input + $jinput = Factory::getApplication()->input; + // get the id + $power_id = $jinput->getInt('id', 0); + // if we have an id we remove all classes of the same namespace and name + if ($power_id > 0 && ($exclude_powers = ComponentbuilderHelper::excludePowers($power_id)) !== false) + { + $query->where('a.id NOT IN (' . implode(',', $exclude_powers) . ')'); + } + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + // if none was found, we add this to set an alternative to set custom + if (!$items) + { + $options[] = Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_NONE_FOUND')); + } + if ($items) + { + if ($this->multiple === false) + { + $options[] = Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_SELECT_AN_OPTION')); + } + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->guid, str_replace('.','\\', $item->namespace) . ' [' . $item->use_name . '] (v' . $item->version . ' - ' . $item->type . ')'); + } + } + return $options; + + } +} diff --git a/admin/src/Field/PluginsclassmethodsField.php b/admin/src/Field/PluginsclassmethodsField.php new file mode 100644 index 000000000..90416ed25 --- /dev/null +++ b/admin/src/Field/PluginsclassmethodsField.php @@ -0,0 +1,88 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Pluginsclassmethods Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class PluginsclassmethodsField extends ListField +{ + /** + * The pluginsclassmethods field type. + * + * @var string + */ + public $type = 'Pluginsclassmethods'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + +// Get the user object. + $user = Factory::getApplication()->getIdentity(); + // Get the databse object. + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name','a.visibility'),array('id','method_name','visibility'))); + $query->from($db->quoteName('#__componentbuilder_class_method', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->where($db->quoteName('a.extension_type') . ' = ' . $db->quote('plugins')); + $query->order('a.name ASC'); + // Implement View Level Access (if set in table) + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $columns = $db->getTableColumns('#__componentbuilder_class_method'); + if(isset($columns['access'])) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + } + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select a method'); + foreach($items as $item) + { + // we are using this code in more then one field JCB custom_code + if ('method' === 'method') + { + $select = $item->visibility . ' function ' . $item->method_name . '()'; + } + else + { + $select = $item->visibility . ' $' . $item->method_name; + } + $options[] = Html::_('select.option', $item->id, $select); + } + } + return $options; + } +} diff --git a/admin/src/Field/PluginsclasspropertiesField.php b/admin/src/Field/PluginsclasspropertiesField.php new file mode 100644 index 000000000..8d87c0861 --- /dev/null +++ b/admin/src/Field/PluginsclasspropertiesField.php @@ -0,0 +1,88 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Pluginsclassproperties Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class PluginsclasspropertiesField extends ListField +{ + /** + * The pluginsclassproperties field type. + * + * @var string + */ + public $type = 'Pluginsclassproperties'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + +// Get the user object. + $user = Factory::getApplication()->getIdentity(); + // Get the databse object. + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name','a.visibility'),array('id','property_name','visibility'))); + $query->from($db->quoteName('#__componentbuilder_class_property', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->where($db->quoteName('a.extension_type') . ' = ' . $db->quote('plugins')); + $query->order('a.name ASC'); + // Implement View Level Access (if set in table) + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $columns = $db->getTableColumns('#__componentbuilder_class_property'); + if(isset($columns['access'])) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + } + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select a property'); + foreach($items as $item) + { + // we are using this code in more then one field JCB custom_code + if ('method' === 'property') + { + $select = $item->visibility . ' function ' . $item->property_name . '()'; + } + else + { + $select = $item->visibility . ' $' . $item->property_name; + } + $options[] = Html::_('select.option', $item->id, $select); + } + } + return $options; + } +} diff --git a/admin/src/Field/PowersclassmethodsField.php b/admin/src/Field/PowersclassmethodsField.php new file mode 100644 index 000000000..f1c6b90f4 --- /dev/null +++ b/admin/src/Field/PowersclassmethodsField.php @@ -0,0 +1,88 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Powersclassmethods Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class PowersclassmethodsField extends ListField +{ + /** + * The powersclassmethods field type. + * + * @var string + */ + public $type = 'Powersclassmethods'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + +// Get the user object. + $user = Factory::getApplication()->getIdentity(); + // Get the databse object. + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name','a.visibility'),array('id','method_name','visibility'))); + $query->from($db->quoteName('#__componentbuilder_class_method', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->where($db->quoteName('a.extension_type') . ' = ' . $db->quote('powers')); + $query->order('a.name ASC'); + // Implement View Level Access (if set in table) + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $columns = $db->getTableColumns('#__componentbuilder_class_method'); + if(isset($columns['access'])) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + } + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select a method'); + foreach($items as $item) + { + // we are using this code in more then one field JCB custom_code + if ('method' === 'method') + { + $select = $item->visibility . ' function ' . $item->method_name . '()'; + } + else + { + $select = $item->visibility . ' $' . $item->method_name; + } + $options[] = Html::_('select.option', $item->id, $select); + } + } + return $options; + } +} diff --git a/admin/src/Field/PowersclasspropertiesField.php b/admin/src/Field/PowersclasspropertiesField.php new file mode 100644 index 000000000..ae1639b5c --- /dev/null +++ b/admin/src/Field/PowersclasspropertiesField.php @@ -0,0 +1,88 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Powersclassproperties Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class PowersclasspropertiesField extends ListField +{ + /** + * The powersclassproperties field type. + * + * @var string + */ + public $type = 'Powersclassproperties'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + +// Get the user object. + $user = Factory::getApplication()->getIdentity(); + // Get the databse object. + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name','a.visibility'),array('id','property_name','visibility'))); + $query->from($db->quoteName('#__componentbuilder_class_property', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->where($db->quoteName('a.extension_type') . ' = ' . $db->quote('powers')); + $query->order('a.name ASC'); + // Implement View Level Access (if set in table) + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $columns = $db->getTableColumns('#__componentbuilder_class_property'); + if(isset($columns['access'])) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + } + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select a property'); + foreach($items as $item) + { + // we are using this code in more then one field JCB custom_code + if ('method' === 'property') + { + $select = $item->visibility . ' function ' . $item->property_name . '()'; + } + else + { + $select = $item->visibility . ' $' . $item->property_name; + } + $options[] = Html::_('select.option', $item->id, $select); + } + } + return $options; + } +} diff --git a/admin/src/Field/PowersfilterapprovedField.php b/admin/src/Field/PowersfilterapprovedField.php new file mode 100644 index 000000000..5a6281bfa --- /dev/null +++ b/admin/src/Field/PowersfilterapprovedField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Powersfilterapproved Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class PowersfilterapprovedField extends ListField +{ + /** + * The powersfilterapproved field type. + * + * @var string + */ + public $type = 'Powersfilterapproved'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('approved')); + $query->from($db->quoteName('#__componentbuilder_power')); + $query->order($db->quoteName('approved') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_SUPER_POWER') . ' -'); + + if ($_results) + { + // get powersmodel + $_model = ComponentbuilderHelper::getModel('powers'); + $_results = array_unique($_results); + foreach ($_results as $approved) + { + // Translate the approved selection + $_text = $_model->selectionTranslation($approved,'approved'); + // Now add the approved and its text to the options array + $_filter[] = Html::_('select.option', $approved, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/PowersfiltertypeField.php b/admin/src/Field/PowersfiltertypeField.php new file mode 100644 index 000000000..683e0338a --- /dev/null +++ b/admin/src/Field/PowersfiltertypeField.php @@ -0,0 +1,77 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Powersfiltertype Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class PowersfiltertypeField extends ListField +{ + /** + * The powersfiltertype field type. + * + * @var string + */ + public $type = 'Powersfiltertype'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('type')); + $query->from($db->quoteName('#__componentbuilder_power')); + $query->order($db->quoteName('type') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + + if ($_results) + { + // get powersmodel + $_model = ComponentbuilderHelper::getModel('powers'); + $_results = array_unique($_results); + foreach ($_results as $type) + { + // Translate the type selection + $_text = $_model->selectionTranslation($type,'type'); + // Now add the type and its text to the options array + $_filter[] = Html::_('select.option', $type, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/ServersField.php b/admin/src/Field/ServersField.php new file mode 100644 index 000000000..7ccd3dbc0 --- /dev/null +++ b/admin/src/Field/ServersField.php @@ -0,0 +1,171 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Servers Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class ServersField extends ListField +{ + /** + * The servers field type. + * + * @var string + */ + public $type = 'Servers'; + + /** + * Override to add new button + * + * @return string The field input markup. + * + * @since 3.2 + */ + protected function getInput() + { + // see if we should add buttons + $set_button = $this->getAttribute('button'); + // get html + $html = parent::getInput(); + // if true set button + if ($set_button === 'true') + { + $button = array(); + $script = array(); + $button_code_name = $this->getAttribute('name'); + // get the input from url + $app = Factory::getApplication(); + $jinput = $app->input; + // get the view name & id + $values = $jinput->getArray(array( + 'id' => 'int', + 'view' => 'word' + )); + // check if new item + $ref = ''; + $refJ = ''; + if (!is_null($values['id']) && strlen($values['view'])) + { + // only load referral if not new item. + $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; + $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; + // get the return value. + $_uri = (string) \Joomla\CMS\Uri\Uri::getInstance(); + $_return = urlencode(base64_encode($_uri)); + // load return value. + $ref .= '&return=' . $_return; + $refJ .= '&return=' . $_return; + } + // get button label + $button_label = trim($button_code_name); + $button_label = preg_replace('/_+/', ' ', $button_label); + $button_label = preg_replace('/\s+/', ' ', $button_label); + $button_label = preg_replace("/[^A-Za-z ]/", '', $button_label); + $button_label = ucfirst(strtolower($button_label)); + // get user object + $user = Factory::getApplication()->getIdentity(); + // only add if user allowed to create server + if ($user->authorise('server.create', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build Create button + $button[] = ' + '; + } + // only add if user allowed to edit server + if ($user->authorise('server.edit', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build edit button + $button[] = ''; + // build script + $script[] = " + document.addEventListener('DOMContentLoaded', function() { + document.getElementById('jform_".$button_code_name."').addEventListener('change', function(e) { + e.preventDefault(); + let ".$button_code_name."Value = this.value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + let ".$button_code_name."Value = document.getElementById('jform_".$button_code_name."').value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + function ".$button_code_name."Button(value) { + var createButton = document.getElementById('".$button_code_name."Create'); + var editButton = document.getElementById('".$button_code_name."Edit'); + if (value > 0) { + // hide the create button + createButton.style.display = 'none'; + // show edit button + editButton.style.display = 'block'; + let url = 'index.php?option=com_componentbuilder&view=servers&task=server.edit&id='+value+'".$refJ."'; + editButton.setAttribute('href', url); + } else { + // show the create button + createButton.style.display = 'block'; + // hide edit button + editButton.style.display = 'none'; + } + }"; + } + // check if button was created for server field. + if (is_array($button) && count($button) > 0) + { + // Load the needed script. + $document = Factory::getApplication()->getDocument(); + $document->addScriptDeclaration(implode(' ',$script)); + // return the button attached to input field. + return '
    ' .$html . implode('',$button).'
    '; + } + } + return $html; + } + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name','a.protocol'),array('id','name', 'protocol'))); + $query->from($db->quoteName('#__componentbuilder_server', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->order('a.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select an option'); + foreach($items as $item) + { + $item->protocol = ($item->protocol == 2) ? Text::_('SFTP') : Text::_('FTP'); + $options[] = Html::_('select.option', $item->id, $item->name.' ['.$item->protocol.']'); + } + } + return $options; + } +} diff --git a/admin/src/Field/ServersfilternameField.php b/admin/src/Field/ServersfilternameField.php new file mode 100644 index 000000000..69f44e6ee --- /dev/null +++ b/admin/src/Field/ServersfilternameField.php @@ -0,0 +1,74 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Serversfiltername Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class ServersfilternameField extends ListField +{ + /** + * The serversfiltername field type. + * + * @var string + */ + public $type = 'Serversfiltername'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('name')); + $query->from($db->quoteName('#__componentbuilder_server')); + $query->order($db->quoteName('name') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_NAME') . ' -'); + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $name) + { + // Now add the name and its text to the options array + $_filter[] = Html::_('select.option', $name, $name); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/ServersfilterprotocolField.php b/admin/src/Field/ServersfilterprotocolField.php new file mode 100644 index 000000000..95c19e0e4 --- /dev/null +++ b/admin/src/Field/ServersfilterprotocolField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Serversfilterprotocol Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class ServersfilterprotocolField extends ListField +{ + /** + * The serversfilterprotocol field type. + * + * @var string + */ + public $type = 'Serversfilterprotocol'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('protocol')); + $query->from($db->quoteName('#__componentbuilder_server')); + $query->order($db->quoteName('protocol') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_PROTOCOL') . ' -'); + + if ($_results) + { + // get serversmodel + $_model = ComponentbuilderHelper::getModel('servers'); + $_results = array_unique($_results); + foreach ($_results as $protocol) + { + // Translate the protocol selection + $_text = $_model->selectionTranslation($protocol,'protocol'); + // Now add the protocol and its text to the options array + $_filter[] = Html::_('select.option', $protocol, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/SiteviewfolderlistField.php b/admin/src/Field/SiteviewfolderlistField.php new file mode 100644 index 000000000..f2f69087d --- /dev/null +++ b/admin/src/Field/SiteviewfolderlistField.php @@ -0,0 +1,69 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Siteviewfolderlist Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class SiteviewfolderlistField extends ListField +{ + /** + * The siteviewfolderlist field type. + * + * @var string + */ + public $type = 'Siteviewfolderlist'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // get custom folder files + $localfolders = []; + $localfolders[] = JPATH_SITE . '/components/com_componentbuilder/views'; + $localfolders[] = JPATH_SITE . '/components/com_componentbuilder/src/View'; + // set the default + $options = []; + // now check if there are files in the folder + foreach ($localfolders as $localfolder) + { + if (is_dir($localfolder) && $folders = \Joomla\Filesystem\Folder::folders($localfolder)) + { + if ($this->multiple === false) + { + $options[] = Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_SELECT_A_SITE_VIEW')); + } + foreach ($folders as $folder) + { + $options[] = Html::_('select.option', $folder, StringHelper::safe($folder, 'W')); + } + } + } + return $options; + } +} diff --git a/admin/src/Field/SiteviewsField.php b/admin/src/Field/SiteviewsField.php new file mode 100644 index 000000000..d87e1539d --- /dev/null +++ b/admin/src/Field/SiteviewsField.php @@ -0,0 +1,68 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Siteviews Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class SiteviewsField extends ListField +{ + /** + * The siteviews field type. + * + * @var string + */ + public $type = 'Siteviews'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get the database object. + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.system_name'),array('id','siteview_system_name'))); + $query->from($db->quoteName('#__componentbuilder_site_view', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->order('a.system_name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = []; + if ($items) + { + if ($this->multiple === false) + { + $options[] = Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_SELECT_AN_OPTION')); + } + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->siteview_system_name); + } + } + return $options; + } +} diff --git a/admin/src/Field/SiteviewsfilteraddcustombuttonField.php b/admin/src/Field/SiteviewsfilteraddcustombuttonField.php new file mode 100644 index 000000000..eb1fec3aa --- /dev/null +++ b/admin/src/Field/SiteviewsfilteraddcustombuttonField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Siteviewsfilteraddcustombutton Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class SiteviewsfilteraddcustombuttonField extends ListField +{ + /** + * The siteviewsfilteraddcustombutton field type. + * + * @var string + */ + public $type = 'Siteviewsfilteraddcustombutton'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('add_custom_button')); + $query->from($db->quoteName('#__componentbuilder_site_view')); + $query->order($db->quoteName('add_custom_button') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_ADD_CUSTOM_BUTTONS') . ' -'); + + if ($_results) + { + // get site_viewsmodel + $_model = ComponentbuilderHelper::getModel('site_views'); + $_results = array_unique($_results); + foreach ($_results as $add_custom_button) + { + // Translate the add_custom_button selection + $_text = $_model->selectionTranslation($add_custom_button,'add_custom_button'); + // Now add the add_custom_button and its text to the options array + $_filter[] = Html::_('select.option', $add_custom_button, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/SiteviewsfilteraddphpajaxField.php b/admin/src/Field/SiteviewsfilteraddphpajaxField.php new file mode 100644 index 000000000..90586d704 --- /dev/null +++ b/admin/src/Field/SiteviewsfilteraddphpajaxField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Siteviewsfilteraddphpajax Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class SiteviewsfilteraddphpajaxField extends ListField +{ + /** + * The siteviewsfilteraddphpajax field type. + * + * @var string + */ + public $type = 'Siteviewsfilteraddphpajax'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('add_php_ajax')); + $query->from($db->quoteName('#__componentbuilder_site_view')); + $query->order($db->quoteName('add_php_ajax') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_ADD_PHP_AJAX') . ' -'); + + if ($_results) + { + // get site_viewsmodel + $_model = ComponentbuilderHelper::getModel('site_views'); + $_results = array_unique($_results); + foreach ($_results as $add_php_ajax) + { + // Translate the add_php_ajax selection + $_text = $_model->selectionTranslation($add_php_ajax,'add_php_ajax'); + // Now add the add_php_ajax and its text to the options array + $_filter[] = Html::_('select.option', $add_php_ajax, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/SnippetsField.php b/admin/src/Field/SnippetsField.php new file mode 100644 index 000000000..b2719b9e4 --- /dev/null +++ b/admin/src/Field/SnippetsField.php @@ -0,0 +1,176 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Snippets Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class SnippetsField extends ListField +{ + /** + * The snippets field type. + * + * @var string + */ + public $type = 'Snippets'; + + /** + * Override to add new button + * + * @return string The field input markup. + * + * @since 3.2 + */ + protected function getInput() + { + // see if we should add buttons + $set_button = $this->getAttribute('button'); + // get html + $html = parent::getInput(); + // if true set button + if ($set_button === 'true') + { + $button = array(); + $script = array(); + $button_code_name = $this->getAttribute('name'); + // get the input from url + $app = Factory::getApplication(); + $jinput = $app->input; + // get the view name & id + $values = $jinput->getArray(array( + 'id' => 'int', + 'view' => 'word' + )); + // check if new item + $ref = ''; + $refJ = ''; + if (!is_null($values['id']) && strlen($values['view'])) + { + // only load referral if not new item. + $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; + $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; + // get the return value. + $_uri = (string) \Joomla\CMS\Uri\Uri::getInstance(); + $_return = urlencode(base64_encode($_uri)); + // load return value. + $ref .= '&return=' . $_return; + $refJ .= '&return=' . $_return; + } + // get button label + $button_label = trim($button_code_name); + $button_label = preg_replace('/_+/', ' ', $button_label); + $button_label = preg_replace('/\s+/', ' ', $button_label); + $button_label = preg_replace("/[^A-Za-z ]/", '', $button_label); + $button_label = ucfirst(strtolower($button_label)); + // get user object + $user = Factory::getApplication()->getIdentity(); + // only add if user allowed to create snippet + if ($user->authorise('core.create', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build Create button + $button[] = ' + '; + } + // only add if user allowed to edit snippet + if ($user->authorise('core.edit', 'com_componentbuilder') && $app->isClient('administrator')) // TODO for now only in admin area. + { + // build edit button + $button[] = ''; + // build script + $script[] = " + document.addEventListener('DOMContentLoaded', function() { + document.getElementById('jform_".$button_code_name."').addEventListener('change', function(e) { + e.preventDefault(); + let ".$button_code_name."Value = this.value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + let ".$button_code_name."Value = document.getElementById('jform_".$button_code_name."').value; + ".$button_code_name."Button(".$button_code_name."Value); + }); + function ".$button_code_name."Button(value) { + var createButton = document.getElementById('".$button_code_name."Create'); + var editButton = document.getElementById('".$button_code_name."Edit'); + if (value > 0) { + // hide the create button + createButton.style.display = 'none'; + // show edit button + editButton.style.display = 'block'; + let url = 'index.php?option=com_componentbuilder&view=snippets&task=snippet.edit&id='+value+'".$refJ."'; + editButton.setAttribute('href', url); + } else { + // show the create button + createButton.style.display = 'block'; + // hide edit button + editButton.style.display = 'none'; + } + }"; + } + // check if button was created for snippet field. + if (is_array($button) && count($button) > 0) + { + // Load the needed script. + $document = Factory::getApplication()->getDocument(); + $document->addScriptDeclaration(implode(' ',$script)); + // return the button attached to input field. + return '
    ' .$html . implode('',$button).'
    '; + } + } + return $html; + } + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name','b.name','c.name'),array('id','snippet_name','type','library'))); + $query->from($db->quoteName('#__componentbuilder_snippet', 'a')); + // From the componentbuilder_snippet_type table. + $query->join('LEFT', $db->quoteName('#__componentbuilder_snippet_type', 'b') . ' ON (' . $db->quoteName('a.type') . ' = ' . $db->quoteName('b.id') . ')'); + // From the componentbuilder_library table. + $query->join('LEFT', $db->quoteName('#__componentbuilder_library', 'c') . ' ON (' . $db->quoteName('a.library') . ' = ' . $db->quoteName('c.id') . ')'); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->order('c.ordering ASC'); + $query->order('b.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + foreach($items as $item) + { + $lib = (isset($item->library) && ComponentbuilderHelper::checkString($item->library)) ? ' (' . $item->library . ')' :''; + $type = (isset($item->type) && ComponentbuilderHelper::checkString($item->type)) ? $item->type :Text::_('COM_COMPONENTBUILDER_NO_TYPE'); + $options[] = Html::_('select.option', $item->id, $type . ' - ' . $item->snippet_name . $lib ); + } + } + return $options; + } +} diff --git a/admin/src/Field/SnippettypeField.php b/admin/src/Field/SnippettypeField.php new file mode 100644 index 000000000..a0ff67600 --- /dev/null +++ b/admin/src/Field/SnippettypeField.php @@ -0,0 +1,64 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Snippettype Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class SnippettypeField extends ListField +{ + /** + * The snippettype field type. + * + * @var string + */ + public $type = 'Snippettype'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name'),array('id','type_name'))); + $query->from($db->quoteName('#__componentbuilder_snippet_type', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->order('a.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = Html::_('select.option', '', 'Select an option'); + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->type_name); + } + } + return $options; + } +} diff --git a/admin/src/Field/SuperpowerpathsField.php b/admin/src/Field/SuperpowerpathsField.php new file mode 100644 index 000000000..fd12a8823 --- /dev/null +++ b/admin/src/Field/SuperpowerpathsField.php @@ -0,0 +1,105 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Field\CheckboxesField; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\Component\Helper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Superpowerpaths Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class SuperpowerpathsField extends CheckboxesField +{ + /** + * The superpowerpaths field type. + * + * @var string + */ + public $type = 'Superpowerpaths'; + + // A DynamicCheckboxes@ Field + /** + * Method to get the data to be passed to the layout for rendering. + * + * @return array + * + * @since 3.5 + */ + protected function getLayoutData() + { + $data = parent::getLayoutData(); + + // True if the field has 'value' set. In other words, it has been stored, don't use the default values. + $hasValue = (isset($this->value) && !empty($this->value)); + + // If a value has been stored, use it. Otherwise, use the defaults. + $checkedOptions = $hasValue ? $this->value : $this->checkedOptions; + + // get the form options + $options = []; + + // get the component params + $params = Helper::getParams(); + $activate = $params->get('super_powers_repositories', 0); + + // set the default + $default = $params->get('super_powers_core', 'joomla/super-powers'); + + // must have one / in the path + if (strpos($default, '/') !== false) + { + $tmp = new \stdClass; + $tmp->text = $tmp->value = trim($default); + $tmp->checked = false; + $options[$tmp->value] = $tmp; + } + + if ($activate == 1) + { + $subform = $params->get($this->fieldname); + + // add the paths found in global settings + if (is_object($subform)) + { + foreach ($subform as $value) + { + if (isset($value->owner) && strlen($value->owner) > 1 && + isset($value->repo) && strlen($value->repo) > 1) + { + $tmp = new \stdClass; + $tmp->text = $tmp->value = trim($value->owner) . '/' . trim($value->repo); + $tmp->checked = false; + + $options[$tmp->value] = $tmp; + } + } + } + } + + $extraData = array( + 'checkedOptions' => is_array($checkedOptions) ? $checkedOptions : explode(',', (string) $checkedOptions), + 'hasValue' => $hasValue, + 'options' => array_values($options) + ); + + return array_merge($data, $extraData); + } +} diff --git a/admin/src/Field/TargetfieldsField.php b/admin/src/Field/TargetfieldsField.php new file mode 100644 index 000000000..8ac9ae69a --- /dev/null +++ b/admin/src/Field/TargetfieldsField.php @@ -0,0 +1,116 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Targetfields Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class TargetfieldsField extends ListField +{ + /** + * The targetfields field type. + * + * @var string + */ + public $type = 'Targetfields'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // load the db opbject + $db = Factory::getDBO(); + // get the input from url + $jinput = Factory::getApplication()->input; + // get the id + $ID = $jinput->getInt('id', 0); + // get the view name + $VIEW = $jinput->get('view', null, 'WORD'); + // rest the fields ids + $fieldIds = array(); + // if this is an actual admin view then we are done + if ('admin_view' === $VIEW && is_numeric($ID) && $ID >= 1) + { + $adminView = $ID; + } + elseif (is_numeric($ID) && $ID >= 1) + { + // get the admin view ID + $adminView = ComponentbuilderHelper::getVar('admin_fields_conditions', (int) $ID, 'id', 'admin_view'); + } + elseif ('admin_view' !== $VIEW) + { + // get the admin view ID + $adminView = $jinput->getInt('refid', 0); + } + if (isset($adminView) && is_numeric($adminView) && $adminView >= 1) + { + // get all the fields linked to the admin view + if ($addFields = ComponentbuilderHelper::getVar('admin_fields', (int) $adminView, 'admin_view', 'addfields')) + { + if (ComponentbuilderHelper::checkJson($addFields)) + { + $addFields = json_decode($addFields, true); + if (ComponentbuilderHelper::checkArray($addFields)) + { + foreach($addFields as $addField) + { + if (isset($addField['field'])) + { + $fieldIds[] = (int) $addField['field']; + } + } + } + } + } + } + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name','t.name'),array('id','name','type'))); + $query->from($db->quoteName('#__componentbuilder_field', 'a')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_fieldtype', 't') . ' ON (' . $db->quoteName('a.fieldtype') . ' = ' . $db->quoteName('t.id') . ')'); + $query->where($db->quoteName('a.published') . ' >= 1'); + // filter by fields linked + if (ComponentbuilderHelper::checkArray($fieldIds)) + { + // only load these fields + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $fieldIds) . ')'); + } + $query->order('a.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + foreach($items as $item) + { + $options[] = Html::_('select.option', $item->id, $item->name . ' [' . $item->type . ']'); + } + } + + return $options; + } +} diff --git a/admin/src/Field/TemplatesfilteraddphpviewField.php b/admin/src/Field/TemplatesfilteraddphpviewField.php new file mode 100644 index 000000000..140fbc45b --- /dev/null +++ b/admin/src/Field/TemplatesfilteraddphpviewField.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Templatesfilteraddphpview Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class TemplatesfilteraddphpviewField extends ListField +{ + /** + * The templatesfilteraddphpview field type. + * + * @var string + */ + public $type = 'Templatesfilteraddphpview'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // Get a db connection. + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('add_php_view')); + $query->from($db->quoteName('#__componentbuilder_template')); + $query->order($db->quoteName('add_php_view') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = []; + $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_COMPONENTBUILDER_FILTER_SELECT_ADD_PHP_CUSTOM_VIEW_SCRIPT') . ' -'); + + if ($_results) + { + // get templatesmodel + $_model = ComponentbuilderHelper::getModel('templates'); + $_results = array_unique($_results); + foreach ($_results as $add_php_view) + { + // Translate the add_php_view selection + $_text = $_model->selectionTranslation($add_php_view,'add_php_view'); + // Now add the add_php_view and its text to the options array + $_filter[] = Html::_('select.option', $add_php_view, Text::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/src/Field/ViewtabsField.php b/admin/src/Field/ViewtabsField.php new file mode 100644 index 000000000..40daf0173 --- /dev/null +++ b/admin/src/Field/ViewtabsField.php @@ -0,0 +1,107 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Viewtabs Form Field class for the Componentbuilder component + * + * @since 1.6 + */ +class ViewtabsField extends ListField +{ + /** + * The viewtabs field type. + * + * @var string + */ + public $type = 'Viewtabs'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of Html options. + * @since 1.6 + */ + protected function getOptions() + { + // get the input from url + $jinput = Factory::getApplication()->input; + // get the view name & id + $fieldsID = $jinput->getInt('id', 0); + $db = Factory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.addtabs'),array('id','addtabs'))); + $query->from($db->quoteName('#__componentbuilder_admin_view', 'a')); + if ($fieldsID > 0) + { + $viewName = $jinput->get('view', null, 'WORD'); + // only allow for fields and custom tabs + if ('admin_fields' !== $viewName && 'admin_custom_tabs' !== $viewName) + { + return false; + } + $query->join('LEFT', $db->quoteName('#__componentbuilder_' . $viewName, 'b') . ' ON (' . $db->quoteName('a.id') . ' = ' . $db->quoteName('b.admin_view') . ')'); + $query->where($db->quoteName('b.id') . ' = ' . (int) $fieldsID); + } + else + { + // get the refs if found + $ref = $jinput->get('ref', null, 'WORD'); + $refid = $jinput->getInt('refid', 0); + if ('admin_view' === $ref && $refid > 0) + { + $query->where($db->quoteName('a.id') . ' = ' . (int) $refid); + } + else + { + // kry maar niks + $query->where($db->quoteName('a.id') . ' = 0'); + } + } + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->order('a.addtabs ASC'); + $db->setQuery((string)$query); + $item = $db->loadObject(); + $options = array(); + if (isset($item->addtabs) && ComponentbuilderHelper::checkJson($item->addtabs)) + { + $items = json_decode($item->addtabs, true); + // check if the array has values + if (ComponentbuilderHelper::checkArray($items)) + { + $nr = 1; + foreach($items as $itemName) + { + $options[] = Html::_('select.option', $nr, $itemName['name']); + $nr++; + } + } + } + // check if any were loaded + if (!ComponentbuilderHelper::checkArray($options)) + { + $options[] = Html::_('select.option', 1, Text::_('COM_COMPONENTBUILDER_DETAILS')); + } + // add the default publish tab as an option + $options[] = Html::_('select.option', 15, Text::_('COM_COMPONENTBUILDER_PUBLISHING')); + return $options; + } +} diff --git a/admin/models/index.html b/admin/src/Field/index.html similarity index 100% rename from admin/models/index.html rename to admin/src/Field/index.html diff --git a/admin/src/Helper/ComponentbuilderEmail.php b/admin/src/Helper/ComponentbuilderEmail.php new file mode 100644 index 000000000..f1e8a0399 --- /dev/null +++ b/admin/src/Helper/ComponentbuilderEmail.php @@ -0,0 +1,470 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Helper; + +use Joomla\CMS\Factory; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Mail\Mail; +use Joomla\Registry\Registry; +use VDM\Joomla\Utilities\ArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder component email helper + * + * @since 3.0 + */ +abstract class ComponentbuilderEmail +{ + /** + * The active recipient + * + * @var activeRecipient (array) + */ + public static $active = []; + + /** + * Configuraiton object + * + * @var Registry + */ + public static ?Registry $config = null; + + /** + * Mailer object + * + * @var Mail + */ + public static ?Mail $mailer = null; + + /** + * Custom Headers + * + * @var array + */ + protected static array $header = []; + + /** + * Get a configuration object + * + */ + public static function getConfig() + { + if (!self::$config) + { + self::$config = ComponentHelper::getParams('com_componentbuilder'); + } + + return self::$config; + } + + /** + * Returns the global mailer object, only creating it if it doesn't already exist. + * + */ + public static function getMailerInstance() + { + if (!self::$mailer) + { + self::$mailer = self::createMailer(); + } + + return self::$mailer; + } + + /** + * Check that a string looks like an email address. + * @param string $address The email address to check + * @param string|callable $patternselect A selector for the validation pattern to use : + * * `auto` Pick best pattern automatically; + * * `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0, PHP >= 5.3.2, 5.2.14; + * * `pcre` Use old PCRE implementation; + * * `php` Use PHP built-in FILTER_VALIDATE_EMAIL; + * * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements. + * * `noregex` Don't use a regex: super fast, really dumb. + * Alternatively you may pass in a callable to inject your own validator, for example: + * PHPMailer::validateAddress('user@example.com', function($address) { + * return (strpos($address, '@') !== false); + * }); + * You can also set the PHPMailer::$validator static to a callable, allowing built-in methods to use your validator. + * @return boolean + * @static + * @access public + */ + public static function validateAddress($address, $patternselect = null): bool + { + return self::getMailerInstance()->validateAddress($address, $patternselect); + } + + /** + * Get a mailer object. + * + * Returns the global {@link Mail} object, only creating it if it doesn't already exist. + * + * @return Mail object + * + * @see Mail + */ + public static function getMailer(): Mail + { + if (!self::$mailer) + { + self::$mailer = self::createMailer(); + } + + $copy = clone self::$mailer; + + return $copy; + } + + /** + * Create a mailer object + * + * @return Mail object + * + * @see Mail + */ + protected static function createMailer(): Mail + { + // set component params + $conf = self::getConfig(); + + // now load the mailer + $mailer = $conf->get('mailer', 'global'); + + // Create a Mail object + $mail = Mail::getInstance(); + + // check if set to global + if ('global' == $mailer) + { + // get the global details + $globalConf = Factory::getConfig(); + + $mailer = $globalConf->get('mailer'); + $smtpauth = ($globalConf->get('smtpauth') == 0) ? null : 1; + $smtpuser = $globalConf->get('smtpuser'); + $smtppass = $globalConf->get('smtppass'); + $smtphost = $globalConf->get('smtphost'); + $smtpsecure = $globalConf->get('smtpsecure'); + $smtpport = $globalConf->get('smtpport'); + $sendmail = $globalConf->get('sendmail'); + $mailfrom = $globalConf->get('mailfrom'); + $fromname = $globalConf->get('fromname'); + $replyto = $globalConf->get('replyto'); + $replytoname = $globalConf->get('replytoname'); + } + else + { + $smtpauth = ($conf->get('smtpauth') == 0) ? null : 1; + $smtpuser = $conf->get('smtpuser'); + $smtppass = $conf->get('smtppass'); + $smtphost = $conf->get('smtphost'); + $smtpsecure = $conf->get('smtpsecure'); + $smtpport = $conf->get('smtpport'); + $sendmail = $conf->get('sendmail'); + $mailfrom = $conf->get('emailfrom'); + $fromname = $conf->get('fromname'); + $replyto = $conf->get('replyto'); + $replytoname = $conf->get('replytoname'); + } + + // Set global sender + $mail->setSender(array($mailfrom, $fromname)); + + // set the global reply-to if found + if ($replyto && $replytoname) + { + $mail->ClearReplyTos(); + $mail->addReplyTo($replyto, $replytoname); + } + + // Default mailer is to use PHP's mail function + switch ($mailer) + { + case 'smtp': + // set the SMTP option + $mail->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport); + break; + + case 'sendmail': + // set the sendmail option + $mail->useSendmail($sendmail); + $mail->IsSendmail(); + break; + + default: + $mail->IsMail(); + break; + } + + return $mail; + } + + /** + * Set a Mail custom header. + * + * @return void + */ + public static function setHeader($target, $value) + { + // set the header + self::$header[$target] = $value; + } + + /** + * Send an email + * + * @return bool on success + * + */ + public static function send($recipient, $subject, $body, $textonly, $mode = 0, $bounce_email = null, $idsession = null, $mailreply = null, $replyname = null , $mailfrom = null, $fromname = null, $cc = null, $bcc = null, $attachment = null, $embeded = null , $embeds = null) + { + // Get a Mail instance + $mail = self::getMailer(); + + // set component params + $conf = self::getConfig(); + + // set if we have override + if ($mailfrom && $fromname) + { + $mail->setSender(array($mailfrom, $fromname)); + } + + // load the bounce email as sender if set + if (!is_null($bounce_email)) + { + $mail->Sender = $bounce_email; + } + + // Add tag to email to identify it + if (!is_null($idsession)) + { + $mail->addCustomHeader('X-VDMmethodID:'.$idsession); + } + + // set headers if found + if (isset(self::$header) && is_array(self::$header) && count((array)self::$header) > 0) + { + foreach (self::$header as $_target => $_value) + { + $mail->addCustomHeader($_target.':'.$_value); + } + } + + // set the subject & Body + $mail->setSubject($subject); + $mail->setBody($body); + + // Are we sending the email as HTML? + if ($mode) + { + $mail->IsHTML(true); + $mail->AltBody = $textonly; + } + + //embed images + if ($embeded) + { + if(ArrayHelper::check($embeds)) + { + foreach($embeds as $embed) + { + $mail->AddEmbeddedImage($embed->Path,$embed->FileName); + } + } + } + + $mail->addRecipient($recipient); + $mail->addCC($cc); + $mail->addBCC($bcc); + $mail->addAttachment($attachment); + + // Take care of reply email addresses + if (is_array($mailreply)) + { + $mail->ClearReplyTos(); + $numReplyTo = count((array)$mailreply); + for ($i=0; $i < $numReplyTo; $i++) + { + $mail->addReplyTo($mailreply[$i], $replyname[$i]); + } + } + elseif (!empty($mailreply)) + { + $mail->ClearReplyTos(); + $mail->addReplyTo($mailreply, $replyname); + } + + // check if we can add the DKIM to email + if ($conf->get('enable_dkim')) + { + if (!empty($conf->get('dkim_domain')) && !empty($conf->get('dkim_selector')) && !empty($conf->get('dkim_private')) && !empty($conf->get('dkim_public'))) + { + $mail->DKIM_domain = $conf->get('dkim_domain'); + $mail->DKIM_selector = $conf->get('dkim_selector'); + $mail->DKIM_identity = $conf->get('dkim_identity'); + $mail->DKIM_passphrase = $conf->get('dkim_passphrase'); + + $tmp = tempnam(sys_get_temp_dir(), 'VDM'); + $h = fopen($tmp, 'w'); + fwrite($h, $conf->get('dkim_private')); + fclose($h); + $mail->DKIM_private = $tmp; + } + } + + $sendmail = $mail->Send(); + + if ($conf->get('enable_dkim') && !empty($conf->get('dkim_domain')) && !empty($conf->get('dkim_selector')) && !empty($conf->get('dkim_private')) && !empty($conf->get('dkim_public'))) + { + @unlink($tmp); + } + + if (method_exists('ComponentbuilderHelper','storeMessage')) + { + // if we have active recipient details + if (isset(self::$active[$recipient])) + { + // store the massage if the method is set + ComponentbuilderHelper::storeMessage($sendmail, self::$active[$recipient], $subject, $body, $textonly, $mode, 'email'); + // clear memory + unset(self::$active[$recipient]); + } + else + { + // store the massage if the method is set + ComponentbuilderHelper::storeMessage($sendmail, $recipient, $subject, $body, $textonly, $mode, 'email'); + } + } + + return $sendmail; + } + + /** + * Set html text (in a row) and subject (as title) to a email table. + * do not use

    instead use
    + * in your html that you pass to this method + * since it is a table row it does not + * work well with paragraphs + * + * @return string on success + * + */ + public static function setBasicBody($html, $subject) + { + $body = []; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = "" . $subject . ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = $html; + $body[] = ""; + $body[] = ""; + + return implode("\n", $body); + } + + /** + * Set html text (in a row) and subject (as title) to a email table. + * do not use

    instead use
    + * in your html that you pass to this method + * since it is a table row it does not + * work well with paragraphs + * + * @return string on success + * + */ + public static function setTableBody($html, $subject) + { + $body = []; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = "" . $subject . ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = "\n"; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = "
    "; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = "
    "; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = ""; + $body[] = "
    "; + $body[] = $html; + $body[] = "
    "; + $body[] = ""; + $body[] = "
    "; + $body[] = ""; + $body[] = "
    "; + $body[] = ""; + $body[] = ""; + $body[] = ""; + + return implode("\n", $body); + } +} diff --git a/admin/src/Helper/ComponentbuilderHelper.php b/admin/src/Helper/ComponentbuilderHelper.php new file mode 100644 index 000000000..c639613e9 --- /dev/null +++ b/admin/src/Helper/ComponentbuilderHelper.php @@ -0,0 +1,7372 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Helper; + + + +// add the autoloader for the composer classes +$composer_autoloader = JPATH_LIBRARIES . '/phpseclib3/vendor/autoload.php'; +if (file_exists($composer_autoloader)) +{ + require_once $composer_autoloader; +} + +// register additional namespace +\spl_autoload_register(function ($class) { + // project-specific base directories and namespace prefix + $search = [ + 'libraries/jcb_powers/VDM.Joomla.Openai' => 'VDM\\Joomla\\Openai', + 'libraries/jcb_powers/VDM.Joomla.Gitea' => 'VDM\\Joomla\\Gitea', + 'libraries/jcb_powers/VDM.Joomla.FOF' => 'VDM\\Joomla\\FOF', + 'libraries/jcb_powers/VDM.Joomla' => 'VDM\\Joomla', + 'libraries/jcb_powers/VDM.Minify' => 'VDM\\Minify', + 'libraries/jcb_powers/VDM.Psr' => 'VDM\\Psr' + ]; + // Start the search and load if found + $found = false; + $found_base_dir = ""; + $found_len = 0; + foreach ($search as $base_dir => $prefix) + { + // does the class use the namespace prefix? + $len = strlen($prefix); + if (strncmp($prefix, $class, $len) === 0) + { + // we have a match so load the values + $found = true; + $found_base_dir = $base_dir; + $found_len = $len; + // done here + break; + } + } + // check if we found a match + if (!$found) + { + // not found so move to the next registered autoloader + return; + } + // get the relative class name + $relative_class = substr($class, $found_len); + // replace the namespace prefix with the base directory, replace namespace + // separators with directory separators in the relative class name, append + // with .php + $file = JPATH_ROOT . '/' . $found_base_dir . '/src' . str_replace('\\', '/', $relative_class) . '.php'; + // if the file exists, require it + if (file_exists($file)) + { + require $file; + } +}); + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Access\Access; +use Joomla\CMS\Access\Rules as AccessRules; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Language\Language; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\CMS\Object\CMSObject; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Version; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use PhpOffice\PhpSpreadsheet\IOFactory; +use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use Joomla\Archive\Archive; +use Joomla\CMS\Filesystem\Folder; +use Joomla\CMS\Filesystem\Path; +use VDM\Joomla\Openai\Factory as OpenaiFactory; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\FileHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\FieldHelper; +use VDM\Joomla\Componentbuilder\Compiler\Factory as CompilerFactory; +use VDM\Joomla\Utilities\Base64Helper; +use VDM\Joomla\FOF\Encrypt\AES; +use VDM\Joomla\Utilities\String\ClassfunctionHelper; +use VDM\Joomla\Utilities\String\FieldHelper as StringFieldHelper; +use VDM\Joomla\Utilities\String\TypeHelper; +use VDM\Joomla\Utilities\String\NamespaceHelper; +use VDM\Joomla\Utilities\MathHelper; +use VDM\Joomla\Utilities\String\PluginHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\Component\Helper; +use VDM\Joomla\Utilities\FormHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder component helper. + * + * @since 3.0 + */ +abstract class ComponentbuilderHelper +{ + /** + * Composer Switch + * + * @var array + */ + protected static $composer = []; + + /** + * The Main Active Language + * + * @var string + */ + public static $langTag; + + /** + * The Global Admin Event Method. + **/ + public static function globalEvent($document) + { + // the Session keeps track of all data related to the current session of this user + self::loadSession(); + } + + + /** + * Just to Add the OPEN AI api to JCB (soon) + * OpenaiFactory + **/ + + /** + * Locked Libraries (we can not have these change) + **/ + public static $libraryNames = array(1 => 'No Library', 2 => 'Bootstrap v4', 3 => 'Uikit v3', 4 => 'Uikit v2', 5 => 'FooTable v2', 6 => 'FooTable v3'); + + /** + * Array of php fields Allowed (16) + **/ + public static $phpFieldArray = array('', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'x', 'HEADER'); + + /** + * The global params + **/ + protected static $params = false; + + /** + * The global updater + **/ + protected static $globalUpdater = array(); + + /** + * The local company details + **/ + protected static $localCompany = array(); + + /** + * The excluded powers + **/ + protected static $exPowers= array(); + + /** + * The snippet paths + **/ + public static $snippetPath = 'https://raw.githubusercontent.com/vdm-io/Joomla-Component-Builder-Snippets/master/'; + public static $snippetsPath = 'https://api.github.com/repos/vdm-io/Joomla-Component-Builder-Snippets/git/trees/master'; + + /** + * The VDM packages paths + **/ + public static $vdmGithubPackageUrl = "https://github.com/vdm-io/JCB-Packages/raw/master/"; + public static $vdmGithubPackagesUrl = "https://api.github.com/repos/vdm-io/JCB-Packages/git/trees/master"; + + /** + * The JCB packages paths + **/ + public static $jcbGithubPackageUrl = "https://github.com/vdm-io/JCB-Community-Packages/raw/master/"; + public static $jcbGithubPackagesUrl = "https://api.github.com/repos/vdm-io/JCB-Community-Packages/git/trees/master"; + + /** + * The bolerplate paths + **/ + public static $bolerplatePath = 'https://raw.githubusercontent.com/vdm-io/boilerplate/jcb/'; + public static $bolerplateAPI = 'https://api.github.com/repos/vdm-io/boilerplate/git/trees/jcb'; + + /** + * The array of constant paths + * + * JPATH_SITE is meant to represent the root path of the JSite application, + * just as JPATH_ADMINISTRATOR is mean to represent the root path of the JAdministrator application. + * + * JPATH_BASE is the root path for the current requested application.... so if you are in the administrator application: + * + * JPATH_BASE == JPATH_ADMINISTRATOR + * + * If you are in the site application: + * + * JPATH_BASE == JPATH_SITE + * + * If you are in the installation application: + * + * JPATH_BASE == JPATH_INSTALLATION. + * + * JPATH_ROOT is the root path for the Joomla install and does not depend upon any application. + * + * @var array + */ + public static $constantPaths = array( + // The path to the administrator folder. + 'JPATH_ADMINISTRATOR' => JPATH_ADMINISTRATOR, + // The path to the installed Joomla! site, or JPATH_ROOT/administrator if executed from the backend. + 'JPATH_BASE' => JPATH_BASE, + // The path to the cache folder. + 'JPATH_CACHE' => JPATH_CACHE, + // The path to the administration folder of the current component being executed. + 'JPATH_COMPONENT_ADMINISTRATOR' => JPATH_COMPONENT_ADMINISTRATOR, + // The path to the site folder of the current component being executed. + 'JPATH_COMPONENT_SITE' => JPATH_COMPONENT_SITE, + // The path to the current component being executed. + 'JPATH_COMPONENT' => JPATH_COMPONENT, + // The path to folder containing the configuration.php file. + 'JPATH_CONFIGURATION' => JPATH_CONFIGURATION, + // The path to the installation folder. + 'JPATH_INSTALLATION' => JPATH_INSTALLATION, + // The path to the libraries folder. + 'JPATH_LIBRARIES' => JPATH_LIBRARIES, + // The path to the plugins folder. + 'JPATH_PLUGINS' => JPATH_PLUGINS, + // The path to the installed Joomla! site. + 'JPATH_ROOT' => JPATH_ROOT, + // The path to the installed Joomla! site. + 'JPATH_SITE' => JPATH_SITE, + // The path to the templates folder. + 'JPATH_THEMES' => JPATH_THEMES + ); + + /** + * get the class method or property + * + * @input int The method/property ID + * @input string The target type + * + * @returns string on success + **/ + public static function getClassCode($id, $type) + { + if ('property' === $type || 'method' === $type) + { + // Get a db connection. + $db = Factory::getDbo(); + // Get user object + $user = Factory::getUser(); + // Create a new query object. + $query = $db->getQuery(true); + // get method + if ('method' === $type) + { + $query->select($db->quoteName(array('a.comment','a.name','a.visibility','a.arguments','a.code'))); + } + // get property + elseif ('property' === $type) + { + $query->select($db->quoteName(array('a.comment','a.name','a.visibility','a.default'))); + } + $query->from($db->quoteName('#__componentbuilder_class_' . $type,'a')); + $query->where($db->quoteName('a.id') . ' = ' . (int) $id); + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $columns = $db->getTableColumns('#__componentbuilder_class_' . $type); + if(isset($columns['access'])) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + } + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + // get the code + $code = $db->loadObject(); + // combine method values + $combinded = array(); + // add comment if set + if (UtilitiesStringHelper::check($code->comment)) + { + $comment = array_map('trim', (array) explode(PHP_EOL, base64_decode($code->comment))); + $combinded[] = "\t" . implode(PHP_EOL . "\t ", $comment); + } + // build method + if ('method' === $type) + { + // set the method signature + if (UtilitiesStringHelper::check($code->arguments)) + { + $combinded[] = "\t" . $code->visibility . ' function ' . $code->name . '(' . base64_decode($code->arguments) . ')'; + } + else + { + $combinded[] = "\t" . $code->visibility . ' function ' . $code->name . '()'; + } + // set the method code + $combinded[] = "\t" . "{"; + // add code if set + if (UtilitiesStringHelper::check(trim($code->code))) + { + $combinded[] = base64_decode($code->code); + } + else + { + $combinded[] = "\t\t// add your code here"; + } + $combinded[] = "\t" . "}"; + } + else + { + if (UtilitiesStringHelper::check($code->default)) + { + $code->default = base64_decode($code->default); + if (is_int($code->default)) + { + // set the class property + $combinded[] = "\t" . $code->visibility . ' $' . $code->name . ' = ' . (int) $code->default . ';'; + } + elseif (is_float($code->default)) + { + // set the class property + $combinded[] = "\t" . $code->visibility . ' $' . $code->name . ' = ' . (float) $code->default . ';'; + } + elseif (('false' === $code->default || 'true' === $code->default) + || (UtilitiesStringHelper::check($code->default) && (strpos($code->default, 'array(') !== false || strpos($code->default, '"') !== false))) + { + // set the class property + $combinded[] = "\t" . $code->visibility . ' $' . $code->name . ' = ' . $code->default . ';'; + } + elseif (UtilitiesStringHelper::check($code->default) && strpos($code->default, '"') === false) + { + // set the class property + $combinded[] = "\t" . $code->visibility . ' $' . $code->name . ' = "' . $code->default . '";'; + } + else + { + // set the class property + $combinded[] = "\t" . $code->visibility . ' $' . $code->name . ';'; + } + } + else + { + // set the class property + $combinded[] = "\t" . $code->visibility . ' $' . $code->name . ';'; + } + } + // return the code + return implode(PHP_EOL, $combinded); + } + } + return false; + } + + /** + * extract Boilerplate Class Extends + * + * @input string The class as a string + * @input string The type of class/extension + * + * @returns string on success + **/ + public static function extractBoilerplateClassExtends(&$class, $type) + { + if (($strings = GetHelper::allBetween($class, 'class ', '}')) !== false && UtilitiesArrayHelper::check($strings)) + { + foreach ($strings as $string) + { + if (($extends = GetHelper::between($string, 'extends ', '{')) !== false && UtilitiesStringHelper::check($extends)) + { + return trim($extends); + } + } + } + return false; + } + + /** + * extract Boilerplate Class Header + * + * @input string The class as a string + * @input string The class being extended + * @input string The type of class/extension + * + * @returns string on success + **/ + public static function extractBoilerplateClassHeader(&$class, $extends, $type) + { + if (($string = GetHelper::between($class, "defined('_JEXEC')", 'extends ' . $extends)) !== false && UtilitiesStringHelper::check($string)) + { + $headArray = explode(PHP_EOL, $string); + if (UtilitiesArrayHelper::check($headArray) && count($headArray) > 3) + { + // remove first since it still has the [or die;] string in it + array_shift($headArray); + // remove the last since it has the class declaration + array_pop($headArray); + // at this point we have the class comment still in as part of the header, lets remove that + $last = count($headArray); + while ($last > 0) + { + $last--; + if (isset($headArray[$last]) && strpos($headArray[$last], '*') !== false) + { + unset($headArray[$last]); + } + else + { + // moment the comment stops, we break out + $last = 0; + } + } + // make sure we only return if we have values + if (UtilitiesArrayHelper::check($headArray)) + { + return implode(PHP_EOL, $headArray); + } + } + } + return false; + } + + /** + * extract Boilerplate Class Comment + * + * @input string The class as a string + * @input string The class being extended + * @input string The type of class/extension + * + * @returns string on success + **/ + public static function extractBoilerplateClassComment(&$class, $extends, $type) + { + if (($string = GetHelper::between($class, "defined('_JEXEC')", 'extends ' . $extends)) !== false && UtilitiesStringHelper::check($string)) + { + $headArray = explode(PHP_EOL, $string); + if (UtilitiesArrayHelper::check($headArray) && count($headArray) > 3) + { + $comment = array(); + // remove the last since it has the class declaration + array_pop($headArray); + // at this point we have the class comment still in as part of the header, lets remove that + $last = count($headArray); + while ($last > 0) + { + $last--; + if (isset($headArray[$last]) && strpos($headArray[$last], '*') !== false) + { + $comment[$last] = $headArray[$last]; + } + else + { + // moment the comment stops, we break out + $last = 0; + } + } + // make sure we only return if we have values + if (UtilitiesArrayHelper::check($comment)) + { + // set the correct order + ksort($comment); + $replace = array('Foo' => '[[[Plugin_name]]]', '[PACKAGE_NAME]' => '[[[Plugin]]]', '1.0.0' => '[[[plugin.version]]]', '1.0' => '[[[plugin.version]]]'); + // now update with JCB placeholders + return str_replace(array_keys($replace), array_values($replace), implode(PHP_EOL, $comment)); + } + } + } + return false; + } + + /** + * extract Boilerplate Class Properties & Methods + * + * @input string The class as a string + * @input string The class being extended + * @input string The type of class/extension + * @input int The plugin groups + * + * @returns string on success + **/ + public static function extractBoilerplateClassPropertiesMethods(&$class, $extends, $type, $plugin_group = null) + { + $bucket = array('property' => array(), 'method' => array()); + // get the class code, and remove the head + $codeArrayTmp = explode('extends ' . $extends, $class); + // make sure we have the correct result + if (UtilitiesArrayHelper::check($codeArrayTmp) && count($codeArrayTmp) == 2) + { + // the triggers + $triggers = array('public' => 1, 'protected' => 2, 'private' => 3); + $codeArray = explode(PHP_EOL, $codeArrayTmp[1]); + unset($codeArrayTmp); + // clean the code + self::cleanBoilerplateCode($codeArray); + // temp bucket + $name = null; + $arg = null; + $target = null; + $visibility = null; + $tmp = array(); + $comment = array(); + // load method + $loadCode = function (&$bucket, &$target, &$name, &$arg, &$visibility, &$tmp, &$comment) use($type, $plugin_group){ + $_tmp = array( + 'name' => $name, + 'visibility' => $visibility, + 'extension_type' => $type + ); + // build filter + $filters = array('extension_type' => $type); + // add more data based on target + if ('method' === $target && UtilitiesArrayHelper::check($tmp)) + { + // clean the code + self::cleanBoilerplateCode($tmp); + // only load if there are values + if (UtilitiesArrayHelper::check($tmp, true)) + { + $_tmp['code'] = implode(PHP_EOL, $tmp); + } + else + { + $_tmp['code'] = ''; + } + // load arguments only if set + if (UtilitiesStringHelper::check($arg)) + { + $_tmp['arguments'] = $arg; + } + } + elseif ('property' === $target) + { + // load default only if set + if (UtilitiesStringHelper::check($arg)) + { + $_tmp['default'] = $arg; + } + } + // load comment only if set + if (UtilitiesArrayHelper::check($comment, true)) + { + $_tmp['comment'] = implode(PHP_EOL, $comment); + } + // load the group target + if ($plugin_group) + { + $_tmp['joomla_plugin_group'] = $plugin_group; + $filters['joomla_plugin_group'] = $plugin_group; + } + // load the local values + if (($locals = self::getLocalBoilerplate($name, $target, $type, $filters)) !== false) + { + foreach ($locals as $key => $value) + { + $_tmp[$key] = $value; + } + } + else + { + $_tmp['id'] = 0; + $_tmp['published'] = 1; + $_tmp['version'] = 1; + } + // store the data based on target + $bucket[$target][] = $_tmp; + }; + // now we start loading + foreach($codeArray as $line) + { + if ($visibility && $target && $name && strpos($line, '/**') !== false) + { + $loadCode($bucket, $target, $name, $arg, $visibility, $tmp, $comment); + // reset loop buckets + $name = null; + $arg = null; + $target = null; + $visibility = null; + $tmp = array(); + $comment = array(); + } + // load the comment before method/property + if (!$visibility && !$target && !$name && strpos($line, '*') !== false) + { + $comment[] = rtrim($line); + } + else + { + if (!$visibility && !$target && !$name) + { + // get the line values + $lineArray = array_values(array_map('trim', preg_split('/\s+/', trim($line)))); + // check if we are at the main line + if (isset($lineArray[0]) && isset($triggers[$lineArray[0]])) + { + $visibility = $lineArray[0]; + if (strpos($line, 'function') !== false) + { + $target = 'method'; + // get the name + $name = trim(GetHelper::between($line, 'function ', '(')); + // get the arguments + $arg = trim(GetHelper::between($line, ' ' . $name . '(', ')')); + } + else + { + $target = 'property'; + if (strpos($line, '=') !== false) + { + // get the name + $name = trim(GetHelper::between($line, '$', '=')); + // get the default + $arg = trim(GetHelper::between($line, '=', ';')); + } + else + { + // get the name + $name = trim(GetHelper::between($line, '$', ';')); + } + } + } + } + else + { + $tmp[] = rtrim($line); + } + } + } + // check if a last method is still around + if ($visibility && $target && $name) + { + $loadCode($bucket, $target, $name, $arg, $visibility, $tmp, $comment); + // reset loop buckets + $name = null; + $arg = null; + $target = null; + $visibility = null; + $tmp = array(); + $comment = array(); + } + return $bucket; + } + return false; + } + + protected static function getLocalBoilerplate($name, $table, $extension_type, $filters = array()) + { + if ('property' === $table || 'method' === $table) + { + // Get a db connection. + $db = Factory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + // get method + $query->select($db->quoteName(array('a.id','a.published','a.version'))); + $query->from($db->quoteName('#__componentbuilder_class_' . $table,'a')); + $query->where($db->quoteName('a.name') . ' = ' . $db->quote($name)); + $query->where($db->quoteName('a.extension_type') . ' = ' . $db->quote($extension_type)); + // add more filters + if (UtilitiesArrayHelper::check($filters)) + { + foreach($filters as $where => $value) + { + if (is_numeric($value)) + { + $query->where($db->quoteName('a.' . $where) . ' = ' . $value); + } + else + { + $query->where($db->quoteName('a.' . $where) . ' = ' . $db->quote($value)); + } + } + } + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + // get the code + return $db->loadAssoc(); + } + } + return false; + } + + protected static function cleanBoilerplateCode(&$code) + { + // remove the first lines until a { is found + $key = 0; + $found = false; + while (!$found) + { + if (isset($code[$key])) + { + if (strpos($code[$key], '{') !== false) + { + unset($code[$key]); + // only remove the first } found + $found = true; + } + // remove empty lines + elseif (!UtilitiesStringHelper::check(trim($code[$key]))) + { + unset($code[$key]); + } + } + // check next line + $key++; + // stop loop at line 30 (really this should never happen) + if ($key > 30) + { + $found = true; + } + } + // reset all keys + $code = array_values($code); + // remove last lines until } + $last = count($code); + while ($last > 0) + { + $last--; + if (isset($code[$last])) + { + if (strpos($code[$last], '}') !== false) + { + unset($code[$last]); + // only remove the first } found + $last = 0; + } + // remove empty lines + elseif (!UtilitiesStringHelper::check(trim($code[$last]))) + { + unset($code[$last]); + } + } + } + } + + /* + * Get the Array of Existing Validation Rule Names + * + * @return array + */ + public static function getExistingValidationRuleNames($lowercase = false) + { + // get the items + $items = self::get('_existing_validation_rules_VDM', null); + if (!$items) + { + // load the file class + jimport('joomla.filesystem.file'); + jimport('joomla.filesystem.folder'); + // set the path to the form validation rules + $path = JPATH_LIBRARIES . '/src/Form/Rule'; + // check if the path exist + if (!Folder::exists($path)) + { + return false; + } + // we must first store the current working directory + $joomla = getcwd(); + // go to that folder + chdir($path); + // load all the files in this path + $items = Folder::files('.', '\.php', true, true); + // change back to Joomla working directory + chdir($joomla); + // make sure we have an array + if (!UtilitiesArrayHelper::check($items)) + { + return false; + } + // remove the Rule.php from the name + $items = array_map( function ($name) { + return str_replace(array('./','Rule.php'), '', $name); + }, $items); + // store the names for next run + self::set('_existing_validation_rules_VDM', json_encode($items)); + } + // make sure it is no longer json + if (JsonHelper::check($items)) + { + $items = json_decode($items, true); + } + // check if the names should be all lowercase + if ($lowercase) + { + $items = array_map( function($item) { + return strtolower($item); + }, $items); + } + return $items; + } + + /** + * Get the snippet contributor details + * + * @param string $filename The file name + * @param string $type The type of file + * + * @return array On success the contributor details + * + */ + public static function getContributorDetails($filename, $type = 'snippet') + { + // start loading the contributor details + $contributor = array(); + // get the path & content + switch ($type) + { + case 'snippet': + $path = self::$snippetPath.$filename; + // get the file if available + $content = FileHelper::getContent($path); + if (JsonHelper::check($content)) + { + $content = json_decode($content, true); + } + break; + default: + // only allow types that are being targeted + return false; + break; + } + // see if we have content and all needed details + if (isset($content) && UtilitiesArrayHelper::check($content) + && isset($content['contributor_company']) + && isset($content['contributor_name']) + && isset($content['contributor_email']) + && isset($content['contributor_website'])) + { + // got the details from file + return array('contributor_company' => $content['contributor_company'] ,'contributor_name' => $content['contributor_name'], 'contributor_email' => $content['contributor_email'], 'contributor_website' => $content['contributor_website'], 'origin' => 'file'); + } + // get the global settings + if (!ObjectHelper::check(self::$params)) + { + self::$params = ComponentHelper::getParams('com_componentbuilder'); + } + // get the global company details + if (!UtilitiesArrayHelper::check(self::$localCompany)) + { + // Set the person sharing information (default VDM ;) + self::$localCompany['company'] = self::$params->get('export_company', 'Vast Development Method'); + self::$localCompany['owner'] = self::$params->get('export_owner', 'Llewellyn van der Merwe'); + self::$localCompany['email'] = self::$params->get('export_email', 'joomla@vdm.io'); + self::$localCompany['website'] = self::$params->get('export_website', 'https://www.vdm.io/'); + } + // default global + return array('contributor_company' => self::$localCompany['company'] ,'contributor_name' => self::$localCompany['owner'], 'contributor_email' => self::$localCompany['email'], 'contributor_website' => self::$localCompany['website'], 'origin' => 'global'); + } + + /** + * Get the library files + * + * @param int $id The library id to target + * + * @return array On success the array of files that belong to this library + * + */ + public static function getLibraryFiles($id) + { + // get the library files, folders, and urls + $files = array(); + // Get a db connection. + $db = Factory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('b.name','a.addurls','a.addfolders','a.addfiles'))); + $query->from($db->quoteName('#__componentbuilder_library_files_folders_urls','a')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_library', 'b') . ' ON (' . $db->quoteName('a.library') . ' = ' . $db->quoteName('b.id') . ')'); + $query->where($db->quoteName('a.library') . ' = ' . (int) $id); + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + // prepare the files + $result = $db->loadObject(); + // first we load the URLs + if (JsonHelper::check($result->addurls)) + { + // convert to array + $result->addurls = json_decode($result->addurls, true); + // set urls + if (UtilitiesArrayHelper::check($result->addurls)) + { + // build media folder path + $mediaPath = '/media/' . strtolower( preg_replace('/\s+/', '-', UtilitiesStringHelper::safe($result->name, 'filename', ' ', false))); + // load the urls + foreach($result->addurls as $url) + { + if (isset($url['url']) && UtilitiesStringHelper::check($url['url'])) + { + // set the path if needed + if (isset($url['type']) && $url['type'] > 1) + { + $fileName = basename($url['url']); + // build sub path + if (strpos($fileName, '.js') !== false) + { + $path = '/js'; + } + elseif (strpos($fileName, '.css') !== false) + { + $path = '/css'; + } + else + { + $path = ''; + } + // set the path to library file + $url['path'] = $mediaPath . $path . '/' . $fileName; // we need this for later + } + // if local path is set, then use it first + if (isset($url['path'])) + { + // load document script + $files[md5($url['path'])] = '(' . Text::_('URL') . ') ' . basename($url['url']) . ' - ' . Text::_('COM_COMPONENTBUILDER_LOCAL'); + } + // check if link must be added + if (isset($url['url']) && ((isset($url['type']) && $url['type'] == 1) || (isset($url['type']) && $url['type'] == 3) || !isset($url['type']))) + { + // load url also if not building document + $files[md5($url['url'])] = '(' . Text::_('URL') . ') ' . basename($url['url']) . ' - ' . Text::_('COM_COMPONENTBUILDER_LINK'); + } + } + } + } + } + // load the local files + if (JsonHelper::check($result->addfiles)) + { + // convert to array + $result->addfiles = json_decode($result->addfiles, true); + // set files + if (UtilitiesArrayHelper::check($result->addfiles)) + { + foreach($result->addfiles as $file) + { + if (isset($file['file']) && isset($file['path'])) + { + $path = '/'.trim($file['path'], '/'); + // check if path has new file name (has extetion) + $pathInfo = pathinfo($path); + if (isset($pathInfo['extension']) && $pathInfo['extension']) + { + // load document script + $files[md5($path)] = '(' . Text::_('COM_COMPONENTBUILDER_FILE') . ') ' . $file['file']; + } + else + { + // load document script + $files[md5($path.'/'.trim($file['file'],'/'))] = '(' . Text::_('COM_COMPONENTBUILDER_FILE') . ') ' . $file['file']; + } + } + } + } + } + // load the files in the folder + if (JsonHelper::check($result->addfolders)) + { + // convert to array + $result->addfolders = json_decode($result->addfolders, true); + // set folder + if (UtilitiesArrayHelper::check($result->addfolders)) + { + // get the global settings + if (!ObjectHelper::check(self::$params)) + { + self::$params = ComponentHelper::getParams('com_componentbuilder'); + } + // reset bucket + $bucket = array(); + // get custom folder path + $customPath = '/'.trim(self::$params->get('custom_folder_path', JPATH_COMPONENT_ADMINISTRATOR.'/custom'), '/'); + // get all the file paths + foreach ($result->addfolders as $folder) + { + if (isset($folder['path']) && isset($folder['folder'])) + { + $_path = '/'.trim($folder['path'], '/'); + $customFolder = '/'.trim($folder['folder'], '/'); + if (isset($folder['rename']) && 1 == $folder['rename']) + { + if ($_paths = FileHelper::getPaths($customPath.$customFolder)) + { + $bucket[$_path] = $_paths; + } + } + else + { + $path = $_path.$customFolder; + if ($_paths = FileHelper::getPaths($customPath.$customFolder)) + { + $bucket[$path] = $_paths; + } + } + } + } + // now load the script + if (UtilitiesArrayHelper::check($bucket)) + { + foreach ($bucket as $root => $paths) + { + // load per path + foreach($paths as $path) + { + $files[md5($root.'/'.trim($path, '/'))] = '(' . Text::_('COM_COMPONENTBUILDER_FOLDER') . ') ' . basename($path) . ' - ' . basename($root); + } + } + } + } + } + // return files if found + if (UtilitiesArrayHelper::check($files)) + { + return $files; + } + } + return false; + } + + /** + * Fix the path to work in the JCB script <-- (main issue here) + * Since we need / slash in all paths, for the JCB script even if it is Windows + * and since MS works with both forward and back slashes + * we just convert all slashes to forward slashes + * + * THIS is just my hack (fix) if you know a better way! speak-up! + * + * @param mix $values the array of paths or the path as a string + * @param array $targets paths to target + * + * @return string + * + */ + public static function fixPath(&$values, $targets = array()) + { + // if multiple to gets searched and fixed + if (UtilitiesArrayHelper::check($values) && UtilitiesArrayHelper::check($targets)) + { + foreach ($targets as $target) + { + if (isset($values[$target]) && strpos($values[$target], '\\') !== false) + { + $values[$target] = str_replace('\\', '/', $values[$target]); + } + } + } + // if just a string + elseif (UtilitiesStringHelper::check($values) && strpos($values, '\\') !== false) + { + $values = str_replace('\\', '/', $values); + } + } + + /** + * get all component IDs + */ + public static function getComponentIDs() + { + // Get a db connection. + $db = Factory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('id'))); + $query->from($db->quoteName('#__componentbuilder_joomla_component')); + $query->where($db->quoteName('published') . ' >= 1'); // do not backup trash + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + return $db->loadColumn(); + } + return false; + } + + /** + * Autoloader + */ + public static function autoLoader($type = 'compiler') + { + // load the type classes + if ('smart' !== $type) + { + foreach (glob(JPATH_ADMINISTRATOR."/components/com_componentbuilder/helpers/".$type."/*.php") as $autoFile) + { + require_once $autoFile; + } + } + // load only if compiler + if ('compiler' === $type) + { + // import the Joomla librarys + jimport('joomla.application.component.modellist'); + } + // load only if smart + if ('smart' === $type) + { + // import the Joomla libraries + jimport('joomla.application.component.modellist'); + } + // load this for all + jimport('joomla.application'); + } + + /* + * Convert repeatable field to subform + * + * @param array $item The array to convert + * @param string $name The main field name + * + * @return array + */ + public static function convertRepeatable($item, $name) + { + // continue only if we have an array + if (UtilitiesArrayHelper::check($item)) + { + $bucket = array(); + foreach ($item as $key => $values) + { + foreach ($values as $nr => $value) + { + if (!isset($bucket[$name . $nr]) || !UtilitiesArrayHelper::check($bucket[$name . $nr])) + { + $bucket[$name . $nr] = array(); + } + $bucket[$name . $nr][$key] = $value; + } + } + return $bucket; + } + return $item; + } + + /* + * Convert repeatable field to subform + * + * @param object $item The item to update + * @param array $searcher The fields to check and update + * @param array $updater To update the local table + * + * @return void + */ + public static function convertRepeatableFields($object, $searcher, $updater = array()) + { + // update the repeatable fields + foreach ($searcher as $key => $sleutel) + { + if (isset($object->{$key})) + { + $isJson = false; + if (JsonHelper::check($object->{$key})) + { + $object->{$key} = json_decode($object->{$key}, true); + $isJson = true; + } + // check if this is old values for repeatable fields + if (UtilitiesArrayHelper::check($object->{$key}) && isset($object->{$key}[$sleutel])) + { + // load it back + $object->{$key} = self::convertRepeatable($object->{$key}, $key); + // add to global updater + if ( + UtilitiesArrayHelper::check($object->{$key}) && UtilitiesArrayHelper::check($updater) && + ( + ( isset($updater['table']) && isset($updater['val']) && isset($updater['key']) ) || + ( isset($updater['unique']) && isset($updater['unique'][$key]) && isset($updater['unique'][$key]['table']) && isset($updater['unique'][$key]['val']) && isset($updater['unique'][$key]['key']) ) + ) + ) + { + $_key = null; + $_value = null; + $_table = null; + // check if we have unique id table for this repeatable/subform field + if ( isset($updater['unique']) && isset($updater['unique'][$key]) && isset($updater['unique'][$key]['table']) && isset($updater['unique'][$key]['val']) && isset($updater['unique'][$key]['key']) ) + { + $_key = $updater['unique'][$key]['key']; + $_value = $updater['unique'][$key]['val']; + $_table = $updater['unique'][$key]['table']; + } + elseif ( isset($updater['table']) && isset($updater['val']) && isset($updater['key']) ) + { + $_key = $updater['key']; + $_value = $updater['val']; + $_table = $updater['table']; + } + // continue only if values are valid + if (UtilitiesStringHelper::check($_table) && UtilitiesStringHelper::check($_key) && $_value > 0) + { + // set target table & item + $target = trim($_table) . '.' . trim($_key) . '.' . trim($_value); + if (!isset(self::$globalUpdater[$target])) + { + self::$globalUpdater[$target] = new \stdClass; + self::$globalUpdater[$target]->{$_key} = (int) $_value; + } + // load the new subform values to global updater + self::$globalUpdater[$target]->{$key} = json_encode($object->{$key}); + } + } + } + // no set back to json if came in as json + if ($isJson && UtilitiesArrayHelper::check($object->{$key})) + { + $object->{$key} = json_encode($object->{$key}); + } + // remove if not json or array + elseif (!UtilitiesArrayHelper::check($object->{$key}) && !JsonHelper::check($object->{$key})) + { + unset($object->{$key}); + } + } + } + return $object; + } + + /** + * Run Global Updater if any are set + * + * @return void + * + */ + public static function runGlobalUpdater() + { + // check if any updates are set to run + if (UtilitiesArrayHelper::check(self::$globalUpdater)) + { + // get the database object + $db = Factory::getDbo(); + foreach (self::$globalUpdater as $tableKeyID => $object) + { + // get the table + $table = explode('.', $tableKeyID); + // update the item + $db->updateObject('#__componentbuilder_' . (string) $table[0] , $object, (string) $table[1]); + } + // rest updater + self::$globalUpdater = array(); + } + } + + /** + * Copy Any Item (only use for direct database copying) + * + * @param int $id The item to copy + * @param string $table The table and model to copy from and with + * @param array $config The values that should change + * + * @return boolean True if success + * + */ + public static function copyItem($id, $type, $config = array()) + { + // only continue if we have an id + if ((int) $id > 0) + { + // get the model + $model = self::getModel($type); + $app = Factory::getApplication(); + // get item + if ($item = $model->getItem($id)) + { + // update values that should change + if (UtilitiesArrayHelper::check($config)) + { + foreach($config as $key => $value) + { + if (isset($item->{$key})) + { + $item->{$key} = $value; + } + } + } + // clone the object + $data = array(); + foreach ($item as $key => $value) + { + $data[$key] = $value; + } + // reset some values + $data['id'] = 0; + $data['version'] = 1; + if (isset($data['tags'])) + { + $data['tags'] = null; + } + if (isset($data['associations'])) + { + $data['associations'] = array(); + } + // remove some unneeded values + unset($data['params']); + unset($data['asset_id']); + unset($data['checked_out']); + unset($data['checked_out_time']); + // Attempt to save the data. + if ($model->save($data)) + { + return true; + } + } + } + return false; + } + + /** + * the basic localkey + **/ + protected static $localkey = false; + + /** + * get the localkey + **/ + public static function getLocalKey() + { + if (!self::$localkey) + { + // get the basic key + self::$localkey = md5(self::getCryptKey('basic', 'localKey34fdWEkl')); + } + return self::$localkey; + } + + /** + * indent HTML + */ + public static function indent($html) + { + // load the class + require_once JPATH_ADMINISTRATOR.'/components/com_componentbuilder/helpers/indenter.php'; + // set new indenter + $indenter = new Indenter(); + // return indented html + return $indenter->indent($html); + } + + public static function checkFileType($file, $sufix) + { + // now check if the file ends with the sufix + return $sufix === "" || ($sufix == substr(strrchr($file, "."), -strlen($sufix))); + } + + public static function imageInfo($path, $request = 'type') + { + // set image + $image = JPATH_SITE.'/'.$path; + // check if exists + if (file_exists($image) && $result = @getimagesize($image)) + { + // return type request + switch ($request) + { + case 'width': + return $result[0]; + break; + case 'height': + return $result[1]; + break; + case 'type': + $extensions = array( + IMAGETYPE_GIF => "gif", + IMAGETYPE_JPEG => "jpg", + IMAGETYPE_PNG => "png", + IMAGETYPE_SWF => "swf", + IMAGETYPE_PSD => "psd", + IMAGETYPE_BMP => "bmp", + IMAGETYPE_TIFF_II => "tiff", + IMAGETYPE_TIFF_MM => "tiff", + IMAGETYPE_JPC => "jpc", + IMAGETYPE_JP2 => "jp2", + IMAGETYPE_JPX => "jpx", + IMAGETYPE_JB2 => "jb2", + IMAGETYPE_SWC => "swc", + IMAGETYPE_IFF => "iff", + IMAGETYPE_WBMP => "wbmp", + IMAGETYPE_XBM => "xbm", + IMAGETYPE_ICO => "ico" + ); + return $extensions[$result[2]]; + break; + case 'attr': + return $result[3]; + break; + case 'all': + default: + return $result; + break; + } + } + return false; + } + + /** + * set the session defaults if not set + **/ + protected static function setSessionDefaults() + { + // noting for now + return true; + } + + /** + * check if it is a new hash + **/ + public static function newHash($hash, $name = 'backup', $type = 'hash', $key = '', $fileType = 'txt') + { + // make sure we have a hash + if (UtilitiesStringHelper::check($hash)) + { + // first get the file path + $path_filename = FileHelper::getPath('path', $name.$type, $fileType, $key, JPATH_COMPONENT_ADMINISTRATOR); + // set as read if not already set + if ($content = FileHelper::getContent($path_filename, false)) + { + if ($hash == $content) + { + return false; + } + } + // set the hash + return FileHelper::write($path_filename, $hash); + } + return false; + } + + protected static $pkOwnerSearch = array( + 'company' => 'COM_COMPONENTBUILDER_DTCOMPANYDTDDSDD', + 'owner' => 'COM_COMPONENTBUILDER_DTOWNERDTDDSDD', + 'email' => 'COM_COMPONENTBUILDER_DTEMAILDTDDSDD', + 'website' => 'COM_COMPONENTBUILDER_DTWEBSITEDTDDSDD', + 'license' => 'COM_COMPONENTBUILDER_DTLICENSEDTDDSDD', + 'copyright' => 'COM_COMPONENTBUILDER_DTCOPYRIGHTDTDDSDD' + ); + + /** + * get the JCB package owner details display + **/ + public static function getPackageOwnerDetailsDisplay(&$info, $trust = false) + { + $hasOwner = false; + $ownerDetails = '

    '; + $ownerDetails .= '
    '; + // load the list items + foreach (self::$pkOwnerSearch as $key => $dd) + { + if ($value = self::getPackageOwnerValue($key, $info)) + { + $ownerDetails .= Text::sprintf($dd, $value); + // check if we have a owner/source name + if (('owner' === $key || 'company' === $key) && !$hasOwner) + { + $hasOwner = true; + $owner = $value; + } + } + } + $ownerDetails .= '
    '; + + // provide some details to how the user can get a key + if ($hasOwner && isset($info['getKeyFrom']['buy_link']) && UtilitiesStringHelper::check($info['getKeyFrom']['buy_link'])) + { + $ownerDetails .= '
    '; + $ownerDetails .= Text::sprintf('COM_COMPONENTBUILDER_BGET_THE_KEY_FROMB_A_SSA', 'class="btn btn-primary" href="'.$info['getKeyFrom']['buy_link'].'" target="_blank" title="get a key from '.$owner.'"', $owner); + } + // add more custom links + elseif ($hasOwner && isset($info['getKeyFrom']['buy_links']) && UtilitiesArrayHelper::check($info['getKeyFrom']['buy_links'])) + { + $buttons = array(); + foreach ($info['getKeyFrom']['buy_links'] as $keyName => $link) + { + $buttons[] = Text::sprintf('COM_COMPONENTBUILDER_BGET_THE_KEY_FROM_SB_FOR_A_SSA', $owner, 'class="btn btn-primary" href="'.$link.'" target="_blank" title="get a key from '.$owner.'"', $keyName); + } + $ownerDetails .= '
    '; + $ownerDetails .= implode('
    ', $buttons); + } + // return the owner details + if (!$hasOwner) + { + $ownerDetails = '

    ' . Text::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS_NOT_FOUND') . '

    '; + if (!$trust) + { + $ownerDetails .= '

    ' . Text::_('COM_COMPONENTBUILDER_BE_CAUTIOUS_DO_NOT_CONTINUE_UNLESS_YOU_TRUST_THE_ORIGIN_OF_THIS_PACKAGE') . '

    '; + } + } + return '
    '.$ownerDetails.'
    '; + } + + public static function getPackageOwnerValue($key, &$info) + { + $source = (isset($info['source']) && isset($info['source'][$key])) ? 'source' : ((isset($info['getKeyFrom']) && isset($info['getKeyFrom'][$key])) ? 'getKeyFrom' : false); + if ($source && UtilitiesStringHelper::check($info[$source][$key])) + { + return $info[$source][$key]; + } + return false; + } + + /** + * get the JCB package component key status + **/ + public static function getPackageComponentsKeyStatus(&$info) + { + // check the package key status + if (!isset($info['key'])) + { + if (isset($info['getKeyFrom']) && isset($info['getKeyFrom']['owner'])) + { + // this just confirms it for older packages + $info['key'] = true; + } + else + { + // this just confirms it for older packages + $info['key'] = false; + } + } + return $info['key']; + } + + protected static $compOwnerSearch = array( + 'ul' => array ( + 'companyname' => 'COM_COMPONENTBUILDER_ICOMPANYI_BSB', + 'author' => 'COM_COMPONENTBUILDER_IAUTHORI_BSB', + 'email' => 'COM_COMPONENTBUILDER_IEMAILI_BSB', + 'website' => 'COM_COMPONENTBUILDER_IWEBSITEI_BSB', + ), + 'other' => array( + 'license' => 'COM_COMPONENTBUILDER_HFOUR_CLASSNAVHEADERLICENSEHFOURPSP', + 'copyright' => 'COM_COMPONENTBUILDER_HFOUR_CLASSNAVHEADERCOPYRIGHTHFOURPSP' + ) + ); + + /** + * get the JCB package component details display + **/ + public static function getPackageComponentsDetailsDisplay(&$info) + { + // check if these components need a key + $needKey = self::getPackageComponentsKeyStatus($info); + if (isset($info['name']) && UtilitiesArrayHelper::check($info['name'])) + { + $cAmount = count((array) $info['name']); + $class2 = ($cAmount == 1) ? 'span12' : 'span6'; + $counter = 1; + $display = array(); + foreach ($info['name'] as $key => $value) + { + // set the name + $name= $value . ' v' . $info['component_version'][$key]; + if ($cAmount > 1 && $counter == 3) + { + $display[] = '
    '; + $counter = 1; + } + if ($cAmount > 1 && $counter == 1) + { + $display[] = '
    '; + } + $display[] = '
    '; + $display[] = '

    '; + $display[] = $name; + if ($needKey) + { + $display[] = ' - ' . Text::sprintf('COM_COMPONENTBUILDER_PAIDLOCKED') . ''; + } + else + { + $display[] = ' - ' . Text::sprintf('COM_COMPONENTBUILDER_FREEOPEN') . ''; + } + $display[] = '

    '; + $display[] = $info['short_description'][$key]; + $display[] = '

    '; + $display[] = '
      '; + // load the list items + foreach (self::$compOwnerSearch['ul'] as $li => $value) + { + if (isset($info[$li]) && isset($info[$li][$key])) + { + $display[] = '
    • '.Text::sprintf($value, $info[$li][$key]).'
    • '; + } + } + $display[] = '
    '; + // if we have a source link we add it + if (isset($info['joomla_source_link']) && UtilitiesArrayHelper::check($info['joomla_source_link']) && isset($info['joomla_source_link'][$key]) && UtilitiesStringHelper::check($info['joomla_source_link'][$key])) + { + $display[] = 'source code'; + } + // load other + foreach (self::$compOwnerSearch['other'] as $other => $value) + { + if (isset($info[$other]) && isset($info[$other][$key])) + { + $display[] = Text::sprintf($value, $info[$other][$key]); + } + } + $display[] = '
    '; + + $counter++; + } + // close the div if needed + if ($cAmount > 1) + { + $display[] = '
    '; + } + return implode("\n",$display); + } + return '
    '.Text::_('COM_COMPONENTBUILDER_NO_COMPONENT_DETAILS_FOUND_SO_IT_IS_NOT_SAFE_TO_CONTINUE').'
    '; + } + + /** + * get the database table columns + **/ + public static function getDbTableColumns($tableName, $as, $type) + { + // Get a db connection. + $db = Factory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__" . $tableName); + // set the type (multi or single) + $unique = ''; + if (1 == $type) + { + $unique = UtilitiesStringHelper::safe($tableName) . '_'; + } + if (UtilitiesArrayHelper::check($columns)) + { + // build the return string + $tableColumns = array(); + foreach ($columns as $column => $typeCast) + { + $tableColumns[] = $as . "." . $column . ' AS ' . $unique . $column; + } + return implode("\n", $tableColumns); + } + return false; + } + + /** + * get the view table columns + **/ + public static function getViewTableColumns($admin_view, $as, $type) + { + // Get a db connection. + $db = Factory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.addfields', 'b.name_single'))); + $query->from($db->quoteName('#__componentbuilder_admin_fields', 'a')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_admin_view', 'b') . ' ON (' . $db->quoteName('a.admin_view') . ' = ' . $db->quoteName('b.id') . ')'); + $query->where($db->quoteName('b.published') . ' = 1'); + $query->where($db->quoteName('a.admin_view') . ' = ' . (int) $admin_view); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $result = $db->loadObject(); + $tableName = ''; + if (1 == $type) + { + $tableName = UtilitiesStringHelper::safe($result->name_single) . '_'; + } + $addfields = json_decode($result->addfields, true); + if (UtilitiesArrayHelper::check($addfields)) + { + // reset all buckets + $field = array(); + $fields = array(); + // get data + foreach ($addfields as $nr => $value) + { + $tmp = self::getFieldNameAndType((int) $value['field']); + if (UtilitiesArrayHelper::check($tmp)) + { + $field[$nr] = $tmp; + } + // insure it is set to alias if needed + if (isset($value['alias']) && $value['alias'] == 1) + { + $field[$nr]['name'] = 'alias'; + } + // remove a field that is not being stored in the database + if (!isset($value['list']) || $value['list'] == 2) + { + unset($field[$nr]); + } + } + // add the basic defaults + $fields[] = $as . ".id AS " . $tableName . "id"; + $fields[] = $as . ".asset_id AS " . $tableName . "asset_id"; + // load data + foreach ($field as $n => $f) + { + if (UtilitiesArrayHelper::check($f)) + { + $fields[] = $as . "." . $f['name'] . " AS " . $tableName . $f['name']; + } + } + // add the basic defaults + $fields[] = $as . ".published AS " . $tableName . "published"; + $fields[] = $as . ".created_by AS " . $tableName . "created_by"; + $fields[] = $as . ".modified_by AS " . $tableName . "modified_by"; + $fields[] = $as . ".created AS " . $tableName . "created"; + $fields[] = $as . ".modified AS " . $tableName . "modified"; + $fields[] = $as . ".version AS " . $tableName . "version"; + $fields[] = $as . ".hits AS " . $tableName . "hits"; + if (0) // TODO access is not set here but per/view in the form linking this admin view to which these field belong to the components (boooo I know but that is the case and so we can't ever really know at this point if this view has access set) + { + $fields[] = $as . ".access AS " . $tableName . "access"; + } + $fields[] = $as . ".ordering AS " . $tableName . "ordering"; + // return the field of this view + return implode("\n", $fields); + } + } + return false; + } + + public static function getFieldNameAndType($id, $spacers = false) + { + // Get a db connection. + $db = Factory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Order it by the ordering field. + $query->select($db->quoteName(array('a.name', 'a.xml'))); + $query->select($db->quoteName(array('c.name'), array('type_name'))); + $query->from('#__componentbuilder_field AS a'); + $query->join('LEFT', $db->quoteName('#__componentbuilder_fieldtype', 'c') . ' ON (' . $db->quoteName('a.fieldtype') . ' = ' . $db->quoteName('c.id') . ')'); + $query->where($db->quoteName('a.id') . ' = '. $db->quote($id)); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + // Load the results as a list of stdClass objects (see later for more options on retrieving data). + $field = $db->loadObject(); + // load the values form params + $field->xml = json_decode($field->xml); + $field->type_name = self::safeTypeName($field->type_name); + $load = true; + // if category then name must be catid (only one per view) + if ($field->type_name === 'category') + { + $name = 'catid'; + } + // if tag is set then enable all tag options for this view (only one per view) + elseif ($field->type_name === 'tag') + { + $name = 'tags'; + } + // don't add spacers or notes + elseif (!$spacers && ($field->type_name == 'spacer' || $field->type_name == 'note')) + { + // make sure the name is unique + return false; + } + else + { + $name = self::safeFieldName(GetHelper::between($field->xml,'name="','"')); + } + + // use field core name only if not found in xml + if (!UtilitiesStringHelper::check($name)) + { + $name = self::safeFieldName($field->name); + } + return array('name' => $name, 'type' => $field->type_name); + } + return false; + } + + /** + * validate that a placeholder is unique + **/ + public static function validateUniquePlaceholder($id, $name, $bool = false) + { + // make sure no padding is set + $name = preg_replace("/[^A-Za-z0-9_]/", '', $name); + // this list may grow as we find more cases that break the compiler (just open an issue on github) + if (in_array($name, array('component', 'view', 'views'))) + { + // check if we must return boolean + if (!$bool) + { + return array ( + 'message' => Text::_('COM_COMPONENTBUILDER_SORRY_THIS_PLACEHOLDER_IS_ALREADY_IN_USE_IN_THE_COMPILER'), + 'status' => 'danger'); + } + return false; + } + // add the padding (needed) + $name = '[[[' . trim($name) . ']]]'; + if (self::placeholderIsSet($id, $name)) + { + // check if we must return boolean + if (!$bool) + { + return array ( + 'message' => Text::_('COM_COMPONENTBUILDER_SORRY_THIS_PLACEHOLDER_IS_ALREADY_IN_USE'), + 'status' => 'danger'); + } + return false; + } + // check if we must return boolean + if (!$bool) + { + return array ( + 'name' => $name, + 'message' => Text::_('COM_COMPONENTBUILDER_GREAT_THIS_PLACEHOLDER_WILL_WORK'), + 'status' => 'success'); + } + return true; + } + + /** + * search for placeholder in table + **/ + protected static function placeholderIsSet($id, $name) + { + // query the table for result array + if (($results = self::getPlaceholderTarget($id, $name)) !== false) + { + // check if we must continue the search + foreach ($results as $_id => $target) + { + if ($name === $target) + { + return true; + } + } + } + return false; + } + + /** + * get placeholder target + **/ + protected static function getPlaceholderTarget($id, $name) + { + // Get a db connection. + $db = Factory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('id', 'target'))); + $query->from($db->quoteName('#__componentbuilder_placeholder')); + $query->where($db->quoteName('target') . ' = '. $db->quote($name)); + // check if we have id + if (is_numeric($id)) + { + $query->where($db->quoteName('id') . ' <> ' . (int) $id); + } + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + return $db->loadAssocList('id', 'target'); + } + return false; + } + + /** + * Powers to exclude + **/ + public static function excludePowers($id) + { + // first check if this power set is already found + if (!isset(self::$exPowers[$id])) + { + // Get a db connection. + $db = Factory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id'))); + $query->from($db->quoteName('#__componentbuilder_power', 'a')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_power', 'b') . ' ON (' . $db->quoteName('a.name') . ' = ' . $db->quoteName('b.name') . ' AND ' . $db->quoteName('a.namespace') . ' = ' . $db->quoteName('b.namespace') . ')'); + $query->where($db->quoteName('b.id') . ' = ' . (int) $id); + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + self::$exPowers[$id] = $db->loadColumn(); + } + // all ways add itself aswell + self::$exPowers[$id][] = $id; + } + // if found return + if (isset(self::$exPowers[$id])) + { + return self::$exPowers[$id]; + } + return false; + } + /** + * The array of dynamic content + * + * @var array + */ + protected static array $dynamicContent = [ + // The banners by size (width - height) + 'banner' => [ + '728-90' => [ + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/banner/joomla-heart-wide.gif', + 'hash' => 'f857e3a38facaeac9eba3cffa912b620', + 'html' => 'Joomla! Volunteers Portal'], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/banner/JCM_2010_120x600.png', + 'hash' => '5389cf3be8569cb3f6793e8bd4013d19', + 'html' => 'Joomla! Community Magazine | Because community matters...'], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/banner/tlwebdesign_jcb_sponsor_728_90.png', + 'hash' => 'd19be1f9f5b2049ff901096aafc246be', + 'html' => 'tlwebdesign a JCB sponsor | Because community matters...'], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/banner/vdm_jcb_sponsor_728_90.gif', + 'hash' => '84478dfa0cd880395815e0ee026812a4', + 'html' => 'VDM a JCB sponsor | Because community matters...'], + [ + 'url' => 'https://cms-experts.org/images/banners/agerix/agerix-loves-jcb-728-90.gif', + 'hash' => 'b24c0726aa809cdcc04bcffe7e1e1529', + 'html' => 'Agerix a JCB sponsor | Because community matters...'] + ], + '160-600' => [ + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/banner/joomla-heart-tall.gif', + 'hash' => '9a75e4929b86c318128b53cf78251678', + 'html' => 'Joomla! Volunteers Portal'], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/banner/JCM_2010_120x600.png', + 'hash' => '5389cf3be8569cb3f6793e8bd4013d19', + 'html' => 'Joomla! Community Magazine | Because community matters...'] + ] + ], + // The build-gif by size (width - height) + 'builder-gif' => [ + // original gif ;) + '480-272' => [ + [ + 'url' => 'https://www.joomlacomponentbuilder.com/images/builder/original.gif', + 'hash' => '676e37a949add8f4573381195cd1061c', + 'html' => '' + ] + ], + // new gif artwork since 2021 + '480-540' => [ + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/1.gif', + 'hash' => 'ce6e36456fa794ba95d981547b2f54f8', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/2.gif', + 'hash' => '0a54dbc393359747e33db90cabb1e2d7', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/3.gif', + 'hash' => '4e5498713ff69a64a0a79dbf620372a3', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/4.gif', + 'hash' => '3554ffab2a6df95a116fd9f0db63925c', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/5.gif', + 'hash' => '08f0cdf188593eca65c6dafd7af27ef9', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/6.gif', + 'hash' => '103b46a7ac3fcb974e25d06f417a4e87', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/7.gif', + 'hash' => 'ffa8547099b7286f89ab7ff5a140dd90', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/8.gif', + 'hash' => '316df780f9e4ce81200a65d3c4303c41', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/9.gif', + 'hash' => '9ab6ba78b6e63a285fdef2ff5e447c93', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/10.gif', + 'hash' => 'cd9abaa1cb95f51a70916da6b70614f2', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/11.gif', + 'hash' => 'cfe53095b5249618e2348223b89262b9', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/12.gif', + 'hash' => '15a6690647d5160d67c80ce4dd1f5602', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/13.gif', + 'hash' => '2f77562e92c8a3b7c47664c98f551fe8', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/14.gif', + 'hash' => '46db15517ef5bd063be85134e1cc575d', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/15.gif', + 'hash' => 'e6c96eff157ea648ceb1583f2cc22544', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/16.gif', + 'hash' => '76010b7d1f99952eb9645df660467ae8', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/17.gif', + 'hash' => '021219ddd72d8fcfc7f80bd4a874d651', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/18.gif', + 'hash' => '383af3179d4ae27301c1292e630d7155', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/19.gif', + 'hash' => '8537e6d7be93447241b521f851e8a61d', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/20.gif', + 'hash' => '10d96f70e3d43086a925b00a7dc0022e', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/21.gif', + 'hash' => '161de9865b171b44039353b8d50491d3', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/22.gif', + 'hash' => '6a2354e43eb97d278d74bb2c12890988', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/23.gif', + 'hash' => '2cb6e2f9562a8dc8eef6d5d8d1a84f5e', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], + [ + 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/24.gif', + 'hash' => '745b3fb5e16515689132432bf02ab1b4', + 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '] + ] + ] + ]; + + /** + * get the dynamic content array size + * + * @param string $type The type of content + * @param string $size The size of the content + * + * @return int on success number of items in array type,size + * + */ + public static function getDynamicContentSize(string $type, string $size): int + { + if (isset(self::$dynamicContent[$type]) && isset(self::$dynamicContent[$type][$size]) + && ($nr = UtilitiesArrayHelper::check(self::$dynamicContent[$type][$size]))) + { + return $nr; + } + return 0; + } + + /** + * get the dynamic content + * + * @param string $type The type of content + * @param string $size The size of the content + * @param mixed $default The default to return + * @param int $try Retry tracker (when bigger then array size it stops) + * @param mixed $getter The specific getter number (not zero based) + * + * @return string on success html string + * + */ + public static function getDynamicContent(string $type, string $size, $default = '', int $try = 1, $getter = null) + { + if (($nr = self::getDynamicContentSize($type, $size)) !== 0) + { + // use specific getter + if ($getter) + { + $get = --$getter; + } + // get the random getter number + elseif ($nr > 1) + { + $get = (int) rand(0, --$nr); + } + else + { + $get = 0; + } + // get the current target if found + if (isset(self::$dynamicContent[$type][$size][$get])) + { + $target = self::$dynamicContent[$type][$size][$get]; + // set file name + $file_name = basename($target['url']); + // set the local path (in admin area so when the component uninstall these images get removed as well) + $path = JPATH_ROOT . "/administrator/components/com_componentbuilder/assets/images/$type/$file_name"; + // check if file exist or if it changed + if (($image_data = FileHelper::getContent($path, false)) === false || + md5($image_data) !== $target['hash']) + { + // since the file does not exist or has changed (so we have a new hash) + // therefore we download it to validate + if (($image_data = FileHelper::getContent($target['url'], false)) !== false && + md5($image_data) === $target['hash']) + { + // create the JCB type path if it does not exist + if (!Folder::exists(JPATH_ROOT . "/administrator/components/com_componentbuilder/assets/images/$type")) + { + Folder::create(JPATH_ROOT . "/administrator/components/com_componentbuilder/assets/images/$type"); + } + // only set the image if the data match the hash + FileHelper::write($path, $image_data); + } + // we retry array size times (unless specific getter is used) + elseif ($try <= $nr && !$getter) + { + // the first time around failed so we try again (the size of the array times) + return self::getDynamicContent($type, $size, $default, ++$try); + } + } + // return found content + return str_replace('[[[ROOT-URL]]]', Uri::root(), $target['html']); + } + } + 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 + **/ + public static $session = array(); + + /** + * the Butler Assistant + **/ + protected static $localSession = array(); + + /** + * start a session if not already set, and load with data + **/ + public static function loadSession() + { + if (!isset(self::$session) || !ObjectHelper::check(self::$session)) + { + self::$session = Factory::getSession(); + } + // set the defaults + self::setSessionDefaults(); + } + + /** + * give Session more to keep + **/ + public static function set($key, $value) + { + if (!isset(self::$session) || !ObjectHelper::check(self::$session)) + { + self::$session = Factory::getSession(); + } + // set to local memory to speed up program + self::$localSession[$key] = $value; + // load to session for later use + return self::$session->set($key, self::$localSession[$key]); + } + + /** + * get info from Session + **/ + public static function get($key, $default = null) + { + if (!isset(self::$session) || !ObjectHelper::check(self::$session)) + { + self::$session = Factory::getSession(); + } + // check if in local memory + if (!isset(self::$localSession[$key])) + { + // set to local memory to speed up program + self::$localSession[$key] = self::$session->get($key, $default); + } + return self::$localSession[$key]; + } + + + /** + * get field type properties + * + * @return array on success + * + */ + public static function getFieldTypeProperties($value, $type, $settings = array(), $xml = null, $dbDefaults = false) + { + // Get a db connection. + $db = Factory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('properties', 'short_description', 'description'))); + // load database default values + if ($dbDefaults) + { + $query->select($db->quoteName(array('datadefault', 'datadefault_other', 'datalenght', 'datalenght_other', 'datatype', 'has_defaults', 'indexes', 'null_switch', 'store'))); + } + $query->from($db->quoteName('#__componentbuilder_fieldtype')); + $query->where($db->quoteName('published') . ' = 1'); + $query->where($db->quoteName($type) . ' = '. $value); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $result = $db->loadObject(); + $properties = json_decode($result->properties, true); + $field = array( + 'subform' => array(), + 'nameListOptions' => array(), + 'php' => array(), + 'values' => " '', + 'short_description' => $result->short_description, + 'description' => $result->description); + // number pointer + $nr = 0; + // php tracker (we must try to load alteast 17 rows + $phpTracker = array(); + // force load all properties + $forceAll = false; + if ($xml && strpos($xml, '..__FORCE_LOAD_ALL_PROPERTIES__..') !== false) + { + $forceAll = true; + } + // value to check since there are false and null values even 0 in the values returned + $confirmation = '8qvZHoyuFYQqpj0YQbc6F3o5DhBlmS-_-a8pmCZfOVSfANjkmV5LG8pCdAY2JNYu6cB'; + // set the headers + $field['values_description'] .= ''; + foreach ($properties as $property) + { + $example = (isset($property['example']) && UtilitiesStringHelper::check($property['example'])) ? $property['example'] : ''; + $field['values_description'] .= ''; + // check if we should load the value + $value = FieldHelper::getValue($xml, $property['name'], $confirmation); + // check if this is a php field + $addPHP = false; + if (strpos($property['name'], 'type_php') !== false) + { + $addPHP = true; + // set the line number + $phpLine = (int) preg_replace('/[^0-9]/', '', $property['name']); + // set the key + $phpKey = trim(preg_replace('/[0-9]+/', '', $property['name']), '_'); + // start array if not already set + if (!isset($field['php'][$phpKey])) + { + $field['php'][$phpKey] = array(); + $field['php'][$phpKey]['value'] = array(); + $field['php'][$phpKey]['desc'] = $property['description']; + // start tracker + $phpTracker[$phpKey] = 1; + } + } + // was the settings for the property passed + if(UtilitiesArrayHelper::check($settings) && isset($settings[$property['name']])) + { + // add the xml values + $field['values'] .= PHP_EOL . "\t" . $property['name'] . '="'. $settings[$property['name']] . '" '; + // add the json values + if ($addPHP) + { + $field['php'][$phpKey]['value'][$phpLine] = $settings[$property['name']]; + $phpTracker[$phpKey]++; + } + else + { + $field['subform']['properties'.$nr] = array('name' => $property['name'], 'value' => $settings[$property['name']], 'desc' => $property['description']); + } + } + elseif ($forceAll || !$xml || $confirmation !== $value) + { + // add the xml values + $field['values'] .= PHP_EOL."\t" . $property['name'] . '="' . ($confirmation !== $value) ? $value : $example .'" '; + // add the json values + if ($addPHP) + { + $field['php'][$phpKey]['value'][$phpLine] = ($confirmation !== $value) ? $value : $example; + $phpTracker[$phpKey]++; + } + else + { + $field['subform']['properties' . $nr] = array('name' => $property['name'], 'value' => ($confirmation !== $value) ? $value : $example, 'desc' => $property['description']); + } + } + // add the name List Options + if (!$addPHP) + { + $field['nameListOptions'][$property['name']] = $property['name']; + } + // increment the number + $nr++; + } + // check if all php is loaded using the tracker + if (UtilitiesStringHelper::check($xml) && isset($phpTracker) && UtilitiesArrayHelper::check($phpTracker)) + { + foreach ($phpTracker as $phpKey => $start) + { + if ($start < 30) + { + // we must search for more code in the xml just incase + foreach(range(2, 30) as $t_nr) + { + $get_ = $phpKey . '_' . $t_nr; + if (!isset($field['php'][$phpKey]['value'][$t_nr]) && ($value = FieldHelper::getValue($xml, $get_, $confirmation)) !== $confirmation) + { + $field['php'][$phpKey]['value'][$t_nr] = $value; + } + } + } + } + } + $field['values'] .= PHP_EOL . "/>"; + $field['values_description'] .= '
    ' . Text::_('COM_COMPONENTBUILDER_PROPERTY') . '' . Text::_('COM_COMPONENTBUILDER_EXAMPLE') . '' . Text::_('COM_COMPONENTBUILDER_DESCRIPTION') . '
    ' . $property['name'] . '' . $example . '' . $property['description'] . '
    '; + // load the database defaults if set and wanted + if ($dbDefaults && isset($result->has_defaults) && $result->has_defaults == 1) + { + $field['database'] = array( + 'datatype' => $result->datatype, + 'datadefault' => $result->datadefault, + 'datadefault_other' => $result->datadefault_other, + 'datalenght' => $result->datalenght, + 'datalenght_other' => $result->datalenght_other, + 'indexes' => $result->indexes, + 'null_switch' => $result->null_switch, + 'store' => $result->store + ); + } + // return found field options + return $field; + } + return false; + } + + /** + * Get a field value from the XML stored string + * + * @param string $xml The xml string of the field + * @param string $get The value key to get from the string + * @param string $confirmation The value to confirm found value + * + * @return string The field value from xml + * @deprecated 3.3 Use FieldHelper::getValue($xml, $get, $confirmation); + */ + public static function getValueFromXMLstring(&$xml, &$get, $confirmation = '') + { + return FieldHelper::getValue($xml, $get, $confirmation); + } + + + /** + * get field types properties + * + * @return array on success + * + */ + public static function getFieldTypesProperties($targets = array(), $filter = array(), $exclude = array(), $type = 'id', $operator = 'IN') + { + // Get a db connection. + $db = Factory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('id','properties'))); + $query->from($db->quoteName('#__componentbuilder_fieldtype')); + $query->where($db->quoteName('published') . ' = 1'); + // make sure we have ids (or get all) + if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator) + { + $query->where($db->quoteName($type) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","',$targets) . '")'); + } + else + { + $query->where($db->quoteName($type) . ' ' . $operator . ' (' . implode(',',$targets) . ')'); + } + // Reset the query using our newly populated query object. + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $_types = array(); + $_properties = array(); + $types = $db->loadObjectList('id'); + foreach ($types as $id => $type) + { + $properties = json_decode($type->properties); + foreach ($properties as $property) + { + if (!isset($_types[$id])) + { + $_types[$id] = array(); + } + // add if no objection is found + $add = true; + // check if we have exclude + if (UtilitiesArrayHelper::check($exclude) && in_array($property->name, $exclude)) + { + continue; + } + // check if we have filter + if (UtilitiesArrayHelper::check($filter)) + { + foreach($filter as $key => $val) + { + if (!isset($property->$key) || $property->$key != $val) + { + $add = false; + } + } + } + // now add the property + if ($add) + { + $_types[$id][$property->name] = array('name' => ucfirst($property->name), 'example' => $property->example, 'description' => $property->description); + // set mandatory + if (isset($property->mandatory) && $property->mandatory == 1) + { + $_types[$id][$property->name]['mandatory'] = true; + } + else + { + $_types[$id][$property->name]['mandatory'] = false; + } + // set translatable + if (isset($property->translatable) && $property->translatable == 1) + { + $_types[$id][$property->name]['translatable'] = true; + } + else + { + $_types[$id][$property->name]['translatable'] = false; + } + $_properties[$property->name] = $_types[$id][$property->name]['name']; + } + } + } + + // return found types & properties + return array('types' => $_types, 'properties' => $_properties); + } + return false; + } + + + /** + * Remove folders with files + * + * @param string $path The path to folder to remove + * @param array|null $ignore The folders and files to ignore and not remove + * + * @return bool True if all are removed + */ + public static function removeFolder(string $path, ?array $ignore = null): bool + { + if (!Folder::exists($path)) + { + return false; + } + + $it = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS); + $files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST); + + // Prepare a base path without trailing slash for comparison + $basePath = rtrim($path, '/'); + + foreach ($files as $fileinfo) + { + $filePath = $fileinfo->getRealPath(); + + if (self::removeFolderShouldIgnore($basePath, $filePath, $ignore)) + { + continue; + } + + if ($fileinfo->isDir()) + { + Folder::delete($filePath); + } + else + { + File::delete($filePath); + } + } + + // Delete the root folder if ignore not set + if (!UtilitiesArrayHelper::check($ignore)) + { + return Folder::delete($path); + } + + return true; + } + + /** + * Check if the current path should be ignored. + * + * @param string $basePath The base directory path + * @param string $filePath The current file or directory path + * @param array|null $ignore List of items to ignore + * + * @return boolean True if the path should be ignored + * @since 3.2.0 + */ + protected static function removeFolderShouldIgnore(string $basePath, string $filePath, ?array $ignore = null): bool + { + if (!$ignore || !UtilitiesArrayHelper::check($ignore)) + { + return false; + } + + foreach ($ignore as $item) + { + if (strpos($filePath, $basePath . '/' . $item) !== false) + { + return true; + } + } + + return false; + } + + /** + * The github access token + **/ + protected static $gitHubAccessToken = ""; + + /** + * The github repo get data errors + **/ + public static $githubRepoDataErrors = array(); + + /** + * get the github repo file list + * + * @return array on success + * + */ + public static function getGithubRepoFileList($type, $target) + { + // get the repo data + if (($repoData = self::getGithubRepoData($type, $target, 'tree')) !== false) + { + return $repoData->tree; + } + return false; + } + + /** + * get the github repo file list + * + * @return array on success + * + */ + public static function getGithubRepoData($type, $url, $target = null, $return_type = 'object') + { + // always reset errors per/request + self::$githubRepoDataErrors = array(); + // get the current Packages (public) + if ('nomemory' === $type || !$repoData = self::get($type)) + { + // add the token if not already added + $_url = self::setGithubToken($url); + // check if the url exist + if (self::urlExists($_url)) + { + // get the data from github + if (($repoData = FileHelper::getContent($_url)) !== false && JsonHelper::check($repoData)) + { + $github_returned = json_decode($repoData); + if (UtilitiesStringHelper::check($target) && + ( (ObjectHelper::check($github_returned) && isset($github_returned->{$target}) && UtilitiesArrayHelper::check($github_returned->{$target})) || + (UtilitiesArrayHelper::check($github_returned) && isset($github_returned[$target]) && UtilitiesArrayHelper::check($github_returned[$target])) )) + { + if ('nomemory' !== $type) + { + // remember to set it + self::set($type, $repoData); + } + } + elseif (!UtilitiesStringHelper::check($target) && (UtilitiesArrayHelper::check($github_returned) || (ObjectHelper::check($github_returned) && !isset($github_returned->message)))) + { + if ('nomemory' !== $type) + { + // remember to set it + self::set($type, $repoData); + } + } + // check if we have error message from github + elseif (($errorMessage = self::githubErrorHandeler(array('error' => null), $github_returned, $type)) !== false) + { + if (isset($errorMessage['error']) && UtilitiesStringHelper::check($errorMessage['error'])) + { + // set the error in the application + Factory::getApplication()->enqueueMessage($errorMessage['error'], 'Error'); + // set the error also in the class encase it is and Ajax call + self::$githubRepoDataErrors[] = $errorMessage['error']; + } + return false; + } + elseif (UtilitiesStringHelper::check($target)) + { + // setup error string + $error = Text::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DID_NOT_RETURN_S_DATA', $url, $target); + // set the error in the application + Factory::getApplication()->enqueueMessage($error, 'Error'); + // set the error also in the class encase it is and Ajax call + self::$githubRepoDataErrors[] = $error; + // we are done here + return false; + } + elseif ('nomemory' !== $type) + { + // setup error string + $error = Text::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DID_NOT_RETURN_S_DATA', $url, $type); + // set the error in the application + Factory::getApplication()->enqueueMessage($error, 'Error'); + // set the error also in the class encase it is and Ajax call + self::$githubRepoDataErrors[] = $error; + // we are done here + return false; + } + else + { + // setup error string + $error = Text::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DID_NOT_RETURN_VALID_DATA', $url, $type); + // set the error in the application + Factory::getApplication()->enqueueMessage($error, 'Error'); + // set the error also in the class encase it is and Ajax call + self::$githubRepoDataErrors[] = $error; + // we are done here + return false; + } + } + else + { + // setup error string + $error = Text::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DOES_NOT_RETURN_ANY_DATA', $url); + // set the error in the application + Factory::getApplication()->enqueueMessage($error, 'Error'); + // set the error also in the class encase it is and Ajax call + self::$githubRepoDataErrors[] = $error; + // we are done here + return false; + } + } + else + { + // setup error string + $error = Text::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DOES_NOT_EXIST', $url); + // set the error in the application + Factory::getApplication()->enqueueMessage($error, 'Error'); + // set the error also in the class encase it is and Ajax call + self::$githubRepoDataErrors[] = $error; + // we are done here + return false; + } + } + // check if we could find packages + if (isset($repoData) && JsonHelper::check($repoData)) + { + if ('object' === $return_type) + { + return json_decode($repoData); + } + elseif ('array' === $return_type) + { + return json_decode($repoData, true); + } + return $repoData; + } + return false; + } + + /** + * get the github error messages + * + * @return array of errors on success + * + */ + protected static function githubErrorHandeler($message, &$github, $type) + { + if (ObjectHelper::check($github) && isset($github->message) && UtilitiesStringHelper::check($github->message)) + { + // set the message + $errorMessage = $github->message; + // add the documentation URL + if (isset($github->documentation_url) && UtilitiesStringHelper::check($github->documentation_url)) + { + $errorMessage = $errorMessage . '
    ' . $github->documentation_url; + } + // check the message + if (strpos($errorMessage, 'Authenticated') !== false) + { + if ('nomemory' === $type) + { + $type = 'data'; + } + // add little more help if it is an access token issue + $errorMessage = Text::sprintf('COM_COMPONENTBUILDER_SBR_YOU_CAN_ADD_A_BGITHUB_ACCESS_TOKENB_TO_COMPONENTBUILDER_GLOBAL_OPTIONS_TO_MAKE_AUTHENTICATED_REQUESTS_TO_GITHUB_AN_ACCESS_TOKEN_WITH_ONLY_PUBLIC_ACCESS_WILL_DO_TO_RETRIEVE_S', $errorMessage, $type); + } + // set error notice + $message['error'] = $errorMessage; + // we have error message + return $message; + } + return false; + } + + /** + * set the github token + * + * @return array of errors on success + * + */ + protected static function setGithubToken($url) + { + // first check if token already set + if (strpos($url, 'access_token=') !== false) + { + // make sure the token is loaded + if (!UtilitiesStringHelper::check(self::$gitHubAccessToken)) + { + // get the global settings + if (!ObjectHelper::check(self::$params)) + { + self::$params = \JComponentHelper::getParams('com_componentbuilder'); + } + self::$gitHubAccessToken = self::$params->get('github_access_token', null); + } + // make sure the token is loaded at this point + if (UtilitiesStringHelper::check(self::$gitHubAccessToken)) + { + $url .= '&access_token=' . self::$gitHubAccessToken; + } + } + return $url; + } + + + /** + * 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 + if ($fieldName) + { + $fieldNames = array( + 'php_import_display' => 'display', + 'php_import_setdata' => 'setdata', + 'php_import_save' => 'save', + 'html_import_view' => 'view', + 'php_import' => 'import', + 'php_import_ext' => 'ext', + 'php_import_headers' => 'headers' + ); + // first check if the field name is found + if (isset($fieldNames[$type])) + { + $type = $fieldNames[$type]; + } + else + { + return ''; + } + } + $script = array(); + if ('display' === $type) + { + // set the display script + $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 = Factory::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'][] = 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 (Super-#-#-___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$target_headers))"; + $script['setdata'][] = self::_t(2) . "{"; + $script['setdata'][] = self::_t(3) . "// make sure the file is loaded"; + $script['setdata'][] = self::_t(3) . "[[[-#-#-Component]]]Helper::composerAutoload('phpspreadsheet');"; + $script['setdata'][] = self::_t(3) . "\$jinput = Factory::getApplication()->input;"; + $script['setdata'][] = self::_t(3) . "foreach(\$target_headers as \$header)"; + $script['setdata'][] = self::_t(3) . "{"; + $script['setdata'][] = self::_t(4) . "if ((\$column = \$jinput->getString(\$header, false)) !== false ||"; + $script['setdata'][] = self::_t(5) . "(\$column = \$jinput->getString(strtolower(\$header), false)) !== false)"; + $script['setdata'][] = self::_t(4) . "{"; + $script['setdata'][] = self::_t(5) . "\$data['target_headers'][\$header] = \$column;"; + $script['setdata'][] = self::_t(4) . "}"; + $script['setdata'][] = self::_t(4) . "else"; + $script['setdata'][] = self::_t(4) . "{"; + $script['setdata'][] = self::_t(5) . "\$data['target_headers'][\$header] = null;"; + $script['setdata'][] = self::_t(4) . "}"; + $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 = IOFactory::identify(\$package['dir']);"; + $script['setdata'][] = self::_t(4) . "\$excelReader = 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'][] = 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 = Factory::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 (Super-#-#-___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$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'][] = 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(Super-#-#-___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$data['array']))"; + $script['save'][] = self::_t(2) . "{"; + $script['save'][] = self::_t(3) . "// get user object"; + $script['save'][] = self::_t(3) . "\$user" . self::_t(2) . "= Factory::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'][] = 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(Super-#-#-___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$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 = Factory::getDbo();"; + $script['save'][] = self::_t(4) . "// set some defaults"; + $script['save'][] = self::_t(4) . "\$todayDate" . self::_t(2) . "= Factory::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'][] = ""; + $script['view'][] = PHP_EOL . "
    "; + $script['view'][] = "
    \" method=\"post\" name=\"adminForm\" id=\"adminForm\" class=\"form-horizontal form-validate\">"; + $script['view'][] = ""; + $script['view'][] = PHP_EOL . self::_t(1) . "sidebar)) : ?>"; + $script['view'][] = self::_t(2) . "
    "; + $script['view'][] = self::_t(3) . "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'][] = PHP_EOL . self::_t(1) . "hasPackage && Super-#-#-___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$this->headerList) && Super-#-#-___0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$this->headers)) : ?>"; + $script['view'][] = self::_t(2) . "
    "; + $script['view'][] = self::_t(3) . ""; + $script['view'][] = self::_t(3) . "
    "; + $script['view'][] = self::_t(4) . ""; + $script['view'][] = self::_t(4) . "
    "; + $script['view'][] = self::_t(5) . ""; + $script['view'][] = self::_t(4) . "
    "; + $script['view'][] = self::_t(3) . "
    "; + $script['view'][] = self::_t(3) . "headerList as \$name => \$title): ?>"; + $script['view'][] = self::_t(4) . "
    "; + $script['view'][] = self::_t(5) . ""; + $script['view'][] = self::_t(5) . "
    "; + $script['view'][] = self::_t(6) . ""; + $script['view'][] = self::_t(5) . "
    "; + $script['view'][] = self::_t(4) . "
    "; + $script['view'][] = self::_t(3) . ""; + $script['view'][] = self::_t(3) . "
    "; + $script['view'][] = self::_t(4) . "\" onclick=\"Joomla.continueImport()\" />"; + $script['view'][] = self::_t(3) . "
    "; + $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(4) . ""; + $script['view'][] = self::_t(4) . "
    "; + $script['view'][] = self::_t(5) . ""; + $script['view'][] = self::_t(5) . "
    "; + $script['view'][] = self::_t(6) . ""; + $script['view'][] = self::_t(5) . "
    "; + $script['view'][] = self::_t(4) . "
    "; + $script['view'][] = self::_t(4) . "
    "; + $script['view'][] = self::_t(5) . "\" onclick=\"Joomla.submitbutton()\" />    (.csv .xls .ods)"; + $script['view'][] = self::_t(4) . "
    "; + $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(4) . ""; + $script['view'][] = self::_t(4) . "
    "; + $script['view'][] = self::_t(5) . ""; + $script['view'][] = self::_t(5) . "
    "; + $script['view'][] = self::_t(6) . "state->get('import.directory'); ?>\" />"; + $script['view'][] = self::_t(5) . "
    "; + $script['view'][] = self::_t(4) . "
    "; + $script['view'][] = self::_t(4) . "
    "; + $script['view'][] = self::_t(5) . "\" onclick=\"Joomla.submitbutton3()\" />    (.csv .xls .ods)"; + $script['view'][] = self::_t(4) . "
    "; + $script['view'][] = self::_t(4) . "
    "; + $script['view'][] = self::_t(2) . ""; + $script['view'][] = ""; + $script['view'][] = PHP_EOL . self::_t(2) . ""; + $script['view'][] = self::_t(3) . "
    "; + $script['view'][] = self::_t(4) . ""; + $script['view'][] = self::_t(4) . "
    "; + $script['view'][] = self::_t(5) . ""; + $script['view'][] = self::_t(5) . "
    "; + $script['view'][] = self::_t(6) . ""; + $script['view'][] = self::_t(5) . "
    "; + $script['view'][] = self::_t(4) . "
    "; + $script['view'][] = self::_t(4) . "
    "; + $script['view'][] = self::_t(5) . "\" onclick=\"Joomla.submitbutton4()\" />    (.csv .xls .ods)"; + $script['view'][] = self::_t(4) . "
    "; + $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'][] = 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) . "= Factory::getApplication();"; + $script['import'][] = self::_t(2) . "\$session" . self::_t(1) . "= Factory::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'][] = 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'][] = 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(PHP_EOL, $script[$type])); + } + return false; + } + + /** + * Field Grouping https://docs.joomla.org/Form_field + * @deprecated 3.3 + **/ + protected static $fieldGroups = array( + 'default' => array( + 'accesslevel', 'cachehandler', 'calendar', 'captcha', 'category', 'checkbox', 'checkboxes', 'chromestyle', + 'color', 'combo', 'componentlayout', 'contentlanguage', 'contenttype', 'databaseconnection', 'components', + 'editor', 'editors', 'email', 'file', 'file', 'filelist', 'folderlist', 'groupedlist', 'headertag', 'helpsite', 'hidden', 'imagelist', + 'integer', 'language', 'list', 'media', 'menu', 'modal_menu', 'menuitem', 'meter', 'modulelayout', 'moduleorder', 'moduleposition', + 'moduletag', 'note', 'number', 'password', 'plugins', 'predefinedlist', 'radio', 'range', 'repeatable', 'rules', + 'sessionhandler', 'spacer', 'sql', 'subform', 'tag', 'tel', 'templatestyle', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup' + ), + 'plain' => array( + 'cachehandler', 'calendar', 'checkbox', 'chromestyle', 'color', 'componentlayout', 'contenttype', 'editor', 'editors', 'captcha', + 'email', 'file', 'headertag', 'helpsite', 'hidden', 'integer', 'language', 'media', 'menu', 'modal_menu', 'menuitem', 'meter', 'modulelayout', 'templatestyle', + 'moduleorder', 'moduletag', 'number', 'password', 'range', 'rules', 'tag', 'tel', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup' + ), + 'option' => array( + 'accesslevel', 'category', 'checkboxes', 'combo', 'contentlanguage', 'databaseconnection', 'components', + 'filelist', 'folderlist', 'imagelist', 'list', 'plugins', 'predefinedlist', 'radio', 'sessionhandler', 'sql', 'groupedlist' + ), + 'text' => array( + 'calendar', 'color', 'editor', 'email', 'number', 'password', 'range', 'tel', 'text', 'textarea', 'url' + ), + 'list' => array( + 'checkbox', 'checkboxes', 'list', 'radio', 'groupedlist', 'combo' + ), + 'dynamic' => array( + 'category', 'file', 'filelist', 'folderlist', 'headertag', 'imagelist', 'integer', 'media', 'meter', 'rules', 'tag', 'timezone', 'user' + ), + 'spacer' => array( + 'note', 'spacer' + ), + 'special' => array( + 'contentlanguage', 'moduleposition', 'plugin', 'repeatable', 'subform' + ), + 'search' => array( + 'editor', 'email', 'tel', 'text', 'textarea', 'url', 'subform' + ) + ); + + /** + * Field Checker + * + * @param string $type The field type + * @param boolean $option The field grouping + * + * @return boolean if the field was found + * @deprecated 3.3 Use CompilerFactory::_('Field.Groups')->check($type, $option); + */ + public static function fieldCheck($type, $option = 'default') + { + return CompilerFactory::_('Field.Groups')->check($type, $option); + } + + /** + * get the field types id -> name of a group or groups + * + * @return array ids of the spacer field types + * @deprecated 3.3 Use CompilerFactory::_('Field.Groups')->types($groups); + */ + public static function getFieldTypesByGroup($groups = array()) + { + return CompilerFactory::_('Field.Groups')->types($groups); + } + + /** + * get the field types IDs of a group or groups + * + * @return array ids of the spacer field types + * @deprecated 3.3 Use CompilerFactory::_('Field.Groups')->typesIds($groups); + */ + public static function getFieldTypesIdsByGroup($groups = array()) + { + return CompilerFactory::_('Field.Groups')->typesIds($groups); + } + + /** + * get the spacer IDs + * + * @return array ids of the spacer field types + * @deprecated 3.3 Use CompilerFactory::_('Field.Groups')->spacerIds(); + */ + public static function getSpacerIds() + { + return CompilerFactory::_('Field.Groups')->spacerIds(); + } + + + /** + * open base64 string if stored as base64 + * + * @param string $data The base64 string + * @param string $key We store the string with that suffix :) + * @param string $default The default switch + * + * @return string The opened string + * @deprecated 3.3 Use Base64Helper::open($data, $key, $default); + */ + public static function openValidBase64($data, $key = '__.o0=base64=Oo.__', $default = 'string') + { + return Base64Helper::open($data, $key, $default); + } + + /** + * prepare base64 string for url + * + * @deprecate Use urlencode(); + */ + public static function base64_urlencode($string, $encode = false) + { + if ($encode) + { + $string = base64_encode($string); + } + return str_replace(array('+', '/'), array('-', '_'), $string); + } + + /** + * prepare base64 string form url + * + * @deprecate + */ + public static function base64_urldecode($string, $decode = false) + { + $string = str_replace(array('-', '_'), array('+', '/'), $string); + if ($decode) + { + $string = base64_decode($string); + } + return $string; + } + + + /** + * Get the file path or url + * + * @param string $type The (url/path) type to return + * @param string $target The Params Target name (if set) + * @param string $default The default path if not set in Params (fallback path) + * @param bool $createIfNotSet The switch to create the folder if not found + * + * @return string On success the path or url is returned based on the type requested + * + */ + public static function getFolderPath($type = 'path', $target = 'folderpath', $default = '', $createIfNotSet = true) + { + // make sure to always have a string/path + if(!UtilitiesStringHelper::check($default)) + { + $default = JPATH_SITE . '/images/'; + } + // get the global settings + if (!ObjectHelper::check(self::$params)) + { + self::$params = \JComponentHelper::getParams('com_componentbuilder'); + } + $folderPath = self::$params->get($target, $default); + // create the folder if it does not exist + if ($createIfNotSet && !Folder::exists($folderPath)) + { + Folder::create($folderPath); + } + // return the url + if ('url' === $type) + { + if (strpos($folderPath, JPATH_SITE) !== false) + { + $folderPath = trim( str_replace( JPATH_SITE, '', $folderPath), '/'); + return Uri::root() . $folderPath . '/'; + } + // since the path is behind the root folder of the site, return only the root url (may be used to build the link) + return Uri::root(); + } + // sanitize the path + return '/' . trim( $folderPath, '/' ) . '/'; + } + + + /** + * the Crypt objects + **/ + protected static $CRYPT = array(); + + /** + * the Cipher MODE switcher (list of ciphers) + **/ + protected static $setCipherMode = array( + 'AES' => true, + 'Rijndael' => true, + 'Twofish' => false, // can but not good idea + 'Blowfish' => false, // can but not good idea + 'RC4' => false, // nope + 'RC2' => false, // can but not good idea + 'TripleDES' => false, // can but not good idea + 'DES' => true + ); + + /** + * get the Crypt object + * + * @return object on success with Crypt power + **/ + public static function crypt($type, $mode = null) + { + // set key based on mode + if ($mode) + { + $key = $type . $mode; + } + else + { + $key = $type; + } + // check if it was already set + if (isset(self::$CRYPT[$key]) && ObjectHelper::check(self::$CRYPT[$key])) + { + return self::$CRYPT[$key]; + } + // make sure we have the composer classes loaded + self::composerAutoload('phpseclib'); + // build class name + $CLASS = '\phpseclib\Crypt\\' . $type; + // make sure we have the phpseclib classes + if (!class_exists($CLASS)) + { + // class not in place so send out error + Factory::getApplication()->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_THE_BSB_LIBRARYCLASS_IS_NOT_AVAILABLE_THIS_LIBRARYCLASS_SHOULD_HAVE_BEEN_ADDED_TO_YOUR_BLIBRARIESPHPSECLIBVENDORB_FOLDER_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFO', $CLASS), 'Error'); + return false; + } + // does this crypt class use mode + if ($mode && isset(self::$setCipherMode[$type]) && self::$setCipherMode[$type]) + { + switch ($mode) + { + case 'CTR': + self::$CRYPT[$key] = new $CLASS('ctr'); + break; + case 'ECB': + self::$CRYPT[$key] = new $CLASS('ecb'); + break; + case 'CBC': + self::$CRYPT[$key] = new $CLASS('cbc'); + break; + case 'CBC3': + self::$CRYPT[$key] = new $CLASS('cbc3'); + break; + case 'CFB': + self::$CRYPT[$key] = new $CLASS('cfb'); + break; + case 'CFB8': + self::$CRYPT[$key] = new $CLASS('cfb8'); + break; + case 'OFB': + self::$CRYPT[$key] = new $CLASS('ofb'); + break; + case 'GCM': + self::$CRYPT[$key] = new $CLASS('gcm'); + break; + case 'STREAM': + self::$CRYPT[$key] = new $CLASS('stream'); + break; + default: + // No valid mode has been specified + Factory::getApplication()->enqueueMessage(Text::_('COM_COMPONENTBUILDER_NO_VALID_MODE_HAS_BEEN_SPECIFIED'), 'Error'); + return false; + break; + } + } + else + { + // set the default + self::$CRYPT[$key] = new $CLASS(); + } + // return the object + return self::$CRYPT[$key]; + } + + /** + * Move File to Server + * + * @param string $localPath The local path to the file + * @param string $fileName The the actual file name + * @param int $serverID The server local id to use + * @param int $protocol The server protocol to use + * @param string $permission The permission validation area + * + * @return bool true on success + **/ + public static function moveToServer($localPath, $fileName, $serverID, $protocol = null, $permission = 'core.export') + { + // get the server + if ($server = self::getServer( (int) $serverID, $protocol, $permission)) + { + // use the FTP protocol + if (1 == $server->jcb_protocol) + { + // now move the file + if (!$server->store($localPath, $fileName)) + { + Factory::getApplication()->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_SERVER', $fileName, $server->jcb_remote_server_name[(int) $serverID]), 'Error'); + return false; + } + // close the connection + $server->quit(); + } + // use the SFTP protocol + elseif (2 == $server->jcb_protocol) + { + // get the remote path + $remote_path = '/' . trim($server->jcb_remote_server_path[(int) $serverID], '/') . '/' . $fileName; + // now move the file + if (!$server->put($remote_path, FileHelper::getContent($localPath, null))) + { + Factory::getApplication()->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_PATH_ON_BSB_SERVER', $fileName, $server->jcb_remote_server_path[(int) $serverID], $server->jcb_remote_server_name[(int) $serverID]), 'Error'); + return false; + } + } + return true; + } + return false; + } + + /** + * the SFTP objects + **/ + protected static $sftp = array(); + + /** + * the FTP objects + **/ + protected static $ftp = array(); + + /** + * get the server object + * + * @param int $serverID The server local id to use + * @param int $protocol The server protocol to use + * @param string $permission The permission validation area + * + * @return object on success server object + **/ + public static function getServer($serverID, $protocol = null, $permission = 'core.export') + { + // if not protocol is given get it (sad I know) + if (!$protocol) + { + $protocol = self::getVar('server', (int) $serverID, 'id', 'protocol'); + } + // return the server object + switch ($protocol) + { + case 1: // FTP + return self::getFtp($serverID, $permission); + break; + case 2: // SFTP + return self::getSftp($serverID, $permission); + break; + } + return false; + } + + /** + * get the sftp object + * + * @param int $serverID The server local id to use + * @param string $permission The permission validation area + * + * @return object on success with sftp power + **/ + public static function getSftp($serverID, $permission = 'core.export') + { + // check if we have a server with that id + if ($server = self::getServerDetails($serverID, 2, $permission)) + { + // check if it was already set + if (!isset(self::$sftp[$server->cache]) || !ObjectHelper::check(self::$sftp[$server->cache])) + { + // make sure we have the composer classes loaded + self::composerAutoload('phpseclib'); + // make sure we have the phpseclib classes + if (!class_exists('\phpseclib\Net\SFTP')) + { + // class not in place so send out error + Factory::getApplication()->enqueueMessage(Text::_('COM_COMPONENTBUILDER_THE_BPHPSECLIBNETSFTPB_LIBRARYCLASS_IS_NOT_AVAILABLE_THIS_LIBRARYCLASS_SHOULD_HAVE_BEEN_ADDED_TO_YOUR_BLIBRARIESVDM_IOVENDORB_FOLDER_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFO'), 'Error'); + return false; + } + // insure the port is set + $server->port = (isset($server->port) && is_numeric($server->port) && $server->port > 0) ? (int) $server->port : 22; + // open the connection + self::$sftp[$server->cache] = new phpseclib\Net\SFTP($server->host, $server->port); + // heads-up on protocol + self::$sftp[$server->cache]->jcb_protocol = 2; // SFTP <-- if called not knowing what type of protocol is being used + // now login based on authentication type + switch($server->authentication) + { + case 1: // password + if (!self::$sftp[$server->cache]->login($server->username, $server->password)) + { + Factory::getApplication()->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_THE_LOGIN_TO_BSB_HAS_FAILED_PLEASE_CHECK_THAT_YOUR_DETAILS_ARE_CORRECT', $server->name), 'Error'); + unset(self::$sftp[$server->cache]); + return false; + } + break; + case 2: // private key file + if (ObjectHelper::check(self::crypt('RSA'))) + { + // check if we have a passprase + if (UtilitiesStringHelper::check($server->secret)) + { + self::crypt('RSA')->setPassword($server->secret); + } + // now load the key file + if (!self::crypt('RSA')->loadKey(FileHelper::getContent($server->private, null))) + { + Factory::getApplication()->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_THE_PRIVATE_KEY_FILE_COULD_NOT_BE_LOADEDFOUND_FOR_BSB_SERVER', $server->name), 'Error'); + unset(self::$sftp[$server->cache]); + return false; + } + // now login + if (!self::$sftp[$server->cache]->login($server->username, self::crypt('RSA'))) + { + Factory::getApplication()->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_THE_LOGIN_TO_BSB_HAS_FAILED_PLEASE_CHECK_THAT_YOUR_DETAILS_ARE_CORRECT', $server->name), 'Error'); + unset(self::$sftp[$server->cache]); + return false; + } + } + break; + case 3: // both password and private key file + if (ObjectHelper::check(self::crypt('RSA'))) + { + // check if we have a passphrase + if (UtilitiesStringHelper::check($server->secret)) + { + self::crypt('RSA')->setPassword($server->secret); + } + // now load the key file + if (!self::crypt('RSA')->loadKey(FileHelper::getContent($server->private, null))) + { + Factory::getApplication()->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_THE_PRIVATE_KEY_FILE_COULD_NOT_BE_LOADEDFOUND_FOR_BSB_SERVER', $server->name), 'Error'); + unset(self::$sftp[$server->cache]); + return false; + } + // now login + if (!self::$sftp[$server->cache]->login($server->username, $server->password, self::crypt('RSA'))) + { + Factory::getApplication()->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_THE_LOGIN_TO_BSB_HAS_FAILED_PLEASE_CHECK_THAT_YOUR_DETAILS_ARE_CORRECT', $server->name), 'Error'); + unset(self::$sftp[$server->cache]); + return false; + } + } + break; + case 4: // private key field + if (ObjectHelper::check(self::crypt('RSA'))) + { + // check if we have a passprase + if (UtilitiesStringHelper::check($server->secret)) + { + self::crypt('RSA')->setPassword($server->secret); + } + // now load the key field + if (!self::crypt('RSA')->loadKey($server->private_key)) + { + Factory::getApplication()->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_THE_PRIVATE_KEY_FIELD_COULD_NOT_BE_LOADED_FOR_BSB_SERVER', $server->name), 'Error'); + unset(self::$sftp[$server->cache]); + return false; + } + // now login + if (!self::$sftp[$server->cache]->login($server->username, self::crypt('RSA'))) + { + Factory::getApplication()->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_THE_LOGIN_TO_BSB_HAS_FAILED_PLEASE_CHECK_THAT_YOUR_DETAILS_ARE_CORRECT', $server->name), 'Error'); + unset(self::$sftp[$server->cache]); + return false; + } + } + break; + case 5: // both password and private key field + if (ObjectHelper::check(self::crypt('RSA'))) + { + // check if we have a passphrase + if (UtilitiesStringHelper::check($server->secret)) + { + self::crypt('RSA')->setPassword($server->secret); + } + // now load the key file + if (!self::crypt('RSA')->loadKey($server->private_key)) + { + Factory::getApplication()->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_THE_PRIVATE_KEY_FIELD_COULD_NOT_BE_LOADED_FOR_BSB_SERVER', $server->name), 'Error'); + unset(self::$sftp[$server->cache]); + return false; + } + // now login + if (!self::$sftp[$server->cache]->login($server->username, $server->password, self::crypt('RSA'))) + { + Factory::getApplication()->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_THE_LOGIN_TO_BSB_HAS_FAILED_PLEASE_CHECK_THAT_YOUR_DETAILS_ARE_CORRECT', $server->name), 'Error'); + unset(self::$sftp[$server->cache]); + return false; + } + } + break; + } + } + // only continue if object is set + if (isset(self::$sftp[$server->cache]) && ObjectHelper::check(self::$sftp[$server->cache])) + { + // set the unique buckets + if (!isset(self::$sftp[$server->cache]->jcb_remote_server_name)) + { + self::$sftp[$server->cache]->jcb_remote_server_name = array(); + self::$sftp[$server->cache]->jcb_remote_server_path = array(); + } + // always set the name and remote server path + self::$sftp[$server->cache]->jcb_remote_server_name[$serverID] = $server->name; + self::$sftp[$server->cache]->jcb_remote_server_path[$serverID] = (UtilitiesStringHelper::check($server->path) && $server->path !== '/') ? $server->path : ''; + // return the sftp object + return self::$sftp[$server->cache]; + } + } + return false; + } + + /** + * get the JClientFtp object + * + * @param int $serverID The server local id to use + * @param string $permission The permission validation area + * + * @return object on success with ftp power + **/ + public static function getFtp($serverID, $permission) + { + // check if we have a server with that id + if ($server = self::getServerDetails($serverID, 1, $permission)) + { + // check if we already have the server instance + if (isset(self::$ftp[$server->cache]) && self::$ftp[$server->cache] instanceof JClientFtp) + { + // always set the name and remote server path + self::$ftp[$server->cache]->jcb_remote_server_name[$serverID] = $server->name; + // if still connected we are ready to go + if (self::$ftp[$server->cache]->isConnected()) + { + // return the FTP instance + return self::$ftp[$server->cache]; + } + // check if we can reinitialise the server + if (self::$ftp[$server->cache]->reinit()) + { + // return the FTP instance + return self::$ftp[$server->cache]; + } + } + // make sure we have a string and it is not default or empty + if (UtilitiesStringHelper::check($server->signature)) + { + // turn into variables + parse_str($server->signature); // because of this I am using strange variable naming to avoid any collisions. + // set options + if (isset($options) && UtilitiesArrayHelper::check($options)) + { + foreach ($options as $o__p0t1on => $vAln3) + { + if ('timeout' === $o__p0t1on) + { + $options[$o__p0t1on] = (int) $vAln3; + } + if ('type' === $o__p0t1on) + { + $options[$o__p0t1on] = (string) $vAln3; + } + } + } + else + { + $options = array(); + } + // get ftp object + if (isset($host) && $host != 'HOSTNAME' && isset($port) && $port != 'PORT_INT' && isset($username) && $username != 'user@name.com' && isset($password) && $password != 'password') + { + // load for reuse + self::$ftp[$server->cache] = JClientFtp::getInstance($host, $port, $options, $username, $password); + } + else + { + // load error to indicate signature was in error + Factory::getApplication()->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_THE_FTP_SIGNATURE_FOR_BSB_WAS_NOT_WELL_FORMED_PLEASE_CHECK_YOUR_SIGNATURE_DETAILS', $server->name), 'Error'); + return false; + } + // check if we are connected + if (self::$ftp[$server->cache] instanceof JClientFtp && self::$ftp[$server->cache]->isConnected()) + { + // heads-up on protocol + self::$ftp[$server->cache]->jcb_protocol = 1; // FTP <-- if called not knowing what type of protocol is being used + // set the unique buckets + if (!isset(self::$ftp[$server->cache]->jcb_remote_server_name)) + { + self::$ftp[$server->cache]->jcb_remote_server_name = array(); + } + // always set the name and remote server path + self::$ftp[$server->cache]->jcb_remote_server_name[$serverID] = $server->name; + // return the FTP instance + return self::$ftp[$server->cache]; + } + // reset since we have no connection + unset(self::$ftp[$server->cache]); + } + // load error to indicate signature was in error + Factory::getApplication()->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_THE_FTP_CONNECTION_FOR_BSB_COULD_NOT_BE_MADE_PLEASE_CHECK_YOUR_SIGNATURE_DETAILS', $server->name), 'Error'); + } + return false; + } + + /** + * get the server details + * + * @param int $serverID The server local id to use + * @param int $protocol The server protocol to use + * @param string $permission The permission validation area + * + * @return object on success with server details + **/ + public static function getServerDetails($serverID, $protocol = 2, $permission = 'core.export') + { + // check if this user has permission to access items + if (!Factory::getUser()->authorise($permission, 'com_componentbuilder')) + { + // set message to inform the user that permission was denied + Factory::getApplication()->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_ACCESS_THE_SERVER_DETAILS_BS_DENIEDB_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFO', UtilitiesStringHelper::safe($permission, 'w')), 'Error'); + return false; + } + // now insure we have correct values + if (is_int($serverID) && is_int($protocol)) + { + // Get a db connection + $db = Factory::getDbo(); + // start the query + $query = $db->getQuery(true); + // select based to protocol + if (2 == $protocol) + { + // SFTP + $query->select($db->quoteName(array('name','authentication','username','host','password','path','port','private','private_key','secret'))); + // cache builder + $cache = array('authentication','username','host','password','port','private','private_key','secret'); + } + else + { + // FTP + $query->select($db->quoteName(array('name','signature'))); + // cache builder + $cache = array('signature'); + } + $query->from($db->quoteName('#__componentbuilder_server')); + $query->where($db->quoteName('id') . ' = ' . (int) $serverID); + $query->where($db->quoteName('protocol') . ' = ' . (int) $protocol); + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $server = $db->loadObject(); + // Get the basic encryption. + $basickey = self::getCryptKey('basic', 'Th1sMnsTbL0ck@d'); + // Get the encryption object. + $basic = new AES($basickey, 128); + // start cache keys + $keys = array(); + // unlock the needed fields + foreach($server as $name => &$value) + { + // unlock the needed fields + if ($name !== 'name' && !empty($value) && $basickey && !is_numeric($value) && $value === base64_encode(base64_decode($value, true))) + { + // basic decrypt of data + $value = rtrim($basic->decryptString($value), "\0"); + } + // build cache (keys) for lower connection latency + if (in_array($name, $cache)) + { + $keys[] = $value; + } + } + // check if cache keys were found + if (UtilitiesArrayHelper::check($keys)) + { + // now set cache + $server->cache = md5(implode('', $keys)); + } + else + { + // default is ID + $server->cache = $serverID; + } + // return the server details + return $server; + } + } + Factory::getApplication()->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_THE_SERVER_DETAILS_FOR_BID_SB_COULD_NOT_BE_RETRIEVED', $serverID), 'Error'); + return false; + } + + /** + * Load the Composer Vendor phpseclib + */ + protected static function composephpseclib() + { + // load the autoloader for phpseclib + require_once JPATH_SITE . '/libraries/phpseclib/vendor/autoload.php'; + // do not load again + self::$composer['phpseclib'] = true; + + return true; + } + + + /** + * the locker + * + * @var array + * @since 3.1 + */ + protected static array $locker = []; + + /** + * the dynamic replacement salt + * + * @var array + * @since 3.1 + */ + protected static array $globalSalt = []; + + /** + * the timer + * + * @var object + * @since 3.1 + */ + protected static $keytimer; + + /** + * To Lock string + * + * @param string $string The string/array to lock + * @param string|null $key The custom key to use + * @param int $salt The switch to add salt and type of salt + * @param int|null $dynamic The dynamic replacement array of salt build string + * @param int $urlencode The switch to control url encoding + * + * @return string Encrypted String + * @since 3.1 + */ + public static function lock(string $string, ?string $key = null, int $salt = 2, ?int $dynamic = null, $urlencode = true): string + { + // get the global settings + if (!$key || !UtilitiesStringHelper::check($key)) + { + // set temp timer + $timer = 2; + // if we have a timer use it + if ($salt > 0) + { + $timer = $salt; + } + // set the default key + $key = self::salt($timer, $dynamic); + // try getting the system key + if (method_exists(get_called_class(), "getCryptKey")) + { + // try getting the medium key first the fall back to basic, and then default + $key = self::getCryptKey('medium', self::getCryptKey('basic', $key)); + } + } + // check if we have a salt timer + if ($salt > 0) + { + $key .= self::salt($salt, $dynamic); + } + // get the locker settings + if (!isset(self::$locker[$key]) || !ObjectHelper::check(self::$locker[$key])) + { + self::$locker[$key] = new AES($key, 128); + } + // convert array or object to string + if (UtilitiesArrayHelper::check($string) || ObjectHelper::check($string)) + { + $string = serialize($string); + } + // prep for url + if ($urlencode && method_exists(get_called_class(), "base64_urlencode")) + { + return self::base64_urlencode(self::$locker[$key]->encryptString($string)); + } + return self::$locker[$key]->encryptString($string); + } + + /** + * To un-Lock string + * + * @param string $string The string to unlock + * @param string $key The custom key to use + * @param int $salt The switch to add salt and type of salt + * @param int $dynamic The dynamic replacement array of salt build string + * @param int $urlencode The switch to control url decoding + * + * @return string Decrypted String + * @since 3.1 + */ + public static function unlock($string, $key = null, $salt = 2, $dynamic = null, $urlencode = true): string + { + // get the global settings + if (!$key || !UtilitiesStringHelper::check($key)) + { + // set temp timer + $timer = 2; + // if we have a timer use it + if ($salt > 0) + { + $timer = $salt; + } + // set the default key + $key = self::salt($timer, $dynamic); + // try getting the system key + if (method_exists(get_called_class(), "getCryptKey")) + { + // try getting the medium key first the fall back to basic, and then default + $key = self::getCryptKey('medium', self::getCryptKey('basic', $key)); + } + } + // check if we have a salt timer + if ($salt > 0) + { + $key .= self::salt($salt, $dynamic); + } + // get the locker settings + if (!isset(self::$locker[$key]) || !ObjectHelper::check(self::$locker[$key])) + { + self::$locker[$key] = new AES($key, 128); + } + // make sure we have real base64 + if ($urlencode && method_exists(get_called_class(), "base64_urldecode")) + { + $string = self::base64_urldecode($string); + } + // basic decrypt string. + if (!empty($string) && !is_numeric($string) && $string === base64_encode(base64_decode($string, true))) + { + $string = rtrim(self::$locker[$key]->decryptString($string), "\0"); + // convert serial string to array + if (self::is_serial($string)) + { + $string = unserialize($string); + } + } + + return $string; + } + + /** + * The Salt + * + * @param int $type The type of length the salt should be valid + * @param int $dynamic The dynamic replacement array of salt build string + * + * @return string + * @since 3.1 + */ + public static function salt(int $type = 1, $dynamic = null): string + { + // get dynamic replacement salt + $dynamic = self::getDynamicSalt($dynamic); + // get the key timer + if (!ObjectHelper::check(self::$keytimer)) + { + // load the date time object + self::$keytimer = new DateTime; + // set the correct time stamp + $vdmLocalTime = new DateTimeZone('Africa/Windhoek'); + self::$keytimer->setTimezone($vdmLocalTime); + } + // set type + if ($type == 2) + { + // hour + $format = 'Y-m-d \o\n ' . self::periodFix(self::$keytimer->format('H')); + } + elseif ($type == 3) + { + // day + $format = 'Y-m-' . self::periodFix(self::$keytimer->format('d')); + } + elseif ($type == 4) + { + // month + $format = 'Y-' . self::periodFix(self::$keytimer->format('m')); + } + else + { + // minute + $format = 'Y-m-d \o\n H:' . self::periodFix(self::$keytimer->format('i')); + } + // get key + if (UtilitiesArrayHelper::check($dynamic)) + { + return md5(str_replace(array_keys($dynamic), array_values($dynamic), self::$keytimer->format($format) . ' @ VDM.I0')); + } + return md5(self::$keytimer->format($format) . ' @ VDM.I0'); + } + + /** + * The function to insure the salt is valid within the given period (third try) + * + * @param int $main The main number + * @since 3.1 + */ + protected static function periodFix(int $main): int + { + return round($main / 3) * 3; + } + + /** + * Check if a string is serialized + * + * @param string $string + * + * @return Boolean + * @since 3.1 + */ + public static function is_serial(string $string): bool + { + return (@unserialize($string) !== false); + } + + /** + * Get dynamic replacement salt + * @since 3.1 + */ + public static function getDynamicSalt($dynamic = null) + { + // load global if not manually set + if (!UtilitiesArrayHelper::check($dynamic)) + { + return self::getGlobalSalt(); + } + // return manual values if set + else + { + return $dynamic; + } + } + + /** + * The random or dynamic secret salt + * @since 3.1 + */ + public static function getSecretSalt($string = null, $size = 9) + { + // set the string + if (!$string) + { + // get random string + $string = self::randomkey($size); + } + // convert string to array + $string = UtilitiesStringHelper::safe($string); + // convert string to array + $array = str_split($string); + // insure only unique values are used + $array = array_unique($array); + // set the size + $size = ($size <= count($array)) ? $size : count($array); + // down size the + return array_slice($array, 0, $size); + } + + /** + * Get global replacement salt + * @since 3.1 + */ + public static function getGlobalSalt() + { + // load from memory if found + if (!UtilitiesArrayHelper::check(self::$globalSalt)) + { + // get the global settings + if (!ObjectHelper::check(self::$params)) + { + self::$params = ComponentHelper::getParams('com_componentbuilder'); + } + // check if we have a global dynamic replacement array available (format --> ' 1->!,3->E,4->A') + $tmp = self::$params->get('dynamic_salt', null); + if (UtilitiesStringHelper::check($tmp) && strpos($tmp, ',') !== false && strpos($tmp, '->') !== false) + { + $salt = array_map('trim', (array) explode(',', $tmp)); + if (UtilitiesArrayHelper::check($salt )) + { + foreach($salt as $replace) + { + $dynamic = array_map('trim', (array) explode('->', $replace)); + if (isset($dynamic[0]) && isset($dynamic[1])) + { + self::$globalSalt[$dynamic[0]] = $dynamic[1]; + } + } + } + } + } + // return global if found + if (UtilitiesArrayHelper::check(self::$globalSalt)) + { + return self::$globalSalt; + } + // return default as fail safe + return array('1' => '!', '3' => 'E', '4' => 'A'); + } + + /** + * Close public protocol + * @since 3.1 + */ + public static function closePublicProtocol($id, $public) + { + // get secret salt + $secretSalt = self::getSecretSalt(self::salt(1,array('4' => 'R','1' => 'E','2' => 'G','7' => 'J','8' => 'A'))); + // get the key + $key = self::salt(1, $secretSalt); + // get secret salt + $secret = self::getSecretSalt(); + // set the secret + $close['SECRET'] = self::lock($secret, $key, 1, array('1' => 's', '3' => 'R', '4' => 'D')); + // get the key + $key = self::salt(1, $secret); + // get the public key + $close['PUBLIC'] = self::lock($public, $key, 1, array('1' => '!', '3' => 'E', '4' => 'A')); + // get secret salt + $secretSalt = self::getSecretSalt($public); + // get the key + $key = self::salt(1, $secretSalt); + // get the ID + $close['ID'] = self::unlock($id, $key, 1, array('1' => 'i', '3' => 'e', '4' => 'B')); + // return closed values + return $close; + } + + /** + * Open public protocol + * @since 3.1 + */ + public static function openPublicProtocol($SECRET, $ID, $PUBLIC) + { + // get secret salt + $secretSalt = self::getSecretSalt(self::salt(1,array('4' => 'R','1' => 'E','2' => 'G','7' => 'J','8' => 'A'))); + // get the key + $key = self::salt(1, $secretSalt); + // get the $SECRET + $SECRET = self::unlock($SECRET, $key, 1, array('1' => 's', '3' => 'R', '4' => 'D')); + // get the key + $key = self::salt(1, $SECRET); + // get the public key + $open['public'] = self::unlock($PUBLIC, $key, 1, array('1' => '!', '3' => 'E', '4' => 'A')); + // get secret salt + $secretSalt = self::getSecretSalt($open['public']); + // get the key + $key = self::salt(1, $secretSalt); + // get the ID + $open['id'] = self::unlock($ID, $key, 1, array('1' => 'i', '3' => 'e', '4' => 'B')); + // return opened values + return $open; + } + + /** + * Workers to load tasks + * + * @var array + * @since 3.1 + */ + protected static array $worker = []; + + /** + * Set a worker dynamic URLs + * + * @var array + * @since 3.1 + */ + protected static array $workerURL = []; + + /** + * Set a worker dynamic HEADERs + * + * @var array + * @since 3.1 + */ + protected static array $workerHEADER = []; + + /** + * Curl Error Notice + * + * @var bool + * @since 3.1 + */ + protected static bool $curlErrorLoaded = false; + + /** + * check if a worker has more work + * + * @param string $function The function to target to perform the task + * + * @return bool + * @since 3.1 + */ + public static function hasWork(string $function): bool + { + if (isset(self::$worker[$function]) && UtilitiesArrayHelper::check(self::$worker[$function])) + { + return count( (array) self::$worker[$function]); + } + return false; + } + + /** + * Set a worker url + * + * @param string $function The function to target to perform the task + * @param string $url The url of where the task is to be performed + * + * @return void + * @since 3.1 + */ + public static function setWorkerUrl(string $function, string $url): void + { + // set the URL if found + if (UtilitiesStringHelper::check($url)) + { + // make sure task function url is up + self::$workerURL[$function] = $url; + } + } + + /** + * Set a worker headers + * + * @param string $function The function to target to perform the task + * @param array|null $headers The headers needed for these workers/function + * + * @return void + * @since 3.1 + */ + public static function setWorkerHeaders(string $function, ?array $headers): void + { + // set the Headers if found + if (UtilitiesArrayHelper::check($headers)) + { + // make sure task function headers are set + self::$workerHEADER[$function] = $headers; + } + } + + /** + * Set a worker that needs to perform a task + * + * @param mixed $data The data to pass to the task + * @param string $function The function to target to perform the task + * @param string $url The url of where the task is to be performed + * @param array $headers The headers needed for these workers/function + * + * @return void + * @since 3.1 + */ + public static function setWorker($data, string $function, ?string $url = null, ?array $headers = null) + { + // make sure task function is up + if (!isset(self::$worker[$function])) + { + self::$worker[$function] = []; + } + + // load the task + self::$worker[$function][] = self::lock($data); + + // set the Headers if found + if ($headers && !isset(self::$workerHEADER[$function])) + { + self::setWorkerHeaders($function, $headers); + } + + // set the URL if found + if ($url && !isset(self::$workerURL[$function])) + { + self::setWorkerUrl($function, $url); + } + } + + /** + * Run set Workers + * + * @param string $function The function to target to perform the task + * @param string $perTask The amount of task per worker + * @param function $callback The option to do a call back when task is completed + * @param int $threadSize The size of the thread + * + * @return bool true On success + * @since 3.1 + */ + public static function runWorker(string $function, $perTask = 50, $callback = null, $threadSize = 20): bool + { + // set task + $task = self::lock($function); + // build headers + $headers = array('VDM-TASK: ' .$task); + // build dynamic headers + if (isset(self::$workerHEADER[$function]) && UtilitiesArrayHelper::check(self::$workerHEADER[$function])) + { + foreach (self::$workerHEADER[$function] as $header) + { + $headers[] = $header; + } + } + // build worker options + $options = array(); + // make sure worker is up + if (isset(self::$worker[$function]) && UtilitiesArrayHelper::check(self::$worker[$function])) + { + // this load method is for each + if (1 == $perTask) + { + // working with a string = 1 + $headers[] = 'VDM-VALUE-TYPE: ' .self::lock(1); + // now load the options + foreach (self::$worker[$function] as $data) + { + $options[] = array(CURLOPT_HTTPHEADER => $headers, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => 'VDM_DATA='. $data); + } + } + // this load method is for bundles + else + { + // working with an array = 2 + $headers[] = 'VDM-VALUE-TYPE: ' .self::lock(2); + // now load the options + $work = array_chunk(self::$worker[$function], $perTask); + foreach ($work as $data) + { + $options[] = array(CURLOPT_HTTPHEADER => $headers, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => 'VDM_DATA='. implode('___VDM___', $data)); + } + } + // relieve worker of task/function + self::$worker[$function] = array(); + } + // do the execution + if (UtilitiesArrayHelper::check($options)) + { + if (isset(self::$workerURL[$function])) + { + $url = self::$workerURL[$function]; + } + else + { + $url = Uri::root() . '/index.php?option=com_componentbuilder&task=api.worker'; + } + return self::curlMultiExec($url, $options, $callback, $threadSize); + } + return false; + } + + /** + * Do a multi curl execution of tasks + * + * @param string $url The url of where the task is to be performed + * @param array $_options The array of curl options/headers to set + * @param function $callback The option to do a call back when task is completed + * @param int $threadSize The size of the thread + * + * @return bool true On success + * @since 3.1 + */ + public static function curlMultiExec(&$url, &$_options, $callback = null, $threadSize = 20) + { + // make sure we have curl available + if (!function_exists('curl_version')) + { + if (!self::$curlErrorLoaded) + { + // set the notice + Factory::getApplication()->enqueueMessage(Text::_('COM_COMPONENTBUILDER_HTWOCURL_NOT_FOUNDHTWOPPLEASE_SETUP_CURL_ON_YOUR_SYSTEM_OR_BCOMPONENTBUILDERB_WILL_NOT_FUNCTION_CORRECTLYP'), 'Error'); + // load the notice only once + self::$curlErrorLoaded = true; + } + return false; + } + // make sure we have an url + if (UtilitiesStringHelper::check($url)) + { + // make sure the thread size isn't greater than the # of _options + $threadSize = (count($_options) < $threadSize) ? count($_options) : $threadSize; + // set the options + $options = array(); + $options[CURLOPT_URL] = $url; + $options[CURLOPT_USERAGENT] = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12'; + $options[CURLOPT_RETURNTRANSFER] = TRUE; + $options[CURLOPT_SSL_VERIFYPEER] = FALSE; + // start multi threading :) + $handle = curl_multi_init(); + // start the first batch of requests + for ($i = 0; $i < $threadSize; $i++) + { + if (isset($_options[$i])) + { + $ch = curl_init(); + foreach ($_options[$i] as $curlopt => $string) + { + $options[$curlopt] = $string; + } + curl_setopt_array($ch, $options); + curl_multi_add_handle($handle, $ch); + } + } + // we wait for all the calls to finish (should not take long) + do { + while(($execrun = curl_multi_exec($handle, $working)) == CURLM_CALL_MULTI_PERFORM); + if($execrun != CURLM_OK) + break; + // a request was just completed -- find out which one + while($done = curl_multi_info_read($handle)) + { + if (is_callable($callback)) + { + // $info = curl_getinfo($done['handle']); + // request successful. process output using the callback function. + $output = curl_multi_getcontent($done['handle']); + $callback($output); + } + $key = $i + 1; + if(isset($_options[$key])) + { + // start a new request (it's important to do this before removing the old one) + $ch = curl_init(); $i++; + // add options + foreach ($_options[$key] as $curlopt => $string) + { + $options[$curlopt] = $string; + } + curl_setopt_array($ch, $options); + curl_multi_add_handle($handle, $ch); + // remove options again + foreach ($_options[$key] as $curlopt => $string) + { + unset($options[$curlopt]); + } + } + // remove the curl handle that just completed + curl_multi_remove_handle($handle, $done['handle']); + } + // stop wasting CPU cycles and rest for a couple ms + usleep(10000); + } while ($working); + // close the curl multi thread + curl_multi_close($handle); + // okay done + return true; + } + return false; + } + + /** + * Get an edit button + * + * @param int $item The item to edit + * @param string $view The type of item to edit + * @param string $views The list view controller name + * @param string $ref The return path + * @param string $component The component these views belong to + * @param string $headsup The message to show on click of button + * + * @return string On success the full html link + * + */ + public static function getEditButton(&$item, $view, $views, $ref = '', $component = 'com_componentbuilder', $headsup = 'COM_COMPONENTBUILDER_ALL_UNSAVED_WORK_ON_THIS_PAGE_WILL_BE_LOST_ARE_YOU_SURE_YOU_WANT_TO_CONTINUE') + { + // get URL + $url = self::getEditURL($item, $view, $views, $ref, $component); + // check if we found any + if (UtilitiesStringHelper::check($url)) + { + // get the global settings + if (!ObjectHelper::check(self::$params)) + { + self::$params = \JComponentHelper::getParams('com_componentbuilder'); + } + // get UIKIT version + $uikit = self::$params->get('uikit_version', 2); + // check that we have the ID + if (ObjectHelper::check($item) && isset($item->id)) + { + // check if the checked_out is available + if (isset($item->checked_out)) + { + $checked_out = (int) $item->checked_out; + } + else + { + $checked_out = self::getVar($view, $item->id, 'id', 'checked_out', '=', str_replace('com_', '', $component)); + } + } + elseif (UtilitiesArrayHelper::check($item) && isset($item['id'])) + { + // check if the checked_out is available + if (isset($item['checked_out'])) + { + $checked_out = (int) $item['checked_out']; + } + else + { + $checked_out = self::getVar($view, $item['id'], 'id', 'checked_out', '=', str_replace('com_', '', $component)); + } + } + elseif (is_numeric($item) && $item > 0) + { + $checked_out = self::getVar($view, $item, 'id', 'checked_out', '=', str_replace('com_', '', $component)); + } + // set the link title + $title = UtilitiesStringHelper::safe(Text::_('COM_COMPONENTBUILDER_EDIT') . ' ' . $view, 'W'); + // check that there is a check message + if (UtilitiesStringHelper::check($headsup)) + { + if (3 == $uikit) + { + $href = 'onclick="UIkit.modal.confirm(\''.Text::_($headsup).'\').then( function(){ window.location.href = \'' . $url . '\' } )" href="javascript:void(0)"'; + } + else + { + $href = 'onclick="UIkit2.modal.confirm(\''.Text::_($headsup).'\', function(){ window.location.href = \'' . $url . '\' })" href="javascript:void(0)"'; + } + } + else + { + $href = 'href="' . $url . '"'; + } + // return UIKIT version 3 + if (3 == $uikit) + { + // check if it is checked out + if (isset($checked_out) && $checked_out > 0) + { + // is this user the one who checked it out + if ($checked_out == Factory::getUser()->id) + { + return ' '; + } + return ' '; + } + // return normal edit link + return ' '; + } + // check if it is checked out (return UIKIT version 2) + if (isset($checked_out) && $checked_out > 0) + { + // is this user the one who checked it out + if ($checked_out == Factory::getUser()->id) + { + return ' '; + } + return ' '; + } + // return normal edit link + return ' '; + } + return ''; + } + + /** + * Get an edit text button + * + * @param string $text The button text + * @param int $item The item to edit + * @param string $view The type of item to edit + * @param string $views The list view controller name + * @param string $ref The return path + * @param string $component The component these views belong to + * @param string $headsup The message to show on click of button + * + * @return string On success the full html link + * + */ + public static function getEditTextButton($text, &$item, $view, $views, $ref = '', $component = 'com_componentbuilder', $jRoute = true, $class = 'uk-button', $headsup = 'COM_COMPONENTBUILDER_ALL_UNSAVED_WORK_ON_THIS_PAGE_WILL_BE_LOST_ARE_YOU_SURE_YOU_WANT_TO_CONTINUE') + { + // make sure we have text + if (!UtilitiesStringHelper::check($text)) + { + return self::getEditButton($item, $view, $views, $ref, $component, $headsup); + } + // get URL + $url = self::getEditURL($item, $view, $views, $ref, $component, $jRoute); + // check if we found any + if (UtilitiesStringHelper::check($url)) + { + // get the global settings + if (!ObjectHelper::check(self::$params)) + { + self::$params = \JComponentHelper::getParams('com_componentbuilder'); + } + // get UIKIT version + $uikit = self::$params->get('uikit_version', 2); + // check that we have the ID + if (ObjectHelper::check($item) && isset($item->id)) + { + // check if the checked_out is available + if (isset($item->checked_out)) + { + $checked_out = (int) $item->checked_out; + } + else + { + $checked_out = self::getVar($view, $item->id, 'id', 'checked_out', '=', str_replace('com_', '', $component)); + } + } + elseif (UtilitiesArrayHelper::check($item) && isset($item['id'])) + { + // check if the checked_out is available + if (isset($item['checked_out'])) + { + $checked_out = (int) $item['checked_out']; + } + else + { + $checked_out = self::getVar($view, $item['id'], 'id', 'checked_out', '=', str_replace('com_', '', $component)); + } + } + elseif (is_numeric($item) && $item > 0) + { + $checked_out = self::getVar($view, $item, 'id', 'checked_out', '=', str_replace('com_', '', $component)); + } + // set the link title + $title = UtilitiesStringHelper::safe(Text::_('COM_COMPONENTBUILDER_EDIT') . ' ' . $view, 'W'); + // check that there is a check message + if (UtilitiesStringHelper::check($headsup)) + { + if (3 == $uikit) + { + $href = 'onclick="UIkit.modal.confirm(\''.Text::_($headsup).'\').then( function(){ window.location.href = \'' . $url . '\' } )" href="javascript:void(0)"'; + } + else + { + $href = 'onclick="UIkit2.modal.confirm(\''.Text::_($headsup).'\', function(){ window.location.href = \'' . $url . '\' })" href="javascript:void(0)"'; + } + } + else + { + $href = 'href="' . $url . '"'; + } + // return UIKIT version 3 + if (3 == $uikit) + { + // check if it is checked out + if (isset($checked_out) && $checked_out > 0) + { + // is this user the one who checked it out + if ($checked_out == Factory::getUser()->id) + { + return ' ' . $text . ''; + } + return ' ' . $text . ''; + } + // return normal edit link + return ' ' . $text . ''; + } + // check if it is checked out (return UIKIT version 2) + if (isset($checked_out) && $checked_out > 0) + { + // is this user the one who checked it out + if ($checked_out == Factory::getUser()->id) + { + return ' ' . $text . ''; + } + return ' ' . $text . ''; + } + // return normal edit link + return ' ' . $text . ''; + } + return ''; + } + + /** + * Get the edit URL + * + * @param int $item The item to edit + * @param string $view The type of item to edit + * @param string $views The list view controller name + * @param string $ref The return path + * @param string $component The component these views belong to + * @param bool $jRoute The switch to add use JRoute or not + * + * @return string On success the edit url + * + */ + public static function getEditURL(&$item, $view, $views, $ref = '', $component = 'com_componentbuilder', $jRoute = true) + { + // build record + $record = new \stdClass(); + // check if user can edit + if (self::canEditItem($record, $item, $view, $views, $component)) + { + // set the edit link + if ($jRoute) + { + return \JRoute::_("index.php?option=" . $component . "&view=" . $views . "&task=" . $view . ".edit&id=" . $record->id . $ref); + } + return "index.php?option=" . $component . "&view=" . $views . "&task=" . $view . ".edit&id=" . $record->id . $ref; + } + return false; + } + + /** + * Can Edit (either any, or own) + * + * @param int $item The item to edit + * @param string $view The type of item to edit + * @param string $views The list view controller name + * @param string $component The component these views belong to + * + * @return bool if user can edit returns true els + * + */ + public static function allowEdit(&$item, $view, $views, $component = 'com_componentbuilder') + { + // build record + $record = new \stdClass(); + return self::canEditItem($record, $item, $view, $views, $component); + } + + + /** + * Can Edit (either any, or own) + * + * @param int $item The item to edit + * @param string $view The type of item to edit + * @param string $views The list view controller name + * @param string $component The component these views belong to + * + * @return bool if user can edit returns true els + * + */ + protected static function canEditItem(&$record, &$item, $view, $views, $component = 'com_componentbuilder') + { + // make sure the user has access to view + if (!Factory::getUser()->authorise($view. '.access', $component)) + { + return false; + } + // we start with false. + $can_edit = false; + // check that we have the ID + if (ObjectHelper::check($item) && isset($item->id)) + { + $record->id = (int) $item->id; + // check if created_by is available + if (isset($item->created_by) && $item->created_by > 0) + { + $record->created_by = (int) $item->created_by; + } + } + elseif (UtilitiesArrayHelper::check($item) && isset($item['id'])) + { + $record->id = (int) $item['id']; + // check if created_by is available + if (isset($item['created_by']) && $item['created_by'] > 0) + { + $record->created_by = (int) $item['created_by']; + } + } + elseif (is_numeric($item)) + { + $record->id = (int) $item; + } + // check ID + if (isset($record->id) && $record->id > 0) + { + // get user action permission to edit + $action = self::getActions($view, $record, $views, 'edit', str_replace('com_', '', $component)); + // check if the view permission is set + if (($can_edit = $action->get($view . '.edit', 'none-set')) === 'none-set') + { + // fall back on the core permission then (this can be an issue) + $can_edit = ($action->get('core.edit', false) || $action->get('core.edit.own', false)); + } + } + return $can_edit; + } + + /** + * set subform type table + * + * @param array $head The header names + * @param array $rows The row values + * @param string $idName The prefix to the table id + * + * @return string + * + */ + public static function setSubformTable($head, $rows, $idName) + { + $table[] = "
    "; + $table[] = "\t
    "; + $table[] = "\t\t
    "; + $table[] = "\t\t\t"; + $table[] = "\t\t\t\t"; + $table[] = "\t\t\t\t\t"; + $table[] = "\t\t\t\t\t\t"; + $table[] = "\t\t\t\t\t"; + $table[] = "\t\t\t\t"; + $table[] = "\t\t\t\t"; + foreach ($rows as $row) + { + $table[] = "\t\t\t\t\t"; + $table[] = "\t\t\t\t\t\t" . $row; + $table[] = "\t\t\t\t\t"; + } + $table[] = "\t\t\t\t"; + $table[] = "\t\t\t
    " . implode("", $head) . "
    "; + $table[] = "\t\t
    "; + $table[] = "\t
    "; + $table[] = "
    "; + // return the table + return implode("\n", $table); + } + + + /** + * Change to nice fancy date + */ + public static function fancyDate($date, $check_stamp = true) + { + if ($check_stamp && !self::isValidTimeStamp($date)) + { + $date = strtotime($date); + } + return date('jS \o\f F Y',$date); + } + + /** + * get date based in period past + */ + public static function fancyDynamicDate($date, $check_stamp = true) + { + if ($check_stamp && !self::isValidTimeStamp($date)) + { + $date = strtotime($date); + } + // older then year + $lastyear = date("Y", strtotime("-1 year")); + $tragetyear = date("Y", $date); + if ($tragetyear <= $lastyear) + { + return date('m/d/y', $date); + } + // same day + $yesterday = strtotime("-1 day"); + if ($date > $yesterday) + { + return date('g:i A', $date); + } + // just month day + return date('M j', $date); + } + + /** + * Change to nice fancy day time and date + */ + public static function fancyDayTimeDate($time, $check_stamp = true) + { + if ($check_stamp && !self::isValidTimeStamp($time)) + { + $time = strtotime($time); + } + return date('D ga jS \o\f F Y',$time); + } + + /** + * Change to nice fancy time and date + */ + public static function fancyDateTime($time, $check_stamp = true) + { + if ($check_stamp && !self::isValidTimeStamp($time)) + { + $time = strtotime($time); + } + return date('(G:i) jS \o\f F Y',$time); + } + + /** + * Change to nice hour:minutes time + */ + public static function fancyTime($time, $check_stamp = true) + { + if ($check_stamp && !self::isValidTimeStamp($time)) + { + $time = strtotime($time); + } + return date('G:i',$time); + } + + /** + * set the date day as Sunday through Saturday + */ + public static function setDayName($date, $check_stamp = true) + { + if ($check_stamp && !self::isValidTimeStamp($date)) + { + $date = strtotime($date); + } + return date('l', $date); + } + + /** + * set the date month as January through December + */ + public static function setMonthName($date, $check_stamp = true) + { + if ($check_stamp && !self::isValidTimeStamp($date)) + { + $date = strtotime($date); + } + return date('F', $date); + } + + /** + * set the date day as 1st + */ + public static function setDay($date, $check_stamp = true) + { + if ($check_stamp && !self::isValidTimeStamp($date)) + { + $date = strtotime($date); + } + return date('jS', $date); + } + + /** + * set the date month as 5 + */ + public static function setMonth($date, $check_stamp = true) + { + if ($check_stamp && !self::isValidTimeStamp($date)) + { + $date = strtotime($date); + } + return date('n', $date); + } + + /** + * set the date year as 2004 (for charts) + */ + public static function setYear($date, $check_stamp = true) + { + if ($check_stamp && !self::isValidTimeStamp($date)) + { + $date = strtotime($date); + } + return date('Y', $date); + } + + /** + * set the date as 2004/05 (for charts) + */ + public static function setYearMonth($date, $spacer = '/', $check_stamp = true) + { + if ($check_stamp && !self::isValidTimeStamp($date)) + { + $date = strtotime($date); + } + return date('Y' . $spacer . 'm', $date); + } + + /** + * set the date as 2004/05/03 (for charts) + */ + public static function setYearMonthDay($date, $spacer = '/', $check_stamp = true) + { + if ($check_stamp && !self::isValidTimeStamp($date)) + { + $date = strtotime($date); + } + return date('Y' . $spacer . 'm' . $spacer . 'd', $date); + } + + /** + * set the date as 03/05/2004 + */ + public static function setDayMonthYear($date, $spacer = '/', $check_stamp = true) + { + if ($check_stamp && !self::isValidTimeStamp($date)) + { + $date = strtotime($date); + } + return date('d' . $spacer . 'm' . $spacer . 'Y', $date); + } + + /** + * Check if string is a valid time stamp + */ + public static function isValidTimeStamp($timestamp) + { + return ((int) $timestamp === $timestamp) + && ($timestamp <= PHP_INT_MAX) + && ($timestamp >= ~PHP_INT_MAX); + } + + /** + * Check if string is a valid date + * https://www.php.net/manual/en/function.checkdate.php#113205 + */ + public static function isValidateDate($date, $format = 'Y-m-d H:i:s') + { + $d = DateTime::createFromFormat($format, $date); + return $d && $d->format($format) == $date; + } + + + /** + * The subform layouts + **/ + protected static $subformLayouts = false; + + /** + * get the subform layout + * + * @input string The view name + * @input string The string name + * + * @returns string on success + **/ + public static function getSubformLayout($view, $field, $default = 'repeatablejcb') + { + // get global values + if (self::$subformLayouts === false) + { + self::$subformLayouts = \JComponentHelper::getParams('com_componentbuilder')->get('subform_layouts', false); + } + // check what we found (else) return default + if (ObjectHelper::check(self::$subformLayouts)) + { + // looking for + $target = $view . '.' . $field; + foreach (self::$subformLayouts as $subform) + { + if ($target === $subform->view_field) + { + return $subform->layout; + } + elseif ('default' === $subform->view_field) + { + $default = $subform->layout; + } + } + } + return $default; + } + + + /** + * Check if a row already exist + * + * @param string $table The table from which to get the variable + * @param array $where The value where + * @param string $main The component in which the table is found + * + * @return int the id, or false + * + */ + public static function checkExist($table, $where, $what = 'id', $operator = '=', $main = 'componentbuilder') + { + // Get a db connection. + $db = Factory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array($what))); + if (empty($table)) + { + $query->from($db->quoteName('#__'.$main)); + } + else + { + $query->from($db->quoteName('#__'.$main.'_'.$table)); + } + if (UtilitiesArrayHelper::check($where)) + { + foreach ($where as $key => $value) + { + if (is_numeric($value)) + { + if (is_float($value + 0)) + { + $query->where($db->quoteName($key) . ' ' . $operator . ' ' . (float) $value); + } + else + { + $query->where($db->quoteName($key) . ' ' . $operator . ' ' . (int) $value); + } + } + elseif (is_bool($value)) + { + $query->where($db->quoteName($key) . ' ' . $operator . ' ' . (bool) $value); + } + // we do not allow arrays at this point + elseif (!UtilitiesArrayHelper::check($value)) + { + $query->where($db->quoteName($key) . ' ' . $operator . ' ' . $db->quote( (string) $value)); + } + else + { + return false; + } + } + } + else + { + return false; + } + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + return $db->loadResult(); + } + return false; + } + + + /** + * Making class or function name safe + * + * @input string The name you would like to make safe + * + * @returns string on success + * + * @since 3.0.9 + * + * @deprecated 4.0 - Use ClassfunctionHelper::safe($name); + */ + public static function safeClassFunctionName($name) + { + return ClassfunctionHelper::safe($name); + } + + /** + * Making field names safe + * + * @input string The you would like to make safe + * @input boolean The switch to return an ALL UPPER CASE string + * @input string The string to use in white space + * + * @returns string on success + * + * @since 3.0.9 + * + * @deprecated 4.0 - Use StringFieldHelper::safe($string, $allcap, $spacer); + */ + public static function safeFieldName($string, $allcap = false, $spacer = '_') + { + // set the local component option + self::setComponentOption(); + + return StringFieldHelper::safe($string, $allcap, $spacer); + } + + /** + * Making field type name safe + * + * @input string The you would like to make safe + * + * @returns string on success + * + * @since 3.0.9 + * + * @deprecated 4.0 - Use TypeHelper::safe($string); + */ + public static function safeTypeName($string) + { + // set the local component option + self::setComponentOption(); + + return TypeHelper::safe($string); + } + + /** + * Making namespace safe + * + * @input string The you would like to make safe + * + * @returns string on success + * + * @since 3.0.9 + * + * @deprecated 4.0 - Use NamespaceHelper::safe($string); + */ + public static function safeNamespace($string) + { + return NamespaceHelper::safe($string); + } + + /** + * get all strings between two other strings + * + * @param string $content The content to search + * @param string $start The starting value + * @param string $end The ending value + * + * @return array On success + * + * @since 3.0.9 + * + * @deprecated 4.0 - Use GetHelper::allBetween($content, $start, $end); + */ + public static function getAllBetween($content, $start, $end) + { + return GetHelper::allBetween($content, $start, $end); + } + + /** + * get a string between two other strings + * + * @param string $content The content to search + * @param string $start The starting value + * @param string $end The ending value + * @param string $default The default value if none found + * + * @return string On success / empty string on failure + * + * @since 3.0.9 + * + * @deprecated 4.0 - Use GetHelper::between($content, $start, $end, $default); + */ + public static function getBetween($content, $start, $end, $default = '') + { + return GetHelper::between($content, $start, $end, $default); + } + + /** + * bc math wrapper (very basic not for accounting) + * + * @param string $type The type bc math + * @param int $val1 The first value + * @param int $val2 The second value + * @param int $scale The scale value + * + * @return float|int + * + * @since 3.0.9 + * + * @deprecated 4.0 - Use MathHelper::bc($type, $val1, $val2, $scale); + */ + public static function bcmath($type, $val1, $val2, $scale = 0) + { + return MathHelper::bc($type, $val1, $val2, $scale); + } + + /** + * Basic sum of an array with more precision + * + * @param array $array The values to sum + * @param int $scale The scale value + * + * @return float|int + * + * @since 3.0.9 + * + * @deprecated 4.0 - Use MathHelper::sum($array, $scale); + */ + public static function bcsum($array, $scale = 4) + { + return MathHelper::sum($array, $scale); + } + + /** + * create plugin class name + * + * @input string The group name + * @input string The name + * + * @return string + * + * @since 3.0.9 + * + * @deprecated 4.0 - Use PluginHelper::safe($name, $group); + */ + public static function createPluginClassName($group, $name) + { + return PluginHelper::safeClassName($name, $group); + } + + /** + * Returns a GUIDv4 string + * + * Thanks to Dave Pearson (and other) + * https://www.php.net/manual/en/function.com-create-guid.php#119168 + * + * Uses the best cryptographically secure method + * for all supported platforms with fallback to an older, + * less secure version. + * + * @param bool $trim + * + * @return string + * + * @since 3.0.9 + * + * @deprecated 4.0 - Use GuidHelper::get($trim); + */ + public static function GUID($trim = true) + { + return GuidHelper::get($trim); + } + + /** + * Validate the Globally Unique Identifier ( and check if table already has this identifier) + * + * @param string $guid + * @param string $table + * @param int $id + * @param string|null $component + * + * @return bool + * + * @since 3.0.9 + * + * @deprecated 4.0 - Use GuidHelper::valid($guid, $table, $id, $component); + */ + public static function validGUID($guid, $table = null, $id = 0, $component = null) + { + // set the local component option + self::setComponentOption(); + + return GuidHelper::valid($guid, $table, $id, $component); + } + + /** + * get the ITEM of a GUID by table + * + * @param string $guid + * @param string $table + * @param string/array $what + * @param string|null $component + * + * @return mixed + * + * @since 3.0.9 + * + * @deprecated 4.0 - Use GuidHelper::valid($guid, $table, $id, $component); + */ + public static function getGUID($guid, $table, $what = 'a.id', $component = null) + { + // set the local component option + self::setComponentOption(); + + return GuidHelper::item($guid, $table, $what, $component); + } + + /** + * Validate the Globally Unique Identifier + * + * Thanks to Lewie + * https://stackoverflow.com/a/1515456/1429677 + * + * @param string $guid + * + * @return bool + * + * @deprecated 4.0 - Use GuidHelper::validate($guid); + */ + protected static function validateGUID($guid) + { + return GuidHelper::valid($guid); + } + + /** + * The zipper method + * + * @param string $workingDIR The directory where the items must be zipped + * @param string $filepath The path to where the zip file must be placed + * + * @return bool true On success + * + * @since 3.0.9 + * + * @deprecated 4.0 - Use FileHelper::zip($workingDIR, $filepath); + */ + public static function zip($workingDIR, &$filepath) + { + return FileHelper::zip($workingDIR, $filepath); + } + + /** + * get the content of a file + * + * @param string $path The path to the file + * @param mixed $none The return value if no content was found + * + * @return string On success + * + * @since 3.0.9 + * + * @deprecated 4.0 - Use FileHelper::getContent($path, $none); + */ + public static function getFileContents($path, $none = '') + { + return FileHelper::getContent($path, $none); + } + + /** + * Write a file to the server + * + * @param string $path The path and file name where to safe the data + * @param string $data The data to safe + * + * @return bool true On success + * + * @since 3.0.9 + * + * @deprecated 4.0 - Use FileHelper::write($path, $data); + */ + public static function writeFile($path, $data) + { + return FileHelper::write($path, $data); + } + + /** + * get all the file paths in folder and sub folders + * + * @param string $folder The local path to parse + * @param array $fileTypes The type of files to get + * + * @return array|null + * + * @since 3.0.9 + * + * @deprecated 4.0 - Use FileHelper::getPaths($folder, $fileTypes , $recurse, $full); + */ + public static function getAllFilePaths($folder, $fileTypes = array('\.php', '\.js', '\.css', '\.less'), $recurse = true, $full = true) + { + return FileHelper::getPaths($folder, $fileTypes , $recurse, $full); + } + + /** + * Get the file path or url + * + * @param string $type The (url/path) type to return + * @param string $target The Params Target name (if set) + * @param string $fileType The kind of filename to generate (if not set no file name is generated) + * @param string $key The key to adjust the filename (if not set ignored) + * @param string $default The default path if not set in Params (fallback path) + * @param bool $createIfNotSet The switch to create the folder if not found + * + * @return string On success the path or url is returned based on the type requested + * + * @since 3.0.9 + * + * @deprecated 4.0 - Use FileHelper::getPath($type, $target, $fileType, $key, $default, $createIfNotSet); + */ + public static function getFilePath($type = 'path', $target = 'filepath', $fileType = null, $key = '', $default = '', $createIfNotSet = true) + { + // set the local component option + self::setComponentOption(); + + return FileHelper::getPath($type, $target, $fileType, $key, $default, $createIfNotSet); + } + + /** + * Check if file exist + * + * @param string $path The url/path to check + * + * @return bool If exist true + * + * @since 3.0.9 + * + * @deprecated 4.0 - Use FileHelper::exists($path); + */ + public static function urlExists($path) + { + return FileHelper::exists($path); + } + + /** + * Set the component option + * + * @param String|null $option The option for the component. + * + * @since 3.0.11 + */ + public static function setComponentOption($option = null) + { + // set the local component option + if (empty($option)) + { + if (empty(Helper::$option) && property_exists(__CLASS__, 'ComponentCodeName')) + { + Helper::$option = 'com_' . self::$ComponentCodeName; + } + } + else + { + Helper::$option = $option; + } + } + + + /** + * Load the Composer Vendors + */ + public static function composerAutoload($target) + { + // insure we load the composer vendor only once + if (!isset(self::$composer[$target])) + { + // get the function name + $functionName = UtilitiesStringHelper::safe('compose' . $target); + // check if method exist + if (method_exists(__CLASS__, $functionName)) + { + return self::{$functionName}(); + } + return false; + } + return self::$composer[$target]; + } + + /** + * Load the Component xml manifest. + */ + public static function manifest() + { + $manifestUrl = JPATH_ADMINISTRATOR."/components/com_componentbuilder/componentbuilder.xml"; + return simplexml_load_file($manifestUrl); + } + + /** + * Joomla version object + */ + protected static $JVersion; + + /** + * set/get Joomla version + */ + public static function jVersion() + { + // check if set + if (!ObjectHelper::check(self::$JVersion)) + { + self::$JVersion = new Version(); + } + return self::$JVersion; + } + + /** + * Load the Contributors details. + */ + public static function getContributors() + { + // get params + $params = ComponentHelper::getParams('com_componentbuilder'); + // start contributors array + $contributors = []; + // get all Contributors (max 20) + $searchArray = range('0','20'); + foreach($searchArray as $nr) + { + if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 1 || $params->get("showContributor".$nr) == 3)) + { + // set link based of selected option + if($params->get("useContributor".$nr) == 1) + { + $link_front = ''; + $link_back = ''; + } + elseif($params->get("useContributor".$nr) == 2) + { + $link_front = ''; + $link_back = ''; + } + else + { + $link_front = ''; + $link_back = ''; + } + $contributors[$nr]['title'] = UtilitiesStringHelper::html($params->get("titleContributor".$nr)); + $contributors[$nr]['name'] = $link_front.UtilitiesStringHelper::html($params->get("nameContributor".$nr)).$link_back; + } + } + return $contributors; + } + + /** + * Load the Component Help URLs. + **/ + public static function getHelpUrl($view) + { + $user = Factory::getApplication()->getIdentity(); + $groups = $user->get('groups'); + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true); + $query->select(array('a.id','a.groups','a.target','a.type','a.article','a.url')); + $query->from('#__componentbuilder_help_document AS a'); + $query->where('a.admin_view = '.$db->quote($view)); + $query->where('a.location = 1'); + $query->where('a.published = 1'); + $db->setQuery($query); + $db->execute(); + if($db->getNumRows()) + { + $helps = $db->loadObjectList(); + if (UtilitiesArrayHelper::check($helps)) + { + foreach ($helps as $nr => $help) + { + if ($help->target == 1) + { + $targetgroups = json_decode($help->groups, true); + if (!array_intersect($targetgroups, $groups)) + { + // if user not in those target groups then remove the item + unset($helps[$nr]); + continue; + } + } + // set the return type + switch ($help->type) + { + // set joomla article + case 1: + return self::loadArticleLink($help->article); + break; + // set help text + case 2: + return self::loadHelpTextLink($help->id); + break; + // set Link + case 3: + return $help->url; + break; + } + } + } + } + return false; + } + + /** + * Get the Article Link. + **/ + protected static function loadArticleLink($id) + { + return Uri::root() . 'index.php?option=com_content&view=article&id='.$id.'&tmpl=component&layout=modal'; + } + + /** + * Get the Help Text Link. + **/ + protected static function loadHelpTextLink($id) + { + $token = Session::getFormToken(); + return 'index.php?option=com_componentbuilder&task=help.getText&id=' . (int) $id . '&' . $token . '=1'; + } + + /** + * Configure the Linkbar. + */ + public static function addSubmenu($submenu) + { + // load user for access menus + $user = Factory::getApplication()->getIdentity(); + // load the submenus to sidebar + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_DASHBOARD'), 'index.php?option=com_componentbuilder&view=componentbuilder', $submenu === 'componentbuilder'); + // Access control (compiler.submenu). + if ($user->authorise('compiler.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_COMPILER'), 'index.php?option=com_componentbuilder&view=compiler', $submenu === 'compiler'); + } + if ($user->authorise('joomla_component.access', 'com_componentbuilder') && $user->authorise('joomla_component.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_JOOMLA_COMPONENTS'), 'index.php?option=com_componentbuilder&view=joomla_components', $submenu === 'joomla_components'); + } + if ($user->authorise('joomla_module.access', 'com_componentbuilder') && $user->authorise('joomla_module.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_JOOMLA_MODULES'), 'index.php?option=com_componentbuilder&view=joomla_modules', $submenu === 'joomla_modules'); + } + if ($user->authorise('joomla_plugin.access', 'com_componentbuilder') && $user->authorise('joomla_plugin.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_JOOMLA_PLUGINS'), 'index.php?option=com_componentbuilder&view=joomla_plugins', $submenu === 'joomla_plugins'); + } + if ($user->authorise('power.access', 'com_componentbuilder') && $user->authorise('power.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_POWERS'), 'index.php?option=com_componentbuilder&view=powers', $submenu === 'powers'); + } + // Access control (search.access && search.submenu). + if ($user->authorise('search.access', 'com_componentbuilder') && $user->authorise('search.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_SEARCH'), 'index.php?option=com_componentbuilder&view=search', $submenu === 'search'); + } + if ($user->authorise('admin_view.access', 'com_componentbuilder') && $user->authorise('admin_view.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_ADMIN_VIEWS'), 'index.php?option=com_componentbuilder&view=admin_views', $submenu === 'admin_views'); + } + if ($user->authorise('custom_admin_view.access', 'com_componentbuilder') && $user->authorise('custom_admin_view.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_CUSTOM_ADMIN_VIEWS'), 'index.php?option=com_componentbuilder&view=custom_admin_views', $submenu === 'custom_admin_views'); + } + if ($user->authorise('site_view.access', 'com_componentbuilder') && $user->authorise('site_view.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_SITE_VIEWS'), 'index.php?option=com_componentbuilder&view=site_views', $submenu === 'site_views'); + } + if ($user->authorise('template.access', 'com_componentbuilder') && $user->authorise('template.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_TEMPLATES'), 'index.php?option=com_componentbuilder&view=templates', $submenu === 'templates'); + } + if ($user->authorise('layout.access', 'com_componentbuilder') && $user->authorise('layout.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_LAYOUTS'), 'index.php?option=com_componentbuilder&view=layouts', $submenu === 'layouts'); + } + if ($user->authorise('dynamic_get.access', 'com_componentbuilder') && $user->authorise('dynamic_get.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_DYNAMIC_GETS'), 'index.php?option=com_componentbuilder&view=dynamic_gets', $submenu === 'dynamic_gets'); + } + if ($user->authorise('custom_code.access', 'com_componentbuilder') && $user->authorise('custom_code.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_CUSTOM_CODES'), 'index.php?option=com_componentbuilder&view=custom_codes', $submenu === 'custom_codes'); + } + if ($user->authorise('placeholder.access', 'com_componentbuilder') && $user->authorise('placeholder.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_PLACEHOLDERS'), 'index.php?option=com_componentbuilder&view=placeholders', $submenu === 'placeholders'); + } + if ($user->authorise('library.access', 'com_componentbuilder') && $user->authorise('library.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_LIBRARIES'), 'index.php?option=com_componentbuilder&view=libraries', $submenu === 'libraries'); + } + if ($user->authorise('snippet.access', 'com_componentbuilder') && $user->authorise('snippet.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_SNIPPETS'), 'index.php?option=com_componentbuilder&view=snippets', $submenu === 'snippets'); + } + // Access control (get_snippets.submenu). + if ($user->authorise('get_snippets.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_GET_SNIPPETS'), 'index.php?option=com_componentbuilder&view=get_snippets', $submenu === 'get_snippets'); + } + if ($user->authorise('validation_rule.access', 'com_componentbuilder') && $user->authorise('validation_rule.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_VALIDATION_RULES'), 'index.php?option=com_componentbuilder&view=validation_rules', $submenu === 'validation_rules'); + } + if ($user->authorise('field.access', 'com_componentbuilder') && $user->authorise('field.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_FIELDS'), 'index.php?option=com_componentbuilder&view=fields', $submenu === 'fields'); + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_FIELD_FIELDS_CATEGORIES'), 'index.php?option=com_categories&view=categories&extension=com_componentbuilder.field', $submenu === 'categories.field'); + } + if ($user->authorise('fieldtype.access', 'com_componentbuilder') && $user->authorise('fieldtype.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_FIELDTYPES'), 'index.php?option=com_componentbuilder&view=fieldtypes', $submenu === 'fieldtypes'); + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_FIELDTYPE_FIELDTYPES_CATEGORIES'), 'index.php?option=com_categories&view=categories&extension=com_componentbuilder.fieldtype', $submenu === 'categories.fieldtype'); + } + if ($user->authorise('language_translation.access', 'com_componentbuilder') && $user->authorise('language_translation.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_LANGUAGE_TRANSLATIONS'), 'index.php?option=com_componentbuilder&view=language_translations', $submenu === 'language_translations'); + } + if ($user->authorise('language.access', 'com_componentbuilder') && $user->authorise('language.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_LANGUAGES'), 'index.php?option=com_componentbuilder&view=languages', $submenu === 'languages'); + } + if ($user->authorise('server.access', 'com_componentbuilder') && $user->authorise('server.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_SERVERS'), 'index.php?option=com_componentbuilder&view=servers', $submenu === 'servers'); + } + if ($user->authorise('help_document.access', 'com_componentbuilder') && $user->authorise('help_document.submenu', 'com_componentbuilder')) + { + \JHtmlSidebar::addEntry(Text::_('COM_COMPONENTBUILDER_SUBMENU_HELP_DOCUMENTS'), 'index.php?option=com_componentbuilder&view=help_documents', $submenu === 'help_documents'); + } + } + + /** + * UIKIT Component Classes + **/ + public static $uk_components = array( + 'data-uk-grid' => array( + 'grid' ), + 'uk-accordion' => array( + 'accordion' ), + 'uk-autocomplete' => array( + 'autocomplete' ), + 'data-uk-datepicker' => array( + 'datepicker' ), + 'uk-form-password' => array( + 'form-password' ), + 'uk-form-select' => array( + 'form-select' ), + 'data-uk-htmleditor' => array( + 'htmleditor' ), + 'data-uk-lightbox' => array( + 'lightbox' ), + 'uk-nestable' => array( + 'nestable' ), + 'UIkit.notify' => array( + 'notify' ), + 'data-uk-parallax' => array( + 'parallax' ), + 'uk-search' => array( + 'search' ), + 'uk-slider' => array( + 'slider' ), + 'uk-slideset' => array( + 'slideset' ), + 'uk-slideshow' => array( + 'slideshow', + 'slideshow-fx' ), + 'uk-sortable' => array( + 'sortable' ), + 'data-uk-sticky' => array( + 'sticky' ), + 'data-uk-timepicker' => array( + 'timepicker' ), + 'data-uk-tooltip' => array( + 'tooltip' ), + 'uk-placeholder' => array( + 'placeholder' ), + 'uk-dotnav' => array( + 'dotnav' ), + 'uk-slidenav' => array( + 'slidenav' ), + 'uk-form' => array( + 'form-advanced' ), + 'uk-progress' => array( + 'progress' ), + 'upload-drop' => array( + 'upload', 'form-file' ) + ); + + /** + * Add UIKIT Components + **/ + public static $uikit = false; + + /** + * Get UIKIT Components + **/ + public static function getUikitComp($content,$classes = array()) + { + if (strpos($content,'class="uk-') !== false) + { + // reset + $temp = []; + foreach (self::$uk_components as $looking => $add) + { + if (strpos($content,$looking) !== false) + { + $temp[] = $looking; + } + } + // make sure uikit is loaded to config + if (strpos($content,'class="uk-') !== false) + { + self::$uikit = true; + } + // sorter + if (UtilitiesArrayHelper::check($temp)) + { + // merger + if (UtilitiesArrayHelper::check($classes)) + { + $newTemp = array_merge($temp,$classes); + $temp = array_unique($newTemp); + } + return $temp; + } + } + if (UtilitiesArrayHelper::check($classes)) + { + return $classes; + } + return false; + } + + /** + * Prepares the xml document + */ + public static function xls($rows, $fileName = null, $title = null, $subjectTab = null, $creator = 'Vast Development Method', $description = null, $category = null,$keywords = null, $modified = null) + { + // set the user + // set fileName if not set + if (!$fileName) + { + $fileName = 'exported_'.Factory::getDate()->format('jS_F_Y'); + } + // set modified if not set + if (!$modified) + { + $modified = $user->name; + } + // set title if not set + if (!$title) + { + $title = 'Book1'; + } + // set tab name if not set + if (!$subjectTab) + { + $subjectTab = 'Sheet1'; + } + + // make sure we have the composer classes loaded + self::composerAutoload('phpspreadsheet'); + + // Create new Spreadsheet object + $spreadsheet = new Spreadsheet(); + + // Set document properties + $spreadsheet->getProperties() + ->setCreator($creator) + ->setCompany('Vast Development Method') + ->setLastModifiedBy($modified) + ->setTitle($title) + ->setSubject($subjectTab); + // The file type + $file_type = 'Xls'; + // set description + if ($description) + { + $spreadsheet->getProperties()->setDescription($description); + } + // set keywords + if ($keywords) + { + $spreadsheet->getProperties()->setKeywords($keywords); + } + // set category + if ($category) + { + $spreadsheet->getProperties()->setCategory($category); + } + + // Some styles + $headerStyles = array( + 'font' => array( + 'bold' => true, + 'color' => array('rgb' => '1171A3'), + 'size' => 12, + 'name' => 'Verdana' + )); + $sideStyles = array( + 'font' => array( + 'bold' => true, + 'color' => array('rgb' => '444444'), + 'size' => 11, + 'name' => 'Verdana' + )); + $normalStyles = array( + 'font' => array( + 'color' => array('rgb' => '444444'), + 'size' => 11, + 'name' => 'Verdana' + )); + + // Add some data + if (($size = UtilitiesArrayHelper::check($rows)) !== false) + { + $i = 1; + + // Based on data size we adapt the behaviour. + $xls_mode = 1; + if ($size > 3000) + { + $xls_mode = 3; + $file_type = 'Csv'; + } + elseif ($size > 2000) + { + $xls_mode = 2; + } + + // Set active sheet and get it. + $active_sheet = $spreadsheet->setActiveSheetIndex(0); + foreach ($rows as $array) + { + $a = 'A'; + foreach ($array as $value) + { + $active_sheet->setCellValue($a.$i, $value); + if ($xls_mode != 3) + { + if ($i == 1) + { + $active_sheet->getColumnDimension($a)->setAutoSize(true); + $active_sheet->getStyle($a.$i)->applyFromArray($headerStyles); + $active_sheet->getStyle($a.$i)->getAlignment()->setHorizontal(PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + } + elseif ($a === 'A') + { + $active_sheet->getStyle($a.$i)->applyFromArray($sideStyles); + } + elseif ($xls_mode == 1) + { + $active_sheet->getStyle($a.$i)->applyFromArray($normalStyles); + } + } + $a++; + } + $i++; + } + } + else + { + return false; + } + + // Rename worksheet + $spreadsheet->getActiveSheet()->setTitle($subjectTab); + + // Set active sheet index to the first sheet, so Excel opens this as the first sheet + $spreadsheet->setActiveSheetIndex(0); + + // Redirect output to a client's web browser (Excel5) + header('Content-Type: application/vnd.ms-excel'); + header('Content-Disposition: attachment;filename="' . $fileName . '.' . strtolower($file_type) .'"'); + header('Cache-Control: max-age=0'); + // If you're serving to IE 9, then the following may be needed + header('Cache-Control: max-age=1'); + + // If you're serving to IE over SSL, then the following may be needed + header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past + header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified + header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1 + header ('Pragma: public'); // HTTP/1.0 + + $writer = IOFactory::createWriter($spreadsheet, $file_type); + $writer->save('php://output'); + jexit(); + } + + /** + * Get CSV Headers + */ + public static function getFileHeaders($dataType) + { + // make sure we have the composer classes loaded + self::composerAutoload('phpspreadsheet'); + // get session object + $session = Factory::getSession(); + $package = $session->get('package', null); + $package = json_decode($package, true); + // set the headers + if(isset($package['dir'])) + { + // only load first three rows + $chunkFilter = new PhpOffice\PhpSpreadsheet\Reader\chunkReadFilter(2,1); + // identify the file type + $inputFileType = IOFactory::identify($package['dir']); + // create the reader for this file type + $excelReader = IOFactory::createReader($inputFileType); + // load the limiting filter + $excelReader->setReadFilter($chunkFilter); + $excelReader->setReadDataOnly(true); + // load the rows (only first three) + $excelObj = $excelReader->load($package['dir']); + $headers = []; + foreach ($excelObj->getActiveSheet()->getRowIterator() as $row) + { + if($row->getRowIndex() == 1) + { + $cellIterator = $row->getCellIterator(); + $cellIterator->setIterateOnlyExistingCells(false); + foreach ($cellIterator as $cell) + { + if (!is_null($cell)) + { + $headers[$cell->getColumn()] = $cell->getValue(); + } + } + $excelObj->disconnectWorksheets(); + unset($excelObj); + break; + } + } + return $headers; + } + return false; + } + + /** + * Load the Composer Vendor phpspreadsheet + */ + protected static function composephpspreadsheet() + { + // load the autoloader for phpspreadsheet + require_once JPATH_SITE . '/libraries/phpspreadsheet/vendor/autoload.php'; + // do not load again + self::$composer['phpspreadsheet'] = true; + + return true; + } + + /** + * Get a Variable + * + * @param string $table The table from which to get the variable + * @param string $where The value where + * @param string $whereString The target/field string where/name + * @param string $what The return field + * @param string $operator The operator between $whereString/field and $where/value + * @param string $main The component in which the table is found + * + * @return mix string/int/float + * @deprecated 3.3 Use GetHelper::var(...); + */ + public static function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = 'componentbuilder') + { + return GetHelper::var( + $table, + $where, + $whereString, + $what, + $operator, + $main + ); + } + + /** + * Get array of variables + * + * @param string $table The table from which to get the variables + * @param string $where The value where + * @param string $whereString The target/field string where/name + * @param string $what The return field + * @param string $operator The operator between $whereString/field and $where/value + * @param string $main The component in which the table is found + * @param bool $unique The switch to return a unique array + * + * @return array + * @deprecated 3.3 Use GetHelper::vars(...); + */ + public static function getVars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = 'componentbuilder', $unique = true) + { + return GetHelper::vars( + $table, + $where, + $whereString, + $what, + $operator, + $main, + $unique + ); + } + + /** + * Convert a json object to a string + * + * @input string $value The json string to convert + * + * @returns a string + * @deprecated 3.3 Use JsonHelper::string(...); + */ + public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name') + { + return JsonHelper::string( + $value, + $sperator, + $table, + $id, + $name + ); + } + + public static function isPublished($id,$type) + { + if ($type == 'raw') + { + $type = 'item'; + } + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true); + $query->select(array('a.published')); + $query->from('#__componentbuilder_'.$type.' AS a'); + $query->where('a.id = '. (int) $id); + $query->where('a.published = 1'); + $db->setQuery($query); + $db->execute(); + $found = $db->getNumRows(); + if($found) + { + return true; + } + return false; + } + + public static function getGroupName($id) + { + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true); + $query->select(array('a.title')); + $query->from('#__usergroups AS a'); + $query->where('a.id = '. (int) $id); + $db->setQuery($query); + $db->execute(); + $found = $db->getNumRows(); + if($found) + { + return $db->loadResult(); + } + return $id; + } + + /** + * Get the action permissions + * + * @param string $view The related view name + * @param int $record The item to act upon + * @param string $views The related list view name + * @param mixed $target Only get this permission (like edit, create, delete) + * @param string $component The target component + * @param object $user The user whose permissions we are loading + * + * @return object The CMSObject of permission/authorised actions + * + */ + public static function getActions($view, &$record = null, $views = null, $target = null, $component = 'componentbuilder', $user = 'null') + { + // load the user if not given + if (!ObjectHelper::check($user)) + { + // get the user object + $user = Factory::getApplication()->getIdentity(); + } + // load the CMSObject + $result = new CMSObject; + // make view name safe (just incase) + $view = UtilitiesStringHelper::safe($view); + if (UtilitiesStringHelper::check($views)) + { + $views = UtilitiesStringHelper::safe($views); + } + // get all actions from component + $actions = Access::getActionsFromFile( + JPATH_ADMINISTRATOR . '/components/com_' . $component . '/access.xml', + "/access/section[@name='component']/" + ); + // if non found then return empty CMSObject + if (empty($actions)) + { + return $result; + } + // get created by if not found + if (ObjectHelper::check($record) && !isset($record->created_by) && isset($record->id)) + { + $record->created_by = GetHelper::var($view, $record->id, 'id', 'created_by', '=', $component); + } + // set actions only set in component settings + $componentActions = array('core.admin', 'core.manage', 'core.options', 'core.export'); + // check if we have a target + $checkTarget = false; + if ($target) + { + // convert to an array + if (UtilitiesStringHelper::check($target)) + { + $target = array($target); + } + // check if we are good to go + if (UtilitiesArrayHelper::check($target)) + { + $checkTarget = true; + } + } + // loop the actions and set the permissions + foreach ($actions as $action) + { + // check target action filter + if ($checkTarget && self::filterActions($view, $action->name, $target)) + { + continue; + } + // set to use component default + $fallback = true; + // reset permission per/action + $permission = false; + $catpermission = false; + // set area + $area = 'comp'; + // check if the record has an ID and the action is item related (not a component action) + if (ObjectHelper::check($record) && isset($record->id) && $record->id > 0 && !in_array($action->name, $componentActions) && + (strpos($action->name, 'core.') !== false || strpos($action->name, $view . '.') !== false)) + { + // we are in item + $area = 'item'; + // The record has been set. Check the record permissions. + $permission = $user->authorise($action->name, 'com_' . $component . '.' . $view . '.' . (int) $record->id); + // if no permission found, check edit own + if (!$permission) + { + // With edit, if the created_by matches current user then dig deeper. + if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) + { + // the correct target + $coreCheck = (array) explode('.', $action->name); + // check that we have both local and global access + if ($user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component . '.' . $view . '.' . (int) $record->id) && + $user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component)) + { + // allow edit + $result->set($action->name, true); + // set not to use global default + // because we already validated it + $fallback = false; + } + else + { + // do not allow edit + $result->set($action->name, false); + $fallback = false; + } + } + } + elseif (UtilitiesStringHelper::check($views) && isset($record->catid) && $record->catid > 0) + { + // we are in item + $area = 'category'; + // set the core check + $coreCheck = explode('.', $action->name); + $core = $coreCheck[0]; + // make sure we use the core. action check for the categories + if (strpos($action->name, $view) !== false && strpos($action->name, 'core.') === false ) + { + $coreCheck[0] = 'core'; + $categoryCheck = implode('.', $coreCheck); + } + else + { + $categoryCheck = $action->name; + } + // The record has a category. Check the category permissions. + $catpermission = $user->authorise($categoryCheck, 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid); + if (!$catpermission && !is_null($catpermission)) + { + // With edit, if the created_by matches current user then dig deeper. + if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) + { + // check that we have both local and global access + if ($user->authorise('core.edit.own', 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid) && + $user->authorise($core . '.edit.own', 'com_' . $component)) + { + // allow edit + $result->set($action->name, true); + // set not to use global default + // because we already validated it + $fallback = false; + } + else + { + // do not allow edit + $result->set($action->name, false); + $fallback = false; + } + } + } + } + } + // if allowed then fallback on component global settings + if ($fallback) + { + // if item/category blocks access then don't fall back on global + if ((($area === 'item') && !$permission) || (($area === 'category') && !$catpermission)) + { + // do not allow + $result->set($action->name, false); + } + // Finally remember the global settings have the final say. (even if item allow) + // The local item permissions can block, but it can't open and override of global permissions. + // Since items are created by users and global permissions is set by system admin. + else + { + $result->set($action->name, $user->authorise($action->name, 'com_' . $component)); + } + } + } + return $result; + } + + /** + * Filter the action permissions + * + * @param string $action The action to check + * @param array $targets The array of target actions + * + * @return boolean true if action should be filtered out + * + */ + protected static function filterActions(&$view, &$action, &$targets) + { + foreach ($targets as $target) + { + if (strpos($action, $view . '.' . $target) !== false || + strpos($action, 'core.' . $target) !== false) + { + return false; + break; + } + } + return true; + } + + /** + * Returns any Model object. + * + * @param string $type The model type to instantiate + * @param string $prefix Prefix for the model class name. Optional. + * @param string $component Component name the model belongs to. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * @throws \Exception + * @since 4.4 + */ + public static function getModel(string $type, string $prefix = 'Administrator', + string $component = 'componentbuilder', array $config = []) + { + // make sure the name is correct + $type = UtilitiesStringHelper::safe($type, 'F'); + $component = strtolower($component); + + if ($prefix !== 'Site' && $prefix !== 'Administrator') + { + $prefix = self::getPrefixFromModelPath($prefix); + } + + // Get the model through the MVCFactory + return Factory::getApplication()->bootComponent('com_' . $component)->getMVCFactory()->createModel($type, $prefix, $config); + } + + /** + * Get the prefix from the model path + * + * @param string $path The model path + * + * @return string The prefix value + * @since 4.4 + */ + protected static function getPrefixFromModelPath(string $path): string + { + // Check if $path starts with JPATH_ADMINISTRATOR path + if (str_starts_with($path, JPATH_ADMINISTRATOR . '/components/')) + { + return 'Administrator'; + } + // Check if $path starts with JPATH_SITE path + elseif (str_starts_with($path, JPATH_SITE . '/components/')) + { + return 'Site'; + } + + return 'Administrator'; + } + + /** + * Add to asset Table + */ + public static function setAsset($id, $table, $inherit = true) + { + $parent = Table::getInstance('Asset'); + $parent->loadByName('com_componentbuilder'); + + $parentId = $parent->id; + $name = 'com_componentbuilder.'.$table.'.'.$id; + $title = ''; + + $asset = Table::getInstance('Asset'); + $asset->loadByName($name); + + // Check for an error. + $error = $asset->getError(); + + if ($error) + { + return false; + } + else + { + // Specify how a new or moved node asset is inserted into the tree. + if ($asset->parent_id != $parentId) + { + $asset->setLocation($parentId, 'last-child'); + } + + // Prepare the asset to be stored. + $asset->parent_id = $parentId; + $asset->name = $name; + $asset->title = $title; + // get the default asset rules + $rules = self::getDefaultAssetRules('com_componentbuilder', $table, $inherit); + if ($rules instanceof AccessRules) + { + $asset->rules = (string) $rules; + } + + if (!$asset->check() || !$asset->store()) + { + Factory::getApplication()->enqueueMessage($asset->getError(), 'warning'); + return false; + } + else + { + // Create an asset_id or heal one that is corrupted. + $object = new \StdClass(); + + // Must be a valid primary key value. + $object->id = $id; + $object->asset_id = (int) $asset->id; + + // Update their asset_id to link to the asset table. + return Factory::getDbo()->updateObject('#__componentbuilder_'.$table, $object, 'id'); + } + } + return false; + } + + /** + * Gets the default asset Rules for a component/view. + */ + protected static function getDefaultAssetRules($component, $view, $inherit = true) + { + // if new or inherited + $assetId = 0; + // Only get the actual item rules if not inheriting + if (!$inherit) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + // check that there is a value + if ($db->getNumRows()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + } + } + // get asset rules + $result = Access::getAssetRules($assetId); + if ($result instanceof AccessRules) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($view !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + elseif ($inherit) + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count((array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules($_result); + // return filtered rules + return $rules; + } + } + return $result; + } + + /** + * xmlAppend + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement + * + * @return void + * @deprecated 3.3 Use FormHelper::append($xml, $node); + */ + public static function xmlAppend(&$xml, $node) + { + FormHelper::append($xml, $node); + } + + /** + * xmlComment + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param string $comment The comment to inject + * + * @return void + * @deprecated 3.3 Use FormHelper::comment($xml, $comment); + */ + public static function xmlComment(&$xml, $comment) + { + FormHelper::comment($xml, $comment); + } + + /** + * xmlAddAttributes + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param array $attributes The attributes to apply to the XML element + * + * @return null + * @deprecated 3.3 Use FormHelper::attributes($xml, $attributes); + */ + public static function xmlAddAttributes(&$xml, $attributes = []) + { + FormHelper::attributes($xml, $attributes); + } + + /** + * xmlAddOptions + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param array $options The options to apply to the XML element + * + * @return void + * @deprecated 3.3 Use FormHelper::options($xml, $options); + */ + public static function xmlAddOptions(&$xml, $options = []) + { + FormHelper::options($xml, $options); + } + + /** + * get the field object + * + * @param array $attributes The array of attributes + * @param string $default The default of the field + * @param array $options The options to apply to the XML element + * + * @return object + * @deprecated 3.3 Use FormHelper::field($attributes, $default, $options); + */ + public static function getFieldObject(&$attributes, $default = '', $options = null) + { + return FormHelper::field($attributes, $default, $options); + } + + /** + * get the field xml + * + * @param array $attributes The array of attributes + * @param array $options The options to apply to the XML element + * + * @return object + * @deprecated 3.3 Use FormHelper::xml($attributes, $options); + */ + public static function getFieldXML(&$attributes, $options = null) + { + return FormHelper::xml($attributes, $options); + } + + /** + * Render Bool Button + * + * @param array $args All the args for the button + * 0) name + * 1) additional (options class) // not used at this time + * 2) default + * 3) yes (name) + * 4) no (name) + * + * @return string The input html of the button + * + */ + public static function renderBoolButton() + { + $args = func_get_args(); + // check if there is additional button class + $additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time + // button attributes + $buttonAttributes = array( + 'type' => 'radio', + 'name' => isset($args[0]) ? UtilitiesStringHelper::html($args[0]) : 'bool_button', + 'label' => isset($args[0]) ? UtilitiesStringHelper::safe(UtilitiesStringHelper::html($args[0]), 'Ww') : 'Bool Button', // not seen anyway + 'class' => 'btn-group', + 'filter' => 'INT', + 'default' => isset($args[2]) ? (int) $args[2] : 0); + // set the button options + $buttonOptions = array( + '1' => isset($args[3]) ? UtilitiesStringHelper::html($args[3]) : 'JYES', + '0' => isset($args[4]) ? UtilitiesStringHelper::html($args[4]) : 'JNO'); + // return the input + return FormHelper::field($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input; + } + + /** + * Check if have an json string + * + * @input string The json string to check + * + * @returns bool true on success + * @deprecated 3.3 Use JsonHelper::check($string); + */ + public static function checkJson($string) + { + return JsonHelper::check($string); + } + + /** + * Check if have an object with a length + * + * @input object The object to check + * + * @returns bool true on success + * @deprecated 3.3 Use ObjectHelper::check($object); + */ + public static function checkObject($object) + { + return ObjectHelper::check($object); + } + + /** + * Check if have an array with a length + * + * @input array The array to check + * + * @returns bool/int number of items in array on success + * @deprecated 3.3 Use UtilitiesArrayHelper::check($array, $removeEmptyString); + */ + public static function checkArray($array, $removeEmptyString = false) + { + return UtilitiesArrayHelper::check($array, $removeEmptyString); + } + + /** + * Check if have a string with a length + * + * @input string The string to check + * + * @returns bool true on success + * @deprecated 3.3 Use UtilitiesStringHelper::check($string); + */ + public static function checkString($string) + { + return UtilitiesStringHelper::check($string); + } + + /** + * Check if we are connected + * Thanks https://stackoverflow.com/a/4860432/1429677 + * + * @returns bool true on success + */ + public static function isConnected() + { + // If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right? + $connected = @fsockopen("www.example.com", 80); + // website, port (try 80 or 443) + if ($connected) + { + //action when connected + $is_conn = true; + fclose($connected); + } + else + { + //action in connection failure + $is_conn = false; + } + return $is_conn; + } + + /** + * Merge an array of array's + * + * @input array The arrays you would like to merge + * + * @returns array on success + * @deprecated 3.3 Use UtilitiesArrayHelper::merge($arrays); + */ + public static function mergeArrays($arrays) + { + return UtilitiesArrayHelper::merge($arrays); + } + + // typo sorry! + public static function sorten($string, $length = 40, $addTip = true) + { + return self::shorten($string, $length, $addTip); + } + + /** + * Shorten a string + * + * @input string The you would like to shorten + * + * @returns string on success + * @deprecated 3.3 Use UtilitiesStringHelper::shorten(...); + */ + public static function shorten($string, $length = 40, $addTip = true) + { + return UtilitiesStringHelper::shorten($string, $length, $addTip); + } + + /** + * Making strings safe (various ways) + * + * @input string The you would like to make safe + * + * @returns string on success + * @deprecated 3.3 Use UtilitiesStringHelper::safe(...); + */ + public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true) + { + return UtilitiesStringHelper::safe( + $string, + $type, + $spacer, + $replaceNumbers, + $keepOnlyCharacters + ); + } + + /** + * Convert none English strings to code usable string + * + * @input an string + * + * @returns a string + * @deprecated 3.3 Use UtilitiesStringHelper::transliterate($string); + */ + public static function transliterate($string) + { + return UtilitiesStringHelper::transliterate($string); + } + + /** + * make sure a string is HTML save + * + * @input an html string + * + * @returns a string + * @deprecated 3.3 Use UtilitiesStringHelper::html(...); + */ + public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40) + { + return UtilitiesStringHelper::html( + $var, + $charset, + $shorten, + $length + ); + } + + /** + * Convert all int in a string to an English word string + * + * @input an string with numbers + * + * @returns a string + * @deprecated 3.3 Use UtilitiesStringHelper::numbers($string); + */ + public static function replaceNumbers($string) + { + return UtilitiesStringHelper::numbers($string); + } + + /** + * Convert an integer into an English word string + * Thanks to Tom Nicholson + * + * @input an int + * @returns a string + * @deprecated 3.3 Use UtilitiesStringHelper::number($x); + */ + public static function numberToString($x) + { + return UtilitiesStringHelper::number($x); + } + + /** + * Random Key + * + * @returns a string + * @deprecated 3.3 Use UtilitiesStringHelper::random($size); + */ + public static function randomkey($size) + { + return UtilitiesStringHelper::random($size); + } + + /** + * Get The Encryption Keys + * + * @param string $type The type of key + * @param string/bool $default The return value if no key was found + * + * @return string On success + * + **/ + public static function getCryptKey($type, $default = false) + { + // Get the global params + $params = ComponentHelper::getParams('com_componentbuilder', true); + // Basic Encryption Type + if ('basic' === $type) + { + $basic_key = $params->get('basic_key', $default); + if (UtilitiesStringHelper::check($basic_key)) + { + return $basic_key; + } + } + + return $default; + } +} diff --git a/admin/src/Helper/HeaderCheck.php b/admin/src/Helper/HeaderCheck.php new file mode 100644 index 000000000..6718a3175 --- /dev/null +++ b/admin/src/Helper/HeaderCheck.php @@ -0,0 +1,130 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Helper; + +use Joomla\CMS\Factory; +use Joomla\CMS\Document\Document; +use Joomla\CMS\Application\CMSApplication; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Helper class for checking loaded scripts and styles in the document header. + * + * @since 3.2.0 + */ +class HeaderCheck +{ + /** + * @var CMSApplication Application object + * + * @since 3.2.0 + */ + protected CMSApplication $app; + + /** + * @var Document object + * + * @since 3.2.0 + */ + protected Document $document; + + /** + * Construct the app and document + * + * @since 3.2.0 + */ + public function __construct() + { + // Initializes the application object. + $this->app ??= Factory::getApplication(); + + // Initializes the document object. + $this->document = $this->app->getDocument(); + } + + /** + * Check if a JavaScript file is loaded in the document head. + * + * @param string $scriptName Name of the script to check. + * + * @return bool True if the script is loaded, false otherwise. + * @since 3.2.0 + */ + public function js_loaded(string $scriptName): bool + { + return $this->isLoaded($scriptName, 'scripts'); + } + + /** + * Check if a CSS file is loaded in the document head. + * + * @param string $scriptName Name of the stylesheet to check. + * + * @return bool True if the stylesheet is loaded, false otherwise. + * @since 3.2.0 + */ + public function css_loaded(string $scriptName): bool + { + return $this->isLoaded($scriptName, 'styleSheets'); + } + + /** + * Abstract method to check if a given script or stylesheet is loaded. + * + * @param string $scriptName Name of the script or stylesheet. + * @param string $type Type of asset to check ('scripts' or 'styleSheets'). + * + * @return bool True if the asset is loaded, false otherwise. + * @since 3.2.0 + */ + private function isLoaded(string $scriptName, string $type): bool + { + // UIkit specific check + if ($this->isUIkit($scriptName)) + { + return true; + } + + $head_data = $this->document->getHeadData(); + foreach (array_keys($head_data[$type]) as $script) + { + if (stristr($script, $scriptName)) + { + return true; + } + } + + return false; + } + + /** + * Check for UIkit framework specific conditions. + * + * @param string $scriptName Name of the script or stylesheet. + * + * @return bool True if UIkit specific conditions are met, false otherwise. + * @since 3.2.0 + */ + private function isUIkit(string $scriptName): bool + { + if (strpos($scriptName, 'uikit') !== false) + { + $get_template_name = $this->app->getTemplate('template')->template; + if (strpos($get_template_name, 'yoo') !== false) + { + return true; + } + } + return false; + } +} diff --git a/admin/models/rules/index.html b/admin/src/Helper/index.html similarity index 100% rename from admin/models/rules/index.html rename to admin/src/Helper/index.html diff --git a/admin/src/Model/Admin_custom_tabsModel.php b/admin/src/Model/Admin_custom_tabsModel.php new file mode 100644 index 000000000..8fb7239d2 --- /dev/null +++ b/admin/src/Model/Admin_custom_tabsModel.php @@ -0,0 +1,957 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Admin_custom_tabs Admin Model + * + * @since 1.6 + */ +class Admin_custom_tabsModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'tabs' => array( + 'fullwidth' => array( + 'tabs' + ), + 'above' => array( + 'admin_view' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/admin_custom_tabs.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/admin_custom_tabs.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.admin_custom_tabs'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'admin_custom_tabs', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->tabs)) + { + // Convert the tabs field to an array. + $tabs = new Registry; + $tabs->loadString($item->tabs); + $item->tabs = $tabs->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.admin_custom_tabs', 'admin_custom_tabs', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('admin_custom_tabs.edit.state', 'com_componentbuilder.admin_custom_tabs.' . (int) $id)) + || ($id == 0 && !$user->authorise('admin_custom_tabs.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('admin_custom_tabs.edit.created_by', 'com_componentbuilder.admin_custom_tabs.' . (int) $id)) + || ($id == 0 && !$user->authorise('admin_custom_tabs.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('admin_custom_tabs.edit.created', 'com_componentbuilder.admin_custom_tabs.' . (int) $id)) + || ($id == 0 && !$user->authorise('admin_custom_tabs.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update the tabs (sub form) layout + $form->setFieldAttribute('tabs', 'layout', ComponentbuilderHelper::getSubformLayout('admin_custom_tabs', 'tabs')); + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('admin_custom_tabs.delete', 'com_componentbuilder.admin_custom_tabs.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('admin_custom_tabs.edit.state', 'com_componentbuilder.admin_custom_tabs.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('admin_custom_tabs.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('admin_custom_tabs.edit', 'com_componentbuilder.admin_custom_tabs.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('admin_custom_tabs.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_admin_custom_tabs')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.admin_custom_tabs.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.admin_custom_tabs', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('admin_custom_tabs'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('admin_custom_tabs'); + } + + if (!$this->canDo->get('admin_custom_tabs.create') && !$this->canDo->get('admin_custom_tabs.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('admin_custom_tabs.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('admin_custom_tabs.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->admin_view) && !is_numeric($this->table->admin_view)) + { + $this->table->admin_view = $this->generateUnique('admin_view',$this->table->admin_view); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('admin_custom_tabs'); + } + + if (!$this->canDo->get('admin_custom_tabs.edit') && !$this->canDo->get('admin_custom_tabs.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('admin_custom_tabs.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('admin_custom_tabs.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the tabs items to data. + if (isset($data['tabs']) && is_array($data['tabs'])) + { + $tabs = new Registry; + $tabs->loadArray($data['tabs']); + $data['tabs'] = (string) $tabs; + } + elseif (!isset($data['tabs'])) + { + // Set the empty tabs to data + $data['tabs'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Admin_fieldsModel.php b/admin/src/Model/Admin_fieldsModel.php new file mode 100644 index 000000000..ec5944cb4 --- /dev/null +++ b/admin/src/Model/Admin_fieldsModel.php @@ -0,0 +1,988 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Admin_fields Admin Model + * + * @since 1.6 + */ +class Admin_fieldsModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'fields' => array( + 'fullwidth' => array( + 'note_on_views', + 'addfields' + ), + 'above' => array( + 'admin_view' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/admin_fields.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/admin_fields.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.admin_fields'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'admin_fields', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->addfields)) + { + // Convert the addfields field to an array. + $addfields = new Registry; + $addfields->loadString($item->addfields); + $item->addfields = $addfields->toArray(); + } + + // check what type of field array we have here (should be subform... but just incase) + // This could happen due to huge data sets + if (isset($item->addfields) && isset($item->addfields['field'])) + { + $bucket = array(); + foreach($item->addfields as $option => $values) + { + foreach($values as $nr => $value) + { + $bucket['addfields'.$nr][$option] = $value; + } + } + $item->addfields = $bucket; + // update the fields in the DB + $fieldsUpdate = new \stdClass(); + $fieldsUpdate->id = (int) $item->id; + $fieldsUpdate->addfields = json_encode($bucket); + $this->_db->updateObject('#__componentbuilder_admin_fields', $fieldsUpdate, 'id'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.admin_fields', 'admin_fields', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('admin_fields.edit.state', 'com_componentbuilder.admin_fields.' . (int) $id)) + || ($id == 0 && !$user->authorise('admin_fields.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('admin_fields.edit.created_by', 'com_componentbuilder.admin_fields.' . (int) $id)) + || ($id == 0 && !$user->authorise('admin_fields.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('admin_fields.edit.created', 'com_componentbuilder.admin_fields.' . (int) $id)) + || ($id == 0 && !$user->authorise('admin_fields.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update the addfields (sub form) layout + $form->setFieldAttribute('addfields', 'layout', ComponentbuilderHelper::getSubformLayout('admin_fields', 'addfields')); + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('admin_fields.delete', 'com_componentbuilder.admin_fields.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('admin_fields.edit.state', 'com_componentbuilder.admin_fields.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('admin_fields.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('admin_fields.edit', 'com_componentbuilder.admin_fields.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('admin_fields.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_admin_fields')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.admin_fields.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.admin_fields', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('admin_fields'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('admin_fields'); + } + + if (!$this->canDo->get('admin_fields.create') && !$this->canDo->get('admin_fields.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('admin_fields.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('admin_fields.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->admin_view) && !is_numeric($this->table->admin_view)) + { + $this->table->admin_view = $this->generateUnique('admin_view',$this->table->admin_view); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('admin_fields'); + } + + if (!$this->canDo->get('admin_fields.edit') && !$this->canDo->get('admin_fields.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('admin_fields.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('admin_fields.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + if (isset($data['addfields']) && UtilitiesArrayHelper::check($data['addfields'])) + { + // Sort fields by 'Tab' ASC, 'Alignment' ASC, 'Order in Edit' ASC + usort($data['addfields'], function ($a, $b) { + $val_a = sprintf('%02u', $a['tab']) . sprintf('%02u', $a['alignment']) . sprintf('%03u', $a['order_edit']); + $val_b = sprintf('%02u', $b['tab']) . sprintf('%02u', $b['alignment']) . sprintf('%03u', $b['order_edit']); + return strcmp($val_a, $val_b); + }); + } + + // Set the addfields items to data. + if (isset($data['addfields']) && is_array($data['addfields'])) + { + $addfields = new Registry; + $addfields->loadArray($data['addfields']); + $data['addfields'] = (string) $addfields; + } + elseif (!isset($data['addfields'])) + { + // Set the empty addfields to data + $data['addfields'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Admin_fields_conditionsModel.php b/admin/src/Model/Admin_fields_conditionsModel.php new file mode 100644 index 000000000..9b3ebbab1 --- /dev/null +++ b/admin/src/Model/Admin_fields_conditionsModel.php @@ -0,0 +1,978 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Admin_fields_conditions Admin Model + * + * @since 1.6 + */ +class Admin_fields_conditionsModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'conditions' => array( + 'fullwidth' => array( + 'note_on_conditions', + 'addconditions' + ), + 'above' => array( + 'admin_view' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/admin_fields_conditions.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/admin_fields_conditions.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.admin_fields_conditions'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'admin_fields_conditions', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->addconditions)) + { + // Convert the addconditions field to an array. + $addconditions = new Registry; + $addconditions->loadString($item->addconditions); + $item->addconditions = $addconditions->toArray(); + } + + // check what type of conditions array we have here (should be subform... but just incase) + // This could happen due to huge data sets + if (isset($item->addconditions) && isset($item->addconditions['target_field'])) + { + $bucket = array(); + foreach($item->addconditions as $option => $values) + { + foreach($values as $nr => $value) + { + $bucket['addconditions'.$nr][$option] = $value; + } + } + $item->addconditions = $bucket; + // update the fields + $conditionsUpdate = new \stdClass(); + $conditionsUpdate->id = (int) $item->id; + $conditionsUpdate->addconditions = json_encode($bucket); + $this->_db->updateObject('#__componentbuilder_admin_fields_conditions', $conditionsUpdate, 'id'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.admin_fields_conditions', 'admin_fields_conditions', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('admin_fields_conditions.edit.state', 'com_componentbuilder.admin_fields_conditions.' . (int) $id)) + || ($id == 0 && !$user->authorise('admin_fields_conditions.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('admin_fields_conditions.edit.created_by', 'com_componentbuilder.admin_fields_conditions.' . (int) $id)) + || ($id == 0 && !$user->authorise('admin_fields_conditions.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('admin_fields_conditions.edit.created', 'com_componentbuilder.admin_fields_conditions.' . (int) $id)) + || ($id == 0 && !$user->authorise('admin_fields_conditions.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update the addconditions (sub form) layout + $form->setFieldAttribute('addconditions', 'layout', ComponentbuilderHelper::getSubformLayout('admin_fields_conditions', 'addconditions')); + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('admin_fields_conditions.delete', 'com_componentbuilder.admin_fields_conditions.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('admin_fields_conditions.edit.state', 'com_componentbuilder.admin_fields_conditions.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('admin_fields_conditions.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('admin_fields_conditions.edit', 'com_componentbuilder.admin_fields_conditions.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('admin_fields_conditions.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_admin_fields_conditions')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.admin_fields_conditions.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.admin_fields_conditions', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('admin_fields_conditions'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('admin_fields_conditions'); + } + + if (!$this->canDo->get('admin_fields_conditions.create') && !$this->canDo->get('admin_fields_conditions.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('admin_fields_conditions.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('admin_fields_conditions.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->admin_view) && !is_numeric($this->table->admin_view)) + { + $this->table->admin_view = $this->generateUnique('admin_view',$this->table->admin_view); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('admin_fields_conditions'); + } + + if (!$this->canDo->get('admin_fields_conditions.edit') && !$this->canDo->get('admin_fields_conditions.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('admin_fields_conditions.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('admin_fields_conditions.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the addconditions items to data. + if (isset($data['addconditions']) && is_array($data['addconditions'])) + { + $addconditions = new Registry; + $addconditions->loadArray($data['addconditions']); + $data['addconditions'] = (string) $addconditions; + } + elseif (!isset($data['addconditions'])) + { + // Set the empty addconditions to data + $data['addconditions'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Admin_fields_relationsModel.php b/admin/src/Model/Admin_fields_relationsModel.php new file mode 100644 index 000000000..b75f6304a --- /dev/null +++ b/admin/src/Model/Admin_fields_relationsModel.php @@ -0,0 +1,1040 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Admin_fields_relations Admin Model + * + * @since 1.6 + */ +class Admin_fields_relationsModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'relations' => array( + 'fullwidth' => array( + 'note_on_relations', + 'addrelations' + ), + 'above' => array( + 'admin_view' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/admin_fields_relations.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/admin_fields_relations.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.admin_fields_relations'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'admin_fields_relations', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('admin_fields_relations__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'admin_fields_relations__'.$id); + ComponentbuilderHelper::set('admin_fields_relations__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->addrelations)) + { + // Convert the addrelations field to an array. + $addrelations = new Registry; + $addrelations->loadString($item->addrelations); + $item->addrelations = $addrelations->toArray(); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('admin_fields_relations__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'admin_fields_relations__'.$id); + ComponentbuilderHelper::set('admin_fields_relations__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.admin_fields_relations', 'admin_fields_relations', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('admin_fields_relations.edit.state', 'com_componentbuilder.admin_fields_relations.' . (int) $id)) + || ($id == 0 && !$user->authorise('admin_fields_relations.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('admin_fields_relations.edit.created_by', 'com_componentbuilder.admin_fields_relations.' . (int) $id)) + || ($id == 0 && !$user->authorise('admin_fields_relations.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('admin_fields_relations.edit.created', 'com_componentbuilder.admin_fields_relations.' . (int) $id)) + || ($id == 0 && !$user->authorise('admin_fields_relations.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update the addrelations (sub form) layout + $form->setFieldAttribute('addrelations', 'layout', ComponentbuilderHelper::getSubformLayout('admin_fields_relations', 'addrelations')); + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('admin_fields_relations.delete', 'com_componentbuilder.admin_fields_relations.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('admin_fields_relations.edit.state', 'com_componentbuilder.admin_fields_relations.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('admin_fields_relations.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('admin_fields_relations.edit', 'com_componentbuilder.admin_fields_relations.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('admin_fields_relations.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_admin_fields_relations')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.admin_fields_relations.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.admin_fields_relations', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('admin_fields_relations'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('admin_fields_relations'); + } + + if (!$this->canDo->get('admin_fields_relations.create') && !$this->canDo->get('admin_fields_relations.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('admin_fields_relations.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('admin_fields_relations.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->admin_view) && !is_numeric($this->table->admin_view)) + { + $this->table->admin_view = $this->generateUnique('admin_view',$this->table->admin_view); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('admin_fields_relations'); + } + + if (!$this->canDo->get('admin_fields_relations.edit') && !$this->canDo->get('admin_fields_relations.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('admin_fields_relations.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('admin_fields_relations.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the addrelations items to data. + if (isset($data['addrelations']) && is_array($data['addrelations'])) + { + $addrelations = new Registry; + $addrelations->loadArray($data['addrelations']); + $data['addrelations'] = (string) $addrelations; + } + elseif (!isset($data['addrelations'])) + { + // Set the empty addrelations to data + $data['addrelations'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Admin_viewModel.php b/admin/src/Model/Admin_viewModel.php new file mode 100644 index 000000000..f198cda10 --- /dev/null +++ b/admin/src/Model/Admin_viewModel.php @@ -0,0 +1,1916 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Admin_view Admin Model + * + * @since 1.6 + */ +class Admin_viewModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'name_single', + 'name_list', + 'type', + 'icon', + 'icon_add', + 'icon_category' + ), + 'right' => array( + 'short_description', + 'description', + 'add_fadein' + ), + 'fullwidth' => array( + 'note_linked_to_notice' + ), + 'above' => array( + 'system_name' + ), + 'under' => array( + 'not_required' + ) + ), + 'php' => array( + 'fullwidth' => array( + 'add_php_ajax', + 'php_ajaxmethod', + 'ajax_input', + 'add_php_getitem', + 'php_getitem', + 'add_php_getitems', + 'php_getitems', + 'add_php_getitems_after_all', + 'php_getitems_after_all', + 'add_php_getlistquery', + 'php_getlistquery', + 'add_php_getform', + 'php_getform', + 'add_php_before_save', + 'php_before_save', + 'add_php_save', + 'php_save', + 'add_php_postsavehook', + 'php_postsavehook', + 'add_php_allowadd', + 'php_allowadd', + 'add_php_allowedit', + 'php_allowedit', + 'add_php_before_cancel', + 'php_before_cancel', + 'add_php_after_cancel', + 'php_after_cancel', + 'add_php_batchcopy', + 'php_batchcopy', + 'add_php_batchmove', + 'php_batchmove', + 'add_php_before_publish', + 'php_before_publish', + 'add_php_after_publish', + 'php_after_publish', + 'add_php_before_delete', + 'php_before_delete', + 'add_php_after_delete', + 'php_after_delete', + 'add_php_document', + 'php_document' + ) + ), + 'custom_import' => array( + 'fullwidth' => array( + 'note_beginner_import', + 'note_advanced_import', + 'add_custom_import', + 'php_import_display', + 'html_import_view', + 'php_import', + 'php_import_headers', + 'php_import_setdata', + 'php_import_save', + 'php_import_ext' + ) + ), + 'mysql' => array( + 'left' => array( + 'mysql_table_engine', + 'mysql_table_charset', + 'mysql_table_collate', + 'mysql_table_row_format', + 'add_sql', + 'source', + 'addtables' + ), + 'fullwidth' => array( + 'sql' + ) + ), + 'settings' => array( + 'fullwidth' => array( + 'note_on_permissions', + 'addpermissions', + 'note_on_tabs', + 'addtabs', + 'note_custom_tabs_note', + 'note_on_linked_views', + 'addlinked_views' + ) + ), + 'fields' => array( + 'left' => array( + 'note_create_edit_notice', + 'alias_builder_type', + 'note_alias_builder_custom', + 'note_alias_builder_default', + 'alias_builder', + 'note_category_menu_switch', + 'add_category_submenu' + ), + 'right' => array( + 'note_create_edit_buttons' + ), + 'fullwidth' => array( + 'note_create_edit_display' + ) + ), + 'css' => array( + 'fullwidth' => array( + 'add_css_view', + 'css_view', + 'add_css_views', + 'css_views' + ) + ), + 'javascript' => array( + 'fullwidth' => array( + 'add_javascript_view_file', + 'javascript_view_file', + 'add_javascript_view_footer', + 'javascript_view_footer', + 'add_javascript_views_file', + 'javascript_views_file', + 'add_javascript_views_footer', + 'javascript_views_footer' + ) + ), + 'custom_buttons' => array( + 'left' => array( + 'add_custom_button', + 'custom_button' + ), + 'fullwidth' => array( + 'php_controller', + 'php_model', + 'php_controller_list', + 'php_model_list' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/admin_view.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/admin_view.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.admin_view'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'admin_view', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('admin_view__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'admin_view__'.$id); + ComponentbuilderHelper::set('admin_view__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->php_allowedit)) + { + // base64 Decode php_allowedit. + $item->php_allowedit = base64_decode($item->php_allowedit); + } + + if (!empty($item->php_postsavehook)) + { + // base64 Decode php_postsavehook. + $item->php_postsavehook = base64_decode($item->php_postsavehook); + } + + if (!empty($item->php_before_save)) + { + // base64 Decode php_before_save. + $item->php_before_save = base64_decode($item->php_before_save); + } + + if (!empty($item->php_getlistquery)) + { + // base64 Decode php_getlistquery. + $item->php_getlistquery = base64_decode($item->php_getlistquery); + } + + if (!empty($item->php_import_ext)) + { + // base64 Decode php_import_ext. + $item->php_import_ext = base64_decode($item->php_import_ext); + } + + if (!empty($item->php_after_publish)) + { + // base64 Decode php_after_publish. + $item->php_after_publish = base64_decode($item->php_after_publish); + } + + if (!empty($item->php_after_cancel)) + { + // base64 Decode php_after_cancel. + $item->php_after_cancel = base64_decode($item->php_after_cancel); + } + + if (!empty($item->php_batchmove)) + { + // base64 Decode php_batchmove. + $item->php_batchmove = base64_decode($item->php_batchmove); + } + + if (!empty($item->php_after_delete)) + { + // base64 Decode php_after_delete. + $item->php_after_delete = base64_decode($item->php_after_delete); + } + + if (!empty($item->php_import)) + { + // base64 Decode php_import. + $item->php_import = base64_decode($item->php_import); + } + + if (!empty($item->php_getitems_after_all)) + { + // base64 Decode php_getitems_after_all. + $item->php_getitems_after_all = base64_decode($item->php_getitems_after_all); + } + + if (!empty($item->php_getform)) + { + // base64 Decode php_getform. + $item->php_getform = base64_decode($item->php_getform); + } + + if (!empty($item->php_save)) + { + // base64 Decode php_save. + $item->php_save = base64_decode($item->php_save); + } + + if (!empty($item->php_allowadd)) + { + // base64 Decode php_allowadd. + $item->php_allowadd = base64_decode($item->php_allowadd); + } + + if (!empty($item->php_before_cancel)) + { + // base64 Decode php_before_cancel. + $item->php_before_cancel = base64_decode($item->php_before_cancel); + } + + if (!empty($item->php_batchcopy)) + { + // base64 Decode php_batchcopy. + $item->php_batchcopy = base64_decode($item->php_batchcopy); + } + + if (!empty($item->php_before_publish)) + { + // base64 Decode php_before_publish. + $item->php_before_publish = base64_decode($item->php_before_publish); + } + + if (!empty($item->php_before_delete)) + { + // base64 Decode php_before_delete. + $item->php_before_delete = base64_decode($item->php_before_delete); + } + + if (!empty($item->php_document)) + { + // base64 Decode php_document. + $item->php_document = base64_decode($item->php_document); + } + + if (!empty($item->sql)) + { + // base64 Decode sql. + $item->sql = base64_decode($item->sql); + } + + if (!empty($item->php_import_display)) + { + // base64 Decode php_import_display. + $item->php_import_display = base64_decode($item->php_import_display); + } + + if (!empty($item->php_import_setdata)) + { + // base64 Decode php_import_setdata. + $item->php_import_setdata = base64_decode($item->php_import_setdata); + } + + if (!empty($item->css_view)) + { + // base64 Decode css_view. + $item->css_view = base64_decode($item->css_view); + } + + if (!empty($item->css_views)) + { + // base64 Decode css_views. + $item->css_views = base64_decode($item->css_views); + } + + if (!empty($item->javascript_view_file)) + { + // base64 Decode javascript_view_file. + $item->javascript_view_file = base64_decode($item->javascript_view_file); + } + + if (!empty($item->javascript_view_footer)) + { + // base64 Decode javascript_view_footer. + $item->javascript_view_footer = base64_decode($item->javascript_view_footer); + } + + if (!empty($item->javascript_views_file)) + { + // base64 Decode javascript_views_file. + $item->javascript_views_file = base64_decode($item->javascript_views_file); + } + + if (!empty($item->javascript_views_footer)) + { + // base64 Decode javascript_views_footer. + $item->javascript_views_footer = base64_decode($item->javascript_views_footer); + } + + if (!empty($item->php_controller)) + { + // base64 Decode php_controller. + $item->php_controller = base64_decode($item->php_controller); + } + + if (!empty($item->php_model)) + { + // base64 Decode php_model. + $item->php_model = base64_decode($item->php_model); + } + + if (!empty($item->php_controller_list)) + { + // base64 Decode php_controller_list. + $item->php_controller_list = base64_decode($item->php_controller_list); + } + + if (!empty($item->php_model_list)) + { + // base64 Decode php_model_list. + $item->php_model_list = base64_decode($item->php_model_list); + } + + if (!empty($item->php_ajaxmethod)) + { + // base64 Decode php_ajaxmethod. + $item->php_ajaxmethod = base64_decode($item->php_ajaxmethod); + } + + if (!empty($item->html_import_view)) + { + // base64 Decode html_import_view. + $item->html_import_view = base64_decode($item->html_import_view); + } + + if (!empty($item->php_getitem)) + { + // base64 Decode php_getitem. + $item->php_getitem = base64_decode($item->php_getitem); + } + + if (!empty($item->php_import_headers)) + { + // base64 Decode php_import_headers. + $item->php_import_headers = base64_decode($item->php_import_headers); + } + + if (!empty($item->php_import_save)) + { + // base64 Decode php_import_save. + $item->php_import_save = base64_decode($item->php_import_save); + } + + if (!empty($item->php_getitems)) + { + // base64 Decode php_getitems. + $item->php_getitems = base64_decode($item->php_getitems); + } + + if (!empty($item->addpermissions)) + { + // Convert the addpermissions field to an array. + $addpermissions = new Registry; + $addpermissions->loadString($item->addpermissions); + $item->addpermissions = $addpermissions->toArray(); + } + + if (!empty($item->addtabs)) + { + // Convert the addtabs field to an array. + $addtabs = new Registry; + $addtabs->loadString($item->addtabs); + $item->addtabs = $addtabs->toArray(); + } + + if (!empty($item->addlinked_views)) + { + // Convert the addlinked_views field to an array. + $addlinked_views = new Registry; + $addlinked_views->loadString($item->addlinked_views); + $item->addlinked_views = $addlinked_views->toArray(); + } + + if (!empty($item->alias_builder)) + { + // Convert the alias_builder field to an array. + $alias_builder = new Registry; + $alias_builder->loadString($item->alias_builder); + $item->alias_builder = $alias_builder->toArray(); + } + + if (!empty($item->custom_button)) + { + // Convert the custom_button field to an array. + $custom_button = new Registry; + $custom_button->loadString($item->custom_button); + $item->custom_button = $custom_button->toArray(); + } + + if (!empty($item->addtables)) + { + // Convert the addtables field to an array. + $addtables = new Registry; + $addtables->loadString($item->addtables); + $item->addtables = $addtables->toArray(); + } + + if (!empty($item->ajax_input)) + { + // Convert the ajax_input field to an array. + $ajax_input = new Registry; + $ajax_input->loadString($item->ajax_input); + $item->ajax_input = $ajax_input->toArray(); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('admin_view__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'admin_view__'.$id); + ComponentbuilderHelper::set('admin_view__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + // update the fields + $objectUpdate = new \stdClass(); + $objectUpdate->id = (int) $item->id; + // repeatable values to check + $arrayChecker = array( + 'addlinked_views' => 'adminview', + 'ajax_input' => 'value_name', + 'custom_button' => 'name', + 'addpermissions' => 'action', + 'addtables' => 'table', + 'addtabs' => 'name' + ); + foreach ($arrayChecker as $_value => $checker) + { + // check what type of array we have here (should be subform... but just in case) + // This could happen due to huge data sets + if (isset($item->{$_value}) && isset($item->{$_value}[$checker])) + { + $bucket = array(); + foreach($item->{$_value} as $option => $values) + { + foreach($values as $nr => $value) + { + $bucket[$_value.$nr][$option] = $value; + } + } + $item->{$_value} = $bucket; + $objectUpdate->{$_value} = json_encode($bucket); + } + } + // be sure to update the table if we found repeatable fields that are still not converted + if (count((array) $objectUpdate) > 1) + { + $this->_db->updateObject('#__componentbuilder_admin_view', $objectUpdate, 'id'); + } + + // update the mysql_table_engine defaults + if (isset($item->mysql_table_engine) && is_numeric($item->mysql_table_engine)) + { + $item->mysql_table_engine = 'MyISAM'; + } + // update the mysql_table_charset defaults + if (isset($item->mysql_table_charset) && is_numeric($item->mysql_table_charset)) + { + $item->mysql_table_charset = 'utf8'; + } + // update the mysql_table_collate defaults + if (isset($item->mysql_table_collate) && is_numeric($item->mysql_table_collate)) + { + $item->mysql_table_collate = 'utf8_general_ci'; + } + + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.admin_view', 'admin_view', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('admin_view.edit.state', 'com_componentbuilder.admin_view.' . (int) $id)) + || ($id == 0 && !$user->authorise('admin_view.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('admin_view.edit.created_by', 'com_componentbuilder.admin_view.' . (int) $id)) + || ($id == 0 && !$user->authorise('admin_view.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('admin_view.edit.created', 'com_componentbuilder.admin_view.' . (int) $id)) + || ($id == 0 && !$user->authorise('admin_view.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update all editors to use this components global editor + $global_editor = ComponentHelper::getParams('com_componentbuilder')->get('editor', 'none'); + // now get all the editor fields + $editors = $form->getXml()->xpath("//field[@type='editor']"); + // check if we found any + if (UtilitiesArrayHelper::check($editors)) + { + foreach ($editors as $editor) + { + // get the field names + $name = (string) $editor['name']; + // set the field editor value (with none as fallback) + $form->setFieldAttribute($name, 'editor', $global_editor . '|none'); + } + } + + + // Only load the GUID if new item (or empty) + if (0 == $id || !($val = $form->getValue('guid'))) + { + $form->setValue('guid', null, GuidHelper::get()); + } + + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('admin_view.delete', 'com_componentbuilder.admin_view.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('admin_view.edit.state', 'com_componentbuilder.admin_view.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('admin_view.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('admin_view.edit', 'com_componentbuilder.admin_view.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('admin_view.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_admin_view')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.admin_view.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.admin_view', $data); + + return $data; + } + + /** + * Method to validate the form data. + * + * @param JForm $form The form to validate against. + * @param array $data The data to validate. + * @param string $group The name of the field group to validate. + * + * @return mixed Array of filtered data if valid, false otherwise. + * + * @see JFormRule + * @see JFilterInput + * @since 12.2 + */ + public function validate($form, $data, $group = null) + { + // check if the not_required field is set + if (isset($data['not_required']) && UtilitiesStringHelper::check($data['not_required'])) + { + $requiredFields = (array) explode(',',(string) $data['not_required']); + $requiredFields = array_unique($requiredFields); + // now change the required field attributes value + foreach ($requiredFields as $requiredField) + { + // make sure there is a string value + if (UtilitiesStringHelper::check($requiredField)) + { + // change to false + $form->setFieldAttribute($requiredField, 'required', 'false'); + // also clear the data set + $data[$requiredField] = ''; + } + } + } + return parent::validate($form, $data, $group); + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return array('guid'); + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + // we must also delete the linked tables found + if (UtilitiesArrayHelper::check($pks)) + { + $_tablesArray = array( + 'admin_fields', + 'admin_fields_conditions', + 'admin_fields_relations', + 'admin_custom_tabs' + ); + foreach($_tablesArray as $_updateTable) + { + // get the linked IDs + if ($_pks = ComponentbuilderHelper::getVars($_updateTable, $pks, 'admin_view', 'id')) + { + // load the model + $_Model = ComponentbuilderHelper::getModel($_updateTable); + // change publish state + $_Model->delete($_pks); + } + } + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + // we must also update all linked tables + if (UtilitiesArrayHelper::check($pks)) + { + $_tablesArray = array( + 'admin_fields', + 'admin_fields_conditions', + 'admin_fields_relations', + 'admin_custom_tabs' + ); + foreach($_tablesArray as $_updateTable) + { + // get the linked IDs + if ($_pks = ComponentbuilderHelper::getVars($_updateTable, $pks, 'admin_view', 'id')) + { + // load the model + $_Model = ComponentbuilderHelper::getModel($_updateTable); + // change publish state + $_Model->publish($_pks, $value); + } + } + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('admin_view'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('admin_view'); + } + + if (!$this->canDo->get('admin_view.create') && !$this->canDo->get('admin_view.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('admin_view.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('admin_view.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('admin_view'); + } + + if (!$this->canDo->get('admin_view.edit') && !$this->canDo->get('admin_view.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('admin_view.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('admin_view.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // if system name is empty create a system name from the name_single + if (empty($data['system_name']) || !UtilitiesStringHelper::check($data['system_name'])) + { + $data['system_name'] = $data['name_single']; + } + + // Set the GUID if empty or not valid + if (empty($data['guid']) && $data['id'] > 0) + { + // get the existing one + $data['guid'] = (string) GetHelper::var('admin_view', $data['id'], 'id', 'guid'); + } + + // Set the GUID if empty or not valid + while (!GuidHelper::valid($data['guid'], "admin_view", $data['id'])) + { + // must always be set + $data['guid'] = (string) GuidHelper::get(); + } + + // Set the addpermissions items to data. + if (isset($data['addpermissions']) && is_array($data['addpermissions'])) + { + $addpermissions = new Registry; + $addpermissions->loadArray($data['addpermissions']); + $data['addpermissions'] = (string) $addpermissions; + } + elseif (!isset($data['addpermissions'])) + { + // Set the empty addpermissions to data + $data['addpermissions'] = ''; + } + + // Set the addtabs items to data. + if (isset($data['addtabs']) && is_array($data['addtabs'])) + { + $addtabs = new Registry; + $addtabs->loadArray($data['addtabs']); + $data['addtabs'] = (string) $addtabs; + } + elseif (!isset($data['addtabs'])) + { + // Set the empty addtabs to data + $data['addtabs'] = ''; + } + + // Set the addlinked_views items to data. + if (isset($data['addlinked_views']) && is_array($data['addlinked_views'])) + { + $addlinked_views = new Registry; + $addlinked_views->loadArray($data['addlinked_views']); + $data['addlinked_views'] = (string) $addlinked_views; + } + elseif (!isset($data['addlinked_views'])) + { + // Set the empty addlinked_views to data + $data['addlinked_views'] = ''; + } + + // Set the alias_builder items to data. + if (isset($data['alias_builder']) && is_array($data['alias_builder'])) + { + $alias_builder = new Registry; + $alias_builder->loadArray($data['alias_builder']); + $data['alias_builder'] = (string) $alias_builder; + } + elseif (!isset($data['alias_builder'])) + { + // Set the empty alias_builder to data + $data['alias_builder'] = ''; + } + + // Set the custom_button items to data. + if (isset($data['custom_button']) && is_array($data['custom_button'])) + { + $custom_button = new Registry; + $custom_button->loadArray($data['custom_button']); + $data['custom_button'] = (string) $custom_button; + } + elseif (!isset($data['custom_button'])) + { + // Set the empty custom_button to data + $data['custom_button'] = ''; + } + + // Set the addtables items to data. + if (isset($data['addtables']) && is_array($data['addtables'])) + { + $addtables = new Registry; + $addtables->loadArray($data['addtables']); + $data['addtables'] = (string) $addtables; + } + elseif (!isset($data['addtables'])) + { + // Set the empty addtables to data + $data['addtables'] = ''; + } + + // Set the ajax_input items to data. + if (isset($data['ajax_input']) && is_array($data['ajax_input'])) + { + $ajax_input = new Registry; + $ajax_input->loadArray($data['ajax_input']); + $data['ajax_input'] = (string) $ajax_input; + } + elseif (!isset($data['ajax_input'])) + { + // Set the empty ajax_input to data + $data['ajax_input'] = ''; + } + + // Set the php_allowedit string to base64 string. + if (isset($data['php_allowedit'])) + { + $data['php_allowedit'] = base64_encode($data['php_allowedit']); + } + + // Set the php_postsavehook string to base64 string. + if (isset($data['php_postsavehook'])) + { + $data['php_postsavehook'] = base64_encode($data['php_postsavehook']); + } + + // Set the php_before_save string to base64 string. + if (isset($data['php_before_save'])) + { + $data['php_before_save'] = base64_encode($data['php_before_save']); + } + + // Set the php_getlistquery string to base64 string. + if (isset($data['php_getlistquery'])) + { + $data['php_getlistquery'] = base64_encode($data['php_getlistquery']); + } + + // Set the php_import_ext string to base64 string. + if (isset($data['php_import_ext'])) + { + $data['php_import_ext'] = base64_encode($data['php_import_ext']); + } + + // Set the php_after_publish string to base64 string. + if (isset($data['php_after_publish'])) + { + $data['php_after_publish'] = base64_encode($data['php_after_publish']); + } + + // Set the php_after_cancel string to base64 string. + if (isset($data['php_after_cancel'])) + { + $data['php_after_cancel'] = base64_encode($data['php_after_cancel']); + } + + // Set the php_batchmove string to base64 string. + if (isset($data['php_batchmove'])) + { + $data['php_batchmove'] = base64_encode($data['php_batchmove']); + } + + // Set the php_after_delete string to base64 string. + if (isset($data['php_after_delete'])) + { + $data['php_after_delete'] = base64_encode($data['php_after_delete']); + } + + // Set the php_import string to base64 string. + if (isset($data['php_import'])) + { + $data['php_import'] = base64_encode($data['php_import']); + } + + // Set the php_getitems_after_all string to base64 string. + if (isset($data['php_getitems_after_all'])) + { + $data['php_getitems_after_all'] = base64_encode($data['php_getitems_after_all']); + } + + // Set the php_getform string to base64 string. + if (isset($data['php_getform'])) + { + $data['php_getform'] = base64_encode($data['php_getform']); + } + + // Set the php_save string to base64 string. + if (isset($data['php_save'])) + { + $data['php_save'] = base64_encode($data['php_save']); + } + + // Set the php_allowadd string to base64 string. + if (isset($data['php_allowadd'])) + { + $data['php_allowadd'] = base64_encode($data['php_allowadd']); + } + + // Set the php_before_cancel string to base64 string. + if (isset($data['php_before_cancel'])) + { + $data['php_before_cancel'] = base64_encode($data['php_before_cancel']); + } + + // Set the php_batchcopy string to base64 string. + if (isset($data['php_batchcopy'])) + { + $data['php_batchcopy'] = base64_encode($data['php_batchcopy']); + } + + // Set the php_before_publish string to base64 string. + if (isset($data['php_before_publish'])) + { + $data['php_before_publish'] = base64_encode($data['php_before_publish']); + } + + // Set the php_before_delete string to base64 string. + if (isset($data['php_before_delete'])) + { + $data['php_before_delete'] = base64_encode($data['php_before_delete']); + } + + // Set the php_document string to base64 string. + if (isset($data['php_document'])) + { + $data['php_document'] = base64_encode($data['php_document']); + } + + // Set the sql string to base64 string. + if (isset($data['sql'])) + { + $data['sql'] = base64_encode($data['sql']); + } + + // Set the php_import_display string to base64 string. + if (isset($data['php_import_display'])) + { + $data['php_import_display'] = base64_encode($data['php_import_display']); + } + + // Set the php_import_setdata string to base64 string. + if (isset($data['php_import_setdata'])) + { + $data['php_import_setdata'] = base64_encode($data['php_import_setdata']); + } + + // Set the css_view string to base64 string. + if (isset($data['css_view'])) + { + $data['css_view'] = base64_encode($data['css_view']); + } + + // Set the css_views string to base64 string. + if (isset($data['css_views'])) + { + $data['css_views'] = base64_encode($data['css_views']); + } + + // Set the javascript_view_file string to base64 string. + if (isset($data['javascript_view_file'])) + { + $data['javascript_view_file'] = base64_encode($data['javascript_view_file']); + } + + // Set the javascript_view_footer string to base64 string. + if (isset($data['javascript_view_footer'])) + { + $data['javascript_view_footer'] = base64_encode($data['javascript_view_footer']); + } + + // Set the javascript_views_file string to base64 string. + if (isset($data['javascript_views_file'])) + { + $data['javascript_views_file'] = base64_encode($data['javascript_views_file']); + } + + // Set the javascript_views_footer string to base64 string. + if (isset($data['javascript_views_footer'])) + { + $data['javascript_views_footer'] = base64_encode($data['javascript_views_footer']); + } + + // Set the php_controller string to base64 string. + if (isset($data['php_controller'])) + { + $data['php_controller'] = base64_encode($data['php_controller']); + } + + // Set the php_model string to base64 string. + if (isset($data['php_model'])) + { + $data['php_model'] = base64_encode($data['php_model']); + } + + // Set the php_controller_list string to base64 string. + if (isset($data['php_controller_list'])) + { + $data['php_controller_list'] = base64_encode($data['php_controller_list']); + } + + // Set the php_model_list string to base64 string. + if (isset($data['php_model_list'])) + { + $data['php_model_list'] = base64_encode($data['php_model_list']); + } + + // Set the php_ajaxmethod string to base64 string. + if (isset($data['php_ajaxmethod'])) + { + $data['php_ajaxmethod'] = base64_encode($data['php_ajaxmethod']); + } + + // Set the html_import_view string to base64 string. + if (isset($data['html_import_view'])) + { + $data['html_import_view'] = base64_encode($data['html_import_view']); + } + + // Set the php_getitem string to base64 string. + if (isset($data['php_getitem'])) + { + $data['php_getitem'] = base64_encode($data['php_getitem']); + } + + // Set the php_import_headers string to base64 string. + if (isset($data['php_import_headers'])) + { + $data['php_import_headers'] = base64_encode($data['php_import_headers']); + } + + // Set the php_import_save string to base64 string. + if (isset($data['php_import_save'])) + { + $data['php_import_save'] = base64_encode($data['php_import_save']); + } + + // Set the php_getitems string to base64 string. + if (isset($data['php_getitems'])) + { + $data['php_getitems'] = base64_encode($data['php_getitems']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } +} diff --git a/admin/src/Model/Admin_viewsModel.php b/admin/src/Model/Admin_viewsModel.php new file mode 100644 index 000000000..cb3ef04b2 --- /dev/null +++ b/admin/src/Model/Admin_viewsModel.php @@ -0,0 +1,965 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Componentbuilder\Utilities\FilterHelper as JCBFilterHelper; +use VDM\Joomla\Utilities\FormHelper as JCBFormHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Admin_views List Model + * + * @since 1.6 + */ +class Admin_viewsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/admin_views.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.add_fadein','add_fadein', + 'a.type','type', + 'a.add_custom_button','add_custom_button', + 'a.add_php_ajax','add_php_ajax', + 'a.add_custom_import','add_custom_import', + 'a.system_name','system_name', + 'a.name_single','name_single', + 'a.short_description','short_description' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Get the filter form - Override the parent method + * + * @param array $data data + * @param boolean $loadData load current data + * + * @return \JForm|boolean The \JForm object or false on error + * + * @since JCB 2.12.5 + */ + public function getFilterForm($data = array(), $loadData = true) + { + // load form from the parent class + $form = parent::getFilterForm($data, $loadData); + + // Create the "joomla_component" filter + $attributes = array( + 'name' => 'joomla_component', + 'type' => 'list', + 'onchange' => 'this.form.submit();', + ); + $options = array( + '' => '- ' . Text::_('COM_COMPONENTBUILDER_NO_COMPONENTS_FOUND') . ' -' + ); + // check if we have joomla components + if (($joomla_components = JCBFilterHelper::names('joomla_component')) !== null) + { + $options = array( + '' => '- ' . Text::_('COM_COMPONENTBUILDER_SELECT_COMPONENT') . ' -' + ); + // make sure we do not lose the key values in normal merge + $options = $options + $joomla_components; + } + + $form->setField(JCBFormHelper::xml($attributes, $options),'filter'); + $form->setValue( + 'joomla_component', + 'filter', + $this->state->get("filter.joomla_component") + ); + array_push($this->filter_fields, 'joomla_component'); + + return $form; + } + + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $add_fadein = $this->getUserStateFromRequest($this->context . '.filter.add_fadein', 'filter_add_fadein'); + if ($formSubmited) + { + $add_fadein = $app->input->post->get('add_fadein'); + $this->setState('filter.add_fadein', $add_fadein); + } + + $type = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type'); + if ($formSubmited) + { + $type = $app->input->post->get('type'); + $this->setState('filter.type', $type); + } + + $add_custom_button = $this->getUserStateFromRequest($this->context . '.filter.add_custom_button', 'filter_add_custom_button'); + if ($formSubmited) + { + $add_custom_button = $app->input->post->get('add_custom_button'); + $this->setState('filter.add_custom_button', $add_custom_button); + } + + $add_php_ajax = $this->getUserStateFromRequest($this->context . '.filter.add_php_ajax', 'filter_add_php_ajax'); + if ($formSubmited) + { + $add_php_ajax = $app->input->post->get('add_php_ajax'); + $this->setState('filter.add_php_ajax', $add_php_ajax); + } + + $add_custom_import = $this->getUserStateFromRequest($this->context . '.filter.add_custom_import', 'filter_add_custom_import'); + if ($formSubmited) + { + $add_custom_import = $app->input->post->get('add_custom_import'); + $this->setState('filter.add_custom_import', $add_custom_import); + } + + $system_name = $this->getUserStateFromRequest($this->context . '.filter.system_name', 'filter_system_name'); + if ($formSubmited) + { + $system_name = $app->input->post->get('system_name'); + $this->setState('filter.system_name', $system_name); + } + + $name_single = $this->getUserStateFromRequest($this->context . '.filter.name_single', 'filter_name_single'); + if ($formSubmited) + { + $name_single = $app->input->post->get('name_single'); + $this->setState('filter.name_single', $name_single); + } + + $short_description = $this->getUserStateFromRequest($this->context . '.filter.short_description', 'filter_short_description'); + if ($formSubmited) + { + $short_description = $app->input->post->get('short_description'); + $this->setState('filter.short_description', $short_description); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('admin_view.access', 'com_componentbuilder.admin_view.' . (int) $item->id) && $user->authorise('admin_view.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // set selection value to a translatable value + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // convert add_fadein + $item->add_fadein = $this->selectionTranslation($item->add_fadein, 'add_fadein'); + // convert type + $item->type = $this->selectionTranslation($item->type, 'type'); + // convert add_custom_button + $item->add_custom_button = $this->selectionTranslation($item->add_custom_button, 'add_custom_button'); + // convert add_php_ajax + $item->add_php_ajax = $this->selectionTranslation($item->add_php_ajax, 'add_php_ajax'); + // convert add_custom_import + $item->add_custom_import = $this->selectionTranslation($item->add_custom_import, 'add_custom_import'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return string The translatable string. + */ + public function selectionTranslation($value,$name) + { + // Array of add_fadein language strings + if ($name === 'add_fadein') + { + $add_fadeinArray = array( + 1 => 'COM_COMPONENTBUILDER_ADMIN_VIEW_ADD', + 0 => 'COM_COMPONENTBUILDER_ADMIN_VIEW_REMOVE' + ); + // Now check if value is found in this array + if (isset($add_fadeinArray[$value]) && StringHelper::check($add_fadeinArray[$value])) + { + return $add_fadeinArray[$value]; + } + } + // Array of type language strings + if ($name === 'type') + { + $typeArray = array( + 1 => 'COM_COMPONENTBUILDER_ADMIN_VIEW_READWRITE', + 2 => 'COM_COMPONENTBUILDER_ADMIN_VIEW_READONLY' + ); + // Now check if value is found in this array + if (isset($typeArray[$value]) && StringHelper::check($typeArray[$value])) + { + return $typeArray[$value]; + } + } + // Array of add_custom_button language strings + if ($name === 'add_custom_button') + { + $add_custom_buttonArray = array( + 1 => 'COM_COMPONENTBUILDER_ADMIN_VIEW_YES', + 0 => 'COM_COMPONENTBUILDER_ADMIN_VIEW_NO' + ); + // Now check if value is found in this array + if (isset($add_custom_buttonArray[$value]) && StringHelper::check($add_custom_buttonArray[$value])) + { + return $add_custom_buttonArray[$value]; + } + } + // Array of add_php_ajax language strings + if ($name === 'add_php_ajax') + { + $add_php_ajaxArray = array( + 1 => 'COM_COMPONENTBUILDER_ADMIN_VIEW_YES', + 0 => 'COM_COMPONENTBUILDER_ADMIN_VIEW_NO' + ); + // Now check if value is found in this array + if (isset($add_php_ajaxArray[$value]) && StringHelper::check($add_php_ajaxArray[$value])) + { + return $add_php_ajaxArray[$value]; + } + } + // Array of add_custom_import language strings + if ($name === 'add_custom_import') + { + $add_custom_importArray = array( + 1 => 'COM_COMPONENTBUILDER_ADMIN_VIEW_YES', + 0 => 'COM_COMPONENTBUILDER_ADMIN_VIEW_NO' + ); + // Now check if value is found in this array + if (isset($add_custom_importArray[$value]) && StringHelper::check($add_custom_importArray[$value])) + { + return $add_custom_importArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_admin_view', 'a')); + + // do not use these filters in the export method + if (!isset($_export) || !$_export) + { + // Filtering "joomla components" + $filter_joomla_component = $this->state->get("filter.joomla_component"); + if ($filter_joomla_component !== null && !empty($filter_joomla_component)) + { + if (($ids = JCBFilterHelper::linked((int) $filter_joomla_component, 'joomla_component_admin_views')) !== null) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')'); + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + } + } + } + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.system_name LIKE '.$search.' OR a.name_single LIKE '.$search.' OR a.short_description LIKE '.$search.' OR a.description LIKE '.$search.' OR a.type LIKE '.$search.' OR a.name_list LIKE '.$search.')'); + } + } + + // Filter by Add_fadein. + $_add_fadein = $this->getState('filter.add_fadein'); + if (is_numeric($_add_fadein)) + { + if (is_float($_add_fadein)) + { + $query->where('a.add_fadein = ' . (float) $_add_fadein); + } + else + { + $query->where('a.add_fadein = ' . (int) $_add_fadein); + } + } + elseif (StringHelper::check($_add_fadein)) + { + $query->where('a.add_fadein = ' . $db->quote($db->escape($_add_fadein))); + } + // Filter by Type. + $_type = $this->getState('filter.type'); + if (is_numeric($_type)) + { + if (is_float($_type)) + { + $query->where('a.type = ' . (float) $_type); + } + else + { + $query->where('a.type = ' . (int) $_type); + } + } + elseif (StringHelper::check($_type)) + { + $query->where('a.type = ' . $db->quote($db->escape($_type))); + } + elseif (UtilitiesArrayHelper::check($_type)) + { + // Secure the array for the query + $_type = array_map( function ($val) use(&$db) { + if (is_numeric($val)) + { + if (is_float($val)) + { + return (float) $val; + } + else + { + return (int) $val; + } + } + elseif (StringHelper::check($val)) + { + return $db->quote($db->escape($val)); + } + }, $_type); + // Filter by the Type Array. + $query->where('a.type IN (' . implode(',', $_type) . ')'); + } + // Filter by Add_custom_button. + $_add_custom_button = $this->getState('filter.add_custom_button'); + if (is_numeric($_add_custom_button)) + { + if (is_float($_add_custom_button)) + { + $query->where('a.add_custom_button = ' . (float) $_add_custom_button); + } + else + { + $query->where('a.add_custom_button = ' . (int) $_add_custom_button); + } + } + elseif (StringHelper::check($_add_custom_button)) + { + $query->where('a.add_custom_button = ' . $db->quote($db->escape($_add_custom_button))); + } + // Filter by Add_php_ajax. + $_add_php_ajax = $this->getState('filter.add_php_ajax'); + if (is_numeric($_add_php_ajax)) + { + if (is_float($_add_php_ajax)) + { + $query->where('a.add_php_ajax = ' . (float) $_add_php_ajax); + } + else + { + $query->where('a.add_php_ajax = ' . (int) $_add_php_ajax); + } + } + elseif (StringHelper::check($_add_php_ajax)) + { + $query->where('a.add_php_ajax = ' . $db->quote($db->escape($_add_php_ajax))); + } + // Filter by Add_custom_import. + $_add_custom_import = $this->getState('filter.add_custom_import'); + if (is_numeric($_add_custom_import)) + { + if (is_float($_add_custom_import)) + { + $query->where('a.add_custom_import = ' . (float) $_add_custom_import); + } + else + { + $query->where('a.add_custom_import = ' . (int) $_add_custom_import); + } + } + elseif (StringHelper::check($_add_custom_import)) + { + $query->where('a.add_custom_import = ' . $db->quote($db->escape($_add_custom_import))); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get list export data. + * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExportData($pks, $user = null) + { + // setup the query + if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks) + { + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + $_export = true; + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_admin_view table + $query->from($db->quoteName('#__componentbuilder_admin_view', 'a')); + // The bulk export path + if ('bulk' === $pks) + { + $query->where('a.id > 0'); + } + // A large array of ID's will not work out well + elseif ($pks_size > 500) + { + // Use lowest ID + $query->where('a.id >= ' . (int) min($pks)); + // Use highest ID + $query->where('a.id <= ' . (int) max($pks)); + } + // The normal default path + else + { + $query->where('a.id IN (' . implode(',',$pks) . ')'); + } + + // do not use these filters in the export method + if (!isset($_export) || !$_export) + { + // Filtering "joomla components" + $filter_joomla_component = $this->state->get("filter.joomla_component"); + if ($filter_joomla_component !== null && !empty($filter_joomla_component)) + { + if (($ids = JCBFilterHelper::linked((int) $filter_joomla_component, 'joomla_component_admin_views')) !== null) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')'); + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + } + } + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.id desc'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('admin_view.access', 'com_componentbuilder.admin_view.' . (int) $item->id) && $user->authorise('admin_view.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // decode php_allowedit + $item->php_allowedit = base64_decode($item->php_allowedit); + // decode php_postsavehook + $item->php_postsavehook = base64_decode($item->php_postsavehook); + // decode php_before_save + $item->php_before_save = base64_decode($item->php_before_save); + // decode php_getlistquery + $item->php_getlistquery = base64_decode($item->php_getlistquery); + // decode php_import_ext + $item->php_import_ext = base64_decode($item->php_import_ext); + // decode php_after_publish + $item->php_after_publish = base64_decode($item->php_after_publish); + // decode php_after_cancel + $item->php_after_cancel = base64_decode($item->php_after_cancel); + // decode php_batchmove + $item->php_batchmove = base64_decode($item->php_batchmove); + // decode php_after_delete + $item->php_after_delete = base64_decode($item->php_after_delete); + // decode php_import + $item->php_import = base64_decode($item->php_import); + // decode php_getitems_after_all + $item->php_getitems_after_all = base64_decode($item->php_getitems_after_all); + // decode php_getform + $item->php_getform = base64_decode($item->php_getform); + // decode php_save + $item->php_save = base64_decode($item->php_save); + // decode php_allowadd + $item->php_allowadd = base64_decode($item->php_allowadd); + // decode php_before_cancel + $item->php_before_cancel = base64_decode($item->php_before_cancel); + // decode php_batchcopy + $item->php_batchcopy = base64_decode($item->php_batchcopy); + // decode php_before_publish + $item->php_before_publish = base64_decode($item->php_before_publish); + // decode php_before_delete + $item->php_before_delete = base64_decode($item->php_before_delete); + // decode php_document + $item->php_document = base64_decode($item->php_document); + // decode sql + $item->sql = base64_decode($item->sql); + // decode php_import_display + $item->php_import_display = base64_decode($item->php_import_display); + // decode php_import_setdata + $item->php_import_setdata = base64_decode($item->php_import_setdata); + // decode css_view + $item->css_view = base64_decode($item->css_view); + // decode css_views + $item->css_views = base64_decode($item->css_views); + // decode javascript_view_file + $item->javascript_view_file = base64_decode($item->javascript_view_file); + // decode javascript_view_footer + $item->javascript_view_footer = base64_decode($item->javascript_view_footer); + // decode javascript_views_file + $item->javascript_views_file = base64_decode($item->javascript_views_file); + // decode javascript_views_footer + $item->javascript_views_footer = base64_decode($item->javascript_views_footer); + // decode php_controller + $item->php_controller = base64_decode($item->php_controller); + // decode php_model + $item->php_model = base64_decode($item->php_model); + // decode php_controller_list + $item->php_controller_list = base64_decode($item->php_controller_list); + // decode php_model_list + $item->php_model_list = base64_decode($item->php_model_list); + // decode php_ajaxmethod + $item->php_ajaxmethod = base64_decode($item->php_ajaxmethod); + // decode html_import_view + $item->html_import_view = base64_decode($item->html_import_view); + // decode php_getitem + $item->php_getitem = base64_decode($item->php_getitem); + // decode php_import_headers + $item->php_import_headers = base64_decode($item->php_import_headers); + // decode php_import_save + $item->php_import_save = base64_decode($item->php_import_save); + // decode php_getitems + $item->php_getitems = base64_decode($item->php_getitems); + // unset the values we don't want exported. + unset($item->asset_id); + unset($item->checked_out); + unset($item->checked_out_time); + } + } + // Add headers to items array. + $headers = $this->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + array_unshift($items,$headers); + } + return $items; + } + } + 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 = Factory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_admin_view"); + if (UtilitiesArrayHelper::check($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; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.add_fadein'); + // Check if the value is an array + $_type = $this->getState('filter.type'); + if (UtilitiesArrayHelper::check($_type)) + { + $id .= ':' . implode(':', $_type); + } + // Check if this is only an number or string + elseif (is_numeric($_type) + || StringHelper::check($_type)) + { + $id .= ':' . $_type; + } + $id .= ':' . $this->getState('filter.add_custom_button'); + $id .= ':' . $this->getState('filter.add_php_ajax'); + $id .= ':' . $this->getState('filter.add_custom_import'); + $id .= ':' . $this->getState('filter.system_name'); + $id .= ':' . $this->getState('filter.name_single'); + $id .= ':' . $this->getState('filter.short_description'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_admin_view')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_admin_view'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Admins_custom_tabsModel.php b/admin/src/Model/Admins_custom_tabsModel.php new file mode 100644 index 000000000..1b2d38236 --- /dev/null +++ b/admin/src/Model/Admins_custom_tabsModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Admins_custom_tabs List Model + * + * @since 1.6 + */ +class Admins_custom_tabsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/admins_custom_tabs.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('admin_custom_tabs.access', 'com_componentbuilder.admin_custom_tabs.' . (int) $item->id) && $user->authorise('admin_custom_tabs.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_admin_custom_tabs', 'a')); + + // From the componentbuilder_admin_view table. + $query->select($db->quoteName('g.system_name','admin_view_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_admin_view', 'g') . ' ON (' . $db->quoteName('a.admin_view') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_admin_custom_tabs')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_admin_custom_tabs'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Admins_fieldsModel.php b/admin/src/Model/Admins_fieldsModel.php new file mode 100644 index 000000000..dc04d253a --- /dev/null +++ b/admin/src/Model/Admins_fieldsModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Admins_fields List Model + * + * @since 1.6 + */ +class Admins_fieldsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/admins_fields.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('admin_fields.access', 'com_componentbuilder.admin_fields.' . (int) $item->id) && $user->authorise('admin_fields.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_admin_fields', 'a')); + + // From the componentbuilder_admin_view table. + $query->select($db->quoteName('g.system_name','admin_view_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_admin_view', 'g') . ' ON (' . $db->quoteName('a.admin_view') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_admin_fields')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_admin_fields'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Admins_fields_conditionsModel.php b/admin/src/Model/Admins_fields_conditionsModel.php new file mode 100644 index 000000000..8dc0a1964 --- /dev/null +++ b/admin/src/Model/Admins_fields_conditionsModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Admins_fields_conditions List Model + * + * @since 1.6 + */ +class Admins_fields_conditionsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/admins_fields_conditions.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('admin_fields_conditions.access', 'com_componentbuilder.admin_fields_conditions.' . (int) $item->id) && $user->authorise('admin_fields_conditions.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_admin_fields_conditions', 'a')); + + // From the componentbuilder_admin_view table. + $query->select($db->quoteName('g.system_name','admin_view_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_admin_view', 'g') . ' ON (' . $db->quoteName('a.admin_view') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_admin_fields_conditions')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_admin_fields_conditions'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Admins_fields_relationsModel.php b/admin/src/Model/Admins_fields_relationsModel.php new file mode 100644 index 000000000..831635058 --- /dev/null +++ b/admin/src/Model/Admins_fields_relationsModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Admins_fields_relations List Model + * + * @since 1.6 + */ +class Admins_fields_relationsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/admins_fields_relations.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('admin_fields_relations.access', 'com_componentbuilder.admin_fields_relations.' . (int) $item->id) && $user->authorise('admin_fields_relations.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_admin_fields_relations', 'a')); + + // From the componentbuilder_admin_view table. + $query->select($db->quoteName('g.system_name','admin_view_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_admin_view', 'g') . ' ON (' . $db->quoteName('a.admin_view') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_admin_fields_relations')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_admin_fields_relations'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/AjaxModel.php b/admin/src/Model/AjaxModel.php new file mode 100644 index 000000000..67a749c9e --- /dev/null +++ b/admin/src/Model/AjaxModel.php @@ -0,0 +1,4126 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\Registry\Registry; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Gitea\Factory as GiteaFactory; +use VDM\Joomla\Componentbuilder\Package\Factory as PackageFactory; +use VDM\Joomla\Utilities\FileHelper; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Search\Factory as SearchFactory; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Utilities\Base64Helper; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\FieldHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Ajax List Model + * + * @since 1.6 + */ +class AjaxModel extends ListModel +{ + /** + * The component params. + * + * @var Registry + * @since 3.2.0 + */ + protected Registry $app_params; + + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + parent::__construct($config, $factory); + + $this->app_params = ComponentHelper::getParams('com_componentbuilder'); + $this->app ??= Factory::getApplication(); + } + + // Used in joomla_component + /** + * get the crowdin project details (html) + **/ + public function getCrowdinDetails($identifier, $key) + { + // set the url + $url = "https://api.crowdin.com/api/project/$identifier/info?key=$key&json"; + // get the details + if (($details = FileHelper::getContent($url, false)) !== false && JsonHelper::check($details)) + { + $details = json_decode($details, true); + // check if there is an error + if (isset($details['error'])) + { + return array('error' => '
    ' . $details['error']['message'] . '

    Identifier: ' . $identifier . '
    '); + } + // build the details html + if (isset($details['details'])) + { + $html = '
    '; + $html .= '

    ' . Text::_('COM_COMPONENTBUILDER_COMPONENT_SUCCESSFULLY_LINKED') . '

    '; + $html .= '

    ' . $details['details']['name'] . '

    '; + if (StringHelper::check($details['details']['description'])) + { + $html .= '

    '; + $html .= $details['details']['description']; + $html .= '

    '; + } + $html .= '
      '; + $html .= '
    • Number of participants: '; + $html .= $details['details']['participants_count']; + $html .= '
    • '; + $html .= '
    • Total strings count: '; + $html .= $details['details']['total_strings_count']; + $html .= '
    • '; + $html .= '
    • Total words count: '; + $html .= $details['details']['total_words_count']; + $html .= '
    • '; + $html .= '
    • Created: '; + $html .= ComponentbuilderHelper::fancyDate($details['details']['created']); + $html .= '
    • '; + $html .= '
    • Last activity: '; + $html .= ComponentbuilderHelper::fancyDate($details['details']['last_activity']); + $html .= '
    • '; + $html .= '
    '; + $html .= '
    '; + return ['html' => $html]; + } + } + return false; + } + + /** + * get the component details (html) + **/ + public function getComponentDetails($id) + { + // Need to find the asset id by the name of the component. + $db = Factory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName(array( + 'id','companyname','component_version','copyright','debug_linenr', + 'description','email','image','license','name','preferred_joomla_version', + 'short_description','website','author','add_placeholders', + 'system_name','mvc_versiondate'))) + ->from($db->quoteName('#__componentbuilder_joomla_component')) + ->where($db->quoteName('id') . ' = ' . (int) $id); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + $object = $db->loadObject(); + + return ['html' => $this->componentDetailsDisplay($object), 'preferred_joomla_version' => $object->preferred_joomla_version ?? 0]; + } + return false; + } + + /** + * get the JCB package info (html) + **/ + public function getJCBpackageInfo($package) + { + // convert URL + $url = base64_decode($package); + $url = str_replace('.zip', '.info', $url); + + // check if url exist + if ($info = FileHelper::getContent($url, false)) + { + $_info = PackageFactory::_('Crypt')->decrypt($info, 'local.legacy'); + + // check if we had success + if (!JsonHelper::check($_info)) + { + $_info = PackageFactory::_('Crypt')->decrypt($info, 'local.fof'); + } + + // check if we have json + if (JsonHelper::check($_info)) + { + $info = json_decode($_info, true); + + return [ + 'owner' => PackageFactory::_('Display.Details')->owner($info, true), + 'packages' => PackageFactory::_('Display.Details')->components($info) + ]; + } + } + + return [ + 'error' => Text::_('COM_COMPONENTBUILDER_JCB_PACKAGE_INFO_PATH_DOES_NOT_WORK_WE_ADVICE_YOU_BNOT_TO_CONTINUEB_WITH_THE_IMPORT_OF_THE_SELECTED_PACKAGE') + ]; + } + + /** + * set the component display + **/ + protected function componentDetailsDisplay($object) + { + // set some vars + $image = (StringHelper::check($object->image)) ? 'Joomla Component Image': ''; + $desc = (StringHelper::check($object->description)) ? $object->description : $object->short_description; + $placeholder = ($object->add_placeholders == 1) ? ' ' . Text::_('COM_COMPONENTBUILDER_YES') . ' ' : ' ' .Text::_('COM_COMPONENTBUILDER_NO') . ' ' ; + $debug = ($object->debug_linenr == 1) ? ' ' .Text::_('COM_COMPONENTBUILDER_YES') . '' : ' ' .Text::_('COM_COMPONENTBUILDER_NO') . ' ' ; + $html = array(); + $html[] = '

    ' . $object->name . ' (v' . $object->component_version . ')

    '; + $html[] = '

    ' . $desc . $image . '

    '; + $html[] = '
      '; + $html[] = '
    • ' . Text::_('COM_COMPONENTBUILDER_COMPANY') . ': ' . $object->companyname . '
    • '; + $html[] = '
    • ' . Text::_('COM_COMPONENTBUILDER_AUTHOR') . ': ' . $object->author . '
    • '; + $html[] = '
    • ' . Text::_('COM_COMPONENTBUILDER_EMAIL') . ': ' . $object->email . '
    • '; + $html[] = '
    • ' . Text::_('COM_COMPONENTBUILDER_WEBSITE') . ': ' . $object->website . '
    • '; + $html[] = '
    '; + $html[] = '

    ' . Text::_('COM_COMPONENTBUILDER_COMPONENT_GLOBAL_SETTINGS') . '

    '; + $html[] = '

    '; + $html[] = Text::_('COM_COMPONENTBUILDER_ADD_CUSTOM_CODE_PLACEHOLDERS') . '
    ' . $placeholder . '
    '; + $html[] = Text::_('COM_COMPONENTBUILDER_DEBUG_LINE_NUMBERS') . '
    ' . $debug ; + $html[] = '

    '; + $html[] = '

    ' . Text::_('COM_COMPONENTBUILDER_LICENSE') . '

    '; + $html[] = '

    ' . $object->license . '

    '; + $html[] = '

    ' . Text::_('COM_COMPONENTBUILDER_COPYRIGHT') . '

    '; + $html[] = '

    ' . $object->copyright . '

    '; + $html[] = ' ' . Text::_('COM_COMPONENTBUILDER_EDIT') . ' ' .$object->system_name . '

    '; + // now return the diplay + return implode("\n", $html); + } + + /** + * get the component details (html) + **/ + public function getCronPath($type) + { + $result = array('error' => '' . Text::_('COM_COMPONENTBUILDER_NO_CRONJOB_PATH_FOUND_SINCE_INCORRECT_TYPE_REQUESTED') . ''); + if ('backup' === $type) + { + $result['error'] = '' . Text::sprintf('COM_COMPONENTBUILDER_NO_CRONJOB_PATH_FOUND_FOR_S', $type) . ''; + if ($this->hasCurl()) + { + $path = '*/5 * * * * curl -s "' .\JUri::root() . 'index.php?option=com_componentbuilder&task=api.backup" >/dev/null 2>&1'; + } + else + { + $path = '*/5 * * * * wget "' .\JUri::root() . 'index.php?option=com_componentbuilder&task=api.backup" >/dev/null 2>&1'; + } + $result['path'] = '' . $path . ''; + } + elseif ('expand' === $type) + { + $result['error'] = '' . Text::sprintf('COM_COMPONENTBUILDER_NO_CRONJOB_PATH_FOUND_FOR_S', $type) . ''; + if ($this->hasCurl()) + { + $path = '* * * * * curl -s "' .\JUri::root() . 'index.php?option=com_componentbuilder&task=api.expand" >/dev/null 2>&1'; + } + else + { + $path = '* * * * * wget "' .\JUri::root() . 'index.php?option=com_componentbuilder&task=api.expand" >/dev/null 2>&1'; + } + $result['path'] = '' . $path . ''; + } + return $result; + } + + protected function hasCurl() + { + return function_exists('curl_version'); + } + + /** + * Check and if a notice is new (per/user) + * + * @param string|null $notice The current notice + * + * @return bool true if is new + * @since 2.0.0 + */ + public function isNew(?string $notice): bool + { + // first get the file path + $path_filename = FileHelper::getPath('path', 'usernotice', 'md', Factory::getUser()->username, JPATH_COMPONENT_ADMINISTRATOR); + + // check if the file is set + if (($content = FileHelper::getContent($path_filename, FALSE)) !== FALSE) + { + if ($notice == $content) + { + return false; + } + } + return true; + } + + /** + * Check if a notice has been read (per/user) + * + * @param string|null $notice The current notice + * + * @return bool true if is read + * @since 2.0.0 + */ + public function isRead(?string $notice): bool + { + // first get the file path + $path_filename = FileHelper::getPath('path', 'usernotice', 'md', Factory::getUser()->username, JPATH_COMPONENT_ADMINISTRATOR); + + // set as read if not already set + if (($content = FileHelper::getContent($path_filename, FALSE)) !== FALSE) + { + if ($notice == $content) + { + return true; + } + } + + return FileHelper::write($path_filename, $notice); + } + + /** + * get Current Version + * + * @param string|null $message The error messages if any. + * + * @return array The array of the notice or error message + * @since 2.3.0 + */ + public function getVersion($version = null) + { + try + { + // get the repository tags + $tags = GiteaFactory::_('Gitea.Repository.Tags')->list('joomla', 'Component-Builder'); + } + catch (DomainException $e) + { + return $this->getTokenForVersion($e->getMessage()); + } + catch (InvalidArgumentException $e) + { + return $this->getTokenForVersion($e->getMessage()); + } + catch (Exception $e) + { + return $this->getTokenForVersion($e->getMessage()); + } + // do we have tags returned + if (isset($tags[0]) && isset($tags[0]->name)) + { + // get the version + $manifest = ComponentbuilderHelper::manifest(); + $local_version = (string) $manifest->version; + $current_version = trim($tags[0]->name, 'vV'); + + // now check if this version is out dated + if ($current_version === $local_version) + { + return ['notice' => ' ' . Text::_('COM_COMPONENTBUILDER_UP_TO_DATE') . '']; + } + else + { + // check if this is beta version + $current_array = array_map(function ($v) { return (int) $v; }, (array) explode('.', $current_version)); + $local_array = array_map(function ($v) { return (int) $v; }, (array) explode('.', $local_version)); + if (($local_array[0] > $current_array[0]) || + ($local_array[0] == $current_array[0] && $local_array[1] > $current_array[1]) || + ($local_array[0] == $current_array[0] && $local_array[1] == $current_array[1] && $local_array[2] > $current_array[2])) + { + return ['notice' => ' ' . Text::_('COM_COMPONENTBUILDER_PRE_RELEASE') . '']; + } + else + { + // download link of the latest version + $download = "https://git.vdm.dev/api/v1/repos/joomla/Component-Builder/archive/" . $tags[0]->name . ".zip"; + + return ['notice' => ' ' . Text::_('COM_COMPONENTBUILDER_OUT_OF_DATE') . '! ' . Text::_('COM_COMPONENTBUILDER_DOWNLOAD_UPDATE') . '!']; + } + } + } + + return $this->getTokenForVersion(); + } + + /** + * Instructions to get Token for version + * + * @param string|null $message The error messages if any. + * + * @return array The array of the error message + * @since 2.3.0 + */ + protected function getTokenForVersion(?string $message = null): array + { + // the URL + $url = 'https://git.vdm.dev/user/settings/applications'; + + // create link + $a = ''; + $_a = ''; + + if ($message) + { + return ['error' => $a . $message . $a_ . Text::_('COM_COMPONENTBUILDER_GET_TOKEN') . $_a]; + } + + return ['error' => $a . Text::_('COM_COMPONENTBUILDER_GET_TOKEN_FROM_VDM_TO_GET_UPDATE_NOTICE_AND_ADD_IT_TO_YOUR_GLOBAL_OPTIONS') . $a_ . Text::_('COM_COMPONENTBUILDER_GET_TOKEN') . $_a]; + } + + /** + * get Wiki Page + * + * @param string|null $message The error messages if any. + * + * @return array The array of the page or error message + * @since 2.3.0 + */ + public function getWiki(string $name = 'Home'): array + { + try + { + // get the gitea wiki page im markdown + $wiki = GiteaFactory::_('Gitea.Repository.Wiki')->get('joomla', 'Component-Builder', $name); + + // now render the page in HTML + $page = $wiki->content ?? null; + } + catch (\DomainException $e) + { + return $this->getTokenForWiki($e->getMessage()); + } + catch (\InvalidArgumentException $e) + { + return $this->getTokenForWiki($e->getMessage()); + } + catch (\Exception $e) + { + return $this->getTokenForWiki($e->getMessage()); + } + + // get the html + if (isset($page)) + { + return ['page' => $page]; + } + + return $this->getTokenForWiki(); + } + + /** + * Instructions to get Token for wiki + * + * @param string|null $message The error messages if any. + * + * @return array The array of the error message + * @since 2.3.0 + */ + protected function getTokenForWiki(?string $message = null): array + { + if ($message) + { + return ['error' => $message]; + } + + return ['error' => Text::_('COM_COMPONENTBUILDER_THE_WIKI_CAN_ONLY_BE_LOADED_WHEN_YOUR_JOOMLA_COMPONENT_BUILDER_SYSTEM_HAS_INTERNET_CONNECTION')]; + } + + // Used in joomla_module + public function getModuleCode($data) + { + // reset the return array + $code = array(); + if (JsonHelper::check($data)) + { + // convert the data to object + $data = json_decode($data); + // set class + if (isset($data->class) && is_numeric($data->class) && ((int) $data->class == 2 || (int) $data->class == 1)) + { + $code['class'] = array(); + // add the code + $code['class']['code'] = '// Include the helper functions only once'; + $code['class']['code'] .= PHP_EOL . "JLoader::register('Mod[[[Module]]]Helper', __DIR__ . '/helper.php');"; + // set placement + $code['class']['merge'] = 1; + $code['class']['merge_target'] = 'prepend'; + } + // get data + if (isset($data->get) && UtilitiesArrayHelper::check($data->get)) + { + $code['get'] = array(); + // add the code + $code['get']['code'] = '// Include the data functions only once'; + $code['get']['code'] .= PHP_EOL . "JLoader::register('Mod[[[Module]]]Data', __DIR__ . '/data.php');"; + // set placement + $code['get']['merge'] = 1; + $code['get']['merge_target'] = 'prepend'; + } + // get libraries + if (isset($data->lib) && UtilitiesArrayHelper::check($data->lib)) + { + $code['lib'] = array(); + // add the code + $code['lib']['code'] = '[[[MOD_LIBRARIES]]]'; + // set placement + $code['lib']['merge'] = 1; + $code['lib']['merge_target'] = '// get the module class sfx (local)'; + } + } + // set the defaults + $code['css'] = array(); + $code['tmpl'] = array(); + // add the code + $code['css']['code'] = '// get the module class sfx (local)'; + $code['css']['code'] .= PHP_EOL . "\$moduleclass_sfx = htmlspecialchars(\$params->get('moduleclass_sfx'), ENT_COMPAT, 'UTF-8');"; + $code['tmpl']['code'] = '// load the default Tmpl'; + $code['tmpl']['code'] .= PHP_EOL . "require JModuleHelper::getLayoutPath('mod_[[[module]]]', \$params->get('layout', 'default'));"; + // set placement + $code['css']['merge'] = 1; + $code['css']['merge_target'] = '// load the default Tmpl'; + $code['tmpl']['merge'] = 1; + $code['tmpl']['merge_target'] = 'append'; + + return $code; + } + + + // Used in joomla_plugin + public function getClassCode($id, $type) + { + return ComponentbuilderHelper::getClassCode($id, $type); + } + + public function getClassCodeIds($id, $type, $key) + { + if ('property' === $type || 'method' === $type) + { + // we get the plugin group, or the powers + if ($key == 1) + { + return ComponentbuilderHelper::getVars('class_' . $type, $id, 'joomla_plugin_group', 'id'); + } + elseif ($key == 2) + { + return ComponentbuilderHelper::getVars('class_' . $type, 'powers', 'extension_type', 'id'); + } + } + elseif ('joomla_plugin_group' === $type) + { + return ComponentbuilderHelper::getVars($type, $id, 'class_extends', 'id'); + } + return false; + } + + public function getClassHeaderCode($id, $type) + { + if ('extends' === $type && ($head = GetHelper::var('class_' . $type, $id, 'id', 'head')) !== false && StringHelper::check($head)) + { + return base64_decode($head); + } + return false; + } + + + // Used in admin_view + 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', + 'admin_custom_tabs' => 'admins_custom_tabs', + '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', + 'custom_code' => 'custom_codes', + 'language' => true); + + public function checkAliasField($type) + { + // get the view name & id + $values = $this->getViewID(); + if (!is_null($values['a_id']) && $values['a_id'] > 0 && strlen($values['a_view']) && in_array($values['a_view'], $this->allowedViewsArray)) + { + // get the fields + if ($fields = GetHelper::var('admin_fields', $values['a_id'], 'admin_view', 'addfields')) + { + // open the fields + if (JsonHelper::check($fields)) + { + $fields = json_decode($fields, true); + if (UtilitiesArrayHelper::check($fields)) + { + foreach($fields as $field) + { + if (isset($field['alias']) && $field['alias'] == 1) + { + return true; + } + } + } + } + } + } + return false; + } + + public function checkCategoryField($type) + { + // get the view name & id + $values = $this->getViewID(); + if (!is_null($values['a_id']) && $values['a_id'] > 0 && strlen($values['a_view']) && in_array($values['a_view'], $this->allowedViewsArray)) + { + // get the fields + if ($fields = GetHelper::var('admin_fields', $values['a_id'], 'admin_view', 'addfields')) + { + // open the fields + if (JsonHelper::check($fields)) + { + $fields = json_decode($fields, true); + if (UtilitiesArrayHelper::check($fields)) + { + foreach($fields as $field) + { + if (isset($field['field']) && + ($field_values = ComponentbuilderHelper::getFieldNameAndType($field['field'])) !== false && + $field_values['type'] === 'category' ) + { + return true; + } + } + } + } + } + } + return false; + } + + public function getDynamicScripts($type) + { + // get from global helper + return ComponentbuilderHelper::getDynamicScripts($type); + } + + protected $functionArray = array( + // Library + 'rename' => 'setYesNo', + 'update' => 'setYesNo', + 'type' => 'setURLType', + // Admin View + 'field' => 'setItemNames', + 'listfield' => 'setItemNames', + 'joinfields' => 'setItemNames', + 'area' => 'setAreaName', + 'set' => 'setCode', + 'join_type' => 'setJoinType', + 'list' => 'setAdminBehaviour', + 'title' => 'setYesNo', + 'alias' => 'setYesNo', + 'sort' => 'setYesNo', + 'search' => 'setYesNo', + 'filter' => 'setYesNo', + 'link' => 'setYesNo', + 'permission' => 'setPermissions', + 'tab' => 'setTabName', + 'alignment' => 'setAlignmentName', + 'target_field' => 'setItemNames', + 'target_behavior' => 'setTargetBehavior', + 'target_relation' => 'setTargetRelation', + 'match_field' => 'setItemNames', + 'match_behavior' => 'setMatchBehavior', + 'match_options' => 'setMatchOptions', + // Joomla Component + 'menu' => 'setYesNo', + 'metadata' => 'setYesNo', + 'default_view' => 'setYesNo', + 'access' => 'setYesNo', + 'public_access' => 'setYesNo', + 'mainmenu' => 'setYesNo', + 'dashboard_list' => 'setYesNo', + 'submenu' => 'setYesNo', + 'dashboard_add' => 'setYesNo', + 'checkin' => 'setYesNo', + 'history' => 'setYesNo', + 'joomla_fields' => 'setYesNo', + 'port' => 'setYesNo', + 'edit_create_site_view' => 'setYesNo', + 'icomoon' => 'setIcoMoon', + 'customadminview' => 'setItemNames', + 'adminviews' => 'setItemNames', + 'adminview' => 'setItemNames', + 'siteview' => 'setItemNames', + 'before' => 'setItemNames'); + + protected function getLanguage($key) + { + $language = array( + // Library (folder file url) + 'rename' => Text::_('COM_COMPONENTBUILDER_RENAME'), + 'path' => Text::_('COM_COMPONENTBUILDER_TARGET_PATH'), + 'update' => Text::_('COM_COMPONENTBUILDER_UPDATE'), + // Admin View (fields) + 'field' => Text::_('COM_COMPONENTBUILDER_FIELD'), + 'listfield' => Text::_('COM_COMPONENTBUILDER_LIST_FIELD'), + 'joinfields' => Text::_('COM_COMPONENTBUILDER_JOIN_FIELDS'), + 'set' => Text::_('COM_COMPONENTBUILDER_GLUECODE'), + 'join_type' => Text::_('COM_COMPONENTBUILDER_JOIN_TYPE'), + 'list' => Text::_('COM_COMPONENTBUILDER_ADMIN_BEHAVIOUR'), + 'order_list' => Text::_('COM_COMPONENTBUILDER_ORDER_IN_LIST_VIEWS'), + 'title' => Text::_('COM_COMPONENTBUILDER_TITLE'), + 'alias' => Text::_('COM_COMPONENTBUILDER_ALIAS'), + 'sort' => Text::_('COM_COMPONENTBUILDER_SORTABLE'), + 'search' => Text::_('COM_COMPONENTBUILDER_SEARCHABLE'), + 'filter' => Text::_('COM_COMPONENTBUILDER_FILTER'), + 'link' => Text::_('COM_COMPONENTBUILDER_LINK'), + 'permission' => Text::_('COM_COMPONENTBUILDER_PERMISSIONS'), + 'tab' => Text::_('COM_COMPONENTBUILDER_TAB'), + 'alignment' => Text::_('COM_COMPONENTBUILDER_ALIGNMENT'), + 'order_edit' => Text::_('COM_COMPONENTBUILDER_ORDER_IN_EDIT'), + // Admin View (conditions) + 'target_field' => Text::_('COM_COMPONENTBUILDER_TARGET_FIELDS'), + 'target_behavior' => Text::_('COM_COMPONENTBUILDER_TARGET_BEHAVIOUR'), + 'target_relation' => Text::_('COM_COMPONENTBUILDER_TARGET_RELATION'), + 'match_field' => Text::_('COM_COMPONENTBUILDER_MATCH_FIELD'), + 'match_behavior' => Text::_('COM_COMPONENTBUILDER_MATCH_BEHAVIOUR'), + 'match_options' => Text::_('COM_COMPONENTBUILDER_MATCH_OPTIONS'), + // Joomla Component + 'menu' => Text::_('COM_COMPONENTBUILDER_ADD_MENU'), + 'metadata' => Text::_('COM_COMPONENTBUILDER_HAS_METADATA'), + 'default_view' => Text::_('COM_COMPONENTBUILDER_DEFAULT_VIEW'), + 'access' => Text::_('COM_COMPONENTBUILDER_ADD_ACCESS'), + 'public_access' => Text::_('COM_COMPONENTBUILDER_PUBLIC_ACCESS'), + 'mainmenu' => Text::_('COM_COMPONENTBUILDER_MAIN_MENU'), + 'dashboard_list' => Text::_('COM_COMPONENTBUILDER_DASHBOARD_LIST_OF_RECORDS'), + 'dashboard_add' => Text::_('COM_COMPONENTBUILDER_DASHBOARD_ADD_RECORD'), + 'submenu' => Text::_('COM_COMPONENTBUILDER_SUBMENU'), + 'checkin' => Text::_('COM_COMPONENTBUILDER_AUTO_CHECKIN'), + 'history' => Text::_('COM_COMPONENTBUILDER_KEEP_HISTORY'), + 'joomla_fields' => Text::_('COM_COMPONENTBUILDER_JOOMLA_FIELDS'), + 'port' => Text::_('COM_COMPONENTBUILDER_EXPORTIMPORT_DATA'), + 'edit_create_site_view' => Text::_('COM_COMPONENTBUILDER_EDITCREATE_SITE_VIEW'), + 'icomoon' => Text::_('COM_COMPONENTBUILDER_ICON'), + 'customadminview' => Text::_('COM_COMPONENTBUILDER_VIEW'), + 'adminviews' => Text::_('COM_COMPONENTBUILDER_VIEWS'), + 'adminview' => Text::_('COM_COMPONENTBUILDER_VIEW'), + 'siteview' => Text::_('COM_COMPONENTBUILDER_VIEW'), + 'before' => Text::_('COM_COMPONENTBUILDER_ORDER_BEFORE') + ); + // check if a unique value is available + if (isset($language[$key])) + { + return $language[$key]; + } + // check a shared value is available + if (strpos($key, '|=VDM=|') !== false) + { + $keys = explode('|=VDM=|', $key); + if (isset($language[$keys[1]])) + { + return $language[$keys[1]]; + } + } + return StringHelper::safe($keys[1], 'Ww'); + } + + protected $ref; + + protected $fieldsArray = array( + 'library_config' => 'addconfig', + 'library_files_folders_urls' => array('addurls', 'addfiles', 'addfolders', 'addfoldersfullpath', 'addfilesfullpath'), + 'admin_fields' => 'addfields', + 'admin_fields_conditions' => 'addconditions', + 'admin_fields_relations' => 'addrelations', + 'component_admin_views' => 'addadmin_views', + 'component_site_views' => 'addsite_views', + 'component_custom_admin_views' => 'addcustom_admin_views'); + + protected $allowedViewsArray = array( + 'admin_view', + 'joomla_component', + 'library'); + + protected $conversionCheck = array( + 'addfields' => 'field', + 'addconditions' => 'target_field', + 'addadmin_views' => 'adminview', + 'addconfig' => 'field', + 'addcustom_admin_views' => 'customadminview', + 'addcustommenus' => 'name', + 'addsite_views' => 'siteview', + 'sql_tweak' => 'adminview', + 'version_update' => 'version'); + + protected $itemNames = array( + 'field' => array(), + 'admin_view' => array(), + 'site_view' => array(), + 'custom_admin_view' => array() + ); + + protected $itemKeys = array( + // admin view + 'field' => array('table' => 'field', 'tables' => 'fields', 'id' => 'id', 'name' => 'name', 'text' => 'Field', 'get' => 'getFieldNameAndType'), + 'target_field' => array('table' => 'field', 'tables' => 'fields', 'id' => 'id', 'name' => 'name', 'text' => 'Field', 'get' => 'getFieldNameAndType'), + 'match_field' => array('table' => 'field', 'tables' => 'fields', 'id' => 'id', 'name' => 'name', 'text' => 'Field', 'get' => 'getFieldNameAndType'), + 'listfield' => array('table' => 'field', 'tables' => 'fields', 'id' => 'id', 'name' => 'name', 'text' => 'Field', 'get' => 'getFieldNameAndType'), + 'joinfields' => array('table' => 'field', 'tables' => 'fields', 'id' => 'id', 'name' => 'name', 'text' => 'Field', 'get' => 'getFieldNameAndType'), + // joomla component view + 'siteview' => array('table' => 'site_view', 'tables' => 'site_views', 'id' => 'id', 'name' => 'name', 'text' => 'Site View'), + 'customadminview' => array('table' => 'custom_admin_view', 'tables' => 'custom_admin_views', 'id' => 'id', 'name' => 'system_name', 'text' => 'Custom Admin View'), + 'adminviews' => array('table' => 'admin_view', 'tables' => 'admin_views', 'id' => 'id', 'name' => 'system_name', 'text' => 'Admin View'), + 'adminview' => array('table' => 'admin_view', 'tables' => 'admin_views', 'id' => 'id', 'name' => 'system_name', 'text' => 'Admin View'), + 'before' => array('table' => 'admin_view', 'tables' => 'admin_views', 'id' => 'id', 'name' => 'system_name', 'text' => 'Admin View') + ); + + protected function checkRepeatableConversion($type, &$fieldsData, $fieldsArrayType, $id, $linked_id_name) + { + if (JsonHelper::check($fieldsData) && isset($this->conversionCheck[$fieldsArrayType])) + { + $fieldsData = json_decode($fieldsData, true); + if (isset($fieldsData[$this->conversionCheck[$fieldsArrayType]])) + { + $bucket = array(); + foreach($fieldsData as $option => $values) + { + foreach($values as $nr => $value) + { + $bucket[$fieldsArrayType.$nr][$option] = $value; + } + } + $fieldsData = json_encode($bucket); + // update the fields + $objectUpdate = new \stdClass(); + $objectUpdate->{$linked_id_name} = (int) $id; + $objectUpdate->{$fieldsArrayType} = $fieldsData; + Factory::getDbo()->updateObject('#__componentbuilder_' . $type, $objectUpdate, 'admin_view'); + } + } + } + + protected function getFieldNameAndType($id) + { + // check if we can get the field name and type + if (($array = ComponentbuilderHelper::getFieldNameAndType($id, true)) !== false) + { + return ' [' . $array['name'] . ' - ' . $array['type'] . ']'; + } + return ''; + } + + protected function setPermissions($header, $values) + { + // check if value is array + if (!UtilitiesArrayHelper::check($values)) + { + $values = array($values); + } + // check if value is array + if (UtilitiesArrayHelper::check($values)) + { + // Editing, Access, View + $bucket = array(); + foreach ($values as $value) + { + switch ($value) + { + case 1: + $bucket[] = Text::_('COM_COMPONENTBUILDER_EDITING'); + break; + case 2: + $bucket[] = Text::_('COM_COMPONENTBUILDER_ACCESS'); + break; + case 3: + $bucket[] = Text::_('COM_COMPONENTBUILDER_VIEW'); + break; + } + } + // check if value is array + if (UtilitiesArrayHelper::check($bucket)) + { + return implode(', ', $bucket); + } + } + return Text::_('COM_COMPONENTBUILDER_NONE'); + } + + protected function setJoinType($header, $value) + { + switch ($value) + { + case 1: + return Text::_('COM_COMPONENTBUILDER_CONCATENATE'); + break; + case 2: + return Text::_('COM_COMPONENTBUILDER_CUSTOM_CODE'); + break; + } + return Text::_('COM_COMPONENTBUILDER_NOT_SET'); + } + + protected function setURLType($header, $value) + { + switch ($value) + { + case 1: + return Text::_('COM_COMPONENTBUILDER_DEFAULT_LINK'); + break; + case 2: + return Text::_('COM_COMPONENTBUILDER_LOCAL_GET'); + break; + case 3: + return Text::_('COM_COMPONENTBUILDER_LINK_LOCAL_DYNAMIC'); + break; + } + return Text::_('COM_COMPONENTBUILDER_NOT_SET'); + } + + protected function setIcoMoon($header, $value) + { + if (StringHelper::check($value)) + { + return ''; + } + return '-'; + } + + protected function setAlignmentName($header, $value) + { + switch ($value) + { + case 1: + return Text::_('COM_COMPONENTBUILDER_LEFT_IN_TAB'); + break; + case 2: + return Text::_('COM_COMPONENTBUILDER_RIGHT_IN_TAB'); + break; + case 3: + return Text::_('COM_COMPONENTBUILDER_FULL_WIDTH_IN_TAB'); + break; + case 4: + return Text::_('COM_COMPONENTBUILDER_ABOVE_TABS'); + break; + case 5: + return Text::_('COM_COMPONENTBUILDER_UNDERNEATH_TABS'); + break; + case 6: + return Text::_('COM_COMPONENTBUILDER_LEFT_OF_TABS'); + break; + case 7: + return Text::_('COM_COMPONENTBUILDER_RIGHT_OF_TABS'); + break; + } + return Text::_('COM_COMPONENTBUILDER_NOT_SET'); + } + + protected function setAdminBehaviour($header, $value) + { + switch ($value) + { + case 1: + return Text::_('COM_COMPONENTBUILDER_SHOW_IN_ALL_LIST_VIEWS'); + break; + case 2: + return Text::_('COM_COMPONENTBUILDER_NONE_DB'); + break; + case 3: + return Text::_('COM_COMPONENTBUILDER_ONLY_IN_ADMIN_LIST_VIEW'); + break; + case 4: + return Text::_('COM_COMPONENTBUILDER_ONLY_IN_LINKED_LIST_VIEWS'); + break; + default: + return Text::_('COM_COMPONENTBUILDER_DEFAULT'); + break; + } + } + + protected $tabNames = array(); + + protected function setTabName($header, $value) + { + // return published if set to 15 (since this is the default number for it) + if (15 == $value) + { + return Text::_('COM_COMPONENTBUILDER_PUBLISHING'); + } + if (!UtilitiesArrayHelper::check($this->tabNames)) + { + // get the view name & id + $values = $this->getViewID(); + if (!is_null($values['a_id']) && $values['a_id'] > 0 && strlen($values['a_view']) && $values['a_view'] === 'admin_view') + { + if ($tabs = GetHelper::var('admin_view', $values['a_id'], 'id', 'addtabs')) + { + $tabs = json_decode($tabs, true); + if (UtilitiesArrayHelper::check($tabs)) + { + $nr = 1; + foreach ($tabs as $tab) + { + if (UtilitiesArrayHelper::check($tab) && isset($tab['name'])) + { + $this->tabNames[$nr] = $tab['name']; + $nr++; + } + } + } + } + } + } + // has it been set + if (UtilitiesArrayHelper::check($this->tabNames) && isset($this->tabNames[$value])) + { + return $this->tabNames[$value]; + } + return Text::_('COM_COMPONENTBUILDER_DETAILS'); + } + + protected function setAreaName($header, $value) + { + switch ($value) + { + case 1: + return Text::_('COM_COMPONENTBUILDER_MODEL_BEFORE_MODELLING'); + break; + case 2: + return Text::_('COM_COMPONENTBUILDER_VIEW'); + break; + case 3: + return Text::_('COM_COMPONENTBUILDER_MODEL_AFTER_MODELLING'); + break; + } + return Text::_('COM_COMPONENTBUILDER_NOT_SET'); + } + + protected function setCode($header, $value) + { + return nl2br(htmlspecialchars($value)); + } + + protected function setYesNo($header, $value) + { + if (1 == $value) + { + return ''; + } + return ''; + } + + protected function setTargetBehavior($header, $value) + { + if (1 == $value) + { + return Text::_('COM_COMPONENTBUILDER_SHOW_TOGGLE'); + } + elseif (3 == $value) + { + return Text::_('COM_COMPONENTBUILDER_SHOW_ONLY'); + } + elseif (4 == $value) + { + return Text::_('COM_COMPONENTBUILDER_HIDE_ONLY'); + } + return Text::_('COM_COMPONENTBUILDER_HIDE_TOGGLE'); + } + + protected function setTargetRelation($header, $value) + { + switch ($value) + { + case 0: + return Text::_('COM_COMPONENTBUILDER_ISOLATE'); + break; + case 1: + return Text::_('COM_COMPONENTBUILDER_CHAIN'); + break; + } + return Text::_('COM_COMPONENTBUILDER_NOT_SET'); + } + + protected function setMatchBehavior($header, $value) + { + switch ($value) + { + case 1: + return Text::_('COM_COMPONENTBUILDER_IS_ONLY_FOUR_LISTRADIOCHECKBOXES'); + break; + case 2: + return Text::_('COM_COMPONENTBUILDER_IS_NOT_ONLY_FOUR_LISTRADIOCHECKBOXES'); + break; + case 3: + return Text::_('COM_COMPONENTBUILDER_ANY_SELECTION_ONLY_FOUR_LISTRADIOCHECKBOXESDYNAMIC_LIST'); + break; + case 4: + return Text::_('COM_COMPONENTBUILDER_ACTIVE_ONLY_FOUR_TEXT_FIELD'); + break; + case 5: + return Text::_('COM_COMPONENTBUILDER_UNACTIVE_ONLY_FOUR_TEXT_FIELD'); + break; + case 6: + return Text::_('COM_COMPONENTBUILDER_KEY_WORD_ALL_CASESENSITIVE_ONLY_FOUR_TEXT_FIELD'); + break; + case 7: + return Text::_('COM_COMPONENTBUILDER_KEY_WORD_ANY_CASESENSITIVE_ONLY_FOUR_TEXT_FIELD'); + break; + case 8: + return Text::_('COM_COMPONENTBUILDER_KEY_WORD_ALL_CASEINSENSITIVE_ONLY_FOUR_TEXT_FIELD'); + break; + case 9: + return Text::_('COM_COMPONENTBUILDER_KEY_WORD_ANY_CASEINSENSITIVE_ONLY_FOUR_TEXT_FIELD'); + break; + case 10: + return Text::_('COM_COMPONENTBUILDER_MIN_LENGTH_ONLY_FOUR_TEXT_FIELD'); + break; + case 11: + return Text::_('COM_COMPONENTBUILDER_MAX_LENGTH_ONLY_FOUR_TEXT_FIELD'); + break; + case 12: + return Text::_('COM_COMPONENTBUILDER_EXACT_LENGTH_ONLY_FOUR_TEXT_FIELD'); + break; + } + return Text::_('COM_COMPONENTBUILDER_NOT_SET'); + } + + protected function setMatchOptions($header, $value) + { + return str_replace("\n", "
    ", $value); + } + + public function getFieldSelectOptions($id) + { + // Create a new query object. + $query = $this->_db->getQuery(true); + $query->select($this->_db->quoteName(array('a.xml', 'b.name'))); + $query->from($this->_db->quoteName('#__componentbuilder_field', 'a')); + $query->join('LEFT', $this->_db->quoteName('#__componentbuilder_fieldtype', 'b') . ' ON (' . $this->_db->quoteName('a.fieldtype') . ' = ' . $this->_db->quoteName('b.id') . ')'); + $query->where($this->_db->quoteName('a.published') . ' = 1'); + $query->where($this->_db->quoteName('a.id') . ' = '. (int) $id); + + // Reset the query using our newly populated query object. + $this->_db->setQuery($query); + $this->_db->execute(); + if ($this->_db->getNumRows()) + { + $result = $this->_db->loadObject(); + $result->name = strtolower($result->name); + if (ComponentbuilderHelper::fieldCheck($result->name,'list')) + { + // load the values form params + $xml = json_decode($result->xml); + + $xmlOptions = GetHelper::between($xml,'option="','"'); + + $optionSet = ''; + if (strpos($xmlOptions,',') !== false) + { + // mulitpal options + $options = explode(',',$xmlOptions); + foreach ($options as $option) + { + // return both value and text + if (StringHelper::check($optionSet)) + { + // no add to option set + $optionSet .= "\n".$option; + } + else + { + // no add to option set + $optionSet .= $option; + } + } + } + else + { + // return both value and text + if (StringHelper::check($optionSet)) + { + // no add to option set + $optionSet .= "\n".$xmlOptions; + } + else + { + // no add to option set + $optionSet .= $xmlOptions; + } + } + // return found field options + return $optionSet; + } + elseif (ComponentbuilderHelper::fieldCheck($result->name,'text')) + { + return "keywords=\"\"\nlength=\"\""; + } + elseif (ComponentbuilderHelper::fieldCheck($result->name,'dynamic')) + { + return 'dynamic_list'; + } + elseif (ComponentbuilderHelper::fieldCheck($result->name)) + { + return 'match field type not supported. Select another!'; + } + else + { + return 'dynamic_list'; + } + } + return false; + } + + public function getTableColumns($tableName) + { + // get the columns + $columns = $this->_db->getTableColumns("#__".$tableName); + if (UtilitiesArrayHelper::check($columns)) + { + // build the return string + $tableColumns = array(); + foreach ($columns as $column => $type) + { + $tableColumns[] = $column . ' => ' . $column; + } + return implode("\n",$tableColumns); + } + return false; + } + + protected $linkedKeys = array( + 'field' => array( + array('table' => 'component_config', 'tables' => 'components_config', 'fields' => array('addconfig' => 'field', 'joomla_component' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT', 'linked_name' => 'system_name'), + array('table' => 'library_config', 'tables' => 'libraries_config', 'fields' => array('addconfig' => 'field', 'library' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_LIBRARY', 'linked_name' => 'name'), + array('table' => 'admin_fields', 'tables' => 'admins_fields', 'fields' => array('addfields' => 'field', 'admin_view' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_ADMIN_VIEW', 'linked_name' => 'system_name'), + array('table' => 'field', 'tables' => 'fields', 'fields' => array('xml' => 'fields', 'name' => 'NAME', 'fieldtype' => 'TYPE'), 'linked' => 'COM_COMPONENTBUILDER_FIELD', 'type_name' => 'name'), + array('table' => 'joomla_module', 'tables' => 'joomla_modules', 'fields' => array('fields' => 'fields.fields.field', 'system_name' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_JOOMLA_MODULE'), + array('table' => 'joomla_plugin', 'tables' => 'joomla_plugins', 'fields' => array('fields' => 'fields.fields.field', 'system_name' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN') + ), + 'admin_view' => array( + array('table' => 'component_admin_views', 'tables' => 'components_admin_views', 'fields' => array('addadmin_views' => 'adminview', 'joomla_component' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT', 'linked_name' => 'system_name') + ), + 'custom_admin_view' => array( + array('table' => 'component_custom_admin_views', 'tables' => 'components_custom_admin_views', 'fields' => array('addcustom_admin_views' => 'customadminview', 'joomla_component' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT', 'linked_name' => 'system_name') + ), + 'site_view' => array( + array('table' => 'component_site_views', 'tables' => 'components_site_views', 'fields' => array('addsite_views' => 'siteview', 'joomla_component' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT', 'linked_name' => 'system_name') + ), + 'library' => array( + array('table' => 'template', 'tables' => 'templates', 'fields' => array('libraries' => 'ARRAY', 'name' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_TEMPLATE'), + array('table' => 'layout', 'tables' => 'layouts', 'fields' => array('libraries' => 'ARRAY', 'name' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_LAYOUT'), + array('table' => 'site_view', 'tables' => 'site_views', 'fields' => array('libraries' => 'ARRAY', 'system_name' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_SITE_VIEW'), + array('table' => 'custom_admin_view', 'tables' => 'custom_admin_views', 'fields' => array('libraries' => 'ARRAY', 'system_name' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW') + ), + 'dynamic_get' => array( + array('table' => 'site_view', 'tables' => 'site_views', 'fields' => array('custom_get' => 'ARRAY', 'main_get' => 'INT', 'system_name' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_SITE_VIEW'), + array('table' => 'custom_admin_view', 'tables' => 'custom_admin_views', 'fields' => array('custom_get' => 'ARRAY', 'main_get' => 'INT', 'system_name' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW') + ), + 'joomla_module' => array( + array('table' => 'component_modules', 'tables' => 'components_modules', 'fields' => array('addjoomla_modules' => 'module', 'joomla_component' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT', 'linked_name' => 'system_name') + ), + 'joomla_plugin' => array( + array('table' => 'component_plugins', 'tables' => 'components_plugins', 'fields' => array('addjoomla_plugins' => 'plugin', 'joomla_component' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT', 'linked_name' => 'system_name') + ), + 'power' => array( + array('table' => 'admin_view', 'tables' => 'admin_views', 'fields' => array('params' => 'admin_view_headers:power_:power', 'system_name' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_ADMIN_VIEW'), + array('table' => 'site_view', 'tables' => 'site_views', 'fields' => array('params' => 'site_view_headers:power_:power', 'system_name' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_SITE_VIEW'), + array('table' => 'custom_admin_view', 'tables' => 'custom_admin_views', 'fields' => array('params' => 'custom_admin_view_headers:power_:power', 'system_name' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW'), + array('table' => 'joomla_component', 'tables' => 'joomla_components', 'fields' => array('params' => 'joomla_component_headers:power_:power', 'system_name' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT'), + array('table' => 'component_dashboard', 'tables' => 'components_dashboard', 'fields' => array('params' => 'component_dashboard_headers:power_:power', 'joomla_component' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_COMPONENT_DASHBOARD', 'linked_name' => 'system_name'), + array('table' => 'power', 'tables' => 'powers', 'fields' => array('extends' => 'GUID', 'implements' => 'ARRAY', 'use_selection' => 'use', 'load_selection' => 'load', 'system_name' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_POWER') + ) + ); + + /** + * Get Linked + * + * @param int $type The display return type + * + * @return string The display return type on success + * + */ + public function getLinked($type) + { + // get the view name & id + $values = $this->getViewID(); + // check if item is set + if (!is_null($values['a_id']) && $values['a_id'] > 0 && strlen($values['a_view'])) + { + // check if we have any linked to config + if (isset($this->linkedKeys[$values['a_view']])) + { + // set a return value + $return_url = 'index.php?option=com_componentbuilder&view=' . (string) $values['a_view'] . '&layout=edit&id=' . (int) $values['a_id']; + if (isset($values['a_return'])) + { + $return_url .= '&return=' . (string) $values['a_return']; + } + // make sure the ref is set + $this->ref = '&ref=' . $values['a_view'] . '&refid=' . $values['a_id'] . '&return=' . urlencode(base64_encode($return_url)); + // specail treatment of powers + $guid = false; + if ('power' === $values['a_view']) + { + $guid = $values['a_guid']; + } + // get the linked to + if ($linked = $this->getLinkedTo($values['a_view'], $values['a_id'], $guid)) + { + // just return it for now a table + $table = '
    '; + $table .= ''; + $table .= ''; + $table .= '
    '.Text::sprintf('COM_COMPONENTBUILDER_PLACES_ACROSS_JCB_WHERE_THIS_S_IS_LINKED', StringHelper::safe($values['a_view'], 'w')).'
    '.Text::_('COM_COMPONENTBUILDER_TYPE_NAME').'
    ' .implode('
    ', $linked) . '
    '; + return $table; + } + } + } + // if not found but has session view name + if (strlen($values['a_view'])) + { + return '

    ' . Text::sprintf('COM_COMPONENTBUILDER_S_NOT_LINKED', StringHelper::safe($values['a_view'], 'Ww')) . '

    ' . Text::sprintf('COM_COMPONENTBUILDER_THIS_BSB_IS_NOT_LINKED_TO_ANY_OTHER_AREAS_OF_JCB_AT_THIS_TIME', $values['a_view']) . '

    '; + } + // no view or id found in session, or view not allowed to access area + return '

    ' . Text::_('COM_COMPONENTBUILDER_ERROR') . '

    ' . Text::_('COM_COMPONENTBUILDER_THERE_WAS_A_PROBLEM_BNO_VIEW_OR_ID_FOUND_IN_SESSION_OR_VIEW_NOT_ALLOWED_TO_ACCESS_AREAB_WE_COULD_NOT_LOAD_ANY_LINKED_TO_VALUES_PLEASE_INFORM_YOUR_SYSTEM_ADMINISTRATOR') . '

    '; + } + + /** + * Get Linked to Items + * + * @param string $view View that is being searched for + * @param int $id ID + * @param string $guid GUID + * + * @return array Found items + * + */ + protected function getLinkedTo($view, $id, $guid) + { + // reset bucket + $linked = array(); + // start search + foreach ($this->linkedKeys[$view] as $search) + { + // Create a new query object. + $query = $this->_db->getQuery(true); + // get all history values + $selection = array_keys($search['fields']); + $selection[] = 'id'; + $query->select($selection); + $query->from('#__componentbuilder_' . $search['table']); + $this->_db->setQuery($query); + $this->_db->execute(); + if ($this->_db->getNumRows()) + { + // load all items + $items = $this->_db->loadObjectList(); + // search the items + foreach ($items as $item) + { + $found = false; + $type_name = null; + foreach ($search['fields'] as $key => $target) + { + if ('NAME' === $target) + { + $linked_name = $item->{$key}; + $linked_nameTable = $key; + continue; + } + elseif ('TYPE' === $target) + { + $type_name = $item->{$key}; + $type_nameTable = $key; + continue; + } + elseif (!$found) + { + if ('INT' === $target) + { + // check if ID match + if ($item->{$key} == $id) + { + $found = true; + } + } + elseif ('GUID' === $target) + { + // check if GUID match + if ($this->linkedGuid($guid, $item->{$key})) + { + $found = true; + } + } + else + { + // check if we have a json + if (JsonHelper::check($item->{$key})) + { + $item->{$key} = json_decode($item->{$key}, true); + } + // if array + if (UtilitiesArrayHelper::check($item->{$key})) + { + if ('ARRAY' === $target) + { + // check if ID match + foreach ($item->{$key} as $_id) + { + if ($_id == $id || $this->linkedGuid($guid, $_id)) + { + $found = true; + } + } + } + else + { + // check if this is a sub sub form target + if (strpos($target, '.') !== false) + { + $_target = (array) explode('.', $target); + // check that we have an array and get the size + if (($_size = UtilitiesArrayHelper::check($_target)) !== false) + { + foreach ($item->{$key} as $row) + { + if ($_size == 2) + { + if (isset($row[$_target[0]]) && isset($row[$_target[0]][$_target[1]]) && ($row[$_target[0]][$_target[1]] == $id || $this->linkedGuid($guid, $row[$_target[0]][$_target[1]]))) + { + $found = true; + } + } + elseif ($_size == 3 && isset($row[$_target[0]]) && UtilitiesArrayHelper::check($row[$_target[0]])) + { + foreach ($row[$_target[0]] as $_row) + { + if (!$found && isset($_row[$_target[2]]) && ($_row[$_target[2]] == $id || $this->linkedGuid($guid, $_row[$_target[2]]))) + { + $found = true; + } + } + } + } + } + } + elseif (strpos($target, ':') !== false) + { + $_target = (array) explode(':', $target); + // check that we have an array and get the size + if (($_size = UtilitiesArrayHelper::check($_target)) == 2) + { + foreach ($item->{$key} as $field_name => $row) + { + if (!$found && $field_name === $_target[0]) + { + foreach ($row as $_key => $_ids) + { + if (!$found && strpos($_key, $_target[1]) !== false && (in_array($id, $_ids) || $this->linkedGuid($guid, $_ids))) + { + $found = true; + } + } + } + } + } + // check that we have an array and get the size + if (($_size = UtilitiesArrayHelper::check($_target)) == 3) + { + foreach ($item->{$key} as $field_name => $row) + { + if (!$found && $field_name === $_target[0]) + { + foreach ($row as $_key => $_items) + { + if (!$found && strpos($_key, $_target[1]) !== false && is_array($_items) && count($_items) > 0) + { + foreach ($_items as $_item) + { + if (!$found && isset($_item[$_target[2]]) && ($id == $_item[$_target[2]] || $this->linkedGuid($guid, $_item[$_target[2]]))) + { + $found = true; + } + } + } + } + } + } + } + } + else + { + foreach ($item->{$key} as $row) + { + if (!$found && isset($row[$target]) && ($row[$target] == $id || $this->linkedGuid($guid, $row[$target]))) + { + $found = true; + } + } + } + } + } + // if string (fields) + if (!$found && 'xml' === $key && StringHelper::check($item->{$key}) + && strpos($item->{$key}, $target.'="') !== false) + { + // now get the fields between + $_fields = GetHelper::between($item->{$key}, $target.'="', '"'); + // check the result + if (StringHelper::check($_fields)) + { + // get the ids of all the fields linked here + $_fields = array_map('trim', (array) explode(',', $_fields)); + // check the result + if (UtilitiesArrayHelper::check($_fields)) + { + foreach ($_fields as $_field) + { + if ($_field == $id || $this->linkedGuid($guid, $_field)) + { + $found = true; + } + } + } + } + } + } + } + } + // check if found + if ($found) + { + // build the name + $edit = true; + if (is_numeric($linked_name) && isset($search['linked_name'])) + { + if (!$linked_name = GetHelper::var($linked_nameTable, (int) $linked_name, 'id', $search['linked_name'])) + { + $linked_name = Text::_('COM_COMPONENTBUILDER_NO_FOUND'); + $edit = false; + } + } + // build the local type + if (is_numeric($type_name) && isset($search['type_name'])) + { + if (!$type_name = GetHelper::var($type_nameTable, (int) $type_name, 'id', $search['type_name'])) + { + $type_name = ''; + } + else + { + $type_name = ' (' . $type_name . ') '; + } + } + elseif (StringHelper::check($type_name) || is_numeric($type_name)) + { + $type_name = ' (' . $type_name . ') '; + } + // set edit link + $link = ($edit) ? ComponentbuilderHelper::getEditButton($item->id, $search['table'], $search['tables'], $this->ref) : ''; + // build the linked + $linked[] = Text::_($search['linked']) . $type_name . ' - ' . $linked_name . ' ' . $link; + } + } + } + } + // check if we found any + if (UtilitiesArrayHelper::check($linked)) + { + return $linked; + } + return false; + } + + /** + * Check if we have a GUID match + * + * @param string|bool $guid The active power guid + * @param string|array $setGuid The linked power guid + * + * @return bool true if match is found + * + */ + protected function linkedGuid($guid, $setGuid): bool + { + // check if GUID is valid + if ($guid && ComponentbuilderHelper::validGUID($guid)) + { + if (is_string($setGuid) && ComponentbuilderHelper::validGUID($setGuid) && $guid === $setGuid) + { + return true; + } + elseif (is_array($setGuid) && in_array($guid, $setGuid)) + { + return true; + } + } + return false; + } + + /** + * The view persistence details + * + * @var array + * @since 3.0.13 + */ + protected $viewid = array(); + + /** + * Get the view details via the session + * + * @input string $call The persistence key + * + * @return mixed + * @since 3.0.13 + */ + protected function getViewID($call = 'table') + { + if (!isset($this->viewid[$call])) + { + // get the vdm key + $jinput = Factory::getApplication()->input; + $vdm = $jinput->get('vdm', null, 'WORD'); + if ($vdm) + { + // set view and id + if ($view = ComponentbuilderHelper::get($vdm)) + { + $current = (array) explode('__', $view); + if (StringHelper::check($current[0]) && isset($current[1]) && is_numeric($current[1])) + { + // get the view name & id + $this->viewid[$call] = array( + 'a_id' => (int) $current[1], + 'a_view' => $current[0] + ); + } + } + // set GUID if found + if (($guid = ComponentbuilderHelper::get($vdm . '__guid')) !== false && method_exists('ComponentbuilderHelper', 'validGUID')) + { + if (ComponentbuilderHelper::validGUID($guid)) + { + $this->viewid[$call]['a_guid'] = $guid; + } + } + // set return if found + if (($return = ComponentbuilderHelper::get($vdm . '__return')) !== false) + { + if (StringHelper::check($return)) + { + $this->viewid[$call]['a_return'] = $return; + } + } + } + } + if (isset($this->viewid[$call])) + { + return $this->viewid[$call]; + } + return false; + } + + + public function getButton($type, $size) + { + if (isset($this->buttonArray[$type])) + { + $user = Factory::getUser(); + // only add if user allowed to create + if ($user->authorise($type.'.create', 'com_componentbuilder')) + { + // get the view name & id + $values = $this->getViewID(); + // check if new item + $ref = ''; + if (!is_null($values['a_id']) && $values['a_id'] > 0 && strlen($values['a_view'])) + { + // check if we have a return value + $return_url = 'index.php?option=com_componentbuilder&view=' . (string) $values['a_view'] . '&layout=edit&id=' . (int) $values['a_id']; + if (isset($values['a_return'])) + { + $return_url .= '&return=' . (string) $values['a_return']; + } + // only load referral if not new item. + $ref = '&ref=' . $values['a_view'] . '&refid=' . $values['a_id'] . '&return=' . urlencode(base64_encode($return_url)); + } + // build url (A tag) + $startAtag = 'onclick="UIkit2.modal.confirm(\''.Text::_('COM_COMPONENTBUILDER_ALL_UNSAVED_WORK_ON_THIS_PAGE_WILL_BE_LOST_ARE_YOU_SURE_YOU_WANT_TO_CONTINUE').'\', function(){ window.location.href = \'index.php?option=com_componentbuilder&view=' . $type . '&layout=edit' . $ref . '\' })" href="javascript:void(0)" title="'.Text::sprintf('COM_COMPONENTBUILDER_CREATE_NEW_S', StringHelper::safe($type, 'W')).'">'; + // build the smallest button + if (3 == $size) + { + $button = ''; + } + // build the smaller button + elseif (2 == $size) + { + $button = ' ' . Text::_('COM_COMPONENTBUILDER_CREATE') . ''; + } + else + // build the big button + { + $button = '
    +
    + +
    + +
    '; + } + // return the button attached to input field + return $button; + } + return ''; + } + return false; + } + + public function getButtonID($type, $size) + { + if (isset($this->buttonArray[$type])) + { + $user = Factory::getUser(); + // only add if user allowed to create + if ($user->authorise($type.'.create', 'com_componentbuilder')) + { + // get the view name & id + $values = $this->getViewID(); + // set the button ID + $css_class = 'control-group-'.StringHelper::safe($type. '-' . $size, 'L', '-'); + // check if new item + $ref = ''; + if (!is_null($values['a_id']) && $values['a_id'] > 0 && strlen($values['a_view'])) + { + // set the return value + $return_url = 'index.php?option=com_componentbuilder&view=' . (string) $values['a_view'] . '&layout=edit&id=' . (int) $values['a_id']; + if (isset($values['a_return'])) + { + $return_url .= '&return=' . (string) $values['a_return']; + } + // only load referral if not new item. + $ref = '&ref=' . $values['a_view'] . '&refid=' . $values['a_id'] . '&return=' . urlencode(base64_encode($return_url)); + // set the key get value + $key_get_value = $values['a_id']; + // check if we have a GUID + //if (isset($values['a_guid'])) + //{ + // $ref .= '&guid=' . (string) $values['a_guid']; + // $key_get_value = $values['a_guid']; + //} + // get item id + if (($id = GetHelper::var($type, $key_get_value, $values['a_view'], 'id')) !== false && $id > 0) + { + $buttonText = Text::sprintf('COM_COMPONENTBUILDER_EDIT_S_FOR_THIS_S', StringHelper::safe($type, 'w'), StringHelper::safe($values['a_view'], 'w')); + $buttonTextSmall = Text::_('COM_COMPONENTBUILDER_EDIT'); + $editThis = 'index.php?option=com_componentbuilder&view='.$this->buttonArray[$type].'&task='.$type.'.edit&id='.$id; + $icon = 'icon-apply'; + } + else + { + $buttonText = Text::sprintf('COM_COMPONENTBUILDER_CREATE_S_FOR_THIS_S', StringHelper::safe($type, 'w'), StringHelper::safe($values['a_view'], 'w')); + $buttonTextSmall = Text::_('COM_COMPONENTBUILDER_CREATE'); + $editThis = 'index.php?option=com_componentbuilder&view='.$type.'&layout=edit'; + $icon = 'icon-new'; + } + // build the button + $button = array(); + if (1 == $size) + { + $button[] = '
    '; + $button[] = '
    '; + $button[] = ''; + $button[] = '
    '; + $button[] = ''; + $button[] = '
    '; + } + elseif (2 == $size) + { + $button[] = ''; + $button[] = $buttonTextSmall; + $button[] = ''; + } + // return the button attached to input field + return implode("\n", $button); + } + // only return notice if big button + if (1 == $size) + { + return '
    ' . Text::sprintf('COM_COMPONENTBUILDER_BUTTON_TO_CREATE_S_WILL_SHOW_ONCE_S_IS_SAVED_FOR_THE_FIRST_TIME', StringHelper::safe($type, 'w'), StringHelper::safe($values['a_view'], 'w')) . '
    '; + } + } + } + return ''; + } + + protected function getSubformTable($idName, $data) + { + // make sure we convert the json to array + if (JsonHelper::check($data)) + { + $data = json_decode($data, true); + } + // make sure we have an array + if (UtilitiesArrayHelper::check($data) && StringHelper::check($idName)) + { + // Build heading + $head = array(); + foreach ($data as $headers) + { + foreach ($headers as $header => $value) + { + if (!isset($head[$header])) + { + $head[$header] = $this->getLanguage($idName . '|=VDM=|' . $header); + } + } + } + // build the rows + $rows = array(); + if (UtilitiesArrayHelper::check($data) && UtilitiesArrayHelper::check($head)) + { + foreach ($data as $nr => $values) + { + foreach ($head as $key => $_header) + { + // set the value for the row + if (isset($values[$key])) + { + $this->setSubformRows($nr, $this->setSubformValue($key, $values[$key]), $rows, $_header); + } + else + { + $this->setSubformRows($nr, $this->setSubformValue($key, ''), $rows, $_header); + } + } + } + } + // build table + if (UtilitiesArrayHelper::check($rows) && UtilitiesArrayHelper::check($head)) + { + // set the number of rows + $this->rowNumber = count($rows); + // return the table + return ComponentbuilderHelper::setSubformTable($head, $rows, $idName); + } + } + return false; + } + + protected function setSubformValue($header, $value) + { + if (array_key_exists($header, $this->functionArray) && method_exists($this, $this->functionArray[$header])) + { + $value = $this->{$this->functionArray[$header]}($header, $value); + } + // if no value are set + if (!StringHelper::check($value)) + { + $value = '-'; + } + return $value; + } + + protected function setSubformRows($nr, $value, &$rows, $_header) + { + // build rows + if (!isset($rows[$nr])) + { + $rows[$nr] = ''.$value.''; + } + else + { + $rows[$nr] .= ''.$value.''; + } + } + + public function getAjaxDisplay($type) + { + if (isset($this->fieldsArray[$type])) + { + // set type name + $typeName = StringHelper::safe($type, 'w'); + // get the view name & id + $values = $this->getViewID(); + // check if we are in the correct view. + if (!is_null($values['a_id']) && $values['a_id'] > 0 && strlen($values['a_view']) && in_array($values['a_view'], $this->allowedViewsArray)) + { + // set a return value + $return_url = 'index.php?option=com_componentbuilder&view=' . (string) $values['a_view'] . '&layout=edit&id=' . (int) $values['a_id']; + // set a global return value + if (isset($values['a_return'])) + { + $return_url .= '&return=' . (string) $values['a_return']; + } + // set the ref + $this->ref = '&ref=' . $values['a_view'] . '&refid=' . $values['a_id'] . '&return=' . urlencode(base64_encode($return_url)); + // set the key get value + $key_get_value = $values['a_id']; + // check if we have a GUID + //if (isset($values['a_guid'])) + //{ + //$this->ref .= '&guid=' . (string) $values['a_guid']; + //$key_get_value = $values['a_guid']; + //} + // load the results + $result = array(); + // return field table + if (UtilitiesArrayHelper::check($this->fieldsArray[$type])) + { + foreach ($this->fieldsArray[$type] as $fieldName) + { + if ($table = $this->getFieldTable($type, $key_get_value, $values['a_view'], $fieldName, $typeName)) + { + $result[] = $table; + } + } + } + elseif (StringHelper::check($this->fieldsArray[$type])) + { + if ($table = $this->getFieldTable($type, $key_get_value, $values['a_view'], $this->fieldsArray[$type], $typeName)) + { + $result[] = $table; + } + } + // check if we have results + if (UtilitiesArrayHelper::check($result) && count($result) == 1) + { + // return the display + return implode('', $result); + } + elseif (UtilitiesArrayHelper::check($result)) + { + // return the display + return '
    ' . implode('
    ', $result) . '
    '; + } + } + return '
    ' . Text::sprintf('COM_COMPONENTBUILDER_NO_S_HAVE_BEEN_LINKED_TO_THIS_VIEW_SOON_AS_THIS_IS_DONE_IT_WILL_BE_DISPLAYED_HERE', $typeName) . '
    '; + } + return '

    ' . Text::_('COM_COMPONENTBUILDER_TYPE_ERROR') . '

    ' . Text::_('COM_COMPONENTBUILDER_THERE_HAS_BEEN_AN_ERROR_IF_THIS_CONTINUES_PLEASE_INFORM_YOUR_SYSTEM_ADMINISTRATOR_OF_A_TYPE_ERROR_IN_THE_FIELDS_DISPLAY_REQUEST') . '

    '; + } + + + protected function setItemNames($header, $value) + { + if (isset($this->itemKeys[$header]) && isset($this->itemKeys[$header]['table']) && isset($this->itemNames[$this->itemKeys[$header]['table']])) + { + // check if we have GUID setup + $validGUID = function ($guid) { + if (method_exists('ComponentbuilderHelper', 'validGUID') && ComponentbuilderHelper::validGUID($guid)) + { + return true; + } + return false; + }; + // check if functions exists + $guidEdit = method_exists('ComponentbuilderHelper', 'getEditButtonGUID'); + $getEdit = method_exists('ComponentbuilderHelper', 'getEditButton'); + // reset bucket + $bucket = array(); + if (UtilitiesArrayHelper::check($value)) + { + foreach ($value as $item) + { + $edit = true; + if (!isset($this->itemNames[$this->itemKeys[$header]['table']][$item])) + { + if (($this->itemNames[$this->itemKeys[$header]['table']][$item] = GetHelper::var($this->itemKeys[$header]['table'], $item, $this->itemKeys[$header]['id'], $this->itemKeys[$header]['name'])) === false) + { + $this->itemNames[$this->itemKeys[$header]['table']][$item] = Text::sprintf('COM_COMPONENTBUILDER_NO_S_FOUND', $this->itemKeys[$header]['text']); + $edit = false; + } + // check if we should load some get + if ($edit && isset($this->itemKeys[$header]['get']) && StringHelper::check($this->itemKeys[$header]['get']) && method_exists(__CLASS__, $this->itemKeys[$header]['get'])) + { + // gets + $this->itemNames[$this->itemKeys[$header]['table']][$item] .= $this->{$this->itemKeys[$header]['get']}($item); + } + } + // check if we are working with GUID + if ($validGUID($item)) + { + // set edit link + $link = ($edit && $guidEdit) ? ComponentbuilderHelper::getEditButtonGUID($item, $this->itemKeys[$header]['id'], $this->itemKeys[$header]['table'], $this->itemKeys[$header]['tables'], $this->ref) : ''; + } + else + { + // set edit link + $link = ($edit && $getEdit) ? ComponentbuilderHelper::getEditButton($item, $this->itemKeys[$header]['table'], $this->itemKeys[$header]['tables'], $this->ref) : ''; + } + // load item + $bucket[] = $this->itemNames[$this->itemKeys[$header]['table']][$item] . $link; + } + } + elseif (is_numeric($value) || $validGUID($value)) + { + $edit = true; + if (!isset($this->itemNames[$this->itemKeys[$header]['table']][$value])) + { + if (($this->itemNames[$this->itemKeys[$header]['table']][$value] = GetHelper::var($this->itemKeys[$header]['table'], $value, $this->itemKeys[$header]['id'], $this->itemKeys[$header]['name'])) === false) + { + $this->itemNames[$this->itemKeys[$header]['table']][$value] = Text::sprintf('COM_COMPONENTBUILDER_NO_S_FOUND', $this->itemKeys[$header]['text']); + $edit = false; + } + // check if we should load some get + if ($edit && isset($this->itemKeys[$header]['get']) && StringHelper::check($this->itemKeys[$header]['get']) && method_exists(__CLASS__, $this->itemKeys[$header]['get'])) + { + // gets + $this->itemNames[$this->itemKeys[$header]['table']][$value] .= $this->{$this->itemKeys[$header]['get']}($value); + } + } + // check if we are working with GUID + if ($validGUID($value)) + { + // set edit link + $link = ($edit && $guidEdit) ? ComponentbuilderHelper::getEditButtonGUID($value, $this->itemKeys[$header]['id'], $this->itemKeys[$header]['table'], $this->itemKeys[$header]['tables'], $this->ref) : ''; + } + else + { + // set edit link + $link = ($edit && $getEdit) ? ComponentbuilderHelper::getEditButton($value, $this->itemKeys[$header]['table'], $this->itemKeys[$header]['tables'], $this->ref) : ''; + } + // load item + $bucket[] = $this->itemNames[$this->itemKeys[$header]['table']][$value] . $link; + } + // return found items + if (UtilitiesArrayHelper::check($bucket)) + { + return implode('
    ', $bucket); + } + return Text::sprintf('COM_COMPONENTBUILDER_NO_S_FOUND', $this->itemKeys[$header]['text']); + } + return Text::_('COM_COMPONENTBUILDER_NO_ITEM_FOUND'); + } + + + protected function getFieldTable($type, $id, $idName, $fieldName, $typeName) + { + // get the field data + if (($fieldsData = GetHelper::var($type, $id, $idName, $fieldName)) !== false) + { + // check repeatable conversion + if (method_exists(__CLASS__, 'checkRepeatableConversion')) + { + $this->checkRepeatableConversion($type, $fieldsData, $fieldName, $id, $idName); + } + // get the table + $table = $this->getSubformTable($type, $fieldsData); + // get row number + $number = (isset($this->rowNumbers) && isset($this->rowNumbers[$type]) && $this->rowNumbers[$type]) ? $this->rowNumbers[$type] : false; + // set notice of bad practice + $notice = ''; + if ($number && isset($this->rowNumber) && $this->rowNumber > $number) + { + $notice = '
    ' . Text::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 ($number && isset($this->rowNumber)) + { + $notice = '
    ' . Text::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; + } + return false; + } + + + // Used in template + public function getTemplateDetails($id) + { + // set table + $table = false; + // Get a db connection. + $db = Factory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id', 'a.alias', 'a.template', 'b.name', 'a.dynamic_get'))); + $query->from($db->quoteName('#__componentbuilder_template', 'a')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_dynamic_get', 'b') . ' ON (' . $db->quoteName('b.id') . ' = ' . $db->quoteName('a.dynamic_get') . ')'); + $query->where($db->quoteName('a.id') . ' != '. (int) $id); + $query->where($db->quoteName('a.published') . ' = 1'); + // Reset the query using our newly populated query object. + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $results = $db->loadObjectList(); + $templateString = array(); + // get the view name & id + $values = $this->getViewID(); + // set a return value + $return_url = 'index.php?option=com_componentbuilder&view=' . (string) $values['a_view'] . '&layout=edit&id=' . (int) $values['a_id']; + if (isset($values['a_return'])) + { + $return_url .= '&return=' . (string) $values['a_return']; + } + // start the ref builder + $ref = ''; + if (!is_null($values['a_id']) && $values['a_id'] > 0 && strlen($values['a_view'])) + { + // set the return ref + $ref = '&ref=' . $values['a_view'] . '&refid=' . $values['a_id'] . '&return=' . urlencode(base64_encode($return_url)); + } + // load the template data + foreach ($results as $result) + { + $edit = (($button = ComponentbuilderHelper::getEditButton($result->id, 'template', 'templates', $ref)) !== false) ? $button : ''; + $editget = (isset($result->dynamic_get) && $result->dynamic_get > 0 && ($button = ComponentbuilderHelper::getEditButton($result->dynamic_get, 'dynamic_get', 'dynamic_gets', $ref)) !== false) ? $button : ''; + $result->name = (StringHelper::check($result->name)) ? $result->name : Text::_('COM_COMPONENTBUILDER_NONE_SELECTED'); + $templateString[] = "".$result->name." ".$editget."<?php echo \$this->loadTemplate('".StringHelper::safe($result->alias)."'); ?> ".$edit.""; + } + // build the table + $table = '

    ' . Text::_('COM_COMPONENTBUILDER_TEMPLATE_CODE_SNIPPETS') . '

    '; + $table .= ''; + $table .= ''; + $table .= '' . implode("", $templateString) . "
    ' . Text::_('COM_COMPONENTBUILDER_TO_ADD_SIMPLY_COPY_AND_PAST_THE_SNIPPET_INTO_YOUR_CODE') . '
    ' . Text::_('COM_COMPONENTBUILDER_NAME_OF_DYNAMICGET') . '' . Text::_('COM_COMPONENTBUILDER_SNIPPET') . '
    "; + } + return $table; + } + + // Used in layout + public function getLayoutDetails($id) + { + // set table + $table = false; + // Get a db connection. + $db = Factory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.alias','a.layout','b.getcustom','b.gettype','b.name','a.dynamic_get'))); + $query->from($db->quoteName('#__componentbuilder_layout', 'a')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_dynamic_get', 'b') . ' ON (' . $db->quoteName('b.id') . ' = ' . $db->quoteName('a.dynamic_get') . ')'); + $query->where($db->quoteName('a.id') . ' != '.(int) $id); + $query->where($db->quoteName('a.published') . ' = 1'); + // Reset the query using our newly populated query object. + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $results = $db->loadObjectList(); + $layoutString = array(); + // get the view name & id + $values = $this->getViewID(); + // set a return value + $return_url = 'index.php?option=com_componentbuilder&view=' . (string) $values['a_view'] . '&layout=edit&id=' . (int) $values['a_id']; + if (isset($values['a_return'])) + { + $return_url .= '&return=' . (string) $values['a_return']; + } + // start the ref builder + $ref = ''; + if (!is_null($values['a_id']) && $values['a_id'] > 0 && strlen($values['a_view'])) + { + // set the return ref + $ref = '&ref=' . $values['a_view'] . '&refid=' . $values['a_id'] . '&return=' . urlencode(base64_encode($return_url)); + } + foreach ($results as $result) + { + $edit = (($button = ComponentbuilderHelper::getEditButton($result->id, 'layout', 'layouts', $ref)) !== false) ? $button : ''; + $editget = (isset($result->dynamic_get) && $result->dynamic_get > 0 && ($button = ComponentbuilderHelper::getEditButton($result->dynamic_get, 'dynamic_get', 'dynamic_gets', $ref)) !== false) ? $button : ''; + $result->name = (StringHelper::check($result->name)) ? $result->name : Text::_('COM_COMPONENTBUILDER_NONE_SELECTED'); + + switch ($result->gettype) + { + case 1: + // single + $layoutString[] = "" . $result->name . " " . $editget . "<?php echo LayoutHelper::render('" . StringHelper::safe($result->alias) . "', \$this->item); ?> " . $edit . ""; + break; + case 2: + // list + $layoutString[] = "" . $result->name . " " . $editget . "<?php echo LayoutHelper::render('" . StringHelper::safe($result->alias) . "', \$this->items); ?> " . $edit . ""; + break; + case 3: + case 4: + // custom + $result->getcustom = StringHelper::safe($result->getcustom); + if (substr($result->getcustom, 0, strlen('get')) == 'get') + { + $varName = substr($result->getcustom, strlen('get')); + } + else + { + $varName = $result->getcustom; + } + $layoutString[] = "" . $result->name . " " . $editget . "<?php echo LayoutHelper::render('" . StringHelper::safe($result->alias) . "', \$this->" . $varName . "); ?> " . $edit . ""; + break; + default: + // no get + $layoutString[] = "" . Text::_('COM_COMPONENTBUILDER_NONE_SELECTED') . "<?php echo LayoutHelper::render('" . StringHelper::safe($result->alias) . "', [?]); ?> " . $edit . ""; + break; + } + } + // build the table + $table = '

    ' . Text::_('COM_COMPONENTBUILDER_LAYOUT_CODE_SNIPPETS') . '

    '; + $table .= ''; + $table .= ''; + $table .= '' . implode("",$layoutString) . "
    ' . Text::_('COM_COMPONENTBUILDER_TO_ADD_SIMPLY_COPY_AND_PAST_THE_SNIPPET_INTO_YOUR_CODE') . '
    ' . Text::_('COM_COMPONENTBUILDER_NAME_OF_DYNAMICGET') . '' . Text::_('COM_COMPONENTBUILDER_SNIPPET') . '
    "; + } + return $table; + } + + // Used in dynamic_get + public function getViewTableColumns($admin_view, $as, $type) + { + return ComponentbuilderHelper::getViewTableColumns($admin_view, $as, $type); + } + + public function getDbTableColumns($tableName, $as, $type) + { + return ComponentbuilderHelper::getDbTableColumns($tableName, $as, $type); + } + + public function getDynamicValues($id, $view) + { + // Get a db connection. + $db = Factory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('getcustom', 'gettype', 'select_all', 'db_table_main', 'view_table_main', 'main_source', 'view_selection', 'db_selection', 'join_view_table', 'join_db_table', 'addcalculation', 'php_calculation'))); + $query->from($db->quoteName('#__componentbuilder_dynamic_get')); + $query->where($db->quoteName('published') . ' = 1'); + $query->where($db->quoteName('id') . ' = ' . (int) $id); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $result = $db->loadObject(); + // reset buket + $selections = array(); + $selectionsList = array(); + // get the main values (name) + if ($result->main_source == 1) + { + if ($result->select_all == 1) + { + $result->view_selection = ComponentbuilderHelper::getViewTableColumns($result->view_table_main, 'a', $result->gettype); + } + $selections[] = explode("\n", $result->view_selection); + } + elseif ($result->main_source == 2) + { + if ($result->select_all == 1) + { + $result->db_selection = ComponentbuilderHelper::getDbTableColumns($result->db_table_main, 'a', $result->gettype); + } + $selections[] = explode("\n", $result->db_selection); + } + elseif ($result->main_source == 3) + { + return '

    Custom get source! You will need to transpose the variables manually.

    '; + } + // get the joined values (name) + $result->join_view_table = json_decode($result->join_view_table, true); + if (!UtilitiesArrayHelper::check($result->join_view_table)) + { + unset($result->join_view_table); + } + $result->join_db_table = json_decode($result->join_db_table, true); + if (!UtilitiesArrayHelper::check($result->join_db_table)) + { + unset($result->join_db_table); + } + // now load the joined values to the selection set + if (isset($result->join_view_table) && UtilitiesArrayHelper::check($result->join_view_table)) + { + foreach ($result->join_view_table as $join_view_table) + { + // check if all is selected + if (strpos($join_view_table['selection'], '*') !== false) + { + $join_view_table['selection'] = ComponentbuilderHelper::getViewTableColumns($join_view_table['view_table'], $join_view_table['as'], $join_view_table['row_type']); + } + // build selection + if ($join_view_table['row_type'] == '1') + { + $selections[] = explode("\n", $join_view_table['selection']); + } + elseif ($join_view_table['row_type'] == '2') + { + $names = $this->setListMethodName(array($join_view_table['on_field'],$join_view_table['join_field']),$join_view_table['view_table'],$join_view_table['as'],1); + $selectionsList[implode('',$names)] = explode("\n", $join_view_table['selection']); + } + } + unset($result->join_view_table); + } + if (isset($result->join_db_table) && UtilitiesArrayHelper::check($result->join_db_table)) + { + foreach ($result->join_db_table as $join_db_table) + { + // check if all is selected + if (strpos($join_db_table['selection'], '*') !== false) + { + $join_db_table['selection'] = ComponentbuilderHelper::getViewTableColumns($join_db_table['view_table'], $join_db_table['as'], $join_db_table['row_type']); + } + // build selections + if ($join_db_table['row_type'] == '1') + { + $selections[] = explode("\n", $join_db_table['selection']); + } + elseif ($join_db_table['row_type'] == '2') + { + $names = $this->setListMethodName(array($join_db_table['on_field'],$join_db_table['join_field']),$join_db_table['db_table'],$join_db_table['as'],2); + $selectionsList[implode('',$names)] = explode("\n", $join_db_table['selection']); + } + } + unset($result->join_db_table); + } + // get the calculation result values (name) + if ($result->addcalculation == 1) + { + $php_calculation = base64_decode($result->php_calculation); + $phpSelections = GetHelper::allBetween($php_calculation,'cal__',' '); + $selections[] = array_unique($phpSelections); + unset($php_calculation); + unset($phpSelections); + unset($result->php_calculation); + } + // name the main var based on view + if ('template' === $view || 'site_view' === $view || 'custom_admin_view' === $view) + { + switch ($result->gettype) + { + case 1: + // single + $buketName = 'this->item'; + break; + case 2: + // list + $buketName = 'this->items'; + break; + case 3: + case 4: + // custom + $result->getcustom = StringHelper::safe($result->getcustom); + if (substr($result->getcustom, 0, strlen('get')) == 'get') + { + $varName = substr($result->getcustom, strlen('get')); + } + else + { + $varName = $result->getcustom; + } + $buketName = 'this->'.$varName; + break; + } + } + elseif ($view == 'layout') + { + $buketName = 'displayData'; + } + // now build the return values + if (UtilitiesArrayHelper::check($selections)) + { + $buket = array(); + switch ($result->gettype) + { + case 1: + case 3: + // single + $ur = '<?php echo $'.$buketName; + $cf = '; ?>'; + break; + case 2: + case 4: + // list + $ur = '<?php echo $item'; + $cf = '; ?>'; + $buket[] = '<?php foreach ($'.$buketName.' as $item): ?>
    '; + break; + } + foreach ($selections as $selection) + { + if (UtilitiesArrayHelper::check($selection)) + { + foreach ($selection as $value) + { + if (strpos($value,'AS') !== false) + { + list($table,$key) = explode('AS',$value); + $buket[] = ''.$ur.'->'.trim($key).$cf.''; + } + else + { + $buket[] = ''.$ur.'->'.trim($value).$cf.''; + } + } + } + } + if (UtilitiesArrayHelper::check($selectionsList)) + { + $buket[] = '
    '; + foreach ($selectionsList as $name => $selectionList) + { + if (UtilitiesArrayHelper::check($selectionList)) + { + $ur = '<?php echo $'.$name; + $cf = '; ?>'; + $buket[] = '<?php foreach ($item->'.$name.' as $'.$name.'): ?>
    '; + foreach ($selectionList as $value) + { + if (strpos($value,'AS') !== false) + { + list($table,$key) = explode('AS',$value); + $buket[] = ''.$ur.'->'.trim($key).$cf.''; + } + else + { + $buket[] = ''.$ur.'->'.trim($value).$cf.''; + } + } + $buket[] = '
    <?php endforeach; ?>
    '; + } + } + } + switch ($result->gettype) + { + case 2: + case 4: + // list + $buket[] = '
    <?php endforeach; ?>'; + break; + } + return implode(' ',$buket); + } + } + return false; + } + + protected function setListMethodName($names, $table, $as, $type) + { + $methodNames = array(); + if (UtilitiesArrayHelper::check($names)) + { + foreach ($names as $nr => $name) + { + if (StringHelper::check($name)) + { + if (strpos($name,'.') !== false) + { + list($dump,$var) = explode('.',$name); + } + else + { + $var = $name; + } + if ($nr > 0) + { + $methodNames[] = StringHelper::safe($var,'F'); + } + else + { + $methodNames[] = StringHelper::safe($var); + } + } + } + } + switch ($type) + { + // set view name + case 1: + $methodNames[] = StringHelper::safe($this->getViewName($table),'F'); + break; + // set db name + case 2: + $methodNames[] = StringHelper::safe($table,'F'); + break; + + } + // make sure there is uniqe method names + $methodNames[] = StringHelper::safe($as,'U'); + return $methodNames; + } + + protected function getViewName($id) + { + // Get the view name + if ($name = GetHelper::var('admin_view', (int) $id, 'id', 'name_single')) + { + return $name; + } + return ''; + } + + // Used in custom_code + public function getEditCustomCodeButtons($id) + { + $view = $this->getViewID(); + // only continue if this is a legitimate call + if (isset($view['a_id']) && $view['a_id'] == $id && isset($view['a_view']) && ($target = $this->getCodeSearchKeys($view['a_view'], 'query_')) !== false) + { + // reset the buttons bucket + $buttons = array(); + // some helper for some fields (I am sorry) + $helper = array('xml' => 'note_filter_information'); + // get input + $jinput = Factory::getApplication()->input; + $return_here = $jinput->get('return_here', null, 'base64'); + // set the return here value if not found + if (StringHelper::check($return_here)) + { + $return_here = '&return=' . $return_here; + } + else + { + $return_here = '&ref=' . $view['a_view'] . '&refid=' . (int) $id; + } + // start db query + $db = Factory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName($target['select'])) + ->from($db->quoteName('#__componentbuilder_' . $target['table'], 'a')) + ->where('a.id = ' . (int) $id); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + $data = $db->loadAssoc(); + // reset the bucket + $bucket = array(); + foreach ($data as $key => $value) + { + if ('id' !== $key && $target['name'] !== $key) + { + if (!isset($target['not_base64'][$key])) + { + $value = Base64Helper::open($value, null); + } + elseif ('json' === $target['not_base64'][$key] && 'xml' === $key) // just for field search + { + $value = json_decode($value); + } + // check if we should search for base64 string inside the text + if (isset($target['base64_search']) && isset($target['base64_search'][$key]) + && isset($target['base64_search'][$key]['start']) && strpos($value, $target['base64_search'][$key]['start']) !== false) + { + // search and open the base64 strings + $this->searchOpenBase64($value, $target['base64_search'][$key]); + } + // check if place holder set + if (strpos($value, '[CUSTOMC' . 'ODE=') !== false) + { + // get all custom codes in value + $bucket[$key] = GetHelper::allBetween($value, '[CUSTOMC' . 'ODE=', ']'); + } + // check if field has string length + if (StringHelper::check($value)) + { + // see if the field needs some help :) + $_key = (isset($helper[$key])) ? $helper[$key] : $key; + + // build the buttons + $buttons[$_key] = array(); + if (($button = $this->getButton('custom_code', 3)) && StringHelper::check($button)) + { + $buttons[$_key]['_create'] = $button; + } + } + } + } + // check if any values found + if (UtilitiesArrayHelper::check($bucket)) + { + foreach ($bucket as $field => $customcodes) + { + // see if the field needs some help :) + $field = (isset($helper[$field])) ? $helper[$field] : $field; + // set the edit icon + $edit_icon = ' '; + // load the buttons found + foreach ($customcodes as $customcode) + { + // get the customcode name + $key = (array) explode('+', $customcode); + // see if we can get the button + if (!isset($buttons[$field][$key[0]]) && ($_id = GetHelper::var('custom_code', $key[0], 'function_name')) !== false + && ($button = ComponentbuilderHelper::getEditTextButton($edit_icon . $key[0], $_id, 'custom_code', 'custom_codes', $return_here, 'com_componentbuilder', false, 'btn btn-small button-edit" style="margin: 0 0 5px 0;')) + && StringHelper::check($button)) + { + $buttons[$field][$key[0]] = $button; + } + } + } + } + } + // only continue if we have buttons in array + if (UtilitiesArrayHelper::check($buttons, true)) + { + return $buttons; + } + } + return false; + } + + public function checkFunctionName($name, $id) + { + $nameArray = (array) $this->splitAtUpperCase($name); + $name = StringHelper::safe(implode(' ', $nameArray), 'cA'); + if ($found = GetHelper::var('custom_code', $name, 'function_name', 'id')) + { + if ((int) $id !== (int) $found) + { + return array ( + 'message' => Text::_('COM_COMPONENTBUILDER_SORRY_THIS_FUNCTION_NAME_IS_ALREADY_IN_USE'), + 'status' => 'danger'); + } + } + return array ( + 'name' => $name, + 'message' => Text::_('COM_COMPONENTBUILDER_GREAT_THIS_FUNCTION_NAME_WILL_WORK'), + 'status' => 'success'); + } + + protected function splitAtUpperCase($string) + { + return preg_split('/(?=[A-Z])/', $string, -1, PREG_SPLIT_NO_EMPTY); + } + + public function usedin($functioName, $id, $targeting) + { + // get the table being targeted + if ($target = $this->getCodeSearchKeys($targeting, 'query')) + { + $db = Factory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName($target['select'])) + ->from($db->quoteName('#__componentbuilder_' . $target['table'], 'a')); + if (strpos($target['name'], '->') !== false && strpos($target['name'], ':') !== false && strpos($target['name'], '.') !== false) + { + // joomla_component->id:joomla_component.system_name (example) + $targetJoin = explode('->', $target['name']); + // get keys + $targetKeys = explode(':', $targetJoin[1]); + // get table.name + $table_name = explode('.', $targetKeys[1]); + // select the correct name + $query->select($db->quoteName(array('c.'.$table_name[1]), array($targetJoin[0]))); + // add some special fetch + $query->join('LEFT', $db->quoteName('#__componentbuilder_' . $table_name[0], 'c') . ' ON (' . $db->quoteName('a.'.$targetJoin[0]) . ' = ' . $db->quoteName('c.'.$targetKeys[0]) . ')'); + // set the correct name + $target['name'] = $targetJoin[0]; + } + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + $bucket = array(); + $hugeDataSet = $db->loadAssocList(); + foreach ($hugeDataSet as $data) + { + foreach ($data as $key => $value) + { + if ('id' !== $key && $target['name'] !== $key) + { + if (!isset($target['not_base64'][$key])) + { + $value = Base64Helper::open($value, null); + } + elseif ('json' === $target['not_base64'][$key] && 'xml' === $key) // just for field search + { + $value = json_decode($value); + } + // check if we should search for base64 string inside the text + if (isset($target['base64_search']) && isset($target['base64_search'][$key]) + && isset($target['base64_search'][$key]['start']) && strpos($value, $target['base64_search'][$key]['start']) !== false) + { + // search and open the base64 strings + $this->searchOpenBase64($value, $target['base64_search'][$key]); + } + // when searching for custom code placeholders + if('functioName' === 'functioName') + { + // check if placeholder found + if (strpos($value, '[CUSTOMC' . 'ODE=' . (string) $functioName . ']') !== false || strpos($value, '[CUSTOMC' . 'ODE=' . (int) $id . ']') !== false || strpos($value, '[CUSTOMC' . 'ODE=' . (string) $functioName . '+') !== false || strpos($value, '[CUSTOMC' . 'ODE=' . (int) $id . '+') !== false) + { + // found it so add to bucket + if (!isset($bucket[$data['id']])) + { + $bucket[$data['id']] = array(); + $bucket[$data['id']]['name'] = $data[$target['name']]; + $bucket[$data['id']]['fields'] = array(); + } + $bucket[$data['id']]['fields'][] = $key; + } + } + // when searching for just placeholders + elseif ('functioName' === 'placeholder') + { + // make sure the placeholder is wrapped + $functioName = preg_replace("/[^A-Za-z0-9_]/", '', $functioName); + // add the padding (needed) + $functioName = '[[[' . trim($functioName) . ']]]'; + // check if placeholder found + if (strpos($value, (string) $functioName) !== false) + { + // found it so add to bucket + if (!isset($bucket[$data['id']])) + { + $bucket[$data['id']] = array(); + $bucket[$data['id']]['name'] = $data[$target['name']]; + $bucket[$data['id']]['fields'] = array(); + } + $bucket[$data['id']]['fields'][] = $key; + } + } + } + } + } + // check if any values found + if (UtilitiesArrayHelper::check($bucket)) + { + // get input + $jinput = Factory::getApplication()->input; + $return_here = $jinput->get('return_here', null, 'base64'); + // set the return here value if not found + if (StringHelper::check($return_here)) + { + $return_here = '&return=' . $return_here; + } + else + { + $return_here = '&ref=custom_code&refid=' . (int) $id; + } + $usedin = array(); + foreach ($bucket as $editId => $values) + { + if (($button = ComponentbuilderHelper::getEditTextButton($values['name'], $editId, $target['table'], $target['views'], $return_here, 'com_componentbuilder', false, '')) + && StringHelper::check($button)) + { + $usedin[] = $button. ' (' . implode(', ', $values['fields']) . ')'; + } + } + $html = '
    • ' . implode('
    • ', $usedin) . '
    '; + return array('in' => $html, 'id' => $targeting); + } + } + } + return false; + } + + + /** + * Search for base64 strings and decode them + * + * @param string $value The string to search + * @param array $target The target search values + * + * @return void + * + */ + protected function searchOpenBase64(&$value, &$target) + { + // first get the start property (if dynamic) + $starts = array(); + if (isset($target['_start'])) + { + // get all values + $allBetween = GetHelper::allBetween($value, $target['start'], $target['_start']); + // just again make sure we found some + if (UtilitiesArrayHelper::check($allBetween)) + { + if (count((array) $allBetween) > 1) + { + // search for many + foreach ($allBetween as $between) + { + // load the starting property + $start = $target['start']; + $start .= $between; + $start .= $target['_start']; + + $starts[] = $start; + } + } + else + { + // load the starting property + $start = $target['start']; + $start .= array_values($allBetween)[0]; + $start .= $target['_start']; + + $starts[] = $start; + } + } + } + else + { + $starts[] = $target['start']; + } + // has any been found + if (UtilitiesArrayHelper::check($starts)) + { + foreach ($starts as $_start) + { + // get the base64 string + $base64 = GetHelper::between($value, $_start, $target['end']); + // now open the base64 text + $tmp = Base64Helper::open($base64); + // insert it back into the value (so we still search the whole string) + $value = str_replace($base64, $tmp, $value); + } + } + } + + + /** + * The code search keys/targets + * + * @var array + */ + protected $codeSearchKeys = array( + // #__componentbuilder_joomla_component (a) + 'joomla_component' => array( + 'search' => array('id', 'system_name', 'php_preflight_install', 'php_postflight_install', + 'php_preflight_update', 'php_postflight_update', 'php_method_uninstall', + 'php_helper_admin', 'php_admin_event', 'php_helper_both', 'php_helper_site', + 'php_site_event', 'javascript', 'readme', 'sql', 'sql_uninstall'), + 'views' => 'joomla_components', + 'not_base64' => array(), + 'name' => 'system_name' + ), + // #__componentbuilder_component_dashboard (b) + 'component_dashboard' => array( + 'search' => array('id', 'joomla_component', 'php_dashboard_methods', 'dashboard_tab'), + 'views' => 'components_dashboard', + 'not_base64' => array('dashboard_tab' => 'json'), + 'name' => 'joomla_component->id:joomla_component.system_name' + ), + // #__componentbuilder_component_placeholders (c) + 'component_placeholders' => array( + 'search' => array('id', 'joomla_component', 'addplaceholders'), + 'views' => 'components_placeholders', + 'not_base64' => array('addplaceholders' => 'json'), + 'name' => 'joomla_component->id:joomla_component.system_name' + ), + // #__componentbuilder_admin_view (d) + 'admin_view' => array( + 'search' => array('id', 'system_name', 'javascript_view_file', 'javascript_view_footer', + 'javascript_views_file', 'javascript_views_footer', 'html_import_view', + 'php_after_delete', 'php_after_publish', 'php_ajaxmethod', 'php_allowedit', 'php_batchcopy', + 'php_batchmove', 'php_before_delete', 'php_before_publish', 'php_before_save', 'php_controller', + 'php_controller_list', 'php_document', 'php_getitem', 'php_getitems', 'php_getitems_after_all', + 'php_getlistquery', 'php_import', 'php_import_display', 'php_import_ext', 'php_import_headers', 'php_getform', + 'php_import_save', 'php_import_setdata', 'php_model', 'php_model_list', 'php_postsavehook', 'php_save', 'sql'), + 'views' => 'admin_views', + 'not_base64' => array(), + 'name' => 'system_name' + ), + // #__componentbuilder_admin_fields_relations (e) + 'admin_fields_relations' => array( + 'search' => array('id', 'admin_view', 'addrelations'), + 'views' => 'admins_fields_relations', + 'not_base64' => array('addrelations' => 'json'), + 'name' => 'admin_view->id:admin_view.system_name' + ), + // #__componentbuilder_admin_custom_tabs (f) + 'admin_custom_tabs' => array( + 'search' => array('id', 'admin_view', 'tabs'), + 'views' => 'admins_custom_tabs', + 'not_base64' => array('tabs' => 'json'), + 'name' => 'admin_view->id:admin_view.system_name' + ), + // #__componentbuilder_custom_admin_view (g) + 'custom_admin_view' => array( + 'search' => array('id', 'system_name', 'default', 'php_view', 'php_jview', 'php_jview_display', 'php_document', + 'javascript_file', 'js_document', 'css_document', 'css', 'php_ajaxmethod', 'php_model', 'php_controller'), + 'views' => 'custom_admin_views', + 'not_base64' => array(), + 'name' => 'system_name' + ), + // #__componentbuilder_site_view (h) + 'site_view' => array( + 'search' => array('id', 'system_name', 'default', 'php_view', 'php_jview', 'php_jview_display', 'php_document', + 'javascript_file', 'js_document', 'css_document', 'css', 'php_ajaxmethod', 'php_model', 'php_controller'), + 'views' => 'site_views', + 'not_base64' => array(), + 'name' => 'system_name' + ), + // #__componentbuilder_field (i) + 'field' => array( + 'search' => array('id', 'name', 'xml', 'javascript_view_footer', 'javascript_views_footer', 'on_save_model_field', 'on_get_model_field', 'initiator_on_save_model', 'initiator_on_get_model'), + 'views' => 'fields', + 'not_base64' => array('xml' => 'json'), + 'base64_search' => array('xml' => array('start' => 'type_php', '_start' => '="', 'end' => '"')), + 'name' => 'name' + ), + // #__componentbuilder_fieldtype (j) + 'fieldtype' => array( + 'search' => array('id', 'name', 'properties'), + 'views' => 'fieldtypes', + 'not_base64' => array('properties' => 'json'), + 'name' => 'name' + ), + // #__componentbuilder_dynamic_get (k) + 'dynamic_get' => array( + 'search' => array('id', 'name', 'php_before_getitem', 'php_after_getitem', 'php_before_getitems', 'php_after_getitems', + 'php_getlistquery', 'php_calculation'), + 'views' => 'dynamic_gets', + 'not_base64' => array(), + 'name' => 'name' + ), + // #__componentbuilder_template (l) + 'template' => array( + 'search' => array('id', 'name', 'php_view', 'template'), + 'views' => 'templates', + 'not_base64' => array(), + 'name' => 'name' + ), + // #__componentbuilder_layout (m) + 'layout' => array( + 'search' => array('id', 'name', 'php_view', 'layout'), + 'views' => 'layouts', + 'not_base64' => array(), + 'name' => 'name' + ), + // #__componentbuilder_library (n) + 'library' => array( + 'search' => array('id', 'name', 'php_setdocument'), + 'views' => 'libraries', + 'not_base64' => array(), + 'name' => 'name' + ), + // #__componentbuilder_custom_code (o) + 'custom_code' => array( + 'search' => array('id', 'system_name', 'code'), + 'views' => 'custom_codes', + 'not_base64' => array(), + 'name' => 'system_name' + ), + // #__componentbuilder_validation_rule (p) + 'validation_rule' => array( + 'search' => array('id', 'name', 'php'), + 'views' => 'validation_rules', + 'not_base64' => array(), + 'name' => 'name' + ), + // #__componentbuilder_joomla_module (q) + 'joomla_module' => array( + 'search' => array('id', 'system_name', 'name', 'default', 'description', 'mod_code', 'class_helper_header', 'class_helper_code', 'php_script_construct', 'php_preflight_install', 'php_preflight_update', + 'php_preflight_uninstall', 'php_postflight_install', 'php_postflight_update', 'php_method_uninstall', 'sql', 'sql_uninstall', 'readme'), + 'views' => 'joomla_modules', + 'not_base64' => array('description' => 'string', 'readme' => 'string'), + 'name' => 'system_name' + ), + // #__componentbuilder_joomla_plugin (r) + 'joomla_plugin' => array( + 'search' => array('id', 'system_name', 'name', 'main_class_code', 'head', 'description', 'php_script_construct', 'php_preflight_install', 'php_preflight_update', + 'php_preflight_uninstall', 'php_postflight_install', 'php_postflight_update', 'php_method_uninstall', 'sql', 'sql_uninstall', 'readme'), + 'views' => 'joomla_plugins', + 'not_base64' => array('description' => 'string', 'readme' => 'string'), + 'name' => 'system_name' + ), + // #__componentbuilder_class_extends (s) + 'class_extends' => array( + 'search' => array('id', 'name', 'head', 'comment'), + 'views' => 'class_extendings', + 'not_base64' => array(), + 'name' => 'name' + ), + // #__componentbuilder_class_property (t) + 'class_property' => array( + 'search' => array('id', 'name', 'default', 'comment'), + 'views' => 'class_properties', + 'not_base64' => array(), + 'name' => 'name' + ), + // #__componentbuilder_class_method (u) + 'class_method' => array( + 'search' => array('id', 'name', 'code', 'comment'), + 'views' => 'class_methods', + 'not_base64' => array(), + 'name' => 'name' + ), + // #__componentbuilder_power (v) + 'power' => array( + 'search' => array('id', 'system_name', 'name', 'description', 'head', 'namespace', 'main_class_code'), + 'views' => 'powers', + 'not_base64' => array('description'), + 'name' => 'system_name' + ) + ); + + /** + * Get the keys of the values to search custom code in + * + * @param string $target The table targeted + * @param string $type The type of get + * + * @return array The query options + * + */ + protected function getCodeSearchKeys($target, $type = null) + { + // set the template if type is query + if ('query' === $type) + { + // setup the tables + $tables = array(); + $key = 'a'; + foreach (array_keys($this->codeSearchKeys) as $table) + { + $tables[$key] = $table; + $key++; + } + // check if we have a match + if (isset($tables[$target])) + { + $target = $tables[$target]; + } + } + // return result ready for a.query + if (('query' === $type || 'query_' === $type) && isset($this->codeSearchKeys[$target])) + { + // set the targets + $codeSearchTarget = $this->codeSearchKeys[$target]; + // add the .a to the selection array + $codeSearchTarget['select'] = array_map( function($select) { return 'a.' . $select; }, $codeSearchTarget['search']); + // also set the table + $codeSearchTarget['table'] = $target; + // remove search + unset($codeSearchTarget['search']); + // return targeted array to use in query + return $codeSearchTarget; + } + // does the target exist + elseif (isset($this->codeSearchKeys[$target])) + { + // return target array values to use in search + return $this->codeSearchKeys[$target]; + } + return false; + } + + + // Used in placeholder + public function checkPlaceholderName($id, $name) + { + return ComponentbuilderHelper::validateUniquePlaceholder($id, $name); + } + + public function placedin($placeholder, $id, $targeting) + { + // get the table being targeted + if ($target = $this->getCodeSearchKeys($targeting, 'query')) + { + $db = Factory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName($target['select'])) + ->from($db->quoteName('#__componentbuilder_' . $target['table'], 'a')); + if (strpos($target['name'], '->') !== false && strpos($target['name'], ':') !== false && strpos($target['name'], '.') !== false) + { + // joomla_component->id:joomla_component.system_name (example) + $targetJoin = explode('->', $target['name']); + // get keys + $targetKeys = explode(':', $targetJoin[1]); + // get table.name + $table_name = explode('.', $targetKeys[1]); + // select the correct name + $query->select($db->quoteName(array('c.'.$table_name[1]), array($targetJoin[0]))); + // add some special fetch + $query->join('LEFT', $db->quoteName('#__componentbuilder_' . $table_name[0], 'c') . ' ON (' . $db->quoteName('a.'.$targetJoin[0]) . ' = ' . $db->quoteName('c.'.$targetKeys[0]) . ')'); + // set the correct name + $target['name'] = $targetJoin[0]; + } + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + $bucket = array(); + $hugeDataSet = $db->loadAssocList(); + foreach ($hugeDataSet as $data) + { + foreach ($data as $key => $value) + { + if ('id' !== $key && $target['name'] !== $key) + { + if (!isset($target['not_base64'][$key])) + { + $value = Base64Helper::open($value, null); + } + elseif ('json' === $target['not_base64'][$key] && 'xml' === $key) // just for field search + { + $value = json_decode($value); + } + // check if we should search for base64 string inside the text + if (isset($target['base64_search']) && isset($target['base64_search'][$key]) + && isset($target['base64_search'][$key]['start']) && strpos($value, $target['base64_search'][$key]['start']) !== false) + { + // search and open the base64 strings + $this->searchOpenBase64($value, $target['base64_search'][$key]); + } + // when searching for custom code placeholders + if('placeholder' === 'functioName') + { + // check if placeholder found + if (strpos($value, '[CUSTOMC' . 'ODE=' . (string) $placeholder . ']') !== false || strpos($value, '[CUSTOMC' . 'ODE=' . (int) $id . ']') !== false || strpos($value, '[CUSTOMC' . 'ODE=' . (string) $placeholder . '+') !== false || strpos($value, '[CUSTOMC' . 'ODE=' . (int) $id . '+') !== false) + { + // found it so add to bucket + if (!isset($bucket[$data['id']])) + { + $bucket[$data['id']] = array(); + $bucket[$data['id']]['name'] = $data[$target['name']]; + $bucket[$data['id']]['fields'] = array(); + } + $bucket[$data['id']]['fields'][] = $key; + } + } + // when searching for just placeholders + elseif ('placeholder' === 'placeholder') + { + // make sure the placeholder is wrapped + $placeholder = preg_replace("/[^A-Za-z0-9_]/", '', $placeholder); + // add the padding (needed) + $placeholder = '[[[' . trim($placeholder) . ']]]'; + // check if placeholder found + if (strpos($value, (string) $placeholder) !== false) + { + // found it so add to bucket + if (!isset($bucket[$data['id']])) + { + $bucket[$data['id']] = array(); + $bucket[$data['id']]['name'] = $data[$target['name']]; + $bucket[$data['id']]['fields'] = array(); + } + $bucket[$data['id']]['fields'][] = $key; + } + } + } + } + } + // check if any values found + if (UtilitiesArrayHelper::check($bucket)) + { + // get input + $jinput = Factory::getApplication()->input; + $return_here = $jinput->get('return_here', null, 'base64'); + // set the return here value if not found + if (StringHelper::check($return_here)) + { + $return_here = '&return=' . $return_here; + } + else + { + $return_here = '&ref=placeholder&refid=' . (int) $id; + } + $placedin = array(); + foreach ($bucket as $editId => $values) + { + if (($button = ComponentbuilderHelper::getEditTextButton($values['name'], $editId, $target['table'], $target['views'], $return_here, 'com_componentbuilder', false, '')) + && StringHelper::check($button)) + { + $placedin[] = $button. ' (' . implode(', ', $values['fields']) . ')'; + } + } + $html = '
    • ' . implode('
    • ', $placedin) . '
    '; + return array('in' => $html, 'id' => $targeting); + } + } + } + return false; + } + + + // Used in validation_rule + public function getExistingValidationRuleCode($name) + { + // make sure we have all the exiting rule names + if ($names = ComponentbuilderHelper::getExistingValidationRuleNames()) + { + // check that this is a valid rule file + if (UtilitiesArrayHelper::check($names) && in_array($name, $names)) + { + // get the full path to rule file + $path = JPATH_LIBRARIES . '/src/Form/Rule/'.$name.'Rule.php'; + // get all the code + if ($code = ComponentbuilderHelper::getFileContents($path)) + { + // remove the class details and the ending } + $codeArray = (array) explode("FormRule\n{\n", $code); + if (isset($codeArray[1])) + { + return array('values' => rtrim(rtrim(rtrim($codeArray[1]),'}'))); + } + } + } + } + return false; + } + + public function checkRuleName($name, $id) + { + $name = StringHelper::safe($name); + if ($found = GetHelper::var('validation_rule', $name, 'name', 'id')) + { + if ((int) $id !== (int) $found) + { + return array ( + 'message' => Text::sprintf('COM_COMPONENTBUILDER_SORRY_THIS_VALIDATION_RULE_NAME_S_ALREADY_EXIST_IN_YOUR_SYSTEM', $name), + 'status' => 'danger', + 'timeout' => 6000); + } + } + // now check the existing once + if ($names = ComponentbuilderHelper::getExistingValidationRuleNames(true)) + { + if (in_array($name, $names)) + { + return array ( + 'message' => Text::sprintf('COM_COMPONENTBUILDER_SORRY_THIS_VALIDATION_RULE_NAME_S_ALREADY_EXIST_AS_PART_OF_THE_JOOMLA_CORE_NO_NEED_TO_CREATE_IT_IF_YOU_ARE_ADAPTING_IT_GIVE_IT_YOUR_OWN_UNIQUE_NAME', $name), + 'status' => 'danger', + 'timeout' => 10000); + } + } + return array ( + 'name' => $name, + 'message' => Text::sprintf('COM_COMPONENTBUILDER_GREAT_THIS_VALIDATION_RULE_NAME_S_WILL_WORK', $name), + 'status' => 'success', + 'timeout' => 5000); + } + + public function getValidationRulesTable($id) + { + // get all the validation rules + if ($rules = $this->getValidationRules()) + { + // build table + $table = '
    '; + $table .= ''; + $table .= ''; + $table .= ''; + foreach ($rules as $name => $decs) + { + // just load the values + $decs = (StringHelper::check($decs) && !is_numeric($decs)) ? $decs : ''; + $table .= ''; + } + return $table.'
    '.Text::sprintf('COM_COMPONENTBUILDER_THE_AVAILABLE_VALIDATION_RULES_FOR_THE_VALIDATE_ATTRIBUTE_ARE').'
    '.Text::_('COM_COMPONENTBUILDER_VALIDATE').''.Text::_('COM_COMPONENTBUILDER_DESCRIPTION').'
    '.$name.''. $decs. '
    '; + } + return false; + } + + public function getValidationRules() + { + // custom rule names + $names = array(); + // make sure we have all the exiting rule names + if (!$exitingNames = ComponentbuilderHelper::getExistingValidationRuleNames(true)) + { + // stop (something is wrong) + return false; + } + // convert names to keys + $exitingNames = array_flip($exitingNames); + // load the descriptions (taken from https://docs.joomla.org/Server-side_form_validation) + $exitingNames["boolean"] = Text::_("COM_COMPONENTBUILDER_ACCEPTS_ONLY_THE_VALUES_ZERO_ONE_TRUE_OR_FALSE_CASEINSENSITIVE"); + $exitingNames["color"] = Text::_("COM_COMPONENTBUILDER_ACCEPTS_ONLY_EMPTY_VALUES_CONVERTED_TO_ZERO_AND_STRINGS_IN_THE_FORM_RGB_OR_RRGGBB_WHERE_R_G_AND_B_ARE_HEX_VALUES"); + $exitingNames["email"] = Text::_("COM_COMPONENTBUILDER_ACCEPTS_AN_EMAIL_ADDRESS_SATISFIES_A_BASIC_SYNTAX_CHECK_IN_THE_PATTERN_OF_QUOTXYZZQUOT_WITH_NO_INVALID_CHARACTERS"); + $exitingNames["equals"] = Text::sprintf("COM_COMPONENTBUILDER_REQUIRES_THE_VALUE_TO_BE_THE_SAME_AS_THAT_HELD_IN_THE_FIELD_NAMED_QUOTFIELDQUOT_EGS", '
    <input
      type="text"
      name="email_check"
      validate="equals"
      field="email"
    />
    '); + $exitingNames["options"] = Text::_("COM_COMPONENTBUILDER_REQUIRES_THE_VALUE_ENTERED_BE_ONE_OF_THE_OPTIONS_IN_AN_ELEMENT_OF_TYPEQUOTLISTQUOT_THAT_IS_THAT_THE_ELEMENT_IS_A_SELECT_LIST"); + $exitingNames["tel"] = Text::_("COM_COMPONENTBUILDER_REQUIRES_THE_VALUE_TO_BE_A_TELEPHONE_NUMBER_COMPLYING_WITH_THE_STANDARDS_OF_NANPA_ITUT_TRECEONE_HUNDRED_AND_SIXTY_FOUR_OR_IETF_RFCFOUR_THOUSAND_NINE_HUNDRED_AND_THIRTY_THREE"); + $exitingNames["url"] = Text::sprintf("COM_COMPONENTBUILDER_VALIDATES_THAT_THE_VALUE_IS_A_URL_WITH_A_VALID_SCHEME_WHICH_CAN_BE_RESTRICTED_BY_THE_OPTIONAL_COMMASEPARATED_FIELD_SCHEME_AND_PASSES_A_BASIC_SYNTAX_CHECK_EGS", '
    <input
      type="text"
      name="link"
      validate="url"
      scheme="http,https,mailto"
    />
    '); + $exitingNames["username"] = Text::_("COM_COMPONENTBUILDER_VALIDATES_THAT_THE_VALUE_DOES_NOT_APPEAR_AS_A_USERNAME_ON_THE_SYSTEM_THAT_IS_THAT_IT_IS_A_VALID_NEW_USERNAME_DOES_NOT_SYNTAX_CHECK_IT_AS_A_VALID_NAME"); + // now get the custom created rules + $db = Factory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.name','a.short_description'))); + $query->from($db->quoteName('#__componentbuilder_validation_rule','a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $names = $db->loadAssocList('name', 'short_description'); + } + // merge the arrays + $rules = UtilitiesArrayHelper::merge(array($exitingNames, $names)); + // sort the array + ksort($rules); + // return the validation rules + return $rules; + } + + // Used in field + // the current extras available + protected $extraFieldProperties = array( + 'listclass' => 'COM_COMPONENTBUILDER_SET_A_CLASS_VALUE_FOR_THE_LIST_VIEW_OF_THIS_FIELD', + 'escape' => 'COM_COMPONENTBUILDER_SHOULD_THIS_FIELD_BE_ESCAPED_IN_THE_LIST_VIEW', + 'display' => 'COM_COMPONENTBUILDER_DISPLAY_SWITCH_FOR_DYNAMIC_PLACEMENT_IN_RELATION_TO_THE_USE_OF_THE_FIELD_IN_MENU_AND_GLOBAL_CONFIGURATION_OPTIONS_SO_THE_CONFIG_OPTION_WILL_ONLY_ADD_THE_FIELD_TO_THE_GLOBAL_CONFIGURATION_AREA_MENU_WILL_ADD_THE_FIELD_ONLY_TO_THE_MENU_AREA', + 'validate' => 'COM_COMPONENTBUILDER_TO_ADD_VALIDATION_TO_A_FIELD_IF_VALIDATION_IS_NOT_PART_OF_FIELD_TYPE_PROPERTIES_LOADED_ABOVE_SO_IF_YOU_HAVE_VALIDATION_SET_AS_A_FIELD_PROPERTY_THIS_EXTRA_PROPERTY_WILL_NOT_BE_NEEDED'); + + public function getFieldTypeProperties($fieldtype) + { + // get the xml + $xml = $this->getFieldXML($fieldtype); + // now get the field options + if ($field = ComponentbuilderHelper::getFieldTypeProperties($fieldtype, 'id', null, $xml, true)) + { + // get subform field properties object + $properties = $this->buildFieldOptionsSubform($field['subform'], $field['nameListOptions']); + // load the extra options + $extraValues = $this->getFieldExtraValues($xml, $field['nameListOptions']); + // set the nameListOption + $extraNameListOption = $this->extraFieldProperties; + array_walk($extraNameListOption, function (&$value, $key) { + $value = $key; + }); + // get subform field object + $extras = $this->buildFieldOptionsSubform($extraValues, $extraNameListOption, 'extraproperties', 'COM_COMPONENTBUILDER_EXTRA_PROPERTIES_LIKE_LISTCLASS_ESCAPE_DISPLAY_VALIDATEBR_SMALLHERE_YOU_CAN_SET_THE_EXTRA_PROPERTIES_FOR_THIS_FIELDSMALL'); + // load the html + $field['subform'] = '
    '. $properties->label . '
    ' . $properties->input . '
    '; + $field['extra'] = '
    '. $extras->label . '
    ' . $extras->input . '
    '; + // check if we have PHP values + if (UtilitiesArrayHelper::check($field['php'])) + { + $field['textarea'] = array(); + foreach($field['php'] as $name => $values) + { + $value = implode(PHP_EOL, $values['value']); + $textarea = $this->buildFieldTextarea($name, $values['desc'], $value, substr_count( $value, PHP_EOL )); + // load the html + $field['textarea'][] = '
    '. $textarea->label . '
    ' . $textarea->input . '

    '; + } + } + // remove some unneeded values + unset($field['values']); + // return found field options + return $field; + } + return false; + } + + protected function getFieldExtraValues($xml, $options) + { + // get the value + $values = array(); + // value to check since there are false and null values even 0 in the values returned + $confirmation = '8qvZHoyuFYQqpj0YQbc6F3o5DhBlmS-_-a8pmCZfOVSfANjkmV5LG8pCdAY2JNYu6cB'; + $nr = 0; + foreach ($this->extraFieldProperties as $extra => $desc) + { + if (!in_array($extra, $options)) + { + $value = FieldHelper::getValue($xml, $extra, $confirmation); + if ($confirmation !== $value) + { + $values['extraproperties' . $nr] = array('name' => $extra, 'value' => $value, 'desc' => Text::_($desc)); + $nr++; + } + } + } + // return only if extras founb + if (UtilitiesArrayHelper::check($values)) + { + return $values; + } + return null; + } + + protected function buildFieldTextarea($name, $desc, $default, $rows) + { + // get the textarea + $textarea = \JFormHelper::loadFieldType('textarea', true); + // start building the name field XML + $textareaXML = new \SimpleXMLElement(''); + // textarea attributes + $textareaAttribute = array( + 'type' => 'textarea', + 'name' => 'property_'.$name, + 'label' => $desc, + 'rows' => (int) ($rows >= 3) ? $rows : $rows + 2, + 'cols' => '15', + 'class' => 'text_area span12', + 'filter' => 'RAW', + 'hint' => 'COM_COMPONENTBUILDER__ADD_YOUR_PHP_SCRIPT_HERE'); + // load the textarea attributes + ComponentbuilderHelper::xmlAddAttributes($textareaXML, $textareaAttribute); + + // setup subform with values + $textarea->setup($textareaXML, $default); + + // return textarea object + return $textarea; + } + + protected function buildFieldOptionsSubform($values, $nameListOptions = null, $name = 'properties', $label = 'COM_COMPONENTBUILDER_PROPERTIESBR_SMALLHERE_YOU_CAN_SET_THE_PROPERTIES_FOR_THIS_FIELDSMALL') + { + // get the subform + $subform = \JFormHelper::loadFieldType('subform', true); + // start building the subform field XML + $subformXML = new \SimpleXMLElement(''); + // subform attributes + $subformAttribute = array( + 'type' => 'subform', + 'name' => $name, + 'label' => $label, + 'layout' => 'joomla.form.field.subform.repeatable-table', + 'multiple' => 'true', + 'icon' => 'list', + 'max' => (UtilitiesArrayHelper::check($nameListOptions)) ? (int) count($nameListOptions) : 4); + // load the subform attributes + ComponentbuilderHelper::xmlAddAttributes($subformXML, $subformAttribute); + // now add the subform child form + $childForm = $subformXML->addChild('form'); + // child form attributes + $childFormAttribute = array( + 'hidden' => 'true', + 'name' => 'list_properties', + 'repeat' => 'true'); + // load the child form attributes + ComponentbuilderHelper::xmlAddAttributes($childForm, $childFormAttribute); + + // start building the name field XML + $nameXML = new \SimpleXMLElement(''); + // subform attributes + $nameAttribute = array( + 'type' => (UtilitiesArrayHelper::check($nameListOptions)) ? 'list' : 'text', + 'name' => 'name', + 'label' => 'COM_COMPONENTBUILDER_PROPERTY', + 'size' => '40', + 'maxlength' => '150', + 'class' => (UtilitiesArrayHelper::check($nameListOptions)) ? 'list_class field_list_name_options' : 'text_area', + 'filter' => 'STRING'); + // add the hint only if not name list and description if name list is an array + if (UtilitiesArrayHelper::check($nameListOptions)) + { + $nameAttribute['description'] = 'COM_COMPONENTBUILDER_SELECTION'; + $nameAttribute['multiple'] = 'false'; + $nameAttribute['onchange'] = "getFieldPropertyDesc(this, '".$name."')"; + } + else + { + $nameAttribute['hint'] = 'COM_COMPONENTBUILDER_PROPERTY_NAME'; + } + // load the subform attributes + ComponentbuilderHelper::xmlAddAttributes($nameXML, $nameAttribute); + // add name list if found + if (UtilitiesArrayHelper::check($nameListOptions)) + { + ComponentbuilderHelper::xmlAddOptions($nameXML, $nameListOptions); + } + // now add the fields to the child form + ComponentbuilderHelper::xmlAppend($childForm, $nameXML); + + // start building the name field XML + $valueXML = new \SimpleXMLElement(''); + // subform attributes + $valueAttribute = array( + 'type' => 'textarea', + 'name' => 'value', + 'label' => 'COM_COMPONENTBUILDER_VALUE', + 'rows' => '1', + 'cols' => '15', + 'class' => 'text_area span12', + 'filter' => 'STRING', + 'hint' => 'COM_COMPONENTBUILDER_PROPERTY_VALUE'); + // load the subform attributes + ComponentbuilderHelper::xmlAddAttributes($valueXML, $valueAttribute); + // now add the fields to the child form + ComponentbuilderHelper::xmlAppend($childForm, $valueXML); + + // start building the desc field XML + $descXML = new \SimpleXMLElement(''); + // subform attributes + $descAttribute = array( + 'type' => 'textarea', + 'name' => 'desc', + 'label' => 'COM_COMPONENTBUILDER_DESCRIPTION', + 'rows' => '3', + 'cols' => '25', + 'readonly' => 'true', + 'class' => 'text_area span12', + 'filter' => 'WORD', + 'hint' => 'COM_COMPONENTBUILDER_SELECT_A_PROPERTY'); + // load the desc attributes + ComponentbuilderHelper::xmlAddAttributes($descXML, $descAttribute); + // now add the fields to the child form + ComponentbuilderHelper::xmlAppend($childForm, $descXML); + + // setup subform with values + $subform->setup($subformXML, $values); + + // return subfrom object + return $subform; + } + + public function getFieldPropertyDesc($_property, $fieldtype) + { + if (is_numeric($fieldtype)) + { + // Get a db connection. + $db = Factory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('properties', 'short_description', 'description'))); + $query->from($db->quoteName('#__componentbuilder_fieldtype')); + $query->where($db->quoteName('id') . ' = '. (int) $fieldtype); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + // get the result + $result = $db->loadObject(); + // get the xml + $xml = $this->getFieldXML($fieldtype); + // open the properties + $properties = json_decode($result->properties,true); + // value to check since there are false and null values even 0 in the values returned + $confirmation = '8qvZHoyuFYQqpj0YQbc6F3o5DhBlmS-_-a8pmCZfOVSfANjkmV5LG8pCdAY2JNYu6cB'; + // make sure we have an array + if (UtilitiesArrayHelper::check($properties)) + { + foreach ($properties as $property) + { + if(isset($property['name']) && $_property === $property['name']) + { + // check if we should load the value + $value = FieldHelper::getValue($xml, $property['name'], $confirmation); + if ($confirmation === $value) + { + $value = (isset($property['example']) && StringHelper::check($property['example'])) ? $property['example'] : ''; + } + // return the found values + return array('value' => $value, 'desc' => $property['description']); + } + } + } + } + } + elseif (isset($this->extraFieldProperties[$_property])) + { + return array('value' => '', 'desc' => Text::_($this->extraFieldProperties[$_property])); + } + return false; + } + + protected function getFieldXML($fieldtype) + { + // reset xml to null + $xml = null; + // get the view name & id + $global = $this->getViewID(); + // get the xml if this view already has it set + if (!is_null($global['a_id']) && $global['a_id'] > 0 && isset($global['a_view']) && 'field' === $global['a_view']) + { + // first check field type + $_fieldType = GetHelper::var('field', $global['a_id'], 'id', 'fieldtype'); + $xmlDB = GetHelper::var('field', $global['a_id'], 'id', 'xml'); + // check if it is a string + if (StringHelper::check($xmlDB)) + { + $xml = json_decode($xmlDB); + } + // remove the field type if not the same + if ($xml && $fieldtype != $_fieldType) + { + // unset some stuff + $pattern = array(); + $pattern[] = '/type=".+?"/i'; // to force the new type to be set + $pattern[] = '/class=".+?"/i'; // to remove all classes + $pattern[] = '/type_php.+?".+?"/i'; // to remove any PHP code stuff + + // also add a special switch to force adding all properties of the new type + $xml = preg_replace($pattern, '..__FORCE_LOAD_ALL_PROPERTIES__..', $xml); + } + } + return $xml; + } + + // Used in admin_fields_relations + public function getCodeGlueOptions($listfield, $joinfields, $type, $area) + { + // CONCATENATE GLUE + if ($type == 1) + { + // MODEL + if ($area == 1 || $area == 3) + { + return ', '; + } + // VIEW + elseif ($area == 2) + { + return '
    '; + } + } + // CUSTOM CODE + elseif ($type == 2) + { + // build fields array + if ('none' !== $joinfields) + { + $fields = array_map( function ($id) { + return (int) $id; + }, (array) explode(',', $joinfields)); + // add the list field to array + array_unshift($fields, (int) $listfield); + } + else + { + $fields = array((int) $listfield); + } + // get field names + $names = array_map( function ($id) { + return '[' . $id . ']=> ' . GetHelper::var('field', $id, 'id', 'name'); + }, $fields); + // MODEL + if ($area == 1 || $area == 3) + { + // create note + $note = "// ". implode('; ', $names); + return $note . PHP_EOL . '$item->{'.(int)$listfield.'} = $item->{' . implode("} . ', ' . \$item->{", $fields) . '};'; + } + // VIEW + elseif ($area == 2) + { + // create note + $note = ""; + return '[field=' . implode("]
    [field=", $fields). ']' . PHP_EOL . PHP_EOL . $note; + } + } + return false; + } + + // Used in search + /** + * Search for value in a table + * + * @param string $tableName The main table to search + * @param int $typeSearch The type of search being done + * @param string $searchValue The value to search for + * @param int $matchCase The switch to control match case + * @param int $wholeWord The switch to control whole word + * @param int $regexSearch The switch to control regex search + * @param int $componentId The option to filter by component + * + * @return array|null + * @since 3.2.0 + **/ + public function doSearch(string $tableName, int $typeSearch, string $searchValue, + int $matchCase, int $wholeWord, int $regexSearch, int $componentId): ?array + { + // check if this is a valid table + if (SearchFactory::_('Table')->exist($tableName)) + { + try + { + // load the configurations + SearchFactory::_('Config')->table_name = $tableName; + SearchFactory::_('Config')->type_search = $typeSearch; + SearchFactory::_('Config')->search_value = $searchValue; + SearchFactory::_('Config')->match_case = $matchCase; + SearchFactory::_('Config')->whole_word = $wholeWord; + SearchFactory::_('Config')->regex_search = $regexSearch; + SearchFactory::_('Config')->component_id = $componentId; + + if (($items = SearchFactory::_('Agent')->table($tableName)) !== null) + { + return [ + 'success' => Text::sprintf('COM_COMPONENTBUILDER_WE_FOUND_SOME_INSTANCES_IN_S', $tableName), + 'items' => $items, + 'fields_count' => SearchFactory::_('Config')->field_counter, + 'line_count' => SearchFactory::_('Config')->line_counter + ]; + } + + return [ + 'not_found' => Text::sprintf('COM_COMPONENTBUILDER_NO_INSTANCES_WHERE_FOUND_IN_S', $tableName), + 'fields_count' => SearchFactory::_('Config')->field_counter, + 'line_count' => SearchFactory::_('Config')->line_counter + ]; + } + catch(Exception $error) + { + return ['error' => $error->getMessage()]; + } + } + + return ['error' => Text::_('COM_COMPONENTBUILDER_THERE_HAS_BEEN_AN_ERROR_PLEASE_TRY_AGAIN')]; + } + + /** + * Search and replace value in a table + * + * @param string $tableName The main table to search + * @param string $searchValue The value to search for + * @param string|null $replaceValue The value to replace search value + * @param int $matchCase The switch to control match case + * @param int $wholeWord The switch to control whole word + * @param int $regexSearch The switch to control regex search + * @param int $componentId The option to filter by component + * + * @return array|null + * @since 3.2.0 + **/ + public function replaceAll(string $tableName, string $searchValue, ?string $replaceValue = null, + int $matchCase, int $wholeWord, int $regexSearch, int $componentId): ?array + { + // check if this is a valid table + if (SearchFactory::_('Table')->exist($tableName)) + { + try + { + // load the configurations + SearchFactory::_('Config')->table_name = $tableName; + SearchFactory::_('Config')->search_value = $searchValue; + SearchFactory::_('Config')->replace_value = $replaceValue; + SearchFactory::_('Config')->match_case = $matchCase; + SearchFactory::_('Config')->whole_word = $wholeWord; + SearchFactory::_('Config')->regex_search = $regexSearch; + SearchFactory::_('Config')->component_id = $componentId; + + if (($number = SearchFactory::_('Agent')->replace()) !== 0) + { + return ['success' => Text::sprintf('COM_COMPONENTBUILDER_ALL_FOUND_INSTANCES_IN_S_WHERE_REPLACED', $tableName)]; + } + return ['not_found' => Text::sprintf('COM_COMPONENTBUILDER_NO_INSTANCES_WHERE_FOUND_IN_S', $tableName)]; + } + catch(Exception $error) + { + return ['error' => $error->getMessage()]; + } + } + return ['error' => Text::_('COM_COMPONENTBUILDER_THERE_HAS_BEEN_AN_ERROR_PLEASE_TRY_AGAIN')]; + } + + /** + * Get a selected search value from a given table and row + * + * @param string $fieldName The field key + * @param int $rowId The item ID + * @param string $tableName The table + * @param string $searchValue The value to search for + * @param string|null $replaceValue The value to replace search value + * @param int $matchCase The switch to control match case + * @param int $wholeWord The switch to control whole word + * @param int $regexSearch The switch to control regex search + * + * @return array + * @since 3.2.0 + **/ + public function getSearchValue(string $fieldName, int $rowId, string $tableName, + string $searchValue, ?string $replaceValue = null, int $matchCase, int $wholeWord, int $regexSearch): array + { + // check if this is a valid table and field + if ($rowId > 0 && SearchFactory::_('Table')->exist($tableName, $fieldName)) + { + try + { + // load the configurations + SearchFactory::_('Config')->table_name = $tableName; + SearchFactory::_('Config')->type_search = 1; + SearchFactory::_('Config')->search_value = $searchValue; + SearchFactory::_('Config')->replace_value = $replaceValue; + SearchFactory::_('Config')->match_case = $matchCase; + SearchFactory::_('Config')->whole_word = $wholeWord; + SearchFactory::_('Config')->regex_search = $regexSearch; + + if (($value = SearchFactory::_('Agent')->getValue($rowId, $fieldName, 0, $tableName)) !== null) + { + // load the value + return ['value' => $value]; + } + } + catch(Exception $error) + { + return ['error' => $error->getMessage()]; + } + } + return ['error' => Text::_('COM_COMPONENTBUILDER_THERE_HAS_BEEN_AN_ERROR_PLEASE_TRY_AGAIN')]; + } + + /** + * Get a replaced search value from a given table and row + * + * @param string $fieldName The field key + * @param int $rowId The item ID + * @param mixed $line The line line + * @param string $tableName The table + * @param string $searchValue The value to search for + * @param string|null $replaceValue The value to replace search value + * @param int $matchCase The switch to control match case + * @param int $wholeWord The switch to control whole word + * @param int $regexSearch The switch to control regex search + * + * @return array + * @since 3.2.0 + **/ + public function getReplaceValue(string $fieldName, int $rowId, $line, string $tableName, + string $searchValue, ?string $replaceValue = null, int $matchCase, int $wholeWord, int $regexSearch): array + { + // check if this is a valid table and field + if ($rowId > 0 && SearchFactory::_('Table')->exist($tableName, $fieldName)) + { + try + { + // load the configurations + SearchFactory::_('Config')->table_name = $tableName; + SearchFactory::_('Config')->type_search = 2; + SearchFactory::_('Config')->search_value = $searchValue; + SearchFactory::_('Config')->replace_value = $replaceValue; + SearchFactory::_('Config')->match_case = $matchCase; + SearchFactory::_('Config')->whole_word = $wholeWord; + SearchFactory::_('Config')->regex_search = $regexSearch; + + // load the value + if (($value = SearchFactory::_('Agent')->getValue($rowId, $fieldName, $line, $tableName, true)) !== null) + { + return ['value' => $value]; + } + } + catch(Exception $error) + { + return ['error' => $error->getMessage()]; + } + } + return ['error' => Text::_('COM_COMPONENTBUILDER_THERE_HAS_BEEN_AN_ERROR_PLEASE_TRY_AGAIN')]; + } + + /** + * Set selected search value in a given table and row + * + * @param mixed $value The field value + * @param int $rowId The item ID + * @param string $fieldName The field key + * @param string $tableName The table + * + * @return array + * @since 3.2.0 + **/ + public function setValue($value, int $rowId, string $fieldName, string $tableName): array + { + // check if this is a valid table and field + if ($rowId > 0 && SearchFactory::_('Table')->exist($tableName, $fieldName) && + SearchFactory::_('Agent')->setValue($value, $rowId, $fieldName, $tableName)) + { + return ['success' => Text::sprintf( + '%s (%s:%s) was successfully updated!', + $tableName, $rowId, $fieldName)]; + } + return ['error' => Text::_('COM_COMPONENTBUILDER_THERE_HAS_BEEN_AN_ERROR_PLEASE_TRY_AGAIN')]; + } + + + // Used in get_snippets + + public function getSnippets($libraries) + { + if (JsonHelper::check($libraries)) + { + $libraries = json_decode($libraries, true); + } + // check if we have an array + if (UtilitiesArrayHelper::check($libraries)) + { + // insure we only have int values + if ($libraries = $this->checkLibraries($libraries)) + { + // Get a db connection. + $db = Factory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName( array('a.id') )); + $query->from($db->quoteName('#__componentbuilder_snippet', 'a')); + $query->where($db->quoteName('a.published') . ' = 1'); + // check for country and region + $query->where($db->quoteName('a.library') . ' IN ('. implode(',',$libraries) .')'); + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + return $db->loadColumn(); + } + } + } + return false; + } + + protected function checkLibraries($libraries) + { + $bucket = array(); + $libraries = array_map( function($id) use (&$bucket) { + // now get bundled libraries + $type = GetHelper::var('library', (int) $id, 'id', 'type'); + if (2 == $type && $bundled = GetHelper::var('library', (int) $id, 'id', 'libraries')) + { + // make sure we have an array if it was json + if (JsonHelper::check($bundled)) + { + $bundled = json_decode($bundled, true); + } + // load in the values if we have an array + if (UtilitiesArrayHelper::check($bundled)) + { + foreach ($bundled as $lib) + { + $bucket[$lib] = $lib; + } + } + elseif (is_numeric($bundled)) + { + $bucket[(int) $bundled] = (int) $bundled; + } + } + else + { + return (int) $id; + } + }, $libraries); + // check if we have any bundled libraries + if (UtilitiesArrayHelper::check($bucket)) + { + foreach ($bucket as $lib) + { + $libraries[] = (int) $lib; + } + } + // check that we have libraries + if (UtilitiesArrayHelper::check($libraries)) + { + $libraries = array_values(array_unique(array_filter($libraries, function($id){return is_int($id);}))); + // check if we have any libraries remaining + if (UtilitiesArrayHelper::check($libraries)) + { + return $libraries; + } + } + return false; + } + public function getSnippetDetails($id) + { + // Get a db connection. + $db = Factory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.name', 'a.heading', 'a.usage', 'a.description', 'b.name', 'a.snippet', 'a.url', 'c.name'), array('name', 'heading', 'usage', 'description', 'type', 'snippet', 'url', 'library'))); + $query->from($db->quoteName('#__componentbuilder_snippet', 'a')); + // From the componentbuilder_snippet_type table. + $query->join('LEFT', $db->quoteName('#__componentbuilder_snippet_type', 'b') . ' ON (' . $db->quoteName('a.type') . ' = ' . $db->quoteName('b.id') . ')'); + // From the componentbuilder_library table. + $query->join('LEFT', $db->quoteName('#__componentbuilder_library', 'c') . ' ON (' . $db->quoteName('a.library') . ' = ' . $db->quoteName('c.id') . ')'); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->where($db->quoteName('a.id') . ' = '. (int) $id); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $snippet = $db->loadObject(); + $snippet->snippet = base64_decode($snippet->snippet); + // return found snippet settings + return $snippet; + } + return false; + } + + public function setSnippetGithub($path, $status) + { + // get user + $user = Factory::getUser(); + $access = $user->authorise('snippet.access', 'com_componentbuilder'); + if ($access) + { + // secure path + $path = StringHelper::safe(str_replace('.json','',$path), 'filename', '', false).'.json'; + // base path + $base_path = basename($path); + // set url + $url = ComponentbuilderHelper::$snippetPath.rawurlencode($base_path); + // get the snippets + if (($snippet = ComponentbuilderHelper::getGithubRepoData('lib_snippet_' . $base_path, $url, null, 'array')) !== false) + { + return $this->saveSnippet($snippet, $status, $user); + } + // see if we have any errors from github + if (UtilitiesArrayHelper::check(ComponentbuilderHelper::$githubRepoDataErrors)) + { + return array('message' => Text::sprintf('COM_COMPONENTBUILDER_ERROR_BR_S', implode('
    ', ComponentbuilderHelper::$githubRepoDataErrors)), 'status' => 'danger'); + } + return array('message' => Text::_('COM_COMPONENTBUILDER_ERROR_THE_PATH_HAS_A_MISMATCH_AND_COULD_THEREFORE_NOT_RETRIEVE_THE_SNIPPET_FROM_GITHUB'), 'status' => 'danger'); + } + return array('message' => Text::_('COM_COMPONENTBUILDER_ERROR_YOU_DO_NOT_HAVE_ACCESS_TO_THE_SNIPPETS'), 'status' => 'danger'); + } + + protected function saveSnippet($item, $status, $user) + { + // set some defaults + $todayDate = Factory::getDate()->toSql(); + // get the type id + $item['type'] = ($id = GetHelper::var('snippet_type', $item['type'], 'name', 'id')) ? $id : $this->createNew($item['type'], 'snippet_type', $user, $todayDate); + // get the library id + $item['library'] = ($id = GetHelper::var('library', $item['library'], 'name', 'id')) ? $id : $this->createNew($item['library'], 'library', $user, $todayDate); + // remove type if zero + if ($item['type'] == 0) + { + unset($item['type']); + } + // remove library if zero + if ($item['library'] == 0) + { + unset($item['library']); + } + // get the snippet ID + $item['id'] = $this->getSnippetId($item); + if ($item['id'] == 0) + { + $canCreate = $user->authorise('snippet.create', 'com_componentbuilder'); + if ('new' === $status && !$canCreate) + { + return array('message' => Text::_('COM_COMPONENTBUILDER_ERROR_YOU_DO_NOT_HAVE_PERMISSION_TO_CREATE_THE_SNIPPET'), 'status' => 'danger'); + } + } + // get the snippet model + $model = ComponentbuilderHelper::getModel('snippet', JPATH_COMPONENT_ADMINISTRATOR); + // save the snippet + if ($model->save($item)) + { + if ($item['id'] == 0) + { + // get the saved item + $updatedItem = $model->getItem(); + $item['id']= $updatedItem->get('id'); + } + // we have to force modified date since the model does not allow you + if ($this->forchDateFix($item)) + { + return array('message' => Text::_('COM_COMPONENTBUILDER_SUCCESS_THE_SNIPPET_WAS_SAVED'), 'status' => 'success'); + } + // return error + return array('message' => Text::_('COM_COMPONENTBUILDER_SUCCESS_THE_SNIPPET_WAS_SAVED_BUT_THE_MODIFIED_DATE_COULD_NOT_BE_ADJUSTED_BR_BR_BTHIS_MEANS_THE_SNIPPETS_WILL_CONTINUE_TO_APPEAR_OUT_OF_DATEB'), 'status' => 'warning'); + } + // return error + return array('message' => Text::_('COM_COMPONENTBUILDER_ERROR_THE_SNIPPET_IS_FAULTY_AND_COULD_NOT_BE_SAVED'), 'status' => 'danger'); + } + + protected function forchDateFix($item) + { + $object = new \stdClass(); + $object->id = (int) $item['id']; + $object->created = $item['created']; + $object->modified = $item['modified']; + // force update + return Factory::getDbo()->updateObject('#__componentbuilder_snippet', $object, 'id'); + } + + protected function getSnippetId($item) + { + // Get a db connection. + $db = Factory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id'))); + $query->from($db->quoteName('#__componentbuilder_snippet', 'a')); + $query->where($db->quoteName('a.name') . ' = ' . (string) $db->quote($item['name'])); + if (is_numeric($item['type'])) + { + $query->where($db->quoteName('a.type') . ' = ' . (int) $item['type']); + } + if (is_numeric($item['library'])) + { + $query->where($db->quoteName('a.library') . ' = ' . (int) $item['library']); + } + // Reset the query using our newly populated query object. + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + return $db->loadResult(); + } + return 0; + } + + protected function createNew($name, $type, $user, $todayDate) + { + // verify that we can continue + if (ComponentbuilderHelper::getActions($type)->get('core.create')) + { + // get the snippet model + $model = ComponentbuilderHelper::getModel($type, JPATH_COMPONENT_ADMINISTRATOR); + // build array to save + $item['id'] = 0; + $item['name'] = $name; + $item['published'] = 1; + $item['version'] = 1; + $item['created'] = $todayDate; + $item['created_by'] = $user->id; + // save the new + $model->save($item); + // get the saved item + $item = $model->getItem(); + return $item->get('id'); + } + return 0; + } +} diff --git a/admin/src/Model/Class_extendingsModel.php b/admin/src/Model/Class_extendingsModel.php new file mode 100644 index 000000000..1fd9d95af --- /dev/null +++ b/admin/src/Model/Class_extendingsModel.php @@ -0,0 +1,468 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Class_extendings List Model + * + * @since 1.6 + */ +class Class_extendingsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/class_extendings.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.extension_type','extension_type', + 'a.name','name' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $extension_type = $this->getUserStateFromRequest($this->context . '.filter.extension_type', 'filter_extension_type'); + if ($formSubmited) + { + $extension_type = $app->input->post->get('extension_type'); + $this->setState('filter.extension_type', $extension_type); + } + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('class_extends.access', 'com_componentbuilder.class_extends.' . (int) $item->id) && $user->authorise('class_extends.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // set selection value to a translatable value + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // convert extension_type + $item->extension_type = $this->selectionTranslation($item->extension_type, 'extension_type'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return string The translatable string. + */ + public function selectionTranslation($value,$name) + { + // Array of extension_type language strings + if ($name === 'extension_type') + { + $extension_typeArray = array( + 0 => 'COM_COMPONENTBUILDER_CLASS_EXTENDS_SELECT_AN_OPTION', + 'powers' => 'COM_COMPONENTBUILDER_CLASS_EXTENDS_POWERS', + 'components' => 'COM_COMPONENTBUILDER_CLASS_EXTENDS_COMPONENTS', + 'plugins' => 'COM_COMPONENTBUILDER_CLASS_EXTENDS_PLUGINS', + 'modules' => 'COM_COMPONENTBUILDER_CLASS_EXTENDS_MODULES' + ); + // Now check if value is found in this array + if (isset($extension_typeArray[$value]) && StringHelper::check($extension_typeArray[$value])) + { + return $extension_typeArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_class_extends', 'a')); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.' OR a.extension_type LIKE '.$search.' OR a.head LIKE '.$search.' OR a.comment LIKE '.$search.')'); + } + } + + // Filter by Extension_type. + $_extension_type = $this->getState('filter.extension_type'); + if (is_numeric($_extension_type)) + { + if (is_float($_extension_type)) + { + $query->where('a.extension_type = ' . (float) $_extension_type); + } + else + { + $query->where('a.extension_type = ' . (int) $_extension_type); + } + } + elseif (StringHelper::check($_extension_type)) + { + $query->where('a.extension_type = ' . $db->quote($db->escape($_extension_type))); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.extension_type'); + $id .= ':' . $this->getState('filter.name'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_class_extends')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_class_extends'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Class_extendsModel.php b/admin/src/Model/Class_extendsModel.php new file mode 100644 index 000000000..57c8b8bca --- /dev/null +++ b/admin/src/Model/Class_extendsModel.php @@ -0,0 +1,1064 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\String\ClassfunctionHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Class_extends Admin Model + * + * @since 1.6 + */ +class Class_extendsModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'name', + 'extension_type' + ), + 'right' => array( + 'comment' + ), + 'fullwidth' => array( + 'head' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/class_extends.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/class_extends.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.class_extends'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'class_extends', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('class_extends__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'class_extends__'.$id); + ComponentbuilderHelper::set('class_extends__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->head)) + { + // base64 Decode head. + $item->head = base64_decode($item->head); + } + + if (!empty($item->comment)) + { + // base64 Decode comment. + $item->comment = base64_decode($item->comment); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('class_extends__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'class_extends__'.$id); + ComponentbuilderHelper::set('class_extends__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.class_extends', 'class_extends', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('class_extends.edit.state', 'com_componentbuilder.class_extends.' . (int) $id)) + || ($id == 0 && !$user->authorise('class_extends.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('class_extends.edit.created_by', 'com_componentbuilder.class_extends.' . (int) $id)) + || ($id == 0 && !$user->authorise('class_extends.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('class_extends.edit.created', 'com_componentbuilder.class_extends.' . (int) $id)) + || ($id == 0 && !$user->authorise('class_extends.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update all editors to use this components global editor + $global_editor = ComponentHelper::getParams('com_componentbuilder')->get('editor', 'none'); + // now get all the editor fields + $editors = $form->getXml()->xpath("//field[@type='editor']"); + // check if we found any + if (UtilitiesArrayHelper::check($editors)) + { + foreach ($editors as $editor) + { + // get the field names + $name = (string) $editor['name']; + // set the field editor value (with none as fallback) + $form->setFieldAttribute($name, 'editor', $global_editor . '|none'); + } + } + + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('class_extends.delete', 'com_componentbuilder.class_extends.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('class_extends.edit.state', 'com_componentbuilder.class_extends.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('class_extends.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('class_extends.edit', 'com_componentbuilder.class_extends.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('class_extends.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_class_extends')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.class_extends.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.class_extends', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('class_extends'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('class_extends'); + } + + if (!$this->canDo->get('class_extends.create') && !$this->canDo->get('class_extends.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('class_extends.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('class_extends.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->name) && !is_numeric($this->table->name)) + { + $this->table->name = $this->generateUnique('name',$this->table->name); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('class_extends'); + } + + if (!$this->canDo->get('class_extends.edit') && !$this->canDo->get('class_extends.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('class_extends.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('class_extends.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // make sure the name is safe to be used as a class name + $data['name'] = ClassfunctionHelper::safe($data['name']); + + // Set the head string to base64 string. + if (isset($data['head'])) + { + $data['head'] = base64_encode($data['head']); + } + + // Set the comment string to base64 string. + if (isset($data['comment'])) + { + $data['comment'] = base64_encode($data['comment']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Class_methodModel.php b/admin/src/Model/Class_methodModel.php new file mode 100644 index 000000000..40a839e4f --- /dev/null +++ b/admin/src/Model/Class_methodModel.php @@ -0,0 +1,1137 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\String\ClassfunctionHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Class_method Admin Model + * + * @since 1.6 + */ +class Class_methodModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'name', + 'arguments', + 'visibility', + 'extension_type', + 'joomla_plugin_group' + ), + 'right' => array( + 'comment' + ), + 'fullwidth' => array( + 'code' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/class_method.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/class_method.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.class_method'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'class_method', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('class_method__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'class_method__'.$id); + ComponentbuilderHelper::set('class_method__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->code)) + { + // base64 Decode code. + $item->code = base64_decode($item->code); + } + + if (!empty($item->comment)) + { + // base64 Decode comment. + $item->comment = base64_decode($item->comment); + } + + if (!empty($item->arguments)) + { + // base64 Decode arguments. + $item->arguments = base64_decode($item->arguments); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('class_method__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'class_method__'.$id); + ComponentbuilderHelper::set('class_method__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.class_method', 'class_method', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('class_method.edit.state', 'com_componentbuilder.class_method.' . (int) $id)) + || ($id == 0 && !$user->authorise('class_method.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('class_method.edit.created_by', 'com_componentbuilder.class_method.' . (int) $id)) + || ($id == 0 && !$user->authorise('class_method.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('class_method.edit.created', 'com_componentbuilder.class_method.' . (int) $id)) + || ($id == 0 && !$user->authorise('class_method.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update all editors to use this components global editor + $global_editor = ComponentHelper::getParams('com_componentbuilder')->get('editor', 'none'); + // now get all the editor fields + $editors = $form->getXml()->xpath("//field[@type='editor']"); + // check if we found any + if (UtilitiesArrayHelper::check($editors)) + { + foreach ($editors as $editor) + { + // get the field names + $name = (string) $editor['name']; + // set the field editor value (with none as fallback) + $form->setFieldAttribute($name, 'editor', $global_editor . '|none'); + } + } + + + // Only load the GUID if new item (or empty) + if (0 == $id || !($val = $form->getValue('guid'))) + { + $form->setValue('guid', null, GuidHelper::get()); + } + + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('class_method.delete', 'com_componentbuilder.class_method.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('class_method.edit.state', 'com_componentbuilder.class_method.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('class_method.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('class_method.edit', 'com_componentbuilder.class_method.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('class_method.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_class_method')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.class_method.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.class_method', $data); + + return $data; + } + + /** + * Method to validate the form data. + * + * @param JForm $form The form to validate against. + * @param array $data The data to validate. + * @param string $group The name of the field group to validate. + * + * @return mixed Array of filtered data if valid, false otherwise. + * + * @see JFormRule + * @see JFilterInput + * @since 12.2 + */ + public function validate($form, $data, $group = null) + { + // check if the not_required field is set + if (isset($data['not_required']) && UtilitiesStringHelper::check($data['not_required'])) + { + $requiredFields = (array) explode(',',(string) $data['not_required']); + $requiredFields = array_unique($requiredFields); + // now change the required field attributes value + foreach ($requiredFields as $requiredField) + { + // make sure there is a string value + if (UtilitiesStringHelper::check($requiredField)) + { + // change to false + $form->setFieldAttribute($requiredField, 'required', 'false'); + // also clear the data set + $data[$requiredField] = ''; + } + } + } + return parent::validate($form, $data, $group); + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return array('guid'); + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('class_method'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('class_method'); + } + + if (!$this->canDo->get('class_method.create') && !$this->canDo->get('class_method.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('class_method.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('class_method.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->name) && !is_numeric($this->table->name)) + { + $this->table->name = $this->generateUnique('name',$this->table->name); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('class_method'); + } + + if (!$this->canDo->get('class_method.edit') && !$this->canDo->get('class_method.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('class_method.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('class_method.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // make sure the name is safe to be used as a function name + $data['name'] = ClassfunctionHelper::safe($data['name']); + + // Set the GUID if empty or not valid + if (empty($data['guid']) && $data['id'] > 0) + { + // get the existing one + $data['guid'] = (string) GetHelper::var('class_method', $data['id'], 'id', 'guid'); + } + + // Set the GUID if empty or not valid + while (!GuidHelper::valid($data['guid'], "class_method", $data['id'])) + { + // must always be set + $data['guid'] = (string) GuidHelper::get(); + } + + // Set the code string to base64 string. + if (isset($data['code'])) + { + $data['code'] = base64_encode($data['code']); + } + + // Set the comment string to base64 string. + if (isset($data['comment'])) + { + $data['comment'] = base64_encode($data['comment']); + } + + // Set the arguments string to base64 string. + if (isset($data['arguments'])) + { + $data['arguments'] = base64_encode($data['arguments']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Class_methodsModel.php b/admin/src/Model/Class_methodsModel.php new file mode 100644 index 000000000..e2ccdd31c --- /dev/null +++ b/admin/src/Model/Class_methodsModel.php @@ -0,0 +1,647 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Class_methods List Model + * + * @since 1.6 + */ +class Class_methodsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/class_methods.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.visibility','visibility', + 'a.extension_type','extension_type', + 'a.name','name' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $visibility = $this->getUserStateFromRequest($this->context . '.filter.visibility', 'filter_visibility'); + if ($formSubmited) + { + $visibility = $app->input->post->get('visibility'); + $this->setState('filter.visibility', $visibility); + } + + $extension_type = $this->getUserStateFromRequest($this->context . '.filter.extension_type', 'filter_extension_type'); + if ($formSubmited) + { + $extension_type = $app->input->post->get('extension_type'); + $this->setState('filter.extension_type', $extension_type); + } + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('class_method.access', 'com_componentbuilder.class_method.' . (int) $item->id) && $user->authorise('class_method.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // decode arguments + $item->arguments = base64_decode($item->arguments); + } + } + + // set selection value to a translatable value + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // convert visibility + $item->visibility = $this->selectionTranslation($item->visibility, 'visibility'); + // convert extension_type + $item->extension_type = $this->selectionTranslation($item->extension_type, 'extension_type'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return string The translatable string. + */ + public function selectionTranslation($value,$name) + { + // Array of visibility language strings + if ($name === 'visibility') + { + $visibilityArray = array( + 'public' => 'COM_COMPONENTBUILDER_CLASS_METHOD_PUBLIC', + 'protected' => 'COM_COMPONENTBUILDER_CLASS_METHOD_PROTECTED', + 'private' => 'COM_COMPONENTBUILDER_CLASS_METHOD_PRIVATE', + 'public static' => 'COM_COMPONENTBUILDER_CLASS_METHOD_PUBLIC_STATIC', + 'protected static' => 'COM_COMPONENTBUILDER_CLASS_METHOD_PROTECTED_STATIC', + 'private static' => 'COM_COMPONENTBUILDER_CLASS_METHOD_PRIVATE_STATIC' + ); + // Now check if value is found in this array + if (isset($visibilityArray[$value]) && StringHelper::check($visibilityArray[$value])) + { + return $visibilityArray[$value]; + } + } + // Array of extension_type language strings + if ($name === 'extension_type') + { + $extension_typeArray = array( + 0 => 'COM_COMPONENTBUILDER_CLASS_METHOD_SELECT_AN_OPTION', + 'powers' => 'COM_COMPONENTBUILDER_CLASS_METHOD_POWERS', + 'components' => 'COM_COMPONENTBUILDER_CLASS_METHOD_COMPONENTS', + 'plugins' => 'COM_COMPONENTBUILDER_CLASS_METHOD_PLUGINS', + 'modules' => 'COM_COMPONENTBUILDER_CLASS_METHOD_MODULES' + ); + // Now check if value is found in this array + if (isset($extension_typeArray[$value]) && StringHelper::check($extension_typeArray[$value])) + { + return $extension_typeArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_class_method', 'a')); + + // From the componentbuilder_joomla_plugin_group table. + $query->select($db->quoteName('g.name','joomla_plugin_group_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_plugin_group', 'g') . ' ON (' . $db->quoteName('a.joomla_plugin_group') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.' OR a.visibility LIKE '.$search.' OR a.extension_type LIKE '.$search.' OR a.comment LIKE '.$search.' OR a.arguments LIKE '.$search.')'); + } + } + + // Filter by Visibility. + $_visibility = $this->getState('filter.visibility'); + if (is_numeric($_visibility)) + { + if (is_float($_visibility)) + { + $query->where('a.visibility = ' . (float) $_visibility); + } + else + { + $query->where('a.visibility = ' . (int) $_visibility); + } + } + elseif (StringHelper::check($_visibility)) + { + $query->where('a.visibility = ' . $db->quote($db->escape($_visibility))); + } + // Filter by Extension_type. + $_extension_type = $this->getState('filter.extension_type'); + if (is_numeric($_extension_type)) + { + if (is_float($_extension_type)) + { + $query->where('a.extension_type = ' . (float) $_extension_type); + } + else + { + $query->where('a.extension_type = ' . (int) $_extension_type); + } + } + elseif (StringHelper::check($_extension_type)) + { + $query->where('a.extension_type = ' . $db->quote($db->escape($_extension_type))); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get list export data. + * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExportData($pks, $user = null) + { + // setup the query + if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks) + { + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + $_export = true; + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_class_method table + $query->from($db->quoteName('#__componentbuilder_class_method', 'a')); + // The bulk export path + if ('bulk' === $pks) + { + $query->where('a.id > 0'); + } + // A large array of ID's will not work out well + elseif ($pks_size > 500) + { + // Use lowest ID + $query->where('a.id >= ' . (int) min($pks)); + // Use highest ID + $query->where('a.id <= ' . (int) max($pks)); + } + // The normal default path + else + { + $query->where('a.id IN (' . implode(',',$pks) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.id desc'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('class_method.access', 'com_componentbuilder.class_method.' . (int) $item->id) && $user->authorise('class_method.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // decode code + $item->code = base64_decode($item->code); + // decode comment + $item->comment = base64_decode($item->comment); + // decode arguments + $item->arguments = base64_decode($item->arguments); + // unset the values we don't want exported. + unset($item->asset_id); + unset($item->checked_out); + unset($item->checked_out_time); + } + } + // Add headers to items array. + $headers = $this->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + array_unshift($items,$headers); + } + return $items; + } + } + 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 = Factory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_class_method"); + if (UtilitiesArrayHelper::check($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; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.visibility'); + $id .= ':' . $this->getState('filter.extension_type'); + $id .= ':' . $this->getState('filter.name'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_class_method')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_class_method'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Class_propertiesModel.php b/admin/src/Model/Class_propertiesModel.php new file mode 100644 index 000000000..4276be965 --- /dev/null +++ b/admin/src/Model/Class_propertiesModel.php @@ -0,0 +1,643 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Class_properties List Model + * + * @since 1.6 + */ +class Class_propertiesModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/class_properties.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.visibility','visibility', + 'a.extension_type','extension_type', + 'a.name','name' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $visibility = $this->getUserStateFromRequest($this->context . '.filter.visibility', 'filter_visibility'); + if ($formSubmited) + { + $visibility = $app->input->post->get('visibility'); + $this->setState('filter.visibility', $visibility); + } + + $extension_type = $this->getUserStateFromRequest($this->context . '.filter.extension_type', 'filter_extension_type'); + if ($formSubmited) + { + $extension_type = $app->input->post->get('extension_type'); + $this->setState('filter.extension_type', $extension_type); + } + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('class_property.access', 'com_componentbuilder.class_property.' . (int) $item->id) && $user->authorise('class_property.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // set selection value to a translatable value + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // convert visibility + $item->visibility = $this->selectionTranslation($item->visibility, 'visibility'); + // convert extension_type + $item->extension_type = $this->selectionTranslation($item->extension_type, 'extension_type'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return string The translatable string. + */ + public function selectionTranslation($value,$name) + { + // Array of visibility language strings + if ($name === 'visibility') + { + $visibilityArray = array( + 'public' => 'COM_COMPONENTBUILDER_CLASS_PROPERTY_PUBLIC', + 'protected' => 'COM_COMPONENTBUILDER_CLASS_PROPERTY_PROTECTED', + 'private' => 'COM_COMPONENTBUILDER_CLASS_PROPERTY_PRIVATE', + 'public static' => 'COM_COMPONENTBUILDER_CLASS_PROPERTY_PUBLIC_STATIC', + 'protected static' => 'COM_COMPONENTBUILDER_CLASS_PROPERTY_PROTECTED_STATIC', + 'private static' => 'COM_COMPONENTBUILDER_CLASS_PROPERTY_PRIVATE_STATIC' + ); + // Now check if value is found in this array + if (isset($visibilityArray[$value]) && StringHelper::check($visibilityArray[$value])) + { + return $visibilityArray[$value]; + } + } + // Array of extension_type language strings + if ($name === 'extension_type') + { + $extension_typeArray = array( + 0 => 'COM_COMPONENTBUILDER_CLASS_PROPERTY_SELECT_AN_OPTION', + 'powers' => 'COM_COMPONENTBUILDER_CLASS_PROPERTY_POWERS', + 'components' => 'COM_COMPONENTBUILDER_CLASS_PROPERTY_COMPONENTS', + 'plugins' => 'COM_COMPONENTBUILDER_CLASS_PROPERTY_PLUGINS', + 'modules' => 'COM_COMPONENTBUILDER_CLASS_PROPERTY_MODULES' + ); + // Now check if value is found in this array + if (isset($extension_typeArray[$value]) && StringHelper::check($extension_typeArray[$value])) + { + return $extension_typeArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_class_property', 'a')); + + // From the componentbuilder_joomla_plugin_group table. + $query->select($db->quoteName('g.name','joomla_plugin_group_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_plugin_group', 'g') . ' ON (' . $db->quoteName('a.joomla_plugin_group') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.' OR a.visibility LIKE '.$search.' OR a.extension_type LIKE '.$search.' OR a.comment LIKE '.$search.')'); + } + } + + // Filter by Visibility. + $_visibility = $this->getState('filter.visibility'); + if (is_numeric($_visibility)) + { + if (is_float($_visibility)) + { + $query->where('a.visibility = ' . (float) $_visibility); + } + else + { + $query->where('a.visibility = ' . (int) $_visibility); + } + } + elseif (StringHelper::check($_visibility)) + { + $query->where('a.visibility = ' . $db->quote($db->escape($_visibility))); + } + // Filter by Extension_type. + $_extension_type = $this->getState('filter.extension_type'); + if (is_numeric($_extension_type)) + { + if (is_float($_extension_type)) + { + $query->where('a.extension_type = ' . (float) $_extension_type); + } + else + { + $query->where('a.extension_type = ' . (int) $_extension_type); + } + } + elseif (StringHelper::check($_extension_type)) + { + $query->where('a.extension_type = ' . $db->quote($db->escape($_extension_type))); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get list export data. + * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExportData($pks, $user = null) + { + // setup the query + if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks) + { + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + $_export = true; + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_class_property table + $query->from($db->quoteName('#__componentbuilder_class_property', 'a')); + // The bulk export path + if ('bulk' === $pks) + { + $query->where('a.id > 0'); + } + // A large array of ID's will not work out well + elseif ($pks_size > 500) + { + // Use lowest ID + $query->where('a.id >= ' . (int) min($pks)); + // Use highest ID + $query->where('a.id <= ' . (int) max($pks)); + } + // The normal default path + else + { + $query->where('a.id IN (' . implode(',',$pks) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.id desc'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('class_property.access', 'com_componentbuilder.class_property.' . (int) $item->id) && $user->authorise('class_property.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // decode comment + $item->comment = base64_decode($item->comment); + // decode default + $item->default = base64_decode($item->default); + // unset the values we don't want exported. + unset($item->asset_id); + unset($item->checked_out); + unset($item->checked_out_time); + } + } + // Add headers to items array. + $headers = $this->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + array_unshift($items,$headers); + } + return $items; + } + } + 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 = Factory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_class_property"); + if (UtilitiesArrayHelper::check($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; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.visibility'); + $id .= ':' . $this->getState('filter.extension_type'); + $id .= ':' . $this->getState('filter.name'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_class_property')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_class_property'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Class_propertyModel.php b/admin/src/Model/Class_propertyModel.php new file mode 100644 index 000000000..1a6bcde83 --- /dev/null +++ b/admin/src/Model/Class_propertyModel.php @@ -0,0 +1,1122 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\String\ClassfunctionHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Class_property Admin Model + * + * @since 1.6 + */ +class Class_propertyModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'name', + 'visibility', + 'default', + 'extension_type', + 'joomla_plugin_group' + ), + 'right' => array( + 'comment' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/class_property.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/class_property.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.class_property'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'class_property', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('class_property__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'class_property__'.$id); + ComponentbuilderHelper::set('class_property__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->comment)) + { + // base64 Decode comment. + $item->comment = base64_decode($item->comment); + } + + if (!empty($item->default)) + { + // base64 Decode default. + $item->default = base64_decode($item->default); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('class_property__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'class_property__'.$id); + ComponentbuilderHelper::set('class_property__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.class_property', 'class_property', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('class_property.edit.state', 'com_componentbuilder.class_property.' . (int) $id)) + || ($id == 0 && !$user->authorise('class_property.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('class_property.edit.created_by', 'com_componentbuilder.class_property.' . (int) $id)) + || ($id == 0 && !$user->authorise('class_property.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('class_property.edit.created', 'com_componentbuilder.class_property.' . (int) $id)) + || ($id == 0 && !$user->authorise('class_property.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update all editors to use this components global editor + $global_editor = ComponentHelper::getParams('com_componentbuilder')->get('editor', 'none'); + // now get all the editor fields + $editors = $form->getXml()->xpath("//field[@type='editor']"); + // check if we found any + if (UtilitiesArrayHelper::check($editors)) + { + foreach ($editors as $editor) + { + // get the field names + $name = (string) $editor['name']; + // set the field editor value (with none as fallback) + $form->setFieldAttribute($name, 'editor', $global_editor . '|none'); + } + } + + + // Only load the GUID if new item (or empty) + if (0 == $id || !($val = $form->getValue('guid'))) + { + $form->setValue('guid', null, GuidHelper::get()); + } + + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('class_property.delete', 'com_componentbuilder.class_property.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('class_property.edit.state', 'com_componentbuilder.class_property.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('class_property.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('class_property.edit', 'com_componentbuilder.class_property.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('class_property.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_class_property')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.class_property.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.class_property', $data); + + return $data; + } + + /** + * Method to validate the form data. + * + * @param JForm $form The form to validate against. + * @param array $data The data to validate. + * @param string $group The name of the field group to validate. + * + * @return mixed Array of filtered data if valid, false otherwise. + * + * @see JFormRule + * @see JFilterInput + * @since 12.2 + */ + public function validate($form, $data, $group = null) + { + // check if the not_required field is set + if (isset($data['not_required']) && UtilitiesStringHelper::check($data['not_required'])) + { + $requiredFields = (array) explode(',',(string) $data['not_required']); + $requiredFields = array_unique($requiredFields); + // now change the required field attributes value + foreach ($requiredFields as $requiredField) + { + // make sure there is a string value + if (UtilitiesStringHelper::check($requiredField)) + { + // change to false + $form->setFieldAttribute($requiredField, 'required', 'false'); + // also clear the data set + $data[$requiredField] = ''; + } + } + } + return parent::validate($form, $data, $group); + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return array('guid'); + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('class_property'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('class_property'); + } + + if (!$this->canDo->get('class_property.create') && !$this->canDo->get('class_property.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('class_property.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('class_property.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->name) && !is_numeric($this->table->name)) + { + $this->table->name = $this->generateUnique('name',$this->table->name); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('class_property'); + } + + if (!$this->canDo->get('class_property.edit') && !$this->canDo->get('class_property.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('class_property.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('class_property.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // make sure the name is safe to be used as a function name + $data['name'] = ClassfunctionHelper::safe($data['name']); + + // Set the GUID if empty or not valid + if (empty($data['guid']) && $data['id'] > 0) + { + // get the existing one + $data['guid'] = (string) GetHelper::var('class_property', $data['id'], 'id', 'guid'); + } + + // Set the GUID if empty or not valid + while (!GuidHelper::valid($data['guid'], "class_property", $data['id'])) + { + // must always be set + $data['guid'] = (string) GuidHelper::get(); + } + + // Set the comment string to base64 string. + if (isset($data['comment'])) + { + $data['comment'] = base64_encode($data['comment']); + } + + // Set the default string to base64 string. + if (isset($data['default'])) + { + $data['default'] = base64_encode($data['default']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/CompilerModel.php b/admin/src/Model/CompilerModel.php new file mode 100644 index 000000000..235a1fa7a --- /dev/null +++ b/admin/src/Model/CompilerModel.php @@ -0,0 +1,530 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Componentbuilder\Compiler\Helper\Compiler; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\JsonHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder List Model for Compiler + * + * @since 1.6 + */ +class CompilerModel extends ListModel +{ + /** + * Represents the current user object. + * + * @var User The user object representing the current user. + * @since 3.2.0 + */ + protected User $user; + + /** + * The unique identifier of the current user. + * + * @var int|null The ID of the current user. + * @since 3.2.0 + */ + protected ?int $userId; + + /** + * Flag indicating whether the current user is a guest. + * + * @var int 1 if the user is a guest, 0 otherwise. + * @since 3.2.0 + */ + protected int $guest; + + /** + * An array of groups that the current user belongs to. + * + * @var array|null An array of user group IDs. + * @since 3.2.0 + */ + protected ?array $groups; + + /** + * An array of view access levels for the current user. + * + * @var array|null An array of access level IDs. + * @since 3.2.0 + */ + protected ?array $levels; + + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The input object, providing access to the request data. + * + * @var Input The input object. + * @since 3.2.0 + */ + protected Input $input; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/compiler.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * A custom property for UIKit components. (not used unless you load v2) + */ + protected $uikitComp; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + $this->input ??= $this->app->getInput(); + + // Set the current user for authorisation checks (for those calling this model directly) + $this->user ??= $this->getCurrentUser(); + $this->userId = $this->user->get('id'); + $this->guest = $this->user->get('guest'); + $this->groups = $this->user->get('groups'); + $this->authorisedGroups = $this->user->getAuthorisedGroups(); + $this->levels = $this->user->getAuthorisedViewLevels(); + + // will be removed + $this->initSet = true; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Make sure all records load, since no pagination allowed. + $this->setState('list.limit', 0); + // Get a db connection. + $db = $this->getDatabase(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Get from #__componentbuilder_joomla_component as a + $query->select($db->quoteName( + array('a.id','a.system_name','a.name','a.name_code','a.component_version','a.debug_linenr','a.short_description','a.image','a.companyname','a.author','a.email','a.website','a.copyright','a.modified','a.created','a.version'), + array('id','system_name','name','name_code','component_version','debug_linenr','short_description','image','companyname','author','email','website','copyright','modified','created','version'))); + $query->from($db->quoteName('#__componentbuilder_joomla_component', 'a')); + // Get where a.published is 1 + $query->where('a.published = 1'); + $query->order('a.modified DESC'); + $query->order('a.created DESC'); + + // return the query object + return $query; + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + $user = $this->user; + // check if this user has permission to access items + if (!$user->authorise('compiler.access', 'com_componentbuilder')) + { + $this->app->enqueueMessage(Text::_('Not authorised!'), 'error'); + // redirect away if not a correct to default view + $this->app->redirect('index.php?option=com_componentbuilder'); + return false; + } + // load parent items + $items = parent::getItems(); + + // Get the global params + $globalParams = ComponentHelper::getParams('com_componentbuilder', true); + + // Insure all item fields are adapted where needed. + if (UtilitiesArrayHelper::check($items)) + { + // Load the JEvent Dispatcher + PluginHelper::importPlugin('content'); + $this->_dispatcher = Factory::getApplication(); + foreach ($items as $nr => &$item) + { + // Always create a slug for sef URL's + $item->slug = ($item->id ?? '0') . (isset($item->alias) ? ':' . $item->alias : ''); + // Check if item has params, or pass whole item. + $params = (isset($item->params) && JsonHelper::check($item->params)) ? json_decode($item->params) : $item; + // Make sure the content prepare plugins fire on copyright + $_copyright = new \stdClass(); + $_copyright->text =& $item->copyright; // value must be in text + // Since all values are now in text (Joomla Limitation), we also add the field name (copyright) to context + $this->_dispatcher->triggerEvent("onContentPrepare", array('com_componentbuilder.compiler.copyright', &$_copyright, &$params, 0)); + // Checking if copyright has uikit components that must be loaded. + $this->uikitComp = ComponentbuilderHelper::getUikitComp($item->copyright,$this->uikitComp); + } + } + + // return items + return $items; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Get the uikit needed components + * + * @return mixed An array of objects on success. + * + */ + public function getUikitComp() + { + if (isset($this->uikitComp) && UtilitiesArrayHelper::check($this->uikitComp)) + { + return $this->uikitComp; + } + return false; + } + + public $compiler; + + public function builder() + { + // run compiler + $this->compiler = new Compiler(); + if($this->compiler) + { + return true; + } + return false; + } + + public function emptyFolder($dir, $removeDir = false) + { + if (\JFolder::exists($dir)) + { + $it = new \RecursiveDirectoryIterator($dir); + $it = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST); + foreach ($it as $file) + { + if ('.' === $file->getBasename() || '..' === $file->getBasename()) continue; + if ($file->isDir()) + { + \JFolder::delete($file->getPathname()); + } + else + { + if ($file->getBasename() !== 'index.html') + { + \JFile::delete($file->getPathname()); + } + } + } + if ($removeDir) + { + if (\JFolder::delete($dir)) + { + return true; + } + } + else + { + return true; + } + } + return false; + } + + public function install($p_file) + { + $this->setState('action', 'install'); + + // Set FTP credentials, if given. + //\JClientHelper::setCredentialsFromRequest('ftp'); + $app = Factory::getApplication(); + + // Load installer plugins for assistance if required: + //\JPluginHelper::importPlugin('installer'); + //$dispatcher = \JEventDispatcher::getInstance(); + + $package = null; + + // This event allows an input pre-treatment, a custom pre-packing or custom installation. + // (e.g. from a JSON description). + //$results = $dispatcher->trigger('onInstallerBeforeInstallation', array($this, &$package)); + + //if (in_array(true, $results, true)) + //{ + // return true; + //} + + //if (in_array(false, $results, true)) + //{ + // return false; + //} + + $config = Factory::getConfig(); + $tmp_dest = $config->get('tmp_path'); + + // Unpack the downloaded package file. + $package = \JInstallerHelper::unpack($tmp_dest . '/' . $p_file, true); + + // insure the install type is folder (JCB zip file is in the folder) + $installType = 'folder'; + + // This event allows a custom installation of the package or a customization of the package: + //$results = $dispatcher->trigger('onInstallerBeforeInstaller', array($this, &$package)); + + //if (in_array(true, $results, true)) + //{ + // return true; + //} + //elseif (in_array(false, $results, true)) + //{ + // return false; + //} + + // Was the package unpacked? + if (!$package || !$package['type']) + { + $app->enqueueMessage(Text::_('COM_INSTALLER_UNABLE_TO_FIND_INSTALL_PACKAGE'), 'error'); + return false; + } + + // Get an installer instance. + $installer = \JInstaller::getInstance(); + + // Install the package. + if (!$installer->install($package['dir'])) + { + // There was an error installing the package. + $msg = Text::sprintf('COM_INSTALLER_INSTALL_ERROR', Text::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type']))); + $result = false; + $msgType = 'error'; + } + else + { + // Package installed successfully. + $msg = Text::sprintf('COM_INSTALLER_INSTALL_SUCCESS', Text::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type']))); + $result = true; + $msgType = 'message'; + } + + // This event allows a custom a post-flight: + // $dispatcher->trigger('onInstallerAfterInstaller', array($this, &$package, $installer, &$result, &$msg)); + + // Set some model state values. + $app = Factory::getApplication(); + $app->enqueueMessage($msg, $msgType); + $this->setState('name', $installer->get('name')); + $this->setState('result', $result); + $app->setUserState('com_componentbuilder.message', $installer->message); + $app->setUserState('com_componentbuilder.extension_message', $installer->get('extension_message')); + $app->setUserState('com_componentbuilder.redirect_url', $installer->get('redirect_url')); + + // Cleanup the install files. + if (!is_file($package['packagefile'])) + { + $config = Factory::getConfig(); + $package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile']; + } + + \JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']); + + // Clear the cached extension data and menu cache + $this->cleanCache('_system', 0); + $this->cleanCache('_system', 1); + $this->cleanCache('com_modules', 0); + $this->cleanCache('com_modules', 1); + $this->cleanCache('com_plugins', 0); + $this->cleanCache('com_plugins', 1); + $this->cleanCache('mod_menu', 0); + $this->cleanCache('mod_menu', 1); + + return $result; + } + + /** + * Get all components in the system + * + * @return array + * @since 3.2.0 + **/ + public function getComponents(): array + { + // Get a db connection. + $db = $this->getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select only id and system name + $query->select($db->quoteName(array('id', 'system_name'),array('id', 'name'))); + $query->from($db->quoteName('#__componentbuilder_joomla_component')); + + // only the active components + $query->where($db->quoteName('published') . ' = 1'); + + // Order it by the ordering field. + $query->order('modified DESC'); + $query->order('created DESC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + // return the result + return $db->loadObjectList(); + } + + + /** + * Get all dynamic content + * + * @return bool + * @since 3.2.0 + **/ + public function getDynamicContent(&$errorMessage): bool + { + // convert error message to array + $errorMessage = []; + $searchArray = [ + // add banners (width - height) + 'banner' => [ + '728-90', + '160-600' + ], + // The build-gif by size (width - height) + 'builder-gif' => [ + '480-540' + ] + ]; + // start search, and get + foreach ($searchArray as $type => $sizes) + { + // per size + foreach ($sizes as $size) + { + // get size + if (($set_size = ComponentbuilderHelper::getDynamicContentSize($type, $size)) !== 0) + { + // we loop over all type size artwork + for ($target = 1; $target <= $set_size; $target++) + { + if (!ComponentbuilderHelper::getDynamicContent($type, $size, false, 0, $target)) + { + $errorMessage[] = Text::sprintf('COM_COMPONENTBUILDER_S_S_NUMBER_BSB_COULD_NOT_BE_DOWNLOADED_SUCCESSFULLY_TO_THIS_JOOMLA_INSTALL', $type, $size, $target); + } + } + } + } + } + // check if we had any errors + if (UtilitiesArrayHelper::check($errorMessage)) + { + // flatten the error message array + $errorMessage = implode('
    ', $errorMessage); + + return false; + } + return true; + } + +} diff --git a/admin/src/Model/Component_admin_viewsModel.php b/admin/src/Model/Component_admin_viewsModel.php new file mode 100644 index 000000000..c6f86f18a --- /dev/null +++ b/admin/src/Model/Component_admin_viewsModel.php @@ -0,0 +1,1005 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Component_admin_views Admin Model + * + * @since 1.6 + */ +class Component_admin_viewsModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'views' => array( + 'fullwidth' => array( + 'note_on_admin_views', + 'addadmin_views' + ), + 'above' => array( + 'joomla_component' + ) + ), + 'clone' => array( + 'left' => array( + 'note_how_to_clone', + 'clone_me' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/component_admin_views.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/component_admin_views.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.component_admin_views'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'component_admin_views', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->addadmin_views)) + { + // Convert the addadmin_views field to an array. + $addadmin_views = new Registry; + $addadmin_views->loadString($item->addadmin_views); + $item->addadmin_views = $addadmin_views->toArray(); + } + + // update the fields + $objectUpdate = new \stdClass(); + $objectUpdate->id = (int) $item->id; + // repeatable values to check + $arrayChecker = array( + 'addadmin_views' => 'adminview' + ); + foreach ($arrayChecker as $_value => $checker) + { + // check what type of array we have here (should be subform... but just in case) + // This could happen due to huge data sets + if (isset($item->{$_value}) && isset($item->{$_value}[$checker])) + { + $bucket = array(); + foreach($item->{$_value} as $option => $values) + { + foreach($values as $nr => $value) + { + $bucket[$_value.$nr][$option] = $value; + } + } + $item->{$_value} = $bucket; + $objectUpdate->{$_value} = json_encode($bucket); + } + } + // be sure to update the table if we found repeatable fields that are still not converted + if (count((array) $objectUpdate) > 1) + { + $this->_db->updateObject('#__componentbuilder_component_admin_views', $objectUpdate, 'id'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.component_admin_views', 'component_admin_views', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('component_admin_views.edit.state', 'com_componentbuilder.component_admin_views.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_admin_views.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('component_admin_views.edit.created_by', 'com_componentbuilder.component_admin_views.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_admin_views.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('component_admin_views.edit.created', 'com_componentbuilder.component_admin_views.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_admin_views.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update the addadmin_views (sub form) layout + $form->setFieldAttribute('addadmin_views', 'layout', ComponentbuilderHelper::getSubformLayout('component_admin_views', 'addadmin_views')); + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('component_admin_views.delete', 'com_componentbuilder.component_admin_views.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('component_admin_views.edit.state', 'com_componentbuilder.component_admin_views.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('component_admin_views.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('component_admin_views.edit', 'com_componentbuilder.component_admin_views.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('component_admin_views.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_component_admin_views')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.component_admin_views.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.component_admin_views', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('component_admin_views'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_admin_views'); + } + + if (!$this->canDo->get('component_admin_views.create') && !$this->canDo->get('component_admin_views.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('component_admin_views.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('component_admin_views.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->joomla_component) && !is_numeric($this->table->joomla_component)) + { + $this->table->joomla_component = $this->generateUnique('joomla_component',$this->table->joomla_component); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_admin_views'); + } + + if (!$this->canDo->get('component_admin_views.edit') && !$this->canDo->get('component_admin_views.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('component_admin_views.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('component_admin_views.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // check if we have a clone moment + if (isset($data['clone_me']) && $data['clone_me'] > 0) + { + // get addadmin_views data from clone_me (component_admin_views) + $data['addadmin_views'] = GetHelper::var('component_admin_views', $data['clone_me'], 'joomla_component', 'addadmin_views'); + } + + + // Set the addadmin_views items to data. + if (isset($data['addadmin_views']) && is_array($data['addadmin_views'])) + { + $addadmin_views = new Registry; + $addadmin_views->loadArray($data['addadmin_views']); + $data['addadmin_views'] = (string) $addadmin_views; + } + elseif (!isset($data['addadmin_views'])) + { + // Set the empty addadmin_views to data + $data['addadmin_views'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Component_configModel.php b/admin/src/Model/Component_configModel.php new file mode 100644 index 000000000..bdc3a87ac --- /dev/null +++ b/admin/src/Model/Component_configModel.php @@ -0,0 +1,1001 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Component_config Admin Model + * + * @since 1.6 + */ +class Component_configModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'options' => array( + 'fullwidth' => array( + 'addconfig' + ), + 'above' => array( + 'joomla_component' + ) + ), + 'clone' => array( + 'left' => array( + 'note_how_to_clone', + 'clone_me' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/component_config.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/component_config.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.component_config'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'component_config', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->addconfig)) + { + // Convert the addconfig field to an array. + $addconfig = new Registry; + $addconfig->loadString($item->addconfig); + $item->addconfig = $addconfig->toArray(); + } + + // update the fields + $objectUpdate = new \stdClass(); + $objectUpdate->id = (int) $item->id; + // repeatable values to check + $arrayChecker = array( + 'addconfig' => 'field' + ); + foreach ($arrayChecker as $_value => $checker) + { + // check what type of array we have here (should be subform... but just in case) + // This could happen due to huge data sets + if (isset($item->{$_value}) && isset($item->{$_value}[$checker])) + { + $bucket = array(); + foreach($item->{$_value} as $option => $values) + { + foreach($values as $nr => $value) + { + $bucket[$_value.$nr][$option] = $value; + } + } + $item->{$_value} = $bucket; + $objectUpdate->{$_value} = json_encode($bucket); + } + } + // be sure to update the table if we found repeatable fields that are still not converted + if (count((array) $objectUpdate) > 1) + { + $this->_db->updateObject('#__componentbuilder_component_config', $objectUpdate, 'id'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.component_config', 'component_config', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('component_config.edit.state', 'com_componentbuilder.component_config.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_config.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('component_config.edit.created_by', 'com_componentbuilder.component_config.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_config.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('component_config.edit.created', 'com_componentbuilder.component_config.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_config.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('component_config.delete', 'com_componentbuilder.component_config.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('component_config.edit.state', 'com_componentbuilder.component_config.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('component_config.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('component_config.edit', 'com_componentbuilder.component_config.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('component_config.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_component_config')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.component_config.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.component_config', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('component_config'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_config'); + } + + if (!$this->canDo->get('component_config.create') && !$this->canDo->get('component_config.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('component_config.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('component_config.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->joomla_component) && !is_numeric($this->table->joomla_component)) + { + $this->table->joomla_component = $this->generateUnique('joomla_component',$this->table->joomla_component); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_config'); + } + + if (!$this->canDo->get('component_config.edit') && !$this->canDo->get('component_config.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('component_config.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('component_config.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // check if we have a clone moment + if (isset($data['clone_me']) && $data['clone_me'] > 0) + { + // get addconfig data from clone_me (component_config) + $data['addconfig'] = GetHelper::var('component_config', $data['clone_me'], 'joomla_component', 'addconfig'); + } + + + // Set the addconfig items to data. + if (isset($data['addconfig']) && is_array($data['addconfig'])) + { + $addconfig = new Registry; + $addconfig->loadArray($data['addconfig']); + $data['addconfig'] = (string) $addconfig; + } + elseif (!isset($data['addconfig'])) + { + // Set the empty addconfig to data + $data['addconfig'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Component_custom_admin_menusModel.php b/admin/src/Model/Component_custom_admin_menusModel.php new file mode 100644 index 000000000..d800291f0 --- /dev/null +++ b/admin/src/Model/Component_custom_admin_menusModel.php @@ -0,0 +1,1004 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Component_custom_admin_menus Admin Model + * + * @since 1.6 + */ +class Component_custom_admin_menusModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'menus' => array( + 'fullwidth' => array( + 'addcustommenus' + ), + 'above' => array( + 'joomla_component' + ) + ), + 'clone' => array( + 'left' => array( + 'note_how_to_clone', + 'clone_me' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/component_custom_admin_menus.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/component_custom_admin_menus.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.component_custom_admin_menus'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'component_custom_admin_menus', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->addcustommenus)) + { + // Convert the addcustommenus field to an array. + $addcustommenus = new Registry; + $addcustommenus->loadString($item->addcustommenus); + $item->addcustommenus = $addcustommenus->toArray(); + } + + // update the fields + $objectUpdate = new \stdClass(); + $objectUpdate->id = (int) $item->id; + // repeatable values to check + $arrayChecker = array( + 'addcustommenus' => 'name' + ); + foreach ($arrayChecker as $_value => $checker) + { + // check what type of array we have here (should be subform... but just in case) + // This could happen due to huge data sets + if (isset($item->{$_value}) && isset($item->{$_value}[$checker])) + { + $bucket = array(); + foreach($item->{$_value} as $option => $values) + { + foreach($values as $nr => $value) + { + $bucket[$_value.$nr][$option] = $value; + } + } + $item->{$_value} = $bucket; + $objectUpdate->{$_value} = json_encode($bucket); + } + } + // be sure to update the table if we found repeatable fields that are still not converted + if (count((array) $objectUpdate) > 1) + { + $this->_db->updateObject('#__componentbuilder_component_custom_admin_menus', $objectUpdate, 'id'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.component_custom_admin_menus', 'component_custom_admin_menus', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('component_custom_admin_menus.edit.state', 'com_componentbuilder.component_custom_admin_menus.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_custom_admin_menus.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('component_custom_admin_menus.edit.created_by', 'com_componentbuilder.component_custom_admin_menus.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_custom_admin_menus.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('component_custom_admin_menus.edit.created', 'com_componentbuilder.component_custom_admin_menus.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_custom_admin_menus.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update the addcustommenus (sub form) layout + $form->setFieldAttribute('addcustommenus', 'layout', ComponentbuilderHelper::getSubformLayout('component_custom_admin_menus', 'addcustommenus')); + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('component_custom_admin_menus.delete', 'com_componentbuilder.component_custom_admin_menus.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('component_custom_admin_menus.edit.state', 'com_componentbuilder.component_custom_admin_menus.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('component_custom_admin_menus.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('component_custom_admin_menus.edit', 'com_componentbuilder.component_custom_admin_menus.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('component_custom_admin_menus.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_component_custom_admin_menus')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.component_custom_admin_menus.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.component_custom_admin_menus', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('component_custom_admin_menus'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_custom_admin_menus'); + } + + if (!$this->canDo->get('component_custom_admin_menus.create') && !$this->canDo->get('component_custom_admin_menus.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('component_custom_admin_menus.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('component_custom_admin_menus.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->joomla_component) && !is_numeric($this->table->joomla_component)) + { + $this->table->joomla_component = $this->generateUnique('joomla_component',$this->table->joomla_component); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_custom_admin_menus'); + } + + if (!$this->canDo->get('component_custom_admin_menus.edit') && !$this->canDo->get('component_custom_admin_menus.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('component_custom_admin_menus.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('component_custom_admin_menus.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // check if we have a clone moment + if (isset($data['clone_me']) && $data['clone_me'] > 0) + { + // get addcustommenus data from clone_me (component_custom_admin_menus) + $data['addcustommenus'] = GetHelper::var('component_custom_admin_menus', $data['clone_me'], 'joomla_component', 'addcustommenus'); + } + + + // Set the addcustommenus items to data. + if (isset($data['addcustommenus']) && is_array($data['addcustommenus'])) + { + $addcustommenus = new Registry; + $addcustommenus->loadArray($data['addcustommenus']); + $data['addcustommenus'] = (string) $addcustommenus; + } + elseif (!isset($data['addcustommenus'])) + { + // Set the empty addcustommenus to data + $data['addcustommenus'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Component_custom_admin_viewsModel.php b/admin/src/Model/Component_custom_admin_viewsModel.php new file mode 100644 index 000000000..4c41468e9 --- /dev/null +++ b/admin/src/Model/Component_custom_admin_viewsModel.php @@ -0,0 +1,1005 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Component_custom_admin_views Admin Model + * + * @since 1.6 + */ +class Component_custom_admin_viewsModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'views' => array( + 'fullwidth' => array( + 'note_on_custom_admin_views', + 'addcustom_admin_views' + ), + 'above' => array( + 'joomla_component' + ) + ), + 'clone' => array( + 'left' => array( + 'note_how_to_clone', + 'clone_me' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/component_custom_admin_views.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/component_custom_admin_views.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.component_custom_admin_views'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'component_custom_admin_views', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->addcustom_admin_views)) + { + // Convert the addcustom_admin_views field to an array. + $addcustom_admin_views = new Registry; + $addcustom_admin_views->loadString($item->addcustom_admin_views); + $item->addcustom_admin_views = $addcustom_admin_views->toArray(); + } + + // update the fields + $objectUpdate = new \stdClass(); + $objectUpdate->id = (int) $item->id; + // repeatable values to check + $arrayChecker = array( + 'addcustom_admin_views' => 'customadminview' + ); + foreach ($arrayChecker as $_value => $checker) + { + // check what type of array we have here (should be subform... but just in case) + // This could happen due to huge data sets + if (isset($item->{$_value}) && isset($item->{$_value}[$checker])) + { + $bucket = array(); + foreach($item->{$_value} as $option => $values) + { + foreach($values as $nr => $value) + { + $bucket[$_value.$nr][$option] = $value; + } + } + $item->{$_value} = $bucket; + $objectUpdate->{$_value} = json_encode($bucket); + } + } + // be sure to update the table if we found repeatable fields that are still not converted + if (count((array) $objectUpdate) > 1) + { + $this->_db->updateObject('#__componentbuilder_component_custom_admin_views', $objectUpdate, 'id'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.component_custom_admin_views', 'component_custom_admin_views', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('component_custom_admin_views.edit.state', 'com_componentbuilder.component_custom_admin_views.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_custom_admin_views.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('component_custom_admin_views.edit.created_by', 'com_componentbuilder.component_custom_admin_views.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_custom_admin_views.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('component_custom_admin_views.edit.created', 'com_componentbuilder.component_custom_admin_views.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_custom_admin_views.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update the addcustom_admin_views (sub form) layout + $form->setFieldAttribute('addcustom_admin_views', 'layout', ComponentbuilderHelper::getSubformLayout('component_custom_admin_views', 'addcustom_admin_views')); + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('component_custom_admin_views.delete', 'com_componentbuilder.component_custom_admin_views.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('component_custom_admin_views.edit.state', 'com_componentbuilder.component_custom_admin_views.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('component_custom_admin_views.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('component_custom_admin_views.edit', 'com_componentbuilder.component_custom_admin_views.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('component_custom_admin_views.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_component_custom_admin_views')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.component_custom_admin_views.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.component_custom_admin_views', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('component_custom_admin_views'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_custom_admin_views'); + } + + if (!$this->canDo->get('component_custom_admin_views.create') && !$this->canDo->get('component_custom_admin_views.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('component_custom_admin_views.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('component_custom_admin_views.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->joomla_component) && !is_numeric($this->table->joomla_component)) + { + $this->table->joomla_component = $this->generateUnique('joomla_component',$this->table->joomla_component); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_custom_admin_views'); + } + + if (!$this->canDo->get('component_custom_admin_views.edit') && !$this->canDo->get('component_custom_admin_views.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('component_custom_admin_views.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('component_custom_admin_views.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // check if we have a clone moment + if (isset($data['clone_me']) && $data['clone_me'] > 0) + { + // get addcustom_admin_views data from clone_me (component_custom_admin_views) + $data['addcustom_admin_views'] = GetHelper::var('component_custom_admin_views', $data['clone_me'], 'joomla_component', 'addcustom_admin_views'); + } + + + // Set the addcustom_admin_views items to data. + if (isset($data['addcustom_admin_views']) && is_array($data['addcustom_admin_views'])) + { + $addcustom_admin_views = new Registry; + $addcustom_admin_views->loadArray($data['addcustom_admin_views']); + $data['addcustom_admin_views'] = (string) $addcustom_admin_views; + } + elseif (!isset($data['addcustom_admin_views'])) + { + // Set the empty addcustom_admin_views to data + $data['addcustom_admin_views'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Component_dashboardModel.php b/admin/src/Model/Component_dashboardModel.php new file mode 100644 index 000000000..1176feaed --- /dev/null +++ b/admin/src/Model/Component_dashboardModel.php @@ -0,0 +1,1103 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Component_dashboard Admin Model + * + * @since 1.6 + */ +class Component_dashboardModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'dashboard' => array( + 'fullwidth' => array( + 'note_php_dashboard_note', + 'php_dashboard_methods', + 'dashboard_tab' + ), + 'above' => array( + 'joomla_component' + ) + ), + 'clone' => array( + 'left' => array( + 'note_how_to_clone', + 'clone_me' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/component_dashboard.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/component_dashboard.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.component_dashboard'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'component_dashboard', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('component_dashboard__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'component_dashboard__'.$id); + ComponentbuilderHelper::set('component_dashboard__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->php_dashboard_methods)) + { + // base64 Decode php_dashboard_methods. + $item->php_dashboard_methods = base64_decode($item->php_dashboard_methods); + } + + if (!empty($item->dashboard_tab)) + { + // Convert the dashboard_tab field to an array. + $dashboard_tab = new Registry; + $dashboard_tab->loadString($item->dashboard_tab); + $item->dashboard_tab = $dashboard_tab->toArray(); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('component_dashboard__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'component_dashboard__'.$id); + ComponentbuilderHelper::set('component_dashboard__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + // update the fields + $objectUpdate = new \stdClass(); + $objectUpdate->id = (int) $item->id; + // repeatable values to check + $arrayChecker = array( + 'dashboard_tab' => 'name' + ); + foreach ($arrayChecker as $_value => $checker) + { + // check what type of array we have here (should be subform... but just in case) + // This could happen due to huge data sets + if (isset($item->{$_value}) && isset($item->{$_value}[$checker])) + { + $bucket = array(); + foreach($item->{$_value} as $option => $values) + { + foreach($values as $nr => $value) + { + $bucket[$_value.$nr][$option] = $value; + } + } + $item->{$_value} = $bucket; + $objectUpdate->{$_value} = json_encode($bucket); + } + } + // be sure to update the table if we found repeatable fields that are still not converted + if (count((array) $objectUpdate) > 1) + { + $this->_db->updateObject('#__componentbuilder_component_dashboard', $objectUpdate, 'id'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.component_dashboard', 'component_dashboard', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('component_dashboard.edit.state', 'com_componentbuilder.component_dashboard.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_dashboard.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('component_dashboard.edit.created_by', 'com_componentbuilder.component_dashboard.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_dashboard.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('component_dashboard.edit.created', 'com_componentbuilder.component_dashboard.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_dashboard.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update the dashboard_tab (sub form) layout + $form->setFieldAttribute('dashboard_tab', 'layout', ComponentbuilderHelper::getSubformLayout('component_dashboard', 'dashboard_tab')); + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('component_dashboard.delete', 'com_componentbuilder.component_dashboard.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('component_dashboard.edit.state', 'com_componentbuilder.component_dashboard.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('component_dashboard.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('component_dashboard.edit', 'com_componentbuilder.component_dashboard.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('component_dashboard.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_component_dashboard')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.component_dashboard.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.component_dashboard', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('component_dashboard'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_dashboard'); + } + + if (!$this->canDo->get('component_dashboard.create') && !$this->canDo->get('component_dashboard.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('component_dashboard.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('component_dashboard.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->joomla_component) && !is_numeric($this->table->joomla_component)) + { + $this->table->joomla_component = $this->generateUnique('joomla_component',$this->table->joomla_component); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_dashboard'); + } + + if (!$this->canDo->get('component_dashboard.edit') && !$this->canDo->get('component_dashboard.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('component_dashboard.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('component_dashboard.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // check if we have a clone moment + if (isset($data['clone_me']) && $data['clone_me'] > 0) + { + // get the following data from clone_me (component_dashboard) + $keys = array('php_dashboard_methods','dashboard_tab','params'); + foreach ($keys as $key) + { + $data[$key] = GetHelper::var('component_dashboard', $data['clone_me'], 'joomla_component', $key); + } + } + + + // Set the dashboard_tab items to data. + if (isset($data['dashboard_tab']) && is_array($data['dashboard_tab'])) + { + $dashboard_tab = new Registry; + $dashboard_tab->loadArray($data['dashboard_tab']); + $data['dashboard_tab'] = (string) $dashboard_tab; + } + elseif (!isset($data['dashboard_tab'])) + { + // Set the empty dashboard_tab to data + $data['dashboard_tab'] = ''; + } + + // Set the php_dashboard_methods string to base64 string. + if (isset($data['php_dashboard_methods'])) + { + $data['php_dashboard_methods'] = base64_encode($data['php_dashboard_methods']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Component_files_foldersModel.php b/admin/src/Model/Component_files_foldersModel.php new file mode 100644 index 000000000..3f972b353 --- /dev/null +++ b/admin/src/Model/Component_files_foldersModel.php @@ -0,0 +1,1081 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Component_files_folders Admin Model + * + * @since 1.6 + */ +class Component_files_foldersModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'basic' => array( + 'fullwidth' => array( + 'note_add_files', + 'addfiles', + 'note_add_folders', + 'addfolders' + ), + 'above' => array( + 'joomla_component' + ) + ), + 'clone' => array( + 'left' => array( + 'note_how_to_clone', + 'clone_me' + ) + ), + 'advance' => array( + 'fullwidth' => array( + 'note_add_files_fullpath', + 'addfilesfullpath', + 'note_add_folders_fullpath', + 'addfoldersfullpath', + 'note_constant_paths' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/component_files_folders.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/component_files_folders.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.component_files_folders'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'component_files_folders', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->addfoldersfullpath)) + { + // Convert the addfoldersfullpath field to an array. + $addfoldersfullpath = new Registry; + $addfoldersfullpath->loadString($item->addfoldersfullpath); + $item->addfoldersfullpath = $addfoldersfullpath->toArray(); + } + + if (!empty($item->addfilesfullpath)) + { + // Convert the addfilesfullpath field to an array. + $addfilesfullpath = new Registry; + $addfilesfullpath->loadString($item->addfilesfullpath); + $item->addfilesfullpath = $addfilesfullpath->toArray(); + } + + if (!empty($item->addfolders)) + { + // Convert the addfolders field to an array. + $addfolders = new Registry; + $addfolders->loadString($item->addfolders); + $item->addfolders = $addfolders->toArray(); + } + + if (!empty($item->addfiles)) + { + // Convert the addfiles field to an array. + $addfiles = new Registry; + $addfiles->loadString($item->addfiles); + $item->addfiles = $addfiles->toArray(); + } + + // update the fields + $objectUpdate = new \stdClass(); + $objectUpdate->id = (int) $item->id; + // repeatable values to check + $arrayChecker = array( + 'addfiles' => 'file', + 'addfolders' => 'folder' + ); + foreach ($arrayChecker as $_value => $checker) + { + // check what type of array we have here (should be subform... but just in case) + // This could happen due to huge data sets + if (isset($item->{$_value}) && isset($item->{$_value}[$checker])) + { + $bucket = array(); + foreach($item->{$_value} as $option => $values) + { + foreach($values as $nr => $value) + { + $bucket[$_value.$nr][$option] = $value; + } + } + $item->{$_value} = $bucket; + $objectUpdate->{$_value} = json_encode($bucket); + } + } + // be sure to update the table if we found repeatable fields that are still not converted + if (count((array) $objectUpdate) > 1) + { + $this->_db->updateObject('#__componentbuilder_component_files_folders', $objectUpdate, 'id'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.component_files_folders', 'component_files_folders', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('component_files_folders.edit.state', 'com_componentbuilder.component_files_folders.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_files_folders.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('component_files_folders.edit.created_by', 'com_componentbuilder.component_files_folders.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_files_folders.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('component_files_folders.edit.created', 'com_componentbuilder.component_files_folders.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_files_folders.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('component_files_folders.delete', 'com_componentbuilder.component_files_folders.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('component_files_folders.edit.state', 'com_componentbuilder.component_files_folders.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('component_files_folders.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('component_files_folders.edit', 'com_componentbuilder.component_files_folders.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('component_files_folders.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_component_files_folders')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.component_files_folders.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.component_files_folders', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('component_files_folders'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_files_folders'); + } + + if (!$this->canDo->get('component_files_folders.create') && !$this->canDo->get('component_files_folders.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('component_files_folders.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('component_files_folders.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->joomla_component) && !is_numeric($this->table->joomla_component)) + { + $this->table->joomla_component = $this->generateUnique('joomla_component',$this->table->joomla_component); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_files_folders'); + } + + if (!$this->canDo->get('component_files_folders.edit') && !$this->canDo->get('component_files_folders.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('component_files_folders.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('component_files_folders.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // check if we have a clone moment + if (isset($data['clone_me']) && $data['clone_me'] > 0) + { + // get the following data from clone_me (component_files_folders) + $keys = array('addfiles','addfolders','addfilesfullpath','addfoldersfullpath'); + foreach ($keys as $key) + { + $data[$key] = GetHelper::var('component_files_folders', $data['clone_me'], 'joomla_component', $key); + } + } + + + // Set the addfoldersfullpath items to data. + if (isset($data['addfoldersfullpath']) && is_array($data['addfoldersfullpath'])) + { + $addfoldersfullpath = new Registry; + $addfoldersfullpath->loadArray($data['addfoldersfullpath']); + $data['addfoldersfullpath'] = (string) $addfoldersfullpath; + } + elseif (!isset($data['addfoldersfullpath'])) + { + // Set the empty addfoldersfullpath to data + $data['addfoldersfullpath'] = ''; + } + + // Set the addfilesfullpath items to data. + if (isset($data['addfilesfullpath']) && is_array($data['addfilesfullpath'])) + { + $addfilesfullpath = new Registry; + $addfilesfullpath->loadArray($data['addfilesfullpath']); + $data['addfilesfullpath'] = (string) $addfilesfullpath; + } + elseif (!isset($data['addfilesfullpath'])) + { + // Set the empty addfilesfullpath to data + $data['addfilesfullpath'] = ''; + } + + // Set the addfolders items to data. + if (isset($data['addfolders']) && is_array($data['addfolders'])) + { + $addfolders = new Registry; + $addfolders->loadArray($data['addfolders']); + $data['addfolders'] = (string) $addfolders; + } + elseif (!isset($data['addfolders'])) + { + // Set the empty addfolders to data + $data['addfolders'] = ''; + } + + // Set the addfiles items to data. + if (isset($data['addfiles']) && is_array($data['addfiles'])) + { + $addfiles = new Registry; + $addfiles->loadArray($data['addfiles']); + $data['addfiles'] = (string) $addfiles; + } + elseif (!isset($data['addfiles'])) + { + // Set the empty addfiles to data + $data['addfiles'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Component_modulesModel.php b/admin/src/Model/Component_modulesModel.php new file mode 100644 index 000000000..55be561c4 --- /dev/null +++ b/admin/src/Model/Component_modulesModel.php @@ -0,0 +1,971 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Component_modules Admin Model + * + * @since 1.6 + */ +class Component_modulesModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'modules' => array( + 'fullwidth' => array( + 'note_on_joomla_modules', + 'addjoomla_modules' + ), + 'above' => array( + 'joomla_component' + ) + ), + 'clone' => array( + 'left' => array( + 'note_how_to_clone', + 'clone_me' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/component_modules.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/component_modules.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.component_modules'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'component_modules', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->addjoomla_modules)) + { + // Convert the addjoomla_modules field to an array. + $addjoomla_modules = new Registry; + $addjoomla_modules->loadString($item->addjoomla_modules); + $item->addjoomla_modules = $addjoomla_modules->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.component_modules', 'component_modules', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('component_modules.edit.state', 'com_componentbuilder.component_modules.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_modules.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('component_modules.edit.created_by', 'com_componentbuilder.component_modules.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_modules.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('component_modules.edit.created', 'com_componentbuilder.component_modules.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_modules.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('component_modules.delete', 'com_componentbuilder.component_modules.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('component_modules.edit.state', 'com_componentbuilder.component_modules.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('component_modules.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('component_modules.edit', 'com_componentbuilder.component_modules.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('component_modules.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_component_modules')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.component_modules.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.component_modules', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('component_modules'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_modules'); + } + + if (!$this->canDo->get('component_modules.create') && !$this->canDo->get('component_modules.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('component_modules.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('component_modules.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->joomla_component) && !is_numeric($this->table->joomla_component)) + { + $this->table->joomla_component = $this->generateUnique('joomla_component',$this->table->joomla_component); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_modules'); + } + + if (!$this->canDo->get('component_modules.edit') && !$this->canDo->get('component_modules.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('component_modules.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('component_modules.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // check if we have a clone moment + if (isset($data['clone_me']) && $data['clone_me'] > 0) + { + // get addjoomla_modules data from clone_me (component_modules) + $data['addjoomla_modules'] = GetHelper::var('component_modules', $data['clone_me'], 'joomla_component', 'addjoomla_modules'); + } + + + // Set the addjoomla_modules items to data. + if (isset($data['addjoomla_modules']) && is_array($data['addjoomla_modules'])) + { + $addjoomla_modules = new Registry; + $addjoomla_modules->loadArray($data['addjoomla_modules']); + $data['addjoomla_modules'] = (string) $addjoomla_modules; + } + elseif (!isset($data['addjoomla_modules'])) + { + // Set the empty addjoomla_modules to data + $data['addjoomla_modules'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Component_mysql_tweaksModel.php b/admin/src/Model/Component_mysql_tweaksModel.php new file mode 100644 index 000000000..be3370a7a --- /dev/null +++ b/admin/src/Model/Component_mysql_tweaksModel.php @@ -0,0 +1,1001 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Component_mysql_tweaks Admin Model + * + * @since 1.6 + */ +class Component_mysql_tweaksModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'mysql_tweaks' => array( + 'fullwidth' => array( + 'sql_tweak' + ), + 'above' => array( + 'joomla_component' + ) + ), + 'clone' => array( + 'left' => array( + 'note_how_to_clone', + 'clone_me' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/component_mysql_tweaks.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/component_mysql_tweaks.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.component_mysql_tweaks'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'component_mysql_tweaks', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->sql_tweak)) + { + // Convert the sql_tweak field to an array. + $sql_tweak = new Registry; + $sql_tweak->loadString($item->sql_tweak); + $item->sql_tweak = $sql_tweak->toArray(); + } + + // update the fields + $objectUpdate = new \stdClass(); + $objectUpdate->id = (int) $item->id; + // repeatable values to check + $arrayChecker = array( + 'sql_tweak' => 'adminview' + ); + foreach ($arrayChecker as $_value => $checker) + { + // check what type of array we have here (should be subform... but just in case) + // This could happen due to huge data sets + if (isset($item->{$_value}) && isset($item->{$_value}[$checker])) + { + $bucket = array(); + foreach($item->{$_value} as $option => $values) + { + foreach($values as $nr => $value) + { + $bucket[$_value.$nr][$option] = $value; + } + } + $item->{$_value} = $bucket; + $objectUpdate->{$_value} = json_encode($bucket); + } + } + // be sure to update the table if we found repeatable fields that are still not converted + if (count((array) $objectUpdate) > 1) + { + $this->_db->updateObject('#__componentbuilder_component_mysql_tweaks', $objectUpdate, 'id'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.component_mysql_tweaks', 'component_mysql_tweaks', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('component_mysql_tweaks.edit.state', 'com_componentbuilder.component_mysql_tweaks.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_mysql_tweaks.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('component_mysql_tweaks.edit.created_by', 'com_componentbuilder.component_mysql_tweaks.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_mysql_tweaks.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('component_mysql_tweaks.edit.created', 'com_componentbuilder.component_mysql_tweaks.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_mysql_tweaks.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('component_mysql_tweaks.delete', 'com_componentbuilder.component_mysql_tweaks.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('component_mysql_tweaks.edit.state', 'com_componentbuilder.component_mysql_tweaks.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('component_mysql_tweaks.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('component_mysql_tweaks.edit', 'com_componentbuilder.component_mysql_tweaks.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('component_mysql_tweaks.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_component_mysql_tweaks')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.component_mysql_tweaks.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.component_mysql_tweaks', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('component_mysql_tweaks'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_mysql_tweaks'); + } + + if (!$this->canDo->get('component_mysql_tweaks.create') && !$this->canDo->get('component_mysql_tweaks.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('component_mysql_tweaks.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('component_mysql_tweaks.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->joomla_component) && !is_numeric($this->table->joomla_component)) + { + $this->table->joomla_component = $this->generateUnique('joomla_component',$this->table->joomla_component); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_mysql_tweaks'); + } + + if (!$this->canDo->get('component_mysql_tweaks.edit') && !$this->canDo->get('component_mysql_tweaks.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('component_mysql_tweaks.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('component_mysql_tweaks.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // check if we have a clone moment + if (isset($data['clone_me']) && $data['clone_me'] > 0) + { + // get sql_tweak data from clone_me (component_mysql_tweaks) + $data['sql_tweak'] = GetHelper::var('component_mysql_tweaks', $data['clone_me'], 'joomla_component', 'sql_tweak'); + } + + + // Set the sql_tweak items to data. + if (isset($data['sql_tweak']) && is_array($data['sql_tweak'])) + { + $sql_tweak = new Registry; + $sql_tweak->loadArray($data['sql_tweak']); + $data['sql_tweak'] = (string) $sql_tweak; + } + elseif (!isset($data['sql_tweak'])) + { + // Set the empty sql_tweak to data + $data['sql_tweak'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Component_placeholdersModel.php b/admin/src/Model/Component_placeholdersModel.php new file mode 100644 index 000000000..f419c6bdf --- /dev/null +++ b/admin/src/Model/Component_placeholdersModel.php @@ -0,0 +1,970 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Component_placeholders Admin Model + * + * @since 1.6 + */ +class Component_placeholdersModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'details' => array( + 'fullwidth' => array( + 'addplaceholders' + ), + 'above' => array( + 'joomla_component' + ) + ), + 'clone' => array( + 'left' => array( + 'note_how_to_clone', + 'clone_me' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/component_placeholders.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/component_placeholders.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.component_placeholders'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'component_placeholders', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->addplaceholders)) + { + // Convert the addplaceholders field to an array. + $addplaceholders = new Registry; + $addplaceholders->loadString($item->addplaceholders); + $item->addplaceholders = $addplaceholders->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.component_placeholders', 'component_placeholders', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('component_placeholders.edit.state', 'com_componentbuilder.component_placeholders.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_placeholders.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('component_placeholders.edit.created_by', 'com_componentbuilder.component_placeholders.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_placeholders.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('component_placeholders.edit.created', 'com_componentbuilder.component_placeholders.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_placeholders.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('component_placeholders.delete', 'com_componentbuilder.component_placeholders.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('component_placeholders.edit.state', 'com_componentbuilder.component_placeholders.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('component_placeholders.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('component_placeholders.edit', 'com_componentbuilder.component_placeholders.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('component_placeholders.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_component_placeholders')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.component_placeholders.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.component_placeholders', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('component_placeholders'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_placeholders'); + } + + if (!$this->canDo->get('component_placeholders.create') && !$this->canDo->get('component_placeholders.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('component_placeholders.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('component_placeholders.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->joomla_component) && !is_numeric($this->table->joomla_component)) + { + $this->table->joomla_component = $this->generateUnique('joomla_component',$this->table->joomla_component); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_placeholders'); + } + + if (!$this->canDo->get('component_placeholders.edit') && !$this->canDo->get('component_placeholders.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('component_placeholders.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('component_placeholders.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // check if we have a clone moment + if (isset($data['clone_me']) && $data['clone_me'] > 0) + { + // get addplaceholders data from clone_me (component_placeholders) + $data['addplaceholders'] = GetHelper::var('component_placeholders', $data['clone_me'], 'joomla_component', 'addplaceholders'); + } + + + // Set the addplaceholders items to data. + if (isset($data['addplaceholders']) && is_array($data['addplaceholders'])) + { + $addplaceholders = new Registry; + $addplaceholders->loadArray($data['addplaceholders']); + $data['addplaceholders'] = (string) $addplaceholders; + } + elseif (!isset($data['addplaceholders'])) + { + // Set the empty addplaceholders to data + $data['addplaceholders'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Component_pluginsModel.php b/admin/src/Model/Component_pluginsModel.php new file mode 100644 index 000000000..12d712da2 --- /dev/null +++ b/admin/src/Model/Component_pluginsModel.php @@ -0,0 +1,971 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Component_plugins Admin Model + * + * @since 1.6 + */ +class Component_pluginsModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'plugins' => array( + 'fullwidth' => array( + 'note_on_joomla_plugins', + 'addjoomla_plugins' + ), + 'above' => array( + 'joomla_component' + ) + ), + 'clone' => array( + 'left' => array( + 'note_how_to_clone', + 'clone_me' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/component_plugins.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/component_plugins.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.component_plugins'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'component_plugins', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->addjoomla_plugins)) + { + // Convert the addjoomla_plugins field to an array. + $addjoomla_plugins = new Registry; + $addjoomla_plugins->loadString($item->addjoomla_plugins); + $item->addjoomla_plugins = $addjoomla_plugins->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.component_plugins', 'component_plugins', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('component_plugins.edit.state', 'com_componentbuilder.component_plugins.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_plugins.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('component_plugins.edit.created_by', 'com_componentbuilder.component_plugins.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_plugins.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('component_plugins.edit.created', 'com_componentbuilder.component_plugins.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_plugins.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('component_plugins.delete', 'com_componentbuilder.component_plugins.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('component_plugins.edit.state', 'com_componentbuilder.component_plugins.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('component_plugins.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('component_plugins.edit', 'com_componentbuilder.component_plugins.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('component_plugins.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_component_plugins')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.component_plugins.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.component_plugins', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('component_plugins'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_plugins'); + } + + if (!$this->canDo->get('component_plugins.create') && !$this->canDo->get('component_plugins.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('component_plugins.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('component_plugins.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->joomla_component) && !is_numeric($this->table->joomla_component)) + { + $this->table->joomla_component = $this->generateUnique('joomla_component',$this->table->joomla_component); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_plugins'); + } + + if (!$this->canDo->get('component_plugins.edit') && !$this->canDo->get('component_plugins.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('component_plugins.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('component_plugins.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // check if we have a clone moment + if (isset($data['clone_me']) && $data['clone_me'] > 0) + { + // get addjoomla_plugins data from clone_me (component_plugins) + $data['addjoomla_plugins'] = GetHelper::var('component_plugins', $data['clone_me'], 'joomla_component', 'addjoomla_plugins'); + } + + + // Set the addjoomla_plugins items to data. + if (isset($data['addjoomla_plugins']) && is_array($data['addjoomla_plugins'])) + { + $addjoomla_plugins = new Registry; + $addjoomla_plugins->loadArray($data['addjoomla_plugins']); + $data['addjoomla_plugins'] = (string) $addjoomla_plugins; + } + elseif (!isset($data['addjoomla_plugins'])) + { + // Set the empty addjoomla_plugins to data + $data['addjoomla_plugins'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Component_routerModel.php b/admin/src/Model/Component_routerModel.php new file mode 100644 index 000000000..1f6b78edc --- /dev/null +++ b/admin/src/Model/Component_routerModel.php @@ -0,0 +1,1102 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Component_router Admin Model + * + * @since 1.6 + */ +class Component_routerModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'settings' => array( + 'fullwidth' => array( + 'router_settings_details_switch', + 'note_router_settings', + 'note_router_settings_advance', + 'mode_constructor_before_parent', + 'note_mode_constructor_before_parent_manual', + 'constructor_before_parent_code', + 'constructor_before_parent_manual', + 'mode_constructor_after_parent', + 'constructor_after_parent_code', + 'mode_methods', + 'methods_code' + ), + 'above' => array( + 'joomla_component' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/component_router.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/component_router.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.component_router'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'component_router', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('component_router__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'component_router__'.$id); + ComponentbuilderHelper::set('component_router__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->methods_code)) + { + // base64 Decode methods_code. + $item->methods_code = base64_decode($item->methods_code); + } + + if (!empty($item->constructor_after_parent_code)) + { + // base64 Decode constructor_after_parent_code. + $item->constructor_after_parent_code = base64_decode($item->constructor_after_parent_code); + } + + if (!empty($item->constructor_before_parent_code)) + { + // base64 Decode constructor_before_parent_code. + $item->constructor_before_parent_code = base64_decode($item->constructor_before_parent_code); + } + + if (!empty($item->constructor_before_parent_manual)) + { + // Convert the constructor_before_parent_manual field to an array. + $constructor_before_parent_manual = new Registry; + $constructor_before_parent_manual->loadString($item->constructor_before_parent_manual); + $item->constructor_before_parent_manual = $constructor_before_parent_manual->toArray(); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('component_router__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'component_router__'.$id); + ComponentbuilderHelper::set('component_router__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.component_router', 'component_router', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('component_router.edit.state', 'com_componentbuilder.component_router.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_router.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('component_router.edit.created_by', 'com_componentbuilder.component_router.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_router.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('component_router.edit.created', 'com_componentbuilder.component_router.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_router.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update all editors to use this components global editor + $global_editor = ComponentHelper::getParams('com_componentbuilder')->get('editor', 'none'); + // now get all the editor fields + $editors = $form->getXml()->xpath("//field[@type='editor']"); + // check if we found any + if (UtilitiesArrayHelper::check($editors)) + { + foreach ($editors as $editor) + { + // get the field names + $name = (string) $editor['name']; + // set the field editor value (with none as fallback) + $form->setFieldAttribute($name, 'editor', $global_editor . '|none'); + } + } + + + // update the constructor_before_parent_manual (sub form) layout + $form->setFieldAttribute('constructor_before_parent_manual', 'layout', ComponentbuilderHelper::getSubformLayout('component_router', 'constructor_before_parent_manual')); + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('component_router.delete', 'com_componentbuilder.component_router.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('component_router.edit.state', 'com_componentbuilder.component_router.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('component_router.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('component_router.edit', 'com_componentbuilder.component_router.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('component_router.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_component_router')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.component_router.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.component_router', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('component_router'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_router'); + } + + if (!$this->canDo->get('component_router.create') && !$this->canDo->get('component_router.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('component_router.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('component_router.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->joomla_component) && !is_numeric($this->table->joomla_component)) + { + $this->table->joomla_component = $this->generateUnique('joomla_component',$this->table->joomla_component); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_router'); + } + + if (!$this->canDo->get('component_router.edit') && !$this->canDo->get('component_router.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('component_router.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('component_router.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the constructor_before_parent_manual items to data. + if (isset($data['constructor_before_parent_manual']) && is_array($data['constructor_before_parent_manual'])) + { + $constructor_before_parent_manual = new Registry; + $constructor_before_parent_manual->loadArray($data['constructor_before_parent_manual']); + $data['constructor_before_parent_manual'] = (string) $constructor_before_parent_manual; + } + elseif (!isset($data['constructor_before_parent_manual'])) + { + // Set the empty constructor_before_parent_manual to data + $data['constructor_before_parent_manual'] = ''; + } + + // Set the methods_code string to base64 string. + if (isset($data['methods_code'])) + { + $data['methods_code'] = base64_encode($data['methods_code']); + } + + // Set the constructor_after_parent_code string to base64 string. + if (isset($data['constructor_after_parent_code'])) + { + $data['constructor_after_parent_code'] = base64_encode($data['constructor_after_parent_code']); + } + + // Set the constructor_before_parent_code string to base64 string. + if (isset($data['constructor_before_parent_code'])) + { + $data['constructor_before_parent_code'] = base64_encode($data['constructor_before_parent_code']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Component_site_viewsModel.php b/admin/src/Model/Component_site_viewsModel.php new file mode 100644 index 000000000..c646f0ce9 --- /dev/null +++ b/admin/src/Model/Component_site_viewsModel.php @@ -0,0 +1,1005 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Component_site_views Admin Model + * + * @since 1.6 + */ +class Component_site_viewsModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'views' => array( + 'fullwidth' => array( + 'note_on_site_views', + 'addsite_views' + ), + 'above' => array( + 'joomla_component' + ) + ), + 'clone' => array( + 'left' => array( + 'note_how_to_clone', + 'clone_me' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/component_site_views.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/component_site_views.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.component_site_views'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'component_site_views', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->addsite_views)) + { + // Convert the addsite_views field to an array. + $addsite_views = new Registry; + $addsite_views->loadString($item->addsite_views); + $item->addsite_views = $addsite_views->toArray(); + } + + // update the fields + $objectUpdate = new \stdClass(); + $objectUpdate->id = (int) $item->id; + // repeatable values to check + $arrayChecker = array( + 'addsite_views' => 'siteview' + ); + foreach ($arrayChecker as $_value => $checker) + { + // check what type of array we have here (should be subform... but just in case) + // This could happen due to huge data sets + if (isset($item->{$_value}) && isset($item->{$_value}[$checker])) + { + $bucket = array(); + foreach($item->{$_value} as $option => $values) + { + foreach($values as $nr => $value) + { + $bucket[$_value.$nr][$option] = $value; + } + } + $item->{$_value} = $bucket; + $objectUpdate->{$_value} = json_encode($bucket); + } + } + // be sure to update the table if we found repeatable fields that are still not converted + if (count((array) $objectUpdate) > 1) + { + $this->_db->updateObject('#__componentbuilder_component_site_views', $objectUpdate, 'id'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.component_site_views', 'component_site_views', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('component_site_views.edit.state', 'com_componentbuilder.component_site_views.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_site_views.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('component_site_views.edit.created_by', 'com_componentbuilder.component_site_views.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_site_views.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('component_site_views.edit.created', 'com_componentbuilder.component_site_views.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_site_views.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update the addsite_views (sub form) layout + $form->setFieldAttribute('addsite_views', 'layout', ComponentbuilderHelper::getSubformLayout('component_site_views', 'addsite_views')); + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('component_site_views.delete', 'com_componentbuilder.component_site_views.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('component_site_views.edit.state', 'com_componentbuilder.component_site_views.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('component_site_views.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('component_site_views.edit', 'com_componentbuilder.component_site_views.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('component_site_views.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_component_site_views')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.component_site_views.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.component_site_views', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('component_site_views'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_site_views'); + } + + if (!$this->canDo->get('component_site_views.create') && !$this->canDo->get('component_site_views.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('component_site_views.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('component_site_views.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->joomla_component) && !is_numeric($this->table->joomla_component)) + { + $this->table->joomla_component = $this->generateUnique('joomla_component',$this->table->joomla_component); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_site_views'); + } + + if (!$this->canDo->get('component_site_views.edit') && !$this->canDo->get('component_site_views.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('component_site_views.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('component_site_views.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // check if we have a clone moment + if (isset($data['clone_me']) && $data['clone_me'] > 0) + { + // get addsite_views data from clone_me (component_site_views) + $data['addsite_views'] = GetHelper::var('component_site_views', $data['clone_me'], 'joomla_component', 'addsite_views'); + } + + + // Set the addsite_views items to data. + if (isset($data['addsite_views']) && is_array($data['addsite_views'])) + { + $addsite_views = new Registry; + $addsite_views->loadArray($data['addsite_views']); + $data['addsite_views'] = (string) $addsite_views; + } + elseif (!isset($data['addsite_views'])) + { + // Set the empty addsite_views to data + $data['addsite_views'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Component_updatesModel.php b/admin/src/Model/Component_updatesModel.php new file mode 100644 index 000000000..1dd84dee9 --- /dev/null +++ b/admin/src/Model/Component_updatesModel.php @@ -0,0 +1,1004 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Component_updates Admin Model + * + * @since 1.6 + */ +class Component_updatesModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'updates' => array( + 'fullwidth' => array( + 'version_update' + ), + 'above' => array( + 'joomla_component' + ) + ), + 'clone' => array( + 'left' => array( + 'note_how_to_clone', + 'clone_me' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/component_updates.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/component_updates.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.component_updates'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'component_updates', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->version_update)) + { + // Convert the version_update field to an array. + $version_update = new Registry; + $version_update->loadString($item->version_update); + $item->version_update = $version_update->toArray(); + } + + // update the fields + $objectUpdate = new \stdClass(); + $objectUpdate->id = (int) $item->id; + // repeatable values to check + $arrayChecker = array( + 'version_update' => 'version' + ); + foreach ($arrayChecker as $_value => $checker) + { + // check what type of array we have here (should be subform... but just in case) + // This could happen due to huge data sets + if (isset($item->{$_value}) && isset($item->{$_value}[$checker])) + { + $bucket = array(); + foreach($item->{$_value} as $option => $values) + { + foreach($values as $nr => $value) + { + $bucket[$_value.$nr][$option] = $value; + } + } + $item->{$_value} = $bucket; + $objectUpdate->{$_value} = json_encode($bucket); + } + } + // be sure to update the table if we found repeatable fields that are still not converted + if (count((array) $objectUpdate) > 1) + { + $this->_db->updateObject('#__componentbuilder_component_updates', $objectUpdate, 'id'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.component_updates', 'component_updates', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('component_updates.edit.state', 'com_componentbuilder.component_updates.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_updates.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('component_updates.edit.created_by', 'com_componentbuilder.component_updates.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_updates.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('component_updates.edit.created', 'com_componentbuilder.component_updates.' . (int) $id)) + || ($id == 0 && !$user->authorise('component_updates.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update the version_update (sub form) layout + $form->setFieldAttribute('version_update', 'layout', ComponentbuilderHelper::getSubformLayout('component_updates', 'version_update')); + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('component_updates.delete', 'com_componentbuilder.component_updates.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('component_updates.edit.state', 'com_componentbuilder.component_updates.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('component_updates.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('component_updates.edit', 'com_componentbuilder.component_updates.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('component_updates.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_component_updates')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.component_updates.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.component_updates', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('component_updates'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_updates'); + } + + if (!$this->canDo->get('component_updates.create') && !$this->canDo->get('component_updates.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('component_updates.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('component_updates.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->joomla_component) && !is_numeric($this->table->joomla_component)) + { + $this->table->joomla_component = $this->generateUnique('joomla_component',$this->table->joomla_component); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('component_updates'); + } + + if (!$this->canDo->get('component_updates.edit') && !$this->canDo->get('component_updates.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('component_updates.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('component_updates.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // check if we have a clone moment + if (isset($data['clone_me']) && $data['clone_me'] > 0) + { + // get version_update data from clone_me (component_updates) + $data['version_update'] = GetHelper::var('component_updates', $data['clone_me'], 'joomla_component', 'version_update'); + } + + + // Set the version_update items to data. + if (isset($data['version_update']) && is_array($data['version_update'])) + { + $version_update = new Registry; + $version_update->loadArray($data['version_update']); + $data['version_update'] = (string) $version_update; + } + elseif (!isset($data['version_update'])) + { + // Set the empty version_update to data + $data['version_update'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/ComponentbuilderModel.php b/admin/src/Model/ComponentbuilderModel.php new file mode 100644 index 000000000..a3c76ddbd --- /dev/null +++ b/admin/src/Model/ComponentbuilderModel.php @@ -0,0 +1,602 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder List Model + * + * @since 1.6 + */ +class ComponentbuilderModel extends ListModel +{ + public function getIcons() + { + // load user for access menus + $user = Factory::getApplication()->getIdentity(); + // reset icon array + $icons = []; + // view groups array + $viewGroups = array( + 'main' => array('png.compiler', 'png.joomla_components', 'png.joomla_modules', 'png.joomla_plugins', 'png.powers', 'png.search', 'png||importjcbpackages||index.php?option=com_componentbuilder&view=joomla_components&task=joomla_components.smartImport', 'png.admin_views', 'png.custom_admin_views', 'png.site_views', 'png.template.add', 'png.templates', 'png.layouts', 'png.dynamic_get.add', 'png.dynamic_gets', 'png.custom_codes', 'png.placeholders', 'png.libraries', 'png.snippets', 'png.get_snippets', 'png.validation_rules', 'png.field.add', 'png.fields', 'png.fields.catid_qpo0O0oqp_com_componentbuilder_po0O0oq_field', 'png.fieldtypes', 'png.fieldtypes.catid_qpo0O0oqp_com_componentbuilder_po0O0oq_fieldtype', 'png.language_translations', 'png.servers', 'png.help_documents') + ); + // view access array + $viewAccess = [ + 'compiler.submenu' => 'compiler.submenu', + 'compiler.dashboard_list' => 'compiler.dashboard_list', + 'search.access' => 'search.access', + 'search.submenu' => 'search.submenu', + 'search.dashboard_list' => 'search.dashboard_list', + 'get_snippets.submenu' => 'get_snippets.submenu', + 'get_snippets.dashboard_list' => 'get_snippets.dashboard_list', + 'joomla_component.create' => 'joomla_component.create', + 'joomla_components.access' => 'joomla_component.access', + 'joomla_component.access' => 'joomla_component.access', + 'joomla_components.submenu' => 'joomla_component.submenu', + 'joomla_components.dashboard_list' => 'joomla_component.dashboard_list', + 'joomla_module.create' => 'joomla_module.create', + 'joomla_modules.access' => 'joomla_module.access', + 'joomla_module.access' => 'joomla_module.access', + 'joomla_modules.submenu' => 'joomla_module.submenu', + 'joomla_modules.dashboard_list' => 'joomla_module.dashboard_list', + 'joomla_plugin.create' => 'joomla_plugin.create', + 'joomla_plugins.access' => 'joomla_plugin.access', + 'joomla_plugin.access' => 'joomla_plugin.access', + 'joomla_plugins.submenu' => 'joomla_plugin.submenu', + 'joomla_plugins.dashboard_list' => 'joomla_plugin.dashboard_list', + 'power.create' => 'power.create', + 'powers.access' => 'power.access', + 'power.access' => 'power.access', + 'powers.submenu' => 'power.submenu', + 'powers.dashboard_list' => 'power.dashboard_list', + 'admin_view.create' => 'admin_view.create', + 'admin_views.access' => 'admin_view.access', + 'admin_view.access' => 'admin_view.access', + 'admin_views.submenu' => 'admin_view.submenu', + 'admin_views.dashboard_list' => 'admin_view.dashboard_list', + 'custom_admin_views.access' => 'custom_admin_view.access', + 'custom_admin_view.access' => 'custom_admin_view.access', + 'custom_admin_views.submenu' => 'custom_admin_view.submenu', + 'custom_admin_views.dashboard_list' => 'custom_admin_view.dashboard_list', + 'site_views.access' => 'site_view.access', + 'site_view.access' => 'site_view.access', + 'site_views.submenu' => 'site_view.submenu', + 'site_views.dashboard_list' => 'site_view.dashboard_list', + 'templates.access' => 'template.access', + 'template.access' => 'template.access', + 'templates.submenu' => 'template.submenu', + 'templates.dashboard_list' => 'template.dashboard_list', + 'template.dashboard_add' => 'template.dashboard_add', + 'layouts.access' => 'layout.access', + 'layout.access' => 'layout.access', + 'layouts.submenu' => 'layout.submenu', + 'layouts.dashboard_list' => 'layout.dashboard_list', + 'dynamic_get.create' => 'dynamic_get.create', + 'dynamic_gets.access' => 'dynamic_get.access', + 'dynamic_get.access' => 'dynamic_get.access', + 'dynamic_gets.submenu' => 'dynamic_get.submenu', + 'dynamic_gets.dashboard_list' => 'dynamic_get.dashboard_list', + 'dynamic_get.dashboard_add' => 'dynamic_get.dashboard_add', + 'custom_code.create' => 'custom_code.create', + 'custom_codes.access' => 'custom_code.access', + 'custom_code.access' => 'custom_code.access', + 'custom_codes.submenu' => 'custom_code.submenu', + 'custom_codes.dashboard_list' => 'custom_code.dashboard_list', + 'class_property.create' => 'class_property.create', + 'class_properties.access' => 'class_property.access', + 'class_property.access' => 'class_property.access', + 'class_method.create' => 'class_method.create', + 'class_methods.access' => 'class_method.access', + 'class_method.access' => 'class_method.access', + 'placeholder.create' => 'placeholder.create', + 'placeholders.access' => 'placeholder.access', + 'placeholder.access' => 'placeholder.access', + 'placeholders.submenu' => 'placeholder.submenu', + 'placeholders.dashboard_list' => 'placeholder.dashboard_list', + 'library.create' => 'library.create', + 'libraries.access' => 'library.access', + 'library.access' => 'library.access', + 'libraries.submenu' => 'library.submenu', + 'libraries.dashboard_list' => 'library.dashboard_list', + 'snippets.access' => 'snippet.access', + 'snippet.access' => 'snippet.access', + 'snippets.submenu' => 'snippet.submenu', + 'snippets.dashboard_list' => 'snippet.dashboard_list', + 'validation_rule.create' => 'validation_rule.create', + 'validation_rules.access' => 'validation_rule.access', + 'validation_rule.access' => 'validation_rule.access', + 'validation_rules.submenu' => 'validation_rule.submenu', + 'validation_rules.dashboard_list' => 'validation_rule.dashboard_list', + 'field.create' => 'field.create', + 'fields.access' => 'field.access', + 'field.access' => 'field.access', + 'fields.submenu' => 'field.submenu', + 'fields.dashboard_list' => 'field.dashboard_list', + 'field.dashboard_add' => 'field.dashboard_add', + 'fieldtype.create' => 'fieldtype.create', + 'fieldtypes.access' => 'fieldtype.access', + 'fieldtype.access' => 'fieldtype.access', + 'fieldtypes.submenu' => 'fieldtype.submenu', + 'fieldtypes.dashboard_list' => 'fieldtype.dashboard_list', + 'language_translation.create' => 'language_translation.create', + 'language_translations.access' => 'language_translation.access', + 'language_translation.access' => 'language_translation.access', + 'language_translations.submenu' => 'language_translation.submenu', + 'language_translations.dashboard_list' => 'language_translation.dashboard_list', + 'language.create' => 'language.create', + 'languages.access' => 'language.access', + 'language.access' => 'language.access', + 'languages.submenu' => 'language.submenu', + 'server.create' => 'server.create', + 'servers.access' => 'server.access', + 'server.access' => 'server.access', + 'servers.submenu' => 'server.submenu', + 'servers.dashboard_list' => 'server.dashboard_list', + 'help_document.create' => 'help_document.create', + 'help_documents.access' => 'help_document.access', + 'help_document.access' => 'help_document.access', + 'help_documents.submenu' => 'help_document.submenu', + 'help_documents.dashboard_list' => 'help_document.dashboard_list', + 'admin_fields.create' => 'admin_fields.create', + 'admins_fields.access' => 'admin_fields.access', + 'admin_fields.access' => 'admin_fields.access', + 'admin_fields_conditions.create' => 'admin_fields_conditions.create', + 'admins_fields_conditions.access' => 'admin_fields_conditions.access', + 'admin_fields_conditions.access' => 'admin_fields_conditions.access', + 'admin_fields_relations.create' => 'admin_fields_relations.create', + 'admins_fields_relations.access' => 'admin_fields_relations.access', + 'admin_fields_relations.access' => 'admin_fields_relations.access', + 'admin_custom_tabs.create' => 'admin_custom_tabs.create', + 'admins_custom_tabs.access' => 'admin_custom_tabs.access', + 'admin_custom_tabs.access' => 'admin_custom_tabs.access', + 'component_admin_views.create' => 'component_admin_views.create', + 'components_admin_views.access' => 'component_admin_views.access', + 'component_admin_views.access' => 'component_admin_views.access', + 'component_site_views.create' => 'component_site_views.create', + 'components_site_views.access' => 'component_site_views.access', + 'component_site_views.access' => 'component_site_views.access', + 'component_custom_admin_views.create' => 'component_custom_admin_views.create', + 'components_custom_admin_views.access' => 'component_custom_admin_views.access', + 'component_custom_admin_views.access' => 'component_custom_admin_views.access', + 'component_updates.create' => 'component_updates.create', + 'components_updates.access' => 'component_updates.access', + 'component_updates.access' => 'component_updates.access', + 'component_mysql_tweaks.create' => 'component_mysql_tweaks.create', + 'components_mysql_tweaks.access' => 'component_mysql_tweaks.access', + 'component_mysql_tweaks.access' => 'component_mysql_tweaks.access', + 'component_custom_admin_menus.create' => 'component_custom_admin_menus.create', + 'components_custom_admin_menus.access' => 'component_custom_admin_menus.access', + 'component_custom_admin_menus.access' => 'component_custom_admin_menus.access', + 'component_router.create' => 'component_router.create', + 'components_routers.access' => 'component_router.access', + 'component_router.access' => 'component_router.access', + 'component_config.create' => 'component_config.create', + 'components_config.access' => 'component_config.access', + 'component_config.access' => 'component_config.access', + 'component_dashboard.create' => 'component_dashboard.create', + 'components_dashboard.access' => 'component_dashboard.access', + 'component_dashboard.access' => 'component_dashboard.access', + 'component_files_folders.create' => 'component_files_folders.create', + 'components_files_folders.access' => 'component_files_folders.access', + 'component_files_folders.access' => 'component_files_folders.access', + 'component_placeholders.create' => 'component_placeholders.create', + 'components_placeholders.access' => 'component_placeholders.access', + 'component_placeholders.access' => 'component_placeholders.access', + 'component_plugins.create' => 'component_plugins.create', + 'components_plugins.access' => 'component_plugins.access', + 'component_plugins.access' => 'component_plugins.access', + 'component_modules.create' => 'component_modules.create', + 'components_modules.access' => 'component_modules.access', + 'component_modules.access' => 'component_modules.access', + 'snippet_type.create' => 'snippet_type.create', + 'snippet_types.access' => 'snippet_type.access', + 'snippet_type.access' => 'snippet_type.access', + 'library_config.create' => 'library_config.create', + 'libraries_config.access' => 'library_config.access', + 'library_config.access' => 'library_config.access', + 'library_files_folders_urls.create' => 'library_files_folders_urls.create', + 'libraries_files_folders_urls.access' => 'library_files_folders_urls.access', + 'library_files_folders_urls.access' => 'library_files_folders_urls.access', + 'class_extends.create' => 'class_extends.create', + 'class_extendings.access' => 'class_extends.access', + 'class_extends.access' => 'class_extends.access', + 'joomla_module_updates.create' => 'joomla_module_updates.create', + 'joomla_modules_updates.access' => 'joomla_module_updates.access', + 'joomla_module_updates.access' => 'joomla_module_updates.access', + 'joomla_module_files_folders_urls.create' => 'joomla_module_files_folders_urls.create', + 'joomla_modules_files_folders_urls.access' => 'joomla_module_files_folders_urls.access', + 'joomla_module_files_folders_urls.access' => 'joomla_module_files_folders_urls.access', + 'joomla_plugin_groups.access' => 'joomla_plugin_group.access', + 'joomla_plugin_group.access' => 'joomla_plugin_group.access', + 'joomla_plugin_updates.create' => 'joomla_plugin_updates.create', + 'joomla_plugins_updates.access' => 'joomla_plugin_updates.access', + 'joomla_plugin_updates.access' => 'joomla_plugin_updates.access', + 'joomla_plugin_files_folders_urls.create' => 'joomla_plugin_files_folders_urls.create', + 'joomla_plugins_files_folders_urls.access' => 'joomla_plugin_files_folders_urls.access', + 'joomla_plugin_files_folders_urls.access' => 'joomla_plugin_files_folders_urls.access', + ]; + // loop over the $views + foreach($viewGroups as $group => $views) + { + $i = 0; + if (UtilitiesArrayHelper::check($views)) + { + foreach($views as $view) + { + $add = false; + // external views (links) + if (strpos($view,'||') !== false) + { + $dwd = explode('||', $view); + if (count($dwd) == 3) + { + list($type, $name, $url) = $dwd; + $viewName = $name; + $alt = $name; + $url = $url; + $image = $name . '.' . $type; + $name = 'COM_COMPONENTBUILDER_DASHBOARD_' . StringHelper::safe($name,'U'); + } + } + // internal views + elseif (strpos($view,'.') !== false) + { + $dwd = explode('.', $view); + if (count($dwd) == 3) + { + list($type, $name, $action) = $dwd; + } + elseif (count($dwd) == 2) + { + list($type, $name) = $dwd; + $action = false; + } + if ($action) + { + $viewName = $name; + switch($action) + { + case 'add': + $url = 'index.php?option=com_componentbuilder&view=' . $name . '&layout=edit'; + $image = $name . '_' . $action. '.' . $type; + $alt = $name . ' ' . $action; + $name = 'COM_COMPONENTBUILDER_DASHBOARD_'.StringHelper::safe($name,'U').'_ADD'; + $add = true; + break; + default: + // check for new convention (more stable) + if (strpos($action, '_qpo0O0oqp_') !== false) + { + list($action, $extension) = (array) explode('_qpo0O0oqp_', $action); + $extension = str_replace('_po0O0oq_', '.', $extension); + } + else + { + $extension = 'com_componentbuilder.' . $name; + } + $url = 'index.php?option=com_categories&view=categories&extension=' . $extension; + $image = $name . '_' . $action . '.' . $type; + $alt = $viewName . ' ' . $action; + $name = 'COM_COMPONENTBUILDER_DASHBOARD_' . StringHelper::safe($name,'U') . '_' . StringHelper::safe($action,'U'); + break; + } + } + else + { + $viewName = $name; + $alt = $name; + $url = 'index.php?option=com_componentbuilder&view=' . $name; + $image = $name . '.' . $type; + $name = 'COM_COMPONENTBUILDER_DASHBOARD_' . StringHelper::safe($name,'U'); + $hover = false; + } + } + else + { + $viewName = $view; + $alt = $view; + $url = 'index.php?option=com_componentbuilder&view=' . $view; + $image = $view . '.png'; + $name = ucwords($view).'

    '; + $hover = false; + } + // first make sure the view access is set + if (UtilitiesArrayHelper::check($viewAccess)) + { + // setup some defaults + $dashboard_add = false; + $dashboard_list = false; + $accessTo = ''; + $accessAdd = ''; + // access checking start + $accessCreate = (isset($viewAccess[$viewName.'.create'])) ? StringHelper::check($viewAccess[$viewName.'.create']):false; + $accessAccess = (isset($viewAccess[$viewName.'.access'])) ? StringHelper::check($viewAccess[$viewName.'.access']):false; + // set main controllers + $accessDashboard_add = (isset($viewAccess[$viewName.'.dashboard_add'])) ? StringHelper::check($viewAccess[$viewName.'.dashboard_add']):false; + $accessDashboard_list = (isset($viewAccess[$viewName.'.dashboard_list'])) ? StringHelper::check($viewAccess[$viewName.'.dashboard_list']):false; + // check for adding access + if ($add && $accessCreate) + { + $accessAdd = $viewAccess[$viewName.'.create']; + } + elseif ($add) + { + $accessAdd = 'core.create'; + } + // check if access to view is set + if ($accessAccess) + { + $accessTo = $viewAccess[$viewName.'.access']; + } + // set main access controllers + if ($accessDashboard_add) + { + $dashboard_add = $user->authorise($viewAccess[$viewName.'.dashboard_add'], 'com_componentbuilder'); + } + if ($accessDashboard_list) + { + $dashboard_list = $user->authorise($viewAccess[$viewName.'.dashboard_list'], 'com_componentbuilder'); + } + if (StringHelper::check($accessAdd) && StringHelper::check($accessTo)) + { + // check access + if($user->authorise($accessAdd, 'com_componentbuilder') && $user->authorise($accessTo, 'com_componentbuilder') && $dashboard_add) + { + $icons[$group][$i] = new \StdClass; + $icons[$group][$i]->url = $url; + $icons[$group][$i]->name = $name; + $icons[$group][$i]->image = $image; + $icons[$group][$i]->alt = $alt; + } + } + elseif (StringHelper::check($accessTo)) + { + // check access + if($user->authorise($accessTo, 'com_componentbuilder') && $dashboard_list) + { + $icons[$group][$i] = new \StdClass; + $icons[$group][$i]->url = $url; + $icons[$group][$i]->name = $name; + $icons[$group][$i]->image = $image; + $icons[$group][$i]->alt = $alt; + } + } + elseif (StringHelper::check($accessAdd)) + { + // check access + if($user->authorise($accessAdd, 'com_componentbuilder') && $dashboard_add) + { + $icons[$group][$i] = new \StdClass; + $icons[$group][$i]->url = $url; + $icons[$group][$i]->name = $name; + $icons[$group][$i]->image = $image; + $icons[$group][$i]->alt = $alt; + } + } + else + { + $icons[$group][$i] = new \StdClass; + $icons[$group][$i]->url = $url; + $icons[$group][$i]->name = $name; + $icons[$group][$i]->image = $image; + $icons[$group][$i]->alt = $alt; + } + } + else + { + $icons[$group][$i] = new \StdClass; + $icons[$group][$i]->url = $url; + $icons[$group][$i]->name = $name; + $icons[$group][$i]->image = $image; + $icons[$group][$i]->alt = $alt; + } + $i++; + } + } + else + { + $icons[$group][$i] = false; + } + } + return $icons; + } + + + public function getWiki() + { + // the call URL + $call_url = Uri::base() . 'index.php?option=com_componentbuilder&task=ajax.getWiki&format=json&raw=true&' . Session::getFormToken() . '=1&name=Home'; + $document = Factory::getDocument(); + $document->addScriptDeclaration(' + function getWikiPage(){ + fetch("' . $call_url . '").then((response) => { + if (response.ok) { + return response.json(); + } + }).then((result) => { + if (typeof result.page !== "undefined") { + document.getElementById("wiki-md").innerHTML = marked.parse(result.page); + } else if (typeof result.error !== "undefined") { + document.getElementById("wiki-md-error").innerHTML = result.error + } + }); + } + setTimeout(getWikiPage, 1000);'); + + return '
    '.Text::_('COM_COMPONENTBUILDER_THE_WIKI_IS_LOADING').'..
    '; + } + + + public function getNoticeboard() + { + // get the document to load the scripts + $document = Factory::getDocument(); + Html::_('script', "media/com_componentbuilder/js/marked.js", ['version' => 'auto']); + $document->addScriptDeclaration(' + var token = "' . Session::getFormToken() . '"; + var noticeboard = "https://vdm.bz/componentbuilder-noticeboard-md"; + document.addEventListener("DOMContentLoaded", function() { + fetch(noticeboard) + .then(response => { + if (!response.ok) { + throw new Error("Network response was not ok"); + } + return response.text(); + }) + .then(board => { + if (board.length > 5) { + document.getElementById("noticeboard-md").innerHTML = marked.parse(board); + getIS(1, board) + .then(result => { + if (result) { + document.querySelectorAll("#cpanel_tabTabs a").forEach(link => { + if (link.href.includes("#vast_development_method") || link.href.includes("#notice_board")) { + var textVDM = link.textContent; + link.innerHTML = "1 " + textVDM; + link.id = "vdm-new-notice"; + document.getElementById("vdm-new-notice").addEventListener("click", () => { + getIS(2, board) + .then(result => { + if (result) { + document.querySelectorAll(".vdm-new-notice").forEach(element => { + element.style.opacity = 0; + }); + } + }); + }); + } + }); + } + }); + } else { + document.getElementById("noticeboard-md").innerHTML = "'.Text::_('COM_COMPONENTBUILDER_ALL_IS_GOOD_PLEASE_CHECK_AGAIN_LATER').'."; + } + }) + .catch(error => { + console.error("There was an error!", error); + document.getElementById("noticeboard-md").innerHTML = "'.Text::_('COM_COMPONENTBUILDER_ALL_IS_GOOD_PLEASE_CHECK_AGAIN_LATER').'."; + }); + }); + + // to check is READ/NEW + function getIS(type, notice) { + let getUrl = ""; + if (type === 1) { + getUrl = "index.php?option=com_componentbuilder&task=ajax.isNew&format=json&raw=true"; + } else if (type === 2) { + getUrl = "index.php?option=com_componentbuilder&task=ajax.isRead&format=json&raw=true"; + } + let request = new URLSearchParams(); + if (token.length > 0 && notice.length) { + request.append(token, "1"); + request.append("notice", notice); + } + return fetch(getUrl, { + method: "POST", + headers: { + "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" + }, + body: request + }).then(response => response.json()); + } + +document.addEventListener("DOMContentLoaded", function() { + document.querySelectorAll(".loading-dots").forEach(function(loading_dots) { + let x = 0; + let intervalId = setInterval(function() { + if (!loading_dots.classList.contains("loading-dots")) { + clearInterval(intervalId); + return; + } + let dots = ".".repeat(x % 8); + loading_dots.textContent = dots; + x++; + }, 500); + }); +});'); + + return '
    '.Text::_('COM_COMPONENTBUILDER_THE_NOTICE_BOARD_IS_LOADING').'..
    '; + } + + public function getReadme() + { + $document = Factory::getDocument(); + $document->addScriptDeclaration(' + var getreadme = "'. Uri::root() . 'administrator/components/com_componentbuilder/README.txt"; + document.addEventListener("DOMContentLoaded", function () { + fetch(getreadme) + .then(response => { + if (!response.ok) { + throw new Error("Network response was not ok"); + } + return response.text(); + }) + .then(readme => { + document.getElementById("readme-md").innerHTML = marked.parse(readme); + }) + .catch(error => { + console.error("There has been a problem with your fetch operation:", error); + document.getElementById("readme-md").innerHTML = "'.Text::_('COM_COMPONENTBUILDER_PLEASE_CHECK_AGAIN_LATER').'."; + }); + });'); + + return '
    '.Text::_('COM_COMPONENTBUILDER_THE_README_IS_LOADING').'..
    '; + } + + /** + * get Current Version Bay adding JavaScript to the Page + * + * @return void + * @since 2.3.0 + */ + public function getVersion() + { + // the call URL + $call_url = Uri::base() . 'index.php?option=com_componentbuilder&task=ajax.getVersion&format=json&raw=true&' . Session::getFormToken() . '=1&version=1'; + $document = Factory::getDocument(); + $document->addScriptDeclaration(' + function getComponentVersionStatus() { + fetch("' . $call_url . '").then((response) => { + if (response.ok) { + return response.json(); + } + }).then((result) => { + if (typeof result.notice !== "undefined") { + document.getElementById("component-update-notice").innerHTML = result.notice; + } else if (typeof result.error !== "undefined") { + document.getElementById("component-update-notice").innerHTML = result.error; + } + }); + } + setTimeout(getComponentVersionStatus, 800);'); + } + +} diff --git a/admin/src/Model/Components_admin_viewsModel.php b/admin/src/Model/Components_admin_viewsModel.php new file mode 100644 index 000000000..419d63014 --- /dev/null +++ b/admin/src/Model/Components_admin_viewsModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_admin_views List Model + * + * @since 1.6 + */ +class Components_admin_viewsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/components_admin_views.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('component_admin_views.access', 'com_componentbuilder.component_admin_views.' . (int) $item->id) && $user->authorise('component_admin_views.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_component_admin_views', 'a')); + + // From the componentbuilder_joomla_component table. + $query->select($db->quoteName('g.system_name','joomla_component_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_component', 'g') . ' ON (' . $db->quoteName('a.joomla_component') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_component_admin_views')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_component_admin_views'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Components_configModel.php b/admin/src/Model/Components_configModel.php new file mode 100644 index 000000000..387bfed17 --- /dev/null +++ b/admin/src/Model/Components_configModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_config List Model + * + * @since 1.6 + */ +class Components_configModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/components_config.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('component_config.access', 'com_componentbuilder.component_config.' . (int) $item->id) && $user->authorise('component_config.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_component_config', 'a')); + + // From the componentbuilder_joomla_component table. + $query->select($db->quoteName('g.system_name','joomla_component_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_component', 'g') . ' ON (' . $db->quoteName('a.joomla_component') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_component_config')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_component_config'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Components_custom_admin_menusModel.php b/admin/src/Model/Components_custom_admin_menusModel.php new file mode 100644 index 000000000..c5be53b80 --- /dev/null +++ b/admin/src/Model/Components_custom_admin_menusModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_custom_admin_menus List Model + * + * @since 1.6 + */ +class Components_custom_admin_menusModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/components_custom_admin_menus.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('component_custom_admin_menus.access', 'com_componentbuilder.component_custom_admin_menus.' . (int) $item->id) && $user->authorise('component_custom_admin_menus.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_component_custom_admin_menus', 'a')); + + // From the componentbuilder_joomla_component table. + $query->select($db->quoteName('g.system_name','joomla_component_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_component', 'g') . ' ON (' . $db->quoteName('a.joomla_component') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_component_custom_admin_menus')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_component_custom_admin_menus'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Components_custom_admin_viewsModel.php b/admin/src/Model/Components_custom_admin_viewsModel.php new file mode 100644 index 000000000..3d907a938 --- /dev/null +++ b/admin/src/Model/Components_custom_admin_viewsModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_custom_admin_views List Model + * + * @since 1.6 + */ +class Components_custom_admin_viewsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/components_custom_admin_views.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('component_custom_admin_views.access', 'com_componentbuilder.component_custom_admin_views.' . (int) $item->id) && $user->authorise('component_custom_admin_views.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_component_custom_admin_views', 'a')); + + // From the componentbuilder_joomla_component table. + $query->select($db->quoteName('g.system_name','joomla_component_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_component', 'g') . ' ON (' . $db->quoteName('a.joomla_component') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_component_custom_admin_views')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_component_custom_admin_views'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Components_dashboardModel.php b/admin/src/Model/Components_dashboardModel.php new file mode 100644 index 000000000..56584cc23 --- /dev/null +++ b/admin/src/Model/Components_dashboardModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_dashboard List Model + * + * @since 1.6 + */ +class Components_dashboardModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/components_dashboard.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('component_dashboard.access', 'com_componentbuilder.component_dashboard.' . (int) $item->id) && $user->authorise('component_dashboard.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_component_dashboard', 'a')); + + // From the componentbuilder_joomla_component table. + $query->select($db->quoteName('g.system_name','joomla_component_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_component', 'g') . ' ON (' . $db->quoteName('a.joomla_component') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_component_dashboard')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_component_dashboard'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Components_files_foldersModel.php b/admin/src/Model/Components_files_foldersModel.php new file mode 100644 index 000000000..434ce6ba6 --- /dev/null +++ b/admin/src/Model/Components_files_foldersModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_files_folders List Model + * + * @since 1.6 + */ +class Components_files_foldersModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/components_files_folders.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('component_files_folders.access', 'com_componentbuilder.component_files_folders.' . (int) $item->id) && $user->authorise('component_files_folders.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_component_files_folders', 'a')); + + // From the componentbuilder_joomla_component table. + $query->select($db->quoteName('g.system_name','joomla_component_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_component', 'g') . ' ON (' . $db->quoteName('a.joomla_component') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_component_files_folders')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_component_files_folders'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Components_modulesModel.php b/admin/src/Model/Components_modulesModel.php new file mode 100644 index 000000000..9d975a2d8 --- /dev/null +++ b/admin/src/Model/Components_modulesModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_modules List Model + * + * @since 1.6 + */ +class Components_modulesModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/components_modules.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('component_modules.access', 'com_componentbuilder.component_modules.' . (int) $item->id) && $user->authorise('component_modules.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_component_modules', 'a')); + + // From the componentbuilder_joomla_component table. + $query->select($db->quoteName('g.system_name','joomla_component_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_component', 'g') . ' ON (' . $db->quoteName('a.joomla_component') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_component_modules')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_component_modules'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Components_mysql_tweaksModel.php b/admin/src/Model/Components_mysql_tweaksModel.php new file mode 100644 index 000000000..57d76a361 --- /dev/null +++ b/admin/src/Model/Components_mysql_tweaksModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_mysql_tweaks List Model + * + * @since 1.6 + */ +class Components_mysql_tweaksModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/components_mysql_tweaks.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('component_mysql_tweaks.access', 'com_componentbuilder.component_mysql_tweaks.' . (int) $item->id) && $user->authorise('component_mysql_tweaks.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_component_mysql_tweaks', 'a')); + + // From the componentbuilder_joomla_component table. + $query->select($db->quoteName('g.system_name','joomla_component_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_component', 'g') . ' ON (' . $db->quoteName('a.joomla_component') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_component_mysql_tweaks')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_component_mysql_tweaks'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Components_placeholdersModel.php b/admin/src/Model/Components_placeholdersModel.php new file mode 100644 index 000000000..7163b71b4 --- /dev/null +++ b/admin/src/Model/Components_placeholdersModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_placeholders List Model + * + * @since 1.6 + */ +class Components_placeholdersModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/components_placeholders.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('component_placeholders.access', 'com_componentbuilder.component_placeholders.' . (int) $item->id) && $user->authorise('component_placeholders.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_component_placeholders', 'a')); + + // From the componentbuilder_joomla_component table. + $query->select($db->quoteName('g.system_name','joomla_component_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_component', 'g') . ' ON (' . $db->quoteName('a.joomla_component') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_component_placeholders')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_component_placeholders'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Components_pluginsModel.php b/admin/src/Model/Components_pluginsModel.php new file mode 100644 index 000000000..b205bf0bc --- /dev/null +++ b/admin/src/Model/Components_pluginsModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_plugins List Model + * + * @since 1.6 + */ +class Components_pluginsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/components_plugins.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('component_plugins.access', 'com_componentbuilder.component_plugins.' . (int) $item->id) && $user->authorise('component_plugins.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_component_plugins', 'a')); + + // From the componentbuilder_joomla_component table. + $query->select($db->quoteName('g.system_name','joomla_component_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_component', 'g') . ' ON (' . $db->quoteName('a.joomla_component') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_component_plugins')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_component_plugins'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Components_routersModel.php b/admin/src/Model/Components_routersModel.php new file mode 100644 index 000000000..89a86bc91 --- /dev/null +++ b/admin/src/Model/Components_routersModel.php @@ -0,0 +1,529 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_routers List Model + * + * @since 1.6 + */ +class Components_routersModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/components_routers.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.mode_constructor_before_parent','mode_constructor_before_parent', + 'a.mode_constructor_after_parent','mode_constructor_after_parent', + 'a.mode_methods','mode_methods' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $mode_constructor_before_parent = $this->getUserStateFromRequest($this->context . '.filter.mode_constructor_before_parent', 'filter_mode_constructor_before_parent'); + if ($formSubmited) + { + $mode_constructor_before_parent = $app->input->post->get('mode_constructor_before_parent'); + $this->setState('filter.mode_constructor_before_parent', $mode_constructor_before_parent); + } + + $mode_constructor_after_parent = $this->getUserStateFromRequest($this->context . '.filter.mode_constructor_after_parent', 'filter_mode_constructor_after_parent'); + if ($formSubmited) + { + $mode_constructor_after_parent = $app->input->post->get('mode_constructor_after_parent'); + $this->setState('filter.mode_constructor_after_parent', $mode_constructor_after_parent); + } + + $mode_methods = $this->getUserStateFromRequest($this->context . '.filter.mode_methods', 'filter_mode_methods'); + if ($formSubmited) + { + $mode_methods = $app->input->post->get('mode_methods'); + $this->setState('filter.mode_methods', $mode_methods); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('component_router.access', 'com_componentbuilder.component_router.' . (int) $item->id) && $user->authorise('component_router.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // set selection value to a translatable value + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // convert mode_constructor_before_parent + $item->mode_constructor_before_parent = $this->selectionTranslation($item->mode_constructor_before_parent, 'mode_constructor_before_parent'); + // convert mode_constructor_after_parent + $item->mode_constructor_after_parent = $this->selectionTranslation($item->mode_constructor_after_parent, 'mode_constructor_after_parent'); + // convert mode_methods + $item->mode_methods = $this->selectionTranslation($item->mode_methods, 'mode_methods'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return string The translatable string. + */ + public function selectionTranslation($value,$name) + { + // Array of mode_constructor_before_parent language strings + if ($name === 'mode_constructor_before_parent') + { + $mode_constructor_before_parentArray = array( + 1 => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_DEFAULT', + 2 => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_MANUAL', + 3 => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_CODE' + ); + // Now check if value is found in this array + if (isset($mode_constructor_before_parentArray[$value]) && StringHelper::check($mode_constructor_before_parentArray[$value])) + { + return $mode_constructor_before_parentArray[$value]; + } + } + // Array of mode_constructor_after_parent language strings + if ($name === 'mode_constructor_after_parent') + { + $mode_constructor_after_parentArray = array( + 1 => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_NONE', + 3 => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_CODE' + ); + // Now check if value is found in this array + if (isset($mode_constructor_after_parentArray[$value]) && StringHelper::check($mode_constructor_after_parentArray[$value])) + { + return $mode_constructor_after_parentArray[$value]; + } + } + // Array of mode_methods language strings + if ($name === 'mode_methods') + { + $mode_methodsArray = array( + 0 => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_NONE', + 1 => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_DEFAULT', + 3 => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_CODE' + ); + // Now check if value is found in this array + if (isset($mode_methodsArray[$value]) && StringHelper::check($mode_methodsArray[$value])) + { + return $mode_methodsArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_component_router', 'a')); + + // From the componentbuilder_joomla_component table. + $query->select($db->quoteName('g.system_name','joomla_component_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_component', 'g') . ' ON (' . $db->quoteName('a.joomla_component') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by Mode_constructor_before_parent. + $_mode_constructor_before_parent = $this->getState('filter.mode_constructor_before_parent'); + if (is_numeric($_mode_constructor_before_parent)) + { + if (is_float($_mode_constructor_before_parent)) + { + $query->where('a.mode_constructor_before_parent = ' . (float) $_mode_constructor_before_parent); + } + else + { + $query->where('a.mode_constructor_before_parent = ' . (int) $_mode_constructor_before_parent); + } + } + elseif (StringHelper::check($_mode_constructor_before_parent)) + { + $query->where('a.mode_constructor_before_parent = ' . $db->quote($db->escape($_mode_constructor_before_parent))); + } + // Filter by Mode_constructor_after_parent. + $_mode_constructor_after_parent = $this->getState('filter.mode_constructor_after_parent'); + if (is_numeric($_mode_constructor_after_parent)) + { + if (is_float($_mode_constructor_after_parent)) + { + $query->where('a.mode_constructor_after_parent = ' . (float) $_mode_constructor_after_parent); + } + else + { + $query->where('a.mode_constructor_after_parent = ' . (int) $_mode_constructor_after_parent); + } + } + elseif (StringHelper::check($_mode_constructor_after_parent)) + { + $query->where('a.mode_constructor_after_parent = ' . $db->quote($db->escape($_mode_constructor_after_parent))); + } + // Filter by Mode_methods. + $_mode_methods = $this->getState('filter.mode_methods'); + if (is_numeric($_mode_methods)) + { + if (is_float($_mode_methods)) + { + $query->where('a.mode_methods = ' . (float) $_mode_methods); + } + else + { + $query->where('a.mode_methods = ' . (int) $_mode_methods); + } + } + elseif (StringHelper::check($_mode_methods)) + { + $query->where('a.mode_methods = ' . $db->quote($db->escape($_mode_methods))); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.mode_constructor_before_parent'); + $id .= ':' . $this->getState('filter.mode_constructor_after_parent'); + $id .= ':' . $this->getState('filter.mode_methods'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_component_router')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_component_router'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Components_site_viewsModel.php b/admin/src/Model/Components_site_viewsModel.php new file mode 100644 index 000000000..76ba231ea --- /dev/null +++ b/admin/src/Model/Components_site_viewsModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_site_views List Model + * + * @since 1.6 + */ +class Components_site_viewsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/components_site_views.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('component_site_views.access', 'com_componentbuilder.component_site_views.' . (int) $item->id) && $user->authorise('component_site_views.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_component_site_views', 'a')); + + // From the componentbuilder_joomla_component table. + $query->select($db->quoteName('g.system_name','joomla_component_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_component', 'g') . ' ON (' . $db->quoteName('a.joomla_component') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_component_site_views')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_component_site_views'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Components_updatesModel.php b/admin/src/Model/Components_updatesModel.php new file mode 100644 index 000000000..86add2ae8 --- /dev/null +++ b/admin/src/Model/Components_updatesModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_updates List Model + * + * @since 1.6 + */ +class Components_updatesModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/components_updates.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('component_updates.access', 'com_componentbuilder.component_updates.' . (int) $item->id) && $user->authorise('component_updates.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_component_updates', 'a')); + + // From the componentbuilder_joomla_component table. + $query->select($db->quoteName('g.system_name','joomla_component_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_component', 'g') . ' ON (' . $db->quoteName('a.joomla_component') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_component_updates')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_component_updates'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Custom_admin_viewModel.php b/admin/src/Model/Custom_admin_viewModel.php new file mode 100644 index 000000000..e9eb36e39 --- /dev/null +++ b/admin/src/Model/Custom_admin_viewModel.php @@ -0,0 +1,1395 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Custom_admin_view Admin Model + * + * @since 1.6 + */ +class Custom_admin_viewModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'name', + 'codename', + 'description', + 'note_libraries_selection', + 'libraries', + 'note_add_php_language_string' + ), + 'right' => array( + 'icon', + 'snippet', + 'note_uikit_snippet', + 'note_snippet_usage' + ), + 'fullwidth' => array( + 'default' + ), + 'above' => array( + 'system_name', + 'context' + ), + 'under' => array( + 'not_required' + ), + 'rightside' => array( + 'custom_get', + 'main_get', + 'dynamic_get', + 'dynamic_values' + ) + ), + 'php' => array( + 'fullwidth' => array( + 'add_php_ajax', + 'php_ajaxmethod', + 'ajax_input', + 'add_php_document', + 'php_document', + 'add_php_view', + 'php_view', + 'add_php_jview_display', + 'php_jview_display', + 'add_php_jview', + 'php_jview' + ) + ), + 'javascript_css' => array( + 'fullwidth' => array( + 'add_js_document', + 'js_document', + 'add_javascript_file', + 'javascript_file', + 'add_css_document', + 'css_document', + 'add_css', + 'css' + ) + ), + 'linked_components' => array( + 'fullwidth' => array( + 'note_linked_to_notice' + ) + ), + 'custom_buttons' => array( + 'left' => array( + 'add_custom_button', + 'custom_button' + ), + 'fullwidth' => array( + 'php_controller', + 'php_model' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/custom_admin_view.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/custom_admin_view.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.custom_admin_view'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'custom_admin_view', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('custom_admin_view__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'custom_admin_view__'.$id); + ComponentbuilderHelper::set('custom_admin_view__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->css_document)) + { + // base64 Decode css_document. + $item->css_document = base64_decode($item->css_document); + } + + if (!empty($item->css)) + { + // base64 Decode css. + $item->css = base64_decode($item->css); + } + + if (!empty($item->js_document)) + { + // base64 Decode js_document. + $item->js_document = base64_decode($item->js_document); + } + + if (!empty($item->javascript_file)) + { + // base64 Decode javascript_file. + $item->javascript_file = base64_decode($item->javascript_file); + } + + if (!empty($item->default)) + { + // base64 Decode default. + $item->default = base64_decode($item->default); + } + + if (!empty($item->php_ajaxmethod)) + { + // base64 Decode php_ajaxmethod. + $item->php_ajaxmethod = base64_decode($item->php_ajaxmethod); + } + + if (!empty($item->php_document)) + { + // base64 Decode php_document. + $item->php_document = base64_decode($item->php_document); + } + + if (!empty($item->php_view)) + { + // base64 Decode php_view. + $item->php_view = base64_decode($item->php_view); + } + + if (!empty($item->php_jview_display)) + { + // base64 Decode php_jview_display. + $item->php_jview_display = base64_decode($item->php_jview_display); + } + + if (!empty($item->php_jview)) + { + // base64 Decode php_jview. + $item->php_jview = base64_decode($item->php_jview); + } + + if (!empty($item->php_controller)) + { + // base64 Decode php_controller. + $item->php_controller = base64_decode($item->php_controller); + } + + if (!empty($item->php_model)) + { + // base64 Decode php_model. + $item->php_model = base64_decode($item->php_model); + } + + if (!empty($item->custom_get)) + { + // Convert the custom_get field to an array. + $custom_get = new Registry; + $custom_get->loadString($item->custom_get); + $item->custom_get = $custom_get->toArray(); + } + + if (!empty($item->libraries)) + { + // Convert the libraries field to an array. + $libraries = new Registry; + $libraries->loadString($item->libraries); + $item->libraries = $libraries->toArray(); + } + + if (!empty($item->ajax_input)) + { + // Convert the ajax_input field to an array. + $ajax_input = new Registry; + $ajax_input->loadString($item->ajax_input); + $item->ajax_input = $ajax_input->toArray(); + } + + if (!empty($item->custom_button)) + { + // Convert the custom_button field to an array. + $custom_button = new Registry; + $custom_button->loadString($item->custom_button); + $item->custom_button = $custom_button->toArray(); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('custom_admin_view__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'custom_admin_view__'.$id); + ComponentbuilderHelper::set('custom_admin_view__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + + // check what type of custom_button array we have here (should be subform... but just incase) + // This could happen due to huge data sets + if (isset($item->custom_button) && isset($item->custom_button['name'])) + { + $bucket = array(); + foreach($item->custom_button as $option => $values) + { + foreach($values as $nr => $value) + { + $bucket['custom_button'.$nr][$option] = $value; + } + } + $item->custom_button = $bucket; + // update the fields + $objectUpdate = new \stdClass(); + $objectUpdate->id = (int) $item->id; + $objectUpdate->custom_button = json_encode($bucket); + // be sure to update the table if we found repeatable fields that are still not converted + $this->_db->updateObject('#__componentbuilder_custom_admin_view', $objectUpdate, 'id'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.custom_admin_view', 'custom_admin_view', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('core.edit.state', 'com_componentbuilder.custom_admin_view.' . (int) $id)) + || ($id == 0 && !$user->authorise('core.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if (!$user->authorise('core.edit.created_by', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if (!$user->authorise('core.edit.created', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update all editors to use this components global editor + $global_editor = ComponentHelper::getParams('com_componentbuilder')->get('editor', 'none'); + // now get all the editor fields + $editors = $form->getXml()->xpath("//field[@type='editor']"); + // check if we found any + if (UtilitiesArrayHelper::check($editors)) + { + foreach ($editors as $editor) + { + // get the field names + $name = (string) $editor['name']; + // set the field editor value (with none as fallback) + $form->setFieldAttribute($name, 'editor', $global_editor . '|none'); + } + } + + + // Only load the GUID if new item (or empty) + if (0 == $id || !($val = $form->getValue('guid'))) + { + $form->setValue('guid', null, GuidHelper::get()); + } + + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('core.delete', 'com_componentbuilder.custom_admin_view.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('core.edit.state', 'com_componentbuilder.custom_admin_view.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return parent::canEditState($record); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('core.edit', 'com_componentbuilder.custom_admin_view.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('core.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_custom_admin_view')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.custom_admin_view.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.custom_admin_view', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return array('guid'); + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('custom_admin_view'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('custom_admin_view'); + } + + if (!$this->canDo->get('core.create') && !$this->canDo->get('custom_admin_view.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('core.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('core.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->name) && !is_numeric($this->table->name)) + { + $this->table->name = $this->generateUnique('name',$this->table->name); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('custom_admin_view'); + } + + if (!$this->canDo->get('core.edit') && !$this->canDo->get('custom_admin_view.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('core.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('core.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // always reset the snippets + $data['snippet'] = 0; + // if system name is empty create from name + if (empty($data['system_name']) || !UtilitiesStringHelper::check($data['system_name'])) + { + $data['system_name'] = $data['name']; + } + // if codename is empty create from name + if (empty($data['codename']) || !UtilitiesStringHelper::check($data['codename'])) + { + $data['codename'] = UtilitiesStringHelper::safe($data['name']); + } + else + { + // always make safe string + $data['codename'] = UtilitiesStringHelper::safe($data['codename']); + } + // if context is empty create from codename + if (empty($data['context']) || !UtilitiesStringHelper::check($data['context'])) + { + $data['context'] = $data['codename']; + } + else + { + // always make safe string + $data['context'] = UtilitiesStringHelper::safe($data['context']); + } + + // Set the GUID if empty or not valid + if (empty($data['guid']) && $data['id'] > 0) + { + // get the existing one + $data['guid'] = (string) GetHelper::var('custom_admin_view', $data['id'], 'id', 'guid'); + } + + // Set the GUID if empty or not valid + while (!GuidHelper::valid($data['guid'], "custom_admin_view", $data['id'])) + { + // must always be set + $data['guid'] = (string) GuidHelper::get(); + } + + // Set the custom_get items to data. + if (isset($data['custom_get']) && is_array($data['custom_get'])) + { + $custom_get = new Registry; + $custom_get->loadArray($data['custom_get']); + $data['custom_get'] = (string) $custom_get; + } + elseif (!isset($data['custom_get'])) + { + // Set the empty custom_get to data + $data['custom_get'] = ''; + } + + // Set the libraries items to data. + if (isset($data['libraries']) && is_array($data['libraries'])) + { + $libraries = new Registry; + $libraries->loadArray($data['libraries']); + $data['libraries'] = (string) $libraries; + } + elseif (!isset($data['libraries'])) + { + // Set the empty libraries to data + $data['libraries'] = ''; + } + + // Set the ajax_input items to data. + if (isset($data['ajax_input']) && is_array($data['ajax_input'])) + { + $ajax_input = new Registry; + $ajax_input->loadArray($data['ajax_input']); + $data['ajax_input'] = (string) $ajax_input; + } + elseif (!isset($data['ajax_input'])) + { + // Set the empty ajax_input to data + $data['ajax_input'] = ''; + } + + // Set the custom_button items to data. + if (isset($data['custom_button']) && is_array($data['custom_button'])) + { + $custom_button = new Registry; + $custom_button->loadArray($data['custom_button']); + $data['custom_button'] = (string) $custom_button; + } + elseif (!isset($data['custom_button'])) + { + // Set the empty custom_button to data + $data['custom_button'] = ''; + } + + // Set the css_document string to base64 string. + if (isset($data['css_document'])) + { + $data['css_document'] = base64_encode($data['css_document']); + } + + // Set the css string to base64 string. + if (isset($data['css'])) + { + $data['css'] = base64_encode($data['css']); + } + + // Set the js_document string to base64 string. + if (isset($data['js_document'])) + { + $data['js_document'] = base64_encode($data['js_document']); + } + + // Set the javascript_file string to base64 string. + if (isset($data['javascript_file'])) + { + $data['javascript_file'] = base64_encode($data['javascript_file']); + } + + // Set the default string to base64 string. + if (isset($data['default'])) + { + $data['default'] = base64_encode($data['default']); + } + + // Set the php_ajaxmethod string to base64 string. + if (isset($data['php_ajaxmethod'])) + { + $data['php_ajaxmethod'] = base64_encode($data['php_ajaxmethod']); + } + + // Set the php_document string to base64 string. + if (isset($data['php_document'])) + { + $data['php_document'] = base64_encode($data['php_document']); + } + + // Set the php_view string to base64 string. + if (isset($data['php_view'])) + { + $data['php_view'] = base64_encode($data['php_view']); + } + + // Set the php_jview_display string to base64 string. + if (isset($data['php_jview_display'])) + { + $data['php_jview_display'] = base64_encode($data['php_jview_display']); + } + + // Set the php_jview string to base64 string. + if (isset($data['php_jview'])) + { + $data['php_jview'] = base64_encode($data['php_jview']); + } + + // Set the php_controller string to base64 string. + if (isset($data['php_controller'])) + { + $data['php_controller'] = base64_encode($data['php_controller']); + } + + // Set the php_model string to base64 string. + if (isset($data['php_model'])) + { + $data['php_model'] = base64_encode($data['php_model']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Custom_admin_viewsModel.php b/admin/src/Model/Custom_admin_viewsModel.php new file mode 100644 index 000000000..45a71a739 --- /dev/null +++ b/admin/src/Model/Custom_admin_viewsModel.php @@ -0,0 +1,819 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\FormHelper as JCBFormHelper; +use VDM\Joomla\Componentbuilder\Utilities\FilterHelper as JCBFilterHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Custom_admin_views List Model + * + * @since 1.6 + */ +class Custom_admin_viewsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/custom_admin_views.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'g.name','main_get', + 'a.add_php_ajax','add_php_ajax', + 'a.add_custom_button','add_custom_button', + 'a.system_name','system_name', + 'a.name','name', + 'a.description','description' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Get the filter form - Override the parent method + * + * @param array $data data + * @param boolean $loadData load current data + * + * @return \JForm|boolean The \JForm object or false on error + * + * @since JCB 2.12.5 + */ + public function getFilterForm($data = array(), $loadData = true) + { + // load form from the parent class + $form = parent::getFilterForm($data, $loadData); + + // Create the "joomla_component" filter + $attributes = array( + 'name' => 'joomla_component', + 'type' => 'list', + 'onchange' => 'this.form.submit();', + ); + $options = array( + '' => '- ' . Text::_('COM_COMPONENTBUILDER_NO_COMPONENTS_FOUND') . ' -' + ); + // check if we have joomla components + if (($joomla_components = JCBFilterHelper::names('joomla_component')) !== null) + { + $options = array( + '' => '- ' . Text::_('COM_COMPONENTBUILDER_SELECT_COMPONENT') . ' -' + ); + // make sure we do not lose the key values in normal merge + $options = $options + $joomla_components; + } + + $form->setField(JCBFormHelper::xml($attributes, $options),'filter'); + $form->setValue( + 'joomla_component', + 'filter', + $this->state->get("filter.joomla_component") + ); + array_push($this->filter_fields, 'joomla_component'); + + return $form; + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $main_get = $this->getUserStateFromRequest($this->context . '.filter.main_get', 'filter_main_get'); + if ($formSubmited) + { + $main_get = $app->input->post->get('main_get'); + $this->setState('filter.main_get', $main_get); + } + + $add_php_ajax = $this->getUserStateFromRequest($this->context . '.filter.add_php_ajax', 'filter_add_php_ajax'); + if ($formSubmited) + { + $add_php_ajax = $app->input->post->get('add_php_ajax'); + $this->setState('filter.add_php_ajax', $add_php_ajax); + } + + $add_custom_button = $this->getUserStateFromRequest($this->context . '.filter.add_custom_button', 'filter_add_custom_button'); + if ($formSubmited) + { + $add_custom_button = $app->input->post->get('add_custom_button'); + $this->setState('filter.add_custom_button', $add_custom_button); + } + + $system_name = $this->getUserStateFromRequest($this->context . '.filter.system_name', 'filter_system_name'); + if ($formSubmited) + { + $system_name = $app->input->post->get('system_name'); + $this->setState('filter.system_name', $system_name); + } + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + $description = $this->getUserStateFromRequest($this->context . '.filter.description', 'filter_description'); + if ($formSubmited) + { + $description = $app->input->post->get('description'); + $this->setState('filter.description', $description); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('custom_admin_view.access', 'com_componentbuilder.custom_admin_view.' . (int) $item->id) && $user->authorise('custom_admin_view.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // set selection value to a translatable value + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // convert add_php_ajax + $item->add_php_ajax = $this->selectionTranslation($item->add_php_ajax, 'add_php_ajax'); + // convert add_custom_button + $item->add_custom_button = $this->selectionTranslation($item->add_custom_button, 'add_custom_button'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return string The translatable string. + */ + public function selectionTranslation($value,$name) + { + // Array of add_php_ajax language strings + if ($name === 'add_php_ajax') + { + $add_php_ajaxArray = array( + 1 => 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_YES', + 0 => 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NO' + ); + // Now check if value is found in this array + if (isset($add_php_ajaxArray[$value]) && StringHelper::check($add_php_ajaxArray[$value])) + { + return $add_php_ajaxArray[$value]; + } + } + // Array of add_custom_button language strings + if ($name === 'add_custom_button') + { + $add_custom_buttonArray = array( + 1 => 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_YES', + 0 => 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NO' + ); + // Now check if value is found in this array + if (isset($add_custom_buttonArray[$value]) && StringHelper::check($add_custom_buttonArray[$value])) + { + return $add_custom_buttonArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_custom_admin_view', 'a')); + + // do not use these filters in the export method + if (!isset($_export) || !$_export) + { + // Filtering "joomla components" + $filter_joomla_component = $this->state->get("filter.joomla_component"); + if ($filter_joomla_component !== null && !empty($filter_joomla_component)) + { + if (($ids = JCBFilterHelper::linked((int) $filter_joomla_component, 'joomla_component_custom_admin_views')) !== null) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')'); + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + } + } + } + + // From the componentbuilder_dynamic_get table. + $query->select($db->quoteName('g.name','main_get_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_dynamic_get', 'g') . ' ON (' . $db->quoteName('a.main_get') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.system_name LIKE '.$search.' OR a.name LIKE '.$search.' OR a.description LIKE '.$search.' OR a.main_get LIKE '.$search.' OR g.name LIKE '.$search.' OR a.codename LIKE '.$search.' OR a.context LIKE '.$search.')'); + } + } + + // Filter by Main_get. + $_main_get = $this->getState('filter.main_get'); + if (is_numeric($_main_get)) + { + if (is_float($_main_get)) + { + $query->where('a.main_get = ' . (float) $_main_get); + } + else + { + $query->where('a.main_get = ' . (int) $_main_get); + } + } + elseif (StringHelper::check($_main_get)) + { + $query->where('a.main_get = ' . $db->quote($db->escape($_main_get))); + } + elseif (UtilitiesArrayHelper::check($_main_get)) + { + // Secure the array for the query + $_main_get = array_map( function ($val) use(&$db) { + if (is_numeric($val)) + { + if (is_float($val)) + { + return (float) $val; + } + else + { + return (int) $val; + } + } + elseif (StringHelper::check($val)) + { + return $db->quote($db->escape($val)); + } + }, $_main_get); + // Filter by the Main_get Array. + $query->where('a.main_get IN (' . implode(',', $_main_get) . ')'); + } + // Filter by Add_php_ajax. + $_add_php_ajax = $this->getState('filter.add_php_ajax'); + if (is_numeric($_add_php_ajax)) + { + if (is_float($_add_php_ajax)) + { + $query->where('a.add_php_ajax = ' . (float) $_add_php_ajax); + } + else + { + $query->where('a.add_php_ajax = ' . (int) $_add_php_ajax); + } + } + elseif (StringHelper::check($_add_php_ajax)) + { + $query->where('a.add_php_ajax = ' . $db->quote($db->escape($_add_php_ajax))); + } + // Filter by Add_custom_button. + $_add_custom_button = $this->getState('filter.add_custom_button'); + if (is_numeric($_add_custom_button)) + { + if (is_float($_add_custom_button)) + { + $query->where('a.add_custom_button = ' . (float) $_add_custom_button); + } + else + { + $query->where('a.add_custom_button = ' . (int) $_add_custom_button); + } + } + elseif (StringHelper::check($_add_custom_button)) + { + $query->where('a.add_custom_button = ' . $db->quote($db->escape($_add_custom_button))); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get list export data. + * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExportData($pks, $user = null) + { + // setup the query + if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks) + { + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + $_export = true; + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_custom_admin_view table + $query->from($db->quoteName('#__componentbuilder_custom_admin_view', 'a')); + // The bulk export path + if ('bulk' === $pks) + { + $query->where('a.id > 0'); + } + // A large array of ID's will not work out well + elseif ($pks_size > 500) + { + // Use lowest ID + $query->where('a.id >= ' . (int) min($pks)); + // Use highest ID + $query->where('a.id <= ' . (int) max($pks)); + } + // The normal default path + else + { + $query->where('a.id IN (' . implode(',',$pks) . ')'); + } + + // do not use these filters in the export method + if (!isset($_export) || !$_export) + { + // Filtering "joomla components" + $filter_joomla_component = $this->state->get("filter.joomla_component"); + if ($filter_joomla_component !== null && !empty($filter_joomla_component)) + { + if (($ids = JCBFilterHelper::linked((int) $filter_joomla_component, 'joomla_component_custom_admin_views')) !== null) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')'); + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + } + } + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.id desc'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('custom_admin_view.access', 'com_componentbuilder.custom_admin_view.' . (int) $item->id) && $user->authorise('custom_admin_view.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // decode css_document + $item->css_document = base64_decode($item->css_document); + // decode css + $item->css = base64_decode($item->css); + // decode js_document + $item->js_document = base64_decode($item->js_document); + // decode javascript_file + $item->javascript_file = base64_decode($item->javascript_file); + // decode default + $item->default = base64_decode($item->default); + // decode php_ajaxmethod + $item->php_ajaxmethod = base64_decode($item->php_ajaxmethod); + // decode php_document + $item->php_document = base64_decode($item->php_document); + // decode php_view + $item->php_view = base64_decode($item->php_view); + // decode php_jview_display + $item->php_jview_display = base64_decode($item->php_jview_display); + // decode php_jview + $item->php_jview = base64_decode($item->php_jview); + // decode php_controller + $item->php_controller = base64_decode($item->php_controller); + // decode php_model + $item->php_model = base64_decode($item->php_model); + // unset the values we don't want exported. + unset($item->asset_id); + unset($item->checked_out); + unset($item->checked_out_time); + } + } + // Add headers to items array. + $headers = $this->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + array_unshift($items,$headers); + } + return $items; + } + } + 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 = Factory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_custom_admin_view"); + if (UtilitiesArrayHelper::check($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; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + // Check if the value is an array + $_main_get = $this->getState('filter.main_get'); + if (UtilitiesArrayHelper::check($_main_get)) + { + $id .= ':' . implode(':', $_main_get); + } + // Check if this is only an number or string + elseif (is_numeric($_main_get) + || StringHelper::check($_main_get)) + { + $id .= ':' . $_main_get; + } + $id .= ':' . $this->getState('filter.add_php_ajax'); + $id .= ':' . $this->getState('filter.add_custom_button'); + $id .= ':' . $this->getState('filter.system_name'); + $id .= ':' . $this->getState('filter.name'); + $id .= ':' . $this->getState('filter.description'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_custom_admin_view')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_custom_admin_view'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Custom_codeModel.php b/admin/src/Model/Custom_codeModel.php new file mode 100644 index 000000000..750772959 --- /dev/null +++ b/admin/src/Model/Custom_codeModel.php @@ -0,0 +1,1136 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Custom_code Admin Model + * + * @since 1.6 + */ +class Custom_codeModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'comment_type', + 'component', + 'type', + 'hashtarget' + ), + 'right' => array( + 'from_line', + 'to_line', + 'hashendtarget' + ), + 'fullwidth' => array( + 'path', + 'note_jcb_placeholder', + 'code', + 'note_placeholders_explained' + ), + 'above' => array( + 'target', + 'system_name', + 'joomla_version', + 'function_name' + ), + 'under' => array( + 'not_required' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/custom_code.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/custom_code.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.custom_code'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'custom_code', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('custom_code__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'custom_code__'.$id); + ComponentbuilderHelper::set('custom_code__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->code)) + { + // base64 Decode code. + $item->code = base64_decode($item->code); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('custom_code__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'custom_code__'.$id); + ComponentbuilderHelper::set('custom_code__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.custom_code', 'custom_code', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('custom_code.edit.state', 'com_componentbuilder.custom_code.' . (int) $id)) + || ($id == 0 && !$user->authorise('custom_code.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('custom_code.edit.created_by', 'com_componentbuilder.custom_code.' . (int) $id)) + || ($id == 0 && !$user->authorise('custom_code.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('custom_code.edit.created', 'com_componentbuilder.custom_code.' . (int) $id)) + || ($id == 0 && !$user->authorise('custom_code.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update all editors to use this components global editor + $global_editor = ComponentHelper::getParams('com_componentbuilder')->get('editor', 'none'); + // now get all the editor fields + $editors = $form->getXml()->xpath("//field[@type='editor']"); + // check if we found any + if (UtilitiesArrayHelper::check($editors)) + { + foreach ($editors as $editor) + { + // get the field names + $name = (string) $editor['name']; + // set the field editor value (with none as fallback) + $form->setFieldAttribute($name, 'editor', $global_editor . '|none'); + } + } + + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('custom_code.delete', 'com_componentbuilder.custom_code.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('custom_code.edit.state', 'com_componentbuilder.custom_code.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('custom_code.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('custom_code.edit', 'com_componentbuilder.custom_code.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('custom_code.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_custom_code')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.custom_code.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.custom_code', $data); + + return $data; + } + + /** + * Method to validate the form data. + * + * @param JForm $form The form to validate against. + * @param array $data The data to validate. + * @param string $group The name of the field group to validate. + * + * @return mixed Array of filtered data if valid, false otherwise. + * + * @see JFormRule + * @see JFilterInput + * @since 12.2 + */ + public function validate($form, $data, $group = null) + { + // check if the not_required field is set + if (isset($data['not_required']) && UtilitiesStringHelper::check($data['not_required'])) + { + $requiredFields = (array) explode(',',(string) $data['not_required']); + $requiredFields = array_unique($requiredFields); + // now change the required field attributes value + foreach ($requiredFields as $requiredField) + { + // make sure there is a string value + if (UtilitiesStringHelper::check($requiredField)) + { + // change to false + $form->setFieldAttribute($requiredField, 'required', 'false'); + // also clear the data set + $data[$requiredField] = ''; + } + } + } + return parent::validate($form, $data, $group); + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('custom_code'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('custom_code'); + } + + if (!$this->canDo->get('custom_code.create') && !$this->canDo->get('custom_code.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('custom_code.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('custom_code.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->component) && !is_numeric($this->table->component)) + { + $this->table->component = $this->generateUnique('component',$this->table->component); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('custom_code'); + } + + if (!$this->canDo->get('custom_code.edit') && !$this->canDo->get('custom_code.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('custom_code.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('custom_code.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // few checks with the new option of using custom code in custom code + if (isset($data['code']) && ($placeholders = GetHelper::allBetween($data['code'], '[CUSTOM' . 'CODE=', ']')) + && UtilitiesArrayHelper::check($placeholders)) + { + // make sure custom code as Hash (automation) target does not have other custom code placeholders + if (isset($data['target']) && 1 == $data['target']) + { + foreach ($placeholders as $placeholder) + { + $data['code'] = str_replace('[CUSTOM' . 'CODE=' . $placeholder . ']', '', $data['code']); + } + // set title + $title = (count($placeholders) == 1) ? Text::_('COM_COMPONENTBUILDER_PLACEHOLDER_REMOVED') : Text::_('COM_COMPONENTBUILDER_PLACEHOLDERS_REMOVED'); + // show message that we have had to remove the custom placeholders + Factory::getApplication()->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_HTHREESHTHREEPCUSTOM_CODE_CAN_ONLY_BE_USED_IN_OTHER_CUSTOM_CODE_IF_SET_AS_BJCB_MANUALB_YOU_CAN_NOT_ADD_THEM_TO_EMHASH_AUTOMATIONEM_CODE_AT_THIS_POINTP', $title), 'Warning'); + } + // make sure that the same custom code is not added to itself + else + { + foreach ($placeholders as $placeholder) + { + // strip the placeholder down to just the function name + $_placeholder = (array) explode('+', $placeholder); + if ($_placeholder[0] === $data['function_name']) + { + $data['code'] = str_replace('[CUSTOM' . 'CODE=' . $placeholder . ']', '', $data['code']); + // show message that we have had to remove the custom placeholders + Factory::getApplication()->enqueueMessage(Text::_('COM_COMPONENTBUILDER_HTHREEPLACEHOLDER_REMOVEDHTHREEPBTHISB_CUSTOM_CODE_CAN_ONLY_BE_USED_IN_BOTHERB_CUSTOM_CODE_NOT_IN_IT_SELF_SINCE_THAT_WILL_CAUSE_A_INFINITE_LOOP_IN_THE_COMPILERP'), 'Warning'); + // stop the loop :) + break; + } + } + } + } + + // Set the code string to base64 string. + if (isset($data['code'])) + { + $data['code'] = base64_encode($data['code']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Custom_codesModel.php b/admin/src/Model/Custom_codesModel.php new file mode 100644 index 000000000..3e09be167 --- /dev/null +++ b/admin/src/Model/Custom_codesModel.php @@ -0,0 +1,748 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Custom_codes List Model + * + * @since 1.6 + */ +class Custom_codesModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/custom_codes.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'g.system_name','component', + 'a.target','target', + 'a.type','type', + 'a.comment_type','comment_type', + 'a.path','path', + 'a.joomla_version','joomla_version' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $component = $this->getUserStateFromRequest($this->context . '.filter.component', 'filter_component'); + if ($formSubmited) + { + $component = $app->input->post->get('component'); + $this->setState('filter.component', $component); + } + + $target = $this->getUserStateFromRequest($this->context . '.filter.target', 'filter_target'); + if ($formSubmited) + { + $target = $app->input->post->get('target'); + $this->setState('filter.target', $target); + } + + $type = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type'); + if ($formSubmited) + { + $type = $app->input->post->get('type'); + $this->setState('filter.type', $type); + } + + $comment_type = $this->getUserStateFromRequest($this->context . '.filter.comment_type', 'filter_comment_type'); + if ($formSubmited) + { + $comment_type = $app->input->post->get('comment_type'); + $this->setState('filter.comment_type', $comment_type); + } + + $path = $this->getUserStateFromRequest($this->context . '.filter.path', 'filter_path'); + if ($formSubmited) + { + $path = $app->input->post->get('path'); + $this->setState('filter.path', $path); + } + + $joomla_version = $this->getUserStateFromRequest($this->context . '.filter.joomla_version', 'filter_joomla_version'); + if ($formSubmited) + { + $joomla_version = $app->input->post->get('joomla_version'); + $this->setState('filter.joomla_version', $joomla_version); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('custom_code.access', 'com_componentbuilder.custom_code.' . (int) $item->id) && $user->authorise('custom_code.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // [1641]=> Target (code action) + $item->target_code = $item->target; + } + } + + if (UtilitiesArrayHelper::check($items) && !isset($_export)) + { + foreach ($items as $nr => &$item) + { + if ($item->target == 2) + { + $item->component_system_name = $item->system_name; + $item->path = '[CUSTO'.'MCODE='.$item->id.']'; // so it is not detected + if (StringHelper::check($item->function_name)) + { + $item->path = '[CUSTO'.'MCODE='.$item->function_name.']'; // so it is not detected + } + $item->type = 2; + } + } + } + + // set selection value to a translatable value + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // convert target + $item->target = $this->selectionTranslation($item->target, 'target'); + // convert type + $item->type = $this->selectionTranslation($item->type, 'type'); + // convert comment_type + $item->comment_type = $this->selectionTranslation($item->comment_type, 'comment_type'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return string The translatable string. + */ + public function selectionTranslation($value,$name) + { + // Array of target language strings + if ($name === 'target') + { + $targetArray = array( + 2 => 'COM_COMPONENTBUILDER_CUSTOM_CODE_JCB_MANUAL', + 1 => 'COM_COMPONENTBUILDER_CUSTOM_CODE_HASH_AUTOMATION' + ); + // Now check if value is found in this array + if (isset($targetArray[$value]) && StringHelper::check($targetArray[$value])) + { + return $targetArray[$value]; + } + } + // Array of type language strings + if ($name === 'type') + { + $typeArray = array( + 1 => 'COM_COMPONENTBUILDER_CUSTOM_CODE_REPLACEMENT', + 2 => 'COM_COMPONENTBUILDER_CUSTOM_CODE_INSERTION' + ); + // Now check if value is found in this array + if (isset($typeArray[$value]) && StringHelper::check($typeArray[$value])) + { + return $typeArray[$value]; + } + } + // Array of comment_type language strings + if ($name === 'comment_type') + { + $comment_typeArray = array( + 1 => 'COM_COMPONENTBUILDER_CUSTOM_CODE_PHPJS', + 2 => 'COM_COMPONENTBUILDER_CUSTOM_CODE_HTML' + ); + // Now check if value is found in this array + if (isset($comment_typeArray[$value]) && StringHelper::check($comment_typeArray[$value])) + { + return $comment_typeArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_custom_code', 'a')); + + // From the componentbuilder_joomla_component table. + $query->select($db->quoteName('g.system_name','component_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_component', 'g') . ' ON (' . $db->quoteName('a.component') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.component LIKE '.$search.' OR g.system_name LIKE '.$search.' OR a.path LIKE '.$search.' OR a.comment_type LIKE '.$search.' OR a.joomla_version LIKE '.$search.' OR a.function_name LIKE '.$search.' OR a.system_name LIKE '.$search.')'); + } + } + + // Filter by Component. + $_component = $this->getState('filter.component'); + if (is_numeric($_component)) + { + if (is_float($_component)) + { + $query->where('a.component = ' . (float) $_component); + } + else + { + $query->where('a.component = ' . (int) $_component); + } + } + elseif (StringHelper::check($_component)) + { + $query->where('a.component = ' . $db->quote($db->escape($_component))); + } + // Filter by Target. + $_target = $this->getState('filter.target'); + if (is_numeric($_target)) + { + if (is_float($_target)) + { + $query->where('a.target = ' . (float) $_target); + } + else + { + $query->where('a.target = ' . (int) $_target); + } + } + elseif (StringHelper::check($_target)) + { + $query->where('a.target = ' . $db->quote($db->escape($_target))); + } + // Filter by Type. + $_type = $this->getState('filter.type'); + if (is_numeric($_type)) + { + if (is_float($_type)) + { + $query->where('a.type = ' . (float) $_type); + } + else + { + $query->where('a.type = ' . (int) $_type); + } + } + elseif (StringHelper::check($_type)) + { + $query->where('a.type = ' . $db->quote($db->escape($_type))); + } + // Filter by Comment_type. + $_comment_type = $this->getState('filter.comment_type'); + if (is_numeric($_comment_type)) + { + if (is_float($_comment_type)) + { + $query->where('a.comment_type = ' . (float) $_comment_type); + } + else + { + $query->where('a.comment_type = ' . (int) $_comment_type); + } + } + elseif (StringHelper::check($_comment_type)) + { + $query->where('a.comment_type = ' . $db->quote($db->escape($_comment_type))); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get list export data. + * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExportData($pks, $user = null) + { + // setup the query + if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks) + { + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + $_export = true; + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_custom_code table + $query->from($db->quoteName('#__componentbuilder_custom_code', 'a')); + // The bulk export path + if ('bulk' === $pks) + { + $query->where('a.id > 0'); + } + // A large array of ID's will not work out well + elseif ($pks_size > 500) + { + // Use lowest ID + $query->where('a.id >= ' . (int) min($pks)); + // Use highest ID + $query->where('a.id <= ' . (int) max($pks)); + } + // The normal default path + else + { + $query->where('a.id IN (' . implode(',',$pks) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.id desc'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('custom_code.access', 'com_componentbuilder.custom_code.' . (int) $item->id) && $user->authorise('custom_code.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // [1641]=> Target (code action) + $item->target_code = $item->target; + // decode code + $item->code = base64_decode($item->code); + // unset the values we don't want exported. + unset($item->asset_id); + unset($item->checked_out); + unset($item->checked_out_time); + } + } + // Add headers to items array. + $headers = $this->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + array_unshift($items,$headers); + } + + if (UtilitiesArrayHelper::check($items) && !isset($_export)) + { + foreach ($items as $nr => &$item) + { + if ($item->target == 2) + { + $item->component_system_name = $item->system_name; + $item->path = '[CUSTO'.'MCODE='.$item->id.']'; // so it is not detected + if (StringHelper::check($item->function_name)) + { + $item->path = '[CUSTO'.'MCODE='.$item->function_name.']'; // so it is not detected + } + $item->type = 2; + } + } + } + return $items; + } + } + 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 = Factory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_custom_code"); + if (UtilitiesArrayHelper::check($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; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.component'); + $id .= ':' . $this->getState('filter.target'); + $id .= ':' . $this->getState('filter.type'); + $id .= ':' . $this->getState('filter.comment_type'); + $id .= ':' . $this->getState('filter.path'); + $id .= ':' . $this->getState('filter.joomla_version'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_custom_code')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_custom_code'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Dynamic_getModel.php b/admin/src/Model/Dynamic_getModel.php new file mode 100644 index 000000000..e374197b1 --- /dev/null +++ b/admin/src/Model/Dynamic_getModel.php @@ -0,0 +1,1446 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Dynamic_get Admin Model + * + * @since 1.6 + */ +class Dynamic_getModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'main' => array( + 'left' => array( + 'main_source', + 'view_table_main', + 'db_table_main', + 'select_all', + 'view_selection', + 'db_selection' + ), + 'right' => array( + 'plugin_events' + ), + 'fullwidth' => array( + 'php_custom_get', + 'note_linked_to_notice' + ), + 'above' => array( + 'name', + 'gettype', + 'getcustom', + 'pagination' + ), + 'under' => array( + 'not_required' + ) + ), + 'abacus' => array( + 'left' => array( + 'addcalculation' + ), + 'fullwidth' => array( + 'note_calculation_item', + 'note_calculation_items', + 'php_calculation' + ) + ), + 'custom_script' => array( + 'fullwidth' => array( + 'add_php_before_getitem', + 'php_before_getitem', + 'add_php_after_getitem', + 'php_after_getitem', + 'add_php_getlistquery', + 'php_getlistquery', + 'add_php_before_getitems', + 'php_before_getitems', + 'add_php_after_getitems', + 'php_after_getitems', + 'add_php_router_parse', + 'php_router_parse_notice', + 'php_router_parse' + ) + ), + 'joint' => array( + 'fullwidth' => array( + 'join_view_table', + 'join_db_table' + ) + ), + 'tweak' => array( + 'fullwidth' => array( + 'filter', + 'where', + 'order', + 'group', + 'global' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/dynamic_get.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/dynamic_get.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.dynamic_get'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'dynamic_get', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('dynamic_get__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'dynamic_get__'.$id); + ComponentbuilderHelper::set('dynamic_get__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->php_calculation)) + { + // base64 Decode php_calculation. + $item->php_calculation = base64_decode($item->php_calculation); + } + + if (!empty($item->php_router_parse)) + { + // base64 Decode php_router_parse. + $item->php_router_parse = base64_decode($item->php_router_parse); + } + + if (!empty($item->php_custom_get)) + { + // base64 Decode php_custom_get. + $item->php_custom_get = base64_decode($item->php_custom_get); + } + + if (!empty($item->php_before_getitem)) + { + // base64 Decode php_before_getitem. + $item->php_before_getitem = base64_decode($item->php_before_getitem); + } + + if (!empty($item->php_after_getitem)) + { + // base64 Decode php_after_getitem. + $item->php_after_getitem = base64_decode($item->php_after_getitem); + } + + if (!empty($item->php_getlistquery)) + { + // base64 Decode php_getlistquery. + $item->php_getlistquery = base64_decode($item->php_getlistquery); + } + + if (!empty($item->php_before_getitems)) + { + // base64 Decode php_before_getitems. + $item->php_before_getitems = base64_decode($item->php_before_getitems); + } + + if (!empty($item->php_after_getitems)) + { + // base64 Decode php_after_getitems. + $item->php_after_getitems = base64_decode($item->php_after_getitems); + } + + if (!empty($item->join_db_table)) + { + // Convert the join_db_table field to an array. + $join_db_table = new Registry; + $join_db_table->loadString($item->join_db_table); + $item->join_db_table = $join_db_table->toArray(); + } + + if (!empty($item->filter)) + { + // Convert the filter field to an array. + $filter = new Registry; + $filter->loadString($item->filter); + $item->filter = $filter->toArray(); + } + + if (!empty($item->where)) + { + // Convert the where field to an array. + $where = new Registry; + $where->loadString($item->where); + $item->where = $where->toArray(); + } + + if (!empty($item->order)) + { + // Convert the order field to an array. + $order = new Registry; + $order->loadString($item->order); + $item->order = $order->toArray(); + } + + if (!empty($item->group)) + { + // Convert the group field to an array. + $group = new Registry; + $group->loadString($item->group); + $item->group = $group->toArray(); + } + + if (!empty($item->global)) + { + // Convert the global field to an array. + $global = new Registry; + $global->loadString($item->global); + $item->global = $global->toArray(); + } + + if (!empty($item->join_view_table)) + { + // Convert the join_view_table field to an array. + $join_view_table = new Registry; + $join_view_table->loadString($item->join_view_table); + $item->join_view_table = $join_view_table->toArray(); + } + + if (!empty($item->plugin_events)) + { + // JSON Decode plugin_events. + $item->plugin_events = json_decode($item->plugin_events); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('dynamic_get__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'dynamic_get__'.$id); + ComponentbuilderHelper::set('dynamic_get__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + + // update the fields + $objectUpdate = new \stdClass(); + $objectUpdate->id = (int) $item->id; + // repeatable values to check + $arrayChecker = array( + 'join_view_table' => 'view_table', + 'join_db_table' => 'db_table', + 'filter' => 'filter_type', + 'where' => 'table_key', + 'order' => 'table_key', + 'global' => 'name' + ); + foreach ($arrayChecker as $_value => $checker) + { + // check what type of array we have here (should be subform... but just in case) + // This could happen due to huge data sets + if (isset($item->{$_value}) && isset($item->{$_value}[$checker])) + { + $bucket = array(); + foreach($item->{$_value} as $option => $values) + { + foreach($values as $nr => $value) + { + $bucket[$_value.$nr][$option] = $value; + } + } + $item->{$_value} = $bucket; + $objectUpdate->{$_value} = json_encode($bucket); + } + } + // be sure to update the table if we found repeatable fields that are still not converted + if (count((array) $objectUpdate) > 1) + { + $this->_db->updateObject('#__componentbuilder_dynamic_get', $objectUpdate, 'id'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.dynamic_get', 'dynamic_get', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('dynamic_get.edit.state', 'com_componentbuilder.dynamic_get.' . (int) $id)) + || ($id == 0 && !$user->authorise('dynamic_get.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if (!$user->authorise('core.edit.created_by', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if (!$user->authorise('core.edit.created', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update all editors to use this components global editor + $global_editor = ComponentHelper::getParams('com_componentbuilder')->get('editor', 'none'); + // now get all the editor fields + $editors = $form->getXml()->xpath("//field[@type='editor']"); + // check if we found any + if (UtilitiesArrayHelper::check($editors)) + { + foreach ($editors as $editor) + { + // get the field names + $name = (string) $editor['name']; + // set the field editor value (with none as fallback) + $form->setFieldAttribute($name, 'editor', $global_editor . '|none'); + } + } + + + // Only load the GUID if new item (or empty) + if (0 == $id || !($val = $form->getValue('guid'))) + { + $form->setValue('guid', null, GuidHelper::get()); + } + + + // update the join_view_table (sub form) layout + $form->setFieldAttribute('join_view_table', 'layout', ComponentbuilderHelper::getSubformLayout('dynamic_get', 'join_view_table')); + + // update the join_db_table (sub form) layout + $form->setFieldAttribute('join_db_table', 'layout', ComponentbuilderHelper::getSubformLayout('dynamic_get', 'join_db_table')); + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('dynamic_get.delete', 'com_componentbuilder.dynamic_get.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('dynamic_get.edit.state', 'com_componentbuilder.dynamic_get.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('dynamic_get.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('dynamic_get.edit', 'com_componentbuilder.dynamic_get.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('dynamic_get.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_dynamic_get')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.dynamic_get.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.dynamic_get', $data); + + return $data; + } + + /** + * Method to validate the form data. + * + * @param JForm $form The form to validate against. + * @param array $data The data to validate. + * @param string $group The name of the field group to validate. + * + * @return mixed Array of filtered data if valid, false otherwise. + * + * @see JFormRule + * @see JFilterInput + * @since 12.2 + */ + public function validate($form, $data, $group = null) + { + // check if the not_required field is set + if (isset($data['not_required']) && UtilitiesStringHelper::check($data['not_required'])) + { + $requiredFields = (array) explode(',',(string) $data['not_required']); + $requiredFields = array_unique($requiredFields); + // now change the required field attributes value + foreach ($requiredFields as $requiredField) + { + // make sure there is a string value + if (UtilitiesStringHelper::check($requiredField)) + { + // change to false + $form->setFieldAttribute($requiredField, 'required', 'false'); + // also clear the data set + $data[$requiredField] = ''; + } + } + } + return parent::validate($form, $data, $group); + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return array('guid'); + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('dynamic_get'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('dynamic_get'); + } + + if (!$this->canDo->get('dynamic_get.create') && !$this->canDo->get('dynamic_get.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('dynamic_get.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('dynamic_get.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->name) && !is_numeric($this->table->name)) + { + $this->table->name = $this->generateUnique('name',$this->table->name); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('dynamic_get'); + } + + if (!$this->canDo->get('dynamic_get.edit') && !$this->canDo->get('dynamic_get.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('dynamic_get.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('dynamic_get.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // Set the GUID if empty or not valid + if (empty($data['guid']) && $data['id'] > 0) + { + // get the existing one + $data['guid'] = (string) GetHelper::var('dynamic_get', $data['id'], 'id', 'guid'); + } + + // Set the GUID if empty or not valid + while (!GuidHelper::valid($data['guid'], "dynamic_get", $data['id'])) + { + // must always be set + $data['guid'] = (string) GuidHelper::get(); + } + + // Set the join_db_table items to data. + if (isset($data['join_db_table']) && is_array($data['join_db_table'])) + { + $join_db_table = new Registry; + $join_db_table->loadArray($data['join_db_table']); + $data['join_db_table'] = (string) $join_db_table; + } + elseif (!isset($data['join_db_table'])) + { + // Set the empty join_db_table to data + $data['join_db_table'] = ''; + } + + // Set the filter items to data. + if (isset($data['filter']) && is_array($data['filter'])) + { + $filter = new Registry; + $filter->loadArray($data['filter']); + $data['filter'] = (string) $filter; + } + elseif (!isset($data['filter'])) + { + // Set the empty filter to data + $data['filter'] = ''; + } + + // Set the where items to data. + if (isset($data['where']) && is_array($data['where'])) + { + $where = new Registry; + $where->loadArray($data['where']); + $data['where'] = (string) $where; + } + elseif (!isset($data['where'])) + { + // Set the empty where to data + $data['where'] = ''; + } + + // Set the order items to data. + if (isset($data['order']) && is_array($data['order'])) + { + $order = new Registry; + $order->loadArray($data['order']); + $data['order'] = (string) $order; + } + elseif (!isset($data['order'])) + { + // Set the empty order to data + $data['order'] = ''; + } + + // Set the group items to data. + if (isset($data['group']) && is_array($data['group'])) + { + $group = new Registry; + $group->loadArray($data['group']); + $data['group'] = (string) $group; + } + elseif (!isset($data['group'])) + { + // Set the empty group to data + $data['group'] = ''; + } + + // Set the global items to data. + if (isset($data['global']) && is_array($data['global'])) + { + $global = new Registry; + $global->loadArray($data['global']); + $data['global'] = (string) $global; + } + elseif (!isset($data['global'])) + { + // Set the empty global to data + $data['global'] = ''; + } + + // Set the join_view_table items to data. + if (isset($data['join_view_table']) && is_array($data['join_view_table'])) + { + $join_view_table = new Registry; + $join_view_table->loadArray($data['join_view_table']); + $data['join_view_table'] = (string) $join_view_table; + } + elseif (!isset($data['join_view_table'])) + { + // Set the empty join_view_table to data + $data['join_view_table'] = ''; + } + + // Set the plugin_events string to JSON string. + if (isset($data['plugin_events'])) + { + $data['plugin_events'] = (string) json_encode($data['plugin_events']); + } + + // Set the php_calculation string to base64 string. + if (isset($data['php_calculation'])) + { + $data['php_calculation'] = base64_encode($data['php_calculation']); + } + + // Set the php_router_parse string to base64 string. + if (isset($data['php_router_parse'])) + { + $data['php_router_parse'] = base64_encode($data['php_router_parse']); + } + + // Set the php_custom_get string to base64 string. + if (isset($data['php_custom_get'])) + { + $data['php_custom_get'] = base64_encode($data['php_custom_get']); + } + + // Set the php_before_getitem string to base64 string. + if (isset($data['php_before_getitem'])) + { + $data['php_before_getitem'] = base64_encode($data['php_before_getitem']); + } + + // Set the php_after_getitem string to base64 string. + if (isset($data['php_after_getitem'])) + { + $data['php_after_getitem'] = base64_encode($data['php_after_getitem']); + } + + // Set the php_getlistquery string to base64 string. + if (isset($data['php_getlistquery'])) + { + $data['php_getlistquery'] = base64_encode($data['php_getlistquery']); + } + + // Set the php_before_getitems string to base64 string. + if (isset($data['php_before_getitems'])) + { + $data['php_before_getitems'] = base64_encode($data['php_before_getitems']); + } + + // Set the php_after_getitems string to base64 string. + if (isset($data['php_after_getitems'])) + { + $data['php_after_getitems'] = base64_encode($data['php_after_getitems']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Dynamic_getsModel.php b/admin/src/Model/Dynamic_getsModel.php new file mode 100644 index 000000000..b4f6d5574 --- /dev/null +++ b/admin/src/Model/Dynamic_getsModel.php @@ -0,0 +1,648 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Dynamic_gets List Model + * + * @since 1.6 + */ +class Dynamic_getsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/dynamic_gets.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.main_source','main_source', + 'a.gettype','gettype', + 'a.name','name' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $main_source = $this->getUserStateFromRequest($this->context . '.filter.main_source', 'filter_main_source'); + if ($formSubmited) + { + $main_source = $app->input->post->get('main_source'); + $this->setState('filter.main_source', $main_source); + } + + $gettype = $this->getUserStateFromRequest($this->context . '.filter.gettype', 'filter_gettype'); + if ($formSubmited) + { + $gettype = $app->input->post->get('gettype'); + $this->setState('filter.gettype', $gettype); + } + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('dynamic_get.access', 'com_componentbuilder.dynamic_get.' . (int) $item->id) && $user->authorise('dynamic_get.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // set selection value to a translatable value + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // convert main_source + $item->main_source = $this->selectionTranslation($item->main_source, 'main_source'); + // convert gettype + $item->gettype = $this->selectionTranslation($item->gettype, 'gettype'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return string The translatable string. + */ + public function selectionTranslation($value,$name) + { + // Array of main_source language strings + if ($name === 'main_source') + { + $main_sourceArray = array( + 0 => 'COM_COMPONENTBUILDER_DYNAMIC_GET_PLEASE_SELECT', + 1 => 'COM_COMPONENTBUILDER_DYNAMIC_GET_BACKEND_VIEW', + 2 => 'COM_COMPONENTBUILDER_DYNAMIC_GET_JOOMLA_DATABASE', + 3 => 'COM_COMPONENTBUILDER_DYNAMIC_GET_CUSTOM' + ); + // Now check if value is found in this array + if (isset($main_sourceArray[$value]) && StringHelper::check($main_sourceArray[$value])) + { + return $main_sourceArray[$value]; + } + } + // Array of gettype language strings + if ($name === 'gettype') + { + $gettypeArray = array( + 1 => 'COM_COMPONENTBUILDER_DYNAMIC_GET_GETITEM', + 2 => 'COM_COMPONENTBUILDER_DYNAMIC_GET_GETLISTQUERY', + 3 => 'COM_COMPONENTBUILDER_DYNAMIC_GET_GETCUSTOM', + 4 => 'COM_COMPONENTBUILDER_DYNAMIC_GET_GETCUSTOMS' + ); + // Now check if value is found in this array + if (isset($gettypeArray[$value]) && StringHelper::check($gettypeArray[$value])) + { + return $gettypeArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_dynamic_get', 'a')); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.' OR a.main_source LIKE '.$search.' OR a.gettype LIKE '.$search.')'); + } + } + + // Filter by Main_source. + $_main_source = $this->getState('filter.main_source'); + if (is_numeric($_main_source)) + { + if (is_float($_main_source)) + { + $query->where('a.main_source = ' . (float) $_main_source); + } + else + { + $query->where('a.main_source = ' . (int) $_main_source); + } + } + elseif (StringHelper::check($_main_source)) + { + $query->where('a.main_source = ' . $db->quote($db->escape($_main_source))); + } + // Filter by Gettype. + $_gettype = $this->getState('filter.gettype'); + if (is_numeric($_gettype)) + { + if (is_float($_gettype)) + { + $query->where('a.gettype = ' . (float) $_gettype); + } + else + { + $query->where('a.gettype = ' . (int) $_gettype); + } + } + elseif (StringHelper::check($_gettype)) + { + $query->where('a.gettype = ' . $db->quote($db->escape($_gettype))); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get list export data. + * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExportData($pks, $user = null) + { + // setup the query + if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks) + { + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + $_export = true; + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_dynamic_get table + $query->from($db->quoteName('#__componentbuilder_dynamic_get', 'a')); + // The bulk export path + if ('bulk' === $pks) + { + $query->where('a.id > 0'); + } + // A large array of ID's will not work out well + elseif ($pks_size > 500) + { + // Use lowest ID + $query->where('a.id >= ' . (int) min($pks)); + // Use highest ID + $query->where('a.id <= ' . (int) max($pks)); + } + // The normal default path + else + { + $query->where('a.id IN (' . implode(',',$pks) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.id desc'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('dynamic_get.access', 'com_componentbuilder.dynamic_get.' . (int) $item->id) && $user->authorise('dynamic_get.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // decode php_calculation + $item->php_calculation = base64_decode($item->php_calculation); + // decode php_router_parse + $item->php_router_parse = base64_decode($item->php_router_parse); + // decode php_custom_get + $item->php_custom_get = base64_decode($item->php_custom_get); + // decode php_before_getitem + $item->php_before_getitem = base64_decode($item->php_before_getitem); + // decode php_after_getitem + $item->php_after_getitem = base64_decode($item->php_after_getitem); + // decode php_getlistquery + $item->php_getlistquery = base64_decode($item->php_getlistquery); + // decode php_before_getitems + $item->php_before_getitems = base64_decode($item->php_before_getitems); + // decode php_after_getitems + $item->php_after_getitems = base64_decode($item->php_after_getitems); + // unset the values we don't want exported. + unset($item->asset_id); + unset($item->checked_out); + unset($item->checked_out_time); + } + } + // Add headers to items array. + $headers = $this->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + array_unshift($items,$headers); + } + return $items; + } + } + 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 = Factory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_dynamic_get"); + if (UtilitiesArrayHelper::check($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; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.main_source'); + $id .= ':' . $this->getState('filter.gettype'); + $id .= ':' . $this->getState('filter.name'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_dynamic_get')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_dynamic_get'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/FieldModel.php b/admin/src/Model/FieldModel.php new file mode 100644 index 000000000..4e79bef99 --- /dev/null +++ b/admin/src/Model/FieldModel.php @@ -0,0 +1,1348 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\String\FieldHelper; +use VDM\Joomla\Utilities\String\TypeHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Field Admin Model + * + * @since 1.6 + */ +class FieldModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'set_properties' => array( + 'fullwidth' => array( + 'note_select_field_type', + 'note_filter_information' + ), + 'above' => array( + 'fieldtype', + 'name', + 'catid' + ), + 'under' => array( + 'not_required' + ) + ), + 'database' => array( + 'left' => array( + 'datatype', + 'datalenght', + 'datalenght_other', + 'datadefault', + 'datadefault_other' + ), + 'right' => array( + 'indexes', + 'null_switch', + 'store', + 'medium_encryption_note', + 'basic_encryption_note', + 'note_whmcs_encryption', + 'note_expert_field_save_mode', + 'initiator_on_save_model', + 'initiator_on_get_model', + 'on_save_model_field', + 'on_get_model_field' + ), + 'fullwidth' => array( + 'note_no_database_settings_needed', + 'note_database_settings_needed' + ) + ), + 'type_info' => array( + 'fullwidth' => array( + 'helpnote', + 'xml' + ) + ), + 'scripts' => array( + 'left' => array( + 'add_css_view', + 'css_view', + 'add_css_views', + 'css_views' + ), + 'right' => array( + 'add_javascript_view_footer', + 'javascript_view_footer', + 'add_javascript_views_footer', + 'javascript_views_footer' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/field.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/field.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.field'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'field', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('field__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'field__'.$id); + ComponentbuilderHelper::set('field__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->on_save_model_field)) + { + // base64 Decode on_save_model_field. + $item->on_save_model_field = base64_decode($item->on_save_model_field); + } + + if (!empty($item->initiator_on_get_model)) + { + // base64 Decode initiator_on_get_model. + $item->initiator_on_get_model = base64_decode($item->initiator_on_get_model); + } + + if (!empty($item->initiator_on_save_model)) + { + // base64 Decode initiator_on_save_model. + $item->initiator_on_save_model = base64_decode($item->initiator_on_save_model); + } + + if (!empty($item->css_views)) + { + // base64 Decode css_views. + $item->css_views = base64_decode($item->css_views); + } + + if (!empty($item->css_view)) + { + // base64 Decode css_view. + $item->css_view = base64_decode($item->css_view); + } + + if (!empty($item->on_get_model_field)) + { + // base64 Decode on_get_model_field. + $item->on_get_model_field = base64_decode($item->on_get_model_field); + } + + if (!empty($item->javascript_view_footer)) + { + // base64 Decode javascript_view_footer. + $item->javascript_view_footer = base64_decode($item->javascript_view_footer); + } + + if (!empty($item->javascript_views_footer)) + { + // base64 Decode javascript_views_footer. + $item->javascript_views_footer = base64_decode($item->javascript_views_footer); + } + + if (!empty($item->xml)) + { + // JSON Decode xml. + $item->xml = json_decode($item->xml); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('field__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'field__'.$id); + ComponentbuilderHelper::set('field__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.field', 'field', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('field.edit.state', 'com_componentbuilder.field.' . (int) $id)) + || ($id == 0 && !$user->authorise('field.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if (!$user->authorise('core.edit.created_by', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if (!$user->authorise('core.edit.created', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update all editors to use this components global editor + $global_editor = ComponentHelper::getParams('com_componentbuilder')->get('editor', 'none'); + // now get all the editor fields + $editors = $form->getXml()->xpath("//field[@type='editor']"); + // check if we found any + if (UtilitiesArrayHelper::check($editors)) + { + foreach ($editors as $editor) + { + // get the field names + $name = (string) $editor['name']; + // set the field editor value (with none as fallback) + $form->setFieldAttribute($name, 'editor', $global_editor . '|none'); + } + } + + + // Only load the GUID if new item (or empty) + if (0 == $id || !($val = $form->getValue('guid'))) + { + $form->setValue('guid', null, GuidHelper::get()); + } + + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('field.delete', 'com_componentbuilder.field.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('field.edit.state', 'com_componentbuilder.field.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('field.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('field.edit', 'com_componentbuilder.field.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('field.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_field')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.field.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.field', $data); + + return $data; + } + + /** + * Method to validate the form data. + * + * @param JForm $form The form to validate against. + * @param array $data The data to validate. + * @param string $group The name of the field group to validate. + * + * @return mixed Array of filtered data if valid, false otherwise. + * + * @see JFormRule + * @see JFilterInput + * @since 12.2 + */ + public function validate($form, $data, $group = null) + { + // check if the not_required field is set + if (isset($data['not_required']) && UtilitiesStringHelper::check($data['not_required'])) + { + $requiredFields = (array) explode(',',(string) $data['not_required']); + $requiredFields = array_unique($requiredFields); + // now change the required field attributes value + foreach ($requiredFields as $requiredField) + { + // make sure there is a string value + if (UtilitiesStringHelper::check($requiredField)) + { + // change to false + $form->setFieldAttribute($requiredField, 'required', 'false'); + // also clear the data set + $data[$requiredField] = ''; + } + } + } + return parent::validate($form, $data, $group); + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return array('guid'); + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('field'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('field'); + } + + if (!$this->canDo->get('field.create') && !$this->canDo->get('field.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('field.edit.state')) + { + $values['published'] = 0; + } + + if (isset($values['category']) && (int) $values['category'] > 0 && !static::checkCategoryId($values['category'])) + { + return false; + } + elseif (isset($values['category']) && (int) $values['category'] > 0) + { + // move the category value to correct field name + $values['catid'] = $values['category']; + unset($values['category']); + } + elseif (isset($values['category'])) + { + unset($values['category']); + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('field.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('field'); + } + + if (!$this->canDo->get('field.edit') && !$this->canDo->get('field.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('field.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + if (isset($values['category']) && (int) $values['category'] > 0 && !static::checkCategoryId($values['category'])) + { + return false; + } + elseif (isset($values['category']) && (int) $values['category'] > 0) + { + // move the category value to correct field name + $values['catid'] = $values['category']; + unset($values['category']); + } + elseif (isset($values['category'])) + { + unset($values['category']); + } + + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('field.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // get the properties + $properties = $input->get('properties', null, 'ARRAY'); + // get the extra properties + $extraproperties = $input->get('extraproperties', null, 'ARRAY'); + // get the type php property + $typephp = array(); + foreach (ComponentbuilderHelper::$phpFieldArray as $x) + { + $typephp[$x] = $input->get('property_type_php' . $x, null, 'RAW'); + } + // make sure we have an array + if (UtilitiesArrayHelper::check($properties)) + { + // set the bucket + $bucket = array(); + foreach($properties as $property) + { + // make sure we have the correct values + if (UtilitiesArrayHelper::check($property) && isset($property['name']) && UtilitiesStringHelper::check($property['name']) && (isset($property['value']) || 'default' === $property['name'])) + { + // some fixes, just in case (more can be added) + switch ($property['name']) + { + // fix the values + case 'name': + // check if we have placeholder in name + if (strpos($property['value'], '[[[') !== false || strpos($property['value'], '###') !== false) + { + $property['value'] = trim($property['value']); + } + else + { + $property['value'] = FieldHelper::safe($property['value']); + } + break; + case 'type': + $property['value'] = TypeHelper::safe($property['value']); + break; + } + // load the property + $bucket[] = "\t" . $property['name'] . '="' . str_replace('"', """, $property['value']) . '"'; + } + } + // make sure we have an array + if (UtilitiesArrayHelper::check($extraproperties)) + { + foreach($extraproperties as $xproperty) + { + // make sure we have the correct values + if (UtilitiesArrayHelper::check($xproperty) && isset($xproperty['name']) && UtilitiesStringHelper::check($xproperty['name']) && isset($xproperty['value'])) + { + // load the extra property + $bucket[] = "\t" . UtilitiesStringHelper::safe($xproperty['name']) . '="' . str_replace('"', """, $xproperty['value']) . '"'; + } + } + } + // load the PHP + foreach ($typephp as $x => $phpvalue) + { + // make sure we have a string + if (UtilitiesStringHelper::check($phpvalue)) + { + // load the type_php property + $bucket[] = "\t" . 'type_php' . $x . '_1="__.o0=base64=Oo.__' . base64_encode($phpvalue) . '"'; + } + } + // if the bucket has been loaded + if (UtilitiesArrayHelper::check($bucket)) + { + $data['xml'] = ""; + } + } + + // Set the GUID if empty or not valid + if (empty($data['guid']) && $data['id'] > 0) + { + // get the existing one + $data['guid'] = (string) GetHelper::var('field', $data['id'], 'id', 'guid'); + } + + // Set the GUID if empty or not valid + while (!GuidHelper::valid($data['guid'], "field", $data['id'])) + { + // must always be set + $data['guid'] = (string) GuidHelper::get(); + } + + // Set the xml string to JSON string. + if (isset($data['xml'])) + { + $data['xml'] = (string) json_encode($data['xml']); + } + + // Set the on_save_model_field string to base64 string. + if (isset($data['on_save_model_field'])) + { + $data['on_save_model_field'] = base64_encode($data['on_save_model_field']); + } + + // Set the initiator_on_get_model string to base64 string. + if (isset($data['initiator_on_get_model'])) + { + $data['initiator_on_get_model'] = base64_encode($data['initiator_on_get_model']); + } + + // Set the initiator_on_save_model string to base64 string. + if (isset($data['initiator_on_save_model'])) + { + $data['initiator_on_save_model'] = base64_encode($data['initiator_on_save_model']); + } + + // Set the css_views string to base64 string. + if (isset($data['css_views'])) + { + $data['css_views'] = base64_encode($data['css_views']); + } + + // Set the css_view string to base64 string. + if (isset($data['css_view'])) + { + $data['css_view'] = base64_encode($data['css_view']); + } + + // Set the on_get_model_field string to base64 string. + if (isset($data['on_get_model_field'])) + { + $data['on_get_model_field'] = base64_encode($data['on_get_model_field']); + } + + // Set the javascript_view_footer string to base64 string. + if (isset($data['javascript_view_footer'])) + { + $data['javascript_view_footer'] = base64_encode($data['javascript_view_footer']); + } + + // Set the javascript_views_footer string to base64 string. + if (isset($data['javascript_views_footer'])) + { + $data['javascript_views_footer'] = base64_encode($data['javascript_views_footer']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/FieldsModel.php b/admin/src/Model/FieldsModel.php new file mode 100644 index 000000000..8b2c17cf8 --- /dev/null +++ b/admin/src/Model/FieldsModel.php @@ -0,0 +1,1006 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\FormHelper as JCBFormHelper; +use VDM\Joomla\Componentbuilder\Utilities\FilterHelper as JCBFilterHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Fields List Model + * + * @since 1.6 + */ +class FieldsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/fields.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'g.name','fieldtype', + 'a.datatype','datatype', + 'a.indexes','indexes', + 'a.null_switch','null_switch', + 'a.store','store', + 'c.title','category_title', + 'c.id', 'category_id', + 'a.catid','catid', + 'a.name','name' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Get the filter form - Override the parent method + * + * @param array $data data + * @param boolean $loadData load current data + * + * @return \JForm|boolean The \JForm object or false on error + * + * @since JCB 2.12.5 + */ + public function getFilterForm($data = array(), $loadData = true) + { + // load form from the parent class + $form = parent::getFilterForm($data, $loadData); + + // Create the "extension" filter + $form->setField(new \SimpleXMLElement( + JCBFilterHelper::extensions() + ),'filter'); + $form->setValue( + 'extension', + 'filter', + $this->state->get("filter.extension") + ); + array_push($this->filter_fields, 'extension'); + + // Create the "admin_view" filter + $attributes = array( + 'name' => 'admin_view', + 'type' => 'list', + 'onchange' => 'this.form.submit();', + ); + $options = array( + '' => '- ' . Text::_('COM_COMPONENTBUILDER_NO_ADMIN_VIEWS_FOUND') . ' -' + ); + // check if we have admin views (and limit to an extension if it is set) + if (($admin_views = JCBFilterHelper::names('admin_view', $this->state->get("filter.extension"))) !== null) + { + $options = array( + '' => '- ' . Text::_('COM_COMPONENTBUILDER_SELECT_ADMIN_VIEW') . ' -' + ); + // make sure we do not lose the key values in normal merge + $options = $options + $admin_views; + } + + $form->setField(JCBFormHelper::xml($attributes, $options),'filter'); + $form->setValue( + 'admin_view', + 'filter', + $this->state->get("filter.admin_view") + ); + array_push($this->filter_fields, 'admin_view'); + + return $form; + } + + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $fieldtype = $this->getUserStateFromRequest($this->context . '.filter.fieldtype', 'filter_fieldtype'); + if ($formSubmited) + { + $fieldtype = $app->input->post->get('fieldtype'); + $this->setState('filter.fieldtype', $fieldtype); + } + + $datatype = $this->getUserStateFromRequest($this->context . '.filter.datatype', 'filter_datatype'); + if ($formSubmited) + { + $datatype = $app->input->post->get('datatype'); + $this->setState('filter.datatype', $datatype); + } + + $indexes = $this->getUserStateFromRequest($this->context . '.filter.indexes', 'filter_indexes'); + if ($formSubmited) + { + $indexes = $app->input->post->get('indexes'); + $this->setState('filter.indexes', $indexes); + } + + $null_switch = $this->getUserStateFromRequest($this->context . '.filter.null_switch', 'filter_null_switch'); + if ($formSubmited) + { + $null_switch = $app->input->post->get('null_switch'); + $this->setState('filter.null_switch', $null_switch); + } + + $store = $this->getUserStateFromRequest($this->context . '.filter.store', 'filter_store'); + if ($formSubmited) + { + $store = $app->input->post->get('store'); + $this->setState('filter.store', $store); + } + + $category = $app->getUserStateFromRequest($this->context . '.filter.category', 'filter_category'); + $this->setState('filter.category', $category); + + $categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id'); + $this->setState('filter.category_id', $categoryId); + + $catid = $this->getUserStateFromRequest($this->context . '.filter.catid', 'filter_catid'); + if ($formSubmited) + { + $catid = $app->input->post->get('catid'); + $this->setState('filter.catid', $catid); + } + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('field.access', 'com_componentbuilder.field.' . (int) $item->id) && $user->authorise('field.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // set selection value to a translatable value + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // convert datatype + $item->datatype = $this->selectionTranslation($item->datatype, 'datatype'); + // convert indexes + $item->indexes = $this->selectionTranslation($item->indexes, 'indexes'); + // convert null_switch + $item->null_switch = $this->selectionTranslation($item->null_switch, 'null_switch'); + // convert store + $item->store = $this->selectionTranslation($item->store, 'store'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return string The translatable string. + */ + public function selectionTranslation($value,$name) + { + // Array of datatype language strings + if ($name === 'datatype') + { + $datatypeArray = array( + 0 => 'COM_COMPONENTBUILDER_FIELD_SELECT_AN_OPTION', + 'CHAR' => 'COM_COMPONENTBUILDER_FIELD_CHAR', + 'VARCHAR' => 'COM_COMPONENTBUILDER_FIELD_VARCHAR', + 'TEXT' => 'COM_COMPONENTBUILDER_FIELD_TEXT', + 'MEDIUMTEXT' => 'COM_COMPONENTBUILDER_FIELD_MEDIUMTEXT', + 'LONGTEXT' => 'COM_COMPONENTBUILDER_FIELD_LONGTEXT', + 'BLOB' => 'COM_COMPONENTBUILDER_FIELD_BLOB', + 'TINYBLOB' => 'COM_COMPONENTBUILDER_FIELD_TINYBLOB', + 'MEDIUMBLOB' => 'COM_COMPONENTBUILDER_FIELD_MEDIUMBLOB', + 'LONGBLOB' => 'COM_COMPONENTBUILDER_FIELD_LONGBLOB', + 'DATETIME' => 'COM_COMPONENTBUILDER_FIELD_DATETIME', + 'DATE' => 'COM_COMPONENTBUILDER_FIELD_DATE', + 'TIME' => 'COM_COMPONENTBUILDER_FIELD_TIME', + 'INT' => 'COM_COMPONENTBUILDER_FIELD_INT', + 'TINYINT' => 'COM_COMPONENTBUILDER_FIELD_TINYINT', + 'BIGINT' => 'COM_COMPONENTBUILDER_FIELD_BIGINT', + 'FLOAT' => 'COM_COMPONENTBUILDER_FIELD_FLOAT', + 'DECIMAL' => 'COM_COMPONENTBUILDER_FIELD_DECIMAL', + 'DOUBLE' => 'COM_COMPONENTBUILDER_FIELD_DOUBLE' + ); + // Now check if value is found in this array + if (isset($datatypeArray[$value]) && StringHelper::check($datatypeArray[$value])) + { + return $datatypeArray[$value]; + } + } + // Array of indexes language strings + if ($name === 'indexes') + { + $indexesArray = array( + 1 => 'COM_COMPONENTBUILDER_FIELD_UNIQUE_KEY', + 2 => 'COM_COMPONENTBUILDER_FIELD_KEY', + 0 => 'COM_COMPONENTBUILDER_FIELD_NONE' + ); + // Now check if value is found in this array + if (isset($indexesArray[$value]) && StringHelper::check($indexesArray[$value])) + { + return $indexesArray[$value]; + } + } + // Array of null_switch language strings + if ($name === 'null_switch') + { + $null_switchArray = array( + 'NULL' => 'COM_COMPONENTBUILDER_FIELD_NULL', + 'NOT NULL' => 'COM_COMPONENTBUILDER_FIELD_NOT_NULL' + ); + // Now check if value is found in this array + if (isset($null_switchArray[$value]) && StringHelper::check($null_switchArray[$value])) + { + return $null_switchArray[$value]; + } + } + // Array of store language strings + if ($name === 'store') + { + $storeArray = array( + 0 => 'COM_COMPONENTBUILDER_FIELD_DEFAULT', + 1 => 'COM_COMPONENTBUILDER_FIELD_JSON', + 2 => 'COM_COMPONENTBUILDER_FIELD_BASE64', + 3 => 'COM_COMPONENTBUILDER_FIELD_BASIC_ENCRYPTION_LOCALDBKEY', + 5 => 'COM_COMPONENTBUILDER_FIELD_MEDIUM_ENCRYPTION_LOCALFILEKEY', + 4 => 'COM_COMPONENTBUILDER_FIELD_WHMCSKEY_ENCRYPTION', + 6 => 'COM_COMPONENTBUILDER_FIELD_EXPERT_MODE_CUSTOM' + ); + // Now check if value is found in this array + if (isset($storeArray[$value]) && StringHelper::check($storeArray[$value])) + { + return $storeArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + $query->select($db->quoteName('c.title','category_title')); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_field', 'a')); + $query->join('LEFT', $db->quoteName('#__categories', 'c') . ' ON (' . $db->quoteName('a.catid') . ' = ' . $db->quoteName('c.id') . ')'); + + // do not use these filters in the export method + if (!isset($_export) || !$_export) + { + // Filtering "extension" + $filter_extension = $this->state->get("filter.extension"); + $field_ids = array(); + $get_ids = true; + if ($get_ids && $filter_extension !== null && !empty($filter_extension)) + { + // column name, and id + $type_extension = explode('__', $filter_extension); + if (($ids = JCBFilterHelper::linked((int) $type_extension[1], (string) $type_extension[0])) !== null) + { + $field_ids = $ids; + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + $get_ids = false; + } + } + + // Filtering "admin_view" + $filter_admin_view = $this->state->get("filter.admin_view"); + if ($get_ids && $filter_admin_view !== null && !empty($filter_admin_view)) + { + if (($ids = JCBFilterHelper::linked((int) $filter_admin_view, 'admin_view')) !== null) + { + // view will return less fields, so we ignore the component + $field_ids = $ids; + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + $get_ids = false; + } + } + // now check if we have IDs + if ($get_ids && UtilitiesArrayHelper::check($field_ids)) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $field_ids) . ')'); + } + } + + // From the componentbuilder_fieldtype table. + $query->select($db->quoteName('g.name','fieldtype_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_fieldtype', 'g') . ' ON (' . $db->quoteName('a.fieldtype') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.' OR a.fieldtype LIKE '.$search.' OR g.name LIKE '.$search.' OR a.datatype LIKE '.$search.' OR a.indexes LIKE '.$search.' OR a.null_switch LIKE '.$search.' OR a.store LIKE '.$search.' OR a.catid LIKE '.$search.' OR a.xml LIKE '.$search.')'); + } + } + + // Filter by Fieldtype. + $_fieldtype = $this->getState('filter.fieldtype'); + if (is_numeric($_fieldtype)) + { + if (is_float($_fieldtype)) + { + $query->where('a.fieldtype = ' . (float) $_fieldtype); + } + else + { + $query->where('a.fieldtype = ' . (int) $_fieldtype); + } + } + elseif (StringHelper::check($_fieldtype)) + { + $query->where('a.fieldtype = ' . $db->quote($db->escape($_fieldtype))); + } + // Filter by Datatype. + $_datatype = $this->getState('filter.datatype'); + if (is_numeric($_datatype)) + { + if (is_float($_datatype)) + { + $query->where('a.datatype = ' . (float) $_datatype); + } + else + { + $query->where('a.datatype = ' . (int) $_datatype); + } + } + elseif (StringHelper::check($_datatype)) + { + $query->where('a.datatype = ' . $db->quote($db->escape($_datatype))); + } + // Filter by Indexes. + $_indexes = $this->getState('filter.indexes'); + if (is_numeric($_indexes)) + { + if (is_float($_indexes)) + { + $query->where('a.indexes = ' . (float) $_indexes); + } + else + { + $query->where('a.indexes = ' . (int) $_indexes); + } + } + elseif (StringHelper::check($_indexes)) + { + $query->where('a.indexes = ' . $db->quote($db->escape($_indexes))); + } + // Filter by Null_switch. + $_null_switch = $this->getState('filter.null_switch'); + if (is_numeric($_null_switch)) + { + if (is_float($_null_switch)) + { + $query->where('a.null_switch = ' . (float) $_null_switch); + } + else + { + $query->where('a.null_switch = ' . (int) $_null_switch); + } + } + elseif (StringHelper::check($_null_switch)) + { + $query->where('a.null_switch = ' . $db->quote($db->escape($_null_switch))); + } + // Filter by Store. + $_store = $this->getState('filter.store'); + if (is_numeric($_store)) + { + if (is_float($_store)) + { + $query->where('a.store = ' . (float) $_store); + } + else + { + $query->where('a.store = ' . (int) $_store); + } + } + elseif (StringHelper::check($_store)) + { + $query->where('a.store = ' . $db->quote($db->escape($_store))); + } + + // Filter by a single or group of categories. + $baselevel = 1; + $categoryId = $this->getState('filter.category_id'); + + if (is_numeric($categoryId)) + { + $cat_tbl = Table::getInstance('Category', 'JTable'); + $cat_tbl->load($categoryId); + $rgt = $cat_tbl->rgt; + $lft = $cat_tbl->lft; + $baselevel = (int) $cat_tbl->level; + $query->where('c.lft >= ' . (int) $lft) + ->where('c.rgt <= ' . (int) $rgt); + } + elseif (is_array($categoryId)) + { + $categoryId = ArrayHelper::toInteger($categoryId); + $categoryId = implode(',', $categoryId); + $query->where('a.catid IN (' . $categoryId . ')'); + } + + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get list export data. + * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExportData($pks, $user = null) + { + // setup the query + if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks) + { + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + $_export = true; + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_field table + $query->from($db->quoteName('#__componentbuilder_field', 'a')); + // The bulk export path + if ('bulk' === $pks) + { + $query->where('a.id > 0'); + } + // A large array of ID's will not work out well + elseif ($pks_size > 500) + { + // Use lowest ID + $query->where('a.id >= ' . (int) min($pks)); + // Use highest ID + $query->where('a.id <= ' . (int) max($pks)); + } + // The normal default path + else + { + $query->where('a.id IN (' . implode(',',$pks) . ')'); + } + + // do not use these filters in the export method + if (!isset($_export) || !$_export) + { + // Filtering "extension" + $filter_extension = $this->state->get("filter.extension"); + $field_ids = array(); + $get_ids = true; + if ($get_ids && $filter_extension !== null && !empty($filter_extension)) + { + // column name, and id + $type_extension = explode('__', $filter_extension); + if (($ids = JCBFilterHelper::linked((int) $type_extension[1], (string) $type_extension[0])) !== null) + { + $field_ids = $ids; + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + $get_ids = false; + } + } + + // Filtering "admin_view" + $filter_admin_view = $this->state->get("filter.admin_view"); + if ($get_ids && $filter_admin_view !== null && !empty($filter_admin_view)) + { + if (($ids = JCBFilterHelper::linked((int) $filter_admin_view, 'admin_view')) !== null) + { + // view will return less fields, so we ignore the component + $field_ids = $ids; + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + $get_ids = false; + } + } + // now check if we have IDs + if ($get_ids && UtilitiesArrayHelper::check($field_ids)) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $field_ids) . ')'); + } + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.id desc'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('field.access', 'com_componentbuilder.field.' . (int) $item->id) && $user->authorise('field.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // decode on_save_model_field + $item->on_save_model_field = base64_decode($item->on_save_model_field); + // decode initiator_on_get_model + $item->initiator_on_get_model = base64_decode($item->initiator_on_get_model); + // decode initiator_on_save_model + $item->initiator_on_save_model = base64_decode($item->initiator_on_save_model); + // decode css_views + $item->css_views = base64_decode($item->css_views); + // decode css_view + $item->css_view = base64_decode($item->css_view); + // decode on_get_model_field + $item->on_get_model_field = base64_decode($item->on_get_model_field); + // decode javascript_view_footer + $item->javascript_view_footer = base64_decode($item->javascript_view_footer); + // decode javascript_views_footer + $item->javascript_views_footer = base64_decode($item->javascript_views_footer); + // unset the values we don't want exported. + unset($item->asset_id); + unset($item->checked_out); + unset($item->checked_out_time); + } + } + // Add headers to items array. + $headers = $this->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + array_unshift($items,$headers); + } + return $items; + } + } + 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 = Factory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_field"); + if (UtilitiesArrayHelper::check($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; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.fieldtype'); + $id .= ':' . $this->getState('filter.datatype'); + $id .= ':' . $this->getState('filter.indexes'); + $id .= ':' . $this->getState('filter.null_switch'); + $id .= ':' . $this->getState('filter.store'); + // Check if the value is an array + $_category = $this->getState('filter.category'); + if (UtilitiesArrayHelper::check($_category)) + { + $id .= ':' . implode(':', $_category); + } + // Check if this is only an number or string + elseif (is_numeric($_category) + || StringHelper::check($_category)) + { + $id .= ':' . $_category; + } + // Check if the value is an array + $_category_id = $this->getState('filter.category_id'); + if (UtilitiesArrayHelper::check($_category_id)) + { + $id .= ':' . implode(':', $_category_id); + } + // Check if this is only an number or string + elseif (is_numeric($_category_id) + || StringHelper::check($_category_id)) + { + $id .= ':' . $_category_id; + } + // Check if the value is an array + $_catid = $this->getState('filter.catid'); + if (UtilitiesArrayHelper::check($_catid)) + { + $id .= ':' . implode(':', $_catid); + } + // Check if this is only an number or string + elseif (is_numeric($_catid) + || StringHelper::check($_catid)) + { + $id .= ':' . $_catid; + } + $id .= ':' . $this->getState('filter.name'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_field')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_field'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/FieldtypeModel.php b/admin/src/Model/FieldtypeModel.php new file mode 100644 index 000000000..233428309 --- /dev/null +++ b/admin/src/Model/FieldtypeModel.php @@ -0,0 +1,1415 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Fieldtype Admin Model + * + * @since 1.6 + */ +class FieldtypeModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'catid', + 'short_description' + ), + 'right' => array( + 'description' + ), + 'fullwidth' => array( + 'note_on_fields', + 'properties', + 'not_required' + ), + 'above' => array( + 'name' + ) + ), + 'database_defaults' => array( + 'left' => array( + 'has_defaults', + 'datatype', + 'datalenght', + 'datalenght_other', + 'datadefault', + 'datadefault_other' + ), + 'right' => array( + 'indexes', + 'null_switch', + 'store', + 'basic_encryption_note', + 'medium_encryption_note', + 'note_whmcs_encryption' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/fieldtype.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/fieldtype.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.fieldtype'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'fieldtype', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('fieldtype__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'fieldtype__'.$id); + ComponentbuilderHelper::set('fieldtype__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->properties)) + { + // Convert the properties field to an array. + $properties = new Registry; + $properties->loadString($item->properties); + $item->properties = $properties->toArray(); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('fieldtype__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'fieldtype__'.$id); + ComponentbuilderHelper::set('fieldtype__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + // check what type of properties array we have here (should be subform... but just incase) + // This could happen due to huge data sets + if (isset($item->properties) && isset($item->properties['name'])) + { + $bucket = array(); + foreach($item->properties as $option => $values) + { + foreach($values as $nr => $value) + { + $bucket['addfields'.$nr][$option] = $value; + } + } + $item->properties = $bucket; + // be sure to update the value in the db + $objectUpdate = new \stdClass(); + $objectUpdate->id = (int) $item->id; + $objectUpdate->properties = json_encode($bucket); + $this->db->updateObject('#__componentbuilder_fieldtype', $objectUpdate, 'id'); + } + } + $this->fieldtypevvvv = $item->id; + + return $item; + } + + /** + * Method to get list data. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getVycfields() + { + // Get the user object. + $user = Factory::getApplication()->getIdentity(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + $query->select($db->quoteName('c.title','category_title')); + + // From the componentbuilder_field table + $query->from($db->quoteName('#__componentbuilder_field', 'a')); + $query->join('LEFT', $db->quoteName('#__categories', 'c') . ' ON (' . $db->quoteName('a.catid') . ' = ' . $db->quoteName('c.id') . ')'); + + // do not use these filters in the export method + if (!isset($_export) || !$_export) + { + // Filtering "extension" + $filter_extension = $this->state->get("filter.extension"); + $field_ids = array(); + $get_ids = true; + if ($get_ids && $filter_extension !== null && !empty($filter_extension)) + { + // column name, and id + $type_extension = explode('__', $filter_extension); + if (($ids = JCBFilterHelper::linked((int) $type_extension[1], (string) $type_extension[0])) !== null) + { + $field_ids = $ids; + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + $get_ids = false; + } + } + + // Filtering "admin_view" + $filter_admin_view = $this->state->get("filter.admin_view"); + if ($get_ids && $filter_admin_view !== null && !empty($filter_admin_view)) + { + if (($ids = JCBFilterHelper::linked((int) $filter_admin_view, 'admin_view')) !== null) + { + // view will return less fields, so we ignore the component + $field_ids = $ids; + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + $get_ids = false; + } + } + // now check if we have IDs + if ($get_ids && UtilitiesArrayHelper::check($field_ids)) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $field_ids) . ')'); + } + } + + // From the componentbuilder_fieldtype table. + $query->select($db->quoteName('g.name','fieldtype_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_fieldtype', 'g') . ' ON (' . $db->quoteName('a.fieldtype') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by fieldtypevvvv global. + $fieldtypevvvv = $this->fieldtypevvvv; + if (is_numeric($fieldtypevvvv )) + { + $query->where('a.fieldtype = ' . (int) $fieldtypevvvv ); + } + elseif (is_string($fieldtypevvvv)) + { + $query->where('a.fieldtype = ' . $db->quote($fieldtypevvvv)); + } + else + { + $query->where('a.fieldtype = -5'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.published ASC'); + $query->order('a.ordering ASC'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('field.access', 'com_componentbuilder.field.' . (int) $item->id) && $user->authorise('field.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // set selection value to a translatable value + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // convert datatype + $item->datatype = $this->selectionTranslationVycfields($item->datatype, 'datatype'); + // convert indexes + $item->indexes = $this->selectionTranslationVycfields($item->indexes, 'indexes'); + // convert null_switch + $item->null_switch = $this->selectionTranslationVycfields($item->null_switch, 'null_switch'); + // convert store + $item->store = $this->selectionTranslationVycfields($item->store, 'store'); + } + } + + return $items; + } + return false; + } + + /** + * Method to convert selection values to translatable string. + * + * @return string The translatable string. + */ + public function selectionTranslationVycfields($value,$name) + { + // Array of datatype language strings + if ($name === 'datatype') + { + $datatypeArray = array( + 0 => 'COM_COMPONENTBUILDER_FIELD_SELECT_AN_OPTION', + 'CHAR' => 'COM_COMPONENTBUILDER_FIELD_CHAR', + 'VARCHAR' => 'COM_COMPONENTBUILDER_FIELD_VARCHAR', + 'TEXT' => 'COM_COMPONENTBUILDER_FIELD_TEXT', + 'MEDIUMTEXT' => 'COM_COMPONENTBUILDER_FIELD_MEDIUMTEXT', + 'LONGTEXT' => 'COM_COMPONENTBUILDER_FIELD_LONGTEXT', + 'BLOB' => 'COM_COMPONENTBUILDER_FIELD_BLOB', + 'TINYBLOB' => 'COM_COMPONENTBUILDER_FIELD_TINYBLOB', + 'MEDIUMBLOB' => 'COM_COMPONENTBUILDER_FIELD_MEDIUMBLOB', + 'LONGBLOB' => 'COM_COMPONENTBUILDER_FIELD_LONGBLOB', + 'DATETIME' => 'COM_COMPONENTBUILDER_FIELD_DATETIME', + 'DATE' => 'COM_COMPONENTBUILDER_FIELD_DATE', + 'TIME' => 'COM_COMPONENTBUILDER_FIELD_TIME', + 'INT' => 'COM_COMPONENTBUILDER_FIELD_INT', + 'TINYINT' => 'COM_COMPONENTBUILDER_FIELD_TINYINT', + 'BIGINT' => 'COM_COMPONENTBUILDER_FIELD_BIGINT', + 'FLOAT' => 'COM_COMPONENTBUILDER_FIELD_FLOAT', + 'DECIMAL' => 'COM_COMPONENTBUILDER_FIELD_DECIMAL', + 'DOUBLE' => 'COM_COMPONENTBUILDER_FIELD_DOUBLE' + ); + // Now check if value is found in this array + if (isset($datatypeArray[$value]) && UtilitiesStringHelper::check($datatypeArray[$value])) + { + return $datatypeArray[$value]; + } + } + // Array of indexes language strings + if ($name === 'indexes') + { + $indexesArray = array( + 1 => 'COM_COMPONENTBUILDER_FIELD_UNIQUE_KEY', + 2 => 'COM_COMPONENTBUILDER_FIELD_KEY', + 0 => 'COM_COMPONENTBUILDER_FIELD_NONE' + ); + // Now check if value is found in this array + if (isset($indexesArray[$value]) && UtilitiesStringHelper::check($indexesArray[$value])) + { + return $indexesArray[$value]; + } + } + // Array of null_switch language strings + if ($name === 'null_switch') + { + $null_switchArray = array( + 'NULL' => 'COM_COMPONENTBUILDER_FIELD_NULL', + 'NOT NULL' => 'COM_COMPONENTBUILDER_FIELD_NOT_NULL' + ); + // Now check if value is found in this array + if (isset($null_switchArray[$value]) && UtilitiesStringHelper::check($null_switchArray[$value])) + { + return $null_switchArray[$value]; + } + } + // Array of store language strings + if ($name === 'store') + { + $storeArray = array( + 0 => 'COM_COMPONENTBUILDER_FIELD_DEFAULT', + 1 => 'COM_COMPONENTBUILDER_FIELD_JSON', + 2 => 'COM_COMPONENTBUILDER_FIELD_BASE64', + 3 => 'COM_COMPONENTBUILDER_FIELD_BASIC_ENCRYPTION_LOCALDBKEY', + 5 => 'COM_COMPONENTBUILDER_FIELD_MEDIUM_ENCRYPTION_LOCALFILEKEY', + 4 => 'COM_COMPONENTBUILDER_FIELD_WHMCSKEY_ENCRYPTION', + 6 => 'COM_COMPONENTBUILDER_FIELD_EXPERT_MODE_CUSTOM' + ); + // Now check if value is found in this array + if (isset($storeArray[$value]) && UtilitiesStringHelper::check($storeArray[$value])) + { + return $storeArray[$value]; + } + } + return $value; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.fieldtype', 'fieldtype', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('fieldtype.edit.state', 'com_componentbuilder.fieldtype.' . (int) $id)) + || ($id == 0 && !$user->authorise('fieldtype.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if (!$user->authorise('core.edit.created_by', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if (!$user->authorise('core.edit.created', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update the properties (sub form) layout + $form->setFieldAttribute('properties', 'layout', ComponentbuilderHelper::getSubformLayout('fieldtype', 'properties')); + + // Only load the GUID if new item (or empty) + if (0 == $id || !($val = $form->getValue('guid'))) + { + $form->setValue('guid', null, GuidHelper::get()); + } + + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('fieldtype.delete', 'com_componentbuilder.fieldtype.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('fieldtype.edit.state', 'com_componentbuilder.fieldtype.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('fieldtype.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('fieldtype.edit', 'com_componentbuilder.fieldtype.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('fieldtype.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_fieldtype')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.fieldtype.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.fieldtype', $data); + + return $data; + } + + /** + * Method to validate the form data. + * + * @param JForm $form The form to validate against. + * @param array $data The data to validate. + * @param string $group The name of the field group to validate. + * + * @return mixed Array of filtered data if valid, false otherwise. + * + * @see JFormRule + * @see JFilterInput + * @since 12.2 + */ + public function validate($form, $data, $group = null) + { + // check if the not_required field is set + if (isset($data['not_required']) && UtilitiesStringHelper::check($data['not_required'])) + { + $requiredFields = (array) explode(',',(string) $data['not_required']); + $requiredFields = array_unique($requiredFields); + // now change the required field attributes value + foreach ($requiredFields as $requiredField) + { + // make sure there is a string value + if (UtilitiesStringHelper::check($requiredField)) + { + // change to false + $form->setFieldAttribute($requiredField, 'required', 'false'); + // also clear the data set + $data[$requiredField] = ''; + } + } + } + return parent::validate($form, $data, $group); + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return array('guid'); + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('fieldtype'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('fieldtype'); + } + + if (!$this->canDo->get('fieldtype.create') && !$this->canDo->get('fieldtype.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('fieldtype.edit.state')) + { + $values['published'] = 0; + } + + if (isset($values['category']) && (int) $values['category'] > 0 && !static::checkCategoryId($values['category'])) + { + return false; + } + elseif (isset($values['category']) && (int) $values['category'] > 0) + { + // move the category value to correct field name + $values['catid'] = $values['category']; + unset($values['category']); + } + elseif (isset($values['category'])) + { + unset($values['category']); + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('fieldtype.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('fieldtype'); + } + + if (!$this->canDo->get('fieldtype.edit') && !$this->canDo->get('fieldtype.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('fieldtype.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + if (isset($values['category']) && (int) $values['category'] > 0 && !static::checkCategoryId($values['category'])) + { + return false; + } + elseif (isset($values['category']) && (int) $values['category'] > 0) + { + // move the category value to correct field name + $values['catid'] = $values['category']; + unset($values['category']); + } + elseif (isset($values['category'])) + { + unset($values['category']); + } + + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('fieldtype.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // Set the GUID if empty or not valid + if (empty($data['guid']) && $data['id'] > 0) + { + // get the existing one + $data['guid'] = (string) GetHelper::var('fieldtype', $data['id'], 'id', 'guid'); + } + + // Set the GUID if empty or not valid + while (!GuidHelper::valid($data['guid'], "fieldtype", $data['id'])) + { + // must always be set + $data['guid'] = (string) GuidHelper::get(); + } + + // Set the properties items to data. + if (isset($data['properties']) && is_array($data['properties'])) + { + $properties = new Registry; + $properties->loadArray($data['properties']); + $data['properties'] = (string) $properties; + } + elseif (!isset($data['properties'])) + { + // Set the empty properties to data + $data['properties'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/FieldtypesModel.php b/admin/src/Model/FieldtypesModel.php new file mode 100644 index 000000000..b1648cbc3 --- /dev/null +++ b/admin/src/Model/FieldtypesModel.php @@ -0,0 +1,612 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Fieldtypes List Model + * + * @since 1.6 + */ +class FieldtypesModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/fieldtypes.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'c.title','category_title', + 'c.id', 'category_id', + 'a.catid','catid', + 'a.name','name', + 'a.short_description','short_description' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $category = $app->getUserStateFromRequest($this->context . '.filter.category', 'filter_category'); + $this->setState('filter.category', $category); + + $categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id'); + $this->setState('filter.category_id', $categoryId); + + $catid = $this->getUserStateFromRequest($this->context . '.filter.catid', 'filter_catid'); + if ($formSubmited) + { + $catid = $app->input->post->get('catid'); + $this->setState('filter.catid', $catid); + } + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + $short_description = $this->getUserStateFromRequest($this->context . '.filter.short_description', 'filter_short_description'); + if ($formSubmited) + { + $short_description = $app->input->post->get('short_description'); + $this->setState('filter.short_description', $short_description); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('fieldtype.access', 'com_componentbuilder.fieldtype.' . (int) $item->id) && $user->authorise('fieldtype.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + $query->select($db->quoteName('c.title','category_title')); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_fieldtype', 'a')); + $query->join('LEFT', $db->quoteName('#__categories', 'c') . ' ON (' . $db->quoteName('a.catid') . ' = ' . $db->quoteName('c.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.' OR a.short_description LIKE '.$search.' OR a.description LIKE '.$search.' OR a.catid LIKE '.$search.')'); + } + } + + + // Filter by a single or group of categories. + $baselevel = 1; + $categoryId = $this->getState('filter.category_id'); + + if (is_numeric($categoryId)) + { + $cat_tbl = Table::getInstance('Category', 'JTable'); + $cat_tbl->load($categoryId); + $rgt = $cat_tbl->rgt; + $lft = $cat_tbl->lft; + $baselevel = (int) $cat_tbl->level; + $query->where('c.lft >= ' . (int) $lft) + ->where('c.rgt <= ' . (int) $rgt); + } + elseif (is_array($categoryId)) + { + $categoryId = ArrayHelper::toInteger($categoryId); + $categoryId = implode(',', $categoryId); + $query->where('a.catid IN (' . $categoryId . ')'); + } + + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get list export data. + * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExportData($pks, $user = null) + { + // setup the query + if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks) + { + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + $_export = true; + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_fieldtype table + $query->from($db->quoteName('#__componentbuilder_fieldtype', 'a')); + // The bulk export path + if ('bulk' === $pks) + { + $query->where('a.id > 0'); + } + // A large array of ID's will not work out well + elseif ($pks_size > 500) + { + // Use lowest ID + $query->where('a.id >= ' . (int) min($pks)); + // Use highest ID + $query->where('a.id <= ' . (int) max($pks)); + } + // The normal default path + else + { + $query->where('a.id IN (' . implode(',',$pks) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.ordering ASC'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('fieldtype.access', 'com_componentbuilder.fieldtype.' . (int) $item->id) && $user->authorise('fieldtype.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // unset the values we don't want exported. + unset($item->asset_id); + unset($item->checked_out); + unset($item->checked_out_time); + } + } + // Add headers to items array. + $headers = $this->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + array_unshift($items,$headers); + } + return $items; + } + } + 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 = Factory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_fieldtype"); + if (UtilitiesArrayHelper::check($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; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + // Check if the value is an array + $_category = $this->getState('filter.category'); + if (UtilitiesArrayHelper::check($_category)) + { + $id .= ':' . implode(':', $_category); + } + // Check if this is only an number or string + elseif (is_numeric($_category) + || StringHelper::check($_category)) + { + $id .= ':' . $_category; + } + // Check if the value is an array + $_category_id = $this->getState('filter.category_id'); + if (UtilitiesArrayHelper::check($_category_id)) + { + $id .= ':' . implode(':', $_category_id); + } + // Check if this is only an number or string + elseif (is_numeric($_category_id) + || StringHelper::check($_category_id)) + { + $id .= ':' . $_category_id; + } + // Check if the value is an array + $_catid = $this->getState('filter.catid'); + if (UtilitiesArrayHelper::check($_catid)) + { + $id .= ':' . implode(':', $_catid); + } + // Check if this is only an number or string + elseif (is_numeric($_catid) + || StringHelper::check($_catid)) + { + $id .= ':' . $_catid; + } + $id .= ':' . $this->getState('filter.name'); + $id .= ':' . $this->getState('filter.short_description'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_fieldtype')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_fieldtype'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Get_snippetsModel.php b/admin/src/Model/Get_snippetsModel.php new file mode 100644 index 000000000..66043b5c8 --- /dev/null +++ b/admin/src/Model/Get_snippetsModel.php @@ -0,0 +1,280 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder List Model for Get_snippets + * + * @since 1.6 + */ +class Get_snippetsModel extends ListModel +{ + /** + * Represents the current user object. + * + * @var User The user object representing the current user. + * @since 3.2.0 + */ + protected User $user; + + /** + * The unique identifier of the current user. + * + * @var int|null The ID of the current user. + * @since 3.2.0 + */ + protected ?int $userId; + + /** + * Flag indicating whether the current user is a guest. + * + * @var int 1 if the user is a guest, 0 otherwise. + * @since 3.2.0 + */ + protected int $guest; + + /** + * An array of groups that the current user belongs to. + * + * @var array|null An array of user group IDs. + * @since 3.2.0 + */ + protected ?array $groups; + + /** + * An array of view access levels for the current user. + * + * @var array|null An array of access level IDs. + * @since 3.2.0 + */ + protected ?array $levels; + + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The input object, providing access to the request data. + * + * @var Input The input object. + * @since 3.2.0 + */ + protected Input $input; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/get_snippets.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * A custom property for UIKit components. (not used unless you load v2) + */ + protected $uikitComp; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + $this->input ??= $this->app->getInput(); + + // Set the current user for authorisation checks (for those calling this model directly) + $this->user ??= $this->getCurrentUser(); + $this->userId = $this->user->get('id'); + $this->guest = $this->user->get('guest'); + $this->groups = $this->user->get('groups'); + $this->authorisedGroups = $this->user->getAuthorisedGroups(); + $this->levels = $this->user->getAuthorisedViewLevels(); + + // will be removed + $this->initSet = true; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Make sure all records load, since no pagination allowed. + $this->setState('list.limit', 0); + // Get a db connection. + $db = $this->getDatabase(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Get from #__componentbuilder_snippet as a + $query->select($db->quoteName( + array('a.id','a.heading','a.name','a.url','a.created','a.modified'), + array('id','heading','name','url','created','modified'))); + $query->from($db->quoteName('#__componentbuilder_snippet', 'a')); + + // Get from #__componentbuilder_snippet_type as b + $query->select($db->quoteName( + array('b.name'), + array('type'))); + $query->join('LEFT', ($db->quoteName('#__componentbuilder_snippet_type', 'b')) . ' ON (' . $db->quoteName('a.type') . ' = ' . $db->quoteName('b.id') . ')'); + + // Get from #__componentbuilder_library as c + $query->select($db->quoteName( + array('c.name'), + array('library'))); + $query->join('LEFT', ($db->quoteName('#__componentbuilder_library', 'c')) . ' ON (' . $db->quoteName('a.library') . ' = ' . $db->quoteName('c.id') . ')'); + + // return the query object + return $query; + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + $user = $this->user; + // check if this user has permission to access items + if (!$user->authorise('get_snippets.access', 'com_componentbuilder')) + { + $this->app->enqueueMessage(Text::_('Not authorised!'), 'error'); + // redirect away if not a correct to default view + $this->app->redirect('index.php?option=com_componentbuilder'); + return false; + } + // load parent items + $items = parent::getItems(); + + // Get the global params + $globalParams = ComponentHelper::getParams('com_componentbuilder', true); + + // Insure all item fields are adapted where needed. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Always create a slug for sef URL's + $item->slug = ($item->id ?? '0') . (isset($item->alias) ? ':' . $item->alias : ''); + } + } + + // return items + return $items; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Get the uikit needed components + * + * @return mixed An array of objects on success. + * + */ + public function getUikitComp() + { + if (isset($this->uikitComp) && UtilitiesArrayHelper::check($this->uikitComp)) + { + return $this->uikitComp; + } + return false; + } +} diff --git a/admin/src/Model/Help_documentModel.php b/admin/src/Model/Help_documentModel.php new file mode 100644 index 000000000..e9e067bd5 --- /dev/null +++ b/admin/src/Model/Help_documentModel.php @@ -0,0 +1,1068 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Help_document Admin Model + * + * @since 1.6 + */ +class Help_documentModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'target', + 'groups', + 'location', + 'admin_view', + 'site_view' + ), + 'right' => array( + 'type', + 'url', + 'article' + ), + 'fullwidth' => array( + 'content' + ), + 'above' => array( + 'title', + 'alias' + ), + 'under' => array( + 'not_required' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/help_document.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/help_document.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.help_document'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'help_document', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->groups)) + { + // JSON Decode groups. + $item->groups = json_decode($item->groups,true); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.help_document', 'help_document', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('help_document.edit.state', 'com_componentbuilder.help_document.' . (int) $id)) + || ($id == 0 && !$user->authorise('help_document.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if (!$user->authorise('core.edit.created_by', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if (!$user->authorise('core.edit.created', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('help_document.delete', 'com_componentbuilder.help_document.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('help_document.edit.state', 'com_componentbuilder.help_document.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('help_document.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('help_document.edit', 'com_componentbuilder.help_document.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('help_document.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_help_document')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.help_document.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.help_document', $data); + + return $data; + } + + /** + * Method to validate the form data. + * + * @param JForm $form The form to validate against. + * @param array $data The data to validate. + * @param string $group The name of the field group to validate. + * + * @return mixed Array of filtered data if valid, false otherwise. + * + * @see JFormRule + * @see JFilterInput + * @since 12.2 + */ + public function validate($form, $data, $group = null) + { + // check if the not_required field is set + if (isset($data['not_required']) && UtilitiesStringHelper::check($data['not_required'])) + { + $requiredFields = (array) explode(',',(string) $data['not_required']); + $requiredFields = array_unique($requiredFields); + // now change the required field attributes value + foreach ($requiredFields as $requiredField) + { + // make sure there is a string value + if (UtilitiesStringHelper::check($requiredField)) + { + // change to false + $form->setFieldAttribute($requiredField, 'required', 'false'); + // also clear the data set + $data[$requiredField] = ''; + } + } + } + return parent::validate($form, $data, $group); + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('help_document'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('help_document'); + } + + if (!$this->canDo->get('help_document.create') && !$this->canDo->get('help_document.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('help_document.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('help_document.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + list($this->table->title, $this->table->alias) = $this->_generateNewTitle($this->table->alias, $this->table->title); + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('help_document'); + } + + if (!$this->canDo->get('help_document.edit') && !$this->canDo->get('help_document.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('help_document.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('help_document.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the groups string to JSON string. + if (isset($data['groups'])) + { + $data['groups'] = (string) json_encode($data['groups']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the title for save as copy + if ($input->get('task') === 'save2copy') + { + $origTable = clone $this->getTable(); + $origTable->load($input->getInt('id')); + + if ($data['title'] == $origTable->title) + { + list($title, $alias) = $this->_generateNewTitle($data['alias'], $data['title']); + $data['title'] = $title; + $data['alias'] = $alias; + } + else + { + if ($data['alias'] == $origTable->alias) + { + $data['alias'] = ''; + } + } + + $data['published'] = 0; + } + + // Automatic handling of alias for empty fields + if (in_array($input->get('task'), array('apply', 'save', 'save2new')) && (int) $input->get('id') == 0) + { + if ($data['alias'] == null || empty($data['alias'])) + { + if (Factory::getConfig()->get('unicodeslugs') == 1) + { + $data['alias'] = OutputFilter::stringURLUnicodeSlug($data['title']); + } + else + { + $data['alias'] = OutputFilter::stringURLSafe($data['title']); + } + + $table = clone $this->getTable(); + + if ($table->load(array('alias' => $data['alias'])) && ($table->id != $data['id'] || $data['id'] == 0)) + { + $msg = Text::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_SAVE_WARNING'); + } + + $data['alias'] = $this->_generateNewTitle($data['alias']); + + if (isset($msg)) + { + Factory::getApplication()->enqueueMessage($msg, 'warning'); + } + } + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title/s & alias. + * + * @param string $alias The alias. + * @param string/array $title The title. + * + * @return array/string Contains the modified title/s and/or alias. + * + */ + protected function _generateNewTitle($alias, $title = null) + { + + // Alter the title/s & alias + $table = $this->getTable(); + + while ($table->load(['alias' => $alias])) + { + // Check if this is an array of titles + if (UtilitiesArrayHelper::check($title)) + { + foreach($title as $nr => &$_title) + { + $_title = StringHelper::increment($_title); + } + } + // Make sure we have a title + elseif ($title) + { + $title = StringHelper::increment($title); + } + $alias = StringHelper::increment($alias, 'dash'); + } + // Check if this is an array of titles + if (UtilitiesArrayHelper::check($title)) + { + $title[] = $alias; + return $title; + } + // Make sure we have a title + elseif ($title) + { + return array($title, $alias); + } + // We only had an alias + return $alias; + } +} diff --git a/admin/src/Model/Help_documentsModel.php b/admin/src/Model/Help_documentsModel.php new file mode 100644 index 000000000..7559b00c5 --- /dev/null +++ b/admin/src/Model/Help_documentsModel.php @@ -0,0 +1,643 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Help_documents List Model + * + * @since 1.6 + */ +class Help_documentsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/help_documents.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.type','type', + 'a.location','location', + 'a.admin_view','admin_view', + 'a.site_view','site_view', + 'a.title','title' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $type = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type'); + if ($formSubmited) + { + $type = $app->input->post->get('type'); + $this->setState('filter.type', $type); + } + + $location = $this->getUserStateFromRequest($this->context . '.filter.location', 'filter_location'); + if ($formSubmited) + { + $location = $app->input->post->get('location'); + $this->setState('filter.location', $location); + } + + $admin_view = $this->getUserStateFromRequest($this->context . '.filter.admin_view', 'filter_admin_view'); + if ($formSubmited) + { + $admin_view = $app->input->post->get('admin_view'); + $this->setState('filter.admin_view', $admin_view); + } + + $site_view = $this->getUserStateFromRequest($this->context . '.filter.site_view', 'filter_site_view'); + if ($formSubmited) + { + $site_view = $app->input->post->get('site_view'); + $this->setState('filter.site_view', $site_view); + } + + $title = $this->getUserStateFromRequest($this->context . '.filter.title', 'filter_title'); + if ($formSubmited) + { + $title = $app->input->post->get('title'); + $this->setState('filter.title', $title); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('help_document.access', 'com_componentbuilder.help_document.' . (int) $item->id) && $user->authorise('help_document.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // convert groups + $item->groups = JsonHelper::string($item->groups, ', ', 'groups'); + } + } + + // set selection value to a translatable value + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // convert type + $item->type = $this->selectionTranslation($item->type, 'type'); + // convert location + $item->location = $this->selectionTranslation($item->location, 'location'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return string The translatable string. + */ + public function selectionTranslation($value,$name) + { + // Array of type language strings + if ($name === 'type') + { + $typeArray = array( + 0 => 'COM_COMPONENTBUILDER_HELP_DOCUMENT_SELECT_AN_OPTION', + 1 => 'COM_COMPONENTBUILDER_HELP_DOCUMENT_JOOMLA_ARTICLE', + 2 => 'COM_COMPONENTBUILDER_HELP_DOCUMENT_TEXT', + 3 => 'COM_COMPONENTBUILDER_HELP_DOCUMENT_URL' + ); + // Now check if value is found in this array + if (isset($typeArray[$value]) && StringHelper::check($typeArray[$value])) + { + return $typeArray[$value]; + } + } + // Array of location language strings + if ($name === 'location') + { + $locationArray = array( + 1 => 'COM_COMPONENTBUILDER_HELP_DOCUMENT_ADMIN', + 2 => 'COM_COMPONENTBUILDER_HELP_DOCUMENT_SITE' + ); + // Now check if value is found in this array + if (isset($locationArray[$value]) && StringHelper::check($locationArray[$value])) + { + return $locationArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_help_document', 'a')); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.title LIKE '.$search.' OR a.type LIKE '.$search.' OR a.location LIKE '.$search.' OR a.admin_view LIKE '.$search.' OR h. LIKE '.$search.' OR a.site_view LIKE '.$search.' OR i. LIKE '.$search.')'); + } + } + + // Filter by Type. + $_type = $this->getState('filter.type'); + if (is_numeric($_type)) + { + if (is_float($_type)) + { + $query->where('a.type = ' . (float) $_type); + } + else + { + $query->where('a.type = ' . (int) $_type); + } + } + elseif (StringHelper::check($_type)) + { + $query->where('a.type = ' . $db->quote($db->escape($_type))); + } + // Filter by Location. + $_location = $this->getState('filter.location'); + if (is_numeric($_location)) + { + if (is_float($_location)) + { + $query->where('a.location = ' . (float) $_location); + } + else + { + $query->where('a.location = ' . (int) $_location); + } + } + elseif (StringHelper::check($_location)) + { + $query->where('a.location = ' . $db->quote($db->escape($_location))); + } + // Filter by Admin_view. + $_admin_view = $this->getState('filter.admin_view'); + if (is_numeric($_admin_view)) + { + if (is_float($_admin_view)) + { + $query->where('a.admin_view = ' . (float) $_admin_view); + } + else + { + $query->where('a.admin_view = ' . (int) $_admin_view); + } + } + elseif (StringHelper::check($_admin_view)) + { + $query->where('a.admin_view = ' . $db->quote($db->escape($_admin_view))); + } + // Filter by Site_view. + $_site_view = $this->getState('filter.site_view'); + if (is_numeric($_site_view)) + { + if (is_float($_site_view)) + { + $query->where('a.site_view = ' . (float) $_site_view); + } + else + { + $query->where('a.site_view = ' . (int) $_site_view); + } + } + elseif (StringHelper::check($_site_view)) + { + $query->where('a.site_view = ' . $db->quote($db->escape($_site_view))); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get list export data. + * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExportData($pks, $user = null) + { + // setup the query + if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks) + { + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + $_export = true; + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_help_document table + $query->from($db->quoteName('#__componentbuilder_help_document', 'a')); + // The bulk export path + if ('bulk' === $pks) + { + $query->where('a.id > 0'); + } + // A large array of ID's will not work out well + elseif ($pks_size > 500) + { + // Use lowest ID + $query->where('a.id >= ' . (int) min($pks)); + // Use highest ID + $query->where('a.id <= ' . (int) max($pks)); + } + // The normal default path + else + { + $query->where('a.id IN (' . implode(',',$pks) . ')'); + } + + // Order the results by ordering + $query->order('a.ordering ASC'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('help_document.access', 'com_componentbuilder.help_document.' . (int) $item->id) && $user->authorise('help_document.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // unset the values we don't want exported. + unset($item->asset_id); + unset($item->checked_out); + unset($item->checked_out_time); + } + } + // Add headers to items array. + $headers = $this->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + array_unshift($items,$headers); + } + return $items; + } + } + 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 = Factory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_help_document"); + if (UtilitiesArrayHelper::check($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; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.type'); + $id .= ':' . $this->getState('filter.location'); + $id .= ':' . $this->getState('filter.admin_view'); + $id .= ':' . $this->getState('filter.site_view'); + $id .= ':' . $this->getState('filter.title'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_help_document')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_help_document'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/ImportModel.php b/admin/src/Model/ImportModel.php new file mode 100644 index 000000000..ba2d18235 --- /dev/null +++ b/admin/src/Model/ImportModel.php @@ -0,0 +1,752 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Filesystem\Folder; +use Joomla\CMS\Filesystem\Path; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\Installer\InstallerHelper; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use PhpOffice\PhpSpreadsheet\IOFactory; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/*** + * Componentbuilder Import Base Database Model + * + * @since 1.6 + */ +class ImportModel extends BaseDatabaseModel +{ + // set uploading values + protected $use_streams = false; + protected $allow_unsafe = false; + protected $safeFileOptions = []; + + /** + * @var object JTable object + */ + protected $_table = null; + + /** + * @var object JTable object + */ + protected $_url = null; + + /** + * Model context string. + * + * @var string + */ + protected $_context = 'com_componentbuilder.import'; + + /** + * Import Settings + */ + protected $getType = NULL; + protected $dataType = NULL; + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @return void + * + */ + protected function populateState() + { + $app = Factory::getApplication('administrator'); + + $this->setState('message', $app->getUserState('com_componentbuilder.message')); + $app->setUserState('com_componentbuilder.message', ''); + + // Recall the 'Import from Directory' path. + $path = $app->getUserStateFromRequest($this->_context . '.import_directory', 'import_directory', $app->get('tmp_path')); + $this->setState('import.directory', $path); + parent::populateState(); + } + + /** + * Import an spreadsheet from either folder, url or upload. + * + * @return boolean result of import + * + */ + public function import() + { + $this->setState('action', 'import'); + $app = Factory::getApplication(); + $session = Factory::getSession(); + $package = null; + $continue = false; + // get import type + $this->getType = $app->input->getString('gettype', NULL); + // get import type + $this->dataType = $session->get('dataType_VDM_IMPORTINTO', NULL); + + if ($package === null) + { + switch ($this->getType) + { + case 'folder': + // Remember the 'Import from Directory' path. + $app->getUserStateFromRequest($this->_context . '.import_directory', 'import_directory'); + $package = $this->_getPackageFromFolder(); + break; + + case 'upload': + $package = $this->_getPackageFromUpload(); + break; + + case 'url': + $package = $this->_getPackageFromUrl(); + break; + + case 'continue': + $continue = true; + $package = $session->get('package', null); + $package = json_decode($package, true); + // clear session + $session->clear('package'); + $session->clear('dataType'); + $session->clear('hasPackage'); + break; + + default: + $app->setUserState('com_componentbuilder.message', Text::_('COM_COMPONENTBUILDER_IMPORT_NO_IMPORT_TYPE_FOUND')); + + return false; + break; + } + } + // Was the package valid? + if (!$package || !$package['type']) + { + if (in_array($this->getType, array('upload', 'url'))) + { + $this->remove($package['packagename']); + } + + $app->setUserState('com_componentbuilder.message', Text::_('COM_COMPONENTBUILDER_IMPORT_UNABLE_TO_FIND_IMPORT_PACKAGE')); + return false; + } + + // first link data to table headers + if(!$continue){ + $package = json_encode($package); + $session->set('package', $package); + $session->set('dataType', $this->dataType); + $session->set('hasPackage', true); + return true; + } + + // set the data + $headerList = json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS', false), true); + if (!$this->setData($package,$this->dataType,$headerList)) + { + // There was an error importing the package + $msg = Text::_('COM_COMPONENTBUILDER_IMPORT_ERROR'); + $back = $session->get('backto_VDM_IMPORT', NULL); + if ($back) + { + $app->setUserState('com_componentbuilder.redirect_url', 'index.php?option=com_componentbuilder&view='.$back); + $session->clear('backto_VDM_IMPORT'); + } + $result = false; + } + else + { + // Package imported sucessfully + $msg = Text::sprintf('COM_COMPONENTBUILDER_IMPORT_SUCCESS', $package['packagename']); + $back = $session->get('backto_VDM_IMPORT', NULL); + if ($back) + { + $app->setUserState('com_componentbuilder.redirect_url', 'index.php?option=com_componentbuilder&view='.$back); + $session->clear('backto_VDM_IMPORT'); + } + $result = true; + } + + // Set some model state values + $app->enqueueMessage($msg); + + // remove file after import + $this->remove($package['packagename']); + $session->clear($this->getType.'_VDM_IMPORTHEADERS'); + + return $result; + } + + /** + * Works out an importation spreadsheet from a HTTP upload + * + * @return spreadsheet definition or false on failure + */ + protected function _getPackageFromUpload() + { + // Get the uploaded file information + $app = Factory::getApplication(); + $input = $app->input; + + // Do not change the filter type 'raw'. We need this to let files containing PHP code to upload. See JInputFiles::get. + $userfile = $input->files->get('import_package', null, 'raw'); + + // Make sure that file uploads are enabled in php + if (!(bool) ini_get('file_uploads')) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_WARNIMPORTFILE'), 'warning'); + return false; + } + + // If there is no uploaded file, we have a problem... + if (!is_array($userfile)) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_NO_FILE_SELECTED'), 'warning'); + return false; + } + + // Check if there was a problem uploading the file. + if ($userfile['error'] || $userfile['size'] < 1) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_WARNIMPORTUPLOADERROR'), 'warning'); + return false; + } + + // Build the appropriate paths + $config = Factory::getConfig(); + $tmp_dest = $config->get('tmp_path') . '/' . $userfile['name']; + $tmp_src = $userfile['tmp_name']; + + // Move uploaded file + $p_file = File::upload($tmp_src, $tmp_dest, $this->use_streams, $this->allow_unsafe, $this->safeFileOptions); + + // Was the package downloaded? + if (!$p_file) + { + $session = Factory::getSession(); + $session->clear('package'); + $session->clear('dataType'); + $session->clear('hasPackage'); + // was not uploaded + return false; + } + + // check that this is a valid spreadsheet + $package = $this->check($userfile['name']); + + return $package; + } + + /** + * Import an spreadsheet from a directory + * + * @return array Spreadsheet details or false on failure + * + */ + protected function _getPackageFromFolder() + { + $app = Factory::getApplication(); + $input = $app->input; + + // Get the path to the package to import + $p_dir = $input->getString('import_directory'); + $p_dir = Path::clean($p_dir); + // Did you give us a valid path? + if (!file_exists($p_dir)) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_PLEASE_ENTER_A_PACKAGE_DIRECTORY'), 'warning'); + return false; + } + + // Detect the package type + $type = $this->getType; + + // Did you give us a valid package? + if (!$type) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE'), 'warning'); + } + + // check the extention + if(!$this->checkExtension($p_dir)) + { + // set error message + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); + return false; + } + + $package['packagename'] = null; + $package['dir'] = $p_dir; + $package['type'] = $type; + + return $package; + } + + /** + * Import an spreadsheet from a URL + * + * @return Package details or false on failure + * + */ + protected function _getPackageFromUrl() + { + $app = Factory::getApplication(); + $input = $app->input; + + // Get the URL of the package to import + $url = $input->getString('import_url'); + + // Did you give us a URL? + if (!$url) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_ENTER_A_URL'), 'warning'); + return false; + } + + // Download the package at the URL given + $p_file = InstallerHelper::downloadPackage($url); + + // Was the package downloaded? + if (!$p_file) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_INVALID_URL'), 'warning'); + return false; + } + + // check that this is a valid spreadsheet + $package = $this->check($p_file); + + return $package; + } + + /** + * Check a file and verifies it as a spreadsheet file + * Supports .csv .xlsx .xls and .ods + * + * @param string $p_filename The uploaded package filename or import directory + * + * @return array of elements + * + */ + protected function check($archivename) + { + $app = Factory::getApplication(); + // Clean the name + $archivename = Path::clean($archivename); + + // check the extention + if(!$this->checkExtension($archivename)) + { + // Cleanup the import files + $this->remove($archivename); + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); + return false; + } + + $config = Factory::getConfig(); + // set Package Name + $check['packagename'] = $archivename; + + // set directory + $check['dir'] = $config->get('tmp_path'). '/' .$archivename; + + // set type + $check['type'] = $this->getType; + + return $check; + } + + /** + * Check the extension + * + * @param string $file Name of the uploaded file + * + * @return boolean True on success + * + */ + protected function checkExtension($file) + { + // check the extention + switch(strtolower(pathinfo($file, PATHINFO_EXTENSION))) + { + case 'xls': + case 'ods': + case 'csv': + return true; + break; + } + return false; + } + + /** + * Clean up temporary uploaded spreadsheet + * + * @param string $package Name of the uploaded spreadsheet file + * + * @return boolean True on success + * + */ + protected function remove($package) + { + jimport('joomla.filesystem.file'); + + $config = Factory::getConfig(); + $package = $config->get('tmp_path'). '/' .$package; + + // Is the package file a valid file? + if (is_file($package)) + { + File::delete($package); + } + elseif (is_file(Path::clean($package))) + { + // It might also be just a base filename + File::delete(Path::clean($package)); + } + } + + /** + * Set the data from the spreadsheet to the database + * + * @param string $package Paths to the uploaded package file + * + * @return boolean false on failure + * + **/ + protected function setData($package,$table,$target_headers) + { + if (UtilitiesArrayHelper::check($target_headers)) + { + // make sure the file is loaded + ComponentbuilderHelper::composerAutoload('phpspreadsheet'); + $jinput = Factory::getApplication()->input; + foreach($target_headers as $header) + { + if (($column = $jinput->getString($header, false)) !== false || + ($column = $jinput->getString(strtolower($header), false)) !== false) + { + $data['target_headers'][$header] = $column; + } + else + { + $data['target_headers'][$header] = null; + } + } + // set the data + if(isset($package['dir'])) + { + $inputFileType = IOFactory::identify($package['dir']); + $excelReader = IOFactory::createReader($inputFileType); + $excelReader->setReadDataOnly(true); + $excelObj = $excelReader->load($package['dir']); + $data['array'] = $excelObj->getActiveSheet()->toArray(null, true,true,true); + $excelObj->disconnectWorksheets(); + unset($excelObj); + return $this->save($data, $table); + } + } + return false; + } + + /** + * Save the data from the file to the database + * + * @param string $package Paths to the uploaded package file + * + * @return boolean false on failure + * + **/ + protected function save($data,$table) + { + // import the data if there is any + if(UtilitiesArrayHelper::check($data['array'])) + { + // get user object + $user = Factory::getUser(); + // remove header if it has headers + $id_key = $data['target_headers']['id']; + $published_key = $data['target_headers']['published']; + $ordering_key = $data['target_headers']['ordering']; + // get the first array set + $firstSet = reset($data['array']); + + // check if first array is a header array and remove if true + if($firstSet[$id_key] == 'id' || $firstSet[$published_key] == 'published' || $firstSet[$ordering_key] == 'ordering') + { + array_shift($data['array']); + } + + // make sure there is still values in array and that it was not only headers + if(UtilitiesArrayHelper::check($data['array']) && $user->authorise($table.'.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) + { + // set target. + $target = array_flip($data['target_headers']); + // Get a db connection. + $db = Factory::getDbo(); + // set some defaults + $todayDate = Factory::getDate()->toSql(); + // get global action permissions + $canDo = ComponentbuilderHelper::getActions($table); + $canEdit = $canDo->get('core.edit'); + $canState = $canDo->get('core.edit.state'); + $canCreate = $canDo->get('core.create'); + $hasAlias = $this->getAliasesUsed($table); + // prosses the data + foreach($data['array'] as $row) + { + $found = false; + if (isset($row[$id_key]) && is_numeric($row[$id_key]) && $row[$id_key] > 0) + { + // raw items import & update! + $query = $db->getQuery(true); + $query + ->select('version') + ->from($db->quoteName('#__componentbuilder_'.$table)) + ->where($db->quoteName('id') . ' = '. $db->quote($row[$id_key])); + // Reset the query using our newly populated query object. + $db->setQuery($query); + $db->execute(); + $found = $db->getNumRows(); + } + + if($found && $canEdit) + { + // update item + $id = $row[$id_key]; + $version = $db->loadResult(); + // reset all buckets + $query = $db->getQuery(true); + $fields = array(); + // Fields to update. + foreach($row as $key => $cell) + { + // ignore column + if ('IGNORE' == $target[$key]) + { + continue; + } + // update modified + if ('modified_by' == $target[$key]) + { + continue; + } + // update modified + if ('modified' == $target[$key]) + { + continue; + } + // update version + if ('version' == $target[$key]) + { + $cell = (int) $version + 1; + } + // verify publish authority + if ('published' == $target[$key] && !$canState) + { + continue; + } + // set to update array + if(in_array($key, $data['target_headers']) && is_numeric($cell)) + { + $fields[] = $db->quoteName($target[$key]) . ' = ' . $cell; + } + elseif(in_array($key, $data['target_headers']) && is_string($cell)) + { + $fields[] = $db->quoteName($target[$key]) . ' = ' . $db->quote($cell); + } + elseif(in_array($key, $data['target_headers']) && is_null($cell)) + { + // if import data is null then set empty + $fields[] = $db->quoteName($target[$key]) . " = ''"; + } + } + // load the defaults + $fields[] = $db->quoteName('modified_by') . ' = ' . $db->quote($user->id); + $fields[] = $db->quoteName('modified') . ' = ' . $db->quote($todayDate); + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('id') . ' = ' . $id + ); + + $query->update($db->quoteName('#__componentbuilder_'.$table))->set($fields)->where($conditions); + $db->setQuery($query); + $db->execute(); + } + elseif ($canCreate) + { + // insert item + $query = $db->getQuery(true); + // reset all buckets + $columns = array(); + $values = array(); + $version = false; + // Insert columns. Insert values. + foreach($row as $key => $cell) + { + // ignore column + if ('IGNORE' == $target[$key]) + { + continue; + } + // remove id + if ('id' == $target[$key]) + { + continue; + } + // update created + if ('created_by' == $target[$key]) + { + continue; + } + // update created + if ('created' == $target[$key]) + { + continue; + } + // Make sure the alias is incremented + if ('alias' == $target[$key]) + { + $cell = $this->getAlias($cell,$table); + } + // update version + if ('version' == $target[$key]) + { + $cell = 1; + $version = true; + } + // set to insert array + if(in_array($key, $data['target_headers']) && is_numeric($cell)) + { + $columns[] = $target[$key]; + $values[] = $cell; + } + elseif(in_array($key, $data['target_headers']) && is_string($cell)) + { + $columns[] = $target[$key]; + $values[] = $db->quote($cell); + } + elseif(in_array($key, $data['target_headers']) && is_null($cell)) + { + // if import data is null then set empty + $columns[] = $target[$key]; + $values[] = "''"; + } + } + // load the defaults + $columns[] = 'created_by'; + $values[] = $db->quote($user->id); + $columns[] = 'created'; + $values[] = $db->quote($todayDate); + if (!$version) + { + $columns[] = 'version'; + $values[] = 1; + } + // Prepare the insert query. + $query + ->insert($db->quoteName('#__componentbuilder_'.$table)) + ->columns($db->quoteName($columns)) + ->values(implode(',', $values)); + // Set the query using our newly populated query object and execute it. + $db->setQuery($query); + $done = $db->execute(); + if ($done) + { + $aId = $db->insertid(); + // make sure the access of asset is set + ComponentbuilderHelper::setAsset($aId,$table); + } + } + else + { + return false; + } + } + return true; + } + } + return false; + } + + protected function getAlias($name,$type = false) + { + // sanitize the name to an alias + if (Factory::getConfig()->get('unicodeslugs') == 1) + { + $alias = OutputFilter::stringURLUnicodeSlug($name); + } + else + { + $alias = OutputFilter::stringURLSafe($name); + } + // must be a uniqe alias + if ($type) + { + return $this->getUniqe($alias,'alias',$type); + } + return $alias; + } + + /** + * Method to generate a uniqe value. + * + * @param string $field name. + * @param string $value data. + * @param string $type table. + * + * @return string New value. + */ + protected function getUniqe($value,$field,$type) + { + // insure the filed is always uniqe + while (isset($this->uniqeValueArray[$type][$field][$value])) + { + $value = StringHelper::increment($value, 'dash'); + } + $this->uniqeValueArray[$type][$field][$value] = $value; + return $value; + } + + protected function getAliasesUsed($table) + { + // Get a db connection. + $db = $this->getDatabase(); + // first we check if there is a alias column + $columns = $db->getTableColumns('#__componentbuilder_'.$table); + if(isset($columns['alias'])){ + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('alias'))); + $query->from($db->quoteName('#__componentbuilder_'.$table)); + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $aliases = $db->loadColumn(); + foreach($aliases as $alias) + { + $this->uniqeValueArray[$table]['alias'][$alias] = $alias; + } + } + return true; + } + return false; + } +} diff --git a/admin/src/Model/Import_joomla_componentsimportModel.php b/admin/src/Model/Import_joomla_componentsimportModel.php new file mode 100644 index 000000000..ac239a2f3 --- /dev/null +++ b/admin/src/Model/Import_joomla_componentsimportModel.php @@ -0,0 +1,3598 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Filesystem\Folder; +use Joomla\CMS\Filesystem\Path; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\Installer\InstallerHelper; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use PhpOffice\PhpSpreadsheet\IOFactory; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Componentbuilder\Package\Factory as PackageFactory; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\FileHelper; +use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Utilities\GuidHelper; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Import_joomla_components Base Database Model + * + * @since 1.6 + */ +class Import_joomla_componentsimportModel extends BaseDatabaseModel +{ + // set uploading values + protected $use_streams = false; + protected $allow_unsafe = false; + protected $safeFileOptions = []; + + /** + * @var object JTable object + */ + protected $_table = null; + + /** + * @var object JTable object + */ + protected $_url = null; + + /** + * Model context string. + * + * @var string + */ + protected $_context = 'com_componentbuilder.import_joomla_components'; + + /** + * Import Settings + */ + protected $getType = NULL; + protected $dataType = NULL; + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @return void + * + */ + protected function populateState() + { + $app = Factory::getApplication('administrator'); + + $this->setState('message', $app->getUserState('com_componentbuilder.message')); + $app->setUserState('com_componentbuilder.message', ''); + + // Recall the 'Import from Directory' path. + $path = $app->getUserStateFromRequest($this->_context . '.import_directory', 'import_directory', $app->get('tmp_path')); + $this->setState('import.directory', $path); + parent::populateState(); + } + + public $canmerge = 1; + public $importGuidOnly = 1; + public $postfix = false; + public $forceUpdate = 0; + public $hasKey = 0; + public $sleutle = ''; + public $data = false; + public $app; + + protected $dir = false; + protected $target = false; + protected $newID = array(); + protected $packageInfo = null; + protected $noopmaker; + protected $updateAfter = array('field' => array(), 'adminview' => array()); + protected $divergedDataMover = array(); + protected $fieldTypes = array(); + protected $isMultiple = array(); + protected $tableColumns = array(); + protected $fieldImportErrors = array(); + protected $specialValue = false; + protected $checksum = null; + protected $checksumURLs = array('vdm' => 'https://raw.githubusercontent.com/vdm-io/JCB-Packages/master/', 'jcb' => 'https://raw.githubusercontent.com/vdm-io/JCB-Community-Packages/master/'); + protected $mustMerge = array('validation_rule', 'fieldtype', 'snippet', 'language', 'language_translation', 'class_extends', 'class_property', 'class_method', 'joomla_plugin_group'); + + /** + * Import an spreadsheet from either folder, url or upload. + * + * @return boolean result of import + * + */ + public function import() + { + // set the state to import + $this->setState('action', 'import'); + // get App + $this->app = Factory::getApplication(); + // get session + $session = Factory::getSession(); + // some defaults + $package = null; + $continue = false; + // get import type + $this->getType = $this->app->input->getString('gettype', NULL); + // do checksum validation + $this->checksum = $this->app->input->getString('checksum', NULL); + // get import type + $this->dataType = $session->get('dataType_VDM_IMPORTINTO', NULL); + // if we have no package + if ($package === null) + { + // we must allow unsafe with smart import since it is code being imported. + if ($this->dataType === 'smart_package') + { + $this->allow_unsafe = true; + } + // action based on get Type + switch ($this->getType) + { + case 'folder': + // Remember the 'Import from Directory' path. + $this->app->getUserStateFromRequest($this->_context . '.import_directory', 'import_directory'); + $package = $this->_getPackageFromFolder(); + break; + + case 'upload': + $package = $this->_getPackageFromUpload(); + break; + + case 'url': + $url = Factory::getApplication()->input->getString('import_url'); + if ($url === base64_encode(base64_decode($url, true))) + { + Factory::getApplication()->input->set('import_url', base64_decode($url)); + } + $package = $this->_getPackageFromUrl(); + break; + + case 'continue-ext': + $continue = true; + $package = $session->get('package', null); + $package = json_decode($package, true); + // clear session + $session->clear('package'); + $session->clear('dataType'); + $session->clear('hasPackage'); + // before we clear this, we add it locally + $packageInfo = $session->get('smart_package_info', null); + // now clear it + $session->clear('smart_package_info'); + // convert to an array if found + if ($packageInfo && JsonHelper::check($packageInfo)) + { + $this->packageInfo = json_decode($packageInfo, true); + } + break; + + default: + $package = $session->get('package', null); + if (JsonHelper::check($package)) + { + // get package + $package = json_decode($package, true); + // remove zip file + if (isset($package['packagename'])) + { + $this->remove($package['packagename']); + } + // check if dir is set + if (isset($package['dir'])) + { + // set auto loader + ComponentbuilderHelper::autoLoader('smart'); + // get install folder + $dir = JFile::stripExt($package['dir']); + // remove unziped folder + ComponentbuilderHelper::removeFolder($dir); + } + } + // clear session + $session->clear('package'); + $session->clear('dataType'); + $session->clear('hasPackage'); + $session->clear('smart_package_info'); + $back = $session->get('backto_VDM_IMPORT', NULL); + $session->clear('backto_VDM_IMPORT'); + if ($back) + { + $this->app->setUserState('com_componentbuilder.redirect_url', 'index.php?option=com_componentbuilder&view=' . $back); + } + $session->clear('backto_VDM_IMPORT'); + return false; + break; + } + } + // Was the package valid? + if (!$package || !$package['type']) + { + if (in_array($this->getType, array('upload', 'url'))) + { + $this->remove($package['packagename']); + } + + $this->app->setUserState('com_componentbuilder.message', Text::_('COM_COMPONENTBUILDER_IMPORT_UNABLE_TO_FIND_IMPORT_PACKAGE')); + return false; + } + + // first link data to table headers + if(!$continue) + { + // check if this a smart package, if true then get info + if ($this->dataType !== 'smart_package' || !$this->getInfo($package, $session)) + { + $this->app->setUserState('com_componentbuilder.message', Text::_('COM_COMPONENTBUILDER_THERE_WAS_AN_ERROR_GETTING_THE_PACKAGE_INFO')); + return false; + } + // set package to session + $package = json_encode($package); + $session->set('package', $package); + $session->set('dataType', $this->dataType); + $session->set('hasPackage', true); + return true; + } + // force update + $this->forceUpdate = $this->app->input->getInt('force_update', 0); + // show more information + $this->moreInfo = $this->app->input->getInt('more_info', 0); + // allow merge + $this->canmerge = $this->app->input->getInt('canmerge', 1); + // forch GUID only search + $this->importGuidOnly = $this->app->input->getInt('import_guid_only', 0); + // has a key + $this->hasKey = $this->app->input->getInt('haskey', 0); + // die sleutle + $this->sleutle = $this->app->input->getString('sleutle', ''); + // try to store/set data + if (!$this->setData($package)) + { + // There was an error importing the package + $msg = Text::_('COM_COMPONENTBUILDER_IMPORT_ERROR'); + $msgType = 'error'; + $back = $session->get('backto_VDM_IMPORT', NULL); + if ($back) + { + $this->app->setUserState('com_componentbuilder.redirect_url', 'index.php?option=com_componentbuilder&view='.$back); + $session->clear('backto_VDM_IMPORT'); + } + $result = false; + } + else + { + // Package imported sucessfully + $msg = Text::sprintf('COM_COMPONENTBUILDER_IMPORT_SUCCESS', $package['packagename']); + $msgType = 'success'; + $back = $session->get('backto_VDM_IMPORT', NULL); + if ($back) + { + $this->app->setUserState('com_componentbuilder.redirect_url', 'index.php?option=com_componentbuilder&view='.$back); + $session->clear('backto_VDM_IMPORT'); + } + $result = true; + } + + // Set message to qeue + $this->app->enqueueMessage($msg, $msgType); + + // remove file after import + $this->remove($package['packagename']); + + return $result; + } + + protected function getInfo(&$package, &$session) + { + // set the data + if(isset($package['dir'])) + { + // set auto loader + ComponentbuilderHelper::autoLoader('smart'); + // extract the package + if (JFile::exists($package['dir'])) + { + // does this package pass a checksum + $checksum = false; + $checksumStatus = 'warning'; + $checksumMessage = Text::_('COM_COMPONENTBUILDER_PLEASE_NOTE_THAT_THIS_PACKAGE_BHAS_NOB_CHECKSUM_VALIDATION'); + // do hash validation here for git repos + if (UtilitiesStringHelper::check($this->checksum) && isset($this->checksumURLs[$this->checksum])) + { + // get packages checksums + $checksums = FileHelper::getContent($this->checksumURLs[$this->checksum].'checksum.json'); + if (JsonHelper::check($checksums)) + { + // convert to array + $checksums = json_decode($checksums, true); + // get package name + $packageName = basename($package['dir']); + // check if package is found + if (isset($checksums[$packageName])) + { + // validate checksum + if ($checksums[$packageName] === sha1_file($package['dir'])) + { + $validator = $this->checksumURLs[$this->checksum].str_replace('.zip', '.sha', $packageName); + $checksumMessage = Text::sprintf('COM_COMPONENTBUILDER_THIS_PACKAGE_BPASSEDB_THE_CHECKSUM_VALIDATIONBR_BR_SMALLMANUALLY_ALSO_VALIDATE_THAT_THE_CORRECT_CHECKSUM_WAS_USEDSMALLBR_THIS_CHECKSUM_BSB_MUST_BE_THE_SAME_AS_THE_ONE_FOUND_A_S_SA', $checksums[$packageName], 'href="'.$validator.'" target="_blank" title="verify checksum">', $validator); + $checksumStatus = 'Success'; + $checksum = true; + } + } + // set error + if (!$checksum) + { + $checksumMessage = Text::_('COM_COMPONENTBUILDER_BBEST_TO_NOT_CONTINUEBBR_YOU_CAN_REFRESH_AND_TRY_AGAINBR_BUT_NOTE_THAT_THIS_PACKAGE_BFAILEDB_CHECKSUM_VALIDATION_THIS_COULD_BE_A_SERIOUS_SECURITY_BREACH_DO_NOT_CONTINUE'); + $checksumStatus = 'error'; + } + } + // set error + else + { + $checksumMessage = Text::_('COM_COMPONENTBUILDER_BBEST_TO_NOT_CONTINUEBBR_WE_COULD_NOT_LOAD_THE_CHECKSUM_FOR_THIS_PACKAGE_AND_SO_NO_VALIDATION_WAS_POSSIBLE_THIS_MAY_BE_DUE_TO_YOUR_NETWORK_OR_A_CHANGE_TO_THAT_PACKAGE_NAME'); + $checksumStatus = 'error'; + } + } + // do not have check sum validation + $this->app->enqueueMessage($checksumMessage, $checksumStatus); + // get the zip adapter + $zip = JArchive::getAdapter('zip'); + // set the directory name + $this->dir = JFile::stripExt($package['dir']); + // unzip the package + $zip->extract($package['dir'], $this->dir); + // check for database file + $infoFile = $this->dir . '/info.vdm'; + if (JFile::exists($infoFile)) + { + // load the data + if ($info = FileHelper::getContent($infoFile)) + { + // unlock the info data + if ((($info_ = PackageFactory::_('Crypt')->decrypt($info, 'local')) !== null && JsonHelper::check($info_)) || + (($info_ = PackageFactory::_('Crypt')->decrypt($info, 'local.legacy')) !== null && JsonHelper::check($info_)) || + (($info_ = PackageFactory::_('Crypt')->decrypt($info, 'local.fof')) !== null && JsonHelper::check($info_))) + { + // we only continue if info could be opened + $session->set('smart_package_info', $info_); + return true; + } + // do not have check sum validation + $this->app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_HTWOWE_COULD_NOT_OPEN_THE_PACKAGEHTWOTHIS_COULD_BE_DUE_TO_THE_FOFENCRYPTION_THAT_IS_NO_LONGER_SUPPORTED_IN_JOOMLA_PLEASE_EXPORT_YOUR_PACKAGES_WITH_JCB_VTHREEZEROELEVENPRO_OR_VTWOONETWOSEVENTEENPUBLIC_OR_HIGHER_TO_BE_ABLE_TO_IMPORT_IT_INTO_THIS_VERSION_OF_JCB'), 'error'); + } + } + ComponentbuilderHelper::removeFolder($this->dir); + } + } + return false; + } + + /** + * Works out an importation spreadsheet from a HTTP upload + * + * @return spreadsheet definition or false on failure + */ + protected function _getPackageFromUpload() + { + // Get the uploaded file information + $app = Factory::getApplication(); + $input = $app->input; + + // Do not change the filter type 'raw'. We need this to let files containing PHP code to upload. See JInputFiles::get. + $userfile = $input->files->get('import_package', null, 'raw'); + + // Make sure that file uploads are enabled in php + if (!(bool) ini_get('file_uploads')) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_WARNIMPORTFILE'), 'warning'); + return false; + } + + // If there is no uploaded file, we have a problem... + if (!is_array($userfile)) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_NO_FILE_SELECTED'), 'warning'); + return false; + } + + // Check if there was a problem uploading the file. + if ($userfile['error'] || $userfile['size'] < 1) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_WARNIMPORTUPLOADERROR'), 'warning'); + return false; + } + + // Build the appropriate paths + $config = Factory::getConfig(); + $tmp_dest = $config->get('tmp_path') . '/' . $userfile['name']; + $tmp_src = $userfile['tmp_name']; + + // Move uploaded file + $p_file = File::upload($tmp_src, $tmp_dest, $this->use_streams, $this->allow_unsafe, $this->safeFileOptions); + + // Was the package downloaded? + if (!$p_file) + { + $session = Factory::getSession(); + $session->clear('package'); + $session->clear('dataType'); + $session->clear('hasPackage'); + // was not uploaded + return false; + } + + // check that this is a valid spreadsheet + $package = $this->check($userfile['name']); + + return $package; + } + + /** + * Import an spreadsheet from a directory + * + * @return array Spreadsheet details or false on failure + * + */ + protected function _getPackageFromFolder() + { + $app = Factory::getApplication(); + $input = $app->input; + + // Get the path to the package to import + $p_dir = $input->getString('import_directory'); + $p_dir = Path::clean($p_dir); + // Did you give us a valid path? + if (!file_exists($p_dir)) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_PLEASE_ENTER_A_PACKAGE_DIRECTORY'), 'warning'); + return false; + } + + // Detect the package type + $type = $this->getType; + + // Did you give us a valid package? + if (!$type) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE'), 'warning'); + } + + // check the extention + if(!$this->checkExtension($p_dir)) + { + // set error message + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); + return false; + } + + $package['packagename'] = null; + $package['dir'] = $p_dir; + $package['type'] = $type; + + return $package; + } + + /** + * Import an spreadsheet from a URL + * + * @return Package details or false on failure + * + */ + protected function _getPackageFromUrl() + { + $app = Factory::getApplication(); + $input = $app->input; + + // Get the URL of the package to import + $url = $input->getString('import_url'); + + // Did you give us a URL? + if (!$url) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_ENTER_A_URL'), 'warning'); + return false; + } + + // Download the package at the URL given + $p_file = InstallerHelper::downloadPackage($url); + + // Was the package downloaded? + if (!$p_file) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_INVALID_URL'), 'warning'); + return false; + } + + // check that this is a valid spreadsheet + $package = $this->check($p_file); + + return $package; + } + + /** + * Check a file and verifies it as a spreadsheet file + * Supports .csv .xlsx .xls and .ods + * + * @param string $p_filename The uploaded package filename or import directory + * + * @return array of elements + * + */ + protected function check($archivename) + { + $app = Factory::getApplication(); + // Clean the name + $archivename = Path::clean($archivename); + + // check the extention + if(!$this->checkExtension($archivename)) + { + // Cleanup the import files + $this->remove($archivename); + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); + return false; + } + + $config = Factory::getConfig(); + // set Package Name + $check['packagename'] = $archivename; + + // set directory + $check['dir'] = $config->get('tmp_path'). '/' .$archivename; + + // set type + $check['type'] = $this->getType; + + return $check; + } + + /** + * Check the extension + * + * @param string $file Name of the uploaded file + * + * @return boolean True on success + * + */ + protected function checkExtension($file) + { + // check the extension + switch(strtolower(pathinfo($file, PATHINFO_EXTENSION))) + { + case 'zip': + if ($this->dataType === 'smart_package') + { + return true; + } + break; + } + return false; + } + + /** + * Clean up temporary uploaded spreadsheet + * + * @param string $package Name of the uploaded spreadsheet file + * + * @return boolean True on success + * + */ + protected function remove($package) + { + $config = Factory::getConfig(); + $package = $config->get('tmp_path'). '/' .$package; + + // Is the package file a valid file? + if (is_file($package)) + { + File::delete($package); + } + elseif (is_file(Path::clean($package))) + { + // It might also be just a base filename + File::delete(Path::clean($package)); + } + } + + /** + * Set the data from the spreadsheet to the database + * + * @param string $package Paths to the uploaded package file + * + * @return boolean false on failure + * + **/ + protected function setData($package) + { + $jinput = Factory::getApplication()->input; + // set the data based on the type of import being done + if ('continue-ext' === $this->getType) + { + // set the data + if(isset($package['dir'])) + { + // set auto loader + ComponentbuilderHelper::autoLoader('smart'); + // extract the package + if (JFile::exists($package['dir'])) + { + // set the directory name + $this->dir = JFile::stripExt($package['dir']); + // check for database file + $dbFile = $this->dir . '/db.vdm'; + if (!JFile::exists($dbFile)) + { + // get the zip adapter + $zip = JArchive::getAdapter('zip'); + // unzip the package + $zip->extract($package['dir'], $this->dir); + } + // check again + if (JFile::exists($dbFile)) + { + // load the data + if ($data = FileHelper::getContent($dbFile)) + { + // prep the data + if ($this->extractData($data)) + { + if (isset($this->data['joomla_component']) && UtilitiesArrayHelper::check($this->data['joomla_component'])) + { + // save the smart data + if ($this->saveSmartComponents()) + { + ComponentbuilderHelper::removeFolder($this->dir); + return true; + } + } + } + } + } + ComponentbuilderHelper::removeFolder($this->dir); + } + } + } + return false; + } + + /** + * Extract the data from the string + * + * @param string $data The data string + * + * @return object false on failure + * + **/ + protected function extractData($data) + { + // remove all line breaks + if (($data = $this->decrypt($data, $this->sleutle)) !== null) + { + // final check if we have success + $data = @unserialize($data); + if (UtilitiesArrayHelper::check($data)) + { + // set the data global + $this->data = $data; + return true; + } + $this->app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_HTWODATA_IS_CORRUPTHTWOTHIS_COULD_BE_DUE_TO_BKEY_ERRORB_OR_BROKEN_PACKAGE'), 'error'); + return false; + } + $this->app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_HTWODATA_IS_CORRUPTHTWOTHIS_COULD_BE_DUE_TO_BROKEN_PACKAGE'), 'error'); + return false; + } + + /** + * Save the smart components + * + * @return boolean false on failure + * + **/ + protected function saveSmartComponents() + { + // get user object + $this->user = Factory::getUser(); + // set some defaults + $this->today = Factory::getDate()->toSql(); + // if we can't merge add postfix to name + if (!$this->canmerge) + { + // set some postfix + $this->postfix = ' ('.UtilitiesStringHelper::random(2).')'; + } + // the array of tables to store + $tables = array( + 'power', 'validation_rule', 'fieldtype', 'field', 'admin_view', 'snippet', 'dynamic_get', 'custom_admin_view', 'site_view', + 'template', 'layout', 'joomla_component', 'language', 'custom_code', 'placeholder', 'class_extends', + 'joomla_module', 'joomla_module_files_folders_urls', 'joomla_module_updates', + 'joomla_plugin_group', 'class_property', 'class_method', 'joomla_plugin', 'joomla_plugin_files_folders_urls', 'joomla_plugin_updates', + 'admin_fields', 'admin_fields_conditions', 'admin_fields_relations', 'admin_custom_tabs', 'component_admin_views', + 'component_site_views', 'component_custom_admin_views', 'component_updates', 'component_mysql_tweaks', + 'component_custom_admin_menus', 'component_config', 'component_dashboard', 'component_files_folders', + 'component_placeholders', 'component_modules', 'component_plugins', 'language_translation' + ); + // get prefix + $prefix = $this->_db->getPrefix(); + // get local tables + $localTables = $this->_db->getTableList(); + // smart table loop + foreach ($tables as $table) + { + // only continue the import if the table is available locally + if (in_array($prefix . 'componentbuilder_' . $table, $localTables)) + { + // save the table to database + if (!$this->saveSmartItems($table)) + { + return false; + } + } + else + { + // check if it is the power table + if ($table === 'power') + { + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_TABLE_BSB_NOT_FOUND_IN_THE_LOCAL_DATABASE_SO_ITS_VALUES_COULD_NOT_BE_IMPORTED_THE_WHOLE_POWERS_FEATURE_IS_ONLY_AVAILABLE_TO_A_HREFSPRO_MEMBERSA_AT_THIS_TIME', '#__componentbuilder_' . $table, '"https://vdm.bz/get-jcb-pro-membership" target="_blank" title="Join PRO Membership today!"'), 'warning'); + } + else + { + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_TABLE_BSB_NOT_FOUND_IN_THE_LOCAL_DATABASE_SO_ITS_VALUES_COULD_NOT_BE_IMPORTED_PLEASE_UPDATE_YOUR_JCB_INSTALL_AND_TRY_AGAIN', '#__componentbuilder_' . $table), 'warning'); + } + } + } + // do a after all run on all items that need it + $this->updateAfterAll(); + // finally move the old datasets + $this->moveDivergedData(); + // lets move all the files to its correct location + if (!$this->moveSmartStuff()) + { + return false; + } + return true; + } + + /** + * Save the smart items + * + * @param string $table The table + * + * @return boolean false on failure + * + **/ + public function saveSmartItems($table) + { + if (isset($this->data[$table]) && UtilitiesArrayHelper::check($this->data[$table])) + { + // add pre import event + $this->preImportEvent($table); + // get global action permissions + $canDo = ComponentbuilderHelper::getActions($table); + $canEdit = $canDo->get('core.edit'); + $canState = $canDo->get('core.edit.state'); + $canCreate = $canDo->get('core.create'); + // check if we should allow merge of local values + $canmerge = $this->allowMerge($table); + // set id keeper + if (!isset($this->newID[$table])) + { + $this->newID[$table] = array(); + } + foreach ($this->data[$table] as $item) + { + $oldID = (int) $item->id; + // first check if exist + if ($canmerge && ($local = $this->getLocalItem($item, $table, 1)) !== false) + { + // display more import info + if ($this->moreInfo) + { + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_BSB_WAS_FOUND', $table.' id:'.$oldID . '->' . $local->id), 'success'); + } + $dbDate = strtotime($item->modified); + $localDate = strtotime($local->modified); + // okay we have it local (check if the version is newer) + if ($this->forceUpdate == 1 || $dbDate > $localDate) + { + // add some local values to item to combine + if ($table === 'language_translation') + { + $item->localComponents = $local->components; + $item->localModules = $local->modules; + $item->localPlugins = $local->plugins; + $item->localTranslation = $local->translation; + } + // make sure we have the correct ID set + $item->id = $local->id; + // yes it is newer, lets update (or is being forced) + if ($canEdit && ($id = $this->updateLocalItem($item, $table, $canState)) !== false) + { + // we had success in + $this->newID[$table][$oldID] = (int) $local->id; + // display more import info + if ($this->moreInfo) + { + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_BSB_HAS_BEEN_UPDATED', $table.' id:'.$oldID . '->' . $id), 'success'); + } + } + else + { + $notice = '!'; + if (!$canEdit) + { + $notice = Text::sprintf("COM_COMPONENTBUILDER__SINCE_YOU_DONT_HAVE_PERMISSION_TO_EDIT_S", $table); + } + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_BSB_COULD_NOT_BE_IMPORTEDS', $table.' id:'.$oldID, $notice), 'error'); + } + } + // insure to load the local ID to link imported values with it + if (!isset($this->newID[$table][$oldID])) + { + $this->newID[$table][$oldID] = (int) $local->id; + } + } + elseif ($canCreate && ($id = $this->addLocalItem($item, $table)) !== false) + { + // not found in local db so add + $this->newID[$table][$oldID] = (int) $id; + // display more import info + if ($this->moreInfo) + { + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_BSB_HAS_BEEN_IMPORTED', $table.' id:'.$oldID . '->' . $id), 'success'); + } + } + else + { + $notice = '!'; + if (!$canCreate) + { + $notice = Text::sprintf("COM_COMPONENTBUILDER__SINCE_YOU_DONT_HAVE_PERMISSION_TO_CREATE_S", $table); + } + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_BSB_COULD_NOT_BE_IMPORTEDS', $table.' id:'.$oldID, $notice), 'error'); + } + } + } + return true; + } + + /** + * Check if this table needs some house cleaning before we import the data + * + * @return void + * + **/ + protected function preImportEvent($table) + { + // if this is custom code table + // remove all custom code linked to these components + // since some code may have been removed and changed + // best unpublish all and let the import publish those still active + if ('custom_code' === $table && isset($this->newID['joomla_component']) && UtilitiesArrayHelper::check($this->newID['joomla_component'])) + { + $query = $this->_db->getQuery(true); + // Field to update. + $fields = array( + $this->_db->quoteName('published') . ' = 0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $this->_db->quoteName('component') . ' IN (' . implode(', ', array_values($this->newID['joomla_component'])) . ')' + ); + + $query->update($this->_db->quoteName('#__componentbuilder_custom_code'))->set($fields)->where($conditions); + + $this->_db->setQuery($query); + $this->_db->execute(); + } + } + + /** + * Check if we should allow merge for this table + * + * @return boolean + * + **/ + protected function allowMerge($table) + { + if ($this->canmerge == 1 || in_array($table, $this->mustMerge)) + { + return true; + } + return false; + } + + /** + * Move the smart content (files & folders) into place + * + * @return boolean false on failure + * + **/ + protected function moveSmartStuff() + { + // make sure to first unlock files + $this->unLockFiles(); + // set params + $params = ComponentHelper::getParams('com_componentbuilder'); + // set custom folder path + $customPath = str_replace('//', '/', $params->get('custom_folder_path', JPATH_COMPONENT_ADMINISTRATOR.'/custom')); + $imagesPath = str_replace('//', '/', JPATH_SITE . '/images'); + $success = true; + // check if we have custom files + $customDir = str_replace('//', '/', $this->dir . '/custom'); + if (JFolder::exists($customDir)) + { + // great we have some custom stuff lets move it + if (!JFolder::copy($customDir, $customPath,'',true)) + { + $this->app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_BCUSTOM_FILESB_NOT_MOVED_TO_CORRECT_LOCATION'), 'error'); + $success = false; + } + // display more import info + elseif ($this->moreInfo) + { + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_SOME_BCUSTOM_FILESB_WERE_MOVED_TO_BSB', $customPath), 'success'); + } + } + // check if we have images + $imageDir = str_replace('//', '/', $this->dir . '/images'); + if (JFolder::exists($imageDir)) + { + // great we have some images lets move them + if (!JFolder::copy($imageDir, $imagesPath,'',true)) + { + $this->app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_BIMAGESB_NOT_MOVED_TO_CORRECT_LOCATION'), 'error'); + $success = false; + } + // display more import info + elseif ($this->moreInfo) + { + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_SOME_BIMAGESB_WERE_MOVED_TO_BSB', $imagesPath), 'success'); + } + } + // now move the dynamic files if found + $dynamicDir = str_replace('//', '/', $this->dir . '/dynamic'); + if (JFolder::exists($dynamicDir)) + { + // get a list of folders + $folders = JFolder::folders($dynamicDir); + // check if we have files + if(UtilitiesArrayHelper::check($folders)) + { + foreach ($folders as $folder) + { + $destination = $this->setDynamicPath($folder); + $fullPath = str_replace('//', '/', $dynamicDir . '/' . $folder); + if (!JFolder::exists($fullPath) || !JFolder::copy($fullPath, $destination,'',true)) + { + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_FOLDER_BSB_WAS_NOT_MOVED_TO_BSB', $folder, $destination), 'error'); + $success = false; + } + // display more import info + elseif ($this->moreInfo) + { + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_FOLDER_BSB_WAS_MOVED_TO_BSB', $folder, $destination), 'success'); + } + } + } + // get a list of files + $files = JFolder::files($dynamicDir); + // check if we have files + if(UtilitiesArrayHelper::check($files)) + { + foreach ($files as $file) + { + $destination = $this->setDynamicPath($file); + $fullPath = str_replace('//', '/', $dynamicDir . '/' . $file); + if (!JFile::exists($fullPath) || !JFile::copy($fullPath, $destination)) + { + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_FILE_BSB_WAS_NOT_MOVED_TO_BSB', $file, $destination), 'error'); + $success = false; + } + // display more import info + elseif ($this->moreInfo) + { + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_FILE_BSB_WAS_MOVED_TO_BSB', $file, $destination), 'success'); + } + } + } + } + return $success; + } + + /** + * Method to unlock all files in all folders of this package + * + * @return void + */ + protected function unLockFiles() + { + // lock the data if set + if(UtilitiesStringHelper::check($this->sleutle) && strlen($this->sleutle) == 32) + { + // we must first store the current working directory + $joomla = getcwd(); + // to avoid that it decrypt the db and info file again we must move per/folder + $folders = array('images', 'custom', 'dynamic'); + // loop the folders + foreach ($folders as $folder) + { + $subPath = str_replace('//', '/', $this->dir . '/' . $folder); + // go to the package sub folder if found + if (JFolder::exists($subPath)) + { + $this->unLockFile($subPath); + } + } + // change back to working dir + chdir($joomla); + } + } + + /** + * The unlocking files + * + * @return void + */ + protected function unLockFile(&$tmpPath) + { + // we are changing the working directory to the tmp path (important) + chdir($tmpPath); + // get a list of files in the current directory tree (all) + $files = JFolder::files('.', '.', true, true); + // read in the file content + foreach ($files as $file) + { + // open the file content + if (($data = $this->decrypt(file_get_contents($file), $this->sleutle)) !== null) + { + // write the decrypted data back to file + if (!FileHelper::write($file, $data)) + { + // in case file could not be unlocked + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_FILE_BSB_COULD_NOT_BE_STORED', $file), 'error'); + } + // display more import info + elseif ($this->moreInfo) + { + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_FILE_BSB_WAS_SUCCESSFULLY_UNLOCKED', $file), 'success'); + } + } + else + { + // in case file could not be unlocked + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_FILE_BSB_COULD_NOT_BE_UNLOCKED', $file), 'error'); + } + } + } + + /** + * decrypt data + * + * @param string $data The data string + * @param string $password The key to unlock + * @param bool $force Should we force phpseclib decryption + * + * @return mixed the data, or false + * + * @since 3.0.11 + **/ + protected function decrypt(string $data, string $password, bool $force = false) + { + // remove all line breaks + $data = $this->removeLineBreaks($data); + + // make sure we have base64 + if ($this->isBase64Encoded($data)) + { + // open the data + if($this->isValidPassword($password)) + { + // try phpseclib version 3 + if(($this->isPhpseclib3Enabled() || $force) && + ($data_ = $this->decryptWithPhpseclib3($data, $password)) !== null) + { + return $data_; + } + + // try phpseclib version 2 + if(($this->isPhpseclib2Enabled() || $force) && + ($data_ = $this->decryptWithPhpseclib2($data, $password)) !== null) + { + return $data_; + } + + // try FOF the outdated method + if (($data_ = $this->decryptWithFof($data, $password)) !== null) + { + return $data_; + } + + $this->app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_HTWOWE_COULD_NOT_OPEN_THE_ENCRYPT_DATAHTWO_THIS_COULD_BE_DUE_TO_THE_FOFENCRYPTION_THAT_IS_NO_LONGER_SUPPORTED_IN_JOOMLABR_PLEASE_EXPORT_YOUR_PACKAGES_WITH_JCB_VTHREEONEONEEIGHT_OR_HIGHER_TO_BE_ABLE_TO_IMPORT_IT_INTO_THIS_VERSION_OF_JCB'), 'error'); + } + else + { + return base64_decode($data); + } + } + + return false; + } + + /** + * Removes all line breaks from a string + * + * @param string $data + * + * @return string + */ + private function removeLineBreaks(string $data): string + { + return str_replace("\n", '', $data); + } + + /** + * Check if the data is base64 encoded + * + * @param string $data + * + * @return bool + */ + private function isBase64Encoded(string $data): bool + { + return $data === base64_encode(base64_decode($data, true)); + } + + /** + * Check if a password is set and has a length of 32 characters + * + * @param string $password + * + * @return bool + */ + private function isValidPassword(string $password): bool + { + return UtilitiesStringHelper::check($password) && strlen($password) == 32; + } + + /** + * Check if we can use phpseclib library version 2 + * + * @return bool + */ + private function isPhpseclib2Enabled(): bool + { + return (bool) isset($this->packageInfo['phpseclib']) && $this->packageInfo['phpseclib']; + } + + /** + * Decrypts data using the phpseclib library version 2 + * + * @param string $data + * @param string $password + * + * @return string|null + */ + private function decryptWithPhpseclib2(string $data, string $password): ?string + { + $data_ = PackageFactory::_('Crypt')->decrypt($data, 'legacy', $password); + if ($data_ !== null) + { + return strcmp($data, $data_) !== 0 ? $data_ : null; + } + return null; + } + + /** + * Check if we can use phpseclib library version 3 + * + * @return bool + */ + private function isPhpseclib3Enabled(): bool + { + return (bool) isset($this->packageInfo['phpseclib3']) && $this->packageInfo['phpseclib3']; + } + + /** + * Decrypts data using the phpseclib library version 3 + * + * @param string $data + * @param string $password + * + * @return string|null + */ + private function decryptWithPhpseclib3(string $data, string $password): ?string + { + $data_ = PackageFactory::_('Crypt')->decrypt($data, 'aes', $password); + if ($data_ !== null) + { + return strcmp($data, $data_) !== 0 ? $data_ : null; + } + return null; + } + + /** + * Decrypts data using the FOF library (outdated method) + * + * @param string $data + * @param string $password + * + * @return string|null + */ + private function decryptWithFof(string $data, string $password): ?string + { + $data_ = PackageFactory::_('Crypt')->decrypt($data, 'fof', $password); + if ($data_ !== null) + { + return strcmp($data, $data_) !== 0 ? $data_ : null; + } + return null; + } + + /** + * Update some items after all + * + * @return void + * + **/ + public function updateAfterAll() + { + // update the fields + if (isset($this->updateAfter['field']) && UtilitiesArrayHelper::check($this->updateAfter['field'])) + { + // update repeatable + foreach ($this->updateAfter['field'] as $field => $action) + { + // if added we must get the ID now, yet if update the id is already set + if ('add' === $action && isset($this->newID['field'][$field])) + { + $field = $this->newID['field'][$field]; + } + // get the field from db + if ($xml = GetHelper::var('field', $field, 'id', 'xml')) + { + if (JsonHelper::check($xml)) + { + $xml = json_decode($xml); + $fields = GetHelper::between($xml, 'fields="', '"'); + $fieldsSets = array(); + if (strpos($fields, ',') !== false) + { + // multiple fields + $fieldsSets = array_map('trim', (array) explode(',', $fields)); + } + elseif (is_numeric($fields)) + { + // single field + $fieldsSets[] = (int) $fields; + } + // update the fields + if (UtilitiesArrayHelper::check($fieldsSets)) + { + $bucket = array(); + foreach ($fieldsSets as $id) + { + if (isset($this->newID['field'][(int) $id])) + { + $bucket[] = $this->newID['field'][(int) $id]; + } + else + { + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_BMULTIPLE_FIELD_REPEATABLE_MODEB_IDS_MISMATCH_IN_BFIELDSB_AND_WAS_EMREMOVEDEM_FROM_THE_FIELD', $id, $field), 'warning'); + } + } + if (UtilitiesArrayHelper::check($bucket)) + { + $string = implode(',', $bucket); + $xml = json_encode(str_replace('fields="' . $fields . '"', 'fields="' . $string . '"', $xml)); + } + else + { + $xml = ''; + } + $object = new \stdClass; + $object->id = $field; + $object->xml = $xml; + // update the field + $this->_db->updateObject('#__componentbuilder_field', $object, 'id'); + } + } + } + } + } + // do a after all run on admin views that need it + if (isset($this->updateAfter['adminview']) && UtilitiesArrayHelper::check($this->updateAfter['adminview'])) + { + // update the addlinked_views + foreach ($this->updateAfter['adminview'] as $adminview => $action) + { + // if added we must get the ID now, yet if update the id is already set + if ('add' === $action && isset($this->newID['admin_view'][(int) $adminview])) + { + $adminview = $this->newID['admin_view'][(int) $adminview]; + } + // get the field from db + if ($addlinked_views = GetHelper::var('admin_view', $adminview, 'id', 'addlinked_views')) + { + if (JsonHelper::check($addlinked_views)) + { + $addlinked_views = json_decode($addlinked_views, true); + // convert Repeatable Fields + if (UtilitiesArrayHelper::check($addlinked_views) && isset($addlinked_views['adminview'])) + { + $addlinked_views = ComponentbuilderHelper::convertRepeatable($addlinked_views, 'addlinked_views'); + } + // update the view IDs + if (UtilitiesArrayHelper::check($addlinked_views)) + { + // only update the view IDs + $addlinked_views = $this->updateIDs($addlinked_views, 'admin_view', array('adminview' => 'admin_view')); + } + // update the fields + $object = new \stdClass; + $object->id = $adminview; + $object->addlinked_views = json_encode($addlinked_views, JSON_FORCE_OBJECT); + // update the admin view + $this->_db->updateObject('#__componentbuilder_admin_view', $object, 'id'); + } + } + } + } + // update the joomla_component dashboard + if (isset($this->updateAfter['joomla_component']) && UtilitiesArrayHelper::check($this->updateAfter['joomla_component'])) + { + // update dashboard of the components + foreach ($this->updateAfter['joomla_component'] as $component => $action) + { + // if added we must get the ID now, yet if update the id is already set + if ('add' === $action && isset($this->newID['joomla_component'][(int) $component])) + { + $component = $this->newID['joomla_component'][(int) $component]; + } + // get the dashboard from db + if ($dashboard = GetHelper::var('joomla_component', $component, 'id', 'dashboard')) + { + if (UtilitiesStringHelper::check($dashboard)) + { + // get id + $id = (int) preg_replace("/[^0-9]/", "", $dashboard); + // update the value + $update = false; + // admin_view + if ((strpos($dashboard, 'A') !== false || strpos($dashboard, 'a') !== false) && isset($this->newID['admin_view'][$id])) + { + // set the new value + $dashboard = 'A_' . $this->newID['admin_view'][$id]; + // update the value + $update = true; + } + // custom_admin_view + elseif ((strpos($dashboard, 'C') !== false || strpos($dashboard, 'c') !== false) && isset($this->newID['custom_admin_view'][$id])) + { + // set the new value + $dashboard = 'C_' . $this->newID['custom_admin_view'][$id]; + // update the value + $update = true; + } + // did we get a new value + if ($update) + { + // now update the joomla_component dashboard value + $object = new \stdClass; + $object->id = (int) $component; + $object->dashboard = $dashboard; + // update the admin view + $this->_db->updateObject('#__componentbuilder_joomla_component', $object, 'id'); + } + } + } + } + } + // update the admin_fields_relations + if (isset($this->updateAfter['relations']) && UtilitiesArrayHelper::check($this->updateAfter['relations'])) + { + // update repeatable + foreach ($this->updateAfter['relations'] as $relation => $action) + { + // check if we must update this relation + $update = false; + // if added we must get the ID now, yet if update the id is already set + if ('add' === $action && isset($this->newID['admin_fields_relations'][$relation])) + { + $relation = $this->newID['admin_fields_relations'][$relation]; + } + // get the set relation from db + if ($addrelations = GetHelper::var('admin_fields_relations', $relation, 'id', 'addrelations')) + { + if (JsonHelper::check($addrelations)) + { + $addrelations = json_decode($addrelations, true); + if (UtilitiesArrayHelper::check($addrelations)) + { + foreach ($addrelations as $nr => &$value) + { + // reset the buckets + $bucket = array(); + // get fields + $found = GetHelper::allBetween($value['set'], '[field=', ']'); + // if found + if (UtilitiesArrayHelper::check($found)) + { + $bucket[] = $found; + } + // get fields + $found = GetHelper::allBetween($value['set'], '$item->{', '}'); + // if found + if (UtilitiesArrayHelper::check($found)) + { + $bucket[] = $found; + } + // check if we have values + if (UtilitiesArrayHelper::check($bucket)) + { + $fields = UtilitiesArrayHelper::merge($bucket); + // reset the buckets + $bucket = array(); + if (UtilitiesArrayHelper::check($fields)) + { + foreach ($fields as $field) + { + if (isset($this->newID['field'][(int) $field])) + { + $bucket['[field=' . (int) $field . ']'] = '[field=' . (int) $this->newID['field'][(int) $field] . ']'; + $bucket['$item->{' . (int) $field . '}'] = '$item->{' . (int) $this->newID['field'][(int) $field] . '}'; + } + else + { + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_BADMIN_FIELDS_RELATIONSB_IDS_MISMATCH_IN_BFIELDSB_AND_WAS_NOT_UPDATED_IN_THE_CUSTOM_CODE', $relation, $field), 'warning'); + } + } + // check if we have a bucket of values to update + if (UtilitiesArrayHelper::check($bucket)) + { + $value['set'] = str_replace(array_keys($bucket), array_values($bucket), $value['set']); + $update = true; + } + } + } + } + // update only if needed + if ($update) + { + $object = new \stdClass; + $object->id = $relation; + $object->addrelations = json_encode($addrelations, JSON_FORCE_OBJECT); + // update the field + $this->_db->updateObject('#__componentbuilder_admin_fields_relations', $object, 'id'); + } + } + } + } + } + } + // update the verious power linked to these powers + if (isset($this->updateAfter['power']) && UtilitiesArrayHelper::check($this->updateAfter['power'])) + { + // update repeatable + foreach ($this->updateAfter['power'] as $power => $action) + { + // check if we must update this power + $update = false; + // if added we must get the ID now, yet if update the id is already set + if ('add' === $action && isset($this->newID['power'][$power])) + { + $power = $this->newID['power'][$power]; + } + // get the power + $query = $this->_db->getQuery(true); + $query->select(array('a.id', 'a.property_selection', 'a.method_selection')); + $query->from($this->_db->quoteName('#__componentbuilder_power', 'a')); + $query->where($this->_db->quoteName('a.id') . ' = '. (int) $power); + // see if we get an item + $this->_db->setQuery($query); + $this->_db->execute(); + if ($this->_db->getNumRows()) + { + $item = $this->_db->loadObject(); + // subform fields to target + $updaterT = array( + // subformfield => array( field => type_value ) + 'property_selection' => array('property' => 'class_property'), + 'method_selection' => array('method' => 'class_method') + ); + // update the subform ids + $this->updateSubformsIDs($item, 'power', $updaterT); + // update the power + $this->_db->updateObject('#__componentbuilder_power', $item, 'id'); + } + } + } + } + + /** + * Moving of diverged data + * + * @return void + * + **/ + public function moveDivergedData() + { + // check if there is data to move + if (UtilitiesArrayHelper::check($this->divergedDataMover)) + { + foreach($this->divergedDataMover as $table => $values) + { + foreach($values as $value) + { + // first check if exist (only add if it does not) + if (!$this->getLocalItem($value, $table, 1, 1, true)) + { + // add the diverged data + $this->addLocalItem($value, $table, true); + } + } + } + } + } + + /** + * Update Many Params IDs + * + * @param array $values The values to update the IDs in + * @param string $table The table these values belong to + * @param array $targets The target to update and its type + * + * @return void + */ + private function updateParamIDs(&$item, $table, $targets) + { + // update the params fields if exist + if (isset($item->params) && JsonHelper::check($item->params)) + { + $paramsArray = json_decode($item->params, true); + if (UtilitiesArrayHelper::check($paramsArray)) + { + foreach ($targets as $field => $targetArray) + { + if (isset($paramsArray[$field])) + { + $target_array = array(); + foreach ($targetArray as $key => $field_table) + { + // sub form in params + if (strpos($key, '.') !==false) + { + $key_array = explode('.', $key); + // set the target + $target_array[$key_array[0]][$key_array[1]] = $field_table; + } + elseif (isset($paramsArray[$field][$key])) + { + // load it back + $paramsArray[$field] = $this->setNewID($paramsArray[$field], $key, $field_table, $table); + } + } + // check if we had some subforms + if (UtilitiesArrayHelper::check($target_array)) + { + $paramsArray[$field] = $this->updateIDs($paramsArray[$field], $table, $target_array); + } + } + } + } + // add the params back + $item->params = json_encode($paramsArray, JSON_FORCE_OBJECT); + } + } + + /** + * Update Many Subform IDs + * + * @param array $values The values to update the IDs in + * @param string $table The table these values belong to + * @param array $targets The target to update and its type + * + * @return void + */ + private function updateSubformsIDs(&$item, $table, $targets) + { + // update the repeatable fields + foreach ($targets as $field => $targetArray) + { + if (isset($item->{$field}) && JsonHelper::check($item->{$field})) + { + $updateArray = json_decode($item->{$field}, true); + if (UtilitiesArrayHelper::check($updateArray)) + { + // load it back + $item->{$field} = json_encode($this->updateIDs($updateArray, $table, $targetArray), JSON_FORCE_OBJECT); + } + } + } + } + + /** + * Update IDs + * + * @param array $values The values to update the IDs in + * @param string $table The table these values belong to + * @param array $targets The target to update and its type + * + * @return void + */ + private function updateIDs($values, $table, $targets) + { + $isJson = false; + if (JsonHelper::check($values)) + { + $values = json_decode($values, true); + $isJson = true; + } + // now update the fields + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $nr => &$value) + { + foreach ($targets as $target => $target_type) + { + if (isset($value[$target])) + { + $value = $this->setNewID($value, $target, $target_type, $table); + } + } + } + } + if ($isJson) + { + return json_encode($values, JSON_FORCE_OBJECT); + } + return $values; + } + + /** + * Set the new ID + * + * @param array $item The values to update the IDs in + * @param string $target The target field + * @param string $type The table of that field + * @param string $table The table these values belong to + * + * @return boolean True on success + * + */ + private function setNewID($item, $target, $type, $table) + { + $isJson = false; + if (JsonHelper::check($item)) + { + $item = json_decode($item, true); + $isJson = true; + } + if (UtilitiesArrayHelper::check($item) && isset($item[$target])) + { + // set item ID + $itemId = (isset($item['id'])) ? $item['id'] : 'id_unknow'; + // check if it is json + $isJsonTarget = false; + if (JsonHelper::check($item[$target])) + { + $item[$target] = json_decode($item[$target], true); + $isJsonTarget = true; + } + // update the target + if (UtilitiesStringHelper::check($item[$target]) || is_numeric($item[$target])) + { + if ($item[$target] <= 0) + { + if ($item[$target] == 0) + { + $item[$target] = ''; + } + } + elseif (isset($this->newID[$type][(int) $item[$target]])) + { + $item[$target] = $this->newID[$type][(int) $item[$target]]; + } + else + { + $this->enqueueIdMismatchMessage($item[$target], $itemId, $target, $type, $table); + $item[$target] = ''; + } + } + elseif (UtilitiesArrayHelper::check($item[$target])) + { + // the bucket to load the items back + $bucket = array(); + foreach ($item[$target] as $nr => $id) + { + if ($id <= 0) + { + if ($id == 0) + { + continue; + } + // we add negative numbers back + $bucket[] = $id; + } + elseif ((UtilitiesStringHelper::check($id) || is_numeric($id)) && isset($this->newID[$type][(int) $id])) + { + $bucket[] = $this->newID[$type][(int) $id]; + } + else + { + $this->enqueueIdMismatchMessage($id, $itemId, $target, $type, $table); + } + } + // set ids back + if (UtilitiesArrayHelper::check($bucket)) + { + $item[$target] = $bucket; + } + } + // convert back to json + if ($isJsonTarget) + { + $item[$target] = json_encode($item[$target], JSON_FORCE_OBJECT); + } + } + elseif (ObjectHelper::check($item) && isset($item->{$target})) + { + // set item ID + $itemId = (isset($item->id)) ? $item->id : 'id_unknow'; + // check if it is json + $isJsonTarget = false; + if (JsonHelper::check($item->{$target})) + { + $item->{$target} = json_decode($item->{$target}, true); + $isJsonTarget = true; + } + // update the target + if (UtilitiesStringHelper::check($item->{$target}) || is_numeric($item->{$target})) + { + if ($item->{$target} <= 0) + { + if ($item->{$target} == 0) + { + $item->{$target} = ''; + } + } + elseif (isset($this->newID[$type][(int) $item->{$target}])) + { + $item->{$target} = $this->newID[$type][(int) $item->{$target}]; + } + else + { + $this->enqueueIdMismatchMessage($item->{$target}, $itemId, $target, $type, $table); + $item->{$target} = ''; + } + } + elseif (UtilitiesArrayHelper::check($item->{$target})) + { + // the bucket to load the items back + $bucket = array(); + foreach ($item->{$target} as $id) + { + if ($id <= 0) + { + if ($id == 0) + { + continue; + } + // we add negative numbers back + $bucket[] = $id; + } + elseif ((UtilitiesStringHelper::check($id) || is_numeric($id)) && isset($this->newID[$type][(int) $id])) + { + $bucket[] = $this->newID[$type][(int) $id]; + } + else + { + $this->enqueueIdMismatchMessage($id, $itemId, $target, $type, $table); + $bucket[] = ''; + } + } + // set ids back + if (UtilitiesArrayHelper::check($bucket)) + { + $item->{$target} = $bucket; + } + } + // convert back to json + if ($isJsonTarget) + { + $item->{$target} = json_encode($item->{$target}, JSON_FORCE_OBJECT); + } + } + // return as json if received as json + if ($isJson) + { + return json_encode($item); + } + return $item; + } + + /** + * Set the new ID + * + * @param int $id The field ID + * @param int $itemId The item ID + * @param string $target The target field + * @param string $type The table of that field + * @param string $table The table these values belong to + * + * @return void + * + */ + private function enqueueIdMismatchMessage($id, $itemId, $target, $type, $table) + { + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_BSBS_IN_BSB_HAS_ID_MISMATCH_SO_THE_BSB_WAS_REMOVED', UtilitiesStringHelper::safe($type, 'Ww'), UtilitiesStringHelper::safe($target, 'Ww') , UtilitiesStringHelper::safe($table, 'w').':'.$itemId, $type . ':' . $id), 'warning'); + } + + /** + * Prep the item + * + * @param object $item The item to prep + * @param string $type The type of values + * @param string $action The action (add/update) + * @param bool $diverged The diverged data switch + * + * @return mixed false on failure + * object on success + * + **/ + private function prepItem($item, $type, $action, $diverged = false) + { + // remove access + if (isset($item->access)) + { + unset($item->access); + } + // remove metadata + if (isset($item->metadata)) + { + unset($item->metadata); + } + // remove metadesc + if (isset($item->metadesc)) + { + unset($item->metadesc); + } + // remove metakey + if (isset($item->metakey)) + { + unset($item->metakey); + } + // remove not_required + if (isset($item->not_required)) + { + unset($item->not_required); + } + // actions to effect all + if (isset($item->asset_id)) + { + unset($item->asset_id); + } + if (isset($item->checked_out)) + { + $item->checked_out = 0; + } + if (isset($item->checked_out_time)) + { + $item->checked_out_time = '0000-00-00 00:00:00'; + } + // do the id fix for the new ids + switch($type) + { + case 'fieldtype': + // repeatable fields to update + $updaterR = array( + // repeatablefield => checker + 'properties' => 'name' + ); + // update the repeatable fields + $item = ComponentbuilderHelper::convertRepeatableFields($item, $updaterR); + break; + case 'field': + // update the fieldtype + if (isset($item->fieldtype) && is_numeric($item->fieldtype) && $item->fieldtype > 0 && isset($this->newID['fieldtype'][(int) $item->fieldtype])) + { + $item->fieldtype = $this->newID['fieldtype'][(int) $item->fieldtype]; + // update multi field values + if ($this->checkMultiFields($item->fieldtype)) + { + $this->updateAfter['field'][(int) $item->id] = $action; // multi field + } + } + elseif (!is_numeric($item->fieldtype) || $item->fieldtype == 0) + { + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_BFIELD_TYPEB_NOT_SET_FOR_BSB', UtilitiesStringHelper::safe($type, 'w').':'.$item->id), 'warning'); + unset($item->fieldtype); + } + else + { + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_BFIELD_TYPEB_IDS_MISMATCH_IN_BSB', $item->fieldtype, UtilitiesStringHelper::safe($type, 'w').':'.$item->id), 'error'); + return false; + } + // if we can't merge add postfix to name + if ($this->postfix) + { + $item->name = $item->name.$this->postfix; + } + break; + case 'dynamic_get': + // update the view_table_main ID + if (isset($item->main_source) && $item->main_source == 1) + { + $item = $this->setNewID($item, 'view_table_main', 'admin_view', $type); + } + // repeatable fields to update + $updaterR = array( + // repeatablefield => checker + 'join_view_table' => 'view_table', + 'join_db_table' => 'db_table', + 'order' => 'table_key', + 'where' => 'table_key', + 'global' => 'name', + 'filter' => 'filter_type' + ); + // update the repeatable fields + $item = ComponentbuilderHelper::convertRepeatableFields($item, $updaterR); + // subform fields to target + $updaterT = array( + // subformfield => field => type_value + 'join_view_table' => array('view_table' => 'admin_view') + ); + // update the subform ids + $this->updateSubformsIDs($item, 'dynamic_get', $updaterT); + // if we can't merge add postfix to name + if ($this->postfix) + { + $item->name = $item->name.$this->postfix; + } + break; + case 'layout': + case 'template': + // update the dynamic_get + $item = $this->setNewID($item, 'dynamic_get', 'dynamic_get', $type); + // update the snippet + $item = $this->setNewID($item, 'snippet', 'snippet', $type); + // if we can't merge add postfix to name + if ($this->postfix) + { + $item->name = $item->name.$this->postfix; + } + break; + case 'custom_admin_view': + case 'site_view': + // update the main_get + $item = $this->setNewID($item, 'main_get', 'dynamic_get', $type); + // update the dynamic_get + $item = $this->setNewID($item, 'dynamic_get', 'dynamic_get', $type); + // update the custom_get + $item = $this->setNewID($item, 'custom_get', 'dynamic_get', $type); + // update the snippet + $item = $this->setNewID($item, 'snippet', 'snippet', $type); + // repeatable fields to update + $updaterR = array( + // repeatablefield => checker + 'ajax_input' => 'value_name', + 'custom_button' => 'name' + ); + // update the repeatable fields + $item = ComponentbuilderHelper::convertRepeatableFields($item, $updaterR); + // if we can't merge add postfix to name + if ($this->postfix) + { + $item->system_name = $item->system_name.$this->postfix; + } + break; + case 'admin_view': + // set the getters anchors + $getter = array('admin_view' => $item->id); + // we must clear the demo content (since it was not moved as far as we know) TODO + if ($item->add_sql == 1 && $item->source == 1) + { + // only if it is mapped to a table + unset($item->add_sql); + unset($item->source); + unset($item->addtables); + } + // update the addfields (old dataset) + if (isset($item->addfields) && JsonHelper::check($item->addfields)) + { + // move the old data + $this->setDivergedDataMover($item->addfields, 'admin_fields', 'addfields', $getter); + } + // remove from this dataset + unset($item->addfields); + // update the addlinked_views + if (isset($item->addlinked_views) && JsonHelper::check($item->addlinked_views)) + { + $this->updateAfter['adminview'][(int) $item->id] = $action; // addlinked_views + } + elseif (isset($item->addlinked_views)) + { + unset($item->addlinked_views); + } + // update the addconditions (old dataset) + if (isset($item->addconditions) && JsonHelper::check($item->addconditions)) + { + // move the old data + $this->setDivergedDataMover($item->addconditions, 'admin_fields_conditions', 'addconditions', $getter); + } + // remove from this dataset + unset($item->addconditions); + // repeatable fields to update + $updaterR = array( + // repeatablefield => checker + 'ajax_input' => 'value_name', + 'custom_button' => 'name', + 'addtables' => 'table', + 'addlinked_views' => 'adminview', + 'addtabs' => 'name', + 'addpermissions' => 'action' + ); + // update the repeatable fields + $item = ComponentbuilderHelper::convertRepeatableFields($item, $updaterR); + // param fields to target + $updaterP = array( + // param_field => field* => field_table + 'fieldordering' => array( + 'admin_ordering_fields.field' => 'field', + 'linked_ordering_fields.field' => 'field' + ), + 'privacy' => array( + 'anonymize_fields.field' => 'field', + 'other_user_fields' => 'field' + ) + ); + // update the params ids + $this->updateParamIDs($item, $type, $updaterP); + // if we can't merge add postfix to name + if ($this->postfix) + { + $item->system_name = $item->system_name.$this->postfix; + } + break; + case 'joomla_component': + // update custom dash after + if (isset($item->dashboard_type) && 2 == $item->dashboard_type) + { + // update the custom dash ID + $this->updateAfter['joomla_component'][(int) $item->id] = $action; // dashboard + } + // set the anchors getters + $getter = array('joomla_component' => $item->id); + // update the addconfig + if (isset($item->addconfig) && JsonHelper::check($item->addconfig)) + { + // move the old data + $this->setDivergedDataMover($item->addconfig, 'component_config', 'addconfig', $getter); + } + // remove from this dataset + unset($item->addconfig); + // update the addadmin_views + if (isset($item->addadmin_views) && JsonHelper::check($item->addadmin_views)) + { + // move the old data + $this->setDivergedDataMover($item->addadmin_views, 'component_admin_views', 'addadmin_views', $getter); + } + // remove from this dataset + unset($item->addadmin_views); + // update the addcustom_admin_views + if (isset($item->addcustom_admin_views) && JsonHelper::check($item->addcustom_admin_views)) + { + // move the old data + $this->setDivergedDataMover($item->addcustom_admin_views, 'component_custom_admin_views', 'addcustom_admin_views', $getter); + } + // remove from this dataset + unset($item->addcustom_admin_views); + // update the addsite_views + if (isset($item->addsite_views) && JsonHelper::check($item->addsite_views)) + { + // move the old data + $this->setDivergedDataMover($item->addsite_views, 'component_site_views', 'addsite_views', $getter); + } + // remove from this dataset + unset($item->addsite_views); + // update the version_update + if (isset($item->version_update) && JsonHelper::check($item->version_update)) + { + // move the old data + $this->setDivergedDataMover($item->version_update, 'component_updates', 'version_update', $getter); + } + // remove from this dataset + unset($item->version_update); + // update the sql_tweak + if (isset($item->sql_tweak) && JsonHelper::check($item->sql_tweak)) + { + // move the old data + $this->setDivergedDataMover($item->sql_tweak, 'component_mysql_tweaks', 'sql_tweak', $getter); + } + // remove from this dataset + unset($item->sql_tweak); + // update the addcustommenus + if (isset($item->addcustommenus) && JsonHelper::check($item->addcustommenus)) + { + // move the old data + $this->setDivergedDataMover($item->addcustommenus, 'component_custom_admin_menus', 'addcustommenus', $getter); + } + // remove from this dataset + unset($item->addcustommenus); + // update the dashboard_tab + if (isset($item->dashboard_tab) && JsonHelper::check($item->dashboard_tab)) + { + // move the old data + $this->setDivergedDataMover($item->dashboard_tab, 'component_dashboard', 'dashboard_tab', $getter); + } + // remove from this dataset + unset($item->dashboard_tab); + // update the php_dashboard_methods + if (isset($item->php_dashboard_methods)) + { + // move the old data + $this->setDivergedDataMover($item->php_dashboard_methods, 'component_dashboard', 'php_dashboard_methods', $getter); + } + // remove from this dataset + unset($item->php_dashboard_methods); + unset($item->add_php_dashboard_methods); + // update the addfiles + if (isset($item->addfiles) && JsonHelper::check($item->addfiles)) + { + // move the old data + $this->setDivergedDataMover($item->addfiles, 'component_files_folders', 'addfiles', $getter); + } + // remove from this dataset + unset($item->addfiles); + // update the addfolders + if (isset($item->addfolders) && JsonHelper::check($item->addfolders)) + { + // move the old data + $this->setDivergedDataMover($item->addfolders, 'component_files_folders', 'addfolders', $getter); + } + // remove from this dataset + unset($item->addfolders); + // update the add_css + if (isset($item->add_css)) + { + $item->add_css_admin = $item->add_css; + } + // remove from this dataset + unset($item->add_css); + // update the css + if (isset($item->css) && UtilitiesStringHelper::check($item->css)) + { + $item->css_admin = $item->css; + } + // remove from this dataset + unset($item->css); + // rename sales_server_ftp field + if (isset($item->sales_server_ftp)) + { + $item->sales_server = $item->sales_server_ftp; + unset($item->sales_server_ftp); + } + // rename update_server_ftp field + if (isset($item->update_server_ftp)) + { + $item->update_server = $item->update_server_ftp; + unset($item->update_server_ftp); + } + // rename export_package_link field + if (isset($item->export_package_link)) + { + $item->joomla_source_link = $item->export_package_link; + unset($item->export_package_link); + } + // repeatable fields to update + $updaterR = array( + // repeatablefield => checker + 'addcontributors' => 'name' + ); + // update the repeatable fields + $item = ComponentbuilderHelper::convertRepeatableFields($item, $updaterR); + // if we can't merge add postfix to name + if ($this->postfix) + { + $item->system_name = $item->system_name.$this->postfix; + } + break; + case 'component_admin_views': + // diverged id already updated + if (!$diverged) + { + // update the joomla_component ID where needed + $item = $this->setNewID($item, 'joomla_component', 'joomla_component', $type); + } + // repeatable fields to update + $updaterR = array( + // repeatablefield => checker + 'addadmin_views' => 'adminview' + ); + // update the repeatable fields + $item = ComponentbuilderHelper::convertRepeatableFields($item, $updaterR); + // subform fields to target + $updaterT = array( + // subformfield => array( field => type_value ) + 'addadmin_views' => array('adminview' => 'admin_view') + ); + // update the subform ids + $this->updateSubformsIDs($item, 'component_admin_views', $updaterT); + break; + case 'component_site_views': + // diverged id already updated + if (!$diverged) + { + // update the joomla_component ID where needed + $item = $this->setNewID($item, 'joomla_component', 'joomla_component', $type); + } + // repeatable fields to update + $updaterR = array( + // repeatablefield => checker + 'addsite_views' => 'siteview' + ); + // update the repeatable fields + $item = ComponentbuilderHelper::convertRepeatableFields($item, $updaterR); + // subform fields to target + $updaterT = array( + // subformfield => array( field => type_value ) + 'addsite_views' => array('siteview' => 'site_view') + ); + // update the subform ids + $this->updateSubformsIDs($item, 'component_site_views', $updaterT); + break; + case 'component_custom_admin_views': + // diverged id already updated + if (!$diverged) + { + // update the joomla_component ID where needed + $item = $this->setNewID($item, 'joomla_component', 'joomla_component', $type); + } + // repeatable fields to update + $updaterR = array( + // repeatablefield => checker + 'addcustom_admin_views' => 'customadminview' + ); + // update the repeatable fields + $item = ComponentbuilderHelper::convertRepeatableFields($item, $updaterR); + // subform fields to target + $updaterT = array( + // subformfield => array( field => type_value ) + 'addcustom_admin_views' => array('customadminview' => 'custom_admin_view', 'adminviews' => 'admin_view', 'before' => 'admin_view') + ); + // update the subform ids + $this->updateSubformsIDs($item, 'component_custom_admin_views', $updaterT); + break; + case 'component_updates': + // diverged id already updated + if (!$diverged) + { + // update the joomla_component ID where needed + $item = $this->setNewID($item, 'joomla_component', 'joomla_component', $type); + } + // repeatable fields to update + $updaterR = array( + // repeatablefield => checker + 'version_update' => 'version' + ); + // update the repeatable fields + $item = ComponentbuilderHelper::convertRepeatableFields($item, $updaterR); + break; + case 'component_mysql_tweaks': + // diverged id already updated + if (!$diverged) + { + // update the joomla_component ID where needed + $item = $this->setNewID($item, 'joomla_component', 'joomla_component', $type); + } + // repeatable fields to update + $updaterR = array( + // repeatablefield => checker + 'sql_tweak' => 'adminview' + ); + // update the repeatable fields + $item = ComponentbuilderHelper::convertRepeatableFields($item, $updaterR); + // subform fields to target + $updaterT = array( + // subformfield => array( field => type_value ) + 'sql_tweak' => array('adminview' => 'admin_view') + ); + // update the subform ids + $this->updateSubformsIDs($item, 'component_mysql_tweaks', $updaterT); + break; + case 'component_custom_admin_menus': + // diverged id already updated + if (!$diverged) + { + // update the joomla_component ID where needed + $item = $this->setNewID($item, 'joomla_component', 'joomla_component', $type); + } + // repeatable fields to update + $updaterR = array( + // repeatablefield => checker + 'addcustommenus' => 'name' + ); + // update the repeatable fields + $item = ComponentbuilderHelper::convertRepeatableFields($item, $updaterR); + // subform fields to target + $updaterT = array( + // subformfield => array( field => type_value ) + 'addcustommenus' => array('before' => 'admin_view') + ); + // update the subform ids + $this->updateSubformsIDs($item, 'component_custom_admin_menus', $updaterT); + break; + case 'component_config': + // diverged id already updated + if (!$diverged) + { + // update the joomla_component ID where needed + $item = $this->setNewID($item, 'joomla_component', 'joomla_component', $type); + } + // repeatable fields to update + $updaterR = array( + // repeatablefield => checker + 'addconfig' => 'field' + ); + // update the repeatable fields + $item = ComponentbuilderHelper::convertRepeatableFields($item, $updaterR); + // subform fields to target + $updaterT = array( + // subformfield => array( field => type_value ) + 'addconfig' => array('field' => 'field') + ); + // update the subform ids + $this->updateSubformsIDs($item, 'component_config', $updaterT); + break; + case 'component_dashboard': + // diverged id already updated + if (!$diverged) + { + // update the joomla_component ID where needed + $item = $this->setNewID($item, 'joomla_component', 'joomla_component', $type); + } + // repeatable fields to update + $updaterR = array( + // repeatablefield => checker + 'dashboard_tab' => 'name' + ); + // update the repeatable fields + $item = ComponentbuilderHelper::convertRepeatableFields($item, $updaterR); + break; + case 'component_placeholders': + // diverged id already updated + if (!$diverged) + { + // update the joomla_component ID where needed + $item = $this->setNewID($item, 'joomla_component', 'joomla_component', $type); + } + break; + case 'component_modules': + // diverged id already updated + if (!$diverged) + { + // update the joomla_component ID where needed + $item = $this->setNewID($item, 'joomla_component', 'joomla_component', $type); + } + // subform fields to target + $updaterT = array( + // subformfield => array( field => type_value ) + 'addjoomla_modules' => array('module' => 'joomla_module') + ); + // update the subform ids + $this->updateSubformsIDs($item, 'component_modules', $updaterT); + break; + case 'component_plugins': + // diverged id already updated + if (!$diverged) + { + // update the joomla_component ID where needed + $item = $this->setNewID($item, 'joomla_component', 'joomla_component', $type); + } + // subform fields to target + $updaterT = array( + // subformfield => array( field => type_value ) + 'addjoomla_plugins' => array('plugin' => 'joomla_plugin') + ); + // update the subform ids + $this->updateSubformsIDs($item, 'component_plugins', $updaterT); + break; + case 'component_files_folders': + // diverged id already updated + if (!$diverged) + { + // update the joomla_component ID where needed + $item = $this->setNewID($item, 'joomla_component', 'joomla_component', $type); + } + // repeatable fields to update + $updaterR = array( + // repeatablefield => checker + 'addfiles' => 'file', + 'addfolders' => 'folder' + ); + // update the repeatable fields + $item = ComponentbuilderHelper::convertRepeatableFields($item, $updaterR); + break; + case 'joomla_module': + // update the custom_get + $item = $this->setNewID($item, 'custom_get', 'dynamic_get', $type); + // if we can't merge add postfix to name + if ($this->postfix) + { + $item->system_name = $item->system_name.$this->postfix; + } + // subform fields to target + $updaterT = array( + // subformfield => array( field => type_value ) + 'fields' => array('field' => 'field') + ); + // update the subform ids + $this->updateSubformsIDs($item, 'joomla_module', $updaterT); + break; + case 'joomla_module_files_folders_urls': + case 'joomla_module_updates': + // diverged id already updated + if (!$diverged) + { + // update the joomla_module ID where needed + $item = $this->setNewID($item, 'joomla_module', 'joomla_module', $type); + } + break; + case 'joomla_plugin_group': + // diverged id already updated + if (!$diverged) + { + // update the class_extends ID where needed + $item = $this->setNewID($item, 'class_extends', 'class_extends', $type); + } + break; + case 'class_method': + case 'class_property': + // diverged id already updated + if (!$diverged) + { + // update the joomla_plugin_group ID where needed + $item = $this->setNewID($item, 'joomla_plugin_group', 'joomla_plugin_group', $type); + } + break; + case 'joomla_plugin': + // diverged id already updated + if (!$diverged) + { + // update the class_extends ID where needed + $item = $this->setNewID($item, 'class_extends', 'class_extends', $type); + // update the joomla_plugin_group ID where needed + $item = $this->setNewID($item, 'joomla_plugin_group', 'joomla_plugin_group', $type); + } + // if we can't merge add postfix to name + if ($this->postfix) + { + $item->system_name = $item->system_name.$this->postfix; + } + // subform fields to target + $updaterT = array( + // subformfield => array( field => type_value ) + 'fields' => array('field' => 'field'), + 'property_selection' => array('property' => 'class_property'), + 'method_selection' => array('method' => 'class_method') + ); + // update the subform ids + $this->updateSubformsIDs($item, 'joomla_plugin', $updaterT); + break; + case 'joomla_plugin_files_folders_urls': + case 'joomla_plugin_updates': + // diverged id already updated + if (!$diverged) + { + // update the joomla_plugin ID where needed + $item = $this->setNewID($item, 'joomla_plugin', 'joomla_plugin', $type); + } + break; + case 'power': + // update the powers after.... since no power is yet found + $this->updateAfter['power'][(int) $item->id] = $action; + break; + case 'custom_code': + // update the component ID where needed + $item = $this->setNewID($item, 'component', 'joomla_component', $type); + break; + case 'language_translation': + $langKeys = array( + array('target' => 'components', 'parent' => 'joomla_component', 'local' => 'localComponents'), + array('target' => 'modules', 'parent' => 'joomla_module', 'local' => 'localModules'), + array('target' => 'plugins', 'parent' => 'joomla_plugin', 'local' => 'localPlugins') + ); + // we have a few to check so we loop them + foreach ($langKeys as $lang) + { + // update the target ID where needed + $item = $this->setNewID($item, $lang['target'], 'joomla_component', $type); + // load the local targets if found + if (isset($item->{$lang['local']}) && JsonHelper::check($item->{$lang['local']})) + { + $targets = array(); + if (isset($item->{$lang['target']}) && JsonHelper::check($item->{$lang['target']})) + { + $targets = json_decode($item->{$lang['target']}, true); + } + $localComponents = json_decode($item->{$lang['local']}, true); + foreach ($localComponents as $lid) + { + if (!is_numeric($lid)) + { + continue; + } + // add if not already there + if (!in_array($lid, $targets)) + { + $targets[] = $lid; + } + } + } + // remove the localComponents + if (isset($item->{$lang['local']})) + { + unset($item->{$lang['local']}); + } + // load it back + if (isset($targets) && UtilitiesArrayHelper::check($targets)) + { + // load it back + $item->{$lang['target']} = json_encode(array_values($targets), JSON_FORCE_OBJECT); + } + } + // merge the translations where needed + if (isset($item->translation) && isset($item->localTranslation) + && JsonHelper::check($item->translation) + && JsonHelper::check($item->localTranslation)) + { + $newTranslations = json_decode($item->translation, true); + $localTranslations = json_decode($item->localTranslation, true); // always the new format + $translations = array(); + $pointer = 0; + $checker = array(); + // okay we have the old format lets merge on that basis + if (isset($newTranslations['translation'])) + { + foreach ($localTranslations as $value) + { + // only keep old translation if the new does not have this translation & language + if (!in_array($value['language'], $newTranslations['language'])) + { + $translations['translation' . $pointer] = array('translation' => $value['translation'], 'language' => $value['language']); + $pointer++; + } + } + foreach ($newTranslations['translation'] as $nr => $newTrans) + { + // now convert the new translation array + $translations['translation' . $pointer] = array('translation' => $newTrans, 'language' => $newTranslations['language'][$nr]); + $pointer++; + } + } + // okay this is the new format lets merge on that basis + elseif (UtilitiesArrayHelper::check($newTranslations)) + { + $translations = $newTranslations; + $pointer = count($translations); + foreach ($localTranslations as $value) + { + $keepLocal = true; + foreach ($newTranslations as $newValue) + { + // only keep old translation if the new does not have this translation & language + if ($value['language'] === $newValue['language']) + { + $keepLocal = false; + } + } + if ($keepLocal) + { + $translations['translation' . $pointer] = array('translation' => $value['translation'], 'language' => $value['language']); + $pointer++; + } + } + } + // okay seem to only have local translations + elseif (UtilitiesArrayHelper::check($localTranslations)) + { + $translations = $localTranslations; + } + // only update if we have translations + if (UtilitiesArrayHelper::check($translations)) + { + $item->translation = json_encode($translations, JSON_FORCE_OBJECT); + } + } + elseif (isset($item->localTranslation) && JsonHelper::check($item->localTranslation)) + { + $item->translation = $item->localTranslation; + } + // remove the localTranslation + if (isset($item->localTranslation)) + { + unset($item->localTranslation); + } + // move entranslation to source + if (isset($item->entranslation)) + { + $item->source = $item->entranslation; + // also remove the old field + unset($item->entranslation); + } + break; + case 'admin_fields': + case 'admin_fields_conditions': + case 'admin_fields_relations': + case 'admin_custom_tabs': + // diverged id already updated + if (!$diverged) + { + // update the admin_view ID where needed + $item = $this->setNewID($item, 'admin_view', 'admin_view', $type); + } + $updaterR = array(); + // set the updater + if ('admin_fields' === $type) + { + // repeatable fields to update + $updaterR = array( + // repeatablefield => checker + 'addfields' => 'field' + ); + // subform fields to target + $updaterT = array( + // subformfield => field => type_value + 'addfields' => array('field' => 'field') + ); + // little tweak... oops + if (isset($item->addconditions)) + { + unset($item->addconditions); + } + } + elseif ('admin_fields_conditions' === $type) + { + // repeatable fields to update + $updaterR = array( + // repeatablefield => checker + 'addconditions' => 'target_field' + ); + // subform fields to target + $updaterT = array( + // subformfield => field => type_value + 'addconditions' => array('target_field' => 'field', 'match_field' => 'field') + ); + } + elseif ('admin_fields_relations' === $type) + { + // subform fields to target + $updaterT = array( + // subformfield => field => type_value + 'addrelations' => array('listfield' => 'field', 'joinfields' => 'field') + ); + // special fix for custom code + $this->updateAfter['relations'][(int) $item->id] = $action; // addrelations->set + } + + // update the repeatable fields + if (isset($updaterR) && UtilitiesArrayHelper::check($updaterR)) + { + $item = ComponentbuilderHelper::convertRepeatableFields($item, $updaterR); + } + // update the subform ids + if (isset($updaterT) && UtilitiesArrayHelper::check($updaterT)) + { + $this->updateSubformsIDs($item, $type, $updaterT); + } + break; + } + // remove all fields/columns not part of the current table + $this->removingFields($type, $item); + // final action prep + switch($action) + { + case 'update': + // set values to follow the update conventions + if (isset($item->created_by)) + { + unset($item->created_by); + } + $item->modified_by = $this->user->id; + $item->modified = $this->today; + // return the item + return $item; + break; + case 'add': + // remove the ID + if (isset($item->id)) + { + unset($item->id); + } + // set values to follow the adding conventions + $item->created_by = $this->user->id; + $item->modified_by = $this->user->id; + $item->modified = $this->today; + // return the item + return $item; + break; + } + return false; + } + + /** + * remove all fields/columns not part of the current table + * + * @param string $type The table this item belongs to + * @param object $item The item to clean + * + * @return viod + */ + private function removingFields($type, &$item) + { + // get the columns + $columns = $this->getTableColumns("#__componentbuilder_" . $type); + if (UtilitiesArrayHelper::check($columns)) + { + foreach ($item as $name => $value) + { + if (!isset($columns[$name])) + { + // we must show a warning that this field was not imported (but just once) + if (!isset($this->fieldImportErrors[$type.$name])) + { + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_FIELD_BSB_NOT_FOUND_IN_LOCAL_DATABASE_TABLE_S_SO_IMPORTED_OF_ITS_VALUES_FAILED_PLEASE_UPDATE_YOUR_JCB_INSTALL_AND_TRY_AGAIN', $name, '#__componentbuilder_' . $type), 'warning'); + // make sure the message is not loaded again + $this->fieldImportErrors[$type.$name] = true; + } + // remove the field & value + unset($item->{$name}); + } + } + } + } + + /** + * get table columns + * + * @param string $table The table + * + * @return array + */ + private function getTableColumns($table) + { + // check if the columns are in memory + if (!isset($this->tableColumns[$table])) + { + // get the columns + $this->tableColumns[$table] = $this->_db->getTableColumns($table); + } + return $this->tableColumns[$table]; + } + + /** + * Set the data that should be moved + * + * @param array/json $values The values/data to move + * @param string $table The table to move the values to + * @param string $type The type of values + * @param array $getters The get values used to anchor the values to the new table + * + * @return bool + */ + private function setDivergedDataMover($values, $table, $type, $getters) + { + // we need to move this to the new $table based on anchors + if (UtilitiesArrayHelper::check($getters)) + { + if (!isset($this->divergedDataMover[$table])) + { + $this->divergedDataMover[$table] = array(); + } + // set unique key + $uniqueKey = md5(serialize($getters)); + if (!isset($this->divergedDataMover[$table][$uniqueKey])) + { + $this->divergedDataMover[$table][$uniqueKey] = new \stdClass; + foreach ($getters as $name => $value) + { + $this->divergedDataMover[$table][$uniqueKey]->{$name} = $value; + } + } + // add the data to the mover + $this->divergedDataMover[$table][$uniqueKey]->{$type} = $values; + // display more import info + if ($this->moreInfo) + { + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_WE_SUCCESSFULLY_MOVED_BSB', UtilitiesStringHelper::safe($type, 'Ww') . ' to ('.UtilitiesStringHelper::safe($table, 'w').')'), 'success'); + } + // success + return true; + } + $this->app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_WE_FAILED_TO_MOVE_BSB', UtilitiesStringHelper::safe($type, 'Ww') . ' to ('.UtilitiesStringHelper::safe($table, 'w').')'), 'warning'); + // failure + return false; + } + + /** + * Check if a field has multiple fields + * + * @param string $typeID The type ID + * + * @return bool true on success + * + */ + private function checkMultiFields($typeID) + { + if(isset($this->isMultiple[$typeID])) + { + return $this->isMultiple[$typeID]; + } + elseif (($type = $this->getFieldType($typeID)) !== false) + { + if ('repeatable' === $type || 'subform' === $type ) + { + $this->isMultiple[$typeID] = true; + } + else + { + $this->isMultiple[$typeID] = false; + } + return $this->isMultiple[$typeID]; + } + return false; + } + + /** + * Get the field type + * + * @param string $id The field type id + * + * @return string field type + * + */ + private function getFieldType($id) + { + if (!isset($this->fieldTypes[$id])) + { + $properties = GetHelper::var('fieldtype', $id, 'id', 'properties'); + if (JsonHelper::check($properties)) + { + $properties = json_decode($properties, true); + // check if this is old values for repeatable fields + if (isset($properties['name'])) + { + $properties = ComponentbuilderHelper::convertRepeatable($properties, 'properties'); + } + // now check to find type + foreach ($properties as $property) + { + if ('type' === $property['name']) + { + if (isset($property['example']) && UtilitiesStringHelper::check($property['example'])) + { + $this->fieldTypes[$id] = $property['example']; + break; + } + } + } + } + // if not found + if (!isset($this->fieldTypes[$id]) && $name = GetHelper::var('fieldtype', $id, 'id', 'name')) + { + $this->fieldTypes[$id] = UtilitiesStringHelper::safe($name); + } + } + // return the type + if (isset($this->fieldTypes[$id])) + { + return $this->fieldTypes[$id]; + } + return false; + } + + /** + * Update the local item + * + * @param object $item The item to update + * @param string $type The type of values + * @param bool $canState The switch to set state + * + * @return mixed false on failure + * ID int on success + * + **/ + private function updateLocalItem(&$item, $type, &$canState) + { + // prep the item + if ($update = $this->prepItem($item, $type, 'update')) + { + // remove the published state if not allowed to edit it + if (!$canState && isset($update->published)) + { + unset($update->published); + } + // update the item + if ($result = $this->_db->updateObject('#__componentbuilder_' . $type, $update, 'id')) + { + // return success + return $update->id; + } + } + return false; + } + + /** + * add the local item + * + * @param object $item The item to update + * @param string $type The type of values + * @param bool $diverged The diverged data switch + * + * @return mixed false on failure + * ID int on success + * + **/ + private function addLocalItem(&$item, $type, $diverged = false) + { + // prep the item + if ($add = $this->prepItem($item, $type, 'add', $diverged)) + { + // insert/add the item + if ($result = $this->_db->insertObject('#__componentbuilder_' . $type, $add)) + { + $aId = $this->_db->insertid(); + // make sure the access of asset is set + ComponentbuilderHelper::setAsset($aId, $type); + // set new ID + return $aId; + } + } + return false; + } + + /** + * Get the local item + * + * @param object $item The item to get + * @param string $type The type of values + * @param bool $retry The retry switch + * @param bool $get The query get switch + * @param bool $diverged The diverged data switch + * + * @return mixed false on failure + * ID int on success + * + **/ + private function getLocalItem($item, $type, $retry = false, $get = 1, $diverged = false) + { + $query = $this->_db->getQuery(true); + $query->select('a.*'); + $query->from($this->_db->quoteName('#__componentbuilder_' . $type, 'a')); + // only run query if where is set + $runQuery = false; + // we first try to get the item by GUID + if ($get == 1 && isset($item->guid)) + { + if (($item = GuidHelper::item($item->guid, $type, 'a.*')) !== false) + { + return $item; + } + // check if we should continue the search + // we only link powers by GUID + elseif ($this->importGuidOnly == 1 || $type === 'power') + { + return false; + } + } + // continue search + if ($get == 1 && isset($item->created) && isset($item->id) && (isset($item->name) || isset($item->system_name))) + { + // to prefent crazy mismatch with old IDs (I know very weired) + if (isset($item->system_name)) + { + $query->where($this->_db->quoteName('a.system_name') . ' = '. $this->_db->quote($item->system_name)); + } + // to prefent crazy mismatch with old IDs (I know very weired) + if (isset($item->name)) + { + $query->where($this->_db->quoteName('a.name') . ' = '. $this->_db->quote($item->name)); + } + // load the created and id + $query->where($this->_db->quoteName('a.created') . ' = '. $this->_db->quote($item->created)); + $query->where($this->_db->quoteName('a.id') .' = '. (int) $item->id); + // set to run query + $runQuery = true; + } + elseif (UtilitiesArrayHelper::check($get)) + { + foreach ($get as $field) + { + // set to run query + $runQuery = true; + if (isset($item->{$field})) + { + // set the value + $value = $item->{$field}; + // check if we have special value + if ($this->specialValue && UtilitiesArrayHelper::check($this->specialValue) && isset($this->specialValue[$field])) + { + $value = $this->specialValue[$field]; + } + // load to query + if (is_numeric($value) && is_int($value)) + { + $query->where($this->_db->quoteName('a.' . $field) . ' = '. (int) $value); + } + elseif (is_numeric($value) && is_float($value)) + { + $query->where($this->_db->quoteName('a.' . $field) . ' = '. (float) $value); + } + elseif(UtilitiesStringHelper::check($value)) // do not allow empty strings (since it could be major mis match) + { + $query->where($this->_db->quoteName('a.' . $field) . ' = '. $this->_db->quote($value)); + } + else + { + // do not run query + $runQuery = false; + } + } + else + { + // do not run query + $runQuery = false; + } + } + } + elseif (isset($item->{$get})) + { + // set to run query + $runQuery = true; + // set the value + $value = $item->{$get}; + // check if we have special value + if ($this->specialValue && UtilitiesArrayHelper::check($this->specialValue) && isset($this->specialValue[$get])) + { + $value = $this->specialValue[$get]; + } + // load to query + if (is_numeric($value) && is_int($value)) + { + $query->where($this->_db->quoteName('a.' . $get) . ' = '. (int) $value); + } + elseif (is_numeric($value) && is_float($value)) + { + $query->where($this->_db->quoteName('a.' . $get) . ' = '. (float) $value); + } + elseif(UtilitiesStringHelper::check($value)) // do not allow empty strings (since it could be major mis match) + { + $query->where($this->_db->quoteName('a.' . $get) . ' = '. $this->_db->quote($value)); + } + else + { + $runQuery = false; // really not needed but who knows for sure... + } + } + // since where has been set run the query + if ($runQuery) + { + // see if we get an item + $this->_db->setQuery($query); + $this->_db->execute(); + if ($this->_db->getNumRows()) + { + return $this->_db->loadObject(); + } + } + // retry to get the item + if ($retry) + { + $retryAgain = false; + $this->specialValue = false; + // set the getter + switch ($type) + { + case 'admin_fields': + case 'admin_fields_conditions': + case 'admin_fields_relations': + case 'admin_custom_tabs': + // get by admin_view (since there should only be one of each name) + $getter = array('admin_view'); + $this->specialValue = array(); + // Yet if diverged it makes sense that the ID is updated. + if ($diverged) + { + $this->specialValue['admin_view'] = (int) $item->admin_view; + } + elseif (isset($this->newID['admin_view'][(int) $item->admin_view])) + { + $this->specialValue['admin_view'] = $this->newID['admin_view'][(int) $item->admin_view]; + } + // (TODO) I have seen this happen, seems dangerous! + else + { + return false; + } + break; + case 'validation_rule': + case 'fieldtype': + // get by name (since there should only be one of each name) + $getter = 'name'; + break; + case 'field': + // get by name and xml to target correct field + if ($retry == 2) + { + // get by name + xml... + $getter = array('name','datatype','store','indexes','null_switch','xml'); + $retryAgain = 3; + } + elseif ($retry == 3) + { + // get by name + created... + $getter = array('name','datatype','created'); + } + else + { + // get by name + xml or type.. + $getter = array('name','datatype','store','indexes','null_switch'); + // lets try to add the fieldtype + if (isset($item->fieldtype) && is_numeric($item->fieldtype) && $item->fieldtype > 0 && isset($this->newID['fieldtype'][(int) $item->fieldtype]) && $this->newID['fieldtype'][(int) $item->fieldtype] > 0) + { + $getter[] = 'fieldtype'; + $this->specialValue = array(); + $this->specialValue['fieldtype'] = $this->newID['fieldtype'][(int) $item->fieldtype]; + $retryAgain = 2; + } + else + { + $getter[] = 'xml'; + $retryAgain = 3; + } + } + break; + case 'site_view': + case 'custom_admin_view': + // get by name, system_name and codename + $getter = array('name', 'system_name', 'codename'); + // lets try to add the main_get + if (isset($item->main_get) && is_numeric($item->main_get) && $item->main_get > 0 && isset($this->newID['dynamic_get'][(int) $item->main_get]) && $this->newID['dynamic_get'][(int) $item->main_get] > 0) + { + $getter[] = 'main_get'; + $this->specialValue = array(); + $this->specialValue['main_get'] = $this->newID['dynamic_get'][(int) $item->main_get]; + } + break; + case 'template': + case 'layout': + // get by code name (since there should only be one) + $getter = 'alias'; + break; + case 'snippet': + // get by snippet (since there should only be one snippet like that) + if ($retry == 2) + { + $getter = array('name', 'snippet', 'url', 'type', 'heading'); + } + else + { + // get by id name.. + $getter = array('id', 'name', 'snippet', 'url', 'type', 'heading'); + $retryAgain = 2; + } + break; + case 'placeholder': + // search for placeholder (since there should only be one) + $getter = 'target'; + break; + case 'custom_code': + // search for custom code + $getter = array('comment_type', 'target'); + $this->specialValue = array(); + // search for Hash (automation) + if (isset($item->target) && $item->target == 1) + { + $getter[] = 'path'; + $getter[] = 'hashtarget'; + $getter[] = 'component'; + // Yet if diverged it makes sense that the ID is updated. + if ($diverged) + { + // set a special value + $this->specialValue['component'] = (int) $item->component; + } + elseif (isset($this->newID['joomla_component'][(int) $item->component])) + { + // set a special value + $this->specialValue['component'] = $this->newID['joomla_component'][(int) $item->component]; + } + // (TODO) I have seen this happen, seems dangerous! + else + { + return false; + } + } + // search for JCB (manual) + elseif (isset($item->target) && $item->target == 2) + { + $getter[] = 'function_name'; + } + else + { + return false; + } + break; + case 'dynamic_get': + if ($retry == 2) + { + // get by name ... + $getter = array('name', 'gettype', 'main_source'); // risky will look at this again + // add some more advanced search + if (isset($item->main_source) && $item->main_source == 1 && isset($item->view_selection) && UtilitiesStringHelper::check($item->view_selection)) + { + $getter[] = 'view_selection'; + } + elseif (isset($item->main_source) && $item->main_source == 2 && isset($item->db_selection) && UtilitiesStringHelper::check($item->db_selection)) + { + $getter[] = 'db_selection'; + } + elseif (isset($item->main_source) && $item->main_source == 3 && isset($item->php_custom_get) && UtilitiesStringHelper::check($item->php_custom_get)) + { + $getter[] = 'php_custom_get'; + } + // add some extra + if (isset($item->getcustom) && UtilitiesStringHelper::check($item->getcustom)) + { + $getter[] = 'getcustom'; + } + } + else + { + // get by id name gettype and main_source + $getter = array('id', 'name', 'gettype', 'main_source'); // risky will look at this again + $retryAgain = 2; + } + break; + case 'admin_view': + if ($retry == 2) + { + // get by name ... + $getter = array('name_list', 'name_single', 'short_description', 'system_name'); // risky will look at this again + } + else + { + // get by id name ... + $getter = array('id', 'name_list', 'name_single', 'short_description', 'system_name'); // risky will look at this again + $retryAgain = 2; + } + break; + case 'joomla_component': + if ($retry == 3) + { + // get by names only + $getter = array('name', 'name_code', 'system_name'); + } + elseif ($retry == 2) + { + // get by name ... + $getter = array('name', 'name_code', 'short_description', 'author', 'email', 'component_version', 'companyname', 'system_name', 'website', 'bom', 'copyright', 'license'); + $retryAgain = 3; + } + else + { + // get by id name ... + $getter = array('id', 'name', 'name_code', 'short_description', 'author', 'component_version', 'companyname', 'system_name'); + $retryAgain = 2; + } + break; + case 'component_admin_views': + case 'component_site_views': + case 'component_custom_admin_views': + case 'component_updates': + case 'component_mysql_tweaks': + case 'component_custom_admin_menus': + case 'component_config': + case 'component_dashboard': + case 'component_placeholders': + case 'component_files_folders': + case 'component_modules': + case 'component_plugins': + // get by joomla_component (since there should only be one of each component) + $getter = array('joomla_component'); + $this->specialValue = array(); + // Yet if diverged it makes sense that the ID is updated. + if ($diverged) + { + $this->specialValue['joomla_component'] = (int) $item->joomla_component; + } + elseif (isset($this->newID['joomla_component'][(int) $item->joomla_component])) + { + $this->specialValue['joomla_component'] = $this->newID['joomla_component'][(int) $item->joomla_component]; + } + // (TODO) I have seen this happen, seems dangerous! + else + { + return false; + } + break; + case 'language_translation': + // get by source translation since there should just be one + $getter = 'source'; + if (isset($item->entranslation)) + { + $item->source = $item->entranslation; + } + break; + case 'language': + // get by language tag since there should just be one + $getter = 'langtag'; + break; + case 'joomla_module': + // get + if ($retry == 3) + { + // get by names, exteneded and group only + $getter = array('name', 'system_name'); + } + elseif ($retry == 2) + { + // get by description + $getter = array('name', 'system_name', 'description'); + $retryAgain = 3; + } + else + { + // get by id + $getter = array('id', 'name', 'system_name'); + $retryAgain = 2; + } + break; + case 'joomla_module_files_folders_urls': + case 'joomla_module_updates': + // get by admin_view (since there should only be one of each name) + $getter = array('joomla_module'); + $this->specialValue = array(); + // Yet if diverged it makes sense that the ID is updated. + if ($diverged) + { + $this->specialValue['joomla_module'] = (int) $item->joomla_module; + } + elseif (isset($this->newID['joomla_module'][(int) $item->joomla_module])) + { + $this->specialValue['joomla_module'] = $this->newID['joomla_module'][(int) $item->joomla_module]; + } + // (TODO) I have seen this happen, seems dangerous! + else + { + return false; + } + break; + case 'joomla_plugin': + // get + if ($retry == 3) + { + // get by names, exteneded and group only + $getter = array('name', 'system_name', 'class_extends', 'joomla_plugin_group'); + } + elseif ($retry == 2) + { + // get by description + $getter = array('name', 'system_name', 'class_extends', 'joomla_plugin_group', 'description'); + $retryAgain = 3; + } + else + { + // get by id + $getter = array('id', 'name', 'system_name', 'class_extends', 'joomla_plugin_group'); + $retryAgain = 2; + } + $this->specialValue = array(); + // Yet if diverged it makes sense that the ID is updated. + if ($diverged) + { + $this->specialValue['class_extends'] = (int) $item->class_extends; + $this->specialValue['joomla_plugin_group'] = (int) $item->joomla_plugin_group; + } + elseif (isset($this->newID['class_extends'][(int) $item->class_extends]) && isset($this->newID['joomla_plugin_group'][(int) $item->joomla_plugin_group])) + { + $this->specialValue['class_extends'] = $this->newID['class_extends'][(int) $item->class_extends]; + $this->specialValue['joomla_plugin_group'] = $this->newID['joomla_plugin_group'][(int) $item->joomla_plugin_group]; + } + // (TODO) I have seen this happen, seems dangerous! + else + { + return false; + } + break; + case 'joomla_plugin_files_folders_urls': + case 'joomla_plugin_updates': + // get by admin_view (since there should only be one of each name) + $getter = array('joomla_plugin'); + $this->specialValue = array(); + // Yet if diverged it makes sense that the ID is updated. + if ($diverged) + { + $this->specialValue['joomla_plugin'] = (int) $item->joomla_plugin; + } + elseif (isset($this->newID['joomla_plugin'][(int) $item->joomla_plugin])) + { + $this->specialValue['joomla_plugin'] = $this->newID['joomla_plugin'][(int) $item->joomla_plugin]; + } + // (TODO) I have seen this happen, seems dangerous! + else + { + return false; + } + break; + case 'joomla_plugin_group': + // get by name since there should just be one + $getter = array('name', 'class_extends'); + $this->specialValue = array(); + // Yet if diverged it makes sense that the ID is updated. + if ($diverged) + { + $this->specialValue['class_extends'] = (int) $item->class_extends; + } + elseif (isset($this->newID['class_extends'][(int) $item->class_extends])) + { + $this->specialValue['class_extends'] = $this->newID['class_extends'][(int) $item->class_extends]; + } + // (TODO) I have seen this happen, seems dangerous! + else + { + return false; + } + break; + case 'class_extends': + case 'class_method': + case 'class_property': + // get by name since there should just be one + $getter = array('name', 'extension_type'); + // Yet if diverged it makes sense that the ID is updated. + if ('plugins' === $item->extension_type && isset($item->joomla_plugin_group)) + { + $getter[] = 'joomla_plugin_group'; + $this->specialValue = array(); + if ($diverged) + { + $this->specialValue['joomla_plugin_group'] = (int) $item->joomla_plugin_group; + } + elseif (isset($this->newID['joomla_plugin_group'][(int) $item->joomla_plugin_group])) + { + $this->specialValue['joomla_plugin_group'] = $this->newID['joomla_plugin_group'][(int) $item->joomla_plugin_group]; + } + // (TODO) I have seen this happen, seems dangerous! + else + { + return false; + } + } + break; + default: + // can't be found so return false + return false; + break; + } + // we try again + return $this->getLocalItem($item, $type, $retryAgain, $getter); + } + return false; + } + + /** + * Update constant path with real full path value + * + * @param string $path The full path + * + * @return string The updated path + * + */ + private function setFullPath($path) + { + return str_replace(array_keys(ComponentbuilderHelper::$constantPaths), array_values(ComponentbuilderHelper::$constantPaths), $path); + } + + /** + * Convert the name to a path + * + * @param string $path The path name + * + * @return string The full path * + */ + private function setDynamicPath($path) + { + // now convert to path + $path = str_replace('__v_d_m__', '/', $path); + // add the full path if possible + return str_replace('//', '/', $this->setFullPath($path)); + } + + + protected function getAlias($name,$type = false) + { + // sanitize the name to an alias + if (Factory::getConfig()->get('unicodeslugs') == 1) + { + $alias = OutputFilter::stringURLUnicodeSlug($name); + } + else + { + $alias = OutputFilter::stringURLSafe($name); + } + // must be a uniqe alias + if ($type) + { + return $this->getUniqe($alias,'alias',$type); + } + return $alias; + } + + /** + * Method to generate a uniqe value. + * + * @param string $field name. + * @param string $value data. + * @param string $type table. + * + * @return string New value. + */ + protected function getUniqe($value,$field,$type) + { + // insure the filed is always uniqe + while (isset($this->uniqeValueArray[$type][$field][$value])) + { + $value = StringHelper::increment($value, 'dash'); + } + $this->uniqeValueArray[$type][$field][$value] = $value; + return $value; + } + + protected function getAliasesUsed($table) + { + // Get a db connection. + $db = $this->getDatabase(); + // first we check if there is a alias column + $columns = $db->getTableColumns('#__componentbuilder_'.$table); + if(isset($columns['alias'])){ + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('alias'))); + $query->from($db->quoteName('#__componentbuilder_'.$table)); + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $aliases = $db->loadColumn(); + foreach($aliases as $alias) + { + $this->uniqeValueArray[$table]['alias'][$alias] = $alias; + } + } + return true; + } + return false; + } +} diff --git a/admin/src/Model/Import_language_translationsimportModel.php b/admin/src/Model/Import_language_translationsimportModel.php new file mode 100644 index 000000000..350ed2503 --- /dev/null +++ b/admin/src/Model/Import_language_translationsimportModel.php @@ -0,0 +1,798 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Filesystem\Folder; +use Joomla\CMS\Filesystem\Path; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\Installer\InstallerHelper; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use PhpOffice\PhpSpreadsheet\IOFactory; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\JsonHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Import_language_translations Base Database Model + * + * @since 1.6 + */ +class Import_language_translationsimportModel extends BaseDatabaseModel +{ + // set uploading values + protected $use_streams = false; + protected $allow_unsafe = false; + protected $safeFileOptions = []; + + /** + * @var object JTable object + */ + protected $_table = null; + + /** + * @var object JTable object + */ + protected $_url = null; + + /** + * Model context string. + * + * @var string + */ + protected $_context = 'com_componentbuilder.import_language_translations'; + + /** + * Import Settings + */ + protected $getType = NULL; + protected $dataType = NULL; + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @return void + * + */ + protected function populateState() + { + $app = Factory::getApplication('administrator'); + + $this->setState('message', $app->getUserState('com_componentbuilder.message')); + $app->setUserState('com_componentbuilder.message', ''); + + // Recall the 'Import from Directory' path. + $path = $app->getUserStateFromRequest($this->_context . '.import_directory', 'import_directory', $app->get('tmp_path')); + $this->setState('import.directory', $path); + parent::populateState(); + } + + /** + * Import an spreadsheet from either folder, url or upload. + * + * @return boolean result of import + * + */ + public function import() + { + $this->setState('action', 'import'); + $app = Factory::getApplication(); + $session = Factory::getSession(); + $package = null; + $continue = false; + // get import type + $this->getType = $app->input->getString('gettype', NULL); + // get import type + $this->dataType = $session->get('dataType_VDM_IMPORTINTO', NULL); + + if ($package === null) + { + switch ($this->getType) + { + case 'folder': + // Remember the 'Import from Directory' path. + $app->getUserStateFromRequest($this->_context . '.import_directory', 'import_directory'); + $package = $this->_getPackageFromFolder(); + break; + + case 'upload': + $package = $this->_getPackageFromUpload(); + break; + + case 'url': + $package = $this->_getPackageFromUrl(); + break; + + case 'continue': + $continue = true; + $package = $session->get('package', null); + $package = json_decode($package, true); + // clear session + $session->clear('package'); + $session->clear('dataType'); + $session->clear('hasPackage'); + break; + + default: + $app->setUserState('com_componentbuilder.message', Text::_('COM_COMPONENTBUILDER_IMPORT_NO_IMPORT_TYPE_FOUND')); + + return false; + break; + } + } + // Was the package valid? + if (!$package || !$package['type']) + { + if (in_array($this->getType, array('upload', 'url'))) + { + $this->remove($package['packagename']); + } + + $app->setUserState('com_componentbuilder.message', Text::_('COM_COMPONENTBUILDER_IMPORT_UNABLE_TO_FIND_IMPORT_PACKAGE')); + return false; + } + + // first link data to table headers + if(!$continue){ + $package = json_encode($package); + $session->set('package', $package); + $session->set('dataType', $this->dataType); + $session->set('hasPackage', true); + return true; + } + // set the data + $headerList = json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS', false), true); + if (!$this->setData($package,$this->dataType,$headerList)) + { + // There was an error importing the package + $msg = Text::_('COM_COMPONENTBUILDER_IMPORT_ERROR'); + $back = $session->get('backto_VDM_IMPORT', NULL); + if ($back) + { + $app->setUserState('com_componentbuilder.redirect_url', 'index.php?option=com_componentbuilder&view='.$back); + $session->clear('backto_VDM_IMPORT'); + } + $result = false; + } + else + { + // Package imported sucessfully + $msg = Text::sprintf('COM_COMPONENTBUILDER_IMPORT_SUCCESS', $package['packagename']); + $back = $session->get('backto_VDM_IMPORT', NULL); + if ($back) + { + $app->setUserState('com_componentbuilder.redirect_url', 'index.php?option=com_componentbuilder&view='.$back); + $session->clear('backto_VDM_IMPORT'); + } + $result = true; + } + + // Set some model state values + $app->enqueueMessage($msg); + + // remove file after import + $this->remove($package['packagename']); + $session->clear($this->getType.'_VDM_IMPORTHEADERS'); + return $result; + } + + /** + * Works out an importation spreadsheet from a HTTP upload + * + * @return spreadsheet definition or false on failure + */ + protected function _getPackageFromUpload() + { + // Get the uploaded file information + $app = Factory::getApplication(); + $input = $app->input; + + // Do not change the filter type 'raw'. We need this to let files containing PHP code to upload. See JInputFiles::get. + $userfile = $input->files->get('import_package', null, 'raw'); + + // Make sure that file uploads are enabled in php + if (!(bool) ini_get('file_uploads')) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_WARNIMPORTFILE'), 'warning'); + return false; + } + + // If there is no uploaded file, we have a problem... + if (!is_array($userfile)) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_NO_FILE_SELECTED'), 'warning'); + return false; + } + + // Check if there was a problem uploading the file. + if ($userfile['error'] || $userfile['size'] < 1) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_WARNIMPORTUPLOADERROR'), 'warning'); + return false; + } + + // Build the appropriate paths + $config = Factory::getConfig(); + $tmp_dest = $config->get('tmp_path') . '/' . $userfile['name']; + $tmp_src = $userfile['tmp_name']; + + // Move uploaded file + $p_file = File::upload($tmp_src, $tmp_dest, $this->use_streams, $this->allow_unsafe, $this->safeFileOptions); + + // Was the package downloaded? + if (!$p_file) + { + $session = Factory::getSession(); + $session->clear('package'); + $session->clear('dataType'); + $session->clear('hasPackage'); + // was not uploaded + return false; + } + + // check that this is a valid spreadsheet + $package = $this->check($userfile['name']); + + return $package; + } + + /** + * Import an spreadsheet from a directory + * + * @return array Spreadsheet details or false on failure + * + */ + protected function _getPackageFromFolder() + { + $app = Factory::getApplication(); + $input = $app->input; + + // Get the path to the package to import + $p_dir = $input->getString('import_directory'); + $p_dir = Path::clean($p_dir); + // Did you give us a valid path? + if (!file_exists($p_dir)) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_PLEASE_ENTER_A_PACKAGE_DIRECTORY'), 'warning'); + return false; + } + + // Detect the package type + $type = $this->getType; + + // Did you give us a valid package? + if (!$type) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE'), 'warning'); + } + + // check the extention + if(!$this->checkExtension($p_dir)) + { + // set error message + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); + return false; + } + + $package['packagename'] = null; + $package['dir'] = $p_dir; + $package['type'] = $type; + + return $package; + } + + /** + * Import an spreadsheet from a URL + * + * @return Package details or false on failure + * + */ + protected function _getPackageFromUrl() + { + $app = Factory::getApplication(); + $input = $app->input; + + // Get the URL of the package to import + $url = $input->getString('import_url'); + + // Did you give us a URL? + if (!$url) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_ENTER_A_URL'), 'warning'); + return false; + } + + // Download the package at the URL given + $p_file = InstallerHelper::downloadPackage($url); + + // Was the package downloaded? + if (!$p_file) + { + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_INVALID_URL'), 'warning'); + return false; + } + + // check that this is a valid spreadsheet + $package = $this->check($p_file); + + return $package; + } + + /** + * Check a file and verifies it as a spreadsheet file + * Supports .csv .xlsx .xls and .ods + * + * @param string $p_filename The uploaded package filename or import directory + * + * @return array of elements + * + */ + protected function check($archivename) + { + $app = Factory::getApplication(); + // Clean the name + $archivename = Path::clean($archivename); + + // check the extention + if(!$this->checkExtension($archivename)) + { + // Cleanup the import files + $this->remove($archivename); + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE'), 'warning'); + return false; + } + + $config = Factory::getConfig(); + // set Package Name + $check['packagename'] = $archivename; + + // set directory + $check['dir'] = $config->get('tmp_path'). '/' .$archivename; + + // set type + $check['type'] = $this->getType; + + return $check; + } + + /** + * Check the extension + * + * @param string $file Name of the uploaded file + * + * @return boolean True on success + * + */ + protected function checkExtension($file) + { + // check the extention + switch(strtolower(pathinfo($file, PATHINFO_EXTENSION))) + { + case 'xls': + case 'ods': + case 'csv': + return true; + break; + } + return false; + } + + /** + * Clean up temporary uploaded spreadsheet + * + * @param string $package Name of the uploaded spreadsheet file + * + * @return boolean True on success + * + */ + protected function remove($package) + { + $config = Factory::getConfig(); + $package = $config->get('tmp_path'). '/' .$package; + + // Is the package file a valid file? + if (is_file($package)) + { + File::delete($package); + } + elseif (is_file(Path::clean($package))) + { + // It might also be just a base filename + File::delete(Path::clean($package)); + } + } + + /** + * Set the data from the spreadsheet to the database + * + * @param string $package Paths to the uploaded package file + * + * @return boolean false on failure + * + **/ + protected function setData($package,$table,$target_headers) + { + if (UtilitiesArrayHelper::check($target_headers)) + { + // make sure the file is loaded + ComponentbuilderHelper::composerAutoload('phpspreadsheet'); + $jinput = Factory::getApplication()->input; + foreach($target_headers as $header) + { + if (($column = $jinput->getString($header, false)) !== false || + ($column = $jinput->getString(strtolower($header), false)) !== false) + { + $data['target_headers'][$header] = $column; + } + else + { + $data['target_headers'][$header] = null; + } + } + // set the data + if(isset($package['dir'])) + { + $inputFileType = IOFactory::identify($package['dir']); + $excelReader = IOFactory::createReader($inputFileType); + $excelReader->setReadDataOnly(true); + $excelObj = $excelReader->load($package['dir']); + $data['array'] = $excelObj->getActiveSheet()->toArray(null, true,true,true); + $excelObj->disconnectWorksheets(); + unset($excelObj); + return $this->save($data, $table); + } + } + return false; + } + + /** + * Save the data from the file to the database + * + * @param string $package Paths to the uploaded package file + * + * @return boolean false on failure + * + **/ + protected function save($data, $table) + { + // import the data if there is any + if(UtilitiesArrayHelper::check($data['array'])) + { + // get user object + $user = Factory::getUser(); + // remove header if it has headers + $id_key = $data['target_headers']['id']; + if (isset($data['target_headers']['Source'])) + { + $source_key = $data['target_headers']['Source']; + } + elseif (isset($data['target_headers']['English'])) + { + $source_key = $data['target_headers']['English']; + } + else + { + $source_key = null; + } + // get the first array set + $firstSet = reset($data['array']); + // check if first array is a header array and remove if true + if($firstSet[$id_key] == 'id' || $firstSet[$source_key] == 'Source' || $firstSet[$source_key] == 'English') + { + array_shift($data['array']); + } + // make sure there is still values in array and that it was not only headers + if(UtilitiesArrayHelper::check($data['array']) && $user->authorise($table.'.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder')) + { + // set target. + $target = array_flip($data['target_headers']); + // Get a db connection. + $db = Factory::getDbo(); + // set some defaults + $todayDate = Factory::getDate()->toSql(); + // get global action permissions + $canDo = ComponentbuilderHelper::getActions($table); + $canEdit = $canDo->get('core.edit'); + $canCreate = $canDo->get('core.create'); + $canState = $canDo->get('core.edit.state'); + // get languages + $languages = ComponentbuilderHelper::getVars('language', 1, 'published', 'langtag'); + // process the data + foreach($data['array'] as $row) + { + $found = false; + $has_id = false; + // check that we have a string or a number<-(which is weird... but happens at times) + if ($canEdit && isset($row[$source_key]) && (UtilitiesStringHelper::check($row[$source_key]) || is_numeric($row[$source_key]))) + { + // raw items import & update! + $query = $db->getQuery(true); + $query->select($db->quoteName(array('id', 'version', 'translation'))); + $query->from($db->quoteName('#__componentbuilder_'.$table)); + if (isset($row[$id_key]) && is_numeric($row[$id_key]) && $row[$id_key] > 0) + { + $query->where($db->quoteName('id') . ' = '. $db->quote($row[$id_key])); + $has_id = true; + } + $query->where($db->quoteName('source') . ' = '. $db->quote($row[$source_key])); + // Reset the query using our newly populated query object. + $db->setQuery($query); + $db->execute(); + $found = $db->getNumRows(); + // check one more time, just with source + if(!$found && $has_id) + { + // raw items import & update! + $query = $db->getQuery(true); + $query->select($db->quoteName(array('id', 'version', 'translation'))); + $query->from($db->quoteName('#__componentbuilder_'.$table)); + $query->where($db->quoteName('source') . ' = '. $db->quote($row[$source_key])); + // Reset the query using our newly populated query object. + $db->setQuery($query); + $db->execute(); + $found = $db->getNumRows(); + } + } + // check if we found the string + if($found && $canEdit) + { + // update item + $item = $db->loadObject(); + $id = $item->id; + // load previous translation strings + if (JsonHelper::check($item->translation)) + { + $translations = json_decode($item->translation, true); + $counter = count($translations) + 2; + $pre = true; + } + else + { + $translations = array(); + $counter = 0; + $pre = false; + } + // reset all buckets + $query = $db->getQuery(true); + $fields = array(); + // Fields to update. + foreach($row as $key => $cell) + { + // ignore column + if ('IGNORE' === $target[$key] || 'modified_by' === $target[$key] || 'modified' === $target[$key] || 'created_by' === $target[$key] || 'created' === $target[$key] || 'source' === strtolower($target[$key]) || 'english' === strtolower($target[$key])) + { + continue; + } + // update version + if ('version' == $target[$key]) + { + $cell = (int) $item->version + 1; + } + // verify publish authority + if ('published' == $target[$key] && !$canState) + { + continue; + } + // set to translations + if(in_array($target[$key], $languages)) + { + // only add if it has a string + if (UtilitiesStringHelper::check($cell)) + { + // remove if was set previously + if ($pre) + { + $tag = $target[$key]; + $translations = array_filter( + $translations, + function($trans) use($tag) { + if ($trans['language'] !== $tag) + { + return true; + } + return false; + }); + } + $translations['translation'.$counter] = array('language' => $target[$key], 'translation' => $cell); + $counter++; + } + } + // set to update array + elseif(in_array($key, $data['target_headers']) && is_numeric($cell)) + { + $fields[] = $db->quoteName($target[$key]) . ' = ' . $cell; + } + elseif(in_array($key, $data['target_headers']) && is_string($cell)) + { + $fields[] = $db->quoteName($target[$key]) . ' = ' . $db->quote($cell); + } + elseif(in_array($key, $data['target_headers']) && is_null($cell)) + { + // if import data is null then set empty + $fields[] = $db->quoteName($target[$key]) . " = ''"; + } + } + // set the translation + if (UtilitiesArrayHelper::check($translations)) + { + $fields[] = $db->quoteName('translation') . ' = ' . $db->quote(json_encode($translations, JSON_FORCE_OBJECT)); + // load the defaults + $fields[] = $db->quoteName('modified_by') . ' = ' . (int) $user->id; + $fields[] = $db->quoteName('modified') . ' = ' . $db->quote($todayDate); + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('id') . ' = ' . $id + ); + // update the local translation + $query->update($db->quoteName('#__componentbuilder_'.$table))->set($fields)->where($conditions); + $db->setQuery($query); + $db->execute(); + } + } + elseif (!$found && $canCreate) + { + $translations = array(); + $counter = 0; + // reset all buckets + $query = $db->getQuery(true); + $values = array(); + $columns = array(); + // Fields to update. + foreach($row as $key => $cell) + { + // ignore column + if ('IGNORE' === $target[$key] || 'modified_by' === $target[$key] || 'modified' === $target[$key] || 'created_by' === $target[$key] || 'created' === $target[$key] || 'version' == $target[$key]) + { + continue; + } + // verify publish authority + if ('published' == $target[$key] && !$canState) + { + continue; + } + // set to translations + if(in_array($target[$key], $languages)) + { + // only add if it has a string + if (UtilitiesStringHelper::check($cell)) + { + $translations['translation'.$counter] = array('language' => $target[$key], 'translation' => $cell); + $counter++; + } + } + // load the source + elseif ('source' === strtolower($target[$key]) || 'english' === strtolower($target[$key])) + { + $columns[] = 'source'; + $values[] = $db->quote($cell); + } + // set to update array + elseif(in_array($key, $data['target_headers']) && is_numeric($cell)) + { + $columns[] = $target[$key]; + $values[] = $cell; + } + elseif(in_array($key, $data['target_headers']) && is_string($cell)) + { + $columns[] = $target[$key]; + $values[] = $db->quote($cell); + } + elseif(in_array($key, $data['target_headers']) && is_null($cell)) + { + // if import data is null then set empty + $columns[] = $target[$key]; + $values[] = ''; + } + } + // set the translation + if (UtilitiesArrayHelper::check($translations)) + { + $columns[] = 'translation'; + $values[] = $db->quote(json_encode($translations, JSON_FORCE_OBJECT)); + } + // check if we have values + if (UtilitiesArrayHelper::check($values)) + { + // load the defaults + $columns[] = 'created_by'; + $values[] = (int) $user->id; + $columns[] = 'created'; + $values[] = $db->quote($todayDate); + $columns[] = 'version'; + $values[] = 1; + // update the local translation + $query->insert($db->quoteName('#__componentbuilder_'.$table))->columns($db->quoteName($columns))->values(implode(',', $values)); + $db->setQuery($query); + $db->execute(); + } + } + } + return true; + } + } + return false; + } + + protected function getAlias($name,$type = false) + { + // sanitize the name to an alias + if (Factory::getConfig()->get('unicodeslugs') == 1) + { + $alias = OutputFilter::stringURLUnicodeSlug($name); + } + else + { + $alias = OutputFilter::stringURLSafe($name); + } + // must be a uniqe alias + if ($type) + { + return $this->getUniqe($alias,'alias',$type); + } + return $alias; + } + + /** + * Method to generate a uniqe value. + * + * @param string $field name. + * @param string $value data. + * @param string $type table. + * + * @return string New value. + */ + protected function getUniqe($value,$field,$type) + { + // insure the filed is always uniqe + while (isset($this->uniqeValueArray[$type][$field][$value])) + { + $value = StringHelper::increment($value, 'dash'); + } + $this->uniqeValueArray[$type][$field][$value] = $value; + return $value; + } + + protected function getAliasesUsed($table) + { + // Get a db connection. + $db = $this->getDatabase(); + // first we check if there is a alias column + $columns = $db->getTableColumns('#__componentbuilder_'.$table); + if(isset($columns['alias'])){ + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('alias'))); + $query->from($db->quoteName('#__componentbuilder_'.$table)); + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $aliases = $db->loadColumn(); + foreach($aliases as $alias) + { + $this->uniqeValueArray[$table]['alias'][$alias] = $alias; + } + } + return true; + } + return false; + } +} diff --git a/admin/src/Model/Joomla_componentModel.php b/admin/src/Model/Joomla_componentModel.php new file mode 100644 index 000000000..48a601d7c --- /dev/null +++ b/admin/src/Model/Joomla_componentModel.php @@ -0,0 +1,1704 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\FOF\Encrypt\AES; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Componentbuilder\Extrusion\Helper\Extrusion; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Joomla_component Admin Model + * + * @since 1.6 + */ +class Joomla_componentModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'name', + 'name_code', + 'component_version', + 'debug_linenr', + 'add_placeholders', + 'remove_line_breaks', + 'mvc_versiondate', + 'note_version_options_1', + 'note_version_options_2', + 'note_version_options_3', + 'short_description', + 'description' + ), + 'right' => array( + 'companyname', + 'author', + 'email', + 'website', + 'add_license', + 'license_type', + 'note_whmcs_lisencing_note', + 'whmcs_key', + 'whmcs_url', + 'whmcs_buy_link', + 'license', + 'bom', + 'image', + 'copyright' + ), + 'above' => array( + 'system_name', + 'preferred_joomla_version', + 'add_powers' + ), + 'under' => array( + 'not_required' + ) + ), + 'dynamic_build_beta' => array( + 'fullwidth' => array( + 'note_buildcomp_dynamic_mysql', + 'buildcomp', + 'buildcompsql' + ) + ), + 'dynamic_integration' => array( + 'left' => array( + 'add_update_server', + 'update_server_url', + 'update_server_target', + 'note_update_server_note_ftp', + 'note_update_server_note_zip', + 'note_update_server_note_other', + 'update_server', + 'add_sales_server', + 'sales_server', + 'add_backup_folder_path', + 'note_backup_folder_path', + 'backup_folder_path', + 'add_git_folder_path', + 'note_git_folder_path', + 'git_folder_path' + ), + 'right' => array( + 'translation_tool', + 'note_crowdin', + 'crowdin_project_identifier', + 'crowdin_project_api_key', + 'crowdin_username', + 'crowdin_account_api_key' + ) + ), + 'readme' => array( + 'left' => array( + 'addreadme', + 'readme' + ), + 'right' => array( + 'note_readme' + ) + ), + 'dash_install' => array( + 'left' => array( + 'dashboard_type' + ), + 'right' => array( + 'note_dynamic_dashboard', + 'dashboard', + 'note_botton_component_dashboard' + ), + 'fullwidth' => array( + 'add_php_preflight_install', + 'php_preflight_install', + 'add_php_preflight_update', + 'php_preflight_update', + 'add_php_postflight_install', + 'php_postflight_install', + 'add_php_postflight_update', + 'php_postflight_update', + 'add_php_method_uninstall', + 'php_method_uninstall' + ) + ), + 'libs_helpers' => array( + 'fullwidth' => array( + 'creatuserhelper', + 'adduikit', + 'addfootable', + 'add_email_helper', + 'add_php_helper_both', + 'php_helper_both', + 'add_php_helper_admin', + 'php_helper_admin', + 'add_admin_event', + 'php_admin_event', + 'add_php_helper_site', + 'php_helper_site', + 'add_site_event', + 'php_site_event', + 'add_javascript', + 'javascript', + 'add_css_admin', + 'css_admin', + 'add_css_site', + 'css_site' + ) + ), + 'mysql' => array( + 'fullwidth' => array( + 'add_sql', + 'sql', + 'add_sql_uninstall', + 'sql_uninstall', + 'assets_table_fix' + ) + ), + 'settings' => array( + 'left' => array( + 'note_moved_views', + 'spacer_hr_1', + 'note_mysql_tweak_options', + 'spacer_hr_2', + 'note_add_custom_menus', + 'spacer_hr_3', + 'note_add_config' + ), + 'right' => array( + 'note_component_files_folders', + 'spacer_hr_4', + 'add_namespace_prefix', + 'namespace_prefix', + 'spacer_hr_5', + 'add_menu_prefix', + 'menu_prefix', + 'spacer_hr_6', + 'to_ignore_note', + 'toignore', + 'spacer_hr_7', + 'jcb_export_package_note', + 'export_key', + 'joomla_source_link', + 'export_buy_link' + ), + 'fullwidth' => array( + 'spacer_hr_8', + 'note_on_contributors', + 'addcontributors', + 'emptycontributors', + 'number' + ) + ), + 'admin_views' => array( + 'fullwidth' => array( + 'note_on_admin_views', + 'note_display_component_admin_views' + ) + ), + 'site_views' => array( + 'fullwidth' => array( + 'note_on_site_views', + 'note_display_component_site_views' + ) + ), + 'custom_admin_views' => array( + 'fullwidth' => array( + 'note_on_custom_admin_views', + 'note_display_component_custom_admin_views' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/joomla_component.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/joomla_component.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.joomla_component'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'joomla_component', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('joomla_component__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'joomla_component__'.$id); + ComponentbuilderHelper::set('joomla_component__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + /** + * The assistant form fields + * + * @var array + */ + public $assistantForm = array( + 'left' => array( + 'name', + 'short_description', + 'guid', + 'copyright' + ), + 'right' => array( + 'name_code', + 'license', + 'bom', + 'image' + ) + ); + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->buildcompsql)) + { + // base64 Decode buildcompsql. + $item->buildcompsql = base64_decode($item->buildcompsql); + } + + if (!empty($item->php_method_uninstall)) + { + // base64 Decode php_method_uninstall. + $item->php_method_uninstall = base64_decode($item->php_method_uninstall); + } + + if (!empty($item->php_preflight_install)) + { + // base64 Decode php_preflight_install. + $item->php_preflight_install = base64_decode($item->php_preflight_install); + } + + if (!empty($item->css_admin)) + { + // base64 Decode css_admin. + $item->css_admin = base64_decode($item->css_admin); + } + + if (!empty($item->php_site_event)) + { + // base64 Decode php_site_event. + $item->php_site_event = base64_decode($item->php_site_event); + } + + if (!empty($item->php_postflight_install)) + { + // base64 Decode php_postflight_install. + $item->php_postflight_install = base64_decode($item->php_postflight_install); + } + + if (!empty($item->sql_uninstall)) + { + // base64 Decode sql_uninstall. + $item->sql_uninstall = base64_decode($item->sql_uninstall); + } + + if (!empty($item->php_helper_both)) + { + // base64 Decode php_helper_both. + $item->php_helper_both = base64_decode($item->php_helper_both); + } + + if (!empty($item->php_admin_event)) + { + // base64 Decode php_admin_event. + $item->php_admin_event = base64_decode($item->php_admin_event); + } + + if (!empty($item->php_helper_admin)) + { + // base64 Decode php_helper_admin. + $item->php_helper_admin = base64_decode($item->php_helper_admin); + } + + if (!empty($item->php_helper_site)) + { + // base64 Decode php_helper_site. + $item->php_helper_site = base64_decode($item->php_helper_site); + } + + if (!empty($item->javascript)) + { + // base64 Decode javascript. + $item->javascript = base64_decode($item->javascript); + } + + if (!empty($item->css_site)) + { + // base64 Decode css_site. + $item->css_site = base64_decode($item->css_site); + } + + if (!empty($item->php_preflight_update)) + { + // base64 Decode php_preflight_update. + $item->php_preflight_update = base64_decode($item->php_preflight_update); + } + + if (!empty($item->php_postflight_update)) + { + // base64 Decode php_postflight_update. + $item->php_postflight_update = base64_decode($item->php_postflight_update); + } + + if (!empty($item->sql)) + { + // base64 Decode sql. + $item->sql = base64_decode($item->sql); + } + + if (!empty($item->readme)) + { + // base64 Decode readme. + $item->readme = base64_decode($item->readme); + } + + // Get the basic encryption. + $basickey = ComponentbuilderHelper::getCryptKey('basic'); + // Get the encryption object. + $basic = new AES($basickey); + + if (!empty($item->crowdin_username) && $basickey && !is_numeric($item->crowdin_username) && $item->crowdin_username === base64_encode(base64_decode($item->crowdin_username, true))) + { + // basic decrypt data crowdin_username. + $item->crowdin_username = rtrim($basic->decryptString($item->crowdin_username), "\0"); + } + + if (!empty($item->whmcs_key) && $basickey && !is_numeric($item->whmcs_key) && $item->whmcs_key === base64_encode(base64_decode($item->whmcs_key, true))) + { + // basic decrypt data whmcs_key. + $item->whmcs_key = rtrim($basic->decryptString($item->whmcs_key), "\0"); + } + + if (!empty($item->export_key) && $basickey && !is_numeric($item->export_key) && $item->export_key === base64_encode(base64_decode($item->export_key, true))) + { + // basic decrypt data export_key. + $item->export_key = rtrim($basic->decryptString($item->export_key), "\0"); + } + + if (!empty($item->crowdin_project_api_key) && $basickey && !is_numeric($item->crowdin_project_api_key) && $item->crowdin_project_api_key === base64_encode(base64_decode($item->crowdin_project_api_key, true))) + { + // basic decrypt data crowdin_project_api_key. + $item->crowdin_project_api_key = rtrim($basic->decryptString($item->crowdin_project_api_key), "\0"); + } + + if (!empty($item->crowdin_account_api_key) && $basickey && !is_numeric($item->crowdin_account_api_key) && $item->crowdin_account_api_key === base64_encode(base64_decode($item->crowdin_account_api_key, true))) + { + // basic decrypt data crowdin_account_api_key. + $item->crowdin_account_api_key = rtrim($basic->decryptString($item->crowdin_account_api_key), "\0"); + } + + if (!empty($item->addcontributors)) + { + // Convert the addcontributors field to an array. + $addcontributors = new Registry; + $addcontributors->loadString($item->addcontributors); + $item->addcontributors = $addcontributors->toArray(); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('joomla_component__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'joomla_component__'.$id); + ComponentbuilderHelper::set('joomla_component__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + + // update the fields + $objectUpdate = new \stdClass(); + $objectUpdate->id = (int) $item->id; + // repeatable values to check + $arrayChecker = array( + 'addcontributors' => 'name' + ); + foreach ($arrayChecker as $_value => $checker) + { + // check what type of array we have here (should be subform... but just in case) + // This could happen due to huge data sets + if (isset($item->{$_value}) && isset($item->{$_value}[$checker])) + { + $bucket = array(); + foreach($item->{$_value} as $option => $values) + { + foreach($values as $nr => $value) + { + $bucket[$_value.$nr][$option] = $value; + } + } + $item->{$_value} = $bucket; + $objectUpdate->{$_value} = json_encode($bucket, JSON_FORCE_OBJECT); + } + } + // be sure to update the table if we found repeatable fields that are still not converted + if (count((array) $objectUpdate) > 1) + { + $this->_db->updateObject('#__componentbuilder_joomla_component', $objectUpdate, 'id'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.joomla_component', 'joomla_component', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('joomla_component.edit.state', 'com_componentbuilder.joomla_component.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_component.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('joomla_component.edit.created_by', 'com_componentbuilder.joomla_component.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_component.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('joomla_component.edit.created', 'com_componentbuilder.joomla_component.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_component.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + // Only load these values if no id is found + if (0 == $id) + { + // set company defaults + $form->setValue('companyname', null, ComponentHelper::getParams('com_componentbuilder')->get('export_company', '')); + $form->setValue('author', null, ComponentHelper::getParams('com_componentbuilder')->get('export_owner', '')); + $form->setValue('email', null, ComponentHelper::getParams('com_componentbuilder')->get('export_email', '')); + $form->setValue('website', null, ComponentHelper::getParams('com_componentbuilder')->get('export_website', '')); + $form->setValue('copyright', null, ComponentHelper::getParams('com_componentbuilder')->get('export_copyright', 'Copyright (C) 2015. All Rights Reserved')); + $form->setValue('license', null, ComponentHelper::getParams('com_componentbuilder')->get('export_license', 'GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html')); + } + + // update all editors to use this components global editor + $global_editor = ComponentHelper::getParams('com_componentbuilder')->get('editor', 'none'); + // now get all the editor fields + $editors = $form->getXml()->xpath("//field[@type='editor']"); + // check if we found any + if (UtilitiesArrayHelper::check($editors)) + { + foreach ($editors as $editor) + { + // get the field names + $name = (string) $editor['name']; + // set the field editor value (with none as fallback) + $form->setFieldAttribute($name, 'editor', $global_editor . '|none'); + } + } + + + // Only load the GUID if new item (or empty) + if (0 == $id || !($val = $form->getValue('guid'))) + { + $form->setValue('guid', null, GuidHelper::get()); + } + + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('joomla_component.delete', 'com_componentbuilder.joomla_component.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('joomla_component.edit.state', 'com_componentbuilder.joomla_component.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('joomla_component.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('joomla_component.edit', 'com_componentbuilder.joomla_component.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('joomla_component.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_joomla_component')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.joomla_component.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.joomla_component', $data); + + return $data; + } + + /** + * Method to validate the form data. + * + * @param JForm $form The form to validate against. + * @param array $data The data to validate. + * @param string $group The name of the field group to validate. + * + * @return mixed Array of filtered data if valid, false otherwise. + * + * @see JFormRule + * @see JFilterInput + * @since 12.2 + */ + public function validate($form, $data, $group = null) + { + // check if the not_required field is set + if (isset($data['not_required']) && UtilitiesStringHelper::check($data['not_required'])) + { + $requiredFields = (array) explode(',',(string) $data['not_required']); + $requiredFields = array_unique($requiredFields); + // now change the required field attributes value + foreach ($requiredFields as $requiredField) + { + // make sure there is a string value + if (UtilitiesStringHelper::check($requiredField)) + { + // change to false + $form->setFieldAttribute($requiredField, 'required', 'false'); + // also clear the data set + $data[$requiredField] = ''; + } + } + } + return parent::validate($form, $data, $group); + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return array('guid'); + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + // we must also delete the linked tables found + if (UtilitiesArrayHelper::check($pks)) + { + $_tablesArray = array( + 'component_admin_views' => 'joomla_component', + 'component_site_views' => 'joomla_component', + 'component_custom_admin_views' => 'joomla_component', + 'component_updates' => 'joomla_component', + 'component_mysql_tweaks' => 'joomla_component', + 'component_custom_admin_menus' => 'joomla_component', + 'component_config' => 'joomla_component', + 'component_dashboard' => 'joomla_component', + 'component_files_folders' => 'joomla_component', + 'component_placeholders' => 'joomla_component', + 'custom_code' => 'component', + 'component_router' => 'joomla_component' + ); + foreach($_tablesArray as $_updateTable => $_key) + { + // get the linked IDs + if ($_pks = ComponentbuilderHelper::getVars($_updateTable, $pks, $_key, 'id')) + { + // load the model + $_Model = ComponentbuilderHelper::getModel($_updateTable); + // delete items + $_Model->delete($_pks); + } + } + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + // we must also update all linked tables + if (UtilitiesArrayHelper::check($pks)) + { + $_tablesArray = array( + 'component_admin_views' => 'joomla_component', + 'component_site_views' => 'joomla_component', + 'component_custom_admin_views' => 'joomla_component', + 'component_updates' => 'joomla_component', + 'component_mysql_tweaks' => 'joomla_component', + 'component_custom_admin_menus' => 'joomla_component', + 'component_config' => 'joomla_component', + 'component_dashboard' => 'joomla_component', + 'component_files_folders' => 'joomla_component', + 'component_placeholders' => 'joomla_component', + 'custom_code' => 'component', + 'component_router' => 'joomla_component' + ); + foreach($_tablesArray as $_updateTable => $_key) + { + // get the linked IDs + if ($_pks = ComponentbuilderHelper::getVars($_updateTable, $pks, $_key, 'id')) + { + // load the model + $_Model = ComponentbuilderHelper::getModel($_updateTable); + // change publish state + $_Model->publish($_pks, $value); + } + } + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('joomla_component'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('joomla_component'); + } + + if (!$this->canDo->get('joomla_component.create') && !$this->canDo->get('joomla_component.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('joomla_component.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('joomla_component.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->system_name) && !is_numeric($this->table->system_name)) + { + $this->table->system_name = $this->generateUnique('system_name',$this->table->system_name); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('joomla_component'); + } + + if (!$this->canDo->get('joomla_component.edit') && !$this->canDo->get('joomla_component.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('joomla_component.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('joomla_component.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // if system name is empty create from name + if (empty($data['system_name']) || !UtilitiesStringHelper::check($data['system_name'])) + { + $data['system_name'] = $data['name']; + } + + // Set the GUID if empty or not valid + if (empty($data['guid']) && $data['id'] > 0) + { + // get the existing one + $data['guid'] = (string) GetHelper::var('joomla_component', $data['id'], 'id', 'guid'); + } + + // Set the GUID if empty or not valid + while (!GuidHelper::valid($data['guid'], "joomla_component", $data['id'])) + { + // must always be set + $data['guid'] = (string) GuidHelper::get(); + } + + // Set the addcontributors items to data. + if (isset($data['addcontributors']) && is_array($data['addcontributors'])) + { + $addcontributors = new Registry; + $addcontributors->loadArray($data['addcontributors']); + $data['addcontributors'] = (string) $addcontributors; + } + elseif (!isset($data['addcontributors'])) + { + // Set the empty addcontributors to data + $data['addcontributors'] = ''; + } + + // Set the buildcompsql string to base64 string. + if (isset($data['buildcompsql'])) + { + $data['buildcompsql'] = base64_encode($data['buildcompsql']); + } + + // Set the php_method_uninstall string to base64 string. + if (isset($data['php_method_uninstall'])) + { + $data['php_method_uninstall'] = base64_encode($data['php_method_uninstall']); + } + + // Set the php_preflight_install string to base64 string. + if (isset($data['php_preflight_install'])) + { + $data['php_preflight_install'] = base64_encode($data['php_preflight_install']); + } + + // Set the css_admin string to base64 string. + if (isset($data['css_admin'])) + { + $data['css_admin'] = base64_encode($data['css_admin']); + } + + // Set the php_site_event string to base64 string. + if (isset($data['php_site_event'])) + { + $data['php_site_event'] = base64_encode($data['php_site_event']); + } + + // Set the php_postflight_install string to base64 string. + if (isset($data['php_postflight_install'])) + { + $data['php_postflight_install'] = base64_encode($data['php_postflight_install']); + } + + // Set the sql_uninstall string to base64 string. + if (isset($data['sql_uninstall'])) + { + $data['sql_uninstall'] = base64_encode($data['sql_uninstall']); + } + + // Set the php_helper_both string to base64 string. + if (isset($data['php_helper_both'])) + { + $data['php_helper_both'] = base64_encode($data['php_helper_both']); + } + + // Set the php_admin_event string to base64 string. + if (isset($data['php_admin_event'])) + { + $data['php_admin_event'] = base64_encode($data['php_admin_event']); + } + + // Set the php_helper_admin string to base64 string. + if (isset($data['php_helper_admin'])) + { + $data['php_helper_admin'] = base64_encode($data['php_helper_admin']); + } + + // Set the php_helper_site string to base64 string. + if (isset($data['php_helper_site'])) + { + $data['php_helper_site'] = base64_encode($data['php_helper_site']); + } + + // Set the javascript string to base64 string. + if (isset($data['javascript'])) + { + $data['javascript'] = base64_encode($data['javascript']); + } + + // Set the css_site string to base64 string. + if (isset($data['css_site'])) + { + $data['css_site'] = base64_encode($data['css_site']); + } + + // Set the php_preflight_update string to base64 string. + if (isset($data['php_preflight_update'])) + { + $data['php_preflight_update'] = base64_encode($data['php_preflight_update']); + } + + // Set the php_postflight_update string to base64 string. + if (isset($data['php_postflight_update'])) + { + $data['php_postflight_update'] = base64_encode($data['php_postflight_update']); + } + + // Set the sql string to base64 string. + if (isset($data['sql'])) + { + $data['sql'] = base64_encode($data['sql']); + } + + // Set the readme string to base64 string. + if (isset($data['readme'])) + { + $data['readme'] = base64_encode($data['readme']); + } + + // Get the basic encryption key. + $basickey = ComponentbuilderHelper::getCryptKey('basic'); + // Get the encryption object + $basic = new AES($basickey); + + // Encrypt data crowdin_username. + if (isset($data['crowdin_username']) && $basickey) + { + $data['crowdin_username'] = $basic->encryptString($data['crowdin_username']); + } + + // Encrypt data whmcs_key. + if (isset($data['whmcs_key']) && $basickey) + { + $data['whmcs_key'] = $basic->encryptString($data['whmcs_key']); + } + + // Encrypt data export_key. + if (isset($data['export_key']) && $basickey) + { + $data['export_key'] = $basic->encryptString($data['export_key']); + } + + // Encrypt data crowdin_project_api_key. + if (isset($data['crowdin_project_api_key']) && $basickey) + { + $data['crowdin_project_api_key'] = $basic->encryptString($data['crowdin_project_api_key']); + } + + // Encrypt data crowdin_account_api_key. + if (isset($data['crowdin_account_api_key']) && $basickey) + { + $data['crowdin_account_api_key'] = $basic->encryptString($data['crowdin_account_api_key']); + } + + // we check if component should be build from sql file + if (isset($data['buildcomp']) && 1 == $data['buildcomp']) + { + $extruder__ = new Extrusion($data); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Joomla_componentsModel.php b/admin/src/Model/Joomla_componentsModel.php new file mode 100644 index 000000000..74a61b95d --- /dev/null +++ b/admin/src/Model/Joomla_componentsModel.php @@ -0,0 +1,3009 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Componentbuilder\Package\Factory as PackageFactory; +use VDM\Joomla\Utilities\FileHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\Base64Helper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\FOF\Encrypt\AES; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_components List Model + * + * @since 1.6 + */ +class Joomla_componentsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/joomla_components.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.companyname','companyname', + 'a.author','author', + 'a.system_name','system_name', + 'a.name_code','name_code', + 'a.short_description','short_description', + 'a.created','created', + 'a.modified','modified' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + public $user; + public $packagePath = false; + public $packageName = false; + public $zipPath = false; + public $key = array(); + public $exportBuyLinks = array(); + public $joomlaSourceLinks = array(); + public $info = array( + 'name' => array(), + 'short_description' => array(), + 'component_version' => array(), + 'companyname' => array(), + 'author' => array(), + 'email' => array(), + 'website' => array(), + 'license' => array(), + 'copyright' => array(), + 'getKeyFrom' => null + ); + public $activeType = 'export'; + public $backupType = 1; + + protected $params; + protected $tempPath; + protected $customPath; + protected $smartBox = array(); + protected $smartIDs = array(); + protected $customCodeM = array(); + protected $placeholderM = array(); + protected $placeholderS = array(); + protected $fieldTypes = array(); + protected $isMultiple = array(); + + /** + * Method to clone the component + * + * @return bool on success. + */ + public function cloner($pks) + { + // get the components + if ($items = $this->getComponents($pks)) + { + // update $pks with returned IDs + $pks = array(); + // start loading the components + $this->smartBox['joomla_component'] = array(); + foreach ($items as $nr => &$item) + { + // check if user has access + $access = ($this->user->authorise('joomla_component.access', 'com_componentbuilder.joomla_component.' . (int) $item->id) && $this->user->authorise('joomla_component.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + // make sure old fields are not exported any more + $this->removeOldComponentValues($item); + // load to global object + $this->smartBox['joomla_component'][$item->id] = $item; + // set the powers linked to this joomla component + $this->setSmartIDs($this->getValues($item->params, 'power', 'joomla_component_headers', null), 'power', false); + // add to pks + $pks[] = $item->id; + } + + // has any data been set for this component + if (JCBArrayHelper::check($pks)) + { + // load the linked stuff + $this->getLinkedToComponents($pks); + } + + // has any data been set for this component + if (isset($this->smartBox['joomla_component']) && JCBArrayHelper::check($this->smartBox['joomla_component'])) + { + // set the folder and move the files of each component to the folder + return $this->smartCloner(); + } + } + return false; + } + + /** + * Method to build the export package + * + * @return bool on success. + */ + public function getSmartExport($pks) + { + // get the components + if ($items = $this->getComponents($pks)) + { + // set custom folder path + $this->customPath = $this->params->get('custom_folder_path', JPATH_COMPONENT_ADMINISTRATOR.'/custom'); + // set the backup paths + $comConfig = Factory::getConfig(); + $this->backupPath = $comConfig->get('tmp_path'); + // check what type of export or backup this is + if ('backup' === $this->activeType || 'manualBackup' === $this->activeType) + { + // set the zip path + $this->zipPath = $this->params->get('cronjob_backup_folder_path', $this->backupPath); + // check what backup type we are working with here + $this->backupType = $this->params->get('cronjob_backup_type', 1); // 1 = local folder; 2 = remote server (default is local) + // if remote server get the ID + if (2 == $this->backupType) + { + $this->backupServer = $this->params->get('cronjob_backup_server', null); + } + // set the date array + $date = Factory::getDate(); + $placeholderDate = array(); + $placeholderDate['[YEAR]'] = $date->format('Y'); + $placeholderDate['[MONTH]'] = $date->format('m'); + $placeholderDate['[DAY]'] = $date->format('d'); + $placeholderDate['[HOUR]'] = $date->format('H'); + $placeholderDate['[MINUTE]'] = $date->format('i'); + // get the package name + $packageName = $this->params->get('backup_package_name', 'JCB_Backup_[YEAR]_[MONTH]_[DAY]'); + $this->packageName = str_replace(array_keys($placeholderDate), array_values($placeholderDate), $packageName); + } + else + { + // set the zip path + $this->zipPath = $this->backupPath; + // set the package name + if (count($items) == 1) + { + $this->packageName = 'JCB_' . $this->getPackageName($items); + } + else + { + $this->packageName = 'JCB_smartPackage'; + } + } + + // set the package path + $this->packagePath = rtrim($this->backupPath, '/') . '/' . $this->packageName; + $this->zipPath = rtrim($this->zipPath, '/') . '/' . $this->packageName .'.zip'; + if (FileHelper::exists($this->packagePath)) + { + // remove if old folder is found + ComponentbuilderHelper::removeFolder($this->packagePath); + } + + // create the folders + JFolder::create($this->packagePath); + + // update $pks with returned IDs + $pks = array(); + + // start loading the components + $this->smartBox['joomla_component'] = array(); + foreach ($items as $nr => &$item) + { + // check if user has access + $access = ($this->user->authorise('joomla_component.access', 'com_componentbuilder.joomla_component.' . (int) $item->id) && $this->user->authorise('joomla_component.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // make sure old fields are not exported any more + $this->removeOldComponentValues($item); + + // build information data set + $this->info['name'][$item->id] = $item->name; + $this->info['short_description'][$item->id] = $item->short_description; + $this->info['component_version'][$item->id] = $item->component_version; + $this->info['companyname'][$item->id] = $item->companyname; + $this->info['author'][$item->id] = $item->author; + $this->info['email'][$item->id] = $item->email; + $this->info['website'][$item->id] = $item->website; + $this->info['license'][$item->id] = $item->license; + $this->info['copyright'][$item->id] = $item->copyright; + + // set the keys + if (isset($item->export_key) && StringHelper::check($item->export_key)) + { + // keep the key locked for exported data set + $export_key = $item->export_key; + if (!is_numeric($item->export_key) && $item->export_key === base64_encode(base64_decode($item->export_key, true))) + { + $export_key = PackageFactory::_('Crypt')->decrypt($item->export_key, 'basic'); + } + // make sure we have a string + if (strlen($export_key) > 4 ) + { + $this->key[$item->id] = $export_key; + } + } + + // get name of this item key_name + if (isset($item->system_name)) + { + $keyName = StringHelper::safe($item->system_name, 'cAmel'); + } + else + { + $keyName = StringHelper::safe($item->name_code); + } + + // set the export buy links + if (isset($item->export_buy_link) && StringHelper::check($item->export_buy_link)) + { + // set the export buy link + $this->info['export_buy_link'][$item->id] = $item->export_buy_link; + } + + // set the export buy links + if (isset($item->joomla_source_link) && StringHelper::check($item->joomla_source_link)) + { + // set the source link + $this->info['joomla_source_link'][$item->id] = $item->joomla_source_link; + } + + // component image + $this->moveIt(array($item->image), 'image'); + // set the custom code ID's + $this->setCodePlaceholdersIds($item, 'joomla_component'); + // set the placeholder ID's + $this->setCodePlaceholdersIds($item, 'joomla_component', 'placeholder'); + // set the language strings for this component + $this->setLanguageTranslation($item->id); + // load to global object + $this->smartBox['joomla_component'][$item->id] = $item; + // set the powers linked to this joomla component + $this->setSmartIDs($this->getValues($item->params, 'power', 'joomla_component_headers', null), 'power', false); + // add to pks + $pks[] = $item->id; + } + + // has any data been set for this component + if (JCBArrayHelper::check($pks)) + { + // load the linked stuff + $this->getLinkedToComponents($pks); + } + + // has any data been set for this component + if (isset($this->smartBox['joomla_component']) && JCBArrayHelper::check($this->smartBox['joomla_component'])) + { + // set the folder and move the files of each component to the folder + return $this->smartExportBuilder(); + } + } + return false; + } + + /** + * Get Everything Linked to Components + * + * @return void + */ + protected function getLinkedToComponents($pks) + { + // array of tables linked to joomla_component + $linkedTables = array( + 'custom_code' => 'component', + 'component_files_folders' => 'joomla_component', + 'component_admin_views' => 'joomla_component', + 'component_config' => 'joomla_component', + 'component_site_views' => 'joomla_component', + 'component_custom_admin_views' => 'joomla_component', + 'component_updates' => 'joomla_component', + 'component_mysql_tweaks' => 'joomla_component', + 'component_custom_admin_menus' => 'joomla_component', + 'component_dashboard' => 'joomla_component', + 'component_placeholders' => 'joomla_component', + 'component_modules' => 'joomla_component', + 'component_plugins' => 'joomla_component'); + // load all tables linked to joomla_component + foreach($linkedTables as $table => $field) + { + $this->setData($table, $pks, $field); + } + // add fields conditions and relations + if (isset($this->smartIDs['admin_view']) && JCBArrayHelper::check($this->smartIDs['admin_view'])) + { + $this->setData('admin_fields', array_values($this->smartIDs['admin_view']), 'admin_view'); + $this->setData('admin_fields_conditions', array_values($this->smartIDs['admin_view']), 'admin_view'); + $this->setData('admin_fields_relations', array_values($this->smartIDs['admin_view']), 'admin_view'); + $this->setData('admin_custom_tabs', array_values($this->smartIDs['admin_view']), 'admin_view'); + } + // add joomla module + if (isset($this->smartIDs['joomla_module']) && JCBArrayHelper::check($this->smartIDs['joomla_module'])) + { + $this->setData('joomla_module', array_values($this->smartIDs['joomla_module']), 'id'); + $this->setData('joomla_module_updates', array_values($this->smartIDs['joomla_module']), 'joomla_module'); + $this->setData('joomla_module_files_folders_urls', array_values($this->smartIDs['joomla_module']), 'joomla_module'); + } + // add joomla plugin + if (isset($this->smartIDs['joomla_plugin']) && JCBArrayHelper::check($this->smartIDs['joomla_plugin'])) + { + $this->setData('joomla_plugin', array_values($this->smartIDs['joomla_plugin']), 'id'); + $this->setData('joomla_plugin_updates', array_values($this->smartIDs['joomla_plugin']), 'joomla_plugin'); + $this->setData('joomla_plugin_files_folders_urls', array_values($this->smartIDs['joomla_plugin']), 'joomla_plugin'); + } + // add validation rules + if (isset($this->smartIDs['validation_rule']) && JCBArrayHelper::check($this->smartIDs['validation_rule'])) + { + $this->setData('validation_rule', array_values($this->smartIDs['validation_rule']), 'name'); + } + // add field types + if (isset($this->smartIDs['fieldtype']) && JCBArrayHelper::check($this->smartIDs['fieldtype'])) + { + $this->setData('fieldtype', array_values($this->smartIDs['fieldtype']), 'id'); + } + // add templates + if (isset($this->smartIDs['template']) && JCBArrayHelper::check($this->smartIDs['template'])) + { + $this->setData('template', array_values($this->smartIDs['template']), 'id'); + } + // add layouts + if (isset($this->smartIDs['layout']) && JCBArrayHelper::check($this->smartIDs['layout'])) + { + $this->setData('layout', array_values($this->smartIDs['layout']), 'id'); + } + // add dynamic get + if (isset($this->smartIDs['dynamic_get']) && JCBArrayHelper::check($this->smartIDs['dynamic_get'])) + { + $this->setData('dynamic_get', array_values($this->smartIDs['dynamic_get']), 'id'); + } + // only if exporting + if ('clone' !== $this->activeType) + { + // add class_property + if (isset($this->smartIDs['class_property']) && JCBArrayHelper::check($this->smartIDs['class_property'])) + { + $this->setData('class_property', array_values($this->smartIDs['class_property']), 'id'); + } + // add class_method + if (isset($this->smartIDs['class_method']) && JCBArrayHelper::check($this->smartIDs['class_method'])) + { + $this->setData('class_method', array_values($this->smartIDs['class_method']), 'id'); + } + // add joomla_plugin_group + if (isset($this->smartIDs['joomla_plugin_group']) && JCBArrayHelper::check($this->smartIDs['joomla_plugin_group'])) + { + $this->setData('joomla_plugin_group', array_values($this->smartIDs['joomla_plugin_group']), 'id'); + } + // add class_extends + if (isset($this->smartIDs['class_extends']) && JCBArrayHelper::check($this->smartIDs['class_extends'])) + { + $this->setData('class_extends', array_values($this->smartIDs['class_extends']), 'id'); + } + // add snippets + if (isset($this->smartIDs['snippet']) && JCBArrayHelper::check($this->smartIDs['snippet'])) + { + $this->setData('snippet', array_values($this->smartIDs['snippet']), 'id'); + } + // add custom code + if (isset($this->smartIDs['custom_code']) && JCBArrayHelper::check($this->smartIDs['custom_code'])) + { + $this->setData('custom_code', array_values($this->smartIDs['custom_code']), 'id'); + } + // add placeholder + if (isset($this->smartIDs['placeholder']) && JCBArrayHelper::check($this->smartIDs['placeholder'])) + { + $this->setData('placeholder', array_values($this->smartIDs['placeholder']), 'id'); + } + // add powers + if (isset($this->smartIDs['power']) && JCBArrayHelper::check($this->smartIDs['power'])) + { + $this->setData('power', array_values($this->smartIDs['power']), 'guid'); + } + // set limiter + $limit = 0; + // and add those custom codes found in custom codes + while (isset($this->smartIDs['custom_code']) && JCBArrayHelper::check($this->smartIDs['custom_code']) && $limit < 100) + { + $this->setData('custom_code', array_values($this->smartIDs['custom_code']), 'id'); + // make sure we break + $limit++; // just in case (should not be needed) + } + } + } + + /** + * Get Components + * + * @return array of objects. + */ + protected function getComponents($pks) + { + // setup the query + if (JCBArrayHelper::check($pks)) + { + // Get the user object. + if (!ObjectHelper::check($this->user)) + { + $this->user = Factory::getUser(); + } + // Create a new query object. + if (!ObjectHelper::check($this->_db)) + { + $this->_db = Factory::getDBO(); + } + $query = $this->_db->getQuery(true); + + // Select some fields + $query->select(array('a.*')); + + // From the componentbuilder_joomla_component table + $query->from($this->_db->quoteName('#__componentbuilder_joomla_component', 'a')); + $query->where('a.id IN (' . implode(',',$pks) . ')'); + + // Implement View Level Access + if (!$this->user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $this->user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.ordering ASC'); + + // Load the items + $this->_db->setQuery($query); + $this->_db->execute(); + if ($this->_db->getNumRows()) + { + // load the items from db + $items = $this->_db->loadObjectList(); + // check if we have items + if (JCBArrayHelper::check($items)) + { + // set params + if (!ObjectHelper::check($this->params)) + { + $this->params = ComponentHelper::getParams('com_componentbuilder'); + } + return $items; + } + } + } + return false; + } + + /** + * Remove all values that are no longer relevant. + * + * @return void. + */ + protected function removeOldComponentValues(&$item) + { + // make sure old fields are not used any more + unset($item->addconfig); + unset($item->addadmin_views); + unset($item->addcustom_admin_views); + unset($item->addsite_views); + unset($item->version_update); + unset($item->sql_tweak); + unset($item->addcustommenus); + unset($item->dashboard_tab); + unset($item->php_dashboard_methods); + unset($item->addfiles); + unset($item->addfolders); + } + + /** + * Set export IDs. + * + * @return void. + */ + protected function setSmartIDs($value, $table, $int = true) + { + // check if table has been set + if (!isset($this->smartIDs[$table])) + { + $this->smartIDs[$table] = array(); + } + // convert if value is in json + if (JsonHelper::check($value)) + { + $value = json_decode($value, true); + } + // now update the fields + if (JCBArrayHelper::check($value)) + { + foreach ($value as $id) + { + if ($int && (StringHelper::check($id) || is_numeric($id)) && 0 !== (int) $id) + { + $this->smartIDs[$table][(int) $id] = (int) $id; + } + elseif (!$int && StringHelper::check($id)) + { + $this->smartIDs[$table][$id] = $this->_db->quote($id); + } + } + } + elseif ($int && (StringHelper::check($value) || is_numeric($value)) && 0 !== (int) $value) + { + $this->smartIDs[$table][(int) $value] = (int) $value; + } + elseif (!$int && StringHelper::check($value)) + { + $this->smartIDs[$table][$value] = $this->_db->quote($value); + } + } + + /** + * Method to get values from repeatable or subform. + * + * @return mixed An array of values on success, false on failure. + */ + protected function getValues($values, $type, $key = null, $prep = 'table') + { + // the ids bucket + $bucket = array(); + // if json convert to array + if (JsonHelper::check($values)) + { + $values = json_decode($values, true); + } + // check that the array has values + if (JCBArrayHelper::check($values)) + { + // check if the key is an array (targeting subform) + if ('subform' === $type && $key) + { + foreach ($values as $value) + { + if (isset($value[$key])) + { + if (is_numeric($value[$key])) + { + $bucket[] = $value[$key]; + } + elseif (StringHelper::check($value[$key])) + { + if ('table' === $prep) + { + $bucket[] = $this->_db->quote($value[$key]); + } + else + { + $bucket[] = $value[$key]; + } + } + } + } + // only return if we set the ids + if (JCBArrayHelper::check($bucket)) + { + // now set the values back + return array_unique($bucket); + } + } + // check if the key is an array (targeting subform subform) + if ('subform++' === $type && strpos($key, '.') !== false) + { + $_key = explode('.', $key); + foreach ($values as $value) + { + if (isset($value[$_key[0]]) && JCBArrayHelper::check($value[$_key[0]])) + { + foreach ($value[$_key[0]] as $_value) + { + if (is_numeric($_value[$_key[1]])) + { + $bucket[] = $_value[$_key[1]]; + } + elseif (StringHelper::check($_value[$_key[1]])) + { + if ('table' === $prep) + { + $bucket[] = $this->_db->quote($_value[$_key[1]]); + } + else + { + $bucket[] = $_value[$_key[1]]; + } + } + } + } + } + // only return if we set the ids + if (JCBArrayHelper::check($bucket)) + { + // now set the values back + return array_unique($bucket); + } + } + // check if the key is an array (targeting repeatable) + if ('repeatable' === $type && $key) + { + if (isset($values[$key])) + { + return array_map(function($value) use($prep){ + if (is_numeric($value)) + { + return $value; + } + elseif (StringHelper::check($value)) + { + if ('table' === $prep) + { + return $this->_db->quote($value); + } + else + { + return $value; + } + } + }, array_unique($values[$key]) ); + } + } + // get the powers + if ('power' === $type) + { + if (isset($values[$key])) + { + foreach ($values[$key] as $k => $val) + { + if (strpos($k, 'power_') !== false && JCBArrayHelper::check($val)) + { + foreach ($val as $v) + { + if (JCBArrayHelper::check($v) && isset($v['power'])) + { + $bucket[$v['power']] = $v['power']; + } + } + } + } + // only return if we set the ids + if (JCBArrayHelper::check($bucket)) + { + // now return the values back + return array_values($bucket); + } + } + } + } + return false; + } + + /** + * Method to get data of a given table. + * + * @return mixed An array of data items on success, false on failure. + */ + protected function setData($table, $values, $key, $string = false) + { + // lets check for json strings + if (JsonHelper::check($values)) + { + $values = json_decode($values, true); + } + // let's check for just a string or int + elseif (is_string($values) || (is_numeric($values) && $values > 0)) + { + $values = [$values]; + } + + // make sure we have an array of values + if (!JCBArrayHelper::check($values, true) || !StringHelper::check($table) || !StringHelper::check($key)) + { + return false; + } + + // start the query + $query = $this->_db->getQuery(true); + // Select some fields + $query->select(array('a.*')); + + // From the componentbuilder_ANY table + $query->from($this->_db->quoteName('#__componentbuilder_'. $table, 'a')); + + // check if this is an array of integers + if ($this->is_numeric($values)) + { + // set the where query + $query->where('a.'.$key.' IN (' . implode(',', $values) . ')'); + } + else + { + // set the where query + $query->where('a.'.$key.' IN (' . implode(',', array_map( function ($var) { + // check if already quoted + if (preg_match('/^(["\']).*\1$/m', $var)) + { + return $var; + } + return $this->_db->quote($var); + }, $values)) . ')'); + } + + // Implement View Level Access + if (!$this->user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $this->user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.ordering ASC'); + // Load the items + $this->_db->setQuery($query); + $this->_db->execute(); + if ($this->_db->getNumRows()) + { + // get the items + $items = $this->_db->loadObjectList(); + // reset the search array (only search for template/layouts) + $searchTLArray = array(); + // check if we have items + if (JCBArrayHelper::check($items)) + { + // set search array if site/custom admin view + if ('site_view' === $table || 'custom_admin_view' === $table) + { + $searchTLArray = array( + 'default' => 'force_it', + 'php_view' => 'add_php_view', + 'php_jview' => 'add_php_jview', + 'php_jview_display' => 'add_php_jview_display', + 'php_document' => 'add_php_document', + 'javascript_file' => 'add_javascript_file', + 'js_document' => 'add_js_document', + 'css_document' => 'add_css_document', + 'css' => 'add_css' + ); + } + // set search array if admin view + if ('admin_view' === $table) + { + $searchTLArray = array( + 'php_getitem' => 'add_php_getitem', + 'php_before_save' => 'add_php_before_save', + 'php_save' => 'add_php_save', + 'php_getform' => 'add_php_getform', + 'php_postsavehook' => 'add_php_postsavehook', + 'php_getitems' => 'add_php_getitems', + 'php_getitems_after_all' => 'add_php_getitems_after_all', + 'php_getlistquery' => 'add_php_getlistquery', + 'php_allowadd' => 'add_php_allowadd', + 'php_allowedit' => 'add_php_allowedit', + 'php_before_cancel' => 'add_php_before_cancel', + 'php_after_cancel' => 'add_php_after_cancel', + 'php_before_delete' => 'add_php_before_delete', + 'php_after_delete' => 'add_php_after_delete', + 'php_before_publish' => 'add_php_before_publish', + 'php_after_publish' => 'add_php_after_publish', + 'php_batchcopy' => 'add_php_batchcopy', + 'php_batchmove' => 'add_php_batchmove', + 'php_document' => 'add_php_document', + 'php_model' => 'add_custom_button', + 'php_controller' => 'add_custom_button', + 'php_model_list' => 'add_custom_button', + 'php_controller_list' => 'add_custom_button' + ); + } + // reset the global array + if ('template' === $table) + { + $this->smartIDs['template'] = array(); + } + elseif ('layout' === $table) + { + $this->smartIDs['layout'] = array(); + } + elseif ('custom_code' === $table && 'id' === $key && !isset($this->smartIDs['custom_code'])) + { + $this->smartIDs['custom_code'] = array(); + } + elseif ('placeholder' === $table && 'id' === $key && !isset($this->smartIDs['placeholder'])) + { + $this->smartIDs['placeholder'] = array(); + } + // start loading the data + if (!isset($this->smartBox[$table])) + { + $this->smartBox[$table] = array(); + } + // start loading the found items + foreach ($items as $nr => &$item) + { + // set the data per id only once + if (!isset($item->id) || 0 === (int) $item->id || isset($this->smartBox[$table][$item->id])) + { + continue; + } + // actions to take before storing the item if table is template, layout, site_view, or custom_admin_view + if ('layout' === $table || 'template' === $table || 'site_view' === $table || 'custom_admin_view' === $table) + { + // unset snippets (we no longer export snippets) + if (isset($item->snippet)) + { + unset($item->snippet); + } + } + // actions to take before storing the item if table is joomla_component + if ('joomla_component' === $table) + { + // make sure old fields are not exported any more + $this->removeOldComponentValues($item); + // set the powers linked to this joomla component + $this->setSmartIDs($this->getValues($item->params, 'power', 'joomla_component_headers', null), 'power', false); + } + // actions to take before storing the item if table is admin_view + if ('admin_view' === $table) + { + // make sure old fields are not exported any more + unset($item->addfields); + unset($item->addconditions); + } + // load to global object + $this->smartBox[$table][$item->id] = $item; + // set the custom code ID's + $this->setCodePlaceholdersIds($item, $table); + // set the placeholder ID's + $this->setCodePlaceholdersIds($item, $table, 'placeholder'); + // actions to take if table is component_files_folders + if (('component_files_folders' === $table || 'joomla_plugin_files_folders_urls' === $table || 'joomla_module_files_folders_urls' === $table) && 'clone' !== $this->activeType) + { + // build files + $this->moveIt($this->getValues($item->addfiles, 'subform', 'file', null), 'file'); + // build folders + $this->moveIt($this->getValues($item->addfolders, 'subform', 'folder', null), 'folder'); + // build full path files + $this->moveIt($this->getValues($item->addfilesfullpath, 'subform', 'filepath', null), 'file', true); + // build full path folders + $this->moveIt($this->getValues($item->addfoldersfullpath, 'subform', 'folderpath', null), 'folder', true); + } + // actions to take if table is component_dashboard + if ('component_dashboard' === $table) + { + // set the powers linked to this dashboard + $this->setSmartIDs($this->getValues($item->params, 'power', 'component_dashboard_headers', null), 'power', false); + } + // actions to take if table is component_config + if ('component_config' === $table) + { + // add config fields + $this->setData('field', $this->getValues($item->addconfig, 'subform', 'field'), 'id'); + } + // actions to take if table is component_admin_views + if ('component_admin_views' === $table) + { + // add admin views + $this->setData('admin_view', $this->getValues($item->addadmin_views, 'subform', 'adminview'), 'id'); + } + // actions to take if table is component_site_views + if ('component_site_views' === $table) + { + // add site views + $this->setData('site_view', $this->getValues($item->addsite_views, 'subform', 'siteview'), 'id'); + } + // actions to take if table is component_custom_admin_views + if ('component_custom_admin_views' === $table) + { + // add custom admin views + $this->setData('custom_admin_view', $this->getValues($item->addcustom_admin_views, 'subform', 'customadminview'), 'id'); + } + // actions to take if table is component_modules + if ('component_modules' === $table) + { + // we remove those modules not part of the export + if (isset($item->addjoomla_modules) && JsonHelper::check($item->addjoomla_modules)) + { + $item->addjoomla_modules = array_filter( + json_decode($item->addjoomla_modules, true), + function ($module) { + // target 2 is only export and target 0 is both (1 is only compile) + if (isset($module['target']) && ($module['target'] == 2 || $module['target'] == 0)) + { + return true; + } + return false; + } + ); + } + // add custom admin views + $this->setData('joomla_module', $this->getValues($item->addjoomla_modules, 'subform', 'module'), 'id'); + } + // actions to take if table is component_plugins + if ('component_plugins' === $table) + { + // we remove those plugins not part of the export + if (isset($item->addjoomla_plugins) && JsonHelper::check($item->addjoomla_plugins)) + { + $item->addjoomla_plugins = array_filter( + json_decode($item->addjoomla_plugins, true), + function ($plugin) { + // target 2 is only export and target 0 is both (1 is only compile) + if (isset($plugin['target']) && ($plugin['target'] == 2 || $plugin['target'] == 0)) + { + return true; + } + return false; + } + ); + } + // add custom admin views + $this->setData('joomla_plugin', $this->getValues($item->addjoomla_plugins, 'subform', 'plugin'), 'id'); + } + // actions to take if table is admin_view + if ('admin_view' === $table) + { + // add fields & conditions + $this->setSmartIDs($item->id, 'admin_view'); + // set the powers linked to this admin view + $this->setSmartIDs($this->getValues($item->params, 'power', 'admin_view_headers', null), 'power', false); + // do not move anything if clone + if ('clone' !== $this->activeType) + { + // admin icon + $this->moveIt(array($item->icon), 'image'); + // admin icon_add + $this->moveIt(array($item->icon_add), 'image'); + // admin icon_category + $this->moveIt(array($item->icon_category), 'image'); + } + } + // actions to take if table is admin_fields + if ('admin_fields' === $table) + { + // add fields + $this->setData('field', $this->getValues($item->addfields, 'subform', 'field'), 'id'); + } + // actions to take if table is admin_fields_conditions + if ('admin_fields_conditions' === $table) + { + // add fields (all should already be added) + $this->setData('field', $this->getValues($item->addconditions, 'subform', 'target_field'), 'id'); + $this->setData('field', $this->getValues($item->addconditions, 'subform', 'match_field'), 'id'); + } + // actions to take if table is admin_fields_relations + if ('admin_fields_relations' === $table) + { + // add fields (all should already be added) + $this->setData('field', $this->getValues($item->addrelations, 'subform', 'listfield'), 'id'); + $this->setData('field', $this->getValues($item->addrelations, 'subform', 'joinfields'), 'id'); + } + // actions to take if table is field + if ('field' === $table) + { + // add field types + $this->setSmartIDs($item->fieldtype, 'fieldtype'); + // check if this field has multiple fields + if ($this->checkMultiFields($item->fieldtype)) + { + $fields = GetHelper::between(json_decode($item->xml), 'fields="', '"'); + $fieldsSets = array(); + if (strpos($fields, ',') !== false) + { + // multiple fields + $fieldsSets = (array) explode(',', $fields); + } + elseif (is_numeric($fields)) + { + // single field + $fieldsSets[] = (int) $fields; + } + // get fields + if (JCBArrayHelper::check($fieldsSets)) + { + $this->setData('field', $fieldsSets, 'id'); + } + } + // check if validation rule is found + $validationRule = GetHelper::between(json_decode($item->xml), 'validate="', '"'); + if (StringHelper::check($validationRule)) + { + // make sure it is lowercase + $validationRule = StringHelper::safe($validationRule); + // get core validation rules + if ($coreValidationRules = ComponentbuilderHelper::getExistingValidationRuleNames(true)) + { + // make sure this rule is not a core validation rule + if (!in_array($validationRule, (array) $coreValidationRules)) + { + // okay load the rule + $this->setSmartIDs($validationRule, 'validation_rule', false); + } + } + } + } + // check if a search is required + if (isset($searchTLArray) && JCBArrayHelper::check($searchTLArray)){ + + // add search array templates and layouts + foreach ($searchTLArray as $scripter => $add) + { + if ($add === 'force_it' || (isset($item->{$add}) && $item->{$add} == 1)) + { + $this->getTemplateLayout($item->{$scripter}); + } + } + } + // actions to take if table is site_view and custom_admin_view + if ('site_view' === $table || 'custom_admin_view' === $table) + { + // add dynamic gets + $this->setSmartIDs($item->main_get, 'dynamic_get'); + $this->setSmartIDs($item->custom_get, 'dynamic_get'); + $this->setSmartIDs($item->dynamic_get, 'dynamic_get'); + // move the icon + if ('custom_admin_view' === $table && isset($item->icon) && 'clone' !== $this->activeType) + { + // view icon + $this->moveIt(array($item->icon), 'image'); + } + // add snippets (was removed please use snippet importer) + if (isset($item->snippet) && is_numeric($item->snippet)) + { + $this->setSmartIDs((int) $item->snippet, 'snippet'); + } + // actions to take if table is site_view + if ('site_view' === $table) + { + // set the powers linked to this admin view + $this->setSmartIDs($this->getValues($item->params, 'power', 'site_view_headers', null), 'power', false); + } + // actions to take if table is custom_admin_view + elseif ('custom_admin_view' === $table) + { + // set the powers linked to this admin view + $this->setSmartIDs($this->getValues($item->params, 'power', 'custom_admin_view_headers', null), 'power', false); + } + } + // actions to take if table is template and layout + if ('layout' === $table || 'template' === $table) + { + // add snippets (was removed please use snippet importer) + if (isset($item->snippet) && is_numeric($item->snippet)) + { + $this->setSmartIDs((int) $item->snippet, 'snippet'); + } + // search for templates & layouts + $this->getTemplateLayout($item->$table, $this->user); + // add search array templates and layouts + if (isset($item->add_php_view) && $item->add_php_view == 1) + { + $this->getTemplateLayout($item->php_view, $this->user); + } + // add dynamic gets + $this->setSmartIDs((int) $item->dynamic_get, 'dynamic_get'); + } + // actions to take if table is joomla_module + if ('joomla_module' === $table) + { + // add the updates and folder stuff + $this->setSmartIDs($item->id, 'joomla_module'); + // add class_extends + $this->setSmartIDs((int) $item->class_extends, 'class_extends'); + // add fields + $this->setData('field', $this->getValues($item->fields, 'subform++', 'fields.field'), 'id'); + // add dynamic gets + $this->setSmartIDs($item->custom_get, 'dynamic_get'); + // set module language strings + $this->setLanguageTranslation($item->id, 'modules'); + } + // actions to take if table is joomla_plugin + if ('joomla_plugin' === $table) + { + // add the updates and folder stuff + $this->setSmartIDs($item->id, 'joomla_plugin'); + // add class_extends + $this->setSmartIDs((int) $item->class_extends, 'class_extends'); + // add joomla_plugin_group + $this->setSmartIDs((int) $item->joomla_plugin_group, 'joomla_plugin_group'); + // add fields + $this->setData('field', $this->getValues($item->fields, 'subform++', 'fields.field'), 'id'); + // add property_selection + $this->setData('class_property', $this->getValues($item->property_selection, 'subform', 'property'), 'id'); + // add class_method + $this->setData('class_method', $this->getValues($item->method_selection, 'subform', 'method'), 'id'); + // set plugin language strings + $this->setLanguageTranslation($item->id, 'plugins'); + } + // actions to take if table is joomla_plugin_group + if ('joomla_plugin_group' === $table) + { + // add class_extends + $this->setSmartIDs((int) $item->class_extends, 'class_extends'); + } + // actions to take if table is class_method or + if ('class_method' === $table || 'class_property' === $table ) + { + // add joomla_plugin_group + $this->setSmartIDs((int) $item->joomla_plugin_group, 'joomla_plugin_group'); + } + // actions to take if table is dynamic_get + if ('dynamic_get' === $table) + { + // add dynamic_get_headers + $this->setSmartIDs($this->getValues($item->params, 'power', 'dynamic_get_headers', null), 'power', false); + } + // actions to take if table is power + if ('power' === $table) + { + // add the extended class (powers) + $this->setData('power', $item->extends, 'guid'); + // add implements interfaces (powers) + $this->setData('power', $item->implements, 'guid'); + // add use classes (powers) + $this->setData('power', $this->getValues($item->use_selection, 'subform', 'use'), 'guid'); + // add load classes (powers) + $this->setData('power', $this->getValues($item->load_selection, 'subform', 'load'), 'guid'); + // add property_selection + $this->setData('class_property', $this->getValues($item->property_selection, 'subform', 'property'), 'id'); + // add class_method + $this->setData('class_method', $this->getValues($item->method_selection, 'subform', 'method'), 'id'); + } + } + } + } + } + + /** + * Method to check if array has only numiric values + * + * @return bool + **/ + protected function is_numeric($array) + { + foreach ($array as $value) + { + if (!is_numeric($value)) + { + return false; + } + } + return true; + } + + /** + * Method to do the smart cloning + * + * @return bool + */ + protected function smartCloner() + { + // check if data is set + if (isset($this->smartBox) && JCBArrayHelper::check($this->smartBox)) + { + // get the import_joomla_components + $model = ComponentbuilderHelper::getModel('import_joomla_components'); + // do not show more information + $model->moreInfo = 0; + // trigger the create new (clone) feature + $model->canmerge = 0; + // set some postfix + $model->postfix = ' ('.StringHelper::random(2).')'; + // get App + $model->app = Factory::getApplication(); + // set user + $model->user = $this->user; + // set today's date + $model->today = Factory::getDate()->toSql(); + // load the data + $model->data = $this->smartBox; + // remove smart box to safe on memory + unset($this->smartBox); + // the array of tables to store + $tables = array( + 'fieldtype', 'field', 'admin_view', 'snippet', 'dynamic_get', 'custom_admin_view', 'site_view', + 'template', 'layout', 'joomla_component', 'language', 'language_translation', 'custom_code', 'placeholder', + 'joomla_module', 'joomla_module_files_folders_urls', 'joomla_module_updates', + 'joomla_plugin', 'joomla_plugin_files_folders_urls', 'joomla_plugin_updates', 'power', + 'admin_fields', 'admin_fields_conditions', 'admin_fields_relations', 'admin_custom_tabs', 'component_admin_views', + 'component_site_views', 'component_custom_admin_views', 'component_updates', 'component_mysql_tweaks', + 'component_custom_admin_menus', 'component_config', 'component_dashboard', 'component_files_folders', + 'component_placeholders', 'component_modules', 'component_plugins' + ); + // smart table loop + foreach ($tables as $table) + { + // save the table to database + if (!$model->saveSmartItems($table)) + { + return false; + } + } + // do an after all run on all items that need it + $model->updateAfterAll(); + // finally move the old datasets + $model->moveDivergedData(); + // we had success + return true; + } + return false; + } + + /** + * Method to build the package to export + * + * @return bool + */ + protected function smartExportBuilder() + { + // check if data is set + if (isset($this->smartBox) && JCBArrayHelper::check($this->smartBox)) + { + // set db data + $data = serialize($this->smartBox); + + // Set the key owner information + $this->info['source'] = array(); + $this->info['source']['company'] = $this->params->get('export_company', null); + $this->info['source']['owner'] = $this->params->get('export_owner', null); + $this->info['source']['email'] = $this->params->get('export_email', null); + $this->info['source']['website'] = $this->params->get('export_website', null); + $this->info['source']['license'] = $this->params->get('export_license', null); + $this->info['source']['copyright'] = $this->params->get('export_copyright', null); + + // lock the data if set + if (JCBArrayHelper::check($this->key)) + { + // lock the data + $this->key = md5(implode('', $this->key)); + + // lock the data + $data = PackageFactory::_('Crypt')->encrypt($data, 'aes', $this->key); + + // Set the key owner information + $this->info['getKeyFrom'] = array(); + $this->info['getKeyFrom']['company'] = $this->info['source']['company']; + $this->info['getKeyFrom']['owner'] = $this->info['source']['owner']; + $this->info['getKeyFrom']['email'] = $this->info['source']['email']; + $this->info['getKeyFrom']['website'] = $this->info['source']['website']; + $this->info['getKeyFrom']['license'] = $this->info['source']['license']; + $this->info['getKeyFrom']['copyright'] = $this->info['source']['copyright']; + // add buy link if only one link is set + if (isset($this->info['export_buy_link']) + && JCBArrayHelper::check($this->info['export_buy_link']) + && count((array) $this->info['export_buy_link']) == 1) + { + $this->info['getKeyFrom']['buy_link'] = array_values($this->info['export_buy_link'])[0]; + } + else + { + // use global if more then one component is exported + // (since they now have one key), or if none has a buy link + $this->info['getKeyFrom']['buy_link'] = $this->params->get('export_buy_link', null); + } + // no remove the buy links + unset($this->info['export_buy_link']); + // if we have multi links add them also + // we started adding this at v2.7.7 + $this->info['key'] = true; + // Changed: 25th Feb. 2023 at v3.1.18 + // $this->info['phpseclib'] = false; + // we started adding this at v3.1.18 + $this->info['phpseclib3'] = true; + } + else + { + // we started adding this at v2.7.7 + $this->info['key'] = false; + // we started adding this at v3.0.11 and v2.12.17 + // $this->info['phpseclib'] = false; + // we started adding this at v3.1.18 + $this->info['phpseclib3'] = false; + // base 64 encode the data + $data = base64_encode($data); + } + + // set the path + $dbPath = $this->packagePath . '/db.vdm'; + + // write the db data to file in package + if (!FileHelper::write($dbPath, wordwrap($data, 128, "\n", true))) + { + return false; + } + + // lock the info data + $info = PackageFactory::_('Crypt')->encrypt(json_encode($this->info), 'local'); + + // set the path + $infoPath = $this->packagePath . '/info.vdm'; + + // write the info data to file in package + if (!FileHelper::write($infoPath, wordwrap($info, 128, "\n", true))) + { + return false; + } + + // lock all files + $this->lockFiles(); + + // remove old zip files with the same name + if (JFile::exists($this->zipPath)) + { + // remove file if found + JFile::delete($this->zipPath); + } + + // zip the folder + if (!FileHelper::zip($this->packagePath, $this->zipPath)) + { + return false; + } + + // move to remote server if needed + if (2 == $this->backupType) + { + if (!PackageFactory::_('Server')->legacyMove( + $this->zipPath, $this->packageName.'.zip', + $this->backupServer, null, 'joomla_component.export' + ) + ) + { + return false; + } + + // remove the local file + JFile::delete($this->zipPath); + } + + // remove the folder + if (!ComponentbuilderHelper::removeFolder($this->packagePath)) + { + return false; + } + + return true; + } + return false; + } + + /** + * Method to lock all files + * + * @return void + */ + protected function lockFiles() + { + // lock the data if set + if (StringHelper::check($this->key) && strlen($this->key) == 32) + { + // we must first store the current working directory + $joomla = getcwd(); + + // to avoid that it encrypt the db and info file again we must move per/folder + $folders = array('images', 'custom', 'dynamic'); + + // loop the folders + foreach ($folders as $folder) + { + // the sub path + $subPath = $this->packagePath.'/'.$folder; + + // go to the package sub folder if found + if (FileHelper::exists($subPath)) + { + $this->lock($subPath); + } + } + + // change back to working dir + chdir($joomla); + } + } + + /** + * The Locker + * + * @return void + */ + protected function lock(&$tmpPath) + { + // we are changing the working directory to the tmp path (important) + chdir($tmpPath); + + // get a list of files in the current directory tree (all) + $files = JFolder::files('.', '.', true, true); + + // read in the file content + foreach ($files as $file) + { + // get file content + $content = FileHelper::getContent($file); + + // write the encrypted string back to file + $content = PackageFactory::_('Crypt')->encrypt($content, 'eac', $this->key); + + // store the encrypted file content in the same file + FileHelper::write($file, wordwrap($content, 128, "\n", true)); + } + } + + /** + * Method to move the files and folder to the package folder + * + * @return bool + */ + protected function moveIt($paths, $type, $dynamic = false) + { + // make sure we have an array + if (!JCBArrayHelper::check($paths)) + { + return false; + } + + // set the name of the folder + if ('file' === $type || 'folder' === $type) + { + $folderName = 'custom'; + // if these are full paths use dynamic folder + if ($dynamic) + { + $folderName = 'dynamic'; + } + } + elseif ('image' === $type) + { + $folderName = 'images'; + } + else + { + return false; + } + + // setup the type path + $tmpPath = str_replace('//', '/', $this->packagePath . '/' . $folderName); + + // create type path if not set + if (!FileHelper::exists($tmpPath)) + { + // create the folders if not found + JFolder::create($tmpPath); + } + + // now move it + foreach ($paths as $item) + { + // make sure we have a string + if (StringHelper::check($item)) + { + // if the file type + if ('file' === $type) + { + // if dynamic paths + if ($dynamic) + { + $tmpFilePath = $tmpPath.'/'.$this->setDynamicPathName($item); + $customFilePath = str_replace('//', '/', $this->setFullPath($item)); + } + else + { + $tmpFilePath = str_replace('//', '/', $tmpPath.'/'.$item); + $customFilePath = str_replace('//', '/', $this->customPath.'/'.$item); + } + // now check if file exist + if (!JFile::exists($tmpFilePath) && JFile::exists($customFilePath)) + { + // move the file to its place + JFile::copy($customFilePath, $tmpFilePath); + } + } + + // if the image type + if ('image' === $type) + { + $imageName = basename($item); + $imagePath = str_replace($imageName, '', $item); + $imageFolderPath = str_replace('//', '/', $this->packagePath.'/'. $imagePath); + + // check if image folder exist + if (!FileHelper::exists($imageFolderPath)) + { + // create the folders if not found + JFolder::create($imageFolderPath); + } + $tmpImagePath = str_replace('//', '/', $this->packagePath.'/'.$item); + $customImagePath = str_replace('//', '/', JPATH_ROOT.'/'.$item); + if (!JFile::exists($tmpImagePath) && JFile::exists($customImagePath)) + { + // move the file to its place + JFile::copy($customImagePath, $tmpImagePath); + } + } + + // if the folder type + if ('folder' === $type) + { + // if dynamic paths + if ($dynamic) + { + $tmpFolderPath = $tmpPath.'/'.$this->setDynamicPathName($item); + $customFolderPath = str_replace('//', '/', $this->setFullPath($item)); + } + else + { + $tmpFolderPath = str_replace('//', '/', $tmpPath.'/'.$item); + $customFolderPath = str_replace('//', '/', $this->customPath.'/'.$item); + } + + if (!FileHelper::exists($tmpFolderPath) && FileHelper::exists($customFolderPath)) + { + // move the folder to its place + JFolder::copy($customFolderPath, $tmpFolderPath,'',true); + } + } + } + } + return true; + } + + /** + * Check if a field has multiple fields + * + * @param string $typeID The type ID + * + * @return bool true on success + * + */ + protected function checkMultiFields($typeID) + { + if(isset($this->isMultiple[$typeID])) + { + return $this->isMultiple[$typeID]; + } + elseif ($type = $this->getFieldType($typeID)) + { + if ('repeatable' === $type || 'subform' === $type ) + { + $this->isMultiple[$typeID] = true; + } + else + { + $this->isMultiple[$typeID] = false; + } + return $this->isMultiple[$typeID]; + } + return false; + } + + /** + * Get the field type + * + * @param string $id The field type id + * + * @return string field type + * + */ + protected function getFieldType($id) + { + if (!isset($this->fieldTypes[$id])) + { + $properties = GetHelper::var('fieldtype', $id, 'id', 'properties'); + if (JsonHelper::check($properties)) + { + $properties = json_decode($properties, true); + foreach ($properties as $property) + { + if ('type' === $property['name']) + { + if (isset($property['example']) && StringHelper::check($property['example'])) + { + $this->fieldTypes[$id] = $property['example']; + break; + } + } + } + } + // if not found + if (!isset($this->fieldTypes[$id]) && $name = GetHelper::var('fieldtype', $id, 'id', 'name')) + { + $this->fieldTypes[$id] = StringHelper::safe($name); + } + } + // return the type + if (isset($this->fieldTypes[$id])) + { + return $this->fieldTypes[$id]; + } + return false; + } + + /** + * Set Template and Layout Data + * + * @param string $default The content to check + * + * @return void + * + */ + protected function getTemplateLayout($default, $user = false) + { + // check if we have base64 encoding + if (base64_encode(base64_decode($default, true)) === $default) + { + $default = base64_decode($default); + } + // set the Template data + $temp1 = GetHelper::allBetween($default, "\$this->loadTemplate('","')"); + $temp2 = GetHelper::allBetween($default, '$this->loadTemplate("','")'); + $templates = array(); + $again = array(); + if (JCBArrayHelper::check($temp1) && JCBArrayHelper::check($temp2)) + { + $templates = array_merge($temp1,$temp2); + } + else + { + if (JCBArrayHelper::check($temp1)) + { + $templates = $temp1; + } + elseif (JCBArrayHelper::check($temp2)) + { + $templates = $temp2; + } + } + if (JCBArrayHelper::check($templates)) + { + foreach ($templates as $template) + { + $data = $this->getDataWithAlias($template, 'template'); + if (JCBArrayHelper::check($data)) + { + if (!isset($this->smartIDs['template']) || !isset($this->smartIDs['template'][$data['id']])) + { + $this->setSmartIDs($data['id'], 'template'); + // call self to get child data + $again[] = $data['html']; + $again[] = $data['php_view']; + } + } + } + } + // set the layout data + $lay1 = GetHelper::allBetween($default, "LayoutHelper::render('","',"); + $lay2 = GetHelper::allBetween($default, 'LayoutHelper::render("','",'); + if (JCBArrayHelper::check($lay1) && JCBArrayHelper::check($lay2)) + { + $layouts = array_merge($lay1,$lay2); + } + else + { + if (JCBArrayHelper::check($lay1)) + { + $layouts = $lay1; + } + elseif (JCBArrayHelper::check($lay2)) + { + $layouts = $lay2; + } + } + if (isset($layouts) && JCBArrayHelper::check($layouts)) + { + foreach ($layouts as $layout) + { + $data = $this->getDataWithAlias($layout, 'layout'); + if (JCBArrayHelper::check($data)) + { + if (!isset($this->smartIDs['layout']) || !isset($this->smartIDs['layout'][$data['id']])) + { + $this->setSmartIDs($data['id'], 'layout'); + // call self to get child data + $again[] = $data['html']; + $again[] = $data['php_view']; + } + } + } + } + if (JCBArrayHelper::check($again)) + { + foreach ($again as $get) + { + $this->getTemplateLayout($get); + } + } + // Set the Data + if ($user) + { + // add templates + if (isset($this->smartIDs['template']) && JCBArrayHelper::check($this->smartIDs['template'])) + { + $this->setData('template', array_values($this->smartIDs['template']), 'id'); + } + // add layouts + if (isset($this->smartIDs['layout']) && JCBArrayHelper::check($this->smartIDs['layout'])) + { + $this->setData('layout', array_values($this->smartIDs['layout']), 'id'); + } + } + } + + /** + * Get Data With Alias + * + * @param string $n_ame The alias name + * @param string $table The table where to find the alias + * @param string $view The view code name + * + * @return array The data found with the alias + * + */ + protected function getDataWithAlias($n_ame, $table) + { + // Create a new query object. + $query = $this->_db->getQuery(true); + $query->select($this->_db->quoteName(array('a.id', 'a.alias', 'a.'.$table, 'a.php_view', 'a.add_php_view'))); + $query->from('#__componentbuilder_'.$table.' AS a'); + $this->_db->setQuery($query); + $rows = $this->_db->loadObjectList(); + foreach ($rows as $row) + { + $k_ey = StringHelper::safe($row->alias); + $key = preg_replace("/[^A-Za-z]/", '', $k_ey); + $name = preg_replace("/[^A-Za-z]/", '', $n_ame); + if ($k_ey == $n_ame || $key == $name) + { + $php_view = ''; + if ($row->add_php_view == 1) + { + $php_view = base64_decode($row->php_view); + } + $contnent = base64_decode($row->{$table}); + // return to continue the search + return array('id' => $row->id, 'html' => $contnent, 'php_view' => $php_view); + } + } + return false; + } + + /** + * Set the ids of the found code placeholders + * + * @param object $item The item being searched + * @param string $target The target table + * @param string $type The type of placeholder to search and set + * + * @return void + * + */ + protected function setCodePlaceholdersIds($item, $target, $type = 'custom_code') + { + if ($keys = $this->getCodeSearchKeys($target)) + { + foreach ($keys['search'] as $key) + { + if ('id' === $key || 'name' === $key || 'system_name' === $key) + { + continue; + } + elseif (!isset($keys['not_base64'][$key])) + { + $value = Base64Helper::open($item->{$key}, null); + } + elseif (isset($keys['not_base64'][$key]) && 'json' === $keys['not_base64'][$key] && 'xml' === $key) // just for field search + { + $value = json_decode($item->{$key}); + } + else + { + $value = $item->{$key}; + } + // check if we should search for base64 string inside the text + if (isset($keys['base64_search']) && isset($keys['base64_search'][$key]) + && isset($keys['base64_search'][$key]['start']) && strpos($value, $keys['base64_search'][$key]['start']) !== false) + { + // search and open the base64 strings + $this->searchOpenBase64($value, $keys['base64_search'][$key]); + } + // based on the type of search + if ('custom_code' === $type) + { + // search the value to see if it has custom code + $codeArray = GetHelper::allBetween($value, '[CUSTOMC' . 'ODE=',']'); + if (JCBArrayHelper::check($codeArray)) + { + foreach ($codeArray as $func) + { + // first make sure we have only the function key + if (strpos($func, '+') !== false) + { + $funcArray = explode('+', $func); + $func = $funcArray[0]; + } + if (!isset($this->customCodeM[$func])) + { + $this->customCodeM[$func] = $func; + // if numeric add to ids + if (is_numeric($func)) + { + $this->setSmartIDs($func, $type); + } + elseif (StringHelper::check($func)) + { + if (($funcID = GetHelper::var($type, $func, 'function_name', 'id')) !== false && is_numeric($funcID)) + { + $this->setSmartIDs($funcID, $type); + } + else + { + // set a notice that custom code was not found (weird) + } + } + } + } + } + } + elseif ('placeholder' === $type) + { + // check if we already have the placeholder search array + if (!JCBArrayHelper::check($this->placeholderM) && !JCBArrayHelper::check($this->placeholderS)) + { + $this->placeholderS = ComponentbuilderHelper::getVars($type, 1, 'published', 'target'); + } + // only continue search if placeholders found + if (JCBArrayHelper::check($this->placeholderS)) + { + foreach ($this->placeholderS as $remove => $placeholder) + { + // search the value to see if it has this placeholder and is not already set + if (!isset($this->placeholderM[$placeholder]) && strpos($value, $placeholder) !== false) + { + // add only once + $this->placeholderM[$placeholder] = $placeholder; + unset($this->placeholderS[$remove]); + // get the ID + if (($placeholderID = GetHelper::var($type, $placeholder, 'target', 'id')) !== false && is_numeric($placeholderID)) + { + $this->setSmartIDs($placeholderID, $type); + } + else + { + // set a notice that placeholder was not found (weird) + } + } + } + } + } + } + } + } + + /** + * Set the language strings for this component + * + * @param int $id The component id + * + * @return void + * + */ + protected function setLanguageTranslation(&$id, $target = 'components') + { + // check if the export of language strings is allowed + if ($this->params->get('export_language_strings', 1) != 1) + { + return; + } + // Create a new query object. + $query = $this->_db->getQuery(true); + $query->select(array('a.*')); + $query->from('#__componentbuilder_language_translation AS a'); + // Implement View Level Access + if (!$this->user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $this->user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.ordering ASC'); + + // Load the items + $this->_db->setQuery($query); + $this->_db->execute(); + if ($this->_db->getNumRows()) + { + $items = $this->_db->loadObjectList(); + // check if we have items + if (JCBArrayHelper::check($items)) + { + if (!isset($this->smartBox['language_translation'])) + { + $this->smartBox['language_translation'] = array(); + } + foreach ($items as $item) + { + if (!isset($this->smartBox['language_translation'][$item->id]) && JsonHelper::check($item->{$target})) + { + $targets = json_decode($item->{$target}, true); + if (in_array($id, $targets)) + { + // load to global object + $this->smartBox['language_translation'][$item->id] = $item; + // add languages + if (isset($item->translation)) + { + $this->setData('language', $this->getValues($item->translation, 'subform', 'language'), 'langtag'); + } + } + } + } + } + } + } + + /** + * Get the package name + * + * @param array $items of all components + * + * @return string The package name + * + */ + protected function getPackageName(&$items) + { + foreach ($items as $item) + { + if (isset($item->system_name)) + { + return StringHelper::safe($item->system_name, 'cAmel'); + } + else + { + return StringHelper::safe($item->name_code); + } + } + } + + /** + * Convert the path to a name + * + * @param string $path The full path + * + * @return string The path name + * + */ + protected function setDynamicPathName($path) + { + // remove the full path if possible + $path = str_replace('//', '/', $this->setConstantPath($path)); + // now convert to string + return str_replace('/', '__v_d_m__', $path); + } + + /** + * Update real full path value with constant path string + * + * @param string $path The full path + * + * @return string The updated path + * + */ + protected function setConstantPath($path) + { + return str_replace(array_values(ComponentbuilderHelper::$constantPaths), array_keys(ComponentbuilderHelper::$constantPaths), $path); + } + + /** + * Update constant path with real full path value + * + * @param string $path The full path + * + * @return string The updated path + * + */ + protected function setFullPath($path) + { + return str_replace(array_keys(ComponentbuilderHelper::$constantPaths), array_values(ComponentbuilderHelper::$constantPaths), $path); + } + + /** + * Search for base64 strings and decode them + * + * @param string $value The string to search + * @param array $target The target search values + * + * @return void + * + */ + protected function searchOpenBase64(&$value, &$target) + { + // first get the start property (if dynamic) + $starts = array(); + if (isset($target['_start'])) + { + // get all values + $allBetween = GetHelper::allBetween($value, $target['start'], $target['_start']); + // just again make sure we found some + if (UtilitiesArrayHelper::check($allBetween)) + { + if (count((array) $allBetween) > 1) + { + // search for many + foreach ($allBetween as $between) + { + // load the starting property + $start = $target['start']; + $start .= $between; + $start .= $target['_start']; + + $starts[] = $start; + } + } + else + { + // load the starting property + $start = $target['start']; + $start .= array_values($allBetween)[0]; + $start .= $target['_start']; + + $starts[] = $start; + } + } + } + else + { + $starts[] = $target['start']; + } + // has any been found + if (UtilitiesArrayHelper::check($starts)) + { + foreach ($starts as $_start) + { + // get the base64 string + $base64 = GetHelper::between($value, $_start, $target['end']); + // now open the base64 text + $tmp = Base64Helper::open($base64); + // insert it back into the value (so we still search the whole string) + $value = str_replace($base64, $tmp, $value); + } + } + } + + + /** + * The code search keys/targets + * + * @var array + */ + protected $codeSearchKeys = array( + // #__componentbuilder_joomla_component (a) + 'joomla_component' => array( + 'search' => array('id', 'system_name', 'php_preflight_install', 'php_postflight_install', + 'php_preflight_update', 'php_postflight_update', 'php_method_uninstall', + 'php_helper_admin', 'php_admin_event', 'php_helper_both', 'php_helper_site', + 'php_site_event', 'javascript', 'readme', 'sql', 'sql_uninstall'), + 'views' => 'joomla_components', + 'not_base64' => array(), + 'name' => 'system_name' + ), + // #__componentbuilder_component_dashboard (b) + 'component_dashboard' => array( + 'search' => array('id', 'joomla_component', 'php_dashboard_methods', 'dashboard_tab'), + 'views' => 'components_dashboard', + 'not_base64' => array('dashboard_tab' => 'json'), + 'name' => 'joomla_component->id:joomla_component.system_name' + ), + // #__componentbuilder_component_placeholders (c) + 'component_placeholders' => array( + 'search' => array('id', 'joomla_component', 'addplaceholders'), + 'views' => 'components_placeholders', + 'not_base64' => array('addplaceholders' => 'json'), + 'name' => 'joomla_component->id:joomla_component.system_name' + ), + // #__componentbuilder_admin_view (d) + 'admin_view' => array( + 'search' => array('id', 'system_name', 'javascript_view_file', 'javascript_view_footer', + 'javascript_views_file', 'javascript_views_footer', 'html_import_view', + 'php_after_delete', 'php_after_publish', 'php_ajaxmethod', 'php_allowedit', 'php_batchcopy', + 'php_batchmove', 'php_before_delete', 'php_before_publish', 'php_before_save', 'php_controller', + 'php_controller_list', 'php_document', 'php_getitem', 'php_getitems', 'php_getitems_after_all', + 'php_getlistquery', 'php_import', 'php_import_display', 'php_import_ext', 'php_import_headers', 'php_getform', + 'php_import_save', 'php_import_setdata', 'php_model', 'php_model_list', 'php_postsavehook', 'php_save', 'sql'), + 'views' => 'admin_views', + 'not_base64' => array(), + 'name' => 'system_name' + ), + // #__componentbuilder_admin_fields_relations (e) + 'admin_fields_relations' => array( + 'search' => array('id', 'admin_view', 'addrelations'), + 'views' => 'admins_fields_relations', + 'not_base64' => array('addrelations' => 'json'), + 'name' => 'admin_view->id:admin_view.system_name' + ), + // #__componentbuilder_admin_custom_tabs (f) + 'admin_custom_tabs' => array( + 'search' => array('id', 'admin_view', 'tabs'), + 'views' => 'admins_custom_tabs', + 'not_base64' => array('tabs' => 'json'), + 'name' => 'admin_view->id:admin_view.system_name' + ), + // #__componentbuilder_custom_admin_view (g) + 'custom_admin_view' => array( + 'search' => array('id', 'system_name', 'default', 'php_view', 'php_jview', 'php_jview_display', 'php_document', + 'javascript_file', 'js_document', 'css_document', 'css', 'php_ajaxmethod', 'php_model', 'php_controller'), + 'views' => 'custom_admin_views', + 'not_base64' => array(), + 'name' => 'system_name' + ), + // #__componentbuilder_site_view (h) + 'site_view' => array( + 'search' => array('id', 'system_name', 'default', 'php_view', 'php_jview', 'php_jview_display', 'php_document', + 'javascript_file', 'js_document', 'css_document', 'css', 'php_ajaxmethod', 'php_model', 'php_controller'), + 'views' => 'site_views', + 'not_base64' => array(), + 'name' => 'system_name' + ), + // #__componentbuilder_field (i) + 'field' => array( + 'search' => array('id', 'name', 'xml', 'javascript_view_footer', 'javascript_views_footer', 'on_save_model_field', 'on_get_model_field', 'initiator_on_save_model', 'initiator_on_get_model'), + 'views' => 'fields', + 'not_base64' => array('xml' => 'json'), + 'base64_search' => array('xml' => array('start' => 'type_php', '_start' => '="', 'end' => '"')), + 'name' => 'name' + ), + // #__componentbuilder_fieldtype (j) + 'fieldtype' => array( + 'search' => array('id', 'name', 'properties'), + 'views' => 'fieldtypes', + 'not_base64' => array('properties' => 'json'), + 'name' => 'name' + ), + // #__componentbuilder_dynamic_get (k) + 'dynamic_get' => array( + 'search' => array('id', 'name', 'php_before_getitem', 'php_after_getitem', 'php_before_getitems', 'php_after_getitems', + 'php_getlistquery', 'php_calculation'), + 'views' => 'dynamic_gets', + 'not_base64' => array(), + 'name' => 'name' + ), + // #__componentbuilder_template (l) + 'template' => array( + 'search' => array('id', 'name', 'php_view', 'template'), + 'views' => 'templates', + 'not_base64' => array(), + 'name' => 'name' + ), + // #__componentbuilder_layout (m) + 'layout' => array( + 'search' => array('id', 'name', 'php_view', 'layout'), + 'views' => 'layouts', + 'not_base64' => array(), + 'name' => 'name' + ), + // #__componentbuilder_library (n) + 'library' => array( + 'search' => array('id', 'name', 'php_setdocument'), + 'views' => 'libraries', + 'not_base64' => array(), + 'name' => 'name' + ), + // #__componentbuilder_custom_code (o) + 'custom_code' => array( + 'search' => array('id', 'system_name', 'code'), + 'views' => 'custom_codes', + 'not_base64' => array(), + 'name' => 'system_name' + ), + // #__componentbuilder_validation_rule (p) + 'validation_rule' => array( + 'search' => array('id', 'name', 'php'), + 'views' => 'validation_rules', + 'not_base64' => array(), + 'name' => 'name' + ), + // #__componentbuilder_joomla_module (q) + 'joomla_module' => array( + 'search' => array('id', 'system_name', 'name', 'default', 'description', 'mod_code', 'class_helper_header', 'class_helper_code', 'php_script_construct', 'php_preflight_install', 'php_preflight_update', + 'php_preflight_uninstall', 'php_postflight_install', 'php_postflight_update', 'php_method_uninstall', 'sql', 'sql_uninstall', 'readme'), + 'views' => 'joomla_modules', + 'not_base64' => array('description' => 'string', 'readme' => 'string'), + 'name' => 'system_name' + ), + // #__componentbuilder_joomla_plugin (r) + 'joomla_plugin' => array( + 'search' => array('id', 'system_name', 'name', 'main_class_code', 'head', 'description', 'php_script_construct', 'php_preflight_install', 'php_preflight_update', + 'php_preflight_uninstall', 'php_postflight_install', 'php_postflight_update', 'php_method_uninstall', 'sql', 'sql_uninstall', 'readme'), + 'views' => 'joomla_plugins', + 'not_base64' => array('description' => 'string', 'readme' => 'string'), + 'name' => 'system_name' + ), + // #__componentbuilder_class_extends (s) + 'class_extends' => array( + 'search' => array('id', 'name', 'head', 'comment'), + 'views' => 'class_extendings', + 'not_base64' => array(), + 'name' => 'name' + ), + // #__componentbuilder_class_property (t) + 'class_property' => array( + 'search' => array('id', 'name', 'default', 'comment'), + 'views' => 'class_properties', + 'not_base64' => array(), + 'name' => 'name' + ), + // #__componentbuilder_class_method (u) + 'class_method' => array( + 'search' => array('id', 'name', 'code', 'comment'), + 'views' => 'class_methods', + 'not_base64' => array(), + 'name' => 'name' + ), + // #__componentbuilder_power (v) + 'power' => array( + 'search' => array('id', 'system_name', 'name', 'description', 'head', 'namespace', 'main_class_code'), + 'views' => 'powers', + 'not_base64' => array('description'), + 'name' => 'system_name' + ) + ); + + /** + * Get the keys of the values to search custom code in + * + * @param string $target The table targeted + * @param string $type The type of get + * + * @return array The query options + * + */ + protected function getCodeSearchKeys($target, $type = null) + { + // set the template if type is query + if ('query' === $type) + { + // setup the tables + $tables = array(); + $key = 'a'; + foreach (array_keys($this->codeSearchKeys) as $table) + { + $tables[$key] = $table; + $key++; + } + // check if we have a match + if (isset($tables[$target])) + { + $target = $tables[$target]; + } + } + // return result ready for a.query + if (('query' === $type || 'query_' === $type) && isset($this->codeSearchKeys[$target])) + { + // set the targets + $codeSearchTarget = $this->codeSearchKeys[$target]; + // add the .a to the selection array + $codeSearchTarget['select'] = array_map( function($select) { return 'a.' . $select; }, $codeSearchTarget['search']); + // also set the table + $codeSearchTarget['table'] = $target; + // remove search + unset($codeSearchTarget['search']); + // return targeted array to use in query + return $codeSearchTarget; + } + // does the target exist + elseif (isset($this->codeSearchKeys[$target])) + { + // return target array values to use in search + return $this->codeSearchKeys[$target]; + } + return false; + } + + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $companyname = $this->getUserStateFromRequest($this->context . '.filter.companyname', 'filter_companyname'); + if ($formSubmited) + { + $companyname = $app->input->post->get('companyname'); + $this->setState('filter.companyname', $companyname); + } + + $author = $this->getUserStateFromRequest($this->context . '.filter.author', 'filter_author'); + if ($formSubmited) + { + $author = $app->input->post->get('author'); + $this->setState('filter.author', $author); + } + + $system_name = $this->getUserStateFromRequest($this->context . '.filter.system_name', 'filter_system_name'); + if ($formSubmited) + { + $system_name = $app->input->post->get('system_name'); + $this->setState('filter.system_name', $system_name); + } + + $name_code = $this->getUserStateFromRequest($this->context . '.filter.name_code', 'filter_name_code'); + if ($formSubmited) + { + $name_code = $app->input->post->get('name_code'); + $this->setState('filter.name_code', $name_code); + } + + $short_description = $this->getUserStateFromRequest($this->context . '.filter.short_description', 'filter_short_description'); + if ($formSubmited) + { + $short_description = $app->input->post->get('short_description'); + $this->setState('filter.short_description', $short_description); + } + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + if ($formSubmited) + { + $created = $app->input->post->get('created'); + $this->setState('filter.created', $created); + } + + $modified = $this->getUserStateFromRequest($this->context . '.filter.modified', 'filter_modified'); + if ($formSubmited) + { + $modified = $app->input->post->get('modified'); + $this->setState('filter.modified', $modified); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('joomla_component.access', 'com_componentbuilder.joomla_component.' . (int) $item->id) && $user->authorise('joomla_component.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_joomla_component', 'a')); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.system_name LIKE '.$search.' OR a.name_code LIKE '.$search.' OR a.short_description LIKE '.$search.' OR a.companyname LIKE '.$search.' OR a.author LIKE '.$search.' OR a.email LIKE '.$search.' OR a.website LIKE '.$search.' OR a.name LIKE '.$search.')'); + } + } + + // Filter by Companyname. + $_companyname = $this->getState('filter.companyname'); + if (is_numeric($_companyname)) + { + if (is_float($_companyname)) + { + $query->where('a.companyname = ' . (float) $_companyname); + } + else + { + $query->where('a.companyname = ' . (int) $_companyname); + } + } + elseif (StringHelper::check($_companyname)) + { + $query->where('a.companyname = ' . $db->quote($db->escape($_companyname))); + } + elseif (UtilitiesArrayHelper::check($_companyname)) + { + // Secure the array for the query + $_companyname = array_map( function ($val) use(&$db) { + if (is_numeric($val)) + { + if (is_float($val)) + { + return (float) $val; + } + else + { + return (int) $val; + } + } + elseif (StringHelper::check($val)) + { + return $db->quote($db->escape($val)); + } + }, $_companyname); + // Filter by the Companyname Array. + $query->where('a.companyname IN (' . implode(',', $_companyname) . ')'); + } + // Filter by Author. + $_author = $this->getState('filter.author'); + if (is_numeric($_author)) + { + if (is_float($_author)) + { + $query->where('a.author = ' . (float) $_author); + } + else + { + $query->where('a.author = ' . (int) $_author); + } + } + elseif (StringHelper::check($_author)) + { + $query->where('a.author = ' . $db->quote($db->escape($_author))); + } + elseif (UtilitiesArrayHelper::check($_author)) + { + // Secure the array for the query + $_author = array_map( function ($val) use(&$db) { + if (is_numeric($val)) + { + if (is_float($val)) + { + return (float) $val; + } + else + { + return (int) $val; + } + } + elseif (StringHelper::check($val)) + { + return $db->quote($db->escape($val)); + } + }, $_author); + // Filter by the Author Array. + $query->where('a.author IN (' . implode(',', $_author) . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get list export data. + * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExportData($pks, $user = null) + { + // setup the query + if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks) + { + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + $_export = true; + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_joomla_component table + $query->from($db->quoteName('#__componentbuilder_joomla_component', 'a')); + // The bulk export path + if ('bulk' === $pks) + { + $query->where('a.id > 0'); + } + // A large array of ID's will not work out well + elseif ($pks_size > 500) + { + // Use lowest ID + $query->where('a.id >= ' . (int) min($pks)); + // Use highest ID + $query->where('a.id <= ' . (int) max($pks)); + } + // The normal default path + else + { + $query->where('a.id IN (' . implode(',',$pks) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.id desc'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Get the basic encryption key. + $basickey = ComponentbuilderHelper::getCryptKey('basic'); + // Get the encryption object. + $basic = new AES($basickey); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('joomla_component.access', 'com_componentbuilder.joomla_component.' . (int) $item->id) && $user->authorise('joomla_component.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // decode buildcompsql + $item->buildcompsql = base64_decode($item->buildcompsql); + // decode php_method_uninstall + $item->php_method_uninstall = base64_decode($item->php_method_uninstall); + // decode php_preflight_install + $item->php_preflight_install = base64_decode($item->php_preflight_install); + // decode css_admin + $item->css_admin = base64_decode($item->css_admin); + // decode php_site_event + $item->php_site_event = base64_decode($item->php_site_event); + // decode php_postflight_install + $item->php_postflight_install = base64_decode($item->php_postflight_install); + // decode sql_uninstall + $item->sql_uninstall = base64_decode($item->sql_uninstall); + // decode php_helper_both + $item->php_helper_both = base64_decode($item->php_helper_both); + if ($basickey && !is_numeric($item->crowdin_username) && $item->crowdin_username === base64_encode(base64_decode($item->crowdin_username, true))) + { + // decrypt crowdin_username + $item->crowdin_username = $basic->decryptString($item->crowdin_username); + } + // decode php_admin_event + $item->php_admin_event = base64_decode($item->php_admin_event); + // decode php_helper_admin + $item->php_helper_admin = base64_decode($item->php_helper_admin); + // decode php_helper_site + $item->php_helper_site = base64_decode($item->php_helper_site); + if ($basickey && !is_numeric($item->whmcs_key) && $item->whmcs_key === base64_encode(base64_decode($item->whmcs_key, true))) + { + // decrypt whmcs_key + $item->whmcs_key = $basic->decryptString($item->whmcs_key); + } + // decode javascript + $item->javascript = base64_decode($item->javascript); + // decode css_site + $item->css_site = base64_decode($item->css_site); + // decode php_preflight_update + $item->php_preflight_update = base64_decode($item->php_preflight_update); + // decode php_postflight_update + $item->php_postflight_update = base64_decode($item->php_postflight_update); + // decode sql + $item->sql = base64_decode($item->sql); + if ($basickey && !is_numeric($item->export_key) && $item->export_key === base64_encode(base64_decode($item->export_key, true))) + { + // decrypt export_key + $item->export_key = $basic->decryptString($item->export_key); + } + // decode readme + $item->readme = base64_decode($item->readme); + if ($basickey && !is_numeric($item->crowdin_project_api_key) && $item->crowdin_project_api_key === base64_encode(base64_decode($item->crowdin_project_api_key, true))) + { + // decrypt crowdin_project_api_key + $item->crowdin_project_api_key = $basic->decryptString($item->crowdin_project_api_key); + } + if ($basickey && !is_numeric($item->crowdin_account_api_key) && $item->crowdin_account_api_key === base64_encode(base64_decode($item->crowdin_account_api_key, true))) + { + // decrypt crowdin_account_api_key + $item->crowdin_account_api_key = $basic->decryptString($item->crowdin_account_api_key); + } + // unset the values we don't want exported. + unset($item->asset_id); + unset($item->checked_out); + unset($item->checked_out_time); + } + } + // Add headers to items array. + $headers = $this->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + array_unshift($items,$headers); + } + return $items; + } + } + 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 = Factory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_joomla_component"); + if (UtilitiesArrayHelper::check($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; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + // Check if the value is an array + $_companyname = $this->getState('filter.companyname'); + if (UtilitiesArrayHelper::check($_companyname)) + { + $id .= ':' . implode(':', $_companyname); + } + // Check if this is only an number or string + elseif (is_numeric($_companyname) + || StringHelper::check($_companyname)) + { + $id .= ':' . $_companyname; + } + // Check if the value is an array + $_author = $this->getState('filter.author'); + if (UtilitiesArrayHelper::check($_author)) + { + $id .= ':' . implode(':', $_author); + } + // Check if this is only an number or string + elseif (is_numeric($_author) + || StringHelper::check($_author)) + { + $id .= ':' . $_author; + } + $id .= ':' . $this->getState('filter.system_name'); + $id .= ':' . $this->getState('filter.name_code'); + $id .= ':' . $this->getState('filter.short_description'); + $id .= ':' . $this->getState('filter.created'); + $id .= ':' . $this->getState('filter.modified'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_joomla_component')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_joomla_component'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Joomla_moduleModel.php b/admin/src/Model/Joomla_moduleModel.php new file mode 100644 index 000000000..438f0f94a --- /dev/null +++ b/admin/src/Model/Joomla_moduleModel.php @@ -0,0 +1,1469 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\String\ClassfunctionHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Joomla_module Admin Model + * + * @since 1.6 + */ +class Joomla_moduleModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'html' => array( + 'left' => array( + 'name', + 'description', + 'libraries', + 'note_libraries_options', + 'note_add_php_language_string' + ), + 'right' => array( + 'snippet', + 'note_uikit_snippet', + 'note_snippet_usage' + ), + 'fullwidth' => array( + 'default', + 'note_linked_to_notice', + 'not_required' + ), + 'above' => array( + 'system_name', + 'module_version', + 'target' + ) + ), + 'script_file' => array( + 'fullwidth' => array( + 'add_php_script_construct', + 'php_script_construct', + 'add_php_preflight_install', + 'php_preflight_install', + 'add_php_preflight_update', + 'php_preflight_update', + 'add_php_preflight_uninstall', + 'php_preflight_uninstall', + 'add_php_postflight_install', + 'php_postflight_install', + 'add_php_postflight_update', + 'php_postflight_update', + 'add_php_method_uninstall', + 'php_method_uninstall' + ) + ), + 'readme' => array( + 'left' => array( + 'addreadme', + 'readme' + ) + ), + 'mysql' => array( + 'fullwidth' => array( + 'add_sql', + 'sql', + 'add_sql_uninstall', + 'sql_uninstall' + ) + ), + 'dynamic_integration' => array( + 'left' => array( + 'add_update_server', + 'update_server_url', + 'update_server_target', + 'note_update_server_note_ftp', + 'note_update_server_note_zip', + 'note_update_server_note_other', + 'update_server', + 'add_sales_server', + 'sales_server' + ) + ), + 'code' => array( + 'left' => array( + 'custom_get' + ), + 'right' => array( + 'note_mod_file_options' + ), + 'fullwidth' => array( + 'mod_code' + ) + ), + 'helper' => array( + 'left' => array( + 'add_class_helper' + ), + 'right' => array( + 'add_class_helper_header' + ), + 'fullwidth' => array( + 'class_helper_header', + 'class_helper_code' + ) + ), + 'forms_fields' => array( + 'fullwidth' => array( + 'fields' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/joomla_module.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/joomla_module.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.joomla_module'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'joomla_module', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('joomla_module__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'joomla_module__'.$id); + ComponentbuilderHelper::set('joomla_module__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->default)) + { + // base64 Decode default. + $item->default = base64_decode($item->default); + } + + if (!empty($item->php_preflight_update)) + { + // base64 Decode php_preflight_update. + $item->php_preflight_update = base64_decode($item->php_preflight_update); + } + + if (!empty($item->php_preflight_uninstall)) + { + // base64 Decode php_preflight_uninstall. + $item->php_preflight_uninstall = base64_decode($item->php_preflight_uninstall); + } + + if (!empty($item->mod_code)) + { + // base64 Decode mod_code. + $item->mod_code = base64_decode($item->mod_code); + } + + if (!empty($item->php_postflight_install)) + { + // base64 Decode php_postflight_install. + $item->php_postflight_install = base64_decode($item->php_postflight_install); + } + + if (!empty($item->php_postflight_update)) + { + // base64 Decode php_postflight_update. + $item->php_postflight_update = base64_decode($item->php_postflight_update); + } + + if (!empty($item->php_method_uninstall)) + { + // base64 Decode php_method_uninstall. + $item->php_method_uninstall = base64_decode($item->php_method_uninstall); + } + + if (!empty($item->class_helper_header)) + { + // base64 Decode class_helper_header. + $item->class_helper_header = base64_decode($item->class_helper_header); + } + + if (!empty($item->sql)) + { + // base64 Decode sql. + $item->sql = base64_decode($item->sql); + } + + if (!empty($item->class_helper_code)) + { + // base64 Decode class_helper_code. + $item->class_helper_code = base64_decode($item->class_helper_code); + } + + if (!empty($item->sql_uninstall)) + { + // base64 Decode sql_uninstall. + $item->sql_uninstall = base64_decode($item->sql_uninstall); + } + + if (!empty($item->readme)) + { + // base64 Decode readme. + $item->readme = base64_decode($item->readme); + } + + if (!empty($item->php_script_construct)) + { + // base64 Decode php_script_construct. + $item->php_script_construct = base64_decode($item->php_script_construct); + } + + if (!empty($item->php_preflight_install)) + { + // base64 Decode php_preflight_install. + $item->php_preflight_install = base64_decode($item->php_preflight_install); + } + + if (!empty($item->libraries)) + { + // Convert the libraries field to an array. + $libraries = new Registry; + $libraries->loadString($item->libraries); + $item->libraries = $libraries->toArray(); + } + + if (!empty($item->custom_get)) + { + // Convert the custom_get field to an array. + $custom_get = new Registry; + $custom_get->loadString($item->custom_get); + $item->custom_get = $custom_get->toArray(); + } + + if (!empty($item->fields)) + { + // Convert the fields field to an array. + $fields = new Registry; + $fields->loadString($item->fields); + $item->fields = $fields->toArray(); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('joomla_module__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'joomla_module__'.$id); + ComponentbuilderHelper::set('joomla_module__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.joomla_module', 'joomla_module', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('joomla_module.edit.state', 'com_componentbuilder.joomla_module.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_module.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('joomla_module.edit.created_by', 'com_componentbuilder.joomla_module.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_module.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('joomla_module.edit.created', 'com_componentbuilder.joomla_module.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_module.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update all editors to use this components global editor + $global_editor = ComponentHelper::getParams('com_componentbuilder')->get('editor', 'none'); + // now get all the editor fields + $editors = $form->getXml()->xpath("//field[@type='editor']"); + // check if we found any + if (UtilitiesArrayHelper::check($editors)) + { + foreach ($editors as $editor) + { + // get the field names + $name = (string) $editor['name']; + // set the field editor value (with none as fallback) + $form->setFieldAttribute($name, 'editor', $global_editor . '|none'); + } + } + + + // Only load the GUID if new item (or empty) + if (0 == $id || !($val = $form->getValue('guid'))) + { + $form->setValue('guid', null, GuidHelper::get()); + } + + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('joomla_module.delete', 'com_componentbuilder.joomla_module.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('joomla_module.edit.state', 'com_componentbuilder.joomla_module.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('joomla_module.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('joomla_module.edit', 'com_componentbuilder.joomla_module.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('joomla_module.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_joomla_module')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.joomla_module.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.joomla_module', $data); + + return $data; + } + + /** + * Method to validate the form data. + * + * @param JForm $form The form to validate against. + * @param array $data The data to validate. + * @param string $group The name of the field group to validate. + * + * @return mixed Array of filtered data if valid, false otherwise. + * + * @see JFormRule + * @see JFilterInput + * @since 12.2 + */ + public function validate($form, $data, $group = null) + { + // check if the not_required field is set + if (isset($data['not_required']) && UtilitiesStringHelper::check($data['not_required'])) + { + $requiredFields = (array) explode(',',(string) $data['not_required']); + $requiredFields = array_unique($requiredFields); + // now change the required field attributes value + foreach ($requiredFields as $requiredField) + { + // make sure there is a string value + if (UtilitiesStringHelper::check($requiredField)) + { + // change to false + $form->setFieldAttribute($requiredField, 'required', 'false'); + // also clear the data set + $data[$requiredField] = ''; + } + } + } + return parent::validate($form, $data, $group); + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return array('guid'); + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + // we must also delete the linked tables found + if (UtilitiesArrayHelper::check($pks)) + { + // linked tables to update + $_tablesArray = array( + 'joomla_module_updates' => 'joomla_module', + 'joomla_module_files_folders_urls' => 'joomla_module' + ); + foreach($_tablesArray as $_updateTable => $_key) + { + // get the linked IDs + if ($_pks = ComponentbuilderHelper::getVars($_updateTable, $pks, $_key, 'id')) + { + // load the model + $_Model = ComponentbuilderHelper::getModel($_updateTable); + // change publish state + $_Model->delete($_pks); + } + } + } + + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + // we must also update all linked tables + if (UtilitiesArrayHelper::check($pks)) + { + // linked tables to update + $_tablesArray = array( + 'joomla_module_updates' => 'joomla_module', + 'joomla_module_files_folders_urls' => 'joomla_module' + ); + foreach($_tablesArray as $_updateTable => $_key) + { + // get the linked IDs + if ($_pks = ComponentbuilderHelper::getVars($_updateTable, $pks, $_key, 'id')) + { + // load the model + $_Model = ComponentbuilderHelper::getModel($_updateTable); + // change publish state + $_Model->publish($_pks, $value); + } + } + } + + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('joomla_module'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('joomla_module'); + } + + if (!$this->canDo->get('joomla_module.create') && !$this->canDo->get('joomla_module.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('joomla_module.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('joomla_module.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->system_name) && !is_numeric($this->table->system_name)) + { + $this->table->system_name = $this->generateUnique('system_name',$this->table->system_name); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('joomla_module'); + } + + if (!$this->canDo->get('joomla_module.edit') && !$this->canDo->get('joomla_module.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('joomla_module.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('joomla_module.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // check if the name has placeholder + if (strpos($data['name'], '[[[') === false && strpos($data['name'], '###') === false) + { + // make sure the name is safe to be used as a function name + $data['name'] = ClassfunctionHelper::safe($data['name']); + } + // always reset the snippets + $data['snippet'] = 0; + // if system name is empty create from name + if (empty($data['system_name']) || !UtilitiesStringHelper::check($data['system_name'])) + { + $data['system_name'] = $data['name']; + } + + // Set the GUID if empty or not valid + if (empty($data['guid']) && $data['id'] > 0) + { + // get the existing one + $data['guid'] = (string) GetHelper::var('joomla_module', $data['id'], 'id', 'guid'); + } + + // Set the GUID if empty or not valid + while (!GuidHelper::valid($data['guid'], "joomla_module", $data['id'])) + { + // must always be set + $data['guid'] = (string) GuidHelper::get(); + } + + // Set the libraries items to data. + if (isset($data['libraries']) && is_array($data['libraries'])) + { + $libraries = new Registry; + $libraries->loadArray($data['libraries']); + $data['libraries'] = (string) $libraries; + } + elseif (!isset($data['libraries'])) + { + // Set the empty libraries to data + $data['libraries'] = ''; + } + + // Set the custom_get items to data. + if (isset($data['custom_get']) && is_array($data['custom_get'])) + { + $custom_get = new Registry; + $custom_get->loadArray($data['custom_get']); + $data['custom_get'] = (string) $custom_get; + } + elseif (!isset($data['custom_get'])) + { + // Set the empty custom_get to data + $data['custom_get'] = ''; + } + + // Set the fields items to data. + if (isset($data['fields']) && is_array($data['fields'])) + { + $fields = new Registry; + $fields->loadArray($data['fields']); + $data['fields'] = (string) $fields; + } + elseif (!isset($data['fields'])) + { + // Set the empty fields to data + $data['fields'] = ''; + } + + // Set the default string to base64 string. + if (isset($data['default'])) + { + $data['default'] = base64_encode($data['default']); + } + + // Set the php_preflight_update string to base64 string. + if (isset($data['php_preflight_update'])) + { + $data['php_preflight_update'] = base64_encode($data['php_preflight_update']); + } + + // Set the php_preflight_uninstall string to base64 string. + if (isset($data['php_preflight_uninstall'])) + { + $data['php_preflight_uninstall'] = base64_encode($data['php_preflight_uninstall']); + } + + // Set the mod_code string to base64 string. + if (isset($data['mod_code'])) + { + $data['mod_code'] = base64_encode($data['mod_code']); + } + + // Set the php_postflight_install string to base64 string. + if (isset($data['php_postflight_install'])) + { + $data['php_postflight_install'] = base64_encode($data['php_postflight_install']); + } + + // Set the php_postflight_update string to base64 string. + if (isset($data['php_postflight_update'])) + { + $data['php_postflight_update'] = base64_encode($data['php_postflight_update']); + } + + // Set the php_method_uninstall string to base64 string. + if (isset($data['php_method_uninstall'])) + { + $data['php_method_uninstall'] = base64_encode($data['php_method_uninstall']); + } + + // Set the class_helper_header string to base64 string. + if (isset($data['class_helper_header'])) + { + $data['class_helper_header'] = base64_encode($data['class_helper_header']); + } + + // Set the sql string to base64 string. + if (isset($data['sql'])) + { + $data['sql'] = base64_encode($data['sql']); + } + + // Set the class_helper_code string to base64 string. + if (isset($data['class_helper_code'])) + { + $data['class_helper_code'] = base64_encode($data['class_helper_code']); + } + + // Set the sql_uninstall string to base64 string. + if (isset($data['sql_uninstall'])) + { + $data['sql_uninstall'] = base64_encode($data['sql_uninstall']); + } + + // Set the readme string to base64 string. + if (isset($data['readme'])) + { + $data['readme'] = base64_encode($data['readme']); + } + + // Set the php_script_construct string to base64 string. + if (isset($data['php_script_construct'])) + { + $data['php_script_construct'] = base64_encode($data['php_script_construct']); + } + + // Set the php_preflight_install string to base64 string. + if (isset($data['php_preflight_install'])) + { + $data['php_preflight_install'] = base64_encode($data['php_preflight_install']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Joomla_module_files_folders_urlsModel.php b/admin/src/Model/Joomla_module_files_folders_urlsModel.php new file mode 100644 index 000000000..92f9472de --- /dev/null +++ b/admin/src/Model/Joomla_module_files_folders_urlsModel.php @@ -0,0 +1,1052 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Joomla_module_files_folders_urls Admin Model + * + * @since 1.6 + */ +class Joomla_module_files_folders_urlsModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'basic' => array( + 'fullwidth' => array( + 'note_add_urls', + 'addurls', + 'note_add_files', + 'addfiles', + 'note_add_folders', + 'addfolders' + ), + 'above' => array( + 'joomla_module' + ) + ), + 'advance' => array( + 'fullwidth' => array( + 'note_add_files_fullpath', + 'addfilesfullpath', + 'note_add_folders_fullpath', + 'addfoldersfullpath', + 'note_constant_paths' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/joomla_module_files_folders_urls.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/joomla_module_files_folders_urls.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.joomla_module_files_folders_urls'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'joomla_module_files_folders_urls', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->addfoldersfullpath)) + { + // Convert the addfoldersfullpath field to an array. + $addfoldersfullpath = new Registry; + $addfoldersfullpath->loadString($item->addfoldersfullpath); + $item->addfoldersfullpath = $addfoldersfullpath->toArray(); + } + + if (!empty($item->addfilesfullpath)) + { + // Convert the addfilesfullpath field to an array. + $addfilesfullpath = new Registry; + $addfilesfullpath->loadString($item->addfilesfullpath); + $item->addfilesfullpath = $addfilesfullpath->toArray(); + } + + if (!empty($item->addfolders)) + { + // Convert the addfolders field to an array. + $addfolders = new Registry; + $addfolders->loadString($item->addfolders); + $item->addfolders = $addfolders->toArray(); + } + + if (!empty($item->addfiles)) + { + // Convert the addfiles field to an array. + $addfiles = new Registry; + $addfiles->loadString($item->addfiles); + $item->addfiles = $addfiles->toArray(); + } + + if (!empty($item->addurls)) + { + // Convert the addurls field to an array. + $addurls = new Registry; + $addurls->loadString($item->addurls); + $item->addurls = $addurls->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.joomla_module_files_folders_urls', 'joomla_module_files_folders_urls', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('joomla_module_files_folders_urls.edit.state', 'com_componentbuilder.joomla_module_files_folders_urls.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_module_files_folders_urls.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('joomla_module_files_folders_urls.edit.created_by', 'com_componentbuilder.joomla_module_files_folders_urls.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_module_files_folders_urls.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('joomla_module_files_folders_urls.edit.created', 'com_componentbuilder.joomla_module_files_folders_urls.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_module_files_folders_urls.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('joomla_module_files_folders_urls.delete', 'com_componentbuilder.joomla_module_files_folders_urls.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('joomla_module_files_folders_urls.edit.state', 'com_componentbuilder.joomla_module_files_folders_urls.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('joomla_module_files_folders_urls.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('joomla_module_files_folders_urls.edit', 'com_componentbuilder.joomla_module_files_folders_urls.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('joomla_module_files_folders_urls.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_joomla_module_files_folders_urls')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.joomla_module_files_folders_urls.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.joomla_module_files_folders_urls', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('joomla_module_files_folders_urls'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('joomla_module_files_folders_urls'); + } + + if (!$this->canDo->get('joomla_module_files_folders_urls.create') && !$this->canDo->get('joomla_module_files_folders_urls.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('joomla_module_files_folders_urls.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('joomla_module_files_folders_urls.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->joomla_module) && !is_numeric($this->table->joomla_module)) + { + $this->table->joomla_module = $this->generateUnique('joomla_module',$this->table->joomla_module); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('joomla_module_files_folders_urls'); + } + + if (!$this->canDo->get('joomla_module_files_folders_urls.edit') && !$this->canDo->get('joomla_module_files_folders_urls.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('joomla_module_files_folders_urls.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('joomla_module_files_folders_urls.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the addfoldersfullpath items to data. + if (isset($data['addfoldersfullpath']) && is_array($data['addfoldersfullpath'])) + { + $addfoldersfullpath = new Registry; + $addfoldersfullpath->loadArray($data['addfoldersfullpath']); + $data['addfoldersfullpath'] = (string) $addfoldersfullpath; + } + elseif (!isset($data['addfoldersfullpath'])) + { + // Set the empty addfoldersfullpath to data + $data['addfoldersfullpath'] = ''; + } + + // Set the addfilesfullpath items to data. + if (isset($data['addfilesfullpath']) && is_array($data['addfilesfullpath'])) + { + $addfilesfullpath = new Registry; + $addfilesfullpath->loadArray($data['addfilesfullpath']); + $data['addfilesfullpath'] = (string) $addfilesfullpath; + } + elseif (!isset($data['addfilesfullpath'])) + { + // Set the empty addfilesfullpath to data + $data['addfilesfullpath'] = ''; + } + + // Set the addfolders items to data. + if (isset($data['addfolders']) && is_array($data['addfolders'])) + { + $addfolders = new Registry; + $addfolders->loadArray($data['addfolders']); + $data['addfolders'] = (string) $addfolders; + } + elseif (!isset($data['addfolders'])) + { + // Set the empty addfolders to data + $data['addfolders'] = ''; + } + + // Set the addfiles items to data. + if (isset($data['addfiles']) && is_array($data['addfiles'])) + { + $addfiles = new Registry; + $addfiles->loadArray($data['addfiles']); + $data['addfiles'] = (string) $addfiles; + } + elseif (!isset($data['addfiles'])) + { + // Set the empty addfiles to data + $data['addfiles'] = ''; + } + + // Set the addurls items to data. + if (isset($data['addurls']) && is_array($data['addurls'])) + { + $addurls = new Registry; + $addurls->loadArray($data['addurls']); + $data['addurls'] = (string) $addurls; + } + elseif (!isset($data['addurls'])) + { + // Set the empty addurls to data + $data['addurls'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Joomla_module_updatesModel.php b/admin/src/Model/Joomla_module_updatesModel.php new file mode 100644 index 000000000..209628133 --- /dev/null +++ b/admin/src/Model/Joomla_module_updatesModel.php @@ -0,0 +1,957 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Joomla_module_updates Admin Model + * + * @since 1.6 + */ +class Joomla_module_updatesModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'updates' => array( + 'fullwidth' => array( + 'version_update' + ), + 'above' => array( + 'joomla_module' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/joomla_module_updates.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/joomla_module_updates.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.joomla_module_updates'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'joomla_module_updates', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->version_update)) + { + // Convert the version_update field to an array. + $version_update = new Registry; + $version_update->loadString($item->version_update); + $item->version_update = $version_update->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.joomla_module_updates', 'joomla_module_updates', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('joomla_module_updates.edit.state', 'com_componentbuilder.joomla_module_updates.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_module_updates.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('joomla_module_updates.edit.created_by', 'com_componentbuilder.joomla_module_updates.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_module_updates.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('joomla_module_updates.edit.created', 'com_componentbuilder.joomla_module_updates.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_module_updates.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update the version_update (sub form) layout + $form->setFieldAttribute('version_update', 'layout', ComponentbuilderHelper::getSubformLayout('joomla_module_updates', 'version_update')); + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('joomla_module_updates.delete', 'com_componentbuilder.joomla_module_updates.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('joomla_module_updates.edit.state', 'com_componentbuilder.joomla_module_updates.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('joomla_module_updates.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('joomla_module_updates.edit', 'com_componentbuilder.joomla_module_updates.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('joomla_module_updates.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_joomla_module_updates')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.joomla_module_updates.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.joomla_module_updates', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('joomla_module_updates'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('joomla_module_updates'); + } + + if (!$this->canDo->get('joomla_module_updates.create') && !$this->canDo->get('joomla_module_updates.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('joomla_module_updates.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('joomla_module_updates.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->joomla_module) && !is_numeric($this->table->joomla_module)) + { + $this->table->joomla_module = $this->generateUnique('joomla_module',$this->table->joomla_module); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('joomla_module_updates'); + } + + if (!$this->canDo->get('joomla_module_updates.edit') && !$this->canDo->get('joomla_module_updates.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('joomla_module_updates.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('joomla_module_updates.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the version_update items to data. + if (isset($data['version_update']) && is_array($data['version_update'])) + { + $version_update = new Registry; + $version_update->loadArray($data['version_update']); + $data['version_update'] = (string) $version_update; + } + elseif (!isset($data['version_update'])) + { + // Set the empty version_update to data + $data['version_update'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Joomla_modulesModel.php b/admin/src/Model/Joomla_modulesModel.php new file mode 100644 index 000000000..002853de7 --- /dev/null +++ b/admin/src/Model/Joomla_modulesModel.php @@ -0,0 +1,624 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_modules List Model + * + * @since 1.6 + */ +class Joomla_modulesModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/joomla_modules.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.target','target', + 'a.system_name','system_name', + 'a.description','description' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $target = $this->getUserStateFromRequest($this->context . '.filter.target', 'filter_target'); + if ($formSubmited) + { + $target = $app->input->post->get('target'); + $this->setState('filter.target', $target); + } + + $system_name = $this->getUserStateFromRequest($this->context . '.filter.system_name', 'filter_system_name'); + if ($formSubmited) + { + $system_name = $app->input->post->get('system_name'); + $this->setState('filter.system_name', $system_name); + } + + $description = $this->getUserStateFromRequest($this->context . '.filter.description', 'filter_description'); + if ($formSubmited) + { + $description = $app->input->post->get('description'); + $this->setState('filter.description', $description); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('joomla_module.access', 'com_componentbuilder.joomla_module.' . (int) $item->id) && $user->authorise('joomla_module.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // set selection value to a translatable value + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // convert target + $item->target = $this->selectionTranslation($item->target, 'target'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return string The translatable string. + */ + public function selectionTranslation($value,$name) + { + // Array of target language strings + if ($name === 'target') + { + $targetArray = array( + 1 => 'COM_COMPONENTBUILDER_JOOMLA_MODULE_SITE', + 2 => 'COM_COMPONENTBUILDER_JOOMLA_MODULE_ADMIN' + ); + // Now check if value is found in this array + if (isset($targetArray[$value]) && StringHelper::check($targetArray[$value])) + { + return $targetArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_joomla_module', 'a')); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.system_name LIKE '.$search.' OR a.description LIKE '.$search.' OR a.name LIKE '.$search.')'); + } + } + + // Filter by Target. + $_target = $this->getState('filter.target'); + if (is_numeric($_target)) + { + if (is_float($_target)) + { + $query->where('a.target = ' . (float) $_target); + } + else + { + $query->where('a.target = ' . (int) $_target); + } + } + elseif (StringHelper::check($_target)) + { + $query->where('a.target = ' . $db->quote($db->escape($_target))); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get list export data. + * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExportData($pks, $user = null) + { + // setup the query + if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks) + { + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + $_export = true; + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_joomla_module table + $query->from($db->quoteName('#__componentbuilder_joomla_module', 'a')); + // The bulk export path + if ('bulk' === $pks) + { + $query->where('a.id > 0'); + } + // A large array of ID's will not work out well + elseif ($pks_size > 500) + { + // Use lowest ID + $query->where('a.id >= ' . (int) min($pks)); + // Use highest ID + $query->where('a.id <= ' . (int) max($pks)); + } + // The normal default path + else + { + $query->where('a.id IN (' . implode(',',$pks) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.id desc'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('joomla_module.access', 'com_componentbuilder.joomla_module.' . (int) $item->id) && $user->authorise('joomla_module.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // decode default + $item->default = base64_decode($item->default); + // decode php_preflight_update + $item->php_preflight_update = base64_decode($item->php_preflight_update); + // decode php_preflight_uninstall + $item->php_preflight_uninstall = base64_decode($item->php_preflight_uninstall); + // decode mod_code + $item->mod_code = base64_decode($item->mod_code); + // decode php_postflight_install + $item->php_postflight_install = base64_decode($item->php_postflight_install); + // decode php_postflight_update + $item->php_postflight_update = base64_decode($item->php_postflight_update); + // decode php_method_uninstall + $item->php_method_uninstall = base64_decode($item->php_method_uninstall); + // decode class_helper_header + $item->class_helper_header = base64_decode($item->class_helper_header); + // decode sql + $item->sql = base64_decode($item->sql); + // decode class_helper_code + $item->class_helper_code = base64_decode($item->class_helper_code); + // decode sql_uninstall + $item->sql_uninstall = base64_decode($item->sql_uninstall); + // decode readme + $item->readme = base64_decode($item->readme); + // decode php_script_construct + $item->php_script_construct = base64_decode($item->php_script_construct); + // decode php_preflight_install + $item->php_preflight_install = base64_decode($item->php_preflight_install); + // unset the values we don't want exported. + unset($item->asset_id); + unset($item->checked_out); + unset($item->checked_out_time); + } + } + // Add headers to items array. + $headers = $this->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + array_unshift($items,$headers); + } + return $items; + } + } + 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 = Factory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_joomla_module"); + if (UtilitiesArrayHelper::check($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; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.target'); + $id .= ':' . $this->getState('filter.system_name'); + $id .= ':' . $this->getState('filter.description'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_joomla_module')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_joomla_module'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Joomla_modules_files_folders_urlsModel.php b/admin/src/Model/Joomla_modules_files_folders_urlsModel.php new file mode 100644 index 000000000..6f691feb5 --- /dev/null +++ b/admin/src/Model/Joomla_modules_files_folders_urlsModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_modules_files_folders_urls List Model + * + * @since 1.6 + */ +class Joomla_modules_files_folders_urlsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/joomla_modules_files_folders_urls.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('joomla_module_files_folders_urls.access', 'com_componentbuilder.joomla_module_files_folders_urls.' . (int) $item->id) && $user->authorise('joomla_module_files_folders_urls.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_joomla_module_files_folders_urls', 'a')); + + // From the componentbuilder_joomla_module table. + $query->select($db->quoteName('g.system_name','joomla_module_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_module', 'g') . ' ON (' . $db->quoteName('a.joomla_module') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_joomla_module_files_folders_urls')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_joomla_module_files_folders_urls'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Joomla_modules_updatesModel.php b/admin/src/Model/Joomla_modules_updatesModel.php new file mode 100644 index 000000000..fd5bb6a22 --- /dev/null +++ b/admin/src/Model/Joomla_modules_updatesModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_modules_updates List Model + * + * @since 1.6 + */ +class Joomla_modules_updatesModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/joomla_modules_updates.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('joomla_module_updates.access', 'com_componentbuilder.joomla_module_updates.' . (int) $item->id) && $user->authorise('joomla_module_updates.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_joomla_module_updates', 'a')); + + // From the componentbuilder_joomla_module table. + $query->select($db->quoteName('g.system_name','joomla_module_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_module', 'g') . ' ON (' . $db->quoteName('a.joomla_module') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_joomla_module_updates')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_joomla_module_updates'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Joomla_pluginModel.php b/admin/src/Model/Joomla_pluginModel.php new file mode 100644 index 000000000..c328e6cf2 --- /dev/null +++ b/admin/src/Model/Joomla_pluginModel.php @@ -0,0 +1,1420 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\String\ClassfunctionHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Joomla_plugin Admin Model + * + * @since 1.6 + */ +class Joomla_pluginModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'code' => array( + 'left' => array( + 'name', + 'description', + 'class_extends', + 'joomla_plugin_group', + 'add_head', + 'note_plugin' + ), + 'right' => array( + 'property_selection', + 'method_selection' + ), + 'fullwidth' => array( + 'head', + 'main_class_code', + 'note_linked_to_notice', + 'not_required' + ), + 'above' => array( + 'system_name', + 'plugin_version' + ) + ), + 'mysql' => array( + 'fullwidth' => array( + 'add_sql', + 'sql', + 'add_sql_uninstall', + 'sql_uninstall' + ) + ), + 'script_file' => array( + 'fullwidth' => array( + 'add_php_script_construct', + 'php_script_construct', + 'add_php_preflight_install', + 'php_preflight_install', + 'add_php_preflight_update', + 'php_preflight_update', + 'add_php_preflight_uninstall', + 'php_preflight_uninstall', + 'add_php_postflight_install', + 'php_postflight_install', + 'add_php_postflight_update', + 'php_postflight_update', + 'add_php_method_uninstall', + 'php_method_uninstall' + ) + ), + 'dynamic_integration' => array( + 'left' => array( + 'add_update_server', + 'update_server_url', + 'update_server_target', + 'note_update_server_note_ftp', + 'note_update_server_note_zip', + 'note_update_server_note_other', + 'update_server', + 'add_sales_server', + 'sales_server' + ) + ), + 'readme' => array( + 'left' => array( + 'addreadme', + 'readme' + ) + ), + 'forms_fields' => array( + 'fullwidth' => array( + 'fields' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/joomla_plugin.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/joomla_plugin.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.joomla_plugin'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'joomla_plugin', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('joomla_plugin__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'joomla_plugin__'.$id); + ComponentbuilderHelper::set('joomla_plugin__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->head)) + { + // base64 Decode head. + $item->head = base64_decode($item->head); + } + + if (!empty($item->main_class_code)) + { + // base64 Decode main_class_code. + $item->main_class_code = base64_decode($item->main_class_code); + } + + if (!empty($item->php_postflight_install)) + { + // base64 Decode php_postflight_install. + $item->php_postflight_install = base64_decode($item->php_postflight_install); + } + + if (!empty($item->php_postflight_update)) + { + // base64 Decode php_postflight_update. + $item->php_postflight_update = base64_decode($item->php_postflight_update); + } + + if (!empty($item->php_method_uninstall)) + { + // base64 Decode php_method_uninstall. + $item->php_method_uninstall = base64_decode($item->php_method_uninstall); + } + + if (!empty($item->sql)) + { + // base64 Decode sql. + $item->sql = base64_decode($item->sql); + } + + if (!empty($item->php_script_construct)) + { + // base64 Decode php_script_construct. + $item->php_script_construct = base64_decode($item->php_script_construct); + } + + if (!empty($item->sql_uninstall)) + { + // base64 Decode sql_uninstall. + $item->sql_uninstall = base64_decode($item->sql_uninstall); + } + + if (!empty($item->readme)) + { + // base64 Decode readme. + $item->readme = base64_decode($item->readme); + } + + if (!empty($item->php_preflight_install)) + { + // base64 Decode php_preflight_install. + $item->php_preflight_install = base64_decode($item->php_preflight_install); + } + + if (!empty($item->php_preflight_update)) + { + // base64 Decode php_preflight_update. + $item->php_preflight_update = base64_decode($item->php_preflight_update); + } + + if (!empty($item->php_preflight_uninstall)) + { + // base64 Decode php_preflight_uninstall. + $item->php_preflight_uninstall = base64_decode($item->php_preflight_uninstall); + } + + if (!empty($item->method_selection)) + { + // Convert the method_selection field to an array. + $method_selection = new Registry; + $method_selection->loadString($item->method_selection); + $item->method_selection = $method_selection->toArray(); + } + + if (!empty($item->property_selection)) + { + // Convert the property_selection field to an array. + $property_selection = new Registry; + $property_selection->loadString($item->property_selection); + $item->property_selection = $property_selection->toArray(); + } + + if (!empty($item->fields)) + { + // Convert the fields field to an array. + $fields = new Registry; + $fields->loadString($item->fields); + $item->fields = $fields->toArray(); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('joomla_plugin__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'joomla_plugin__'.$id); + ComponentbuilderHelper::set('joomla_plugin__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.joomla_plugin', 'joomla_plugin', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('joomla_plugin.edit.state', 'com_componentbuilder.joomla_plugin.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_plugin.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('joomla_plugin.edit.created_by', 'com_componentbuilder.joomla_plugin.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_plugin.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('joomla_plugin.edit.created', 'com_componentbuilder.joomla_plugin.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_plugin.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update all editors to use this components global editor + $global_editor = ComponentHelper::getParams('com_componentbuilder')->get('editor', 'none'); + // now get all the editor fields + $editors = $form->getXml()->xpath("//field[@type='editor']"); + // check if we found any + if (UtilitiesArrayHelper::check($editors)) + { + foreach ($editors as $editor) + { + // get the field names + $name = (string) $editor['name']; + // set the field editor value (with none as fallback) + $form->setFieldAttribute($name, 'editor', $global_editor . '|none'); + } + } + + + // Only load the GUID if new item (or empty) + if (0 == $id || !($val = $form->getValue('guid'))) + { + $form->setValue('guid', null, GuidHelper::get()); + } + + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('joomla_plugin.delete', 'com_componentbuilder.joomla_plugin.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('joomla_plugin.edit.state', 'com_componentbuilder.joomla_plugin.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('joomla_plugin.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('joomla_plugin.edit', 'com_componentbuilder.joomla_plugin.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('joomla_plugin.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_joomla_plugin')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.joomla_plugin.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.joomla_plugin', $data); + + return $data; + } + + /** + * Method to validate the form data. + * + * @param JForm $form The form to validate against. + * @param array $data The data to validate. + * @param string $group The name of the field group to validate. + * + * @return mixed Array of filtered data if valid, false otherwise. + * + * @see JFormRule + * @see JFilterInput + * @since 12.2 + */ + public function validate($form, $data, $group = null) + { + // check if the not_required field is set + if (isset($data['not_required']) && UtilitiesStringHelper::check($data['not_required'])) + { + $requiredFields = (array) explode(',',(string) $data['not_required']); + $requiredFields = array_unique($requiredFields); + // now change the required field attributes value + foreach ($requiredFields as $requiredField) + { + // make sure there is a string value + if (UtilitiesStringHelper::check($requiredField)) + { + // change to false + $form->setFieldAttribute($requiredField, 'required', 'false'); + // also clear the data set + $data[$requiredField] = ''; + } + } + } + return parent::validate($form, $data, $group); + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return array('guid'); + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + // we must also delete the linked tables found + if (UtilitiesArrayHelper::check($pks)) + { + // linked tables to update + $_tablesArray = array( + 'joomla_plugin_updates' => 'joomla_plugin', + 'joomla_plugin_files_folders_urls' => 'joomla_plugin' + ); + foreach($_tablesArray as $_updateTable => $_key) + { + // get the linked IDs + if ($_pks = ComponentbuilderHelper::getVars($_updateTable, $pks, $_key, 'id')) + { + // load the model + $_Model = ComponentbuilderHelper::getModel($_updateTable); + // change publish state + $_Model->delete($_pks); + } + } + } + + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + // we must also update all linked tables + if (UtilitiesArrayHelper::check($pks)) + { + // linked tables to update + $_tablesArray = array( + 'joomla_plugin_updates' => 'joomla_plugin', + 'joomla_plugin_files_folders_urls' => 'joomla_plugin' + ); + foreach($_tablesArray as $_updateTable => $_key) + { + // get the linked IDs + if ($_pks = ComponentbuilderHelper::getVars($_updateTable, $pks, $_key, 'id')) + { + // load the model + $_Model = ComponentbuilderHelper::getModel($_updateTable); + // change publish state + $_Model->publish($_pks, $value); + } + } + } + + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin'); + } + + if (!$this->canDo->get('joomla_plugin.create') && !$this->canDo->get('joomla_plugin.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('joomla_plugin.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('joomla_plugin.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->system_name) && !is_numeric($this->table->system_name)) + { + $this->table->system_name = $this->generateUnique('system_name',$this->table->system_name); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin'); + } + + if (!$this->canDo->get('joomla_plugin.edit') && !$this->canDo->get('joomla_plugin.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('joomla_plugin.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('joomla_plugin.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // check if the name has placeholder + if (strpos($data['name'], '[[[') === false && strpos($data['name'], '###') === false) + { + // make sure the name is safe to be used as a function name + $data['name'] = ClassfunctionHelper::safe($data['name']); + } + // if system name is empty create from name + if (empty($data['system_name']) || !UtilitiesStringHelper::check($data['system_name'])) + { + $data['system_name'] = $data['name']; + } + + // Set the GUID if empty or not valid + if (empty($data['guid']) && $data['id'] > 0) + { + // get the existing one + $data['guid'] = (string) GetHelper::var('joomla_plugin', $data['id'], 'id', 'guid'); + } + + // Set the GUID if empty or not valid + while (!GuidHelper::valid($data['guid'], "joomla_plugin", $data['id'])) + { + // must always be set + $data['guid'] = (string) GuidHelper::get(); + } + + // Set the method_selection items to data. + if (isset($data['method_selection']) && is_array($data['method_selection'])) + { + $method_selection = new Registry; + $method_selection->loadArray($data['method_selection']); + $data['method_selection'] = (string) $method_selection; + } + elseif (!isset($data['method_selection'])) + { + // Set the empty method_selection to data + $data['method_selection'] = ''; + } + + // Set the property_selection items to data. + if (isset($data['property_selection']) && is_array($data['property_selection'])) + { + $property_selection = new Registry; + $property_selection->loadArray($data['property_selection']); + $data['property_selection'] = (string) $property_selection; + } + elseif (!isset($data['property_selection'])) + { + // Set the empty property_selection to data + $data['property_selection'] = ''; + } + + // Set the fields items to data. + if (isset($data['fields']) && is_array($data['fields'])) + { + $fields = new Registry; + $fields->loadArray($data['fields']); + $data['fields'] = (string) $fields; + } + elseif (!isset($data['fields'])) + { + // Set the empty fields to data + $data['fields'] = ''; + } + + // Set the head string to base64 string. + if (isset($data['head'])) + { + $data['head'] = base64_encode($data['head']); + } + + // Set the main_class_code string to base64 string. + if (isset($data['main_class_code'])) + { + $data['main_class_code'] = base64_encode($data['main_class_code']); + } + + // Set the php_postflight_install string to base64 string. + if (isset($data['php_postflight_install'])) + { + $data['php_postflight_install'] = base64_encode($data['php_postflight_install']); + } + + // Set the php_postflight_update string to base64 string. + if (isset($data['php_postflight_update'])) + { + $data['php_postflight_update'] = base64_encode($data['php_postflight_update']); + } + + // Set the php_method_uninstall string to base64 string. + if (isset($data['php_method_uninstall'])) + { + $data['php_method_uninstall'] = base64_encode($data['php_method_uninstall']); + } + + // Set the sql string to base64 string. + if (isset($data['sql'])) + { + $data['sql'] = base64_encode($data['sql']); + } + + // Set the php_script_construct string to base64 string. + if (isset($data['php_script_construct'])) + { + $data['php_script_construct'] = base64_encode($data['php_script_construct']); + } + + // Set the sql_uninstall string to base64 string. + if (isset($data['sql_uninstall'])) + { + $data['sql_uninstall'] = base64_encode($data['sql_uninstall']); + } + + // Set the readme string to base64 string. + if (isset($data['readme'])) + { + $data['readme'] = base64_encode($data['readme']); + } + + // Set the php_preflight_install string to base64 string. + if (isset($data['php_preflight_install'])) + { + $data['php_preflight_install'] = base64_encode($data['php_preflight_install']); + } + + // Set the php_preflight_update string to base64 string. + if (isset($data['php_preflight_update'])) + { + $data['php_preflight_update'] = base64_encode($data['php_preflight_update']); + } + + // Set the php_preflight_uninstall string to base64 string. + if (isset($data['php_preflight_uninstall'])) + { + $data['php_preflight_uninstall'] = base64_encode($data['php_preflight_uninstall']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Joomla_plugin_files_folders_urlsModel.php b/admin/src/Model/Joomla_plugin_files_folders_urlsModel.php new file mode 100644 index 000000000..b75fe81f8 --- /dev/null +++ b/admin/src/Model/Joomla_plugin_files_folders_urlsModel.php @@ -0,0 +1,1052 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Joomla_plugin_files_folders_urls Admin Model + * + * @since 1.6 + */ +class Joomla_plugin_files_folders_urlsModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'basic' => array( + 'fullwidth' => array( + 'note_add_urls', + 'addurls', + 'note_add_files', + 'addfiles', + 'note_add_folders', + 'addfolders' + ), + 'above' => array( + 'joomla_plugin' + ) + ), + 'advance' => array( + 'fullwidth' => array( + 'note_add_files_fullpath', + 'addfilesfullpath', + 'note_add_folders_fullpath', + 'addfoldersfullpath', + 'note_constant_paths' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/joomla_plugin_files_folders_urls.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/joomla_plugin_files_folders_urls.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.joomla_plugin_files_folders_urls'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'joomla_plugin_files_folders_urls', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->addfoldersfullpath)) + { + // Convert the addfoldersfullpath field to an array. + $addfoldersfullpath = new Registry; + $addfoldersfullpath->loadString($item->addfoldersfullpath); + $item->addfoldersfullpath = $addfoldersfullpath->toArray(); + } + + if (!empty($item->addfilesfullpath)) + { + // Convert the addfilesfullpath field to an array. + $addfilesfullpath = new Registry; + $addfilesfullpath->loadString($item->addfilesfullpath); + $item->addfilesfullpath = $addfilesfullpath->toArray(); + } + + if (!empty($item->addfolders)) + { + // Convert the addfolders field to an array. + $addfolders = new Registry; + $addfolders->loadString($item->addfolders); + $item->addfolders = $addfolders->toArray(); + } + + if (!empty($item->addfiles)) + { + // Convert the addfiles field to an array. + $addfiles = new Registry; + $addfiles->loadString($item->addfiles); + $item->addfiles = $addfiles->toArray(); + } + + if (!empty($item->addurls)) + { + // Convert the addurls field to an array. + $addurls = new Registry; + $addurls->loadString($item->addurls); + $item->addurls = $addurls->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.joomla_plugin_files_folders_urls', 'joomla_plugin_files_folders_urls', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('joomla_plugin_files_folders_urls.edit.state', 'com_componentbuilder.joomla_plugin_files_folders_urls.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_plugin_files_folders_urls.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('joomla_plugin_files_folders_urls.edit.created_by', 'com_componentbuilder.joomla_plugin_files_folders_urls.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_plugin_files_folders_urls.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('joomla_plugin_files_folders_urls.edit.created', 'com_componentbuilder.joomla_plugin_files_folders_urls.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_plugin_files_folders_urls.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('joomla_plugin_files_folders_urls.delete', 'com_componentbuilder.joomla_plugin_files_folders_urls.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('joomla_plugin_files_folders_urls.edit.state', 'com_componentbuilder.joomla_plugin_files_folders_urls.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('joomla_plugin_files_folders_urls.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('joomla_plugin_files_folders_urls.edit', 'com_componentbuilder.joomla_plugin_files_folders_urls.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('joomla_plugin_files_folders_urls.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_joomla_plugin_files_folders_urls')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.joomla_plugin_files_folders_urls.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.joomla_plugin_files_folders_urls', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_files_folders_urls'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_files_folders_urls'); + } + + if (!$this->canDo->get('joomla_plugin_files_folders_urls.create') && !$this->canDo->get('joomla_plugin_files_folders_urls.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('joomla_plugin_files_folders_urls.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('joomla_plugin_files_folders_urls.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->joomla_plugin) && !is_numeric($this->table->joomla_plugin)) + { + $this->table->joomla_plugin = $this->generateUnique('joomla_plugin',$this->table->joomla_plugin); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_files_folders_urls'); + } + + if (!$this->canDo->get('joomla_plugin_files_folders_urls.edit') && !$this->canDo->get('joomla_plugin_files_folders_urls.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('joomla_plugin_files_folders_urls.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('joomla_plugin_files_folders_urls.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the addfoldersfullpath items to data. + if (isset($data['addfoldersfullpath']) && is_array($data['addfoldersfullpath'])) + { + $addfoldersfullpath = new Registry; + $addfoldersfullpath->loadArray($data['addfoldersfullpath']); + $data['addfoldersfullpath'] = (string) $addfoldersfullpath; + } + elseif (!isset($data['addfoldersfullpath'])) + { + // Set the empty addfoldersfullpath to data + $data['addfoldersfullpath'] = ''; + } + + // Set the addfilesfullpath items to data. + if (isset($data['addfilesfullpath']) && is_array($data['addfilesfullpath'])) + { + $addfilesfullpath = new Registry; + $addfilesfullpath->loadArray($data['addfilesfullpath']); + $data['addfilesfullpath'] = (string) $addfilesfullpath; + } + elseif (!isset($data['addfilesfullpath'])) + { + // Set the empty addfilesfullpath to data + $data['addfilesfullpath'] = ''; + } + + // Set the addfolders items to data. + if (isset($data['addfolders']) && is_array($data['addfolders'])) + { + $addfolders = new Registry; + $addfolders->loadArray($data['addfolders']); + $data['addfolders'] = (string) $addfolders; + } + elseif (!isset($data['addfolders'])) + { + // Set the empty addfolders to data + $data['addfolders'] = ''; + } + + // Set the addfiles items to data. + if (isset($data['addfiles']) && is_array($data['addfiles'])) + { + $addfiles = new Registry; + $addfiles->loadArray($data['addfiles']); + $data['addfiles'] = (string) $addfiles; + } + elseif (!isset($data['addfiles'])) + { + // Set the empty addfiles to data + $data['addfiles'] = ''; + } + + // Set the addurls items to data. + if (isset($data['addurls']) && is_array($data['addurls'])) + { + $addurls = new Registry; + $addurls->loadArray($data['addurls']); + $data['addurls'] = (string) $addurls; + } + elseif (!isset($data['addurls'])) + { + // Set the empty addurls to data + $data['addurls'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Joomla_plugin_groupModel.php b/admin/src/Model/Joomla_plugin_groupModel.php new file mode 100644 index 000000000..affd12165 --- /dev/null +++ b/admin/src/Model/Joomla_plugin_groupModel.php @@ -0,0 +1,934 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\String\ClassfunctionHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Joomla_plugin_group Admin Model + * + * @since 1.6 + */ +class Joomla_plugin_groupModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'name' + ), + 'right' => array( + 'class_extends' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/joomla_plugin_group.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/joomla_plugin_group.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.joomla_plugin_group'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'joomla_plugin_group', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.joomla_plugin_group', 'joomla_plugin_group', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('core.edit.state', 'com_componentbuilder.joomla_plugin_group.' . (int) $id)) + || ($id == 0 && !$user->authorise('core.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if (!$user->authorise('core.edit.created_by', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if (!$user->authorise('core.edit.created', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('core.delete', 'com_componentbuilder.joomla_plugin_group.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('core.edit.state', 'com_componentbuilder.joomla_plugin_group.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return parent::canEditState($record); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + + return Factory::getApplication()->getIdentity()->authorise('core.edit', 'com_componentbuilder.joomla_plugin_group.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or parent::allowEdit($data, $key); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_joomla_plugin_group')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.joomla_plugin_group.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.joomla_plugin_group', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_group'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_group'); + } + + if (!$this->canDo->get('core.create') && !$this->canDo->get('joomla_plugin_group.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('core.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('core.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->name) && !is_numeric($this->table->name)) + { + $this->table->name = $this->generateUnique('name',$this->table->name); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_group'); + } + + if (!$this->canDo->get('core.edit') && !$this->canDo->get('joomla_plugin_group.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('core.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('core.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // make sure the name is safe to be used as a function name + $data['name'] = ClassfunctionHelper::safe($data['name']); + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Joomla_plugin_groupsModel.php b/admin/src/Model/Joomla_plugin_groupsModel.php new file mode 100644 index 000000000..c2d077a1d --- /dev/null +++ b/admin/src/Model/Joomla_plugin_groupsModel.php @@ -0,0 +1,413 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_plugin_groups List Model + * + * @since 1.6 + */ +class Joomla_plugin_groupsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/joomla_plugin_groups.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'g.name','class_extends', + 'a.name','name' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $class_extends = $this->getUserStateFromRequest($this->context . '.filter.class_extends', 'filter_class_extends'); + if ($formSubmited) + { + $class_extends = $app->input->post->get('class_extends'); + $this->setState('filter.class_extends', $class_extends); + } + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_joomla_plugin_group', 'a')); + + // From the componentbuilder_class_extends table. + $query->select($db->quoteName('g.name','class_extends_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_class_extends', 'g') . ' ON (' . $db->quoteName('a.class_extends') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.' OR a.class_extends LIKE '.$search.' OR g.name LIKE '.$search.')'); + } + } + + // Filter by Class_extends. + $_class_extends = $this->getState('filter.class_extends'); + if (is_numeric($_class_extends)) + { + if (is_float($_class_extends)) + { + $query->where('a.class_extends = ' . (float) $_class_extends); + } + else + { + $query->where('a.class_extends = ' . (int) $_class_extends); + } + } + elseif (StringHelper::check($_class_extends)) + { + $query->where('a.class_extends = ' . $db->quote($db->escape($_class_extends))); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.class_extends'); + $id .= ':' . $this->getState('filter.name'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_joomla_plugin_group')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_joomla_plugin_group'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Joomla_plugin_updatesModel.php b/admin/src/Model/Joomla_plugin_updatesModel.php new file mode 100644 index 000000000..0195b682f --- /dev/null +++ b/admin/src/Model/Joomla_plugin_updatesModel.php @@ -0,0 +1,957 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Joomla_plugin_updates Admin Model + * + * @since 1.6 + */ +class Joomla_plugin_updatesModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'updates' => array( + 'fullwidth' => array( + 'version_update' + ), + 'above' => array( + 'joomla_plugin' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/joomla_plugin_updates.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/joomla_plugin_updates.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.joomla_plugin_updates'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'joomla_plugin_updates', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->version_update)) + { + // Convert the version_update field to an array. + $version_update = new Registry; + $version_update->loadString($item->version_update); + $item->version_update = $version_update->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.joomla_plugin_updates', 'joomla_plugin_updates', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('joomla_plugin_updates.edit.state', 'com_componentbuilder.joomla_plugin_updates.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_plugin_updates.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('joomla_plugin_updates.edit.created_by', 'com_componentbuilder.joomla_plugin_updates.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_plugin_updates.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('joomla_plugin_updates.edit.created', 'com_componentbuilder.joomla_plugin_updates.' . (int) $id)) + || ($id == 0 && !$user->authorise('joomla_plugin_updates.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update the version_update (sub form) layout + $form->setFieldAttribute('version_update', 'layout', ComponentbuilderHelper::getSubformLayout('joomla_plugin_updates', 'version_update')); + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('joomla_plugin_updates.delete', 'com_componentbuilder.joomla_plugin_updates.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('joomla_plugin_updates.edit.state', 'com_componentbuilder.joomla_plugin_updates.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('joomla_plugin_updates.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('joomla_plugin_updates.edit', 'com_componentbuilder.joomla_plugin_updates.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('joomla_plugin_updates.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_joomla_plugin_updates')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.joomla_plugin_updates.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.joomla_plugin_updates', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_updates'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_updates'); + } + + if (!$this->canDo->get('joomla_plugin_updates.create') && !$this->canDo->get('joomla_plugin_updates.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('joomla_plugin_updates.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('joomla_plugin_updates.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->joomla_plugin) && !is_numeric($this->table->joomla_plugin)) + { + $this->table->joomla_plugin = $this->generateUnique('joomla_plugin',$this->table->joomla_plugin); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_updates'); + } + + if (!$this->canDo->get('joomla_plugin_updates.edit') && !$this->canDo->get('joomla_plugin_updates.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('joomla_plugin_updates.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('joomla_plugin_updates.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the version_update items to data. + if (isset($data['version_update']) && is_array($data['version_update'])) + { + $version_update = new Registry; + $version_update->loadArray($data['version_update']); + $data['version_update'] = (string) $version_update; + } + elseif (!isset($data['version_update'])) + { + // Set the empty version_update to data + $data['version_update'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Joomla_pluginsModel.php b/admin/src/Model/Joomla_pluginsModel.php new file mode 100644 index 000000000..58f6469d2 --- /dev/null +++ b/admin/src/Model/Joomla_pluginsModel.php @@ -0,0 +1,636 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Utilities\ObjectHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_plugins List Model + * + * @since 1.6 + */ +class Joomla_pluginsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/joomla_plugins.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'g.name','class_extends', + 'h.name','joomla_plugin_group', + 'a.system_name','system_name' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + + /** + * get Boilerplate + * + * @return boolean + */ + public function getBoilerplate() + { + // get boilerplate repo root details + if (($repo_tree = ComponentbuilderHelper::getGithubRepoFileList('boilerplate', ComponentbuilderHelper::$bolerplateAPI)) !== false) + { + $found = array_values(array_filter( + $repo_tree, + function($tree) { + if (isset($tree->path) && $tree->path === 'plugins') + { + return true; + } + return false; + } + )); + // make sure we have the correct boilerplate + if (UtilitiesArrayHelper::check($found) && count($found) == 1 && method_exists(__CLASS__, 'getPluginsBoilerplate')) + { + // get the plugins boilerplate + return $this->getPluginsBoilerplate($found[0]->url); + } + } + return false; + } + + /** + * get Plugin Boilerplate + * + * @return boolean true on success + * + */ + protected function getPluginsBoilerplate($url) + { + // get boilerplate root for plugins + if (($plugin_tree = ComponentbuilderHelper::getGithubRepoFileList('boilerplate_plugins', $url)) !== false) + { + // get the app object + $app = Factory::getApplication(); + // set the table names + $tables = array(); + $tables['e'] = 'class_extends'; + $tables['g'] = 'joomla_plugin_group'; + $tables['m'] = 'class_method'; + $tables['p'] = 'class_property'; + // load the needed models + $models = array(); + $models['e'] = ComponentbuilderHelper::getModel($tables['e']); + $models['g'] = ComponentbuilderHelper::getModel($tables['g']); + $models['p'] = ComponentbuilderHelper::getModel($tables['p']); + $models['m'] = ComponentbuilderHelper::getModel($tables['m']); + // get the needed data of each plugin group + $groups = array_map( + function($tree) use(&$app, &$models, &$tables){ + if (($fooClass = ComponentbuilderHelper::getFileContents(ComponentbuilderHelper::$bolerplatePath . '/plugins/' . $tree->path . '/foo.php')) !== false && StringHelper::check($fooClass)) + { + // extract the boilerplate class extends and check if already set + if (($classExtends = ComponentbuilderHelper::extractBoilerplateClassExtends($fooClass, 'plugins')) !== false && + ($classExtendsID = GetHelper::var('class_extends', $classExtends, 'name', 'id')) === false) + { + // load the extends class name + $class = array('id' => 0, 'published' => 1, 'version' => 1, 'name' => $classExtends); + // extract the boilerplate class header + $class['head'] = ComponentbuilderHelper::extractBoilerplateClassHeader($fooClass, $classExtends, 'plugins'); + // extract the boilerplate class comment + $class['comment'] = ComponentbuilderHelper::extractBoilerplateClassComment($fooClass, $classExtends, 'plugins'); + // set the extension type + $class['extension_type'] = 'plugins'; + // store the class + $this->storePluginBoilerplate($tables['e'], $models['e'], $class, $app); + // work around + $classExtendsID = GetHelper::var('class_extends', $classExtends, 'name', 'id'); + } + // set plugin group if not already set + if (($pluginGroupID = GetHelper::var('joomla_plugin_group', $tree->path, 'name', 'id')) === false) + { + // load the plugin group name + $pluginGroup = array('id' => 0, 'published' => 1, 'version' => 1, 'name' => $tree->path, 'class_extends' => $classExtendsID); + // store the group + $this->storePluginBoilerplate($tables['g'], $models['g'], $pluginGroup, $app); + // work around + $pluginGroupID = GetHelper::var('joomla_plugin_group', $tree->path, 'name', 'id'); + } + // extract the boilerplate class property and methods + if (($classProperiesMethods = ComponentbuilderHelper::extractBoilerplateClassPropertiesMethods($fooClass, $classExtends, 'plugins', $pluginGroupID)) !== false) + { + // create the properties found + if (isset($classProperiesMethods['property']) && UtilitiesArrayHelper::check($classProperiesMethods['property'])) + { + foreach ($classProperiesMethods['property'] as $_property) + { + // force update by default + $this->storePluginBoilerplate($tables['p'], $models['p'], $_property, $app); + } + } + // create the method found (TODO just create for now but we could later add a force update) + if (isset($classProperiesMethods['method']) && UtilitiesArrayHelper::check($classProperiesMethods['method'])) + { + foreach ($classProperiesMethods['method'] as $_method) + { + // force update by default + $this->storePluginBoilerplate($tables['m'], $models['m'], $_method, $app); + } + } + } + } + }, + $plugin_tree + ); + } + } + + /** + * store Plugin Boilerplate + * + * @return boolean true on success + * + */ + protected function storePluginBoilerplate(&$table, &$method, &$boilerplate, &$app) + { + // Sometimes the form needs some posted data, such as for plugins and modules. + $form = $method->getForm($boilerplate, false); + if (!$form) + { + $app->enqueueMessage($method->getError(), 'error'); + return false; + } + // Send an object which can be modified through the plugin event + $objData = (object) $boilerplate; + $app->triggerEvent( + 'onContentNormaliseRequestData', + array('com_componentbuilder.' . $table, $objData, $form) + ); + $boilerplate = (array) $objData; + // Test whether the data is valid. + $validData = $method->validate($form, $boilerplate); + // Check for validation errors. + if ($validData === false) + { + // Get the validation messages. + $errors = $method->getErrors(); + // Push up to three validation messages out to the user. + for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) + { + if ($errors[$i] instanceof \Exception) + { + $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); + } + else + { + $app->enqueueMessage($errors[$i], 'warning'); + } + } + return false; + } + // Attempt to save the data. + if (!$method->save($validData)) + { + $app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_BOILERPLATE_PLUGIN_S_DATA_COULD_NOT_BE_SAVED', $table), 'error'); + return false; + } + return true; + } + + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $class_extends = $this->getUserStateFromRequest($this->context . '.filter.class_extends', 'filter_class_extends'); + if ($formSubmited) + { + $class_extends = $app->input->post->get('class_extends'); + $this->setState('filter.class_extends', $class_extends); + } + + $joomla_plugin_group = $this->getUserStateFromRequest($this->context . '.filter.joomla_plugin_group', 'filter_joomla_plugin_group'); + if ($formSubmited) + { + $joomla_plugin_group = $app->input->post->get('joomla_plugin_group'); + $this->setState('filter.joomla_plugin_group', $joomla_plugin_group); + } + + $system_name = $this->getUserStateFromRequest($this->context . '.filter.system_name', 'filter_system_name'); + if ($formSubmited) + { + $system_name = $app->input->post->get('system_name'); + $this->setState('filter.system_name', $system_name); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('joomla_plugin.access', 'com_componentbuilder.joomla_plugin.' . (int) $item->id) && $user->authorise('joomla_plugin.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_joomla_plugin', 'a')); + + // From the componentbuilder_class_extends table. + $query->select($db->quoteName('g.name','class_extends_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_class_extends', 'g') . ' ON (' . $db->quoteName('a.class_extends') . ' = ' . $db->quoteName('g.id') . ')'); + + // From the componentbuilder_joomla_plugin_group table. + $query->select($db->quoteName('h.name','joomla_plugin_group_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_plugin_group', 'h') . ' ON (' . $db->quoteName('a.joomla_plugin_group') . ' = ' . $db->quoteName('h.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.system_name LIKE '.$search.' OR a.class_extends LIKE '.$search.' OR g.name LIKE '.$search.' OR a.joomla_plugin_group LIKE '.$search.' OR h.name LIKE '.$search.' OR a.description LIKE '.$search.' OR a.name LIKE '.$search.')'); + } + } + + // Filter by Class_extends. + $_class_extends = $this->getState('filter.class_extends'); + if (is_numeric($_class_extends)) + { + if (is_float($_class_extends)) + { + $query->where('a.class_extends = ' . (float) $_class_extends); + } + else + { + $query->where('a.class_extends = ' . (int) $_class_extends); + } + } + elseif (StringHelper::check($_class_extends)) + { + $query->where('a.class_extends = ' . $db->quote($db->escape($_class_extends))); + } + // Filter by Joomla_plugin_group. + $_joomla_plugin_group = $this->getState('filter.joomla_plugin_group'); + if (is_numeric($_joomla_plugin_group)) + { + if (is_float($_joomla_plugin_group)) + { + $query->where('a.joomla_plugin_group = ' . (float) $_joomla_plugin_group); + } + else + { + $query->where('a.joomla_plugin_group = ' . (int) $_joomla_plugin_group); + } + } + elseif (StringHelper::check($_joomla_plugin_group)) + { + $query->where('a.joomla_plugin_group = ' . $db->quote($db->escape($_joomla_plugin_group))); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.class_extends'); + $id .= ':' . $this->getState('filter.joomla_plugin_group'); + $id .= ':' . $this->getState('filter.system_name'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_joomla_plugin')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_joomla_plugin'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Joomla_plugins_files_folders_urlsModel.php b/admin/src/Model/Joomla_plugins_files_folders_urlsModel.php new file mode 100644 index 000000000..cfc9f4fd7 --- /dev/null +++ b/admin/src/Model/Joomla_plugins_files_folders_urlsModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_plugins_files_folders_urls List Model + * + * @since 1.6 + */ +class Joomla_plugins_files_folders_urlsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/joomla_plugins_files_folders_urls.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('joomla_plugin_files_folders_urls.access', 'com_componentbuilder.joomla_plugin_files_folders_urls.' . (int) $item->id) && $user->authorise('joomla_plugin_files_folders_urls.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_joomla_plugin_files_folders_urls', 'a')); + + // From the componentbuilder_joomla_plugin table. + $query->select($db->quoteName('g.system_name','joomla_plugin_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_plugin', 'g') . ' ON (' . $db->quoteName('a.joomla_plugin') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_joomla_plugin_files_folders_urls')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_joomla_plugin_files_folders_urls'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Joomla_plugins_updatesModel.php b/admin/src/Model/Joomla_plugins_updatesModel.php new file mode 100644 index 000000000..9ec74874e --- /dev/null +++ b/admin/src/Model/Joomla_plugins_updatesModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_plugins_updates List Model + * + * @since 1.6 + */ +class Joomla_plugins_updatesModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/joomla_plugins_updates.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('joomla_plugin_updates.access', 'com_componentbuilder.joomla_plugin_updates.' . (int) $item->id) && $user->authorise('joomla_plugin_updates.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_joomla_plugin_updates', 'a')); + + // From the componentbuilder_joomla_plugin table. + $query->select($db->quoteName('g.system_name','joomla_plugin_system_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_plugin', 'g') . ' ON (' . $db->quoteName('a.joomla_plugin') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_joomla_plugin_updates')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_joomla_plugin_updates'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/LanguageModel.php b/admin/src/Model/LanguageModel.php new file mode 100644 index 000000000..ec0d65001 --- /dev/null +++ b/admin/src/Model/LanguageModel.php @@ -0,0 +1,931 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Language Admin Model + * + * @since 1.6 + */ +class LanguageModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'name' + ), + 'right' => array( + 'langtag' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/language.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/language.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.language'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'language', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.language', 'language', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('language.edit.state', 'com_componentbuilder.language.' . (int) $id)) + || ($id == 0 && !$user->authorise('language.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if (!$user->authorise('core.edit.created_by', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if (!$user->authorise('core.edit.created', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('language.delete', 'com_componentbuilder.language.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('language.edit.state', 'com_componentbuilder.language.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('language.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('language.edit', 'com_componentbuilder.language.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('language.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_language')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.language.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.language', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('language'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('language'); + } + + if (!$this->canDo->get('language.create') && !$this->canDo->get('language.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('language.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('language.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->name) && !is_numeric($this->table->name)) + { + $this->table->name = $this->generateUnique('name',$this->table->name); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('language'); + } + + if (!$this->canDo->get('language.edit') && !$this->canDo->get('language.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('language.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('language.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Language_translationModel.php b/admin/src/Model/Language_translationModel.php new file mode 100644 index 000000000..2b2b33c40 --- /dev/null +++ b/admin/src/Model/Language_translationModel.php @@ -0,0 +1,1071 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Language_translation Admin Model + * + * @since 1.6 + */ +class Language_translationModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'details' => array( + 'fullwidth' => array( + 'source', + 'translation', + 'components', + 'modules', + 'plugins' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/language_translation.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/language_translation.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.language_translation'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'language_translation', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('language_translation__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'language_translation__'.$id); + ComponentbuilderHelper::set('language_translation__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->translation)) + { + // Convert the translation field to an array. + $translation = new Registry; + $translation->loadString($item->translation); + $item->translation = $translation->toArray(); + } + + if (!empty($item->plugins)) + { + // JSON Decode plugins. + $item->plugins = json_decode($item->plugins); + } + + if (!empty($item->modules)) + { + // JSON Decode modules. + $item->modules = json_decode($item->modules); + } + + if (!empty($item->components)) + { + // JSON Decode components. + $item->components = json_decode($item->components); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('language_translation__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'language_translation__'.$id); + ComponentbuilderHelper::set('language_translation__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.language_translation', 'language_translation', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('language_translation.edit.state', 'com_componentbuilder.language_translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('language_translation.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if (!$user->authorise('core.edit.created_by', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if (!$user->authorise('core.edit.created', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('language_translation.delete', 'com_componentbuilder.language_translation.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('language_translation.edit.state', 'com_componentbuilder.language_translation.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('language_translation.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('language_translation.edit', 'com_componentbuilder.language_translation.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('language_translation.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_language_translation')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.language_translation.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.language_translation', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('language_translation'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('language_translation'); + } + + if (!$this->canDo->get('language_translation.create') && !$this->canDo->get('language_translation.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('language_translation.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('language_translation.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->source) && !is_numeric($this->table->source)) + { + $this->table->source = $this->generateUnique('source',$this->table->source); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('language_translation'); + } + + if (!$this->canDo->get('language_translation.edit') && !$this->canDo->get('language_translation.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('language_translation.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('language_translation.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the translation items to data. + if (isset($data['translation']) && is_array($data['translation'])) + { + $translation = new Registry; + $translation->loadArray($data['translation']); + $data['translation'] = (string) $translation; + } + elseif (!isset($data['translation'])) + { + // Set the empty translation to data + $data['translation'] = ''; + } + + // Set the plugins string to JSON string. + if (isset($data['plugins'])) + { + $data['plugins'] = (string) json_encode($data['plugins']); + } + + // Set the modules string to JSON string. + if (isset($data['modules'])) + { + $data['modules'] = (string) json_encode($data['modules']); + } + + // Set the components string to JSON string. + if (isset($data['components'])) + { + $data['components'] = (string) json_encode($data['components']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Language_translationsModel.php b/admin/src/Model/Language_translationsModel.php new file mode 100644 index 000000000..3fa452160 --- /dev/null +++ b/admin/src/Model/Language_translationsModel.php @@ -0,0 +1,824 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\FormHelper as JCBFormHelper; +use VDM\Joomla\Componentbuilder\Utilities\FilterHelper as JCBFilterHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\JsonHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Language_translations List Model + * + * @since 1.6 + */ +class Language_translationsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/language_translations.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.source','source' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Get the filter form - Override the parent method + * + * @param array $data data + * @param boolean $loadData load current data + * + * @return \JForm|boolean The \JForm object or false on error + * + * @since JCB 2.12.5 + */ + public function getFilterForm($data = array(), $loadData = true) + { + // load form from the parent class + $form = parent::getFilterForm($data, $loadData); + + // Create the "extension" filter + $form->setField(new \SimpleXMLElement( + JCBFilterHelper::extensions() + ),'filter'); + $form->setValue( + 'extension', + 'filter', + $this->state->get("filter.extension") + ); + array_push($this->filter_fields, 'extension'); + + // Create the "translated in" filter + $attributes = array( + 'name' => 'translated', + 'type' => 'list', + 'onchange' => 'this.form.submit();', + ); + // no languages found notice + $options = array( + '' => '- ' . Text::_('COM_COMPONENTBUILDER_NO_LANGUAGES_FOUND') . ' -' + ); + // check if we have languages set + if (($languages = JCBFilterHelper::languages()) !== null) + { + $options = array( + '' => '- ' . Text::_('COM_COMPONENTBUILDER_TRANSLATED_IN') . ' -', + 'all' => Text::_('COM_COMPONENTBUILDER_EVERY_LANGUAGE') + ); + + $options = array_merge($options, $languages); + } + + $form->setField(JCBFormHelper::xml($attributes, $options),'filter'); + $form->setValue( + 'translated', + 'filter', + $this->state->get("filter.translated") + ); + array_push($this->filter_fields, 'translated'); + + // Create the "not translated in" filter + $attributes = array( + 'name' => 'not_translated', + 'type' => 'list', + 'onchange' => 'this.form.submit();', + ); + // no languages found notice + $options = array( + '' => '- ' . Text::_('COM_COMPONENTBUILDER_NO_LANGUAGES_FOUND') . ' -' + ); + // check if we have languages set + if ($languages) + { + $options = array( + '' => '- ' . Text::_('COM_COMPONENTBUILDER_NOT_TRANSLATED_IN') . ' -', + 'none' => Text::_('COM_COMPONENTBUILDER_ANY_LANGUAGE') + ); + + $options = array_merge($options, $languages); + } + + $form->setField(JCBFormHelper::xml($attributes, $options),'filter'); + $form->setValue( + 'not_translated', + 'filter', + $this->state->get("filter.not_translated") + ); + array_push($this->filter_fields, 'not_translated'); + + return $form; + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $source = $this->getUserStateFromRequest($this->context . '.filter.source', 'filter_source'); + if ($formSubmited) + { + $source = $app->input->post->get('source'); + $this->setState('filter.source', $source); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('language_translation.access', 'com_componentbuilder.language_translation.' . (int) $item->id) && $user->authorise('language_translation.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // escape all strings if not being exported + if (!isset($_export)) + { + $item->source = StringHelper::html($item->source, 'UTF-8', true, 150); + } + } + } + // prep the lang strings for export + if (isset($_export) && $_export && UtilitiesArrayHelper::check($items)) + { + // insure we have the same order in the languages + $languages = ComponentbuilderHelper::getVars('language', 1, 'published', 'langtag'); + foreach ($items as $nr => &$item) + { + // remove some values completely + unset($item->components); + unset($item->modules); + unset($item->plugins); + unset($item->params); + unset($item->published); + unset($item->created_by); + unset($item->modified_by); + unset($item->created); + unset($item->modified); + unset($item->version); + unset($item->hits); + unset($item->access); + unset($item->ordering); + // set the lang order + if ($nr != 0) + { + foreach ($languages as $lanTag) + { + $item->{$lanTag} = ''; + } + // now adapt the source + if (isset($item->translation) && JsonHelper::check($item->translation)) + { + $translations = json_decode($item->translation, true); + if (UtilitiesArrayHelper::check($translations)) + { + foreach ($translations as $language) + { + if (isset($language['translation']) && StringHelper::check($language['translation']) + && isset($language['language']) && StringHelper::check($language['language'])) + { + $item->{$language['language']} = $language['translation']; + } + } + } + } + } + // remove translation + unset($item->translation); + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_language_translation', 'a')); + + // do not use these filters in the export method + if (!isset($_export) || !$_export) + { + // Filtering "translated in" + $filter_translated = $this->state->get("filter.translated"); + if ($filter_translated !== null && !empty($filter_translated)) + { + if (($ids = JCBFilterHelper::translations($filter_translated)) !== null) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')'); + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + } + } + + // Filtering "not translated in" + $filter_not_translated = $this->state->get("filter.not_translated"); + if ($filter_not_translated !== null && !empty($filter_not_translated)) + { + if (($ids = JCBFilterHelper::translations($filter_not_translated, false)) !== null) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',',$ids) . ')'); + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + } + } + + // Filtering "extension" + $filter_extension = $this->state->get("filter.extension"); + if ($filter_extension !== null && !empty($filter_extension)) + { + // column name, and id + $type_extension = explode('__', $filter_extension); + if (($ids = JCBFilterHelper::translation((int) $type_extension[1], $type_extension[0])) !== null) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')'); + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + } + } + } + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.source LIKE '.$search.' OR a.translation LIKE '.$search.')'); + } + } + + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get list export data. + * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExportData($pks, $user = null) + { + // setup the query + if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks) + { + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + $_export = true; + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_language_translation table + $query->from($db->quoteName('#__componentbuilder_language_translation', 'a')); + // The bulk export path + if ('bulk' === $pks) + { + $query->where('a.id > 0'); + } + // A large array of ID's will not work out well + elseif ($pks_size > 500) + { + // Use lowest ID + $query->where('a.id >= ' . (int) min($pks)); + // Use highest ID + $query->where('a.id <= ' . (int) max($pks)); + } + // The normal default path + else + { + $query->where('a.id IN (' . implode(',',$pks) . ')'); + } + + // do not use these filters in the export method + if (!isset($_export) || !$_export) + { + // Filtering "translated in" + $filter_translated = $this->state->get("filter.translated"); + if ($filter_translated !== null && !empty($filter_translated)) + { + if (($ids = JCBFilterHelper::translations($filter_translated)) !== null) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')'); + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + } + } + + // Filtering "not translated in" + $filter_not_translated = $this->state->get("filter.not_translated"); + if ($filter_not_translated !== null && !empty($filter_not_translated)) + { + if (($ids = JCBFilterHelper::translations($filter_not_translated, false)) !== null) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',',$ids) . ')'); + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + } + } + + // Filtering "extension" + $filter_extension = $this->state->get("filter.extension"); + if ($filter_extension !== null && !empty($filter_extension)) + { + // column name, and id + $type_extension = explode('__', $filter_extension); + if (($ids = JCBFilterHelper::translation((int) $type_extension[1], $type_extension[0])) !== null) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')'); + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + } + } + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.ordering ASC'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('language_translation.access', 'com_componentbuilder.language_translation.' . (int) $item->id) && $user->authorise('language_translation.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // escape all strings if not being exported + if (!isset($_export)) + { + $item->source = StringHelper::html($item->source, 'UTF-8', true, 150); + } + // unset the values we don't want exported. + unset($item->asset_id); + unset($item->checked_out); + unset($item->checked_out_time); + } + } + // Add headers to items array. + $headers = $this->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + array_unshift($items,$headers); + } + + // prep the lang strings for export + if (isset($_export) && $_export && UtilitiesArrayHelper::check($items)) + { + // insure we have the same order in the languages + $languages = ComponentbuilderHelper::getVars('language', 1, 'published', 'langtag'); + foreach ($items as $nr => &$item) + { + // remove some values completely + unset($item->components); + unset($item->modules); + unset($item->plugins); + unset($item->params); + unset($item->published); + unset($item->created_by); + unset($item->modified_by); + unset($item->created); + unset($item->modified); + unset($item->version); + unset($item->hits); + unset($item->access); + unset($item->ordering); + // set the lang order + if ($nr != 0) + { + foreach ($languages as $lanTag) + { + $item->{$lanTag} = ''; + } + // now adapt the source + if (isset($item->translation) && JsonHelper::check($item->translation)) + { + $translations = json_decode($item->translation, true); + if (UtilitiesArrayHelper::check($translations)) + { + foreach ($translations as $language) + { + if (isset($language['translation']) && StringHelper::check($language['translation']) + && isset($language['language']) && StringHelper::check($language['language'])) + { + $item->{$language['language']} = $language['translation']; + } + } + } + } + } + // remove translation + unset($item->translation); + } + } + return $items; + } + } + return false; + } + + /** + * Method to get header. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExImPortHeaders() + { + $languages = ComponentbuilderHelper::getVars('language', 1, 'published', 'langtag'); + // start setup of headers + $headers = new \stdClass(); + $headers->id = 'id'; + $headers->Source = 'Source'; + // add the languages + if (UtilitiesArrayHelper::check($languages)) + { + foreach ($languages as $language) + { + $headers->{$language} = $language; + } + } + return $headers; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.source'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_language_translation')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_language_translation'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/LanguagesModel.php b/admin/src/Model/LanguagesModel.php new file mode 100644 index 000000000..e3b1c2b04 --- /dev/null +++ b/admin/src/Model/LanguagesModel.php @@ -0,0 +1,660 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Languages List Model + * + * @since 1.6 + */ +class LanguagesModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/languages.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.name','name', + 'a.langtag','langtag' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Load all the languages found in Joomla into JCB + * + * @since 2.7.5 + * + * @return bool true on success + */ + public function buildLanguages() + { + if ($languages = $this->getLanguages()) + { + // make sure we have an array + if (UtilitiesArrayHelper::check($languages)) + { + // get the model + $model = ComponentbuilderHelper::getModel('language'); + foreach ($languages as $language) + { + // only load it is a package + if ('package' === $language->type) + { + // build array to store/update + $tmp = array(); + $tmp['id'] = 0; + $tmp['name'] = (string) $language->name; + $tmp['langtag'] = (string) str_replace('pkg_', '', $language->element); + // check if already set + if ($id = GetHelper::var('language', $tmp['langtag'], 'langtag', 'id')) + { + $tmp['id'] = (int) $id; + } + // save update the language in the database + $model->save($tmp); + } + } + return true; + } + } + return false; + } + + /** + * Gets an array of objects from the updatesite. + * + * @return object[] An array of results. + * + * @since 2.7.5 + * @throws RuntimeException + */ + protected function getLanguages() + { + $updateSite = $this->getUpdateSite(); + + $http = new JHttp; + + try + { + $response = $http->get($updateSite); + } + catch (RuntimeException $e) + { + $response = null; + } + + if ($response === null || $response->code !== 200) + { + Factory::getApplication()->enqueueMessage(Text::_('COM_COMPONENTBUILDER_NO_LANGUAGES_UPDATE_SERVER_FOUND'), 'warning'); + + return; + } + + $updateSiteXML = simplexml_load_string($response->body); + $languages = array(); + + foreach ($updateSiteXML->extension as $extension) + { + $language = new \stdClass; + + foreach ($extension->attributes() as $key => $value) + { + $language->$key = (string) $value; + } + + $languages[$language->name] = $language; + } + + // we must add the British language en-GB (since Joomla Ships with it) + $language = new \stdClass; + $language->name = 'English GB'; + $language->element = 'pkg_en-GB'; + $language->type = 'package'; + $languages[$language->name] = $language; + + usort($languages, function($a, $b) + { + return strcmp($a->name, $b->name); + }); + + return $languages; + } + + /** + * Get the Update Site + * + * @since 2.7.5 + * + * @return string The URL of the Accredited Languagepack Updatesite XML + */ + private function getUpdateSite() + { + $db = $this->getDbo(); + $query = $db->getQuery(true) + ->select($db->qn('us.location')) + ->from($db->qn('#__extensions', 'e')) + ->where($db->qn('e.type') . ' = ' . $db->q('package')) + ->where($db->qn('e.element') . ' = ' . $db->q('pkg_en-GB')) + ->where($db->qn('e.client_id') . ' = 0') + ->join('LEFT', $db->qn('#__update_sites_extensions', 'use') . ' ON ' . $db->qn('use.extension_id') . ' = ' . $db->qn('e.extension_id')) + ->join('LEFT', $db->qn('#__update_sites', 'us') . ' ON ' . $db->qn('us.update_site_id') . ' = ' . $db->qn('use.update_site_id')); + + return $db->setQuery($query)->loadResult(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + $langtag = $this->getUserStateFromRequest($this->context . '.filter.langtag', 'filter_langtag'); + if ($formSubmited) + { + $langtag = $app->input->post->get('langtag'); + $this->setState('filter.langtag', $langtag); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('language.access', 'com_componentbuilder.language.' . (int) $item->id) && $user->authorise('language.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_language', 'a')); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.' OR a.langtag LIKE '.$search.')'); + } + } + + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get list export data. + * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExportData($pks, $user = null) + { + // setup the query + if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks) + { + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + $_export = true; + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_language table + $query->from($db->quoteName('#__componentbuilder_language', 'a')); + // The bulk export path + if ('bulk' === $pks) + { + $query->where('a.id > 0'); + } + // A large array of ID's will not work out well + elseif ($pks_size > 500) + { + // Use lowest ID + $query->where('a.id >= ' . (int) min($pks)); + // Use highest ID + $query->where('a.id <= ' . (int) max($pks)); + } + // The normal default path + else + { + $query->where('a.id IN (' . implode(',',$pks) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.ordering ASC'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('language.access', 'com_componentbuilder.language.' . (int) $item->id) && $user->authorise('language.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // unset the values we don't want exported. + unset($item->asset_id); + unset($item->checked_out); + unset($item->checked_out_time); + } + } + // Add headers to items array. + $headers = $this->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + array_unshift($items,$headers); + } + return $items; + } + } + 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 = Factory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_language"); + if (UtilitiesArrayHelper::check($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; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.name'); + $id .= ':' . $this->getState('filter.langtag'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_language')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_language'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/LayoutModel.php b/admin/src/Model/LayoutModel.php new file mode 100644 index 000000000..0806e78a9 --- /dev/null +++ b/admin/src/Model/LayoutModel.php @@ -0,0 +1,1174 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Layout Admin Model + * + * @since 1.6 + */ +class LayoutModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'name', + 'alias', + 'description', + 'note_libraries_selection', + 'libraries', + 'note_add_php_language_string' + ), + 'right' => array( + 'snippet', + 'note_uikit_snippet', + 'note_snippet_usage' + ), + 'fullwidth' => array( + 'layout' + ), + 'under' => array( + 'not_required' + ), + 'rightside' => array( + 'dynamic_get', + 'dynamic_values' + ) + ), + 'custom_script' => array( + 'fullwidth' => array( + 'add_php_view', + 'php_view' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/layout.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/layout.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.layout'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'layout', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('layout__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'layout__'.$id); + ComponentbuilderHelper::set('layout__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->php_view)) + { + // base64 Decode php_view. + $item->php_view = base64_decode($item->php_view); + } + + if (!empty($item->layout)) + { + // base64 Decode layout. + $item->layout = base64_decode($item->layout); + } + + if (!empty($item->libraries)) + { + // Convert the libraries field to an array. + $libraries = new Registry; + $libraries->loadString($item->libraries); + $item->libraries = $libraries->toArray(); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('layout__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'layout__'.$id); + ComponentbuilderHelper::set('layout__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.layout', 'layout', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('core.edit.state', 'com_componentbuilder.layout.' . (int) $id)) + || ($id == 0 && !$user->authorise('core.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if (!$user->authorise('core.edit.created_by', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if (!$user->authorise('core.edit.created', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update all editors to use this components global editor + $global_editor = ComponentHelper::getParams('com_componentbuilder')->get('editor', 'none'); + // now get all the editor fields + $editors = $form->getXml()->xpath("//field[@type='editor']"); + // check if we found any + if (UtilitiesArrayHelper::check($editors)) + { + foreach ($editors as $editor) + { + // get the field names + $name = (string) $editor['name']; + // set the field editor value (with none as fallback) + $form->setFieldAttribute($name, 'editor', $global_editor . '|none'); + } + } + + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('core.delete', 'com_componentbuilder.layout.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('core.edit.state', 'com_componentbuilder.layout.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return parent::canEditState($record); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('core.edit', 'com_componentbuilder.layout.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('core.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_layout')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.layout.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.layout', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('layout'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('layout'); + } + + if (!$this->canDo->get('core.create') && !$this->canDo->get('layout.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('core.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('core.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + list($this->table->name, $this->table->alias) = $this->_generateNewTitle($this->table->alias, $this->table->name); + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('layout'); + } + + if (!$this->canDo->get('core.edit') && !$this->canDo->get('layout.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('core.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('core.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // always reset the snippets + $data['snippet'] = 0; + + // Set the libraries items to data. + if (isset($data['libraries']) && is_array($data['libraries'])) + { + $libraries = new Registry; + $libraries->loadArray($data['libraries']); + $data['libraries'] = (string) $libraries; + } + elseif (!isset($data['libraries'])) + { + // Set the empty libraries to data + $data['libraries'] = ''; + } + + // Set the php_view string to base64 string. + if (isset($data['php_view'])) + { + $data['php_view'] = base64_encode($data['php_view']); + } + + // Set the layout string to base64 string. + if (isset($data['layout'])) + { + $data['layout'] = base64_encode($data['layout']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the name for save as copy + if ($input->get('task') === 'save2copy') + { + $origTable = clone $this->getTable(); + $origTable->load($input->getInt('id')); + + if ($data['name'] == $origTable->name) + { + list($name, $alias) = $this->_generateNewTitle($data['alias'], $data['name']); + $data['name'] = $name; + $data['alias'] = $alias; + } + else + { + if ($data['alias'] == $origTable->alias) + { + $data['alias'] = ''; + } + } + + $data['published'] = 0; + } + + // Automatic handling of alias for empty fields + if (in_array($input->get('task'), array('apply', 'save', 'save2new')) && (int) $input->get('id') == 0) + { + if ($data['alias'] == null || empty($data['alias'])) + { + if (Factory::getConfig()->get('unicodeslugs') == 1) + { + $data['alias'] = OutputFilter::stringURLUnicodeSlug($data['name']); + } + else + { + $data['alias'] = OutputFilter::stringURLSafe($data['name']); + } + + $table = clone $this->getTable(); + + if ($table->load(array('alias' => $data['alias'])) && ($table->id != $data['id'] || $data['id'] == 0)) + { + $msg = Text::_('COM_COMPONENTBUILDER_LAYOUT_SAVE_WARNING'); + } + + $data['alias'] = $this->_generateNewTitle($data['alias']); + + if (isset($msg)) + { + Factory::getApplication()->enqueueMessage($msg, 'warning'); + } + } + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title/s & alias. + * + * @param string $alias The alias. + * @param string/array $title The title. + * + * @return array/string Contains the modified title/s and/or alias. + * + */ + protected function _generateNewTitle($alias, $title = null) + { + + // Alter the title/s & alias + $table = $this->getTable(); + + while ($table->load(['alias' => $alias])) + { + // Check if this is an array of titles + if (UtilitiesArrayHelper::check($title)) + { + foreach($title as $nr => &$_title) + { + $_title = StringHelper::increment($_title); + } + } + // Make sure we have a title + elseif ($title) + { + $title = StringHelper::increment($title); + } + $alias = StringHelper::increment($alias, 'dash'); + } + // Check if this is an array of titles + if (UtilitiesArrayHelper::check($title)) + { + $title[] = $alias; + return $title; + } + // Make sure we have a title + elseif ($title) + { + return array($title, $alias); + } + // We only had an alias + return $alias; + } +} diff --git a/admin/src/Model/LayoutsModel.php b/admin/src/Model/LayoutsModel.php new file mode 100644 index 000000000..811dfa15e --- /dev/null +++ b/admin/src/Model/LayoutsModel.php @@ -0,0 +1,630 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Layouts List Model + * + * @since 1.6 + */ +class LayoutsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/layouts.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'g.name','dynamic_get', + 'a.add_php_view','add_php_view', + 'a.name','name', + 'a.description','description' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $dynamic_get = $this->getUserStateFromRequest($this->context . '.filter.dynamic_get', 'filter_dynamic_get'); + if ($formSubmited) + { + $dynamic_get = $app->input->post->get('dynamic_get'); + $this->setState('filter.dynamic_get', $dynamic_get); + } + + $add_php_view = $this->getUserStateFromRequest($this->context . '.filter.add_php_view', 'filter_add_php_view'); + if ($formSubmited) + { + $add_php_view = $app->input->post->get('add_php_view'); + $this->setState('filter.add_php_view', $add_php_view); + } + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + $description = $this->getUserStateFromRequest($this->context . '.filter.description', 'filter_description'); + if ($formSubmited) + { + $description = $app->input->post->get('description'); + $this->setState('filter.description', $description); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('layout.access', 'com_componentbuilder.layout.' . (int) $item->id) && $user->authorise('layout.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // set selection value to a translatable value + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // convert add_php_view + $item->add_php_view = $this->selectionTranslation($item->add_php_view, 'add_php_view'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return string The translatable string. + */ + public function selectionTranslation($value,$name) + { + // Array of add_php_view language strings + if ($name === 'add_php_view') + { + $add_php_viewArray = array( + 1 => 'COM_COMPONENTBUILDER_LAYOUT_YES', + 0 => 'COM_COMPONENTBUILDER_LAYOUT_NO' + ); + // Now check if value is found in this array + if (isset($add_php_viewArray[$value]) && StringHelper::check($add_php_viewArray[$value])) + { + return $add_php_viewArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_layout', 'a')); + + // From the componentbuilder_dynamic_get table. + $query->select($db->quoteName('g.name','dynamic_get_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_dynamic_get', 'g') . ' ON (' . $db->quoteName('a.dynamic_get') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.' OR a.description LIKE '.$search.' OR a.dynamic_get LIKE '.$search.' OR g.name LIKE '.$search.' OR a.alias LIKE '.$search.')'); + } + } + + // Filter by Dynamic_get. + $_dynamic_get = $this->getState('filter.dynamic_get'); + if (is_numeric($_dynamic_get)) + { + if (is_float($_dynamic_get)) + { + $query->where('a.dynamic_get = ' . (float) $_dynamic_get); + } + else + { + $query->where('a.dynamic_get = ' . (int) $_dynamic_get); + } + } + elseif (StringHelper::check($_dynamic_get)) + { + $query->where('a.dynamic_get = ' . $db->quote($db->escape($_dynamic_get))); + } + // Filter by Add_php_view. + $_add_php_view = $this->getState('filter.add_php_view'); + if (is_numeric($_add_php_view)) + { + if (is_float($_add_php_view)) + { + $query->where('a.add_php_view = ' . (float) $_add_php_view); + } + else + { + $query->where('a.add_php_view = ' . (int) $_add_php_view); + } + } + elseif (StringHelper::check($_add_php_view)) + { + $query->where('a.add_php_view = ' . $db->quote($db->escape($_add_php_view))); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get list export data. + * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExportData($pks, $user = null) + { + // setup the query + if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks) + { + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + $_export = true; + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_layout table + $query->from($db->quoteName('#__componentbuilder_layout', 'a')); + // The bulk export path + if ('bulk' === $pks) + { + $query->where('a.id > 0'); + } + // A large array of ID's will not work out well + elseif ($pks_size > 500) + { + // Use lowest ID + $query->where('a.id >= ' . (int) min($pks)); + // Use highest ID + $query->where('a.id <= ' . (int) max($pks)); + } + // The normal default path + else + { + $query->where('a.id IN (' . implode(',',$pks) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.id desc'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('layout.access', 'com_componentbuilder.layout.' . (int) $item->id) && $user->authorise('layout.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // decode php_view + $item->php_view = base64_decode($item->php_view); + // decode layout + $item->layout = base64_decode($item->layout); + // unset the values we don't want exported. + unset($item->asset_id); + unset($item->checked_out); + unset($item->checked_out_time); + } + } + // Add headers to items array. + $headers = $this->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + array_unshift($items,$headers); + } + return $items; + } + } + 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 = Factory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_layout"); + if (UtilitiesArrayHelper::check($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; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.dynamic_get'); + $id .= ':' . $this->getState('filter.add_php_view'); + $id .= ':' . $this->getState('filter.name'); + $id .= ':' . $this->getState('filter.description'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_layout')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_layout'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/LibrariesModel.php b/admin/src/Model/LibrariesModel.php new file mode 100644 index 000000000..b950b178b --- /dev/null +++ b/admin/src/Model/LibrariesModel.php @@ -0,0 +1,541 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Libraries List Model + * + * @since 1.6 + */ +class LibrariesModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/libraries.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.target','target', + 'a.how','how', + 'a.type','type', + 'a.name','name', + 'a.description','description' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $target = $this->getUserStateFromRequest($this->context . '.filter.target', 'filter_target'); + if ($formSubmited) + { + $target = $app->input->post->get('target'); + $this->setState('filter.target', $target); + } + + $how = $this->getUserStateFromRequest($this->context . '.filter.how', 'filter_how'); + if ($formSubmited) + { + $how = $app->input->post->get('how'); + $this->setState('filter.how', $how); + } + + $type = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type'); + if ($formSubmited) + { + $type = $app->input->post->get('type'); + $this->setState('filter.type', $type); + } + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + $description = $this->getUserStateFromRequest($this->context . '.filter.description', 'filter_description'); + if ($formSubmited) + { + $description = $app->input->post->get('description'); + $this->setState('filter.description', $description); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('library.access', 'com_componentbuilder.library.' . (int) $item->id) && $user->authorise('library.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // set selection value to a translatable value + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // convert target + $item->target = $this->selectionTranslation($item->target, 'target'); + // convert type + $item->type = $this->selectionTranslation($item->type, 'type'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return string The translatable string. + */ + public function selectionTranslation($value,$name) + { + // Array of target language strings + if ($name === 'target') + { + $targetArray = array( + 1 => 'COM_COMPONENTBUILDER_LIBRARY_MEDIA', + 2 => 'COM_COMPONENTBUILDER_LIBRARY_LIBRARIES' + ); + // Now check if value is found in this array + if (isset($targetArray[$value]) && StringHelper::check($targetArray[$value])) + { + return $targetArray[$value]; + } + } + // Array of type language strings + if ($name === 'type') + { + $typeArray = array( + 1 => 'COM_COMPONENTBUILDER_LIBRARY_MAIN', + 2 => 'COM_COMPONENTBUILDER_LIBRARY_BUNDLE' + ); + // Now check if value is found in this array + if (isset($typeArray[$value]) && StringHelper::check($typeArray[$value])) + { + return $typeArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_library', 'a')); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.' OR a.description LIKE '.$search.')'); + } + } + + // Filter by Target. + $_target = $this->getState('filter.target'); + if (is_numeric($_target)) + { + if (is_float($_target)) + { + $query->where('a.target = ' . (float) $_target); + } + else + { + $query->where('a.target = ' . (int) $_target); + } + } + elseif (StringHelper::check($_target)) + { + $query->where('a.target = ' . $db->quote($db->escape($_target))); + } + // Filter by How. + $_how = $this->getState('filter.how'); + if (is_numeric($_how)) + { + if (is_float($_how)) + { + $query->where('a.how = ' . (float) $_how); + } + else + { + $query->where('a.how = ' . (int) $_how); + } + } + elseif (StringHelper::check($_how)) + { + $query->where('a.how = ' . $db->quote($db->escape($_how))); + } + // Filter by Type. + $_type = $this->getState('filter.type'); + if (is_numeric($_type)) + { + if (is_float($_type)) + { + $query->where('a.type = ' . (float) $_type); + } + else + { + $query->where('a.type = ' . (int) $_type); + } + } + elseif (StringHelper::check($_type)) + { + $query->where('a.type = ' . $db->quote($db->escape($_type))); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.target'); + $id .= ':' . $this->getState('filter.how'); + $id .= ':' . $this->getState('filter.type'); + $id .= ':' . $this->getState('filter.name'); + $id .= ':' . $this->getState('filter.description'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_library')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_library'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Libraries_configModel.php b/admin/src/Model/Libraries_configModel.php new file mode 100644 index 000000000..c9f4e11c4 --- /dev/null +++ b/admin/src/Model/Libraries_configModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Libraries_config List Model + * + * @since 1.6 + */ +class Libraries_configModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/libraries_config.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('library_config.access', 'com_componentbuilder.library_config.' . (int) $item->id) && $user->authorise('library_config.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_library_config', 'a')); + + // From the componentbuilder_library table. + $query->select($db->quoteName('g.name','library_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_library', 'g') . ' ON (' . $db->quoteName('a.library') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_library_config')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_library_config'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Libraries_files_folders_urlsModel.php b/admin/src/Model/Libraries_files_folders_urlsModel.php new file mode 100644 index 000000000..d901e93e5 --- /dev/null +++ b/admin/src/Model/Libraries_files_folders_urlsModel.php @@ -0,0 +1,385 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Libraries_files_folders_urls List Model + * + * @since 1.6 + */ +class Libraries_files_folders_urlsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/libraries_files_folders_urls.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('library_files_folders_urls.access', 'com_componentbuilder.library_files_folders_urls.' . (int) $item->id) && $user->authorise('library_files_folders_urls.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_library_files_folders_urls', 'a')); + + // From the componentbuilder_library table. + $query->select($db->quoteName('g.name','library_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_library', 'g') . ' ON (' . $db->quoteName('a.library') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_library_files_folders_urls')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_library_files_folders_urls'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/LibraryModel.php b/admin/src/Model/LibraryModel.php new file mode 100644 index 000000000..abfa27bb1 --- /dev/null +++ b/admin/src/Model/LibraryModel.php @@ -0,0 +1,1246 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Library Admin Model + * + * @since 1.6 + */ +class LibraryModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'behaviour' => array( + 'left' => array( + 'note_library_instruction', + 'libraries' + ), + 'right' => array( + 'description' + ), + 'fullwidth' => array( + 'note_no_behaviour_one', + 'note_yes_behaviour_one', + 'note_build_in_behaviour_one', + 'note_yes_behaviour_library', + 'addconditions', + 'php_setdocument' + ), + 'above' => array( + 'name', + 'target', + 'how', + 'type' + ), + 'under' => array( + 'not_required' + ) + ), + 'config' => array( + 'fullwidth' => array( + 'note_no_behaviour_two', + 'note_yes_behaviour_two', + 'note_build_in_behaviour_two', + 'note_display_library_config' + ) + ), + 'files_folders_urls' => array( + 'fullwidth' => array( + 'note_no_behaviour_three', + 'note_build_in_behaviour_three', + 'note_display_library_files_folders_urls' + ) + ), + 'linked' => array( + 'fullwidth' => array( + 'note_linked_to_notice' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/library.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/library.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.library'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'library', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('library__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'library__'.$id); + ComponentbuilderHelper::set('library__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->php_setdocument)) + { + // base64 Decode php_setdocument. + $item->php_setdocument = base64_decode($item->php_setdocument); + } + + if (!empty($item->libraries)) + { + // Convert the libraries field to an array. + $libraries = new Registry; + $libraries->loadString($item->libraries); + $item->libraries = $libraries->toArray(); + } + + if (!empty($item->addconditions)) + { + // Convert the addconditions field to an array. + $addconditions = new Registry; + $addconditions->loadString($item->addconditions); + $item->addconditions = $addconditions->toArray(); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('library__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'library__'.$id); + ComponentbuilderHelper::set('library__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.library', 'library', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('library.edit.state', 'com_componentbuilder.library.' . (int) $id)) + || ($id == 0 && !$user->authorise('library.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if (!$user->authorise('core.edit.created_by', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if (!$user->authorise('core.edit.created', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // Only load the GUID if new item (or empty) + if (0 == $id || !($val = $form->getValue('guid'))) + { + $form->setValue('guid', null, GuidHelper::get()); + } + + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('library.delete', 'com_componentbuilder.library.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('library.edit.state', 'com_componentbuilder.library.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('library.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('library.edit', 'com_componentbuilder.library.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('library.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_library')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.library.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.library', $data); + + return $data; + } + + /** + * Method to validate the form data. + * + * @param JForm $form The form to validate against. + * @param array $data The data to validate. + * @param string $group The name of the field group to validate. + * + * @return mixed Array of filtered data if valid, false otherwise. + * + * @see JFormRule + * @see JFilterInput + * @since 12.2 + */ + public function validate($form, $data, $group = null) + { + // check if the not_required field is set + if (isset($data['not_required']) && UtilitiesStringHelper::check($data['not_required'])) + { + $requiredFields = (array) explode(',',(string) $data['not_required']); + $requiredFields = array_unique($requiredFields); + // now change the required field attributes value + foreach ($requiredFields as $requiredField) + { + // make sure there is a string value + if (UtilitiesStringHelper::check($requiredField)) + { + // change to false + $form->setFieldAttribute($requiredField, 'required', 'false'); + // also clear the data set + $data[$requiredField] = ''; + } + } + } + return parent::validate($form, $data, $group); + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return array('guid'); + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + // insure the locked library are not deleted + $app = Factory::getApplication(); + foreach ($pks as $nr => $pk) + { + // remove if it is a locked library + if ($pk > 0 && isset(ComponentbuilderHelper::$libraryNames[$pk])) + { + // do not allow delete + unset($pks[$nr]); + // set a message to remind them not to delete these libraries (since they are locked) + $app->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_THE_BSB_LIBRARY_CAN_NOT_BE_DELETED_OR_THINGS_WILL_BREAK', ComponentbuilderHelper::$libraryNames[$pk]), 'warning'); + } + } + // check if we can still continue + if (!UtilitiesArrayHelper::check($pks)) + { + return false; + } + if (!parent::delete($pks)) + { + return false; + } + + // we must also delete the linked tables found + if (UtilitiesArrayHelper::check($pks)) + { + $_tablesArray = array( + 'snippet', + 'library_config', + 'library_files_folders_urls' + ); + foreach($_tablesArray as $_updateTable) + { + // get the linked IDs + if ($_pks = ComponentbuilderHelper::getVars($_updateTable, $pks, 'library', 'id')) + { + // load the model + $_Model = ComponentbuilderHelper::getModel($_updateTable); + // change publish state + $_Model->delete($_pks); + } + } + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + // we must also update all linked tables + if (UtilitiesArrayHelper::check($pks)) + { + $_tablesArray = array( + 'snippet', + 'library_config', + 'library_files_folders_urls' + ); + foreach($_tablesArray as $_updateTable) + { + // get the linked IDs + if ($_pks = ComponentbuilderHelper::getVars($_updateTable, $pks, 'library', 'id')) + { + // load the model + $_Model = ComponentbuilderHelper::getModel($_updateTable); + // change publish state + $_Model->publish($_pks, $value); + } + } + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('library'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('library'); + } + + if (!$this->canDo->get('library.create') && !$this->canDo->get('library.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('library.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('library.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->name) && !is_numeric($this->table->name)) + { + $this->table->name = $this->generateUnique('name',$this->table->name); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('library'); + } + + if (!$this->canDo->get('library.edit') && !$this->canDo->get('library.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('library.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('library.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // Set the GUID if empty or not valid + if (empty($data['guid']) && $data['id'] > 0) + { + // get the existing one + $data['guid'] = (string) GetHelper::var('library', $data['id'], 'id', 'guid'); + } + + // Set the GUID if empty or not valid + while (!GuidHelper::valid($data['guid'], "library", $data['id'])) + { + // must always be set + $data['guid'] = (string) GuidHelper::get(); + } + + // Set the libraries items to data. + if (isset($data['libraries']) && is_array($data['libraries'])) + { + $libraries = new Registry; + $libraries->loadArray($data['libraries']); + $data['libraries'] = (string) $libraries; + } + elseif (!isset($data['libraries'])) + { + // Set the empty libraries to data + $data['libraries'] = ''; + } + + // Set the addconditions items to data. + if (isset($data['addconditions']) && is_array($data['addconditions'])) + { + $addconditions = new Registry; + $addconditions->loadArray($data['addconditions']); + $data['addconditions'] = (string) $addconditions; + } + elseif (!isset($data['addconditions'])) + { + // Set the empty addconditions to data + $data['addconditions'] = ''; + } + + // Set the php_setdocument string to base64 string. + if (isset($data['php_setdocument'])) + { + $data['php_setdocument'] = base64_encode($data['php_setdocument']); + } + + // insure the locked library names are not changed + if ($data['id'] > 0 && isset(ComponentbuilderHelper::$libraryNames[$data['id']])) + { + // check if it has or is being changed + if (ComponentbuilderHelper::$libraryNames[$data['id']] !== $data['name']) + { + // the wrong name + $name_ = $data['name']; + // change it back + $data['name'] = ComponentbuilderHelper::$libraryNames[$data['id']]; + // give a notice that the name can not be changed + Factory::getApplication()->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_THE_NAME_OF_THIS_LIBRARY_BSB_CAN_NOT_BE_CHANGED_TO_BSB_OR_THINGS_WILL_BREAK', $data['name'], $name_), 'warning'); + } + // always insure they remain set a main libraries + $data['type'] = 1; + } + // also check to insure these names are not used again + if (!isset(ComponentbuilderHelper::$libraryNames[$data['id']]) && in_array($data['name'], ComponentbuilderHelper::$libraryNames)) + { + $data['name'] = $this->generateUniqe('name', $data['name']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Library_configModel.php b/admin/src/Model/Library_configModel.php new file mode 100644 index 000000000..339920b8d --- /dev/null +++ b/admin/src/Model/Library_configModel.php @@ -0,0 +1,954 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Library_config Admin Model + * + * @since 1.6 + */ +class Library_configModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'tweaks' => array( + 'fullwidth' => array( + 'addconfig' + ), + 'above' => array( + 'library' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/library_config.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/library_config.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.library_config'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'library_config', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->addconfig)) + { + // Convert the addconfig field to an array. + $addconfig = new Registry; + $addconfig->loadString($item->addconfig); + $item->addconfig = $addconfig->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.library_config', 'library_config', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('library_config.edit.state', 'com_componentbuilder.library_config.' . (int) $id)) + || ($id == 0 && !$user->authorise('library_config.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('library_config.edit.created_by', 'com_componentbuilder.library_config.' . (int) $id)) + || ($id == 0 && !$user->authorise('library_config.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('library_config.edit.created', 'com_componentbuilder.library_config.' . (int) $id)) + || ($id == 0 && !$user->authorise('library_config.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('library_config.delete', 'com_componentbuilder.library_config.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('library_config.edit.state', 'com_componentbuilder.library_config.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('library_config.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('library_config.edit', 'com_componentbuilder.library_config.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('library_config.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_library_config')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.library_config.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.library_config', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('library_config'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('library_config'); + } + + if (!$this->canDo->get('library_config.create') && !$this->canDo->get('library_config.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('library_config.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('library_config.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->library) && !is_numeric($this->table->library)) + { + $this->table->library = $this->generateUnique('library',$this->table->library); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('library_config'); + } + + if (!$this->canDo->get('library_config.edit') && !$this->canDo->get('library_config.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('library_config.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('library_config.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the addconfig items to data. + if (isset($data['addconfig']) && is_array($data['addconfig'])) + { + $addconfig = new Registry; + $addconfig->loadArray($data['addconfig']); + $data['addconfig'] = (string) $addconfig; + } + elseif (!isset($data['addconfig'])) + { + // Set the empty addconfig to data + $data['addconfig'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Library_files_folders_urlsModel.php b/admin/src/Model/Library_files_folders_urlsModel.php new file mode 100644 index 000000000..05e389356 --- /dev/null +++ b/admin/src/Model/Library_files_folders_urlsModel.php @@ -0,0 +1,1052 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Library_files_folders_urls Admin Model + * + * @since 1.6 + */ +class Library_files_folders_urlsModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'basic' => array( + 'fullwidth' => array( + 'note_add_urls', + 'addurls', + 'note_add_files', + 'addfiles', + 'note_add_folders', + 'addfolders' + ), + 'above' => array( + 'library' + ) + ), + 'advance' => array( + 'fullwidth' => array( + 'note_add_files_fullpath', + 'addfilesfullpath', + 'note_add_folders_fullpath', + 'addfoldersfullpath', + 'note_constant_paths' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/library_files_folders_urls.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/library_files_folders_urls.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.library_files_folders_urls'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'library_files_folders_urls', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->addfoldersfullpath)) + { + // Convert the addfoldersfullpath field to an array. + $addfoldersfullpath = new Registry; + $addfoldersfullpath->loadString($item->addfoldersfullpath); + $item->addfoldersfullpath = $addfoldersfullpath->toArray(); + } + + if (!empty($item->addfilesfullpath)) + { + // Convert the addfilesfullpath field to an array. + $addfilesfullpath = new Registry; + $addfilesfullpath->loadString($item->addfilesfullpath); + $item->addfilesfullpath = $addfilesfullpath->toArray(); + } + + if (!empty($item->addfolders)) + { + // Convert the addfolders field to an array. + $addfolders = new Registry; + $addfolders->loadString($item->addfolders); + $item->addfolders = $addfolders->toArray(); + } + + if (!empty($item->addfiles)) + { + // Convert the addfiles field to an array. + $addfiles = new Registry; + $addfiles->loadString($item->addfiles); + $item->addfiles = $addfiles->toArray(); + } + + if (!empty($item->addurls)) + { + // Convert the addurls field to an array. + $addurls = new Registry; + $addurls->loadString($item->addurls); + $item->addurls = $addurls->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.library_files_folders_urls', 'library_files_folders_urls', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('library_files_folders_urls.edit.state', 'com_componentbuilder.library_files_folders_urls.' . (int) $id)) + || ($id == 0 && !$user->authorise('library_files_folders_urls.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('library_files_folders_urls.edit.created_by', 'com_componentbuilder.library_files_folders_urls.' . (int) $id)) + || ($id == 0 && !$user->authorise('library_files_folders_urls.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('library_files_folders_urls.edit.created', 'com_componentbuilder.library_files_folders_urls.' . (int) $id)) + || ($id == 0 && !$user->authorise('library_files_folders_urls.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('library_files_folders_urls.delete', 'com_componentbuilder.library_files_folders_urls.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('library_files_folders_urls.edit.state', 'com_componentbuilder.library_files_folders_urls.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('library_files_folders_urls.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('library_files_folders_urls.edit', 'com_componentbuilder.library_files_folders_urls.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('library_files_folders_urls.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_library_files_folders_urls')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.library_files_folders_urls.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.library_files_folders_urls', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('library_files_folders_urls'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('library_files_folders_urls'); + } + + if (!$this->canDo->get('library_files_folders_urls.create') && !$this->canDo->get('library_files_folders_urls.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('library_files_folders_urls.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('library_files_folders_urls.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->library) && !is_numeric($this->table->library)) + { + $this->table->library = $this->generateUnique('library',$this->table->library); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('library_files_folders_urls'); + } + + if (!$this->canDo->get('library_files_folders_urls.edit') && !$this->canDo->get('library_files_folders_urls.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('library_files_folders_urls.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('library_files_folders_urls.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the addfoldersfullpath items to data. + if (isset($data['addfoldersfullpath']) && is_array($data['addfoldersfullpath'])) + { + $addfoldersfullpath = new Registry; + $addfoldersfullpath->loadArray($data['addfoldersfullpath']); + $data['addfoldersfullpath'] = (string) $addfoldersfullpath; + } + elseif (!isset($data['addfoldersfullpath'])) + { + // Set the empty addfoldersfullpath to data + $data['addfoldersfullpath'] = ''; + } + + // Set the addfilesfullpath items to data. + if (isset($data['addfilesfullpath']) && is_array($data['addfilesfullpath'])) + { + $addfilesfullpath = new Registry; + $addfilesfullpath->loadArray($data['addfilesfullpath']); + $data['addfilesfullpath'] = (string) $addfilesfullpath; + } + elseif (!isset($data['addfilesfullpath'])) + { + // Set the empty addfilesfullpath to data + $data['addfilesfullpath'] = ''; + } + + // Set the addfolders items to data. + if (isset($data['addfolders']) && is_array($data['addfolders'])) + { + $addfolders = new Registry; + $addfolders->loadArray($data['addfolders']); + $data['addfolders'] = (string) $addfolders; + } + elseif (!isset($data['addfolders'])) + { + // Set the empty addfolders to data + $data['addfolders'] = ''; + } + + // Set the addfiles items to data. + if (isset($data['addfiles']) && is_array($data['addfiles'])) + { + $addfiles = new Registry; + $addfiles->loadArray($data['addfiles']); + $data['addfiles'] = (string) $addfiles; + } + elseif (!isset($data['addfiles'])) + { + // Set the empty addfiles to data + $data['addfiles'] = ''; + } + + // Set the addurls items to data. + if (isset($data['addurls']) && is_array($data['addurls'])) + { + $addurls = new Registry; + $addurls->loadArray($data['addurls']); + $data['addurls'] = (string) $addurls; + } + elseif (!isset($data['addurls'])) + { + // Set the empty addurls to data + $data['addurls'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/PlaceholderModel.php b/admin/src/Model/PlaceholderModel.php new file mode 100644 index 000000000..7935aa1da --- /dev/null +++ b/admin/src/Model/PlaceholderModel.php @@ -0,0 +1,1033 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Placeholder Admin Model + * + * @since 1.6 + */ +class PlaceholderModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'target' + ), + 'right' => array( + 'value' + ), + 'fullwidth' => array( + 'note_placeholders_placedin' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/placeholder.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/placeholder.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.placeholder'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'placeholder', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('placeholder__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'placeholder__'.$id); + ComponentbuilderHelper::set('placeholder__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->value)) + { + // base64 Decode value. + $item->value = base64_decode($item->value); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('placeholder__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'placeholder__'.$id); + ComponentbuilderHelper::set('placeholder__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.placeholder', 'placeholder', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('placeholder.edit.state', 'com_componentbuilder.placeholder.' . (int) $id)) + || ($id == 0 && !$user->authorise('placeholder.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if (!$user->authorise('core.edit.created_by', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if (!$user->authorise('core.edit.created', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('placeholder.delete', 'com_componentbuilder.placeholder.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('placeholder.edit.state', 'com_componentbuilder.placeholder.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('placeholder.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('placeholder.edit', 'com_componentbuilder.placeholder.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('placeholder.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_placeholder')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.placeholder.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.placeholder', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('placeholder'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('placeholder'); + } + + if (!$this->canDo->get('placeholder.create') && !$this->canDo->get('placeholder.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('placeholder.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('placeholder.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->target) && !is_numeric($this->table->target)) + { + $this->table->target = $this->generateUnique('target',$this->table->target); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('placeholder'); + } + + if (!$this->canDo->get('placeholder.edit') && !$this->canDo->get('placeholder.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('placeholder.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('placeholder.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // make sure no padding is set + $data['target'] = preg_replace("/[^A-Za-z0-9_]/", '', $data['target']); + // add the padding (needed) + $data['target'] = '[[[' . trim($data['target']) . ']]]'; + + // Set the value string to base64 string. + if (isset($data['value'])) + { + $data['value'] = base64_encode($data['value']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/PlaceholdersModel.php b/admin/src/Model/PlaceholdersModel.php new file mode 100644 index 000000000..672bd971e --- /dev/null +++ b/admin/src/Model/PlaceholdersModel.php @@ -0,0 +1,540 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Placeholders List Model + * + * @since 1.6 + */ +class PlaceholdersModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/placeholders.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.target','target', + 'a.value','value' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $target = $this->getUserStateFromRequest($this->context . '.filter.target', 'filter_target'); + if ($formSubmited) + { + $target = $app->input->post->get('target'); + $this->setState('filter.target', $target); + } + + $value = $this->getUserStateFromRequest($this->context . '.filter.value', 'filter_value'); + if ($formSubmited) + { + $value = $app->input->post->get('value'); + $this->setState('filter.value', $value); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('placeholder.access', 'com_componentbuilder.placeholder.' . (int) $item->id) && $user->authorise('placeholder.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // decode value + $item->value = base64_decode($item->value); + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_placeholder', 'a')); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.target LIKE '.$search.' OR a.value LIKE '.$search.')'); + } + } + + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get list export data. + * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExportData($pks, $user = null) + { + // setup the query + if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks) + { + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + $_export = true; + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_placeholder table + $query->from($db->quoteName('#__componentbuilder_placeholder', 'a')); + // The bulk export path + if ('bulk' === $pks) + { + $query->where('a.id > 0'); + } + // A large array of ID's will not work out well + elseif ($pks_size > 500) + { + // Use lowest ID + $query->where('a.id >= ' . (int) min($pks)); + // Use highest ID + $query->where('a.id <= ' . (int) max($pks)); + } + // The normal default path + else + { + $query->where('a.id IN (' . implode(',',$pks) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.id desc'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('placeholder.access', 'com_componentbuilder.placeholder.' . (int) $item->id) && $user->authorise('placeholder.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // decode value + $item->value = base64_decode($item->value); + // unset the values we don't want exported. + unset($item->asset_id); + unset($item->checked_out); + unset($item->checked_out_time); + } + } + // Add headers to items array. + $headers = $this->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + array_unshift($items,$headers); + } + return $items; + } + } + 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 = Factory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_placeholder"); + if (UtilitiesArrayHelper::check($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; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.target'); + $id .= ':' . $this->getState('filter.value'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_placeholder')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_placeholder'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/PowerModel.php b/admin/src/Model/PowerModel.php new file mode 100644 index 000000000..247e2e075 --- /dev/null +++ b/admin/src/Model/PowerModel.php @@ -0,0 +1,1322 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Componentbuilder\Power\Factory as PowerFactory; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\String\ClassfunctionHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Power Admin Model + * + * @since 1.6 + */ +class PowerModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'code' => array( + 'left' => array( + 'name', + 'description', + 'extends', + 'extends_custom', + 'implements', + 'implements_custom', + 'namespace', + 'add_head' + ), + 'right' => array( + 'property_selection', + 'method_selection', + 'namespace_details' + ), + 'fullwidth' => array( + 'head', + 'use_selection', + 'main_class_code', + 'load_powers_note', + 'load_selection', + 'note_linked_to_notice', + 'not_required' + ), + 'above' => array( + 'system_name', + 'type', + 'power_version' + ) + ), + 'licensing' => array( + 'fullwidth' => array( + 'add_licensing_template', + 'licensing_template' + ) + ), + 'super_power' => array( + 'left' => array( + 'approved', + 'approved_paths' + ), + 'right' => array( + 'note_approved_paths' + ) + ), + 'composer' => array( + 'fullwidth' => array( + 'autoload_composer_note', + 'composer' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/power.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/power.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.power'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'power', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('power__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'power__'.$id); + ComponentbuilderHelper::set('power__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->licensing_template)) + { + // base64 Decode licensing_template. + $item->licensing_template = base64_decode($item->licensing_template); + } + + if (!empty($item->head)) + { + // base64 Decode head. + $item->head = base64_decode($item->head); + } + + if (!empty($item->main_class_code)) + { + // base64 Decode main_class_code. + $item->main_class_code = base64_decode($item->main_class_code); + } + + if (!empty($item->method_selection)) + { + // Convert the method_selection field to an array. + $method_selection = new Registry; + $method_selection->loadString($item->method_selection); + $item->method_selection = $method_selection->toArray(); + } + + if (!empty($item->load_selection)) + { + // Convert the load_selection field to an array. + $load_selection = new Registry; + $load_selection->loadString($item->load_selection); + $item->load_selection = $load_selection->toArray(); + } + + if (!empty($item->composer)) + { + // Convert the composer field to an array. + $composer = new Registry; + $composer->loadString($item->composer); + $item->composer = $composer->toArray(); + } + + if (!empty($item->property_selection)) + { + // Convert the property_selection field to an array. + $property_selection = new Registry; + $property_selection->loadString($item->property_selection); + $item->property_selection = $property_selection->toArray(); + } + + if (!empty($item->implements)) + { + // Convert the implements field to an array. + $implements = new Registry; + $implements->loadString($item->implements); + $item->implements = $implements->toArray(); + } + + if (!empty($item->use_selection)) + { + // Convert the use_selection field to an array. + $use_selection = new Registry; + $use_selection->loadString($item->use_selection); + $item->use_selection = $use_selection->toArray(); + } + + if (!empty($item->approved_paths)) + { + // JSON Decode approved_paths. + $item->approved_paths = json_decode($item->approved_paths); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('power__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'power__'.$id); + ComponentbuilderHelper::set('power__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.power', 'power', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('power.edit.state', 'com_componentbuilder.power.' . (int) $id)) + || ($id == 0 && !$user->authorise('power.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('power.edit.created_by', 'com_componentbuilder.power.' . (int) $id)) + || ($id == 0 && !$user->authorise('power.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('power.edit.created', 'com_componentbuilder.power.' . (int) $id)) + || ($id == 0 && !$user->authorise('power.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update all editors to use this components global editor + $global_editor = ComponentHelper::getParams('com_componentbuilder')->get('editor', 'none'); + // now get all the editor fields + $editors = $form->getXml()->xpath("//field[@type='editor']"); + // check if we found any + if (UtilitiesArrayHelper::check($editors)) + { + foreach ($editors as $editor) + { + // get the field names + $name = (string) $editor['name']; + // set the field editor value (with none as fallback) + $form->setFieldAttribute($name, 'editor', $global_editor . '|none'); + } + } + + + // Only load the GUID if new item (or empty) + if (0 == $id || !($val = $form->getValue('guid'))) + { + $form->setValue('guid', null, GuidHelper::get()); + } + + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('power.delete', 'com_componentbuilder.power.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('power.edit.state', 'com_componentbuilder.power.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('power.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('power.edit', 'com_componentbuilder.power.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('power.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_power')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.power.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.power', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return array('guid'); + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('power'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('power'); + } + + if (!$this->canDo->get('power.create') && !$this->canDo->get('power.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('power.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('power.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->system_name) && !is_numeric($this->table->system_name)) + { + $this->table->system_name = $this->generateUnique('system_name',$this->table->system_name); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('power'); + } + + if (!$this->canDo->get('power.edit') && !$this->canDo->get('power.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('power.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('power.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the empty approved_paths item to data + if (!isset($data['approved_paths'])) + { + $data['approved_paths'] = ''; + } + + // check if the name has placeholder + if (strpos($data['name'], '[[[') === false && strpos($data['name'], '###') === false) + { + // make sure the name is safe to be used as a function name + $data['name'] = ClassfunctionHelper::safe($data['name']); + } + + // if system name is empty create from name + if (empty($data['system_name']) || !UtilitiesStringHelper::check($data['system_name'])) + { + $data['system_name'] = $data['name']; + } + + // must set the version if empty + if (empty($data['power_version']) && $data['id'] > 0 && ($power_version = GetHelper::var('power', $data['id'], 'id', 'power_version')) !== false) + { + $data['power_version'] = $power_version; + } + // we must preserve versions (so that a change to the version number must result in save as copy) + elseif ($data['id'] > 0 && ($old_version = GetHelper::var('power', $data['id'], 'id', 'power_version')) && $data['power_version'] != $old_version) + { + // lets check if we already have this version + if (($existing_id = ComponentbuilderHelper::checkExist('power', ['power_version' => $data['power_version'], 'name' => $data['name'], 'namespace' => $data['namespace']])) !== false) + { + // class of that version already exist so we reset the version + \Factory::getApplication()->enqueueMessage(Text::sprintf("COM_COMPONENTBUILDER_POWERS_A_HREFS_TARGET_BLANK_TITLEOPEN_POWERSA_WITH_VERSION_S_ALREADY_EXIST", $existing_id, 'index.php?option=com_componentbuilder&view=powers&task=power.edit&id=' . $existing_id, $data['namespace'] . '\\' . $data['name'], $data['power_version']), 'error'); + $data['power_version'] = $old_version; + } + else + { + // does not exist so we allow save2copy + $data['id'] = 0; + Factory::getApplication()->input->set('task', 'save2copy'); + } + } + + // load dynamic code if relevant + if (($main_class_code = PowerFactory::_('Power.Generator')->get($data)) !== null) + { + $data['main_class_code'] = $main_class_code; + } + + // Set the GUID if empty or not valid + if (empty($data['guid']) && $data['id'] > 0) + { + // get the existing one + $data['guid'] = (string) GetHelper::var('power', $data['id'], 'id', 'guid'); + } + + // Set the GUID if empty or not valid + while (!GuidHelper::valid($data['guid'], "power", $data['id'])) + { + // must always be set + $data['guid'] = (string) GuidHelper::get(); + } + + // Set the method_selection items to data. + if (isset($data['method_selection']) && is_array($data['method_selection'])) + { + $method_selection = new Registry; + $method_selection->loadArray($data['method_selection']); + $data['method_selection'] = (string) $method_selection; + } + elseif (!isset($data['method_selection'])) + { + // Set the empty method_selection to data + $data['method_selection'] = ''; + } + + // Set the load_selection items to data. + if (isset($data['load_selection']) && is_array($data['load_selection'])) + { + $load_selection = new Registry; + $load_selection->loadArray($data['load_selection']); + $data['load_selection'] = (string) $load_selection; + } + elseif (!isset($data['load_selection'])) + { + // Set the empty load_selection to data + $data['load_selection'] = ''; + } + + // Set the composer items to data. + if (isset($data['composer']) && is_array($data['composer'])) + { + $composer = new Registry; + $composer->loadArray($data['composer']); + $data['composer'] = (string) $composer; + } + elseif (!isset($data['composer'])) + { + // Set the empty composer to data + $data['composer'] = ''; + } + + // Set the property_selection items to data. + if (isset($data['property_selection']) && is_array($data['property_selection'])) + { + $property_selection = new Registry; + $property_selection->loadArray($data['property_selection']); + $data['property_selection'] = (string) $property_selection; + } + elseif (!isset($data['property_selection'])) + { + // Set the empty property_selection to data + $data['property_selection'] = ''; + } + + // Set the implements items to data. + if (isset($data['implements']) && is_array($data['implements'])) + { + $implements = new Registry; + $implements->loadArray($data['implements']); + $data['implements'] = (string) $implements; + } + elseif (!isset($data['implements'])) + { + // Set the empty implements to data + $data['implements'] = ''; + } + + // Set the use_selection items to data. + if (isset($data['use_selection']) && is_array($data['use_selection'])) + { + $use_selection = new Registry; + $use_selection->loadArray($data['use_selection']); + $data['use_selection'] = (string) $use_selection; + } + elseif (!isset($data['use_selection'])) + { + // Set the empty use_selection to data + $data['use_selection'] = ''; + } + + // Set the approved_paths string to JSON string. + if (isset($data['approved_paths'])) + { + $data['approved_paths'] = (string) json_encode($data['approved_paths']); + } + + // Set the licensing_template string to base64 string. + if (isset($data['licensing_template'])) + { + $data['licensing_template'] = base64_encode($data['licensing_template']); + } + + // Set the head string to base64 string. + if (isset($data['head'])) + { + $data['head'] = base64_encode($data['head']); + } + + // Set the main_class_code string to base64 string. + if (isset($data['main_class_code'])) + { + $data['main_class_code'] = base64_encode($data['main_class_code']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/PowersModel.php b/admin/src/Model/PowersModel.php new file mode 100644 index 000000000..67c1c5408 --- /dev/null +++ b/admin/src/Model/PowersModel.php @@ -0,0 +1,716 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\Component\Helper as JCBHelper; +use VDM\Joomla\Componentbuilder\Utilities\FilterHelper as JCBFilterHelper; +use VDM\Joomla\Utilities\FormHelper as JCBFormHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Powers List Model + * + * @since 1.6 + */ +class PowersModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/powers.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.type','type', + 'a.approved','approved', + 'a.system_name','system_name', + 'a.namespace','namespace', + 'a.power_version','power_version' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Get the filter form - Override the parent method + * + * @param array $data data + * @param boolean $loadData load current data + * + * @return \JForm|boolean The \JForm object or false on error + * + * @since JCB 2.12.5 + */ + public function getFilterForm($data = array(), $loadData = true) + { + // load form from the parent class + $form = parent::getFilterForm($data, $loadData); + + // Create the "admin_view" filter + $attributes = array( + 'name' => 'namegroup', + 'type' => 'list', + 'onchange' => 'this.form.submit();', + ); + $options = array( + '' => '- ' . Text::_('COM_COMPONENTBUILDER_NO_NAMESPACE_FOUND') . ' -' + ); + // check if we have namespace (and limit to an extension if it is set) + if (($namespaces = JCBFilterHelper::namespaces()) !== null) + { + $options = array( + '' => '- ' . Text::_('COM_COMPONENTBUILDER_SELECT_A_NAMESPACE') . ' -' + ); + // make sure we do not lose the key values in normal merge + $options = $options + $namespaces; + } + + $form->setField(JCBFormHelper::xml($attributes, $options),'filter'); + $form->setValue( + 'namegroup', + 'filter', + $this->state->get("filter.namegroup") + ); + array_push($this->filter_fields, 'namegroup'); + + // get the component params + $params = JCBHelper::getParams(); + $activate = $params->get('super_powers_repositories', 0); + if ($activate == 1) + { + $subform = $params->get('approved_paths', null); + + // create approved paths filter + $attributes = array( + 'name' => 'approved_paths', + 'type' => 'list', + 'onchange' => 'this.form.submit();', + ); + $options = array( + '' => '- ' . Text::_('COM_COMPONENTBUILDER_NO_PATHS_FOUND') . ' -' + ); + + // add the paths found in global settings + if (is_object($subform)) + { + $core = $params->get('super_powers_core', 'joomla/super-powers'); + + $options = array( + '' => '- ' . Text::_('COM_COMPONENTBUILDER_SELECT_APPROVED_PATH') . ' -', + $core => $core + ); + + foreach ($subform as $value) + { + if (isset($value->owner) && strlen($value->owner) > 1 && + isset($value->repo) && strlen($value->repo) > 1) + { + $value = trim($value->owner) . '/' . trim($value->repo); + + $options[$value] = $value; + } + } + } + + $form->setField(JCBFormHelper::xml($attributes, $options), 'filter'); + $form->setValue( + 'approved_paths', + 'filter', + $this->state->get("filter.approved_paths") + ); + array_push($this->filter_fields, 'approved_paths'); + } + + return $form; + } + + /** + * Check if a power can be used in linking + * + * @param string $type the type of power + * + * @return bool + * @since JCB 3.1.23 + */ + protected function isSuperPower(string $type): bool + { + return in_array($type, ['class', 'abstract class', 'final class', 'trait']); + } + + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $type = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type'); + if ($formSubmited) + { + $type = $app->input->post->get('type'); + $this->setState('filter.type', $type); + } + + $approved = $this->getUserStateFromRequest($this->context . '.filter.approved', 'filter_approved'); + if ($formSubmited) + { + $approved = $app->input->post->get('approved'); + $this->setState('filter.approved', $approved); + } + + $system_name = $this->getUserStateFromRequest($this->context . '.filter.system_name', 'filter_system_name'); + if ($formSubmited) + { + $system_name = $app->input->post->get('system_name'); + $this->setState('filter.system_name', $system_name); + } + + $namespace = $this->getUserStateFromRequest($this->context . '.filter.namespace', 'filter_namespace'); + if ($formSubmited) + { + $namespace = $app->input->post->get('namespace'); + $this->setState('filter.namespace', $namespace); + } + + $power_version = $this->getUserStateFromRequest($this->context . '.filter.power_version', 'filter_power_version'); + if ($formSubmited) + { + $power_version = $app->input->post->get('power_version'); + $this->setState('filter.power_version', $power_version); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('power.access', 'com_componentbuilder.power.' . (int) $item->id) && $user->authorise('power.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // create the GUID placeholder key + if ($this->isSuperPower($item->type)) + { + $item->super_power_key = 'Super_'.'_'.'_' . str_replace('-', '_', $item->guid) . '_'.'_'.'_Power'; + } + // remove dots + $item->namespace = str_replace('.','\\', $item->namespace); + } + } + + // set selection value to a translatable value + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // convert type + $item->type = $this->selectionTranslation($item->type, 'type'); + // convert approved + $item->approved = $this->selectionTranslation($item->approved, 'approved'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return string The translatable string. + */ + public function selectionTranslation($value,$name) + { + // Array of type language strings + if ($name === 'type') + { + $typeArray = array( + 'class' => 'COM_COMPONENTBUILDER_POWER_CLASS', + 'abstract class' => 'COM_COMPONENTBUILDER_POWER_ABSTRACT_CLASS', + 'final class' => 'COM_COMPONENTBUILDER_POWER_FINAL_CLASS', + 'interface' => 'COM_COMPONENTBUILDER_POWER_INTERFACE', + 'trait' => 'COM_COMPONENTBUILDER_POWER_TRAIT' + ); + // Now check if value is found in this array + if (isset($typeArray[$value]) && StringHelper::check($typeArray[$value])) + { + return $typeArray[$value]; + } + } + // Array of approved language strings + if ($name === 'approved') + { + $approvedArray = array( + 0 => 'COM_COMPONENTBUILDER_POWER_NOT_APPROVED', + 1 => 'COM_COMPONENTBUILDER_POWER_APPROVED' + ); + // Now check if value is found in this array + if (isset($approvedArray[$value]) && StringHelper::check($approvedArray[$value])) + { + return $approvedArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_power', 'a')); + + // do not use these filters in the export method + if (!isset($_export) || !$_export) + { + // Filtering "namegroup" + $filter_namegroup = $this->state->get("filter.namegroup"); + if ($filter_namegroup !== null && !empty($filter_namegroup)) + { + if (($ids = JCBFilterHelper::namegroup($filter_namegroup)) !== null) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')'); + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + } + } + + // Filtering "approved paths" + $filter_approved_paths = $this->state->get("filter.approved_paths"); + if ($filter_approved_paths !== null && !empty($filter_approved_paths)) + { + if (($ids = JCBFilterHelper::paths($filter_approved_paths)) !== null) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')'); + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + } + } + } + + // From the componentbuilder_power table. + $query->select($db->quoteName(['g.name','g.id'],['extends_name','extends_id'])); + $query->join('LEFT', $db->quoteName('#__componentbuilder_power', 'g') . ' ON (' . $db->quoteName('a.extends') . ' = ' . $db->quoteName('g.guid') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.system_name LIKE '.$search.' OR a.type LIKE '.$search.' OR a.description LIKE '.$search.' OR a.extends LIKE '.$search.' OR a.extends_custom LIKE '.$search.' OR a.approved_paths LIKE '.$search.' OR a.guid LIKE '.$search.' OR a.name LIKE '.$search.')'); + } + } + + // Filter by Type. + $_type = $this->getState('filter.type'); + if (is_numeric($_type)) + { + if (is_float($_type)) + { + $query->where('a.type = ' . (float) $_type); + } + else + { + $query->where('a.type = ' . (int) $_type); + } + } + elseif (StringHelper::check($_type)) + { + $query->where('a.type = ' . $db->quote($db->escape($_type))); + } + elseif (UtilitiesArrayHelper::check($_type)) + { + // Secure the array for the query + $_type = array_map( function ($val) use(&$db) { + if (is_numeric($val)) + { + if (is_float($val)) + { + return (float) $val; + } + else + { + return (int) $val; + } + } + elseif (StringHelper::check($val)) + { + return $db->quote($db->escape($val)); + } + }, $_type); + // Filter by the Type Array. + $query->where('a.type IN (' . implode(',', $_type) . ')'); + } + // Filter by Approved. + $_approved = $this->getState('filter.approved'); + if (is_numeric($_approved)) + { + if (is_float($_approved)) + { + $query->where('a.approved = ' . (float) $_approved); + } + else + { + $query->where('a.approved = ' . (int) $_approved); + } + } + elseif (StringHelper::check($_approved)) + { + $query->where('a.approved = ' . $db->quote($db->escape($_approved))); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + // Check if the value is an array + $_type = $this->getState('filter.type'); + if (UtilitiesArrayHelper::check($_type)) + { + $id .= ':' . implode(':', $_type); + } + // Check if this is only an number or string + elseif (is_numeric($_type) + || StringHelper::check($_type)) + { + $id .= ':' . $_type; + } + $id .= ':' . $this->getState('filter.approved'); + $id .= ':' . $this->getState('filter.system_name'); + $id .= ':' . $this->getState('filter.namespace'); + $id .= ':' . $this->getState('filter.power_version'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_power')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_power'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/SearchModel.php b/admin/src/Model/SearchModel.php new file mode 100644 index 000000000..6887d31f1 --- /dev/null +++ b/admin/src/Model/SearchModel.php @@ -0,0 +1,384 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ItemModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\User\User; +use Joomla\Input\Input; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Componentbuilder\Search\Factory as SearchFactory; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Search Item Model + * + * @since 1.6 + */ +class SearchModel extends ItemModel +{ + /** + * Model context string. + * + * @var string + * @since 1.6 + */ + protected $_context = 'com_componentbuilder.search'; + + /** + * Represents the current user object. + * + * @var User The user object representing the current user. + * @since 3.2.0 + */ + protected User $user; + + /** + * The unique identifier of the current user. + * + * @var int|null The ID of the current user. + * @since 3.2.0 + */ + protected ?int $userId; + + /** + * Flag indicating whether the current user is a guest. + * + * @var int 1 if the user is a guest, 0 otherwise. + * @since 3.2.0 + */ + protected int $guest; + + /** + * An array of groups that the current user belongs to. + * + * @var array|null An array of user group IDs. + * @since 3.2.0 + */ + protected ?array $groups; + + /** + * An array of view access levels for the current user. + * + * @var array|null An array of access level IDs. + * @since 3.2.0 + */ + protected ?array $levels; + + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The input object, providing access to the request data. + * + * @var Input The input object. + * @since 3.2.0 + */ + protected Input $input; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/search.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * A custom property for UI Kit components. + * + * @var array|null Property for storing UI Kit component-related data or objects. + * @since 3.2.0 + */ + protected ?array $uikitComp; + + /** + * @var object item + * @since 1.6 + */ + protected $item; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 3.0 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + $this->input ??= $this->app->getInput(); + + // Set the current user for authorisation checks (for those calling this model directly) + $this->user ??= $this->getCurrentUser(); + $this->userId = $this->user->get('id'); + $this->guest = $this->user->get('guest'); + $this->groups = $this->user->get('groups'); + $this->authorisedGroups = $this->user->getAuthorisedGroups(); + $this->levels = $this->user->getAuthorisedViewLevels(); + + // will be removed + $this->initSet = true; + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @return void + * @since 1.6 + */ + protected function populateState() + { + // Get the item main id + $id = $this->input->getInt('id', null); + $this->setState('search.id', $id); + + // Load the parameters. + parent::populateState(); + } + + /** + * Method to get article data. + * + * @param integer $pk The id of the article. + * + * @return mixed Menu item data object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + // check if this user has permission to access item + if (!$this->user->authorise('search.access', 'com_componentbuilder')) + { + $this->app->enqueueMessage(Text::_('Not authorised!'), 'error'); + // redirect away if not a correct to cPanel/default view + $this->app->redirect('index.php?option=com_componentbuilder'); + return false; + } + + $pk = (!empty($pk)) ? $pk : (int) $this->getState('search.id'); + + $pk = $this->userId; + + if ($this->_item === null) + { + $this->_item = []; + } + + if (!isset($this->_item[$pk])) + { + try + { + // Get a db connection. + $db = $this->getDatabase(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Get data + // load the tables and components + $data = ['tables' => SearchFactory::_('Table')->tables(), 'components' => $this->getComponents()]; + + + if (empty($data)) + { + $app = Factory::getApplication(); + // If no data is found redirect to default page and show warning. + $app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_NOT_FOUND_OR_ACCESS_DENIED'), 'warning'); + $app->redirect('index.php?option=com_componentbuilder'); + return false; + } + + // set data object to item. + $this->_item[$pk] = $data; + } + catch (\Exception $e) + { + if ($e->getCode() == 404) + { + // Need to go thru the error handler to allow Redirect to work. + throw $e; + } + else + { + $this->setError($e); + $this->_item[$pk] = false; + } + } + } + + return $this->_item[$pk]; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Custom Method + * + * @return mixed item data object on success, false on failure. + * + */ + public function getUrlValues() + { + // Get a db connection. + $db = $this->getDatabase(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Get data + $data = [ + 'type_search' => SearchFactory::_('Config')->get('type_search', 1), + 'search_value' => SearchFactory::_('Config')->get('search_value', ''), + 'replace_value' => SearchFactory::_('Config')->get('replace_value', ''), + 'match_case' => SearchFactory::_('Config')->get('match_case', 0), + 'whole_word' => SearchFactory::_('Config')->get('whole_word', 0), + 'regex_search' => SearchFactory::_('Config')->get('regex_search', 0), + 'table_name' => SearchFactory::_('Config')->get('table_name', -1) + ]; + + if (empty($data)) + { + return false; + } + + // return data object. + return $data; + } + + /** + * Get the uikit needed components + * + * @return mixed An array of objects on success. + * + */ + public function getUikitComp() + { + if (isset($this->uikitComp) && UtilitiesArrayHelper::check($this->uikitComp)) + { + return $this->uikitComp; + } + return false; + } + + + /** + * Get all components in the system + * + * @return array + * @since 3.2.0 + **/ + public function getComponents(): array + { + // Get a db connection. + $db = $this->getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select only id and system name + $query->select($db->quoteName(array('id', 'system_name'),array('id', 'name'))); + $query->from($db->quoteName('#__componentbuilder_joomla_component')); + + // only the active components + $query->where($db->quoteName('published') . ' = 1'); + + // Order it by the ordering field. + $query->order('modified DESC'); + $query->order('created DESC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + // return the result + return $db->loadObjectList(); + } + +} diff --git a/admin/src/Model/ServerModel.php b/admin/src/Model/ServerModel.php new file mode 100644 index 000000000..b5b4e378c --- /dev/null +++ b/admin/src/Model/ServerModel.php @@ -0,0 +1,1105 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\FOF\Encrypt\AES; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Server Admin Model + * + * @since 1.6 + */ +class ServerModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'username', + 'host', + 'port', + 'path' + ), + 'right' => array( + 'authentication', + 'password', + 'private', + 'private_key', + 'secret' + ), + 'fullwidth' => array( + 'note_ftp_signature', + 'signature', + 'note_ssh_security', + 'not_required' + ), + 'above' => array( + 'name', + 'protocol' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/server.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/server.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.server'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'server', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + // Get the basic encryption. + $basickey = ComponentbuilderHelper::getCryptKey('basic'); + // Get the encryption object. + $basic = new AES($basickey); + + if (!empty($item->signature) && $basickey && !is_numeric($item->signature) && $item->signature === base64_encode(base64_decode($item->signature, true))) + { + // basic decrypt data signature. + $item->signature = rtrim($basic->decryptString($item->signature), "\0"); + } + + if (!empty($item->private_key) && $basickey && !is_numeric($item->private_key) && $item->private_key === base64_encode(base64_decode($item->private_key, true))) + { + // basic decrypt data private_key. + $item->private_key = rtrim($basic->decryptString($item->private_key), "\0"); + } + + if (!empty($item->secret) && $basickey && !is_numeric($item->secret) && $item->secret === base64_encode(base64_decode($item->secret, true))) + { + // basic decrypt data secret. + $item->secret = rtrim($basic->decryptString($item->secret), "\0"); + } + + if (!empty($item->password) && $basickey && !is_numeric($item->password) && $item->password === base64_encode(base64_decode($item->password, true))) + { + // basic decrypt data password. + $item->password = rtrim($basic->decryptString($item->password), "\0"); + } + + if (!empty($item->private) && $basickey && !is_numeric($item->private) && $item->private === base64_encode(base64_decode($item->private, true))) + { + // basic decrypt data private. + $item->private = rtrim($basic->decryptString($item->private), "\0"); + } + + if (!empty($item->path) && $basickey && !is_numeric($item->path) && $item->path === base64_encode(base64_decode($item->path, true))) + { + // basic decrypt data path. + $item->path = rtrim($basic->decryptString($item->path), "\0"); + } + + if (!empty($item->port) && $basickey && !is_numeric($item->port) && $item->port === base64_encode(base64_decode($item->port, true))) + { + // basic decrypt data port. + $item->port = rtrim($basic->decryptString($item->port), "\0"); + } + + if (!empty($item->host) && $basickey && !is_numeric($item->host) && $item->host === base64_encode(base64_decode($item->host, true))) + { + // basic decrypt data host. + $item->host = rtrim($basic->decryptString($item->host), "\0"); + } + + if (!empty($item->username) && $basickey && !is_numeric($item->username) && $item->username === base64_encode(base64_decode($item->username, true))) + { + // basic decrypt data username. + $item->username = rtrim($basic->decryptString($item->username), "\0"); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.server', 'server', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('server.edit.state', 'com_componentbuilder.server.' . (int) $id)) + || ($id == 0 && !$user->authorise('server.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('server.edit.created_by', 'com_componentbuilder.server.' . (int) $id)) + || ($id == 0 && !$user->authorise('server.edit.created_by', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('server.edit.created', 'com_componentbuilder.server.' . (int) $id)) + || ($id == 0 && !$user->authorise('server.edit.created', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('server.delete', 'com_componentbuilder.server.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('server.edit.state', 'com_componentbuilder.server.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('server.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('server.edit', 'com_componentbuilder.server.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('server.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_server')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.server.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.server', $data); + + return $data; + } + + /** + * Method to validate the form data. + * + * @param JForm $form The form to validate against. + * @param array $data The data to validate. + * @param string $group The name of the field group to validate. + * + * @return mixed Array of filtered data if valid, false otherwise. + * + * @see JFormRule + * @see JFilterInput + * @since 12.2 + */ + public function validate($form, $data, $group = null) + { + // check if the not_required field is set + if (isset($data['not_required']) && UtilitiesStringHelper::check($data['not_required'])) + { + $requiredFields = (array) explode(',',(string) $data['not_required']); + $requiredFields = array_unique($requiredFields); + // now change the required field attributes value + foreach ($requiredFields as $requiredField) + { + // make sure there is a string value + if (UtilitiesStringHelper::check($requiredField)) + { + // change to false + $form->setFieldAttribute($requiredField, 'required', 'false'); + // also clear the data set + $data[$requiredField] = ''; + } + } + } + return parent::validate($form, $data, $group); + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('server'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('server'); + } + + if (!$this->canDo->get('server.create') && !$this->canDo->get('server.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('server.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('server.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->name) && !is_numeric($this->table->name)) + { + $this->table->name = $this->generateUnique('name',$this->table->name); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('server'); + } + + if (!$this->canDo->get('server.edit') && !$this->canDo->get('server.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('server.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('server.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Get the basic encryption key. + $basickey = ComponentbuilderHelper::getCryptKey('basic'); + // Get the encryption object + $basic = new AES($basickey); + + // Encrypt data signature. + if (isset($data['signature']) && $basickey) + { + $data['signature'] = $basic->encryptString($data['signature']); + } + + // Encrypt data private_key. + if (isset($data['private_key']) && $basickey) + { + $data['private_key'] = $basic->encryptString($data['private_key']); + } + + // Encrypt data secret. + if (isset($data['secret']) && $basickey) + { + $data['secret'] = $basic->encryptString($data['secret']); + } + + // Encrypt data password. + if (isset($data['password']) && $basickey) + { + $data['password'] = $basic->encryptString($data['password']); + } + + // Encrypt data private. + if (isset($data['private']) && $basickey) + { + $data['private'] = $basic->encryptString($data['private']); + } + + // Encrypt data path. + if (isset($data['path']) && $basickey) + { + $data['path'] = $basic->encryptString($data['path']); + } + + // Encrypt data port. + if (isset($data['port']) && $basickey) + { + $data['port'] = $basic->encryptString($data['port']); + } + + // Encrypt data host. + if (isset($data['host']) && $basickey) + { + $data['host'] = $basic->encryptString($data['host']); + } + + // Encrypt data username. + if (isset($data['username']) && $basickey) + { + $data['username'] = $basic->encryptString($data['username']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/ServersModel.php b/admin/src/Model/ServersModel.php new file mode 100644 index 000000000..b99e5ffd3 --- /dev/null +++ b/admin/src/Model/ServersModel.php @@ -0,0 +1,656 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\FOF\Encrypt\AES; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Servers List Model + * + * @since 1.6 + */ +class ServersModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/servers.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.name','name', + 'a.protocol','protocol' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + $protocol = $this->getUserStateFromRequest($this->context . '.filter.protocol', 'filter_protocol'); + if ($formSubmited) + { + $protocol = $app->input->post->get('protocol'); + $this->setState('filter.protocol', $protocol); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('server.access', 'com_componentbuilder.server.' . (int) $item->id) && $user->authorise('server.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // set selection value to a translatable value + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // convert protocol + $item->protocol = $this->selectionTranslation($item->protocol, 'protocol'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return string The translatable string. + */ + public function selectionTranslation($value,$name) + { + // Array of protocol language strings + if ($name === 'protocol') + { + $protocolArray = array( + 0 => 'COM_COMPONENTBUILDER_SERVER_SELECT_AN_OPTION', + 1 => 'COM_COMPONENTBUILDER_SERVER_FTP', + 2 => 'COM_COMPONENTBUILDER_SERVER_SFTP' + ); + // Now check if value is found in this array + if (isset($protocolArray[$value]) && StringHelper::check($protocolArray[$value])) + { + return $protocolArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_server', 'a')); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.' OR a.protocol LIKE '.$search.')'); + } + } + + // Filter by Name. + $_name = $this->getState('filter.name'); + if (is_numeric($_name)) + { + if (is_float($_name)) + { + $query->where('a.name = ' . (float) $_name); + } + else + { + $query->where('a.name = ' . (int) $_name); + } + } + elseif (StringHelper::check($_name)) + { + $query->where('a.name = ' . $db->quote($db->escape($_name))); + } + // Filter by Protocol. + $_protocol = $this->getState('filter.protocol'); + if (is_numeric($_protocol)) + { + if (is_float($_protocol)) + { + $query->where('a.protocol = ' . (float) $_protocol); + } + else + { + $query->where('a.protocol = ' . (int) $_protocol); + } + } + elseif (StringHelper::check($_protocol)) + { + $query->where('a.protocol = ' . $db->quote($db->escape($_protocol))); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get list export data. + * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExportData($pks, $user = null) + { + // setup the query + if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks) + { + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + $_export = true; + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_server table + $query->from($db->quoteName('#__componentbuilder_server', 'a')); + // The bulk export path + if ('bulk' === $pks) + { + $query->where('a.id > 0'); + } + // A large array of ID's will not work out well + elseif ($pks_size > 500) + { + // Use lowest ID + $query->where('a.id >= ' . (int) min($pks)); + // Use highest ID + $query->where('a.id <= ' . (int) max($pks)); + } + // The normal default path + else + { + $query->where('a.id IN (' . implode(',',$pks) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.ordering ASC'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Get the basic encryption key. + $basickey = ComponentbuilderHelper::getCryptKey('basic'); + // Get the encryption object. + $basic = new AES($basickey); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('server.access', 'com_componentbuilder.server.' . (int) $item->id) && $user->authorise('server.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + if ($basickey && !is_numeric($item->signature) && $item->signature === base64_encode(base64_decode($item->signature, true))) + { + // decrypt signature + $item->signature = $basic->decryptString($item->signature); + } + if ($basickey && !is_numeric($item->private_key) && $item->private_key === base64_encode(base64_decode($item->private_key, true))) + { + // decrypt private_key + $item->private_key = $basic->decryptString($item->private_key); + } + if ($basickey && !is_numeric($item->secret) && $item->secret === base64_encode(base64_decode($item->secret, true))) + { + // decrypt secret + $item->secret = $basic->decryptString($item->secret); + } + if ($basickey && !is_numeric($item->password) && $item->password === base64_encode(base64_decode($item->password, true))) + { + // decrypt password + $item->password = $basic->decryptString($item->password); + } + if ($basickey && !is_numeric($item->private) && $item->private === base64_encode(base64_decode($item->private, true))) + { + // decrypt private + $item->private = $basic->decryptString($item->private); + } + if ($basickey && !is_numeric($item->path) && $item->path === base64_encode(base64_decode($item->path, true))) + { + // decrypt path + $item->path = $basic->decryptString($item->path); + } + if ($basickey && !is_numeric($item->port) && $item->port === base64_encode(base64_decode($item->port, true))) + { + // decrypt port + $item->port = $basic->decryptString($item->port); + } + if ($basickey && !is_numeric($item->host) && $item->host === base64_encode(base64_decode($item->host, true))) + { + // decrypt host + $item->host = $basic->decryptString($item->host); + } + if ($basickey && !is_numeric($item->username) && $item->username === base64_encode(base64_decode($item->username, true))) + { + // decrypt username + $item->username = $basic->decryptString($item->username); + } + // unset the values we don't want exported. + unset($item->asset_id); + unset($item->checked_out); + unset($item->checked_out_time); + } + } + // Add headers to items array. + $headers = $this->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + array_unshift($items,$headers); + } + return $items; + } + } + 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 = Factory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_[[[view]]]"); + if (UtilitiesArrayHelper::check($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; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.name'); + $id .= ':' . $this->getState('filter.protocol'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_server')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_server'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Site_viewModel.php b/admin/src/Model/Site_viewModel.php new file mode 100644 index 000000000..1d3975efc --- /dev/null +++ b/admin/src/Model/Site_viewModel.php @@ -0,0 +1,1416 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Site_view Admin Model + * + * @since 1.6 + */ +class Site_viewModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'name', + 'codename', + 'description', + 'note_libraries_selection', + 'libraries', + 'note_add_php_language_string' + ), + 'right' => array( + 'snippet', + 'note_uikit_snippet', + 'note_snippet_usage' + ), + 'fullwidth' => array( + 'default' + ), + 'above' => array( + 'system_name', + 'context' + ), + 'under' => array( + 'not_required' + ), + 'rightside' => array( + 'custom_get', + 'main_get', + 'dynamic_get', + 'dynamic_values' + ) + ), + 'php' => array( + 'fullwidth' => array( + 'add_php_ajax', + 'php_ajaxmethod', + 'ajax_input', + 'add_php_document', + 'php_document', + 'add_php_view', + 'php_view', + 'add_php_jview_display', + 'php_jview_display', + 'add_php_jview', + 'php_jview' + ) + ), + 'javascript_css' => array( + 'fullwidth' => array( + 'add_javascript_file', + 'javascript_file', + 'add_js_document', + 'js_document', + 'add_css_document', + 'css_document', + 'add_css', + 'css' + ) + ), + 'linked_components' => array( + 'fullwidth' => array( + 'note_linked_to_notice' + ) + ), + 'custom_buttons' => array( + 'left' => array( + 'add_custom_button' + ), + 'right' => array( + 'button_position' + ), + 'fullwidth' => array( + 'note_custom_toolbar_placeholder', + 'custom_button', + 'php_controller', + 'php_model' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/site_view.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/site_view.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.site_view'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'site_view', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('site_view__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'site_view__'.$id); + ComponentbuilderHelper::set('site_view__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->js_document)) + { + // base64 Decode js_document. + $item->js_document = base64_decode($item->js_document); + } + + if (!empty($item->javascript_file)) + { + // base64 Decode javascript_file. + $item->javascript_file = base64_decode($item->javascript_file); + } + + if (!empty($item->default)) + { + // base64 Decode default. + $item->default = base64_decode($item->default); + } + + if (!empty($item->css_document)) + { + // base64 Decode css_document. + $item->css_document = base64_decode($item->css_document); + } + + if (!empty($item->css)) + { + // base64 Decode css. + $item->css = base64_decode($item->css); + } + + if (!empty($item->php_ajaxmethod)) + { + // base64 Decode php_ajaxmethod. + $item->php_ajaxmethod = base64_decode($item->php_ajaxmethod); + } + + if (!empty($item->php_document)) + { + // base64 Decode php_document. + $item->php_document = base64_decode($item->php_document); + } + + if (!empty($item->php_view)) + { + // base64 Decode php_view. + $item->php_view = base64_decode($item->php_view); + } + + if (!empty($item->php_jview_display)) + { + // base64 Decode php_jview_display. + $item->php_jview_display = base64_decode($item->php_jview_display); + } + + if (!empty($item->php_jview)) + { + // base64 Decode php_jview. + $item->php_jview = base64_decode($item->php_jview); + } + + if (!empty($item->php_controller)) + { + // base64 Decode php_controller. + $item->php_controller = base64_decode($item->php_controller); + } + + if (!empty($item->php_model)) + { + // base64 Decode php_model. + $item->php_model = base64_decode($item->php_model); + } + + if (!empty($item->custom_get)) + { + // Convert the custom_get field to an array. + $custom_get = new Registry; + $custom_get->loadString($item->custom_get); + $item->custom_get = $custom_get->toArray(); + } + + if (!empty($item->libraries)) + { + // Convert the libraries field to an array. + $libraries = new Registry; + $libraries->loadString($item->libraries); + $item->libraries = $libraries->toArray(); + } + + if (!empty($item->ajax_input)) + { + // Convert the ajax_input field to an array. + $ajax_input = new Registry; + $ajax_input->loadString($item->ajax_input); + $item->ajax_input = $ajax_input->toArray(); + } + + if (!empty($item->custom_button)) + { + // Convert the custom_button field to an array. + $custom_button = new Registry; + $custom_button->loadString($item->custom_button); + $item->custom_button = $custom_button->toArray(); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('site_view__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'site_view__'.$id); + ComponentbuilderHelper::set('site_view__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + + // update the fields + $objectUpdate = new \stdClass(); + $objectUpdate->id = (int) $item->id; + // check what type of custom_button array we have here (should be subform... but just incase) + // This could happen due to huge data sets + if (isset($item->custom_button) && isset($item->custom_button['name'])) + { + $bucket = array(); + foreach($item->custom_button as $option => $values) + { + foreach($values as $nr => $value) + { + $bucket['custom_button'.$nr][$option] = $value; + } + } + $item->custom_button = $bucket; + $objectUpdate->custom_button = json_encode($bucket); + } + // check what type of ajax_input array we have here (should be subform... but just incase) + // This could happen due to huge data sets + if (isset($item->ajax_input) && isset($item->ajax_input['value_name'])) + { + $bucket = array(); + foreach($item->ajax_input as $option => $values) + { + foreach($values as $nr => $value) + { + $bucket['ajax_input'.$nr][$option] = $value; + } + } + $item->ajax_input = $bucket; + $objectUpdate->ajax_input = json_encode($bucket); + } + // be sure to update the table if we found repeatable fields that are still not converted + if (count((array) $objectUpdate) > 1) + { + $this->_db->updateObject('#__componentbuilder_site_view', $objectUpdate, 'id'); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.site_view', 'site_view', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('core.edit.state', 'com_componentbuilder.site_view.' . (int) $id)) + || ($id == 0 && !$user->authorise('core.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if (!$user->authorise('core.edit.created_by', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if (!$user->authorise('core.edit.created', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update all editors to use this components global editor + $global_editor = ComponentHelper::getParams('com_componentbuilder')->get('editor', 'none'); + // now get all the editor fields + $editors = $form->getXml()->xpath("//field[@type='editor']"); + // check if we found any + if (UtilitiesArrayHelper::check($editors)) + { + foreach ($editors as $editor) + { + // get the field names + $name = (string) $editor['name']; + // set the field editor value (with none as fallback) + $form->setFieldAttribute($name, 'editor', $global_editor . '|none'); + } + } + + + // Only load the GUID if new item (or empty) + if (0 == $id || !($val = $form->getValue('guid'))) + { + $form->setValue('guid', null, GuidHelper::get()); + } + + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('core.delete', 'com_componentbuilder.site_view.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('core.edit.state', 'com_componentbuilder.site_view.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return parent::canEditState($record); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('core.edit', 'com_componentbuilder.site_view.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('core.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_site_view')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.site_view.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.site_view', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return array('guid'); + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('site_view'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('site_view'); + } + + if (!$this->canDo->get('core.create') && !$this->canDo->get('site_view.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('core.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('core.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->name) && !is_numeric($this->table->name)) + { + $this->table->name = $this->generateUnique('name',$this->table->name); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('site_view'); + } + + if (!$this->canDo->get('core.edit') && !$this->canDo->get('site_view.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('core.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('core.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // always reset the snippets + $data['snippet'] = 0; + // if system name is empty create from name + if (empty($data['system_name']) || !UtilitiesStringHelper::check($data['system_name'])) + { + $data['system_name'] = $data['name']; + } + // if codename is empty create from name + if (empty($data['codename']) || !UtilitiesStringHelper::check($data['codename'])) + { + $data['codename'] = UtilitiesStringHelper::safe($data['name']); + } + else + { + // always make safe string + $data['codename'] = UtilitiesStringHelper::safe($data['codename']); + } + // if context is empty create from codename + if (empty($data['context']) || !UtilitiesStringHelper::check($data['context'])) + { + $data['context'] = $data['codename']; + } + else + { + // always make safe string + $data['context'] = UtilitiesStringHelper::safe($data['context']); + } + + // Set the GUID if empty or not valid + if (empty($data['guid']) && $data['id'] > 0) + { + // get the existing one + $data['guid'] = (string) GetHelper::var('site_view', $data['id'], 'id', 'guid'); + } + + // Set the GUID if empty or not valid + while (!GuidHelper::valid($data['guid'], "site_view", $data['id'])) + { + // must always be set + $data['guid'] = (string) GuidHelper::get(); + } + + // Set the custom_get items to data. + if (isset($data['custom_get']) && is_array($data['custom_get'])) + { + $custom_get = new Registry; + $custom_get->loadArray($data['custom_get']); + $data['custom_get'] = (string) $custom_get; + } + elseif (!isset($data['custom_get'])) + { + // Set the empty custom_get to data + $data['custom_get'] = ''; + } + + // Set the libraries items to data. + if (isset($data['libraries']) && is_array($data['libraries'])) + { + $libraries = new Registry; + $libraries->loadArray($data['libraries']); + $data['libraries'] = (string) $libraries; + } + elseif (!isset($data['libraries'])) + { + // Set the empty libraries to data + $data['libraries'] = ''; + } + + // Set the ajax_input items to data. + if (isset($data['ajax_input']) && is_array($data['ajax_input'])) + { + $ajax_input = new Registry; + $ajax_input->loadArray($data['ajax_input']); + $data['ajax_input'] = (string) $ajax_input; + } + elseif (!isset($data['ajax_input'])) + { + // Set the empty ajax_input to data + $data['ajax_input'] = ''; + } + + // Set the custom_button items to data. + if (isset($data['custom_button']) && is_array($data['custom_button'])) + { + $custom_button = new Registry; + $custom_button->loadArray($data['custom_button']); + $data['custom_button'] = (string) $custom_button; + } + elseif (!isset($data['custom_button'])) + { + // Set the empty custom_button to data + $data['custom_button'] = ''; + } + + // Set the js_document string to base64 string. + if (isset($data['js_document'])) + { + $data['js_document'] = base64_encode($data['js_document']); + } + + // Set the javascript_file string to base64 string. + if (isset($data['javascript_file'])) + { + $data['javascript_file'] = base64_encode($data['javascript_file']); + } + + // Set the default string to base64 string. + if (isset($data['default'])) + { + $data['default'] = base64_encode($data['default']); + } + + // Set the css_document string to base64 string. + if (isset($data['css_document'])) + { + $data['css_document'] = base64_encode($data['css_document']); + } + + // Set the css string to base64 string. + if (isset($data['css'])) + { + $data['css'] = base64_encode($data['css']); + } + + // Set the php_ajaxmethod string to base64 string. + if (isset($data['php_ajaxmethod'])) + { + $data['php_ajaxmethod'] = base64_encode($data['php_ajaxmethod']); + } + + // Set the php_document string to base64 string. + if (isset($data['php_document'])) + { + $data['php_document'] = base64_encode($data['php_document']); + } + + // Set the php_view string to base64 string. + if (isset($data['php_view'])) + { + $data['php_view'] = base64_encode($data['php_view']); + } + + // Set the php_jview_display string to base64 string. + if (isset($data['php_jview_display'])) + { + $data['php_jview_display'] = base64_encode($data['php_jview_display']); + } + + // Set the php_jview string to base64 string. + if (isset($data['php_jview'])) + { + $data['php_jview'] = base64_encode($data['php_jview']); + } + + // Set the php_controller string to base64 string. + if (isset($data['php_controller'])) + { + $data['php_controller'] = base64_encode($data['php_controller']); + } + + // Set the php_model string to base64 string. + if (isset($data['php_model'])) + { + $data['php_model'] = base64_encode($data['php_model']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Site_viewsModel.php b/admin/src/Model/Site_viewsModel.php new file mode 100644 index 000000000..b829523aa --- /dev/null +++ b/admin/src/Model/Site_viewsModel.php @@ -0,0 +1,828 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\FormHelper as JCBFormHelper; +use VDM\Joomla\Componentbuilder\Utilities\FilterHelper as JCBFilterHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Site_views List Model + * + * @since 1.6 + */ +class Site_viewsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/site_views.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'g.name','main_get', + 'a.add_php_ajax','add_php_ajax', + 'a.add_custom_button','add_custom_button', + 'a.system_name','system_name', + 'a.name','name', + 'a.description','description', + 'a.context','context' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Get the filter form - Override the parent method + * + * @param array $data data + * @param boolean $loadData load current data + * + * @return \JForm|boolean The \JForm object or false on error + * + * @since JCB 2.12.5 + */ + public function getFilterForm($data = array(), $loadData = true) + { + // load form from the parent class + $form = parent::getFilterForm($data, $loadData); + + // Create the "joomla_component" filter + $attributes = array( + 'name' => 'joomla_component', + 'type' => 'list', + 'onchange' => 'this.form.submit();', + ); + $options = array( + '' => '- ' . Text::_('COM_COMPONENTBUILDER_NO_COMPONENTS_FOUND') . ' -' + ); + // check if we have joomla components + if (($joomla_components = JCBFilterHelper::names('joomla_component')) !== null) + { + $options = array( + '' => '- ' . Text::_('COM_COMPONENTBUILDER_SELECT_COMPONENT') . ' -' + ); + // make sure we do not lose the key values in normal merge + $options = $options + $joomla_components; + } + + $form->setField(JCBFormHelper::xml($attributes, $options),'filter'); + $form->setValue( + 'joomla_component', + 'filter', + $this->state->get("filter.joomla_component") + ); + array_push($this->filter_fields, 'joomla_component'); + + return $form; + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $main_get = $this->getUserStateFromRequest($this->context . '.filter.main_get', 'filter_main_get'); + if ($formSubmited) + { + $main_get = $app->input->post->get('main_get'); + $this->setState('filter.main_get', $main_get); + } + + $add_php_ajax = $this->getUserStateFromRequest($this->context . '.filter.add_php_ajax', 'filter_add_php_ajax'); + if ($formSubmited) + { + $add_php_ajax = $app->input->post->get('add_php_ajax'); + $this->setState('filter.add_php_ajax', $add_php_ajax); + } + + $add_custom_button = $this->getUserStateFromRequest($this->context . '.filter.add_custom_button', 'filter_add_custom_button'); + if ($formSubmited) + { + $add_custom_button = $app->input->post->get('add_custom_button'); + $this->setState('filter.add_custom_button', $add_custom_button); + } + + $system_name = $this->getUserStateFromRequest($this->context . '.filter.system_name', 'filter_system_name'); + if ($formSubmited) + { + $system_name = $app->input->post->get('system_name'); + $this->setState('filter.system_name', $system_name); + } + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + $description = $this->getUserStateFromRequest($this->context . '.filter.description', 'filter_description'); + if ($formSubmited) + { + $description = $app->input->post->get('description'); + $this->setState('filter.description', $description); + } + + $context = $this->getUserStateFromRequest($this->context . '.filter.context', 'filter_context'); + if ($formSubmited) + { + $context = $app->input->post->get('context'); + $this->setState('filter.context', $context); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('site_view.access', 'com_componentbuilder.site_view.' . (int) $item->id) && $user->authorise('site_view.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // set selection value to a translatable value + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // convert add_php_ajax + $item->add_php_ajax = $this->selectionTranslation($item->add_php_ajax, 'add_php_ajax'); + // convert add_custom_button + $item->add_custom_button = $this->selectionTranslation($item->add_custom_button, 'add_custom_button'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return string The translatable string. + */ + public function selectionTranslation($value,$name) + { + // Array of add_php_ajax language strings + if ($name === 'add_php_ajax') + { + $add_php_ajaxArray = array( + 1 => 'COM_COMPONENTBUILDER_SITE_VIEW_YES', + 0 => 'COM_COMPONENTBUILDER_SITE_VIEW_NO' + ); + // Now check if value is found in this array + if (isset($add_php_ajaxArray[$value]) && StringHelper::check($add_php_ajaxArray[$value])) + { + return $add_php_ajaxArray[$value]; + } + } + // Array of add_custom_button language strings + if ($name === 'add_custom_button') + { + $add_custom_buttonArray = array( + 1 => 'COM_COMPONENTBUILDER_SITE_VIEW_YES', + 0 => 'COM_COMPONENTBUILDER_SITE_VIEW_NO' + ); + // Now check if value is found in this array + if (isset($add_custom_buttonArray[$value]) && StringHelper::check($add_custom_buttonArray[$value])) + { + return $add_custom_buttonArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_site_view', 'a')); + + // do not use these filters in the export method + if (!isset($_export) || !$_export) + { + // Filtering "joomla components" + $filter_joomla_component = $this->state->get("filter.joomla_component"); + if ($filter_joomla_component !== null && !empty($filter_joomla_component)) + { + if (($ids = JCBFilterHelper::linked((int) $filter_joomla_component, 'joomla_component_site_views')) !== null) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')'); + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + } + } + } + + // From the componentbuilder_dynamic_get table. + $query->select($db->quoteName('g.name','main_get_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_dynamic_get', 'g') . ' ON (' . $db->quoteName('a.main_get') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.system_name LIKE '.$search.' OR a.name LIKE '.$search.' OR a.description LIKE '.$search.' OR a.main_get LIKE '.$search.' OR g.name LIKE '.$search.' OR a.codename LIKE '.$search.' OR a.context LIKE '.$search.')'); + } + } + + // Filter by Main_get. + $_main_get = $this->getState('filter.main_get'); + if (is_numeric($_main_get)) + { + if (is_float($_main_get)) + { + $query->where('a.main_get = ' . (float) $_main_get); + } + else + { + $query->where('a.main_get = ' . (int) $_main_get); + } + } + elseif (StringHelper::check($_main_get)) + { + $query->where('a.main_get = ' . $db->quote($db->escape($_main_get))); + } + elseif (UtilitiesArrayHelper::check($_main_get)) + { + // Secure the array for the query + $_main_get = array_map( function ($val) use(&$db) { + if (is_numeric($val)) + { + if (is_float($val)) + { + return (float) $val; + } + else + { + return (int) $val; + } + } + elseif (StringHelper::check($val)) + { + return $db->quote($db->escape($val)); + } + }, $_main_get); + // Filter by the Main_get Array. + $query->where('a.main_get IN (' . implode(',', $_main_get) . ')'); + } + // Filter by Add_php_ajax. + $_add_php_ajax = $this->getState('filter.add_php_ajax'); + if (is_numeric($_add_php_ajax)) + { + if (is_float($_add_php_ajax)) + { + $query->where('a.add_php_ajax = ' . (float) $_add_php_ajax); + } + else + { + $query->where('a.add_php_ajax = ' . (int) $_add_php_ajax); + } + } + elseif (StringHelper::check($_add_php_ajax)) + { + $query->where('a.add_php_ajax = ' . $db->quote($db->escape($_add_php_ajax))); + } + // Filter by Add_custom_button. + $_add_custom_button = $this->getState('filter.add_custom_button'); + if (is_numeric($_add_custom_button)) + { + if (is_float($_add_custom_button)) + { + $query->where('a.add_custom_button = ' . (float) $_add_custom_button); + } + else + { + $query->where('a.add_custom_button = ' . (int) $_add_custom_button); + } + } + elseif (StringHelper::check($_add_custom_button)) + { + $query->where('a.add_custom_button = ' . $db->quote($db->escape($_add_custom_button))); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get list export data. + * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExportData($pks, $user = null) + { + // setup the query + if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks) + { + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + $_export = true; + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_site_view table + $query->from($db->quoteName('#__componentbuilder_site_view', 'a')); + // The bulk export path + if ('bulk' === $pks) + { + $query->where('a.id > 0'); + } + // A large array of ID's will not work out well + elseif ($pks_size > 500) + { + // Use lowest ID + $query->where('a.id >= ' . (int) min($pks)); + // Use highest ID + $query->where('a.id <= ' . (int) max($pks)); + } + // The normal default path + else + { + $query->where('a.id IN (' . implode(',',$pks) . ')'); + } + + // do not use these filters in the export method + if (!isset($_export) || !$_export) + { + // Filtering "joomla components" + $filter_joomla_component = $this->state->get("filter.joomla_component"); + if ($filter_joomla_component !== null && !empty($filter_joomla_component)) + { + if (($ids = JCBFilterHelper::linked((int) $filter_joomla_component, 'joomla_component_site_views')) !== null) + { + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')'); + } + else + { + // there is none + $query->where($db->quoteName('a.id') . ' = ' . 0); + } + } + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.id desc'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('site_view.access', 'com_componentbuilder.site_view.' . (int) $item->id) && $user->authorise('site_view.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // decode js_document + $item->js_document = base64_decode($item->js_document); + // decode javascript_file + $item->javascript_file = base64_decode($item->javascript_file); + // decode default + $item->default = base64_decode($item->default); + // decode css_document + $item->css_document = base64_decode($item->css_document); + // decode css + $item->css = base64_decode($item->css); + // decode php_ajaxmethod + $item->php_ajaxmethod = base64_decode($item->php_ajaxmethod); + // decode php_document + $item->php_document = base64_decode($item->php_document); + // decode php_view + $item->php_view = base64_decode($item->php_view); + // decode php_jview_display + $item->php_jview_display = base64_decode($item->php_jview_display); + // decode php_jview + $item->php_jview = base64_decode($item->php_jview); + // decode php_controller + $item->php_controller = base64_decode($item->php_controller); + // decode php_model + $item->php_model = base64_decode($item->php_model); + // unset the values we don't want exported. + unset($item->asset_id); + unset($item->checked_out); + unset($item->checked_out_time); + } + } + // Add headers to items array. + $headers = $this->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + array_unshift($items,$headers); + } + return $items; + } + } + 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 = Factory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_site_view"); + if (UtilitiesArrayHelper::check($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; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + // Check if the value is an array + $_main_get = $this->getState('filter.main_get'); + if (UtilitiesArrayHelper::check($_main_get)) + { + $id .= ':' . implode(':', $_main_get); + } + // Check if this is only an number or string + elseif (is_numeric($_main_get) + || StringHelper::check($_main_get)) + { + $id .= ':' . $_main_get; + } + $id .= ':' . $this->getState('filter.add_php_ajax'); + $id .= ':' . $this->getState('filter.add_custom_button'); + $id .= ':' . $this->getState('filter.system_name'); + $id .= ':' . $this->getState('filter.name'); + $id .= ':' . $this->getState('filter.description'); + $id .= ':' . $this->getState('filter.context'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_site_view')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_site_view'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/SnippetModel.php b/admin/src/Model/SnippetModel.php new file mode 100644 index 000000000..f1b7dbb08 --- /dev/null +++ b/admin/src/Model/SnippetModel.php @@ -0,0 +1,1005 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Snippet Admin Model + * + * @since 1.6 + */ +class SnippetModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'type', + 'heading', + 'description', + 'usage' + ), + 'right' => array( + 'snippet' + ), + 'above' => array( + 'name', + 'url', + 'library' + ) + ), + 'contributor' => array( + 'left' => array( + 'contributor_company', + 'contributor_website' + ), + 'right' => array( + 'contributor_name', + 'contributor_email' + ), + 'fullwidth' => array( + 'note_contributor_details' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/snippet.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/snippet.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.snippet'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'snippet', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->snippet)) + { + // base64 Decode snippet. + $item->snippet = base64_decode($item->snippet); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.snippet', 'snippet', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('core.edit.state', 'com_componentbuilder.snippet.' . (int) $id)) + || ($id == 0 && !$user->authorise('core.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if (!$user->authorise('core.edit.created_by', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if (!$user->authorise('core.edit.created', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // Only load the GUID if new item (or empty) + if (0 == $id || !($val = $form->getValue('guid'))) + { + $form->setValue('guid', null, GuidHelper::get()); + } + + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('core.delete', 'com_componentbuilder.snippet.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('core.edit.state', 'com_componentbuilder.snippet.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return parent::canEditState($record); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('core.edit', 'com_componentbuilder.snippet.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('core.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_snippet')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.snippet.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.snippet', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return array('guid'); + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('snippet'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('snippet'); + } + + if (!$this->canDo->get('core.create') && !$this->canDo->get('snippet.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('core.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('core.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->name) && !is_numeric($this->table->name)) + { + $this->table->name = $this->generateUnique('name',$this->table->name); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('snippet'); + } + + if (!$this->canDo->get('core.edit') && !$this->canDo->get('snippet.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('core.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('core.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // set the contributor details if not set + if (strlen($data['contributor_company']) < 1 || strlen($data['contributor_name']) < 1 || strlen($data['contributor_email']) < 3 || strlen($data['contributor_website']) < 3) + { + // get the library name + $library = ($name = GetHelper::var('library', $item['library'], 'id', 'name')) ? $name:'Common'; + // get the library name + $type = ($name = GetHelper::var('snippet_type', $item['type'], 'id', 'name')) ? $name:'No Library'; + // build the filename + $filename = UtilitiesStringHelper::safe($library . ' - (' . $type . ') ' . $item['name'], 'filename', '', false). '.json'; + // now get the contributor details (slow) + $contributor = ComponentbuilderHelper::getContributorDetails($filename); + // now update the local snippet contributor details + $data['contributor_company'] = $contributor['contributor_company']; + $data['contributor_name'] = $contributor['contributor_name']; + $data['contributor_email'] = $contributor['contributor_email']; + $data['contributor_website'] = $contributor['contributor_website']; + } + + // Set the GUID if empty or not valid + if (empty($data['guid']) && $data['id'] > 0) + { + // get the existing one + $data['guid'] = (string) GetHelper::var('snippet', $data['id'], 'id', 'guid'); + } + + // Set the GUID if empty or not valid + while (!GuidHelper::valid($data['guid'], "snippet", $data['id'])) + { + // must always be set + $data['guid'] = (string) GuidHelper::get(); + } + + // Set the snippet string to base64 string. + if (isset($data['snippet'])) + { + $data['snippet'] = base64_encode($data['snippet']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Snippet_typeModel.php b/admin/src/Model/Snippet_typeModel.php new file mode 100644 index 000000000..73f5b6c07 --- /dev/null +++ b/admin/src/Model/Snippet_typeModel.php @@ -0,0 +1,931 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Snippet_type Admin Model + * + * @since 1.6 + */ +class Snippet_typeModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'name' + ), + 'right' => array( + 'description' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/snippet_type.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/snippet_type.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.snippet_type'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'snippet_type', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.snippet_type', 'snippet_type', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('snippet_type.edit.state', 'com_componentbuilder.snippet_type.' . (int) $id)) + || ($id == 0 && !$user->authorise('snippet_type.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if (!$user->authorise('core.edit.created_by', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if (!$user->authorise('core.edit.created', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('snippet_type.delete', 'com_componentbuilder.snippet_type.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('snippet_type.edit.state', 'com_componentbuilder.snippet_type.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('snippet_type.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('snippet_type.edit', 'com_componentbuilder.snippet_type.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('snippet_type.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_snippet_type')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.snippet_type.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.snippet_type', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('snippet_type'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('snippet_type'); + } + + if (!$this->canDo->get('snippet_type.create') && !$this->canDo->get('snippet_type.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('snippet_type.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('snippet_type.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->name) && !is_numeric($this->table->name)) + { + $this->table->name = $this->generateUnique('name',$this->table->name); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('snippet_type'); + } + + if (!$this->canDo->get('snippet_type.edit') && !$this->canDo->get('snippet_type.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('snippet_type.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('snippet_type.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Snippet_typesModel.php b/admin/src/Model/Snippet_typesModel.php new file mode 100644 index 000000000..38d35371d --- /dev/null +++ b/admin/src/Model/Snippet_typesModel.php @@ -0,0 +1,414 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Snippet_types List Model + * + * @since 1.6 + */ +class Snippet_typesModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/snippet_types.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.name','name', + 'a.description','description' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + $description = $this->getUserStateFromRequest($this->context . '.filter.description', 'filter_description'); + if ($formSubmited) + { + $description = $app->input->post->get('description'); + $this->setState('filter.description', $description); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('snippet_type.access', 'com_componentbuilder.snippet_type.' . (int) $item->id) && $user->authorise('snippet_type.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_snippet_type', 'a')); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.' OR a.description LIKE '.$search.')'); + } + } + + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.name'); + $id .= ':' . $this->getState('filter.description'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_snippet_type')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_snippet_type'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/SnippetsModel.php b/admin/src/Model/SnippetsModel.php new file mode 100644 index 000000000..53e51d9eb --- /dev/null +++ b/admin/src/Model/SnippetsModel.php @@ -0,0 +1,721 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Snippets List Model + * + * @since 1.6 + */ +class SnippetsModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/snippets.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'g.name','type', + 'h.name','library', + 'a.name','name', + 'a.url','url', + 'a.heading','heading' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + public $user; + public $zipPath; + + /** + * Method to build the export package + * + * @return bool on success. + */ + public function shareSnippets($pks) + { + // setup the query + if (UtilitiesArrayHelper::check($pks)) + { + // Get the user object. + if (!ObjectHelper::check($this->user)) + { + $this->user = Factory::getUser(); + } + // Create a new query object. + if (!ObjectHelper::check($this->_db)) + { + $this->_db = Factory::getDBO(); + } + $query = $this->_db->getQuery(true); + + // Select some fields + $query->select($this->_db->quoteName( + array('a.name','a.heading','a.description','a.usage','a.snippet','a.url','b.name','c.name','a.created','a.modified','a.contributor_company','a.contributor_name','a.contributor_email','a.contributor_website'), + array('name','heading','description','usage','snippet','url','type','library','created','modified','contributor_company','contributor_name','contributor_email','contributor_website') + )); + + // From the componentbuilder_snippet table + $query->from($this->_db->quoteName('#__componentbuilder_snippet', 'a')); + // From the componentbuilder_snippet_type table. + $query->join('LEFT', $this->_db->quoteName('#__componentbuilder_snippet_type', 'b') . ' ON (' . $this->_db->quoteName('a.type') . ' = ' . $this->_db->quoteName('b.id') . ')'); + // From the componentbuilder_library table. + $query->join('LEFT', $this->_db->quoteName('#__componentbuilder_library', 'c') . ' ON (' . $this->_db->quoteName('a.library') . ' = ' . $this->_db->quoteName('c.id') . ')'); + $query->where('a.id IN (' . implode(',',$pks) . ')'); + + // Implement View Level Access + if (!$this->user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $this->user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.ordering ASC'); + + // Load the items + $this->_db->setQuery($query); + $this->_db->execute(); + if ($this->_db->getNumRows()) + { + // load the items from db + $items = $this->_db->loadObjectList(); + // check if we have items + if (UtilitiesArrayHelper::check($items)) + { + // get the shared paths + $this->fullPath = rtrim(ComponentbuilderHelper::getFolderPath('path', 'sharepath', Factory::getConfig()->get('tmp_path')), '/') . '/snippets'; + // remove old folder with the same name + if (JFolder::exists($this->fullPath)) + { + // remove if old folder is found + ComponentbuilderHelper::removeFolder($this->fullPath); + } + // create the full path + JFolder::create($this->fullPath); + // set zip path + $this->zipPath = $this->fullPath .'.zip'; + // remove old zip files with the same name + if (JFile::exists($this->zipPath)) + { + // remove file if found + JFile::delete($this->zipPath); + } + // prep the item + foreach($items as $item) + { + // just unlock the snippet + $item->snippet = base64_decode($item->snippet); + // build filename + $fileName = StringHelper::safe($item->library . ' - (' . $item->type . ') ' . $item->name, 'filename', '', false) . '.json'; + // if the snippet has its own contributor details set, then do not change + if (!strlen($item->contributor_company) || !strlen($item->contributor_name) || !strlen($item->contributor_email) || !strlen($item->contributor_website)) + { + // load the correct contributor details to each snippet (this is very slow) + $_contributor = ComponentbuilderHelper::getContributorDetails($fileName); + $item->contributor_company = $_contributor['contributor_company']; + $item->contributor_name = $_contributor['contributor_name']; + $item->contributor_email = $_contributor['contributor_email']; + $item->contributor_website = $_contributor['contributor_website']; + } + // now store the snippet info + ComponentbuilderHelper::writeFile($this->fullPath . '/' . $fileName, json_encode($item, JSON_PRETTY_PRINT)); + } + // zip the folder + if (!ComponentbuilderHelper::zip($this->fullPath, $this->zipPath)) + { + return false; + } + // remove the folder + if (!ComponentbuilderHelper::removeFolder($this->fullPath)) + { + return false; + } + return true; + } + } + } + return false; + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $type = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type'); + if ($formSubmited) + { + $type = $app->input->post->get('type'); + $this->setState('filter.type', $type); + } + + $library = $this->getUserStateFromRequest($this->context . '.filter.library', 'filter_library'); + if ($formSubmited) + { + $library = $app->input->post->get('library'); + $this->setState('filter.library', $library); + } + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + $url = $this->getUserStateFromRequest($this->context . '.filter.url', 'filter_url'); + if ($formSubmited) + { + $url = $app->input->post->get('url'); + $this->setState('filter.url', $url); + } + + $heading = $this->getUserStateFromRequest($this->context . '.filter.heading', 'filter_heading'); + if ($formSubmited) + { + $heading = $app->input->post->get('heading'); + $this->setState('filter.heading', $heading); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('snippet.access', 'com_componentbuilder.snippet.' . (int) $item->id) && $user->authorise('snippet.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_snippet', 'a')); + + // From the componentbuilder_snippet_type table. + $query->select($db->quoteName('g.name','type_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_snippet_type', 'g') . ' ON (' . $db->quoteName('a.type') . ' = ' . $db->quoteName('g.id') . ')'); + + // From the componentbuilder_library table. + $query->select($db->quoteName('h.name','library_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_library', 'h') . ' ON (' . $db->quoteName('a.library') . ' = ' . $db->quoteName('h.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.' OR a.url LIKE '.$search.' OR a.type LIKE '.$search.' OR g.name LIKE '.$search.' OR a.heading LIKE '.$search.' OR a.library LIKE '.$search.' OR h.name LIKE '.$search.' OR a.description LIKE '.$search.')'); + } + } + + // Filter by Type. + $_type = $this->getState('filter.type'); + if (is_numeric($_type)) + { + if (is_float($_type)) + { + $query->where('a.type = ' . (float) $_type); + } + else + { + $query->where('a.type = ' . (int) $_type); + } + } + elseif (StringHelper::check($_type)) + { + $query->where('a.type = ' . $db->quote($db->escape($_type))); + } + // Filter by Library. + $_library = $this->getState('filter.library'); + if (is_numeric($_library)) + { + if (is_float($_library)) + { + $query->where('a.library = ' . (float) $_library); + } + else + { + $query->where('a.library = ' . (int) $_library); + } + } + elseif (StringHelper::check($_library)) + { + $query->where('a.library = ' . $db->quote($db->escape($_library))); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get list export data. + * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExportData($pks, $user = null) + { + // setup the query + if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks) + { + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + $_export = true; + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_snippet table + $query->from($db->quoteName('#__componentbuilder_snippet', 'a')); + // The bulk export path + if ('bulk' === $pks) + { + $query->where('a.id > 0'); + } + // A large array of ID's will not work out well + elseif ($pks_size > 500) + { + // Use lowest ID + $query->where('a.id >= ' . (int) min($pks)); + // Use highest ID + $query->where('a.id <= ' . (int) max($pks)); + } + // The normal default path + else + { + $query->where('a.id IN (' . implode(',',$pks) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.id desc'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('snippet.access', 'com_componentbuilder.snippet.' . (int) $item->id) && $user->authorise('snippet.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // decode snippet + $item->snippet = base64_decode($item->snippet); + // unset the values we don't want exported. + unset($item->asset_id); + unset($item->checked_out); + unset($item->checked_out_time); + } + } + // Add headers to items array. + $headers = $this->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + array_unshift($items,$headers); + } + return $items; + } + } + 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 = Factory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_snippet"); + if (UtilitiesArrayHelper::check($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; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.type'); + $id .= ':' . $this->getState('filter.library'); + $id .= ':' . $this->getState('filter.name'); + $id .= ':' . $this->getState('filter.url'); + $id .= ':' . $this->getState('filter.heading'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_snippet')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_snippet'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/TemplateModel.php b/admin/src/Model/TemplateModel.php new file mode 100644 index 000000000..2b508da24 --- /dev/null +++ b/admin/src/Model/TemplateModel.php @@ -0,0 +1,1174 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Template Admin Model + * + * @since 1.6 + */ +class TemplateModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'name', + 'alias', + 'description', + 'note_libraries_selection', + 'libraries', + 'note_add_php_language_string' + ), + 'right' => array( + 'snippet', + 'note_snippet_usage', + 'note_uikit_snippet' + ), + 'fullwidth' => array( + 'template' + ), + 'under' => array( + 'not_required' + ), + 'rightside' => array( + 'dynamic_get', + 'dynamic_values' + ) + ), + 'custom_script' => array( + 'fullwidth' => array( + 'add_php_view', + 'php_view' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/template.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/template.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.template'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'template', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('template__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'template__'.$id); + ComponentbuilderHelper::set('template__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->php_view)) + { + // base64 Decode php_view. + $item->php_view = base64_decode($item->php_view); + } + + if (!empty($item->template)) + { + // base64 Decode template. + $item->template = base64_decode($item->template); + } + + if (!empty($item->libraries)) + { + // Convert the libraries field to an array. + $libraries = new Registry; + $libraries->loadString($item->libraries); + $item->libraries = $libraries->toArray(); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('template__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'template__'.$id); + ComponentbuilderHelper::set('template__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.template', 'template', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('core.edit.state', 'com_componentbuilder.template.' . (int) $id)) + || ($id == 0 && !$user->authorise('core.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if (!$user->authorise('core.edit.created_by', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if (!$user->authorise('core.edit.created', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // update all editors to use this components global editor + $global_editor = ComponentHelper::getParams('com_componentbuilder')->get('editor', 'none'); + // now get all the editor fields + $editors = $form->getXml()->xpath("//field[@type='editor']"); + // check if we found any + if (UtilitiesArrayHelper::check($editors)) + { + foreach ($editors as $editor) + { + // get the field names + $name = (string) $editor['name']; + // set the field editor value (with none as fallback) + $form->setFieldAttribute($name, 'editor', $global_editor . '|none'); + } + } + + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('core.delete', 'com_componentbuilder.template.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('core.edit.state', 'com_componentbuilder.template.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return parent::canEditState($record); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('core.edit', 'com_componentbuilder.template.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('core.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_template')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.template.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.template', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('template'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('template'); + } + + if (!$this->canDo->get('core.create') && !$this->canDo->get('template.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('core.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('core.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + list($this->table->name, $this->table->alias) = $this->_generateNewTitle($this->table->alias, $this->table->name); + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('template'); + } + + if (!$this->canDo->get('core.edit') && !$this->canDo->get('template.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('core.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('core.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // always reset the snippets + $data['snippet'] = 0; + + // Set the libraries items to data. + if (isset($data['libraries']) && is_array($data['libraries'])) + { + $libraries = new Registry; + $libraries->loadArray($data['libraries']); + $data['libraries'] = (string) $libraries; + } + elseif (!isset($data['libraries'])) + { + // Set the empty libraries to data + $data['libraries'] = ''; + } + + // Set the php_view string to base64 string. + if (isset($data['php_view'])) + { + $data['php_view'] = base64_encode($data['php_view']); + } + + // Set the template string to base64 string. + if (isset($data['template'])) + { + $data['template'] = base64_encode($data['template']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the name for save as copy + if ($input->get('task') === 'save2copy') + { + $origTable = clone $this->getTable(); + $origTable->load($input->getInt('id')); + + if ($data['name'] == $origTable->name) + { + list($name, $alias) = $this->_generateNewTitle($data['alias'], $data['name']); + $data['name'] = $name; + $data['alias'] = $alias; + } + else + { + if ($data['alias'] == $origTable->alias) + { + $data['alias'] = ''; + } + } + + $data['published'] = 0; + } + + // Automatic handling of alias for empty fields + if (in_array($input->get('task'), array('apply', 'save', 'save2new')) && (int) $input->get('id') == 0) + { + if ($data['alias'] == null || empty($data['alias'])) + { + if (Factory::getConfig()->get('unicodeslugs') == 1) + { + $data['alias'] = OutputFilter::stringURLUnicodeSlug($data['name']); + } + else + { + $data['alias'] = OutputFilter::stringURLSafe($data['name']); + } + + $table = clone $this->getTable(); + + if ($table->load(array('alias' => $data['alias'])) && ($table->id != $data['id'] || $data['id'] == 0)) + { + $msg = Text::_('COM_COMPONENTBUILDER_TEMPLATE_SAVE_WARNING'); + } + + $data['alias'] = $this->_generateNewTitle($data['alias']); + + if (isset($msg)) + { + Factory::getApplication()->enqueueMessage($msg, 'warning'); + } + } + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title/s & alias. + * + * @param string $alias The alias. + * @param string/array $title The title. + * + * @return array/string Contains the modified title/s and/or alias. + * + */ + protected function _generateNewTitle($alias, $title = null) + { + + // Alter the title/s & alias + $table = $this->getTable(); + + while ($table->load(['alias' => $alias])) + { + // Check if this is an array of titles + if (UtilitiesArrayHelper::check($title)) + { + foreach($title as $nr => &$_title) + { + $_title = StringHelper::increment($_title); + } + } + // Make sure we have a title + elseif ($title) + { + $title = StringHelper::increment($title); + } + $alias = StringHelper::increment($alias, 'dash'); + } + // Check if this is an array of titles + if (UtilitiesArrayHelper::check($title)) + { + $title[] = $alias; + return $title; + } + // Make sure we have a title + elseif ($title) + { + return array($title, $alias); + } + // We only had an alias + return $alias; + } +} diff --git a/admin/src/Model/TemplatesModel.php b/admin/src/Model/TemplatesModel.php new file mode 100644 index 000000000..58976d4d1 --- /dev/null +++ b/admin/src/Model/TemplatesModel.php @@ -0,0 +1,630 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Templates List Model + * + * @since 1.6 + */ +class TemplatesModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/templates.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'g.name','dynamic_get', + 'a.add_php_view','add_php_view', + 'a.name','name', + 'a.description','description' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $dynamic_get = $this->getUserStateFromRequest($this->context . '.filter.dynamic_get', 'filter_dynamic_get'); + if ($formSubmited) + { + $dynamic_get = $app->input->post->get('dynamic_get'); + $this->setState('filter.dynamic_get', $dynamic_get); + } + + $add_php_view = $this->getUserStateFromRequest($this->context . '.filter.add_php_view', 'filter_add_php_view'); + if ($formSubmited) + { + $add_php_view = $app->input->post->get('add_php_view'); + $this->setState('filter.add_php_view', $add_php_view); + } + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + $description = $this->getUserStateFromRequest($this->context . '.filter.description', 'filter_description'); + if ($formSubmited) + { + $description = $app->input->post->get('description'); + $this->setState('filter.description', $description); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('template.access', 'com_componentbuilder.template.' . (int) $item->id) && $user->authorise('template.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // set selection value to a translatable value + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // convert add_php_view + $item->add_php_view = $this->selectionTranslation($item->add_php_view, 'add_php_view'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return string The translatable string. + */ + public function selectionTranslation($value,$name) + { + // Array of add_php_view language strings + if ($name === 'add_php_view') + { + $add_php_viewArray = array( + 1 => 'COM_COMPONENTBUILDER_TEMPLATE_YES', + 0 => 'COM_COMPONENTBUILDER_TEMPLATE_NO' + ); + // Now check if value is found in this array + if (isset($add_php_viewArray[$value]) && StringHelper::check($add_php_viewArray[$value])) + { + return $add_php_viewArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_template', 'a')); + + // From the componentbuilder_dynamic_get table. + $query->select($db->quoteName('g.name','dynamic_get_name')); + $query->join('LEFT', $db->quoteName('#__componentbuilder_dynamic_get', 'g') . ' ON (' . $db->quoteName('a.dynamic_get') . ' = ' . $db->quoteName('g.id') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.' OR a.description LIKE '.$search.' OR a.dynamic_get LIKE '.$search.' OR g.name LIKE '.$search.' OR a.alias LIKE '.$search.')'); + } + } + + // Filter by Dynamic_get. + $_dynamic_get = $this->getState('filter.dynamic_get'); + if (is_numeric($_dynamic_get)) + { + if (is_float($_dynamic_get)) + { + $query->where('a.dynamic_get = ' . (float) $_dynamic_get); + } + else + { + $query->where('a.dynamic_get = ' . (int) $_dynamic_get); + } + } + elseif (StringHelper::check($_dynamic_get)) + { + $query->where('a.dynamic_get = ' . $db->quote($db->escape($_dynamic_get))); + } + // Filter by Add_php_view. + $_add_php_view = $this->getState('filter.add_php_view'); + if (is_numeric($_add_php_view)) + { + if (is_float($_add_php_view)) + { + $query->where('a.add_php_view = ' . (float) $_add_php_view); + } + else + { + $query->where('a.add_php_view = ' . (int) $_add_php_view); + } + } + elseif (StringHelper::check($_add_php_view)) + { + $query->where('a.add_php_view = ' . $db->quote($db->escape($_add_php_view))); + } + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get list export data. + * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExportData($pks, $user = null) + { + // setup the query + if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks) + { + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + $_export = true; + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_template table + $query->from($db->quoteName('#__componentbuilder_template', 'a')); + // The bulk export path + if ('bulk' === $pks) + { + $query->where('a.id > 0'); + } + // A large array of ID's will not work out well + elseif ($pks_size > 500) + { + // Use lowest ID + $query->where('a.id >= ' . (int) min($pks)); + // Use highest ID + $query->where('a.id <= ' . (int) max($pks)); + } + // The normal default path + else + { + $query->where('a.id IN (' . implode(',',$pks) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.id desc'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('template.access', 'com_componentbuilder.template.' . (int) $item->id) && $user->authorise('template.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // decode php_view + $item->php_view = base64_decode($item->php_view); + // decode template + $item->template = base64_decode($item->template); + // unset the values we don't want exported. + unset($item->asset_id); + unset($item->checked_out); + unset($item->checked_out_time); + } + } + // Add headers to items array. + $headers = $this->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + array_unshift($items,$headers); + } + return $items; + } + } + 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 = Factory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_template"); + if (UtilitiesArrayHelper::check($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; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.dynamic_get'); + $id .= ':' . $this->getState('filter.add_php_view'); + $id .= ':' . $this->getState('filter.name'); + $id .= ':' . $this->getState('filter.description'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_template')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_template'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/src/Model/Validation_ruleModel.php b/admin/src/Model/Validation_ruleModel.php new file mode 100644 index 000000000..068a4f7a8 --- /dev/null +++ b/admin/src/Model/Validation_ruleModel.php @@ -0,0 +1,1031 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Table\Table; +use Joomla\CMS\UCM\UCMType; +use Joomla\CMS\Versioning\VersionableModelTrait; +use Joomla\CMS\User\User; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Validation_rule Admin Model + * + * @since 1.6 + */ +class Validation_ruleModel extends AdminModel +{ + use VersionableModelTrait; + + /** + * The tab layout fields array. + * + * @var array + * @since 3.0.0 + */ + protected $tabLayoutFields = array( + 'extends_formrule' => array( + 'left' => array( + 'name' + ), + 'right' => array( + 'short_description' + ), + 'fullwidth' => array( + 'php' + ), + 'above' => array( + 'inherit' + ) + ) + ); + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/validation_rule.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js', + 'media/com_componentbuilder/js/validation_rule.js' + ]; + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_COMPONENTBUILDER'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_componentbuilder.validation_rule'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return Table A database object + * @since 3.0 + * @throws \Exception + */ + public function getTable($type = 'validation_rule', $prefix = 'Administrator', $config = []) + { + // get instance of the table + return parent::getTable($type, $prefix, $config); + } + + + /** + * get VDM internal session key + * + * @return string the session key + * + */ + public function getVDM() + { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('validation_rule__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'validation_rule__'.$id); + ComponentbuilderHelper::set('validation_rule__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + return $this->vastDevMod; + } + + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->php)) + { + // base64 Decode php. + $item->php = base64_decode($item->php); + } + + + if (empty($item->id)) + { + $id = 0; + } + else + { + $id = $item->id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('validation_rule__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = UtilitiesStringHelper::random(50); + ComponentbuilderHelper::set($this->vastDevMod, 'validation_rule__'.$id); + ComponentbuilderHelper::set('validation_rule__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = Factory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ObjectHelper::check($item) && isset($item->guid) + && GuidHelper::valid($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return Form|boolean A Form object on success, false on failure + * @since 1.6 + */ + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_componentbuilder.validation_rule', 'validation_rule', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = Factory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = Factory::getApplication()->getIdentity(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('validation_rule.edit.state', 'com_componentbuilder.validation_rule.' . (int) $id)) + || ($id == 0 && !$user->authorise('validation_rule.edit.state', 'com_componentbuilder'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if (!$user->authorise('core.edit.created_by', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if (!$user->authorise('core.edit.created', 'com_componentbuilder')) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canDelete($record) + { + if (empty($record->id) || ($record->published != -2)) + { + return false; + } + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('validation_rule.delete', 'com_componentbuilder.validation_rule.' . (int) $record->id); + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * @since 1.6 + */ + protected function canEditState($record) + { + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('validation_rule.edit.state', 'com_componentbuilder.validation_rule.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absence of better information, revert to the component permissions. + return $user->authorise('validation_rule.edit.state', 'com_componentbuilder'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = [], $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = Factory::getApplication()->getIdentity(); + + return $user->authorise('validation_rule.edit', 'com_componentbuilder.validation_rule.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('validation_rule.edit', 'com_componentbuilder'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param Table $table A Table object. + * + * @return void + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = Factory::getDate(); + $user = $this->getCurrentUser(); + + if (isset($table->name)) + { + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__componentbuilder_validation_rule')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState('com_componentbuilder.edit.validation_rule.data', []); + + if (empty($data)) + { + $data = $this->getItem(); + } + + // run the perprocess of the data + $this->preprocessData('com_componentbuilder.validation_rule', $data); + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(Text::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user ??= $this->getCurrentUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new UCMType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = ComponentbuilderHelper::getActions('validation_rule'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new UCMType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('validation_rule'); + } + + if (!$this->canDo->get('validation_rule.create') && !$this->canDo->get('validation_rule.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('validation_rule.edit.state')) + { + $values['published'] = 0; + } + + $newIds = []; + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('validation_rule.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (UtilitiesStringHelper::check($this->table->name) && !is_numeric($this->table->name)) + { + $this->table->name = $this->generateUnique('name',$this->table->name); + } + + // insert all set values + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = Factory::getApplication()->getIdentity(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = ComponentbuilderHelper::getActions('validation_rule'); + } + + if (!$this->canDo->get('validation_rule.edit') && !$this->canDo->get('validation_rule.batch')) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('validation_rule.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('validation_rule.edit', $contexts[$pk])) + { + $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (UtilitiesArrayHelper::check($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * @since 1.6 + */ + public function save($data) + { + $input = Factory::getApplication()->getInput(); + $filter = InputFilter::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new Registry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the php string to base64 string. + if (isset($data['php'])) + { + $data['php'] = base64_encode($data['php']); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new Registry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (UtilitiesArrayHelper::check($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * @since 3.0 + */ + protected function generateUnique($field, $value) + { + // set field value unique + $table = $this->getTable(); + + while ($table->load([$field => $value])) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(['title' => $title])) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/src/Model/Validation_rulesModel.php b/admin/src/Model/Validation_rulesModel.php new file mode 100644 index 000000000..ba8d1fb68 --- /dev/null +++ b/admin/src/Model/Validation_rulesModel.php @@ -0,0 +1,538 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Model; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplicationInterface; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\User\User; +use Joomla\Utilities\ArrayHelper; +use Joomla\Input\Input; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Helper\TagsHelper; +use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Validation_rules List Model + * + * @since 1.6 + */ +class Validation_rulesModel extends ListModel +{ + /** + * The application object. + * + * @var CMSApplicationInterface The application instance. + * @since 3.2.0 + */ + protected CMSApplicationInterface $app; + + /** + * The styles array. + * + * @var array + * @since 4.3 + */ + protected array $styles = [ + 'administrator/components/com_componentbuilder/assets/css/admin.css', + 'administrator/components/com_componentbuilder/assets/css/validation_rules.css' + ]; + + /** + * The scripts array. + * + * @var array + * @since 4.3 + */ + protected array $scripts = [ + 'administrator/components/com_componentbuilder/assets/js/admin.js' + ]; + + /** + * Constructor + * + * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). + * @param ?MVCFactoryInterface $factory The factory. + * + * @since 1.6 + * @throws \Exception + */ + public function __construct($config = [], MVCFactoryInterface $factory = null) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.name','name', + 'a.short_description','short_description' + ); + } + + parent::__construct($config, $factory); + + $this->app ??= Factory::getApplication(); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * @since 1.7.0 + */ + protected function populateState($ordering = null, $direction = null) + { + $app = $this->app; + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + $short_description = $this->getUserStateFromRequest($this->context . '.filter.short_description', 'filter_short_description'); + if ($formSubmited) + { + $short_description = $app->input->post->get('short_description'); + $this->setState('filter.short_description', $short_description); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * @since 1.6 + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('validation_rule.access', 'com_componentbuilder.validation_rule.' . (int) $item->id) && $user->authorise('validation_rule.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + * @since 1.6 + */ + protected function getListQuery() + { + // Get the user object. + $user = $this->getCurrentUser(); + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_item table + $query->from($db->quoteName('#__componentbuilder_validation_rule', 'a')); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (UtilitiesArrayHelper::check($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.' OR a.short_description LIKE '.$search.')'); + } + } + + + // Add the list ordering clause. + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); + if ($orderCol != '') + { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get list export data. + * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * + * @return mixed An array of data items on success, false on failure. + */ + public function getExportData($pks, $user = null) + { + // setup the query + if (($pks_size = UtilitiesArrayHelper::check($pks)) !== false || 'bulk' === $pks) + { + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + $_export = true; + // Get the user object if not set. + if (!isset($user) || !ObjectHelper::check($user)) + { + $user = $this->getCurrentUser(); + } + // Create a new query object. + $db = $this->getDatabase(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the componentbuilder_validation_rule table + $query->from($db->quoteName('#__componentbuilder_validation_rule', 'a')); + // The bulk export path + if ('bulk' === $pks) + { + $query->where('a.id > 0'); + } + // A large array of ID's will not work out well + elseif ($pks_size > 500) + { + // Use lowest ID + $query->where('a.id >= ' . (int) min($pks)); + // Use highest ID + $query->where('a.id <= ' . (int) max($pks)); + } + // The normal default path + else + { + $query->where('a.id IN (' . implode(',',$pks) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_componentbuilder')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.id desc'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (UtilitiesArrayHelper::check($items)) + { + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('validation_rule.access', 'com_componentbuilder.validation_rule.' . (int) $item->id) && $user->authorise('validation_rule.access', 'com_componentbuilder')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + // decode php + $item->php = base64_decode($item->php); + // unset the values we don't want exported. + unset($item->asset_id); + unset($item->checked_out); + unset($item->checked_out_time); + } + } + // Add headers to items array. + $headers = $this->getExImPortHeaders(); + if (ObjectHelper::check($headers)) + { + array_unshift($items,$headers); + } + return $items; + } + } + 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 = Factory::getDbo(); + // get the columns + $columns = $db->getTableColumns("#__componentbuilder_validation_rule"); + if (UtilitiesArrayHelper::check($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; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * @since 1.6 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (UtilitiesArrayHelper::check($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || StringHelper::check($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.name'); + $id .= ':' . $this->getState('filter.short_description'); + + return parent::getStoreId($id); + } + + /** + * Method to get the styles that have to be included on the view + * + * @return array styles files + * @since 4.3 + */ + public function getStyles(): array + { + return $this->styles; + } + + /** + * Method to set the styles that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setStyles(string $path): void + { + $this->styles[] = $path; + } + + /** + * Method to get the script that have to be included on the view + * + * @return array script files + * @since 4.3 + */ + public function getScripts(): array + { + return $this->scripts; + } + + /** + * Method to set the script that have to be included on the view + * + * @return void + * @since 4.3 + */ + public function setScript(string $path): void + { + $this->scripts[] = $path; + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return bool + * @since 3.2.0 + */ + protected function checkInNow(): bool + { + // Get set check in time + $time = ComponentHelper::getParams('com_componentbuilder')->get('check_in'); + + if ($time) + { + // Get a db connection. + $db = $this->getDatabase(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__componentbuilder_validation_rule')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = Factory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__componentbuilder_validation_rule'))->set($fields)->where($conditions); + + $db->setQuery($query); + + return $db->execute(); + } + } + + return false; + } +} diff --git a/admin/tables/index.html b/admin/src/Model/index.html similarity index 100% rename from admin/tables/index.html rename to admin/src/Model/index.html diff --git a/admin/src/Rule/CodeRule.php b/admin/src/Rule/CodeRule.php new file mode 100644 index 000000000..a3bbabc8a --- /dev/null +++ b/admin/src/Rule/CodeRule.php @@ -0,0 +1,61 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Rule; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Form\FormRule; +use Joomla\Registry\Registry; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('JPATH_PLATFORM') or die; + +/** + * Form Rule (Code) class for the Joomla Platform. + * + * @since 3.5 + */ +class CodeRule extends FormRule +{ + /** + * Method to test the value. + * + * @param \SimpleXMLElement $element The SimpleXMLElement object representing the `` tag for the form field object. + * @param mixed $value The form field value to validate. + * @param string $group The field name group control value. This acts as an array container for the field. + * For example if the field has name="foo" and the group value is set to "bar" then the + * full field name would end up being "bar[foo]". + * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. + * @param Form $form The form object for which the field is being tested. + * + * @return boolean True if the value is valid, false otherwise. + */ + public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null) + { + // This removes all validation (is dangerous) but needed to submit code via JCB + return true; + + /** + * My idea is to add some kind of validation to improve JCB code (per/language) + * + * So at this time this code validation is used for JavaScript,CSS,HTML and PHP. + * We can see what language is being worked on with the syntax property in the $element. (in JCB) + * What complicates things is the placeholders, of both custom code, component, and view names. + * Ideally we could strip them and then validate the code to being syntactically correct. + * But since some of the placeholders form part of the class/function names and the more, it seems like we are pressed for a much more advance solution. + * If you have any ideas to how we can go about to do this, then please open an issue on github and lets begin. (this is a nice to have, so don't break a leg...) + */ + } +} diff --git a/admin/src/Rule/GuidRule.php b/admin/src/Rule/GuidRule.php new file mode 100644 index 000000000..c216278f3 --- /dev/null +++ b/admin/src/Rule/GuidRule.php @@ -0,0 +1,62 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Rule; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Form\FormRule; +use Joomla\Registry\Registry; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('JPATH_PLATFORM') or die; + +/** + * Form Rule (Guid) class for the Joomla Platform. + * + * @since 3.5 + */ +class GuidRule extends FormRule +{ + /** + * Method to test for a Globally Unique Identifier. + * + * @param \SimpleXMLElement $element The SimpleXMLElement object representing the `` tag for the form field object. + * @param mixed $value The form field value to validate. + * @param string $group The field name group control value. This acts as an array container for the field. + * For example if the field has name="foo" and the group value is set to "bar" then the + * full field name would end up being "bar[foo]". + * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. + * @param Form $form The form object for which the field is being tested. + * + * @return boolean True if the value is valid, false otherwise. + * + */ + public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null) + { + $value = trim($value); + + // If the field is empty and not required, the field is valid. + $required = ((string) $element['required'] == 'true' || (string) $element['required'] == 'required'); + + if (!$required && empty($value)) + { + return true; + } + + // thanks to Lewie https://stackoverflow.com/a/1515456/1429677 + return preg_match("/^(\{)?[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}(?(1)\})$/i", $value); + } + +} diff --git a/admin/src/Rule/IntRule.php b/admin/src/Rule/IntRule.php new file mode 100644 index 000000000..25bc01833 --- /dev/null +++ b/admin/src/Rule/IntRule.php @@ -0,0 +1,64 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Rule; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Form\FormRule; +use Joomla\Registry\Registry; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('JPATH_PLATFORM') or die; + +/** + * Form Rule (Int) class for the Joomla Platform. + * + * @since 3.5 + */ +class IntRule extends FormRule +{ + /** + * Method to test that an integer value was added. + * + * @param \SimpleXMLElement $element The SimpleXMLElement object representing the `` tag for the form field object. + * @param mixed $value The form field value to validate. + * @param string $group The field name group control value. This acts as an array container for the field. + * For example if the field has name="foo" and the group value is set to "bar" then the + * full field name would end up being "bar[foo]". + * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. + * @param Form $form The form object for which the field is being tested. + * + * @return boolean True if the value is valid integer, false otherwise. + * + */ + public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null) + { + // Check if the field is required. + $required = ((string) $element['required'] == 'true' || (string) $element['required'] == 'required'); + + // If the value is empty and the field is not required return True. + if (($value === '' || $value === null) && ! $required) + { + return true; + } + + // now validate the value to be an integer + // we need to validate a string with the integer in it + // since this is how Joomla passes the value to the test method + // so we use type coercion along with is_numeric + return is_numeric($value) && is_int(+$value); + // if you have a better idea... lets hear it. + } +} diff --git a/admin/src/Rule/SourcemapcheckerRule.php b/admin/src/Rule/SourcemapcheckerRule.php new file mode 100644 index 000000000..c0a09eec5 --- /dev/null +++ b/admin/src/Rule/SourcemapcheckerRule.php @@ -0,0 +1,143 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Rule; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Form\FormRule; +use Joomla\Registry\Registry; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; + +// No direct access to this file +\defined('JPATH_PLATFORM') or die; + +/** + * Form Rule (Sourcemapchecker) class for the Joomla Platform. + * + * @since 3.5 + */ +class SourcemapcheckerRule extends FormRule +{ + /** + * Method to test if the selected source map has all the fields it would need + * + * @param \SimpleXMLElement $element The SimpleXMLElement object representing the `` tag for the form field object. + * @param mixed $value The form field value to validate. + * @param string $group The field name group control value. This acts as an array container for the field. + * For example if the field has name="foo" and the group value is set to "bar" then the + * full field name would end up being "bar[foo]". + * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. + * @param Form $form The form object for which the field is being tested. + * + * @return boolean True if the value is valid, false otherwise. + * + * @since 3.10.12 + */ + public function test(\SimpleXMLElement $element, $value, $group = null, ?Registry $input = null, ?Form $form = null) + { + $fields = $this->getSelectedFields($value); + + $status = true; + + if ($fields === []) + { + // no fields selected (not good) + $missing = Text::_('COM_COMPONENTBUILDER_NO_FIELDS_WHERE_SELECTED'); + $status = false; + } + // we only test if we have a table name + elseif (($table = $input->get('table')) !== null) + { + // the fields to ignore Since 3.2 + $ignore = [ + 'checked_out_time', + 'checked_out', + 'modified', + 'created', + 'modified_by', + 'created_by' + ]; + + // get the database object. + $db = Factory::getDbo(); + + $columnDetails = $db->getTableColumns('#__' . $table, false); + $requiredColumns = []; + + foreach ($columnDetails as $column => $details) + { + if (in_array($column, $ignore)) + { + continue; + } + + if ($details->Null === 'NO' && ($details->Default === null || strtolower($details->Extra) === 'auto_increment')) + { + $requiredColumns[] = $column; + } + } + + $_missing = array_diff($requiredColumns, $fields); + + if (!empty($_missing)) + { + // Format missing fields for better readability + $missing = implode(', ', $_missing); + $status = false; + } + } + + // when we fail + if (!$status) + { + Factory::getApplication()->enqueueMessage(Text::sprintf('COM_COMPONENTBUILDER_REQUIRED_FIELDS_MISSING_IN_THE_BMYSQL_TABLES_SOURCE_MAPB_SELECTIONBR_S', $missing), 'Error'); + } + + return $status; + } + + /** + * Method to get array of fields + * + * @param string|null $value + * + * @return array + * @since 3.2.0 + */ + private function getSelectedFields(?string $value): array + { + // reset array buckets + $fields = []; + // the other tables + if (is_string($value) && strpos((string) $value, PHP_EOL) !== false) + { + $lines = explode(PHP_EOL, (string) $value); + if (ArrayHelper::check($lines)) + { + foreach ($lines as $field) + { + if (strpos($field, "=>") !== false) + { + list($source) = explode( + "=>", $field, 2 + ); + $fields[] = trim($source); + } + } + } + } + return $fields; + } +} diff --git a/admin/src/Rule/UniqueplaceholderRule.php b/admin/src/Rule/UniqueplaceholderRule.php new file mode 100644 index 000000000..1e964fbdb --- /dev/null +++ b/admin/src/Rule/UniqueplaceholderRule.php @@ -0,0 +1,54 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Rule; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Form\FormRule; +use Joomla\Registry\Registry; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('JPATH_PLATFORM') or die; + +/** + * Form Rule (Uniqueplaceholder) class for the Joomla Platform. + * + * @since 3.5 + */ +class UniqueplaceholderRule extends FormRule +{ + /** + * Method to test the field value for uniqueness. + * + * @param \SimpleXMLElement $element The SimpleXMLElement object representing the `` tag for the form field object. + * @param mixed $value The form field value to validate. + * @param string $group The field name group control value. This acts as an array container for the field. + * For example if the field has name="foo" and the group value is set to "bar" then the + * full field name would end up being "bar[foo]". + * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. + * @param Form $form The form object for which the field is being tested. + * + * @return boolean True if the value is valid, false otherwise. + * + * @since 11.1 + */ + public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null) + { + // Get the extra field check attribute. + $id = ($input instanceof Registry) ? $input->get('id', null) : null; + // now test against all the placeholders and the compiler + return ComponentbuilderHelper::validateUniquePlaceholder($id, $value, true); + } +} diff --git a/admin/views/admin_custom_tabs/tmpl/index.html b/admin/src/Rule/index.html similarity index 100% rename from admin/views/admin_custom_tabs/tmpl/index.html rename to admin/src/Rule/index.html diff --git a/admin/views/admin_fields/tmpl/index.html b/admin/src/Service/index.html similarity index 100% rename from admin/views/admin_fields/tmpl/index.html rename to admin/src/Service/index.html diff --git a/admin/src/Table/Admin_custom_tabsTable.php b/admin/src/Table/Admin_custom_tabsTable.php new file mode 100644 index 000000000..4065d8a9e --- /dev/null +++ b/admin/src/Table/Admin_custom_tabsTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Admins_custom_tabs Table class + * + * @since 1.6 + */ +class Admin_custom_tabsTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.admin_custom_tabs'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_admin_custom_tabs', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Admin_custom_tabs table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New admin_custom_tabs. A admin_custom_tabs created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.admin_custom_tabs.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Admin_fieldsTable.php b/admin/src/Table/Admin_fieldsTable.php new file mode 100644 index 000000000..3746c6a88 --- /dev/null +++ b/admin/src/Table/Admin_fieldsTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Admins_fields Table class + * + * @since 1.6 + */ +class Admin_fieldsTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.admin_fields'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_admin_fields', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Admin_fields table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New admin_fields. A admin_fields created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_ADMIN_FIELDS_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_ADMIN_FIELDS_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.admin_fields.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Admin_fields_conditionsTable.php b/admin/src/Table/Admin_fields_conditionsTable.php new file mode 100644 index 000000000..3033a670f --- /dev/null +++ b/admin/src/Table/Admin_fields_conditionsTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Admins_fields_conditions Table class + * + * @since 1.6 + */ +class Admin_fields_conditionsTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.admin_fields_conditions'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_admin_fields_conditions', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Admin_fields_conditions table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New admin_fields_conditions. A admin_fields_conditions created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.admin_fields_conditions.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Admin_fields_relationsTable.php b/admin/src/Table/Admin_fields_relationsTable.php new file mode 100644 index 000000000..b2a5a6a31 --- /dev/null +++ b/admin/src/Table/Admin_fields_relationsTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Admins_fields_relations Table class + * + * @since 1.6 + */ +class Admin_fields_relationsTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.admin_fields_relations'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_admin_fields_relations', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Admin_fields_relations table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New admin_fields_relations. A admin_fields_relations created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.admin_fields_relations.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Admin_viewTable.php b/admin/src/Table/Admin_viewTable.php new file mode 100644 index 000000000..b98f25dfa --- /dev/null +++ b/admin/src/Table/Admin_viewTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Admin_views Table class + * + * @since 1.6 + */ +class Admin_viewTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.admin_view'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_admin_view', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Admin_view table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New admin_view. A admin_view created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_ADMIN_VIEW_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_ADMIN_VIEW_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.admin_view.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Class_extendsTable.php b/admin/src/Table/Class_extendsTable.php new file mode 100644 index 000000000..1d1ebccac --- /dev/null +++ b/admin/src/Table/Class_extendsTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Class_extendings Table class + * + * @since 1.6 + */ +class Class_extendsTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.class_extends'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_class_extends', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Class_extends table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New class_extends. A class_extends created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_CLASS_EXTENDS_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_CLASS_EXTENDS_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.class_extends.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Class_methodTable.php b/admin/src/Table/Class_methodTable.php new file mode 100644 index 000000000..ad4306acb --- /dev/null +++ b/admin/src/Table/Class_methodTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Class_methods Table class + * + * @since 1.6 + */ +class Class_methodTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.class_method'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_class_method', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Class_method table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New class_method. A class_method created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_CLASS_METHOD_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_CLASS_METHOD_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.class_method.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Class_propertyTable.php b/admin/src/Table/Class_propertyTable.php new file mode 100644 index 000000000..c36529382 --- /dev/null +++ b/admin/src/Table/Class_propertyTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Class_properties Table class + * + * @since 1.6 + */ +class Class_propertyTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.class_property'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_class_property', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Class_property table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New class_property. A class_property created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_CLASS_PROPERTY_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_CLASS_PROPERTY_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.class_property.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Component_admin_viewsTable.php b/admin/src/Table/Component_admin_viewsTable.php new file mode 100644 index 000000000..8df698d8c --- /dev/null +++ b/admin/src/Table/Component_admin_viewsTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_admin_views Table class + * + * @since 1.6 + */ +class Component_admin_viewsTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.component_admin_views'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_component_admin_views', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Component_admin_views table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New component_admin_views. A component_admin_views created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.component_admin_views.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Component_configTable.php b/admin/src/Table/Component_configTable.php new file mode 100644 index 000000000..66275d8b7 --- /dev/null +++ b/admin/src/Table/Component_configTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_config Table class + * + * @since 1.6 + */ +class Component_configTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.component_config'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_component_config', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Component_config table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New component_config. A component_config created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_CONFIG_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_CONFIG_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.component_config.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Component_custom_admin_menusTable.php b/admin/src/Table/Component_custom_admin_menusTable.php new file mode 100644 index 000000000..08ae8f8c3 --- /dev/null +++ b/admin/src/Table/Component_custom_admin_menusTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_custom_admin_menus Table class + * + * @since 1.6 + */ +class Component_custom_admin_menusTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.component_custom_admin_menus'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_component_custom_admin_menus', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Component_custom_admin_menus table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New component_custom_admin_menus. A component_custom_admin_menus created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.component_custom_admin_menus.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Component_custom_admin_viewsTable.php b/admin/src/Table/Component_custom_admin_viewsTable.php new file mode 100644 index 000000000..92b62985b --- /dev/null +++ b/admin/src/Table/Component_custom_admin_viewsTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_custom_admin_views Table class + * + * @since 1.6 + */ +class Component_custom_admin_viewsTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.component_custom_admin_views'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_component_custom_admin_views', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Component_custom_admin_views table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New component_custom_admin_views. A component_custom_admin_views created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.component_custom_admin_views.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Component_dashboardTable.php b/admin/src/Table/Component_dashboardTable.php new file mode 100644 index 000000000..0a57d1c6d --- /dev/null +++ b/admin/src/Table/Component_dashboardTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_dashboard Table class + * + * @since 1.6 + */ +class Component_dashboardTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.component_dashboard'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_component_dashboard', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Component_dashboard table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New component_dashboard. A component_dashboard created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.component_dashboard.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Component_files_foldersTable.php b/admin/src/Table/Component_files_foldersTable.php new file mode 100644 index 000000000..9dd776431 --- /dev/null +++ b/admin/src/Table/Component_files_foldersTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_files_folders Table class + * + * @since 1.6 + */ +class Component_files_foldersTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.component_files_folders'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_component_files_folders', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Component_files_folders table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New component_files_folders. A component_files_folders created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.component_files_folders.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Component_modulesTable.php b/admin/src/Table/Component_modulesTable.php new file mode 100644 index 000000000..66b1a66e8 --- /dev/null +++ b/admin/src/Table/Component_modulesTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_modules Table class + * + * @since 1.6 + */ +class Component_modulesTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.component_modules'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_component_modules', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Component_modules table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New component_modules. A component_modules created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_MODULES_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_MODULES_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.component_modules.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Component_mysql_tweaksTable.php b/admin/src/Table/Component_mysql_tweaksTable.php new file mode 100644 index 000000000..4dd87a695 --- /dev/null +++ b/admin/src/Table/Component_mysql_tweaksTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_mysql_tweaks Table class + * + * @since 1.6 + */ +class Component_mysql_tweaksTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.component_mysql_tweaks'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_component_mysql_tweaks', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Component_mysql_tweaks table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New component_mysql_tweaks. A component_mysql_tweaks created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.component_mysql_tweaks.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Component_placeholdersTable.php b/admin/src/Table/Component_placeholdersTable.php new file mode 100644 index 000000000..c04e1a695 --- /dev/null +++ b/admin/src/Table/Component_placeholdersTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_placeholders Table class + * + * @since 1.6 + */ +class Component_placeholdersTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.component_placeholders'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_component_placeholders', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Component_placeholders table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New component_placeholders. A component_placeholders created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.component_placeholders.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Component_pluginsTable.php b/admin/src/Table/Component_pluginsTable.php new file mode 100644 index 000000000..ccd61da4f --- /dev/null +++ b/admin/src/Table/Component_pluginsTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_plugins Table class + * + * @since 1.6 + */ +class Component_pluginsTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.component_plugins'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_component_plugins', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Component_plugins table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New component_plugins. A component_plugins created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_PLUGINS_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_PLUGINS_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.component_plugins.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Component_routerTable.php b/admin/src/Table/Component_routerTable.php new file mode 100644 index 000000000..550b154e4 --- /dev/null +++ b/admin/src/Table/Component_routerTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_routers Table class + * + * @since 1.6 + */ +class Component_routerTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.component_router'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_component_router', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Component_router table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New component_router. A component_router created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_ROUTER_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_ROUTER_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.component_router.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Component_site_viewsTable.php b/admin/src/Table/Component_site_viewsTable.php new file mode 100644 index 000000000..5a7b0aaed --- /dev/null +++ b/admin/src/Table/Component_site_viewsTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_site_views Table class + * + * @since 1.6 + */ +class Component_site_viewsTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.component_site_views'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_component_site_views', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Component_site_views table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New component_site_views. A component_site_views created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.component_site_views.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Component_updatesTable.php b/admin/src/Table/Component_updatesTable.php new file mode 100644 index 000000000..a0de98d2e --- /dev/null +++ b/admin/src/Table/Component_updatesTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Components_updates Table class + * + * @since 1.6 + */ +class Component_updatesTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.component_updates'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_component_updates', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Component_updates table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New component_updates. A component_updates created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_UPDATES_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_COMPONENT_UPDATES_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.component_updates.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Custom_admin_viewTable.php b/admin/src/Table/Custom_admin_viewTable.php new file mode 100644 index 000000000..42a3c01e1 --- /dev/null +++ b/admin/src/Table/Custom_admin_viewTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Custom_admin_views Table class + * + * @since 1.6 + */ +class Custom_admin_viewTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.custom_admin_view'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_custom_admin_view', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Custom_admin_view table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New custom_admin_view. A custom_admin_view created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.custom_admin_view.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Custom_codeTable.php b/admin/src/Table/Custom_codeTable.php new file mode 100644 index 000000000..f59d4b853 --- /dev/null +++ b/admin/src/Table/Custom_codeTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Custom_codes Table class + * + * @since 1.6 + */ +class Custom_codeTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.custom_code'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_custom_code', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Custom_code table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New custom_code. A custom_code created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_CUSTOM_CODE_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_CUSTOM_CODE_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.custom_code.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Dynamic_getTable.php b/admin/src/Table/Dynamic_getTable.php new file mode 100644 index 000000000..b7c519f3d --- /dev/null +++ b/admin/src/Table/Dynamic_getTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Dynamic_gets Table class + * + * @since 1.6 + */ +class Dynamic_getTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.dynamic_get'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_dynamic_get', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Dynamic_get table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New dynamic_get. A dynamic_get created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_DYNAMIC_GET_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_DYNAMIC_GET_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.dynamic_get.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/FieldTable.php b/admin/src/Table/FieldTable.php new file mode 100644 index 000000000..5a5b24e7d --- /dev/null +++ b/admin/src/Table/FieldTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Fields Table class + * + * @since 1.6 + */ +class FieldTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.field'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_field', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Field table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New field. A field created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias, 'catid' => $this->catid]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_FIELD_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_FIELD_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.field.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/FieldtypeTable.php b/admin/src/Table/FieldtypeTable.php new file mode 100644 index 000000000..44f775398 --- /dev/null +++ b/admin/src/Table/FieldtypeTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Fieldtypes Table class + * + * @since 1.6 + */ +class FieldtypeTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.fieldtype'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_fieldtype', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Fieldtype table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New fieldtype. A fieldtype created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias, 'catid' => $this->catid]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_FIELDTYPE_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_FIELDTYPE_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.fieldtype.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Help_documentTable.php b/admin/src/Table/Help_documentTable.php new file mode 100644 index 000000000..ceb706136 --- /dev/null +++ b/admin/src/Table/Help_documentTable.php @@ -0,0 +1,390 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Help_documents Table class + * + * @since 1.6 + */ +class Help_documentTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.help_document'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_help_document', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Help_document table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New help_document. A help_document created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.help_document.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * Generate a valid alias from title / date. + * Remains public to be able to check for duplicated alias before saving + * + * @return string + */ + public function generateAlias() + { + if (empty($this->alias)) + { + $this->alias = $this->title; + } + + $this->alias = ApplicationHelper::stringURLSafe($this->alias); + + if (trim(str_replace('-', '', $this->alias)) == '') + { + $this->alias = Factory::getDate()->format('Y-m-d-H-i-s'); + } + + return $this->alias; + } +} diff --git a/admin/src/Table/Joomla_componentTable.php b/admin/src/Table/Joomla_componentTable.php new file mode 100644 index 000000000..9b1407a67 --- /dev/null +++ b/admin/src/Table/Joomla_componentTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_components Table class + * + * @since 1.6 + */ +class Joomla_componentTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.joomla_component'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_joomla_component', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Joomla_component table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New joomla_component. A joomla_component created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.joomla_component.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Joomla_moduleTable.php b/admin/src/Table/Joomla_moduleTable.php new file mode 100644 index 000000000..3f87c6d11 --- /dev/null +++ b/admin/src/Table/Joomla_moduleTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_modules Table class + * + * @since 1.6 + */ +class Joomla_moduleTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.joomla_module'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_joomla_module', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Joomla_module table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New joomla_module. A joomla_module created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_JOOMLA_MODULE_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_JOOMLA_MODULE_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.joomla_module.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Joomla_module_files_folders_urlsTable.php b/admin/src/Table/Joomla_module_files_folders_urlsTable.php new file mode 100644 index 000000000..51a5df048 --- /dev/null +++ b/admin/src/Table/Joomla_module_files_folders_urlsTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_modules_files_folders_urls Table class + * + * @since 1.6 + */ +class Joomla_module_files_folders_urlsTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.joomla_module_files_folders_urls'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_joomla_module_files_folders_urls', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Joomla_module_files_folders_urls table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New joomla_module_files_folders_urls. A joomla_module_files_folders_urls created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.joomla_module_files_folders_urls.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Joomla_module_updatesTable.php b/admin/src/Table/Joomla_module_updatesTable.php new file mode 100644 index 000000000..1fa1fb39e --- /dev/null +++ b/admin/src/Table/Joomla_module_updatesTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_modules_updates Table class + * + * @since 1.6 + */ +class Joomla_module_updatesTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.joomla_module_updates'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_joomla_module_updates', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Joomla_module_updates table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New joomla_module_updates. A joomla_module_updates created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.joomla_module_updates.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Joomla_pluginTable.php b/admin/src/Table/Joomla_pluginTable.php new file mode 100644 index 000000000..748845347 --- /dev/null +++ b/admin/src/Table/Joomla_pluginTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_plugins Table class + * + * @since 1.6 + */ +class Joomla_pluginTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.joomla_plugin'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_joomla_plugin', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Joomla_plugin table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New joomla_plugin. A joomla_plugin created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.joomla_plugin.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Joomla_plugin_files_folders_urlsTable.php b/admin/src/Table/Joomla_plugin_files_folders_urlsTable.php new file mode 100644 index 000000000..2b6cdc2c0 --- /dev/null +++ b/admin/src/Table/Joomla_plugin_files_folders_urlsTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_plugins_files_folders_urls Table class + * + * @since 1.6 + */ +class Joomla_plugin_files_folders_urlsTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.joomla_plugin_files_folders_urls'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_joomla_plugin_files_folders_urls', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Joomla_plugin_files_folders_urls table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New joomla_plugin_files_folders_urls. A joomla_plugin_files_folders_urls created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.joomla_plugin_files_folders_urls.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Joomla_plugin_groupTable.php b/admin/src/Table/Joomla_plugin_groupTable.php new file mode 100644 index 000000000..a8325ba29 --- /dev/null +++ b/admin/src/Table/Joomla_plugin_groupTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_plugin_groups Table class + * + * @since 1.6 + */ +class Joomla_plugin_groupTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.joomla_plugin_group'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_joomla_plugin_group', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Joomla_plugin_group table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New joomla_plugin_group. A joomla_plugin_group created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.joomla_plugin_group.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Joomla_plugin_updatesTable.php b/admin/src/Table/Joomla_plugin_updatesTable.php new file mode 100644 index 000000000..7609db9c1 --- /dev/null +++ b/admin/src/Table/Joomla_plugin_updatesTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_plugins_updates Table class + * + * @since 1.6 + */ +class Joomla_plugin_updatesTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.joomla_plugin_updates'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_joomla_plugin_updates', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Joomla_plugin_updates table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New joomla_plugin_updates. A joomla_plugin_updates created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.joomla_plugin_updates.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/LanguageTable.php b/admin/src/Table/LanguageTable.php new file mode 100644 index 000000000..61472ba16 --- /dev/null +++ b/admin/src/Table/LanguageTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Languages Table class + * + * @since 1.6 + */ +class LanguageTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.language'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_language', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Language table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New language. A language created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_LANGUAGE_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_LANGUAGE_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.language.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Language_translationTable.php b/admin/src/Table/Language_translationTable.php new file mode 100644 index 000000000..7161913ec --- /dev/null +++ b/admin/src/Table/Language_translationTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Language_translations Table class + * + * @since 1.6 + */ +class Language_translationTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.language_translation'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_language_translation', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Language_translation table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New language_translation. A language_translation created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.language_translation.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/LayoutTable.php b/admin/src/Table/LayoutTable.php new file mode 100644 index 000000000..f422c4310 --- /dev/null +++ b/admin/src/Table/LayoutTable.php @@ -0,0 +1,390 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Layouts Table class + * + * @since 1.6 + */ +class LayoutTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.layout'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_layout', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Layout table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New layout. A layout created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_LAYOUT_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_LAYOUT_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.layout.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * Generate a valid alias from title / date. + * Remains public to be able to check for duplicated alias before saving + * + * @return string + */ + public function generateAlias() + { + if (empty($this->alias)) + { + $this->alias = $this->name; + } + + $this->alias = ApplicationHelper::stringURLSafe($this->alias); + + if (trim(str_replace('-', '', $this->alias)) == '') + { + $this->alias = Factory::getDate()->format('Y-m-d-H-i-s'); + } + + return $this->alias; + } +} diff --git a/admin/src/Table/LibraryTable.php b/admin/src/Table/LibraryTable.php new file mode 100644 index 000000000..201dc0aa5 --- /dev/null +++ b/admin/src/Table/LibraryTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Libraries Table class + * + * @since 1.6 + */ +class LibraryTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.library'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_library', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Library table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New library. A library created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_LIBRARY_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_LIBRARY_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.library.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Library_configTable.php b/admin/src/Table/Library_configTable.php new file mode 100644 index 000000000..56dec96d8 --- /dev/null +++ b/admin/src/Table/Library_configTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Libraries_config Table class + * + * @since 1.6 + */ +class Library_configTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.library_config'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_library_config', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Library_config table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New library_config. A library_config created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_LIBRARY_CONFIG_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_LIBRARY_CONFIG_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.library_config.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Library_files_folders_urlsTable.php b/admin/src/Table/Library_files_folders_urlsTable.php new file mode 100644 index 000000000..3c0a71197 --- /dev/null +++ b/admin/src/Table/Library_files_folders_urlsTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Libraries_files_folders_urls Table class + * + * @since 1.6 + */ +class Library_files_folders_urlsTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.library_files_folders_urls'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_library_files_folders_urls', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Library_files_folders_urls table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New library_files_folders_urls. A library_files_folders_urls created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.library_files_folders_urls.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/PlaceholderTable.php b/admin/src/Table/PlaceholderTable.php new file mode 100644 index 000000000..99dc14534 --- /dev/null +++ b/admin/src/Table/PlaceholderTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Placeholders Table class + * + * @since 1.6 + */ +class PlaceholderTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.placeholder'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_placeholder', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Placeholder table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New placeholder. A placeholder created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_PLACEHOLDER_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_PLACEHOLDER_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.placeholder.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/PowerTable.php b/admin/src/Table/PowerTable.php new file mode 100644 index 000000000..1099b25c8 --- /dev/null +++ b/admin/src/Table/PowerTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Powers Table class + * + * @since 1.6 + */ +class PowerTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.power'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_power', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Power table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New power. A power created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_POWER_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_POWER_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.power.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/ServerTable.php b/admin/src/Table/ServerTable.php new file mode 100644 index 000000000..4815c60ff --- /dev/null +++ b/admin/src/Table/ServerTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Servers Table class + * + * @since 1.6 + */ +class ServerTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.server'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_server', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Server table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New server. A server created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_SERVER_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_SERVER_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.server.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Site_viewTable.php b/admin/src/Table/Site_viewTable.php new file mode 100644 index 000000000..7c8fc8a55 --- /dev/null +++ b/admin/src/Table/Site_viewTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Site_views Table class + * + * @since 1.6 + */ +class Site_viewTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.site_view'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_site_view', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Site_view table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New site_view. A site_view created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_SITE_VIEW_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_SITE_VIEW_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.site_view.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/SnippetTable.php b/admin/src/Table/SnippetTable.php new file mode 100644 index 000000000..80f571dc5 --- /dev/null +++ b/admin/src/Table/SnippetTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Snippets Table class + * + * @since 1.6 + */ +class SnippetTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.snippet'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_snippet', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Snippet table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New snippet. A snippet created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_SNIPPET_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_SNIPPET_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.snippet.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/Snippet_typeTable.php b/admin/src/Table/Snippet_typeTable.php new file mode 100644 index 000000000..89eb2fc62 --- /dev/null +++ b/admin/src/Table/Snippet_typeTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Snippet_types Table class + * + * @since 1.6 + */ +class Snippet_typeTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.snippet_type'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_snippet_type', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Snippet_type table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New snippet_type. A snippet_type created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_SNIPPET_TYPE_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_SNIPPET_TYPE_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.snippet_type.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/src/Table/TemplateTable.php b/admin/src/Table/TemplateTable.php new file mode 100644 index 000000000..668fead5e --- /dev/null +++ b/admin/src/Table/TemplateTable.php @@ -0,0 +1,390 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Templates Table class + * + * @since 1.6 + */ +class TemplateTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.template'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_template', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Template table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New template. A template created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_TEMPLATE_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_TEMPLATE_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.template.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * Generate a valid alias from title / date. + * Remains public to be able to check for duplicated alias before saving + * + * @return string + */ + public function generateAlias() + { + if (empty($this->alias)) + { + $this->alias = $this->name; + } + + $this->alias = ApplicationHelper::stringURLSafe($this->alias); + + if (trim(str_replace('-', '', $this->alias)) == '') + { + $this->alias = Factory::getDate()->format('Y-m-d-H-i-s'); + } + + return $this->alias; + } +} diff --git a/admin/src/Table/Validation_ruleTable.php b/admin/src/Table/Validation_ruleTable.php new file mode 100644 index 000000000..36a5a617a --- /dev/null +++ b/admin/src/Table/Validation_ruleTable.php @@ -0,0 +1,377 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\Table; + +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; +use Joomla\CMS\Access\Access as AccessRules; +use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; +use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Validation_rules Table class + * + * @since 1.6 + */ +class Validation_ruleTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface +{ + use TaggableTableTrait; + use CurrentUserTrait; + + /** + * Constructor + * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * + * @param object Database connector object + * @since 4.0 + */ + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) + { + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_componentbuilder.validation_rule'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__componentbuilder_validation_rule', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ + public function bind($array, $ignore = '') + { + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new AccessRules($array['rules']); + $this->setRules($rules); + } + + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Validation_rule table. + * + * @param boolean Toggle whether null values should be updated. + * + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; + + if ($this->id) + { + // Existing item + $this->modified = $date; + $this->modified_by = $userId; + } + else + { + // New validation_rule. A validation_rule created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date; + } + if (empty($this->created_by)) + { + $this->created_by = $userId; + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = new self($this->getDbo(), $this->getDispatcher()); + + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_VALIDATION_RULE_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_COMPONENTBUILDER_VALIDATION_RULE_ERROR_UNIQUE_ALIAS_TRASHED')); + } + + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = PunycodeHelper::urlToPunycode($this->url); + } + + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = PunycodeHelper::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 + */ + public function check() + { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = []; + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty AccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_componentbuilder.validation_rule.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return AccessRules The AccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = Factory::getContainer()->get(DatabaseInterface::class); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof AccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = []; + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the AccessRules object for the asset rules. + $rules = new AccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form table_name.id + * where id is the value of the primary key of the table. + * + * @return string + * + * @since 1.7.0 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + + return $this->getTypeAlias() . '.' . (int) $this->$k; + } + + /** + * Method to get the parent asset under which to register this one. + * + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. + * + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 + */ + protected function _getAssetParentId(Table $table = null, $id = null) + { + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); + + // load the componentbuilder asset + $assets->loadByName('com_componentbuilder'); + + return $assets->id ?? $rootId ?? 1; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } +} diff --git a/admin/views/admin_fields_conditions/tmpl/index.html b/admin/src/Table/index.html similarity index 100% rename from admin/views/admin_fields_conditions/tmpl/index.html rename to admin/src/Table/index.html diff --git a/admin/src/View/Admin_custom_tabs/HtmlView.php b/admin/src/View/Admin_custom_tabs/HtmlView.php new file mode 100644 index 000000000..37c43eaef --- /dev/null +++ b/admin/src/View/Admin_custom_tabs/HtmlView.php @@ -0,0 +1,236 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Admin_custom_tabs; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Admin_custom_tabs Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Admin_custom_tabs view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('admin_custom_tabs', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_NEW' : 'COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('admin_custom_tabs.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('admin_custom_tabs.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('admin_custom_tabs.edit')) + { + // We can save the record. + ToolbarHelper::save('admin_custom_tabs.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('admin_custom_tabs.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('admin_custom_tabs.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('admin_custom_tabs.create')) + { + ToolbarHelper::apply('admin_custom_tabs.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('admin_custom_tabs.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('admin_custom_tabs.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('admin_custom_tabs.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('admin_custom_tabs.edit')) + { + // We can save the new record + ToolbarHelper::apply('admin_custom_tabs.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('admin_custom_tabs.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('admin_custom_tabs.create')) + { + ToolbarHelper::custom('admin_custom_tabs.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('admin_custom_tabs.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('admin_custom_tabs.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.admin_custom_tabs', $this->item->id); + } + if ($this->canDo->get('admin_custom_tabs.create')) + { + ToolbarHelper::custom('admin_custom_tabs.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('admin_custom_tabs.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('admin_custom_tabs'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_NEW' : 'COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + } +} diff --git a/admin/views/admin_fields_relations/tmpl/index.html b/admin/src/View/Admin_custom_tabs/index.html similarity index 100% rename from admin/views/admin_fields_relations/tmpl/index.html rename to admin/src/View/Admin_custom_tabs/index.html diff --git a/admin/src/View/Admin_fields/HtmlView.php b/admin/src/View/Admin_fields/HtmlView.php new file mode 100644 index 000000000..2afdfd006 --- /dev/null +++ b/admin/src/View/Admin_fields/HtmlView.php @@ -0,0 +1,251 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Admin_fields; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Admin_fields Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Admin_fields view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('admin_fields', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_ADMIN_FIELDS_NEW' : 'COM_COMPONENTBUILDER_ADMIN_FIELDS_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('admin_fields.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('admin_fields.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('admin_fields.edit')) + { + // We can save the record. + ToolbarHelper::save('admin_fields.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('admin_fields.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('admin_fields.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('admin_fields.create')) + { + ToolbarHelper::apply('admin_fields.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('admin_fields.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('admin_fields.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('admin_fields.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('admin_fields.edit')) + { + // We can save the new record + ToolbarHelper::apply('admin_fields.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('admin_fields.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('admin_fields.create')) + { + ToolbarHelper::custom('admin_fields.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('admin_fields.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('admin_fields.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.admin_fields', $this->item->id); + } + if ($this->canDo->get('admin_fields.create')) + { + ToolbarHelper::custom('admin_fields.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('admin_fields.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('admin_fields'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_ADMIN_FIELDS_NEW' : 'COM_COMPONENTBUILDER_ADMIN_FIELDS_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + Text::script('COM_COMPONENTBUILDER_THE_BNONE_DBB_OPTION_WILL_REMOVE_THIS_FIELD_FROM_BEING_SAVED_IN_THE_DATABASE'); + Text::script('COM_COMPONENTBUILDER_ONLY_USE_THE_BNONE_DBB_OPTION_IF_YOU_ARE_PLANNING_ON_TARGETING_THIS_FIELD_WITH_JAVASCRIPTCUSTOM_PHP_TO_MOVE_ITS_VALUE_INTO_ANOTHER_FIELD_THAT_DOES_GET_SAVED_TO_THE_DATABASE'); + Text::script('COM_COMPONENTBUILDER_THE_BSHOW_IN_ALL_LIST_VIEWSB_OPTION_WILL_ADD_THIS_FIELD_TO_ALL_LIST_VIEWS_ADMIN_AMP_LINKED'); + Text::script('COM_COMPONENTBUILDER_THE_BONLY_IN_ADMIN_LIST_VIEWB_OPTION_WILL_ONLY_ADD_THIS_FIELD_TO_THE_ADMIN_LIST_VIEW_NOT_TO_ANY_LINKED_VIEWS'); + Text::script('COM_COMPONENTBUILDER_THE_BONLY_IN_LINKED_LIST_VIEWSB_OPTION_WILL_ONLY_ADD_THIS_FIELD_TO_THE_LINKED_LIST_VIEW_IF_THIS_VIEW_GETS_LINKED_TO_OTHER_VIEW_NOT_TO_THIS_ADMIN_LIST_VIEW'); + Text::script('COM_COMPONENTBUILDER_THESE_OPTIONS_ARE_NOT_AVAILABLE_TO_THE_FIELD_IF_BNONE_DBB_OPTION_IS_SELECTED'); + Text::script('COM_COMPONENTBUILDER_THESE_OPTIONS_ARE_ONLY_AVAILABLE_TO_THE_FIELD_IF_BSHOW_IN_LIST_VIEWB_OPTION_IS_SELECTED'); + Text::script('COM_COMPONENTBUILDER_THE_BMULTI_FILTERB_SELECTION_OPTION_ALLOWS_THE_USER_TO_SELECT_MORE_THEN_ONE_VALUE_IN_THIS_FILTERFIELD_PLEASE_NOTE_THAT_THIS_OPTION_BONLY_WORKSB_WITH_THE_BNEWB_FILTERS_THAT_LOAD_ABOVE_THE_ADMIN_LIST_VIEW_YOU_CAN_SELECT_THE_NEW_FILTER_OPTION_WHENWHERE_YOU_ADD_THE_VIEW_TO_THE_COMPONENT'); + Text::script('COM_COMPONENTBUILDER_THE_BSINGLE_FILTERB_SELECTION_OPTION_ALLOWS_THE_USER_TO_SELECT_JUST_ONE_VALUE_IN_THIS_FILTERFIELD'); + } +} diff --git a/admin/views/admin_view/tmpl/index.html b/admin/src/View/Admin_fields/index.html similarity index 100% rename from admin/views/admin_view/tmpl/index.html rename to admin/src/View/Admin_fields/index.html diff --git a/admin/src/View/Admin_fields_conditions/HtmlView.php b/admin/src/View/Admin_fields_conditions/HtmlView.php new file mode 100644 index 000000000..bd8e5b4f5 --- /dev/null +++ b/admin/src/View/Admin_fields_conditions/HtmlView.php @@ -0,0 +1,238 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Admin_fields_conditions; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Admin_fields_conditions Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Admin_fields_conditions view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('admin_fields_conditions', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_NEW' : 'COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('admin_fields_conditions.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('admin_fields_conditions.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('admin_fields_conditions.edit')) + { + // We can save the record. + ToolbarHelper::save('admin_fields_conditions.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('admin_fields_conditions.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('admin_fields_conditions.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('admin_fields_conditions.create')) + { + ToolbarHelper::apply('admin_fields_conditions.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('admin_fields_conditions.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('admin_fields_conditions.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('admin_fields_conditions.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('admin_fields_conditions.edit')) + { + // We can save the new record + ToolbarHelper::apply('admin_fields_conditions.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('admin_fields_conditions.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('admin_fields_conditions.create')) + { + ToolbarHelper::custom('admin_fields_conditions.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('admin_fields_conditions.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('admin_fields_conditions.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.admin_fields_conditions', $this->item->id); + } + if ($this->canDo->get('admin_fields_conditions.create')) + { + ToolbarHelper::custom('admin_fields_conditions.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('admin_fields_conditions.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('admin_fields_conditions'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_NEW' : 'COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + } +} diff --git a/admin/views/admin_views/index.html b/admin/src/View/Admin_fields_conditions/index.html similarity index 100% rename from admin/views/admin_views/index.html rename to admin/src/View/Admin_fields_conditions/index.html diff --git a/admin/src/View/Admin_fields_relations/HtmlView.php b/admin/src/View/Admin_fields_relations/HtmlView.php new file mode 100644 index 000000000..03ad7db30 --- /dev/null +++ b/admin/src/View/Admin_fields_relations/HtmlView.php @@ -0,0 +1,242 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Admin_fields_relations; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Admin_fields_relations Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Admin_fields_relations view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('admin_fields_relations', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_NEW' : 'COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('admin_fields_relations.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('admin_fields_relations.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('admin_fields_relations.edit')) + { + // We can save the record. + ToolbarHelper::save('admin_fields_relations.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('admin_fields_relations.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('admin_fields_relations.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('admin_fields_relations.create')) + { + ToolbarHelper::apply('admin_fields_relations.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('admin_fields_relations.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('admin_fields_relations.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('admin_fields_relations.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('admin_fields_relations.edit')) + { + // We can save the new record + ToolbarHelper::apply('admin_fields_relations.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('admin_fields_relations.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('admin_fields_relations.create')) + { + ToolbarHelper::custom('admin_fields_relations.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('admin_fields_relations.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('admin_fields_relations.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.admin_fields_relations', $this->item->id); + } + if ($this->canDo->get('admin_fields_relations.create')) + { + ToolbarHelper::custom('admin_fields_relations.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('admin_fields_relations.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('admin_fields_relations'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_NEW' : 'COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + } +} diff --git a/admin/views/admin_views/tmpl/index.html b/admin/src/View/Admin_fields_relations/index.html similarity index 100% rename from admin/views/admin_views/tmpl/index.html rename to admin/src/View/Admin_fields_relations/index.html diff --git a/admin/src/View/Admin_view/HtmlView.php b/admin/src/View/Admin_view/HtmlView.php new file mode 100644 index 000000000..90dc9ffe6 --- /dev/null +++ b/admin/src/View/Admin_view/HtmlView.php @@ -0,0 +1,248 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Admin_view; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Admin_view Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Admin_view view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('admin_view', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_ADMIN_VIEW_NEW' : 'COM_COMPONENTBUILDER_ADMIN_VIEW_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('admin_view.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('admin_view.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('admin_view.edit')) + { + // We can save the record. + ToolbarHelper::save('admin_view.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('admin_view.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('admin_view.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('admin_view.create')) + { + ToolbarHelper::apply('admin_view.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('admin_view.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('admin_view.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('admin_view.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('admin_view.edit')) + { + // We can save the new record + ToolbarHelper::apply('admin_view.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('admin_view.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('admin_view.create')) + { + ToolbarHelper::custom('admin_view.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('admin_view.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('admin_view.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.admin_view', $this->item->id); + } + if ($this->canDo->get('admin_view.create')) + { + ToolbarHelper::custom('admin_view.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('admin_view.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('admin_view'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_ADMIN_VIEW_NEW' : 'COM_COMPONENTBUILDER_ADMIN_VIEW_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + } +} diff --git a/admin/views/admins_custom_tabs/index.html b/admin/src/View/Admin_view/index.html similarity index 100% rename from admin/views/admins_custom_tabs/index.html rename to admin/src/View/Admin_view/index.html diff --git a/admin/src/View/Admin_views/HtmlView.php b/admin/src/View/Admin_views/HtmlView.php new file mode 100644 index 000000000..5a249edd8 --- /dev/null +++ b/admin/src/View/Admin_views/HtmlView.php @@ -0,0 +1,224 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Admin_views; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Admin_views + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Admin_views view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('admin_view'); + $this->canEdit = $this->canDo->get('admin_view.edit'); + $this->canState = $this->canDo->get('admin_view.edit.state'); + $this->canCreate = $this->canDo->get('admin_view.create'); + $this->canDelete = $this->canDo->get('admin_view.delete'); + $this->canBatch = ($this->canDo->get('admin_view.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_ADMIN_VIEWS'), 'stack'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('admin_view.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('admin_view.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('admin_views.publish'); + ToolbarHelper::unpublishList('admin_views.unpublish'); + ToolbarHelper::archiveList('admin_views.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('admin_views.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'admin_views.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('admin_views.trash'); + } + } + if ($this->user->authorise('admin_view.run_expansion', 'com_componentbuilder')) + { + // add Run Expansion button. + ToolbarHelper::custom('admin_views.runExpansion', 'expand-2 custom-button-runexpansion', '', 'COM_COMPONENTBUILDER_RUN_EXPANSION', false); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('admin_views'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_ADMIN_VIEWS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.system_name' => Text::_('COM_COMPONENTBUILDER_ADMIN_VIEW_SYSTEM_NAME_LABEL'), + 'a.name_single' => Text::_('COM_COMPONENTBUILDER_ADMIN_VIEW_NAME_SINGLE_LABEL'), + 'a.short_description' => Text::_('COM_COMPONENTBUILDER_ADMIN_VIEW_SHORT_DESCRIPTION_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/admins_custom_tabs/tmpl/index.html b/admin/src/View/Admin_views/index.html similarity index 100% rename from admin/views/admins_custom_tabs/tmpl/index.html rename to admin/src/View/Admin_views/index.html diff --git a/admin/src/View/Admins_custom_tabs/HtmlView.php b/admin/src/View/Admins_custom_tabs/HtmlView.php new file mode 100644 index 000000000..bb875a5ee --- /dev/null +++ b/admin/src/View/Admins_custom_tabs/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Admins_custom_tabs; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Admins_custom_tabs + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Admins_custom_tabs view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('admin_custom_tabs'); + $this->canEdit = $this->canDo->get('admin_custom_tabs.edit'); + $this->canState = $this->canDo->get('admin_custom_tabs.edit.state'); + $this->canCreate = $this->canDo->get('admin_custom_tabs.create'); + $this->canDelete = $this->canDo->get('admin_custom_tabs.delete'); + $this->canBatch = ($this->canDo->get('admin_custom_tabs.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_ADMINS_CUSTOM_TABS'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('admin_custom_tabs.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('admin_custom_tabs.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('admins_custom_tabs.publish'); + ToolbarHelper::unpublishList('admins_custom_tabs.unpublish'); + ToolbarHelper::archiveList('admins_custom_tabs.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('admins_custom_tabs.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'admins_custom_tabs.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('admins_custom_tabs.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('admins_custom_tabs'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_ADMINS_CUSTOM_TABS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/admins_fields/index.html b/admin/src/View/Admins_custom_tabs/index.html similarity index 100% rename from admin/views/admins_fields/index.html rename to admin/src/View/Admins_custom_tabs/index.html diff --git a/admin/src/View/Admins_fields/HtmlView.php b/admin/src/View/Admins_fields/HtmlView.php new file mode 100644 index 000000000..3b0a3fdcb --- /dev/null +++ b/admin/src/View/Admins_fields/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Admins_fields; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Admins_fields + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Admins_fields view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('admin_fields'); + $this->canEdit = $this->canDo->get('admin_fields.edit'); + $this->canState = $this->canDo->get('admin_fields.edit.state'); + $this->canCreate = $this->canDo->get('admin_fields.create'); + $this->canDelete = $this->canDo->get('admin_fields.delete'); + $this->canBatch = ($this->canDo->get('admin_fields.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_ADMINS_FIELDS'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('admin_fields.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('admin_fields.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('admins_fields.publish'); + ToolbarHelper::unpublishList('admins_fields.unpublish'); + ToolbarHelper::archiveList('admins_fields.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('admins_fields.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'admins_fields.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('admins_fields.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('admins_fields'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_ADMINS_FIELDS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/admins_fields/tmpl/index.html b/admin/src/View/Admins_fields/index.html similarity index 100% rename from admin/views/admins_fields/tmpl/index.html rename to admin/src/View/Admins_fields/index.html diff --git a/admin/src/View/Admins_fields_conditions/HtmlView.php b/admin/src/View/Admins_fields_conditions/HtmlView.php new file mode 100644 index 000000000..1120bbaae --- /dev/null +++ b/admin/src/View/Admins_fields_conditions/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Admins_fields_conditions; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Admins_fields_conditions + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Admins_fields_conditions view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('admin_fields_conditions'); + $this->canEdit = $this->canDo->get('admin_fields_conditions.edit'); + $this->canState = $this->canDo->get('admin_fields_conditions.edit.state'); + $this->canCreate = $this->canDo->get('admin_fields_conditions.create'); + $this->canDelete = $this->canDo->get('admin_fields_conditions.delete'); + $this->canBatch = ($this->canDo->get('admin_fields_conditions.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_ADMINS_FIELDS_CONDITIONS'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('admin_fields_conditions.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('admin_fields_conditions.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('admins_fields_conditions.publish'); + ToolbarHelper::unpublishList('admins_fields_conditions.unpublish'); + ToolbarHelper::archiveList('admins_fields_conditions.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('admins_fields_conditions.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'admins_fields_conditions.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('admins_fields_conditions.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('admins_fields_conditions'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_ADMINS_FIELDS_CONDITIONS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/admins_fields_conditions/index.html b/admin/src/View/Admins_fields_conditions/index.html similarity index 100% rename from admin/views/admins_fields_conditions/index.html rename to admin/src/View/Admins_fields_conditions/index.html diff --git a/admin/src/View/Admins_fields_relations/HtmlView.php b/admin/src/View/Admins_fields_relations/HtmlView.php new file mode 100644 index 000000000..9582c17bd --- /dev/null +++ b/admin/src/View/Admins_fields_relations/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Admins_fields_relations; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Admins_fields_relations + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Admins_fields_relations view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('admin_fields_relations'); + $this->canEdit = $this->canDo->get('admin_fields_relations.edit'); + $this->canState = $this->canDo->get('admin_fields_relations.edit.state'); + $this->canCreate = $this->canDo->get('admin_fields_relations.create'); + $this->canDelete = $this->canDo->get('admin_fields_relations.delete'); + $this->canBatch = ($this->canDo->get('admin_fields_relations.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_ADMINS_FIELDS_RELATIONS'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('admin_fields_relations.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('admin_fields_relations.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('admins_fields_relations.publish'); + ToolbarHelper::unpublishList('admins_fields_relations.unpublish'); + ToolbarHelper::archiveList('admins_fields_relations.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('admins_fields_relations.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'admins_fields_relations.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('admins_fields_relations.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('admins_fields_relations'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_ADMINS_FIELDS_RELATIONS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/admins_fields_conditions/tmpl/index.html b/admin/src/View/Admins_fields_relations/index.html similarity index 100% rename from admin/views/admins_fields_conditions/tmpl/index.html rename to admin/src/View/Admins_fields_relations/index.html diff --git a/admin/src/View/Class_extendings/HtmlView.php b/admin/src/View/Class_extendings/HtmlView.php new file mode 100644 index 000000000..a907310d7 --- /dev/null +++ b/admin/src/View/Class_extendings/HtmlView.php @@ -0,0 +1,218 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Class_extendings; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Class_extendings + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Class_extendings view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('class_extends'); + $this->canEdit = $this->canDo->get('class_extends.edit'); + $this->canState = $this->canDo->get('class_extends.edit.state'); + $this->canCreate = $this->canDo->get('class_extends.create'); + $this->canDelete = $this->canDo->get('class_extends.delete'); + $this->canBatch = ($this->canDo->get('class_extends.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_CLASS_EXTENDINGS'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('class_extends.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('class_extends.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('class_extendings.publish'); + ToolbarHelper::unpublishList('class_extendings.unpublish'); + ToolbarHelper::archiveList('class_extendings.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('class_extendings.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'class_extendings.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('class_extendings.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('class_extendings'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_CLASS_EXTENDINGS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.name' => Text::_('COM_COMPONENTBUILDER_CLASS_EXTENDS_NAME_LABEL'), + 'a.extension_type' => Text::_('COM_COMPONENTBUILDER_CLASS_EXTENDS_EXTENSION_TYPE_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/admins_fields_relations/index.html b/admin/src/View/Class_extendings/index.html similarity index 100% rename from admin/views/admins_fields_relations/index.html rename to admin/src/View/Class_extendings/index.html diff --git a/admin/src/View/Class_extends/HtmlView.php b/admin/src/View/Class_extends/HtmlView.php new file mode 100644 index 000000000..118acfb89 --- /dev/null +++ b/admin/src/View/Class_extends/HtmlView.php @@ -0,0 +1,248 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Class_extends; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Class_extends Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Class_extends view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('class_extends', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_CLASS_EXTENDS_NEW' : 'COM_COMPONENTBUILDER_CLASS_EXTENDS_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('class_extends.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('class_extends.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('class_extends.edit')) + { + // We can save the record. + ToolbarHelper::save('class_extends.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('class_extends.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('class_extends.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('class_extends.create')) + { + ToolbarHelper::apply('class_extends.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('class_extends.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('class_extends.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('class_extends.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('class_extends.edit')) + { + // We can save the new record + ToolbarHelper::apply('class_extends.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('class_extends.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('class_extends.create')) + { + ToolbarHelper::custom('class_extends.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('class_extends.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('class_extends.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.class_extends', $this->item->id); + } + if ($this->canDo->get('class_extends.create')) + { + ToolbarHelper::custom('class_extends.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('class_extends.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('class_extends'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_CLASS_EXTENDS_NEW' : 'COM_COMPONENTBUILDER_CLASS_EXTENDS_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + } +} diff --git a/admin/views/admins_fields_relations/tmpl/index.html b/admin/src/View/Class_extends/index.html similarity index 100% rename from admin/views/admins_fields_relations/tmpl/index.html rename to admin/src/View/Class_extends/index.html diff --git a/admin/src/View/Class_method/HtmlView.php b/admin/src/View/Class_method/HtmlView.php new file mode 100644 index 000000000..56262dc3f --- /dev/null +++ b/admin/src/View/Class_method/HtmlView.php @@ -0,0 +1,248 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Class_method; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Class_method Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Class_method view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('class_method', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_CLASS_METHOD_NEW' : 'COM_COMPONENTBUILDER_CLASS_METHOD_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('class_method.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('class_method.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('class_method.edit')) + { + // We can save the record. + ToolbarHelper::save('class_method.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('class_method.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('class_method.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('class_method.create')) + { + ToolbarHelper::apply('class_method.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('class_method.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('class_method.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('class_method.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('class_method.edit')) + { + // We can save the new record + ToolbarHelper::apply('class_method.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('class_method.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('class_method.create')) + { + ToolbarHelper::custom('class_method.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('class_method.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('class_method.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.class_method', $this->item->id); + } + if ($this->canDo->get('class_method.create')) + { + ToolbarHelper::custom('class_method.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('class_method.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('class_method'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_CLASS_METHOD_NEW' : 'COM_COMPONENTBUILDER_CLASS_METHOD_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + } +} diff --git a/admin/views/class_extendings/index.html b/admin/src/View/Class_method/index.html similarity index 100% rename from admin/views/class_extendings/index.html rename to admin/src/View/Class_method/index.html diff --git a/admin/src/View/Class_methods/HtmlView.php b/admin/src/View/Class_methods/HtmlView.php new file mode 100644 index 000000000..52d3a5204 --- /dev/null +++ b/admin/src/View/Class_methods/HtmlView.php @@ -0,0 +1,219 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Class_methods; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Class_methods + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Class_methods view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('class_method'); + $this->canEdit = $this->canDo->get('class_method.edit'); + $this->canState = $this->canDo->get('class_method.edit.state'); + $this->canCreate = $this->canDo->get('class_method.create'); + $this->canDelete = $this->canDo->get('class_method.delete'); + $this->canBatch = ($this->canDo->get('class_method.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_CLASS_METHODS'), 'cube'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('class_method.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('class_method.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('class_methods.publish'); + ToolbarHelper::unpublishList('class_methods.unpublish'); + ToolbarHelper::archiveList('class_methods.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('class_methods.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'class_methods.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('class_methods.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('class_methods'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_CLASS_METHODS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.name' => Text::_('COM_COMPONENTBUILDER_CLASS_METHOD_NAME_LABEL'), + 'a.visibility' => Text::_('COM_COMPONENTBUILDER_CLASS_METHOD_VISIBILITY_LABEL'), + 'a.extension_type' => Text::_('COM_COMPONENTBUILDER_CLASS_METHOD_EXTENSION_TYPE_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/class_extendings/tmpl/index.html b/admin/src/View/Class_methods/index.html similarity index 100% rename from admin/views/class_extendings/tmpl/index.html rename to admin/src/View/Class_methods/index.html diff --git a/admin/src/View/Class_properties/HtmlView.php b/admin/src/View/Class_properties/HtmlView.php new file mode 100644 index 000000000..18fc993d2 --- /dev/null +++ b/admin/src/View/Class_properties/HtmlView.php @@ -0,0 +1,219 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Class_properties; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Class_properties + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Class_properties view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('class_property'); + $this->canEdit = $this->canDo->get('class_property.edit'); + $this->canState = $this->canDo->get('class_property.edit.state'); + $this->canCreate = $this->canDo->get('class_property.create'); + $this->canDelete = $this->canDo->get('class_property.delete'); + $this->canBatch = ($this->canDo->get('class_property.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_CLASS_PROPERTIES'), 'cube'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('class_property.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('class_property.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('class_properties.publish'); + ToolbarHelper::unpublishList('class_properties.unpublish'); + ToolbarHelper::archiveList('class_properties.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('class_properties.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'class_properties.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('class_properties.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('class_properties'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_CLASS_PROPERTIES')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.name' => Text::_('COM_COMPONENTBUILDER_CLASS_PROPERTY_NAME_LABEL'), + 'a.visibility' => Text::_('COM_COMPONENTBUILDER_CLASS_PROPERTY_VISIBILITY_LABEL'), + 'a.extension_type' => Text::_('COM_COMPONENTBUILDER_CLASS_PROPERTY_EXTENSION_TYPE_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/class_extends/tmpl/index.html b/admin/src/View/Class_properties/index.html similarity index 100% rename from admin/views/class_extends/tmpl/index.html rename to admin/src/View/Class_properties/index.html diff --git a/admin/src/View/Class_property/HtmlView.php b/admin/src/View/Class_property/HtmlView.php new file mode 100644 index 000000000..1a3aa1e1c --- /dev/null +++ b/admin/src/View/Class_property/HtmlView.php @@ -0,0 +1,248 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Class_property; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Class_property Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Class_property view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('class_property', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_CLASS_PROPERTY_NEW' : 'COM_COMPONENTBUILDER_CLASS_PROPERTY_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('class_property.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('class_property.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('class_property.edit')) + { + // We can save the record. + ToolbarHelper::save('class_property.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('class_property.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('class_property.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('class_property.create')) + { + ToolbarHelper::apply('class_property.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('class_property.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('class_property.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('class_property.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('class_property.edit')) + { + // We can save the new record + ToolbarHelper::apply('class_property.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('class_property.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('class_property.create')) + { + ToolbarHelper::custom('class_property.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('class_property.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('class_property.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.class_property', $this->item->id); + } + if ($this->canDo->get('class_property.create')) + { + ToolbarHelper::custom('class_property.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('class_property.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('class_property'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_CLASS_PROPERTY_NEW' : 'COM_COMPONENTBUILDER_CLASS_PROPERTY_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + } +} diff --git a/admin/views/class_method/tmpl/index.html b/admin/src/View/Class_property/index.html similarity index 100% rename from admin/views/class_method/tmpl/index.html rename to admin/src/View/Class_property/index.html diff --git a/admin/src/View/Compiler/HtmlView.php b/admin/src/View/Compiler/HtmlView.php new file mode 100644 index 000000000..e058a4f43 --- /dev/null +++ b/admin/src/View/Compiler/HtmlView.php @@ -0,0 +1,819 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Compiler; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\HeaderCheck; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Form\Form; +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Layout\LayoutHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\FormHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Compiler + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Display the view + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // get component params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // get the application + $this->app ??= Factory::getApplication(); + // get the user object + $this->user ??= $this->app->getIdentity(); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('compiler'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + // Initialise variables. + $this->items = $this->get('Items'); + // get the success message if set + $this->SuccessMessage = $this->app->getUserState('com_componentbuilder.success_message', false); + + // get active components + $this->Components = $this->get('Components'); + + // get the needed form fields + $this->form = $this->getDynamicForm(); + + // set the compiler artwork from global settings + $this->builder_gif_size = $this->params->get('builder_gif_size', '480-272'); + + // only run these checks if he has access + if ($this->canDo->get('compiler.compiler_animations')) + { + // if the new artwork is not being targeted hide download option of artwork + if ('480-540' !== $this->builder_gif_size) + { + $this->canDo->set('compiler.compiler_animations', false); + } + // we count of all the files are already there + else + { + $directory_path = JPATH_ROOT . "/administrator/components/com_componentbuilder/assets/images/builder-gif"; + // get all the gif files in the gif folder + $all_gifs = null; + if (is_dir($directory_path) && is_readable($directory_path)) + { + $all_gifs = scandir($directory_path); + + } + + // check if we have any values + if ($all_gifs !== null && ArrayHelper::check($all_gifs)) + { + // count number of files but remove the 2 dot values + $num_gifs = count($all_gifs) - 2; + // if we have more or the same number of files that are in the array, the we hide the download option + if ($num_gifs >= ComponentbuilderHelper::getDynamicContentSize('builder-gif', '480-540')) + { + $this->canDo->set('compiler.compiler_animations', false); + } + } + } + } + // just get it on the page for now.... + ToolbarHelper::inlinehelp(); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + // add the tool bar + $this->addToolBar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode(PHP_EOL, $errors), 500); + } + + parent::display($tpl); + + // Set the html view document stuff + $this->_prepareDocument(); + } + + // These are subform layouts used in JCB + // LayoutHelper::render('sectionjcb', [?]); // added to ensure the layout are loaded + // LayoutHelper::render('repeatablejcb', [?]); // added to ensure the layout are loaded + + /** + * Get the dynamic build form fields needed on the page + * + * @return Form|null The form fields + * + * @since 3.2.0 + */ + public function getDynamicForm(): ?Form + { + if(ArrayHelper::check($this->Components)) + { + // start the form + $form = new Form('Builder'); + + $form->load('
    + +
    +
    '); + + // sales attributes + $attributes = [ + 'type' => 'radio', + 'name' => 'backup', + 'label' => 'COM_COMPONENTBUILDER_ADD_TO_BACKUP_FOLDER_AMP_SALES_SERVER_SMALLIF_SETSMALL', + 'class' => 'btn-group btn-group-yesno', + 'description' => 'COM_COMPONENTBUILDER_SHOULD_THE_ZIPPED_PACKAGE_OF_THE_COMPONENT_BE_MOVED_TO_THE_LOCAL_BACKUP_AND_REMOTE_SALES_SERVER_THIS_IS_ONLY_APPLICABLE_IF_THIS_COMPONENT_HAS_THOSE_VALUES_SET', + 'default' => '0']; + // set the sales options + $options = [ + '1' => 'COM_COMPONENTBUILDER_YES', + '0' => 'COM_COMPONENTBUILDER_NO']; + + // add to form + $xml = FormHelper::xml($attributes, $options); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'builder'); + } + + // repository attributes + $attributes = [ + 'type' => 'radio', + 'name' => 'repository', + 'label' => 'COM_COMPONENTBUILDER_ADD_TO_REPOSITORY_FOLDER', + 'class' => 'btn-group btn-group-yesno', + 'description' => 'COM_COMPONENTBUILDER_SHOULD_THE_COMPONENT_BE_MOVED_TO_YOUR_LOCAL_REPOSITORY_FOLDER', + 'default' => '1']; + // start the repository options + $options = [ + '1' => 'COM_COMPONENTBUILDER_YES', + '0' => 'COM_COMPONENTBUILDER_NO']; + + // add to form + $xml = FormHelper::xml($attributes, $options); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'builder'); + } + + // placeholders attributes + $attributes = [ + 'type' => 'radio', + 'name' => 'add_placeholders', + 'label' => 'COM_COMPONENTBUILDER_ADD_CUSTOM_CODE_PLACEHOLDERS', + 'class' => 'btn-group btn-group-yesno', + 'description' => 'COM_COMPONENTBUILDER_SHOULD_JCB_INSERT_THE_CUSTOM_CODE_PLACEHOLDERS_THIS_IS_ONLY_APPLICABLE_IF_THIS_COMPONENT_HAS_CUSTOM_CODE', + 'default' => '2']; + // start the placeholders options + $options = [ + '2' => 'COM_COMPONENTBUILDER_GLOBAL', + '1' => 'COM_COMPONENTBUILDER_YES', + '0' => 'COM_COMPONENTBUILDER_NO']; + + // add to form + $xml = FormHelper::xml($attributes, $options); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'builder'); + } + + // debuglinenr attributes + $attributes = [ + 'type' => 'radio', + 'name' => 'debug_line_nr', + 'label' => 'COM_COMPONENTBUILDER_DEBUG_LINE_NUMBERS', + 'class' => 'btn-group btn-group-yesno', + 'description' => 'COM_COMPONENTBUILDER_ADD_CORRESPONDING_LINE_NUMBERS_TO_THE_DYNAMIC_COMMENTS_SO_TO_SEE_WHERE_IN_THE_COMPILER_THE_LINES_OF_CODE_WAS_BUILD_THIS_WILL_HELP_IF_YOU_NEED_TO_GET_MORE_TECHNICAL_WITH_AN_ISSUE_ON_GITHUB_OR_EVEN_FOR_YOUR_OWN_DEBUGGING', + 'default' => '2']; + $options = [ + '2' => 'COM_COMPONENTBUILDER_GLOBAL', + '1' => 'COM_COMPONENTBUILDER_YES', + '0' => 'COM_COMPONENTBUILDER_NO']; + + // add to form + $xml = FormHelper::xml($attributes, $options); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'builder'); + } + + // minify attributes + $attributes = [ + 'type' => 'radio', + 'name' => 'minify', + 'label' => 'COM_COMPONENTBUILDER_MINIFY_JAVASCRIPT', + 'class' => 'btn-group btn-group-yesno', + 'description' => 'COM_COMPONENTBUILDER_SHOULD_THE_JAVASCRIPT_BE_MINIFIED_IN_THE_COMPONENT', + 'default' => '2']; + $options = [ + '2' => 'COM_COMPONENTBUILDER_GLOBAL', + '1' => 'COM_COMPONENTBUILDER_YES', + '0' => 'COM_COMPONENTBUILDER_NO']; + + // add to form + $xml = FormHelper::xml($attributes, $options); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'builder'); + } + + // powers attributes + $attributes = [ + 'type' => 'radio', + 'name' => 'powers', + 'label' => 'COM_COMPONENTBUILDER_ADD_POWERS', + 'class' => 'btn-group btn-group-yesno', + 'description' => 'COM_COMPONENTBUILDER_SHOULD_JCB_ADD_ANY_POWERS_THAT_ARE_CONNECTED_TO_THIS_COMPONENT_THIS_MAY_BE_HELPFUL_IF_YOU_ARE_LOADING_POWERS_VIA_ANOTHER_COMPONENT_AND_WOULD_LIKE_TO_AVOID_ADDING_IT_TO_BOTH_JUST_REMEMBER_THAT_IN_THIS_CASE_YOU_NEED_TO_LOAD_THE_POWERS_VIA_A_PLUGIN', + 'default' => '2']; + $options = [ + '2' => 'COM_COMPONENTBUILDER_GLOBAL', + '1' => 'COM_COMPONENTBUILDER_YES', + '0' => 'COM_COMPONENTBUILDER_NO']; + + // add to form + $xml = FormHelper::xml($attributes, $options); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'builder'); + } + + // component attributes + $attributes = [ + 'type' => 'list', + 'name' => 'component_id', + 'label' => 'COM_COMPONENTBUILDER_COMPONENTS', + 'class' => 'list_class', + 'description' => 'COM_COMPONENTBUILDER_SELECT_THE_COMPONENT_TO_COMPILE', + 'required' => 'true']; + // start the component options + $options = []; + $options[''] = 'COM_COMPONENTBUILDER__SELECT_COMPONENT_'; + // load component options from array + foreach($this->Components as $component) + { + $options[(int) $component->id] = $this->escape($component->name); + } + + // add to form + $xml = FormHelper::xml($attributes, $options); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'builder'); + } + + // Joomla Versions attributes + $attributes = [ + 'type' => 'list', + 'name' => 'joomla_version', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_VERSION', + 'class' => 'list_class', + 'description' => 'COM_COMPONENTBUILDER_WHAT_VERSION_OF_JOOMLA_WOULD_YOU_LIKE_TO_TARGET', + 'default' => '3']; + // start the joomla versions options + $options = [ + '3' => 'COM_COMPONENTBUILDER_JOOMLA_THREE', + '4' => 'COM_COMPONENTBUILDER_JOOMLA_FOUR', + '5' => 'COM_COMPONENTBUILDER_JOOMLA_FIVE' + ]; + + // add to form + $xml = FormHelper::xml($attributes, $options); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'builder'); + } + + // Joomla Version 3 attributes + $attributes = [ + 'type' => 'note', + 'name' => 'joomla_version_note_three', + 'description' => 'COM_COMPONENTBUILDER_YOUR_COMPONENT_WILL_BE_COMPILED_TO_WORK_IN_JOOMLA_THREE', + 'class' => 'alert alert-success', + 'showon' => 'joomla_version:3']; + + // add to form + $xml = FormHelper::xml($attributes); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'builder'); + } + + // Joomla Version 4 and five attributes + $attributes = [ + 'type' => 'note', + 'name' => 'joomla_version_note_four', + 'description' => 'COM_COMPONENTBUILDER_YOUR_COMPONENT_WILL_BE_COMPILED_TO_WORK_IN_JOOMLA_FOUR', + 'class' => 'alert alert-success', + 'showon' => 'joomla_version:4']; + + // add to form + $xml = FormHelper::xml($attributes); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'builder'); + } + + // Joomla Version 5 and five attributes + $attributes = [ + 'type' => 'note', + 'name' => 'joomla_version_note_five', + 'description' => 'COM_COMPONENTBUILDER_YOUR_COMPONENT_WILL_BE_COMPILED_TO_WORK_IN_JOOMLA_FIVE', + 'class' => 'alert alert-success', + 'showon' => 'joomla_version:5']; + + // add to form + $xml = FormHelper::xml($attributes); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'builder'); + } + + // Advanced Options + $attributes = [ + 'type' => 'radio', + 'name' => 'show_advanced_options', + 'label' => 'COM_COMPONENTBUILDER_SHOW_ADVANCED_OPTIONS', + 'class' => 'btn-group btn-group-yesno', + 'description' => 'COM_COMPONENTBUILDER_WOULD_YOU_LIKE_TO_SEE_THE_ADVANCED_COMPILER_OPTIONS', + 'default' => '0']; + // start the advanced options switch + $options = [ + '1' => 'COM_COMPONENTBUILDER_YES', + '0' => 'COM_COMPONENTBUILDER_NO']; + + // add to form + $xml = FormHelper::xml($attributes, $options); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'builder'); + } + + // Advanced Options note attributes + $attributes = [ + 'type' => 'note', + 'name' => 'show_advanced_options_note', + 'label' => "COM_COMPONENTBUILDER_ADVANCED_OPTIONS", + 'heading' => 'h3', + 'showon' => 'show_advanced_options:1']; + + // add to form + $xml = FormHelper::xml($attributes); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'advanced'); + } + + // powers repository attributes + $attributes = [ + 'type' => 'radio', + 'name' => 'powers_repository', + 'label' => 'COM_COMPONENTBUILDER_ACTIVATE_SUPER_POWERS', + 'class' => 'btn-group btn-group-yesno', + 'description' => 'COM_COMPONENTBUILDER_THIS_ADDS_POWERS_TO_A_LOCAL_REPOSITORY_FOLDER_ALL_BAPPROVEDB_POWERS_LINKED_TO_THIS_COMPONENT_WILL_BE_MOVED_TO_YOUR_BLOCALB_POWERS_REPOSITORY_FOLDER_INTO_THEIR_SELECTIVE_TARGET_PATHS_THIS_LOCAL_FOLDER_PATH_MUST_BE_SET_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_BSUPER_POWERB_TAB', + 'default' => '2', + 'showon' => 'show_advanced_options:1']; + // start the repository options + $options = [ + '2' => 'COM_COMPONENTBUILDER_GLOBAL', + '1' => 'COM_COMPONENTBUILDER_YES', + '0' => 'COM_COMPONENTBUILDER_NO']; + + // add to form + $xml = FormHelper::xml($attributes, $options); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'advanced'); + } + + // powers local path to repositories attributes + $attributes = [ + 'type' => 'text', + 'name' => 'local_powers_repository_path', + 'label' => 'COM_COMPONENTBUILDER_LOCAL_POWERS_REPOSITORY_PATH', + 'class' => 'btn-group btn-group-yesno', + 'description' => 'COM_COMPONENTBUILDER_HERE_YOU_CAN_SET_THE_PATH_TO_THE_SUPER_POWERS_LOCAL_REPOSITORY_FOLDER_WHERE_BLAYERCOREB_AND_ALL_TARGETED_BLAYEROWNB_SUB_PATHS_WILL_BE_PLACED_WITH_THEIR_SELECTIVE_BSWITCHAPPROVEDB_POWERS', + 'default' => $this->params->get('local_powers_repository_path', ''), + 'showon' => 'show_advanced_options:1[AND]powers_repository:1']; + + // add to form + $xml = FormHelper::xml($attributes); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'advanced'); + } + + // Indentation attributes + $attributes = [ + 'type' => 'radio', + 'name' => 'indentation_value', + 'label' => 'COM_COMPONENTBUILDER_INDENTATION_OPTIONS', + 'class' => 'btn-group btn-group-yesno', + 'description' => 'COM_COMPONENTBUILDER_WHICH_TYPE_OF_INDENTATION_WOULD_YOU_LIKE_TO_USE_PLEASE_NOTE_THAT_THIS_DOES_NOT_YET_IMPACT_THE_STATIC_TEMPLATES', + 'default' => '1', + 'showon' => 'show_advanced_options:1']; + + // start the indentation options + $options = [ + '1' => 'COM_COMPONENTBUILDER_TAB', + '2' => 'COM_COMPONENTBUILDER_TWO_SPACES', + '4' => 'COM_COMPONENTBUILDER_FOUR_SPACES']; + + // add to form + $xml = FormHelper::xml($attributes, $options); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'advanced'); + } + + // Build date attributes + $attributes = [ + 'type' => 'radio', + 'name' => 'add_build_date', + 'label' => 'COM_COMPONENTBUILDER_BUILD_DATE', + 'class' => 'btn-group btn-group-yesno', + 'description' => 'COM_COMPONENTBUILDER_WOULD_YOU_LIKE_TO_OVERRIDE_THE_BUILD_DATE', + 'default' => '1', + 'showon' => 'show_advanced_options:1']; + // start the build date options + $options = [ + '1' => 'COM_COMPONENTBUILDER_DEFAULT', + '2' => 'COM_COMPONENTBUILDER_MANUAL', + '3' => 'COM_COMPONENTBUILDER_COMPONENT']; + + // add to form + $xml = FormHelper::xml($attributes, $options); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'advanced'); + } + + // Build date note attributes + $attributes = [ + 'type' => 'note', + 'name' => 'add_build_date_note_two', + 'description' => 'COM_COMPONENTBUILDER_ALLOWS_YOU_TO_OVERRIDE_THE_BUILD_DATE_BY_SELECTING_A_DATE_MANUALLY_FROM_THE_CALENDER', + 'class' => 'alert alert-info', + 'showon' => 'show_advanced_options:1[AND]add_build_date:2']; + + // add to form + $xml = FormHelper::xml($attributes); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'advanced'); + } + + // Build date note attributes + $attributes = [ + 'type' => 'note', + 'name' => 'add_build_date_note_three', + 'description' => "COM_COMPONENTBUILDER_THE_COMPONENTS_LAST_MODIFIED_DATE_WILL_BE_USED", + 'class' => 'alert alert-info', + 'showon' => 'show_advanced_options:1[AND]add_build_date:3']; + + // add to form + $xml = FormHelper::xml($attributes); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'advanced'); + } + + // Build date calendar attributes + $attributes = [ + 'type' => 'calendar', + 'name' => 'build_date', + 'label' => 'COM_COMPONENTBUILDER_SELECT_BUILD_DATE', + 'format' => '%Y-%m-%d', + 'filter' => 'user_utc', + 'default' => 'now', + 'size' => '22', + 'showon' => 'show_advanced_options:1[AND]add_build_date:2']; + + // add to form + $xml = FormHelper::xml($attributes); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'advanced'); + } + + // Build date note attributes + $attributes = [ + 'type' => 'note', + 'name' => 'donations_note', + 'label' => "COM_COMPONENTBUILDER_DONATIONS", + 'description' => $this->getSupportMessage(), + 'class' => 'alert alert-success', + 'heading' => 'h1', + 'showon' => 'show_advanced_options:1']; + + // add to form + $xml = FormHelper::xml($attributes); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'advanced'); + } + + // Build date note line attributes + $attributes = [ + 'type' => 'note', + 'name' => 'donations_note_line', + 'description' => '
    ', + 'showon' => 'show_advanced_options:1']; + + // add to form + $xml = FormHelper::xml($attributes); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'advanced'); + } + + // return the form array + return $form; + } + + return null; + } + + /** + * Get the dynamic support request/gratitude message + * + * @return string The support message + * + * @since 3.2.0 + */ + protected function getSupportMessage(): string + { + return LayoutHelper::render('jcbsupportmessage', []); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + + // Only load jQuery if needed. (default is true) + if ($this->params->get('add_jquery_framework', 1) == 1) + { + Html::_('jquery.framework'); + } + // Load the header checker class. + // Initialize the header checker. + $HeaderCheck = new HeaderCheck(); + + // Load uikit options. + $uikit = $this->params->get('uikit_load'); + // Set script size. + $size = $this->params->get('uikit_min'); + // Set css style. + $style = $this->params->get('uikit_style'); + + // The uikit css. + if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) + { + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit'.$style.$size.'.css', ['version' => 'auto']); + } + // The uikit js. + if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) + { + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit'.$size.'.js', ['version' => 'auto']); + } + + // Load the needed uikit components in this view. + $uikitComp = $this->get('UikitComp'); + if ($uikit != 2 && isset($uikitComp) && ArrayHelper::check($uikitComp)) + { + // loading... + foreach ($uikitComp as $class) + { + foreach (ComponentbuilderHelper::$uk_components[$class] as $name) + { + // check if the CSS file exists. + if (File::exists(JPATH_ROOT.'/media/com_componentbuilder/uikit-v2/css/components/'.$name.$style.$size.'.css')) + { + // load the css. + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/'.$name.$style.$size.'.css', ['version' => 'auto']); + } + // check if the JavaScript file exists. + if (File::exists(JPATH_ROOT.'/media/com_componentbuilder/uikit-v2/js/components/'.$name.$size.'.js')) + { + // load the js. + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/'.$name.$size.'.js', ['version' => 'auto'], ['type' => 'text/javascript', 'async' => 'async']); + } + } + } + } + // add marked library + Html::_('script', 'administrator/components/com_componentbuilder/custom/marked.js', ['version' => 'auto']); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + // Set the Custom JS script to view + $this->getDocument()->addScriptDeclaration(" + function getComponentDetails_server(id) { + let getUrl = JRouter(\"index.php?option=com_componentbuilder&task=ajax.getComponentDetails&format=json&raw=true\"); + let request = new URLSearchParams(); + if (token.length > 0 && id > 0) { + request.append(token, '1'); + request.append('id', id); + } + return fetch(getUrl + '&' + request.toString(), { + method: 'GET', + headers: { + 'Accept': 'application/json' + } + }).then(response => response.json()); + } + function getComponentDetails(id) { + getComponentDetails_server(id).then(function(result) { + if (result.html) { + document.getElementById('component-details').innerHTML = result.html; + if (result.preferred_joomla_version) { + jQuery('#joomla_version').val(result.preferred_joomla_version); + jQuery('#joomla_version').trigger('liszt:updated'); + jQuery('#joomla_version').trigger('change'); + } + } + }); + } + + document.addEventListener('DOMContentLoaded', function() { + fetchNoticeboard(\"https://vdm.bz/componentbuilder-noticeboard-md\", \".noticeboard-md\", true); + fetchNoticeboard(\"https://vdm.bz/componentbuilder-pro-noticeboard-md\", \".proboard-md\", false); + }); + function fetchNoticeboard(url, selector, processGetIS) { + fetch(url) + .then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.text(); + }) + .then(board => { + var elements = document.querySelectorAll(selector); + if (board.length > 5) { + let html_board = marked.parse(board); + elements.forEach(element => { + element.innerHTML = html_board; + }); + if (processGetIS) { + getIS(1, board).then(result => { + if (result) { + document.querySelectorAll(\".vdm-new-notice\").forEach(element => { + element.style.display = 'block'; + }); + getIS(2, board); + } + }); + } + } else { + elements.forEach(element => { + element.innerHTML = all_is_good; + }); + } + }) + .catch(error => { + console.error('There was an error!', error); + document.querySelectorAll(selector).forEach(element => { + element.innerHTML = all_is_good; + }); + }); + } + // to check is READ/NEW + function getIS(type, notice) { + let getUrl = \"\"; + if (type === 1) { + getUrl = JRouter(\"index.php?option=com_componentbuilder&task=ajax.isNew&format=json&raw=true\"); + } else if (type === 2) { + getUrl = JRouter(\"index.php?option=com_componentbuilder&task=ajax.isRead&format=json&raw=true\"); + } + let request = new URLSearchParams(); + if (token.length > 0 && notice.length) { + request.append(token, \"1\"); + request.append(\"notice\", notice); + } + return fetch(getUrl, { + method: \"POST\", + headers: { + \"Content-Type\": \"application/x-www-form-urlencoded;charset=UTF-8\" + }, + body: request + }).then(response => response.json()); + } + "); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + // hide the main menu + $this->app->input->set('hidemainmenu', true); + // add title to the page + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_COMPILER'),'cogs'); + // add cpanel button + ToolbarHelper::custom('compiler.dashboard', 'grid-2', '', 'COM_COMPONENTBUILDER_DASH', false); + if ($this->canDo->get('compiler.run_expansion')) + { + // add Run Expansion button. + ToolbarHelper::custom('compiler.runExpansion', 'expand-2 custom-button-runexpansion', '', 'COM_COMPONENTBUILDER_RUN_EXPANSION', false); + } + if ($this->canDo->get('compiler.translate')) + { + // add Translate button. + ToolbarHelper::custom('compiler.runTranslator', 'comments-2 custom-button-runtranslator', '', 'COM_COMPONENTBUILDER_TRANSLATE', false); + } + if ($this->canDo->get('compiler.compiler_animations')) + { + // add Compiler Animations button. + ToolbarHelper::custom('compiler.getDynamicContent', 'download custom-button-getdynamiccontent', '', 'COM_COMPONENTBUILDER_COMPILER_ANIMATIONS', false); + } + if ($this->canDo->get('compiler.clear_tmp')) + { + // add Clear tmp button. + ToolbarHelper::custom('compiler.clearTmp', 'purge custom-button-cleartmp', '', 'COM_COMPONENTBUILDER_CLEAR_TMP', false); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('compiler'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = false, int $length = 40) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } +} diff --git a/admin/views/class_methods/index.html b/admin/src/View/Compiler/index.html similarity index 100% rename from admin/views/class_methods/index.html rename to admin/src/View/Compiler/index.html diff --git a/admin/src/View/Component_admin_views/HtmlView.php b/admin/src/View/Component_admin_views/HtmlView.php new file mode 100644 index 000000000..0b3e9fd79 --- /dev/null +++ b/admin/src/View/Component_admin_views/HtmlView.php @@ -0,0 +1,236 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Component_admin_views; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Component_admin_views Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Component_admin_views view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_admin_views', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('component_admin_views.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('component_admin_views.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('component_admin_views.edit')) + { + // We can save the record. + ToolbarHelper::save('component_admin_views.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('component_admin_views.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('component_admin_views.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('component_admin_views.create')) + { + ToolbarHelper::apply('component_admin_views.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_admin_views.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('component_admin_views.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('component_admin_views.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('component_admin_views.edit')) + { + // We can save the new record + ToolbarHelper::apply('component_admin_views.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_admin_views.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('component_admin_views.create')) + { + ToolbarHelper::custom('component_admin_views.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_admin_views.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_admin_views.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.component_admin_views', $this->item->id); + } + if ($this->canDo->get('component_admin_views.create')) + { + ToolbarHelper::custom('component_admin_views.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('component_admin_views.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('component_admin_views'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + } +} diff --git a/admin/views/class_methods/tmpl/index.html b/admin/src/View/Component_admin_views/index.html similarity index 100% rename from admin/views/class_methods/tmpl/index.html rename to admin/src/View/Component_admin_views/index.html diff --git a/admin/src/View/Component_config/HtmlView.php b/admin/src/View/Component_config/HtmlView.php new file mode 100644 index 000000000..1397fa1e7 --- /dev/null +++ b/admin/src/View/Component_config/HtmlView.php @@ -0,0 +1,230 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Component_config; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Component_config Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Component_config view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_config', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_CONFIG_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_CONFIG_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('component_config.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('component_config.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('component_config.edit')) + { + // We can save the record. + ToolbarHelper::save('component_config.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('component_config.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('component_config.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('component_config.create')) + { + ToolbarHelper::apply('component_config.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_config.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('component_config.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('component_config.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('component_config.edit')) + { + // We can save the new record + ToolbarHelper::apply('component_config.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_config.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('component_config.create')) + { + ToolbarHelper::custom('component_config.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_config.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_config.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.component_config', $this->item->id); + } + if ($this->canDo->get('component_config.create')) + { + ToolbarHelper::custom('component_config.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('component_config.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('component_config'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_CONFIG_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_CONFIG_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } +} diff --git a/admin/views/class_properties/index.html b/admin/src/View/Component_config/index.html similarity index 100% rename from admin/views/class_properties/index.html rename to admin/src/View/Component_config/index.html diff --git a/admin/src/View/Component_custom_admin_menus/HtmlView.php b/admin/src/View/Component_custom_admin_menus/HtmlView.php new file mode 100644 index 000000000..dcc16c40b --- /dev/null +++ b/admin/src/View/Component_custom_admin_menus/HtmlView.php @@ -0,0 +1,236 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Component_custom_admin_menus; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Component_custom_admin_menus Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Component_custom_admin_menus view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_custom_admin_menus', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('component_custom_admin_menus.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('component_custom_admin_menus.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('component_custom_admin_menus.edit')) + { + // We can save the record. + ToolbarHelper::save('component_custom_admin_menus.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('component_custom_admin_menus.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('component_custom_admin_menus.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('component_custom_admin_menus.create')) + { + ToolbarHelper::apply('component_custom_admin_menus.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_custom_admin_menus.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('component_custom_admin_menus.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('component_custom_admin_menus.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('component_custom_admin_menus.edit')) + { + // We can save the new record + ToolbarHelper::apply('component_custom_admin_menus.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_custom_admin_menus.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('component_custom_admin_menus.create')) + { + ToolbarHelper::custom('component_custom_admin_menus.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_custom_admin_menus.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_custom_admin_menus.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.component_custom_admin_menus', $this->item->id); + } + if ($this->canDo->get('component_custom_admin_menus.create')) + { + ToolbarHelper::custom('component_custom_admin_menus.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('component_custom_admin_menus.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('component_custom_admin_menus'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + } +} diff --git a/admin/views/class_properties/tmpl/index.html b/admin/src/View/Component_custom_admin_menus/index.html similarity index 100% rename from admin/views/class_properties/tmpl/index.html rename to admin/src/View/Component_custom_admin_menus/index.html diff --git a/admin/src/View/Component_custom_admin_views/HtmlView.php b/admin/src/View/Component_custom_admin_views/HtmlView.php new file mode 100644 index 000000000..01b290008 --- /dev/null +++ b/admin/src/View/Component_custom_admin_views/HtmlView.php @@ -0,0 +1,236 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Component_custom_admin_views; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Component_custom_admin_views Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Component_custom_admin_views view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_custom_admin_views', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('component_custom_admin_views.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('component_custom_admin_views.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('component_custom_admin_views.edit')) + { + // We can save the record. + ToolbarHelper::save('component_custom_admin_views.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('component_custom_admin_views.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('component_custom_admin_views.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('component_custom_admin_views.create')) + { + ToolbarHelper::apply('component_custom_admin_views.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_custom_admin_views.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('component_custom_admin_views.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('component_custom_admin_views.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('component_custom_admin_views.edit')) + { + // We can save the new record + ToolbarHelper::apply('component_custom_admin_views.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_custom_admin_views.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('component_custom_admin_views.create')) + { + ToolbarHelper::custom('component_custom_admin_views.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_custom_admin_views.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_custom_admin_views.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.component_custom_admin_views', $this->item->id); + } + if ($this->canDo->get('component_custom_admin_views.create')) + { + ToolbarHelper::custom('component_custom_admin_views.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('component_custom_admin_views.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('component_custom_admin_views'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + } +} diff --git a/admin/views/class_property/tmpl/index.html b/admin/src/View/Component_custom_admin_views/index.html similarity index 100% rename from admin/views/class_property/tmpl/index.html rename to admin/src/View/Component_custom_admin_views/index.html diff --git a/admin/src/View/Component_dashboard/HtmlView.php b/admin/src/View/Component_dashboard/HtmlView.php new file mode 100644 index 000000000..cbbc74fab --- /dev/null +++ b/admin/src/View/Component_dashboard/HtmlView.php @@ -0,0 +1,248 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Component_dashboard; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Component_dashboard Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Component_dashboard view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_dashboard', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('component_dashboard.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('component_dashboard.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('component_dashboard.edit')) + { + // We can save the record. + ToolbarHelper::save('component_dashboard.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('component_dashboard.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('component_dashboard.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('component_dashboard.create')) + { + ToolbarHelper::apply('component_dashboard.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_dashboard.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('component_dashboard.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('component_dashboard.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('component_dashboard.edit')) + { + // We can save the new record + ToolbarHelper::apply('component_dashboard.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_dashboard.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('component_dashboard.create')) + { + ToolbarHelper::custom('component_dashboard.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_dashboard.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_dashboard.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.component_dashboard', $this->item->id); + } + if ($this->canDo->get('component_dashboard.create')) + { + ToolbarHelper::custom('component_dashboard.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('component_dashboard.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('component_dashboard'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + } +} diff --git a/admin/views/compiler/index.html b/admin/src/View/Component_dashboard/index.html similarity index 100% rename from admin/views/compiler/index.html rename to admin/src/View/Component_dashboard/index.html diff --git a/admin/src/View/Component_files_folders/HtmlView.php b/admin/src/View/Component_files_folders/HtmlView.php new file mode 100644 index 000000000..316636bdc --- /dev/null +++ b/admin/src/View/Component_files_folders/HtmlView.php @@ -0,0 +1,230 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Component_files_folders; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Component_files_folders Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Component_files_folders view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_files_folders', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('component_files_folders.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('component_files_folders.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('component_files_folders.edit')) + { + // We can save the record. + ToolbarHelper::save('component_files_folders.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('component_files_folders.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('component_files_folders.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('component_files_folders.create')) + { + ToolbarHelper::apply('component_files_folders.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_files_folders.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('component_files_folders.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('component_files_folders.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('component_files_folders.edit')) + { + // We can save the new record + ToolbarHelper::apply('component_files_folders.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_files_folders.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('component_files_folders.create')) + { + ToolbarHelper::custom('component_files_folders.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_files_folders.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_files_folders.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.component_files_folders', $this->item->id); + } + if ($this->canDo->get('component_files_folders.create')) + { + ToolbarHelper::custom('component_files_folders.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('component_files_folders.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('component_files_folders'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } +} diff --git a/admin/views/compiler/tmpl/index.html b/admin/src/View/Component_files_folders/index.html similarity index 100% rename from admin/views/compiler/tmpl/index.html rename to admin/src/View/Component_files_folders/index.html diff --git a/admin/src/View/Component_modules/HtmlView.php b/admin/src/View/Component_modules/HtmlView.php new file mode 100644 index 000000000..64db1e266 --- /dev/null +++ b/admin/src/View/Component_modules/HtmlView.php @@ -0,0 +1,230 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Component_modules; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Component_modules Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Component_modules view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_modules', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_MODULES_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_MODULES_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('component_modules.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('component_modules.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('component_modules.edit')) + { + // We can save the record. + ToolbarHelper::save('component_modules.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('component_modules.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('component_modules.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('component_modules.create')) + { + ToolbarHelper::apply('component_modules.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_modules.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('component_modules.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('component_modules.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('component_modules.edit')) + { + // We can save the new record + ToolbarHelper::apply('component_modules.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_modules.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('component_modules.create')) + { + ToolbarHelper::custom('component_modules.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_modules.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_modules.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.component_modules', $this->item->id); + } + if ($this->canDo->get('component_modules.create')) + { + ToolbarHelper::custom('component_modules.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('component_modules.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('component_modules'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_MODULES_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_MODULES_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } +} diff --git a/admin/views/component_admin_views/tmpl/index.html b/admin/src/View/Component_modules/index.html similarity index 100% rename from admin/views/component_admin_views/tmpl/index.html rename to admin/src/View/Component_modules/index.html diff --git a/admin/src/View/Component_mysql_tweaks/HtmlView.php b/admin/src/View/Component_mysql_tweaks/HtmlView.php new file mode 100644 index 000000000..7b5494ee1 --- /dev/null +++ b/admin/src/View/Component_mysql_tweaks/HtmlView.php @@ -0,0 +1,230 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Component_mysql_tweaks; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Component_mysql_tweaks Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Component_mysql_tweaks view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_mysql_tweaks', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('component_mysql_tweaks.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('component_mysql_tweaks.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('component_mysql_tweaks.edit')) + { + // We can save the record. + ToolbarHelper::save('component_mysql_tweaks.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('component_mysql_tweaks.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('component_mysql_tweaks.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('component_mysql_tweaks.create')) + { + ToolbarHelper::apply('component_mysql_tweaks.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_mysql_tweaks.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('component_mysql_tweaks.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('component_mysql_tweaks.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('component_mysql_tweaks.edit')) + { + // We can save the new record + ToolbarHelper::apply('component_mysql_tweaks.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_mysql_tweaks.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('component_mysql_tweaks.create')) + { + ToolbarHelper::custom('component_mysql_tweaks.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_mysql_tweaks.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_mysql_tweaks.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.component_mysql_tweaks', $this->item->id); + } + if ($this->canDo->get('component_mysql_tweaks.create')) + { + ToolbarHelper::custom('component_mysql_tweaks.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('component_mysql_tweaks.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('component_mysql_tweaks'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } +} diff --git a/admin/views/component_config/tmpl/index.html b/admin/src/View/Component_mysql_tweaks/index.html similarity index 100% rename from admin/views/component_config/tmpl/index.html rename to admin/src/View/Component_mysql_tweaks/index.html diff --git a/admin/src/View/Component_placeholders/HtmlView.php b/admin/src/View/Component_placeholders/HtmlView.php new file mode 100644 index 000000000..26375a67e --- /dev/null +++ b/admin/src/View/Component_placeholders/HtmlView.php @@ -0,0 +1,230 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Component_placeholders; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Component_placeholders Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Component_placeholders view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_placeholders', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('component_placeholders.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('component_placeholders.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('component_placeholders.edit')) + { + // We can save the record. + ToolbarHelper::save('component_placeholders.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('component_placeholders.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('component_placeholders.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('component_placeholders.create')) + { + ToolbarHelper::apply('component_placeholders.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_placeholders.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('component_placeholders.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('component_placeholders.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('component_placeholders.edit')) + { + // We can save the new record + ToolbarHelper::apply('component_placeholders.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_placeholders.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('component_placeholders.create')) + { + ToolbarHelper::custom('component_placeholders.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_placeholders.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_placeholders.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.component_placeholders', $this->item->id); + } + if ($this->canDo->get('component_placeholders.create')) + { + ToolbarHelper::custom('component_placeholders.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('component_placeholders.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('component_placeholders'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } +} diff --git a/admin/views/component_custom_admin_menus/tmpl/index.html b/admin/src/View/Component_placeholders/index.html similarity index 100% rename from admin/views/component_custom_admin_menus/tmpl/index.html rename to admin/src/View/Component_placeholders/index.html diff --git a/admin/src/View/Component_plugins/HtmlView.php b/admin/src/View/Component_plugins/HtmlView.php new file mode 100644 index 000000000..6e3db36fb --- /dev/null +++ b/admin/src/View/Component_plugins/HtmlView.php @@ -0,0 +1,230 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Component_plugins; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Component_plugins Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Component_plugins view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_plugins', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_PLUGINS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_PLUGINS_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('component_plugins.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('component_plugins.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('component_plugins.edit')) + { + // We can save the record. + ToolbarHelper::save('component_plugins.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('component_plugins.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('component_plugins.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('component_plugins.create')) + { + ToolbarHelper::apply('component_plugins.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_plugins.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('component_plugins.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('component_plugins.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('component_plugins.edit')) + { + // We can save the new record + ToolbarHelper::apply('component_plugins.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_plugins.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('component_plugins.create')) + { + ToolbarHelper::custom('component_plugins.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_plugins.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_plugins.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.component_plugins', $this->item->id); + } + if ($this->canDo->get('component_plugins.create')) + { + ToolbarHelper::custom('component_plugins.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('component_plugins.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('component_plugins'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_PLUGINS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_PLUGINS_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } +} diff --git a/admin/views/component_custom_admin_views/tmpl/index.html b/admin/src/View/Component_plugins/index.html similarity index 100% rename from admin/views/component_custom_admin_views/tmpl/index.html rename to admin/src/View/Component_plugins/index.html diff --git a/admin/src/View/Component_router/HtmlView.php b/admin/src/View/Component_router/HtmlView.php new file mode 100644 index 000000000..e910b1c4c --- /dev/null +++ b/admin/src/View/Component_router/HtmlView.php @@ -0,0 +1,238 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Component_router; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Component_router Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Component_router view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_router', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('component_router.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('component_router.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('component_router.edit')) + { + // We can save the record. + ToolbarHelper::save('component_router.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('component_router.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('component_router.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('component_router.create')) + { + ToolbarHelper::apply('component_router.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_router.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('component_router.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('component_router.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('component_router.edit')) + { + // We can save the new record + ToolbarHelper::apply('component_router.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_router.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('component_router.create')) + { + ToolbarHelper::custom('component_router.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_router.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_router.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.component_router', $this->item->id); + } + if ($this->canDo->get('component_router.create')) + { + ToolbarHelper::custom('component_router.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('component_router.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('component_router'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + } +} diff --git a/admin/views/component_dashboard/tmpl/index.html b/admin/src/View/Component_router/index.html similarity index 100% rename from admin/views/component_dashboard/tmpl/index.html rename to admin/src/View/Component_router/index.html diff --git a/admin/src/View/Component_site_views/HtmlView.php b/admin/src/View/Component_site_views/HtmlView.php new file mode 100644 index 000000000..0f8533e29 --- /dev/null +++ b/admin/src/View/Component_site_views/HtmlView.php @@ -0,0 +1,236 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Component_site_views; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Component_site_views Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Component_site_views view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_site_views', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('component_site_views.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('component_site_views.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('component_site_views.edit')) + { + // We can save the record. + ToolbarHelper::save('component_site_views.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('component_site_views.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('component_site_views.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('component_site_views.create')) + { + ToolbarHelper::apply('component_site_views.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_site_views.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('component_site_views.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('component_site_views.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('component_site_views.edit')) + { + // We can save the new record + ToolbarHelper::apply('component_site_views.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_site_views.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('component_site_views.create')) + { + ToolbarHelper::custom('component_site_views.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_site_views.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_site_views.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.component_site_views', $this->item->id); + } + if ($this->canDo->get('component_site_views.create')) + { + ToolbarHelper::custom('component_site_views.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('component_site_views.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('component_site_views'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + } +} diff --git a/admin/views/component_files_folders/tmpl/index.html b/admin/src/View/Component_site_views/index.html similarity index 100% rename from admin/views/component_files_folders/tmpl/index.html rename to admin/src/View/Component_site_views/index.html diff --git a/admin/src/View/Component_updates/HtmlView.php b/admin/src/View/Component_updates/HtmlView.php new file mode 100644 index 000000000..2f46b0110 --- /dev/null +++ b/admin/src/View/Component_updates/HtmlView.php @@ -0,0 +1,230 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Component_updates; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Component_updates Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Component_updates view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_updates', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_UPDATES_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_UPDATES_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('component_updates.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('component_updates.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('component_updates.edit')) + { + // We can save the record. + ToolbarHelper::save('component_updates.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('component_updates.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('component_updates.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('component_updates.create')) + { + ToolbarHelper::apply('component_updates.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_updates.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('component_updates.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('component_updates.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('component_updates.edit')) + { + // We can save the new record + ToolbarHelper::apply('component_updates.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('component_updates.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('component_updates.create')) + { + ToolbarHelper::custom('component_updates.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_updates.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_updates.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.component_updates', $this->item->id); + } + if ($this->canDo->get('component_updates.create')) + { + ToolbarHelper::custom('component_updates.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('component_updates.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('component_updates'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_UPDATES_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_UPDATES_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } +} diff --git a/admin/views/component_modules/tmpl/index.html b/admin/src/View/Component_updates/index.html similarity index 100% rename from admin/views/component_modules/tmpl/index.html rename to admin/src/View/Component_updates/index.html diff --git a/admin/src/View/Componentbuilder/HtmlView.php b/admin/src/View/Componentbuilder/HtmlView.php new file mode 100644 index 000000000..4d878d056 --- /dev/null +++ b/admin/src/View/Componentbuilder/HtmlView.php @@ -0,0 +1,106 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Componentbuilder; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * View display method + * @return void + */ + function display($tpl = null) + { + // Assign data to the view + $this->icons = $this->get('Icons'); + $this->contributors = ComponentbuilderHelper::getContributors(); + + // get the manifest details of the component + $this->manifest = ComponentbuilderHelper::manifest(); + $this->wiki = $this->get('Wiki'); + $this->noticeboard = $this->get('Noticeboard'); + $this->readme = $this->get('Readme'); + $this->version = $this->get('Version'); + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + $canDo = ComponentbuilderHelper::getActions('componentbuilder'); + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_DASHBOARD'), 'grid-2'); + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('componentbuilder'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + if ($canDo->get('core.admin') || $canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // set page title + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_DASHBOARD')); + + // add manifest to page JavaScript + $this->getDocument()->addScriptDeclaration("var manifest = JSON.parse('" . json_encode($this->manifest) . "');", "text/javascript"); + + // add dashboard style sheets + Html::_('stylesheet', "administrator/components/com_componentbuilder/assets/css/dashboard.css", ['version' => 'auto']); + } +} diff --git a/admin/views/component_mysql_tweaks/tmpl/index.html b/admin/src/View/Componentbuilder/index.html similarity index 100% rename from admin/views/component_mysql_tweaks/tmpl/index.html rename to admin/src/View/Componentbuilder/index.html diff --git a/admin/src/View/Components_admin_views/HtmlView.php b/admin/src/View/Components_admin_views/HtmlView.php new file mode 100644 index 000000000..80a956552 --- /dev/null +++ b/admin/src/View/Components_admin_views/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Components_admin_views; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Components_admin_views + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Components_admin_views view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_admin_views'); + $this->canEdit = $this->canDo->get('component_admin_views.edit'); + $this->canState = $this->canDo->get('component_admin_views.edit.state'); + $this->canCreate = $this->canDo->get('component_admin_views.create'); + $this->canDelete = $this->canDo->get('component_admin_views.delete'); + $this->canBatch = ($this->canDo->get('component_admin_views.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('component_admin_views.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('component_admin_views.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('components_admin_views.publish'); + ToolbarHelper::unpublishList('components_admin_views.unpublish'); + ToolbarHelper::archiveList('components_admin_views.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('components_admin_views.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'components_admin_views.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('components_admin_views.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('components_admin_views'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/component_placeholders/tmpl/index.html b/admin/src/View/Components_admin_views/index.html similarity index 100% rename from admin/views/component_placeholders/tmpl/index.html rename to admin/src/View/Components_admin_views/index.html diff --git a/admin/src/View/Components_config/HtmlView.php b/admin/src/View/Components_config/HtmlView.php new file mode 100644 index 000000000..a29b16f66 --- /dev/null +++ b/admin/src/View/Components_config/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Components_config; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Components_config + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Components_config view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_config'); + $this->canEdit = $this->canDo->get('component_config.edit'); + $this->canState = $this->canDo->get('component_config.edit.state'); + $this->canCreate = $this->canDo->get('component_config.create'); + $this->canDelete = $this->canDo->get('component_config.delete'); + $this->canBatch = ($this->canDo->get('component_config.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_COMPONENTS_CONFIG'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('component_config.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('component_config.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('components_config.publish'); + ToolbarHelper::unpublishList('components_config.unpublish'); + ToolbarHelper::archiveList('components_config.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('components_config.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'components_config.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('components_config.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('components_config'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_COMPONENTS_CONFIG')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/component_plugins/tmpl/index.html b/admin/src/View/Components_config/index.html similarity index 100% rename from admin/views/component_plugins/tmpl/index.html rename to admin/src/View/Components_config/index.html diff --git a/admin/src/View/Components_custom_admin_menus/HtmlView.php b/admin/src/View/Components_custom_admin_menus/HtmlView.php new file mode 100644 index 000000000..6e2448ea4 --- /dev/null +++ b/admin/src/View/Components_custom_admin_menus/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Components_custom_admin_menus; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Components_custom_admin_menus + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Components_custom_admin_menus view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_custom_admin_menus'); + $this->canEdit = $this->canDo->get('component_custom_admin_menus.edit'); + $this->canState = $this->canDo->get('component_custom_admin_menus.edit.state'); + $this->canCreate = $this->canDo->get('component_custom_admin_menus.create'); + $this->canDelete = $this->canDo->get('component_custom_admin_menus.delete'); + $this->canBatch = ($this->canDo->get('component_custom_admin_menus.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_MENUS'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('component_custom_admin_menus.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('component_custom_admin_menus.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('components_custom_admin_menus.publish'); + ToolbarHelper::unpublishList('components_custom_admin_menus.unpublish'); + ToolbarHelper::archiveList('components_custom_admin_menus.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('components_custom_admin_menus.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'components_custom_admin_menus.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('components_custom_admin_menus.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('components_custom_admin_menus'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_MENUS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/component_site_views/tmpl/index.html b/admin/src/View/Components_custom_admin_menus/index.html similarity index 100% rename from admin/views/component_site_views/tmpl/index.html rename to admin/src/View/Components_custom_admin_menus/index.html diff --git a/admin/src/View/Components_custom_admin_views/HtmlView.php b/admin/src/View/Components_custom_admin_views/HtmlView.php new file mode 100644 index 000000000..3a4222d5d --- /dev/null +++ b/admin/src/View/Components_custom_admin_views/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Components_custom_admin_views; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Components_custom_admin_views + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Components_custom_admin_views view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_custom_admin_views'); + $this->canEdit = $this->canDo->get('component_custom_admin_views.edit'); + $this->canState = $this->canDo->get('component_custom_admin_views.edit.state'); + $this->canCreate = $this->canDo->get('component_custom_admin_views.create'); + $this->canDelete = $this->canDo->get('component_custom_admin_views.delete'); + $this->canBatch = ($this->canDo->get('component_custom_admin_views.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_VIEWS'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('component_custom_admin_views.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('component_custom_admin_views.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('components_custom_admin_views.publish'); + ToolbarHelper::unpublishList('components_custom_admin_views.unpublish'); + ToolbarHelper::archiveList('components_custom_admin_views.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('components_custom_admin_views.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'components_custom_admin_views.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('components_custom_admin_views.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('components_custom_admin_views'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_VIEWS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/component_updates/tmpl/index.html b/admin/src/View/Components_custom_admin_views/index.html similarity index 100% rename from admin/views/component_updates/tmpl/index.html rename to admin/src/View/Components_custom_admin_views/index.html diff --git a/admin/src/View/Components_dashboard/HtmlView.php b/admin/src/View/Components_dashboard/HtmlView.php new file mode 100644 index 000000000..48e3c78eb --- /dev/null +++ b/admin/src/View/Components_dashboard/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Components_dashboard; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Components_dashboard + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Components_dashboard view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_dashboard'); + $this->canEdit = $this->canDo->get('component_dashboard.edit'); + $this->canState = $this->canDo->get('component_dashboard.edit.state'); + $this->canCreate = $this->canDo->get('component_dashboard.create'); + $this->canDelete = $this->canDo->get('component_dashboard.delete'); + $this->canBatch = ($this->canDo->get('component_dashboard.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_COMPONENTS_DASHBOARD'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('component_dashboard.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('component_dashboard.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('components_dashboard.publish'); + ToolbarHelper::unpublishList('components_dashboard.unpublish'); + ToolbarHelper::archiveList('components_dashboard.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('components_dashboard.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'components_dashboard.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('components_dashboard.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('components_dashboard'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_COMPONENTS_DASHBOARD')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/componentbuilder/index.html b/admin/src/View/Components_dashboard/index.html similarity index 100% rename from admin/views/componentbuilder/index.html rename to admin/src/View/Components_dashboard/index.html diff --git a/admin/src/View/Components_files_folders/HtmlView.php b/admin/src/View/Components_files_folders/HtmlView.php new file mode 100644 index 000000000..0754dc6f5 --- /dev/null +++ b/admin/src/View/Components_files_folders/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Components_files_folders; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Components_files_folders + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Components_files_folders view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_files_folders'); + $this->canEdit = $this->canDo->get('component_files_folders.edit'); + $this->canState = $this->canDo->get('component_files_folders.edit.state'); + $this->canCreate = $this->canDo->get('component_files_folders.create'); + $this->canDelete = $this->canDo->get('component_files_folders.delete'); + $this->canBatch = ($this->canDo->get('component_files_folders.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_COMPONENTS_FILES_FOLDERS'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('component_files_folders.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('component_files_folders.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('components_files_folders.publish'); + ToolbarHelper::unpublishList('components_files_folders.unpublish'); + ToolbarHelper::archiveList('components_files_folders.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('components_files_folders.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'components_files_folders.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('components_files_folders.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('components_files_folders'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_COMPONENTS_FILES_FOLDERS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/componentbuilder/tmpl/index.html b/admin/src/View/Components_files_folders/index.html similarity index 100% rename from admin/views/componentbuilder/tmpl/index.html rename to admin/src/View/Components_files_folders/index.html diff --git a/admin/src/View/Components_modules/HtmlView.php b/admin/src/View/Components_modules/HtmlView.php new file mode 100644 index 000000000..513fd0ece --- /dev/null +++ b/admin/src/View/Components_modules/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Components_modules; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Components_modules + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Components_modules view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_modules'); + $this->canEdit = $this->canDo->get('component_modules.edit'); + $this->canState = $this->canDo->get('component_modules.edit.state'); + $this->canCreate = $this->canDo->get('component_modules.create'); + $this->canDelete = $this->canDo->get('component_modules.delete'); + $this->canBatch = ($this->canDo->get('component_modules.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_COMPONENTS_MODULES'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('component_modules.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('component_modules.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('components_modules.publish'); + ToolbarHelper::unpublishList('components_modules.unpublish'); + ToolbarHelper::archiveList('components_modules.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('components_modules.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'components_modules.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('components_modules.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('components_modules'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_COMPONENTS_MODULES')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/components_admin_views/index.html b/admin/src/View/Components_modules/index.html similarity index 100% rename from admin/views/components_admin_views/index.html rename to admin/src/View/Components_modules/index.html diff --git a/admin/src/View/Components_mysql_tweaks/HtmlView.php b/admin/src/View/Components_mysql_tweaks/HtmlView.php new file mode 100644 index 000000000..f46d56d93 --- /dev/null +++ b/admin/src/View/Components_mysql_tweaks/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Components_mysql_tweaks; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Components_mysql_tweaks + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Components_mysql_tweaks view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_mysql_tweaks'); + $this->canEdit = $this->canDo->get('component_mysql_tweaks.edit'); + $this->canState = $this->canDo->get('component_mysql_tweaks.edit.state'); + $this->canCreate = $this->canDo->get('component_mysql_tweaks.create'); + $this->canDelete = $this->canDo->get('component_mysql_tweaks.delete'); + $this->canBatch = ($this->canDo->get('component_mysql_tweaks.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_COMPONENTS_MYSQL_TWEAKS'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('component_mysql_tweaks.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('component_mysql_tweaks.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('components_mysql_tweaks.publish'); + ToolbarHelper::unpublishList('components_mysql_tweaks.unpublish'); + ToolbarHelper::archiveList('components_mysql_tweaks.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('components_mysql_tweaks.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'components_mysql_tweaks.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('components_mysql_tweaks.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('components_mysql_tweaks'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_COMPONENTS_MYSQL_TWEAKS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/components_admin_views/tmpl/index.html b/admin/src/View/Components_mysql_tweaks/index.html similarity index 100% rename from admin/views/components_admin_views/tmpl/index.html rename to admin/src/View/Components_mysql_tweaks/index.html diff --git a/admin/src/View/Components_placeholders/HtmlView.php b/admin/src/View/Components_placeholders/HtmlView.php new file mode 100644 index 000000000..c203408c2 --- /dev/null +++ b/admin/src/View/Components_placeholders/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Components_placeholders; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Components_placeholders + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Components_placeholders view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_placeholders'); + $this->canEdit = $this->canDo->get('component_placeholders.edit'); + $this->canState = $this->canDo->get('component_placeholders.edit.state'); + $this->canCreate = $this->canDo->get('component_placeholders.create'); + $this->canDelete = $this->canDo->get('component_placeholders.delete'); + $this->canBatch = ($this->canDo->get('component_placeholders.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_COMPONENTS_PLACEHOLDERS'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('component_placeholders.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('component_placeholders.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('components_placeholders.publish'); + ToolbarHelper::unpublishList('components_placeholders.unpublish'); + ToolbarHelper::archiveList('components_placeholders.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('components_placeholders.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'components_placeholders.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('components_placeholders.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('components_placeholders'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_COMPONENTS_PLACEHOLDERS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/components_config/index.html b/admin/src/View/Components_placeholders/index.html similarity index 100% rename from admin/views/components_config/index.html rename to admin/src/View/Components_placeholders/index.html diff --git a/admin/src/View/Components_plugins/HtmlView.php b/admin/src/View/Components_plugins/HtmlView.php new file mode 100644 index 000000000..f49a57e6a --- /dev/null +++ b/admin/src/View/Components_plugins/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Components_plugins; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Components_plugins + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Components_plugins view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_plugins'); + $this->canEdit = $this->canDo->get('component_plugins.edit'); + $this->canState = $this->canDo->get('component_plugins.edit.state'); + $this->canCreate = $this->canDo->get('component_plugins.create'); + $this->canDelete = $this->canDo->get('component_plugins.delete'); + $this->canBatch = ($this->canDo->get('component_plugins.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_COMPONENTS_PLUGINS'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('component_plugins.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('component_plugins.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('components_plugins.publish'); + ToolbarHelper::unpublishList('components_plugins.unpublish'); + ToolbarHelper::archiveList('components_plugins.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('components_plugins.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'components_plugins.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('components_plugins.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('components_plugins'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_COMPONENTS_PLUGINS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/components_config/tmpl/index.html b/admin/src/View/Components_plugins/index.html similarity index 100% rename from admin/views/components_config/tmpl/index.html rename to admin/src/View/Components_plugins/index.html diff --git a/admin/src/View/Components_routers/HtmlView.php b/admin/src/View/Components_routers/HtmlView.php new file mode 100644 index 000000000..ba03720bc --- /dev/null +++ b/admin/src/View/Components_routers/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Components_routers; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Components_routers + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Components_routers view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_router'); + $this->canEdit = $this->canDo->get('component_router.edit'); + $this->canState = $this->canDo->get('component_router.edit.state'); + $this->canCreate = $this->canDo->get('component_router.create'); + $this->canDelete = $this->canDo->get('component_router.delete'); + $this->canBatch = ($this->canDo->get('component_router.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_COMPONENTS_ROUTERS'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('component_router.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('component_router.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('components_routers.publish'); + ToolbarHelper::unpublishList('components_routers.unpublish'); + ToolbarHelper::archiveList('components_routers.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('components_routers.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'components_routers.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('components_routers.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('components_routers'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_COMPONENTS_ROUTERS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/components_custom_admin_menus/index.html b/admin/src/View/Components_routers/index.html similarity index 100% rename from admin/views/components_custom_admin_menus/index.html rename to admin/src/View/Components_routers/index.html diff --git a/admin/src/View/Components_site_views/HtmlView.php b/admin/src/View/Components_site_views/HtmlView.php new file mode 100644 index 000000000..2d0890f98 --- /dev/null +++ b/admin/src/View/Components_site_views/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Components_site_views; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Components_site_views + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Components_site_views view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_site_views'); + $this->canEdit = $this->canDo->get('component_site_views.edit'); + $this->canState = $this->canDo->get('component_site_views.edit.state'); + $this->canCreate = $this->canDo->get('component_site_views.create'); + $this->canDelete = $this->canDo->get('component_site_views.delete'); + $this->canBatch = ($this->canDo->get('component_site_views.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('component_site_views.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('component_site_views.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('components_site_views.publish'); + ToolbarHelper::unpublishList('components_site_views.unpublish'); + ToolbarHelper::archiveList('components_site_views.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('components_site_views.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'components_site_views.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('components_site_views.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('components_site_views'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/components_custom_admin_menus/tmpl/index.html b/admin/src/View/Components_site_views/index.html similarity index 100% rename from admin/views/components_custom_admin_menus/tmpl/index.html rename to admin/src/View/Components_site_views/index.html diff --git a/admin/src/View/Components_updates/HtmlView.php b/admin/src/View/Components_updates/HtmlView.php new file mode 100644 index 000000000..109f2daa1 --- /dev/null +++ b/admin/src/View/Components_updates/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Components_updates; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Components_updates + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Components_updates view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('component_updates'); + $this->canEdit = $this->canDo->get('component_updates.edit'); + $this->canState = $this->canDo->get('component_updates.edit.state'); + $this->canCreate = $this->canDo->get('component_updates.create'); + $this->canDelete = $this->canDo->get('component_updates.delete'); + $this->canBatch = ($this->canDo->get('component_updates.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_COMPONENTS_UPDATES'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('component_updates.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('component_updates.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('components_updates.publish'); + ToolbarHelper::unpublishList('components_updates.unpublish'); + ToolbarHelper::archiveList('components_updates.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('components_updates.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'components_updates.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('components_updates.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('components_updates'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_COMPONENTS_UPDATES')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/components_custom_admin_views/index.html b/admin/src/View/Components_updates/index.html similarity index 100% rename from admin/views/components_custom_admin_views/index.html rename to admin/src/View/Components_updates/index.html diff --git a/admin/src/View/Custom_admin_view/HtmlView.php b/admin/src/View/Custom_admin_view/HtmlView.php new file mode 100644 index 000000000..9dbb11522 --- /dev/null +++ b/admin/src/View/Custom_admin_view/HtmlView.php @@ -0,0 +1,248 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Custom_admin_view; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Custom_admin_view Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Custom_admin_view view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('custom_admin_view', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NEW' : 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('core.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('custom_admin_view.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('core.edit')) + { + // We can save the record. + ToolbarHelper::save('custom_admin_view.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('custom_admin_view.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('custom_admin_view.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('core.create')) + { + ToolbarHelper::apply('custom_admin_view.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('custom_admin_view.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('custom_admin_view.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('custom_admin_view.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('core.edit')) + { + // We can save the new record + ToolbarHelper::apply('custom_admin_view.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('custom_admin_view.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('core.create')) + { + ToolbarHelper::custom('custom_admin_view.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('custom_admin_view.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('core.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.custom_admin_view', $this->item->id); + } + if ($this->canDo->get('core.create')) + { + ToolbarHelper::custom('custom_admin_view.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('custom_admin_view.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('custom_admin_view'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NEW' : 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + } +} diff --git a/admin/views/components_custom_admin_views/tmpl/index.html b/admin/src/View/Custom_admin_view/index.html similarity index 100% rename from admin/views/components_custom_admin_views/tmpl/index.html rename to admin/src/View/Custom_admin_view/index.html diff --git a/admin/src/View/Custom_admin_views/HtmlView.php b/admin/src/View/Custom_admin_views/HtmlView.php new file mode 100644 index 000000000..260230d38 --- /dev/null +++ b/admin/src/View/Custom_admin_views/HtmlView.php @@ -0,0 +1,225 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Custom_admin_views; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Custom_admin_views + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Custom_admin_views view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('custom_admin_view'); + $this->canEdit = $this->canDo->get('core.edit'); + $this->canState = $this->canDo->get('core.edit.state'); + $this->canCreate = $this->canDo->get('core.create'); + $this->canDelete = $this->canDo->get('core.delete'); + $this->canBatch = ($this->canDo->get('custom_admin_view.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEWS'), 'screen'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('custom_admin_view.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('custom_admin_view.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('custom_admin_views.publish'); + ToolbarHelper::unpublishList('custom_admin_views.unpublish'); + ToolbarHelper::archiveList('custom_admin_views.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('custom_admin_views.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'custom_admin_views.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('custom_admin_views.trash'); + } + } + if ($this->user->authorise('custom_admin_view.get_snippets', 'com_componentbuilder')) + { + // add Get Snippets button. + ToolbarHelper::custom('custom_admin_views.getSnippets', 'search custom-button-getsnippets', '', 'COM_COMPONENTBUILDER_GET_SNIPPETS', false); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('custom_admin_views'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEWS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.system_name' => Text::_('COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_SYSTEM_NAME_LABEL'), + 'a.name' => Text::_('COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NAME_LABEL'), + 'a.description' => Text::_('COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_DESCRIPTION_LABEL'), + 'g.name' => Text::_('COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_MAIN_GET_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/components_dashboard/index.html b/admin/src/View/Custom_admin_views/index.html similarity index 100% rename from admin/views/components_dashboard/index.html rename to admin/src/View/Custom_admin_views/index.html diff --git a/admin/src/View/Custom_code/HtmlView.php b/admin/src/View/Custom_code/HtmlView.php new file mode 100644 index 000000000..1f6fd45e6 --- /dev/null +++ b/admin/src/View/Custom_code/HtmlView.php @@ -0,0 +1,251 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Custom_code; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Custom_code Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Custom_code view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('custom_code', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_CUSTOM_CODE_NEW' : 'COM_COMPONENTBUILDER_CUSTOM_CODE_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('custom_code.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('custom_code.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('custom_code.edit')) + { + // We can save the record. + ToolbarHelper::save('custom_code.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('custom_code.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('custom_code.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('custom_code.create')) + { + ToolbarHelper::apply('custom_code.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('custom_code.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('custom_code.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('custom_code.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('custom_code.edit')) + { + // We can save the new record + ToolbarHelper::apply('custom_code.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('custom_code.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('custom_code.create')) + { + ToolbarHelper::custom('custom_code.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('custom_code.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('custom_code.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.custom_code', $this->item->id); + } + if ($this->canDo->get('custom_code.create')) + { + ToolbarHelper::custom('custom_code.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('custom_code.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('custom_code'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_CUSTOM_CODE_NEW' : 'COM_COMPONENTBUILDER_CUSTOM_CODE_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + // need to add some language strings + Text::script('COM_COMPONENTBUILDER_FUNCTION_NAME_ALREADY_TAKEN_PLEASE_TRY_AGAIN'); + Text::script('COM_COMPONENTBUILDER_YOU_MUST_ADD_AN_UNIQUE_FUNCTION_NAME'); + } +} diff --git a/admin/views/components_dashboard/tmpl/index.html b/admin/src/View/Custom_code/index.html similarity index 100% rename from admin/views/components_dashboard/tmpl/index.html rename to admin/src/View/Custom_code/index.html diff --git a/admin/src/View/Custom_codes/HtmlView.php b/admin/src/View/Custom_codes/HtmlView.php new file mode 100644 index 000000000..d5dacdb39 --- /dev/null +++ b/admin/src/View/Custom_codes/HtmlView.php @@ -0,0 +1,227 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Custom_codes; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Custom_codes + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Custom_codes view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('custom_code'); + $this->canEdit = $this->canDo->get('custom_code.edit'); + $this->canState = $this->canDo->get('custom_code.edit.state'); + $this->canCreate = $this->canDo->get('custom_code.create'); + $this->canDelete = $this->canDo->get('custom_code.delete'); + $this->canBatch = ($this->canDo->get('custom_code.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_CUSTOM_CODES'), 'shuffle'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('custom_code.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('custom_code.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('custom_codes.publish'); + ToolbarHelper::unpublishList('custom_codes.unpublish'); + ToolbarHelper::archiveList('custom_codes.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('custom_codes.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'custom_codes.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('custom_codes.trash'); + } + } + if ($this->user->authorise('custom_code.run_expansion', 'com_componentbuilder')) + { + // add Run Expansion button. + ToolbarHelper::custom('custom_codes.runExpansion', 'expand-2 custom-button-runexpansion', '', 'COM_COMPONENTBUILDER_RUN_EXPANSION', false); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('custom_codes'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_CUSTOM_CODES')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'g.system_name' => Text::_('COM_COMPONENTBUILDER_CUSTOM_CODE_COMPONENT_LABEL'), + 'a.path' => Text::_('COM_COMPONENTBUILDER_CUSTOM_CODE_PATH_LABEL'), + 'a.target' => Text::_('COM_COMPONENTBUILDER_CUSTOM_CODE_TARGET_LABEL'), + 'a.type' => Text::_('COM_COMPONENTBUILDER_CUSTOM_CODE_TYPE_LABEL'), + 'a.comment_type' => Text::_('COM_COMPONENTBUILDER_CUSTOM_CODE_COMMENT_TYPE_LABEL'), + 'a.joomla_version' => Text::_('COM_COMPONENTBUILDER_CUSTOM_CODE_JOOMLA_VERSION_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/components_files_folders/index.html b/admin/src/View/Custom_codes/index.html similarity index 100% rename from admin/views/components_files_folders/index.html rename to admin/src/View/Custom_codes/index.html diff --git a/admin/src/View/Dynamic_get/HtmlView.php b/admin/src/View/Dynamic_get/HtmlView.php new file mode 100644 index 000000000..4aedef652 --- /dev/null +++ b/admin/src/View/Dynamic_get/HtmlView.php @@ -0,0 +1,248 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Dynamic_get; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Dynamic_get Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Dynamic_get view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('dynamic_get', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_DYNAMIC_GET_NEW' : 'COM_COMPONENTBUILDER_DYNAMIC_GET_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('dynamic_get.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('dynamic_get.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('dynamic_get.edit')) + { + // We can save the record. + ToolbarHelper::save('dynamic_get.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('dynamic_get.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('dynamic_get.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('dynamic_get.create')) + { + ToolbarHelper::apply('dynamic_get.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('dynamic_get.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('dynamic_get.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('dynamic_get.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('dynamic_get.edit')) + { + // We can save the new record + ToolbarHelper::apply('dynamic_get.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('dynamic_get.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('dynamic_get.create')) + { + ToolbarHelper::custom('dynamic_get.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('dynamic_get.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('dynamic_get.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.dynamic_get', $this->item->id); + } + if ($this->canDo->get('dynamic_get.create')) + { + ToolbarHelper::custom('dynamic_get.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('dynamic_get.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('dynamic_get'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_DYNAMIC_GET_NEW' : 'COM_COMPONENTBUILDER_DYNAMIC_GET_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + } +} diff --git a/admin/views/components_files_folders/tmpl/index.html b/admin/src/View/Dynamic_get/index.html similarity index 100% rename from admin/views/components_files_folders/tmpl/index.html rename to admin/src/View/Dynamic_get/index.html diff --git a/admin/src/View/Dynamic_gets/HtmlView.php b/admin/src/View/Dynamic_gets/HtmlView.php new file mode 100644 index 000000000..c37b43a4e --- /dev/null +++ b/admin/src/View/Dynamic_gets/HtmlView.php @@ -0,0 +1,224 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Dynamic_gets; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Dynamic_gets + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Dynamic_gets view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('dynamic_get'); + $this->canEdit = $this->canDo->get('dynamic_get.edit'); + $this->canState = $this->canDo->get('dynamic_get.edit.state'); + $this->canCreate = $this->canDo->get('dynamic_get.create'); + $this->canDelete = $this->canDo->get('dynamic_get.delete'); + $this->canBatch = ($this->canDo->get('dynamic_get.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_DYNAMIC_GETS'), 'database'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('dynamic_get.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('dynamic_get.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('dynamic_gets.publish'); + ToolbarHelper::unpublishList('dynamic_gets.unpublish'); + ToolbarHelper::archiveList('dynamic_gets.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('dynamic_gets.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'dynamic_gets.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('dynamic_gets.trash'); + } + } + if ($this->user->authorise('dynamic_get.run_expansion', 'com_componentbuilder')) + { + // add Run Expansion button. + ToolbarHelper::custom('dynamic_gets.runExpansion', 'expand-2 custom-button-runexpansion', '', 'COM_COMPONENTBUILDER_RUN_EXPANSION', false); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('dynamic_gets'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_DYNAMIC_GETS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.name' => Text::_('COM_COMPONENTBUILDER_DYNAMIC_GET_NAME_LABEL'), + 'a.main_source' => Text::_('COM_COMPONENTBUILDER_DYNAMIC_GET_MAIN_SOURCE_LABEL'), + 'a.gettype' => Text::_('COM_COMPONENTBUILDER_DYNAMIC_GET_GETTYPE_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/components_modules/index.html b/admin/src/View/Dynamic_gets/index.html similarity index 100% rename from admin/views/components_modules/index.html rename to admin/src/View/Dynamic_gets/index.html diff --git a/admin/src/View/Field/HtmlView.php b/admin/src/View/Field/HtmlView.php new file mode 100644 index 000000000..b10e1e392 --- /dev/null +++ b/admin/src/View/Field/HtmlView.php @@ -0,0 +1,257 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Field; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Field Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Field view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('field', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_FIELD_NEW' : 'COM_COMPONENTBUILDER_FIELD_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('field.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('field.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('field.edit')) + { + // We can save the record. + ToolbarHelper::save('field.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('field.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('field.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('field.create')) + { + ToolbarHelper::apply('field.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('field.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('field.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('field.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('field.edit')) + { + // We can save the new record + ToolbarHelper::apply('field.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('field.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('field.create')) + { + ToolbarHelper::custom('field.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('field.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('field.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.field', $this->item->id); + } + if ($this->canDo->get('field.create')) + { + ToolbarHelper::custom('field.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('field.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('field'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_FIELD_NEW' : 'COM_COMPONENTBUILDER_FIELD_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + // add the libs for subform (since not adding it via xml but ajax) + Html::_('jquery.ui', array('core', 'sortable')); + Html::_('script', 'system/subform-repeatable.js', array('version' => 'auto', 'relative' => true)); + // set some lang + Text::script('COM_COMPONENTBUILDER_PROPERTY_ALREADY_SELECTED_TRY_ANOTHER'); + Text::script('COM_COMPONENTBUILDER_TYPE_OR_SELECT_SOME_OPTIONS'); + Text::script('COM_COMPONENTBUILDER_NO_RESULTS_MATCH'); + Text::script('COM_COMPONENTBUILDER_SELECT_A_PROPERTY'); + Text::script('COM_COMPONENTBUILDER_NO_DESCRIPTION_FOUND'); + } +} diff --git a/admin/views/components_modules/tmpl/index.html b/admin/src/View/Field/index.html similarity index 100% rename from admin/views/components_modules/tmpl/index.html rename to admin/src/View/Field/index.html diff --git a/admin/src/View/Fields/HtmlView.php b/admin/src/View/Fields/HtmlView.php new file mode 100644 index 000000000..4e543f8bd --- /dev/null +++ b/admin/src/View/Fields/HtmlView.php @@ -0,0 +1,228 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Fields; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Fields + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Fields view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('field'); + $this->canEdit = $this->canDo->get('field.edit'); + $this->canState = $this->canDo->get('field.edit.state'); + $this->canCreate = $this->canDo->get('field.create'); + $this->canDelete = $this->canDo->get('field.delete'); + $this->canBatch = ($this->canDo->get('field.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_FIELDS'), 'lamp'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('field.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('field.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('fields.publish'); + ToolbarHelper::unpublishList('fields.unpublish'); + ToolbarHelper::archiveList('fields.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('fields.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'fields.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('fields.trash'); + } + } + if ($this->user->authorise('field.run_expansion', 'com_componentbuilder')) + { + // add Run Expansion button. + ToolbarHelper::custom('fields.runExpansion', 'expand-2 custom-button-runexpansion', '', 'COM_COMPONENTBUILDER_RUN_EXPANSION', false); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('fields'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_FIELDS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.name' => Text::_('COM_COMPONENTBUILDER_FIELD_NAME_LABEL'), + 'g.name' => Text::_('COM_COMPONENTBUILDER_FIELD_FIELDTYPE_LABEL'), + 'a.datatype' => Text::_('COM_COMPONENTBUILDER_FIELD_DATATYPE_LABEL'), + 'a.indexes' => Text::_('COM_COMPONENTBUILDER_FIELD_INDEXES_LABEL'), + 'a.null_switch' => Text::_('COM_COMPONENTBUILDER_FIELD_NULL_SWITCH_LABEL'), + 'a.store' => Text::_('COM_COMPONENTBUILDER_FIELD_STORE_LABEL'), + 'category_title' => Text::_('COM_COMPONENTBUILDER_FIELD_FIELDS_CATEGORIES'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/components_mysql_tweaks/index.html b/admin/src/View/Fields/index.html similarity index 100% rename from admin/views/components_mysql_tweaks/index.html rename to admin/src/View/Fields/index.html diff --git a/admin/src/View/Fieldtype/HtmlView.php b/admin/src/View/Fieldtype/HtmlView.php new file mode 100644 index 000000000..8e035ea6b --- /dev/null +++ b/admin/src/View/Fieldtype/HtmlView.php @@ -0,0 +1,299 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Fieldtype; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Fieldtype Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Fieldtype view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('fieldtype', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Get Linked view data + $this->vycfields = $this->get('Vycfields'); + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_FIELDTYPE_NEW' : 'COM_COMPONENTBUILDER_FIELDTYPE_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('fieldtype.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('fieldtype.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('fieldtype.edit')) + { + // We can save the record. + ToolbarHelper::save('fieldtype.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('fieldtype.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('fieldtype.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('fieldtype.create')) + { + ToolbarHelper::apply('fieldtype.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('fieldtype.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('fieldtype.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('fieldtype.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('fieldtype.edit')) + { + // We can save the new record + ToolbarHelper::apply('fieldtype.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('fieldtype.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('fieldtype.create')) + { + ToolbarHelper::custom('fieldtype.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('fieldtype.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('fieldtype.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.fieldtype', $this->item->id); + } + if ($this->canDo->get('fieldtype.create')) + { + ToolbarHelper::custom('fieldtype.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('fieldtype.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('fieldtype'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_FIELDTYPE_NEW' : 'COM_COMPONENTBUILDER_FIELDTYPE_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + + // Add the CSS for Footable + Html::_('stylesheet', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', ['version' => 'auto']); + Html::_('stylesheet', 'media/com_componentbuilder/footable-v3/css/footable.standalone.min.css', ['version' => 'auto']); + // Add the JavaScript for Footable (adding all functions) + Html::_('script', 'media/com_componentbuilder/footable-v3/js/footable.min.js', ['version' => 'auto']); + + $footable = "jQuery(document).ready(function() { jQuery(function () { jQuery('.footable').footable();});});"; + $this->getDocument()->addScriptDeclaration($footable); + + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + // get Uikit Version + $this->uikitVersion = $this->params->get('uikit_version', 2); + // Load uikit options. + $uikit = $this->params->get('uikit_load'); + $isAdmin = Factory::getApplication()->isClient('administrator'); + // Set script size. + $size = $this->params->get('uikit_min'); + // Use Uikit Version 2 + if (2 == $this->uikitVersion && ($isAdmin || $uikit != 2)) + { + // Set css style. + $style = $this->params->get('uikit_style'); + // only load if needed + if ($isAdmin || $uikit != 3) + { + // add the style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit' . $style . $size . '.css' , ['version' => 'auto']); + } + // add the style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/accordion' . $style . $size . '.css' , ['version' => 'auto']); + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/tooltip' . $style . $size . '.css' , ['version' => 'auto']); + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify' . $style . $size . '.css' , ['version' => 'auto']); + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/form-file' . $style . $size . '.css' , ['version' => 'auto']); + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/progress' . $style . $size . '.css' , ['version' => 'auto']); + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/placeholder' . $style . $size . '.css' , ['version' => 'auto']); + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2//css/components/upload' . $style . $size . '.css' , ['version' => 'auto']); + // only load if needed + if ($isAdmin || $uikit != 3) + { + // add JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit' . $size . '.js', ['version' => 'auto']); + } + // add JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/accordion' . $size . '.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/tooltip' . $size . '.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox' . $size . '.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify' . $size . '.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/upload' . $size . '.js', ['version' => 'auto']); + } + // Use Uikit Version 3 + elseif (3 == $this->uikitVersion && ($isAdmin || $uikit != 2)) + { + // add the style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v3/css/uikit'.$size.'.css', ['version' => 'auto']); + // add JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v3/js/uikit'.$size.'.js', ['version' => 'auto']); + // add icons + Html::_('script', 'media/com_componentbuilder/uikit-v3/js/uikit-icons'.$size.'.js', ['version' => 'auto']); + } + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + } +} diff --git a/admin/views/components_mysql_tweaks/tmpl/index.html b/admin/src/View/Fieldtype/index.html similarity index 100% rename from admin/views/components_mysql_tweaks/tmpl/index.html rename to admin/src/View/Fieldtype/index.html diff --git a/admin/src/View/Fieldtypes/HtmlView.php b/admin/src/View/Fieldtypes/HtmlView.php new file mode 100644 index 000000000..be6f3563b --- /dev/null +++ b/admin/src/View/Fieldtypes/HtmlView.php @@ -0,0 +1,219 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Fieldtypes; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Fieldtypes + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Fieldtypes view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('fieldtype'); + $this->canEdit = $this->canDo->get('fieldtype.edit'); + $this->canState = $this->canDo->get('fieldtype.edit.state'); + $this->canCreate = $this->canDo->get('fieldtype.create'); + $this->canDelete = $this->canDo->get('fieldtype.delete'); + $this->canBatch = ($this->canDo->get('fieldtype.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_FIELDTYPES'), 'power-cord'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('fieldtype.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('fieldtype.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('fieldtypes.publish'); + ToolbarHelper::unpublishList('fieldtypes.unpublish'); + ToolbarHelper::archiveList('fieldtypes.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('fieldtypes.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'fieldtypes.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('fieldtypes.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('fieldtypes'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_FIELDTYPES')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.name' => Text::_('COM_COMPONENTBUILDER_FIELDTYPE_NAME_LABEL'), + 'a.short_description' => Text::_('COM_COMPONENTBUILDER_FIELDTYPE_SHORT_DESCRIPTION_LABEL'), + 'category_title' => Text::_('COM_COMPONENTBUILDER_FIELDTYPE_FIELDTYPES_CATEGORIES'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/components_placeholders/index.html b/admin/src/View/Fieldtypes/index.html similarity index 100% rename from admin/views/components_placeholders/index.html rename to admin/src/View/Fieldtypes/index.html diff --git a/admin/src/View/Get_snippets/HtmlView.php b/admin/src/View/Get_snippets/HtmlView.php new file mode 100644 index 000000000..561ad1377 --- /dev/null +++ b/admin/src/View/Get_snippets/HtmlView.php @@ -0,0 +1,361 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Get_snippets; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\HeaderCheck; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Filesystem\File; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Get_snippets + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Display the view + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // get component params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // get the application + $this->app ??= Factory::getApplication(); + // get the user object + $this->user ??= $this->app->getIdentity(); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('get_snippets'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + // Initialise variables. + $this->items = $this->get('Items'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + // add the tool bar + $this->addToolBar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode(PHP_EOL, $errors), 500); + } + + parent::display($tpl); + + // Set the html view document stuff + $this->_prepareDocument(); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + + // Only load jQuery if needed. (default is true) + if ($this->params->get('add_jquery_framework', 1) == 1) + { + Html::_('jquery.framework'); + } + // Load the header checker class. + // Initialize the header checker. + $HeaderCheck = new HeaderCheck(); + + // Add View JavaScript File + Html::_('script', "administrator/components/com_componentbuilder/assets/js/get_snippets.js", ['version' => 'auto']); + + // Load uikit options. + $uikit = $this->params->get('uikit_load'); + // Set script size. + $size = $this->params->get('uikit_min'); + // Set css style. + $style = $this->params->get('uikit_style'); + + // The uikit css. + if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) + { + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit'.$style.$size.'.css', ['version' => 'auto']); + } + // The uikit js. + if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) + { + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit'.$size.'.js', ['version' => 'auto']); + } + + // Load the script to find all uikit components needed. + if ($uikit != 2) + { + // Set the default uikit components in this view. + $uikitComp = []; + $uikitComp[] = 'data-uk-grid'; + } + + // Load the needed uikit components in this view. + if ($uikit != 2 && isset($uikitComp) && ArrayHelper::check($uikitComp)) + { + // loading... + foreach ($uikitComp as $class) + { + foreach (ComponentbuilderHelper::$uk_components[$class] as $name) + { + // check if the CSS file exists. + if (File::exists(JPATH_ROOT.'/media/com_componentbuilder/uikit-v2/css/components/'.$name.$style.$size.'.css')) + { + // load the css. + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/'.$name.$style.$size.'.css', ['version' => 'auto']); + } + // check if the JavaScript file exists. + if (File::exists(JPATH_ROOT.'/media/com_componentbuilder/uikit-v2/js/components/'.$name.$size.'.js')) + { + // load the js. + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/'.$name.$size.'.js', ['version' => 'auto'], ['type' => 'text/javascript', 'async' => 'async']); + } + } + } + } + // load the local snippets + if (ArrayHelper::check($this->items)) + { + $local_snippets = array(); + foreach ($this->items as $item) + { + $path = StringHelper::safe($item->library . ' - (' . $item->type . ') ' . $item->name, 'filename', '', false). '.json'; + $local_snippets[$path] = $item; + } + } + + // Add the JavaScript for JStore + Html::_('script', 'media/com_componentbuilder/js/jquery.json.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/js/jstorage.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/js/strtotime.js', ['version' => 'auto']); + // check if we should use browser storage + $setBrowserStorage = $this->params->get('set_browser_storage', null); + if ($setBrowserStorage) + { + // check what (Time To Live) show we use + $storageTimeToLive = $this->params->get('storage_time_to_live', 'global'); + if ('global' == $storageTimeToLive) + { + // use the global session time + $session = Factory::getSession(); + // must have itin milliseconds + $expire = ($session->getExpire()*60)* 1000; + } + else + { + // use the Componentbuilder Global setting + if (0 != $storageTimeToLive) + { + // this will convert the time into milliseconds + $storageTimeToLive = $storageTimeToLive * 1000; + } + $expire = $storageTimeToLive; + } + } + else + { + // set to use no storage + $expire = 30000; // only 30 seconds + } + // Set the Time To Live To JavaScript + $this->document->addScriptDeclaration("var expire = ". (int) $expire.";"); + // set snippet path + $this->document->addScriptDeclaration("var snippetPath = '". ComponentbuilderHelper::$snippetPath ."';"); + $this->document->addScriptDeclaration("var snippetsPath = '". ComponentbuilderHelper::$snippetsPath ."';"); + // token + $this->document->addScriptDeclaration("var token = '". \JSession::getFormToken() ."';"); + // add some global items buckets for bulk updating + $this->document->addScriptDeclaration("var bulkItems = {};"); + $this->document->addScriptDeclaration("bulkItems.new = [];"); + $this->document->addScriptDeclaration("bulkItems.diverged = [];"); + $this->document->addScriptDeclaration("bulkItems.ahead = [];"); + $this->document->addScriptDeclaration("bulkItems.behind = [];"); + // set an error message if needed + $this->document->addScriptDeclaration("var returnError = '

    ".Text::_('COM_COMPONENTBUILDER_AN_ERROR_HAS_OCCURRED')."!

    ".Text::_('COM_COMPONENTBUILDER_PLEASE_TRY_AGAIN_LATER').".

    ';"); + // need to add some language strings + Text::script('COM_COMPONENTBUILDER_JCB_COMMUNITY_SNIPPETS'); + Text::script('COM_COMPONENTBUILDER_SNIPPETS'); + Text::script('COM_COMPONENTBUILDER_SNIPPET'); + Text::script('COM_COMPONENTBUILDER_VIEW_SNIPPET_OF_COMMUNITY_VERSION'); + Text::script('COM_COMPONENTBUILDER_GET_SNIPPET'); + Text::script('COM_COMPONENTBUILDER_LOCAL_SNIPPET'); + Text::script('COM_COMPONENTBUILDER_GET_THE_SNIPPET_FROM_GITHUB_AND_UPDATE_THE_LOCAL_VERSION'); + Text::script('COM_COMPONENTBUILDER_GET_THE_SNIPPET_FROM_GITHUB_AND_INSTALL_IT_LOCALLY'); + Text::script('COM_COMPONENTBUILDER_NO_NEED_TO_GET_IT_SINCE_IT_IS_ALREADY_IN_SYNC_WITH_YOUR_LOCAL_VERSION'); + Text::script('COM_COMPONENTBUILDER_USAGE'); + Text::script('COM_COMPONENTBUILDER_VIEW_USAGE_OF_COMMUNITY_VERSION'); + Text::script('COM_COMPONENTBUILDER_DESCRIPTION'); + Text::script('COM_COMPONENTBUILDER_VIEW_DESCRIPTION_OF_COMMUNITY_VERSION'); + Text::script('COM_COMPONENTBUILDER_VIEW_BLAME'); + Text::script('COM_COMPONENTBUILDER_VIEW_WHO_CONTRIBUTED_TO_THIS_SNIPPET'); + Text::script('COM_COMPONENTBUILDER_VIEW_SNIPPET_REFERENCE_URL'); + Text::script('COM_COMPONENTBUILDER_SNIPPET_COULD_NOT_BE_UPDATEDSAVED'); + Text::script('COM_COMPONENTBUILDER_SNIPPETS_COULD_NOT_BE_UPDATEDSAVED'); + Text::script('COM_COMPONENTBUILDER_LINK_TO_THE_CONTRIBUTOR'); + Text::script('COM_COMPONENTBUILDER_VIEW_THE_CONTRIBUTOR_DETAILS'); + Text::script('COM_COMPONENTBUILDER_JCB_COMMUNITY'); + Text::script('COM_COMPONENTBUILDER_COMPANY_NAME'); + Text::script('COM_COMPONENTBUILDER_AUTHOR_NAME'); + Text::script('COM_COMPONENTBUILDER_AUTHOR_EMAIL'); + Text::script('COM_COMPONENTBUILDER_AUTHOR_WEBSITE'); + Text::script('COM_COMPONENTBUILDER_THERE_ARE_NO_NEW_SNIPPETS_AT_THIS_TIME'); + Text::script('COM_COMPONENTBUILDER_THERE_ARE_NO_DIVERGED_SNIPPETS_AT_THIS_TIME'); + Text::script('COM_COMPONENTBUILDER_THERE_ARE_NO_AHEAD_SNIPPETS_AT_THIS_TIME'); + Text::script('COM_COMPONENTBUILDER_THERE_ARE_NO_OUT_OF_DATE_SNIPPETS_AT_THIS_TIME'); + Text::script('COM_COMPONENTBUILDER_THERE_ARE_NO_SNIPPETS_TO_UPDATE_AT_THIS_TIME'); + Text::script('COM_COMPONENTBUILDER_AVAILABLE_LIBRARIES'); + Text::script('COM_COMPONENTBUILDER_OPEN_LIBRARY_SNIPPETS'); + // add some lang verfy messages + $this->document->addScriptDeclaration(" + // set the snippet from gitHub + function getConfirmUpdate(status) { + switch(status) { + case 'new': + return '".Text::_('COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_ADD_THIS_NEW_JCB_COMMUNITY_SNIPPET_TO_YOUR_LOCAL_SNIPPETS')."'; + break; + case 'behind': + return '".Text::_('COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_UPDATE_YOUR_LOCAL_SNIPPET_WITH_THIS_NEWER_JCB_COMMUNITY_SNIPPET')."'; + break; + case 'ahead': + return '".Text::_('COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_UPDATE_YOUR_LOCAL_SNIPPET_WITH_THIS_OLDER_JCB_COMMUNITY_SNIPPET')."'; + break; + case 'diverged': + return '".Text::_('COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_REPLACE_YOUR_LOCAL_SNIPPET_WITH_THIS_JCB_COMMUNITY_SNIPPET')."'; + break; + default: + return '".Text::_('COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_CONTINUE')."'; + break; + } + } + "); + // load the local snippets + if (ArrayHelper::check($this->items)) + { + // Set the local snippets array + $this->document->addScriptDeclaration("var local_snippets = ". json_encode($local_snippets).";"); + } + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + // hide the main menu + $this->app->input->set('hidemainmenu', true); + // add title to the page + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_GET_SNIPPETS'),'search'); + // add cpanel button + ToolbarHelper::custom('get_snippets.dashboard', 'grid-2', '', 'COM_COMPONENTBUILDER_DASH', false); + if ($this->canDo->get('get_snippets.custom_admin_views')) + { + // add Custom Admin Views button. + ToolbarHelper::custom('get_snippets.openCustomAdminViews', 'screen custom-button-opencustomadminviews', '', 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEWS', false); + } + if ($this->canDo->get('get_snippets.site_views')) + { + // add Site Views button. + ToolbarHelper::custom('get_snippets.openSiteViews', 'palette custom-button-opensiteviews', '', 'COM_COMPONENTBUILDER_SITE_VIEWS', false); + } + if ($this->canDo->get('get_snippets.templates')) + { + // add Templates button. + ToolbarHelper::custom('get_snippets.openTemplates', 'brush custom-button-opentemplates', '', 'COM_COMPONENTBUILDER_TEMPLATES', false); + } + if ($this->canDo->get('get_snippets.layouts')) + { + // add Layouts button. + ToolbarHelper::custom('get_snippets.openLayouts', 'brush custom-button-openlayouts', '', 'COM_COMPONENTBUILDER_LAYOUTS', false); + } + if ($this->canDo->get('get_snippets.snippets')) + { + // add Snippets button. + ToolbarHelper::custom('get_snippets.openSnippets', 'pin custom-button-opensnippets', '', 'COM_COMPONENTBUILDER_SNIPPETS', false); + } + if ($this->canDo->get('get_snippets.libraries')) + { + // add Libraries button. + ToolbarHelper::custom('get_snippets.openLibraries', 'puzzle custom-button-openlibraries', '', 'COM_COMPONENTBUILDER_LIBRARIES', false); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('get_snippets'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = false, int $length = 40) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } +} diff --git a/admin/views/components_placeholders/tmpl/index.html b/admin/src/View/Get_snippets/index.html similarity index 100% rename from admin/views/components_placeholders/tmpl/index.html rename to admin/src/View/Get_snippets/index.html diff --git a/admin/src/View/Help_document/HtmlView.php b/admin/src/View/Help_document/HtmlView.php new file mode 100644 index 000000000..56a920f7e --- /dev/null +++ b/admin/src/View/Help_document/HtmlView.php @@ -0,0 +1,230 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Help_document; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Help_document Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Help_document view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('help_document', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_HELP_DOCUMENT_NEW' : 'COM_COMPONENTBUILDER_HELP_DOCUMENT_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('help_document.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('help_document.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('help_document.edit')) + { + // We can save the record. + ToolbarHelper::save('help_document.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('help_document.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('help_document.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('help_document.create')) + { + ToolbarHelper::apply('help_document.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('help_document.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('help_document.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('help_document.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('help_document.edit')) + { + // We can save the new record + ToolbarHelper::apply('help_document.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('help_document.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('help_document.create')) + { + ToolbarHelper::custom('help_document.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('help_document.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('help_document.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.help_document', $this->item->id); + } + if ($this->canDo->get('help_document.create')) + { + ToolbarHelper::custom('help_document.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('help_document.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('help_document'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_HELP_DOCUMENT_NEW' : 'COM_COMPONENTBUILDER_HELP_DOCUMENT_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } +} diff --git a/admin/views/components_plugins/index.html b/admin/src/View/Help_document/index.html similarity index 100% rename from admin/views/components_plugins/index.html rename to admin/src/View/Help_document/index.html diff --git a/admin/src/View/Help_documents/HtmlView.php b/admin/src/View/Help_documents/HtmlView.php new file mode 100644 index 000000000..dd0e95191 --- /dev/null +++ b/admin/src/View/Help_documents/HtmlView.php @@ -0,0 +1,221 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Help_documents; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Help_documents + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Help_documents view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('help_document'); + $this->canEdit = $this->canDo->get('help_document.edit'); + $this->canState = $this->canDo->get('help_document.edit.state'); + $this->canCreate = $this->canDo->get('help_document.create'); + $this->canDelete = $this->canDo->get('help_document.delete'); + $this->canBatch = ($this->canDo->get('help_document.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_HELP_DOCUMENTS'), 'support'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('help_document.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('help_document.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('help_documents.publish'); + ToolbarHelper::unpublishList('help_documents.unpublish'); + ToolbarHelper::archiveList('help_documents.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('help_documents.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'help_documents.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('help_documents.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('help_documents'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_HELP_DOCUMENTS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.title' => Text::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_TITLE_LABEL'), + 'a.type' => Text::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_TYPE_LABEL'), + 'a.location' => Text::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_LOCATION_LABEL'), + 'h.' => Text::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_ADMIN_VIEW_LABEL'), + 'i.' => Text::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_SITE_VIEW_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/components_plugins/tmpl/index.html b/admin/src/View/Help_documents/index.html similarity index 100% rename from admin/views/components_plugins/tmpl/index.html rename to admin/src/View/Help_documents/index.html diff --git a/admin/src/View/Import/HtmlView.php b/admin/src/View/Import/HtmlView.php new file mode 100644 index 000000000..4bf0a3d26 --- /dev/null +++ b/admin/src/View/Import/HtmlView.php @@ -0,0 +1,106 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Import; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Toolbar\ToolbarHelper; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Import Html View + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + protected $headerList; + protected $hasPackage = false; + protected $headers; + protected $hasHeader = 0; + protected $dataType; + + /** + * Display the view + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + $paths = new \StdClass; + $paths->first = ''; + $state = $this->get('state'); + + $this->paths = &$paths; + $this->state = &$state; + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('import'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // get the session object + $session = Factory::getSession(); + // check if it has package + $this->hasPackage = $session->get('hasPackage', false); + $this->dataType = $session->get('dataType', false); + if($this->hasPackage && $this->dataType) + { + $this->headerList = json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS', false),true); + $this->headers = ComponentbuilderHelper::getFileHeaders($this->dataType); + // clear the data type + $session->clear('dataType'); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_IMPORT_TITLE'), 'upload'); + + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('import'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } +} diff --git a/admin/views/components_site_views/index.html b/admin/src/View/Import/index.html similarity index 100% rename from admin/views/components_site_views/index.html rename to admin/src/View/Import/index.html diff --git a/admin/src/View/Import_joomla_componentsimport/HtmlView.php b/admin/src/View/Import_joomla_componentsimport/HtmlView.php new file mode 100644 index 000000000..15d590948 --- /dev/null +++ b/admin/src/View/Import_joomla_componentsimport/HtmlView.php @@ -0,0 +1,475 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Import_joomla_componentsImport; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\FormHelper as UtilitiesFormHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Import_joomla_components Html View + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + protected $headerList; + protected $hasPackage = false; + protected $headers; + protected $hasHeader = 0; + protected $dataType; + protected $packageInfo; + protected $formPackage; + protected $vdmPackages = false; + protected $directories = array(); + + public function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + ComponentbuilderHelper::addSubmenu('import'); + } + // get component params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + + $paths = new \stdClass; + $paths->first = ''; + $state = $this->get('state'); + + $this->paths = &$paths; + $this->state = &$state; + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('import'); + // load the application + $this->app = Factory::getApplication(); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + // add title to the page + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_JCB_PACKAGE_IMPORT'), 'upload'); + // add refesh button. + ToolbarHelper::custom('joomla_component.refresh', 'refresh', '', 'COM_COMPONENTBUILDER_REFRESH', false); + } + // get the session object + $session = Factory::getSession(); + // check if it has package + $this->hasPackage = $session->get('hasPackage', false); + $this->dataType = $session->get('dataType', false); + if (!$this->dataType) + { + $this->dataType = $session->get('dataType_VDM_IMPORTINTO', null); + } + + // get the management input from global settings + $manageDirectories = $this->params->get('manage_jcb_package_directories', 2); + if ($manageDirectories == 2) + { + $this->directories = array('vdm', 'jcb'); + } + elseif ($manageDirectories == 1) + { + $this->directories = (array) $this->params->get('jcb_package_directories'); + } + + // set form only if smart package + if ($this->dataType === 'smart_package') + { + $this->packageInfo = json_decode($session->get('smart_package_info', false), true); + + // add the form class + jimport('joomla.form.form'); + + // load the forms + $this->formPackage = $this->_getForm($this->dataType); + $this->vdmPackages = $this->_getForm('vdm_package'); + $this->jcbPackages = $this->_getForm('jcb_package'); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // set the document + $this->setDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Prepares the document + */ + protected function setDocument() + { + // always make sure jquery is loaded. + Html::_('jquery.framework'); + + // Add the JavaScript for JStore + Html::_('script', 'media/com_componentbuilder/js/jquery.json.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/js/jstorage.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/js/strtotime.js', ['version' => 'auto']); + // add marked library + Html::_('script', "media/com_componentbuilder/js/marked.js", ['version' => 'auto']); + // check if we should use browser storage + $setBrowserStorage = $this->params->get('set_browser_storage', null); + if ($setBrowserStorage) + { + // check what (Time To Live) show we use + $storageTimeToLive = $this->params->get('storage_time_to_live', 'global'); + if ('global' == $storageTimeToLive) + { + // use the global session time + $session = Factory::getSession(); + // must have itin milliseconds + $expire = ($session->getExpire()*60)* 1000; + } + else + { + // use the Componentbuilder Global setting + if (0 != $storageTimeToLive) + { + // this will convert the time into milliseconds + $storageTimeToLive = $storageTimeToLive * 1000; + } + $expire = $storageTimeToLive; + } + } + else + { + // set to use no storage + $expire = 30000; // only 30 seconds + } + + // Set the Time To Live To JavaScript + $this->document->addScriptDeclaration("var expire = ". (int) $expire.";"); + $this->document->addScriptDeclaration("var all_is_good = '".Text::_('COM_COMPONENTBUILDER_ALL_IS_GOOD_THERE_IS_NO_NOTICE_AT_THIS_TIME')."';"); + // add a token on the page for javascript + $this->document->addScriptDeclaration("var token = '".\JSession::getFormToken()."';"); + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + } + + public function _getForm($type) + { + $form = array(); + if ('smart_package' === $type) + { + // get the force_update radio field + $force_update = FormHelper::loadFieldType('radio',true); + // start force_update xl + $force_updateXML = new \SimpleXMLElement(''); + // force_update attributes + $force_updateAttributes = array( + 'type' => 'radio', + 'name' => 'force_update', + 'label' => 'COM_COMPONENTBUILDER_FORCE_LOCAL_UPDATE', + 'class' => 'btn-group btn-group-yesno', + 'description' => 'COM_COMPONENTBUILDER_SHOULD_WE_FORCE_THE_UPDATE_OF_ALL_LOCAL_DATA_EVEN_IF_IT_IS_NEWER_THEN_THE_DATA_BEING_IMPORTED', + 'default' => '0'); + // load the force_update attributes + UtilitiesFormHelper::attributes($force_updateXML, $force_updateAttributes); + // set the force_update options + $force_updateOptions = array( + '1' => 'COM_COMPONENTBUILDER_YES', + '0' => 'COM_COMPONENTBUILDER_NO'); + // load the force_update options + UtilitiesFormHelper::options($force_updateXML, $force_updateOptions); + // setup the force_update radio field + $force_update->setup($force_updateXML,0); + // add to form + $form[] = $force_update; + + // get the more_info radio field + $more_info = FormHelper::loadFieldType('radio',true); + // start more_info xml + $more_infoXML = new \SimpleXMLElement(''); + // more_info attributes + $more_infoAttributes = array( + 'type' => 'radio', + 'name' => 'more_info', + 'label' => 'COM_COMPONENTBUILDER_SEE_ALL_IMPORT_INFO', + 'class' => 'btn-group btn-group-yesno', + 'description' => 'COM_COMPONENTBUILDER_SHOULD_WE_BE_SHOWING_MORE_ELABORATE_INFORMATION_DURING_IMPORT', + 'default' => '0'); + // load the more_info attributes + UtilitiesFormHelper::attributes($more_infoXML, $more_infoAttributes); + // set the more_info options + $more_infoOptions = array( + '1' => 'COM_COMPONENTBUILDER_YES', + '0' => 'COM_COMPONENTBUILDER_NO'); + // load the more_info options + UtilitiesFormHelper::options($more_infoXML, $more_infoOptions); + // setup the more_info radio field + $more_info->setup($more_infoXML,0); + // add to form + $form[] = $more_info; + + // get the merge radio field + $merge = FormHelper::loadFieldType('radio',true); + // start merge xml + $mergeXML = new \SimpleXMLElement(''); + // merge attributes + $mergeAttributes = array( + 'type' => 'radio', + 'name' => 'canmerge', + 'label' => 'COM_COMPONENTBUILDER_MERGE', + 'class' => 'btn-group btn-group-yesno', + 'description' => 'COM_COMPONENTBUILDER_SHOULD_WE_MERGE_THE_COMPONENTS_WITH_SIMILAR_LOCAL_COMPONENTS_MERGING_THE_COMPONENTS_USE_TO_BE_THE_DEFAULT_BEHAVIOUR_BUT_NOW_YOU_CAN_IMPORT_THE_COMPONENTS_AND_FORCE_IT_NOT_TO_MERGE_THE_FOLLOWING_AREAS_VALIDATION_RULE_FIELDTYPE_SNIPPET_LANGUAGE_LANGUAGE_TRANSLATION_JOOMLA_PLUGIN_GROUP_CLASS_EXTENDS_CLASS_PROPERTY_CLASS_METHOD_BMUST_AND_WILL_STILLB_MERGE_EVEN_OF_YOUR_SELECTION_IS_BNOB_BECAUSE_OF_THE_SINGULAR_NATURE_OF_THOSE_AREAS', + 'default' => '1'); + // load the merge attributes + UtilitiesFormHelper::attributes($mergeXML, $mergeAttributes); + // set the merge options + $mergeOptions = array( + '1' => 'COM_COMPONENTBUILDER_YES', + '0' => 'COM_COMPONENTBUILDER_NO'); + // load the merge options + UtilitiesFormHelper::options($mergeXML, $mergeOptions); + // setup the merge radio field + $merge->setup($mergeXML,1); + // add to form + $form[] = $merge; + + // get the import_guid_only radio field + $import_guid_only = FormHelper::loadFieldType('radio',true); + // start import_guid_only xml + $import_guid_onlyXML = new \SimpleXMLElement(''); + // import_guid_only attributes + $import_guid_onlyAttributes = array( + 'type' => 'radio', + 'name' => 'import_guid_only', + 'label' => 'COM_COMPONENTBUILDER_IMPORT_BY_GUID_ONLY', + 'class' => 'btn-group btn-group-yesno', + 'description' => 'COM_COMPONENTBUILDER_FORCE_THAT_THIS_JCB_PACKAGE_IMPORT_SEARCH_FOR_LOCAL_ITEMS_TO_BE_DONE_WITH_GUID_VALUE_ONLY_IF_BMERGEB_IS_SET_TO_YES_ABOVE', + 'default' => '1'); + // load the import_guid_only attributes + UtilitiesFormHelper::attributes($import_guid_onlyXML, $import_guid_onlyAttributes); + // set the import_guid_only options + $import_guid_onlyOptions = array( + '1' => 'COM_COMPONENTBUILDER_YES', + '0' => 'COM_COMPONENTBUILDER_NO'); + // load the import_guid_only options + UtilitiesFormHelper::options($import_guid_onlyXML, $import_guid_onlyOptions); + // setup the import_guid_only radio field + $import_guid_only->setup($import_guid_onlyXML, $this->params->get('import_guid_only', 0)); + // add to form + $form[] = $import_guid_only; + + if (!$this->packageInfo || ComponentbuilderHelper::getPackageComponentsKeyStatus($this->packageInfo)) + { + // set required field + $required = true; + // does the packages has info + if (!$this->packageInfo) + { + // get the haskey radio field + $haskey = FormHelper::loadFieldType('radio',true); + // start haskey xml + $haskeyXML = new \SimpleXMLElement(''); + // haskey attributes + $haskeyAttributes = array( + 'type' => 'radio', + 'name' => 'haskey', + 'label' => 'COM_COMPONENTBUILDER_USE_KEY', + 'class' => 'btn-group btn-group-yesno', + 'description' => 'COM_COMPONENTBUILDER_DOES_THIS_PACKAGE_REQUIRE_A_KEY_TO_INSTALL', + 'default' => '1', + 'filter' => 'INT'); + // load the haskey attributes + UtilitiesFormHelper::attributes($haskeyXML, $haskeyAttributes); + // set the haskey options + $haskeyOptions = array( + '1' => 'COM_COMPONENTBUILDER_YES', + '0' => 'COM_COMPONENTBUILDER_NO'); + // load the haskey options + UtilitiesFormHelper::options($haskeyXML, $haskeyOptions); + // setup the haskey radio field + $haskey->setup($haskeyXML,1); + // add to form + $form[] = $haskey; + + // now make required false + $required = false; + } + + // get the sleutle password field + $sleutle = FormHelper::loadFieldType('password',true); + // start sleutle xml + $sleutleXML = new \SimpleXMLElement(''); + // sleutle attributes + $sleutleAttributes = array( + 'type' => 'password', + 'name' => 'sleutle', + 'label' => 'COM_COMPONENTBUILDER_KEY', + 'class' => 'text_area', + 'description' => 'COM_COMPONENTBUILDER_THE_KEY_OF_THIS_PACKAGE', + 'autocomplete' => 'false', + 'filter' => 'STRING', + 'hint' => 'COM_COMPONENTBUILDER_ADD_KEY_HERE'); + // should this be required + if ($required) + { + $sleutleAttributes['required'] = 'true'; + } + // load the sleutle attributes + UtilitiesFormHelper::attributes($sleutleXML, $sleutleAttributes); + // setup the sleutle password field + $sleutle->setup($sleutleXML,''); + // add to form + $form[] = $sleutle; + } + } + elseif ('vdm_package' === $type && in_array('vdm', $this->directories) && $vdmListObjects = ComponentbuilderHelper::getGithubRepoFileList('vdmGithubPackages', ComponentbuilderHelper::$vdmGithubPackagesUrl)) + { + if (ArrayHelper::check($vdmListObjects)) + { + // get the vdm_package list field + $vdm_package = FormHelper::loadFieldType('list',true); + // start vdm_package xml + $vdm_packageXML = new \SimpleXMLElement(''); + // vdm_package attributes + $vdm_packageAttributes = array( + 'type' => 'list', + 'name' => 'vdm_package', + 'label' => 'COM_COMPONENTBUILDER_PACKAGE', + 'class' => 'list_class', + 'description' => 'COM_COMPONENTBUILDER_SELECT_THE_PACKAGE_TO_IMPORT', + 'onchange' => "getJCBpackageInfo('vdm')"); + // load the list + $load = false; + // load the vdm_package attributes + UtilitiesFormHelper::attributes($vdm_packageXML, $vdm_packageAttributes); + // start the vdm_package options + $vdm_packageOptions = array(); + $vdm_packageOptions[''] = 'COM_COMPONENTBUILDER__SELECT_PACKAGE_'; + // load vdm_package options from array + foreach($vdmListObjects as $vdmListObject) + { + if (strpos($vdmListObject->path, '.zip') !== false) + { + $vdm_packageOptions[base64_encode(ComponentbuilderHelper::$vdmGithubPackageUrl.$vdmListObject->path)] = $this->setPackageName($vdmListObject->path); + $load = true; + } + } + // only load if at least one item was found + if ($load) + { + // load the vdm_package options + UtilitiesFormHelper::options($vdm_packageXML, $vdm_packageOptions); + // setup the vdm_package radio field + $vdm_package->setup($vdm_packageXML,''); + // add to form + $form[] = $vdm_package; + } + } + } + elseif ('jcb_package' === $type && in_array('jcb', $this->directories) && $jcbListObjects = ComponentbuilderHelper::getGithubRepoFileList('communityGithubPackages', ComponentbuilderHelper::$jcbGithubPackagesUrl)) + { + if (ArrayHelper::check($jcbListObjects)) + { + // get the jcb_package list field + $jcb_package = FormHelper::loadFieldType('list',true); + // start jcb_package xml + $jcb_packageXML = new \SimpleXMLElement(''); + // jcb_package attributes + $jcb_packageAttributes = array( + 'type' => 'list', + 'name' => 'jcb_package', + 'label' => 'COM_COMPONENTBUILDER_PACKAGE', + 'class' => 'list_class', + 'description' => 'COM_COMPONENTBUILDER_SELECT_THE_PACKAGE_TO_IMPORT', + 'onchange' => "getJCBpackageInfo('jcb')"); + // load the list + $load = false; + // load the jcb_package attributes + UtilitiesFormHelper::attributes($jcb_packageXML, $jcb_packageAttributes); + // start the jcb_package options + $jcb_packageOptions = array(); + $jcb_packageOptions[''] = 'COM_COMPONENTBUILDER__SELECT_PACKAGE_'; + // load jcb_package options from array + foreach($jcbListObjects as $jcbListObject) + { + if (strpos($jcbListObject->path, '.zip') !== false) + { + $jcb_packageOptions[base64_encode(ComponentbuilderHelper::$jcbGithubPackageUrl.$jcbListObject->path)] = $this->setPackageName($jcbListObject->path); + $load = true; + } + } + // only load if at least one item was found + if ($load) + { + // load the jcb_package options + UtilitiesFormHelper::options($jcb_packageXML, $jcb_packageOptions); + // setup the jcb_package radio field + $jcb_package->setup($jcb_packageXML,''); + // add to form + $form[] = $jcb_package; + } + } + } + return $form; + } + + public function setPackageName($name) + { + // return the name + return StringHelper::safe( preg_replace('/(?canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('import_joomla_components'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } +} diff --git a/admin/views/components_site_views/tmpl/index.html b/admin/src/View/Import_joomla_componentsimport/index.html similarity index 100% rename from admin/views/components_site_views/tmpl/index.html rename to admin/src/View/Import_joomla_componentsimport/index.html diff --git a/admin/src/View/Import_language_translationsimport/HtmlView.php b/admin/src/View/Import_language_translationsimport/HtmlView.php new file mode 100644 index 000000000..632a4004e --- /dev/null +++ b/admin/src/View/Import_language_translationsimport/HtmlView.php @@ -0,0 +1,107 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Import_language_translationsImport; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Import_language_translations Html View + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + protected $headerList; + protected $hasPackage = false; + protected $headers; + protected $hasHeader = 0; + protected $dataType; + + public function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + ComponentbuilderHelper::addSubmenu('import'); + } + + $paths = new \stdClass; + $paths->first = ''; + $state = $this->get('state'); + + $this->paths = &$paths; + $this->state = &$state; + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('import'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + } + + // get the session object + $session = Factory::getSession(); + // check if it has package + $this->hasPackage = $session->get('hasPackage', false); + $this->dataType = $session->get('dataType', false); + if($this->hasPackage && $this->dataType) + { + $this->headerList = json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS', false),true); + $this->headers = ComponentbuilderHelper::getFileHeaders($this->dataType); + // clear the data type + $session->clear('dataType'); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))){ + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_IMPORT_TITLE'), 'upload'); + + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('import_language_translations'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } +} diff --git a/admin/views/components_updates/index.html b/admin/src/View/Import_language_translationsimport/index.html similarity index 100% rename from admin/views/components_updates/index.html rename to admin/src/View/Import_language_translationsimport/index.html diff --git a/admin/src/View/Joomla_component/HtmlView.php b/admin/src/View/Joomla_component/HtmlView.php new file mode 100644 index 000000000..b281adcba --- /dev/null +++ b/admin/src/View/Joomla_component/HtmlView.php @@ -0,0 +1,248 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Joomla_component; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_component Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Joomla_component view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('joomla_component', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('joomla_component.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('joomla_component.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('joomla_component.edit')) + { + // We can save the record. + ToolbarHelper::save('joomla_component.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('joomla_component.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('joomla_component.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('joomla_component.create')) + { + ToolbarHelper::apply('joomla_component.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('joomla_component.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('joomla_component.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('joomla_component.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('joomla_component.edit')) + { + // We can save the new record + ToolbarHelper::apply('joomla_component.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('joomla_component.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('joomla_component.create')) + { + ToolbarHelper::custom('joomla_component.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('joomla_component.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('joomla_component.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.joomla_component', $this->item->id); + } + if ($this->canDo->get('joomla_component.create')) + { + ToolbarHelper::custom('joomla_component.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('joomla_component.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_component'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + // add var key + $this->getDocument()->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->getDocument()->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + } +} diff --git a/admin/views/components_updates/tmpl/index.html b/admin/src/View/Joomla_component/index.html similarity index 100% rename from admin/views/components_updates/tmpl/index.html rename to admin/src/View/Joomla_component/index.html diff --git a/admin/src/View/Joomla_components/HtmlView.php b/admin/src/View/Joomla_components/HtmlView.php new file mode 100644 index 000000000..3c8a4aedd --- /dev/null +++ b/admin/src/View/Joomla_components/HtmlView.php @@ -0,0 +1,252 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Joomla_components; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Joomla_components + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Joomla_components view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('joomla_component'); + $this->canEdit = $this->canDo->get('joomla_component.edit'); + $this->canState = $this->canDo->get('joomla_component.edit.state'); + $this->canCreate = $this->canDo->get('joomla_component.create'); + $this->canDelete = $this->canDo->get('joomla_component.delete'); + $this->canBatch = ($this->canDo->get('joomla_component.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENTS'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('joomla_component.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('joomla_component.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('joomla_components.publish'); + ToolbarHelper::unpublishList('joomla_components.unpublish'); + ToolbarHelper::archiveList('joomla_components.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('joomla_components.checkin'); + } + } + if ($this->user->authorise('joomla_component.clone', 'com_componentbuilder')) + { + // add Clone button. + ToolbarHelper::custom('joomla_components.cloner', 'save-copy custom-button-cloner', '', 'COM_COMPONENTBUILDER_CLONE', 'true'); + } + if ($this->user->authorise('joomla_component.export_jcb_packages', 'com_componentbuilder')) + { + // add Export JCB Packages button. + ToolbarHelper::custom('joomla_components.smartExport', 'download custom-button-smartexport', '', 'COM_COMPONENTBUILDER_EXPORT_JCB_PACKAGES', 'true'); + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'joomla_components.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('joomla_components.trash'); + } + } + if ($this->user->authorise('joomla_component.import_jcb_packages', 'com_componentbuilder')) + { + // add Import JCB Packages button. + ToolbarHelper::custom('joomla_components.smartImport', 'upload custom-button-smartimport', '', 'COM_COMPONENTBUILDER_IMPORT_JCB_PACKAGES', false); + } + if ($this->user->authorise('joomla_component.run_expansion', 'com_componentbuilder')) + { + // add Run Expansion button. + ToolbarHelper::custom('joomla_components.runExpansion', 'expand-2 custom-button-runexpansion', '', 'COM_COMPONENTBUILDER_RUN_EXPANSION', false); + } + if ($this->user->authorise('joomla_component.backup', 'com_componentbuilder')) + { + // add Backup button. + ToolbarHelper::custom('joomla_components.backup', 'archive custom-button-backup', '', 'COM_COMPONENTBUILDER_BACKUP', false); + } + if ($this->user->authorise('joomla_component.clear_tmp', 'com_componentbuilder')) + { + // add Clear tmp button. + ToolbarHelper::custom('joomla_components.clearTmp', 'purge custom-button-cleartmp', '', 'COM_COMPONENTBUILDER_CLEAR_TMP', false); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_components'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENTS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.system_name' => Text::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_SYSTEM_NAME_LABEL'), + 'a.name_code' => Text::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NAME_CODE_LABEL'), + 'a.short_description' => Text::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_SHORT_DESCRIPTION_LABEL'), + 'a.companyname' => Text::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_COMPANYNAME_LABEL'), + 'a.created' => Text::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CREATED_LABEL'), + 'a.modified' => Text::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_MODIFIED_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/custom_admin_view/tmpl/index.html b/admin/src/View/Joomla_components/index.html similarity index 100% rename from admin/views/custom_admin_view/tmpl/index.html rename to admin/src/View/Joomla_components/index.html diff --git a/admin/src/View/Joomla_module/HtmlView.php b/admin/src/View/Joomla_module/HtmlView.php new file mode 100644 index 000000000..791b1d494 --- /dev/null +++ b/admin/src/View/Joomla_module/HtmlView.php @@ -0,0 +1,283 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Joomla_module; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_module Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Joomla_module view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('joomla_module', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_MODULE_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_MODULE_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('joomla_module.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('joomla_module.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('joomla_module.edit')) + { + // We can save the record. + ToolbarHelper::save('joomla_module.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('joomla_module.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('joomla_module.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('joomla_module.create')) + { + ToolbarHelper::apply('joomla_module.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('joomla_module.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('joomla_module.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('joomla_module.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('joomla_module.edit')) + { + // We can save the new record + ToolbarHelper::apply('joomla_module.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('joomla_module.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('joomla_module.create')) + { + ToolbarHelper::custom('joomla_module.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('joomla_module.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('joomla_module.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.joomla_module', $this->item->id); + } + if ($this->canDo->get('joomla_module.create')) + { + ToolbarHelper::custom('joomla_module.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('joomla_module.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_module'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_MODULE_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_MODULE_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + // Add the JavaScript for JStore + Html::_('script', 'media/com_componentbuilder/js/jquery.json.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/js/jstorage.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/js/strtotime.js', ['version' => 'auto']); + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + // check if we should use browser storage + $setBrowserStorage = $this->params->get('set_browser_storage', null); + if ($setBrowserStorage) + { + // check what (Time To Live) show we use + $storageTimeToLive = $this->params->get('storage_time_to_live', 'global'); + if ('global' == $storageTimeToLive) + { + // use the global session time + $session = Factory::getSession(); + // must have itin milliseconds + $expire = ($session->getExpire()*60)* 1000; + } + else + { + // use the Componentbuilder Global setting + if (0 != $storageTimeToLive) + { + // this will convert the time into milliseconds + $storageTimeToLive = $storageTimeToLive * 1000; + } + $expire = $storageTimeToLive; + } + } + else + { + // set to use no storage + $expire = 30000; // only 30 seconds + } + // Set the Time To Live To JavaScript + $this->document->addScriptDeclaration("var expire = ". (int) $expire.";"); + } +} diff --git a/admin/views/custom_admin_views/index.html b/admin/src/View/Joomla_module/index.html similarity index 100% rename from admin/views/custom_admin_views/index.html rename to admin/src/View/Joomla_module/index.html diff --git a/admin/src/View/Joomla_module_files_folders_urls/HtmlView.php b/admin/src/View/Joomla_module_files_folders_urls/HtmlView.php new file mode 100644 index 000000000..58a092bc8 --- /dev/null +++ b/admin/src/View/Joomla_module_files_folders_urls/HtmlView.php @@ -0,0 +1,230 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Joomla_module_files_folders_urls; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_module_files_folders_urls Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Joomla_module_files_folders_urls view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('joomla_module_files_folders_urls', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('joomla_module_files_folders_urls.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('joomla_module_files_folders_urls.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('joomla_module_files_folders_urls.edit')) + { + // We can save the record. + ToolbarHelper::save('joomla_module_files_folders_urls.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('joomla_module_files_folders_urls.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('joomla_module_files_folders_urls.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('joomla_module_files_folders_urls.create')) + { + ToolbarHelper::apply('joomla_module_files_folders_urls.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('joomla_module_files_folders_urls.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('joomla_module_files_folders_urls.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('joomla_module_files_folders_urls.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('joomla_module_files_folders_urls.edit')) + { + // We can save the new record + ToolbarHelper::apply('joomla_module_files_folders_urls.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('joomla_module_files_folders_urls.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('joomla_module_files_folders_urls.create')) + { + ToolbarHelper::custom('joomla_module_files_folders_urls.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('joomla_module_files_folders_urls.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('joomla_module_files_folders_urls.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.joomla_module_files_folders_urls', $this->item->id); + } + if ($this->canDo->get('joomla_module_files_folders_urls.create')) + { + ToolbarHelper::custom('joomla_module_files_folders_urls.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('joomla_module_files_folders_urls.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_module_files_folders_urls'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } +} diff --git a/admin/views/custom_admin_views/tmpl/index.html b/admin/src/View/Joomla_module_files_folders_urls/index.html similarity index 100% rename from admin/views/custom_admin_views/tmpl/index.html rename to admin/src/View/Joomla_module_files_folders_urls/index.html diff --git a/admin/src/View/Joomla_module_updates/HtmlView.php b/admin/src/View/Joomla_module_updates/HtmlView.php new file mode 100644 index 000000000..227a4ab12 --- /dev/null +++ b/admin/src/View/Joomla_module_updates/HtmlView.php @@ -0,0 +1,230 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Joomla_module_updates; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_module_updates Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Joomla_module_updates view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('joomla_module_updates', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('joomla_module_updates.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('joomla_module_updates.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('joomla_module_updates.edit')) + { + // We can save the record. + ToolbarHelper::save('joomla_module_updates.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('joomla_module_updates.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('joomla_module_updates.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('joomla_module_updates.create')) + { + ToolbarHelper::apply('joomla_module_updates.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('joomla_module_updates.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('joomla_module_updates.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('joomla_module_updates.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('joomla_module_updates.edit')) + { + // We can save the new record + ToolbarHelper::apply('joomla_module_updates.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('joomla_module_updates.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('joomla_module_updates.create')) + { + ToolbarHelper::custom('joomla_module_updates.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('joomla_module_updates.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('joomla_module_updates.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.joomla_module_updates', $this->item->id); + } + if ($this->canDo->get('joomla_module_updates.create')) + { + ToolbarHelper::custom('joomla_module_updates.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('joomla_module_updates.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_module_updates'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } +} diff --git a/admin/views/custom_code/tmpl/index.html b/admin/src/View/Joomla_module_updates/index.html similarity index 100% rename from admin/views/custom_code/tmpl/index.html rename to admin/src/View/Joomla_module_updates/index.html diff --git a/admin/src/View/Joomla_modules/HtmlView.php b/admin/src/View/Joomla_modules/HtmlView.php new file mode 100644 index 000000000..52b783f01 --- /dev/null +++ b/admin/src/View/Joomla_modules/HtmlView.php @@ -0,0 +1,228 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Joomla_modules; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Joomla_modules + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Joomla_modules view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('joomla_module'); + $this->canEdit = $this->canDo->get('joomla_module.edit'); + $this->canState = $this->canDo->get('joomla_module.edit.state'); + $this->canCreate = $this->canDo->get('joomla_module.create'); + $this->canDelete = $this->canDo->get('joomla_module.delete'); + $this->canBatch = ($this->canDo->get('joomla_module.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_JOOMLA_MODULES'), 'cube'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('joomla_module.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('joomla_module.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('joomla_modules.publish'); + ToolbarHelper::unpublishList('joomla_modules.unpublish'); + ToolbarHelper::archiveList('joomla_modules.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('joomla_modules.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'joomla_modules.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('joomla_modules.trash'); + } + } + if ($this->user->authorise('joomla_module.get_snippets', 'com_componentbuilder')) + { + // add Get Snippets button. + ToolbarHelper::custom('joomla_modules.getSnippets', 'search custom-button-getsnippets', '', 'COM_COMPONENTBUILDER_GET_SNIPPETS', false); + } + if ($this->user->authorise('joomla_module.run_expansion', 'com_componentbuilder')) + { + // add Run Expansion button. + ToolbarHelper::custom('joomla_modules.runExpansion', 'expand-2 custom-button-runexpansion', '', 'COM_COMPONENTBUILDER_RUN_EXPANSION', false); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_modules'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_JOOMLA_MODULES')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.system_name' => Text::_('COM_COMPONENTBUILDER_JOOMLA_MODULE_SYSTEM_NAME_LABEL'), + 'a.description' => Text::_('COM_COMPONENTBUILDER_JOOMLA_MODULE_DESCRIPTION_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/custom_codes/index.html b/admin/src/View/Joomla_modules/index.html similarity index 100% rename from admin/views/custom_codes/index.html rename to admin/src/View/Joomla_modules/index.html diff --git a/admin/src/View/Joomla_modules_files_folders_urls/HtmlView.php b/admin/src/View/Joomla_modules_files_folders_urls/HtmlView.php new file mode 100644 index 000000000..b1664093d --- /dev/null +++ b/admin/src/View/Joomla_modules_files_folders_urls/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Joomla_modules_files_folders_urls; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Joomla_modules_files_folders_urls + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Joomla_modules_files_folders_urls view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('joomla_module_files_folders_urls'); + $this->canEdit = $this->canDo->get('joomla_module_files_folders_urls.edit'); + $this->canState = $this->canDo->get('joomla_module_files_folders_urls.edit.state'); + $this->canCreate = $this->canDo->get('joomla_module_files_folders_urls.create'); + $this->canDelete = $this->canDo->get('joomla_module_files_folders_urls.delete'); + $this->canBatch = ($this->canDo->get('joomla_module_files_folders_urls.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_JOOMLA_MODULES_FILES_FOLDERS_URLS'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('joomla_module_files_folders_urls.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('joomla_module_files_folders_urls.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('joomla_modules_files_folders_urls.publish'); + ToolbarHelper::unpublishList('joomla_modules_files_folders_urls.unpublish'); + ToolbarHelper::archiveList('joomla_modules_files_folders_urls.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('joomla_modules_files_folders_urls.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'joomla_modules_files_folders_urls.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('joomla_modules_files_folders_urls.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_modules_files_folders_urls'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_JOOMLA_MODULES_FILES_FOLDERS_URLS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/custom_codes/tmpl/index.html b/admin/src/View/Joomla_modules_files_folders_urls/index.html similarity index 100% rename from admin/views/custom_codes/tmpl/index.html rename to admin/src/View/Joomla_modules_files_folders_urls/index.html diff --git a/admin/src/View/Joomla_modules_updates/HtmlView.php b/admin/src/View/Joomla_modules_updates/HtmlView.php new file mode 100644 index 000000000..59614f1b0 --- /dev/null +++ b/admin/src/View/Joomla_modules_updates/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Joomla_modules_updates; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Joomla_modules_updates + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Joomla_modules_updates view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('joomla_module_updates'); + $this->canEdit = $this->canDo->get('joomla_module_updates.edit'); + $this->canState = $this->canDo->get('joomla_module_updates.edit.state'); + $this->canCreate = $this->canDo->get('joomla_module_updates.create'); + $this->canDelete = $this->canDo->get('joomla_module_updates.delete'); + $this->canBatch = ($this->canDo->get('joomla_module_updates.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('joomla_module_updates.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('joomla_module_updates.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('joomla_modules_updates.publish'); + ToolbarHelper::unpublishList('joomla_modules_updates.unpublish'); + ToolbarHelper::archiveList('joomla_modules_updates.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('joomla_modules_updates.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'joomla_modules_updates.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('joomla_modules_updates.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_modules_updates'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/dynamic_get/tmpl/index.html b/admin/src/View/Joomla_modules_updates/index.html similarity index 100% rename from admin/views/dynamic_get/tmpl/index.html rename to admin/src/View/Joomla_modules_updates/index.html diff --git a/admin/src/View/Joomla_plugin/HtmlView.php b/admin/src/View/Joomla_plugin/HtmlView.php new file mode 100644 index 000000000..e828adf82 --- /dev/null +++ b/admin/src/View/Joomla_plugin/HtmlView.php @@ -0,0 +1,326 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Joomla_plugin; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\ArrayHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_plugin Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Joomla_plugin view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('joomla_plugin.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('joomla_plugin.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('joomla_plugin.edit')) + { + // We can save the record. + ToolbarHelper::save('joomla_plugin.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('joomla_plugin.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('joomla_plugin.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('joomla_plugin.create')) + { + ToolbarHelper::apply('joomla_plugin.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('joomla_plugin.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('joomla_plugin.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('joomla_plugin.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('joomla_plugin.edit')) + { + // We can save the new record + ToolbarHelper::apply('joomla_plugin.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('joomla_plugin.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('joomla_plugin.create')) + { + ToolbarHelper::custom('joomla_plugin.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('joomla_plugin.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('joomla_plugin.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.joomla_plugin', $this->item->id); + } + if ($this->canDo->get('joomla_plugin.create')) + { + ToolbarHelper::custom('joomla_plugin.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('joomla_plugin.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_plugin'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + // Add the JavaScript for JStore + Html::_('script', 'media/com_componentbuilder/js/jquery.json.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/js/jstorage.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/js/strtotime.js', ['version' => 'auto']); + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + // set some lang + Text::script('COM_COMPONENTBUILDER_ALREADY_SELECTED_TRY_ANOTHER'); + Text::script('COM_COMPONENTBUILDER_TYPE_OR_SELECT_SOME_OPTIONS'); + Text::script('COM_COMPONENTBUILDER_NO_RESULTS_MATCH'); + Text::script('COM_COMPONENTBUILDER_SELECT_A_PROPERTY'); + Text::script('COM_COMPONENTBUILDER_NO_DESCRIPTION_FOUND'); + // check if we should use browser storage + $setBrowserStorage = $this->params->get('set_browser_storage', null); + if ($setBrowserStorage) + { + // check what (Time To Live) show we use + $storageTimeToLive = $this->params->get('storage_time_to_live', 'global'); + if ('global' == $storageTimeToLive) + { + // use the global session time + $session = Factory::getSession(); + // must have itin milliseconds + $expire = ($session->getExpire()*60)* 1000; + } + else + { + // use the Componentbuilder Global setting + if (0 != $storageTimeToLive) + { + // this will convert the time into milliseconds + $storageTimeToLive = $storageTimeToLive * 1000; + } + $expire = $storageTimeToLive; + } + } + else + { + // set to use no storage + $expire = 30000; // only 30 seconds + } + // Set the Time To Live To JavaScript + $this->document->addScriptDeclaration("var expire = ". (int) $expire.";"); + $this->document->addScriptDeclaration("selectionArray = {'property':{},'method':{}};"); + // add a few field options via PHP + \JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); + $tmp_ = \JFormHelper::loadFieldType('joomlaplugingroups')->options; + if (ArrayHelper::check($tmp_)) + { + $_tmp = array(); + foreach ($tmp_ as $item) + { + $_tmp[$item->value] = $item->text; + } + // Set the values to JavaScript + $this->document->addScriptDeclaration("selectionArray['joomla_plugin_group'] = ". json_encode($_tmp) . ";"); + } + $tmp_ = \JFormHelper::loadFieldType('pluginsclassproperties')->options; + if (ArrayHelper::check($tmp_)) + { + $_tmp = array(); + foreach ($tmp_ as $item) + { + $_tmp[$item->value] = $item->text; + } + // Set the values to JavaScript + $this->document->addScriptDeclaration("selectionArray['property'] = ". json_encode($_tmp) . ";"); + } + $tmp_ = \JFormHelper::loadFieldType('pluginsclassmethods')->options; + if (ArrayHelper::check($tmp_)) + { + $_tmp = array(); + foreach ($tmp_ as $item) + { + $_tmp[$item->value] = $item->text; + } + // Set the values to JavaScript + $this->document->addScriptDeclaration("selectionArray['method'] = ". json_encode($_tmp) . ";"); + } + } +} diff --git a/admin/views/dynamic_gets/index.html b/admin/src/View/Joomla_plugin/index.html similarity index 100% rename from admin/views/dynamic_gets/index.html rename to admin/src/View/Joomla_plugin/index.html diff --git a/admin/src/View/Joomla_plugin_files_folders_urls/HtmlView.php b/admin/src/View/Joomla_plugin_files_folders_urls/HtmlView.php new file mode 100644 index 000000000..b7e9d6513 --- /dev/null +++ b/admin/src/View/Joomla_plugin_files_folders_urls/HtmlView.php @@ -0,0 +1,230 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Joomla_plugin_files_folders_urls; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_plugin_files_folders_urls Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Joomla_plugin_files_folders_urls view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_files_folders_urls', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('joomla_plugin_files_folders_urls.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('joomla_plugin_files_folders_urls.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('joomla_plugin_files_folders_urls.edit')) + { + // We can save the record. + ToolbarHelper::save('joomla_plugin_files_folders_urls.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('joomla_plugin_files_folders_urls.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('joomla_plugin_files_folders_urls.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('joomla_plugin_files_folders_urls.create')) + { + ToolbarHelper::apply('joomla_plugin_files_folders_urls.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('joomla_plugin_files_folders_urls.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('joomla_plugin_files_folders_urls.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('joomla_plugin_files_folders_urls.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('joomla_plugin_files_folders_urls.edit')) + { + // We can save the new record + ToolbarHelper::apply('joomla_plugin_files_folders_urls.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('joomla_plugin_files_folders_urls.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('joomla_plugin_files_folders_urls.create')) + { + ToolbarHelper::custom('joomla_plugin_files_folders_urls.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('joomla_plugin_files_folders_urls.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('joomla_plugin_files_folders_urls.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.joomla_plugin_files_folders_urls', $this->item->id); + } + if ($this->canDo->get('joomla_plugin_files_folders_urls.create')) + { + ToolbarHelper::custom('joomla_plugin_files_folders_urls.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('joomla_plugin_files_folders_urls.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_plugin_files_folders_urls'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } +} diff --git a/admin/views/dynamic_gets/tmpl/index.html b/admin/src/View/Joomla_plugin_files_folders_urls/index.html similarity index 100% rename from admin/views/dynamic_gets/tmpl/index.html rename to admin/src/View/Joomla_plugin_files_folders_urls/index.html diff --git a/admin/src/View/Joomla_plugin_group/HtmlView.php b/admin/src/View/Joomla_plugin_group/HtmlView.php new file mode 100644 index 000000000..525996ca8 --- /dev/null +++ b/admin/src/View/Joomla_plugin_group/HtmlView.php @@ -0,0 +1,230 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Joomla_plugin_group; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_plugin_group Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Joomla_plugin_group view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_group', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('core.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('joomla_plugin_group.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('core.edit')) + { + // We can save the record. + ToolbarHelper::save('joomla_plugin_group.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('joomla_plugin_group.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('joomla_plugin_group.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('core.create')) + { + ToolbarHelper::apply('joomla_plugin_group.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('joomla_plugin_group.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('joomla_plugin_group.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('joomla_plugin_group.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('core.edit')) + { + // We can save the new record + ToolbarHelper::apply('joomla_plugin_group.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('joomla_plugin_group.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('core.create')) + { + ToolbarHelper::custom('joomla_plugin_group.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('joomla_plugin_group.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('core.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.joomla_plugin_group', $this->item->id); + } + if ($this->canDo->get('core.create')) + { + ToolbarHelper::custom('joomla_plugin_group.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('joomla_plugin_group.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_plugin_group'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } +} diff --git a/admin/views/field/tmpl/index.html b/admin/src/View/Joomla_plugin_group/index.html similarity index 100% rename from admin/views/field/tmpl/index.html rename to admin/src/View/Joomla_plugin_group/index.html diff --git a/admin/src/View/Joomla_plugin_groups/HtmlView.php b/admin/src/View/Joomla_plugin_groups/HtmlView.php new file mode 100644 index 000000000..efaac6bee --- /dev/null +++ b/admin/src/View/Joomla_plugin_groups/HtmlView.php @@ -0,0 +1,218 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Joomla_plugin_groups; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Joomla_plugin_groups + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Joomla_plugin_groups view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_group'); + $this->canEdit = $this->canDo->get('core.edit'); + $this->canState = $this->canDo->get('core.edit.state'); + $this->canCreate = $this->canDo->get('core.create'); + $this->canDelete = $this->canDo->get('core.delete'); + $this->canBatch = ($this->canDo->get('joomla_plugin_group.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUPS'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('joomla_plugin_group.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('joomla_plugin_group.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('joomla_plugin_groups.publish'); + ToolbarHelper::unpublishList('joomla_plugin_groups.unpublish'); + ToolbarHelper::archiveList('joomla_plugin_groups.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('joomla_plugin_groups.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'joomla_plugin_groups.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('joomla_plugin_groups.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_plugin_groups'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUPS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.name' => Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_NAME_LABEL'), + 'g.name' => Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_CLASS_EXTENDS_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/fields/index.html b/admin/src/View/Joomla_plugin_groups/index.html similarity index 100% rename from admin/views/fields/index.html rename to admin/src/View/Joomla_plugin_groups/index.html diff --git a/admin/src/View/Joomla_plugin_updates/HtmlView.php b/admin/src/View/Joomla_plugin_updates/HtmlView.php new file mode 100644 index 000000000..d7a934ff6 --- /dev/null +++ b/admin/src/View/Joomla_plugin_updates/HtmlView.php @@ -0,0 +1,230 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Joomla_plugin_updates; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Joomla_plugin_updates Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Joomla_plugin_updates view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_updates', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('joomla_plugin_updates.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('joomla_plugin_updates.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('joomla_plugin_updates.edit')) + { + // We can save the record. + ToolbarHelper::save('joomla_plugin_updates.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('joomla_plugin_updates.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('joomla_plugin_updates.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('joomla_plugin_updates.create')) + { + ToolbarHelper::apply('joomla_plugin_updates.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('joomla_plugin_updates.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('joomla_plugin_updates.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('joomla_plugin_updates.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('joomla_plugin_updates.edit')) + { + // We can save the new record + ToolbarHelper::apply('joomla_plugin_updates.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('joomla_plugin_updates.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('joomla_plugin_updates.create')) + { + ToolbarHelper::custom('joomla_plugin_updates.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('joomla_plugin_updates.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('joomla_plugin_updates.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.joomla_plugin_updates', $this->item->id); + } + if ($this->canDo->get('joomla_plugin_updates.create')) + { + ToolbarHelper::custom('joomla_plugin_updates.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('joomla_plugin_updates.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_plugin_updates'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } +} diff --git a/admin/views/fields/tmpl/index.html b/admin/src/View/Joomla_plugin_updates/index.html similarity index 100% rename from admin/views/fields/tmpl/index.html rename to admin/src/View/Joomla_plugin_updates/index.html diff --git a/admin/src/View/Joomla_plugins/HtmlView.php b/admin/src/View/Joomla_plugins/HtmlView.php new file mode 100644 index 000000000..23442df88 --- /dev/null +++ b/admin/src/View/Joomla_plugins/HtmlView.php @@ -0,0 +1,239 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Joomla_plugins; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Joomla_plugins + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Joomla_plugins view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin'); + $this->canEdit = $this->canDo->get('joomla_plugin.edit'); + $this->canState = $this->canDo->get('joomla_plugin.edit.state'); + $this->canCreate = $this->canDo->get('joomla_plugin.create'); + $this->canDelete = $this->canDo->get('joomla_plugin.delete'); + $this->canBatch = ($this->canDo->get('joomla_plugin.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGINS'), 'power-cord'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('joomla_plugin.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('joomla_plugin.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('joomla_plugins.publish'); + ToolbarHelper::unpublishList('joomla_plugins.unpublish'); + ToolbarHelper::archiveList('joomla_plugins.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('joomla_plugins.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'joomla_plugins.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('joomla_plugins.trash'); + } + } + if ($this->user->authorise('joomla_plugin.run_expansion', 'com_componentbuilder')) + { + // add Run Expansion button. + ToolbarHelper::custom('joomla_plugins.runExpansion', 'expand-2 custom-button-runexpansion', '', 'COM_COMPONENTBUILDER_RUN_EXPANSION', false); + } + if ($this->user->authorise('joomla_plugin.get_boilerplate', 'com_componentbuilder')) + { + // add Get Boilerplate button. + ToolbarHelper::custom('joomla_plugins.getBoilerplate', 'joomla custom-button-getboilerplate', '', 'COM_COMPONENTBUILDER_GET_BOILERPLATE', false); + } + if ($this->user->authorise('joomla_plugin.methods', 'com_componentbuilder')) + { + // add Methods button. + ToolbarHelper::custom('joomla_plugins.openClassMethods', 'joomla custom-button-openclassmethods', '', 'COM_COMPONENTBUILDER_METHODS', false); + } + if ($this->user->authorise('joomla_plugin.properties', 'com_componentbuilder')) + { + // add Properties button. + ToolbarHelper::custom('joomla_plugins.openClassProperties', 'joomla custom-button-openclassproperties', '', 'COM_COMPONENTBUILDER_PROPERTIES', false); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_plugins'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGINS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.system_name' => Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_SYSTEM_NAME_LABEL'), + 'g.name' => Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_CLASS_EXTENDS_LABEL'), + 'h.name' => Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_JOOMLA_PLUGIN_GROUP_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/fieldtype/tmpl/index.html b/admin/src/View/Joomla_plugins/index.html similarity index 100% rename from admin/views/fieldtype/tmpl/index.html rename to admin/src/View/Joomla_plugins/index.html diff --git a/admin/src/View/Joomla_plugins_files_folders_urls/HtmlView.php b/admin/src/View/Joomla_plugins_files_folders_urls/HtmlView.php new file mode 100644 index 000000000..af9daddac --- /dev/null +++ b/admin/src/View/Joomla_plugins_files_folders_urls/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Joomla_plugins_files_folders_urls; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Joomla_plugins_files_folders_urls + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Joomla_plugins_files_folders_urls view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_files_folders_urls'); + $this->canEdit = $this->canDo->get('joomla_plugin_files_folders_urls.edit'); + $this->canState = $this->canDo->get('joomla_plugin_files_folders_urls.edit.state'); + $this->canCreate = $this->canDo->get('joomla_plugin_files_folders_urls.create'); + $this->canDelete = $this->canDo->get('joomla_plugin_files_folders_urls.delete'); + $this->canBatch = ($this->canDo->get('joomla_plugin_files_folders_urls.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('joomla_plugin_files_folders_urls.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('joomla_plugin_files_folders_urls.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('joomla_plugins_files_folders_urls.publish'); + ToolbarHelper::unpublishList('joomla_plugins_files_folders_urls.unpublish'); + ToolbarHelper::archiveList('joomla_plugins_files_folders_urls.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('joomla_plugins_files_folders_urls.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'joomla_plugins_files_folders_urls.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('joomla_plugins_files_folders_urls.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_plugins_files_folders_urls'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/fieldtypes/index.html b/admin/src/View/Joomla_plugins_files_folders_urls/index.html similarity index 100% rename from admin/views/fieldtypes/index.html rename to admin/src/View/Joomla_plugins_files_folders_urls/index.html diff --git a/admin/src/View/Joomla_plugins_updates/HtmlView.php b/admin/src/View/Joomla_plugins_updates/HtmlView.php new file mode 100644 index 000000000..5f062b632 --- /dev/null +++ b/admin/src/View/Joomla_plugins_updates/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Joomla_plugins_updates; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Joomla_plugins_updates + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Joomla_plugins_updates view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_updates'); + $this->canEdit = $this->canDo->get('joomla_plugin_updates.edit'); + $this->canState = $this->canDo->get('joomla_plugin_updates.edit.state'); + $this->canCreate = $this->canDo->get('joomla_plugin_updates.create'); + $this->canDelete = $this->canDo->get('joomla_plugin_updates.delete'); + $this->canBatch = ($this->canDo->get('joomla_plugin_updates.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('joomla_plugin_updates.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('joomla_plugin_updates.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('joomla_plugins_updates.publish'); + ToolbarHelper::unpublishList('joomla_plugins_updates.unpublish'); + ToolbarHelper::archiveList('joomla_plugins_updates.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('joomla_plugins_updates.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'joomla_plugins_updates.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('joomla_plugins_updates.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_plugins_updates'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/fieldtypes/tmpl/index.html b/admin/src/View/Joomla_plugins_updates/index.html similarity index 100% rename from admin/views/fieldtypes/tmpl/index.html rename to admin/src/View/Joomla_plugins_updates/index.html diff --git a/admin/src/View/Language/HtmlView.php b/admin/src/View/Language/HtmlView.php new file mode 100644 index 000000000..1bb4f28e0 --- /dev/null +++ b/admin/src/View/Language/HtmlView.php @@ -0,0 +1,230 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Language; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Language Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Language view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('language', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_LANGUAGE_NEW' : 'COM_COMPONENTBUILDER_LANGUAGE_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('language.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('language.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('language.edit')) + { + // We can save the record. + ToolbarHelper::save('language.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('language.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('language.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('language.create')) + { + ToolbarHelper::apply('language.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('language.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('language.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('language.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('language.edit')) + { + // We can save the new record + ToolbarHelper::apply('language.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('language.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('language.create')) + { + ToolbarHelper::custom('language.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('language.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('language.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.language', $this->item->id); + } + if ($this->canDo->get('language.create')) + { + ToolbarHelper::custom('language.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('language.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('language'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_LANGUAGE_NEW' : 'COM_COMPONENTBUILDER_LANGUAGE_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } +} diff --git a/admin/views/get_snippets/index.html b/admin/src/View/Language/index.html similarity index 100% rename from admin/views/get_snippets/index.html rename to admin/src/View/Language/index.html diff --git a/admin/src/View/Language_translation/HtmlView.php b/admin/src/View/Language_translation/HtmlView.php new file mode 100644 index 000000000..c1270bc49 --- /dev/null +++ b/admin/src/View/Language_translation/HtmlView.php @@ -0,0 +1,241 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Language_translation; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Language_translation Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Language_translation view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('language_translation', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_NEW' : 'COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('language_translation.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('language_translation.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('language_translation.edit')) + { + // We can save the record. + ToolbarHelper::save('language_translation.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('language_translation.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('language_translation.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('language_translation.create')) + { + ToolbarHelper::apply('language_translation.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('language_translation.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('language_translation.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('language_translation.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('language_translation.edit')) + { + // We can save the new record + ToolbarHelper::apply('language_translation.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('language_translation.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('language_translation.create')) + { + ToolbarHelper::custom('language_translation.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('language_translation.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('language_translation.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.language_translation', $this->item->id); + } + if ($this->canDo->get('language_translation.create')) + { + ToolbarHelper::custom('language_translation.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('language_translation.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('language_translation'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_NEW' : 'COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + // add JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + // add the style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '".$this->get('VDM')."';"); + } +} diff --git a/admin/views/get_snippets/tmpl/index.html b/admin/src/View/Language_translation/index.html similarity index 100% rename from admin/views/get_snippets/tmpl/index.html rename to admin/src/View/Language_translation/index.html diff --git a/admin/src/View/Language_translations/HtmlView.php b/admin/src/View/Language_translations/HtmlView.php new file mode 100644 index 000000000..c7a0eb23a --- /dev/null +++ b/admin/src/View/Language_translations/HtmlView.php @@ -0,0 +1,217 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Language_translations; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Language_translations + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Language_translations view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('language_translation'); + $this->canEdit = $this->canDo->get('language_translation.edit'); + $this->canState = $this->canDo->get('language_translation.edit.state'); + $this->canCreate = $this->canDo->get('language_translation.create'); + $this->canDelete = $this->canDo->get('language_translation.delete'); + $this->canBatch = ($this->canDo->get('language_translation.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS'), 'comments-2'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('language_translation.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('language_translation.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('language_translations.publish'); + ToolbarHelper::unpublishList('language_translations.unpublish'); + ToolbarHelper::archiveList('language_translations.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('language_translations.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'language_translations.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('language_translations.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('language_translations'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.source' => Text::_('COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_SOURCE_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/help_document/tmpl/index.html b/admin/src/View/Language_translations/index.html similarity index 100% rename from admin/views/help_document/tmpl/index.html rename to admin/src/View/Language_translations/index.html diff --git a/admin/src/View/Languages/HtmlView.php b/admin/src/View/Languages/HtmlView.php new file mode 100644 index 000000000..7f9907a27 --- /dev/null +++ b/admin/src/View/Languages/HtmlView.php @@ -0,0 +1,223 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Languages; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Languages + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Languages view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('language'); + $this->canEdit = $this->canDo->get('language.edit'); + $this->canState = $this->canDo->get('language.edit.state'); + $this->canCreate = $this->canDo->get('language.create'); + $this->canDelete = $this->canDo->get('language.delete'); + $this->canBatch = ($this->canDo->get('language.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_LANGUAGES'), 'comment'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('language.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('language.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('languages.publish'); + ToolbarHelper::unpublishList('languages.unpublish'); + ToolbarHelper::archiveList('languages.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('languages.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'languages.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('languages.trash'); + } + } + if ($this->user->authorise('language.build', 'com_componentbuilder')) + { + // add Build button. + ToolbarHelper::custom('languages.buildLanguages', 'joomla custom-button-buildlanguages', '', 'COM_COMPONENTBUILDER_BUILD', false); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('languages'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_LANGUAGES')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.name' => Text::_('COM_COMPONENTBUILDER_LANGUAGE_NAME_LABEL'), + 'a.langtag' => Text::_('COM_COMPONENTBUILDER_LANGUAGE_LANGTAG_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/help_documents/index.html b/admin/src/View/Languages/index.html similarity index 100% rename from admin/views/help_documents/index.html rename to admin/src/View/Languages/index.html diff --git a/admin/src/View/Layout/HtmlView.php b/admin/src/View/Layout/HtmlView.php new file mode 100644 index 000000000..63901109a --- /dev/null +++ b/admin/src/View/Layout/HtmlView.php @@ -0,0 +1,248 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Layout; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Layout Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Layout view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('layout', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_LAYOUT_NEW' : 'COM_COMPONENTBUILDER_LAYOUT_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('core.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('layout.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('core.edit')) + { + // We can save the record. + ToolbarHelper::save('layout.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('layout.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('layout.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('core.create')) + { + ToolbarHelper::apply('layout.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('layout.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('layout.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('layout.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('core.edit')) + { + // We can save the new record + ToolbarHelper::apply('layout.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('layout.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('core.create')) + { + ToolbarHelper::custom('layout.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('layout.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('core.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.layout', $this->item->id); + } + if ($this->canDo->get('core.create')) + { + ToolbarHelper::custom('layout.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('layout.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('layout'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_LAYOUT_NEW' : 'COM_COMPONENTBUILDER_LAYOUT_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + } +} diff --git a/admin/views/help_documents/tmpl/index.html b/admin/src/View/Layout/index.html similarity index 100% rename from admin/views/help_documents/tmpl/index.html rename to admin/src/View/Layout/index.html diff --git a/admin/src/View/Layouts/HtmlView.php b/admin/src/View/Layouts/HtmlView.php new file mode 100644 index 000000000..7516ef8d3 --- /dev/null +++ b/admin/src/View/Layouts/HtmlView.php @@ -0,0 +1,224 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Layouts; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Layouts + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Layouts view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('layout'); + $this->canEdit = $this->canDo->get('core.edit'); + $this->canState = $this->canDo->get('core.edit.state'); + $this->canCreate = $this->canDo->get('core.create'); + $this->canDelete = $this->canDo->get('core.delete'); + $this->canBatch = ($this->canDo->get('layout.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_LAYOUTS'), 'brush'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('layout.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('layout.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('layouts.publish'); + ToolbarHelper::unpublishList('layouts.unpublish'); + ToolbarHelper::archiveList('layouts.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('layouts.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'layouts.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('layouts.trash'); + } + } + if ($this->user->authorise('layout.get_snippets', 'com_componentbuilder')) + { + // add Get Snippets button. + ToolbarHelper::custom('layouts.getSnippets', 'search custom-button-getsnippets', '', 'COM_COMPONENTBUILDER_GET_SNIPPETS', false); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('layouts'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_LAYOUTS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.name' => Text::_('COM_COMPONENTBUILDER_LAYOUT_NAME_LABEL'), + 'a.description' => Text::_('COM_COMPONENTBUILDER_LAYOUT_DESCRIPTION_LABEL'), + 'g.name' => Text::_('COM_COMPONENTBUILDER_LAYOUT_DYNAMIC_GET_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/import/index.html b/admin/src/View/Layouts/index.html similarity index 100% rename from admin/views/import/index.html rename to admin/src/View/Layouts/index.html diff --git a/admin/src/View/Libraries/HtmlView.php b/admin/src/View/Libraries/HtmlView.php new file mode 100644 index 000000000..5afc96567 --- /dev/null +++ b/admin/src/View/Libraries/HtmlView.php @@ -0,0 +1,225 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Libraries; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Libraries + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Libraries view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('library'); + $this->canEdit = $this->canDo->get('library.edit'); + $this->canState = $this->canDo->get('library.edit.state'); + $this->canCreate = $this->canDo->get('library.create'); + $this->canDelete = $this->canDo->get('library.delete'); + $this->canBatch = ($this->canDo->get('library.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_LIBRARIES'), 'puzzle'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('library.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('library.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('libraries.publish'); + ToolbarHelper::unpublishList('libraries.unpublish'); + ToolbarHelper::archiveList('libraries.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('libraries.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'libraries.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('libraries.trash'); + } + } + if ($this->user->authorise('library.get_snippets', 'com_componentbuilder')) + { + // add Get Snippets button. + ToolbarHelper::custom('libraries.getSnippets', 'search custom-button-getsnippets', '', 'COM_COMPONENTBUILDER_GET_SNIPPETS', false); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('libraries'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_LIBRARIES')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.name' => Text::_('COM_COMPONENTBUILDER_LIBRARY_NAME_LABEL'), + 'a.target' => Text::_('COM_COMPONENTBUILDER_LIBRARY_TARGET_LABEL'), + 'a.type' => Text::_('COM_COMPONENTBUILDER_LIBRARY_TYPE_LABEL'), + 'a.description' => Text::_('COM_COMPONENTBUILDER_LIBRARY_DESCRIPTION_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/import/tmpl/index.html b/admin/src/View/Libraries/index.html similarity index 100% rename from admin/views/import/tmpl/index.html rename to admin/src/View/Libraries/index.html diff --git a/admin/src/View/Libraries_config/HtmlView.php b/admin/src/View/Libraries_config/HtmlView.php new file mode 100644 index 000000000..a8e21b1c5 --- /dev/null +++ b/admin/src/View/Libraries_config/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Libraries_config; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Libraries_config + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Libraries_config view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('library_config'); + $this->canEdit = $this->canDo->get('library_config.edit'); + $this->canState = $this->canDo->get('library_config.edit.state'); + $this->canCreate = $this->canDo->get('library_config.create'); + $this->canDelete = $this->canDo->get('library_config.delete'); + $this->canBatch = ($this->canDo->get('library_config.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_LIBRARIES_CONFIG'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('library_config.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('library_config.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('libraries_config.publish'); + ToolbarHelper::unpublishList('libraries_config.unpublish'); + ToolbarHelper::archiveList('libraries_config.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('libraries_config.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'libraries_config.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('libraries_config.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('libraries_config'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_LIBRARIES_CONFIG')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/import_joomla_components/index.html b/admin/src/View/Libraries_config/index.html similarity index 100% rename from admin/views/import_joomla_components/index.html rename to admin/src/View/Libraries_config/index.html diff --git a/admin/src/View/Libraries_files_folders_urls/HtmlView.php b/admin/src/View/Libraries_files_folders_urls/HtmlView.php new file mode 100644 index 000000000..57d180ed7 --- /dev/null +++ b/admin/src/View/Libraries_files_folders_urls/HtmlView.php @@ -0,0 +1,216 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Libraries_files_folders_urls; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Libraries_files_folders_urls + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Libraries_files_folders_urls view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('library_files_folders_urls'); + $this->canEdit = $this->canDo->get('library_files_folders_urls.edit'); + $this->canState = $this->canDo->get('library_files_folders_urls.edit.state'); + $this->canCreate = $this->canDo->get('library_files_folders_urls.create'); + $this->canDelete = $this->canDo->get('library_files_folders_urls.delete'); + $this->canBatch = ($this->canDo->get('library_files_folders_urls.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('library_files_folders_urls.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('library_files_folders_urls.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('libraries_files_folders_urls.publish'); + ToolbarHelper::unpublishList('libraries_files_folders_urls.unpublish'); + ToolbarHelper::archiveList('libraries_files_folders_urls.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('libraries_files_folders_urls.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'libraries_files_folders_urls.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('libraries_files_folders_urls.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('libraries_files_folders_urls'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/import_joomla_components/tmpl/index.html b/admin/src/View/Libraries_files_folders_urls/index.html similarity index 100% rename from admin/views/import_joomla_components/tmpl/index.html rename to admin/src/View/Libraries_files_folders_urls/index.html diff --git a/admin/src/View/Library/HtmlView.php b/admin/src/View/Library/HtmlView.php new file mode 100644 index 000000000..32a068698 --- /dev/null +++ b/admin/src/View/Library/HtmlView.php @@ -0,0 +1,248 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Library; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Library Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Library view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('library', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_LIBRARY_NEW' : 'COM_COMPONENTBUILDER_LIBRARY_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('library.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('library.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('library.edit')) + { + // We can save the record. + ToolbarHelper::save('library.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('library.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('library.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('library.create')) + { + ToolbarHelper::apply('library.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('library.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('library.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('library.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('library.edit')) + { + // We can save the new record + ToolbarHelper::apply('library.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('library.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('library.create')) + { + ToolbarHelper::custom('library.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('library.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('library.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.library', $this->item->id); + } + if ($this->canDo->get('library.create')) + { + ToolbarHelper::custom('library.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('library.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('library'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_LIBRARY_NEW' : 'COM_COMPONENTBUILDER_LIBRARY_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + } +} diff --git a/admin/views/import_language_translations/index.html b/admin/src/View/Library/index.html similarity index 100% rename from admin/views/import_language_translations/index.html rename to admin/src/View/Library/index.html diff --git a/admin/src/View/Library_config/HtmlView.php b/admin/src/View/Library_config/HtmlView.php new file mode 100644 index 000000000..1a2c3561a --- /dev/null +++ b/admin/src/View/Library_config/HtmlView.php @@ -0,0 +1,230 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Library_config; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Library_config Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Library_config view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('library_config', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_LIBRARY_CONFIG_NEW' : 'COM_COMPONENTBUILDER_LIBRARY_CONFIG_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('library_config.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('library_config.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('library_config.edit')) + { + // We can save the record. + ToolbarHelper::save('library_config.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('library_config.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('library_config.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('library_config.create')) + { + ToolbarHelper::apply('library_config.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('library_config.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('library_config.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('library_config.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('library_config.edit')) + { + // We can save the new record + ToolbarHelper::apply('library_config.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('library_config.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('library_config.create')) + { + ToolbarHelper::custom('library_config.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('library_config.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('library_config.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.library_config', $this->item->id); + } + if ($this->canDo->get('library_config.create')) + { + ToolbarHelper::custom('library_config.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('library_config.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('library_config'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_LIBRARY_CONFIG_NEW' : 'COM_COMPONENTBUILDER_LIBRARY_CONFIG_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } +} diff --git a/admin/views/import_language_translations/tmpl/index.html b/admin/src/View/Library_config/index.html similarity index 100% rename from admin/views/import_language_translations/tmpl/index.html rename to admin/src/View/Library_config/index.html diff --git a/admin/src/View/Library_files_folders_urls/HtmlView.php b/admin/src/View/Library_files_folders_urls/HtmlView.php new file mode 100644 index 000000000..25eb4bc47 --- /dev/null +++ b/admin/src/View/Library_files_folders_urls/HtmlView.php @@ -0,0 +1,230 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Library_files_folders_urls; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Library_files_folders_urls Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Library_files_folders_urls view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('library_files_folders_urls', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_NEW' : 'COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('library_files_folders_urls.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('library_files_folders_urls.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('library_files_folders_urls.edit')) + { + // We can save the record. + ToolbarHelper::save('library_files_folders_urls.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('library_files_folders_urls.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('library_files_folders_urls.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('library_files_folders_urls.create')) + { + ToolbarHelper::apply('library_files_folders_urls.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('library_files_folders_urls.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('library_files_folders_urls.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('library_files_folders_urls.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('library_files_folders_urls.edit')) + { + // We can save the new record + ToolbarHelper::apply('library_files_folders_urls.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('library_files_folders_urls.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('library_files_folders_urls.create')) + { + ToolbarHelper::custom('library_files_folders_urls.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('library_files_folders_urls.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('library_files_folders_urls.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.library_files_folders_urls', $this->item->id); + } + if ($this->canDo->get('library_files_folders_urls.create')) + { + ToolbarHelper::custom('library_files_folders_urls.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('library_files_folders_urls.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('library_files_folders_urls'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_NEW' : 'COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } +} diff --git a/admin/views/index.html b/admin/src/View/Library_files_folders_urls/index.html similarity index 100% rename from admin/views/index.html rename to admin/src/View/Library_files_folders_urls/index.html diff --git a/admin/src/View/Placeholder/HtmlView.php b/admin/src/View/Placeholder/HtmlView.php new file mode 100644 index 000000000..01bbe3fcf --- /dev/null +++ b/admin/src/View/Placeholder/HtmlView.php @@ -0,0 +1,251 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Placeholder; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Placeholder Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Placeholder view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('placeholder', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_PLACEHOLDER_NEW' : 'COM_COMPONENTBUILDER_PLACEHOLDER_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('placeholder.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('placeholder.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('placeholder.edit')) + { + // We can save the record. + ToolbarHelper::save('placeholder.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('placeholder.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('placeholder.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('placeholder.create')) + { + ToolbarHelper::apply('placeholder.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('placeholder.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('placeholder.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('placeholder.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('placeholder.edit')) + { + // We can save the new record + ToolbarHelper::apply('placeholder.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('placeholder.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('placeholder.create')) + { + ToolbarHelper::custom('placeholder.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('placeholder.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('placeholder.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.placeholder', $this->item->id); + } + if ($this->canDo->get('placeholder.create')) + { + ToolbarHelper::custom('placeholder.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('placeholder.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('placeholder'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_PLACEHOLDER_NEW' : 'COM_COMPONENTBUILDER_PLACEHOLDER_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + // add some language strings + Text::script('COM_COMPONENTBUILDER_PLACEHOLDER_ALREADY_TAKEN_PLEASE_TRY_AGAIN'); + Text::script('COM_COMPONENTBUILDER_YOU_MUST_ADD_AN_UNIQUE_PLACEHOLDER'); + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + } +} diff --git a/admin/views/joomla_component/tmpl/index.html b/admin/src/View/Placeholder/index.html similarity index 100% rename from admin/views/joomla_component/tmpl/index.html rename to admin/src/View/Placeholder/index.html diff --git a/admin/src/View/Placeholders/HtmlView.php b/admin/src/View/Placeholders/HtmlView.php new file mode 100644 index 000000000..ee7c7a7b2 --- /dev/null +++ b/admin/src/View/Placeholders/HtmlView.php @@ -0,0 +1,218 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Placeholders; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Placeholders + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Placeholders view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('placeholder'); + $this->canEdit = $this->canDo->get('placeholder.edit'); + $this->canState = $this->canDo->get('placeholder.edit.state'); + $this->canCreate = $this->canDo->get('placeholder.create'); + $this->canDelete = $this->canDo->get('placeholder.delete'); + $this->canBatch = ($this->canDo->get('placeholder.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_PLACEHOLDERS'), 'search'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('placeholder.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('placeholder.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('placeholders.publish'); + ToolbarHelper::unpublishList('placeholders.unpublish'); + ToolbarHelper::archiveList('placeholders.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('placeholders.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'placeholders.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('placeholders.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('placeholders'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_PLACEHOLDERS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.target' => Text::_('COM_COMPONENTBUILDER_PLACEHOLDER_TARGET_LABEL'), + 'a.value' => Text::_('COM_COMPONENTBUILDER_PLACEHOLDER_VALUE_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/joomla_components/index.html b/admin/src/View/Placeholders/index.html similarity index 100% rename from admin/views/joomla_components/index.html rename to admin/src/View/Placeholders/index.html diff --git a/admin/src/View/Power/HtmlView.php b/admin/src/View/Power/HtmlView.php new file mode 100644 index 000000000..a0631aeb6 --- /dev/null +++ b/admin/src/View/Power/HtmlView.php @@ -0,0 +1,295 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Power; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Power Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Power view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('power', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_POWER_NEW' : 'COM_COMPONENTBUILDER_POWER_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('power.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('power.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('power.edit')) + { + // We can save the record. + ToolbarHelper::save('power.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('power.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('power.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('power.create')) + { + ToolbarHelper::apply('power.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('power.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('power.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('power.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('power.edit')) + { + // We can save the new record + ToolbarHelper::apply('power.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('power.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('power.create')) + { + ToolbarHelper::custom('power.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('power.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('power.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.power', $this->item->id); + } + if ($this->canDo->get('power.create')) + { + ToolbarHelper::custom('power.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + if ($this->canDo->get('power.reset')) + { + // add Reset button. + ToolbarHelper::custom('power.resetPowers', 'joomla custom-button-resetpowers', '', 'COM_COMPONENTBUILDER_RESET', false); + } + ToolbarHelper::cancel('power.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('power'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_POWER_NEW' : 'COM_COMPONENTBUILDER_POWER_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + // Add the JavaScript for JStore + Html::_('script', 'media/com_componentbuilder/js/jquery.json.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/js/jstorage.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/js/strtotime.js', ['version' => 'auto']); + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + // set some lang + Text::script('COM_COMPONENTBUILDER_ALREADY_SELECTED_TRY_ANOTHER'); + Text::script('COM_COMPONENTBUILDER_TYPE_OR_SELECT_SOME_OPTIONS'); + Text::script('COM_COMPONENTBUILDER_NO_RESULTS_MATCH'); + Text::script('COM_COMPONENTBUILDER_SELECT_A_PROPERTY'); + Text::script('COM_COMPONENTBUILDER_NO_DESCRIPTION_FOUND'); + // check if we should use browser storage + $setBrowserStorage = $this->params->get('set_browser_storage', null); + if ($setBrowserStorage) + { + // check what (Time To Live) show we use + $storageTimeToLive = $this->params->get('storage_time_to_live', 'global'); + if ('global' == $storageTimeToLive) + { + // use the global session time + $session = Factory::getSession(); + // must have itin milliseconds + $expire = ($session->getExpire()*60)* 1000; + } + else + { + // use the Componentbuilder Global setting + if (0 != $storageTimeToLive) + { + // this will convert the time into milliseconds + $storageTimeToLive = $storageTimeToLive * 1000; + } + $expire = $storageTimeToLive; + } + } + else + { + // set to use no storage + $expire = 30000; // only 30 seconds + } + // Set the Time To Live To JavaScript + $this->document->addScriptDeclaration("var expire = ". (int) $expire.";"); + $this->document->addScriptDeclaration("selectionArray = {'property':{},'method':{}};"); + } +} diff --git a/admin/views/joomla_components/tmpl/index.html b/admin/src/View/Power/index.html similarity index 100% rename from admin/views/joomla_components/tmpl/index.html rename to admin/src/View/Power/index.html diff --git a/admin/src/View/Powers/HtmlView.php b/admin/src/View/Powers/HtmlView.php new file mode 100644 index 000000000..8decff35f --- /dev/null +++ b/admin/src/View/Powers/HtmlView.php @@ -0,0 +1,235 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Powers; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Powers + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Powers view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('power'); + $this->canEdit = $this->canDo->get('power.edit'); + $this->canState = $this->canDo->get('power.edit.state'); + $this->canCreate = $this->canDo->get('power.create'); + $this->canDelete = $this->canDo->get('power.delete'); + $this->canBatch = ($this->canDo->get('power.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_POWERS'), 'flash'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('power.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('power.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('powers.publish'); + ToolbarHelper::unpublishList('powers.unpublish'); + ToolbarHelper::archiveList('powers.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('powers.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'powers.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('powers.trash'); + } + } + if ($this->user->authorise('power.run_expansion', 'com_componentbuilder')) + { + // add Run Expansion button. + ToolbarHelper::custom('powers.runExpansion', 'expand-2 custom-button-runexpansion', '', 'COM_COMPONENTBUILDER_RUN_EXPANSION', false); + } + if ($this->user->authorise('power.init', 'com_componentbuilder')) + { + // add Init button. + ToolbarHelper::custom('powers.initPowers', 'health custom-button-initpowers', '', 'COM_COMPONENTBUILDER_INIT', false); + } + if ($this->user->authorise('power.reset', 'com_componentbuilder')) + { + // add Reset button. + ToolbarHelper::custom('powers.resetPowers', 'joomla custom-button-resetpowers', '', 'COM_COMPONENTBUILDER_RESET', false); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('powers'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_POWERS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.system_name' => Text::_('COM_COMPONENTBUILDER_POWER_SYSTEM_NAME_LABEL'), + 'a.namespace' => Text::_('COM_COMPONENTBUILDER_POWER_NAMESPACE_LABEL'), + 'a.type' => Text::_('COM_COMPONENTBUILDER_POWER_TYPE_LABEL'), + 'a.power_version' => Text::_('COM_COMPONENTBUILDER_POWER_POWER_VERSION_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/joomla_module/tmpl/index.html b/admin/src/View/Powers/index.html similarity index 100% rename from admin/views/joomla_module/tmpl/index.html rename to admin/src/View/Powers/index.html diff --git a/admin/src/View/Search/HtmlView.php b/admin/src/View/Search/HtmlView.php new file mode 100644 index 000000000..8311a8ee5 --- /dev/null +++ b/admin/src/View/Search/HtmlView.php @@ -0,0 +1,475 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Search; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\HeaderCheck; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use Joomla\CMS\Filesystem\File; +use VDM\Joomla\Componentbuilder\Search\Factory as SearchFactory; +use Joomla\CMS\Form\Form; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\FormHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Search + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Display the view + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // get component params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // get the application + $this->app ??= Factory::getApplication(); + // get the user object + $this->user ??= Factory::getApplication()->getIdentity(); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('search'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + // Initialise variables. + $this->item = $this->get('Item'); + $this->urlvalues = $this->get('UrlValues'); + // get the needed form fields + $this->form = $this->getDynamicForm(); + + // build our table headers + $this->table_headers = array( + 'edit' => 'E', + 'code' => Text::_('COM_COMPONENTBUILDER_FOUND_TEXT'), + 'table' => Text::_('COM_COMPONENTBUILDER_TABLE'), + 'field' => Text::_('COM_COMPONENTBUILDER_FIELD'), + 'id' => Text::_('ID'), + 'line' => Text::_('COM_COMPONENTBUILDER_LINE') + ); + + // set some JavaScript Language + Text::script('COM_COMPONENTBUILDER_YOUR_ARE_ABOUT_TO_UPDATE_ROW'); + Text::script('COM_COMPONENTBUILDER_FIELD_IN_THE'); + Text::script('COM_COMPONENTBUILDER_TABLE'); + Text::script('COM_COMPONENTBUILDER_THIS_CAN_NOT_BE_UNDONE_ARE_YOU_SURE_YOU_WANT_TO_CONTINUE'); + Text::script('COM_COMPONENTBUILDER_YOUR_ARE_ABOUT_TO_UPDATE_BALLB_VALUES_THAT_CAN_BE_FOUND_IN_THE_DATABASE'); + Text::script('COM_COMPONENTBUILDER_YOU_WILL_REPLACE'); + Text::script('COM_COMPONENTBUILDER_WITH'); + Text::script('COM_COMPONENTBUILDER_THIS_CAN_NOT_BE_UNDONE_BYOU_HAVE_BEEN_WARNEDB'); + Text::script('COM_COMPONENTBUILDER_ARE_YOU_THEREFORE_ABSOLUTELY_SURE_YOU_WANT_TO_CONTINUE'); + Text::script('COM_COMPONENTBUILDER_THE_SEARCH_PROCESS_HAD_AN_ERROR_WITH_TABLE'); + Text::script('COM_COMPONENTBUILDER_THE_REPLACE_PROCESS_HAD_AN_ERROR_WITH_TABLE'); + Text::script('COM_COMPONENTBUILDER_REPLACE_PROCESS_COMPLETE'); + Text::script('COM_COMPONENTBUILDER_SEARCHING'); + Text::script('COM_COMPONENTBUILDER_TABLES_WITH'); + Text::script('COM_COMPONENTBUILDER_FIELDS_THAT_HAD'); + Text::script('COM_COMPONENTBUILDER_LINES'); + Text::script('COM_COMPONENTBUILDER_AND_FINISHED_THE_SEARCH_IN'); + Text::script('COM_COMPONENTBUILDER_SECONDS'); + Text::script('COM_COMPONENTBUILDER_WOULD_YOU_LIKE_TO_DO_A_REVERSE_SEARCH'); + Text::script('COM_COMPONENTBUILDER_WOULD_YOU_LIKE_TO_REPEAT_THE_SAME_SEARCH'); + Text::script('COM_COMPONENTBUILDER_YES_UPDATE_ALL'); + Text::script('COM_COMPONENTBUILDER_NO'); + Text::script('COM_COMPONENTBUILDER_YES'); + // just get it on the page for now.... + ToolbarHelper::inlinehelp(); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + // add the tool bar + $this->addToolBar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode(PHP_EOL, $errors), 500); + } + + parent::display($tpl); + + // Set the html view document stuff + $this->_prepareDocument(); + } + + /** + * Get the dynamic build form fields needed on the page + * + * @return Form|null The array of form fields + * + * @since 3.2.0 + */ + public function getDynamicForm(): ?Form + { + if(ArrayHelper::check($this->item) && + ArrayHelper::check($this->item['tables']) && + ArrayHelper::check($this->item['components'])) + { + // start the form + $form = new Form('Search'); + + $form->load('
    + +
    +
    +
    +
    '); + + // Search Mode + $attributes = [ + 'type' => 'radio', + 'name' => 'type_search', + 'hiddenLabel' => true, + 'label' => 'COM_COMPONENTBUILDER_MODE', + 'class' => 'btn-group', + 'description' => 'COM_COMPONENTBUILDER_SEARCH_OR_SEARCH_AND_REPLACE', + 'default' => $this->urlvalues['type_search']]; + // set the mode options + $options = [ + 1 => 'COM_COMPONENTBUILDER_SEARCH', + 2 => 'COM_COMPONENTBUILDER_REPLACE', + 0 => 'COM_COMPONENTBUILDER_CLEAR']; + // add to form + $xml = FormHelper::xml($attributes, $options); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'search'); + } + + // search text attributes + $attributes = [ + 'type' => 'text', + 'name' => 'search_value', + 'hiddenLabel' => true, + 'label' => 'COM_COMPONENTBUILDER_SEARCH', + 'size' => 150, + 'maxlength' => 200, + 'description' => 'COM_COMPONENTBUILDER_HERE_YOU_CAN_ENTER_YOUR_SEARCH_TEXT', + 'filter' => 'RAW', + 'class' => 'search-value span11', + 'hint' => 'COM_COMPONENTBUILDER_ENTER_YOUR_SEARCH_TEXT', + 'autocomplete' => true, + 'default' => $this->urlvalues['search_value']]; + // add to form + $xml = FormHelper::xml($attributes); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'search'); + } + + // replace text attributes + $attributes = [ + 'type' => 'text', + 'name' => 'replace_value', + 'hiddenLabel' => true, + 'label' => 'COM_COMPONENTBUILDER_REPLACE', + 'size' => 150, + 'maxlength' => 200, + 'description' => 'COM_COMPONENTBUILDER_HERE_YOU_CAN_ENTER_THE_REPLACE_TEXT_THAT_YOU_WOULD_LIKE_TO_USE_AS_REPLACEMENT_FOR_THE_SEARCH_TEXT_FOUND', + 'filter' => 'RAW', + 'class' => 'replace-value span11', + 'hint' => 'COM_COMPONENTBUILDER_ENTER_YOUR_REPLACE_TEXT', + 'autocomplete' => true, + 'showon' => 'type_search:2', + 'default' => $this->urlvalues['replace_value']]; + // add to form + $xml = FormHelper::xml($attributes); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'search'); + } + + // Search Behaviour + $default = []; + if ($this->urlvalues['match_case'] == 1) + { + $default[] = 'match_case'; + } + if ($this->urlvalues['whole_word'] == 1) + { + $default[] = 'whole_word'; + } + if ($this->urlvalues['regex_search'] == 1) + { + $default[] = 'regex_search'; + } + $attributes = [ + 'type' => 'checkboxes', + 'name' => 'search_behaviour', + 'label' => 'COM_COMPONENTBUILDER_BEHAVIOUR', + 'description' => 'COM_COMPONENTBUILDER_SET_THE_SEARCH_BEHAVIOUR_HERE']; + if (ArrayHelper::check($default)) + { + $attributes['default'] = implode(',', $default); + } + // set the mode options + $options = [ + 'match_case' => 'COM_COMPONENTBUILDER_MATCH_CASE', + 'whole_word' => 'COM_COMPONENTBUILDER_WHOLE_WORD', + 'regex_search' => 'COM_COMPONENTBUILDER_REGEX_SEARCH']; + // add to form + $xml = FormHelper::xml($attributes, $options); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'settings'); + } + + // component attributes + $attributes = [ + 'type' => 'list', + 'name' => 'component_id', + 'label' => 'COM_COMPONENTBUILDER_COMPONENTS_BR_SMALLDISABLED_SOONSMALL', + 'class' => 'list_class', + 'description' => 'COM_COMPONENTBUILDER_SELECT_THE_COMPONENT_TO_SEARCH', + 'required' => 'true', + 'disable' => 'true', + 'readonly' => 'true', + 'default' => -1]; + // start the component options + $options = []; + $options['-1'] = 'COM_COMPONENTBUILDER__SEARCH_ALL_'; + // load component options from array + foreach($this->item['components'] as $component) + { + $options[(int) $component->id] = $this->escape($component->name); + } + // add to form + $xml = FormHelper::xml($attributes, $options); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'settings'); + } + + // table attributes + $attributes = [ + 'type' => 'list', + 'name' => 'table_name', + 'label' => 'COM_COMPONENTBUILDER_TABLES', + 'class' => 'list_class', + 'description' => 'COM_COMPONENTBUILDER_SELECT_THE_TABLE_TO_SEARCH', + 'required' => 'true', + 'default' => $this->urlvalues['table_name']]; + // start the component options + $options = []; + $options['-1'] = 'COM_COMPONENTBUILDER__SEARCH_ALL_'; + // load table options from array + foreach($this->item['tables'] as $table) + { + $options[$table] = $this->escape($table); + } + // add to form + $xml = FormHelper::xml($attributes, $options); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'settings'); + } + + // editor attributes + $attributes = [ + 'type' => 'editor', + 'name' => 'item_code', + 'label' => 'COM_COMPONENTBUILDER_ITEM_CODE', + 'width' => '100%', + 'height' => '150px', + 'class' => 'item_code_editor', + 'syntax' => 'php', + 'buttons' => 'false', + 'filter' => 'raw', + 'editor' => 'codemirror|none']; + // add to form + $xml = FormHelper::xml($attributes, $options); + if ($xml instanceof \SimpleXMLElement) + { + $form->setField($xml, null, true, 'view'); + } + + // return the form array + return $form; + } + + return null; + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + + // Only load jQuery if needed. (default is true) + if ($this->params->get('add_jquery_framework', 1) == 1) + { + Html::_('jquery.framework'); + } + // Load the header checker class. + // Initialize the header checker. + $HeaderCheck = new HeaderCheck(); + + // always load these files. + Html::_('stylesheet', "media/com_componentbuilder/datatable/css/datatables.min.css", ['version' => 'auto']); + Html::_('script', "media/com_componentbuilder/datatable/js/pdfmake.min.js", ['version' => 'auto']); + Html::_('script', "media/com_componentbuilder/datatable/js/vfs_fonts.js", ['version' => 'auto']); + Html::_('script', "media/com_componentbuilder/datatable/js/datatables.min.js", ['version' => 'auto']); + + // Add View JavaScript File + Html::_('script', "administrator/components/com_componentbuilder/assets/js/search.js", ['version' => 'auto']); + + // Load uikit options. + $uikit = $this->params->get('uikit_load'); + // Set script size. + $size = $this->params->get('uikit_min'); + // Set css style. + $style = $this->params->get('uikit_style'); + + // The uikit css. + if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) + { + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit'.$style.$size.'.css', ['version' => 'auto']); + } + // The uikit js. + if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) + { + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit'.$size.'.js', ['version' => 'auto']); + } + + // Load the script to find all uikit components needed. + if ($uikit != 2) + { + // Set the default uikit components in this view. + $uikitComp = []; + $uikitComp[] = 'UIkit.notify'; + $uikitComp[] = 'uk-progress'; + } + + // Load the needed uikit components in this view. + if ($uikit != 2 && isset($uikitComp) && ArrayHelper::check($uikitComp)) + { + // loading... + foreach ($uikitComp as $class) + { + foreach (ComponentbuilderHelper::$uk_components[$class] as $name) + { + // check if the CSS file exists. + if (File::exists(JPATH_ROOT.'/media/com_componentbuilder/uikit-v2/css/components/'.$name.$style.$size.'.css')) + { + // load the css. + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/'.$name.$style.$size.'.css', ['version' => 'auto']); + } + // check if the JavaScript file exists. + if (File::exists(JPATH_ROOT.'/media/com_componentbuilder/uikit-v2/js/components/'.$name.$size.'.js')) + { + // load the js. + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/'.$name.$size.'.js', ['version' => 'auto'], ['type' => 'text/javascript', 'async' => 'async']); + } + } + } + } + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + // hide the main menu + $this->app->input->set('hidemainmenu', true); + // set the title + if (isset($this->item->name) && $this->item->name) + { + $title = $this->item->name; + } + // Check for empty title and add view name if param is set + if (empty($title)) + { + $title = Text::_('COM_COMPONENTBUILDER_SEARCH'); + } + // add title to the page + ToolbarHelper::title($title,'search'); + // add cpanel button + ToolbarHelper::custom('search.dashboard', 'grid-2', '', 'COM_COMPONENTBUILDER_DASH', false); + if ($this->canDo->get('search.compiler')) + { + // add Compiler button. + ToolbarHelper::custom('search.openCompiler', 'cogs custom-button-opencompiler', '', 'COM_COMPONENTBUILDER_COMPILER', false); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('search'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = false, int $length = 40) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } +} diff --git a/admin/views/joomla_module_files_folders_urls/tmpl/index.html b/admin/src/View/Search/index.html similarity index 100% rename from admin/views/joomla_module_files_folders_urls/tmpl/index.html rename to admin/src/View/Search/index.html diff --git a/admin/src/View/Server/HtmlView.php b/admin/src/View/Server/HtmlView.php new file mode 100644 index 000000000..df9bfac5a --- /dev/null +++ b/admin/src/View/Server/HtmlView.php @@ -0,0 +1,230 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Server; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Server Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Server view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('server', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_SERVER_NEW' : 'COM_COMPONENTBUILDER_SERVER_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('server.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('server.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('server.edit')) + { + // We can save the record. + ToolbarHelper::save('server.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('server.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('server.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('server.create')) + { + ToolbarHelper::apply('server.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('server.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('server.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('server.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('server.edit')) + { + // We can save the new record + ToolbarHelper::apply('server.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('server.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('server.create')) + { + ToolbarHelper::custom('server.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('server.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('server.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.server', $this->item->id); + } + if ($this->canDo->get('server.create')) + { + ToolbarHelper::custom('server.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('server.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('server'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_SERVER_NEW' : 'COM_COMPONENTBUILDER_SERVER_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } +} diff --git a/admin/views/joomla_module_updates/tmpl/index.html b/admin/src/View/Server/index.html similarity index 100% rename from admin/views/joomla_module_updates/tmpl/index.html rename to admin/src/View/Server/index.html diff --git a/admin/src/View/Servers/HtmlView.php b/admin/src/View/Servers/HtmlView.php new file mode 100644 index 000000000..52e3ac2d0 --- /dev/null +++ b/admin/src/View/Servers/HtmlView.php @@ -0,0 +1,218 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Servers; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Servers + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Servers view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('server'); + $this->canEdit = $this->canDo->get('server.edit'); + $this->canState = $this->canDo->get('server.edit.state'); + $this->canCreate = $this->canDo->get('server.create'); + $this->canDelete = $this->canDo->get('server.delete'); + $this->canBatch = ($this->canDo->get('server.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_SERVERS'), 'flash'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('server.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('server.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('servers.publish'); + ToolbarHelper::unpublishList('servers.unpublish'); + ToolbarHelper::archiveList('servers.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('servers.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'servers.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('servers.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('servers'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_SERVERS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.name' => Text::_('COM_COMPONENTBUILDER_SERVER_NAME_LABEL'), + 'a.protocol' => Text::_('COM_COMPONENTBUILDER_SERVER_PROTOCOL_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/joomla_modules/index.html b/admin/src/View/Servers/index.html similarity index 100% rename from admin/views/joomla_modules/index.html rename to admin/src/View/Servers/index.html diff --git a/admin/src/View/Site_view/HtmlView.php b/admin/src/View/Site_view/HtmlView.php new file mode 100644 index 000000000..8e497e9e6 --- /dev/null +++ b/admin/src/View/Site_view/HtmlView.php @@ -0,0 +1,248 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Site_view; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Site_view Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Site_view view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('site_view', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_SITE_VIEW_NEW' : 'COM_COMPONENTBUILDER_SITE_VIEW_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('core.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('site_view.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('core.edit')) + { + // We can save the record. + ToolbarHelper::save('site_view.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('site_view.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('site_view.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('core.create')) + { + ToolbarHelper::apply('site_view.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('site_view.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('site_view.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('site_view.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('core.edit')) + { + // We can save the new record + ToolbarHelper::apply('site_view.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('site_view.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('core.create')) + { + ToolbarHelper::custom('site_view.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('site_view.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('core.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.site_view', $this->item->id); + } + if ($this->canDo->get('core.create')) + { + ToolbarHelper::custom('site_view.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('site_view.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('site_view'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_SITE_VIEW_NEW' : 'COM_COMPONENTBUILDER_SITE_VIEW_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + } +} diff --git a/admin/views/joomla_modules/tmpl/index.html b/admin/src/View/Site_view/index.html similarity index 100% rename from admin/views/joomla_modules/tmpl/index.html rename to admin/src/View/Site_view/index.html diff --git a/admin/src/View/Site_views/HtmlView.php b/admin/src/View/Site_views/HtmlView.php new file mode 100644 index 000000000..d8598185b --- /dev/null +++ b/admin/src/View/Site_views/HtmlView.php @@ -0,0 +1,226 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Site_views; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Site_views + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Site_views view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('site_view'); + $this->canEdit = $this->canDo->get('core.edit'); + $this->canState = $this->canDo->get('core.edit.state'); + $this->canCreate = $this->canDo->get('core.create'); + $this->canDelete = $this->canDo->get('core.delete'); + $this->canBatch = ($this->canDo->get('site_view.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_SITE_VIEWS'), 'palette'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('site_view.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('site_view.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('site_views.publish'); + ToolbarHelper::unpublishList('site_views.unpublish'); + ToolbarHelper::archiveList('site_views.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('site_views.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'site_views.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('site_views.trash'); + } + } + if ($this->user->authorise('site_view.get_snippets', 'com_componentbuilder')) + { + // add Get Snippets button. + ToolbarHelper::custom('site_views.getSnippets', 'search custom-button-getsnippets', '', 'COM_COMPONENTBUILDER_GET_SNIPPETS', false); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('site_views'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_SITE_VIEWS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.system_name' => Text::_('COM_COMPONENTBUILDER_SITE_VIEW_SYSTEM_NAME_LABEL'), + 'a.name' => Text::_('COM_COMPONENTBUILDER_SITE_VIEW_NAME_LABEL'), + 'a.description' => Text::_('COM_COMPONENTBUILDER_SITE_VIEW_DESCRIPTION_LABEL'), + 'g.name' => Text::_('COM_COMPONENTBUILDER_SITE_VIEW_MAIN_GET_LABEL'), + 'a.context' => Text::_('COM_COMPONENTBUILDER_SITE_VIEW_CONTEXT_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/joomla_modules_files_folders_urls/index.html b/admin/src/View/Site_views/index.html similarity index 100% rename from admin/views/joomla_modules_files_folders_urls/index.html rename to admin/src/View/Site_views/index.html diff --git a/admin/src/View/Snippet/HtmlView.php b/admin/src/View/Snippet/HtmlView.php new file mode 100644 index 000000000..047e3991e --- /dev/null +++ b/admin/src/View/Snippet/HtmlView.php @@ -0,0 +1,230 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Snippet; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Snippet Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Snippet view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('snippet', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_SNIPPET_NEW' : 'COM_COMPONENTBUILDER_SNIPPET_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('core.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('snippet.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('core.edit')) + { + // We can save the record. + ToolbarHelper::save('snippet.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('snippet.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('snippet.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('core.create')) + { + ToolbarHelper::apply('snippet.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('snippet.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('snippet.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('snippet.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('core.edit')) + { + // We can save the new record + ToolbarHelper::apply('snippet.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('snippet.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('core.create')) + { + ToolbarHelper::custom('snippet.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('snippet.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('core.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.snippet', $this->item->id); + } + if ($this->canDo->get('core.create')) + { + ToolbarHelper::custom('snippet.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('snippet.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('snippet'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_SNIPPET_NEW' : 'COM_COMPONENTBUILDER_SNIPPET_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } +} diff --git a/admin/views/joomla_modules_files_folders_urls/tmpl/index.html b/admin/src/View/Snippet/index.html similarity index 100% rename from admin/views/joomla_modules_files_folders_urls/tmpl/index.html rename to admin/src/View/Snippet/index.html diff --git a/admin/src/View/Snippet_type/HtmlView.php b/admin/src/View/Snippet_type/HtmlView.php new file mode 100644 index 000000000..d0292f157 --- /dev/null +++ b/admin/src/View/Snippet_type/HtmlView.php @@ -0,0 +1,230 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Snippet_type; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Snippet_type Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Snippet_type view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('snippet_type', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_SNIPPET_TYPE_NEW' : 'COM_COMPONENTBUILDER_SNIPPET_TYPE_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('snippet_type.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('snippet_type.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('snippet_type.edit')) + { + // We can save the record. + ToolbarHelper::save('snippet_type.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('snippet_type.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('snippet_type.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('snippet_type.create')) + { + ToolbarHelper::apply('snippet_type.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('snippet_type.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('snippet_type.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('snippet_type.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('snippet_type.edit')) + { + // We can save the new record + ToolbarHelper::apply('snippet_type.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('snippet_type.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('snippet_type.create')) + { + ToolbarHelper::custom('snippet_type.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('snippet_type.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('snippet_type.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.snippet_type', $this->item->id); + } + if ($this->canDo->get('snippet_type.create')) + { + ToolbarHelper::custom('snippet_type.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('snippet_type.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('snippet_type'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_SNIPPET_TYPE_NEW' : 'COM_COMPONENTBUILDER_SNIPPET_TYPE_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } +} diff --git a/admin/views/joomla_modules_updates/index.html b/admin/src/View/Snippet_type/index.html similarity index 100% rename from admin/views/joomla_modules_updates/index.html rename to admin/src/View/Snippet_type/index.html diff --git a/admin/src/View/Snippet_types/HtmlView.php b/admin/src/View/Snippet_types/HtmlView.php new file mode 100644 index 000000000..1a021bf00 --- /dev/null +++ b/admin/src/View/Snippet_types/HtmlView.php @@ -0,0 +1,218 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Snippet_types; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Snippet_types + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Snippet_types view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('snippet_type'); + $this->canEdit = $this->canDo->get('snippet_type.edit'); + $this->canState = $this->canDo->get('snippet_type.edit.state'); + $this->canCreate = $this->canDo->get('snippet_type.create'); + $this->canDelete = $this->canDo->get('snippet_type.delete'); + $this->canBatch = ($this->canDo->get('snippet_type.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_SNIPPET_TYPES'), 'joomla'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('snippet_type.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('snippet_type.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('snippet_types.publish'); + ToolbarHelper::unpublishList('snippet_types.unpublish'); + ToolbarHelper::archiveList('snippet_types.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('snippet_types.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'snippet_types.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('snippet_types.trash'); + } + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('snippet_types'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_SNIPPET_TYPES')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.name' => Text::_('COM_COMPONENTBUILDER_SNIPPET_TYPE_NAME_LABEL'), + 'a.description' => Text::_('COM_COMPONENTBUILDER_SNIPPET_TYPE_DESCRIPTION_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/joomla_modules_updates/tmpl/index.html b/admin/src/View/Snippet_types/index.html similarity index 100% rename from admin/views/joomla_modules_updates/tmpl/index.html rename to admin/src/View/Snippet_types/index.html diff --git a/admin/src/View/Snippets/HtmlView.php b/admin/src/View/Snippets/HtmlView.php new file mode 100644 index 000000000..5c99ce54b --- /dev/null +++ b/admin/src/View/Snippets/HtmlView.php @@ -0,0 +1,231 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Snippets; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Snippets + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Snippets view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('snippet'); + $this->canEdit = $this->canDo->get('core.edit'); + $this->canState = $this->canDo->get('core.edit.state'); + $this->canCreate = $this->canDo->get('core.create'); + $this->canDelete = $this->canDo->get('core.delete'); + $this->canBatch = ($this->canDo->get('snippet.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_SNIPPETS'), 'pin'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('snippet.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('snippet.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('snippets.publish'); + ToolbarHelper::unpublishList('snippets.unpublish'); + ToolbarHelper::archiveList('snippets.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('snippets.checkin'); + } + } + if ($this->user->authorise('snippet.share_snippets', 'com_componentbuilder')) + { + // add Share Snippets button. + ToolbarHelper::custom('snippets.shareSnippets', 'share custom-button-sharesnippets', '', 'COM_COMPONENTBUILDER_SHARE_SNIPPETS', 'true'); + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'snippets.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('snippets.trash'); + } + } + if ($this->user->authorise('snippet.get_snippets', 'com_componentbuilder')) + { + // add Get Snippets button. + ToolbarHelper::custom('snippets.getSnippets', 'search custom-button-getsnippets', '', 'COM_COMPONENTBUILDER_GET_SNIPPETS', false); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('snippets'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_SNIPPETS')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.name' => Text::_('COM_COMPONENTBUILDER_SNIPPET_NAME_LABEL'), + 'a.url' => Text::_('COM_COMPONENTBUILDER_SNIPPET_URL_LABEL'), + 'g.name' => Text::_('COM_COMPONENTBUILDER_SNIPPET_TYPE_LABEL'), + 'a.heading' => Text::_('COM_COMPONENTBUILDER_SNIPPET_HEADING_LABEL'), + 'h.name' => Text::_('COM_COMPONENTBUILDER_SNIPPET_LIBRARY_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/joomla_plugin/tmpl/index.html b/admin/src/View/Snippets/index.html similarity index 100% rename from admin/views/joomla_plugin/tmpl/index.html rename to admin/src/View/Snippets/index.html diff --git a/admin/src/View/Template/HtmlView.php b/admin/src/View/Template/HtmlView.php new file mode 100644 index 000000000..3854e8a93 --- /dev/null +++ b/admin/src/View/Template/HtmlView.php @@ -0,0 +1,248 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Template; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Template Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Template view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('template', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_TEMPLATE_NEW' : 'COM_COMPONENTBUILDER_TEMPLATE_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('core.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('template.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('core.edit')) + { + // We can save the record. + ToolbarHelper::save('template.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('template.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('template.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('core.create')) + { + ToolbarHelper::apply('template.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('template.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('template.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('template.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('core.edit')) + { + // We can save the new record + ToolbarHelper::apply('template.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('template.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('core.create')) + { + ToolbarHelper::custom('template.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('template.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('core.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.template', $this->item->id); + } + if ($this->canDo->get('core.create')) + { + ToolbarHelper::custom('template.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('template.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('template'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_TEMPLATE_NEW' : 'COM_COMPONENTBUILDER_TEMPLATE_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + } +} diff --git a/admin/views/joomla_plugin_files_folders_urls/tmpl/index.html b/admin/src/View/Template/index.html similarity index 100% rename from admin/views/joomla_plugin_files_folders_urls/tmpl/index.html rename to admin/src/View/Template/index.html diff --git a/admin/src/View/Templates/HtmlView.php b/admin/src/View/Templates/HtmlView.php new file mode 100644 index 000000000..9d5854704 --- /dev/null +++ b/admin/src/View/Templates/HtmlView.php @@ -0,0 +1,224 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Templates; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Templates + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Templates view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('template'); + $this->canEdit = $this->canDo->get('core.edit'); + $this->canState = $this->canDo->get('core.edit.state'); + $this->canCreate = $this->canDo->get('core.create'); + $this->canDelete = $this->canDo->get('core.delete'); + $this->canBatch = ($this->canDo->get('template.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_TEMPLATES'), 'brush'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('template.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('template.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('templates.publish'); + ToolbarHelper::unpublishList('templates.unpublish'); + ToolbarHelper::archiveList('templates.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('templates.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'templates.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('templates.trash'); + } + } + if ($this->user->authorise('template.get_snippets', 'com_componentbuilder')) + { + // add Get Snippets button. + ToolbarHelper::custom('templates.getSnippets', 'search custom-button-getsnippets', '', 'COM_COMPONENTBUILDER_GET_SNIPPETS', false); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('templates'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_TEMPLATES')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.name' => Text::_('COM_COMPONENTBUILDER_TEMPLATE_NAME_LABEL'), + 'a.description' => Text::_('COM_COMPONENTBUILDER_TEMPLATE_DESCRIPTION_LABEL'), + 'g.name' => Text::_('COM_COMPONENTBUILDER_TEMPLATE_DYNAMIC_GET_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/joomla_plugin_group/tmpl/index.html b/admin/src/View/Templates/index.html similarity index 100% rename from admin/views/joomla_plugin_group/tmpl/index.html rename to admin/src/View/Templates/index.html diff --git a/admin/src/View/Validation_rule/HtmlView.php b/admin/src/View/Validation_rule/HtmlView.php new file mode 100644 index 000000000..7e7dfbcea --- /dev/null +++ b/admin/src/View/Validation_rule/HtmlView.php @@ -0,0 +1,251 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Validation_rule; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Validation_rule Html View class + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Validation_rule view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // set params + $this->params = ComponentHelper::getParams('com_componentbuilder'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = ComponentbuilderHelper::getActions('validation_rule', $this->item); + // get input + $jinput = Factory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string) $this->ref . '&refid=' . (int) $this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string) $this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string) $return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getApplication()->getIdentity(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_VALIDATION_RULE_NEW' : 'COM_COMPONENTBUILDER_VALIDATION_RULE_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (StringHelper::check($this->referral)) + { + if ($this->canDo->get('validation_rule.create') && $isNew) + { + // We can create the record. + ToolbarHelper::save('validation_rule.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('validation_rule.edit')) + { + // We can save the record. + ToolbarHelper::save('validation_rule.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + ToolbarHelper::cancel('validation_rule.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + ToolbarHelper::cancel('validation_rule.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('validation_rule.create')) + { + ToolbarHelper::apply('validation_rule.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('validation_rule.save', 'JTOOLBAR_SAVE'); + ToolbarHelper::custom('validation_rule.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + ToolbarHelper::cancel('validation_rule.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('validation_rule.edit')) + { + // We can save the new record + ToolbarHelper::apply('validation_rule.apply', 'JTOOLBAR_APPLY'); + ToolbarHelper::save('validation_rule.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('validation_rule.create')) + { + ToolbarHelper::custom('validation_rule.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('validation_rule.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('validation_rule.edit') && $canVersion) + { + ToolbarHelper::versions('com_componentbuilder.validation_rule', $this->item->id); + } + if ($this->canDo->get('validation_rule.create')) + { + ToolbarHelper::custom('validation_rule.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + ToolbarHelper::cancel('validation_rule.cancel', 'JTOOLBAR_CLOSE'); + } + } + ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('validation_rule'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 30) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $isNew = ($this->item->id < 1); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_VALIDATION_RULE_NEW' : 'COM_COMPONENTBUILDER_VALIDATION_RULE_EDIT')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // Add Ajax Token + $this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + + + // add the Uikit v2 style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']); + + // add the Uikit v2 extra style sheets + Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']); + // add Uikit v2 extra JavaScripts + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']); + Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']); + // add var key + $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); + // add return_here + $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) \JUri::getInstance())) . "';"); + // need to add some language strings + Text::script('COM_COMPONENTBUILDER_VALIDATION_RULE_NAME_ALREADY_TAKEN_PLEASE_TRY_AGAIN'); + Text::script('COM_COMPONENTBUILDER_YOU_MUST_ADD_AN_UNIQUE_VALIDATION_RULE_NAME'); + } +} diff --git a/admin/views/joomla_plugin_groups/index.html b/admin/src/View/Validation_rule/index.html similarity index 100% rename from admin/views/joomla_plugin_groups/index.html rename to admin/src/View/Validation_rule/index.html diff --git a/admin/src/View/Validation_rules/HtmlView.php b/admin/src/View/Validation_rules/HtmlView.php new file mode 100644 index 000000000..f3cb4f5af --- /dev/null +++ b/admin/src/View/Validation_rules/HtmlView.php @@ -0,0 +1,223 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +namespace VDM\Component\Componentbuilder\Administrator\View\Validation_rules; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +\defined('_JEXEC') or die; + +/** + * Componentbuilder Html View class for the Validation_rules + * + * @since 1.6 + */ +class HtmlView extends BaseHtmlView +{ + /** + * Validation_rules view display method + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return void + * @since 1.6 + */ + public function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->styles = $this->get('Styles'); + $this->scripts = $this->get('Scripts'); + $this->user ??= Factory::getApplication()->getIdentity(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + // get global action permissions + $this->canDo = ComponentbuilderHelper::getActions('validation_rule'); + $this->canEdit = $this->canDo->get('validation_rule.edit'); + $this->canState = $this->canDo->get('validation_rule.edit.state'); + $this->canCreate = $this->canDo->get('validation_rule.create'); + $this->canDelete = $this->canDo->get('validation_rule.delete'); + $this->canBatch = ($this->canDo->get('validation_rule.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \Exception(implode("\n", $errors), 500); + } + + // Set the html view document stuff + $this->_prepareDocument(); + + // Display the template + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * @since 1.6 + */ + protected function addToolbar(): void + { + ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_VALIDATION_RULES'), 'shield'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('validation_rule.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('validation_rule.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('validation_rules.publish'); + ToolbarHelper::unpublishList('validation_rules.unpublish'); + ToolbarHelper::archiveList('validation_rules.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('validation_rules.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'validation_rules.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('validation_rules.trash'); + } + } + if ($this->user->authorise('validation_rule.run_expansion', 'com_componentbuilder')) + { + // add Run Expansion button. + ToolbarHelper::custom('validation_rules.runExpansion', 'expand-2 custom-button-runexpansion', '', 'COM_COMPONENTBUILDER_RUN_EXPANSION', false); + } + + // set help url for this view if found + $this->help_url = ComponentbuilderHelper::getHelpUrl('validation_rules'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + ToolbarHelper::preferences('com_componentbuilder'); + } + } + + /** + * Prepare some document related stuff. + * + * @return void + * @since 1.6 + */ + protected function _prepareDocument(): void + { + // Load jQuery + Html::_('jquery.framework'); + $this->getDocument()->setTitle(Text::_('COM_COMPONENTBUILDER_VALIDATION_RULES')); + // add styles + foreach ($this->styles as $style) + { + Html::_('stylesheet', $style, ['version' => 'auto']); + } + // add scripts + foreach ($this->scripts as $script) + { + Html::_('script', $script, ['version' => 'auto']); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * @param bool $shorten The switch to shorten. + * @param int $length The shorting length. + * + * @return mixed The escaped value. + * @since 1.6 + */ + public function escape($var, bool $shorten = true, int $length = 50) + { + if (!is_string($var)) + { + return $var; + } + + return StringHelper::html($var, $this->_charset ?? 'UTF-8', $shorten, $length); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array containing the field name to sort by as the key and display text as value + * @since 1.6 + */ + protected function getSortFields() + { + return array( + 'a.ordering' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.name' => Text::_('COM_COMPONENTBUILDER_VALIDATION_RULE_NAME_LABEL'), + 'a.short_description' => Text::_('COM_COMPONENTBUILDER_VALIDATION_RULE_SHORT_DESCRIPTION_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/joomla_plugin_groups/tmpl/index.html b/admin/src/View/Validation_rules/index.html similarity index 100% rename from admin/views/joomla_plugin_groups/tmpl/index.html rename to admin/src/View/Validation_rules/index.html diff --git a/admin/views/joomla_plugin_updates/tmpl/index.html b/admin/src/View/index.html similarity index 100% rename from admin/views/joomla_plugin_updates/tmpl/index.html rename to admin/src/View/index.html diff --git a/admin/views/joomla_plugins/index.html b/admin/src/index.html similarity index 100% rename from admin/views/joomla_plugins/index.html rename to admin/src/index.html diff --git a/admin/tables/admin_custom_tabs.php b/admin/tables/admin_custom_tabs.php deleted file mode 100644 index ecfc44dfa..000000000 --- a/admin/tables/admin_custom_tabs.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Admins_custom_tabs Table class - */ -class ComponentbuilderTableAdmin_custom_tabs extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_admin_custom_tabs', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.admin_custom_tabs')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Admin_custom_tabs table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New admin_custom_tabs. A admin_custom_tabs created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('admin_custom_tabs', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('admin_custom_tabs', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.admin_custom_tabs.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.admin_custom_tabs.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/admin_fields.php b/admin/tables/admin_fields.php deleted file mode 100644 index ab1f66067..000000000 --- a/admin/tables/admin_fields.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Admins_fields Table class - */ -class ComponentbuilderTableAdmin_fields extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_admin_fields', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.admin_fields')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Admin_fields table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New admin_fields. A admin_fields created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('admin_fields', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_ADMIN_FIELDS_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('admin_fields', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.admin_fields.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.admin_fields.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/admin_fields_conditions.php b/admin/tables/admin_fields_conditions.php deleted file mode 100644 index 01806f6be..000000000 --- a/admin/tables/admin_fields_conditions.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Admins_fields_conditions Table class - */ -class ComponentbuilderTableAdmin_fields_conditions extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_admin_fields_conditions', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.admin_fields_conditions')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Admin_fields_conditions table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New admin_fields_conditions. A admin_fields_conditions created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('admin_fields_conditions', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('admin_fields_conditions', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.admin_fields_conditions.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.admin_fields_conditions.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/admin_fields_relations.php b/admin/tables/admin_fields_relations.php deleted file mode 100644 index 5d9dc7a3d..000000000 --- a/admin/tables/admin_fields_relations.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Admins_fields_relations Table class - */ -class ComponentbuilderTableAdmin_fields_relations extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_admin_fields_relations', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.admin_fields_relations')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Admin_fields_relations table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New admin_fields_relations. A admin_fields_relations created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('admin_fields_relations', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('admin_fields_relations', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.admin_fields_relations.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.admin_fields_relations.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/admin_view.php b/admin/tables/admin_view.php deleted file mode 100644 index da8f8463b..000000000 --- a/admin/tables/admin_view.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Admin_views Table class - */ -class ComponentbuilderTableAdmin_view extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_admin_view', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.admin_view')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Admin_view table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New admin_view. A admin_view created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('admin_view', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_ADMIN_VIEW_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('admin_view', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.admin_view.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.admin_view.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/class_extends.php b/admin/tables/class_extends.php deleted file mode 100644 index cb6f084fd..000000000 --- a/admin/tables/class_extends.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Class_extendings Table class - */ -class ComponentbuilderTableClass_extends extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_class_extends', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.class_extends')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Class_extends table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New class_extends. A class_extends created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('class_extends', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_CLASS_EXTENDS_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('class_extends', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.class_extends.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.class_extends.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/class_method.php b/admin/tables/class_method.php deleted file mode 100644 index 01e179ca2..000000000 --- a/admin/tables/class_method.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Class_methods Table class - */ -class ComponentbuilderTableClass_method extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_class_method', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.class_method')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Class_method table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New class_method. A class_method created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('class_method', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_CLASS_METHOD_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('class_method', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.class_method.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.class_method.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/class_property.php b/admin/tables/class_property.php deleted file mode 100644 index 632e06b83..000000000 --- a/admin/tables/class_property.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Class_properties Table class - */ -class ComponentbuilderTableClass_property extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_class_property', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.class_property')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Class_property table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New class_property. A class_property created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('class_property', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_CLASS_PROPERTY_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('class_property', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.class_property.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.class_property.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/component_admin_views.php b/admin/tables/component_admin_views.php deleted file mode 100644 index 9a655fa0b..000000000 --- a/admin/tables/component_admin_views.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_admin_views Table class - */ -class ComponentbuilderTableComponent_admin_views extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_component_admin_views', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.component_admin_views')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Component_admin_views table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New component_admin_views. A component_admin_views created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('component_admin_views', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('component_admin_views', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.component_admin_views.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.component_admin_views.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/component_config.php b/admin/tables/component_config.php deleted file mode 100644 index 7893f4009..000000000 --- a/admin/tables/component_config.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_config Table class - */ -class ComponentbuilderTableComponent_config extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_component_config', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.component_config')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Component_config table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New component_config. A component_config created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('component_config', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_COMPONENT_CONFIG_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('component_config', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.component_config.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.component_config.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/component_custom_admin_menus.php b/admin/tables/component_custom_admin_menus.php deleted file mode 100644 index 839a6647f..000000000 --- a/admin/tables/component_custom_admin_menus.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_custom_admin_menus Table class - */ -class ComponentbuilderTableComponent_custom_admin_menus extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_component_custom_admin_menus', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.component_custom_admin_menus')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Component_custom_admin_menus table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New component_custom_admin_menus. A component_custom_admin_menus created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('component_custom_admin_menus', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('component_custom_admin_menus', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.component_custom_admin_menus.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.component_custom_admin_menus.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/component_custom_admin_views.php b/admin/tables/component_custom_admin_views.php deleted file mode 100644 index fada7ce5b..000000000 --- a/admin/tables/component_custom_admin_views.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_custom_admin_views Table class - */ -class ComponentbuilderTableComponent_custom_admin_views extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_component_custom_admin_views', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.component_custom_admin_views')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Component_custom_admin_views table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New component_custom_admin_views. A component_custom_admin_views created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('component_custom_admin_views', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('component_custom_admin_views', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.component_custom_admin_views.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.component_custom_admin_views.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/component_dashboard.php b/admin/tables/component_dashboard.php deleted file mode 100644 index ccf0800c1..000000000 --- a/admin/tables/component_dashboard.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_dashboard Table class - */ -class ComponentbuilderTableComponent_dashboard extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_component_dashboard', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.component_dashboard')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Component_dashboard table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New component_dashboard. A component_dashboard created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('component_dashboard', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('component_dashboard', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.component_dashboard.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.component_dashboard.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/component_files_folders.php b/admin/tables/component_files_folders.php deleted file mode 100644 index c71309592..000000000 --- a/admin/tables/component_files_folders.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_files_folders Table class - */ -class ComponentbuilderTableComponent_files_folders extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_component_files_folders', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.component_files_folders')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Component_files_folders table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New component_files_folders. A component_files_folders created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('component_files_folders', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('component_files_folders', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.component_files_folders.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.component_files_folders.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/component_modules.php b/admin/tables/component_modules.php deleted file mode 100644 index 86a664472..000000000 --- a/admin/tables/component_modules.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_modules Table class - */ -class ComponentbuilderTableComponent_modules extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_component_modules', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.component_modules')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Component_modules table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New component_modules. A component_modules created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('component_modules', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_COMPONENT_MODULES_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('component_modules', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.component_modules.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.component_modules.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/component_mysql_tweaks.php b/admin/tables/component_mysql_tweaks.php deleted file mode 100644 index b68f15a17..000000000 --- a/admin/tables/component_mysql_tweaks.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_mysql_tweaks Table class - */ -class ComponentbuilderTableComponent_mysql_tweaks extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_component_mysql_tweaks', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.component_mysql_tweaks')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Component_mysql_tweaks table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New component_mysql_tweaks. A component_mysql_tweaks created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('component_mysql_tweaks', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('component_mysql_tweaks', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.component_mysql_tweaks.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.component_mysql_tweaks.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/component_placeholders.php b/admin/tables/component_placeholders.php deleted file mode 100644 index b83af5f40..000000000 --- a/admin/tables/component_placeholders.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_placeholders Table class - */ -class ComponentbuilderTableComponent_placeholders extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_component_placeholders', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.component_placeholders')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Component_placeholders table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New component_placeholders. A component_placeholders created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('component_placeholders', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('component_placeholders', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.component_placeholders.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.component_placeholders.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/component_plugins.php b/admin/tables/component_plugins.php deleted file mode 100644 index d861dd74d..000000000 --- a/admin/tables/component_plugins.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_plugins Table class - */ -class ComponentbuilderTableComponent_plugins extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_component_plugins', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.component_plugins')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Component_plugins table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New component_plugins. A component_plugins created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('component_plugins', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_COMPONENT_PLUGINS_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('component_plugins', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.component_plugins.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.component_plugins.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/component_site_views.php b/admin/tables/component_site_views.php deleted file mode 100644 index b833b7196..000000000 --- a/admin/tables/component_site_views.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_site_views Table class - */ -class ComponentbuilderTableComponent_site_views extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_component_site_views', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.component_site_views')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Component_site_views table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New component_site_views. A component_site_views created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('component_site_views', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('component_site_views', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.component_site_views.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.component_site_views.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/component_updates.php b/admin/tables/component_updates.php deleted file mode 100644 index 01c57ed10..000000000 --- a/admin/tables/component_updates.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Components_updates Table class - */ -class ComponentbuilderTableComponent_updates extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_component_updates', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.component_updates')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Component_updates table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New component_updates. A component_updates created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('component_updates', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_COMPONENT_UPDATES_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('component_updates', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.component_updates.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.component_updates.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/custom_admin_view.php b/admin/tables/custom_admin_view.php deleted file mode 100644 index 28a76d3ff..000000000 --- a/admin/tables/custom_admin_view.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Custom_admin_views Table class - */ -class ComponentbuilderTableCustom_admin_view extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_custom_admin_view', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.custom_admin_view')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Custom_admin_view table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New custom_admin_view. A custom_admin_view created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('custom_admin_view', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('custom_admin_view', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.custom_admin_view.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.custom_admin_view.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/custom_code.php b/admin/tables/custom_code.php deleted file mode 100644 index a93c6f998..000000000 --- a/admin/tables/custom_code.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Custom_codes Table class - */ -class ComponentbuilderTableCustom_code extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_custom_code', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.custom_code')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Custom_code table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New custom_code. A custom_code created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('custom_code', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_CUSTOM_CODE_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('custom_code', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.custom_code.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.custom_code.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/dynamic_get.php b/admin/tables/dynamic_get.php deleted file mode 100644 index b25e61c35..000000000 --- a/admin/tables/dynamic_get.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Dynamic_gets Table class - */ -class ComponentbuilderTableDynamic_get extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_dynamic_get', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.dynamic_get')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Dynamic_get table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New dynamic_get. A dynamic_get created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('dynamic_get', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_DYNAMIC_GET_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('dynamic_get', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.dynamic_get.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.dynamic_get.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/field.php b/admin/tables/field.php deleted file mode 100644 index 4161923ce..000000000 --- a/admin/tables/field.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Fields Table class - */ -class ComponentbuilderTableField extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_field', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.field')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Field table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New field. A field created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('field', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_FIELD_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('field', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.field.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.field.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/fieldtype.php b/admin/tables/fieldtype.php deleted file mode 100644 index 2fbd152c2..000000000 --- a/admin/tables/fieldtype.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Fieldtypes Table class - */ -class ComponentbuilderTableFieldtype extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_fieldtype', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.fieldtype')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Fieldtype table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New fieldtype. A fieldtype created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('fieldtype', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_FIELDTYPE_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('fieldtype', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.fieldtype.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.fieldtype.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/help_document.php b/admin/tables/help_document.php deleted file mode 100644 index deb548887..000000000 --- a/admin/tables/help_document.php +++ /dev/null @@ -1,337 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Help_documents Table class - */ -class ComponentbuilderTableHelp_document extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_help_document', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.help_document')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Help_document table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New help_document. A help_document created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('help_document', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('help_document', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.help_document.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.help_document.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * Generate a valid alias from title / date. - * Remains public to be able to check for duplicated alias before saving - * - * @return string - */ - public function generateAlias() - { - if (empty($this->alias)) - { - $this->alias = $this->title; - } - - $this->alias = JApplicationHelper::stringURLSafe($this->alias); - - if (trim(str_replace('-', '', $this->alias)) == '') - { - $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s'); - } - - return $this->alias; - } - -} diff --git a/admin/tables/joomla_component.php b/admin/tables/joomla_component.php deleted file mode 100644 index 19c081019..000000000 --- a/admin/tables/joomla_component.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_components Table class - */ -class ComponentbuilderTableJoomla_component extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_joomla_component', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.joomla_component')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Joomla_component table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New joomla_component. A joomla_component created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('joomla_component', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('joomla_component', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.joomla_component.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.joomla_component.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/joomla_module.php b/admin/tables/joomla_module.php deleted file mode 100644 index 36d3e8b44..000000000 --- a/admin/tables/joomla_module.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_modules Table class - */ -class ComponentbuilderTableJoomla_module extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_joomla_module', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.joomla_module')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Joomla_module table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New joomla_module. A joomla_module created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('joomla_module', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_JOOMLA_MODULE_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('joomla_module', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.joomla_module.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.joomla_module.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/joomla_module_files_folders_urls.php b/admin/tables/joomla_module_files_folders_urls.php deleted file mode 100644 index decc60e82..000000000 --- a/admin/tables/joomla_module_files_folders_urls.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_modules_files_folders_urls Table class - */ -class ComponentbuilderTableJoomla_module_files_folders_urls extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_joomla_module_files_folders_urls', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.joomla_module_files_folders_urls')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Joomla_module_files_folders_urls table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New joomla_module_files_folders_urls. A joomla_module_files_folders_urls created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('joomla_module_files_folders_urls', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('joomla_module_files_folders_urls', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.joomla_module_files_folders_urls.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.joomla_module_files_folders_urls.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/joomla_module_updates.php b/admin/tables/joomla_module_updates.php deleted file mode 100644 index a266666ef..000000000 --- a/admin/tables/joomla_module_updates.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_modules_updates Table class - */ -class ComponentbuilderTableJoomla_module_updates extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_joomla_module_updates', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.joomla_module_updates')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Joomla_module_updates table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New joomla_module_updates. A joomla_module_updates created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('joomla_module_updates', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('joomla_module_updates', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.joomla_module_updates.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.joomla_module_updates.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/joomla_plugin.php b/admin/tables/joomla_plugin.php deleted file mode 100644 index 14d118601..000000000 --- a/admin/tables/joomla_plugin.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_plugins Table class - */ -class ComponentbuilderTableJoomla_plugin extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_joomla_plugin', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.joomla_plugin')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Joomla_plugin table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New joomla_plugin. A joomla_plugin created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('joomla_plugin', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('joomla_plugin', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.joomla_plugin.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.joomla_plugin.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/joomla_plugin_files_folders_urls.php b/admin/tables/joomla_plugin_files_folders_urls.php deleted file mode 100644 index 50210cde2..000000000 --- a/admin/tables/joomla_plugin_files_folders_urls.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_plugins_files_folders_urls Table class - */ -class ComponentbuilderTableJoomla_plugin_files_folders_urls extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_joomla_plugin_files_folders_urls', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.joomla_plugin_files_folders_urls')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Joomla_plugin_files_folders_urls table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New joomla_plugin_files_folders_urls. A joomla_plugin_files_folders_urls created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('joomla_plugin_files_folders_urls', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('joomla_plugin_files_folders_urls', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.joomla_plugin_files_folders_urls.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.joomla_plugin_files_folders_urls.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/joomla_plugin_group.php b/admin/tables/joomla_plugin_group.php deleted file mode 100644 index 0bfe96a3c..000000000 --- a/admin/tables/joomla_plugin_group.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_plugin_groups Table class - */ -class ComponentbuilderTableJoomla_plugin_group extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_joomla_plugin_group', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.joomla_plugin_group')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Joomla_plugin_group table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New joomla_plugin_group. A joomla_plugin_group created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('joomla_plugin_group', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('joomla_plugin_group', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.joomla_plugin_group.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.joomla_plugin_group.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/joomla_plugin_updates.php b/admin/tables/joomla_plugin_updates.php deleted file mode 100644 index 770333de4..000000000 --- a/admin/tables/joomla_plugin_updates.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Joomla_plugins_updates Table class - */ -class ComponentbuilderTableJoomla_plugin_updates extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_joomla_plugin_updates', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.joomla_plugin_updates')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Joomla_plugin_updates table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New joomla_plugin_updates. A joomla_plugin_updates created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('joomla_plugin_updates', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('joomla_plugin_updates', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.joomla_plugin_updates.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.joomla_plugin_updates.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/language.php b/admin/tables/language.php deleted file mode 100644 index 1b81f6007..000000000 --- a/admin/tables/language.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Languages Table class - */ -class ComponentbuilderTableLanguage extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_language', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.language')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Language table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New language. A language created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('language', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_LANGUAGE_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('language', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.language.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.language.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/language_translation.php b/admin/tables/language_translation.php deleted file mode 100644 index c8bd8a6bd..000000000 --- a/admin/tables/language_translation.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Language_translations Table class - */ -class ComponentbuilderTableLanguage_translation extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_language_translation', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.language_translation')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Language_translation table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New language_translation. A language_translation created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('language_translation', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('language_translation', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.language_translation.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.language_translation.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/layout.php b/admin/tables/layout.php deleted file mode 100644 index 1ec121893..000000000 --- a/admin/tables/layout.php +++ /dev/null @@ -1,337 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Layouts Table class - */ -class ComponentbuilderTableLayout extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_layout', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.layout')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Layout table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New layout. A layout created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('layout', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_LAYOUT_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('layout', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.layout.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.layout.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * Generate a valid alias from title / date. - * Remains public to be able to check for duplicated alias before saving - * - * @return string - */ - public function generateAlias() - { - if (empty($this->alias)) - { - $this->alias = $this->name; - } - - $this->alias = JApplicationHelper::stringURLSafe($this->alias); - - if (trim(str_replace('-', '', $this->alias)) == '') - { - $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s'); - } - - return $this->alias; - } - -} diff --git a/admin/tables/library.php b/admin/tables/library.php deleted file mode 100644 index b476df994..000000000 --- a/admin/tables/library.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Libraries Table class - */ -class ComponentbuilderTableLibrary extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_library', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.library')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Library table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New library. A library created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('library', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_LIBRARY_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('library', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.library.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.library.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/library_config.php b/admin/tables/library_config.php deleted file mode 100644 index e1260aa42..000000000 --- a/admin/tables/library_config.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Libraries_config Table class - */ -class ComponentbuilderTableLibrary_config extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_library_config', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.library_config')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Library_config table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New library_config. A library_config created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('library_config', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_LIBRARY_CONFIG_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('library_config', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.library_config.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.library_config.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/library_files_folders_urls.php b/admin/tables/library_files_folders_urls.php deleted file mode 100644 index 4c8aeaf2a..000000000 --- a/admin/tables/library_files_folders_urls.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Libraries_files_folders_urls Table class - */ -class ComponentbuilderTableLibrary_files_folders_urls extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_library_files_folders_urls', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.library_files_folders_urls')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Library_files_folders_urls table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New library_files_folders_urls. A library_files_folders_urls created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('library_files_folders_urls', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('library_files_folders_urls', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.library_files_folders_urls.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.library_files_folders_urls.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/placeholder.php b/admin/tables/placeholder.php deleted file mode 100644 index d5c519b34..000000000 --- a/admin/tables/placeholder.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Placeholders Table class - */ -class ComponentbuilderTablePlaceholder extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_placeholder', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.placeholder')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Placeholder table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New placeholder. A placeholder created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('placeholder', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_PLACEHOLDER_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('placeholder', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.placeholder.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.placeholder.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/power.php b/admin/tables/power.php deleted file mode 100644 index 870895317..000000000 --- a/admin/tables/power.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Powers Table class - */ -class ComponentbuilderTablePower extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_power', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.power')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Power table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New power. A power created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('power', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_POWER_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('power', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.power.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.power.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/server.php b/admin/tables/server.php deleted file mode 100644 index bc2628a01..000000000 --- a/admin/tables/server.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Servers Table class - */ -class ComponentbuilderTableServer extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_server', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.server')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Server table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New server. A server created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('server', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_SERVER_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('server', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.server.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.server.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/site_view.php b/admin/tables/site_view.php deleted file mode 100644 index f7cb9e369..000000000 --- a/admin/tables/site_view.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Site_views Table class - */ -class ComponentbuilderTableSite_view extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_site_view', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.site_view')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Site_view table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New site_view. A site_view created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('site_view', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_SITE_VIEW_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('site_view', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.site_view.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.site_view.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/snippet.php b/admin/tables/snippet.php deleted file mode 100644 index 65afde210..000000000 --- a/admin/tables/snippet.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Snippets Table class - */ -class ComponentbuilderTableSnippet extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_snippet', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.snippet')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Snippet table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New snippet. A snippet created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('snippet', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_SNIPPET_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('snippet', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.snippet.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.snippet.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/snippet_type.php b/admin/tables/snippet_type.php deleted file mode 100644 index c2d5759d6..000000000 --- a/admin/tables/snippet_type.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Snippet_types Table class - */ -class ComponentbuilderTableSnippet_type extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_snippet_type', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.snippet_type')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Snippet_type table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New snippet_type. A snippet_type created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('snippet_type', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_SNIPPET_TYPE_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('snippet_type', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.snippet_type.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.snippet_type.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tables/template.php b/admin/tables/template.php deleted file mode 100644 index 19870e7e4..000000000 --- a/admin/tables/template.php +++ /dev/null @@ -1,337 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Templates Table class - */ -class ComponentbuilderTableTemplate extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_template', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.template')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Template table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New template. A template created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('template', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_TEMPLATE_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('template', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.template.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.template.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * Generate a valid alias from title / date. - * Remains public to be able to check for duplicated alias before saving - * - * @return string - */ - public function generateAlias() - { - if (empty($this->alias)) - { - $this->alias = $this->name; - } - - $this->alias = JApplicationHelper::stringURLSafe($this->alias); - - if (trim(str_replace('-', '', $this->alias)) == '') - { - $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s'); - } - - return $this->alias; - } - -} diff --git a/admin/tables/validation_rule.php b/admin/tables/validation_rule.php deleted file mode 100644 index 8e785d58d..000000000 --- a/admin/tables/validation_rule.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Table\Table; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; - -/** - * Validation_rules Table class - */ -class ComponentbuilderTableValidation_rule extends Table -{ - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - - /** - * Constructor - * - * @param object Database connector object - */ - function __construct(&$db) - { - parent::__construct('#__componentbuilder_validation_rule', 'id', $db); - - // Adding History Options - JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.validation_rule')); - } - - public function bind($array, $ignore = '') - { - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new JAccessRules($array['rules']); - $this->setRules($rules); - } - return parent::bind($array, $ignore); - } - - /** - * Overload the store method for the Validation_rule table. - * - * @param boolean Toggle whether null values should be updated. - * @return boolean True on success, false on failure. - * @since 1.6 - */ - public function store($updateNulls = false) - { - $date = JFactory::getDate(); - $user = JFactory::getUser(); - - if ($this->id) - { - // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); - } - else - { - // New validation_rule. A validation_rule created and created_by field can be set by the user, - // so we don't touch either of these if they are set. - if (!(int) $this->created) - { - $this->created = $date->toSql(); - } - if (empty($this->created_by)) - { - $this->created_by = $user->get('id'); - } - } - - if (isset($this->alias)) - { - // Verify that the alias is unique - $table = JTable::getInstance('validation_rule', 'ComponentbuilderTable'); - - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->setError(JText::_('COM_COMPONENTBUILDER_VALIDATION_RULE_ERROR_UNIQUE_ALIAS')); - return false; - } - } - - if (isset($this->url)) - { - // Convert IDN urls to punycode - $this->url = JStringPunycode::urlToPunycode($this->url); - } - if (isset($this->website)) - { - // Convert IDN urls to punycode - $this->website = JStringPunycode::urlToPunycode($this->website); - } - - return parent::store($updateNulls); - } - - /** - * Overloaded check method to ensure data integrity. - * - * @return boolean True on success. - */ - public function check() - { - if (isset($this->alias)) - { - // Generate a valid alias - $this->generateAlias(); - - $table = JTable::getInstance('validation_rule', 'componentbuilderTable'); - - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) - { - $this->alias = StringHelper::increment($this->alias, 'dash'); - } - } - - /* - * Clean up keywords -- eliminate extra spaces between phrases - * and cr (\r) and lf (\n) characters from string. - * Only process if not empty. - */ - if (!empty($this->metakey)) - { - // Array of characters to remove. - $bad_characters = array("\n", "\r", "\"", "<", ">"); - - // Remove bad characters. - $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); - - // Create array using commas as delimiter. - $keys = explode(',', $after_clean); - $clean_keys = array(); - - foreach ($keys as $key) - { - // Ignore blank keywords. - if (trim($key)) - { - $clean_keys[] = trim($key); - } - } - - // Put array back together delimited by ", " - $this->metakey = implode(", ", $clean_keys); - } - - // Clean up description -- eliminate quotes and <> brackets - if (!empty($this->metadesc)) - { - // Only process if not empty - $bad_characters = array("\"", "<", ">"); - $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); - } - - // If we don't have any access rules set at this point just use an empty JAccessRules class - if (!$this->getRules()) - { - $rules = $this->getDefaultAssetValues('com_componentbuilder.validation_rule.'.$this->id); - $this->setRules($rules); - } - - // Set ordering - if ($this->published < 0) - { - // Set ordering to 0 if state is archived or trashed - $this->ordering = 0; - } - - return true; - } - - /** - * Gets the default asset values for a component. - * - * @param $string $component The component asset name to search for - * - * @return JAccessRules The JAccessRules object for the asset - */ - protected function getDefaultAssetValues($component, $try = true) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - if ($db->loadRowList()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. - } - // try again - elseif ($try) - { - $try = explode('.',$component); - $result = $this->getDefaultAssetValues($try[0], false); - if ($result instanceof JAccessRules) - { - if (isset($try[1])) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($try[1] !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - else - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count( (array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules; - $rules->mergeCollection($_result); - - return $rules; - } - } - return $result; - } - } - return JAccess::getAssetRules(0); - } - - /** - * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' - * where id is the value of the primary key of the table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - return 'com_componentbuilder.validation_rule.'.(int) $this->$k; - } - - /** - * Method to return the title to use for the asset table. - * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record - * - * @return int - * @since 2.5 - */ - protected function _getAssetParentId(JTable $table = NULL, $id = NULL) - { - $asset = JTable::getInstance('Asset'); - $asset->loadByName('com_componentbuilder'); - - return $asset->id; - } - - /** - * This view does not actually have an alias - * - * @return bool - */ - public function generateAlias() - { - return false; - } - -} diff --git a/admin/tmpl/admin_custom_tabs/default.php b/admin/tmpl/admin_custom_tabs/default.php new file mode 100644 index 000000000..598c0d812 --- /dev/null +++ b/admin/tmpl/admin_custom_tabs/default.php @@ -0,0 +1,105 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + diff --git a/admin/views/joomla_plugins/tmpl/index.html b/admin/tmpl/admin_custom_tabs/index.html similarity index 100% rename from admin/views/joomla_plugins/tmpl/index.html rename to admin/tmpl/admin_custom_tabs/index.html diff --git a/admin/tmpl/admin_fields/default.php b/admin/tmpl/admin_fields/default.php new file mode 100644 index 000000000..d30781357 --- /dev/null +++ b/admin/tmpl/admin_fields/default.php @@ -0,0 +1,294 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/views/joomla_plugins_files_folders_urls/index.html b/admin/tmpl/admin_fields/index.html similarity index 100% rename from admin/views/joomla_plugins_files_folders_urls/index.html rename to admin/tmpl/admin_fields/index.html diff --git a/admin/tmpl/admin_fields_conditions/default.php b/admin/tmpl/admin_fields_conditions/default.php new file mode 100644 index 000000000..ec728012d --- /dev/null +++ b/admin/tmpl/admin_fields_conditions/default.php @@ -0,0 +1,150 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/views/joomla_plugins_files_folders_urls/tmpl/index.html b/admin/tmpl/admin_fields_conditions/index.html similarity index 100% rename from admin/views/joomla_plugins_files_folders_urls/tmpl/index.html rename to admin/tmpl/admin_fields_conditions/index.html diff --git a/admin/tmpl/admin_fields_relations/default.php b/admin/tmpl/admin_fields_relations/default.php new file mode 100644 index 000000000..81af0af01 --- /dev/null +++ b/admin/tmpl/admin_fields_relations/default.php @@ -0,0 +1,128 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/views/joomla_plugins_updates/index.html b/admin/tmpl/admin_fields_relations/index.html similarity index 100% rename from admin/views/joomla_plugins_updates/index.html rename to admin/tmpl/admin_fields_relations/index.html diff --git a/admin/tmpl/admin_view/default.php b/admin/tmpl/admin_view/default.php new file mode 100644 index 000000000..61c330b70 --- /dev/null +++ b/admin/tmpl/admin_view/default.php @@ -0,0 +1,808 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/views/joomla_plugins_updates/tmpl/index.html b/admin/tmpl/admin_view/index.html similarity index 100% rename from admin/views/joomla_plugins_updates/tmpl/index.html rename to admin/tmpl/admin_view/index.html diff --git a/admin/tmpl/admin_views/default.php b/admin/tmpl/admin_views/default.php new file mode 100644 index 000000000..9a0ca540e --- /dev/null +++ b/admin/tmpl/admin_views/default.php @@ -0,0 +1,80 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=admin_views.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'admin_viewList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    + diff --git a/admin/tmpl/admin_views/default_body.php b/admin/tmpl/admin_views/default_body.php new file mode 100644 index 000000000..f67fd24cd --- /dev/null +++ b/admin/tmpl/admin_views/default_body.php @@ -0,0 +1,161 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=admin_views&task=admin_view.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('admin_view',$item,'admin_views'); + ?> + + + get('admin_view.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('admin_view.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('admin_view.edit')): ?> + escape($item->system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'admin_views.', $canCheckin); ?> + + + escape($item->system_name); ?> + + - + type); ?> +
    + 'admin_fields', + 'views' => 'admins_fields', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_ADMIN_FIELDS'), + 'icon' => 'list'), + array( + 'view' => 'admin_fields_relations', + 'views' => 'admins_fields_relations', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_ADMIN_FIELDS_RELATIONS'), + 'icon' => 'tree-2'), + array( + 'view' => 'admin_fields_conditions', + 'views' => 'admins_fields_conditions', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_ADMIN_FIELDS_CONDITIONS'), + 'icon' => 'shuffle'), + array( + 'view' => 'admin_custom_tabs', + 'views' => 'admins_custom_tabs', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_ADMIN_CUSTOM_TABS'), + 'icon' => 'folder-plus') + ); + } + ?> +
    + + get($_button['view'].'.edit') && ($id = GetHelper::var($_button['view'], $item->id, 'admin_view', 'id')) !== false): ?> + + get($_button['view'].'.create')): ?> + + + +
    + + +
    : + escape($item->name_single); ?>
    + : + escape($item->name_list); ?> +
    + + +
    + escape($item->short_description); ?> +
      +
    • : + add_custom_button); ?>
    • +
    • : + add_custom_import); ?>
    • +
    • : + add_fadein); ?>
    • +
    • : + add_php_ajax); ?>
    • +
    +
    + + + get('admin_view.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'admin_views.', true, 'cb'); ?> + + published, $i, 'admin_views.', false, 'cb'); ?> + + + published, $i, 'admin_views.', true, 'cb'); ?> + + + published, $i, 'admin_views.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/admin_views/default_foot.php b/admin/tmpl/admin_views/default_foot.php new file mode 100644 index 000000000..8722e1abb --- /dev/null +++ b/admin/tmpl/admin_views/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/admin_views/default_head.php b/admin/tmpl/admin_views/default_head.php new file mode 100644 index 000000000..3ee5048ce --- /dev/null +++ b/admin/tmpl/admin_views/default_head.php @@ -0,0 +1,56 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/admin_views/default_toolbar.php b/admin/tmpl/admin_views/default_toolbar.php new file mode 100644 index 000000000..aab53e03b --- /dev/null +++ b/admin/tmpl/admin_views/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/admin_views/emptystate.php b/admin/tmpl/admin_views/emptystate.php new file mode 100644 index 000000000..be0695d03 --- /dev/null +++ b/admin/tmpl/admin_views/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_ADMIN_VIEWS', + 'formURL' => 'index.php?option=com_componentbuilder&view=admin_views', + 'icon' => 'icon-stack', +]; + +if ($this->user->authorise('admin_view.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=admin_view.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/language/tmpl/index.html b/admin/tmpl/admin_views/index.html similarity index 100% rename from admin/views/language/tmpl/index.html rename to admin/tmpl/admin_views/index.html diff --git a/admin/tmpl/admins_custom_tabs/default.php b/admin/tmpl/admins_custom_tabs/default.php new file mode 100644 index 000000000..bf878cfb0 --- /dev/null +++ b/admin/tmpl/admins_custom_tabs/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=admins_custom_tabs.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'admin_custom_tabsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/admins_custom_tabs/default_body.php b/admin/tmpl/admins_custom_tabs/default_body.php new file mode 100644 index 000000000..7c9275752 --- /dev/null +++ b/admin/tmpl/admins_custom_tabs/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=admins_custom_tabs&task=admin_custom_tabs.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('admin_custom_tabs',$item,'admins_custom_tabs'); + ?> + + + get('admin_custom_tabs.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('admin_custom_tabs.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('admin_custom_tabs.edit')): ?> + escape($item->admin_view_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'admins_custom_tabs.', $canCheckin); ?> + + + escape($item->admin_view_system_name); ?> + +
    + + + get('admin_custom_tabs.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'admins_custom_tabs.', true, 'cb'); ?> + + published, $i, 'admins_custom_tabs.', false, 'cb'); ?> + + + published, $i, 'admins_custom_tabs.', true, 'cb'); ?> + + + published, $i, 'admins_custom_tabs.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/admins_custom_tabs/default_foot.php b/admin/tmpl/admins_custom_tabs/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/admins_custom_tabs/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/admins_custom_tabs/default_head.php b/admin/tmpl/admins_custom_tabs/default_head.php new file mode 100644 index 000000000..cc16172d0 --- /dev/null +++ b/admin/tmpl/admins_custom_tabs/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/admins_custom_tabs/default_toolbar.php b/admin/tmpl/admins_custom_tabs/default_toolbar.php new file mode 100644 index 000000000..e7f5b7d6b --- /dev/null +++ b/admin/tmpl/admins_custom_tabs/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/admins_custom_tabs/emptystate.php b/admin/tmpl/admins_custom_tabs/emptystate.php new file mode 100644 index 000000000..1764e8b21 --- /dev/null +++ b/admin/tmpl/admins_custom_tabs/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_ADMINS_CUSTOM_TABS', + 'formURL' => 'index.php?option=com_componentbuilder&view=admins_custom_tabs', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('admin_custom_tabs.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=admin_custom_tabs.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/language_translation/tmpl/index.html b/admin/tmpl/admins_custom_tabs/index.html similarity index 100% rename from admin/views/language_translation/tmpl/index.html rename to admin/tmpl/admins_custom_tabs/index.html diff --git a/admin/tmpl/admins_fields/default.php b/admin/tmpl/admins_fields/default.php new file mode 100644 index 000000000..5a6571252 --- /dev/null +++ b/admin/tmpl/admins_fields/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=admins_fields.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'admin_fieldsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/admins_fields/default_body.php b/admin/tmpl/admins_fields/default_body.php new file mode 100644 index 000000000..6e59a89fa --- /dev/null +++ b/admin/tmpl/admins_fields/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=admins_fields&task=admin_fields.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('admin_fields',$item,'admins_fields'); + ?> + + + get('admin_fields.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('admin_fields.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('admin_fields.edit')): ?> + escape($item->admin_view_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'admins_fields.', $canCheckin); ?> + + + escape($item->admin_view_system_name); ?> + +
    + + + get('admin_fields.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'admins_fields.', true, 'cb'); ?> + + published, $i, 'admins_fields.', false, 'cb'); ?> + + + published, $i, 'admins_fields.', true, 'cb'); ?> + + + published, $i, 'admins_fields.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/admins_fields/default_foot.php b/admin/tmpl/admins_fields/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/admins_fields/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/admins_fields/default_head.php b/admin/tmpl/admins_fields/default_head.php new file mode 100644 index 000000000..cbdfe9c06 --- /dev/null +++ b/admin/tmpl/admins_fields/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/admins_fields/default_toolbar.php b/admin/tmpl/admins_fields/default_toolbar.php new file mode 100644 index 000000000..6c0b96dbe --- /dev/null +++ b/admin/tmpl/admins_fields/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/admins_fields/emptystate.php b/admin/tmpl/admins_fields/emptystate.php new file mode 100644 index 000000000..b29ee383b --- /dev/null +++ b/admin/tmpl/admins_fields/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_ADMINS_FIELDS', + 'formURL' => 'index.php?option=com_componentbuilder&view=admins_fields', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('admin_fields.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=admin_fields.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/language_translations/index.html b/admin/tmpl/admins_fields/index.html similarity index 100% rename from admin/views/language_translations/index.html rename to admin/tmpl/admins_fields/index.html diff --git a/admin/tmpl/admins_fields_conditions/default.php b/admin/tmpl/admins_fields_conditions/default.php new file mode 100644 index 000000000..0e5fdfefe --- /dev/null +++ b/admin/tmpl/admins_fields_conditions/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=admins_fields_conditions.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'admin_fields_conditionsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/admins_fields_conditions/default_body.php b/admin/tmpl/admins_fields_conditions/default_body.php new file mode 100644 index 000000000..90a3d2e39 --- /dev/null +++ b/admin/tmpl/admins_fields_conditions/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=admins_fields_conditions&task=admin_fields_conditions.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('admin_fields_conditions',$item,'admins_fields_conditions'); + ?> + + + get('admin_fields_conditions.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('admin_fields_conditions.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('admin_fields_conditions.edit')): ?> + escape($item->admin_view_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'admins_fields_conditions.', $canCheckin); ?> + + + escape($item->admin_view_system_name); ?> + +
    + + + get('admin_fields_conditions.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'admins_fields_conditions.', true, 'cb'); ?> + + published, $i, 'admins_fields_conditions.', false, 'cb'); ?> + + + published, $i, 'admins_fields_conditions.', true, 'cb'); ?> + + + published, $i, 'admins_fields_conditions.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/admins_fields_conditions/default_foot.php b/admin/tmpl/admins_fields_conditions/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/admins_fields_conditions/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/admins_fields_conditions/default_head.php b/admin/tmpl/admins_fields_conditions/default_head.php new file mode 100644 index 000000000..472eb6f3b --- /dev/null +++ b/admin/tmpl/admins_fields_conditions/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/admins_fields_conditions/default_toolbar.php b/admin/tmpl/admins_fields_conditions/default_toolbar.php new file mode 100644 index 000000000..c1b4f1963 --- /dev/null +++ b/admin/tmpl/admins_fields_conditions/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/admins_fields_conditions/emptystate.php b/admin/tmpl/admins_fields_conditions/emptystate.php new file mode 100644 index 000000000..3dd2ccaa5 --- /dev/null +++ b/admin/tmpl/admins_fields_conditions/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_ADMINS_FIELDS_CONDITIONS', + 'formURL' => 'index.php?option=com_componentbuilder&view=admins_fields_conditions', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('admin_fields_conditions.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=admin_fields_conditions.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/language_translations/tmpl/index.html b/admin/tmpl/admins_fields_conditions/index.html similarity index 100% rename from admin/views/language_translations/tmpl/index.html rename to admin/tmpl/admins_fields_conditions/index.html diff --git a/admin/tmpl/admins_fields_relations/default.php b/admin/tmpl/admins_fields_relations/default.php new file mode 100644 index 000000000..ddf782d37 --- /dev/null +++ b/admin/tmpl/admins_fields_relations/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=admins_fields_relations.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'admin_fields_relationsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/admins_fields_relations/default_body.php b/admin/tmpl/admins_fields_relations/default_body.php new file mode 100644 index 000000000..8e487ff32 --- /dev/null +++ b/admin/tmpl/admins_fields_relations/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=admins_fields_relations&task=admin_fields_relations.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('admin_fields_relations',$item,'admins_fields_relations'); + ?> + + + get('admin_fields_relations.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('admin_fields_relations.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('admin_fields_relations.edit')): ?> + escape($item->admin_view_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'admins_fields_relations.', $canCheckin); ?> + + + escape($item->admin_view_system_name); ?> + +
    + + + get('admin_fields_relations.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'admins_fields_relations.', true, 'cb'); ?> + + published, $i, 'admins_fields_relations.', false, 'cb'); ?> + + + published, $i, 'admins_fields_relations.', true, 'cb'); ?> + + + published, $i, 'admins_fields_relations.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/admins_fields_relations/default_foot.php b/admin/tmpl/admins_fields_relations/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/admins_fields_relations/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/admins_fields_relations/default_head.php b/admin/tmpl/admins_fields_relations/default_head.php new file mode 100644 index 000000000..54df8b0a7 --- /dev/null +++ b/admin/tmpl/admins_fields_relations/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/admins_fields_relations/default_toolbar.php b/admin/tmpl/admins_fields_relations/default_toolbar.php new file mode 100644 index 000000000..f363411ff --- /dev/null +++ b/admin/tmpl/admins_fields_relations/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/admins_fields_relations/emptystate.php b/admin/tmpl/admins_fields_relations/emptystate.php new file mode 100644 index 000000000..52019bd79 --- /dev/null +++ b/admin/tmpl/admins_fields_relations/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_ADMINS_FIELDS_RELATIONS', + 'formURL' => 'index.php?option=com_componentbuilder&view=admins_fields_relations', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('admin_fields_relations.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=admin_fields_relations.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/languages/index.html b/admin/tmpl/admins_fields_relations/index.html similarity index 100% rename from admin/views/languages/index.html rename to admin/tmpl/admins_fields_relations/index.html diff --git a/admin/tmpl/class_extendings/default.php b/admin/tmpl/class_extendings/default.php new file mode 100644 index 000000000..c8d50c1b6 --- /dev/null +++ b/admin/tmpl/class_extendings/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=class_extendings.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'class_extendsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/class_extendings/default_body.php b/admin/tmpl/class_extendings/default_body.php new file mode 100644 index 000000000..418db43f4 --- /dev/null +++ b/admin/tmpl/class_extendings/default_body.php @@ -0,0 +1,101 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=class_extendings&task=class_extends.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('class_extends',$item,'class_extendings'); + ?> + + + get('class_extends.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('class_extends.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('class_extends.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'class_extendings.', $canCheckin); ?> + + + escape($item->name); ?> + +
    + + + extension_type); ?> + + + get('class_extends.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'class_extendings.', true, 'cb'); ?> + + published, $i, 'class_extendings.', false, 'cb'); ?> + + + published, $i, 'class_extendings.', true, 'cb'); ?> + + + published, $i, 'class_extendings.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/class_extendings/default_foot.php b/admin/tmpl/class_extendings/default_foot.php new file mode 100644 index 000000000..b93986e05 --- /dev/null +++ b/admin/tmpl/class_extendings/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/class_extendings/default_head.php b/admin/tmpl/class_extendings/default_head.php new file mode 100644 index 000000000..22dea094f --- /dev/null +++ b/admin/tmpl/class_extendings/default_head.php @@ -0,0 +1,53 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/class_extendings/default_toolbar.php b/admin/tmpl/class_extendings/default_toolbar.php new file mode 100644 index 000000000..adfdce898 --- /dev/null +++ b/admin/tmpl/class_extendings/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/class_extendings/emptystate.php b/admin/tmpl/class_extendings/emptystate.php new file mode 100644 index 000000000..ff09114e7 --- /dev/null +++ b/admin/tmpl/class_extendings/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_CLASS_EXTENDINGS', + 'formURL' => 'index.php?option=com_componentbuilder&view=class_extendings', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('class_extends.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=class_extends.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/languages/tmpl/index.html b/admin/tmpl/class_extendings/index.html similarity index 100% rename from admin/views/languages/tmpl/index.html rename to admin/tmpl/class_extendings/index.html diff --git a/admin/tmpl/class_extends/default.php b/admin/tmpl/class_extends/default.php new file mode 100644 index 000000000..d6fd6db26 --- /dev/null +++ b/admin/tmpl/class_extends/default.php @@ -0,0 +1,133 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/views/layout/tmpl/index.html b/admin/tmpl/class_extends/index.html similarity index 100% rename from admin/views/layout/tmpl/index.html rename to admin/tmpl/class_extends/index.html diff --git a/admin/tmpl/class_method/default.php b/admin/tmpl/class_method/default.php new file mode 100644 index 000000000..5ee3a1cd1 --- /dev/null +++ b/admin/tmpl/class_method/default.php @@ -0,0 +1,148 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/views/layouts/index.html b/admin/tmpl/class_method/index.html similarity index 100% rename from admin/views/layouts/index.html rename to admin/tmpl/class_method/index.html diff --git a/admin/tmpl/class_methods/default.php b/admin/tmpl/class_methods/default.php new file mode 100644 index 000000000..2c25533c3 --- /dev/null +++ b/admin/tmpl/class_methods/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=class_methods.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'class_methodList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/class_methods/default_body.php b/admin/tmpl/class_methods/default_body.php new file mode 100644 index 000000000..0078c1558 --- /dev/null +++ b/admin/tmpl/class_methods/default_body.php @@ -0,0 +1,113 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=class_methods&task=class_method.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('class_method',$item,'class_methods'); + ?> + + + get('class_method.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('class_method.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('class_method.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'class_methods.', $canCheckin); ?> + + + escape($item->name); ?> + ( + escape($item->arguments); ?>) +
    + + + visibility); ?> + + +
    joomla_plugin_group) && $item->joomla_plugin_group > 0): ?> + + extension_type); ?> : + escape($item->joomla_plugin_group_name); ?> + + + extension_type); ?> + +
    + + + get('class_method.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'class_methods.', true, 'cb'); ?> + + published, $i, 'class_methods.', false, 'cb'); ?> + + + published, $i, 'class_methods.', true, 'cb'); ?> + + + published, $i, 'class_methods.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/class_methods/default_foot.php b/admin/tmpl/class_methods/default_foot.php new file mode 100644 index 000000000..8722e1abb --- /dev/null +++ b/admin/tmpl/class_methods/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/class_methods/default_head.php b/admin/tmpl/class_methods/default_head.php new file mode 100644 index 000000000..58e9d1012 --- /dev/null +++ b/admin/tmpl/class_methods/default_head.php @@ -0,0 +1,56 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/class_methods/default_toolbar.php b/admin/tmpl/class_methods/default_toolbar.php new file mode 100644 index 000000000..ae4b66312 --- /dev/null +++ b/admin/tmpl/class_methods/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/class_methods/emptystate.php b/admin/tmpl/class_methods/emptystate.php new file mode 100644 index 000000000..6364b6c46 --- /dev/null +++ b/admin/tmpl/class_methods/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_CLASS_METHODS', + 'formURL' => 'index.php?option=com_componentbuilder&view=class_methods', + 'icon' => 'icon-cube', +]; + +if ($this->user->authorise('class_method.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=class_method.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/layouts/tmpl/index.html b/admin/tmpl/class_methods/index.html similarity index 100% rename from admin/views/layouts/tmpl/index.html rename to admin/tmpl/class_methods/index.html diff --git a/admin/tmpl/class_properties/default.php b/admin/tmpl/class_properties/default.php new file mode 100644 index 000000000..b256994f9 --- /dev/null +++ b/admin/tmpl/class_properties/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=class_properties.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'class_propertyList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/class_properties/default_body.php b/admin/tmpl/class_properties/default_body.php new file mode 100644 index 000000000..5a557bccb --- /dev/null +++ b/admin/tmpl/class_properties/default_body.php @@ -0,0 +1,113 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=class_properties&task=class_property.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('class_property',$item,'class_properties'); + ?> + + + get('class_property.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('class_property.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('class_property.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'class_properties.', $canCheckin); ?> + + + escape($item->name); ?> + +
    + + + visibility); ?> + + +
    joomla_plugin_group) && StringHelper::check($item->joomla_plugin_group)): ?> + + extension_type); ?> : + escape($item->joomla_plugin_group_name); ?> + + + extension_type); ?> + +
    + + + get('class_property.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'class_properties.', true, 'cb'); ?> + + published, $i, 'class_properties.', false, 'cb'); ?> + + + published, $i, 'class_properties.', true, 'cb'); ?> + + + published, $i, 'class_properties.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/class_properties/default_foot.php b/admin/tmpl/class_properties/default_foot.php new file mode 100644 index 000000000..8722e1abb --- /dev/null +++ b/admin/tmpl/class_properties/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/class_properties/default_head.php b/admin/tmpl/class_properties/default_head.php new file mode 100644 index 000000000..463576c71 --- /dev/null +++ b/admin/tmpl/class_properties/default_head.php @@ -0,0 +1,56 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/class_properties/default_toolbar.php b/admin/tmpl/class_properties/default_toolbar.php new file mode 100644 index 000000000..b72cb59a7 --- /dev/null +++ b/admin/tmpl/class_properties/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/class_properties/emptystate.php b/admin/tmpl/class_properties/emptystate.php new file mode 100644 index 000000000..6b66d0957 --- /dev/null +++ b/admin/tmpl/class_properties/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_CLASS_PROPERTIES', + 'formURL' => 'index.php?option=com_componentbuilder&view=class_properties', + 'icon' => 'icon-cube', +]; + +if ($this->user->authorise('class_property.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=class_property.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/libraries/index.html b/admin/tmpl/class_properties/index.html similarity index 100% rename from admin/views/libraries/index.html rename to admin/tmpl/class_properties/index.html diff --git a/admin/tmpl/class_property/default.php b/admin/tmpl/class_property/default.php new file mode 100644 index 000000000..0d5b0d45f --- /dev/null +++ b/admin/tmpl/class_property/default.php @@ -0,0 +1,143 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/views/libraries/tmpl/index.html b/admin/tmpl/class_property/index.html similarity index 100% rename from admin/views/libraries/tmpl/index.html rename to admin/tmpl/class_property/index.html diff --git a/admin/tmpl/compiler/default.php b/admin/tmpl/compiler/default.php new file mode 100644 index 000000000..ff81c9f41 --- /dev/null +++ b/admin/tmpl/compiler/default.php @@ -0,0 +1,262 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); +use Joomla\CMS\Session\Session; + +// No direct access to this file +defined('_JEXEC') or die; + +$this->app->input->set('hidemainmenu', false); +$selectNotice = '

    ' . Text::_('COM_COMPONENTBUILDER_HI') . ' ' . $this->user->name . '

    '; +$selectNotice .= '

    ' . Text::_('COM_COMPONENTBUILDER_PLEASE_SELECT_A_COMPONENT_THAT_YOU_WOULD_LIKE_TO_COMPILE') . '

    '; + +// set the noticeboard options +$noticeboardOptions = array('vdm', 'pro'); + +?> +canDo->get('compiler.access')): ?> + + +
    + SuccessMessage)): ?> +
    + + SuccessMessage; ?> +
    + +
    +
    +
    +

    +
    +
    +
    + form): ?> + form->renderFieldset('builder'); ?> + +
    + + + +
    +
    +
    +
    form->renderFieldset('advanced'); ?>
    +
    + 'noticeboard' , 'active' => $noticeboardOptions[array_rand($noticeboardOptions)])); ?> +
    +
    + + + + + +
    +
    + + +

    + diff --git a/admin/views/libraries_config/index.html b/admin/tmpl/compiler/index.html similarity index 100% rename from admin/views/libraries_config/index.html rename to admin/tmpl/compiler/index.html diff --git a/admin/tmpl/component_admin_views/default.php b/admin/tmpl/component_admin_views/default.php new file mode 100644 index 000000000..3b888a2cf --- /dev/null +++ b/admin/tmpl/component_admin_views/default.php @@ -0,0 +1,147 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/views/libraries_config/tmpl/index.html b/admin/tmpl/component_admin_views/index.html similarity index 100% rename from admin/views/libraries_config/tmpl/index.html rename to admin/tmpl/component_admin_views/index.html diff --git a/admin/tmpl/component_config/default.php b/admin/tmpl/component_config/default.php new file mode 100644 index 000000000..87fc2d2f2 --- /dev/null +++ b/admin/tmpl/component_config/default.php @@ -0,0 +1,113 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + diff --git a/admin/views/libraries_files_folders_urls/index.html b/admin/tmpl/component_config/index.html similarity index 100% rename from admin/views/libraries_files_folders_urls/index.html rename to admin/tmpl/component_config/index.html diff --git a/admin/tmpl/component_custom_admin_menus/default.php b/admin/tmpl/component_custom_admin_menus/default.php new file mode 100644 index 000000000..da4dd8f68 --- /dev/null +++ b/admin/tmpl/component_custom_admin_menus/default.php @@ -0,0 +1,113 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + diff --git a/admin/views/libraries_files_folders_urls/tmpl/index.html b/admin/tmpl/component_custom_admin_menus/index.html similarity index 100% rename from admin/views/libraries_files_folders_urls/tmpl/index.html rename to admin/tmpl/component_custom_admin_menus/index.html diff --git a/admin/tmpl/component_custom_admin_views/default.php b/admin/tmpl/component_custom_admin_views/default.php new file mode 100644 index 000000000..e3231e824 --- /dev/null +++ b/admin/tmpl/component_custom_admin_views/default.php @@ -0,0 +1,137 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/views/library/tmpl/index.html b/admin/tmpl/component_custom_admin_views/index.html similarity index 100% rename from admin/views/library/tmpl/index.html rename to admin/tmpl/component_custom_admin_views/index.html diff --git a/admin/tmpl/component_dashboard/default.php b/admin/tmpl/component_dashboard/default.php new file mode 100644 index 000000000..be448c2c7 --- /dev/null +++ b/admin/tmpl/component_dashboard/default.php @@ -0,0 +1,151 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/views/library_config/tmpl/index.html b/admin/tmpl/component_dashboard/index.html similarity index 100% rename from admin/views/library_config/tmpl/index.html rename to admin/tmpl/component_dashboard/index.html diff --git a/admin/tmpl/component_files_folders/default.php b/admin/tmpl/component_files_folders/default.php new file mode 100644 index 000000000..2f279d595 --- /dev/null +++ b/admin/tmpl/component_files_folders/default.php @@ -0,0 +1,123 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + diff --git a/admin/views/library_files_folders_urls/tmpl/index.html b/admin/tmpl/component_files_folders/index.html similarity index 100% rename from admin/views/library_files_folders_urls/tmpl/index.html rename to admin/tmpl/component_files_folders/index.html diff --git a/admin/tmpl/component_modules/default.php b/admin/tmpl/component_modules/default.php new file mode 100644 index 000000000..41a52c842 --- /dev/null +++ b/admin/tmpl/component_modules/default.php @@ -0,0 +1,129 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/views/placeholder/tmpl/index.html b/admin/tmpl/component_modules/index.html similarity index 100% rename from admin/views/placeholder/tmpl/index.html rename to admin/tmpl/component_modules/index.html diff --git a/admin/tmpl/component_mysql_tweaks/default.php b/admin/tmpl/component_mysql_tweaks/default.php new file mode 100644 index 000000000..d7571883e --- /dev/null +++ b/admin/tmpl/component_mysql_tweaks/default.php @@ -0,0 +1,113 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + diff --git a/admin/views/placeholders/index.html b/admin/tmpl/component_mysql_tweaks/index.html similarity index 100% rename from admin/views/placeholders/index.html rename to admin/tmpl/component_mysql_tweaks/index.html diff --git a/admin/tmpl/component_placeholders/default.php b/admin/tmpl/component_placeholders/default.php new file mode 100644 index 000000000..24df16614 --- /dev/null +++ b/admin/tmpl/component_placeholders/default.php @@ -0,0 +1,113 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + diff --git a/admin/views/placeholders/tmpl/index.html b/admin/tmpl/component_placeholders/index.html similarity index 100% rename from admin/views/placeholders/tmpl/index.html rename to admin/tmpl/component_placeholders/index.html diff --git a/admin/tmpl/component_plugins/default.php b/admin/tmpl/component_plugins/default.php new file mode 100644 index 000000000..da8ddf56e --- /dev/null +++ b/admin/tmpl/component_plugins/default.php @@ -0,0 +1,129 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/views/power/tmpl/index.html b/admin/tmpl/component_plugins/index.html similarity index 100% rename from admin/views/power/tmpl/index.html rename to admin/tmpl/component_plugins/index.html diff --git a/admin/tmpl/component_router/default.php b/admin/tmpl/component_router/default.php new file mode 100644 index 000000000..f17a5279f --- /dev/null +++ b/admin/tmpl/component_router/default.php @@ -0,0 +1,105 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + diff --git a/admin/views/powers/index.html b/admin/tmpl/component_router/index.html similarity index 100% rename from admin/views/powers/index.html rename to admin/tmpl/component_router/index.html diff --git a/admin/tmpl/component_site_views/default.php b/admin/tmpl/component_site_views/default.php new file mode 100644 index 000000000..961ceafaf --- /dev/null +++ b/admin/tmpl/component_site_views/default.php @@ -0,0 +1,113 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + diff --git a/admin/views/powers/tmpl/index.html b/admin/tmpl/component_site_views/index.html similarity index 100% rename from admin/views/powers/tmpl/index.html rename to admin/tmpl/component_site_views/index.html diff --git a/admin/tmpl/component_updates/default.php b/admin/tmpl/component_updates/default.php new file mode 100644 index 000000000..f421a0faa --- /dev/null +++ b/admin/tmpl/component_updates/default.php @@ -0,0 +1,113 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + diff --git a/admin/views/search/index.html b/admin/tmpl/component_updates/index.html similarity index 100% rename from admin/views/search/index.html rename to admin/tmpl/component_updates/index.html diff --git a/admin/tmpl/componentbuilder/default.php b/admin/tmpl/componentbuilder/default.php new file mode 100644 index 000000000..43747d321 --- /dev/null +++ b/admin/tmpl/componentbuilder/default.php @@ -0,0 +1,82 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    +
    + 'cpanel')); ?> + + +
    +
    + 'main')); ?> + + loadTemplate('main');?> + + +
    +
    + 'vdm')); ?> + + loadTemplate('vdm');?> + + +
    +
    + + + +
    +
    + 'wiki_one')); ?> + + loadTemplate('wiki_tutorials');?> + + +
    +
    + + + +
    +
    + 'notice_board_one')); ?> + + loadTemplate('notice_board_vast_development_method');?> + + +
    +
    + + + +
    +
    + 'readme_one')); ?> + + loadTemplate('readme_information');?> + + +
    +
    + + + +
    +
    \ No newline at end of file diff --git a/admin/tmpl/componentbuilder/default_main.php b/admin/tmpl/componentbuilder/default_main.php new file mode 100644 index 000000000..3ca794477 --- /dev/null +++ b/admin/tmpl/componentbuilder/default_main.php @@ -0,0 +1,32 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +icons['main']) && is_array($this->icons['main'])) :?> + icons['main'] as $icon): ?> + + +
    + +

    + \ No newline at end of file diff --git a/admin/views/componentbuilder/tmpl/default_notice_board_vast_development_method.php b/admin/tmpl/componentbuilder/default_notice_board_vast_development_method.php similarity index 78% rename from admin/views/componentbuilder/tmpl/default_notice_board_vast_development_method.php rename to admin/tmpl/componentbuilder/default_notice_board_vast_development_method.php index e034e5c9d..1d28ee3f9 100644 --- a/admin/views/componentbuilder/tmpl/default_notice_board_vast_development_method.php +++ b/admin/tmpl/componentbuilder/default_notice_board_vast_development_method.php @@ -9,8 +9,12 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +use Joomla\CMS\Language\Text; +use Joomla\CMS\Router\Route; +use Joomla\CMS\HTML\HTMLHelper as Html; + // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; ?> noticeboard; ?> diff --git a/admin/views/componentbuilder/tmpl/default_readme_information.php b/admin/tmpl/componentbuilder/default_readme_information.php similarity index 78% rename from admin/views/componentbuilder/tmpl/default_readme_information.php rename to admin/tmpl/componentbuilder/default_readme_information.php index 30e82a5ed..2bad44b97 100644 --- a/admin/views/componentbuilder/tmpl/default_readme_information.php +++ b/admin/tmpl/componentbuilder/default_readme_information.php @@ -9,8 +9,12 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +use Joomla\CMS\Language\Text; +use Joomla\CMS\Router\Route; +use Joomla\CMS\HTML\HTMLHelper as Html; + // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; ?> readme; ?> diff --git a/admin/tmpl/componentbuilder/default_vdm.php b/admin/tmpl/componentbuilder/default_vdm.php new file mode 100644 index 000000000..d90c286a8 --- /dev/null +++ b/admin/tmpl/componentbuilder/default_vdm.php @@ -0,0 +1,41 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use VDM\Joomla\Utilities\ArrayHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +<?php echo Text::_('COM_COMPONENTBUILDER'); ?> + +
    +contributors)): ?> + contributors) > 1): ?> +

    + +

    + +
      + contributors as $contributor): ?> +
    • :
    • + +
    +
    + \ No newline at end of file diff --git a/admin/views/componentbuilder/tmpl/default_wiki_tutorials.php b/admin/tmpl/componentbuilder/default_wiki_tutorials.php similarity index 78% rename from admin/views/componentbuilder/tmpl/default_wiki_tutorials.php rename to admin/tmpl/componentbuilder/default_wiki_tutorials.php index f057541f5..bf41cd55e 100644 --- a/admin/views/componentbuilder/tmpl/default_wiki_tutorials.php +++ b/admin/tmpl/componentbuilder/default_wiki_tutorials.php @@ -9,8 +9,12 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +use Joomla\CMS\Language\Text; +use Joomla\CMS\Router\Route; +use Joomla\CMS\HTML\HTMLHelper as Html; + // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; ?> wiki; ?> diff --git a/admin/views/search/tmpl/index.html b/admin/tmpl/componentbuilder/index.html similarity index 100% rename from admin/views/search/tmpl/index.html rename to admin/tmpl/componentbuilder/index.html diff --git a/admin/tmpl/components_admin_views/default.php b/admin/tmpl/components_admin_views/default.php new file mode 100644 index 000000000..34a956efd --- /dev/null +++ b/admin/tmpl/components_admin_views/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_admin_views.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'component_admin_viewsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/components_admin_views/default_body.php b/admin/tmpl/components_admin_views/default_body.php new file mode 100644 index 000000000..e8a098f51 --- /dev/null +++ b/admin/tmpl/components_admin_views/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=components_admin_views&task=component_admin_views.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('component_admin_views',$item,'components_admin_views'); + ?> + + + get('component_admin_views.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('component_admin_views.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('component_admin_views.edit')): ?> + escape($item->joomla_component_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'components_admin_views.', $canCheckin); ?> + + + escape($item->joomla_component_system_name); ?> + +
    + + + get('component_admin_views.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'components_admin_views.', true, 'cb'); ?> + + published, $i, 'components_admin_views.', false, 'cb'); ?> + + + published, $i, 'components_admin_views.', true, 'cb'); ?> + + + published, $i, 'components_admin_views.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/components_admin_views/default_foot.php b/admin/tmpl/components_admin_views/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/components_admin_views/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/components_admin_views/default_head.php b/admin/tmpl/components_admin_views/default_head.php new file mode 100644 index 000000000..f770979c1 --- /dev/null +++ b/admin/tmpl/components_admin_views/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/components_admin_views/default_toolbar.php b/admin/tmpl/components_admin_views/default_toolbar.php new file mode 100644 index 000000000..edcb9e30e --- /dev/null +++ b/admin/tmpl/components_admin_views/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/components_admin_views/emptystate.php b/admin/tmpl/components_admin_views/emptystate.php new file mode 100644 index 000000000..de7705802 --- /dev/null +++ b/admin/tmpl/components_admin_views/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS', + 'formURL' => 'index.php?option=com_componentbuilder&view=components_admin_views', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('component_admin_views.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=component_admin_views.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/server/tmpl/index.html b/admin/tmpl/components_admin_views/index.html similarity index 100% rename from admin/views/server/tmpl/index.html rename to admin/tmpl/components_admin_views/index.html diff --git a/admin/tmpl/components_config/default.php b/admin/tmpl/components_config/default.php new file mode 100644 index 000000000..cc8f87e60 --- /dev/null +++ b/admin/tmpl/components_config/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_config.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'component_configList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/components_config/default_body.php b/admin/tmpl/components_config/default_body.php new file mode 100644 index 000000000..8ebe7b985 --- /dev/null +++ b/admin/tmpl/components_config/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=components_config&task=component_config.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('component_config',$item,'components_config'); + ?> + + + get('component_config.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('component_config.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('component_config.edit')): ?> + escape($item->joomla_component_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'components_config.', $canCheckin); ?> + + + escape($item->joomla_component_system_name); ?> + +
    + + + get('component_config.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'components_config.', true, 'cb'); ?> + + published, $i, 'components_config.', false, 'cb'); ?> + + + published, $i, 'components_config.', true, 'cb'); ?> + + + published, $i, 'components_config.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/components_config/default_foot.php b/admin/tmpl/components_config/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/components_config/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/components_config/default_head.php b/admin/tmpl/components_config/default_head.php new file mode 100644 index 000000000..047a7e5c9 --- /dev/null +++ b/admin/tmpl/components_config/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/components_config/default_toolbar.php b/admin/tmpl/components_config/default_toolbar.php new file mode 100644 index 000000000..dd7b2d10d --- /dev/null +++ b/admin/tmpl/components_config/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/components_config/emptystate.php b/admin/tmpl/components_config/emptystate.php new file mode 100644 index 000000000..a5b584096 --- /dev/null +++ b/admin/tmpl/components_config/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_COMPONENTS_CONFIG', + 'formURL' => 'index.php?option=com_componentbuilder&view=components_config', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('component_config.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=component_config.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/servers/index.html b/admin/tmpl/components_config/index.html similarity index 100% rename from admin/views/servers/index.html rename to admin/tmpl/components_config/index.html diff --git a/admin/tmpl/components_custom_admin_menus/default.php b/admin/tmpl/components_custom_admin_menus/default.php new file mode 100644 index 000000000..9f8dc009c --- /dev/null +++ b/admin/tmpl/components_custom_admin_menus/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_custom_admin_menus.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'component_custom_admin_menusList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/components_custom_admin_menus/default_body.php b/admin/tmpl/components_custom_admin_menus/default_body.php new file mode 100644 index 000000000..86441c647 --- /dev/null +++ b/admin/tmpl/components_custom_admin_menus/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=components_custom_admin_menus&task=component_custom_admin_menus.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('component_custom_admin_menus',$item,'components_custom_admin_menus'); + ?> + + + get('component_custom_admin_menus.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('component_custom_admin_menus.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('component_custom_admin_menus.edit')): ?> + escape($item->joomla_component_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'components_custom_admin_menus.', $canCheckin); ?> + + + escape($item->joomla_component_system_name); ?> + +
    + + + get('component_custom_admin_menus.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'components_custom_admin_menus.', true, 'cb'); ?> + + published, $i, 'components_custom_admin_menus.', false, 'cb'); ?> + + + published, $i, 'components_custom_admin_menus.', true, 'cb'); ?> + + + published, $i, 'components_custom_admin_menus.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/components_custom_admin_menus/default_foot.php b/admin/tmpl/components_custom_admin_menus/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/components_custom_admin_menus/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/components_custom_admin_menus/default_head.php b/admin/tmpl/components_custom_admin_menus/default_head.php new file mode 100644 index 000000000..eb72f9c88 --- /dev/null +++ b/admin/tmpl/components_custom_admin_menus/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/components_custom_admin_menus/default_toolbar.php b/admin/tmpl/components_custom_admin_menus/default_toolbar.php new file mode 100644 index 000000000..9a95aae22 --- /dev/null +++ b/admin/tmpl/components_custom_admin_menus/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/components_custom_admin_menus/emptystate.php b/admin/tmpl/components_custom_admin_menus/emptystate.php new file mode 100644 index 000000000..31a41fad7 --- /dev/null +++ b/admin/tmpl/components_custom_admin_menus/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_MENUS', + 'formURL' => 'index.php?option=com_componentbuilder&view=components_custom_admin_menus', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('component_custom_admin_menus.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=component_custom_admin_menus.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/servers/tmpl/index.html b/admin/tmpl/components_custom_admin_menus/index.html similarity index 100% rename from admin/views/servers/tmpl/index.html rename to admin/tmpl/components_custom_admin_menus/index.html diff --git a/admin/tmpl/components_custom_admin_views/default.php b/admin/tmpl/components_custom_admin_views/default.php new file mode 100644 index 000000000..19998da5a --- /dev/null +++ b/admin/tmpl/components_custom_admin_views/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_custom_admin_views.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'component_custom_admin_viewsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/components_custom_admin_views/default_body.php b/admin/tmpl/components_custom_admin_views/default_body.php new file mode 100644 index 000000000..e01261ef4 --- /dev/null +++ b/admin/tmpl/components_custom_admin_views/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=components_custom_admin_views&task=component_custom_admin_views.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('component_custom_admin_views',$item,'components_custom_admin_views'); + ?> + + + get('component_custom_admin_views.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('component_custom_admin_views.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('component_custom_admin_views.edit')): ?> + escape($item->joomla_component_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'components_custom_admin_views.', $canCheckin); ?> + + + escape($item->joomla_component_system_name); ?> + +
    + + + get('component_custom_admin_views.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'components_custom_admin_views.', true, 'cb'); ?> + + published, $i, 'components_custom_admin_views.', false, 'cb'); ?> + + + published, $i, 'components_custom_admin_views.', true, 'cb'); ?> + + + published, $i, 'components_custom_admin_views.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/components_custom_admin_views/default_foot.php b/admin/tmpl/components_custom_admin_views/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/components_custom_admin_views/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/components_custom_admin_views/default_head.php b/admin/tmpl/components_custom_admin_views/default_head.php new file mode 100644 index 000000000..c9b591c2a --- /dev/null +++ b/admin/tmpl/components_custom_admin_views/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/components_custom_admin_views/default_toolbar.php b/admin/tmpl/components_custom_admin_views/default_toolbar.php new file mode 100644 index 000000000..38bd0a1f1 --- /dev/null +++ b/admin/tmpl/components_custom_admin_views/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/components_custom_admin_views/emptystate.php b/admin/tmpl/components_custom_admin_views/emptystate.php new file mode 100644 index 000000000..1d011aacd --- /dev/null +++ b/admin/tmpl/components_custom_admin_views/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_VIEWS', + 'formURL' => 'index.php?option=com_componentbuilder&view=components_custom_admin_views', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('component_custom_admin_views.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=component_custom_admin_views.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/site_view/tmpl/index.html b/admin/tmpl/components_custom_admin_views/index.html similarity index 100% rename from admin/views/site_view/tmpl/index.html rename to admin/tmpl/components_custom_admin_views/index.html diff --git a/admin/tmpl/components_dashboard/default.php b/admin/tmpl/components_dashboard/default.php new file mode 100644 index 000000000..3462fb6e9 --- /dev/null +++ b/admin/tmpl/components_dashboard/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_dashboard.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'component_dashboardList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/components_dashboard/default_body.php b/admin/tmpl/components_dashboard/default_body.php new file mode 100644 index 000000000..80bb7ebab --- /dev/null +++ b/admin/tmpl/components_dashboard/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=components_dashboard&task=component_dashboard.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('component_dashboard',$item,'components_dashboard'); + ?> + + + get('component_dashboard.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('component_dashboard.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('component_dashboard.edit')): ?> + escape($item->joomla_component_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'components_dashboard.', $canCheckin); ?> + + + escape($item->joomla_component_system_name); ?> + +
    + + + get('component_dashboard.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'components_dashboard.', true, 'cb'); ?> + + published, $i, 'components_dashboard.', false, 'cb'); ?> + + + published, $i, 'components_dashboard.', true, 'cb'); ?> + + + published, $i, 'components_dashboard.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/components_dashboard/default_foot.php b/admin/tmpl/components_dashboard/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/components_dashboard/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/components_dashboard/default_head.php b/admin/tmpl/components_dashboard/default_head.php new file mode 100644 index 000000000..a219db9c9 --- /dev/null +++ b/admin/tmpl/components_dashboard/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/components_dashboard/default_toolbar.php b/admin/tmpl/components_dashboard/default_toolbar.php new file mode 100644 index 000000000..67e2bb6dd --- /dev/null +++ b/admin/tmpl/components_dashboard/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/components_dashboard/emptystate.php b/admin/tmpl/components_dashboard/emptystate.php new file mode 100644 index 000000000..6faeb6bcc --- /dev/null +++ b/admin/tmpl/components_dashboard/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_COMPONENTS_DASHBOARD', + 'formURL' => 'index.php?option=com_componentbuilder&view=components_dashboard', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('component_dashboard.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=component_dashboard.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/site_views/index.html b/admin/tmpl/components_dashboard/index.html similarity index 100% rename from admin/views/site_views/index.html rename to admin/tmpl/components_dashboard/index.html diff --git a/admin/tmpl/components_files_folders/default.php b/admin/tmpl/components_files_folders/default.php new file mode 100644 index 000000000..0cb759c41 --- /dev/null +++ b/admin/tmpl/components_files_folders/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_files_folders.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'component_files_foldersList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/components_files_folders/default_body.php b/admin/tmpl/components_files_folders/default_body.php new file mode 100644 index 000000000..691abdd2b --- /dev/null +++ b/admin/tmpl/components_files_folders/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=components_files_folders&task=component_files_folders.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('component_files_folders',$item,'components_files_folders'); + ?> + + + get('component_files_folders.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('component_files_folders.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('component_files_folders.edit')): ?> + escape($item->joomla_component_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'components_files_folders.', $canCheckin); ?> + + + escape($item->joomla_component_system_name); ?> + +
    + + + get('component_files_folders.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'components_files_folders.', true, 'cb'); ?> + + published, $i, 'components_files_folders.', false, 'cb'); ?> + + + published, $i, 'components_files_folders.', true, 'cb'); ?> + + + published, $i, 'components_files_folders.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/components_files_folders/default_foot.php b/admin/tmpl/components_files_folders/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/components_files_folders/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/components_files_folders/default_head.php b/admin/tmpl/components_files_folders/default_head.php new file mode 100644 index 000000000..b602e599f --- /dev/null +++ b/admin/tmpl/components_files_folders/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/components_files_folders/default_toolbar.php b/admin/tmpl/components_files_folders/default_toolbar.php new file mode 100644 index 000000000..24cbecd9e --- /dev/null +++ b/admin/tmpl/components_files_folders/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/components_files_folders/emptystate.php b/admin/tmpl/components_files_folders/emptystate.php new file mode 100644 index 000000000..6ee92336d --- /dev/null +++ b/admin/tmpl/components_files_folders/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_COMPONENTS_FILES_FOLDERS', + 'formURL' => 'index.php?option=com_componentbuilder&view=components_files_folders', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('component_files_folders.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=component_files_folders.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/site_views/tmpl/index.html b/admin/tmpl/components_files_folders/index.html similarity index 100% rename from admin/views/site_views/tmpl/index.html rename to admin/tmpl/components_files_folders/index.html diff --git a/admin/tmpl/components_modules/default.php b/admin/tmpl/components_modules/default.php new file mode 100644 index 000000000..f98f8099d --- /dev/null +++ b/admin/tmpl/components_modules/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_modules.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'component_modulesList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/components_modules/default_body.php b/admin/tmpl/components_modules/default_body.php new file mode 100644 index 000000000..654bbbb96 --- /dev/null +++ b/admin/tmpl/components_modules/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=components_modules&task=component_modules.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('component_modules',$item,'components_modules'); + ?> + + + get('component_modules.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('component_modules.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('component_modules.edit')): ?> + escape($item->joomla_component_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'components_modules.', $canCheckin); ?> + + + escape($item->joomla_component_system_name); ?> + +
    + + + get('component_modules.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'components_modules.', true, 'cb'); ?> + + published, $i, 'components_modules.', false, 'cb'); ?> + + + published, $i, 'components_modules.', true, 'cb'); ?> + + + published, $i, 'components_modules.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/components_modules/default_foot.php b/admin/tmpl/components_modules/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/components_modules/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/components_modules/default_head.php b/admin/tmpl/components_modules/default_head.php new file mode 100644 index 000000000..6e31a0d29 --- /dev/null +++ b/admin/tmpl/components_modules/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/components_modules/default_toolbar.php b/admin/tmpl/components_modules/default_toolbar.php new file mode 100644 index 000000000..016b4ed3a --- /dev/null +++ b/admin/tmpl/components_modules/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/components_modules/emptystate.php b/admin/tmpl/components_modules/emptystate.php new file mode 100644 index 000000000..18891db0d --- /dev/null +++ b/admin/tmpl/components_modules/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_COMPONENTS_MODULES', + 'formURL' => 'index.php?option=com_componentbuilder&view=components_modules', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('component_modules.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=component_modules.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/snippet/tmpl/index.html b/admin/tmpl/components_modules/index.html similarity index 100% rename from admin/views/snippet/tmpl/index.html rename to admin/tmpl/components_modules/index.html diff --git a/admin/tmpl/components_mysql_tweaks/default.php b/admin/tmpl/components_mysql_tweaks/default.php new file mode 100644 index 000000000..4dcb7f003 --- /dev/null +++ b/admin/tmpl/components_mysql_tweaks/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_mysql_tweaks.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'component_mysql_tweaksList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/components_mysql_tweaks/default_body.php b/admin/tmpl/components_mysql_tweaks/default_body.php new file mode 100644 index 000000000..aac55a86c --- /dev/null +++ b/admin/tmpl/components_mysql_tweaks/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=components_mysql_tweaks&task=component_mysql_tweaks.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('component_mysql_tweaks',$item,'components_mysql_tweaks'); + ?> + + + get('component_mysql_tweaks.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('component_mysql_tweaks.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('component_mysql_tweaks.edit')): ?> + escape($item->joomla_component_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'components_mysql_tweaks.', $canCheckin); ?> + + + escape($item->joomla_component_system_name); ?> + +
    + + + get('component_mysql_tweaks.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'components_mysql_tweaks.', true, 'cb'); ?> + + published, $i, 'components_mysql_tweaks.', false, 'cb'); ?> + + + published, $i, 'components_mysql_tweaks.', true, 'cb'); ?> + + + published, $i, 'components_mysql_tweaks.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/components_mysql_tweaks/default_foot.php b/admin/tmpl/components_mysql_tweaks/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/components_mysql_tweaks/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/components_mysql_tweaks/default_head.php b/admin/tmpl/components_mysql_tweaks/default_head.php new file mode 100644 index 000000000..9e4eef105 --- /dev/null +++ b/admin/tmpl/components_mysql_tweaks/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/components_mysql_tweaks/default_toolbar.php b/admin/tmpl/components_mysql_tweaks/default_toolbar.php new file mode 100644 index 000000000..e1a6338db --- /dev/null +++ b/admin/tmpl/components_mysql_tweaks/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/components_mysql_tweaks/emptystate.php b/admin/tmpl/components_mysql_tweaks/emptystate.php new file mode 100644 index 000000000..986146db0 --- /dev/null +++ b/admin/tmpl/components_mysql_tweaks/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_COMPONENTS_MYSQL_TWEAKS', + 'formURL' => 'index.php?option=com_componentbuilder&view=components_mysql_tweaks', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('component_mysql_tweaks.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=component_mysql_tweaks.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/snippet_type/tmpl/index.html b/admin/tmpl/components_mysql_tweaks/index.html similarity index 100% rename from admin/views/snippet_type/tmpl/index.html rename to admin/tmpl/components_mysql_tweaks/index.html diff --git a/admin/tmpl/components_placeholders/default.php b/admin/tmpl/components_placeholders/default.php new file mode 100644 index 000000000..bec17c53c --- /dev/null +++ b/admin/tmpl/components_placeholders/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_placeholders.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'component_placeholdersList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/components_placeholders/default_body.php b/admin/tmpl/components_placeholders/default_body.php new file mode 100644 index 000000000..048fd08ea --- /dev/null +++ b/admin/tmpl/components_placeholders/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=components_placeholders&task=component_placeholders.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('component_placeholders',$item,'components_placeholders'); + ?> + + + get('component_placeholders.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('component_placeholders.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('component_placeholders.edit')): ?> + escape($item->joomla_component_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'components_placeholders.', $canCheckin); ?> + + + escape($item->joomla_component_system_name); ?> + +
    + + + get('component_placeholders.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'components_placeholders.', true, 'cb'); ?> + + published, $i, 'components_placeholders.', false, 'cb'); ?> + + + published, $i, 'components_placeholders.', true, 'cb'); ?> + + + published, $i, 'components_placeholders.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/components_placeholders/default_foot.php b/admin/tmpl/components_placeholders/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/components_placeholders/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/components_placeholders/default_head.php b/admin/tmpl/components_placeholders/default_head.php new file mode 100644 index 000000000..85d33e64b --- /dev/null +++ b/admin/tmpl/components_placeholders/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/components_placeholders/default_toolbar.php b/admin/tmpl/components_placeholders/default_toolbar.php new file mode 100644 index 000000000..0038e5bbb --- /dev/null +++ b/admin/tmpl/components_placeholders/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/components_placeholders/emptystate.php b/admin/tmpl/components_placeholders/emptystate.php new file mode 100644 index 000000000..0f077e762 --- /dev/null +++ b/admin/tmpl/components_placeholders/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_COMPONENTS_PLACEHOLDERS', + 'formURL' => 'index.php?option=com_componentbuilder&view=components_placeholders', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('component_placeholders.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=component_placeholders.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/snippet_types/index.html b/admin/tmpl/components_placeholders/index.html similarity index 100% rename from admin/views/snippet_types/index.html rename to admin/tmpl/components_placeholders/index.html diff --git a/admin/tmpl/components_plugins/default.php b/admin/tmpl/components_plugins/default.php new file mode 100644 index 000000000..1dcb71add --- /dev/null +++ b/admin/tmpl/components_plugins/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_plugins.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'component_pluginsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/components_plugins/default_body.php b/admin/tmpl/components_plugins/default_body.php new file mode 100644 index 000000000..246965807 --- /dev/null +++ b/admin/tmpl/components_plugins/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=components_plugins&task=component_plugins.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('component_plugins',$item,'components_plugins'); + ?> + + + get('component_plugins.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('component_plugins.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('component_plugins.edit')): ?> + escape($item->joomla_component_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'components_plugins.', $canCheckin); ?> + + + escape($item->joomla_component_system_name); ?> + +
    + + + get('component_plugins.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'components_plugins.', true, 'cb'); ?> + + published, $i, 'components_plugins.', false, 'cb'); ?> + + + published, $i, 'components_plugins.', true, 'cb'); ?> + + + published, $i, 'components_plugins.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/components_plugins/default_foot.php b/admin/tmpl/components_plugins/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/components_plugins/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/components_plugins/default_head.php b/admin/tmpl/components_plugins/default_head.php new file mode 100644 index 000000000..0b4d05e51 --- /dev/null +++ b/admin/tmpl/components_plugins/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/components_plugins/default_toolbar.php b/admin/tmpl/components_plugins/default_toolbar.php new file mode 100644 index 000000000..dcc9c079f --- /dev/null +++ b/admin/tmpl/components_plugins/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/components_plugins/emptystate.php b/admin/tmpl/components_plugins/emptystate.php new file mode 100644 index 000000000..14a4706ab --- /dev/null +++ b/admin/tmpl/components_plugins/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_COMPONENTS_PLUGINS', + 'formURL' => 'index.php?option=com_componentbuilder&view=components_plugins', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('component_plugins.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=component_plugins.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/snippet_types/tmpl/index.html b/admin/tmpl/components_plugins/index.html similarity index 100% rename from admin/views/snippet_types/tmpl/index.html rename to admin/tmpl/components_plugins/index.html diff --git a/admin/tmpl/components_routers/default.php b/admin/tmpl/components_routers/default.php new file mode 100644 index 000000000..71c079e39 --- /dev/null +++ b/admin/tmpl/components_routers/default.php @@ -0,0 +1,86 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_routers.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'component_routerList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    + diff --git a/admin/tmpl/components_routers/default_body.php b/admin/tmpl/components_routers/default_body.php new file mode 100644 index 000000000..cb6a094ec --- /dev/null +++ b/admin/tmpl/components_routers/default_body.php @@ -0,0 +1,107 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=components_routers&task=component_router.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('component_router',$item,'components_routers'); + ?> + + + get('component_router.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('component_router.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('component_router.edit')): ?> + escape($item->joomla_component_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'components_routers.', $canCheckin); ?> + + + escape($item->joomla_component_system_name); ?> + +
    + + + mode_constructor_before_parent); ?> + + + mode_constructor_after_parent); ?> + + + mode_methods); ?> + + + get('component_router.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'components_routers.', true, 'cb'); ?> + + published, $i, 'components_routers.', false, 'cb'); ?> + + + published, $i, 'components_routers.', true, 'cb'); ?> + + + published, $i, 'components_routers.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/components_routers/default_foot.php b/admin/tmpl/components_routers/default_foot.php new file mode 100644 index 000000000..398ede1cc --- /dev/null +++ b/admin/tmpl/components_routers/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/components_routers/default_head.php b/admin/tmpl/components_routers/default_head.php new file mode 100644 index 000000000..e4ba3fe27 --- /dev/null +++ b/admin/tmpl/components_routers/default_head.php @@ -0,0 +1,59 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + + + + + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/components_routers/default_toolbar.php b/admin/tmpl/components_routers/default_toolbar.php new file mode 100644 index 000000000..29126aa1c --- /dev/null +++ b/admin/tmpl/components_routers/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/components_routers/emptystate.php b/admin/tmpl/components_routers/emptystate.php new file mode 100644 index 000000000..63dff6657 --- /dev/null +++ b/admin/tmpl/components_routers/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_COMPONENTS_ROUTERS', + 'formURL' => 'index.php?option=com_componentbuilder&view=components_routers', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('component_router.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=component_router.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/snippets/index.html b/admin/tmpl/components_routers/index.html similarity index 100% rename from admin/views/snippets/index.html rename to admin/tmpl/components_routers/index.html diff --git a/admin/tmpl/components_site_views/default.php b/admin/tmpl/components_site_views/default.php new file mode 100644 index 000000000..6ce706260 --- /dev/null +++ b/admin/tmpl/components_site_views/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_site_views.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'component_site_viewsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/components_site_views/default_body.php b/admin/tmpl/components_site_views/default_body.php new file mode 100644 index 000000000..c94fb79a4 --- /dev/null +++ b/admin/tmpl/components_site_views/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=components_site_views&task=component_site_views.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('component_site_views',$item,'components_site_views'); + ?> + + + get('component_site_views.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('component_site_views.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('component_site_views.edit')): ?> + escape($item->joomla_component_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'components_site_views.', $canCheckin); ?> + + + escape($item->joomla_component_system_name); ?> + +
    + + + get('component_site_views.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'components_site_views.', true, 'cb'); ?> + + published, $i, 'components_site_views.', false, 'cb'); ?> + + + published, $i, 'components_site_views.', true, 'cb'); ?> + + + published, $i, 'components_site_views.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/components_site_views/default_foot.php b/admin/tmpl/components_site_views/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/components_site_views/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/components_site_views/default_head.php b/admin/tmpl/components_site_views/default_head.php new file mode 100644 index 000000000..d32359dc5 --- /dev/null +++ b/admin/tmpl/components_site_views/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/components_site_views/default_toolbar.php b/admin/tmpl/components_site_views/default_toolbar.php new file mode 100644 index 000000000..cadbc6d27 --- /dev/null +++ b/admin/tmpl/components_site_views/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/components_site_views/emptystate.php b/admin/tmpl/components_site_views/emptystate.php new file mode 100644 index 000000000..85cfc0c79 --- /dev/null +++ b/admin/tmpl/components_site_views/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS', + 'formURL' => 'index.php?option=com_componentbuilder&view=components_site_views', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('component_site_views.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=component_site_views.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/snippets/tmpl/index.html b/admin/tmpl/components_site_views/index.html similarity index 100% rename from admin/views/snippets/tmpl/index.html rename to admin/tmpl/components_site_views/index.html diff --git a/admin/tmpl/components_updates/default.php b/admin/tmpl/components_updates/default.php new file mode 100644 index 000000000..f43a92670 --- /dev/null +++ b/admin/tmpl/components_updates/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_updates.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'component_updatesList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/components_updates/default_body.php b/admin/tmpl/components_updates/default_body.php new file mode 100644 index 000000000..1c568744a --- /dev/null +++ b/admin/tmpl/components_updates/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=components_updates&task=component_updates.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('component_updates',$item,'components_updates'); + ?> + + + get('component_updates.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('component_updates.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('component_updates.edit')): ?> + escape($item->joomla_component_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'components_updates.', $canCheckin); ?> + + + escape($item->joomla_component_system_name); ?> + +
    + + + get('component_updates.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'components_updates.', true, 'cb'); ?> + + published, $i, 'components_updates.', false, 'cb'); ?> + + + published, $i, 'components_updates.', true, 'cb'); ?> + + + published, $i, 'components_updates.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/components_updates/default_foot.php b/admin/tmpl/components_updates/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/components_updates/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/components_updates/default_head.php b/admin/tmpl/components_updates/default_head.php new file mode 100644 index 000000000..2bbab1aac --- /dev/null +++ b/admin/tmpl/components_updates/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/components_updates/default_toolbar.php b/admin/tmpl/components_updates/default_toolbar.php new file mode 100644 index 000000000..67e0581c5 --- /dev/null +++ b/admin/tmpl/components_updates/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/components_updates/emptystate.php b/admin/tmpl/components_updates/emptystate.php new file mode 100644 index 000000000..f2794d0b4 --- /dev/null +++ b/admin/tmpl/components_updates/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_COMPONENTS_UPDATES', + 'formURL' => 'index.php?option=com_componentbuilder&view=components_updates', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('component_updates.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=component_updates.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/template/tmpl/index.html b/admin/tmpl/components_updates/index.html similarity index 100% rename from admin/views/template/tmpl/index.html rename to admin/tmpl/components_updates/index.html diff --git a/admin/tmpl/custom_admin_view/default.php b/admin/tmpl/custom_admin_view/default.php new file mode 100644 index 000000000..ed095424a --- /dev/null +++ b/admin/tmpl/custom_admin_view/default.php @@ -0,0 +1,439 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/views/templates/index.html b/admin/tmpl/custom_admin_view/index.html similarity index 100% rename from admin/views/templates/index.html rename to admin/tmpl/custom_admin_view/index.html diff --git a/admin/tmpl/custom_admin_views/default.php b/admin/tmpl/custom_admin_views/default.php new file mode 100644 index 000000000..a78bc6e28 --- /dev/null +++ b/admin/tmpl/custom_admin_views/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=custom_admin_views.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'custom_admin_viewList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/custom_admin_views/default_body.php b/admin/tmpl/custom_admin_views/default_body.php new file mode 100644 index 000000000..fb40e2cae --- /dev/null +++ b/admin/tmpl/custom_admin_views/default_body.php @@ -0,0 +1,130 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=custom_admin_views&task=custom_admin_view.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('custom_admin_view',$item,'custom_admin_views'); + ?> + + + get('core.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('core.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('core.edit')): ?> + escape($item->system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'custom_admin_views.', $canCheckin); ?> + + + escape($item->system_name); ?> + +
    + + +
    : + escape($item->name); ?>
    + : + escape($item->codename); ?>
    + context)): ?> + : + escape($item->context); ?> + +
    + + +
    + escape($item->description); ?> +
      +
    • : + add_custom_button); ?>
    • +
    • : + add_php_ajax); ?>
    • +
    +
    + + +
    + user->authorise('dynamic_get.edit', 'com_componentbuilder.dynamic_get.' . (int) $item->main_get)): ?> + escape($item->main_get_name); ?> + + escape($item->main_get_name); ?> + +
    + + + get('core.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'custom_admin_views.', true, 'cb'); ?> + + published, $i, 'custom_admin_views.', false, 'cb'); ?> + + + published, $i, 'custom_admin_views.', true, 'cb'); ?> + + + published, $i, 'custom_admin_views.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/custom_admin_views/default_foot.php b/admin/tmpl/custom_admin_views/default_foot.php new file mode 100644 index 000000000..398ede1cc --- /dev/null +++ b/admin/tmpl/custom_admin_views/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/custom_admin_views/default_head.php b/admin/tmpl/custom_admin_views/default_head.php new file mode 100644 index 000000000..d4ae7396b --- /dev/null +++ b/admin/tmpl/custom_admin_views/default_head.php @@ -0,0 +1,59 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/custom_admin_views/default_toolbar.php b/admin/tmpl/custom_admin_views/default_toolbar.php new file mode 100644 index 000000000..8e6eb53da --- /dev/null +++ b/admin/tmpl/custom_admin_views/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/custom_admin_views/emptystate.php b/admin/tmpl/custom_admin_views/emptystate.php new file mode 100644 index 000000000..d23519d72 --- /dev/null +++ b/admin/tmpl/custom_admin_views/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEWS', + 'formURL' => 'index.php?option=com_componentbuilder&view=custom_admin_views', + 'icon' => 'icon-screen', +]; + +if ($this->user->authorise('custom_admin_view.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=custom_admin_view.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/templates/tmpl/index.html b/admin/tmpl/custom_admin_views/index.html similarity index 100% rename from admin/views/templates/tmpl/index.html rename to admin/tmpl/custom_admin_views/index.html diff --git a/admin/tmpl/custom_code/default.php b/admin/tmpl/custom_code/default.php new file mode 100644 index 000000000..d36a4cd11 --- /dev/null +++ b/admin/tmpl/custom_code/default.php @@ -0,0 +1,288 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/views/validation_rule/tmpl/index.html b/admin/tmpl/custom_code/index.html similarity index 100% rename from admin/views/validation_rule/tmpl/index.html rename to admin/tmpl/custom_code/index.html diff --git a/admin/tmpl/custom_codes/default.php b/admin/tmpl/custom_codes/default.php new file mode 100644 index 000000000..455424f32 --- /dev/null +++ b/admin/tmpl/custom_codes/default.php @@ -0,0 +1,80 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=custom_codes.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'custom_codeList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    + diff --git a/admin/tmpl/custom_codes/default_body.php b/admin/tmpl/custom_codes/default_body.php new file mode 100644 index 000000000..701e62c8a --- /dev/null +++ b/admin/tmpl/custom_codes/default_body.php @@ -0,0 +1,118 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=custom_codes&task=custom_code.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('custom_code',$item,'custom_codes'); + ?> + + + get('custom_code.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('custom_code.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('custom_code.edit')): ?> + escape($item->component_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'custom_codes.', $canCheckin); ?> + + + escape($item->component_system_name); ?> + +
    + + + escape($item->path); ?> + + + target); ?> + + + type); ?> + + + comment_type); ?> + + +
    target_code == 1): ?> + joomla_version}"; ?> + + # + +
    + + + get('custom_code.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'custom_codes.', true, 'cb'); ?> + + published, $i, 'custom_codes.', false, 'cb'); ?> + + + published, $i, 'custom_codes.', true, 'cb'); ?> + + + published, $i, 'custom_codes.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/custom_codes/default_foot.php b/admin/tmpl/custom_codes/default_foot.php new file mode 100644 index 000000000..57816d9c2 --- /dev/null +++ b/admin/tmpl/custom_codes/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/custom_codes/default_head.php b/admin/tmpl/custom_codes/default_head.php new file mode 100644 index 000000000..d69df9b72 --- /dev/null +++ b/admin/tmpl/custom_codes/default_head.php @@ -0,0 +1,65 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/custom_codes/default_toolbar.php b/admin/tmpl/custom_codes/default_toolbar.php new file mode 100644 index 000000000..17f06ff86 --- /dev/null +++ b/admin/tmpl/custom_codes/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/custom_codes/emptystate.php b/admin/tmpl/custom_codes/emptystate.php new file mode 100644 index 000000000..6bd7e86de --- /dev/null +++ b/admin/tmpl/custom_codes/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_CUSTOM_CODES', + 'formURL' => 'index.php?option=com_componentbuilder&view=custom_codes', + 'icon' => 'icon-shuffle', +]; + +if ($this->user->authorise('custom_code.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=custom_code.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/validation_rules/index.html b/admin/tmpl/custom_codes/index.html similarity index 100% rename from admin/views/validation_rules/index.html rename to admin/tmpl/custom_codes/index.html diff --git a/admin/tmpl/dynamic_get/default.php b/admin/tmpl/dynamic_get/default.php new file mode 100644 index 000000000..395475739 --- /dev/null +++ b/admin/tmpl/dynamic_get/default.php @@ -0,0 +1,716 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/views/validation_rules/tmpl/index.html b/admin/tmpl/dynamic_get/index.html similarity index 100% rename from admin/views/validation_rules/tmpl/index.html rename to admin/tmpl/dynamic_get/index.html diff --git a/admin/tmpl/dynamic_gets/default.php b/admin/tmpl/dynamic_gets/default.php new file mode 100644 index 000000000..d3cd2e989 --- /dev/null +++ b/admin/tmpl/dynamic_gets/default.php @@ -0,0 +1,80 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=dynamic_gets.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'dynamic_getList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    + diff --git a/admin/tmpl/dynamic_gets/default_body.php b/admin/tmpl/dynamic_gets/default_body.php new file mode 100644 index 000000000..4d2ad4993 --- /dev/null +++ b/admin/tmpl/dynamic_gets/default_body.php @@ -0,0 +1,104 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=dynamic_gets&task=dynamic_get.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('dynamic_get',$item,'dynamic_gets'); + ?> + + + get('dynamic_get.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('dynamic_get.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('dynamic_get.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'dynamic_gets.', $canCheckin); ?> + + + escape($item->name); ?> + +
    + + + main_source); ?> + + + gettype); ?> + + + get('dynamic_get.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'dynamic_gets.', true, 'cb'); ?> + + published, $i, 'dynamic_gets.', false, 'cb'); ?> + + + published, $i, 'dynamic_gets.', true, 'cb'); ?> + + + published, $i, 'dynamic_gets.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/dynamic_gets/default_foot.php b/admin/tmpl/dynamic_gets/default_foot.php new file mode 100644 index 000000000..8722e1abb --- /dev/null +++ b/admin/tmpl/dynamic_gets/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/dynamic_gets/default_head.php b/admin/tmpl/dynamic_gets/default_head.php new file mode 100644 index 000000000..9d8ae74d6 --- /dev/null +++ b/admin/tmpl/dynamic_gets/default_head.php @@ -0,0 +1,56 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/dynamic_gets/default_toolbar.php b/admin/tmpl/dynamic_gets/default_toolbar.php new file mode 100644 index 000000000..7aadb1d0b --- /dev/null +++ b/admin/tmpl/dynamic_gets/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/dynamic_gets/emptystate.php b/admin/tmpl/dynamic_gets/emptystate.php new file mode 100644 index 000000000..68f2e1bc8 --- /dev/null +++ b/admin/tmpl/dynamic_gets/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_DYNAMIC_GETS', + 'formURL' => 'index.php?option=com_componentbuilder&view=dynamic_gets', + 'icon' => 'icon-database', +]; + +if ($this->user->authorise('dynamic_get.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=dynamic_get.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/site/assets/css/index.html b/admin/tmpl/dynamic_gets/index.html similarity index 100% rename from site/assets/css/index.html rename to admin/tmpl/dynamic_gets/index.html diff --git a/admin/tmpl/field/default.php b/admin/tmpl/field/default.php new file mode 100644 index 000000000..4e84391eb --- /dev/null +++ b/admin/tmpl/field/default.php @@ -0,0 +1,392 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/site/assets/images/index.html b/admin/tmpl/field/index.html similarity index 100% rename from site/assets/images/index.html rename to admin/tmpl/field/index.html diff --git a/admin/tmpl/fields/default.php b/admin/tmpl/fields/default.php new file mode 100644 index 000000000..8ebbdb963 --- /dev/null +++ b/admin/tmpl/fields/default.php @@ -0,0 +1,80 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=fields.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'fieldList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    + diff --git a/admin/tmpl/fields/default_body.php b/admin/tmpl/fields/default_body.php new file mode 100644 index 000000000..085b6bcd0 --- /dev/null +++ b/admin/tmpl/fields/default_body.php @@ -0,0 +1,128 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=fields&task=field.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('field',$item,'fields'); + ?> + + + get('field.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('field.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('field.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'fields.', $canCheckin); ?> + + + escape($item->name); ?> + +
    + + +
    + user->authorise('fieldtype.edit', 'com_componentbuilder.fieldtype.' . (int) $item->fieldtype)): ?> + escape($item->fieldtype_name); ?> + + escape($item->fieldtype_name); ?> + +
    + + + datatype); ?> + + + indexes); ?> + + + null_switch); ?> + + + store); ?> + + +
    + user->authorise('core.edit', 'com_componentbuilder.field.category.' . (int)$item->catid)): ?> + escape($item->category_title); ?> + + escape($item->category_title); ?> + +
    + + + get('field.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'fields.', true, 'cb'); ?> + + published, $i, 'fields.', false, 'cb'); ?> + + + published, $i, 'fields.', true, 'cb'); ?> + + + published, $i, 'fields.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/fields/default_foot.php b/admin/tmpl/fields/default_foot.php new file mode 100644 index 000000000..57befc805 --- /dev/null +++ b/admin/tmpl/fields/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/fields/default_head.php b/admin/tmpl/fields/default_head.php new file mode 100644 index 000000000..51099810f --- /dev/null +++ b/admin/tmpl/fields/default_head.php @@ -0,0 +1,68 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/fields/default_toolbar.php b/admin/tmpl/fields/default_toolbar.php new file mode 100644 index 000000000..138bcdaa9 --- /dev/null +++ b/admin/tmpl/fields/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/fields/emptystate.php b/admin/tmpl/fields/emptystate.php new file mode 100644 index 000000000..9153f9847 --- /dev/null +++ b/admin/tmpl/fields/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_FIELDS', + 'formURL' => 'index.php?option=com_componentbuilder&view=fields', + 'icon' => 'icon-lamp', +]; + +if ($this->user->authorise('field.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=field.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/site/assets/index.html b/admin/tmpl/fields/index.html similarity index 100% rename from site/assets/index.html rename to admin/tmpl/fields/index.html diff --git a/admin/tmpl/fieldtype/default.php b/admin/tmpl/fieldtype/default.php new file mode 100644 index 000000000..584d7d34e --- /dev/null +++ b/admin/tmpl/fieldtype/default.php @@ -0,0 +1,547 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/site/assets/js/index.html b/admin/tmpl/fieldtype/index.html similarity index 100% rename from site/assets/js/index.html rename to admin/tmpl/fieldtype/index.html diff --git a/admin/tmpl/fieldtypes/default.php b/admin/tmpl/fieldtypes/default.php new file mode 100644 index 000000000..d2a7943b7 --- /dev/null +++ b/admin/tmpl/fieldtypes/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=fieldtypes.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'fieldtypeList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/fieldtypes/default_body.php b/admin/tmpl/fieldtypes/default_body.php new file mode 100644 index 000000000..346ef45ea --- /dev/null +++ b/admin/tmpl/fieldtypes/default_body.php @@ -0,0 +1,110 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=fieldtypes&task=fieldtype.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('fieldtype',$item,'fieldtypes'); + ?> + + + get('fieldtype.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('fieldtype.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('fieldtype.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'fieldtypes.', $canCheckin); ?> + + + escape($item->name); ?> + +
    + + + escape($item->short_description); ?> + + +
    + user->authorise('core.edit', 'com_componentbuilder.fieldtype.category.' . (int)$item->catid)): ?> + escape($item->category_title); ?> + + escape($item->category_title); ?> + +
    + + + get('fieldtype.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'fieldtypes.', true, 'cb'); ?> + + published, $i, 'fieldtypes.', false, 'cb'); ?> + + + published, $i, 'fieldtypes.', true, 'cb'); ?> + + + published, $i, 'fieldtypes.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/fieldtypes/default_foot.php b/admin/tmpl/fieldtypes/default_foot.php new file mode 100644 index 000000000..8722e1abb --- /dev/null +++ b/admin/tmpl/fieldtypes/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/fieldtypes/default_head.php b/admin/tmpl/fieldtypes/default_head.php new file mode 100644 index 000000000..48ae38ce8 --- /dev/null +++ b/admin/tmpl/fieldtypes/default_head.php @@ -0,0 +1,56 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/fieldtypes/default_toolbar.php b/admin/tmpl/fieldtypes/default_toolbar.php new file mode 100644 index 000000000..f773b1e46 --- /dev/null +++ b/admin/tmpl/fieldtypes/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/fieldtypes/emptystate.php b/admin/tmpl/fieldtypes/emptystate.php new file mode 100644 index 000000000..b2a984285 --- /dev/null +++ b/admin/tmpl/fieldtypes/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_FIELDTYPES', + 'formURL' => 'index.php?option=com_componentbuilder&view=fieldtypes', + 'icon' => 'icon-power-cord', +]; + +if ($this->user->authorise('fieldtype.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=fieldtype.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/site/controllers/index.html b/admin/tmpl/fieldtypes/index.html similarity index 100% rename from site/controllers/index.html rename to admin/tmpl/fieldtypes/index.html diff --git a/admin/tmpl/get_snippets/default.php b/admin/tmpl/get_snippets/default.php new file mode 100644 index 000000000..94233d109 --- /dev/null +++ b/admin/tmpl/get_snippets/default.php @@ -0,0 +1,261 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> +canDo->get('get_snippets.access')): ?> + + +
    + + +
    + +
    +


    +


    ..

    +
    + +
    +

    +
    + +
    +



    +

    +

    +

    +
    +
    +
    +



    +

    +

    +

    +
    +
    +
    +



    +

    +

    +

    +
    +
    +
    +



    +

    +

    +

    +
    +
    +
    +



    +

    +

    +

    +
    +
    + + + +

    + diff --git a/site/helpers/index.html b/admin/tmpl/get_snippets/index.html similarity index 100% rename from site/helpers/index.html rename to admin/tmpl/get_snippets/index.html diff --git a/admin/tmpl/help_document/default.php b/admin/tmpl/help_document/default.php new file mode 100644 index 000000000..20b321b04 --- /dev/null +++ b/admin/tmpl/help_document/default.php @@ -0,0 +1,189 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/site/index.html b/admin/tmpl/help_document/index.html similarity index 100% rename from site/index.html rename to admin/tmpl/help_document/index.html diff --git a/admin/tmpl/help_documents/default.php b/admin/tmpl/help_documents/default.php new file mode 100644 index 000000000..188109306 --- /dev/null +++ b/admin/tmpl/help_documents/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=help_documents.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'help_documentList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/help_documents/default_body.php b/admin/tmpl/help_documents/default_body.php new file mode 100644 index 000000000..f45d860a3 --- /dev/null +++ b/admin/tmpl/help_documents/default_body.php @@ -0,0 +1,113 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=help_documents&task=help_document.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('help_document',$item,'help_documents'); + ?> + + + get('help_document.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('help_document.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('help_document.edit')): ?> + escape($item->title); ?> + checked_out): ?> + name, $item->checked_out_time, 'help_documents.', $canCheckin); ?> + + + escape($item->title); ?> + +
    + + + type); ?> + + + escape($item->groups); ?> + + + location); ?> + + + escape($item->admin_view); ?> + + + escape($item->site_view); ?> + + + get('help_document.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'help_documents.', true, 'cb'); ?> + + published, $i, 'help_documents.', false, 'cb'); ?> + + + published, $i, 'help_documents.', true, 'cb'); ?> + + + published, $i, 'help_documents.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/help_documents/default_foot.php b/admin/tmpl/help_documents/default_foot.php new file mode 100644 index 000000000..57816d9c2 --- /dev/null +++ b/admin/tmpl/help_documents/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/help_documents/default_head.php b/admin/tmpl/help_documents/default_head.php new file mode 100644 index 000000000..850f7faa3 --- /dev/null +++ b/admin/tmpl/help_documents/default_head.php @@ -0,0 +1,65 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/help_documents/default_toolbar.php b/admin/tmpl/help_documents/default_toolbar.php new file mode 100644 index 000000000..1384c375f --- /dev/null +++ b/admin/tmpl/help_documents/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/help_documents/emptystate.php b/admin/tmpl/help_documents/emptystate.php new file mode 100644 index 000000000..83fbc9b86 --- /dev/null +++ b/admin/tmpl/help_documents/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_HELP_DOCUMENTS', + 'formURL' => 'index.php?option=com_componentbuilder&view=help_documents', + 'icon' => 'icon-support', +]; + +if ($this->user->authorise('help_document.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=help_document.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/site/language/en-GB/index.html b/admin/tmpl/help_documents/index.html similarity index 100% rename from site/language/en-GB/index.html rename to admin/tmpl/help_documents/index.html diff --git a/admin/tmpl/import/default.php b/admin/tmpl/import/default.php new file mode 100644 index 000000000..1a84f3c0b --- /dev/null +++ b/admin/tmpl/import/default.php @@ -0,0 +1,196 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\Router\Route; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +Html::_('jquery.framework'); +Html::_('bootstrap.tooltip'); +Html::_('script', 'system/core.js', false, true); +Html::_('behavior.keepalive'); + +?> + + +
    +
    +
    + + hasPackage && ArrayHelper::check($this->headerList) && ArrayHelper::check($this->headers)) : ?> +
    + +
    + +
    + +
    +
    + headerList as $name => $title): ?> +
    + +
    + +
    +
    + +
    + +
    +
    + + + 'upload')); ?> + + +
    + +
    + +
    + +
    +
    +
    +     (.csv .xls .ods) +
    +
    + + + +
    + +
    + +
    + +
    +
    +
    +     (.csv .xls .ods) +
    +
    + + + +
    + +
    + +
    + +
    +
    +
    +     (.csv .xls .ods) +
    +
    + + + + + + + +
    \ No newline at end of file diff --git a/site/language/index.html b/admin/tmpl/import/index.html similarity index 100% rename from site/language/index.html rename to admin/tmpl/import/index.html diff --git a/admin/tmpl/import_joomla_componentsimport/default.php b/admin/tmpl/import_joomla_componentsimport/default.php new file mode 100644 index 000000000..b1bfe05f7 --- /dev/null +++ b/admin/tmpl/import_joomla_componentsimport/default.php @@ -0,0 +1,565 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Router\Route; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Joomla\Utilities\ArrayHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +Html::_('jquery.framework'); +Html::_('bootstrap.tooltip'); +Html::_('script', 'system/core.js', false, true); +Html::_('behavior.keepalive'); + +?> + + +dataType === 'smart_package') ? '.zip' : 'none'; ?> +
    +
    + + sidebar)) : ?> +
    + sidebar; ?> +
    +
    + +
    + + +
    + hasPackage) && $this->hasPackage && $this->dataType === 'smart_package') : ?> + packageInfo['name']) && ArrayHelper::check($this->packageInfo['name'])) + { + $cAmount = count($this->packageInfo['name']); + $comP = ($cAmount == 1) ? 'Component' : 'Components'; + } + else + { + $cAmount = 1; + $comP = 'Component'; + } + $hasOwner = (isset($this->packageInfo['getKeyFrom']) && ArrayHelper::check($this->packageInfo['getKeyFrom'])) ? true:false; + $class1 = ($hasOwner) ? 'span6' : 'span12'; + ?> +

    +

    + 'advanced')); ?> + + +
    +
    + + formPackage): ?> + formPackage as $field): ?> +
    +
    label;?>
    +
    input;?>
    +
    + + +
    +
    + + +
    +
    +
    + +

    + +
    + +
    + owner($this->packageInfo); ?> +
    + + + + packageInfo['name']) && ArrayHelper::check($this->packageInfo['name'])) : ?> + + components($this->packageInfo); ?> + + + + + + + dataType === 'smart_package'): ?> +

    +

    + + 'upload')); ?> + + +
    + +
    + +
    + +
    +
    +
    +     () +
    +
    + + + +
    + +
    + +
    + +
    +
    +
    +     () +
    +
    + + + +
    + +
    + +
    + +
    +
    +
    +     () +
    +
    + + + vdmPackages) && ArrayHelper::check($this->vdmPackages)): ?> + +
    +
    +

    +

    +

    +
    +
    + + vdmPackages as $field): ?> +
    +
    label;?>
    +
    input;?>
    +
    + +
    +     +
    +
    +
    +
    +
    +
    +

    +
    +
    +
    + + + + jcbPackages) && ArrayHelper::check($this->jcbPackages)) : ?> + +
    +
    +

    +

    +

    +
    +
    + + jcbPackages as $field): ?> +
    +
    label;?>
    +
    input;?>
    +
    + +
    +     +
    +
    +
    +
    +
    +
    +

    +
    +
    +
    + + + + + + + + + +
    + +
    + diff --git a/site/layouts/index.html b/admin/tmpl/import_joomla_componentsimport/index.html similarity index 100% rename from site/layouts/index.html rename to admin/tmpl/import_joomla_componentsimport/index.html diff --git a/admin/tmpl/import_language_translationsimport/default.php b/admin/tmpl/import_language_translationsimport/default.php new file mode 100644 index 000000000..cfc44f90a --- /dev/null +++ b/admin/tmpl/import_language_translationsimport/default.php @@ -0,0 +1,240 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Router\Route; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Joomla\Utilities\ArrayHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +Html::_('jquery.framework'); +Html::_('bootstrap.tooltip'); +Html::_('script', 'system/core.js', false, true); +Html::_('behavior.keepalive'); + +?> + + + +
    +
    + + + sidebar)) : ?> +
    + sidebar; ?> +
    +
    + +
    + + + + hasPackage && ArrayHelper::check($this->headerList) && ArrayHelper::check($this->headers)) : ?> +
    + +
    + +
    + +
    +
    + headerList as $name => $title): ?> +
    + +
    + +
    +
    + +
    + +
    +
    + + + 'upload')); ?> + + +
    + +
    + +
    + +
    +
    +
    +     (.csv .xls .ods) +
    +
    + + + +
    + +
    + +
    + +
    +
    +
    +     (.csv .xls .ods) +
    +
    + + + + +
    + +
    + +
    + +
    +
    +
    +     (.csv .xls .ods) +
    +
    + + + + + + + +
    diff --git a/site/models/index.html b/admin/tmpl/import_language_translationsimport/index.html similarity index 100% rename from site/models/index.html rename to admin/tmpl/import_language_translationsimport/index.html diff --git a/site/views/api/index.html b/admin/tmpl/index.html similarity index 100% rename from site/views/api/index.html rename to admin/tmpl/index.html diff --git a/admin/tmpl/joomla_component/default.php b/admin/tmpl/joomla_component/default.php new file mode 100644 index 000000000..22cb8e898 --- /dev/null +++ b/admin/tmpl/joomla_component/default.php @@ -0,0 +1,794 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/site/views/api/tmpl/index.html b/admin/tmpl/joomla_component/index.html similarity index 100% rename from site/views/api/tmpl/index.html rename to admin/tmpl/joomla_component/index.html diff --git a/admin/tmpl/joomla_components/default.php b/admin/tmpl/joomla_components/default.php new file mode 100644 index 000000000..74b170a12 --- /dev/null +++ b/admin/tmpl/joomla_components/default.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=joomla_components.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'joomla_componentList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    + diff --git a/admin/tmpl/joomla_components/default_body.php b/admin/tmpl/joomla_components/default_body.php new file mode 100644 index 000000000..5397a605d --- /dev/null +++ b/admin/tmpl/joomla_components/default_body.php @@ -0,0 +1,241 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=joomla_components&task=joomla_component.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('joomla_component',$item,'joomla_components'); + ?> + + + get('joomla_component.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('joomla_component.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('joomla_component.edit')): ?> + escape($item->system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'joomla_components.', $canCheckin); ?> + + + escape($item->system_name); ?> + + - escape($item->component_version); ?> +
    + return_here is set + if (!isset($this->return_here)) + { + $this->return_here = urlencode(base64_encode((string) Uri::getInstance())); + } + // setup the buttons + if (!isset($_buttons) || !ArrayHelper::check($_buttons)) + { + $_buttons = array(); + $_buttons[0] = array( + array( + 'view' => 'component_admin_views', + 'views' => 'components_admin_views', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_COMPONENT_ADMIN_VIEWS'), + 'icon' => 'stack'), + array( + 'view' => 'component_custom_admin_views', + 'views' => 'components_custom_admin_views', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_COMPONENT_CUSTOM_ADMIN_VIEWS'), + 'icon' => 'screen'), + array( + 'view' => 'component_site_views', + 'views' => 'components_site_views', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_COMPONENT_SITE_VIEWS'), + 'icon' => 'palette'), + array( + 'view' => 'component_router', + 'views' => 'components_routers', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_COMPONENT_SITE_ROUTER'), + 'icon' => 'tree-2'), + array( + 'view' => 'component_config', + 'views' => 'components_config', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_COMPONENT_CONFIG'), + 'icon' => 'options') + ); + $_buttons[1] = array( + array( + 'view' => 'component_placeholders', + 'views' => 'components_placeholders', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_COMPONENT_PLACEHOLDERS'), + 'icon' => 'search'), + array( + 'view' => 'component_updates', + 'views' => 'components_updates', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_COMPONENT_UPDATES'), + 'icon' => 'database'), + array( + 'view' => 'component_mysql_tweaks', + 'views' => 'components_mysql_tweaks', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_COMPONENT_MYSQL_TWEAKS'), + 'icon' => 'screwdriver'), + array( + 'view' => 'component_files_folders', + 'views' => 'components_files_folders', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_COMPONENT_FILES_FOLDERS'), + 'icon' => 'briefcase') + ); + $_buttons[2] = array( + array( + 'view' => 'component_custom_admin_menus', + 'views' => 'components_custom_admin_menus', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_COMPONENT_CUSTOM_ADMIN_MENUS'), + 'icon' => 'plus'), + array( + 'view' => 'component_dashboard', + 'views' => 'components_dashboard', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_COMPONENT_DASHBOARD'), + 'icon' => 'dashboard'), + array( + 'view' => 'component_modules', + 'views' => 'components_modules', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_COMPONENT_MODULES'), + 'icon' => 'cube'), + array( + 'view' => 'component_plugins', + 'views' => 'components_plugins', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_COMPONENT_PLUGINS'), + 'icon' => 'power-cord') + ); + } + ?> +
    + + get($_button['view'].'.edit') && ($id = GetHelper::var($_button['view'], $item->id, 'joomla_component', 'id')) !== false): ?> + + get($_button['view'].'.create')): ?> + + + + +
    + + +
    + escape($item->name_code); ?> +
    +
    + + get($_button['view'].'.edit') && ($id = GetHelper::var($_button['view'], $item->id, 'joomla_component', 'id')) !== false): ?> + + get($_button['view'].'.create')): ?> + + + +
    + + +
    + escape($item->short_description); ?> +
    +
    + + get($_button['view'].'.edit') && ($id = GetHelper::var($_button['view'], $item->id, 'joomla_component', 'id')) !== false): ?> + + get($_button['view'].'.create')): ?> + + + +
    + + +
    escape($item->companyname); ?>
    + author)) : ?> + escape($item->author); ?>
    + + email) && StringHelper::check($item->author)) : ?> + + escape($item->email); ?> + +
    + + website) && StringHelper::check($item->author)) : ?> + + escape($item->website); ?> + + +
    + + + get('joomla_component.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'joomla_components.', true, 'cb'); ?> + + published, $i, 'joomla_components.', false, 'cb'); ?> + + + published, $i, 'joomla_components.', true, 'cb'); ?> + + + published, $i, 'joomla_components.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/joomla_components/default_foot.php b/admin/tmpl/joomla_components/default_foot.php new file mode 100644 index 000000000..398ede1cc --- /dev/null +++ b/admin/tmpl/joomla_components/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/joomla_components/default_head.php b/admin/tmpl/joomla_components/default_head.php new file mode 100644 index 000000000..b60a30dc7 --- /dev/null +++ b/admin/tmpl/joomla_components/default_head.php @@ -0,0 +1,59 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/joomla_components/default_toolbar.php b/admin/tmpl/joomla_components/default_toolbar.php new file mode 100644 index 000000000..45d34b0a1 --- /dev/null +++ b/admin/tmpl/joomla_components/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/joomla_components/emptystate.php b/admin/tmpl/joomla_components/emptystate.php new file mode 100644 index 000000000..2596e9b07 --- /dev/null +++ b/admin/tmpl/joomla_components/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENTS', + 'formURL' => 'index.php?option=com_componentbuilder&view=joomla_components', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('joomla_component.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=joomla_component.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/site/views/index.html b/admin/tmpl/joomla_components/index.html similarity index 100% rename from site/views/index.html rename to admin/tmpl/joomla_components/index.html diff --git a/admin/tmpl/joomla_module/default.php b/admin/tmpl/joomla_module/default.php new file mode 100644 index 000000000..2fe389ddd --- /dev/null +++ b/admin/tmpl/joomla_module/default.php @@ -0,0 +1,665 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/tmpl/joomla_module/index.html b/admin/tmpl/joomla_module/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/joomla_module/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/joomla_module_files_folders_urls/default.php b/admin/tmpl/joomla_module_files_folders_urls/default.php new file mode 100644 index 000000000..d0e703827 --- /dev/null +++ b/admin/tmpl/joomla_module_files_folders_urls/default.php @@ -0,0 +1,115 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + diff --git a/admin/tmpl/joomla_module_files_folders_urls/index.html b/admin/tmpl/joomla_module_files_folders_urls/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/joomla_module_files_folders_urls/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/joomla_module_updates/default.php b/admin/tmpl/joomla_module_updates/default.php new file mode 100644 index 000000000..bde2f1ae3 --- /dev/null +++ b/admin/tmpl/joomla_module_updates/default.php @@ -0,0 +1,105 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + diff --git a/admin/tmpl/joomla_module_updates/index.html b/admin/tmpl/joomla_module_updates/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/joomla_module_updates/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/joomla_modules/default.php b/admin/tmpl/joomla_modules/default.php new file mode 100644 index 000000000..dab282708 --- /dev/null +++ b/admin/tmpl/joomla_modules/default.php @@ -0,0 +1,81 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=joomla_modules.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'joomla_moduleList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    + diff --git a/admin/tmpl/joomla_modules/default_body.php b/admin/tmpl/joomla_modules/default_body.php new file mode 100644 index 000000000..8a7c8c956 --- /dev/null +++ b/admin/tmpl/joomla_modules/default_body.php @@ -0,0 +1,135 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=joomla_modules&task=joomla_module.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('joomla_module',$item,'joomla_modules'); + ?> + + + get('joomla_module.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('joomla_module.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('joomla_module.edit')): ?> + escape($item->system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'joomla_modules.', $canCheckin); ?> + + + escape($item->system_name); ?> + - + escape($item->module_version); ?> +
    + 'joomla_module_updates', + 'views' => 'joomla_modules_updates', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_MODULE_UPDATES'), + 'icon' => 'database'), + array( + 'view' => 'joomla_module_files_folders_urls', + 'views' => 'joomla_modules_files_folders_urls', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_MODULE_FILES_FOLDERS'), + 'icon' => 'briefcase') + ); + } + ?> +
    + + get($_button['view'].'.edit') && ($id = GetHelper::var($_button['view'], $item->id, 'joomla_module', 'id')) !== false): ?> + + get($_button['view'].'.create')): ?> + + + +
    + + + target); ?> + + + escape($item->description); ?> + + + get('joomla_module.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'joomla_modules.', true, 'cb'); ?> + + published, $i, 'joomla_modules.', false, 'cb'); ?> + + + published, $i, 'joomla_modules.', true, 'cb'); ?> + + + published, $i, 'joomla_modules.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/joomla_modules/default_foot.php b/admin/tmpl/joomla_modules/default_foot.php new file mode 100644 index 000000000..8722e1abb --- /dev/null +++ b/admin/tmpl/joomla_modules/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/joomla_modules/default_head.php b/admin/tmpl/joomla_modules/default_head.php new file mode 100644 index 000000000..6c72f4003 --- /dev/null +++ b/admin/tmpl/joomla_modules/default_head.php @@ -0,0 +1,56 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/joomla_modules/default_toolbar.php b/admin/tmpl/joomla_modules/default_toolbar.php new file mode 100644 index 000000000..1feadaecd --- /dev/null +++ b/admin/tmpl/joomla_modules/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/joomla_modules/emptystate.php b/admin/tmpl/joomla_modules/emptystate.php new file mode 100644 index 000000000..ccb89d844 --- /dev/null +++ b/admin/tmpl/joomla_modules/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_JOOMLA_MODULES', + 'formURL' => 'index.php?option=com_componentbuilder&view=joomla_modules', + 'icon' => 'icon-cube', +]; + +if ($this->user->authorise('joomla_module.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=joomla_module.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/joomla_modules/index.html b/admin/tmpl/joomla_modules/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/joomla_modules/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/joomla_modules_files_folders_urls/default.php b/admin/tmpl/joomla_modules_files_folders_urls/default.php new file mode 100644 index 000000000..0e2a96432 --- /dev/null +++ b/admin/tmpl/joomla_modules_files_folders_urls/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=joomla_modules_files_folders_urls.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'joomla_module_files_folders_urlsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/joomla_modules_files_folders_urls/default_body.php b/admin/tmpl/joomla_modules_files_folders_urls/default_body.php new file mode 100644 index 000000000..e61307b33 --- /dev/null +++ b/admin/tmpl/joomla_modules_files_folders_urls/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=joomla_modules_files_folders_urls&task=joomla_module_files_folders_urls.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('joomla_module_files_folders_urls',$item,'joomla_modules_files_folders_urls'); + ?> + + + get('joomla_module_files_folders_urls.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('joomla_module_files_folders_urls.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('joomla_module_files_folders_urls.edit')): ?> + escape($item->joomla_module_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'joomla_modules_files_folders_urls.', $canCheckin); ?> + + + escape($item->joomla_module_system_name); ?> + +
    + + + get('joomla_module_files_folders_urls.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'joomla_modules_files_folders_urls.', true, 'cb'); ?> + + published, $i, 'joomla_modules_files_folders_urls.', false, 'cb'); ?> + + + published, $i, 'joomla_modules_files_folders_urls.', true, 'cb'); ?> + + + published, $i, 'joomla_modules_files_folders_urls.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/joomla_modules_files_folders_urls/default_foot.php b/admin/tmpl/joomla_modules_files_folders_urls/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/joomla_modules_files_folders_urls/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/joomla_modules_files_folders_urls/default_head.php b/admin/tmpl/joomla_modules_files_folders_urls/default_head.php new file mode 100644 index 000000000..b816e7306 --- /dev/null +++ b/admin/tmpl/joomla_modules_files_folders_urls/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/joomla_modules_files_folders_urls/default_toolbar.php b/admin/tmpl/joomla_modules_files_folders_urls/default_toolbar.php new file mode 100644 index 000000000..1a2af9250 --- /dev/null +++ b/admin/tmpl/joomla_modules_files_folders_urls/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/joomla_modules_files_folders_urls/emptystate.php b/admin/tmpl/joomla_modules_files_folders_urls/emptystate.php new file mode 100644 index 000000000..ddfcee6c6 --- /dev/null +++ b/admin/tmpl/joomla_modules_files_folders_urls/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_JOOMLA_MODULES_FILES_FOLDERS_URLS', + 'formURL' => 'index.php?option=com_componentbuilder&view=joomla_modules_files_folders_urls', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('joomla_module_files_folders_urls.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=joomla_module_files_folders_urls.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/joomla_modules_files_folders_urls/index.html b/admin/tmpl/joomla_modules_files_folders_urls/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/joomla_modules_files_folders_urls/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/joomla_modules_updates/default.php b/admin/tmpl/joomla_modules_updates/default.php new file mode 100644 index 000000000..7f1a5b1f0 --- /dev/null +++ b/admin/tmpl/joomla_modules_updates/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=joomla_modules_updates.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'joomla_module_updatesList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/joomla_modules_updates/default_body.php b/admin/tmpl/joomla_modules_updates/default_body.php new file mode 100644 index 000000000..efa21d2f0 --- /dev/null +++ b/admin/tmpl/joomla_modules_updates/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=joomla_modules_updates&task=joomla_module_updates.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('joomla_module_updates',$item,'joomla_modules_updates'); + ?> + + + get('joomla_module_updates.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('joomla_module_updates.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('joomla_module_updates.edit')): ?> + escape($item->joomla_module_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'joomla_modules_updates.', $canCheckin); ?> + + + escape($item->joomla_module_system_name); ?> + +
    + + + get('joomla_module_updates.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'joomla_modules_updates.', true, 'cb'); ?> + + published, $i, 'joomla_modules_updates.', false, 'cb'); ?> + + + published, $i, 'joomla_modules_updates.', true, 'cb'); ?> + + + published, $i, 'joomla_modules_updates.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/joomla_modules_updates/default_foot.php b/admin/tmpl/joomla_modules_updates/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/joomla_modules_updates/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/joomla_modules_updates/default_head.php b/admin/tmpl/joomla_modules_updates/default_head.php new file mode 100644 index 000000000..6511f1804 --- /dev/null +++ b/admin/tmpl/joomla_modules_updates/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/joomla_modules_updates/default_toolbar.php b/admin/tmpl/joomla_modules_updates/default_toolbar.php new file mode 100644 index 000000000..04bc9f322 --- /dev/null +++ b/admin/tmpl/joomla_modules_updates/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/joomla_modules_updates/emptystate.php b/admin/tmpl/joomla_modules_updates/emptystate.php new file mode 100644 index 000000000..d8e5078a2 --- /dev/null +++ b/admin/tmpl/joomla_modules_updates/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES', + 'formURL' => 'index.php?option=com_componentbuilder&view=joomla_modules_updates', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('joomla_module_updates.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=joomla_module_updates.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/joomla_modules_updates/index.html b/admin/tmpl/joomla_modules_updates/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/joomla_modules_updates/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/joomla_plugin/default.php b/admin/tmpl/joomla_plugin/default.php new file mode 100644 index 000000000..b047c3768 --- /dev/null +++ b/admin/tmpl/joomla_plugin/default.php @@ -0,0 +1,659 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/tmpl/joomla_plugin/index.html b/admin/tmpl/joomla_plugin/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/joomla_plugin/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/joomla_plugin_files_folders_urls/default.php b/admin/tmpl/joomla_plugin_files_folders_urls/default.php new file mode 100644 index 000000000..e5b8b1293 --- /dev/null +++ b/admin/tmpl/joomla_plugin_files_folders_urls/default.php @@ -0,0 +1,115 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + diff --git a/admin/tmpl/joomla_plugin_files_folders_urls/index.html b/admin/tmpl/joomla_plugin_files_folders_urls/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/joomla_plugin_files_folders_urls/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/joomla_plugin_group/default.php b/admin/tmpl/joomla_plugin_group/default.php new file mode 100644 index 000000000..2c83260a6 --- /dev/null +++ b/admin/tmpl/joomla_plugin_group/default.php @@ -0,0 +1,105 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + diff --git a/admin/tmpl/joomla_plugin_group/index.html b/admin/tmpl/joomla_plugin_group/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/joomla_plugin_group/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/joomla_plugin_groups/default.php b/admin/tmpl/joomla_plugin_groups/default.php new file mode 100644 index 000000000..b4c337730 --- /dev/null +++ b/admin/tmpl/joomla_plugin_groups/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=joomla_plugin_groups.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'joomla_plugin_groupList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/joomla_plugin_groups/default_body.php b/admin/tmpl/joomla_plugin_groups/default_body.php new file mode 100644 index 000000000..0b2746114 --- /dev/null +++ b/admin/tmpl/joomla_plugin_groups/default_body.php @@ -0,0 +1,107 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=joomla_plugin_groups&task=joomla_plugin_group.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('joomla_plugin_group',$item,'joomla_plugin_groups'); + ?> + + + get('core.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('core.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('core.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'joomla_plugin_groups.', $canCheckin); ?> + + + escape($item->name); ?> + +
    + + +
    + user->authorise('class_extends.edit', 'com_componentbuilder.class_extends.' . (int) $item->class_extends)): ?> + escape($item->class_extends_name); ?> + + escape($item->class_extends_name); ?> + +
    + + + get('core.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'joomla_plugin_groups.', true, 'cb'); ?> + + published, $i, 'joomla_plugin_groups.', false, 'cb'); ?> + + + published, $i, 'joomla_plugin_groups.', true, 'cb'); ?> + + + published, $i, 'joomla_plugin_groups.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/joomla_plugin_groups/default_foot.php b/admin/tmpl/joomla_plugin_groups/default_foot.php new file mode 100644 index 000000000..b93986e05 --- /dev/null +++ b/admin/tmpl/joomla_plugin_groups/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/joomla_plugin_groups/default_head.php b/admin/tmpl/joomla_plugin_groups/default_head.php new file mode 100644 index 000000000..d34dfcdeb --- /dev/null +++ b/admin/tmpl/joomla_plugin_groups/default_head.php @@ -0,0 +1,53 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/joomla_plugin_groups/default_toolbar.php b/admin/tmpl/joomla_plugin_groups/default_toolbar.php new file mode 100644 index 000000000..7bc04d539 --- /dev/null +++ b/admin/tmpl/joomla_plugin_groups/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/joomla_plugin_groups/emptystate.php b/admin/tmpl/joomla_plugin_groups/emptystate.php new file mode 100644 index 000000000..1bc06e3d8 --- /dev/null +++ b/admin/tmpl/joomla_plugin_groups/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUPS', + 'formURL' => 'index.php?option=com_componentbuilder&view=joomla_plugin_groups', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('joomla_plugin_group.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=joomla_plugin_group.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/joomla_plugin_groups/index.html b/admin/tmpl/joomla_plugin_groups/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/joomla_plugin_groups/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/joomla_plugin_updates/default.php b/admin/tmpl/joomla_plugin_updates/default.php new file mode 100644 index 000000000..779c5cb08 --- /dev/null +++ b/admin/tmpl/joomla_plugin_updates/default.php @@ -0,0 +1,105 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + diff --git a/admin/tmpl/joomla_plugin_updates/index.html b/admin/tmpl/joomla_plugin_updates/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/joomla_plugin_updates/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/joomla_plugins/default.php b/admin/tmpl/joomla_plugins/default.php new file mode 100644 index 000000000..29b9bb0e9 --- /dev/null +++ b/admin/tmpl/joomla_plugins/default.php @@ -0,0 +1,81 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=joomla_plugins.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'joomla_pluginList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    + diff --git a/admin/tmpl/joomla_plugins/default_body.php b/admin/tmpl/joomla_plugins/default_body.php new file mode 100644 index 000000000..dae6294c1 --- /dev/null +++ b/admin/tmpl/joomla_plugins/default_body.php @@ -0,0 +1,147 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=joomla_plugins&task=joomla_plugin.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('joomla_plugin',$item,'joomla_plugins'); + ?> + + + get('joomla_plugin.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('joomla_plugin.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('joomla_plugin.edit')): ?> + escape($item->system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'joomla_plugins.', $canCheckin); ?> + + + escape($item->system_name); ?> + - + escape($item->plugin_version); ?> +
    + 'joomla_plugin_updates', + 'views' => 'joomla_plugins_updates', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_PLUGIN_UPDATES'), + 'icon' => 'database'), + array( + 'view' => 'joomla_plugin_files_folders_urls', + 'views' => 'joomla_plugins_files_folders_urls', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_PLUGIN_FILES_FOLDERS'), + 'icon' => 'briefcase') + ); + } + ?> +
    + + get($_button['view'].'.edit') && ($id = GetHelper::var($_button['view'], $item->id, 'joomla_plugin', 'id')) !== false): ?> + + get($_button['view'].'.create')): ?> + + + +
    + + +
    + user->authorise('class_extends.edit', 'com_componentbuilder.class_extends.' . (int) $item->class_extends)): ?> + escape($item->class_extends_name); ?> + + escape($item->class_extends_name); ?> + +
    + + +
    + user->authorise('core.edit', 'com_componentbuilder.joomla_plugin_group.' . (int) $item->joomla_plugin_group)): ?> + escape($item->joomla_plugin_group_name); ?> + + escape($item->joomla_plugin_group_name); ?> + +
    + + + get('joomla_plugin.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'joomla_plugins.', true, 'cb'); ?> + + published, $i, 'joomla_plugins.', false, 'cb'); ?> + + + published, $i, 'joomla_plugins.', true, 'cb'); ?> + + + published, $i, 'joomla_plugins.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/joomla_plugins/default_foot.php b/admin/tmpl/joomla_plugins/default_foot.php new file mode 100644 index 000000000..8722e1abb --- /dev/null +++ b/admin/tmpl/joomla_plugins/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/joomla_plugins/default_head.php b/admin/tmpl/joomla_plugins/default_head.php new file mode 100644 index 000000000..6c4e493dd --- /dev/null +++ b/admin/tmpl/joomla_plugins/default_head.php @@ -0,0 +1,56 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/joomla_plugins/default_toolbar.php b/admin/tmpl/joomla_plugins/default_toolbar.php new file mode 100644 index 000000000..c1adf1b91 --- /dev/null +++ b/admin/tmpl/joomla_plugins/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/joomla_plugins/emptystate.php b/admin/tmpl/joomla_plugins/emptystate.php new file mode 100644 index 000000000..1634035be --- /dev/null +++ b/admin/tmpl/joomla_plugins/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_JOOMLA_PLUGINS', + 'formURL' => 'index.php?option=com_componentbuilder&view=joomla_plugins', + 'icon' => 'icon-power-cord', +]; + +if ($this->user->authorise('joomla_plugin.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=joomla_plugin.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/joomla_plugins/index.html b/admin/tmpl/joomla_plugins/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/joomla_plugins/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/joomla_plugins_files_folders_urls/default.php b/admin/tmpl/joomla_plugins_files_folders_urls/default.php new file mode 100644 index 000000000..72f9d054a --- /dev/null +++ b/admin/tmpl/joomla_plugins_files_folders_urls/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=joomla_plugins_files_folders_urls.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'joomla_plugin_files_folders_urlsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/joomla_plugins_files_folders_urls/default_body.php b/admin/tmpl/joomla_plugins_files_folders_urls/default_body.php new file mode 100644 index 000000000..4173e36c0 --- /dev/null +++ b/admin/tmpl/joomla_plugins_files_folders_urls/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=joomla_plugins_files_folders_urls&task=joomla_plugin_files_folders_urls.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('joomla_plugin_files_folders_urls',$item,'joomla_plugins_files_folders_urls'); + ?> + + + get('joomla_plugin_files_folders_urls.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('joomla_plugin_files_folders_urls.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('joomla_plugin_files_folders_urls.edit')): ?> + escape($item->joomla_plugin_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'joomla_plugins_files_folders_urls.', $canCheckin); ?> + + + escape($item->joomla_plugin_system_name); ?> + +
    + + + get('joomla_plugin_files_folders_urls.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'joomla_plugins_files_folders_urls.', true, 'cb'); ?> + + published, $i, 'joomla_plugins_files_folders_urls.', false, 'cb'); ?> + + + published, $i, 'joomla_plugins_files_folders_urls.', true, 'cb'); ?> + + + published, $i, 'joomla_plugins_files_folders_urls.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/joomla_plugins_files_folders_urls/default_foot.php b/admin/tmpl/joomla_plugins_files_folders_urls/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/joomla_plugins_files_folders_urls/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/joomla_plugins_files_folders_urls/default_head.php b/admin/tmpl/joomla_plugins_files_folders_urls/default_head.php new file mode 100644 index 000000000..fa2f935dd --- /dev/null +++ b/admin/tmpl/joomla_plugins_files_folders_urls/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/joomla_plugins_files_folders_urls/default_toolbar.php b/admin/tmpl/joomla_plugins_files_folders_urls/default_toolbar.php new file mode 100644 index 000000000..e2b39d4e8 --- /dev/null +++ b/admin/tmpl/joomla_plugins_files_folders_urls/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/joomla_plugins_files_folders_urls/emptystate.php b/admin/tmpl/joomla_plugins_files_folders_urls/emptystate.php new file mode 100644 index 000000000..1db5e823b --- /dev/null +++ b/admin/tmpl/joomla_plugins_files_folders_urls/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS', + 'formURL' => 'index.php?option=com_componentbuilder&view=joomla_plugins_files_folders_urls', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('joomla_plugin_files_folders_urls.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=joomla_plugin_files_folders_urls.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/joomla_plugins_files_folders_urls/index.html b/admin/tmpl/joomla_plugins_files_folders_urls/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/joomla_plugins_files_folders_urls/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/joomla_plugins_updates/default.php b/admin/tmpl/joomla_plugins_updates/default.php new file mode 100644 index 000000000..22cf56a82 --- /dev/null +++ b/admin/tmpl/joomla_plugins_updates/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=joomla_plugins_updates.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'joomla_plugin_updatesList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/joomla_plugins_updates/default_body.php b/admin/tmpl/joomla_plugins_updates/default_body.php new file mode 100644 index 000000000..d1fb8daeb --- /dev/null +++ b/admin/tmpl/joomla_plugins_updates/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=joomla_plugins_updates&task=joomla_plugin_updates.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('joomla_plugin_updates',$item,'joomla_plugins_updates'); + ?> + + + get('joomla_plugin_updates.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('joomla_plugin_updates.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('joomla_plugin_updates.edit')): ?> + escape($item->joomla_plugin_system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'joomla_plugins_updates.', $canCheckin); ?> + + + escape($item->joomla_plugin_system_name); ?> + +
    + + + get('joomla_plugin_updates.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'joomla_plugins_updates.', true, 'cb'); ?> + + published, $i, 'joomla_plugins_updates.', false, 'cb'); ?> + + + published, $i, 'joomla_plugins_updates.', true, 'cb'); ?> + + + published, $i, 'joomla_plugins_updates.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/joomla_plugins_updates/default_foot.php b/admin/tmpl/joomla_plugins_updates/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/joomla_plugins_updates/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/joomla_plugins_updates/default_head.php b/admin/tmpl/joomla_plugins_updates/default_head.php new file mode 100644 index 000000000..6702c44f1 --- /dev/null +++ b/admin/tmpl/joomla_plugins_updates/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/joomla_plugins_updates/default_toolbar.php b/admin/tmpl/joomla_plugins_updates/default_toolbar.php new file mode 100644 index 000000000..5147a52b3 --- /dev/null +++ b/admin/tmpl/joomla_plugins_updates/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/joomla_plugins_updates/emptystate.php b/admin/tmpl/joomla_plugins_updates/emptystate.php new file mode 100644 index 000000000..f3b67f4b7 --- /dev/null +++ b/admin/tmpl/joomla_plugins_updates/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES', + 'formURL' => 'index.php?option=com_componentbuilder&view=joomla_plugins_updates', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('joomla_plugin_updates.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=joomla_plugin_updates.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/joomla_plugins_updates/index.html b/admin/tmpl/joomla_plugins_updates/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/joomla_plugins_updates/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/language/default.php b/admin/tmpl/language/default.php new file mode 100644 index 000000000..dd61e3d9f --- /dev/null +++ b/admin/tmpl/language/default.php @@ -0,0 +1,105 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + diff --git a/admin/tmpl/language/index.html b/admin/tmpl/language/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/language/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/language_translation/default.php b/admin/tmpl/language_translation/default.php new file mode 100644 index 000000000..7518593b5 --- /dev/null +++ b/admin/tmpl/language_translation/default.php @@ -0,0 +1,127 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/tmpl/language_translation/index.html b/admin/tmpl/language_translation/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/language_translation/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/language_translations/default.php b/admin/tmpl/language_translations/default.php new file mode 100644 index 000000000..730cf69f7 --- /dev/null +++ b/admin/tmpl/language_translations/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=language_translations.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'language_translationList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/language_translations/default_body.php b/admin/tmpl/language_translations/default_body.php new file mode 100644 index 000000000..45461ec72 --- /dev/null +++ b/admin/tmpl/language_translations/default_body.php @@ -0,0 +1,184 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=language_translations&task=language_translation.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('language_translation',$item,'language_translations'); + ?> + + + get('language_translation.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('language_translation.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('language_translation.edit')): ?> + source; ?> + checked_out): ?> + name, $item->checked_out_time, 'language_translations.', $canCheckin); ?> + + + source; ?> + + translation)) + { + $translations = json_decode($item->translation, true); + if (ArrayHelper::check($translations)) + { + foreach ($translations as $language) + { + if (isset($language['translation']) && StringHelper::check($language['translation']) + && isset($language['language']) && StringHelper::check($language['language'])) + { + $langBucket[$language['language']] = $language['language']; + } + } + } + } + // start how many usedin's + $counterUsedin = array(); + // set how many components use this string + if (JsonHelper::check($item->components)) + { + $item->components = json_decode($item->components, true); + } + if (($number = ArrayHelper::check($item->components)) !== false) + { + if ($number == 1) + { + $counterUsedin[] = $number . ' ' . Text::_('COM_COMPONENTBUILDER_COMPONENT'); + } + else + { + $counterUsedin[] = $number . ' ' . Text::_('COM_COMPONENTBUILDER_COMPONENTS'); + } + } + // set how many modules use this string + if (JsonHelper::check($item->modules)) + { + $item->modules = json_decode($item->modules, true); + } + if (($number = ArrayHelper::check($item->modules)) !== false) + { + if ($number == 1) + { + $counterUsedin[] = $number . ' ' . Text::_('COM_COMPONENTBUILDER_MODULE'); + } + else + { + $counterUsedin[] = $number . ' ' . Text::_('COM_COMPONENTBUILDER_MODULES'); + } + } + // set how many plugins use this string + if (JsonHelper::check($item->plugins)) + { + $item->plugins = json_decode($item->plugins, true); + } + if (($number = ArrayHelper::check($item->plugins)) !== false) + { + if ($number == 1) + { + $counterUsedin[] = $number . ' ' . Text::_('COM_COMPONENTBUILDER_PLUGIN'); + } + else + { + $counterUsedin[] = $number . ' ' . Text::_('COM_COMPONENTBUILDER_PLUGINS'); + } + } + // build the numbers + $numbersUsedin = ''; + if (ArrayHelper::check($counterUsedin)) + { + $numbersUsedin = '
    ' . Text::_('COM_COMPONENTBUILDER_USED_IN') . ' ' . implode('
    ', $counterUsedin); + } + // load the languages to the string + if (ArrayHelper::check($langBucket)) + { + echo '
    ' . Text::_('COM_COMPONENTBUILDER_ALREADY_TRANSLATED_INTO') . ' (' . implode(', ', $langBucket) . ')' . $numbersUsedin . ''; + } + else + { + echo '
    (' . Text::_('COM_COMPONENTBUILDER_NOTRANSLATION') . ')' . $numbersUsedin . ''; + } + ?> +
    + + + get('language_translation.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'language_translations.', true, 'cb'); ?> + + published, $i, 'language_translations.', false, 'cb'); ?> + + + published, $i, 'language_translations.', true, 'cb'); ?> + + + published, $i, 'language_translations.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/language_translations/default_foot.php b/admin/tmpl/language_translations/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/language_translations/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/language_translations/default_head.php b/admin/tmpl/language_translations/default_head.php new file mode 100644 index 000000000..24ea90ca1 --- /dev/null +++ b/admin/tmpl/language_translations/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/language_translations/default_toolbar.php b/admin/tmpl/language_translations/default_toolbar.php new file mode 100644 index 000000000..9100eb20a --- /dev/null +++ b/admin/tmpl/language_translations/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/language_translations/emptystate.php b/admin/tmpl/language_translations/emptystate.php new file mode 100644 index 000000000..da194b18f --- /dev/null +++ b/admin/tmpl/language_translations/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS', + 'formURL' => 'index.php?option=com_componentbuilder&view=language_translations', + 'icon' => 'icon-comments-2', +]; + +if ($this->user->authorise('language_translation.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=language_translation.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/language_translations/index.html b/admin/tmpl/language_translations/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/language_translations/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/languages/default.php b/admin/tmpl/languages/default.php new file mode 100644 index 000000000..a9ae5f784 --- /dev/null +++ b/admin/tmpl/languages/default.php @@ -0,0 +1,81 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=languages.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'languageList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    + diff --git a/admin/tmpl/languages/default_body.php b/admin/tmpl/languages/default_body.php new file mode 100644 index 000000000..694525286 --- /dev/null +++ b/admin/tmpl/languages/default_body.php @@ -0,0 +1,101 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=languages&task=language.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('language',$item,'languages'); + ?> + + + get('language.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('language.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('language.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'languages.', $canCheckin); ?> + + + escape($item->name); ?> + +
    + + + escape($item->langtag); ?> + + + get('language.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'languages.', true, 'cb'); ?> + + published, $i, 'languages.', false, 'cb'); ?> + + + published, $i, 'languages.', true, 'cb'); ?> + + + published, $i, 'languages.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/languages/default_foot.php b/admin/tmpl/languages/default_foot.php new file mode 100644 index 000000000..b93986e05 --- /dev/null +++ b/admin/tmpl/languages/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/languages/default_head.php b/admin/tmpl/languages/default_head.php new file mode 100644 index 000000000..869e71035 --- /dev/null +++ b/admin/tmpl/languages/default_head.php @@ -0,0 +1,53 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/languages/default_toolbar.php b/admin/tmpl/languages/default_toolbar.php new file mode 100644 index 000000000..0688bd2e8 --- /dev/null +++ b/admin/tmpl/languages/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/languages/emptystate.php b/admin/tmpl/languages/emptystate.php new file mode 100644 index 000000000..b452523ea --- /dev/null +++ b/admin/tmpl/languages/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_LANGUAGES', + 'formURL' => 'index.php?option=com_componentbuilder&view=languages', + 'icon' => 'icon-comment', +]; + +if ($this->user->authorise('language.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=language.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/languages/index.html b/admin/tmpl/languages/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/languages/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/layout/default.php b/admin/tmpl/layout/default.php new file mode 100644 index 000000000..fea913462 --- /dev/null +++ b/admin/tmpl/layout/default.php @@ -0,0 +1,231 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/tmpl/layout/index.html b/admin/tmpl/layout/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/layout/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/layouts/default.php b/admin/tmpl/layouts/default.php new file mode 100644 index 000000000..ff80ed9ac --- /dev/null +++ b/admin/tmpl/layouts/default.php @@ -0,0 +1,77 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=layouts.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'layoutList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    + diff --git a/admin/tmpl/layouts/default_body.php b/admin/tmpl/layouts/default_body.php new file mode 100644 index 000000000..f7db1bc56 --- /dev/null +++ b/admin/tmpl/layouts/default_body.php @@ -0,0 +1,118 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=layouts&task=layout.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('layout',$item,'layouts'); + ?> + + + get('core.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('core.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('core.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'layouts.', $canCheckin); ?> + + + escape($item->name); ?> +
    + <?php echo LayoutHelper::render('alias); ?>', [?]); ?> +
    + + +
    + escape($item->description); ?> +
      +
    • : + add_php_view); ?>
    • +
    +
    + + +
    + user->authorise('dynamic_get.edit', 'com_componentbuilder.dynamic_get.' . (int) $item->dynamic_get)): ?> + escape($item->dynamic_get_name); ?> + + escape($item->dynamic_get_name); ?> + +
    + + + get('core.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'layouts.', true, 'cb'); ?> + + published, $i, 'layouts.', false, 'cb'); ?> + + + published, $i, 'layouts.', true, 'cb'); ?> + + + published, $i, 'layouts.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/layouts/default_foot.php b/admin/tmpl/layouts/default_foot.php new file mode 100644 index 000000000..8722e1abb --- /dev/null +++ b/admin/tmpl/layouts/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/layouts/default_head.php b/admin/tmpl/layouts/default_head.php new file mode 100644 index 000000000..cbe511266 --- /dev/null +++ b/admin/tmpl/layouts/default_head.php @@ -0,0 +1,56 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/layouts/default_toolbar.php b/admin/tmpl/layouts/default_toolbar.php new file mode 100644 index 000000000..46fa1447b --- /dev/null +++ b/admin/tmpl/layouts/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/layouts/emptystate.php b/admin/tmpl/layouts/emptystate.php new file mode 100644 index 000000000..a7387805d --- /dev/null +++ b/admin/tmpl/layouts/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_LAYOUTS', + 'formURL' => 'index.php?option=com_componentbuilder&view=layouts', + 'icon' => 'icon-brush', +]; + +if ($this->user->authorise('layout.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=layout.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/layouts/index.html b/admin/tmpl/layouts/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/layouts/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/libraries/default.php b/admin/tmpl/libraries/default.php new file mode 100644 index 000000000..4eb0b0c9e --- /dev/null +++ b/admin/tmpl/libraries/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=libraries.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'libraryList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/libraries/default_body.php b/admin/tmpl/libraries/default_body.php new file mode 100644 index 000000000..4965b2b11 --- /dev/null +++ b/admin/tmpl/libraries/default_body.php @@ -0,0 +1,143 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\GetHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=libraries&task=library.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('library',$item,'libraries'); + ?> + + + get('library.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('library.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('library.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'libraries.', $canCheckin); ?> + + + escape($item->name); ?> + +
    + 'library_config', + 'views' => 'libraries_config', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_LIBRARY_CONFIG_FIELDS'), + 'icon' => 'options'), + array( + 'view' => 'library_files_folders_urls', + 'views' => 'libraries_files_folders_urls', + 'title' => Text::_('COM_COMPONENTBUILDER_THE_LIBRARY_FILES_FOLDERS_URLS'), + 'icon' => 'briefcase') + ); + } + ?> +
    + + get($_button['view'].'.edit') && ($id = GetHelper::var($_button['view'], $item->id, 'library', 'id')) !== false): ?> + + get($_button['view'].'.create')): ?> + + + +
    + + + target); ?> + + + escape($item->how); ?> + + + type); ?> + + + escape($item->description); ?> + + + get('library.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'libraries.', true, 'cb'); ?> + + published, $i, 'libraries.', false, 'cb'); ?> + + + published, $i, 'libraries.', true, 'cb'); ?> + + + published, $i, 'libraries.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/libraries/default_foot.php b/admin/tmpl/libraries/default_foot.php new file mode 100644 index 000000000..c5ab6bd63 --- /dev/null +++ b/admin/tmpl/libraries/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/libraries/default_head.php b/admin/tmpl/libraries/default_head.php new file mode 100644 index 000000000..3ac87f7c4 --- /dev/null +++ b/admin/tmpl/libraries/default_head.php @@ -0,0 +1,62 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/libraries/default_toolbar.php b/admin/tmpl/libraries/default_toolbar.php new file mode 100644 index 000000000..bc2614300 --- /dev/null +++ b/admin/tmpl/libraries/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/libraries/emptystate.php b/admin/tmpl/libraries/emptystate.php new file mode 100644 index 000000000..092fed7c4 --- /dev/null +++ b/admin/tmpl/libraries/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_LIBRARIES', + 'formURL' => 'index.php?option=com_componentbuilder&view=libraries', + 'icon' => 'icon-puzzle', +]; + +if ($this->user->authorise('library.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=library.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/libraries/index.html b/admin/tmpl/libraries/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/libraries/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/libraries_config/default.php b/admin/tmpl/libraries_config/default.php new file mode 100644 index 000000000..cdb39ebbc --- /dev/null +++ b/admin/tmpl/libraries_config/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=libraries_config.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'library_configList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/libraries_config/default_body.php b/admin/tmpl/libraries_config/default_body.php new file mode 100644 index 000000000..822835788 --- /dev/null +++ b/admin/tmpl/libraries_config/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=libraries_config&task=library_config.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('library_config',$item,'libraries_config'); + ?> + + + get('library_config.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('library_config.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('library_config.edit')): ?> + escape($item->library_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'libraries_config.', $canCheckin); ?> + + + escape($item->library_name); ?> + +
    + + + get('library_config.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'libraries_config.', true, 'cb'); ?> + + published, $i, 'libraries_config.', false, 'cb'); ?> + + + published, $i, 'libraries_config.', true, 'cb'); ?> + + + published, $i, 'libraries_config.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/libraries_config/default_foot.php b/admin/tmpl/libraries_config/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/libraries_config/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/libraries_config/default_head.php b/admin/tmpl/libraries_config/default_head.php new file mode 100644 index 000000000..ec2cb4a9d --- /dev/null +++ b/admin/tmpl/libraries_config/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/libraries_config/default_toolbar.php b/admin/tmpl/libraries_config/default_toolbar.php new file mode 100644 index 000000000..55de0c3ed --- /dev/null +++ b/admin/tmpl/libraries_config/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/libraries_config/emptystate.php b/admin/tmpl/libraries_config/emptystate.php new file mode 100644 index 000000000..33b27144d --- /dev/null +++ b/admin/tmpl/libraries_config/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_LIBRARIES_CONFIG', + 'formURL' => 'index.php?option=com_componentbuilder&view=libraries_config', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('library_config.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=library_config.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/libraries_config/index.html b/admin/tmpl/libraries_config/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/libraries_config/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/libraries_files_folders_urls/default.php b/admin/tmpl/libraries_files_folders_urls/default.php new file mode 100644 index 000000000..d04b314b0 --- /dev/null +++ b/admin/tmpl/libraries_files_folders_urls/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=libraries_files_folders_urls.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'library_files_folders_urlsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/libraries_files_folders_urls/default_body.php b/admin/tmpl/libraries_files_folders_urls/default_body.php new file mode 100644 index 000000000..01d1e25c9 --- /dev/null +++ b/admin/tmpl/libraries_files_folders_urls/default_body.php @@ -0,0 +1,98 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=libraries_files_folders_urls&task=library_files_folders_urls.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('library_files_folders_urls',$item,'libraries_files_folders_urls'); + ?> + + + get('library_files_folders_urls.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('library_files_folders_urls.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('library_files_folders_urls.edit')): ?> + escape($item->library_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'libraries_files_folders_urls.', $canCheckin); ?> + + + escape($item->library_name); ?> + +
    + + + get('library_files_folders_urls.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'libraries_files_folders_urls.', true, 'cb'); ?> + + published, $i, 'libraries_files_folders_urls.', false, 'cb'); ?> + + + published, $i, 'libraries_files_folders_urls.', true, 'cb'); ?> + + + published, $i, 'libraries_files_folders_urls.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/libraries_files_folders_urls/default_foot.php b/admin/tmpl/libraries_files_folders_urls/default_foot.php new file mode 100644 index 000000000..bd37c3de7 --- /dev/null +++ b/admin/tmpl/libraries_files_folders_urls/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/libraries_files_folders_urls/default_head.php b/admin/tmpl/libraries_files_folders_urls/default_head.php new file mode 100644 index 000000000..c96473780 --- /dev/null +++ b/admin/tmpl/libraries_files_folders_urls/default_head.php @@ -0,0 +1,50 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/libraries_files_folders_urls/default_toolbar.php b/admin/tmpl/libraries_files_folders_urls/default_toolbar.php new file mode 100644 index 000000000..989ea1703 --- /dev/null +++ b/admin/tmpl/libraries_files_folders_urls/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/libraries_files_folders_urls/emptystate.php b/admin/tmpl/libraries_files_folders_urls/emptystate.php new file mode 100644 index 000000000..103c9a6aa --- /dev/null +++ b/admin/tmpl/libraries_files_folders_urls/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS', + 'formURL' => 'index.php?option=com_componentbuilder&view=libraries_files_folders_urls', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('library_files_folders_urls.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=library_files_folders_urls.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/libraries_files_folders_urls/index.html b/admin/tmpl/libraries_files_folders_urls/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/libraries_files_folders_urls/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/library/default.php b/admin/tmpl/library/default.php new file mode 100644 index 000000000..391941996 --- /dev/null +++ b/admin/tmpl/library/default.php @@ -0,0 +1,608 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/tmpl/library/index.html b/admin/tmpl/library/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/library/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/library_config/default.php b/admin/tmpl/library_config/default.php new file mode 100644 index 000000000..6a1e87dca --- /dev/null +++ b/admin/tmpl/library_config/default.php @@ -0,0 +1,105 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + diff --git a/admin/tmpl/library_config/index.html b/admin/tmpl/library_config/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/library_config/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/library_files_folders_urls/default.php b/admin/tmpl/library_files_folders_urls/default.php new file mode 100644 index 000000000..38a8a2171 --- /dev/null +++ b/admin/tmpl/library_files_folders_urls/default.php @@ -0,0 +1,115 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + diff --git a/admin/tmpl/library_files_folders_urls/index.html b/admin/tmpl/library_files_folders_urls/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/library_files_folders_urls/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/placeholder/default.php b/admin/tmpl/placeholder/default.php new file mode 100644 index 000000000..f04f78b3d --- /dev/null +++ b/admin/tmpl/placeholder/default.php @@ -0,0 +1,156 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/tmpl/placeholder/index.html b/admin/tmpl/placeholder/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/placeholder/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/placeholders/default.php b/admin/tmpl/placeholders/default.php new file mode 100644 index 000000000..79894cdc7 --- /dev/null +++ b/admin/tmpl/placeholders/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=placeholders.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'placeholderList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/placeholders/default_body.php b/admin/tmpl/placeholders/default_body.php new file mode 100644 index 000000000..95b9508ed --- /dev/null +++ b/admin/tmpl/placeholders/default_body.php @@ -0,0 +1,101 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=placeholders&task=placeholder.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('placeholder',$item,'placeholders'); + ?> + + + get('placeholder.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('placeholder.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('placeholder.edit')): ?> + escape($item->target); ?> + checked_out): ?> + name, $item->checked_out_time, 'placeholders.', $canCheckin); ?> + + + escape($item->target); ?> + +
    + + + escape($item->value); ?> + + + get('placeholder.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'placeholders.', true, 'cb'); ?> + + published, $i, 'placeholders.', false, 'cb'); ?> + + + published, $i, 'placeholders.', true, 'cb'); ?> + + + published, $i, 'placeholders.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/placeholders/default_foot.php b/admin/tmpl/placeholders/default_foot.php new file mode 100644 index 000000000..b93986e05 --- /dev/null +++ b/admin/tmpl/placeholders/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/placeholders/default_head.php b/admin/tmpl/placeholders/default_head.php new file mode 100644 index 000000000..3a6942996 --- /dev/null +++ b/admin/tmpl/placeholders/default_head.php @@ -0,0 +1,53 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/placeholders/default_toolbar.php b/admin/tmpl/placeholders/default_toolbar.php new file mode 100644 index 000000000..38b73d4e9 --- /dev/null +++ b/admin/tmpl/placeholders/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/placeholders/emptystate.php b/admin/tmpl/placeholders/emptystate.php new file mode 100644 index 000000000..d6a101314 --- /dev/null +++ b/admin/tmpl/placeholders/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_PLACEHOLDERS', + 'formURL' => 'index.php?option=com_componentbuilder&view=placeholders', + 'icon' => 'icon-search', +]; + +if ($this->user->authorise('placeholder.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=placeholder.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/placeholders/index.html b/admin/tmpl/placeholders/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/placeholders/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/power/default.php b/admin/tmpl/power/default.php new file mode 100644 index 000000000..844f128d9 --- /dev/null +++ b/admin/tmpl/power/default.php @@ -0,0 +1,199 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/tmpl/power/index.html b/admin/tmpl/power/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/power/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/powers/default.php b/admin/tmpl/powers/default.php new file mode 100644 index 000000000..6ee091b04 --- /dev/null +++ b/admin/tmpl/powers/default.php @@ -0,0 +1,83 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=powers.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'powerList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    + diff --git a/admin/tmpl/powers/default_body.php b/admin/tmpl/powers/default_body.php new file mode 100644 index 000000000..e6dcdab21 --- /dev/null +++ b/admin/tmpl/powers/default_body.php @@ -0,0 +1,117 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=powers&task=power.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('power',$item,'powers'); + ?> + + + get('power.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('power.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('power.edit')): ?> + escape($item->system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'powers.', $canCheckin); ?> + + + escape($item->system_name); ?> +
    GUID: + escape($item->guid); ?>super_power_key)): ?>
    SPK: super_power_key; ?>
    +
    + + + namespace; ?> + + +
    : + type); ?>extends)) : ?>
    : + user->authorise('power.edit', 'com_componentbuilder.power.' . (int) $item->extends_id)): ?> + escape($item->extends_name); ?> + + escape($item->extends_name); ?> + extends === '-1') : ?>
    : + escape($item->extends_custom); ?>
    : + approved); ?> +
    + + + escape($item->power_version); ?> + + + get('power.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'powers.', true, 'cb'); ?> + + published, $i, 'powers.', false, 'cb'); ?> + + + published, $i, 'powers.', true, 'cb'); ?> + + + published, $i, 'powers.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/powers/default_foot.php b/admin/tmpl/powers/default_foot.php new file mode 100644 index 000000000..398ede1cc --- /dev/null +++ b/admin/tmpl/powers/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/powers/default_head.php b/admin/tmpl/powers/default_head.php new file mode 100644 index 000000000..3ce902428 --- /dev/null +++ b/admin/tmpl/powers/default_head.php @@ -0,0 +1,59 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/powers/default_toolbar.php b/admin/tmpl/powers/default_toolbar.php new file mode 100644 index 000000000..a3b1fcca8 --- /dev/null +++ b/admin/tmpl/powers/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/powers/emptystate.php b/admin/tmpl/powers/emptystate.php new file mode 100644 index 000000000..06abcdc0c --- /dev/null +++ b/admin/tmpl/powers/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_POWERS', + 'formURL' => 'index.php?option=com_componentbuilder&view=powers', + 'icon' => 'icon-flash', +]; + +if ($this->user->authorise('power.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=power.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/powers/index.html b/admin/tmpl/powers/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/powers/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/search/default.php b/admin/tmpl/search/default.php new file mode 100644 index 000000000..80384a124 --- /dev/null +++ b/admin/tmpl/search/default.php @@ -0,0 +1,360 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\ArrayHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); +use Joomla\CMS\Session\Session; + +// No direct access to this file +defined('_JEXEC') or die; + +// allow main menu selection +$this->app->input->set('hidemainmenu', false); + +// set the basu URL +$url_base = \JUri::base() . 'index.php?option=com_componentbuilder'; +$url_search = $url_base . '&view=search'; + +// get main search input field +$search_value = $this->form->getField('search_value'); + +?> +canDo->get('search.access')): ?> + +item->id)) ? '&id='. (int) $this->item->id : ''; ?> + +
    + form): ?> +
    +
    + + + +
    +
    + form->renderField('type_search'); ?> +
    + input; ?> + + +
    + form->renderField('replace_value'); ?> + +
    +
    + form->renderFieldset('settings'); ?> +
    +
    +
    +
    +
    + 'search_results_table', + 'headers' => $this->table_headers, + 'items' => 7, + 'init' => false, + 'table_class' => "table table-striped", + 'table_container_class' => "overflow-x-auto" + ]); ?> +
    +
    +
    + +
    + form->getInput('item_code'); ?> +
    +
    + + +
    + +
    +item['tables']) && ArrayHelper::check($this->item['tables'])) : ?> + + + +

    + diff --git a/admin/tmpl/search/index.html b/admin/tmpl/search/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/search/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/server/default.php b/admin/tmpl/server/default.php new file mode 100644 index 000000000..522197dcc --- /dev/null +++ b/admin/tmpl/server/default.php @@ -0,0 +1,293 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/tmpl/server/index.html b/admin/tmpl/server/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/server/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/servers/default.php b/admin/tmpl/servers/default.php new file mode 100644 index 000000000..d3d92f914 --- /dev/null +++ b/admin/tmpl/servers/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=servers.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'serverList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/servers/default_body.php b/admin/tmpl/servers/default_body.php new file mode 100644 index 000000000..2b4dadb00 --- /dev/null +++ b/admin/tmpl/servers/default_body.php @@ -0,0 +1,101 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=servers&task=server.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('server',$item,'servers'); + ?> + + + get('server.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('server.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('server.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'servers.', $canCheckin); ?> + + + escape($item->name); ?> + +
    + + + protocol); ?> + + + get('server.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'servers.', true, 'cb'); ?> + + published, $i, 'servers.', false, 'cb'); ?> + + + published, $i, 'servers.', true, 'cb'); ?> + + + published, $i, 'servers.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/servers/default_foot.php b/admin/tmpl/servers/default_foot.php new file mode 100644 index 000000000..b93986e05 --- /dev/null +++ b/admin/tmpl/servers/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/servers/default_head.php b/admin/tmpl/servers/default_head.php new file mode 100644 index 000000000..27705f992 --- /dev/null +++ b/admin/tmpl/servers/default_head.php @@ -0,0 +1,53 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/servers/default_toolbar.php b/admin/tmpl/servers/default_toolbar.php new file mode 100644 index 000000000..cb1f874a5 --- /dev/null +++ b/admin/tmpl/servers/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/servers/emptystate.php b/admin/tmpl/servers/emptystate.php new file mode 100644 index 000000000..274c89afa --- /dev/null +++ b/admin/tmpl/servers/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_SERVERS', + 'formURL' => 'index.php?option=com_componentbuilder&view=servers', + 'icon' => 'icon-flash', +]; + +if ($this->user->authorise('server.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=server.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/servers/index.html b/admin/tmpl/servers/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/servers/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/site_view/default.php b/admin/tmpl/site_view/default.php new file mode 100644 index 000000000..70c4a8579 --- /dev/null +++ b/admin/tmpl/site_view/default.php @@ -0,0 +1,457 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/tmpl/site_view/index.html b/admin/tmpl/site_view/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/site_view/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/site_views/default.php b/admin/tmpl/site_views/default.php new file mode 100644 index 000000000..4aaa8dcb9 --- /dev/null +++ b/admin/tmpl/site_views/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=site_views.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'site_viewList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/site_views/default_body.php b/admin/tmpl/site_views/default_body.php new file mode 100644 index 000000000..dceee1be3 --- /dev/null +++ b/admin/tmpl/site_views/default_body.php @@ -0,0 +1,130 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=site_views&task=site_view.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('site_view',$item,'site_views'); + ?> + + + get('core.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('core.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('core.edit')): ?> + escape($item->system_name); ?> + checked_out): ?> + name, $item->checked_out_time, 'site_views.', $canCheckin); ?> + + + escape($item->system_name); ?> + +
    + + +
    : + escape($item->name); ?>
    + : + escape($item->codename); ?>
    + context)): ?> + : + escape($item->context); ?> + +
    + + +
    + escape($item->description); ?> +
      +
    • : + add_custom_button); ?>
    • +
    • : + add_php_ajax); ?>
    • +
    +
    + + +
    + user->authorise('dynamic_get.edit', 'com_componentbuilder.dynamic_get.' . (int) $item->main_get)): ?> + escape($item->main_get_name); ?> + + escape($item->main_get_name); ?> + +
    + + + get('core.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'site_views.', true, 'cb'); ?> + + published, $i, 'site_views.', false, 'cb'); ?> + + + published, $i, 'site_views.', true, 'cb'); ?> + + + published, $i, 'site_views.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/site_views/default_foot.php b/admin/tmpl/site_views/default_foot.php new file mode 100644 index 000000000..398ede1cc --- /dev/null +++ b/admin/tmpl/site_views/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/site_views/default_head.php b/admin/tmpl/site_views/default_head.php new file mode 100644 index 000000000..a6d861513 --- /dev/null +++ b/admin/tmpl/site_views/default_head.php @@ -0,0 +1,59 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/site_views/default_toolbar.php b/admin/tmpl/site_views/default_toolbar.php new file mode 100644 index 000000000..241145486 --- /dev/null +++ b/admin/tmpl/site_views/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/site_views/emptystate.php b/admin/tmpl/site_views/emptystate.php new file mode 100644 index 000000000..de4312c7a --- /dev/null +++ b/admin/tmpl/site_views/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_SITE_VIEWS', + 'formURL' => 'index.php?option=com_componentbuilder&view=site_views', + 'icon' => 'icon-palette', +]; + +if ($this->user->authorise('site_view.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=site_view.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/site_views/index.html b/admin/tmpl/site_views/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/site_views/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/snippet/default.php b/admin/tmpl/snippet/default.php new file mode 100644 index 000000000..3772928e2 --- /dev/null +++ b/admin/tmpl/snippet/default.php @@ -0,0 +1,122 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    +
    + + +
    + + 'details', 'recall' => true]); ?> + + +
    +
    + +
    +
    + +
    +
    + + + +
    +
    + +
    +
    + +
    +
    +
    +
    + +
    +
    + + + ignore_fieldsets = array('details','metadata','vdmmetadata','accesscontrol'); ?> + tab_name = 'snippetTab'; ?> + + + canDo->get('core.edit.created_by') || $this->canDo->get('core.edit.created') || $this->canDo->get('core.edit.state') || ($this->canDo->get('core.delete') && $this->canDo->get('core.edit.state'))) : ?> + +
    +
    + +
    +
    + +
    +
    + + + + canDo->get('core.admin')) : ?> + +
    +
    +
    +
    + form->getFieldset('accesscontrol') as $field): ?> +
    + label; echo $field->input;?> +
    +
    + +
    +
    +
    +
    + + + + + +
    + + +
    +
    +
    +
    + + diff --git a/admin/tmpl/snippet/index.html b/admin/tmpl/snippet/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/snippet/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/snippet_type/default.php b/admin/tmpl/snippet_type/default.php new file mode 100644 index 000000000..77d7a3981 --- /dev/null +++ b/admin/tmpl/snippet_type/default.php @@ -0,0 +1,105 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + diff --git a/admin/tmpl/snippet_type/index.html b/admin/tmpl/snippet_type/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/snippet_type/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/snippet_types/default.php b/admin/tmpl/snippet_types/default.php new file mode 100644 index 000000000..42a440b60 --- /dev/null +++ b/admin/tmpl/snippet_types/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=snippet_types.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'snippet_typeList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/snippet_types/default_body.php b/admin/tmpl/snippet_types/default_body.php new file mode 100644 index 000000000..da5ba7b33 --- /dev/null +++ b/admin/tmpl/snippet_types/default_body.php @@ -0,0 +1,101 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=snippet_types&task=snippet_type.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('snippet_type',$item,'snippet_types'); + ?> + + + get('snippet_type.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('snippet_type.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('snippet_type.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'snippet_types.', $canCheckin); ?> + + + escape($item->name); ?> + +
    + + + escape($item->description); ?> + + + get('snippet_type.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'snippet_types.', true, 'cb'); ?> + + published, $i, 'snippet_types.', false, 'cb'); ?> + + + published, $i, 'snippet_types.', true, 'cb'); ?> + + + published, $i, 'snippet_types.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/snippet_types/default_foot.php b/admin/tmpl/snippet_types/default_foot.php new file mode 100644 index 000000000..b93986e05 --- /dev/null +++ b/admin/tmpl/snippet_types/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/snippet_types/default_head.php b/admin/tmpl/snippet_types/default_head.php new file mode 100644 index 000000000..89a7db645 --- /dev/null +++ b/admin/tmpl/snippet_types/default_head.php @@ -0,0 +1,53 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/snippet_types/default_toolbar.php b/admin/tmpl/snippet_types/default_toolbar.php new file mode 100644 index 000000000..c48b48874 --- /dev/null +++ b/admin/tmpl/snippet_types/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/snippet_types/emptystate.php b/admin/tmpl/snippet_types/emptystate.php new file mode 100644 index 000000000..e1d32654d --- /dev/null +++ b/admin/tmpl/snippet_types/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_SNIPPET_TYPES', + 'formURL' => 'index.php?option=com_componentbuilder&view=snippet_types', + 'icon' => 'icon-joomla', +]; + +if ($this->user->authorise('snippet_type.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=snippet_type.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/snippet_types/index.html b/admin/tmpl/snippet_types/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/snippet_types/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/snippets/default.php b/admin/tmpl/snippets/default.php new file mode 100644 index 000000000..ad0e89b86 --- /dev/null +++ b/admin/tmpl/snippets/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=snippets.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'snippetList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/snippets/default_body.php b/admin/tmpl/snippets/default_body.php new file mode 100644 index 000000000..8a696f7d6 --- /dev/null +++ b/admin/tmpl/snippets/default_body.php @@ -0,0 +1,116 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=snippets&task=snippet.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('snippet',$item,'snippets'); + ?> + + + get('core.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('core.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('core.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'snippets.', $canCheckin); ?> + + + escape($item->name); ?> + +
    + + + escape($item->url); ?> + + + escape($item->type_name); ?> + + + escape($item->heading); ?> + + +
    + user->authorise('library.edit', 'com_componentbuilder.library.' . (int) $item->library)): ?> + escape($item->library_name); ?> + + escape($item->library_name); ?> + +
    + + + get('core.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'snippets.', true, 'cb'); ?> + + published, $i, 'snippets.', false, 'cb'); ?> + + + published, $i, 'snippets.', true, 'cb'); ?> + + + published, $i, 'snippets.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/snippets/default_foot.php b/admin/tmpl/snippets/default_foot.php new file mode 100644 index 000000000..c5ab6bd63 --- /dev/null +++ b/admin/tmpl/snippets/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/snippets/default_head.php b/admin/tmpl/snippets/default_head.php new file mode 100644 index 000000000..2b4d52329 --- /dev/null +++ b/admin/tmpl/snippets/default_head.php @@ -0,0 +1,62 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/snippets/default_toolbar.php b/admin/tmpl/snippets/default_toolbar.php new file mode 100644 index 000000000..1f23a2a00 --- /dev/null +++ b/admin/tmpl/snippets/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/snippets/emptystate.php b/admin/tmpl/snippets/emptystate.php new file mode 100644 index 000000000..9a61ee2ed --- /dev/null +++ b/admin/tmpl/snippets/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_SNIPPETS', + 'formURL' => 'index.php?option=com_componentbuilder&view=snippets', + 'icon' => 'icon-pin', +]; + +if ($this->user->authorise('snippet.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=snippet.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/snippets/index.html b/admin/tmpl/snippets/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/snippets/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/template/default.php b/admin/tmpl/template/default.php new file mode 100644 index 000000000..637d66458 --- /dev/null +++ b/admin/tmpl/template/default.php @@ -0,0 +1,236 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/tmpl/template/index.html b/admin/tmpl/template/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/template/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/templates/default.php b/admin/tmpl/templates/default.php new file mode 100644 index 000000000..e8fbd96f7 --- /dev/null +++ b/admin/tmpl/templates/default.php @@ -0,0 +1,77 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=templates.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'templateList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    + diff --git a/admin/tmpl/templates/default_body.php b/admin/tmpl/templates/default_body.php new file mode 100644 index 000000000..caab355c6 --- /dev/null +++ b/admin/tmpl/templates/default_body.php @@ -0,0 +1,118 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=templates&task=template.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('template',$item,'templates'); + ?> + + + get('core.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('core.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('core.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'templates.', $canCheckin); ?> + + + escape($item->name); ?> +
    + <?php echo $this->loadTemplate('alias); ?>'); ?> +
    + + +
    + escape($item->description); ?> +
      +
    • : + add_php_view); ?>
    • +
    +
    + + +
    + user->authorise('dynamic_get.edit', 'com_componentbuilder.dynamic_get.' . (int) $item->dynamic_get)): ?> + escape($item->dynamic_get_name); ?> + + escape($item->dynamic_get_name); ?> + +
    + + + get('core.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'templates.', true, 'cb'); ?> + + published, $i, 'templates.', false, 'cb'); ?> + + + published, $i, 'templates.', true, 'cb'); ?> + + + published, $i, 'templates.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/templates/default_foot.php b/admin/tmpl/templates/default_foot.php new file mode 100644 index 000000000..8722e1abb --- /dev/null +++ b/admin/tmpl/templates/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/templates/default_head.php b/admin/tmpl/templates/default_head.php new file mode 100644 index 000000000..7dbc92a0a --- /dev/null +++ b/admin/tmpl/templates/default_head.php @@ -0,0 +1,56 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/templates/default_toolbar.php b/admin/tmpl/templates/default_toolbar.php new file mode 100644 index 000000000..f80f52afb --- /dev/null +++ b/admin/tmpl/templates/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/templates/emptystate.php b/admin/tmpl/templates/emptystate.php new file mode 100644 index 000000000..381f367f3 --- /dev/null +++ b/admin/tmpl/templates/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_TEMPLATES', + 'formURL' => 'index.php?option=com_componentbuilder&view=templates', + 'icon' => 'icon-brush', +]; + +if ($this->user->authorise('template.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=template.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/templates/index.html b/admin/tmpl/templates/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/templates/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/validation_rule/default.php b/admin/tmpl/validation_rule/default.php new file mode 100644 index 000000000..402a442ea --- /dev/null +++ b/admin/tmpl/validation_rule/default.php @@ -0,0 +1,161 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + + + diff --git a/admin/tmpl/validation_rule/index.html b/admin/tmpl/validation_rule/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/validation_rule/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tmpl/validation_rules/default.php b/admin/tmpl/validation_rules/default.php new file mode 100644 index 000000000..fb5ff5fc9 --- /dev/null +++ b/admin/tmpl/validation_rules/default.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=validation_rules.saveOrderAjax&tmpl=component'; + Html::_('sortablelist.sortable', 'validation_ruleList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
    +
    + $this)); +?> +items)): ?> +
    + +
    + + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
    + +
    + + + +
    diff --git a/admin/tmpl/validation_rules/default_body.php b/admin/tmpl/validation_rules/default_body.php new file mode 100644 index 000000000..975d1e15c --- /dev/null +++ b/admin/tmpl/validation_rules/default_body.php @@ -0,0 +1,101 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$edit = "index.php?option=com_componentbuilder&view=validation_rules&task=validation_rule.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); + $canDo = ComponentbuilderHelper::getActions('validation_rule',$item,'validation_rules'); + ?> + + + get('validation_rule.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . Html::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('validation_rule.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
    + get('validation_rule.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'validation_rules.', $canCheckin); ?> + + + escape($item->name); ?> + +
    + + + escape($item->short_description); ?> + + + get('validation_rule.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'validation_rules.', true, 'cb'); ?> + + published, $i, 'validation_rules.', false, 'cb'); ?> + + + published, $i, 'validation_rules.', true, 'cb'); ?> + + + published, $i, 'validation_rules.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/tmpl/validation_rules/default_foot.php b/admin/tmpl/validation_rules/default_foot.php new file mode 100644 index 000000000..b93986e05 --- /dev/null +++ b/admin/tmpl/validation_rules/default_foot.php @@ -0,0 +1,18 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/tmpl/validation_rules/default_head.php b/admin/tmpl/validation_rules/default_head.php new file mode 100644 index 000000000..fb33061b8 --- /dev/null +++ b/admin/tmpl/validation_rules/default_head.php @@ -0,0 +1,53 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/tmpl/validation_rules/default_toolbar.php b/admin/tmpl/validation_rules/default_toolbar.php new file mode 100644 index 000000000..8e42e40db --- /dev/null +++ b/admin/tmpl/validation_rules/default_toolbar.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +// No direct access to this file +defined('_JEXEC') or die; + +?> +
    + +
    + + +
    +
    + + pagination->getLimitBox(); ?> +
    +
    + + +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/admin/tmpl/validation_rules/emptystate.php b/admin/tmpl/validation_rules/emptystate.php new file mode 100644 index 000000000..50f418107 --- /dev/null +++ b/admin/tmpl/validation_rules/emptystate.php @@ -0,0 +1,28 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +use Joomla\CMS\Layout\LayoutHelper; + +// No direct access to this file +defined('_JEXEC') or die; + +$displayData = [ + 'textPrefix' => 'COM_COMPONENTBUILDER_VALIDATION_RULES', + 'formURL' => 'index.php?option=com_componentbuilder&view=validation_rules', + 'icon' => 'icon-shield', +]; + +if ($this->user->authorise('validation_rule.create', 'com_componentbuilder')) +{ + $displayData['createURL'] = 'index.php?option=com_componentbuilder&task=validation_rule.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/tmpl/validation_rules/index.html b/admin/tmpl/validation_rules/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/tmpl/validation_rules/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/admin_custom_tabs/submitbutton.js b/admin/views/admin_custom_tabs/submitbutton.js deleted file mode 100644 index 3136b79f5..000000000 --- a/admin/views/admin_custom_tabs/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('admin_custom_tabs, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/admin_custom_tabs/tmpl/edit.php b/admin/views/admin_custom_tabs/tmpl/edit.php deleted file mode 100644 index fa875b421..000000000 --- a/admin/views/admin_custom_tabs/tmpl/edit.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - diff --git a/admin/views/admin_custom_tabs/view.html.php b/admin/views/admin_custom_tabs/view.html.php deleted file mode 100644 index edfef670b..000000000 --- a/admin/views/admin_custom_tabs/view.html.php +++ /dev/null @@ -1,203 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Admin_custom_tabs Html View class - */ -class ComponentbuilderViewAdmin_custom_tabs extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('admin_custom_tabs', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_NEW' : 'COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('admin_custom_tabs.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('admin_custom_tabs.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('admin_custom_tabs.edit')) - { - // We can save the record. - JToolBarHelper::save('admin_custom_tabs.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('admin_custom_tabs.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('admin_custom_tabs.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('admin_custom_tabs.create')) - { - JToolBarHelper::apply('admin_custom_tabs.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('admin_custom_tabs.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('admin_custom_tabs.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('admin_custom_tabs.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('admin_custom_tabs.edit')) - { - // We can save the new record - JToolBarHelper::apply('admin_custom_tabs.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('admin_custom_tabs.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('admin_custom_tabs.create')) - { - JToolBarHelper::custom('admin_custom_tabs.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('admin_custom_tabs.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('admin_custom_tabs.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.admin_custom_tabs', $this->item->id); - } - if ($this->canDo->get('admin_custom_tabs.create')) - { - JToolBarHelper::custom('admin_custom_tabs.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('admin_custom_tabs.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('admin_custom_tabs'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_NEW' : 'COM_COMPONENTBUILDER_ADMIN_CUSTOM_TABS_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/admin_custom_tabs.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/admin_custom_tabs/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/admin_fields/submitbutton.js b/admin/views/admin_fields/submitbutton.js deleted file mode 100644 index e556dfa01..000000000 --- a/admin/views/admin_fields/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('admin_fields, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/admin_fields/tmpl/edit.php b/admin/views/admin_fields/tmpl/edit.php deleted file mode 100644 index fa4bab4ee..000000000 --- a/admin/views/admin_fields/tmpl/edit.php +++ /dev/null @@ -1,294 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/admin_fields/view.html.php b/admin/views/admin_fields/view.html.php deleted file mode 100644 index 082f6ed31..000000000 --- a/admin/views/admin_fields/view.html.php +++ /dev/null @@ -1,218 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Admin_fields Html View class - */ -class ComponentbuilderViewAdmin_fields extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('admin_fields', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_ADMIN_FIELDS_NEW' : 'COM_COMPONENTBUILDER_ADMIN_FIELDS_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('admin_fields.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('admin_fields.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('admin_fields.edit')) - { - // We can save the record. - JToolBarHelper::save('admin_fields.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('admin_fields.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('admin_fields.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('admin_fields.create')) - { - JToolBarHelper::apply('admin_fields.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('admin_fields.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('admin_fields.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('admin_fields.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('admin_fields.edit')) - { - // We can save the new record - JToolBarHelper::apply('admin_fields.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('admin_fields.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('admin_fields.create')) - { - JToolBarHelper::custom('admin_fields.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('admin_fields.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('admin_fields.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.admin_fields', $this->item->id); - } - if ($this->canDo->get('admin_fields.create')) - { - JToolBarHelper::custom('admin_fields.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('admin_fields.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('admin_fields'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_ADMIN_FIELDS_NEW' : 'COM_COMPONENTBUILDER_ADMIN_FIELDS_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/admin_fields.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/admin_fields/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - JText::script('COM_COMPONENTBUILDER_THE_BNONE_DBB_OPTION_WILL_REMOVE_THIS_FIELD_FROM_BEING_SAVED_IN_THE_DATABASE'); - JText::script('COM_COMPONENTBUILDER_ONLY_USE_THE_BNONE_DBB_OPTION_IF_YOU_ARE_PLANNING_ON_TARGETING_THIS_FIELD_WITH_JAVASCRIPTCUSTOM_PHP_TO_MOVE_ITS_VALUE_INTO_ANOTHER_FIELD_THAT_DOES_GET_SAVED_TO_THE_DATABASE'); - JText::script('COM_COMPONENTBUILDER_THE_BSHOW_IN_ALL_LIST_VIEWSB_OPTION_WILL_ADD_THIS_FIELD_TO_ALL_LIST_VIEWS_ADMIN_AMP_LINKED'); - JText::script('COM_COMPONENTBUILDER_THE_BONLY_IN_ADMIN_LIST_VIEWB_OPTION_WILL_ONLY_ADD_THIS_FIELD_TO_THE_ADMIN_LIST_VIEW_NOT_TO_ANY_LINKED_VIEWS'); - JText::script('COM_COMPONENTBUILDER_THE_BONLY_IN_LINKED_LIST_VIEWSB_OPTION_WILL_ONLY_ADD_THIS_FIELD_TO_THE_LINKED_LIST_VIEW_IF_THIS_VIEW_GETS_LINKED_TO_OTHER_VIEW_NOT_TO_THIS_ADMIN_LIST_VIEW'); - JText::script('COM_COMPONENTBUILDER_THESE_OPTIONS_ARE_NOT_AVAILABLE_TO_THE_FIELD_IF_BNONE_DBB_OPTION_IS_SELECTED'); - JText::script('COM_COMPONENTBUILDER_THESE_OPTIONS_ARE_ONLY_AVAILABLE_TO_THE_FIELD_IF_BSHOW_IN_LIST_VIEWB_OPTION_IS_SELECTED'); - JText::script('COM_COMPONENTBUILDER_THE_BMULTI_FILTERB_SELECTION_OPTION_ALLOWS_THE_USER_TO_SELECT_MORE_THEN_ONE_VALUE_IN_THIS_FILTERFIELD_PLEASE_NOTE_THAT_THIS_OPTION_BONLY_WORKSB_WITH_THE_BNEWB_FILTERS_THAT_LOAD_ABOVE_THE_ADMIN_LIST_VIEW_YOU_CAN_SELECT_THE_NEW_FILTER_OPTION_WHENWHERE_YOU_ADD_THE_VIEW_TO_THE_COMPONENT'); - JText::script('COM_COMPONENTBUILDER_THE_BSINGLE_FILTERB_SELECTION_OPTION_ALLOWS_THE_USER_TO_SELECT_JUST_ONE_VALUE_IN_THIS_FILTERFIELD'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/admin_fields_conditions/submitbutton.js b/admin/views/admin_fields_conditions/submitbutton.js deleted file mode 100644 index 8f895a98e..000000000 --- a/admin/views/admin_fields_conditions/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('admin_fields_conditions, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/admin_fields_conditions/tmpl/edit.php b/admin/views/admin_fields_conditions/tmpl/edit.php deleted file mode 100644 index 1545a7509..000000000 --- a/admin/views/admin_fields_conditions/tmpl/edit.php +++ /dev/null @@ -1,150 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/admin_fields_conditions/view.html.php b/admin/views/admin_fields_conditions/view.html.php deleted file mode 100644 index 931135f07..000000000 --- a/admin/views/admin_fields_conditions/view.html.php +++ /dev/null @@ -1,205 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Admin_fields_conditions Html View class - */ -class ComponentbuilderViewAdmin_fields_conditions extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('admin_fields_conditions', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_NEW' : 'COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('admin_fields_conditions.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('admin_fields_conditions.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('admin_fields_conditions.edit')) - { - // We can save the record. - JToolBarHelper::save('admin_fields_conditions.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('admin_fields_conditions.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('admin_fields_conditions.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('admin_fields_conditions.create')) - { - JToolBarHelper::apply('admin_fields_conditions.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('admin_fields_conditions.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('admin_fields_conditions.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('admin_fields_conditions.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('admin_fields_conditions.edit')) - { - // We can save the new record - JToolBarHelper::apply('admin_fields_conditions.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('admin_fields_conditions.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('admin_fields_conditions.create')) - { - JToolBarHelper::custom('admin_fields_conditions.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('admin_fields_conditions.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('admin_fields_conditions.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.admin_fields_conditions', $this->item->id); - } - if ($this->canDo->get('admin_fields_conditions.create')) - { - JToolBarHelper::custom('admin_fields_conditions.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('admin_fields_conditions.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('admin_fields_conditions'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_NEW' : 'COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/admin_fields_conditions.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/admin_fields_conditions/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/admin_fields_relations/submitbutton.js b/admin/views/admin_fields_relations/submitbutton.js deleted file mode 100644 index 1b4a2e852..000000000 --- a/admin/views/admin_fields_relations/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('admin_fields_relations, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/admin_fields_relations/tmpl/edit.php b/admin/views/admin_fields_relations/tmpl/edit.php deleted file mode 100644 index b94f1553f..000000000 --- a/admin/views/admin_fields_relations/tmpl/edit.php +++ /dev/null @@ -1,128 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/admin_fields_relations/view.html.php b/admin/views/admin_fields_relations/view.html.php deleted file mode 100644 index 10ac0243f..000000000 --- a/admin/views/admin_fields_relations/view.html.php +++ /dev/null @@ -1,209 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Admin_fields_relations Html View class - */ -class ComponentbuilderViewAdmin_fields_relations extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('admin_fields_relations', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_NEW' : 'COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('admin_fields_relations.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('admin_fields_relations.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('admin_fields_relations.edit')) - { - // We can save the record. - JToolBarHelper::save('admin_fields_relations.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('admin_fields_relations.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('admin_fields_relations.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('admin_fields_relations.create')) - { - JToolBarHelper::apply('admin_fields_relations.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('admin_fields_relations.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('admin_fields_relations.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('admin_fields_relations.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('admin_fields_relations.edit')) - { - // We can save the new record - JToolBarHelper::apply('admin_fields_relations.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('admin_fields_relations.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('admin_fields_relations.create')) - { - JToolBarHelper::custom('admin_fields_relations.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('admin_fields_relations.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('admin_fields_relations.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.admin_fields_relations', $this->item->id); - } - if ($this->canDo->get('admin_fields_relations.create')) - { - JToolBarHelper::custom('admin_fields_relations.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('admin_fields_relations.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('admin_fields_relations'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_NEW' : 'COM_COMPONENTBUILDER_ADMIN_FIELDS_RELATIONS_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/admin_fields_relations.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/admin_fields_relations/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/admin_view/submitbutton.js b/admin/views/admin_view/submitbutton.js deleted file mode 100644 index ae90ad060..000000000 --- a/admin/views/admin_view/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('admin_view, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/admin_view/tmpl/edit.php b/admin/views/admin_view/tmpl/edit.php deleted file mode 100644 index 349faeac3..000000000 --- a/admin/views/admin_view/tmpl/edit.php +++ /dev/null @@ -1,806 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/admin_view/view.html.php b/admin/views/admin_view/view.html.php deleted file mode 100644 index b65d8c47f..000000000 --- a/admin/views/admin_view/view.html.php +++ /dev/null @@ -1,215 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Admin_view Html View class - */ -class ComponentbuilderViewAdmin_view extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('admin_view', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_ADMIN_VIEW_NEW' : 'COM_COMPONENTBUILDER_ADMIN_VIEW_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('admin_view.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('admin_view.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('admin_view.edit')) - { - // We can save the record. - JToolBarHelper::save('admin_view.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('admin_view.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('admin_view.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('admin_view.create')) - { - JToolBarHelper::apply('admin_view.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('admin_view.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('admin_view.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('admin_view.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('admin_view.edit')) - { - // We can save the new record - JToolBarHelper::apply('admin_view.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('admin_view.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('admin_view.create')) - { - JToolBarHelper::custom('admin_view.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('admin_view.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('admin_view.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.admin_view', $this->item->id); - } - if ($this->canDo->get('admin_view.create')) - { - JToolBarHelper::custom('admin_view.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('admin_view.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('admin_view'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_ADMIN_VIEW_NEW' : 'COM_COMPONENTBUILDER_ADMIN_VIEW_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/admin_view.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/admin_view/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/admin_views/tmpl/default.php b/admin/views/admin_views/tmpl/default.php deleted file mode 100644 index 22163bb26..000000000 --- a/admin/views/admin_views/tmpl/default.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAdminviewsfiltertype', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_TYPE') . ' -')); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=admin_views.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'admin_viewList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_ADMIN_VIEWS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - - diff --git a/admin/views/admin_views/tmpl/default_batch_body.php b/admin/views/admin_views/tmpl/default_batch_body.php deleted file mode 100644 index 4bf6c5487..000000000 --- a/admin/views/admin_views/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/admin_views/tmpl/default_batch_footer.php b/admin/views/admin_views/tmpl/default_batch_footer.php deleted file mode 100644 index 6ae30f899..000000000 --- a/admin/views/admin_views/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/admin_views/tmpl/default_body.php b/admin/views/admin_views/tmpl/default_body.php deleted file mode 100644 index 38310f033..000000000 --- a/admin/views/admin_views/tmpl/default_body.php +++ /dev/null @@ -1,153 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); -use VDM\Joomla\Utilities\ArrayHelper; - -$edit = "index.php?option=com_componentbuilder&view=admin_views&task=admin_view.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('admin_view',$item,'admin_views'); - ?> - - - get('admin_view.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('admin_view.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('admin_view.edit')): ?> - escape($item->system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'admin_views.', $canCheckin); ?> - - - escape($item->system_name); ?> - - - - type); ?> -
    - 'admin_fields', - 'views' => 'admins_fields', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_ADMIN_FIELDS'), - 'icon' => 'list'), - array( - 'view' => 'admin_fields_relations', - 'views' => 'admins_fields_relations', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_ADMIN_FIELDS_RELATIONS'), - 'icon' => 'tree-2'), - array( - 'view' => 'admin_fields_conditions', - 'views' => 'admins_fields_conditions', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_ADMIN_FIELDS_CONDITIONS'), - 'icon' => 'shuffle'), - array( - 'view' => 'admin_custom_tabs', - 'views' => 'admins_custom_tabs', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_ADMIN_CUSTOM_TABS'), - 'icon' => 'folder-plus') - ); - } - ?> -
    - - get($_button['view'].'.edit') && ($id = ComponentbuilderHelper::getVar($_button['view'], $item->id, 'admin_view', 'id')) !== false): ?> - - get($_button['view'].'.create')): ?> - - - -
    - - -
    : - escape($item->name_single); ?>
    - : - escape($item->name_list); ?> -
    - - -
    - escape($item->short_description); ?> -
      -
    • : - add_custom_button); ?>
    • -
    • : - add_custom_import); ?>
    • -
    • : - add_fadein); ?>
    • -
    • : - add_php_ajax); ?>
    • -
    -
    - - - get('admin_view.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'admin_views.', true, 'cb'); ?> - - published, $i, 'admin_views.', false, 'cb'); ?> - - - published, $i, 'admin_views.', true, 'cb'); ?> - - - published, $i, 'admin_views.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/admin_views/tmpl/default_foot.php b/admin/views/admin_views/tmpl/default_foot.php deleted file mode 100644 index eff41e725..000000000 --- a/admin/views/admin_views/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/admin_views/tmpl/default_head.php b/admin/views/admin_views/tmpl/default_head.php deleted file mode 100644 index a00370493..000000000 --- a/admin/views/admin_views/tmpl/default_head.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/admin_views/tmpl/default_toolbar.php b/admin/views/admin_views/tmpl/default_toolbar.php deleted file mode 100644 index 8fce82e8a..000000000 --- a/admin/views/admin_views/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/admin_views/view.html.php b/admin/views/admin_views/view.html.php deleted file mode 100644 index 910c0d860..000000000 --- a/admin/views/admin_views/view.html.php +++ /dev/null @@ -1,338 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Admin_views - */ -class ComponentbuilderViewAdmin_views extends HtmlView -{ - /** - * Admin_views view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('admin_views'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('admin_view'); - $this->canEdit = $this->canDo->get('admin_view.edit'); - $this->canState = $this->canDo->get('admin_view.edit.state'); - $this->canCreate = $this->canDo->get('admin_view.create'); - $this->canDelete = $this->canDo->get('admin_view.delete'); - $this->canBatch = ($this->canDo->get('admin_view.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_ADMIN_VIEWS'), 'stack'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=admin_views'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('admin_view.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('admin_view.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('admin_views.publish'); - JToolBarHelper::unpublishList('admin_views.unpublish'); - JToolBarHelper::archiveList('admin_views.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('admin_views.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'admin_views.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('admin_views.trash'); - } - - if ($this->canDo->get('core.export') && $this->canDo->get('admin_view.export')) - { - JToolBarHelper::custom('admin_views.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); - } - } - if ($this->user->authorise('admin_view.run_expansion', 'com_componentbuilder')) - { - // add Run Expansion button. - JToolBarHelper::custom('admin_views.runExpansion', 'expand-2 custom-button-runexpansion', '', 'COM_COMPONENTBUILDER_RUN_EXPANSION', false); - } - - if ($this->canDo->get('core.import') && $this->canDo->get('admin_view.import')) - { - JToolBarHelper::custom('admin_views.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('admin_views'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - - // Only load Add Fadein batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Add Fadein Selection - $this->add_fadeinOptions = JFormHelper::loadFieldType('adminviewsfilteraddfadein')->options; - // We do some sanitation for Add Fadein filter - if (ComponentbuilderHelper::checkArray($this->add_fadeinOptions) && - isset($this->add_fadeinOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->add_fadeinOptions[0]->value)) - { - unset($this->add_fadeinOptions[0]); - } - // Add Fadein Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_FADEIN_LABEL').' -', - 'batch[add_fadein]', - JHtml::_('select.options', $this->add_fadeinOptions, 'value', 'text') - ); - } - - // Only load Type batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Type Selection - $this->typeOptions = JFormHelper::loadFieldType('adminviewsfiltertype')->options; - // We do some sanitation for Type filter - if (ComponentbuilderHelper::checkArray($this->typeOptions) && - isset($this->typeOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->typeOptions[0]->value)) - { - unset($this->typeOptions[0]); - } - // Type Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_ADMIN_VIEW_TYPE_LABEL').' -', - 'batch[type]', - JHtml::_('select.options', $this->typeOptions, 'value', 'text') - ); - } - - // Only load Add Custom Button batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Add Custom Button Selection - $this->add_custom_buttonOptions = JFormHelper::loadFieldType('adminviewsfilteraddcustombutton')->options; - // We do some sanitation for Add Custom Button filter - if (ComponentbuilderHelper::checkArray($this->add_custom_buttonOptions) && - isset($this->add_custom_buttonOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->add_custom_buttonOptions[0]->value)) - { - unset($this->add_custom_buttonOptions[0]); - } - // Add Custom Button Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_CUSTOM_BUTTON_LABEL').' -', - 'batch[add_custom_button]', - JHtml::_('select.options', $this->add_custom_buttonOptions, 'value', 'text') - ); - } - - // Only load Add Php Ajax batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Add Php Ajax Selection - $this->add_php_ajaxOptions = JFormHelper::loadFieldType('adminviewsfilteraddphpajax')->options; - // We do some sanitation for Add Php Ajax filter - if (ComponentbuilderHelper::checkArray($this->add_php_ajaxOptions) && - isset($this->add_php_ajaxOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->add_php_ajaxOptions[0]->value)) - { - unset($this->add_php_ajaxOptions[0]); - } - // Add Php Ajax Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_PHP_AJAX_LABEL').' -', - 'batch[add_php_ajax]', - JHtml::_('select.options', $this->add_php_ajaxOptions, 'value', 'text') - ); - } - - // Only load Add Custom Import batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Add Custom Import Selection - $this->add_custom_importOptions = JFormHelper::loadFieldType('adminviewsfilteraddcustomimport')->options; - // We do some sanitation for Add Custom Import filter - if (ComponentbuilderHelper::checkArray($this->add_custom_importOptions) && - isset($this->add_custom_importOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->add_custom_importOptions[0]->value)) - { - unset($this->add_custom_importOptions[0]); - } - // Add Custom Import Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_ADMIN_VIEW_ADD_CUSTOM_IMPORT_LABEL').' -', - 'batch[add_custom_import]', - JHtml::_('select.options', $this->add_custom_importOptions, 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_ADMIN_VIEWS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/admin_views.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.system_name' => JText::_('COM_COMPONENTBUILDER_ADMIN_VIEW_SYSTEM_NAME_LABEL'), - 'a.name_single' => JText::_('COM_COMPONENTBUILDER_ADMIN_VIEW_NAME_SINGLE_LABEL'), - 'a.short_description' => JText::_('COM_COMPONENTBUILDER_ADMIN_VIEW_SHORT_DESCRIPTION_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/admins_custom_tabs/tmpl/default.php b/admin/views/admins_custom_tabs/tmpl/default.php deleted file mode 100644 index 2f09fbdfd..000000000 --- a/admin/views/admins_custom_tabs/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=admins_custom_tabs.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'admin_custom_tabsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_ADMINS_CUSTOM_TABS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/admins_custom_tabs/tmpl/default_batch_body.php b/admin/views/admins_custom_tabs/tmpl/default_batch_body.php deleted file mode 100644 index fad921bcd..000000000 --- a/admin/views/admins_custom_tabs/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/admins_custom_tabs/tmpl/default_batch_footer.php b/admin/views/admins_custom_tabs/tmpl/default_batch_footer.php deleted file mode 100644 index 7f7aaa780..000000000 --- a/admin/views/admins_custom_tabs/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/admins_custom_tabs/tmpl/default_body.php b/admin/views/admins_custom_tabs/tmpl/default_body.php deleted file mode 100644 index 9929b4fe9..000000000 --- a/admin/views/admins_custom_tabs/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=admins_custom_tabs&task=admin_custom_tabs.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('admin_custom_tabs',$item,'admins_custom_tabs'); - ?> - - - get('admin_custom_tabs.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('admin_custom_tabs.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('admin_custom_tabs.edit')): ?> - escape($item->admin_view_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'admins_custom_tabs.', $canCheckin); ?> - - - escape($item->admin_view_system_name); ?> - -
    - - - get('admin_custom_tabs.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'admins_custom_tabs.', true, 'cb'); ?> - - published, $i, 'admins_custom_tabs.', false, 'cb'); ?> - - - published, $i, 'admins_custom_tabs.', true, 'cb'); ?> - - - published, $i, 'admins_custom_tabs.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/admins_custom_tabs/tmpl/default_foot.php b/admin/views/admins_custom_tabs/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/admins_custom_tabs/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/admins_custom_tabs/tmpl/default_head.php b/admin/views/admins_custom_tabs/tmpl/default_head.php deleted file mode 100644 index e60b8291c..000000000 --- a/admin/views/admins_custom_tabs/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/admins_custom_tabs/tmpl/default_toolbar.php b/admin/views/admins_custom_tabs/tmpl/default_toolbar.php deleted file mode 100644 index 5fd946a8e..000000000 --- a/admin/views/admins_custom_tabs/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/admins_custom_tabs/view.html.php b/admin/views/admins_custom_tabs/view.html.php deleted file mode 100644 index 84201b327..000000000 --- a/admin/views/admins_custom_tabs/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Admins_custom_tabs - */ -class ComponentbuilderViewAdmins_custom_tabs extends HtmlView -{ - /** - * Admins_custom_tabs view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('admins_custom_tabs'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('admin_custom_tabs'); - $this->canEdit = $this->canDo->get('admin_custom_tabs.edit'); - $this->canState = $this->canDo->get('admin_custom_tabs.edit.state'); - $this->canCreate = $this->canDo->get('admin_custom_tabs.create'); - $this->canDelete = $this->canDo->get('admin_custom_tabs.delete'); - $this->canBatch = ($this->canDo->get('admin_custom_tabs.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_ADMINS_CUSTOM_TABS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=admins_custom_tabs'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('admin_custom_tabs.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('admin_custom_tabs.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('admins_custom_tabs.publish'); - JToolBarHelper::unpublishList('admins_custom_tabs.unpublish'); - JToolBarHelper::archiveList('admins_custom_tabs.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('admins_custom_tabs.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'admins_custom_tabs.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('admins_custom_tabs.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('admins_custom_tabs'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_ADMINS_CUSTOM_TABS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/admins_custom_tabs.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/admins_fields/tmpl/default.php b/admin/views/admins_fields/tmpl/default.php deleted file mode 100644 index d01f39f80..000000000 --- a/admin/views/admins_fields/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=admins_fields.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'admin_fieldsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_ADMINS_FIELDS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/admins_fields/tmpl/default_batch_body.php b/admin/views/admins_fields/tmpl/default_batch_body.php deleted file mode 100644 index 65f459ce6..000000000 --- a/admin/views/admins_fields/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/admins_fields/tmpl/default_batch_footer.php b/admin/views/admins_fields/tmpl/default_batch_footer.php deleted file mode 100644 index d6a067041..000000000 --- a/admin/views/admins_fields/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/admins_fields/tmpl/default_body.php b/admin/views/admins_fields/tmpl/default_body.php deleted file mode 100644 index 1e88227a1..000000000 --- a/admin/views/admins_fields/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=admins_fields&task=admin_fields.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('admin_fields',$item,'admins_fields'); - ?> - - - get('admin_fields.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('admin_fields.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('admin_fields.edit')): ?> - escape($item->admin_view_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'admins_fields.', $canCheckin); ?> - - - escape($item->admin_view_system_name); ?> - -
    - - - get('admin_fields.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'admins_fields.', true, 'cb'); ?> - - published, $i, 'admins_fields.', false, 'cb'); ?> - - - published, $i, 'admins_fields.', true, 'cb'); ?> - - - published, $i, 'admins_fields.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/admins_fields/tmpl/default_foot.php b/admin/views/admins_fields/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/admins_fields/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/admins_fields/tmpl/default_head.php b/admin/views/admins_fields/tmpl/default_head.php deleted file mode 100644 index d1bf8ec2f..000000000 --- a/admin/views/admins_fields/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/admins_fields/tmpl/default_toolbar.php b/admin/views/admins_fields/tmpl/default_toolbar.php deleted file mode 100644 index 4a686fa29..000000000 --- a/admin/views/admins_fields/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/admins_fields/view.html.php b/admin/views/admins_fields/view.html.php deleted file mode 100644 index ef6cad1dc..000000000 --- a/admin/views/admins_fields/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Admins_fields - */ -class ComponentbuilderViewAdmins_fields extends HtmlView -{ - /** - * Admins_fields view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('admins_fields'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('admin_fields'); - $this->canEdit = $this->canDo->get('admin_fields.edit'); - $this->canState = $this->canDo->get('admin_fields.edit.state'); - $this->canCreate = $this->canDo->get('admin_fields.create'); - $this->canDelete = $this->canDo->get('admin_fields.delete'); - $this->canBatch = ($this->canDo->get('admin_fields.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_ADMINS_FIELDS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=admins_fields'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('admin_fields.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('admin_fields.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('admins_fields.publish'); - JToolBarHelper::unpublishList('admins_fields.unpublish'); - JToolBarHelper::archiveList('admins_fields.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('admins_fields.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'admins_fields.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('admins_fields.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('admins_fields'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_ADMINS_FIELDS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/admins_fields.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/admins_fields_conditions/tmpl/default.php b/admin/views/admins_fields_conditions/tmpl/default.php deleted file mode 100644 index be3a6f921..000000000 --- a/admin/views/admins_fields_conditions/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=admins_fields_conditions.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'admin_fields_conditionsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_ADMINS_FIELDS_CONDITIONS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/admins_fields_conditions/tmpl/default_batch_body.php b/admin/views/admins_fields_conditions/tmpl/default_batch_body.php deleted file mode 100644 index 822e061b8..000000000 --- a/admin/views/admins_fields_conditions/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/admins_fields_conditions/tmpl/default_batch_footer.php b/admin/views/admins_fields_conditions/tmpl/default_batch_footer.php deleted file mode 100644 index 1b5a0ab74..000000000 --- a/admin/views/admins_fields_conditions/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/admins_fields_conditions/tmpl/default_body.php b/admin/views/admins_fields_conditions/tmpl/default_body.php deleted file mode 100644 index 432b6ae1c..000000000 --- a/admin/views/admins_fields_conditions/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=admins_fields_conditions&task=admin_fields_conditions.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('admin_fields_conditions',$item,'admins_fields_conditions'); - ?> - - - get('admin_fields_conditions.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('admin_fields_conditions.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('admin_fields_conditions.edit')): ?> - escape($item->admin_view_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'admins_fields_conditions.', $canCheckin); ?> - - - escape($item->admin_view_system_name); ?> - -
    - - - get('admin_fields_conditions.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'admins_fields_conditions.', true, 'cb'); ?> - - published, $i, 'admins_fields_conditions.', false, 'cb'); ?> - - - published, $i, 'admins_fields_conditions.', true, 'cb'); ?> - - - published, $i, 'admins_fields_conditions.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/admins_fields_conditions/tmpl/default_foot.php b/admin/views/admins_fields_conditions/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/admins_fields_conditions/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/admins_fields_conditions/tmpl/default_head.php b/admin/views/admins_fields_conditions/tmpl/default_head.php deleted file mode 100644 index 1067d645e..000000000 --- a/admin/views/admins_fields_conditions/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/admins_fields_conditions/tmpl/default_toolbar.php b/admin/views/admins_fields_conditions/tmpl/default_toolbar.php deleted file mode 100644 index 2a8196011..000000000 --- a/admin/views/admins_fields_conditions/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/admins_fields_conditions/view.html.php b/admin/views/admins_fields_conditions/view.html.php deleted file mode 100644 index d99212b9c..000000000 --- a/admin/views/admins_fields_conditions/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Admins_fields_conditions - */ -class ComponentbuilderViewAdmins_fields_conditions extends HtmlView -{ - /** - * Admins_fields_conditions view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('admins_fields_conditions'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('admin_fields_conditions'); - $this->canEdit = $this->canDo->get('admin_fields_conditions.edit'); - $this->canState = $this->canDo->get('admin_fields_conditions.edit.state'); - $this->canCreate = $this->canDo->get('admin_fields_conditions.create'); - $this->canDelete = $this->canDo->get('admin_fields_conditions.delete'); - $this->canBatch = ($this->canDo->get('admin_fields_conditions.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_ADMINS_FIELDS_CONDITIONS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=admins_fields_conditions'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('admin_fields_conditions.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('admin_fields_conditions.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('admins_fields_conditions.publish'); - JToolBarHelper::unpublishList('admins_fields_conditions.unpublish'); - JToolBarHelper::archiveList('admins_fields_conditions.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('admins_fields_conditions.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'admins_fields_conditions.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('admins_fields_conditions.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('admins_fields_conditions'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_ADMINS_FIELDS_CONDITIONS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/admins_fields_conditions.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/admins_fields_relations/tmpl/default.php b/admin/views/admins_fields_relations/tmpl/default.php deleted file mode 100644 index e515b42ea..000000000 --- a/admin/views/admins_fields_relations/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=admins_fields_relations.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'admin_fields_relationsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_ADMINS_FIELDS_RELATIONS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/admins_fields_relations/tmpl/default_batch_body.php b/admin/views/admins_fields_relations/tmpl/default_batch_body.php deleted file mode 100644 index f45996a1e..000000000 --- a/admin/views/admins_fields_relations/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/admins_fields_relations/tmpl/default_batch_footer.php b/admin/views/admins_fields_relations/tmpl/default_batch_footer.php deleted file mode 100644 index adc091fbb..000000000 --- a/admin/views/admins_fields_relations/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/admins_fields_relations/tmpl/default_body.php b/admin/views/admins_fields_relations/tmpl/default_body.php deleted file mode 100644 index 7c5fb6506..000000000 --- a/admin/views/admins_fields_relations/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=admins_fields_relations&task=admin_fields_relations.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('admin_fields_relations',$item,'admins_fields_relations'); - ?> - - - get('admin_fields_relations.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('admin_fields_relations.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('admin_fields_relations.edit')): ?> - escape($item->admin_view_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'admins_fields_relations.', $canCheckin); ?> - - - escape($item->admin_view_system_name); ?> - -
    - - - get('admin_fields_relations.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'admins_fields_relations.', true, 'cb'); ?> - - published, $i, 'admins_fields_relations.', false, 'cb'); ?> - - - published, $i, 'admins_fields_relations.', true, 'cb'); ?> - - - published, $i, 'admins_fields_relations.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/admins_fields_relations/tmpl/default_foot.php b/admin/views/admins_fields_relations/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/admins_fields_relations/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/admins_fields_relations/tmpl/default_head.php b/admin/views/admins_fields_relations/tmpl/default_head.php deleted file mode 100644 index 2557d2a11..000000000 --- a/admin/views/admins_fields_relations/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/admins_fields_relations/tmpl/default_toolbar.php b/admin/views/admins_fields_relations/tmpl/default_toolbar.php deleted file mode 100644 index 236c32115..000000000 --- a/admin/views/admins_fields_relations/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/admins_fields_relations/view.html.php b/admin/views/admins_fields_relations/view.html.php deleted file mode 100644 index dfcada8ef..000000000 --- a/admin/views/admins_fields_relations/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Admins_fields_relations - */ -class ComponentbuilderViewAdmins_fields_relations extends HtmlView -{ - /** - * Admins_fields_relations view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('admins_fields_relations'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('admin_fields_relations'); - $this->canEdit = $this->canDo->get('admin_fields_relations.edit'); - $this->canState = $this->canDo->get('admin_fields_relations.edit.state'); - $this->canCreate = $this->canDo->get('admin_fields_relations.create'); - $this->canDelete = $this->canDo->get('admin_fields_relations.delete'); - $this->canBatch = ($this->canDo->get('admin_fields_relations.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_ADMINS_FIELDS_RELATIONS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=admins_fields_relations'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('admin_fields_relations.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('admin_fields_relations.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('admins_fields_relations.publish'); - JToolBarHelper::unpublishList('admins_fields_relations.unpublish'); - JToolBarHelper::archiveList('admins_fields_relations.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('admins_fields_relations.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'admins_fields_relations.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('admins_fields_relations.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('admins_fields_relations'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_ADMINS_FIELDS_RELATIONS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/admins_fields_relations.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/class_extendings/tmpl/default.php b/admin/views/class_extendings/tmpl/default.php deleted file mode 100644 index 053a616f2..000000000 --- a/admin/views/class_extendings/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=class_extendings.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'class_extendsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_CLASS_EXTENDINGS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/class_extendings/tmpl/default_batch_body.php b/admin/views/class_extendings/tmpl/default_batch_body.php deleted file mode 100644 index ed473bd78..000000000 --- a/admin/views/class_extendings/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/class_extendings/tmpl/default_batch_footer.php b/admin/views/class_extendings/tmpl/default_batch_footer.php deleted file mode 100644 index abd385711..000000000 --- a/admin/views/class_extendings/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/class_extendings/tmpl/default_body.php b/admin/views/class_extendings/tmpl/default_body.php deleted file mode 100644 index b0c9ea780..000000000 --- a/admin/views/class_extendings/tmpl/default_body.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=class_extendings&task=class_extends.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('class_extends',$item,'class_extendings'); - ?> - - - get('class_extends.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('class_extends.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('class_extends.edit')): ?> - escape($item->name); ?> - checked_out): ?> - name, $item->checked_out_time, 'class_extendings.', $canCheckin); ?> - - - escape($item->name); ?> - -
    - - - extension_type); ?> - - - get('class_extends.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'class_extendings.', true, 'cb'); ?> - - published, $i, 'class_extendings.', false, 'cb'); ?> - - - published, $i, 'class_extendings.', true, 'cb'); ?> - - - published, $i, 'class_extendings.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/class_extendings/tmpl/default_foot.php b/admin/views/class_extendings/tmpl/default_foot.php deleted file mode 100644 index 95317c3bb..000000000 --- a/admin/views/class_extendings/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/class_extendings/tmpl/default_head.php b/admin/views/class_extendings/tmpl/default_head.php deleted file mode 100644 index 40bee431c..000000000 --- a/admin/views/class_extendings/tmpl/default_head.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/class_extendings/tmpl/default_toolbar.php b/admin/views/class_extendings/tmpl/default_toolbar.php deleted file mode 100644 index 18c6a9ac6..000000000 --- a/admin/views/class_extendings/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/class_extendings/view.html.php b/admin/views/class_extendings/view.html.php deleted file mode 100644 index 3e0582f87..000000000 --- a/admin/views/class_extendings/view.html.php +++ /dev/null @@ -1,242 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Class_extendings - */ -class ComponentbuilderViewClass_extendings extends HtmlView -{ - /** - * Class_extendings view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('class_extendings'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('class_extends'); - $this->canEdit = $this->canDo->get('class_extends.edit'); - $this->canState = $this->canDo->get('class_extends.edit.state'); - $this->canCreate = $this->canDo->get('class_extends.create'); - $this->canDelete = $this->canDo->get('class_extends.delete'); - $this->canBatch = ($this->canDo->get('class_extends.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_CLASS_EXTENDINGS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=class_extendings'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('class_extends.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('class_extends.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('class_extendings.publish'); - JToolBarHelper::unpublishList('class_extendings.unpublish'); - JToolBarHelper::archiveList('class_extendings.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('class_extendings.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'class_extendings.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('class_extendings.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('class_extendings'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - - // Only load Extension Type batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Extension Type Selection - $this->extension_typeOptions = JFormHelper::loadFieldType('classextendingsfilterextensiontype')->options; - // We do some sanitation for Extension Type filter - if (ComponentbuilderHelper::checkArray($this->extension_typeOptions) && - isset($this->extension_typeOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->extension_typeOptions[0]->value)) - { - unset($this->extension_typeOptions[0]); - } - // Extension Type Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_CLASS_EXTENDS_EXTENSION_TYPE_LABEL').' -', - 'batch[extension_type]', - JHtml::_('select.options', $this->extension_typeOptions, 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_CLASS_EXTENDINGS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/class_extendings.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.name' => JText::_('COM_COMPONENTBUILDER_CLASS_EXTENDS_NAME_LABEL'), - 'a.extension_type' => JText::_('COM_COMPONENTBUILDER_CLASS_EXTENDS_EXTENSION_TYPE_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/class_extends/submitbutton.js b/admin/views/class_extends/submitbutton.js deleted file mode 100644 index ca3c27842..000000000 --- a/admin/views/class_extends/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('class_extends, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/class_extends/tmpl/edit.php b/admin/views/class_extends/tmpl/edit.php deleted file mode 100644 index dde23d141..000000000 --- a/admin/views/class_extends/tmpl/edit.php +++ /dev/null @@ -1,133 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/class_extends/view.html.php b/admin/views/class_extends/view.html.php deleted file mode 100644 index d1017670f..000000000 --- a/admin/views/class_extends/view.html.php +++ /dev/null @@ -1,215 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Class_extends Html View class - */ -class ComponentbuilderViewClass_extends extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('class_extends', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_CLASS_EXTENDS_NEW' : 'COM_COMPONENTBUILDER_CLASS_EXTENDS_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('class_extends.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('class_extends.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('class_extends.edit')) - { - // We can save the record. - JToolBarHelper::save('class_extends.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('class_extends.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('class_extends.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('class_extends.create')) - { - JToolBarHelper::apply('class_extends.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('class_extends.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('class_extends.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('class_extends.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('class_extends.edit')) - { - // We can save the new record - JToolBarHelper::apply('class_extends.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('class_extends.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('class_extends.create')) - { - JToolBarHelper::custom('class_extends.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('class_extends.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('class_extends.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.class_extends', $this->item->id); - } - if ($this->canDo->get('class_extends.create')) - { - JToolBarHelper::custom('class_extends.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('class_extends.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('class_extends'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_CLASS_EXTENDS_NEW' : 'COM_COMPONENTBUILDER_CLASS_EXTENDS_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/class_extends.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/class_extends/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/class_method/submitbutton.js b/admin/views/class_method/submitbutton.js deleted file mode 100644 index 6deb83564..000000000 --- a/admin/views/class_method/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('class_method, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/class_method/tmpl/edit.php b/admin/views/class_method/tmpl/edit.php deleted file mode 100644 index ce6d969c9..000000000 --- a/admin/views/class_method/tmpl/edit.php +++ /dev/null @@ -1,148 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/class_method/view.html.php b/admin/views/class_method/view.html.php deleted file mode 100644 index 9d34501d2..000000000 --- a/admin/views/class_method/view.html.php +++ /dev/null @@ -1,215 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Class_method Html View class - */ -class ComponentbuilderViewClass_method extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('class_method', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_CLASS_METHOD_NEW' : 'COM_COMPONENTBUILDER_CLASS_METHOD_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('class_method.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('class_method.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('class_method.edit')) - { - // We can save the record. - JToolBarHelper::save('class_method.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('class_method.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('class_method.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('class_method.create')) - { - JToolBarHelper::apply('class_method.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('class_method.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('class_method.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('class_method.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('class_method.edit')) - { - // We can save the new record - JToolBarHelper::apply('class_method.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('class_method.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('class_method.create')) - { - JToolBarHelper::custom('class_method.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('class_method.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('class_method.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.class_method', $this->item->id); - } - if ($this->canDo->get('class_method.create')) - { - JToolBarHelper::custom('class_method.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('class_method.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('class_method'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_CLASS_METHOD_NEW' : 'COM_COMPONENTBUILDER_CLASS_METHOD_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/class_method.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/class_method/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/class_methods/tmpl/default.php b/admin/views/class_methods/tmpl/default.php deleted file mode 100644 index 2d488533e..000000000 --- a/admin/views/class_methods/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=class_methods.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'class_methodList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_CLASS_METHODS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/class_methods/tmpl/default_batch_body.php b/admin/views/class_methods/tmpl/default_batch_body.php deleted file mode 100644 index ce0e3678f..000000000 --- a/admin/views/class_methods/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/class_methods/tmpl/default_batch_footer.php b/admin/views/class_methods/tmpl/default_batch_footer.php deleted file mode 100644 index fa2cd5bba..000000000 --- a/admin/views/class_methods/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/class_methods/tmpl/default_body.php b/admin/views/class_methods/tmpl/default_body.php deleted file mode 100644 index 0e3b36953..000000000 --- a/admin/views/class_methods/tmpl/default_body.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=class_methods&task=class_method.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('class_method',$item,'class_methods'); - ?> - - - get('class_method.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('class_method.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('class_method.edit')): ?> - escape($item->name); ?> - checked_out): ?> - name, $item->checked_out_time, 'class_methods.', $canCheckin); ?> - - - escape($item->name); ?> - ( - escape($item->arguments); ?>) -
    - - - visibility); ?> - - -
    joomla_plugin_group) && $item->joomla_plugin_group > 0): ?> - - extension_type); ?> : - escape($item->joomla_plugin_group_name); ?> - - - extension_type); ?> - -
    - - - get('class_method.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'class_methods.', true, 'cb'); ?> - - published, $i, 'class_methods.', false, 'cb'); ?> - - - published, $i, 'class_methods.', true, 'cb'); ?> - - - published, $i, 'class_methods.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/class_methods/tmpl/default_foot.php b/admin/views/class_methods/tmpl/default_foot.php deleted file mode 100644 index eff41e725..000000000 --- a/admin/views/class_methods/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/class_methods/tmpl/default_head.php b/admin/views/class_methods/tmpl/default_head.php deleted file mode 100644 index 61ba12426..000000000 --- a/admin/views/class_methods/tmpl/default_head.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/class_methods/tmpl/default_toolbar.php b/admin/views/class_methods/tmpl/default_toolbar.php deleted file mode 100644 index 84830c379..000000000 --- a/admin/views/class_methods/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/class_methods/view.html.php b/admin/views/class_methods/view.html.php deleted file mode 100644 index 29c445ee0..000000000 --- a/admin/views/class_methods/view.html.php +++ /dev/null @@ -1,273 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Class_methods - */ -class ComponentbuilderViewClass_methods extends HtmlView -{ - /** - * Class_methods view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('class_methods'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('class_method'); - $this->canEdit = $this->canDo->get('class_method.edit'); - $this->canState = $this->canDo->get('class_method.edit.state'); - $this->canCreate = $this->canDo->get('class_method.create'); - $this->canDelete = $this->canDo->get('class_method.delete'); - $this->canBatch = ($this->canDo->get('class_method.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_CLASS_METHODS'), 'cube'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=class_methods'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('class_method.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('class_method.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('class_methods.publish'); - JToolBarHelper::unpublishList('class_methods.unpublish'); - JToolBarHelper::archiveList('class_methods.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('class_methods.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'class_methods.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('class_methods.trash'); - } - - if ($this->canDo->get('core.export') && $this->canDo->get('class_method.export')) - { - JToolBarHelper::custom('class_methods.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); - } - } - - if ($this->canDo->get('core.import') && $this->canDo->get('class_method.import')) - { - JToolBarHelper::custom('class_methods.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('class_methods'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - - // Only load Visibility batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Visibility Selection - $this->visibilityOptions = JFormHelper::loadFieldType('classmethodsfiltervisibility')->options; - // We do some sanitation for Visibility filter - if (ComponentbuilderHelper::checkArray($this->visibilityOptions) && - isset($this->visibilityOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->visibilityOptions[0]->value)) - { - unset($this->visibilityOptions[0]); - } - // Visibility Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_CLASS_METHOD_VISIBILITY_LABEL').' -', - 'batch[visibility]', - JHtml::_('select.options', $this->visibilityOptions, 'value', 'text') - ); - } - - // Only load Extension Type batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Extension Type Selection - $this->extension_typeOptions = JFormHelper::loadFieldType('classmethodsfilterextensiontype')->options; - // We do some sanitation for Extension Type filter - if (ComponentbuilderHelper::checkArray($this->extension_typeOptions) && - isset($this->extension_typeOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->extension_typeOptions[0]->value)) - { - unset($this->extension_typeOptions[0]); - } - // Extension Type Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_CLASS_METHOD_EXTENSION_TYPE_LABEL').' -', - 'batch[extension_type]', - JHtml::_('select.options', $this->extension_typeOptions, 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_CLASS_METHODS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/class_methods.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.name' => JText::_('COM_COMPONENTBUILDER_CLASS_METHOD_NAME_LABEL'), - 'a.visibility' => JText::_('COM_COMPONENTBUILDER_CLASS_METHOD_VISIBILITY_LABEL'), - 'a.extension_type' => JText::_('COM_COMPONENTBUILDER_CLASS_METHOD_EXTENSION_TYPE_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/class_properties/tmpl/default.php b/admin/views/class_properties/tmpl/default.php deleted file mode 100644 index bdc5e8c93..000000000 --- a/admin/views/class_properties/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=class_properties.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'class_propertyList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_CLASS_PROPERTIES_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/class_properties/tmpl/default_batch_body.php b/admin/views/class_properties/tmpl/default_batch_body.php deleted file mode 100644 index 9bd922141..000000000 --- a/admin/views/class_properties/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/class_properties/tmpl/default_batch_footer.php b/admin/views/class_properties/tmpl/default_batch_footer.php deleted file mode 100644 index 7243f9707..000000000 --- a/admin/views/class_properties/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/class_properties/tmpl/default_body.php b/admin/views/class_properties/tmpl/default_body.php deleted file mode 100644 index 4befb19f3..000000000 --- a/admin/views/class_properties/tmpl/default_body.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); -use VDM\Joomla\Utilities\StringHelper; - -$edit = "index.php?option=com_componentbuilder&view=class_properties&task=class_property.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('class_property',$item,'class_properties'); - ?> - - - get('class_property.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('class_property.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('class_property.edit')): ?> - escape($item->name); ?> - checked_out): ?> - name, $item->checked_out_time, 'class_properties.', $canCheckin); ?> - - - escape($item->name); ?> - -
    - - - visibility); ?> - - -
    joomla_plugin_group) && StringHelper::check($item->joomla_plugin_group)): ?> - - extension_type); ?> : - escape($item->joomla_plugin_group_name); ?> - - - extension_type); ?> - -
    - - - get('class_property.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'class_properties.', true, 'cb'); ?> - - published, $i, 'class_properties.', false, 'cb'); ?> - - - published, $i, 'class_properties.', true, 'cb'); ?> - - - published, $i, 'class_properties.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/class_properties/tmpl/default_foot.php b/admin/views/class_properties/tmpl/default_foot.php deleted file mode 100644 index eff41e725..000000000 --- a/admin/views/class_properties/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/class_properties/tmpl/default_head.php b/admin/views/class_properties/tmpl/default_head.php deleted file mode 100644 index 1f74bde03..000000000 --- a/admin/views/class_properties/tmpl/default_head.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/class_properties/tmpl/default_toolbar.php b/admin/views/class_properties/tmpl/default_toolbar.php deleted file mode 100644 index 5950a1dc2..000000000 --- a/admin/views/class_properties/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/class_properties/view.html.php b/admin/views/class_properties/view.html.php deleted file mode 100644 index 58201f0e2..000000000 --- a/admin/views/class_properties/view.html.php +++ /dev/null @@ -1,273 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Class_properties - */ -class ComponentbuilderViewClass_properties extends HtmlView -{ - /** - * Class_properties view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('class_properties'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('class_property'); - $this->canEdit = $this->canDo->get('class_property.edit'); - $this->canState = $this->canDo->get('class_property.edit.state'); - $this->canCreate = $this->canDo->get('class_property.create'); - $this->canDelete = $this->canDo->get('class_property.delete'); - $this->canBatch = ($this->canDo->get('class_property.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_CLASS_PROPERTIES'), 'cube'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=class_properties'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('class_property.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('class_property.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('class_properties.publish'); - JToolBarHelper::unpublishList('class_properties.unpublish'); - JToolBarHelper::archiveList('class_properties.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('class_properties.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'class_properties.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('class_properties.trash'); - } - - if ($this->canDo->get('core.export') && $this->canDo->get('class_property.export')) - { - JToolBarHelper::custom('class_properties.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); - } - } - - if ($this->canDo->get('core.import') && $this->canDo->get('class_property.import')) - { - JToolBarHelper::custom('class_properties.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('class_properties'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - - // Only load Visibility batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Visibility Selection - $this->visibilityOptions = JFormHelper::loadFieldType('classpropertiesfiltervisibility')->options; - // We do some sanitation for Visibility filter - if (ComponentbuilderHelper::checkArray($this->visibilityOptions) && - isset($this->visibilityOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->visibilityOptions[0]->value)) - { - unset($this->visibilityOptions[0]); - } - // Visibility Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_CLASS_PROPERTY_VISIBILITY_LABEL').' -', - 'batch[visibility]', - JHtml::_('select.options', $this->visibilityOptions, 'value', 'text') - ); - } - - // Only load Extension Type batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Extension Type Selection - $this->extension_typeOptions = JFormHelper::loadFieldType('classpropertiesfilterextensiontype')->options; - // We do some sanitation for Extension Type filter - if (ComponentbuilderHelper::checkArray($this->extension_typeOptions) && - isset($this->extension_typeOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->extension_typeOptions[0]->value)) - { - unset($this->extension_typeOptions[0]); - } - // Extension Type Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_CLASS_PROPERTY_EXTENSION_TYPE_LABEL').' -', - 'batch[extension_type]', - JHtml::_('select.options', $this->extension_typeOptions, 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_CLASS_PROPERTIES')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/class_properties.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.name' => JText::_('COM_COMPONENTBUILDER_CLASS_PROPERTY_NAME_LABEL'), - 'a.visibility' => JText::_('COM_COMPONENTBUILDER_CLASS_PROPERTY_VISIBILITY_LABEL'), - 'a.extension_type' => JText::_('COM_COMPONENTBUILDER_CLASS_PROPERTY_EXTENSION_TYPE_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/class_property/submitbutton.js b/admin/views/class_property/submitbutton.js deleted file mode 100644 index 58f528b96..000000000 --- a/admin/views/class_property/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('class_property, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/class_property/tmpl/edit.php b/admin/views/class_property/tmpl/edit.php deleted file mode 100644 index 4873e8cb2..000000000 --- a/admin/views/class_property/tmpl/edit.php +++ /dev/null @@ -1,143 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/class_property/view.html.php b/admin/views/class_property/view.html.php deleted file mode 100644 index 0c363262a..000000000 --- a/admin/views/class_property/view.html.php +++ /dev/null @@ -1,215 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Class_property Html View class - */ -class ComponentbuilderViewClass_property extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('class_property', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_CLASS_PROPERTY_NEW' : 'COM_COMPONENTBUILDER_CLASS_PROPERTY_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('class_property.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('class_property.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('class_property.edit')) - { - // We can save the record. - JToolBarHelper::save('class_property.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('class_property.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('class_property.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('class_property.create')) - { - JToolBarHelper::apply('class_property.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('class_property.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('class_property.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('class_property.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('class_property.edit')) - { - // We can save the new record - JToolBarHelper::apply('class_property.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('class_property.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('class_property.create')) - { - JToolBarHelper::custom('class_property.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('class_property.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('class_property.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.class_property', $this->item->id); - } - if ($this->canDo->get('class_property.create')) - { - JToolBarHelper::custom('class_property.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('class_property.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('class_property'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_CLASS_PROPERTY_NEW' : 'COM_COMPONENTBUILDER_CLASS_PROPERTY_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/class_property.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/class_property/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/compiler/tmpl/default.php b/admin/views/compiler/tmpl/default.php deleted file mode 100644 index 744feffb5..000000000 --- a/admin/views/compiler/tmpl/default.php +++ /dev/null @@ -1,239 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); -use VDM\Joomla\Utilities\StringHelper; - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); - -$this->app->input->set('hidemainmenu', false); -$selectNotice = '

    ' . JText::_('COM_COMPONENTBUILDER_HI') . ' ' . $this->user->name . '

    '; -$selectNotice .= '

    ' . JText::_('COM_COMPONENTBUILDER_PLEASE_SELECT_A_COMPONENT_THAT_YOU_WOULD_LIKE_TO_COMPILE') . '

    '; - -// set the noticeboard options -$noticeboardOptions = array('vdm', 'pro'); -?> -canDo->get('compiler.access')): ?> - - -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - SuccessMessage)): ?> -
    - - SuccessMessage; ?> -
    - -
    -
    -
    -

    -
    -
    -
    - form): ?> - form->renderFieldset('builder'); ?> - -
    -
    -
    - - - -
    -
    -
    -
    form->renderFieldset('advanced'); ?>
    -
    - 'noticeboard' , 'active' => $noticeboardOptions[array_rand($noticeboardOptions)])); ?> -
    -
    - - - - - -
    -
    - - -

    - diff --git a/admin/views/compiler/view.html.php b/admin/views/compiler/view.html.php deleted file mode 100644 index 2a47eff3e..000000000 --- a/admin/views/compiler/view.html.php +++ /dev/null @@ -1,771 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; -use Joomla\CMS\Filesystem\File; -use Joomla\CMS\Form\Form; -use VDM\Joomla\Utilities\ArrayHelper; - -/** - * Componentbuilder Html View class for the Compiler - */ -class ComponentbuilderViewCompiler extends HtmlView -{ - // Overwriting JView display method - function display($tpl = null) - { - // get component params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // get the application - $this->app = JFactory::getApplication(); - // get the user object - $this->user = JFactory::getUser(); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('compiler'); - // Initialise variables. - $this->items = $this->get('Items'); - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('compiler'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=compiler'); - $this->sidebar = JHtmlSidebar::render(); - } - // get the success message if set - $this->SuccessMessage = $this->app->getUserState('com_componentbuilder.success_message', false); - - // get active components - $this->Components = $this->get('Components'); - - // get the needed form fields - $this->form = $this->getDynamicForm(); - - // set the compiler artwork from global settings - $this->builder_gif_size = $this->params->get('builder_gif_size', '480-272'); - - // only run these checks if he has access - if ($this->canDo->get('compiler.compiler_animations')) - { - // if the new artwork is not being targeted hide download option of artwork - if ('480-540' !== $this->builder_gif_size) - { - $this->canDo->set('compiler.compiler_animations', false); - } - // we count of all the files are already there - else - { - $directory_path = JPATH_ROOT . "/administrator/components/com_componentbuilder/assets/images/builder-gif"; - // get all the gif files in the gif folder - $all_gifs = null; - if (is_dir($directory_path) && is_readable($directory_path)) - { - $all_gifs = scandir($directory_path); - - } - - // check if we have any values - if ($all_gifs !== null && ArrayHelper::check($all_gifs)) - { - // count number of files but remove the 2 dot values - $num_gifs = count($all_gifs) - 2; - // if we have more or the same number of files that are in the array, the we hide the download option - if ($num_gifs >= ComponentbuilderHelper::getDynamicContentSize('builder-gif', '480-540')) - { - $this->canDo->set('compiler.compiler_animations', false); - } - } - } - } - - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - // add the tool bar - $this->addToolBar(); - } - - // set the document - $this->setDocument(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode(PHP_EOL, $errors), 500); - } - - parent::display($tpl); - } - - // These are subform layouts used in JCB - // JLayoutHelper::render('sectionjcb', [?]); // added to ensure the layout are loaded - // JLayoutHelper::render('repeatablejcb', [?]); // added to ensure the layout are loaded - - /** - * Get the dynamic build form fields needed on the page - * - * @return Form|null The form fields - * - * @since 3.2.0 - */ - public function getDynamicForm(): ?Form - { - if(ArrayHelper::check($this->Components)) - { - // start the form - $form = new Form('Builder'); - - $form->load('
    -
    -
    -
    '); - - // sales attributes - $attributes = [ - 'type' => 'radio', - 'name' => 'backup', - 'label' => 'COM_COMPONENTBUILDER_ADD_TO_BACKUP_FOLDER_AMP_SALES_SERVER_SMALLIF_SETSMALL', - 'class' => 'btn-group btn-group-yesno', - 'description' => 'COM_COMPONENTBUILDER_SHOULD_THE_ZIPPED_PACKAGE_OF_THE_COMPONENT_BE_MOVED_TO_THE_LOCAL_BACKUP_AND_REMOTE_SALES_SERVER_THIS_IS_ONLY_APPLICABLE_IF_THIS_COMPONENT_HAS_THOSE_VALUES_SET', - 'default' => '0']; - // set the sales options - $options = [ - '1' => 'COM_COMPONENTBUILDER_YES', - '0' => 'COM_COMPONENTBUILDER_NO']; - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes, $options); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'builder'); - } - - // repository attributes - $attributes = [ - 'type' => 'radio', - 'name' => 'repository', - 'label' => 'COM_COMPONENTBUILDER_ADD_TO_REPOSITORY_FOLDER', - 'class' => 'btn-group btn-group-yesno', - 'description' => 'COM_COMPONENTBUILDER_SHOULD_THE_COMPONENT_BE_MOVED_TO_YOUR_LOCAL_REPOSITORY_FOLDER', - 'default' => '1']; - // start the repository options - $options = [ - '1' => 'COM_COMPONENTBUILDER_YES', - '0' => 'COM_COMPONENTBUILDER_NO']; - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes, $options); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'builder'); - } - - // placeholders attributes - $attributes = [ - 'type' => 'radio', - 'name' => 'add_placeholders', - 'label' => 'COM_COMPONENTBUILDER_ADD_CUSTOM_CODE_PLACEHOLDERS', - 'class' => 'btn-group btn-group-yesno', - 'description' => 'COM_COMPONENTBUILDER_SHOULD_JCB_INSERT_THE_CUSTOM_CODE_PLACEHOLDERS_THIS_IS_ONLY_APPLICABLE_IF_THIS_COMPONENT_HAS_CUSTOM_CODE', - 'default' => '2']; - // start the placeholders options - $options = [ - '2' => 'COM_COMPONENTBUILDER_GLOBAL', - '1' => 'COM_COMPONENTBUILDER_YES', - '0' => 'COM_COMPONENTBUILDER_NO']; - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes, $options); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'builder'); - } - - // debuglinenr attributes - $attributes = [ - 'type' => 'radio', - 'name' => 'debug_line_nr', - 'label' => 'COM_COMPONENTBUILDER_DEBUG_LINE_NUMBERS', - 'class' => 'btn-group btn-group-yesno', - 'description' => 'COM_COMPONENTBUILDER_ADD_CORRESPONDING_LINE_NUMBERS_TO_THE_DYNAMIC_COMMENTS_SO_TO_SEE_WHERE_IN_THE_COMPILER_THE_LINES_OF_CODE_WAS_BUILD_THIS_WILL_HELP_IF_YOU_NEED_TO_GET_MORE_TECHNICAL_WITH_AN_ISSUE_ON_GITHUB_OR_EVEN_FOR_YOUR_OWN_DEBUGGING', - 'default' => '2']; - $options = [ - '2' => 'COM_COMPONENTBUILDER_GLOBAL', - '1' => 'COM_COMPONENTBUILDER_YES', - '0' => 'COM_COMPONENTBUILDER_NO']; - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes, $options); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'builder'); - } - - // minify attributes - $attributes = [ - 'type' => 'radio', - 'name' => 'minify', - 'label' => 'COM_COMPONENTBUILDER_MINIFY_JAVASCRIPT', - 'class' => 'btn-group btn-group-yesno', - 'description' => 'COM_COMPONENTBUILDER_SHOULD_THE_JAVASCRIPT_BE_MINIFIED_IN_THE_COMPONENT', - 'default' => '2']; - $options = [ - '2' => 'COM_COMPONENTBUILDER_GLOBAL', - '1' => 'COM_COMPONENTBUILDER_YES', - '0' => 'COM_COMPONENTBUILDER_NO']; - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes, $options); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'builder'); - } - - // powers attributes - $attributes = [ - 'type' => 'radio', - 'name' => 'powers', - 'label' => 'COM_COMPONENTBUILDER_ADD_POWERS', - 'class' => 'btn-group btn-group-yesno', - 'description' => 'COM_COMPONENTBUILDER_SHOULD_JCB_ADD_ANY_POWERS_THAT_ARE_CONNECTED_TO_THIS_COMPONENT_THIS_MAY_BE_HELPFUL_IF_YOU_ARE_LOADING_POWERS_VIA_ANOTHER_COMPONENT_AND_WOULD_LIKE_TO_AVOID_ADDING_IT_TO_BOTH_JUST_REMEMBER_THAT_IN_THIS_CASE_YOU_NEED_TO_LOAD_THE_POWERS_VIA_A_PLUGIN', - 'default' => '2']; - $options = [ - '2' => 'COM_COMPONENTBUILDER_GLOBAL', - '1' => 'COM_COMPONENTBUILDER_YES', - '0' => 'COM_COMPONENTBUILDER_NO']; - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes, $options); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'builder'); - } - - // component attributes - $attributes = [ - 'type' => 'list', - 'name' => 'component_id', - 'label' => 'COM_COMPONENTBUILDER_COMPONENTS', - 'class' => 'list_class', - 'description' => 'COM_COMPONENTBUILDER_SELECT_THE_COMPONENT_TO_COMPILE', - 'required' => 'true']; - // start the component options - $options = []; - $options[''] = 'COM_COMPONENTBUILDER__SELECT_COMPONENT_'; - // load component options from array - foreach($this->Components as $component) - { - $options[(int) $component->id] = $this->escape($component->name); - } - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes, $options); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'builder'); - } - - // Advanced Options - $attributes = [ - 'type' => 'radio', - 'name' => 'show_advanced_options', - 'label' => 'COM_COMPONENTBUILDER_SHOW_ADVANCED_OPTIONS', - 'class' => 'btn-group btn-group-yesno', - 'description' => 'COM_COMPONENTBUILDER_WOULD_YOU_LIKE_TO_SEE_THE_ADVANCED_COMPILER_OPTIONS', - 'default' => '0']; - // start the advanced options switch - $options = [ - '1' => 'COM_COMPONENTBUILDER_YES', - '0' => 'COM_COMPONENTBUILDER_NO']; - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes, $options); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'builder'); - } - - // Advanced Options note attributes - $attributes = [ - 'type' => 'note', - 'name' => 'show_advanced_options_note', - 'label' => "COM_COMPONENTBUILDER_ADVANCED_OPTIONS", - 'heading' => 'h3', - 'showon' => 'show_advanced_options:1']; - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'advanced'); - } - - // Joomla Versions attributes - $attributes = [ - 'type' => 'radio', - 'name' => 'joomla_version_donations', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_VERSION', - 'class' => 'btn-group btn-group-yesno', - 'description' => 'COM_COMPONENTBUILDER_WHAT_VERSION_OF_JOOMLA_WOULD_YOU_LIKE_TO_TARGET', - 'default' => '3', - 'showon' => 'show_advanced_options:1']; - // start the joomla versions options - $options = [ - '3' => 'COM_COMPONENTBUILDER_JOOMLA_THREE', - '4' => 'COM_COMPONENTBUILDER_JOOMLA_FOUR']; - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes, $options); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'advanced'); - } - - // Joomla Version 3 attributes - $attributes = [ - 'type' => 'note', - 'name' => 'joomla_version_note_three', - 'description' => 'COM_COMPONENTBUILDER_YOUR_COMPONENT_WILL_BE_COMPILED_TO_WORK_IN_JOOMLA_THREE', - 'class' => 'alert alert-success', - 'showon' => 'show_advanced_options:1[AND]joomla_version_donations:3']; - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'advanced'); - } - - // Joomla Version 4 attributes - $attributes = [ - 'type' => 'note', - 'name' => 'joomla_version_note_four', - 'description' => 'COM_COMPONENTBUILDER_JCB_IS_NOT_YET_FULLY_READY_FOR_JOOMLA_FOUR_BUT_WITH_YOUR_HELP_WE_CAN_MAKE_THE_TRANSITION_FASTER_SHOW_YOUR_SUPPORT_BY_MAKING_A_DONATION_TODAY_AND_HELP_US_BRING_JCB_TO_THE_NEXT_LEVELBR_BR_BYOUR_COMPONENT_WILL_STILL_ONLY_BE_COMPILED_FOR_JOOMLA_THREEB', - 'class' => 'alert alert-info', - 'showon' => 'show_advanced_options:1[AND]joomla_version_donations:4']; - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'advanced'); - } - - // powers repository attributes - $attributes = [ - 'type' => 'radio', - 'name' => 'powers_repository', - 'label' => 'COM_COMPONENTBUILDER_ACTIVATE_SUPER_POWERS', - 'class' => 'btn-group btn-group-yesno', - 'description' => 'COM_COMPONENTBUILDER_THIS_ADDS_POWERS_TO_A_LOCAL_REPOSITORY_FOLDER_ALL_BAPPROVEDB_POWERS_LINKED_TO_THIS_COMPONENT_WILL_BE_MOVED_TO_YOUR_BLOCALB_POWERS_REPOSITORY_FOLDER_INTO_THEIR_SELECTIVE_TARGET_PATHS_THIS_LOCAL_FOLDER_PATH_MUST_BE_SET_IN_THE_GLOBAL_OPTIONS_OF_JCB_UNDER_THE_BSUPER_POWERB_TAB', - 'default' => '2', - 'showon' => 'show_advanced_options:1']; - // start the repository options - $options = [ - '2' => 'COM_COMPONENTBUILDER_GLOBAL', - '1' => 'COM_COMPONENTBUILDER_YES', - '0' => 'COM_COMPONENTBUILDER_NO']; - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes, $options); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'advanced'); - } - - // powers local path to repositories attributes - $attributes = [ - 'type' => 'text', - 'name' => 'local_powers_repository_path', - 'label' => 'COM_COMPONENTBUILDER_LOCAL_POWERS_REPOSITORY_PATH', - 'class' => 'btn-group btn-group-yesno', - 'description' => 'COM_COMPONENTBUILDER_HERE_YOU_CAN_SET_THE_PATH_TO_THE_SUPER_POWERS_LOCAL_REPOSITORY_FOLDER_WHERE_BLAYERCOREB_AND_ALL_TARGETED_BLAYEROWNB_SUB_PATHS_WILL_BE_PLACED_WITH_THEIR_SELECTIVE_BSWITCHAPPROVEDB_POWERS', - 'default' => $this->params->get('local_powers_repository_path', ''), - 'showon' => 'show_advanced_options:1[AND]powers_repository:1']; - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'advanced'); - } - - // Indentation attributes - $attributes = [ - 'type' => 'radio', - 'name' => 'indentation_value', - 'label' => 'COM_COMPONENTBUILDER_INDENTATION_OPTIONS', - 'class' => 'btn-group btn-group-yesno', - 'description' => 'COM_COMPONENTBUILDER_WHICH_TYPE_OF_INDENTATION_WOULD_YOU_LIKE_TO_USE_PLEASE_NOTE_THAT_THIS_DOES_NOT_YET_IMPACT_THE_STATIC_TEMPLATES', - 'default' => '1', - 'showon' => 'show_advanced_options:1']; - - // start the indentation options - $options = [ - '1' => 'COM_COMPONENTBUILDER_TAB', - '2' => 'COM_COMPONENTBUILDER_TWO_SPACES', - '4' => 'COM_COMPONENTBUILDER_FOUR_SPACES']; - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes, $options); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'advanced'); - } - - // Build date attributes - $attributes = [ - 'type' => 'radio', - 'name' => 'add_build_date', - 'label' => 'COM_COMPONENTBUILDER_BUILD_DATE', - 'class' => 'btn-group btn-group-yesno', - 'description' => 'COM_COMPONENTBUILDER_WOULD_YOU_LIKE_TO_OVERRIDE_THE_BUILD_DATE', - 'default' => '1', - 'showon' => 'show_advanced_options:1']; - // start the build date options - $options = [ - '1' => 'COM_COMPONENTBUILDER_DEFAULT', - '2' => 'COM_COMPONENTBUILDER_MANUAL', - '3' => 'COM_COMPONENTBUILDER_COMPONENT']; - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes, $options); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'advanced'); - } - - // Build date note attributes - $attributes = [ - 'type' => 'note', - 'name' => 'add_build_date_note_two', - 'description' => 'COM_COMPONENTBUILDER_ALLOWS_YOU_TO_OVERRIDE_THE_BUILD_DATE_BY_SELECTING_A_DATE_MANUALLY_FROM_THE_CALENDER', - 'class' => 'alert alert-info', - 'showon' => 'show_advanced_options:1[AND]add_build_date:2']; - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'advanced'); - } - - // Build date note attributes - $attributes = [ - 'type' => 'note', - 'name' => 'add_build_date_note_three', - 'description' => "COM_COMPONENTBUILDER_THE_COMPONENTS_LAST_MODIFIED_DATE_WILL_BE_USED", - 'class' => 'alert alert-info', - 'showon' => 'show_advanced_options:1[AND]add_build_date:3']; - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'advanced'); - } - - // Build date calendar attributes - $attributes = [ - 'type' => 'calendar', - 'name' => 'build_date', - 'label' => 'COM_COMPONENTBUILDER_SELECT_BUILD_DATE', - 'format' => '%Y-%m-%d', - 'filter' => 'user_utc', - 'default' => 'now', - 'size' => '22', - 'showon' => 'show_advanced_options:1[AND]add_build_date:2']; - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'advanced'); - } - - // Build date note attributes - $attributes = [ - 'type' => 'note', - 'name' => 'donations_note', - 'label' => "COM_COMPONENTBUILDER_DONATIONS", - 'description' => $this->getSupportMessage(), - 'class' => 'alert alert-success', - 'heading' => 'h1', - 'showon' => 'show_advanced_options:1']; - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'advanced'); - } - - // Build date note line attributes - $attributes = [ - 'type' => 'note', - 'name' => 'donations_note_line', - 'description' => '
    ', - 'showon' => 'show_advanced_options:1']; - - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'advanced'); - } - - // return the form array - return $form; - } - - return null; - } - - /** - * Get the dynamic support request/gratitude message - * - * @return string The support message - * - * @since 3.2.0 - */ - protected function getSupportMessage(): string - { - return JLayoutHelper::render('jcbsupportmessage', []); - } - - - /** - * Prepares the document - */ - protected function setDocument() - { - - // Only load jQuery if needed. (default is true) - if ($this->params->get('add_jquery_framework', 1) == 1) - { - JHtml::_('jquery.framework'); - } - // Load the header checker class. - require_once( JPATH_COMPONENT_ADMINISTRATOR.'/helpers/headercheck.php' ); - // Initialize the header checker. - $HeaderCheck = new componentbuilderHeaderCheck; - - // Load uikit options. - $uikit = $this->params->get('uikit_load'); - // Set script size. - $size = $this->params->get('uikit_min'); - // Set css style. - $style = $this->params->get('uikit_style'); - - // The uikit css. - if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) - { - JHtml::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit'.$style.$size.'.css', ['version' => 'auto']); - } - // The uikit js. - if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) - { - JHtml::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit'.$size.'.js', ['version' => 'auto']); - } - - // Load the script to find all uikit components needed. - if ($uikit != 2) - { - // Set the default uikit components in this view. - $uikitComp = array(); - $uikitComp[] = 'data-uk-grid'; - - // Get field uikit components needed in this view. - $uikitFieldComp = $this->get('UikitComp'); - if (isset($uikitFieldComp) && ComponentbuilderHelper::checkArray($uikitFieldComp)) - { - if (isset($uikitComp) && ComponentbuilderHelper::checkArray($uikitComp)) - { - $uikitComp = array_merge($uikitComp, $uikitFieldComp); - $uikitComp = array_unique($uikitComp); - } - else - { - $uikitComp = $uikitFieldComp; - } - } - } - - // Load the needed uikit components in this view. - if ($uikit != 2 && isset($uikitComp) && ComponentbuilderHelper::checkArray($uikitComp)) - { - // load just in case. - jimport('joomla.filesystem.file'); - // loading... - foreach ($uikitComp as $class) - { - foreach (ComponentbuilderHelper::$uk_components[$class] as $name) - { - // check if the CSS file exists. - if (File::exists(JPATH_ROOT.'/media/com_componentbuilder/uikit-v2/css/components/'.$name.$style.$size.'.css')) - { - // load the css. - JHtml::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/'.$name.$style.$size.'.css', ['version' => 'auto']); - } - // check if the JavaScript file exists. - if (File::exists(JPATH_ROOT.'/media/com_componentbuilder/uikit-v2/js/components/'.$name.$size.'.js')) - { - // load the js. - JHtml::_('script', 'media/com_componentbuilder/uikit-v2/js/components/'.$name.$size.'.js', ['version' => 'auto'], ['type' => 'text/javascript', 'async' => 'async']); - } - } - } - } - // add marked library - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/custom/marked.js"); - // add the document default css file - JHtml::_('stylesheet', 'administrator/components/com_componentbuilder/assets/css/compiler.css', ['version' => 'auto']); - // Set the Custom JS script to view - $this->document->addScriptDeclaration(" - function getComponentDetails_server(id){ - var getUrl = JRouter(\"index.php?option=com_componentbuilder&task=ajax.getComponentDetails&format=json&raw=true\"); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id; - } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false - }); - } - function getComponentDetails(id) { - getComponentDetails_server(id).done(function(result) { - if(result.html) { - jQuery('#component-details').html(result.html); - } - }); - } - - var noticeboard = \"https://vdm.bz/componentbuilder-noticeboard-md\"; - var proboard = \"https://vdm.bz/componentbuilder-pro-noticeboard-md\"; - jQuery(document).ready(function () { - jQuery.get(noticeboard) - .success(function(board) { - if (board.length > 5) { - jQuery(\".noticeboard-md\").html(marked.parse(board)); - getIS(1,board).done(function(result) { - if (result){ - jQuery(\".vdm-new-notice\").show(); - getIS(2,board); - } - }); - } else { - jQuery(\".noticeboard-md\").html(all_is_good); - } - }) - .error(function(jqXHR, textStatus, errorThrown) { - jQuery(\".noticeboard-md\").html(all_is_good); - }); - jQuery.get(proboard) - .success(function(board) { - if (board.length > 5) { - jQuery(\".proboard-md\").html(marked.parse(board)); - } else { - jQuery(\".proboard-md\").html(all_is_good); - } - }) - .error(function(jqXHR, textStatus, errorThrown) { - jQuery(\".proboard-md\").html(all_is_good); - }); - }); - // to check is READ/NEW - function getIS(type,notice){ - if (type == 1) { - var getUrl = JRouter(\"index.php?option=com_componentbuilder&task=ajax.isNew&format=json&raw=true\"); - } else if (type == 2) { - var getUrl = JRouter(\"index.php?option=com_componentbuilder&task=ajax.isRead&format=json&raw=true\"); - } - if(token.length > 0 && notice.length){ - var request = token+\"=1¬ice=\"+notice; - } - return jQuery.ajax({ - type: \"POST\", - url: getUrl, - dataType: 'json', - data: request, - jsonp: false - }); - } - - "); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - // hide the main menu - $this->app->input->set('hidemainmenu', true); - // add title to the page - JToolbarHelper::title(JText::_('COM_COMPONENTBUILDER_COMPILER'),'cogs'); - // add cpanel button - JToolBarHelper::custom('compiler.dashboard', 'grid-2', '', 'COM_COMPONENTBUILDER_DASH', false); - if ($this->canDo->get('compiler.run_expansion')) - { - // add Run Expansion button. - JToolBarHelper::custom('compiler.runExpansion', 'expand-2 custom-button-runexpansion', '', 'COM_COMPONENTBUILDER_RUN_EXPANSION', false); - } - if ($this->canDo->get('compiler.translate')) - { - // add Translate button. - JToolBarHelper::custom('compiler.runTranslator', 'comments-2 custom-button-runtranslator', '', 'COM_COMPONENTBUILDER_TRANSLATE', false); - } - if ($this->canDo->get('compiler.compiler_animations')) - { - // add Compiler Animations button. - JToolBarHelper::custom('compiler.getDynamicContent', 'download custom-button-getdynamiccontent', '', 'COM_COMPONENTBUILDER_COMPILER_ANIMATIONS', false); - } - if ($this->canDo->get('compiler.clear_tmp')) - { - // add Clear tmp button. - JToolBarHelper::custom('compiler.clearTmp', 'purge custom-button-cleartmp', '', 'COM_COMPONENTBUILDER_CLEAR_TMP', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('compiler'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } -} diff --git a/admin/views/component_admin_views/submitbutton.js b/admin/views/component_admin_views/submitbutton.js deleted file mode 100644 index 0f2245f95..000000000 --- a/admin/views/component_admin_views/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('component_admin_views, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/component_admin_views/tmpl/edit.php b/admin/views/component_admin_views/tmpl/edit.php deleted file mode 100644 index a2656f508..000000000 --- a/admin/views/component_admin_views/tmpl/edit.php +++ /dev/null @@ -1,147 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/component_admin_views/view.html.php b/admin/views/component_admin_views/view.html.php deleted file mode 100644 index 9abe9f66f..000000000 --- a/admin/views/component_admin_views/view.html.php +++ /dev/null @@ -1,203 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Component_admin_views Html View class - */ -class ComponentbuilderViewComponent_admin_views extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_admin_views', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('component_admin_views.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('component_admin_views.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('component_admin_views.edit')) - { - // We can save the record. - JToolBarHelper::save('component_admin_views.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('component_admin_views.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('component_admin_views.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('component_admin_views.create')) - { - JToolBarHelper::apply('component_admin_views.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_admin_views.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('component_admin_views.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('component_admin_views.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('component_admin_views.edit')) - { - // We can save the new record - JToolBarHelper::apply('component_admin_views.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_admin_views.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('component_admin_views.create')) - { - JToolBarHelper::custom('component_admin_views.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_admin_views.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_admin_views.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.component_admin_views', $this->item->id); - } - if ($this->canDo->get('component_admin_views.create')) - { - JToolBarHelper::custom('component_admin_views.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('component_admin_views.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('component_admin_views'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_ADMIN_VIEWS_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/component_admin_views.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/component_admin_views/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/component_config/submitbutton.js b/admin/views/component_config/submitbutton.js deleted file mode 100644 index a8ec644e5..000000000 --- a/admin/views/component_config/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('component_config, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/component_config/tmpl/edit.php b/admin/views/component_config/tmpl/edit.php deleted file mode 100644 index 2253a8e58..000000000 --- a/admin/views/component_config/tmpl/edit.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - diff --git a/admin/views/component_config/view.html.php b/admin/views/component_config/view.html.php deleted file mode 100644 index 54b732a30..000000000 --- a/admin/views/component_config/view.html.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Component_config Html View class - */ -class ComponentbuilderViewComponent_config extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_config', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_CONFIG_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_CONFIG_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('component_config.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('component_config.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('component_config.edit')) - { - // We can save the record. - JToolBarHelper::save('component_config.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('component_config.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('component_config.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('component_config.create')) - { - JToolBarHelper::apply('component_config.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_config.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('component_config.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('component_config.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('component_config.edit')) - { - // We can save the new record - JToolBarHelper::apply('component_config.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_config.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('component_config.create')) - { - JToolBarHelper::custom('component_config.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_config.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_config.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.component_config', $this->item->id); - } - if ($this->canDo->get('component_config.create')) - { - JToolBarHelper::custom('component_config.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('component_config.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('component_config'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_CONFIG_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_CONFIG_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/component_config.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/component_config/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/component_custom_admin_menus/submitbutton.js b/admin/views/component_custom_admin_menus/submitbutton.js deleted file mode 100644 index fc1f91476..000000000 --- a/admin/views/component_custom_admin_menus/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('component_custom_admin_menus, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/component_custom_admin_menus/tmpl/edit.php b/admin/views/component_custom_admin_menus/tmpl/edit.php deleted file mode 100644 index 0a86ae7c2..000000000 --- a/admin/views/component_custom_admin_menus/tmpl/edit.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - diff --git a/admin/views/component_custom_admin_menus/view.html.php b/admin/views/component_custom_admin_menus/view.html.php deleted file mode 100644 index ee5101736..000000000 --- a/admin/views/component_custom_admin_menus/view.html.php +++ /dev/null @@ -1,203 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Component_custom_admin_menus Html View class - */ -class ComponentbuilderViewComponent_custom_admin_menus extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_custom_admin_menus', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('component_custom_admin_menus.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('component_custom_admin_menus.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('component_custom_admin_menus.edit')) - { - // We can save the record. - JToolBarHelper::save('component_custom_admin_menus.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('component_custom_admin_menus.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('component_custom_admin_menus.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('component_custom_admin_menus.create')) - { - JToolBarHelper::apply('component_custom_admin_menus.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_custom_admin_menus.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('component_custom_admin_menus.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('component_custom_admin_menus.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('component_custom_admin_menus.edit')) - { - // We can save the new record - JToolBarHelper::apply('component_custom_admin_menus.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_custom_admin_menus.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('component_custom_admin_menus.create')) - { - JToolBarHelper::custom('component_custom_admin_menus.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_custom_admin_menus.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_custom_admin_menus.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.component_custom_admin_menus', $this->item->id); - } - if ($this->canDo->get('component_custom_admin_menus.create')) - { - JToolBarHelper::custom('component_custom_admin_menus.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('component_custom_admin_menus.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('component_custom_admin_menus'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_MENUS_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/component_custom_admin_menus.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/component_custom_admin_menus/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/component_custom_admin_views/submitbutton.js b/admin/views/component_custom_admin_views/submitbutton.js deleted file mode 100644 index e2046450c..000000000 --- a/admin/views/component_custom_admin_views/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('component_custom_admin_views, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/component_custom_admin_views/tmpl/edit.php b/admin/views/component_custom_admin_views/tmpl/edit.php deleted file mode 100644 index 8ee039b2a..000000000 --- a/admin/views/component_custom_admin_views/tmpl/edit.php +++ /dev/null @@ -1,137 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/component_custom_admin_views/view.html.php b/admin/views/component_custom_admin_views/view.html.php deleted file mode 100644 index 3a876daaa..000000000 --- a/admin/views/component_custom_admin_views/view.html.php +++ /dev/null @@ -1,203 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Component_custom_admin_views Html View class - */ -class ComponentbuilderViewComponent_custom_admin_views extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_custom_admin_views', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('component_custom_admin_views.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('component_custom_admin_views.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('component_custom_admin_views.edit')) - { - // We can save the record. - JToolBarHelper::save('component_custom_admin_views.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('component_custom_admin_views.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('component_custom_admin_views.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('component_custom_admin_views.create')) - { - JToolBarHelper::apply('component_custom_admin_views.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_custom_admin_views.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('component_custom_admin_views.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('component_custom_admin_views.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('component_custom_admin_views.edit')) - { - // We can save the new record - JToolBarHelper::apply('component_custom_admin_views.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_custom_admin_views.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('component_custom_admin_views.create')) - { - JToolBarHelper::custom('component_custom_admin_views.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_custom_admin_views.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_custom_admin_views.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.component_custom_admin_views', $this->item->id); - } - if ($this->canDo->get('component_custom_admin_views.create')) - { - JToolBarHelper::custom('component_custom_admin_views.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('component_custom_admin_views.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('component_custom_admin_views'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_CUSTOM_ADMIN_VIEWS_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/component_custom_admin_views.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/component_custom_admin_views/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/component_dashboard/submitbutton.js b/admin/views/component_dashboard/submitbutton.js deleted file mode 100644 index 6e34fa22d..000000000 --- a/admin/views/component_dashboard/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('component_dashboard, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/component_dashboard/tmpl/edit.php b/admin/views/component_dashboard/tmpl/edit.php deleted file mode 100644 index fadf55943..000000000 --- a/admin/views/component_dashboard/tmpl/edit.php +++ /dev/null @@ -1,149 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/component_dashboard/view.html.php b/admin/views/component_dashboard/view.html.php deleted file mode 100644 index 18a78393c..000000000 --- a/admin/views/component_dashboard/view.html.php +++ /dev/null @@ -1,215 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Component_dashboard Html View class - */ -class ComponentbuilderViewComponent_dashboard extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_dashboard', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('component_dashboard.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('component_dashboard.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('component_dashboard.edit')) - { - // We can save the record. - JToolBarHelper::save('component_dashboard.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('component_dashboard.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('component_dashboard.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('component_dashboard.create')) - { - JToolBarHelper::apply('component_dashboard.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_dashboard.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('component_dashboard.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('component_dashboard.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('component_dashboard.edit')) - { - // We can save the new record - JToolBarHelper::apply('component_dashboard.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_dashboard.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('component_dashboard.create')) - { - JToolBarHelper::custom('component_dashboard.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_dashboard.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_dashboard.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.component_dashboard', $this->item->id); - } - if ($this->canDo->get('component_dashboard.create')) - { - JToolBarHelper::custom('component_dashboard.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('component_dashboard.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('component_dashboard'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_DASHBOARD_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/component_dashboard.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/component_dashboard/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/component_files_folders/submitbutton.js b/admin/views/component_files_folders/submitbutton.js deleted file mode 100644 index 7067ad539..000000000 --- a/admin/views/component_files_folders/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('component_files_folders, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/component_files_folders/tmpl/edit.php b/admin/views/component_files_folders/tmpl/edit.php deleted file mode 100644 index 958f67af5..000000000 --- a/admin/views/component_files_folders/tmpl/edit.php +++ /dev/null @@ -1,123 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - diff --git a/admin/views/component_files_folders/view.html.php b/admin/views/component_files_folders/view.html.php deleted file mode 100644 index 7a4429e10..000000000 --- a/admin/views/component_files_folders/view.html.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Component_files_folders Html View class - */ -class ComponentbuilderViewComponent_files_folders extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_files_folders', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('component_files_folders.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('component_files_folders.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('component_files_folders.edit')) - { - // We can save the record. - JToolBarHelper::save('component_files_folders.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('component_files_folders.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('component_files_folders.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('component_files_folders.create')) - { - JToolBarHelper::apply('component_files_folders.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_files_folders.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('component_files_folders.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('component_files_folders.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('component_files_folders.edit')) - { - // We can save the new record - JToolBarHelper::apply('component_files_folders.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_files_folders.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('component_files_folders.create')) - { - JToolBarHelper::custom('component_files_folders.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_files_folders.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_files_folders.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.component_files_folders', $this->item->id); - } - if ($this->canDo->get('component_files_folders.create')) - { - JToolBarHelper::custom('component_files_folders.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('component_files_folders.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('component_files_folders'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/component_files_folders.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/component_files_folders/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/component_modules/submitbutton.js b/admin/views/component_modules/submitbutton.js deleted file mode 100644 index 18eb9c606..000000000 --- a/admin/views/component_modules/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('component_modules, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/component_modules/tmpl/edit.php b/admin/views/component_modules/tmpl/edit.php deleted file mode 100644 index af478d8b5..000000000 --- a/admin/views/component_modules/tmpl/edit.php +++ /dev/null @@ -1,129 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/component_modules/view.html.php b/admin/views/component_modules/view.html.php deleted file mode 100644 index 1f60bb45d..000000000 --- a/admin/views/component_modules/view.html.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Component_modules Html View class - */ -class ComponentbuilderViewComponent_modules extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_modules', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_MODULES_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_MODULES_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('component_modules.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('component_modules.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('component_modules.edit')) - { - // We can save the record. - JToolBarHelper::save('component_modules.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('component_modules.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('component_modules.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('component_modules.create')) - { - JToolBarHelper::apply('component_modules.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_modules.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('component_modules.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('component_modules.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('component_modules.edit')) - { - // We can save the new record - JToolBarHelper::apply('component_modules.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_modules.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('component_modules.create')) - { - JToolBarHelper::custom('component_modules.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_modules.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_modules.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.component_modules', $this->item->id); - } - if ($this->canDo->get('component_modules.create')) - { - JToolBarHelper::custom('component_modules.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('component_modules.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('component_modules'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_MODULES_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_MODULES_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/component_modules.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/component_modules/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/component_mysql_tweaks/submitbutton.js b/admin/views/component_mysql_tweaks/submitbutton.js deleted file mode 100644 index 2f18b64d8..000000000 --- a/admin/views/component_mysql_tweaks/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('component_mysql_tweaks, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/component_mysql_tweaks/tmpl/edit.php b/admin/views/component_mysql_tweaks/tmpl/edit.php deleted file mode 100644 index e8d358697..000000000 --- a/admin/views/component_mysql_tweaks/tmpl/edit.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - diff --git a/admin/views/component_mysql_tweaks/view.html.php b/admin/views/component_mysql_tweaks/view.html.php deleted file mode 100644 index af9ff8fb0..000000000 --- a/admin/views/component_mysql_tweaks/view.html.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Component_mysql_tweaks Html View class - */ -class ComponentbuilderViewComponent_mysql_tweaks extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_mysql_tweaks', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('component_mysql_tweaks.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('component_mysql_tweaks.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('component_mysql_tweaks.edit')) - { - // We can save the record. - JToolBarHelper::save('component_mysql_tweaks.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('component_mysql_tweaks.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('component_mysql_tweaks.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('component_mysql_tweaks.create')) - { - JToolBarHelper::apply('component_mysql_tweaks.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_mysql_tweaks.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('component_mysql_tweaks.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('component_mysql_tweaks.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('component_mysql_tweaks.edit')) - { - // We can save the new record - JToolBarHelper::apply('component_mysql_tweaks.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_mysql_tweaks.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('component_mysql_tweaks.create')) - { - JToolBarHelper::custom('component_mysql_tweaks.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_mysql_tweaks.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_mysql_tweaks.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.component_mysql_tweaks', $this->item->id); - } - if ($this->canDo->get('component_mysql_tweaks.create')) - { - JToolBarHelper::custom('component_mysql_tweaks.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('component_mysql_tweaks.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('component_mysql_tweaks'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_MYSQL_TWEAKS_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/component_mysql_tweaks.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/component_mysql_tweaks/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/component_placeholders/submitbutton.js b/admin/views/component_placeholders/submitbutton.js deleted file mode 100644 index 507163adc..000000000 --- a/admin/views/component_placeholders/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('component_placeholders, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/component_placeholders/tmpl/edit.php b/admin/views/component_placeholders/tmpl/edit.php deleted file mode 100644 index 0f448502e..000000000 --- a/admin/views/component_placeholders/tmpl/edit.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - diff --git a/admin/views/component_placeholders/view.html.php b/admin/views/component_placeholders/view.html.php deleted file mode 100644 index 841ac7bf9..000000000 --- a/admin/views/component_placeholders/view.html.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Component_placeholders Html View class - */ -class ComponentbuilderViewComponent_placeholders extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_placeholders', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('component_placeholders.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('component_placeholders.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('component_placeholders.edit')) - { - // We can save the record. - JToolBarHelper::save('component_placeholders.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('component_placeholders.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('component_placeholders.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('component_placeholders.create')) - { - JToolBarHelper::apply('component_placeholders.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_placeholders.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('component_placeholders.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('component_placeholders.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('component_placeholders.edit')) - { - // We can save the new record - JToolBarHelper::apply('component_placeholders.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_placeholders.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('component_placeholders.create')) - { - JToolBarHelper::custom('component_placeholders.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_placeholders.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_placeholders.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.component_placeholders', $this->item->id); - } - if ($this->canDo->get('component_placeholders.create')) - { - JToolBarHelper::custom('component_placeholders.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('component_placeholders.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('component_placeholders'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_PLACEHOLDERS_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/component_placeholders.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/component_placeholders/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/component_plugins/submitbutton.js b/admin/views/component_plugins/submitbutton.js deleted file mode 100644 index 161c07e7e..000000000 --- a/admin/views/component_plugins/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('component_plugins, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/component_plugins/tmpl/edit.php b/admin/views/component_plugins/tmpl/edit.php deleted file mode 100644 index 41890aa03..000000000 --- a/admin/views/component_plugins/tmpl/edit.php +++ /dev/null @@ -1,129 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/component_plugins/view.html.php b/admin/views/component_plugins/view.html.php deleted file mode 100644 index 6a0c54226..000000000 --- a/admin/views/component_plugins/view.html.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Component_plugins Html View class - */ -class ComponentbuilderViewComponent_plugins extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_plugins', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_PLUGINS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_PLUGINS_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('component_plugins.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('component_plugins.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('component_plugins.edit')) - { - // We can save the record. - JToolBarHelper::save('component_plugins.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('component_plugins.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('component_plugins.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('component_plugins.create')) - { - JToolBarHelper::apply('component_plugins.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_plugins.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('component_plugins.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('component_plugins.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('component_plugins.edit')) - { - // We can save the new record - JToolBarHelper::apply('component_plugins.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_plugins.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('component_plugins.create')) - { - JToolBarHelper::custom('component_plugins.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_plugins.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_plugins.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.component_plugins', $this->item->id); - } - if ($this->canDo->get('component_plugins.create')) - { - JToolBarHelper::custom('component_plugins.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('component_plugins.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('component_plugins'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_PLUGINS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_PLUGINS_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/component_plugins.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/component_plugins/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/component_site_views/submitbutton.js b/admin/views/component_site_views/submitbutton.js deleted file mode 100644 index b8a924960..000000000 --- a/admin/views/component_site_views/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('component_site_views, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/component_site_views/tmpl/edit.php b/admin/views/component_site_views/tmpl/edit.php deleted file mode 100644 index 2482501a2..000000000 --- a/admin/views/component_site_views/tmpl/edit.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - diff --git a/admin/views/component_site_views/view.html.php b/admin/views/component_site_views/view.html.php deleted file mode 100644 index 629fb73ac..000000000 --- a/admin/views/component_site_views/view.html.php +++ /dev/null @@ -1,203 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Component_site_views Html View class - */ -class ComponentbuilderViewComponent_site_views extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_site_views', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('component_site_views.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('component_site_views.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('component_site_views.edit')) - { - // We can save the record. - JToolBarHelper::save('component_site_views.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('component_site_views.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('component_site_views.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('component_site_views.create')) - { - JToolBarHelper::apply('component_site_views.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_site_views.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('component_site_views.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('component_site_views.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('component_site_views.edit')) - { - // We can save the new record - JToolBarHelper::apply('component_site_views.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_site_views.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('component_site_views.create')) - { - JToolBarHelper::custom('component_site_views.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_site_views.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_site_views.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.component_site_views', $this->item->id); - } - if ($this->canDo->get('component_site_views.create')) - { - JToolBarHelper::custom('component_site_views.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('component_site_views.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('component_site_views'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/component_site_views.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/component_site_views/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/component_updates/submitbutton.js b/admin/views/component_updates/submitbutton.js deleted file mode 100644 index 3584ee6bf..000000000 --- a/admin/views/component_updates/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('component_updates, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/component_updates/tmpl/edit.php b/admin/views/component_updates/tmpl/edit.php deleted file mode 100644 index a29bf936a..000000000 --- a/admin/views/component_updates/tmpl/edit.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - diff --git a/admin/views/component_updates/view.html.php b/admin/views/component_updates/view.html.php deleted file mode 100644 index 3e01537f8..000000000 --- a/admin/views/component_updates/view.html.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Component_updates Html View class - */ -class ComponentbuilderViewComponent_updates extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_updates', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_UPDATES_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_UPDATES_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('component_updates.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('component_updates.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('component_updates.edit')) - { - // We can save the record. - JToolBarHelper::save('component_updates.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('component_updates.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('component_updates.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('component_updates.create')) - { - JToolBarHelper::apply('component_updates.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_updates.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('component_updates.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('component_updates.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('component_updates.edit')) - { - // We can save the new record - JToolBarHelper::apply('component_updates.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('component_updates.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('component_updates.create')) - { - JToolBarHelper::custom('component_updates.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_updates.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_updates.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.component_updates', $this->item->id); - } - if ($this->canDo->get('component_updates.create')) - { - JToolBarHelper::custom('component_updates.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('component_updates.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('component_updates'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_UPDATES_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_UPDATES_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/component_updates.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/component_updates/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/componentbuilder/tmpl/default.php b/admin/views/componentbuilder/tmpl/default.php deleted file mode 100644 index 626d49926..000000000 --- a/admin/views/componentbuilder/tmpl/default.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - - - -?> -
    -
    - 'cpanel')); ?> - - -
    -
    - 'main')); ?> - - loadTemplate('main');?> - - -
    -
    - 'vdm')); ?> - - loadTemplate('vdm');?> - - -
    -
    - - - - -
    -
    - 'wiki_one')); ?> - - loadTemplate('wiki_tutorials');?> - - -
    -
    - -
    -
    - - - -
    -
    - 'notice_board_one')); ?> - - loadTemplate('notice_board_vast_development_method');?> - - -
    -
    - -
    -
    - - - -
    -
    - 'readme_one')); ?> - - loadTemplate('readme_information');?> - - -
    -
    - -
    -
    - - - -
    -
    \ No newline at end of file diff --git a/admin/views/componentbuilder/tmpl/default_main.php b/admin/views/componentbuilder/tmpl/default_main.php deleted file mode 100644 index ca37bf361..000000000 --- a/admin/views/componentbuilder/tmpl/default_main.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -icons['main']) && is_array($this->icons['main'])) :?> - icons['main'] as $icon): ?> - - -
    - -

    - \ No newline at end of file diff --git a/admin/views/componentbuilder/tmpl/default_vdm.php b/admin/views/componentbuilder/tmpl/default_vdm.php deleted file mode 100644 index 2249ff26e..000000000 --- a/admin/views/componentbuilder/tmpl/default_vdm.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -<?php echo JText::_('COM_COMPONENTBUILDER'); ?> - -
    -contributors)): ?> - contributors) > 1): ?> -

    - -

    - -
      - contributors as $contributor): ?> -
    • :
    • - -
    -
    - \ No newline at end of file diff --git a/admin/views/componentbuilder/view.html.php b/admin/views/componentbuilder/view.html.php deleted file mode 100644 index ca502ee7e..000000000 --- a/admin/views/componentbuilder/view.html.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - - - -/** - * Componentbuilder View class - */ -class ComponentbuilderViewComponentbuilder extends JViewLegacy -{ - /** - * View display method - * @return void - */ - function display($tpl = null) - { - // Assign data to the view - $this->icons = $this->get('Icons'); - $this->contributors = ComponentbuilderHelper::getContributors(); - $this->wiki = $this->get('Wiki'); - $this->noticeboard = $this->get('Noticeboard'); - $this->readme = $this->get('Readme'); - $this->version = $this->get('Version'); - - // get the manifest details of the component - $this->manifest = ComponentbuilderHelper::manifest(); - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - $canDo = ComponentbuilderHelper::getActions('componentbuilder'); - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_DASHBOARD'), 'grid-2'); - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('componentbuilder'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - if ($canDo->get('core.admin') || $canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $document = JFactory::getDocument(); - - // add dashboard style sheets - $document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/dashboard.css"); - - // set page title - $document->setTitle(JText::_('COM_COMPONENTBUILDER_DASHBOARD')); - - // add manifest to page JavaScript - $document->addScriptDeclaration("var manifest = jQuery.parseJSON('" . json_encode($this->manifest) . "');", "text/javascript"); - } -} diff --git a/admin/views/components_admin_views/tmpl/default.php b/admin/views/components_admin_views/tmpl/default.php deleted file mode 100644 index b24ea1388..000000000 --- a/admin/views/components_admin_views/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_admin_views.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'component_admin_viewsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/components_admin_views/tmpl/default_batch_body.php b/admin/views/components_admin_views/tmpl/default_batch_body.php deleted file mode 100644 index 8f6c857bd..000000000 --- a/admin/views/components_admin_views/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/components_admin_views/tmpl/default_batch_footer.php b/admin/views/components_admin_views/tmpl/default_batch_footer.php deleted file mode 100644 index 54ad51713..000000000 --- a/admin/views/components_admin_views/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/components_admin_views/tmpl/default_body.php b/admin/views/components_admin_views/tmpl/default_body.php deleted file mode 100644 index 11afa0aaf..000000000 --- a/admin/views/components_admin_views/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=components_admin_views&task=component_admin_views.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('component_admin_views',$item,'components_admin_views'); - ?> - - - get('component_admin_views.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('component_admin_views.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('component_admin_views.edit')): ?> - escape($item->joomla_component_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'components_admin_views.', $canCheckin); ?> - - - escape($item->joomla_component_system_name); ?> - -
    - - - get('component_admin_views.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'components_admin_views.', true, 'cb'); ?> - - published, $i, 'components_admin_views.', false, 'cb'); ?> - - - published, $i, 'components_admin_views.', true, 'cb'); ?> - - - published, $i, 'components_admin_views.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/components_admin_views/tmpl/default_foot.php b/admin/views/components_admin_views/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/components_admin_views/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/components_admin_views/tmpl/default_head.php b/admin/views/components_admin_views/tmpl/default_head.php deleted file mode 100644 index c2ec89b1b..000000000 --- a/admin/views/components_admin_views/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/components_admin_views/tmpl/default_toolbar.php b/admin/views/components_admin_views/tmpl/default_toolbar.php deleted file mode 100644 index 14c7fbf0d..000000000 --- a/admin/views/components_admin_views/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/components_admin_views/view.html.php b/admin/views/components_admin_views/view.html.php deleted file mode 100644 index f1943e4c8..000000000 --- a/admin/views/components_admin_views/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Components_admin_views - */ -class ComponentbuilderViewComponents_admin_views extends HtmlView -{ - /** - * Components_admin_views view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('components_admin_views'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_admin_views'); - $this->canEdit = $this->canDo->get('component_admin_views.edit'); - $this->canState = $this->canDo->get('component_admin_views.edit.state'); - $this->canCreate = $this->canDo->get('component_admin_views.create'); - $this->canDelete = $this->canDo->get('component_admin_views.delete'); - $this->canBatch = ($this->canDo->get('component_admin_views.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=components_admin_views'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('component_admin_views.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('component_admin_views.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('components_admin_views.publish'); - JToolBarHelper::unpublishList('components_admin_views.unpublish'); - JToolBarHelper::archiveList('components_admin_views.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('components_admin_views.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'components_admin_views.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('components_admin_views.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('components_admin_views'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/components_admin_views.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/components_config/tmpl/default.php b/admin/views/components_config/tmpl/default.php deleted file mode 100644 index b06f61058..000000000 --- a/admin/views/components_config/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_config.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'component_configList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_COMPONENTS_CONFIG_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/components_config/tmpl/default_batch_body.php b/admin/views/components_config/tmpl/default_batch_body.php deleted file mode 100644 index 1e3e0e244..000000000 --- a/admin/views/components_config/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/components_config/tmpl/default_batch_footer.php b/admin/views/components_config/tmpl/default_batch_footer.php deleted file mode 100644 index d875e488a..000000000 --- a/admin/views/components_config/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/components_config/tmpl/default_body.php b/admin/views/components_config/tmpl/default_body.php deleted file mode 100644 index 3c18b63d7..000000000 --- a/admin/views/components_config/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=components_config&task=component_config.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('component_config',$item,'components_config'); - ?> - - - get('component_config.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('component_config.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('component_config.edit')): ?> - escape($item->joomla_component_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'components_config.', $canCheckin); ?> - - - escape($item->joomla_component_system_name); ?> - -
    - - - get('component_config.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'components_config.', true, 'cb'); ?> - - published, $i, 'components_config.', false, 'cb'); ?> - - - published, $i, 'components_config.', true, 'cb'); ?> - - - published, $i, 'components_config.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/components_config/tmpl/default_foot.php b/admin/views/components_config/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/components_config/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/components_config/tmpl/default_head.php b/admin/views/components_config/tmpl/default_head.php deleted file mode 100644 index b05b4873b..000000000 --- a/admin/views/components_config/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/components_config/tmpl/default_toolbar.php b/admin/views/components_config/tmpl/default_toolbar.php deleted file mode 100644 index c02473590..000000000 --- a/admin/views/components_config/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/components_config/view.html.php b/admin/views/components_config/view.html.php deleted file mode 100644 index 4d0d8d298..000000000 --- a/admin/views/components_config/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Components_config - */ -class ComponentbuilderViewComponents_config extends HtmlView -{ - /** - * Components_config view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('components_config'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_config'); - $this->canEdit = $this->canDo->get('component_config.edit'); - $this->canState = $this->canDo->get('component_config.edit.state'); - $this->canCreate = $this->canDo->get('component_config.create'); - $this->canDelete = $this->canDo->get('component_config.delete'); - $this->canBatch = ($this->canDo->get('component_config.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_COMPONENTS_CONFIG'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=components_config'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('component_config.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('component_config.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('components_config.publish'); - JToolBarHelper::unpublishList('components_config.unpublish'); - JToolBarHelper::archiveList('components_config.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('components_config.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'components_config.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('components_config.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('components_config'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_COMPONENTS_CONFIG')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/components_config.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/components_custom_admin_menus/tmpl/default.php b/admin/views/components_custom_admin_menus/tmpl/default.php deleted file mode 100644 index 2d5ec413d..000000000 --- a/admin/views/components_custom_admin_menus/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_custom_admin_menus.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'component_custom_admin_menusList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_MENUS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/components_custom_admin_menus/tmpl/default_batch_body.php b/admin/views/components_custom_admin_menus/tmpl/default_batch_body.php deleted file mode 100644 index f13281eea..000000000 --- a/admin/views/components_custom_admin_menus/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/components_custom_admin_menus/tmpl/default_batch_footer.php b/admin/views/components_custom_admin_menus/tmpl/default_batch_footer.php deleted file mode 100644 index e57bc6c87..000000000 --- a/admin/views/components_custom_admin_menus/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/components_custom_admin_menus/tmpl/default_body.php b/admin/views/components_custom_admin_menus/tmpl/default_body.php deleted file mode 100644 index 3dd5a1716..000000000 --- a/admin/views/components_custom_admin_menus/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=components_custom_admin_menus&task=component_custom_admin_menus.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('component_custom_admin_menus',$item,'components_custom_admin_menus'); - ?> - - - get('component_custom_admin_menus.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('component_custom_admin_menus.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('component_custom_admin_menus.edit')): ?> - escape($item->joomla_component_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'components_custom_admin_menus.', $canCheckin); ?> - - - escape($item->joomla_component_system_name); ?> - -
    - - - get('component_custom_admin_menus.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'components_custom_admin_menus.', true, 'cb'); ?> - - published, $i, 'components_custom_admin_menus.', false, 'cb'); ?> - - - published, $i, 'components_custom_admin_menus.', true, 'cb'); ?> - - - published, $i, 'components_custom_admin_menus.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/components_custom_admin_menus/tmpl/default_foot.php b/admin/views/components_custom_admin_menus/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/components_custom_admin_menus/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/components_custom_admin_menus/tmpl/default_head.php b/admin/views/components_custom_admin_menus/tmpl/default_head.php deleted file mode 100644 index e8856e014..000000000 --- a/admin/views/components_custom_admin_menus/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/components_custom_admin_menus/tmpl/default_toolbar.php b/admin/views/components_custom_admin_menus/tmpl/default_toolbar.php deleted file mode 100644 index d7fe14794..000000000 --- a/admin/views/components_custom_admin_menus/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/components_custom_admin_menus/view.html.php b/admin/views/components_custom_admin_menus/view.html.php deleted file mode 100644 index 8e3075413..000000000 --- a/admin/views/components_custom_admin_menus/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Components_custom_admin_menus - */ -class ComponentbuilderViewComponents_custom_admin_menus extends HtmlView -{ - /** - * Components_custom_admin_menus view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('components_custom_admin_menus'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_custom_admin_menus'); - $this->canEdit = $this->canDo->get('component_custom_admin_menus.edit'); - $this->canState = $this->canDo->get('component_custom_admin_menus.edit.state'); - $this->canCreate = $this->canDo->get('component_custom_admin_menus.create'); - $this->canDelete = $this->canDo->get('component_custom_admin_menus.delete'); - $this->canBatch = ($this->canDo->get('component_custom_admin_menus.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_MENUS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=components_custom_admin_menus'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('component_custom_admin_menus.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('component_custom_admin_menus.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('components_custom_admin_menus.publish'); - JToolBarHelper::unpublishList('components_custom_admin_menus.unpublish'); - JToolBarHelper::archiveList('components_custom_admin_menus.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('components_custom_admin_menus.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'components_custom_admin_menus.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('components_custom_admin_menus.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('components_custom_admin_menus'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_MENUS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/components_custom_admin_menus.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/components_custom_admin_views/tmpl/default.php b/admin/views/components_custom_admin_views/tmpl/default.php deleted file mode 100644 index fea76e5ac..000000000 --- a/admin/views/components_custom_admin_views/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_custom_admin_views.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'component_custom_admin_viewsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_VIEWS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/components_custom_admin_views/tmpl/default_batch_body.php b/admin/views/components_custom_admin_views/tmpl/default_batch_body.php deleted file mode 100644 index 6ccbf0f46..000000000 --- a/admin/views/components_custom_admin_views/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/components_custom_admin_views/tmpl/default_batch_footer.php b/admin/views/components_custom_admin_views/tmpl/default_batch_footer.php deleted file mode 100644 index 0e6decc2a..000000000 --- a/admin/views/components_custom_admin_views/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/components_custom_admin_views/tmpl/default_body.php b/admin/views/components_custom_admin_views/tmpl/default_body.php deleted file mode 100644 index a84f71aef..000000000 --- a/admin/views/components_custom_admin_views/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=components_custom_admin_views&task=component_custom_admin_views.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('component_custom_admin_views',$item,'components_custom_admin_views'); - ?> - - - get('component_custom_admin_views.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('component_custom_admin_views.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('component_custom_admin_views.edit')): ?> - escape($item->joomla_component_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'components_custom_admin_views.', $canCheckin); ?> - - - escape($item->joomla_component_system_name); ?> - -
    - - - get('component_custom_admin_views.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'components_custom_admin_views.', true, 'cb'); ?> - - published, $i, 'components_custom_admin_views.', false, 'cb'); ?> - - - published, $i, 'components_custom_admin_views.', true, 'cb'); ?> - - - published, $i, 'components_custom_admin_views.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/components_custom_admin_views/tmpl/default_foot.php b/admin/views/components_custom_admin_views/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/components_custom_admin_views/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/components_custom_admin_views/tmpl/default_head.php b/admin/views/components_custom_admin_views/tmpl/default_head.php deleted file mode 100644 index b8c49c4a6..000000000 --- a/admin/views/components_custom_admin_views/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/components_custom_admin_views/tmpl/default_toolbar.php b/admin/views/components_custom_admin_views/tmpl/default_toolbar.php deleted file mode 100644 index 7f78685ba..000000000 --- a/admin/views/components_custom_admin_views/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/components_custom_admin_views/view.html.php b/admin/views/components_custom_admin_views/view.html.php deleted file mode 100644 index b59abfe7f..000000000 --- a/admin/views/components_custom_admin_views/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Components_custom_admin_views - */ -class ComponentbuilderViewComponents_custom_admin_views extends HtmlView -{ - /** - * Components_custom_admin_views view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('components_custom_admin_views'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_custom_admin_views'); - $this->canEdit = $this->canDo->get('component_custom_admin_views.edit'); - $this->canState = $this->canDo->get('component_custom_admin_views.edit.state'); - $this->canCreate = $this->canDo->get('component_custom_admin_views.create'); - $this->canDelete = $this->canDo->get('component_custom_admin_views.delete'); - $this->canBatch = ($this->canDo->get('component_custom_admin_views.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_VIEWS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=components_custom_admin_views'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('component_custom_admin_views.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('component_custom_admin_views.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('components_custom_admin_views.publish'); - JToolBarHelper::unpublishList('components_custom_admin_views.unpublish'); - JToolBarHelper::archiveList('components_custom_admin_views.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('components_custom_admin_views.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'components_custom_admin_views.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('components_custom_admin_views.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('components_custom_admin_views'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_COMPONENTS_CUSTOM_ADMIN_VIEWS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/components_custom_admin_views.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/components_dashboard/tmpl/default.php b/admin/views/components_dashboard/tmpl/default.php deleted file mode 100644 index fa5ccc583..000000000 --- a/admin/views/components_dashboard/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_dashboard.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'component_dashboardList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_COMPONENTS_DASHBOARD_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/components_dashboard/tmpl/default_batch_body.php b/admin/views/components_dashboard/tmpl/default_batch_body.php deleted file mode 100644 index db41f7cfe..000000000 --- a/admin/views/components_dashboard/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/components_dashboard/tmpl/default_batch_footer.php b/admin/views/components_dashboard/tmpl/default_batch_footer.php deleted file mode 100644 index f90300467..000000000 --- a/admin/views/components_dashboard/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/components_dashboard/tmpl/default_body.php b/admin/views/components_dashboard/tmpl/default_body.php deleted file mode 100644 index 00de39ed2..000000000 --- a/admin/views/components_dashboard/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=components_dashboard&task=component_dashboard.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('component_dashboard',$item,'components_dashboard'); - ?> - - - get('component_dashboard.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('component_dashboard.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('component_dashboard.edit')): ?> - escape($item->joomla_component_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'components_dashboard.', $canCheckin); ?> - - - escape($item->joomla_component_system_name); ?> - -
    - - - get('component_dashboard.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'components_dashboard.', true, 'cb'); ?> - - published, $i, 'components_dashboard.', false, 'cb'); ?> - - - published, $i, 'components_dashboard.', true, 'cb'); ?> - - - published, $i, 'components_dashboard.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/components_dashboard/tmpl/default_foot.php b/admin/views/components_dashboard/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/components_dashboard/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/components_dashboard/tmpl/default_head.php b/admin/views/components_dashboard/tmpl/default_head.php deleted file mode 100644 index c240e3ccb..000000000 --- a/admin/views/components_dashboard/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/components_dashboard/tmpl/default_toolbar.php b/admin/views/components_dashboard/tmpl/default_toolbar.php deleted file mode 100644 index 8b4a75221..000000000 --- a/admin/views/components_dashboard/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/components_dashboard/view.html.php b/admin/views/components_dashboard/view.html.php deleted file mode 100644 index d0272e3b6..000000000 --- a/admin/views/components_dashboard/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Components_dashboard - */ -class ComponentbuilderViewComponents_dashboard extends HtmlView -{ - /** - * Components_dashboard view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('components_dashboard'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_dashboard'); - $this->canEdit = $this->canDo->get('component_dashboard.edit'); - $this->canState = $this->canDo->get('component_dashboard.edit.state'); - $this->canCreate = $this->canDo->get('component_dashboard.create'); - $this->canDelete = $this->canDo->get('component_dashboard.delete'); - $this->canBatch = ($this->canDo->get('component_dashboard.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_COMPONENTS_DASHBOARD'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=components_dashboard'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('component_dashboard.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('component_dashboard.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('components_dashboard.publish'); - JToolBarHelper::unpublishList('components_dashboard.unpublish'); - JToolBarHelper::archiveList('components_dashboard.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('components_dashboard.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'components_dashboard.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('components_dashboard.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('components_dashboard'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_COMPONENTS_DASHBOARD')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/components_dashboard.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/components_files_folders/tmpl/default.php b/admin/views/components_files_folders/tmpl/default.php deleted file mode 100644 index fb7ee61ca..000000000 --- a/admin/views/components_files_folders/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_files_folders.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'component_files_foldersList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_COMPONENTS_FILES_FOLDERS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/components_files_folders/tmpl/default_batch_body.php b/admin/views/components_files_folders/tmpl/default_batch_body.php deleted file mode 100644 index e61876a50..000000000 --- a/admin/views/components_files_folders/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/components_files_folders/tmpl/default_batch_footer.php b/admin/views/components_files_folders/tmpl/default_batch_footer.php deleted file mode 100644 index ffdfa4d0a..000000000 --- a/admin/views/components_files_folders/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/components_files_folders/tmpl/default_body.php b/admin/views/components_files_folders/tmpl/default_body.php deleted file mode 100644 index 970ac4108..000000000 --- a/admin/views/components_files_folders/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=components_files_folders&task=component_files_folders.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('component_files_folders',$item,'components_files_folders'); - ?> - - - get('component_files_folders.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('component_files_folders.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('component_files_folders.edit')): ?> - escape($item->joomla_component_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'components_files_folders.', $canCheckin); ?> - - - escape($item->joomla_component_system_name); ?> - -
    - - - get('component_files_folders.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'components_files_folders.', true, 'cb'); ?> - - published, $i, 'components_files_folders.', false, 'cb'); ?> - - - published, $i, 'components_files_folders.', true, 'cb'); ?> - - - published, $i, 'components_files_folders.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/components_files_folders/tmpl/default_foot.php b/admin/views/components_files_folders/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/components_files_folders/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/components_files_folders/tmpl/default_head.php b/admin/views/components_files_folders/tmpl/default_head.php deleted file mode 100644 index 7c3cfb580..000000000 --- a/admin/views/components_files_folders/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/components_files_folders/tmpl/default_toolbar.php b/admin/views/components_files_folders/tmpl/default_toolbar.php deleted file mode 100644 index 65990c2f2..000000000 --- a/admin/views/components_files_folders/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/components_files_folders/view.html.php b/admin/views/components_files_folders/view.html.php deleted file mode 100644 index e84fddcdc..000000000 --- a/admin/views/components_files_folders/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Components_files_folders - */ -class ComponentbuilderViewComponents_files_folders extends HtmlView -{ - /** - * Components_files_folders view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('components_files_folders'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_files_folders'); - $this->canEdit = $this->canDo->get('component_files_folders.edit'); - $this->canState = $this->canDo->get('component_files_folders.edit.state'); - $this->canCreate = $this->canDo->get('component_files_folders.create'); - $this->canDelete = $this->canDo->get('component_files_folders.delete'); - $this->canBatch = ($this->canDo->get('component_files_folders.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_COMPONENTS_FILES_FOLDERS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=components_files_folders'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('component_files_folders.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('component_files_folders.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('components_files_folders.publish'); - JToolBarHelper::unpublishList('components_files_folders.unpublish'); - JToolBarHelper::archiveList('components_files_folders.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('components_files_folders.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'components_files_folders.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('components_files_folders.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('components_files_folders'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_COMPONENTS_FILES_FOLDERS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/components_files_folders.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/components_modules/tmpl/default.php b/admin/views/components_modules/tmpl/default.php deleted file mode 100644 index c28121201..000000000 --- a/admin/views/components_modules/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_modules.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'component_modulesList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_COMPONENTS_MODULES_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/components_modules/tmpl/default_batch_body.php b/admin/views/components_modules/tmpl/default_batch_body.php deleted file mode 100644 index 5607bbb39..000000000 --- a/admin/views/components_modules/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/components_modules/tmpl/default_batch_footer.php b/admin/views/components_modules/tmpl/default_batch_footer.php deleted file mode 100644 index c19f5bea2..000000000 --- a/admin/views/components_modules/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/components_modules/tmpl/default_body.php b/admin/views/components_modules/tmpl/default_body.php deleted file mode 100644 index 21a8b8475..000000000 --- a/admin/views/components_modules/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=components_modules&task=component_modules.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('component_modules',$item,'components_modules'); - ?> - - - get('component_modules.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('component_modules.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('component_modules.edit')): ?> - escape($item->joomla_component_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'components_modules.', $canCheckin); ?> - - - escape($item->joomla_component_system_name); ?> - -
    - - - get('component_modules.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'components_modules.', true, 'cb'); ?> - - published, $i, 'components_modules.', false, 'cb'); ?> - - - published, $i, 'components_modules.', true, 'cb'); ?> - - - published, $i, 'components_modules.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/components_modules/tmpl/default_foot.php b/admin/views/components_modules/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/components_modules/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/components_modules/tmpl/default_head.php b/admin/views/components_modules/tmpl/default_head.php deleted file mode 100644 index b2114e532..000000000 --- a/admin/views/components_modules/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/components_modules/tmpl/default_toolbar.php b/admin/views/components_modules/tmpl/default_toolbar.php deleted file mode 100644 index 4d67f147e..000000000 --- a/admin/views/components_modules/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/components_modules/view.html.php b/admin/views/components_modules/view.html.php deleted file mode 100644 index 95d6f6d0b..000000000 --- a/admin/views/components_modules/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Components_modules - */ -class ComponentbuilderViewComponents_modules extends HtmlView -{ - /** - * Components_modules view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('components_modules'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_modules'); - $this->canEdit = $this->canDo->get('component_modules.edit'); - $this->canState = $this->canDo->get('component_modules.edit.state'); - $this->canCreate = $this->canDo->get('component_modules.create'); - $this->canDelete = $this->canDo->get('component_modules.delete'); - $this->canBatch = ($this->canDo->get('component_modules.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_COMPONENTS_MODULES'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=components_modules'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('component_modules.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('component_modules.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('components_modules.publish'); - JToolBarHelper::unpublishList('components_modules.unpublish'); - JToolBarHelper::archiveList('components_modules.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('components_modules.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'components_modules.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('components_modules.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('components_modules'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_COMPONENTS_MODULES')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/components_modules.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/components_mysql_tweaks/tmpl/default.php b/admin/views/components_mysql_tweaks/tmpl/default.php deleted file mode 100644 index 85e86f0d8..000000000 --- a/admin/views/components_mysql_tweaks/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_mysql_tweaks.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'component_mysql_tweaksList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_COMPONENTS_MYSQL_TWEAKS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/components_mysql_tweaks/tmpl/default_batch_body.php b/admin/views/components_mysql_tweaks/tmpl/default_batch_body.php deleted file mode 100644 index e06a88118..000000000 --- a/admin/views/components_mysql_tweaks/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/components_mysql_tweaks/tmpl/default_batch_footer.php b/admin/views/components_mysql_tweaks/tmpl/default_batch_footer.php deleted file mode 100644 index 2d5d8f6e1..000000000 --- a/admin/views/components_mysql_tweaks/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/components_mysql_tweaks/tmpl/default_body.php b/admin/views/components_mysql_tweaks/tmpl/default_body.php deleted file mode 100644 index fda5a621c..000000000 --- a/admin/views/components_mysql_tweaks/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=components_mysql_tweaks&task=component_mysql_tweaks.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('component_mysql_tweaks',$item,'components_mysql_tweaks'); - ?> - - - get('component_mysql_tweaks.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('component_mysql_tweaks.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('component_mysql_tweaks.edit')): ?> - escape($item->joomla_component_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'components_mysql_tweaks.', $canCheckin); ?> - - - escape($item->joomla_component_system_name); ?> - -
    - - - get('component_mysql_tweaks.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'components_mysql_tweaks.', true, 'cb'); ?> - - published, $i, 'components_mysql_tweaks.', false, 'cb'); ?> - - - published, $i, 'components_mysql_tweaks.', true, 'cb'); ?> - - - published, $i, 'components_mysql_tweaks.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/components_mysql_tweaks/tmpl/default_foot.php b/admin/views/components_mysql_tweaks/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/components_mysql_tweaks/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/components_mysql_tweaks/tmpl/default_head.php b/admin/views/components_mysql_tweaks/tmpl/default_head.php deleted file mode 100644 index 913a11704..000000000 --- a/admin/views/components_mysql_tweaks/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/components_mysql_tweaks/tmpl/default_toolbar.php b/admin/views/components_mysql_tweaks/tmpl/default_toolbar.php deleted file mode 100644 index 8d7b8873a..000000000 --- a/admin/views/components_mysql_tweaks/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/components_mysql_tweaks/view.html.php b/admin/views/components_mysql_tweaks/view.html.php deleted file mode 100644 index 88094a7de..000000000 --- a/admin/views/components_mysql_tweaks/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Components_mysql_tweaks - */ -class ComponentbuilderViewComponents_mysql_tweaks extends HtmlView -{ - /** - * Components_mysql_tweaks view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('components_mysql_tweaks'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_mysql_tweaks'); - $this->canEdit = $this->canDo->get('component_mysql_tweaks.edit'); - $this->canState = $this->canDo->get('component_mysql_tweaks.edit.state'); - $this->canCreate = $this->canDo->get('component_mysql_tweaks.create'); - $this->canDelete = $this->canDo->get('component_mysql_tweaks.delete'); - $this->canBatch = ($this->canDo->get('component_mysql_tweaks.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_COMPONENTS_MYSQL_TWEAKS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=components_mysql_tweaks'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('component_mysql_tweaks.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('component_mysql_tweaks.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('components_mysql_tweaks.publish'); - JToolBarHelper::unpublishList('components_mysql_tweaks.unpublish'); - JToolBarHelper::archiveList('components_mysql_tweaks.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('components_mysql_tweaks.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'components_mysql_tweaks.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('components_mysql_tweaks.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('components_mysql_tweaks'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_COMPONENTS_MYSQL_TWEAKS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/components_mysql_tweaks.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/components_placeholders/tmpl/default.php b/admin/views/components_placeholders/tmpl/default.php deleted file mode 100644 index 23cdf1072..000000000 --- a/admin/views/components_placeholders/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_placeholders.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'component_placeholdersList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_COMPONENTS_PLACEHOLDERS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/components_placeholders/tmpl/default_batch_body.php b/admin/views/components_placeholders/tmpl/default_batch_body.php deleted file mode 100644 index 60ad0790c..000000000 --- a/admin/views/components_placeholders/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/components_placeholders/tmpl/default_batch_footer.php b/admin/views/components_placeholders/tmpl/default_batch_footer.php deleted file mode 100644 index 5c3dff310..000000000 --- a/admin/views/components_placeholders/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/components_placeholders/tmpl/default_body.php b/admin/views/components_placeholders/tmpl/default_body.php deleted file mode 100644 index cfd962727..000000000 --- a/admin/views/components_placeholders/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=components_placeholders&task=component_placeholders.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('component_placeholders',$item,'components_placeholders'); - ?> - - - get('component_placeholders.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('component_placeholders.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('component_placeholders.edit')): ?> - escape($item->joomla_component_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'components_placeholders.', $canCheckin); ?> - - - escape($item->joomla_component_system_name); ?> - -
    - - - get('component_placeholders.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'components_placeholders.', true, 'cb'); ?> - - published, $i, 'components_placeholders.', false, 'cb'); ?> - - - published, $i, 'components_placeholders.', true, 'cb'); ?> - - - published, $i, 'components_placeholders.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/components_placeholders/tmpl/default_foot.php b/admin/views/components_placeholders/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/components_placeholders/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/components_placeholders/tmpl/default_head.php b/admin/views/components_placeholders/tmpl/default_head.php deleted file mode 100644 index 1561b5be7..000000000 --- a/admin/views/components_placeholders/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/components_placeholders/tmpl/default_toolbar.php b/admin/views/components_placeholders/tmpl/default_toolbar.php deleted file mode 100644 index 561fb2a30..000000000 --- a/admin/views/components_placeholders/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/components_placeholders/view.html.php b/admin/views/components_placeholders/view.html.php deleted file mode 100644 index 6e0b1a526..000000000 --- a/admin/views/components_placeholders/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Components_placeholders - */ -class ComponentbuilderViewComponents_placeholders extends HtmlView -{ - /** - * Components_placeholders view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('components_placeholders'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_placeholders'); - $this->canEdit = $this->canDo->get('component_placeholders.edit'); - $this->canState = $this->canDo->get('component_placeholders.edit.state'); - $this->canCreate = $this->canDo->get('component_placeholders.create'); - $this->canDelete = $this->canDo->get('component_placeholders.delete'); - $this->canBatch = ($this->canDo->get('component_placeholders.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_COMPONENTS_PLACEHOLDERS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=components_placeholders'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('component_placeholders.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('component_placeholders.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('components_placeholders.publish'); - JToolBarHelper::unpublishList('components_placeholders.unpublish'); - JToolBarHelper::archiveList('components_placeholders.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('components_placeholders.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'components_placeholders.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('components_placeholders.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('components_placeholders'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_COMPONENTS_PLACEHOLDERS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/components_placeholders.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/components_plugins/tmpl/default.php b/admin/views/components_plugins/tmpl/default.php deleted file mode 100644 index cbc627581..000000000 --- a/admin/views/components_plugins/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_plugins.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'component_pluginsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_COMPONENTS_PLUGINS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/components_plugins/tmpl/default_batch_body.php b/admin/views/components_plugins/tmpl/default_batch_body.php deleted file mode 100644 index 2bf0834af..000000000 --- a/admin/views/components_plugins/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/components_plugins/tmpl/default_batch_footer.php b/admin/views/components_plugins/tmpl/default_batch_footer.php deleted file mode 100644 index d266dc969..000000000 --- a/admin/views/components_plugins/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/components_plugins/tmpl/default_body.php b/admin/views/components_plugins/tmpl/default_body.php deleted file mode 100644 index 92e34b278..000000000 --- a/admin/views/components_plugins/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=components_plugins&task=component_plugins.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('component_plugins',$item,'components_plugins'); - ?> - - - get('component_plugins.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('component_plugins.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('component_plugins.edit')): ?> - escape($item->joomla_component_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'components_plugins.', $canCheckin); ?> - - - escape($item->joomla_component_system_name); ?> - -
    - - - get('component_plugins.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'components_plugins.', true, 'cb'); ?> - - published, $i, 'components_plugins.', false, 'cb'); ?> - - - published, $i, 'components_plugins.', true, 'cb'); ?> - - - published, $i, 'components_plugins.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/components_plugins/tmpl/default_foot.php b/admin/views/components_plugins/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/components_plugins/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/components_plugins/tmpl/default_head.php b/admin/views/components_plugins/tmpl/default_head.php deleted file mode 100644 index ca4304a21..000000000 --- a/admin/views/components_plugins/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/components_plugins/tmpl/default_toolbar.php b/admin/views/components_plugins/tmpl/default_toolbar.php deleted file mode 100644 index 7038cf1fc..000000000 --- a/admin/views/components_plugins/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/components_plugins/view.html.php b/admin/views/components_plugins/view.html.php deleted file mode 100644 index da7c53e35..000000000 --- a/admin/views/components_plugins/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Components_plugins - */ -class ComponentbuilderViewComponents_plugins extends HtmlView -{ - /** - * Components_plugins view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('components_plugins'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_plugins'); - $this->canEdit = $this->canDo->get('component_plugins.edit'); - $this->canState = $this->canDo->get('component_plugins.edit.state'); - $this->canCreate = $this->canDo->get('component_plugins.create'); - $this->canDelete = $this->canDo->get('component_plugins.delete'); - $this->canBatch = ($this->canDo->get('component_plugins.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_COMPONENTS_PLUGINS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=components_plugins'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('component_plugins.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('component_plugins.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('components_plugins.publish'); - JToolBarHelper::unpublishList('components_plugins.unpublish'); - JToolBarHelper::archiveList('components_plugins.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('components_plugins.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'components_plugins.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('components_plugins.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('components_plugins'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_COMPONENTS_PLUGINS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/components_plugins.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/components_site_views/tmpl/default.php b/admin/views/components_site_views/tmpl/default.php deleted file mode 100644 index bb3204ea6..000000000 --- a/admin/views/components_site_views/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_site_views.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'component_site_viewsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/components_site_views/tmpl/default_batch_body.php b/admin/views/components_site_views/tmpl/default_batch_body.php deleted file mode 100644 index 0e01f04aa..000000000 --- a/admin/views/components_site_views/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/components_site_views/tmpl/default_batch_footer.php b/admin/views/components_site_views/tmpl/default_batch_footer.php deleted file mode 100644 index fadb2466b..000000000 --- a/admin/views/components_site_views/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/components_site_views/tmpl/default_body.php b/admin/views/components_site_views/tmpl/default_body.php deleted file mode 100644 index 09b2060aa..000000000 --- a/admin/views/components_site_views/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=components_site_views&task=component_site_views.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('component_site_views',$item,'components_site_views'); - ?> - - - get('component_site_views.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('component_site_views.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('component_site_views.edit')): ?> - escape($item->joomla_component_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'components_site_views.', $canCheckin); ?> - - - escape($item->joomla_component_system_name); ?> - -
    - - - get('component_site_views.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'components_site_views.', true, 'cb'); ?> - - published, $i, 'components_site_views.', false, 'cb'); ?> - - - published, $i, 'components_site_views.', true, 'cb'); ?> - - - published, $i, 'components_site_views.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/components_site_views/tmpl/default_foot.php b/admin/views/components_site_views/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/components_site_views/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/components_site_views/tmpl/default_head.php b/admin/views/components_site_views/tmpl/default_head.php deleted file mode 100644 index b75bce10c..000000000 --- a/admin/views/components_site_views/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/components_site_views/tmpl/default_toolbar.php b/admin/views/components_site_views/tmpl/default_toolbar.php deleted file mode 100644 index 722b022a0..000000000 --- a/admin/views/components_site_views/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/components_site_views/view.html.php b/admin/views/components_site_views/view.html.php deleted file mode 100644 index 6f60f7f6a..000000000 --- a/admin/views/components_site_views/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Components_site_views - */ -class ComponentbuilderViewComponents_site_views extends HtmlView -{ - /** - * Components_site_views view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('components_site_views'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_site_views'); - $this->canEdit = $this->canDo->get('component_site_views.edit'); - $this->canState = $this->canDo->get('component_site_views.edit.state'); - $this->canCreate = $this->canDo->get('component_site_views.create'); - $this->canDelete = $this->canDo->get('component_site_views.delete'); - $this->canBatch = ($this->canDo->get('component_site_views.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=components_site_views'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('component_site_views.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('component_site_views.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('components_site_views.publish'); - JToolBarHelper::unpublishList('components_site_views.unpublish'); - JToolBarHelper::archiveList('components_site_views.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('components_site_views.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'components_site_views.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('components_site_views.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('components_site_views'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_COMPONENTS_SITE_VIEWS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/components_site_views.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/components_updates/tmpl/default.php b/admin/views/components_updates/tmpl/default.php deleted file mode 100644 index d07ba5d73..000000000 --- a/admin/views/components_updates/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_updates.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'component_updatesList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_COMPONENTS_UPDATES_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/components_updates/tmpl/default_batch_body.php b/admin/views/components_updates/tmpl/default_batch_body.php deleted file mode 100644 index aac362ee8..000000000 --- a/admin/views/components_updates/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/components_updates/tmpl/default_batch_footer.php b/admin/views/components_updates/tmpl/default_batch_footer.php deleted file mode 100644 index 14d8880d1..000000000 --- a/admin/views/components_updates/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/components_updates/tmpl/default_body.php b/admin/views/components_updates/tmpl/default_body.php deleted file mode 100644 index 3d1f87ac9..000000000 --- a/admin/views/components_updates/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=components_updates&task=component_updates.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('component_updates',$item,'components_updates'); - ?> - - - get('component_updates.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('component_updates.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('component_updates.edit')): ?> - escape($item->joomla_component_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'components_updates.', $canCheckin); ?> - - - escape($item->joomla_component_system_name); ?> - -
    - - - get('component_updates.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'components_updates.', true, 'cb'); ?> - - published, $i, 'components_updates.', false, 'cb'); ?> - - - published, $i, 'components_updates.', true, 'cb'); ?> - - - published, $i, 'components_updates.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/components_updates/tmpl/default_foot.php b/admin/views/components_updates/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/components_updates/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/components_updates/tmpl/default_head.php b/admin/views/components_updates/tmpl/default_head.php deleted file mode 100644 index 267374a6c..000000000 --- a/admin/views/components_updates/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/components_updates/tmpl/default_toolbar.php b/admin/views/components_updates/tmpl/default_toolbar.php deleted file mode 100644 index c8c2cd292..000000000 --- a/admin/views/components_updates/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/components_updates/view.html.php b/admin/views/components_updates/view.html.php deleted file mode 100644 index 5c5b3b7b6..000000000 --- a/admin/views/components_updates/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Components_updates - */ -class ComponentbuilderViewComponents_updates extends HtmlView -{ - /** - * Components_updates view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('components_updates'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('component_updates'); - $this->canEdit = $this->canDo->get('component_updates.edit'); - $this->canState = $this->canDo->get('component_updates.edit.state'); - $this->canCreate = $this->canDo->get('component_updates.create'); - $this->canDelete = $this->canDo->get('component_updates.delete'); - $this->canBatch = ($this->canDo->get('component_updates.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_COMPONENTS_UPDATES'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=components_updates'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('component_updates.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('component_updates.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('components_updates.publish'); - JToolBarHelper::unpublishList('components_updates.unpublish'); - JToolBarHelper::archiveList('components_updates.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('components_updates.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'components_updates.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('components_updates.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('components_updates'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_COMPONENTS_UPDATES')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/components_updates.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/custom_admin_view/submitbutton.js b/admin/views/custom_admin_view/submitbutton.js deleted file mode 100644 index 83d9f2923..000000000 --- a/admin/views/custom_admin_view/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('custom_admin_view, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/custom_admin_view/tmpl/edit.php b/admin/views/custom_admin_view/tmpl/edit.php deleted file mode 100644 index ffa81a575..000000000 --- a/admin/views/custom_admin_view/tmpl/edit.php +++ /dev/null @@ -1,434 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/custom_admin_view/view.html.php b/admin/views/custom_admin_view/view.html.php deleted file mode 100644 index c4a6f37d7..000000000 --- a/admin/views/custom_admin_view/view.html.php +++ /dev/null @@ -1,215 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Custom_admin_view Html View class - */ -class ComponentbuilderViewCustom_admin_view extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('custom_admin_view', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NEW' : 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('core.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('custom_admin_view.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('core.edit')) - { - // We can save the record. - JToolBarHelper::save('custom_admin_view.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('custom_admin_view.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('custom_admin_view.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('core.create')) - { - JToolBarHelper::apply('custom_admin_view.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('custom_admin_view.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('custom_admin_view.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('custom_admin_view.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('core.edit')) - { - // We can save the new record - JToolBarHelper::apply('custom_admin_view.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('custom_admin_view.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('core.create')) - { - JToolBarHelper::custom('custom_admin_view.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('custom_admin_view.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('core.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.custom_admin_view', $this->item->id); - } - if ($this->canDo->get('core.create')) - { - JToolBarHelper::custom('custom_admin_view.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('custom_admin_view.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('custom_admin_view'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NEW' : 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/custom_admin_view.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/custom_admin_view/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/custom_admin_views/tmpl/default.php b/admin/views/custom_admin_views/tmpl/default.php deleted file mode 100644 index 0670e0b90..000000000 --- a/admin/views/custom_admin_views/tmpl/default.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleMaingets', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_MAIN_GET') . ' -')); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=custom_admin_views.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'custom_admin_viewList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEWS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/custom_admin_views/tmpl/default_batch_body.php b/admin/views/custom_admin_views/tmpl/default_batch_body.php deleted file mode 100644 index 2aeafec6f..000000000 --- a/admin/views/custom_admin_views/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/custom_admin_views/tmpl/default_batch_footer.php b/admin/views/custom_admin_views/tmpl/default_batch_footer.php deleted file mode 100644 index d9ba702fe..000000000 --- a/admin/views/custom_admin_views/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/custom_admin_views/tmpl/default_body.php b/admin/views/custom_admin_views/tmpl/default_body.php deleted file mode 100644 index c66378b18..000000000 --- a/admin/views/custom_admin_views/tmpl/default_body.php +++ /dev/null @@ -1,123 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); -use VDM\Joomla\Utilities\StringHelper; - -$edit = "index.php?option=com_componentbuilder&view=custom_admin_views&task=custom_admin_view.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('custom_admin_view',$item,'custom_admin_views'); - ?> - - - get('core.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('core.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('core.edit')): ?> - escape($item->system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'custom_admin_views.', $canCheckin); ?> - - - escape($item->system_name); ?> - -
    - - -
    : - escape($item->name); ?>
    - : - escape($item->codename); ?>
    - context)): ?> - : - escape($item->context); ?> - -
    - - -
    - escape($item->description); ?> -
      -
    • : - add_custom_button); ?>
    • -
    • : - add_php_ajax); ?>
    • -
    -
    - - -
    - user->authorise('dynamic_get.edit', 'com_componentbuilder.dynamic_get.' . (int) $item->main_get)): ?> - escape($item->main_get_name); ?> - - escape($item->main_get_name); ?> - -
    - - - get('core.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'custom_admin_views.', true, 'cb'); ?> - - published, $i, 'custom_admin_views.', false, 'cb'); ?> - - - published, $i, 'custom_admin_views.', true, 'cb'); ?> - - - published, $i, 'custom_admin_views.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/custom_admin_views/tmpl/default_foot.php b/admin/views/custom_admin_views/tmpl/default_foot.php deleted file mode 100644 index 5a05d8cfd..000000000 --- a/admin/views/custom_admin_views/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/custom_admin_views/tmpl/default_head.php b/admin/views/custom_admin_views/tmpl/default_head.php deleted file mode 100644 index 42e2ebed7..000000000 --- a/admin/views/custom_admin_views/tmpl/default_head.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/custom_admin_views/tmpl/default_toolbar.php b/admin/views/custom_admin_views/tmpl/default_toolbar.php deleted file mode 100644 index b6d5d0644..000000000 --- a/admin/views/custom_admin_views/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/custom_admin_views/view.html.php b/admin/views/custom_admin_views/view.html.php deleted file mode 100644 index f8675e470..000000000 --- a/admin/views/custom_admin_views/view.html.php +++ /dev/null @@ -1,299 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Custom_admin_views - */ -class ComponentbuilderViewCustom_admin_views extends HtmlView -{ - /** - * Custom_admin_views view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('custom_admin_views'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('custom_admin_view'); - $this->canEdit = $this->canDo->get('core.edit'); - $this->canState = $this->canDo->get('core.edit.state'); - $this->canCreate = $this->canDo->get('core.create'); - $this->canDelete = $this->canDo->get('core.delete'); - $this->canBatch = ($this->canDo->get('custom_admin_view.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEWS'), 'screen'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=custom_admin_views'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('custom_admin_view.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('custom_admin_view.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('custom_admin_views.publish'); - JToolBarHelper::unpublishList('custom_admin_views.unpublish'); - JToolBarHelper::archiveList('custom_admin_views.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('custom_admin_views.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'custom_admin_views.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('custom_admin_views.trash'); - } - - if ($this->canDo->get('core.export') && $this->canDo->get('custom_admin_view.export')) - { - JToolBarHelper::custom('custom_admin_views.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); - } - } - if ($this->user->authorise('custom_admin_view.get_snippets', 'com_componentbuilder')) - { - // add Get Snippets button. - JToolBarHelper::custom('custom_admin_views.getSnippets', 'search custom-button-getsnippets', '', 'COM_COMPONENTBUILDER_GET_SNIPPETS', false); - } - - if ($this->canDo->get('core.import') && $this->canDo->get('custom_admin_view.import')) - { - JToolBarHelper::custom('custom_admin_views.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('custom_admin_views'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - - // Only load Main Get Name batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Main Get Name Selection - $this->main_getNameOptions = JFormHelper::loadFieldType('Maingets')->options; - // We do some sanitation for Main Get Name filter - if (ComponentbuilderHelper::checkArray($this->main_getNameOptions) && - isset($this->main_getNameOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->main_getNameOptions[0]->value)) - { - unset($this->main_getNameOptions[0]); - } - // Main Get Name Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_MAIN_GET_LABEL').' -', - 'batch[main_get]', - JHtml::_('select.options', $this->main_getNameOptions, 'value', 'text') - ); - } - - // Only load Add Php Ajax batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Add Php Ajax Selection - $this->add_php_ajaxOptions = JFormHelper::loadFieldType('customadminviewsfilteraddphpajax')->options; - // We do some sanitation for Add Php Ajax filter - if (ComponentbuilderHelper::checkArray($this->add_php_ajaxOptions) && - isset($this->add_php_ajaxOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->add_php_ajaxOptions[0]->value)) - { - unset($this->add_php_ajaxOptions[0]); - } - // Add Php Ajax Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_PHP_AJAX_LABEL').' -', - 'batch[add_php_ajax]', - JHtml::_('select.options', $this->add_php_ajaxOptions, 'value', 'text') - ); - } - - // Only load Add Custom Button batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Add Custom Button Selection - $this->add_custom_buttonOptions = JFormHelper::loadFieldType('customadminviewsfilteraddcustombutton')->options; - // We do some sanitation for Add Custom Button filter - if (ComponentbuilderHelper::checkArray($this->add_custom_buttonOptions) && - isset($this->add_custom_buttonOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->add_custom_buttonOptions[0]->value)) - { - unset($this->add_custom_buttonOptions[0]); - } - // Add Custom Button Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_CUSTOM_BUTTON_LABEL').' -', - 'batch[add_custom_button]', - JHtml::_('select.options', $this->add_custom_buttonOptions, 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEWS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/custom_admin_views.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.system_name' => JText::_('COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_SYSTEM_NAME_LABEL'), - 'a.name' => JText::_('COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NAME_LABEL'), - 'a.description' => JText::_('COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_DESCRIPTION_LABEL'), - 'g.name' => JText::_('COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_MAIN_GET_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/custom_code/submitbutton.js b/admin/views/custom_code/submitbutton.js deleted file mode 100644 index 4f8ce242b..000000000 --- a/admin/views/custom_code/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('custom_code, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/custom_code/tmpl/edit.php b/admin/views/custom_code/tmpl/edit.php deleted file mode 100644 index 763e852cc..000000000 --- a/admin/views/custom_code/tmpl/edit.php +++ /dev/null @@ -1,286 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/custom_code/view.html.php b/admin/views/custom_code/view.html.php deleted file mode 100644 index e92f23e32..000000000 --- a/admin/views/custom_code/view.html.php +++ /dev/null @@ -1,218 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Custom_code Html View class - */ -class ComponentbuilderViewCustom_code extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('custom_code', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_CUSTOM_CODE_NEW' : 'COM_COMPONENTBUILDER_CUSTOM_CODE_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('custom_code.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('custom_code.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('custom_code.edit')) - { - // We can save the record. - JToolBarHelper::save('custom_code.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('custom_code.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('custom_code.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('custom_code.create')) - { - JToolBarHelper::apply('custom_code.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('custom_code.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('custom_code.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('custom_code.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('custom_code.edit')) - { - // We can save the new record - JToolBarHelper::apply('custom_code.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('custom_code.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('custom_code.create')) - { - JToolBarHelper::custom('custom_code.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('custom_code.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('custom_code.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.custom_code', $this->item->id); - } - if ($this->canDo->get('custom_code.create')) - { - JToolBarHelper::custom('custom_code.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('custom_code.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('custom_code'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_CUSTOM_CODE_NEW' : 'COM_COMPONENTBUILDER_CUSTOM_CODE_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/custom_code.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/custom_code/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - // need to add some language strings - JText::script('COM_COMPONENTBUILDER_FUNCTION_NAME_ALREADY_TAKEN_PLEASE_TRY_AGAIN'); - JText::script('COM_COMPONENTBUILDER_YOU_MUST_ADD_AN_UNIQUE_FUNCTION_NAME'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/custom_codes/tmpl/default.php b/admin/views/custom_codes/tmpl/default.php deleted file mode 100644 index 2532aa74a..000000000 --- a/admin/views/custom_codes/tmpl/default.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=custom_codes.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'custom_codeList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_CUSTOM_CODES_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - - diff --git a/admin/views/custom_codes/tmpl/default_batch_body.php b/admin/views/custom_codes/tmpl/default_batch_body.php deleted file mode 100644 index e8ad68f57..000000000 --- a/admin/views/custom_codes/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/custom_codes/tmpl/default_batch_footer.php b/admin/views/custom_codes/tmpl/default_batch_footer.php deleted file mode 100644 index 0cda1901a..000000000 --- a/admin/views/custom_codes/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/custom_codes/tmpl/default_body.php b/admin/views/custom_codes/tmpl/default_body.php deleted file mode 100644 index 74d584ea3..000000000 --- a/admin/views/custom_codes/tmpl/default_body.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=custom_codes&task=custom_code.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('custom_code',$item,'custom_codes'); - ?> - - - get('custom_code.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('custom_code.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('custom_code.edit')): ?> - escape($item->component_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'custom_codes.', $canCheckin); ?> - - - escape($item->component_system_name); ?> - -
    - - - escape($item->path); ?> - - - target); ?> - - - type); ?> - - - comment_type); ?> - - - get('custom_code.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'custom_codes.', true, 'cb'); ?> - - published, $i, 'custom_codes.', false, 'cb'); ?> - - - published, $i, 'custom_codes.', true, 'cb'); ?> - - - published, $i, 'custom_codes.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/custom_codes/tmpl/default_foot.php b/admin/views/custom_codes/tmpl/default_foot.php deleted file mode 100644 index 729d85997..000000000 --- a/admin/views/custom_codes/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/custom_codes/tmpl/default_head.php b/admin/views/custom_codes/tmpl/default_head.php deleted file mode 100644 index 50f030c35..000000000 --- a/admin/views/custom_codes/tmpl/default_head.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/custom_codes/tmpl/default_toolbar.php b/admin/views/custom_codes/tmpl/default_toolbar.php deleted file mode 100644 index 62b00c4d5..000000000 --- a/admin/views/custom_codes/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/custom_codes/view.html.php b/admin/views/custom_codes/view.html.php deleted file mode 100644 index 4c9274739..000000000 --- a/admin/views/custom_codes/view.html.php +++ /dev/null @@ -1,320 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Custom_codes - */ -class ComponentbuilderViewCustom_codes extends HtmlView -{ - /** - * Custom_codes view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('custom_codes'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('custom_code'); - $this->canEdit = $this->canDo->get('custom_code.edit'); - $this->canState = $this->canDo->get('custom_code.edit.state'); - $this->canCreate = $this->canDo->get('custom_code.create'); - $this->canDelete = $this->canDo->get('custom_code.delete'); - $this->canBatch = ($this->canDo->get('custom_code.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_CUSTOM_CODES'), 'shuffle'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=custom_codes'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('custom_code.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('custom_code.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('custom_codes.publish'); - JToolBarHelper::unpublishList('custom_codes.unpublish'); - JToolBarHelper::archiveList('custom_codes.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('custom_codes.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'custom_codes.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('custom_codes.trash'); - } - - if ($this->canDo->get('core.export') && $this->canDo->get('custom_code.export')) - { - JToolBarHelper::custom('custom_codes.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); - } - } - if ($this->user->authorise('custom_code.run_expansion', 'com_componentbuilder')) - { - // add Run Expansion button. - JToolBarHelper::custom('custom_codes.runExpansion', 'expand-2 custom-button-runexpansion', '', 'COM_COMPONENTBUILDER_RUN_EXPANSION', false); - } - - if ($this->canDo->get('core.import') && $this->canDo->get('custom_code.import')) - { - JToolBarHelper::custom('custom_codes.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('custom_codes'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - - // Only load Component System Name batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Component System Name Selection - $this->componentSystem_nameOptions = JFormHelper::loadFieldType('Joomlacomponent')->options; - // We do some sanitation for Component System Name filter - if (ComponentbuilderHelper::checkArray($this->componentSystem_nameOptions) && - isset($this->componentSystem_nameOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->componentSystem_nameOptions[0]->value)) - { - unset($this->componentSystem_nameOptions[0]); - } - // Component System Name Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_CUSTOM_CODE_COMPONENT_LABEL').' -', - 'batch[component]', - JHtml::_('select.options', $this->componentSystem_nameOptions, 'value', 'text') - ); - } - - // Only load Target batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Target Selection - $this->targetOptions = JFormHelper::loadFieldType('customcodesfiltertarget')->options; - // We do some sanitation for Target filter - if (ComponentbuilderHelper::checkArray($this->targetOptions) && - isset($this->targetOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->targetOptions[0]->value)) - { - unset($this->targetOptions[0]); - } - // Target Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_CUSTOM_CODE_TARGET_LABEL').' -', - 'batch[target]', - JHtml::_('select.options', $this->targetOptions, 'value', 'text') - ); - } - - // Only load Type batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Type Selection - $this->typeOptions = JFormHelper::loadFieldType('customcodesfiltertype')->options; - // We do some sanitation for Type filter - if (ComponentbuilderHelper::checkArray($this->typeOptions) && - isset($this->typeOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->typeOptions[0]->value)) - { - unset($this->typeOptions[0]); - } - // Type Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_CUSTOM_CODE_TYPE_LABEL').' -', - 'batch[type]', - JHtml::_('select.options', $this->typeOptions, 'value', 'text') - ); - } - - // Only load Comment Type batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Comment Type Selection - $this->comment_typeOptions = JFormHelper::loadFieldType('customcodesfiltercommenttype')->options; - // We do some sanitation for Comment Type filter - if (ComponentbuilderHelper::checkArray($this->comment_typeOptions) && - isset($this->comment_typeOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->comment_typeOptions[0]->value)) - { - unset($this->comment_typeOptions[0]); - } - // Comment Type Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_CUSTOM_CODE_COMMENT_TYPE_LABEL').' -', - 'batch[comment_type]', - JHtml::_('select.options', $this->comment_typeOptions, 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_CUSTOM_CODES')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/custom_codes.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'g.system_name' => JText::_('COM_COMPONENTBUILDER_CUSTOM_CODE_COMPONENT_LABEL'), - 'a.path' => JText::_('COM_COMPONENTBUILDER_CUSTOM_CODE_PATH_LABEL'), - 'a.target' => JText::_('COM_COMPONENTBUILDER_CUSTOM_CODE_TARGET_LABEL'), - 'a.type' => JText::_('COM_COMPONENTBUILDER_CUSTOM_CODE_TYPE_LABEL'), - 'a.comment_type' => JText::_('COM_COMPONENTBUILDER_CUSTOM_CODE_COMMENT_TYPE_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/dynamic_get/submitbutton.js b/admin/views/dynamic_get/submitbutton.js deleted file mode 100644 index 526acadac..000000000 --- a/admin/views/dynamic_get/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('dynamic_get, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/dynamic_get/tmpl/edit.php b/admin/views/dynamic_get/tmpl/edit.php deleted file mode 100644 index 2077be177..000000000 --- a/admin/views/dynamic_get/tmpl/edit.php +++ /dev/null @@ -1,714 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/dynamic_get/view.html.php b/admin/views/dynamic_get/view.html.php deleted file mode 100644 index 8fc0761fc..000000000 --- a/admin/views/dynamic_get/view.html.php +++ /dev/null @@ -1,215 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Dynamic_get Html View class - */ -class ComponentbuilderViewDynamic_get extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('dynamic_get', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_DYNAMIC_GET_NEW' : 'COM_COMPONENTBUILDER_DYNAMIC_GET_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('dynamic_get.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('dynamic_get.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('dynamic_get.edit')) - { - // We can save the record. - JToolBarHelper::save('dynamic_get.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('dynamic_get.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('dynamic_get.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('dynamic_get.create')) - { - JToolBarHelper::apply('dynamic_get.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('dynamic_get.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('dynamic_get.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('dynamic_get.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('dynamic_get.edit')) - { - // We can save the new record - JToolBarHelper::apply('dynamic_get.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('dynamic_get.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('dynamic_get.create')) - { - JToolBarHelper::custom('dynamic_get.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('dynamic_get.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('dynamic_get.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.dynamic_get', $this->item->id); - } - if ($this->canDo->get('dynamic_get.create')) - { - JToolBarHelper::custom('dynamic_get.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('dynamic_get.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('dynamic_get'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_DYNAMIC_GET_NEW' : 'COM_COMPONENTBUILDER_DYNAMIC_GET_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/dynamic_get.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/dynamic_get/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/dynamic_gets/tmpl/default.php b/admin/views/dynamic_gets/tmpl/default.php deleted file mode 100644 index 6bfab7288..000000000 --- a/admin/views/dynamic_gets/tmpl/default.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=dynamic_gets.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'dynamic_getList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_DYNAMIC_GETS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - - diff --git a/admin/views/dynamic_gets/tmpl/default_batch_body.php b/admin/views/dynamic_gets/tmpl/default_batch_body.php deleted file mode 100644 index c3faa117c..000000000 --- a/admin/views/dynamic_gets/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/dynamic_gets/tmpl/default_batch_footer.php b/admin/views/dynamic_gets/tmpl/default_batch_footer.php deleted file mode 100644 index 06f13551e..000000000 --- a/admin/views/dynamic_gets/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/dynamic_gets/tmpl/default_body.php b/admin/views/dynamic_gets/tmpl/default_body.php deleted file mode 100644 index 5f040a3d0..000000000 --- a/admin/views/dynamic_gets/tmpl/default_body.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=dynamic_gets&task=dynamic_get.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('dynamic_get',$item,'dynamic_gets'); - ?> - - - get('dynamic_get.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('dynamic_get.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('dynamic_get.edit')): ?> - escape($item->name); ?> - checked_out): ?> - name, $item->checked_out_time, 'dynamic_gets.', $canCheckin); ?> - - - escape($item->name); ?> - -
    - - - main_source); ?> - - - gettype); ?> - - - get('dynamic_get.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'dynamic_gets.', true, 'cb'); ?> - - published, $i, 'dynamic_gets.', false, 'cb'); ?> - - - published, $i, 'dynamic_gets.', true, 'cb'); ?> - - - published, $i, 'dynamic_gets.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/dynamic_gets/tmpl/default_foot.php b/admin/views/dynamic_gets/tmpl/default_foot.php deleted file mode 100644 index eff41e725..000000000 --- a/admin/views/dynamic_gets/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/dynamic_gets/tmpl/default_head.php b/admin/views/dynamic_gets/tmpl/default_head.php deleted file mode 100644 index b93c46469..000000000 --- a/admin/views/dynamic_gets/tmpl/default_head.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/dynamic_gets/tmpl/default_toolbar.php b/admin/views/dynamic_gets/tmpl/default_toolbar.php deleted file mode 100644 index 6035becc9..000000000 --- a/admin/views/dynamic_gets/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/dynamic_gets/view.html.php b/admin/views/dynamic_gets/view.html.php deleted file mode 100644 index c6c300e2d..000000000 --- a/admin/views/dynamic_gets/view.html.php +++ /dev/null @@ -1,278 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Dynamic_gets - */ -class ComponentbuilderViewDynamic_gets extends HtmlView -{ - /** - * Dynamic_gets view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('dynamic_gets'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('dynamic_get'); - $this->canEdit = $this->canDo->get('dynamic_get.edit'); - $this->canState = $this->canDo->get('dynamic_get.edit.state'); - $this->canCreate = $this->canDo->get('dynamic_get.create'); - $this->canDelete = $this->canDo->get('dynamic_get.delete'); - $this->canBatch = ($this->canDo->get('dynamic_get.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_DYNAMIC_GETS'), 'database'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=dynamic_gets'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('dynamic_get.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('dynamic_get.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('dynamic_gets.publish'); - JToolBarHelper::unpublishList('dynamic_gets.unpublish'); - JToolBarHelper::archiveList('dynamic_gets.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('dynamic_gets.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'dynamic_gets.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('dynamic_gets.trash'); - } - - if ($this->canDo->get('core.export') && $this->canDo->get('dynamic_get.export')) - { - JToolBarHelper::custom('dynamic_gets.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); - } - } - if ($this->user->authorise('dynamic_get.run_expansion', 'com_componentbuilder')) - { - // add Run Expansion button. - JToolBarHelper::custom('dynamic_gets.runExpansion', 'expand-2 custom-button-runexpansion', '', 'COM_COMPONENTBUILDER_RUN_EXPANSION', false); - } - - if ($this->canDo->get('core.import') && $this->canDo->get('dynamic_get.import')) - { - JToolBarHelper::custom('dynamic_gets.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('dynamic_gets'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - - // Only load Main Source batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Main Source Selection - $this->main_sourceOptions = JFormHelper::loadFieldType('dynamicgetsfiltermainsource')->options; - // We do some sanitation for Main Source filter - if (ComponentbuilderHelper::checkArray($this->main_sourceOptions) && - isset($this->main_sourceOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->main_sourceOptions[0]->value)) - { - unset($this->main_sourceOptions[0]); - } - // Main Source Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_DYNAMIC_GET_MAIN_SOURCE_LABEL').' -', - 'batch[main_source]', - JHtml::_('select.options', $this->main_sourceOptions, 'value', 'text') - ); - } - - // Only load Gettype batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Gettype Selection - $this->gettypeOptions = JFormHelper::loadFieldType('dynamicgetsfiltergettype')->options; - // We do some sanitation for Gettype filter - if (ComponentbuilderHelper::checkArray($this->gettypeOptions) && - isset($this->gettypeOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->gettypeOptions[0]->value)) - { - unset($this->gettypeOptions[0]); - } - // Gettype Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_DYNAMIC_GET_GETTYPE_LABEL').' -', - 'batch[gettype]', - JHtml::_('select.options', $this->gettypeOptions, 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_DYNAMIC_GETS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/dynamic_gets.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.name' => JText::_('COM_COMPONENTBUILDER_DYNAMIC_GET_NAME_LABEL'), - 'a.main_source' => JText::_('COM_COMPONENTBUILDER_DYNAMIC_GET_MAIN_SOURCE_LABEL'), - 'a.gettype' => JText::_('COM_COMPONENTBUILDER_DYNAMIC_GET_GETTYPE_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/field/submitbutton.js b/admin/views/field/submitbutton.js deleted file mode 100644 index f161b448b..000000000 --- a/admin/views/field/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('field, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/field/tmpl/edit.php b/admin/views/field/tmpl/edit.php deleted file mode 100644 index 9f721a707..000000000 --- a/admin/views/field/tmpl/edit.php +++ /dev/null @@ -1,390 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/field/view.html.php b/admin/views/field/view.html.php deleted file mode 100644 index 0804fecc5..000000000 --- a/admin/views/field/view.html.php +++ /dev/null @@ -1,224 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Field Html View class - */ -class ComponentbuilderViewField extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('field', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_FIELD_NEW' : 'COM_COMPONENTBUILDER_FIELD_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('field.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('field.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('field.edit')) - { - // We can save the record. - JToolBarHelper::save('field.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('field.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('field.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('field.create')) - { - JToolBarHelper::apply('field.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('field.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('field.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('field.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('field.edit')) - { - // We can save the new record - JToolBarHelper::apply('field.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('field.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('field.create')) - { - JToolBarHelper::custom('field.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('field.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('field.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.field', $this->item->id); - } - if ($this->canDo->get('field.create')) - { - JToolBarHelper::custom('field.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('field.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('field'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_FIELD_NEW' : 'COM_COMPONENTBUILDER_FIELD_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/field.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/field/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - // add the libs for subform (since not adding it via xml but ajax) - JHtml::_('jquery.ui', array('core', 'sortable')); - JHtml::_('script', 'system/subform-repeatable.js', array('version' => 'auto', 'relative' => true)); - // set some lang - JText::script('COM_COMPONENTBUILDER_PROPERTY_ALREADY_SELECTED_TRY_ANOTHER'); - JText::script('COM_COMPONENTBUILDER_TYPE_OR_SELECT_SOME_OPTIONS'); - JText::script('COM_COMPONENTBUILDER_NO_RESULTS_MATCH'); - JText::script('COM_COMPONENTBUILDER_SELECT_A_PROPERTY'); - JText::script('COM_COMPONENTBUILDER_NO_DESCRIPTION_FOUND'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/fields/tmpl/default.php b/admin/views/fields/tmpl/default.php deleted file mode 100644 index ecc7a3d78..000000000 --- a/admin/views/fields/tmpl/default.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleCategories', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_FIELDS_CATEGORIES') . ' -')); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=fields.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'fieldList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_FIELDS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - - diff --git a/admin/views/fields/tmpl/default_batch_body.php b/admin/views/fields/tmpl/default_batch_body.php deleted file mode 100644 index 48f0df1af..000000000 --- a/admin/views/fields/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/fields/tmpl/default_batch_footer.php b/admin/views/fields/tmpl/default_batch_footer.php deleted file mode 100644 index 3c00bc099..000000000 --- a/admin/views/fields/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/fields/tmpl/default_body.php b/admin/views/fields/tmpl/default_body.php deleted file mode 100644 index 9d677174f..000000000 --- a/admin/views/fields/tmpl/default_body.php +++ /dev/null @@ -1,121 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=fields&task=field.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('field',$item,'fields'); - ?> - - - get('field.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('field.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('field.edit')): ?> - escape($item->name); ?> - checked_out): ?> - name, $item->checked_out_time, 'fields.', $canCheckin); ?> - - - escape($item->name); ?> - -
    - - -
    - user->authorise('fieldtype.edit', 'com_componentbuilder.fieldtype.' . (int) $item->fieldtype)): ?> - escape($item->fieldtype_name); ?> - - escape($item->fieldtype_name); ?> - -
    - - - datatype); ?> - - - indexes); ?> - - - null_switch); ?> - - - store); ?> - - -
    - user->authorise('core.edit', 'com_componentbuilder.field.category.' . (int)$item->catid)): ?> - escape($item->category_title); ?> - - escape($item->category_title); ?> - -
    - - - get('field.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'fields.', true, 'cb'); ?> - - published, $i, 'fields.', false, 'cb'); ?> - - - published, $i, 'fields.', true, 'cb'); ?> - - - published, $i, 'fields.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/fields/tmpl/default_foot.php b/admin/views/fields/tmpl/default_foot.php deleted file mode 100644 index e0680c631..000000000 --- a/admin/views/fields/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/fields/tmpl/default_head.php b/admin/views/fields/tmpl/default_head.php deleted file mode 100644 index a15b460ef..000000000 --- a/admin/views/fields/tmpl/default_head.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/fields/tmpl/default_toolbar.php b/admin/views/fields/tmpl/default_toolbar.php deleted file mode 100644 index 3d08c5650..000000000 --- a/admin/views/fields/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/fields/view.html.php b/admin/views/fields/view.html.php deleted file mode 100644 index e37e8b641..000000000 --- a/admin/views/fields/view.html.php +++ /dev/null @@ -1,352 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Fields - */ -class ComponentbuilderViewFields extends HtmlView -{ - /** - * Fields view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('fields'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('field'); - $this->canEdit = $this->canDo->get('field.edit'); - $this->canState = $this->canDo->get('field.edit.state'); - $this->canCreate = $this->canDo->get('field.create'); - $this->canDelete = $this->canDo->get('field.delete'); - $this->canBatch = ($this->canDo->get('field.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_FIELDS'), 'lamp'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=fields'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('field.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('field.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('fields.publish'); - JToolBarHelper::unpublishList('fields.unpublish'); - JToolBarHelper::archiveList('fields.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('fields.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'fields.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('fields.trash'); - } - - if ($this->canDo->get('core.export') && $this->canDo->get('field.export')) - { - JToolBarHelper::custom('fields.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); - } - } - if ($this->user->authorise('field.run_expansion', 'com_componentbuilder')) - { - // add Run Expansion button. - JToolBarHelper::custom('fields.runExpansion', 'expand-2 custom-button-runexpansion', '', 'COM_COMPONENTBUILDER_RUN_EXPANSION', false); - } - - if ($this->canDo->get('core.import') && $this->canDo->get('field.import')) - { - JToolBarHelper::custom('fields.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('fields'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Category Batch selection. - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_CATEGORY'), - 'batch[category]', - JHtml::_('select.options', JHtml::_('category.options', 'com_componentbuilder.field'), 'value', 'text') - ); - } - - // Only load Fieldtype Name batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Fieldtype Name Selection - $this->fieldtypeNameOptions = JFormHelper::loadFieldType('Fieldtypes')->options; - // We do some sanitation for Fieldtype Name filter - if (ComponentbuilderHelper::checkArray($this->fieldtypeNameOptions) && - isset($this->fieldtypeNameOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->fieldtypeNameOptions[0]->value)) - { - unset($this->fieldtypeNameOptions[0]); - } - // Fieldtype Name Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_FIELD_FIELDTYPE_LABEL').' -', - 'batch[fieldtype]', - JHtml::_('select.options', $this->fieldtypeNameOptions, 'value', 'text') - ); - } - - // Only load Datatype batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Datatype Selection - $this->datatypeOptions = JFormHelper::loadFieldType('fieldsfilterdatatype')->options; - // We do some sanitation for Datatype filter - if (ComponentbuilderHelper::checkArray($this->datatypeOptions) && - isset($this->datatypeOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->datatypeOptions[0]->value)) - { - unset($this->datatypeOptions[0]); - } - // Datatype Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_FIELD_DATATYPE_LABEL').' -', - 'batch[datatype]', - JHtml::_('select.options', $this->datatypeOptions, 'value', 'text') - ); - } - - // Only load Indexes batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Indexes Selection - $this->indexesOptions = JFormHelper::loadFieldType('fieldsfilterindexes')->options; - // We do some sanitation for Indexes filter - if (ComponentbuilderHelper::checkArray($this->indexesOptions) && - isset($this->indexesOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->indexesOptions[0]->value)) - { - unset($this->indexesOptions[0]); - } - // Indexes Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_FIELD_INDEXES_LABEL').' -', - 'batch[indexes]', - JHtml::_('select.options', $this->indexesOptions, 'value', 'text') - ); - } - - // Only load Null Switch batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Null Switch Selection - $this->null_switchOptions = JFormHelper::loadFieldType('fieldsfilternullswitch')->options; - // We do some sanitation for Null Switch filter - if (ComponentbuilderHelper::checkArray($this->null_switchOptions) && - isset($this->null_switchOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->null_switchOptions[0]->value)) - { - unset($this->null_switchOptions[0]); - } - // Null Switch Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_FIELD_NULL_SWITCH_LABEL').' -', - 'batch[null_switch]', - JHtml::_('select.options', $this->null_switchOptions, 'value', 'text') - ); - } - - // Only load Store batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Store Selection - $this->storeOptions = JFormHelper::loadFieldType('fieldsfilterstore')->options; - // We do some sanitation for Store filter - if (ComponentbuilderHelper::checkArray($this->storeOptions) && - isset($this->storeOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->storeOptions[0]->value)) - { - unset($this->storeOptions[0]); - } - // Store Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_FIELD_STORE_LABEL').' -', - 'batch[store]', - JHtml::_('select.options', $this->storeOptions, 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_FIELDS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/fields.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.name' => JText::_('COM_COMPONENTBUILDER_FIELD_NAME_LABEL'), - 'g.name' => JText::_('COM_COMPONENTBUILDER_FIELD_FIELDTYPE_LABEL'), - 'a.datatype' => JText::_('COM_COMPONENTBUILDER_FIELD_DATATYPE_LABEL'), - 'a.indexes' => JText::_('COM_COMPONENTBUILDER_FIELD_INDEXES_LABEL'), - 'a.null_switch' => JText::_('COM_COMPONENTBUILDER_FIELD_NULL_SWITCH_LABEL'), - 'a.store' => JText::_('COM_COMPONENTBUILDER_FIELD_STORE_LABEL'), - 'category_title' => JText::_('COM_COMPONENTBUILDER_FIELD_FIELDS_CATEGORIES'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/fieldtype/submitbutton.js b/admin/views/fieldtype/submitbutton.js deleted file mode 100644 index 7880a9e25..000000000 --- a/admin/views/fieldtype/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('fieldtype, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/fieldtype/tmpl/edit.php b/admin/views/fieldtype/tmpl/edit.php deleted file mode 100644 index 8259f6b6e..000000000 --- a/admin/views/fieldtype/tmpl/edit.php +++ /dev/null @@ -1,547 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/fieldtype/view.html.php b/admin/views/fieldtype/view.html.php deleted file mode 100644 index 0d7f2eccc..000000000 --- a/admin/views/fieldtype/view.html.php +++ /dev/null @@ -1,266 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Fieldtype Html View class - */ -class ComponentbuilderViewFieldtype extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('fieldtype', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Get Linked view data - $this->vycfields = $this->get('Vycfields'); - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_FIELDTYPE_NEW' : 'COM_COMPONENTBUILDER_FIELDTYPE_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('fieldtype.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('fieldtype.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('fieldtype.edit')) - { - // We can save the record. - JToolBarHelper::save('fieldtype.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('fieldtype.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('fieldtype.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('fieldtype.create')) - { - JToolBarHelper::apply('fieldtype.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('fieldtype.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('fieldtype.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('fieldtype.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('fieldtype.edit')) - { - // We can save the new record - JToolBarHelper::apply('fieldtype.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('fieldtype.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('fieldtype.create')) - { - JToolBarHelper::custom('fieldtype.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('fieldtype.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('fieldtype.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.fieldtype', $this->item->id); - } - if ($this->canDo->get('fieldtype.create')) - { - JToolBarHelper::custom('fieldtype.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('fieldtype.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('fieldtype'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_FIELDTYPE_NEW' : 'COM_COMPONENTBUILDER_FIELDTYPE_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/fieldtype.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - - // Add the CSS for Footable - $this->document->addStyleSheet('https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css'); - JHtml::_('stylesheet', 'media/com_componentbuilder/footable-v3/css/footable.standalone.min.css', ['version' => 'auto']); - // Add the JavaScript for Footable (adding all functions) - JHtml::_('script', 'media/com_componentbuilder/footable-v3/js/footable.min.js', ['version' => 'auto']); - - $footable = "jQuery(document).ready(function() { jQuery(function () { jQuery('.footable').footable();});});"; - $this->document->addScriptDeclaration($footable); - - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/fieldtype/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // get Uikit Version - $this->uikitVersion = $this->params->get('uikit_version', 2); - // Load uikit options. - $uikit = $this->params->get('uikit_load'); - $isAdmin = JFactory::getApplication()->isClient('administrator'); - // Set script size. - $size = $this->params->get('uikit_min'); - // Use Uikit Version 2 - if (2 == $this->uikitVersion && ($isAdmin || $uikit != 2)) - { - // Set css style. - $style = $this->params->get('uikit_style'); - // only load if needed - if ($isAdmin || $uikit != 3) - { - // add the style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit' . $style . $size . '.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - // add the style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/accordion' . $style . $size . '.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/tooltip' . $style . $size . '.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify' . $style . $size . '.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/form-file' . $style . $size . '.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/progress' . $style . $size . '.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/placeholder' . $style . $size . '.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2//css/components/upload' . $style . $size . '.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // only load if needed - if ($isAdmin || $uikit != 3) - { - // add JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit' . $size . '.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - } - // add JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/accordion' . $size . '.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/tooltip' . $size . '.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox' . $size . '.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify' . $size . '.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/upload' . $size . '.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - } - // Use Uikit Version 3 - elseif (3 == $this->uikitVersion && ($isAdmin || $uikit != 2)) - { - // add the style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v3/css/uikit'.$size.'.css', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v3/js/uikit'.$size.'.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - // add icons - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v3/js/uikit-icons'.$size.'.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - } - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/fieldtypes/tmpl/default.php b/admin/views/fieldtypes/tmpl/default.php deleted file mode 100644 index b2398a512..000000000 --- a/admin/views/fieldtypes/tmpl/default.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleCategories', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_FIELDTYPES_CATEGORIES') . ' -')); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=fieldtypes.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'fieldtypeList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_FIELDTYPES_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/fieldtypes/tmpl/default_batch_body.php b/admin/views/fieldtypes/tmpl/default_batch_body.php deleted file mode 100644 index 6f70f8415..000000000 --- a/admin/views/fieldtypes/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/fieldtypes/tmpl/default_batch_footer.php b/admin/views/fieldtypes/tmpl/default_batch_footer.php deleted file mode 100644 index fc86dcb67..000000000 --- a/admin/views/fieldtypes/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/fieldtypes/tmpl/default_body.php b/admin/views/fieldtypes/tmpl/default_body.php deleted file mode 100644 index 2c0f000db..000000000 --- a/admin/views/fieldtypes/tmpl/default_body.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=fieldtypes&task=fieldtype.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('fieldtype',$item,'fieldtypes'); - ?> - - - get('fieldtype.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('fieldtype.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('fieldtype.edit')): ?> - escape($item->name); ?> - checked_out): ?> - name, $item->checked_out_time, 'fieldtypes.', $canCheckin); ?> - - - escape($item->name); ?> - -
    - - - escape($item->short_description); ?> - - -
    - user->authorise('core.edit', 'com_componentbuilder.fieldtype.category.' . (int)$item->catid)): ?> - escape($item->category_title); ?> - - escape($item->category_title); ?> - -
    - - - get('fieldtype.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'fieldtypes.', true, 'cb'); ?> - - published, $i, 'fieldtypes.', false, 'cb'); ?> - - - published, $i, 'fieldtypes.', true, 'cb'); ?> - - - published, $i, 'fieldtypes.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/fieldtypes/tmpl/default_foot.php b/admin/views/fieldtypes/tmpl/default_foot.php deleted file mode 100644 index eff41e725..000000000 --- a/admin/views/fieldtypes/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/fieldtypes/tmpl/default_head.php b/admin/views/fieldtypes/tmpl/default_head.php deleted file mode 100644 index 115fc0e6b..000000000 --- a/admin/views/fieldtypes/tmpl/default_head.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/fieldtypes/tmpl/default_toolbar.php b/admin/views/fieldtypes/tmpl/default_toolbar.php deleted file mode 100644 index 75e26aebe..000000000 --- a/admin/views/fieldtypes/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/fieldtypes/view.html.php b/admin/views/fieldtypes/view.html.php deleted file mode 100644 index 9fa379881..000000000 --- a/admin/views/fieldtypes/view.html.php +++ /dev/null @@ -1,243 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Fieldtypes - */ -class ComponentbuilderViewFieldtypes extends HtmlView -{ - /** - * Fieldtypes view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('fieldtypes'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('fieldtype'); - $this->canEdit = $this->canDo->get('fieldtype.edit'); - $this->canState = $this->canDo->get('fieldtype.edit.state'); - $this->canCreate = $this->canDo->get('fieldtype.create'); - $this->canDelete = $this->canDo->get('fieldtype.delete'); - $this->canBatch = ($this->canDo->get('fieldtype.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_FIELDTYPES'), 'power-cord'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=fieldtypes'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('fieldtype.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('fieldtype.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('fieldtypes.publish'); - JToolBarHelper::unpublishList('fieldtypes.unpublish'); - JToolBarHelper::archiveList('fieldtypes.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('fieldtypes.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'fieldtypes.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('fieldtypes.trash'); - } - - if ($this->canDo->get('core.export') && $this->canDo->get('fieldtype.export')) - { - JToolBarHelper::custom('fieldtypes.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); - } - } - - if ($this->canDo->get('core.import') && $this->canDo->get('fieldtype.import')) - { - JToolBarHelper::custom('fieldtypes.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('fieldtypes'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Category Batch selection. - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_CATEGORY'), - 'batch[category]', - JHtml::_('select.options', JHtml::_('category.options', 'com_componentbuilder.fieldtype'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_FIELDTYPES')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/fieldtypes.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.name' => JText::_('COM_COMPONENTBUILDER_FIELDTYPE_NAME_LABEL'), - 'a.short_description' => JText::_('COM_COMPONENTBUILDER_FIELDTYPE_SHORT_DESCRIPTION_LABEL'), - 'category_title' => JText::_('COM_COMPONENTBUILDER_FIELDTYPE_FIELDTYPES_CATEGORIES'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/get_snippets/tmpl/default.php b/admin/views/get_snippets/tmpl/default.php deleted file mode 100644 index 74cef80ce..000000000 --- a/admin/views/get_snippets/tmpl/default.php +++ /dev/null @@ -1,251 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -?> -canDo->get('get_snippets.access')): ?> - - -
    - - -
    - -
    -


    -


    ..

    -
    - -
    -

    -
    - -
    -



    -

    -

    -

    -
    -
    -
    -



    -

    -

    -

    -
    -
    -
    -



    -

    -

    -

    -
    -
    -
    -



    -

    -

    -

    -
    -
    -
    -



    -

    -

    -

    -
    -
    - - - -

    - diff --git a/admin/views/get_snippets/view.html.php b/admin/views/get_snippets/view.html.php deleted file mode 100644 index af14e980b..000000000 --- a/admin/views/get_snippets/view.html.php +++ /dev/null @@ -1,321 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; -use Joomla\CMS\Filesystem\File; -use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\StringHelper; - -/** - * Componentbuilder Html View class for the Get_snippets - */ -class ComponentbuilderViewGet_snippets extends HtmlView -{ - // Overwriting JView display method - function display($tpl = null) - { - // get component params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // get the application - $this->app = JFactory::getApplication(); - // get the user object - $this->user = JFactory::getUser(); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('get_snippets'); - // Initialise variables. - $this->items = $this->get('Items'); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - // add the tool bar - $this->addToolBar(); - } - - // set the document - $this->setDocument(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode(PHP_EOL, $errors), 500); - } - - parent::display($tpl); - } - - /** - * Prepares the document - */ - protected function setDocument() - { - - // Only load jQuery if needed. (default is true) - if ($this->params->get('add_jquery_framework', 1) == 1) - { - JHtml::_('jquery.framework'); - } - // Load the header checker class. - require_once( JPATH_COMPONENT_ADMINISTRATOR.'/helpers/headercheck.php' ); - // Initialize the header checker. - $HeaderCheck = new componentbuilderHeaderCheck; - - // Add View JavaScript File - JHtml::_('script', "administrator/components/com_componentbuilder/assets/js/get_snippets.js", ['version' => 'auto']); - - // Load uikit options. - $uikit = $this->params->get('uikit_load'); - // Set script size. - $size = $this->params->get('uikit_min'); - // Set css style. - $style = $this->params->get('uikit_style'); - - // The uikit css. - if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) - { - JHtml::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit'.$style.$size.'.css', ['version' => 'auto']); - } - // The uikit js. - if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) - { - JHtml::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit'.$size.'.js', ['version' => 'auto']); - } - - // Load the script to find all uikit components needed. - if ($uikit != 2) - { - // Set the default uikit components in this view. - $uikitComp = array(); - $uikitComp[] = 'data-uk-grid'; - } - - // Load the needed uikit components in this view. - if ($uikit != 2 && isset($uikitComp) && ComponentbuilderHelper::checkArray($uikitComp)) - { - // load just in case. - jimport('joomla.filesystem.file'); - // loading... - foreach ($uikitComp as $class) - { - foreach (ComponentbuilderHelper::$uk_components[$class] as $name) - { - // check if the CSS file exists. - if (File::exists(JPATH_ROOT.'/media/com_componentbuilder/uikit-v2/css/components/'.$name.$style.$size.'.css')) - { - // load the css. - JHtml::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/'.$name.$style.$size.'.css', ['version' => 'auto']); - } - // check if the JavaScript file exists. - if (File::exists(JPATH_ROOT.'/media/com_componentbuilder/uikit-v2/js/components/'.$name.$size.'.js')) - { - // load the js. - JHtml::_('script', 'media/com_componentbuilder/uikit-v2/js/components/'.$name.$size.'.js', ['version' => 'auto'], ['type' => 'text/javascript', 'async' => 'async']); - } - } - } - } - // load the local snippets - if (ArrayHelper::check($this->items)) - { - $local_snippets = array(); - foreach ($this->items as $item) - { - $path = StringHelper::safe($item->library . ' - (' . $item->type . ') ' . $item->name, 'filename', '', false). '.json'; - $local_snippets[$path] = $item; - } - } - - // Add the JavaScript for JStore - $this->document->addScript(JURI::root() .'media/com_componentbuilder/js/jquery.json.min.js'); - $this->document->addScript(JURI::root() .'media/com_componentbuilder/js/jstorage.min.js'); - $this->document->addScript(JURI::root() .'media/com_componentbuilder/js/strtotime.js'); - // check if we should use browser storage - $setBrowserStorage = $this->params->get('set_browser_storage', null); - if ($setBrowserStorage) - { - // check what (Time To Live) show we use - $storageTimeToLive = $this->params->get('storage_time_to_live', 'global'); - if ('global' == $storageTimeToLive) - { - // use the global session time - $session = JFactory::getSession(); - // must have itin milliseconds - $expire = ($session->getExpire()*60)* 1000; - } - else - { - // use the Componentbuilder Global setting - if (0 != $storageTimeToLive) - { - // this will convert the time into milliseconds - $storageTimeToLive = $storageTimeToLive * 1000; - } - $expire = $storageTimeToLive; - } - } - else - { - // set to use no storage - $expire = 30000; // only 30 seconds - } - // Set the Time To Live To JavaScript - $this->document->addScriptDeclaration("var expire = ". (int) $expire.";"); - // set snippet path - $this->document->addScriptDeclaration("var snippetPath = '". ComponentbuilderHelper::$snippetPath ."';"); - $this->document->addScriptDeclaration("var snippetsPath = '". ComponentbuilderHelper::$snippetsPath ."';"); - // token - $this->document->addScriptDeclaration("var token = '". JSession::getFormToken() ."';"); - // add some global items buckets for bulk updating - $this->document->addScriptDeclaration("var bulkItems = {};"); - $this->document->addScriptDeclaration("bulkItems.new = [];"); - $this->document->addScriptDeclaration("bulkItems.diverged = [];"); - $this->document->addScriptDeclaration("bulkItems.ahead = [];"); - $this->document->addScriptDeclaration("bulkItems.behind = [];"); - // set an error message if needed - $this->document->addScriptDeclaration("var returnError = '

    ".JText::_('COM_COMPONENTBUILDER_AN_ERROR_HAS_OCCURRED')."!

    ".JText::_('COM_COMPONENTBUILDER_PLEASE_TRY_AGAIN_LATER').".

    ';"); - // need to add some language strings - JText::script('COM_COMPONENTBUILDER_JCB_COMMUNITY_SNIPPETS'); - JText::script('COM_COMPONENTBUILDER_SNIPPETS'); - JText::script('COM_COMPONENTBUILDER_SNIPPET'); - JText::script('COM_COMPONENTBUILDER_VIEW_SNIPPET_OF_COMMUNITY_VERSION'); - JText::script('COM_COMPONENTBUILDER_GET_SNIPPET'); - JText::script('COM_COMPONENTBUILDER_LOCAL_SNIPPET'); - JText::script('COM_COMPONENTBUILDER_GET_THE_SNIPPET_FROM_GITHUB_AND_UPDATE_THE_LOCAL_VERSION'); - JText::script('COM_COMPONENTBUILDER_GET_THE_SNIPPET_FROM_GITHUB_AND_INSTALL_IT_LOCALLY'); - JText::script('COM_COMPONENTBUILDER_NO_NEED_TO_GET_IT_SINCE_IT_IS_ALREADY_IN_SYNC_WITH_YOUR_LOCAL_VERSION'); - JText::script('COM_COMPONENTBUILDER_USAGE'); - JText::script('COM_COMPONENTBUILDER_VIEW_USAGE_OF_COMMUNITY_VERSION'); - JText::script('COM_COMPONENTBUILDER_DESCRIPTION'); - JText::script('COM_COMPONENTBUILDER_VIEW_DESCRIPTION_OF_COMMUNITY_VERSION'); - JText::script('COM_COMPONENTBUILDER_VIEW_BLAME'); - JText::script('COM_COMPONENTBUILDER_VIEW_WHO_CONTRIBUTED_TO_THIS_SNIPPET'); - JText::script('COM_COMPONENTBUILDER_VIEW_SNIPPET_REFERENCE_URL'); - JText::script('COM_COMPONENTBUILDER_SNIPPET_COULD_NOT_BE_UPDATEDSAVED'); - JText::script('COM_COMPONENTBUILDER_SNIPPETS_COULD_NOT_BE_UPDATEDSAVED'); - JText::script('COM_COMPONENTBUILDER_LINK_TO_THE_CONTRIBUTOR'); - JText::script('COM_COMPONENTBUILDER_VIEW_THE_CONTRIBUTOR_DETAILS'); - JText::script('COM_COMPONENTBUILDER_JCB_COMMUNITY'); - JText::script('COM_COMPONENTBUILDER_COMPANY_NAME'); - JText::script('COM_COMPONENTBUILDER_AUTHOR_NAME'); - JText::script('COM_COMPONENTBUILDER_AUTHOR_EMAIL'); - JText::script('COM_COMPONENTBUILDER_AUTHOR_WEBSITE'); - JText::script('COM_COMPONENTBUILDER_THERE_ARE_NO_NEW_SNIPPETS_AT_THIS_TIME'); - JText::script('COM_COMPONENTBUILDER_THERE_ARE_NO_DIVERGED_SNIPPETS_AT_THIS_TIME'); - JText::script('COM_COMPONENTBUILDER_THERE_ARE_NO_AHEAD_SNIPPETS_AT_THIS_TIME'); - JText::script('COM_COMPONENTBUILDER_THERE_ARE_NO_OUT_OF_DATE_SNIPPETS_AT_THIS_TIME'); - JText::script('COM_COMPONENTBUILDER_THERE_ARE_NO_SNIPPETS_TO_UPDATE_AT_THIS_TIME'); - JText::script('COM_COMPONENTBUILDER_AVAILABLE_LIBRARIES'); - JText::script('COM_COMPONENTBUILDER_OPEN_LIBRARY_SNIPPETS'); - // add some lang verfy messages - $this->document->addScriptDeclaration(" - // set the snippet from gitHub - function getConfirmUpdate(status) { - switch(status) { - case 'new': - return '".JText::_('COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_ADD_THIS_NEW_JCB_COMMUNITY_SNIPPET_TO_YOUR_LOCAL_SNIPPETS')."'; - break; - case 'behind': - return '".JText::_('COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_UPDATE_YOUR_LOCAL_SNIPPET_WITH_THIS_NEWER_JCB_COMMUNITY_SNIPPET')."'; - break; - case 'ahead': - return '".JText::_('COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_UPDATE_YOUR_LOCAL_SNIPPET_WITH_THIS_OLDER_JCB_COMMUNITY_SNIPPET')."'; - break; - case 'diverged': - return '".JText::_('COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_REPLACE_YOUR_LOCAL_SNIPPET_WITH_THIS_JCB_COMMUNITY_SNIPPET')."'; - break; - default: - return '".JText::_('COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_CONTINUE')."'; - break; - } - } - "); - // load the local snippets - if (ArrayHelper::check($this->items)) - { - // Set the local snippets array - $this->document->addScriptDeclaration("var local_snippets = ". json_encode($local_snippets).";"); - } - // add the document default css file - JHtml::_('stylesheet', 'administrator/components/com_componentbuilder/assets/css/get_snippets.css', ['version' => 'auto']); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - // hide the main menu - $this->app->input->set('hidemainmenu', true); - // add title to the page - JToolbarHelper::title(JText::_('COM_COMPONENTBUILDER_GET_SNIPPETS'),'search'); - // add cpanel button - JToolBarHelper::custom('get_snippets.dashboard', 'grid-2', '', 'COM_COMPONENTBUILDER_DASH', false); - if ($this->canDo->get('get_snippets.custom_admin_views')) - { - // add Custom Admin Views button. - JToolBarHelper::custom('get_snippets.openCustomAdminViews', 'screen custom-button-opencustomadminviews', '', 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEWS', false); - } - if ($this->canDo->get('get_snippets.site_views')) - { - // add Site Views button. - JToolBarHelper::custom('get_snippets.openSiteViews', 'palette custom-button-opensiteviews', '', 'COM_COMPONENTBUILDER_SITE_VIEWS', false); - } - if ($this->canDo->get('get_snippets.templates')) - { - // add Templates button. - JToolBarHelper::custom('get_snippets.openTemplates', 'brush custom-button-opentemplates', '', 'COM_COMPONENTBUILDER_TEMPLATES', false); - } - if ($this->canDo->get('get_snippets.layouts')) - { - // add Layouts button. - JToolBarHelper::custom('get_snippets.openLayouts', 'brush custom-button-openlayouts', '', 'COM_COMPONENTBUILDER_LAYOUTS', false); - } - if ($this->canDo->get('get_snippets.snippets')) - { - // add Snippets button. - JToolBarHelper::custom('get_snippets.openSnippets', 'pin custom-button-opensnippets', '', 'COM_COMPONENTBUILDER_SNIPPETS', false); - } - if ($this->canDo->get('get_snippets.libraries')) - { - // add Libraries button. - JToolBarHelper::custom('get_snippets.openLibraries', 'puzzle custom-button-openlibraries', '', 'COM_COMPONENTBUILDER_LIBRARIES', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('get_snippets'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } -} diff --git a/admin/views/help_document/submitbutton.js b/admin/views/help_document/submitbutton.js deleted file mode 100644 index 27198a162..000000000 --- a/admin/views/help_document/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('help_document, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/help_document/tmpl/edit.php b/admin/views/help_document/tmpl/edit.php deleted file mode 100644 index 27a49473d..000000000 --- a/admin/views/help_document/tmpl/edit.php +++ /dev/null @@ -1,189 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/help_document/view.html.php b/admin/views/help_document/view.html.php deleted file mode 100644 index 8549c7eaf..000000000 --- a/admin/views/help_document/view.html.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Help_document Html View class - */ -class ComponentbuilderViewHelp_document extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('help_document', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_HELP_DOCUMENT_NEW' : 'COM_COMPONENTBUILDER_HELP_DOCUMENT_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('help_document.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('help_document.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('help_document.edit')) - { - // We can save the record. - JToolBarHelper::save('help_document.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('help_document.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('help_document.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('help_document.create')) - { - JToolBarHelper::apply('help_document.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('help_document.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('help_document.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('help_document.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('help_document.edit')) - { - // We can save the new record - JToolBarHelper::apply('help_document.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('help_document.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('help_document.create')) - { - JToolBarHelper::custom('help_document.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('help_document.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('help_document.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.help_document', $this->item->id); - } - if ($this->canDo->get('help_document.create')) - { - JToolBarHelper::custom('help_document.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('help_document.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('help_document'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_HELP_DOCUMENT_NEW' : 'COM_COMPONENTBUILDER_HELP_DOCUMENT_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/help_document.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/help_document/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/help_documents/tmpl/default.php b/admin/views/help_documents/tmpl/default.php deleted file mode 100644 index 4a8dcb041..000000000 --- a/admin/views/help_documents/tmpl/default.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=help_documents.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'help_documentList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENTS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/help_documents/tmpl/default_batch_body.php b/admin/views/help_documents/tmpl/default_batch_body.php deleted file mode 100644 index d946ec995..000000000 --- a/admin/views/help_documents/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/help_documents/tmpl/default_batch_footer.php b/admin/views/help_documents/tmpl/default_batch_footer.php deleted file mode 100644 index df213dcd9..000000000 --- a/admin/views/help_documents/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/help_documents/tmpl/default_body.php b/admin/views/help_documents/tmpl/default_body.php deleted file mode 100644 index e3ea244de..000000000 --- a/admin/views/help_documents/tmpl/default_body.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=help_documents&task=help_document.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('help_document',$item,'help_documents'); - ?> - - - get('help_document.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('help_document.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('help_document.edit')): ?> - escape($item->title); ?> - checked_out): ?> - name, $item->checked_out_time, 'help_documents.', $canCheckin); ?> - - - escape($item->title); ?> - -
    - - - type); ?> - - - escape($item->groups); ?> - - - location); ?> - - - escape($item->admin_view); ?> - - - escape($item->site_view); ?> - - - get('help_document.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'help_documents.', true, 'cb'); ?> - - published, $i, 'help_documents.', false, 'cb'); ?> - - - published, $i, 'help_documents.', true, 'cb'); ?> - - - published, $i, 'help_documents.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/help_documents/tmpl/default_foot.php b/admin/views/help_documents/tmpl/default_foot.php deleted file mode 100644 index d800cc269..000000000 --- a/admin/views/help_documents/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/help_documents/tmpl/default_head.php b/admin/views/help_documents/tmpl/default_head.php deleted file mode 100644 index c1097f4f3..000000000 --- a/admin/views/help_documents/tmpl/default_head.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/help_documents/tmpl/default_toolbar.php b/admin/views/help_documents/tmpl/default_toolbar.php deleted file mode 100644 index a9b97a8ec..000000000 --- a/admin/views/help_documents/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/help_documents/view.html.php b/admin/views/help_documents/view.html.php deleted file mode 100644 index 08b606523..000000000 --- a/admin/views/help_documents/view.html.php +++ /dev/null @@ -1,305 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Help_documents - */ -class ComponentbuilderViewHelp_documents extends HtmlView -{ - /** - * Help_documents view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('help_documents'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('help_document'); - $this->canEdit = $this->canDo->get('help_document.edit'); - $this->canState = $this->canDo->get('help_document.edit.state'); - $this->canCreate = $this->canDo->get('help_document.create'); - $this->canDelete = $this->canDo->get('help_document.delete'); - $this->canBatch = ($this->canDo->get('help_document.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENTS'), 'support'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=help_documents'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('help_document.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('help_document.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('help_documents.publish'); - JToolBarHelper::unpublishList('help_documents.unpublish'); - JToolBarHelper::archiveList('help_documents.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('help_documents.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'help_documents.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('help_documents.trash'); - } - - if ($this->canDo->get('core.export') && $this->canDo->get('help_document.export')) - { - JToolBarHelper::custom('help_documents.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); - } - } - - if ($this->canDo->get('core.import') && $this->canDo->get('help_document.import')) - { - JToolBarHelper::custom('help_documents.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('help_documents'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load Type batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Type Selection - $this->typeOptions = JFormHelper::loadFieldType('helpdocumentsfiltertype')->options; - // We do some sanitation for Type filter - if (ComponentbuilderHelper::checkArray($this->typeOptions) && - isset($this->typeOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->typeOptions[0]->value)) - { - unset($this->typeOptions[0]); - } - // Type Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_TYPE_LABEL').' -', - 'batch[type]', - JHtml::_('select.options', $this->typeOptions, 'value', 'text') - ); - } - - // Only load Location batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Location Selection - $this->locationOptions = JFormHelper::loadFieldType('helpdocumentsfilterlocation')->options; - // We do some sanitation for Location filter - if (ComponentbuilderHelper::checkArray($this->locationOptions) && - isset($this->locationOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->locationOptions[0]->value)) - { - unset($this->locationOptions[0]); - } - // Location Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_LOCATION_LABEL').' -', - 'batch[location]', - JHtml::_('select.options', $this->locationOptions, 'value', 'text') - ); - } - - // Only load Admin View batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Admin View Selection - $this->admin_viewOptions = JFormHelper::loadFieldType('Adminviewfolderlist')->options; - // We do some sanitation for Admin View filter - if (ComponentbuilderHelper::checkArray($this->admin_viewOptions) && - isset($this->admin_viewOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->admin_viewOptions[0]->value)) - { - unset($this->admin_viewOptions[0]); - } - // Admin View Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_ADMIN_VIEW_LABEL').' -', - 'batch[admin_view]', - JHtml::_('select.options', $this->admin_viewOptions, 'value', 'text') - ); - } - - // Only load Site View batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Site View Selection - $this->site_viewOptions = JFormHelper::loadFieldType('Siteviewfolderlist')->options; - // We do some sanitation for Site View filter - if (ComponentbuilderHelper::checkArray($this->site_viewOptions) && - isset($this->site_viewOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->site_viewOptions[0]->value)) - { - unset($this->site_viewOptions[0]); - } - // Site View Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_SITE_VIEW_LABEL').' -', - 'batch[site_view]', - JHtml::_('select.options', $this->site_viewOptions, 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENTS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/help_documents.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.title' => JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_TITLE_LABEL'), - 'a.type' => JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_TYPE_LABEL'), - 'a.location' => JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_LOCATION_LABEL'), - 'g.' => JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_ADMIN_VIEW_LABEL'), - 'h.' => JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_SITE_VIEW_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/import/tmpl/default.php b/admin/views/import/tmpl/default.php deleted file mode 100644 index 5f2f7198b..000000000 --- a/admin/views/import/tmpl/default.php +++ /dev/null @@ -1,217 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('jquery.framework'); -JHtml::_('bootstrap.tooltip'); -JHtml::_('script', 'system/core.js', false, true); -JHtml::_('behavior.keepalive'); -?> - - -
    -
    - - sidebar)) : ?> -
    - sidebar; ?> -
    -
    - -
    - - - hasPackage && ComponentbuilderHelper::checkArray($this->headerList) && ComponentbuilderHelper::checkArray($this->headers)) : ?> -
    - -
    - -
    - -
    -
    - headerList as $name => $title): ?> -
    - -
    - -
    -
    - -
    - -
    -
    - - - 'upload')); ?> - - -
    - -
    - -
    - -
    -
    -
    -     (.csv .xls .ods) -
    -
    - - - -
    - -
    - -
    - -
    -
    -
    -     (.csv .xls .ods) -
    -
    - - - -
    - -
    - -
    - -
    -
    -
    -     (.csv .xls .ods) -
    -
    - - - - - - - -
    \ No newline at end of file diff --git a/admin/views/import/view.html.php b/admin/views/import/view.html.php deleted file mode 100644 index b7669e5be..000000000 --- a/admin/views/import/view.html.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Import Html View - */ -class ComponentbuilderViewImport extends HtmlView -{ - protected $headerList; - protected $hasPackage = false; - protected $headers; - protected $hasHeader = 0; - protected $dataType; - - public function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('import'); - } - - $paths = new stdClass; - $paths->first = ''; - $state = $this->get('state'); - - $this->paths = &$paths; - $this->state = &$state; - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('import'); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - } - - // get the session object - $session = JFactory::getSession(); - // check if it has package - $this->hasPackage = $session->get('hasPackage', false); - $this->dataType = $session->get('dataType', false); - if($this->hasPackage && $this->dataType) - { - $this->headerList = json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS', false),true); - $this->headers = ComponentbuilderHelper::getFileHeaders($this->dataType); - // clear the data type - $session->clear('dataType'); - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_IMPORT_TITLE'), 'upload'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=import'); - - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('import'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } -} diff --git a/admin/views/import_joomla_components/tmpl/default.php b/admin/views/import_joomla_components/tmpl/default.php deleted file mode 100644 index 59d07a8da..000000000 --- a/admin/views/import_joomla_components/tmpl/default.php +++ /dev/null @@ -1,550 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); -use VDM\Joomla\Utilities\ArrayHelper; - -JHtml::_('jquery.framework'); -JHtml::_('bootstrap.tooltip'); -JHtml::_('script', 'system/core.js', false, true); -JHtml::_('behavior.keepalive'); -?> - - -dataType === 'smart_package') ? '.zip' : 'none'; ?> -
    -
    - - sidebar)) : ?> -
    - sidebar; ?> -
    -
    - -
    - - -
    - hasPackage) && $this->hasPackage && $this->dataType === 'smart_package') : ?> - packageInfo['name']) && ArrayHelper::check($this->packageInfo['name'])) - { - $cAmount = count($this->packageInfo['name']); - $comP = ($cAmount == 1) ? 'Component' : 'Components'; - } - else - { - $cAmount = 1; - $comP = 'Component'; - } - $hasOwner = (isset($this->packageInfo['getKeyFrom']) && ArrayHelper::check($this->packageInfo['getKeyFrom'])) ? true:false; - $class1 = ($hasOwner) ? 'span6' : 'span12'; - ?> -

    -

    - 'advanced')); ?> - - -
    -
    - - formPackage): ?> - formPackage as $field): ?> -
    -
    label;?>
    -
    input;?>
    -
    - - -
    -
    - - -
    -
    -
    - -

    - -
    - -
    - owner($this->packageInfo); ?> -
    - - - - packageInfo['name']) && ArrayHelper::check($this->packageInfo['name'])) : ?> - - components($this->packageInfo); ?> - - - - - - - dataType === 'smart_package'): ?> -

    -

    - - 'upload')); ?> - - -
    - -
    - -
    - -
    -
    -
    -     () -
    -
    - - - -
    - -
    - -
    - -
    -
    -
    -     () -
    -
    - - - -
    - -
    - -
    - -
    -
    -
    -     () -
    -
    - - - vdmPackages) && ArrayHelper::check($this->vdmPackages)): ?> - -
    -
    -

    -

    -

    -
    -
    - - vdmPackages as $field): ?> -
    -
    label;?>
    -
    input;?>
    -
    - -
    -     -
    -
    -
    -
    -
    -
    -

    -
    -
    -
    - - - - jcbPackages) && ArrayHelper::check($this->jcbPackages)) : ?> - -
    -
    -

    -

    -

    -
    -
    - - jcbPackages as $field): ?> -
    -
    label;?>
    -
    input;?>
    -
    - -
    -     -
    -
    -
    -
    -
    -
    -

    -
    -
    -
    - - - - - - - - - -
    - -
    - diff --git a/admin/views/import_joomla_components/view.html.php b/admin/views/import_joomla_components/view.html.php deleted file mode 100644 index 32f4bf1b4..000000000 --- a/admin/views/import_joomla_components/view.html.php +++ /dev/null @@ -1,462 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; -use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\StringHelper; - -/** - * Componentbuilder Import_joomla_components Html View - */ -class ComponentbuilderViewImport_joomla_components extends HtmlView -{ - protected $headerList; - protected $hasPackage = false; - protected $headers; - protected $hasHeader = 0; - protected $dataType; - protected $packageInfo; - protected $formPackage; - protected $vdmPackages = false; - protected $directories = array(); - - public function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('import'); - } - // get component params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - - $paths = new stdClass; - $paths->first = ''; - $state = $this->get('state'); - - $this->paths = &$paths; - $this->state = &$state; - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('import'); - // load the application - $this->app = JFactory::getApplication(); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // add title to the page - JToolbarHelper::title(JText::_('COM_COMPONENTBUILDER_JCB_PACKAGE_IMPORT'), 'upload'); - // add refesh button. - JToolBarHelper::custom('joomla_component.refresh', 'refresh', '', 'COM_COMPONENTBUILDER_REFRESH', false); - } - // get the session object - $session = JFactory::getSession(); - // check if it has package - $this->hasPackage = $session->get('hasPackage', false); - $this->dataType = $session->get('dataType', false); - if (!$this->dataType) - { - $this->dataType = $session->get('dataType_VDM_IMPORTINTO', null); - } - - // get the management input from global settings - $manageDirectories = $this->params->get('manage_jcb_package_directories', 2); - if ($manageDirectories == 2) - { - $this->directories = array('vdm', 'jcb'); - } - elseif ($manageDirectories == 1) - { - $this->directories = (array) $this->params->get('jcb_package_directories'); - } - - // set form only if smart package - if ($this->dataType === 'smart_package') - { - $this->packageInfo = json_decode($session->get('smart_package_info', false), true); - - // add the form class - jimport('joomla.form.form'); - - // load the forms - $this->formPackage = $this->_getForm($this->dataType); - $this->vdmPackages = $this->_getForm('vdm_package'); - $this->jcbPackages = $this->_getForm('jcb_package'); - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // set the document - $this->setDocument(); - - // Display the template - parent::display($tpl); - } - - /** - * Prepares the document - */ - protected function setDocument() - { - // always make sure jquery is loaded. - JHtml::_('jquery.framework'); - - // Add the JavaScript for JStore - $this->document->addScript(JURI::root() .'media/com_componentbuilder/js/jquery.json.min.js'); - $this->document->addScript(JURI::root() .'media/com_componentbuilder/js/jstorage.min.js'); - $this->document->addScript(JURI::root() .'media/com_componentbuilder/js/strtotime.js'); - // add marked library - $this->document->addScript(JURI::root() . "media/com_componentbuilder/js/marked.js"); - // check if we should use browser storage - $setBrowserStorage = $this->params->get('set_browser_storage', null); - if ($setBrowserStorage) - { - // check what (Time To Live) show we use - $storageTimeToLive = $this->params->get('storage_time_to_live', 'global'); - if ('global' == $storageTimeToLive) - { - // use the global session time - $session = JFactory::getSession(); - // must have itin milliseconds - $expire = ($session->getExpire()*60)* 1000; - } - else - { - // use the Componentbuilder Global setting - if (0 != $storageTimeToLive) - { - // this will convert the time into milliseconds - $storageTimeToLive = $storageTimeToLive * 1000; - } - $expire = $storageTimeToLive; - } - } - else - { - // set to use no storage - $expire = 30000; // only 30 seconds - } - - // Set the Time To Live To JavaScript - $this->document->addScriptDeclaration("var expire = ". (int) $expire.";"); - $this->document->addScriptDeclaration("var all_is_good = '".JText::_('COM_COMPONENTBUILDER_ALL_IS_GOOD_THERE_IS_NO_NOTICE_AT_THIS_TIME')."';"); - // add a token on the page for javascript - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - } - - public function _getForm($type) - { - $form = array(); - if ('smart_package' === $type) - { - // get the force_update radio field - $force_update = JFormHelper::loadFieldType('radio',true); - // start force_update xml - $force_updateXML = new SimpleXMLElement(''); - // force_update attributes - $force_updateAttributes = array( - 'type' => 'radio', - 'name' => 'force_update', - 'label' => 'COM_COMPONENTBUILDER_FORCE_LOCAL_UPDATE', - 'class' => 'btn-group btn-group-yesno', - 'description' => 'COM_COMPONENTBUILDER_SHOULD_WE_FORCE_THE_UPDATE_OF_ALL_LOCAL_DATA_EVEN_IF_IT_IS_NEWER_THEN_THE_DATA_BEING_IMPORTED', - 'default' => '0'); - // load the force_update attributes - ComponentbuilderHelper::xmlAddAttributes($force_updateXML, $force_updateAttributes); - // set the force_update options - $force_updateOptions = array( - '1' => 'COM_COMPONENTBUILDER_YES', - '0' => 'COM_COMPONENTBUILDER_NO'); - // load the force_update options - ComponentbuilderHelper::xmlAddOptions($force_updateXML, $force_updateOptions); - // setup the force_update radio field - $force_update->setup($force_updateXML,0); - // add to form - $form[] = $force_update; - - // get the more_info radio field - $more_info = JFormHelper::loadFieldType('radio',true); - // start more_info xml - $more_infoXML = new SimpleXMLElement(''); - // more_info attributes - $more_infoAttributes = array( - 'type' => 'radio', - 'name' => 'more_info', - 'label' => 'COM_COMPONENTBUILDER_SEE_ALL_IMPORT_INFO', - 'class' => 'btn-group btn-group-yesno', - 'description' => 'COM_COMPONENTBUILDER_SHOULD_WE_BE_SHOWING_MORE_ELABORATE_INFORMATION_DURING_IMPORT', - 'default' => '0'); - // load the more_info attributes - ComponentbuilderHelper::xmlAddAttributes($more_infoXML, $more_infoAttributes); - // set the more_info options - $more_infoOptions = array( - '1' => 'COM_COMPONENTBUILDER_YES', - '0' => 'COM_COMPONENTBUILDER_NO'); - // load the more_info options - ComponentbuilderHelper::xmlAddOptions($more_infoXML, $more_infoOptions); - // setup the more_info radio field - $more_info->setup($more_infoXML,0); - // add to form - $form[] = $more_info; - - // get the merge radio field - $merge = JFormHelper::loadFieldType('radio',true); - // start merge xml - $mergeXML = new SimpleXMLElement(''); - // merge attributes - $mergeAttributes = array( - 'type' => 'radio', - 'name' => 'canmerge', - 'label' => 'COM_COMPONENTBUILDER_MERGE', - 'class' => 'btn-group btn-group-yesno', - 'description' => 'COM_COMPONENTBUILDER_SHOULD_WE_MERGE_THE_COMPONENTS_WITH_SIMILAR_LOCAL_COMPONENTS_MERGING_THE_COMPONENTS_USE_TO_BE_THE_DEFAULT_BEHAVIOUR_BUT_NOW_YOU_CAN_IMPORT_THE_COMPONENTS_AND_FORCE_IT_NOT_TO_MERGE_THE_FOLLOWING_AREAS_VALIDATION_RULE_FIELDTYPE_SNIPPET_LANGUAGE_LANGUAGE_TRANSLATION_JOOMLA_PLUGIN_GROUP_CLASS_EXTENDS_CLASS_PROPERTY_CLASS_METHOD_BMUST_AND_WILL_STILLB_MERGE_EVEN_OF_YOUR_SELECTION_IS_BNOB_BECAUSE_OF_THE_SINGULAR_NATURE_OF_THOSE_AREAS', - 'default' => '1'); - // load the merge attributes - ComponentbuilderHelper::xmlAddAttributes($mergeXML, $mergeAttributes); - // set the merge options - $mergeOptions = array( - '1' => 'COM_COMPONENTBUILDER_YES', - '0' => 'COM_COMPONENTBUILDER_NO'); - // load the merge options - ComponentbuilderHelper::xmlAddOptions($mergeXML, $mergeOptions); - // setup the merge radio field - $merge->setup($mergeXML,1); - // add to form - $form[] = $merge; - - // get the import_guid_only radio field - $import_guid_only = JFormHelper::loadFieldType('radio',true); - // start import_guid_only xml - $import_guid_onlyXML = new SimpleXMLElement(''); - // import_guid_only attributes - $import_guid_onlyAttributes = array( - 'type' => 'radio', - 'name' => 'import_guid_only', - 'label' => 'COM_COMPONENTBUILDER_IMPORT_BY_GUID_ONLY', - 'class' => 'btn-group btn-group-yesno', - 'description' => 'COM_COMPONENTBUILDER_FORCE_THAT_THIS_JCB_PACKAGE_IMPORT_SEARCH_FOR_LOCAL_ITEMS_TO_BE_DONE_WITH_GUID_VALUE_ONLY_IF_BMERGEB_IS_SET_TO_YES_ABOVE', - 'default' => '1'); - // load the import_guid_only attributes - ComponentbuilderHelper::xmlAddAttributes($import_guid_onlyXML, $import_guid_onlyAttributes); - // set the import_guid_only options - $import_guid_onlyOptions = array( - '1' => 'COM_COMPONENTBUILDER_YES', - '0' => 'COM_COMPONENTBUILDER_NO'); - // load the import_guid_only options - ComponentbuilderHelper::xmlAddOptions($import_guid_onlyXML, $import_guid_onlyOptions); - // setup the import_guid_only radio field - $import_guid_only->setup($import_guid_onlyXML, $this->params->get('import_guid_only', 0)); - // add to form - $form[] = $import_guid_only; - - if (!$this->packageInfo || ComponentbuilderHelper::getPackageComponentsKeyStatus($this->packageInfo)) - { - // set required field - $required = true; - // does the packages has info - if (!$this->packageInfo) - { - // get the haskey radio field - $haskey = JFormHelper::loadFieldType('radio',true); - // start haskey xml - $haskeyXML = new SimpleXMLElement(''); - // haskey attributes - $haskeyAttributes = array( - 'type' => 'radio', - 'name' => 'haskey', - 'label' => 'COM_COMPONENTBUILDER_USE_KEY', - 'class' => 'btn-group btn-group-yesno', - 'description' => 'COM_COMPONENTBUILDER_DOES_THIS_PACKAGE_REQUIRE_A_KEY_TO_INSTALL', - 'default' => '1', - 'filter' => 'INT'); - // load the haskey attributes - ComponentbuilderHelper::xmlAddAttributes($haskeyXML, $haskeyAttributes); - // set the haskey options - $haskeyOptions = array( - '1' => 'COM_COMPONENTBUILDER_YES', - '0' => 'COM_COMPONENTBUILDER_NO'); - // load the haskey options - ComponentbuilderHelper::xmlAddOptions($haskeyXML, $haskeyOptions); - // setup the haskey radio field - $haskey->setup($haskeyXML,1); - // add to form - $form[] = $haskey; - - // now make required false - $required = false; - } - - // get the sleutle password field - $sleutle = JFormHelper::loadFieldType('password',true); - // start sleutle xml - $sleutleXML = new SimpleXMLElement(''); - // sleutle attributes - $sleutleAttributes = array( - 'type' => 'password', - 'name' => 'sleutle', - 'label' => 'COM_COMPONENTBUILDER_KEY', - 'class' => 'text_area', - 'description' => 'COM_COMPONENTBUILDER_THE_KEY_OF_THIS_PACKAGE', - 'autocomplete' => 'false', - 'filter' => 'STRING', - 'hint' => 'COM_COMPONENTBUILDER_ADD_KEY_HERE'); - // should this be required - if ($required) - { - $sleutleAttributes['required'] = 'true'; - } - // load the sleutle attributes - ComponentbuilderHelper::xmlAddAttributes($sleutleXML, $sleutleAttributes); - // setup the sleutle password field - $sleutle->setup($sleutleXML,''); - // add to form - $form[] = $sleutle; - } - } - elseif ('vdm_package' === $type && in_array('vdm', $this->directories) && $vdmListObjects = ComponentbuilderHelper::getGithubRepoFileList('vdmGithubPackages', ComponentbuilderHelper::$vdmGithubPackagesUrl)) - { - if (ArrayHelper::check($vdmListObjects)) - { - // get the vdm_package list field - $vdm_package = JFormHelper::loadFieldType('list',true); - // start vdm_package xml - $vdm_packageXML = new SimpleXMLElement(''); - // vdm_package attributes - $vdm_packageAttributes = array( - 'type' => 'list', - 'name' => 'vdm_package', - 'label' => 'COM_COMPONENTBUILDER_PACKAGE', - 'class' => 'list_class', - 'description' => 'COM_COMPONENTBUILDER_SELECT_THE_PACKAGE_TO_IMPORT', - 'onchange' => "getJCBpackageInfo('vdm')"); - // load the list - $load = false; - // load the vdm_package attributes - ComponentbuilderHelper::xmlAddAttributes($vdm_packageXML, $vdm_packageAttributes); - // start the vdm_package options - $vdm_packageOptions = array(); - $vdm_packageOptions[''] = 'COM_COMPONENTBUILDER__SELECT_PACKAGE_'; - // load vdm_package options from array - foreach($vdmListObjects as $vdmListObject) - { - if (strpos($vdmListObject->path, '.zip') !== false) - { - $vdm_packageOptions[base64_encode(ComponentbuilderHelper::$vdmGithubPackageUrl.$vdmListObject->path)] = $this->setPackageName($vdmListObject->path); - $load = true; - } - } - // only load if at least one item was found - if ($load) - { - // load the vdm_package options - ComponentbuilderHelper::xmlAddOptions($vdm_packageXML, $vdm_packageOptions); - // setup the vdm_package radio field - $vdm_package->setup($vdm_packageXML,''); - // add to form - $form[] = $vdm_package; - } - } - } - elseif ('jcb_package' === $type && in_array('jcb', $this->directories) && $jcbListObjects = ComponentbuilderHelper::getGithubRepoFileList('communityGithubPackages', ComponentbuilderHelper::$jcbGithubPackagesUrl)) - { - if (ArrayHelper::check($jcbListObjects)) - { - // get the jcb_package list field - $jcb_package = JFormHelper::loadFieldType('list',true); - // start jcb_package xml - $jcb_packageXML = new SimpleXMLElement(''); - // jcb_package attributes - $jcb_packageAttributes = array( - 'type' => 'list', - 'name' => 'jcb_package', - 'label' => 'COM_COMPONENTBUILDER_PACKAGE', - 'class' => 'list_class', - 'description' => 'COM_COMPONENTBUILDER_SELECT_THE_PACKAGE_TO_IMPORT', - 'onchange' => "getJCBpackageInfo('jcb')"); - // load the list - $load = false; - // load the jcb_package attributes - ComponentbuilderHelper::xmlAddAttributes($jcb_packageXML, $jcb_packageAttributes); - // start the jcb_package options - $jcb_packageOptions = array(); - $jcb_packageOptions[''] = 'COM_COMPONENTBUILDER__SELECT_PACKAGE_'; - // load jcb_package options from array - foreach($jcbListObjects as $jcbListObject) - { - if (strpos($jcbListObject->path, '.zip') !== false) - { - $jcb_packageOptions[base64_encode(ComponentbuilderHelper::$jcbGithubPackageUrl.$jcbListObject->path)] = $this->setPackageName($jcbListObject->path); - $load = true; - } - } - // only load if at least one item was found - if ($load) - { - // load the jcb_package options - ComponentbuilderHelper::xmlAddOptions($jcb_packageXML, $jcb_packageOptions); - // setup the jcb_package radio field - $jcb_package->setup($jcb_packageXML,''); - // add to form - $form[] = $jcb_package; - } - } - } - return $form; - } - - public function setPackageName($name) - { - // return the name - return StringHelper::safe( preg_replace('/(?canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('import_joomla_components'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } -} diff --git a/admin/views/import_language_translations/tmpl/default.php b/admin/views/import_language_translations/tmpl/default.php deleted file mode 100644 index fb97b080e..000000000 --- a/admin/views/import_language_translations/tmpl/default.php +++ /dev/null @@ -1,233 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('jquery.framework'); -JHtml::_('bootstrap.tooltip'); -JHtml::_('script', 'system/core.js', false, true); -JHtml::_('behavior.keepalive'); -?> - - - -
    -
    - - - sidebar)) : ?> -
    - sidebar; ?> -
    -
    - -
    - - - - hasPackage && ComponentbuilderHelper::checkArray($this->headerList) && ComponentbuilderHelper::checkArray($this->headers)) : ?> -
    - -
    - -
    - -
    -
    - headerList as $name => $title): ?> -
    - -
    - -
    -
    - -
    - -
    -
    - - - 'upload')); ?> - - -
    - -
    - -
    - -
    -
    -
    -     (.csv .xls .ods) -
    -
    - - - -
    - -
    - -
    - -
    -
    -
    -     (.csv .xls .ods) -
    -
    - - - - -
    - -
    - -
    - -
    -
    -
    -     (.csv .xls .ods) -
    -
    - - - - - - - -
    diff --git a/admin/views/import_language_translations/view.html.php b/admin/views/import_language_translations/view.html.php deleted file mode 100644 index 959664a4b..000000000 --- a/admin/views/import_language_translations/view.html.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Import_language_translations Html View - */ -class ComponentbuilderViewImport_language_translations extends HtmlView -{ - protected $headerList; - protected $hasPackage = false; - protected $headers; - protected $hasHeader = 0; - protected $dataType; - - public function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('import'); - } - - $paths = new stdClass; - $paths->first = ''; - $state = $this->get('state'); - - $this->paths = &$paths; - $this->state = &$state; - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('import'); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - } - - // get the session object - $session = JFactory::getSession(); - // check if it has package - $this->hasPackage = $session->get('hasPackage', false); - $this->dataType = $session->get('dataType', false); - if($this->hasPackage && $this->dataType) - { - $this->headerList = json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS', false),true); - $this->headers = ComponentbuilderHelper::getFileHeaders($this->dataType); - // clear the data type - $session->clear('dataType'); - } - - // Check for errors. - if (count($errors = $this->get('Errors'))){ - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_IMPORT_TITLE'), 'upload'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=import_language_translations'); - - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('import_language_translations'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } -} diff --git a/admin/views/joomla_component/submitbutton.js b/admin/views/joomla_component/submitbutton.js deleted file mode 100644 index ae3597043..000000000 --- a/admin/views/joomla_component/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('joomla_component, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/joomla_component/tmpl/edit.php b/admin/views/joomla_component/tmpl/edit.php deleted file mode 100644 index d9926093e..000000000 --- a/admin/views/joomla_component/tmpl/edit.php +++ /dev/null @@ -1,792 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/joomla_component/view.html.php b/admin/views/joomla_component/view.html.php deleted file mode 100644 index 227818cdc..000000000 --- a/admin/views/joomla_component/view.html.php +++ /dev/null @@ -1,215 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Joomla_component Html View class - */ -class ComponentbuilderViewJoomla_component extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('joomla_component', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('joomla_component.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('joomla_component.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('joomla_component.edit')) - { - // We can save the record. - JToolBarHelper::save('joomla_component.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('joomla_component.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('joomla_component.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('joomla_component.create')) - { - JToolBarHelper::apply('joomla_component.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('joomla_component.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('joomla_component.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('joomla_component.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('joomla_component.edit')) - { - // We can save the new record - JToolBarHelper::apply('joomla_component.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('joomla_component.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('joomla_component.create')) - { - JToolBarHelper::custom('joomla_component.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('joomla_component.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('joomla_component.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.joomla_component', $this->item->id); - } - if ($this->canDo->get('joomla_component.create')) - { - JToolBarHelper::custom('joomla_component.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('joomla_component.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_component'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/joomla_component.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/joomla_component/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/joomla_components/tmpl/default.php b/admin/views/joomla_components/tmpl/default.php deleted file mode 100644 index de80fb824..000000000 --- a/admin/views/joomla_components/tmpl/default.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleJoomlacomponentsfiltercompanyname', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_COMPANY_NAME') . ' -')); -JHtml::_('formbehavior.chosen', '.multipleJoomlacomponentsfilterauthor', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_AUTHOR') . ' -')); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=joomla_components.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'joomla_componentList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENTS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - - diff --git a/admin/views/joomla_components/tmpl/default_batch_body.php b/admin/views/joomla_components/tmpl/default_batch_body.php deleted file mode 100644 index 1c10b1805..000000000 --- a/admin/views/joomla_components/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/joomla_components/tmpl/default_batch_footer.php b/admin/views/joomla_components/tmpl/default_batch_footer.php deleted file mode 100644 index 1f073cecc..000000000 --- a/admin/views/joomla_components/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/joomla_components/tmpl/default_body.php b/admin/views/joomla_components/tmpl/default_body.php deleted file mode 100644 index 5c046d245..000000000 --- a/admin/views/joomla_components/tmpl/default_body.php +++ /dev/null @@ -1,227 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); -use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\StringHelper; - -$edit = "index.php?option=com_componentbuilder&view=joomla_components&task=joomla_component.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('joomla_component',$item,'joomla_components'); - ?> - - - get('joomla_component.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('joomla_component.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('joomla_component.edit')): ?> - escape($item->system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'joomla_components.', $canCheckin); ?> - - - escape($item->system_name); ?> - - - escape($item->component_version); ?> -
    - return_here is set - if (!isset($this->return_here)) - { - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - } - // setup the buttons - if (!isset($_buttons) || !ArrayHelper::check($_buttons)) - { - $_buttons = array(); - $_buttons[0] = array( - array( - 'view' => 'component_admin_views', - 'views' => 'components_admin_views', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_ADMIN_VIEWS'), - 'icon' => 'stack'), - array( - 'view' => 'component_custom_admin_views', - 'views' => 'components_custom_admin_views', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_CUSTOM_ADMIN_VIEWS'), - 'icon' => 'screen'), - array( - 'view' => 'component_site_views', - 'views' => 'components_site_views', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_SITE_VIEWS'), - 'icon' => 'palette'), - array( - 'view' => 'component_config', - 'views' => 'components_config', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_CONFIG'), - 'icon' => 'options') - ); - $_buttons[1] = array( - array( - 'view' => 'component_placeholders', - 'views' => 'components_placeholders', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_PLACEHOLDERS'), - 'icon' => 'search'), - array( - 'view' => 'component_updates', - 'views' => 'components_updates', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_UPDATES'), - 'icon' => 'database'), - array( - 'view' => 'component_mysql_tweaks', - 'views' => 'components_mysql_tweaks', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_MYSQL_TWEAKS'), - 'icon' => 'screwdriver'), - array( - 'view' => 'component_files_folders', - 'views' => 'components_files_folders', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_FILES_FOLDERS'), - 'icon' => 'briefcase') - ); - $_buttons[2] = array( - array( - 'view' => 'component_custom_admin_menus', - 'views' => 'components_custom_admin_menus', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_CUSTOM_ADMIN_MENUS'), - 'icon' => 'plus'), - array( - 'view' => 'component_dashboard', - 'views' => 'components_dashboard', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_DASHBOARD'), - 'icon' => 'dashboard'), - array( - 'view' => 'component_modules', - 'views' => 'components_modules', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_MODULES'), - 'icon' => 'cube'), - array( - 'view' => 'component_plugins', - 'views' => 'components_plugins', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_COMPONENT_PLUGINS'), - 'icon' => 'power-cord') - ); - } - ?> -
    - - get($_button['view'].'.edit') && ($id = ComponentbuilderHelper::getVar($_button['view'], $item->id, 'joomla_component', 'id')) !== false): ?> - - get($_button['view'].'.create')): ?> - - - -
    - - -
    - escape($item->name_code); ?> -
    -
    - - get($_button['view'].'.edit') && ($id = ComponentbuilderHelper::getVar($_button['view'], $item->id, 'joomla_component', 'id')) !== false): ?> - - get($_button['view'].'.create')): ?> - - - -
    - - -
    - escape($item->short_description); ?> -
    -
    - - get($_button['view'].'.edit') && ($id = ComponentbuilderHelper::getVar($_button['view'], $item->id, 'joomla_component', 'id')) !== false): ?> - - get($_button['view'].'.create')): ?> - - - -
    - - -
    escape($item->companyname); ?>
    - author)) : ?> - escape($item->author); ?>
    - - email) && StringHelper::check($item->author)) : ?> - - escape($item->email); ?> - -
    - - website) && StringHelper::check($item->author)) : ?> - - escape($item->website); ?> - - -
    - - - get('joomla_component.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'joomla_components.', true, 'cb'); ?> - - published, $i, 'joomla_components.', false, 'cb'); ?> - - - published, $i, 'joomla_components.', true, 'cb'); ?> - - - published, $i, 'joomla_components.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/joomla_components/tmpl/default_foot.php b/admin/views/joomla_components/tmpl/default_foot.php deleted file mode 100644 index 5a05d8cfd..000000000 --- a/admin/views/joomla_components/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/joomla_components/tmpl/default_head.php b/admin/views/joomla_components/tmpl/default_head.php deleted file mode 100644 index e148c450f..000000000 --- a/admin/views/joomla_components/tmpl/default_head.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/joomla_components/tmpl/default_toolbar.php b/admin/views/joomla_components/tmpl/default_toolbar.php deleted file mode 100644 index b6f171729..000000000 --- a/admin/views/joomla_components/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/joomla_components/view.html.php b/admin/views/joomla_components/view.html.php deleted file mode 100644 index 8d2b4f833..000000000 --- a/admin/views/joomla_components/view.html.php +++ /dev/null @@ -1,306 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Joomla_components - */ -class ComponentbuilderViewJoomla_components extends HtmlView -{ - /** - * Joomla_components view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('joomla_components'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('joomla_component'); - $this->canEdit = $this->canDo->get('joomla_component.edit'); - $this->canState = $this->canDo->get('joomla_component.edit.state'); - $this->canCreate = $this->canDo->get('joomla_component.create'); - $this->canDelete = $this->canDo->get('joomla_component.delete'); - $this->canBatch = ($this->canDo->get('joomla_component.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENTS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=joomla_components'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('joomla_component.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('joomla_component.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('joomla_components.publish'); - JToolBarHelper::unpublishList('joomla_components.unpublish'); - JToolBarHelper::archiveList('joomla_components.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('joomla_components.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - if ($this->user->authorise('joomla_component.clone', 'com_componentbuilder')) - { - // add Clone button. - JToolBarHelper::custom('joomla_components.cloner', 'save-copy custom-button-cloner', '', 'COM_COMPONENTBUILDER_CLONE', 'true'); - } - if ($this->user->authorise('joomla_component.export_jcb_packages', 'com_componentbuilder')) - { - // add Export JCB Packages button. - JToolBarHelper::custom('joomla_components.smartExport', 'download custom-button-smartexport', '', 'COM_COMPONENTBUILDER_EXPORT_JCB_PACKAGES', 'true'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'joomla_components.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('joomla_components.trash'); - } - - if ($this->canDo->get('core.export') && $this->canDo->get('joomla_component.export')) - { - JToolBarHelper::custom('joomla_components.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); - } - } - if ($this->user->authorise('joomla_component.import_jcb_packages', 'com_componentbuilder')) - { - // add Import JCB Packages button. - JToolBarHelper::custom('joomla_components.smartImport', 'upload custom-button-smartimport', '', 'COM_COMPONENTBUILDER_IMPORT_JCB_PACKAGES', false); - } - if ($this->user->authorise('joomla_component.run_expansion', 'com_componentbuilder')) - { - // add Run Expansion button. - JToolBarHelper::custom('joomla_components.runExpansion', 'expand-2 custom-button-runexpansion', '', 'COM_COMPONENTBUILDER_RUN_EXPANSION', false); - } - if ($this->user->authorise('joomla_component.backup', 'com_componentbuilder')) - { - // add Backup button. - JToolBarHelper::custom('joomla_components.backup', 'archive custom-button-backup', '', 'COM_COMPONENTBUILDER_BACKUP', false); - } - if ($this->user->authorise('joomla_component.clear_tmp', 'com_componentbuilder')) - { - // add Clear tmp button. - JToolBarHelper::custom('joomla_components.clearTmp', 'purge custom-button-cleartmp', '', 'COM_COMPONENTBUILDER_CLEAR_TMP', false); - } - - if ($this->canDo->get('core.import') && $this->canDo->get('joomla_component.import')) - { - JToolBarHelper::custom('joomla_components.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_components'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - - // Only load Companyname batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Companyname Selection - $this->companynameOptions = JFormHelper::loadFieldType('joomlacomponentsfiltercompanyname')->options; - // We do some sanitation for Companyname filter - if (ComponentbuilderHelper::checkArray($this->companynameOptions) && - isset($this->companynameOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->companynameOptions[0]->value)) - { - unset($this->companynameOptions[0]); - } - // Companyname Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_COMPANYNAME_LABEL').' -', - 'batch[companyname]', - JHtml::_('select.options', $this->companynameOptions, 'value', 'text') - ); - } - - // Only load Author batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Author Selection - $this->authorOptions = JFormHelper::loadFieldType('joomlacomponentsfilterauthor')->options; - // We do some sanitation for Author filter - if (ComponentbuilderHelper::checkArray($this->authorOptions) && - isset($this->authorOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->authorOptions[0]->value)) - { - unset($this->authorOptions[0]); - } - // Author Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_AUTHOR_LABEL').' -', - 'batch[author]', - JHtml::_('select.options', $this->authorOptions, 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENTS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/joomla_components.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.system_name' => JText::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_SYSTEM_NAME_LABEL'), - 'a.name_code' => JText::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NAME_CODE_LABEL'), - 'a.short_description' => JText::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_SHORT_DESCRIPTION_LABEL'), - 'a.companyname' => JText::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_COMPANYNAME_LABEL'), - 'a.created' => JText::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CREATED_LABEL'), - 'a.modified' => JText::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_MODIFIED_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/joomla_module/submitbutton.js b/admin/views/joomla_module/submitbutton.js deleted file mode 100644 index 15089b320..000000000 --- a/admin/views/joomla_module/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('joomla_module, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/joomla_module/tmpl/edit.php b/admin/views/joomla_module/tmpl/edit.php deleted file mode 100644 index cb6da1ee7..000000000 --- a/admin/views/joomla_module/tmpl/edit.php +++ /dev/null @@ -1,663 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/joomla_module/view.html.php b/admin/views/joomla_module/view.html.php deleted file mode 100644 index 713113811..000000000 --- a/admin/views/joomla_module/view.html.php +++ /dev/null @@ -1,250 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Joomla_module Html View class - */ -class ComponentbuilderViewJoomla_module extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('joomla_module', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_MODULE_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_MODULE_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('joomla_module.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('joomla_module.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('joomla_module.edit')) - { - // We can save the record. - JToolBarHelper::save('joomla_module.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('joomla_module.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('joomla_module.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('joomla_module.create')) - { - JToolBarHelper::apply('joomla_module.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('joomla_module.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('joomla_module.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('joomla_module.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('joomla_module.edit')) - { - // We can save the new record - JToolBarHelper::apply('joomla_module.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('joomla_module.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('joomla_module.create')) - { - JToolBarHelper::custom('joomla_module.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('joomla_module.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('joomla_module.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.joomla_module', $this->item->id); - } - if ($this->canDo->get('joomla_module.create')) - { - JToolBarHelper::custom('joomla_module.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('joomla_module.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_module'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_MODULE_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_MODULE_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/joomla_module.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/joomla_module/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - // Add the JavaScript for JStore - $this->document->addScript(JURI::root() .'media/com_componentbuilder/js/jquery.json.min.js'); - $this->document->addScript(JURI::root() .'media/com_componentbuilder/js/jstorage.min.js'); - $this->document->addScript(JURI::root() .'media/com_componentbuilder/js/strtotime.js'); - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - // check if we should use browser storage - $setBrowserStorage = $this->params->get('set_browser_storage', null); - if ($setBrowserStorage) - { - // check what (Time To Live) show we use - $storageTimeToLive = $this->params->get('storage_time_to_live', 'global'); - if ('global' == $storageTimeToLive) - { - // use the global session time - $session = JFactory::getSession(); - // must have itin milliseconds - $expire = ($session->getExpire()*60)* 1000; - } - else - { - // use the Componentbuilder Global setting - if (0 != $storageTimeToLive) - { - // this will convert the time into milliseconds - $storageTimeToLive = $storageTimeToLive * 1000; - } - $expire = $storageTimeToLive; - } - } - else - { - // set to use no storage - $expire = 30000; // only 30 seconds - } - // Set the Time To Live To JavaScript - $this->document->addScriptDeclaration("var expire = ". (int) $expire.";"); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/joomla_module_files_folders_urls/submitbutton.js b/admin/views/joomla_module_files_folders_urls/submitbutton.js deleted file mode 100644 index 730ccad05..000000000 --- a/admin/views/joomla_module_files_folders_urls/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('joomla_module_files_folders_urls, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/joomla_module_files_folders_urls/tmpl/edit.php b/admin/views/joomla_module_files_folders_urls/tmpl/edit.php deleted file mode 100644 index 7543ffad6..000000000 --- a/admin/views/joomla_module_files_folders_urls/tmpl/edit.php +++ /dev/null @@ -1,115 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - diff --git a/admin/views/joomla_module_files_folders_urls/view.html.php b/admin/views/joomla_module_files_folders_urls/view.html.php deleted file mode 100644 index ea5f77f57..000000000 --- a/admin/views/joomla_module_files_folders_urls/view.html.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Joomla_module_files_folders_urls Html View class - */ -class ComponentbuilderViewJoomla_module_files_folders_urls extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('joomla_module_files_folders_urls', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('joomla_module_files_folders_urls.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('joomla_module_files_folders_urls.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('joomla_module_files_folders_urls.edit')) - { - // We can save the record. - JToolBarHelper::save('joomla_module_files_folders_urls.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('joomla_module_files_folders_urls.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('joomla_module_files_folders_urls.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('joomla_module_files_folders_urls.create')) - { - JToolBarHelper::apply('joomla_module_files_folders_urls.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('joomla_module_files_folders_urls.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('joomla_module_files_folders_urls.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('joomla_module_files_folders_urls.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('joomla_module_files_folders_urls.edit')) - { - // We can save the new record - JToolBarHelper::apply('joomla_module_files_folders_urls.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('joomla_module_files_folders_urls.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('joomla_module_files_folders_urls.create')) - { - JToolBarHelper::custom('joomla_module_files_folders_urls.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('joomla_module_files_folders_urls.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('joomla_module_files_folders_urls.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.joomla_module_files_folders_urls', $this->item->id); - } - if ($this->canDo->get('joomla_module_files_folders_urls.create')) - { - JToolBarHelper::custom('joomla_module_files_folders_urls.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('joomla_module_files_folders_urls.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_module_files_folders_urls'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/joomla_module_files_folders_urls.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/joomla_module_files_folders_urls/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/joomla_module_updates/submitbutton.js b/admin/views/joomla_module_updates/submitbutton.js deleted file mode 100644 index 4c0b34647..000000000 --- a/admin/views/joomla_module_updates/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('joomla_module_updates, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/joomla_module_updates/tmpl/edit.php b/admin/views/joomla_module_updates/tmpl/edit.php deleted file mode 100644 index bc2a12f1b..000000000 --- a/admin/views/joomla_module_updates/tmpl/edit.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - diff --git a/admin/views/joomla_module_updates/view.html.php b/admin/views/joomla_module_updates/view.html.php deleted file mode 100644 index 6ac9314de..000000000 --- a/admin/views/joomla_module_updates/view.html.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Joomla_module_updates Html View class - */ -class ComponentbuilderViewJoomla_module_updates extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('joomla_module_updates', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('joomla_module_updates.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('joomla_module_updates.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('joomla_module_updates.edit')) - { - // We can save the record. - JToolBarHelper::save('joomla_module_updates.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('joomla_module_updates.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('joomla_module_updates.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('joomla_module_updates.create')) - { - JToolBarHelper::apply('joomla_module_updates.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('joomla_module_updates.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('joomla_module_updates.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('joomla_module_updates.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('joomla_module_updates.edit')) - { - // We can save the new record - JToolBarHelper::apply('joomla_module_updates.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('joomla_module_updates.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('joomla_module_updates.create')) - { - JToolBarHelper::custom('joomla_module_updates.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('joomla_module_updates.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('joomla_module_updates.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.joomla_module_updates', $this->item->id); - } - if ($this->canDo->get('joomla_module_updates.create')) - { - JToolBarHelper::custom('joomla_module_updates.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('joomla_module_updates.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_module_updates'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/joomla_module_updates.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/joomla_module_updates/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/joomla_modules/tmpl/default.php b/admin/views/joomla_modules/tmpl/default.php deleted file mode 100644 index 0e96906f3..000000000 --- a/admin/views/joomla_modules/tmpl/default.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=joomla_modules.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'joomla_moduleList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_JOOMLA_MODULES_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - - diff --git a/admin/views/joomla_modules/tmpl/default_batch_body.php b/admin/views/joomla_modules/tmpl/default_batch_body.php deleted file mode 100644 index 1559f5c53..000000000 --- a/admin/views/joomla_modules/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/joomla_modules/tmpl/default_batch_footer.php b/admin/views/joomla_modules/tmpl/default_batch_footer.php deleted file mode 100644 index 26eff5f18..000000000 --- a/admin/views/joomla_modules/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/joomla_modules/tmpl/default_body.php b/admin/views/joomla_modules/tmpl/default_body.php deleted file mode 100644 index d0536eb79..000000000 --- a/admin/views/joomla_modules/tmpl/default_body.php +++ /dev/null @@ -1,127 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); -use VDM\Joomla\Utilities\ArrayHelper; - -$edit = "index.php?option=com_componentbuilder&view=joomla_modules&task=joomla_module.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('joomla_module',$item,'joomla_modules'); - ?> - - - get('joomla_module.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('joomla_module.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('joomla_module.edit')): ?> - escape($item->system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'joomla_modules.', $canCheckin); ?> - - - escape($item->system_name); ?> - - - escape($item->module_version); ?> -
    - 'joomla_module_updates', - 'views' => 'joomla_modules_updates', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_MODULE_UPDATES'), - 'icon' => 'database'), - array( - 'view' => 'joomla_module_files_folders_urls', - 'views' => 'joomla_modules_files_folders_urls', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_MODULE_FILES_FOLDERS'), - 'icon' => 'briefcase') - ); - } - ?> -
    - - get($_button['view'].'.edit') && ($id = ComponentbuilderHelper::getVar($_button['view'], $item->id, 'joomla_module', 'id')) !== false): ?> - - get($_button['view'].'.create')): ?> - - - -
    - - - target); ?> - - - escape($item->description); ?> - - - get('joomla_module.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'joomla_modules.', true, 'cb'); ?> - - published, $i, 'joomla_modules.', false, 'cb'); ?> - - - published, $i, 'joomla_modules.', true, 'cb'); ?> - - - published, $i, 'joomla_modules.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/joomla_modules/tmpl/default_foot.php b/admin/views/joomla_modules/tmpl/default_foot.php deleted file mode 100644 index eff41e725..000000000 --- a/admin/views/joomla_modules/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/joomla_modules/tmpl/default_head.php b/admin/views/joomla_modules/tmpl/default_head.php deleted file mode 100644 index 738216dca..000000000 --- a/admin/views/joomla_modules/tmpl/default_head.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/joomla_modules/tmpl/default_toolbar.php b/admin/views/joomla_modules/tmpl/default_toolbar.php deleted file mode 100644 index b68cfe35f..000000000 --- a/admin/views/joomla_modules/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/joomla_modules/view.html.php b/admin/views/joomla_modules/view.html.php deleted file mode 100644 index 707046496..000000000 --- a/admin/views/joomla_modules/view.html.php +++ /dev/null @@ -1,262 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Joomla_modules - */ -class ComponentbuilderViewJoomla_modules extends HtmlView -{ - /** - * Joomla_modules view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('joomla_modules'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('joomla_module'); - $this->canEdit = $this->canDo->get('joomla_module.edit'); - $this->canState = $this->canDo->get('joomla_module.edit.state'); - $this->canCreate = $this->canDo->get('joomla_module.create'); - $this->canDelete = $this->canDo->get('joomla_module.delete'); - $this->canBatch = ($this->canDo->get('joomla_module.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_JOOMLA_MODULES'), 'cube'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=joomla_modules'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('joomla_module.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('joomla_module.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('joomla_modules.publish'); - JToolBarHelper::unpublishList('joomla_modules.unpublish'); - JToolBarHelper::archiveList('joomla_modules.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('joomla_modules.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'joomla_modules.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('joomla_modules.trash'); - } - - if ($this->canDo->get('core.export') && $this->canDo->get('joomla_module.export')) - { - JToolBarHelper::custom('joomla_modules.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); - } - } - if ($this->user->authorise('joomla_module.get_snippets', 'com_componentbuilder')) - { - // add Get Snippets button. - JToolBarHelper::custom('joomla_modules.getSnippets', 'search custom-button-getsnippets', '', 'COM_COMPONENTBUILDER_GET_SNIPPETS', false); - } - if ($this->user->authorise('joomla_module.run_expansion', 'com_componentbuilder')) - { - // add Run Expansion button. - JToolBarHelper::custom('joomla_modules.runExpansion', 'expand-2 custom-button-runexpansion', '', 'COM_COMPONENTBUILDER_RUN_EXPANSION', false); - } - - if ($this->canDo->get('core.import') && $this->canDo->get('joomla_module.import')) - { - JToolBarHelper::custom('joomla_modules.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_modules'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - - // Only load Target batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Target Selection - $this->targetOptions = JFormHelper::loadFieldType('joomlamodulesfiltertarget')->options; - // We do some sanitation for Target filter - if (ComponentbuilderHelper::checkArray($this->targetOptions) && - isset($this->targetOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->targetOptions[0]->value)) - { - unset($this->targetOptions[0]); - } - // Target Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_JOOMLA_MODULE_TARGET_LABEL').' -', - 'batch[target]', - JHtml::_('select.options', $this->targetOptions, 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_JOOMLA_MODULES')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/joomla_modules.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.system_name' => JText::_('COM_COMPONENTBUILDER_JOOMLA_MODULE_SYSTEM_NAME_LABEL'), - 'a.description' => JText::_('COM_COMPONENTBUILDER_JOOMLA_MODULE_DESCRIPTION_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/joomla_modules_files_folders_urls/tmpl/default.php b/admin/views/joomla_modules_files_folders_urls/tmpl/default.php deleted file mode 100644 index 9b280df27..000000000 --- a/admin/views/joomla_modules_files_folders_urls/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=joomla_modules_files_folders_urls.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'joomla_module_files_folders_urlsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_JOOMLA_MODULES_FILES_FOLDERS_URLS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/joomla_modules_files_folders_urls/tmpl/default_batch_body.php b/admin/views/joomla_modules_files_folders_urls/tmpl/default_batch_body.php deleted file mode 100644 index 4160ddfb3..000000000 --- a/admin/views/joomla_modules_files_folders_urls/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/joomla_modules_files_folders_urls/tmpl/default_batch_footer.php b/admin/views/joomla_modules_files_folders_urls/tmpl/default_batch_footer.php deleted file mode 100644 index 80fd9c031..000000000 --- a/admin/views/joomla_modules_files_folders_urls/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/joomla_modules_files_folders_urls/tmpl/default_body.php b/admin/views/joomla_modules_files_folders_urls/tmpl/default_body.php deleted file mode 100644 index f1bebaa66..000000000 --- a/admin/views/joomla_modules_files_folders_urls/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=joomla_modules_files_folders_urls&task=joomla_module_files_folders_urls.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('joomla_module_files_folders_urls',$item,'joomla_modules_files_folders_urls'); - ?> - - - get('joomla_module_files_folders_urls.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('joomla_module_files_folders_urls.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('joomla_module_files_folders_urls.edit')): ?> - escape($item->joomla_module_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'joomla_modules_files_folders_urls.', $canCheckin); ?> - - - escape($item->joomla_module_system_name); ?> - -
    - - - get('joomla_module_files_folders_urls.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'joomla_modules_files_folders_urls.', true, 'cb'); ?> - - published, $i, 'joomla_modules_files_folders_urls.', false, 'cb'); ?> - - - published, $i, 'joomla_modules_files_folders_urls.', true, 'cb'); ?> - - - published, $i, 'joomla_modules_files_folders_urls.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/joomla_modules_files_folders_urls/tmpl/default_foot.php b/admin/views/joomla_modules_files_folders_urls/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/joomla_modules_files_folders_urls/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/joomla_modules_files_folders_urls/tmpl/default_head.php b/admin/views/joomla_modules_files_folders_urls/tmpl/default_head.php deleted file mode 100644 index 8194953d3..000000000 --- a/admin/views/joomla_modules_files_folders_urls/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/joomla_modules_files_folders_urls/tmpl/default_toolbar.php b/admin/views/joomla_modules_files_folders_urls/tmpl/default_toolbar.php deleted file mode 100644 index 0cc4eef9a..000000000 --- a/admin/views/joomla_modules_files_folders_urls/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/joomla_modules_files_folders_urls/view.html.php b/admin/views/joomla_modules_files_folders_urls/view.html.php deleted file mode 100644 index ef7c4e34e..000000000 --- a/admin/views/joomla_modules_files_folders_urls/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Joomla_modules_files_folders_urls - */ -class ComponentbuilderViewJoomla_modules_files_folders_urls extends HtmlView -{ - /** - * Joomla_modules_files_folders_urls view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('joomla_modules_files_folders_urls'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('joomla_module_files_folders_urls'); - $this->canEdit = $this->canDo->get('joomla_module_files_folders_urls.edit'); - $this->canState = $this->canDo->get('joomla_module_files_folders_urls.edit.state'); - $this->canCreate = $this->canDo->get('joomla_module_files_folders_urls.create'); - $this->canDelete = $this->canDo->get('joomla_module_files_folders_urls.delete'); - $this->canBatch = ($this->canDo->get('joomla_module_files_folders_urls.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_JOOMLA_MODULES_FILES_FOLDERS_URLS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=joomla_modules_files_folders_urls'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('joomla_module_files_folders_urls.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('joomla_module_files_folders_urls.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('joomla_modules_files_folders_urls.publish'); - JToolBarHelper::unpublishList('joomla_modules_files_folders_urls.unpublish'); - JToolBarHelper::archiveList('joomla_modules_files_folders_urls.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('joomla_modules_files_folders_urls.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'joomla_modules_files_folders_urls.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('joomla_modules_files_folders_urls.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_modules_files_folders_urls'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_JOOMLA_MODULES_FILES_FOLDERS_URLS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/joomla_modules_files_folders_urls.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/joomla_modules_updates/tmpl/default.php b/admin/views/joomla_modules_updates/tmpl/default.php deleted file mode 100644 index 246614dd5..000000000 --- a/admin/views/joomla_modules_updates/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=joomla_modules_updates.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'joomla_module_updatesList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/joomla_modules_updates/tmpl/default_batch_body.php b/admin/views/joomla_modules_updates/tmpl/default_batch_body.php deleted file mode 100644 index d46f11823..000000000 --- a/admin/views/joomla_modules_updates/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/joomla_modules_updates/tmpl/default_batch_footer.php b/admin/views/joomla_modules_updates/tmpl/default_batch_footer.php deleted file mode 100644 index 9a3f18843..000000000 --- a/admin/views/joomla_modules_updates/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/joomla_modules_updates/tmpl/default_body.php b/admin/views/joomla_modules_updates/tmpl/default_body.php deleted file mode 100644 index c50324b3e..000000000 --- a/admin/views/joomla_modules_updates/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=joomla_modules_updates&task=joomla_module_updates.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('joomla_module_updates',$item,'joomla_modules_updates'); - ?> - - - get('joomla_module_updates.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('joomla_module_updates.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('joomla_module_updates.edit')): ?> - escape($item->joomla_module_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'joomla_modules_updates.', $canCheckin); ?> - - - escape($item->joomla_module_system_name); ?> - -
    - - - get('joomla_module_updates.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'joomla_modules_updates.', true, 'cb'); ?> - - published, $i, 'joomla_modules_updates.', false, 'cb'); ?> - - - published, $i, 'joomla_modules_updates.', true, 'cb'); ?> - - - published, $i, 'joomla_modules_updates.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/joomla_modules_updates/tmpl/default_foot.php b/admin/views/joomla_modules_updates/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/joomla_modules_updates/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/joomla_modules_updates/tmpl/default_head.php b/admin/views/joomla_modules_updates/tmpl/default_head.php deleted file mode 100644 index 85c5c902a..000000000 --- a/admin/views/joomla_modules_updates/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/joomla_modules_updates/tmpl/default_toolbar.php b/admin/views/joomla_modules_updates/tmpl/default_toolbar.php deleted file mode 100644 index 2a2f01f41..000000000 --- a/admin/views/joomla_modules_updates/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/joomla_modules_updates/view.html.php b/admin/views/joomla_modules_updates/view.html.php deleted file mode 100644 index da3e8a64f..000000000 --- a/admin/views/joomla_modules_updates/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Joomla_modules_updates - */ -class ComponentbuilderViewJoomla_modules_updates extends HtmlView -{ - /** - * Joomla_modules_updates view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('joomla_modules_updates'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('joomla_module_updates'); - $this->canEdit = $this->canDo->get('joomla_module_updates.edit'); - $this->canState = $this->canDo->get('joomla_module_updates.edit.state'); - $this->canCreate = $this->canDo->get('joomla_module_updates.create'); - $this->canDelete = $this->canDo->get('joomla_module_updates.delete'); - $this->canBatch = ($this->canDo->get('joomla_module_updates.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=joomla_modules_updates'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('joomla_module_updates.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('joomla_module_updates.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('joomla_modules_updates.publish'); - JToolBarHelper::unpublishList('joomla_modules_updates.unpublish'); - JToolBarHelper::archiveList('joomla_modules_updates.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('joomla_modules_updates.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'joomla_modules_updates.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('joomla_modules_updates.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_modules_updates'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_JOOMLA_MODULES_UPDATES')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/joomla_modules_updates.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/joomla_plugin/submitbutton.js b/admin/views/joomla_plugin/submitbutton.js deleted file mode 100644 index f078a60c1..000000000 --- a/admin/views/joomla_plugin/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('joomla_plugin, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/joomla_plugin/tmpl/edit.php b/admin/views/joomla_plugin/tmpl/edit.php deleted file mode 100644 index 3e0069787..000000000 --- a/admin/views/joomla_plugin/tmpl/edit.php +++ /dev/null @@ -1,657 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/joomla_plugin/view.html.php b/admin/views/joomla_plugin/view.html.php deleted file mode 100644 index e148e064b..000000000 --- a/admin/views/joomla_plugin/view.html.php +++ /dev/null @@ -1,293 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; -use VDM\Joomla\Utilities\ArrayHelper; - -/** - * Joomla_plugin Html View class - */ -class ComponentbuilderViewJoomla_plugin extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('joomla_plugin.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('joomla_plugin.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('joomla_plugin.edit')) - { - // We can save the record. - JToolBarHelper::save('joomla_plugin.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('joomla_plugin.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('joomla_plugin.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('joomla_plugin.create')) - { - JToolBarHelper::apply('joomla_plugin.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('joomla_plugin.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('joomla_plugin.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('joomla_plugin.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('joomla_plugin.edit')) - { - // We can save the new record - JToolBarHelper::apply('joomla_plugin.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('joomla_plugin.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('joomla_plugin.create')) - { - JToolBarHelper::custom('joomla_plugin.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('joomla_plugin.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('joomla_plugin.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.joomla_plugin', $this->item->id); - } - if ($this->canDo->get('joomla_plugin.create')) - { - JToolBarHelper::custom('joomla_plugin.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('joomla_plugin.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_plugin'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/joomla_plugin.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/joomla_plugin/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - // Add the JavaScript for JStore - $this->document->addScript(JURI::root() .'media/com_componentbuilder/js/jquery.json.min.js'); - $this->document->addScript(JURI::root() .'media/com_componentbuilder/js/jstorage.min.js'); - $this->document->addScript(JURI::root() .'media/com_componentbuilder/js/strtotime.js'); - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - // set some lang - JText::script('COM_COMPONENTBUILDER_ALREADY_SELECTED_TRY_ANOTHER'); - JText::script('COM_COMPONENTBUILDER_TYPE_OR_SELECT_SOME_OPTIONS'); - JText::script('COM_COMPONENTBUILDER_NO_RESULTS_MATCH'); - JText::script('COM_COMPONENTBUILDER_SELECT_A_PROPERTY'); - JText::script('COM_COMPONENTBUILDER_NO_DESCRIPTION_FOUND'); - // check if we should use browser storage - $setBrowserStorage = $this->params->get('set_browser_storage', null); - if ($setBrowserStorage) - { - // check what (Time To Live) show we use - $storageTimeToLive = $this->params->get('storage_time_to_live', 'global'); - if ('global' == $storageTimeToLive) - { - // use the global session time - $session = JFactory::getSession(); - // must have itin milliseconds - $expire = ($session->getExpire()*60)* 1000; - } - else - { - // use the Componentbuilder Global setting - if (0 != $storageTimeToLive) - { - // this will convert the time into milliseconds - $storageTimeToLive = $storageTimeToLive * 1000; - } - $expire = $storageTimeToLive; - } - } - else - { - // set to use no storage - $expire = 30000; // only 30 seconds - } - // Set the Time To Live To JavaScript - $this->document->addScriptDeclaration("var expire = ". (int) $expire.";"); - $this->document->addScriptDeclaration("selectionArray = {'property':{},'method':{}};"); - // add a few field options via PHP - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - $tmp_ = JFormHelper::loadFieldType('joomlaplugingroups')->options; - if (ArrayHelper::check($tmp_)) - { - $_tmp = array(); - foreach ($tmp_ as $item) - { - $_tmp[$item->value] = $item->text; - } - // Set the values to JavaScript - $this->document->addScriptDeclaration("selectionArray['joomla_plugin_group'] = ". json_encode($_tmp) . ";"); - } - $tmp_ = JFormHelper::loadFieldType('pluginsclassproperties')->options; - if (ArrayHelper::check($tmp_)) - { - $_tmp = array(); - foreach ($tmp_ as $item) - { - $_tmp[$item->value] = $item->text; - } - // Set the values to JavaScript - $this->document->addScriptDeclaration("selectionArray['property'] = ". json_encode($_tmp) . ";"); - } - $tmp_ = JFormHelper::loadFieldType('pluginsclassmethods')->options; - if (ArrayHelper::check($tmp_)) - { - $_tmp = array(); - foreach ($tmp_ as $item) - { - $_tmp[$item->value] = $item->text; - } - // Set the values to JavaScript - $this->document->addScriptDeclaration("selectionArray['method'] = ". json_encode($_tmp) . ";"); - } - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/joomla_plugin_files_folders_urls/submitbutton.js b/admin/views/joomla_plugin_files_folders_urls/submitbutton.js deleted file mode 100644 index c08fe1b77..000000000 --- a/admin/views/joomla_plugin_files_folders_urls/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('joomla_plugin_files_folders_urls, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/joomla_plugin_files_folders_urls/tmpl/edit.php b/admin/views/joomla_plugin_files_folders_urls/tmpl/edit.php deleted file mode 100644 index b0a8399c7..000000000 --- a/admin/views/joomla_plugin_files_folders_urls/tmpl/edit.php +++ /dev/null @@ -1,115 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - diff --git a/admin/views/joomla_plugin_files_folders_urls/view.html.php b/admin/views/joomla_plugin_files_folders_urls/view.html.php deleted file mode 100644 index c865920c1..000000000 --- a/admin/views/joomla_plugin_files_folders_urls/view.html.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Joomla_plugin_files_folders_urls Html View class - */ -class ComponentbuilderViewJoomla_plugin_files_folders_urls extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_files_folders_urls', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('joomla_plugin_files_folders_urls.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('joomla_plugin_files_folders_urls.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('joomla_plugin_files_folders_urls.edit')) - { - // We can save the record. - JToolBarHelper::save('joomla_plugin_files_folders_urls.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('joomla_plugin_files_folders_urls.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('joomla_plugin_files_folders_urls.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('joomla_plugin_files_folders_urls.create')) - { - JToolBarHelper::apply('joomla_plugin_files_folders_urls.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('joomla_plugin_files_folders_urls.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('joomla_plugin_files_folders_urls.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('joomla_plugin_files_folders_urls.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('joomla_plugin_files_folders_urls.edit')) - { - // We can save the new record - JToolBarHelper::apply('joomla_plugin_files_folders_urls.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('joomla_plugin_files_folders_urls.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('joomla_plugin_files_folders_urls.create')) - { - JToolBarHelper::custom('joomla_plugin_files_folders_urls.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('joomla_plugin_files_folders_urls.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('joomla_plugin_files_folders_urls.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.joomla_plugin_files_folders_urls', $this->item->id); - } - if ($this->canDo->get('joomla_plugin_files_folders_urls.create')) - { - JToolBarHelper::custom('joomla_plugin_files_folders_urls.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('joomla_plugin_files_folders_urls.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_plugin_files_folders_urls'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/joomla_plugin_files_folders_urls.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/joomla_plugin_files_folders_urls/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/joomla_plugin_group/submitbutton.js b/admin/views/joomla_plugin_group/submitbutton.js deleted file mode 100644 index fc92b25a1..000000000 --- a/admin/views/joomla_plugin_group/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('joomla_plugin_group, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/joomla_plugin_group/tmpl/edit.php b/admin/views/joomla_plugin_group/tmpl/edit.php deleted file mode 100644 index d872ebf0f..000000000 --- a/admin/views/joomla_plugin_group/tmpl/edit.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - diff --git a/admin/views/joomla_plugin_group/view.html.php b/admin/views/joomla_plugin_group/view.html.php deleted file mode 100644 index 64dc53935..000000000 --- a/admin/views/joomla_plugin_group/view.html.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Joomla_plugin_group Html View class - */ -class ComponentbuilderViewJoomla_plugin_group extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_group', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('core.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('joomla_plugin_group.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('core.edit')) - { - // We can save the record. - JToolBarHelper::save('joomla_plugin_group.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('joomla_plugin_group.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('joomla_plugin_group.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('core.create')) - { - JToolBarHelper::apply('joomla_plugin_group.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('joomla_plugin_group.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('joomla_plugin_group.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('joomla_plugin_group.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('core.edit')) - { - // We can save the new record - JToolBarHelper::apply('joomla_plugin_group.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('joomla_plugin_group.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('core.create')) - { - JToolBarHelper::custom('joomla_plugin_group.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('joomla_plugin_group.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('core.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.joomla_plugin_group', $this->item->id); - } - if ($this->canDo->get('core.create')) - { - JToolBarHelper::custom('joomla_plugin_group.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('joomla_plugin_group.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_plugin_group'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/joomla_plugin_group.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/joomla_plugin_group/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/joomla_plugin_groups/tmpl/default.php b/admin/views/joomla_plugin_groups/tmpl/default.php deleted file mode 100644 index b349b2fb9..000000000 --- a/admin/views/joomla_plugin_groups/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=joomla_plugin_groups.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'joomla_plugin_groupList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUPS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/joomla_plugin_groups/tmpl/default_batch_body.php b/admin/views/joomla_plugin_groups/tmpl/default_batch_body.php deleted file mode 100644 index 91c0e4888..000000000 --- a/admin/views/joomla_plugin_groups/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/joomla_plugin_groups/tmpl/default_batch_footer.php b/admin/views/joomla_plugin_groups/tmpl/default_batch_footer.php deleted file mode 100644 index 7d1f1168e..000000000 --- a/admin/views/joomla_plugin_groups/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/joomla_plugin_groups/tmpl/default_body.php b/admin/views/joomla_plugin_groups/tmpl/default_body.php deleted file mode 100644 index 4aaae4478..000000000 --- a/admin/views/joomla_plugin_groups/tmpl/default_body.php +++ /dev/null @@ -1,100 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=joomla_plugin_groups&task=joomla_plugin_group.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('joomla_plugin_group',$item,'joomla_plugin_groups'); - ?> - - - get('core.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('core.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('core.edit')): ?> - escape($item->name); ?> - checked_out): ?> - name, $item->checked_out_time, 'joomla_plugin_groups.', $canCheckin); ?> - - - escape($item->name); ?> - -
    - - -
    - user->authorise('class_extends.edit', 'com_componentbuilder.class_extends.' . (int) $item->class_extends)): ?> - escape($item->class_extends_name); ?> - - escape($item->class_extends_name); ?> - -
    - - - get('core.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'joomla_plugin_groups.', true, 'cb'); ?> - - published, $i, 'joomla_plugin_groups.', false, 'cb'); ?> - - - published, $i, 'joomla_plugin_groups.', true, 'cb'); ?> - - - published, $i, 'joomla_plugin_groups.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/joomla_plugin_groups/tmpl/default_foot.php b/admin/views/joomla_plugin_groups/tmpl/default_foot.php deleted file mode 100644 index 95317c3bb..000000000 --- a/admin/views/joomla_plugin_groups/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/joomla_plugin_groups/tmpl/default_head.php b/admin/views/joomla_plugin_groups/tmpl/default_head.php deleted file mode 100644 index 5d1aee41a..000000000 --- a/admin/views/joomla_plugin_groups/tmpl/default_head.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/joomla_plugin_groups/tmpl/default_toolbar.php b/admin/views/joomla_plugin_groups/tmpl/default_toolbar.php deleted file mode 100644 index 3e623ce92..000000000 --- a/admin/views/joomla_plugin_groups/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/joomla_plugin_groups/view.html.php b/admin/views/joomla_plugin_groups/view.html.php deleted file mode 100644 index 04539db20..000000000 --- a/admin/views/joomla_plugin_groups/view.html.php +++ /dev/null @@ -1,242 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Joomla_plugin_groups - */ -class ComponentbuilderViewJoomla_plugin_groups extends HtmlView -{ - /** - * Joomla_plugin_groups view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('joomla_plugin_groups'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_group'); - $this->canEdit = $this->canDo->get('core.edit'); - $this->canState = $this->canDo->get('core.edit.state'); - $this->canCreate = $this->canDo->get('core.create'); - $this->canDelete = $this->canDo->get('core.delete'); - $this->canBatch = ($this->canDo->get('joomla_plugin_group.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUPS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=joomla_plugin_groups'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('joomla_plugin_group.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('joomla_plugin_group.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('joomla_plugin_groups.publish'); - JToolBarHelper::unpublishList('joomla_plugin_groups.unpublish'); - JToolBarHelper::archiveList('joomla_plugin_groups.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('joomla_plugin_groups.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'joomla_plugin_groups.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('joomla_plugin_groups.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_plugin_groups'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - - // Only load Class Extends Name batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Class Extends Name Selection - $this->class_extendsNameOptions = JFormHelper::loadFieldType('Classextends')->options; - // We do some sanitation for Class Extends Name filter - if (ComponentbuilderHelper::checkArray($this->class_extendsNameOptions) && - isset($this->class_extendsNameOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->class_extendsNameOptions[0]->value)) - { - unset($this->class_extendsNameOptions[0]); - } - // Class Extends Name Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_CLASS_EXTENDS_LABEL').' -', - 'batch[class_extends]', - JHtml::_('select.options', $this->class_extendsNameOptions, 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUPS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/joomla_plugin_groups.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.name' => JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_NAME_LABEL'), - 'g.name' => JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP_CLASS_EXTENDS_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/joomla_plugin_updates/submitbutton.js b/admin/views/joomla_plugin_updates/submitbutton.js deleted file mode 100644 index 38837cdec..000000000 --- a/admin/views/joomla_plugin_updates/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('joomla_plugin_updates, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/joomla_plugin_updates/tmpl/edit.php b/admin/views/joomla_plugin_updates/tmpl/edit.php deleted file mode 100644 index 0e7951443..000000000 --- a/admin/views/joomla_plugin_updates/tmpl/edit.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - diff --git a/admin/views/joomla_plugin_updates/view.html.php b/admin/views/joomla_plugin_updates/view.html.php deleted file mode 100644 index ac27291ff..000000000 --- a/admin/views/joomla_plugin_updates/view.html.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Joomla_plugin_updates Html View class - */ -class ComponentbuilderViewJoomla_plugin_updates extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_updates', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('joomla_plugin_updates.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('joomla_plugin_updates.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('joomla_plugin_updates.edit')) - { - // We can save the record. - JToolBarHelper::save('joomla_plugin_updates.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('joomla_plugin_updates.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('joomla_plugin_updates.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('joomla_plugin_updates.create')) - { - JToolBarHelper::apply('joomla_plugin_updates.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('joomla_plugin_updates.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('joomla_plugin_updates.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('joomla_plugin_updates.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('joomla_plugin_updates.edit')) - { - // We can save the new record - JToolBarHelper::apply('joomla_plugin_updates.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('joomla_plugin_updates.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('joomla_plugin_updates.create')) - { - JToolBarHelper::custom('joomla_plugin_updates.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('joomla_plugin_updates.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('joomla_plugin_updates.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.joomla_plugin_updates', $this->item->id); - } - if ($this->canDo->get('joomla_plugin_updates.create')) - { - JToolBarHelper::custom('joomla_plugin_updates.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('joomla_plugin_updates.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_plugin_updates'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_NEW' : 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/joomla_plugin_updates.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/joomla_plugin_updates/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/joomla_plugins/tmpl/default.php b/admin/views/joomla_plugins/tmpl/default.php deleted file mode 100644 index 1947e1002..000000000 --- a/admin/views/joomla_plugins/tmpl/default.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=joomla_plugins.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'joomla_pluginList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGINS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - - diff --git a/admin/views/joomla_plugins/tmpl/default_batch_body.php b/admin/views/joomla_plugins/tmpl/default_batch_body.php deleted file mode 100644 index 6403aceae..000000000 --- a/admin/views/joomla_plugins/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/joomla_plugins/tmpl/default_batch_footer.php b/admin/views/joomla_plugins/tmpl/default_batch_footer.php deleted file mode 100644 index 2a5ad07a4..000000000 --- a/admin/views/joomla_plugins/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/joomla_plugins/tmpl/default_body.php b/admin/views/joomla_plugins/tmpl/default_body.php deleted file mode 100644 index 456fe5e3b..000000000 --- a/admin/views/joomla_plugins/tmpl/default_body.php +++ /dev/null @@ -1,139 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); -use VDM\Joomla\Utilities\ArrayHelper; - -$edit = "index.php?option=com_componentbuilder&view=joomla_plugins&task=joomla_plugin.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('joomla_plugin',$item,'joomla_plugins'); - ?> - - - get('joomla_plugin.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('joomla_plugin.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('joomla_plugin.edit')): ?> - escape($item->system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'joomla_plugins.', $canCheckin); ?> - - - escape($item->system_name); ?> - - - escape($item->plugin_version); ?> -
    - 'joomla_plugin_updates', - 'views' => 'joomla_plugins_updates', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_PLUGIN_UPDATES'), - 'icon' => 'database'), - array( - 'view' => 'joomla_plugin_files_folders_urls', - 'views' => 'joomla_plugins_files_folders_urls', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_PLUGIN_FILES_FOLDERS'), - 'icon' => 'briefcase') - ); - } - ?> -
    - - get($_button['view'].'.edit') && ($id = ComponentbuilderHelper::getVar($_button['view'], $item->id, 'joomla_plugin', 'id')) !== false): ?> - - get($_button['view'].'.create')): ?> - - - -
    - - -
    - user->authorise('class_extends.edit', 'com_componentbuilder.class_extends.' . (int) $item->class_extends)): ?> - escape($item->class_extends_name); ?> - - escape($item->class_extends_name); ?> - -
    - - -
    - user->authorise('core.edit', 'com_componentbuilder.joomla_plugin_group.' . (int) $item->joomla_plugin_group)): ?> - escape($item->joomla_plugin_group_name); ?> - - escape($item->joomla_plugin_group_name); ?> - -
    - - - get('joomla_plugin.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'joomla_plugins.', true, 'cb'); ?> - - published, $i, 'joomla_plugins.', false, 'cb'); ?> - - - published, $i, 'joomla_plugins.', true, 'cb'); ?> - - - published, $i, 'joomla_plugins.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/joomla_plugins/tmpl/default_foot.php b/admin/views/joomla_plugins/tmpl/default_foot.php deleted file mode 100644 index eff41e725..000000000 --- a/admin/views/joomla_plugins/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/joomla_plugins/tmpl/default_head.php b/admin/views/joomla_plugins/tmpl/default_head.php deleted file mode 100644 index f4f403c60..000000000 --- a/admin/views/joomla_plugins/tmpl/default_head.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/joomla_plugins/tmpl/default_toolbar.php b/admin/views/joomla_plugins/tmpl/default_toolbar.php deleted file mode 100644 index cc0c41ca1..000000000 --- a/admin/views/joomla_plugins/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/joomla_plugins/view.html.php b/admin/views/joomla_plugins/view.html.php deleted file mode 100644 index 97db42891..000000000 --- a/admin/views/joomla_plugins/view.html.php +++ /dev/null @@ -1,283 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Joomla_plugins - */ -class ComponentbuilderViewJoomla_plugins extends HtmlView -{ - /** - * Joomla_plugins view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('joomla_plugins'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin'); - $this->canEdit = $this->canDo->get('joomla_plugin.edit'); - $this->canState = $this->canDo->get('joomla_plugin.edit.state'); - $this->canCreate = $this->canDo->get('joomla_plugin.create'); - $this->canDelete = $this->canDo->get('joomla_plugin.delete'); - $this->canBatch = ($this->canDo->get('joomla_plugin.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGINS'), 'power-cord'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=joomla_plugins'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('joomla_plugin.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('joomla_plugin.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('joomla_plugins.publish'); - JToolBarHelper::unpublishList('joomla_plugins.unpublish'); - JToolBarHelper::archiveList('joomla_plugins.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('joomla_plugins.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'joomla_plugins.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('joomla_plugins.trash'); - } - } - if ($this->user->authorise('joomla_plugin.run_expansion', 'com_componentbuilder')) - { - // add Run Expansion button. - JToolBarHelper::custom('joomla_plugins.runExpansion', 'expand-2 custom-button-runexpansion', '', 'COM_COMPONENTBUILDER_RUN_EXPANSION', false); - } - if ($this->user->authorise('joomla_plugin.get_boilerplate', 'com_componentbuilder')) - { - // add Get Boilerplate button. - JToolBarHelper::custom('joomla_plugins.getBoilerplate', 'joomla custom-button-getboilerplate', '', 'COM_COMPONENTBUILDER_GET_BOILERPLATE', false); - } - if ($this->user->authorise('joomla_plugin.methods', 'com_componentbuilder')) - { - // add Methods button. - JToolBarHelper::custom('joomla_plugins.openClassMethods', 'joomla custom-button-openclassmethods', '', 'COM_COMPONENTBUILDER_METHODS', false); - } - if ($this->user->authorise('joomla_plugin.properties', 'com_componentbuilder')) - { - // add Properties button. - JToolBarHelper::custom('joomla_plugins.openClassProperties', 'joomla custom-button-openclassproperties', '', 'COM_COMPONENTBUILDER_PROPERTIES', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_plugins'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - - // Only load Class Extends Name batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Class Extends Name Selection - $this->class_extendsNameOptions = JFormHelper::loadFieldType('Classextends')->options; - // We do some sanitation for Class Extends Name filter - if (ComponentbuilderHelper::checkArray($this->class_extendsNameOptions) && - isset($this->class_extendsNameOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->class_extendsNameOptions[0]->value)) - { - unset($this->class_extendsNameOptions[0]); - } - // Class Extends Name Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_CLASS_EXTENDS_LABEL').' -', - 'batch[class_extends]', - JHtml::_('select.options', $this->class_extendsNameOptions, 'value', 'text') - ); - } - - // Only load Joomla Plugin Group Name batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Joomla Plugin Group Name Selection - $this->joomla_plugin_groupNameOptions = JFormHelper::loadFieldType('Joomlaplugingroups')->options; - // We do some sanitation for Joomla Plugin Group Name filter - if (ComponentbuilderHelper::checkArray($this->joomla_plugin_groupNameOptions) && - isset($this->joomla_plugin_groupNameOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->joomla_plugin_groupNameOptions[0]->value)) - { - unset($this->joomla_plugin_groupNameOptions[0]); - } - // Joomla Plugin Group Name Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_JOOMLA_PLUGIN_GROUP_LABEL').' -', - 'batch[joomla_plugin_group]', - JHtml::_('select.options', $this->joomla_plugin_groupNameOptions, 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGINS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/joomla_plugins.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.system_name' => JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_SYSTEM_NAME_LABEL'), - 'g.name' => JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_CLASS_EXTENDS_LABEL'), - 'h.name' => JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_JOOMLA_PLUGIN_GROUP_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/joomla_plugins_files_folders_urls/tmpl/default.php b/admin/views/joomla_plugins_files_folders_urls/tmpl/default.php deleted file mode 100644 index 47e3be557..000000000 --- a/admin/views/joomla_plugins_files_folders_urls/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=joomla_plugins_files_folders_urls.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'joomla_plugin_files_folders_urlsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/joomla_plugins_files_folders_urls/tmpl/default_batch_body.php b/admin/views/joomla_plugins_files_folders_urls/tmpl/default_batch_body.php deleted file mode 100644 index f506921e6..000000000 --- a/admin/views/joomla_plugins_files_folders_urls/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/joomla_plugins_files_folders_urls/tmpl/default_batch_footer.php b/admin/views/joomla_plugins_files_folders_urls/tmpl/default_batch_footer.php deleted file mode 100644 index 32e0f688e..000000000 --- a/admin/views/joomla_plugins_files_folders_urls/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/joomla_plugins_files_folders_urls/tmpl/default_body.php b/admin/views/joomla_plugins_files_folders_urls/tmpl/default_body.php deleted file mode 100644 index 8a6a6f844..000000000 --- a/admin/views/joomla_plugins_files_folders_urls/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=joomla_plugins_files_folders_urls&task=joomla_plugin_files_folders_urls.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('joomla_plugin_files_folders_urls',$item,'joomla_plugins_files_folders_urls'); - ?> - - - get('joomla_plugin_files_folders_urls.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('joomla_plugin_files_folders_urls.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('joomla_plugin_files_folders_urls.edit')): ?> - escape($item->joomla_plugin_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'joomla_plugins_files_folders_urls.', $canCheckin); ?> - - - escape($item->joomla_plugin_system_name); ?> - -
    - - - get('joomla_plugin_files_folders_urls.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'joomla_plugins_files_folders_urls.', true, 'cb'); ?> - - published, $i, 'joomla_plugins_files_folders_urls.', false, 'cb'); ?> - - - published, $i, 'joomla_plugins_files_folders_urls.', true, 'cb'); ?> - - - published, $i, 'joomla_plugins_files_folders_urls.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/joomla_plugins_files_folders_urls/tmpl/default_foot.php b/admin/views/joomla_plugins_files_folders_urls/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/joomla_plugins_files_folders_urls/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/joomla_plugins_files_folders_urls/tmpl/default_head.php b/admin/views/joomla_plugins_files_folders_urls/tmpl/default_head.php deleted file mode 100644 index 75d5c8a71..000000000 --- a/admin/views/joomla_plugins_files_folders_urls/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/joomla_plugins_files_folders_urls/tmpl/default_toolbar.php b/admin/views/joomla_plugins_files_folders_urls/tmpl/default_toolbar.php deleted file mode 100644 index c6e81769a..000000000 --- a/admin/views/joomla_plugins_files_folders_urls/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/joomla_plugins_files_folders_urls/view.html.php b/admin/views/joomla_plugins_files_folders_urls/view.html.php deleted file mode 100644 index d04b33cce..000000000 --- a/admin/views/joomla_plugins_files_folders_urls/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Joomla_plugins_files_folders_urls - */ -class ComponentbuilderViewJoomla_plugins_files_folders_urls extends HtmlView -{ - /** - * Joomla_plugins_files_folders_urls view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('joomla_plugins_files_folders_urls'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_files_folders_urls'); - $this->canEdit = $this->canDo->get('joomla_plugin_files_folders_urls.edit'); - $this->canState = $this->canDo->get('joomla_plugin_files_folders_urls.edit.state'); - $this->canCreate = $this->canDo->get('joomla_plugin_files_folders_urls.create'); - $this->canDelete = $this->canDo->get('joomla_plugin_files_folders_urls.delete'); - $this->canBatch = ($this->canDo->get('joomla_plugin_files_folders_urls.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=joomla_plugins_files_folders_urls'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('joomla_plugin_files_folders_urls.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('joomla_plugin_files_folders_urls.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('joomla_plugins_files_folders_urls.publish'); - JToolBarHelper::unpublishList('joomla_plugins_files_folders_urls.unpublish'); - JToolBarHelper::archiveList('joomla_plugins_files_folders_urls.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('joomla_plugins_files_folders_urls.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'joomla_plugins_files_folders_urls.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('joomla_plugins_files_folders_urls.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_plugins_files_folders_urls'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGINS_FILES_FOLDERS_URLS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/joomla_plugins_files_folders_urls.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/joomla_plugins_updates/tmpl/default.php b/admin/views/joomla_plugins_updates/tmpl/default.php deleted file mode 100644 index a526ebc8a..000000000 --- a/admin/views/joomla_plugins_updates/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=joomla_plugins_updates.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'joomla_plugin_updatesList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/joomla_plugins_updates/tmpl/default_batch_body.php b/admin/views/joomla_plugins_updates/tmpl/default_batch_body.php deleted file mode 100644 index e91855470..000000000 --- a/admin/views/joomla_plugins_updates/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/joomla_plugins_updates/tmpl/default_batch_footer.php b/admin/views/joomla_plugins_updates/tmpl/default_batch_footer.php deleted file mode 100644 index d12431355..000000000 --- a/admin/views/joomla_plugins_updates/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/joomla_plugins_updates/tmpl/default_body.php b/admin/views/joomla_plugins_updates/tmpl/default_body.php deleted file mode 100644 index 7e9e2cfbb..000000000 --- a/admin/views/joomla_plugins_updates/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=joomla_plugins_updates&task=joomla_plugin_updates.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('joomla_plugin_updates',$item,'joomla_plugins_updates'); - ?> - - - get('joomla_plugin_updates.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('joomla_plugin_updates.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('joomla_plugin_updates.edit')): ?> - escape($item->joomla_plugin_system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'joomla_plugins_updates.', $canCheckin); ?> - - - escape($item->joomla_plugin_system_name); ?> - -
    - - - get('joomla_plugin_updates.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'joomla_plugins_updates.', true, 'cb'); ?> - - published, $i, 'joomla_plugins_updates.', false, 'cb'); ?> - - - published, $i, 'joomla_plugins_updates.', true, 'cb'); ?> - - - published, $i, 'joomla_plugins_updates.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/joomla_plugins_updates/tmpl/default_foot.php b/admin/views/joomla_plugins_updates/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/joomla_plugins_updates/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/joomla_plugins_updates/tmpl/default_head.php b/admin/views/joomla_plugins_updates/tmpl/default_head.php deleted file mode 100644 index e9e16ff9a..000000000 --- a/admin/views/joomla_plugins_updates/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/joomla_plugins_updates/tmpl/default_toolbar.php b/admin/views/joomla_plugins_updates/tmpl/default_toolbar.php deleted file mode 100644 index 2168a1ddb..000000000 --- a/admin/views/joomla_plugins_updates/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/joomla_plugins_updates/view.html.php b/admin/views/joomla_plugins_updates/view.html.php deleted file mode 100644 index dafb65471..000000000 --- a/admin/views/joomla_plugins_updates/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Joomla_plugins_updates - */ -class ComponentbuilderViewJoomla_plugins_updates extends HtmlView -{ - /** - * Joomla_plugins_updates view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('joomla_plugins_updates'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('joomla_plugin_updates'); - $this->canEdit = $this->canDo->get('joomla_plugin_updates.edit'); - $this->canState = $this->canDo->get('joomla_plugin_updates.edit.state'); - $this->canCreate = $this->canDo->get('joomla_plugin_updates.create'); - $this->canDelete = $this->canDo->get('joomla_plugin_updates.delete'); - $this->canBatch = ($this->canDo->get('joomla_plugin_updates.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=joomla_plugins_updates'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('joomla_plugin_updates.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('joomla_plugin_updates.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('joomla_plugins_updates.publish'); - JToolBarHelper::unpublishList('joomla_plugins_updates.unpublish'); - JToolBarHelper::archiveList('joomla_plugins_updates.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('joomla_plugins_updates.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'joomla_plugins_updates.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('joomla_plugins_updates.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('joomla_plugins_updates'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGINS_UPDATES')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/joomla_plugins_updates.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/language/submitbutton.js b/admin/views/language/submitbutton.js deleted file mode 100644 index ae9a69f29..000000000 --- a/admin/views/language/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('language, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/language/tmpl/edit.php b/admin/views/language/tmpl/edit.php deleted file mode 100644 index 200ef98a2..000000000 --- a/admin/views/language/tmpl/edit.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - diff --git a/admin/views/language/view.html.php b/admin/views/language/view.html.php deleted file mode 100644 index 0e2a338ef..000000000 --- a/admin/views/language/view.html.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Language Html View class - */ -class ComponentbuilderViewLanguage extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('language', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_LANGUAGE_NEW' : 'COM_COMPONENTBUILDER_LANGUAGE_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('language.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('language.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('language.edit')) - { - // We can save the record. - JToolBarHelper::save('language.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('language.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('language.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('language.create')) - { - JToolBarHelper::apply('language.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('language.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('language.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('language.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('language.edit')) - { - // We can save the new record - JToolBarHelper::apply('language.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('language.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('language.create')) - { - JToolBarHelper::custom('language.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('language.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('language.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.language', $this->item->id); - } - if ($this->canDo->get('language.create')) - { - JToolBarHelper::custom('language.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('language.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('language'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_LANGUAGE_NEW' : 'COM_COMPONENTBUILDER_LANGUAGE_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/language.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/language/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/language_translation/submitbutton.js b/admin/views/language_translation/submitbutton.js deleted file mode 100644 index 187881e5c..000000000 --- a/admin/views/language_translation/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('language_translation, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/language_translation/tmpl/edit.php b/admin/views/language_translation/tmpl/edit.php deleted file mode 100644 index d6cac3dcb..000000000 --- a/admin/views/language_translation/tmpl/edit.php +++ /dev/null @@ -1,127 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/language_translation/view.html.php b/admin/views/language_translation/view.html.php deleted file mode 100644 index ee847122b..000000000 --- a/admin/views/language_translation/view.html.php +++ /dev/null @@ -1,208 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Language_translation Html View class - */ -class ComponentbuilderViewLanguage_translation extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('language_translation', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_NEW' : 'COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('language_translation.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('language_translation.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('language_translation.edit')) - { - // We can save the record. - JToolBarHelper::save('language_translation.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('language_translation.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('language_translation.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('language_translation.create')) - { - JToolBarHelper::apply('language_translation.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('language_translation.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('language_translation.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('language_translation.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('language_translation.edit')) - { - // We can save the new record - JToolBarHelper::apply('language_translation.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('language_translation.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('language_translation.create')) - { - JToolBarHelper::custom('language_translation.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('language_translation.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('language_translation.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.language_translation', $this->item->id); - } - if ($this->canDo->get('language_translation.create')) - { - JToolBarHelper::custom('language_translation.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('language_translation.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('language_translation'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_NEW' : 'COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/language_translation.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/language_translation/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - // add JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' ); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', 'text/javascript', true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', 'text/javascript', true); - // add the style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' ); - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' ); - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '".$this->get('VDM')."';"); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/language_translations/tmpl/default.php b/admin/views/language_translations/tmpl/default.php deleted file mode 100644 index 3e55d5bf4..000000000 --- a/admin/views/language_translations/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=language_translations.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'language_translationList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/language_translations/tmpl/default_batch_body.php b/admin/views/language_translations/tmpl/default_batch_body.php deleted file mode 100644 index 49c23d7e6..000000000 --- a/admin/views/language_translations/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/language_translations/tmpl/default_batch_footer.php b/admin/views/language_translations/tmpl/default_batch_footer.php deleted file mode 100644 index f81041d77..000000000 --- a/admin/views/language_translations/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/language_translations/tmpl/default_body.php b/admin/views/language_translations/tmpl/default_body.php deleted file mode 100644 index 58b411247..000000000 --- a/admin/views/language_translations/tmpl/default_body.php +++ /dev/null @@ -1,177 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); -use VDM\Joomla\Utilities\JsonHelper; -use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\StringHelper; - -$edit = "index.php?option=com_componentbuilder&view=language_translations&task=language_translation.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('language_translation',$item,'language_translations'); - ?> - - - get('language_translation.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('language_translation.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('language_translation.edit')): ?> - source; ?> - checked_out): ?> - name, $item->checked_out_time, 'language_translations.', $canCheckin); ?> - - - source; ?> - - translation)) - { - $translations = json_decode($item->translation, true); - if (ArrayHelper::check($translations)) - { - foreach ($translations as $language) - { - if (isset($language['translation']) && StringHelper::check($language['translation']) - && isset($language['language']) && StringHelper::check($language['language'])) - { - $langBucket[$language['language']] = $language['language']; - } - } - } - } - // start how many usedin's - $counterUsedin = array(); - // set how many components use this string - if (JsonHelper::check($item->components)) - { - $item->components = json_decode($item->components, true); - } - if (($number = ArrayHelper::check($item->components)) !== false) - { - if ($number == 1) - { - $counterUsedin[] = $number . ' ' . JText::_('COM_COMPONENTBUILDER_COMPONENT'); - } - else - { - $counterUsedin[] = $number . ' ' . JText::_('COM_COMPONENTBUILDER_COMPONENTS'); - } - } - // set how many modules use this string - if (JsonHelper::check($item->modules)) - { - $item->modules = json_decode($item->modules, true); - } - if (($number = ArrayHelper::check($item->modules)) !== false) - { - if ($number == 1) - { - $counterUsedin[] = $number . ' ' . JText::_('COM_COMPONENTBUILDER_MODULE'); - } - else - { - $counterUsedin[] = $number . ' ' . JText::_('COM_COMPONENTBUILDER_MODULES'); - } - } - // set how many plugins use this string - if (JsonHelper::check($item->plugins)) - { - $item->plugins = json_decode($item->plugins, true); - } - if (($number = ArrayHelper::check($item->plugins)) !== false) - { - if ($number == 1) - { - $counterUsedin[] = $number . ' ' . JText::_('COM_COMPONENTBUILDER_PLUGIN'); - } - else - { - $counterUsedin[] = $number . ' ' . JText::_('COM_COMPONENTBUILDER_PLUGINS'); - } - } - // build the numbers - $numbersUsedin = ''; - if (ArrayHelper::check($counterUsedin)) - { - $numbersUsedin = '
    ' . JText::_('COM_COMPONENTBUILDER_USED_IN') . ' ' . implode('
    ', $counterUsedin); - } - // load the languages to the string - if (ArrayHelper::check($langBucket)) - { - echo '
    ' . JText::_('COM_COMPONENTBUILDER_ALREADY_TRANSLATED_INTO') . ' (' . implode(', ', $langBucket) . ')' . $numbersUsedin . ''; - } - else - { - echo '
    (' . JText::_('COM_COMPONENTBUILDER_NOTRANSLATION') . ')' . $numbersUsedin . ''; - } - ?> -
    - - - get('language_translation.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'language_translations.', true, 'cb'); ?> - - published, $i, 'language_translations.', false, 'cb'); ?> - - - published, $i, 'language_translations.', true, 'cb'); ?> - - - published, $i, 'language_translations.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/language_translations/tmpl/default_foot.php b/admin/views/language_translations/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/language_translations/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/language_translations/tmpl/default_head.php b/admin/views/language_translations/tmpl/default_head.php deleted file mode 100644 index 36b321c31..000000000 --- a/admin/views/language_translations/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/language_translations/tmpl/default_toolbar.php b/admin/views/language_translations/tmpl/default_toolbar.php deleted file mode 100644 index a45a14e30..000000000 --- a/admin/views/language_translations/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/language_translations/view.html.php b/admin/views/language_translations/view.html.php deleted file mode 100644 index eef6d9c5f..000000000 --- a/admin/views/language_translations/view.html.php +++ /dev/null @@ -1,231 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Language_translations - */ -class ComponentbuilderViewLanguage_translations extends HtmlView -{ - /** - * Language_translations view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('language_translations'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('language_translation'); - $this->canEdit = $this->canDo->get('language_translation.edit'); - $this->canState = $this->canDo->get('language_translation.edit.state'); - $this->canCreate = $this->canDo->get('language_translation.create'); - $this->canDelete = $this->canDo->get('language_translation.delete'); - $this->canBatch = ($this->canDo->get('language_translation.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS'), 'comments-2'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=language_translations'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('language_translation.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('language_translation.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('language_translations.publish'); - JToolBarHelper::unpublishList('language_translations.unpublish'); - JToolBarHelper::archiveList('language_translations.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('language_translations.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'language_translations.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('language_translations.trash'); - } - - if ($this->canDo->get('core.export') && $this->canDo->get('language_translation.export')) - { - JToolBarHelper::custom('language_translations.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); - } - } - - if ($this->canDo->get('core.import') && $this->canDo->get('language_translation.import')) - { - JToolBarHelper::custom('language_translations.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('language_translations'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_LANGUAGE_TRANSLATIONS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/language_translations.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.source' => JText::_('COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_SOURCE_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/languages/tmpl/default.php b/admin/views/languages/tmpl/default.php deleted file mode 100644 index 4f6c1aa40..000000000 --- a/admin/views/languages/tmpl/default.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=languages.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'languageList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_LANGUAGES_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - - diff --git a/admin/views/languages/tmpl/default_batch_body.php b/admin/views/languages/tmpl/default_batch_body.php deleted file mode 100644 index 2a68eaf19..000000000 --- a/admin/views/languages/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/languages/tmpl/default_batch_footer.php b/admin/views/languages/tmpl/default_batch_footer.php deleted file mode 100644 index db1d83918..000000000 --- a/admin/views/languages/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/languages/tmpl/default_body.php b/admin/views/languages/tmpl/default_body.php deleted file mode 100644 index b9c83d689..000000000 --- a/admin/views/languages/tmpl/default_body.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=languages&task=language.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('language',$item,'languages'); - ?> - - - get('language.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('language.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('language.edit')): ?> - escape($item->name); ?> - checked_out): ?> - name, $item->checked_out_time, 'languages.', $canCheckin); ?> - - - escape($item->name); ?> - -
    - - - escape($item->langtag); ?> - - - get('language.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'languages.', true, 'cb'); ?> - - published, $i, 'languages.', false, 'cb'); ?> - - - published, $i, 'languages.', true, 'cb'); ?> - - - published, $i, 'languages.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/languages/tmpl/default_foot.php b/admin/views/languages/tmpl/default_foot.php deleted file mode 100644 index 95317c3bb..000000000 --- a/admin/views/languages/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/languages/tmpl/default_head.php b/admin/views/languages/tmpl/default_head.php deleted file mode 100644 index e7f971724..000000000 --- a/admin/views/languages/tmpl/default_head.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/languages/tmpl/default_toolbar.php b/admin/views/languages/tmpl/default_toolbar.php deleted file mode 100644 index a96a0c3f1..000000000 --- a/admin/views/languages/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/languages/view.html.php b/admin/views/languages/view.html.php deleted file mode 100644 index 86b8ac1c7..000000000 --- a/admin/views/languages/view.html.php +++ /dev/null @@ -1,237 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Languages - */ -class ComponentbuilderViewLanguages extends HtmlView -{ - /** - * Languages view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('languages'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('language'); - $this->canEdit = $this->canDo->get('language.edit'); - $this->canState = $this->canDo->get('language.edit.state'); - $this->canCreate = $this->canDo->get('language.create'); - $this->canDelete = $this->canDo->get('language.delete'); - $this->canBatch = ($this->canDo->get('language.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_LANGUAGES'), 'comment'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=languages'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('language.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('language.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('languages.publish'); - JToolBarHelper::unpublishList('languages.unpublish'); - JToolBarHelper::archiveList('languages.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('languages.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'languages.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('languages.trash'); - } - - if ($this->canDo->get('core.export') && $this->canDo->get('language.export')) - { - JToolBarHelper::custom('languages.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); - } - } - if ($this->user->authorise('language.build', 'com_componentbuilder')) - { - // add Build button. - JToolBarHelper::custom('languages.buildLanguages', 'joomla custom-button-buildlanguages', '', 'COM_COMPONENTBUILDER_BUILD', false); - } - - if ($this->canDo->get('core.import') && $this->canDo->get('language.import')) - { - JToolBarHelper::custom('languages.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('languages'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_LANGUAGES')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/languages.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.name' => JText::_('COM_COMPONENTBUILDER_LANGUAGE_NAME_LABEL'), - 'a.langtag' => JText::_('COM_COMPONENTBUILDER_LANGUAGE_LANGTAG_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/layout/submitbutton.js b/admin/views/layout/submitbutton.js deleted file mode 100644 index d0f44b6c8..000000000 --- a/admin/views/layout/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('layout, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/layout/tmpl/edit.php b/admin/views/layout/tmpl/edit.php deleted file mode 100644 index 2b9d6aae8..000000000 --- a/admin/views/layout/tmpl/edit.php +++ /dev/null @@ -1,228 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/layout/view.html.php b/admin/views/layout/view.html.php deleted file mode 100644 index a02210e2e..000000000 --- a/admin/views/layout/view.html.php +++ /dev/null @@ -1,215 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Layout Html View class - */ -class ComponentbuilderViewLayout extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('layout', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_LAYOUT_NEW' : 'COM_COMPONENTBUILDER_LAYOUT_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('core.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('layout.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('core.edit')) - { - // We can save the record. - JToolBarHelper::save('layout.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('layout.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('layout.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('core.create')) - { - JToolBarHelper::apply('layout.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('layout.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('layout.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('layout.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('core.edit')) - { - // We can save the new record - JToolBarHelper::apply('layout.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('layout.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('core.create')) - { - JToolBarHelper::custom('layout.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('layout.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('core.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.layout', $this->item->id); - } - if ($this->canDo->get('core.create')) - { - JToolBarHelper::custom('layout.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('layout.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('layout'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_LAYOUT_NEW' : 'COM_COMPONENTBUILDER_LAYOUT_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/layout.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/layout/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/layouts/tmpl/default.php b/admin/views/layouts/tmpl/default.php deleted file mode 100644 index 94d8ba26f..000000000 --- a/admin/views/layouts/tmpl/default.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=layouts.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'layoutList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_LAYOUTS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - - diff --git a/admin/views/layouts/tmpl/default_batch_body.php b/admin/views/layouts/tmpl/default_batch_body.php deleted file mode 100644 index eab4d30bf..000000000 --- a/admin/views/layouts/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/layouts/tmpl/default_batch_footer.php b/admin/views/layouts/tmpl/default_batch_footer.php deleted file mode 100644 index 7eccedde0..000000000 --- a/admin/views/layouts/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/layouts/tmpl/default_body.php b/admin/views/layouts/tmpl/default_body.php deleted file mode 100644 index de4c6499c..000000000 --- a/admin/views/layouts/tmpl/default_body.php +++ /dev/null @@ -1,111 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); -use VDM\Joomla\Utilities\StringHelper; - -$edit = "index.php?option=com_componentbuilder&view=layouts&task=layout.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('layout',$item,'layouts'); - ?> - - - get('core.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('core.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('core.edit')): ?> - escape($item->name); ?> - checked_out): ?> - name, $item->checked_out_time, 'layouts.', $canCheckin); ?> - - - escape($item->name); ?> -
    - <?php echo JLayoutHelper::render('alias); ?>', [?]); ?> -
    - - -
    - escape($item->description); ?> -
      -
    • : - add_php_view); ?>
    • -
    -
    - - -
    - user->authorise('dynamic_get.edit', 'com_componentbuilder.dynamic_get.' . (int) $item->dynamic_get)): ?> - escape($item->dynamic_get_name); ?> - - escape($item->dynamic_get_name); ?> - -
    - - - get('core.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'layouts.', true, 'cb'); ?> - - published, $i, 'layouts.', false, 'cb'); ?> - - - published, $i, 'layouts.', true, 'cb'); ?> - - - published, $i, 'layouts.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/layouts/tmpl/default_foot.php b/admin/views/layouts/tmpl/default_foot.php deleted file mode 100644 index eff41e725..000000000 --- a/admin/views/layouts/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/layouts/tmpl/default_head.php b/admin/views/layouts/tmpl/default_head.php deleted file mode 100644 index 80ddc8de8..000000000 --- a/admin/views/layouts/tmpl/default_head.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/layouts/tmpl/default_toolbar.php b/admin/views/layouts/tmpl/default_toolbar.php deleted file mode 100644 index c331d8ac3..000000000 --- a/admin/views/layouts/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/layouts/view.html.php b/admin/views/layouts/view.html.php deleted file mode 100644 index afcd8cfb0..000000000 --- a/admin/views/layouts/view.html.php +++ /dev/null @@ -1,278 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Layouts - */ -class ComponentbuilderViewLayouts extends HtmlView -{ - /** - * Layouts view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('layouts'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('layout'); - $this->canEdit = $this->canDo->get('core.edit'); - $this->canState = $this->canDo->get('core.edit.state'); - $this->canCreate = $this->canDo->get('core.create'); - $this->canDelete = $this->canDo->get('core.delete'); - $this->canBatch = ($this->canDo->get('layout.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_LAYOUTS'), 'brush'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=layouts'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('layout.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('layout.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('layouts.publish'); - JToolBarHelper::unpublishList('layouts.unpublish'); - JToolBarHelper::archiveList('layouts.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('layouts.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'layouts.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('layouts.trash'); - } - - if ($this->canDo->get('core.export') && $this->canDo->get('layout.export')) - { - JToolBarHelper::custom('layouts.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); - } - } - if ($this->user->authorise('layout.get_snippets', 'com_componentbuilder')) - { - // add Get Snippets button. - JToolBarHelper::custom('layouts.getSnippets', 'search custom-button-getsnippets', '', 'COM_COMPONENTBUILDER_GET_SNIPPETS', false); - } - - if ($this->canDo->get('core.import') && $this->canDo->get('layout.import')) - { - JToolBarHelper::custom('layouts.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('layouts'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - - // Only load Dynamic Get Name batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Dynamic Get Name Selection - $this->dynamic_getNameOptions = JFormHelper::loadFieldType('Dynamicget')->options; - // We do some sanitation for Dynamic Get Name filter - if (ComponentbuilderHelper::checkArray($this->dynamic_getNameOptions) && - isset($this->dynamic_getNameOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->dynamic_getNameOptions[0]->value)) - { - unset($this->dynamic_getNameOptions[0]); - } - // Dynamic Get Name Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_LAYOUT_DYNAMIC_GET_LABEL').' -', - 'batch[dynamic_get]', - JHtml::_('select.options', $this->dynamic_getNameOptions, 'value', 'text') - ); - } - - // Only load Add Php View batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Add Php View Selection - $this->add_php_viewOptions = JFormHelper::loadFieldType('layoutsfilteraddphpview')->options; - // We do some sanitation for Add Php View filter - if (ComponentbuilderHelper::checkArray($this->add_php_viewOptions) && - isset($this->add_php_viewOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->add_php_viewOptions[0]->value)) - { - unset($this->add_php_viewOptions[0]); - } - // Add Php View Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_LAYOUT_ADD_PHP_VIEW_LABEL').' -', - 'batch[add_php_view]', - JHtml::_('select.options', $this->add_php_viewOptions, 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_LAYOUTS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/layouts.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.name' => JText::_('COM_COMPONENTBUILDER_LAYOUT_NAME_LABEL'), - 'a.description' => JText::_('COM_COMPONENTBUILDER_LAYOUT_DESCRIPTION_LABEL'), - 'g.name' => JText::_('COM_COMPONENTBUILDER_LAYOUT_DYNAMIC_GET_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/libraries/tmpl/default.php b/admin/views/libraries/tmpl/default.php deleted file mode 100644 index a53de89f5..000000000 --- a/admin/views/libraries/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=libraries.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'libraryList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_LIBRARIES_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/libraries/tmpl/default_batch_body.php b/admin/views/libraries/tmpl/default_batch_body.php deleted file mode 100644 index dbd54cd99..000000000 --- a/admin/views/libraries/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/libraries/tmpl/default_batch_footer.php b/admin/views/libraries/tmpl/default_batch_footer.php deleted file mode 100644 index 0dc3cf243..000000000 --- a/admin/views/libraries/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/libraries/tmpl/default_body.php b/admin/views/libraries/tmpl/default_body.php deleted file mode 100644 index 56c6ba9b5..000000000 --- a/admin/views/libraries/tmpl/default_body.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); -use VDM\Joomla\Utilities\ArrayHelper; - -$edit = "index.php?option=com_componentbuilder&view=libraries&task=library.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('library',$item,'libraries'); - ?> - - - get('library.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('library.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('library.edit')): ?> - escape($item->name); ?> - checked_out): ?> - name, $item->checked_out_time, 'libraries.', $canCheckin); ?> - - - escape($item->name); ?> - -
    - 'library_config', - 'views' => 'libraries_config', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_LIBRARY_CONFIG_FIELDS'), - 'icon' => 'options'), - array( - 'view' => 'library_files_folders_urls', - 'views' => 'libraries_files_folders_urls', - 'title' => JText::_('COM_COMPONENTBUILDER_THE_LIBRARY_FILES_FOLDERS_URLS'), - 'icon' => 'briefcase') - ); - } - ?> -
    - - get($_button['view'].'.edit') && ($id = ComponentbuilderHelper::getVar($_button['view'], $item->id, 'library', 'id')) !== false): ?> - - get($_button['view'].'.create')): ?> - - - -
    - - - target); ?> - - - escape($item->how); ?> - - - type); ?> - - - escape($item->description); ?> - - - get('library.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'libraries.', true, 'cb'); ?> - - published, $i, 'libraries.', false, 'cb'); ?> - - - published, $i, 'libraries.', true, 'cb'); ?> - - - published, $i, 'libraries.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/libraries/tmpl/default_foot.php b/admin/views/libraries/tmpl/default_foot.php deleted file mode 100644 index 729d85997..000000000 --- a/admin/views/libraries/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/libraries/tmpl/default_head.php b/admin/views/libraries/tmpl/default_head.php deleted file mode 100644 index 88474d488..000000000 --- a/admin/views/libraries/tmpl/default_head.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/libraries/tmpl/default_toolbar.php b/admin/views/libraries/tmpl/default_toolbar.php deleted file mode 100644 index fe1d3a65b..000000000 --- a/admin/views/libraries/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/libraries/view.html.php b/admin/views/libraries/view.html.php deleted file mode 100644 index 4e6059858..000000000 --- a/admin/views/libraries/view.html.php +++ /dev/null @@ -1,289 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Libraries - */ -class ComponentbuilderViewLibraries extends HtmlView -{ - /** - * Libraries view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('libraries'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('library'); - $this->canEdit = $this->canDo->get('library.edit'); - $this->canState = $this->canDo->get('library.edit.state'); - $this->canCreate = $this->canDo->get('library.create'); - $this->canDelete = $this->canDo->get('library.delete'); - $this->canBatch = ($this->canDo->get('library.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_LIBRARIES'), 'puzzle'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=libraries'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('library.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('library.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('libraries.publish'); - JToolBarHelper::unpublishList('libraries.unpublish'); - JToolBarHelper::archiveList('libraries.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('libraries.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'libraries.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('libraries.trash'); - } - } - if ($this->user->authorise('library.get_snippets', 'com_componentbuilder')) - { - // add Get Snippets button. - JToolBarHelper::custom('libraries.getSnippets', 'search custom-button-getsnippets', '', 'COM_COMPONENTBUILDER_GET_SNIPPETS', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('libraries'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - - // Only load Target batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Target Selection - $this->targetOptions = JFormHelper::loadFieldType('librariesfiltertarget')->options; - // We do some sanitation for Target filter - if (ComponentbuilderHelper::checkArray($this->targetOptions) && - isset($this->targetOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->targetOptions[0]->value)) - { - unset($this->targetOptions[0]); - } - // Target Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_LIBRARY_TARGET_LABEL').' -', - 'batch[target]', - JHtml::_('select.options', $this->targetOptions, 'value', 'text') - ); - } - - // Only load How batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set How Selection - $this->howOptions = JFormHelper::loadFieldType('Filebehaviour')->options; - // We do some sanitation for How filter - if (ComponentbuilderHelper::checkArray($this->howOptions) && - isset($this->howOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->howOptions[0]->value)) - { - unset($this->howOptions[0]); - } - // How Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_LIBRARY_HOW_LABEL').' -', - 'batch[how]', - JHtml::_('select.options', $this->howOptions, 'value', 'text') - ); - } - - // Only load Type batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Type Selection - $this->typeOptions = JFormHelper::loadFieldType('librariesfiltertype')->options; - // We do some sanitation for Type filter - if (ComponentbuilderHelper::checkArray($this->typeOptions) && - isset($this->typeOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->typeOptions[0]->value)) - { - unset($this->typeOptions[0]); - } - // Type Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_LIBRARY_TYPE_LABEL').' -', - 'batch[type]', - JHtml::_('select.options', $this->typeOptions, 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_LIBRARIES')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/libraries.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.name' => JText::_('COM_COMPONENTBUILDER_LIBRARY_NAME_LABEL'), - 'a.target' => JText::_('COM_COMPONENTBUILDER_LIBRARY_TARGET_LABEL'), - 'a.type' => JText::_('COM_COMPONENTBUILDER_LIBRARY_TYPE_LABEL'), - 'a.description' => JText::_('COM_COMPONENTBUILDER_LIBRARY_DESCRIPTION_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/libraries_config/tmpl/default.php b/admin/views/libraries_config/tmpl/default.php deleted file mode 100644 index b75db1b1e..000000000 --- a/admin/views/libraries_config/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=libraries_config.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'library_configList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_LIBRARIES_CONFIG_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/libraries_config/tmpl/default_batch_body.php b/admin/views/libraries_config/tmpl/default_batch_body.php deleted file mode 100644 index ec95fef63..000000000 --- a/admin/views/libraries_config/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/libraries_config/tmpl/default_batch_footer.php b/admin/views/libraries_config/tmpl/default_batch_footer.php deleted file mode 100644 index 48bae1162..000000000 --- a/admin/views/libraries_config/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/libraries_config/tmpl/default_body.php b/admin/views/libraries_config/tmpl/default_body.php deleted file mode 100644 index 12998458a..000000000 --- a/admin/views/libraries_config/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=libraries_config&task=library_config.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('library_config',$item,'libraries_config'); - ?> - - - get('library_config.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('library_config.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('library_config.edit')): ?> - escape($item->library_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'libraries_config.', $canCheckin); ?> - - - escape($item->library_name); ?> - -
    - - - get('library_config.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'libraries_config.', true, 'cb'); ?> - - published, $i, 'libraries_config.', false, 'cb'); ?> - - - published, $i, 'libraries_config.', true, 'cb'); ?> - - - published, $i, 'libraries_config.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/libraries_config/tmpl/default_foot.php b/admin/views/libraries_config/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/libraries_config/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/libraries_config/tmpl/default_head.php b/admin/views/libraries_config/tmpl/default_head.php deleted file mode 100644 index 1af8f76bf..000000000 --- a/admin/views/libraries_config/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/libraries_config/tmpl/default_toolbar.php b/admin/views/libraries_config/tmpl/default_toolbar.php deleted file mode 100644 index c5155287e..000000000 --- a/admin/views/libraries_config/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/libraries_config/view.html.php b/admin/views/libraries_config/view.html.php deleted file mode 100644 index 58b1a4282..000000000 --- a/admin/views/libraries_config/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Libraries_config - */ -class ComponentbuilderViewLibraries_config extends HtmlView -{ - /** - * Libraries_config view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('libraries_config'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('library_config'); - $this->canEdit = $this->canDo->get('library_config.edit'); - $this->canState = $this->canDo->get('library_config.edit.state'); - $this->canCreate = $this->canDo->get('library_config.create'); - $this->canDelete = $this->canDo->get('library_config.delete'); - $this->canBatch = ($this->canDo->get('library_config.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_LIBRARIES_CONFIG'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=libraries_config'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('library_config.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('library_config.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('libraries_config.publish'); - JToolBarHelper::unpublishList('libraries_config.unpublish'); - JToolBarHelper::archiveList('libraries_config.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('libraries_config.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'libraries_config.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('libraries_config.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('libraries_config'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_LIBRARIES_CONFIG')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/libraries_config.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/libraries_files_folders_urls/tmpl/default.php b/admin/views/libraries_files_folders_urls/tmpl/default.php deleted file mode 100644 index 95b6f9afc..000000000 --- a/admin/views/libraries_files_folders_urls/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=libraries_files_folders_urls.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'library_files_folders_urlsList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/libraries_files_folders_urls/tmpl/default_batch_body.php b/admin/views/libraries_files_folders_urls/tmpl/default_batch_body.php deleted file mode 100644 index a0da763dc..000000000 --- a/admin/views/libraries_files_folders_urls/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/libraries_files_folders_urls/tmpl/default_batch_footer.php b/admin/views/libraries_files_folders_urls/tmpl/default_batch_footer.php deleted file mode 100644 index ee8e16280..000000000 --- a/admin/views/libraries_files_folders_urls/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/libraries_files_folders_urls/tmpl/default_body.php b/admin/views/libraries_files_folders_urls/tmpl/default_body.php deleted file mode 100644 index df0366f02..000000000 --- a/admin/views/libraries_files_folders_urls/tmpl/default_body.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=libraries_files_folders_urls&task=library_files_folders_urls.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('library_files_folders_urls',$item,'libraries_files_folders_urls'); - ?> - - - get('library_files_folders_urls.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('library_files_folders_urls.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('library_files_folders_urls.edit')): ?> - escape($item->library_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'libraries_files_folders_urls.', $canCheckin); ?> - - - escape($item->library_name); ?> - -
    - - - get('library_files_folders_urls.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'libraries_files_folders_urls.', true, 'cb'); ?> - - published, $i, 'libraries_files_folders_urls.', false, 'cb'); ?> - - - published, $i, 'libraries_files_folders_urls.', true, 'cb'); ?> - - - published, $i, 'libraries_files_folders_urls.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/libraries_files_folders_urls/tmpl/default_foot.php b/admin/views/libraries_files_folders_urls/tmpl/default_foot.php deleted file mode 100644 index 6b61458a9..000000000 --- a/admin/views/libraries_files_folders_urls/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/libraries_files_folders_urls/tmpl/default_head.php b/admin/views/libraries_files_folders_urls/tmpl/default_head.php deleted file mode 100644 index 37bcce7f0..000000000 --- a/admin/views/libraries_files_folders_urls/tmpl/default_head.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/libraries_files_folders_urls/tmpl/default_toolbar.php b/admin/views/libraries_files_folders_urls/tmpl/default_toolbar.php deleted file mode 100644 index a378013fb..000000000 --- a/admin/views/libraries_files_folders_urls/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/libraries_files_folders_urls/view.html.php b/admin/views/libraries_files_folders_urls/view.html.php deleted file mode 100644 index 72c20afc8..000000000 --- a/admin/views/libraries_files_folders_urls/view.html.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Libraries_files_folders_urls - */ -class ComponentbuilderViewLibraries_files_folders_urls extends HtmlView -{ - /** - * Libraries_files_folders_urls view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('libraries_files_folders_urls'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('library_files_folders_urls'); - $this->canEdit = $this->canDo->get('library_files_folders_urls.edit'); - $this->canState = $this->canDo->get('library_files_folders_urls.edit.state'); - $this->canCreate = $this->canDo->get('library_files_folders_urls.create'); - $this->canDelete = $this->canDo->get('library_files_folders_urls.delete'); - $this->canBatch = ($this->canDo->get('library_files_folders_urls.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=libraries_files_folders_urls'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('library_files_folders_urls.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('library_files_folders_urls.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('libraries_files_folders_urls.publish'); - JToolBarHelper::unpublishList('libraries_files_folders_urls.unpublish'); - JToolBarHelper::archiveList('libraries_files_folders_urls.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('libraries_files_folders_urls.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'libraries_files_folders_urls.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('libraries_files_folders_urls.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('libraries_files_folders_urls'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/libraries_files_folders_urls.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/library/submitbutton.js b/admin/views/library/submitbutton.js deleted file mode 100644 index 8f0989d1b..000000000 --- a/admin/views/library/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('library, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/library/tmpl/edit.php b/admin/views/library/tmpl/edit.php deleted file mode 100644 index 492892ef6..000000000 --- a/admin/views/library/tmpl/edit.php +++ /dev/null @@ -1,606 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/library/view.html.php b/admin/views/library/view.html.php deleted file mode 100644 index d013e61b7..000000000 --- a/admin/views/library/view.html.php +++ /dev/null @@ -1,215 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Library Html View class - */ -class ComponentbuilderViewLibrary extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('library', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_LIBRARY_NEW' : 'COM_COMPONENTBUILDER_LIBRARY_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('library.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('library.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('library.edit')) - { - // We can save the record. - JToolBarHelper::save('library.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('library.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('library.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('library.create')) - { - JToolBarHelper::apply('library.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('library.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('library.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('library.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('library.edit')) - { - // We can save the new record - JToolBarHelper::apply('library.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('library.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('library.create')) - { - JToolBarHelper::custom('library.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('library.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('library.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.library', $this->item->id); - } - if ($this->canDo->get('library.create')) - { - JToolBarHelper::custom('library.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('library.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('library'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_LIBRARY_NEW' : 'COM_COMPONENTBUILDER_LIBRARY_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/library.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/library/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/library_config/submitbutton.js b/admin/views/library_config/submitbutton.js deleted file mode 100644 index d866dc9e0..000000000 --- a/admin/views/library_config/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('library_config, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/library_config/tmpl/edit.php b/admin/views/library_config/tmpl/edit.php deleted file mode 100644 index f5273842d..000000000 --- a/admin/views/library_config/tmpl/edit.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - diff --git a/admin/views/library_config/view.html.php b/admin/views/library_config/view.html.php deleted file mode 100644 index 5a93d492b..000000000 --- a/admin/views/library_config/view.html.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Library_config Html View class - */ -class ComponentbuilderViewLibrary_config extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('library_config', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_LIBRARY_CONFIG_NEW' : 'COM_COMPONENTBUILDER_LIBRARY_CONFIG_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('library_config.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('library_config.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('library_config.edit')) - { - // We can save the record. - JToolBarHelper::save('library_config.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('library_config.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('library_config.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('library_config.create')) - { - JToolBarHelper::apply('library_config.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('library_config.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('library_config.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('library_config.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('library_config.edit')) - { - // We can save the new record - JToolBarHelper::apply('library_config.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('library_config.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('library_config.create')) - { - JToolBarHelper::custom('library_config.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('library_config.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('library_config.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.library_config', $this->item->id); - } - if ($this->canDo->get('library_config.create')) - { - JToolBarHelper::custom('library_config.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('library_config.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('library_config'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_LIBRARY_CONFIG_NEW' : 'COM_COMPONENTBUILDER_LIBRARY_CONFIG_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/library_config.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/library_config/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/library_files_folders_urls/submitbutton.js b/admin/views/library_files_folders_urls/submitbutton.js deleted file mode 100644 index aa185e495..000000000 --- a/admin/views/library_files_folders_urls/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('library_files_folders_urls, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/library_files_folders_urls/tmpl/edit.php b/admin/views/library_files_folders_urls/tmpl/edit.php deleted file mode 100644 index 4e0288b09..000000000 --- a/admin/views/library_files_folders_urls/tmpl/edit.php +++ /dev/null @@ -1,115 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - diff --git a/admin/views/library_files_folders_urls/view.html.php b/admin/views/library_files_folders_urls/view.html.php deleted file mode 100644 index 23436a336..000000000 --- a/admin/views/library_files_folders_urls/view.html.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Library_files_folders_urls Html View class - */ -class ComponentbuilderViewLibrary_files_folders_urls extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('library_files_folders_urls', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_NEW' : 'COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('library_files_folders_urls.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('library_files_folders_urls.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('library_files_folders_urls.edit')) - { - // We can save the record. - JToolBarHelper::save('library_files_folders_urls.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('library_files_folders_urls.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('library_files_folders_urls.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('library_files_folders_urls.create')) - { - JToolBarHelper::apply('library_files_folders_urls.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('library_files_folders_urls.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('library_files_folders_urls.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('library_files_folders_urls.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('library_files_folders_urls.edit')) - { - // We can save the new record - JToolBarHelper::apply('library_files_folders_urls.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('library_files_folders_urls.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('library_files_folders_urls.create')) - { - JToolBarHelper::custom('library_files_folders_urls.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('library_files_folders_urls.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('library_files_folders_urls.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.library_files_folders_urls', $this->item->id); - } - if ($this->canDo->get('library_files_folders_urls.create')) - { - JToolBarHelper::custom('library_files_folders_urls.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('library_files_folders_urls.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('library_files_folders_urls'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_NEW' : 'COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/library_files_folders_urls.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/library_files_folders_urls/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/placeholder/submitbutton.js b/admin/views/placeholder/submitbutton.js deleted file mode 100644 index d04723239..000000000 --- a/admin/views/placeholder/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('placeholder, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/placeholder/tmpl/edit.php b/admin/views/placeholder/tmpl/edit.php deleted file mode 100644 index 5104790a8..000000000 --- a/admin/views/placeholder/tmpl/edit.php +++ /dev/null @@ -1,154 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/placeholder/view.html.php b/admin/views/placeholder/view.html.php deleted file mode 100644 index 3c1951e33..000000000 --- a/admin/views/placeholder/view.html.php +++ /dev/null @@ -1,218 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Placeholder Html View class - */ -class ComponentbuilderViewPlaceholder extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('placeholder', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_PLACEHOLDER_NEW' : 'COM_COMPONENTBUILDER_PLACEHOLDER_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('placeholder.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('placeholder.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('placeholder.edit')) - { - // We can save the record. - JToolBarHelper::save('placeholder.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('placeholder.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('placeholder.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('placeholder.create')) - { - JToolBarHelper::apply('placeholder.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('placeholder.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('placeholder.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('placeholder.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('placeholder.edit')) - { - // We can save the new record - JToolBarHelper::apply('placeholder.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('placeholder.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('placeholder.create')) - { - JToolBarHelper::custom('placeholder.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('placeholder.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('placeholder.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.placeholder', $this->item->id); - } - if ($this->canDo->get('placeholder.create')) - { - JToolBarHelper::custom('placeholder.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('placeholder.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('placeholder'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_PLACEHOLDER_NEW' : 'COM_COMPONENTBUILDER_PLACEHOLDER_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/placeholder.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/placeholder/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - // add some language strings - JText::script('COM_COMPONENTBUILDER_PLACEHOLDER_ALREADY_TAKEN_PLEASE_TRY_AGAIN'); - JText::script('COM_COMPONENTBUILDER_YOU_MUST_ADD_AN_UNIQUE_PLACEHOLDER'); - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/placeholders/tmpl/default.php b/admin/views/placeholders/tmpl/default.php deleted file mode 100644 index 23924ba21..000000000 --- a/admin/views/placeholders/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=placeholders.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'placeholderList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_PLACEHOLDERS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/placeholders/tmpl/default_batch_body.php b/admin/views/placeholders/tmpl/default_batch_body.php deleted file mode 100644 index e4b9f6bc0..000000000 --- a/admin/views/placeholders/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/placeholders/tmpl/default_batch_footer.php b/admin/views/placeholders/tmpl/default_batch_footer.php deleted file mode 100644 index 837a720b2..000000000 --- a/admin/views/placeholders/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/placeholders/tmpl/default_body.php b/admin/views/placeholders/tmpl/default_body.php deleted file mode 100644 index b8bf8c1f5..000000000 --- a/admin/views/placeholders/tmpl/default_body.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=placeholders&task=placeholder.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('placeholder',$item,'placeholders'); - ?> - - - get('placeholder.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('placeholder.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('placeholder.edit')): ?> - escape($item->target); ?> - checked_out): ?> - name, $item->checked_out_time, 'placeholders.', $canCheckin); ?> - - - escape($item->target); ?> - -
    - - - escape($item->value); ?> - - - get('placeholder.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'placeholders.', true, 'cb'); ?> - - published, $i, 'placeholders.', false, 'cb'); ?> - - - published, $i, 'placeholders.', true, 'cb'); ?> - - - published, $i, 'placeholders.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/placeholders/tmpl/default_foot.php b/admin/views/placeholders/tmpl/default_foot.php deleted file mode 100644 index 95317c3bb..000000000 --- a/admin/views/placeholders/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/placeholders/tmpl/default_head.php b/admin/views/placeholders/tmpl/default_head.php deleted file mode 100644 index cff0d59ba..000000000 --- a/admin/views/placeholders/tmpl/default_head.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/placeholders/tmpl/default_toolbar.php b/admin/views/placeholders/tmpl/default_toolbar.php deleted file mode 100644 index f3b9b7c54..000000000 --- a/admin/views/placeholders/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/placeholders/view.html.php b/admin/views/placeholders/view.html.php deleted file mode 100644 index 585257a91..000000000 --- a/admin/views/placeholders/view.html.php +++ /dev/null @@ -1,232 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Placeholders - */ -class ComponentbuilderViewPlaceholders extends HtmlView -{ - /** - * Placeholders view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('placeholders'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('placeholder'); - $this->canEdit = $this->canDo->get('placeholder.edit'); - $this->canState = $this->canDo->get('placeholder.edit.state'); - $this->canCreate = $this->canDo->get('placeholder.create'); - $this->canDelete = $this->canDo->get('placeholder.delete'); - $this->canBatch = ($this->canDo->get('placeholder.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_PLACEHOLDERS'), 'search'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=placeholders'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('placeholder.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('placeholder.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('placeholders.publish'); - JToolBarHelper::unpublishList('placeholders.unpublish'); - JToolBarHelper::archiveList('placeholders.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('placeholders.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'placeholders.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('placeholders.trash'); - } - - if ($this->canDo->get('core.export') && $this->canDo->get('placeholder.export')) - { - JToolBarHelper::custom('placeholders.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); - } - } - - if ($this->canDo->get('core.import') && $this->canDo->get('placeholder.import')) - { - JToolBarHelper::custom('placeholders.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('placeholders'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_PLACEHOLDERS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/placeholders.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.target' => JText::_('COM_COMPONENTBUILDER_PLACEHOLDER_TARGET_LABEL'), - 'a.value' => JText::_('COM_COMPONENTBUILDER_PLACEHOLDER_VALUE_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/power/submitbutton.js b/admin/views/power/submitbutton.js deleted file mode 100644 index 6def81bae..000000000 --- a/admin/views/power/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('power, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/power/tmpl/edit.php b/admin/views/power/tmpl/edit.php deleted file mode 100644 index de7e111bd..000000000 --- a/admin/views/power/tmpl/edit.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/power/view.html.php b/admin/views/power/view.html.php deleted file mode 100644 index a4df7f955..000000000 --- a/admin/views/power/view.html.php +++ /dev/null @@ -1,262 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Power Html View class - */ -class ComponentbuilderViewPower extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('power', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_POWER_NEW' : 'COM_COMPONENTBUILDER_POWER_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('power.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('power.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('power.edit')) - { - // We can save the record. - JToolBarHelper::save('power.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('power.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('power.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('power.create')) - { - JToolBarHelper::apply('power.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('power.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('power.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('power.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('power.edit')) - { - // We can save the new record - JToolBarHelper::apply('power.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('power.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('power.create')) - { - JToolBarHelper::custom('power.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('power.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('power.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.power', $this->item->id); - } - if ($this->canDo->get('power.create')) - { - JToolBarHelper::custom('power.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - if ($this->canDo->get('power.reset')) - { - // add Reset button. - JToolBarHelper::custom('power.resetPowers', 'joomla custom-button-resetpowers', '', 'COM_COMPONENTBUILDER_RESET', false); - } - JToolBarHelper::cancel('power.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('power'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_POWER_NEW' : 'COM_COMPONENTBUILDER_POWER_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/power.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/power/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - // Add the JavaScript for JStore - $this->document->addScript(JURI::root() .'media/com_componentbuilder/js/jquery.json.min.js'); - $this->document->addScript(JURI::root() .'media/com_componentbuilder/js/jstorage.min.js'); - $this->document->addScript(JURI::root() .'media/com_componentbuilder/js/strtotime.js'); - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - // set some lang - JText::script('COM_COMPONENTBUILDER_ALREADY_SELECTED_TRY_ANOTHER'); - JText::script('COM_COMPONENTBUILDER_TYPE_OR_SELECT_SOME_OPTIONS'); - JText::script('COM_COMPONENTBUILDER_NO_RESULTS_MATCH'); - JText::script('COM_COMPONENTBUILDER_SELECT_A_PROPERTY'); - JText::script('COM_COMPONENTBUILDER_NO_DESCRIPTION_FOUND'); - // check if we should use browser storage - $setBrowserStorage = $this->params->get('set_browser_storage', null); - if ($setBrowserStorage) - { - // check what (Time To Live) show we use - $storageTimeToLive = $this->params->get('storage_time_to_live', 'global'); - if ('global' == $storageTimeToLive) - { - // use the global session time - $session = JFactory::getSession(); - // must have itin milliseconds - $expire = ($session->getExpire()*60)* 1000; - } - else - { - // use the Componentbuilder Global setting - if (0 != $storageTimeToLive) - { - // this will convert the time into milliseconds - $storageTimeToLive = $storageTimeToLive * 1000; - } - $expire = $storageTimeToLive; - } - } - else - { - // set to use no storage - $expire = 30000; // only 30 seconds - } - // Set the Time To Live To JavaScript - $this->document->addScriptDeclaration("var expire = ". (int) $expire.";"); - $this->document->addScriptDeclaration("selectionArray = {'property':{},'method':{}};"); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/powers/tmpl/default.php b/admin/views/powers/tmpl/default.php deleted file mode 100644 index b105ed33f..000000000 --- a/admin/views/powers/tmpl/default.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multiplePowersfiltertype', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_TYPE_OF_POWER') . ' -')); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=powers.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'powerList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_POWERS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - - diff --git a/admin/views/powers/tmpl/default_batch_body.php b/admin/views/powers/tmpl/default_batch_body.php deleted file mode 100644 index e4d5adeb6..000000000 --- a/admin/views/powers/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/powers/tmpl/default_batch_footer.php b/admin/views/powers/tmpl/default_batch_footer.php deleted file mode 100644 index 5119b600f..000000000 --- a/admin/views/powers/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/powers/tmpl/default_body.php b/admin/views/powers/tmpl/default_body.php deleted file mode 100644 index 8d8d7708b..000000000 --- a/admin/views/powers/tmpl/default_body.php +++ /dev/null @@ -1,110 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=powers&task=power.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('power',$item,'powers'); - ?> - - - get('power.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('power.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('power.edit')): ?> - escape($item->system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'powers.', $canCheckin); ?> - - - escape($item->system_name); ?> -
    GUID: - escape($item->guid); ?>super_power_key)): ?>
    SPK: super_power_key; ?>
    -
    - - - namespace; ?> - - -
    : - type); ?>extends)) : ?>
    : - user->authorise('power.edit', 'com_componentbuilder.power.' . (int) $item->extends_id)): ?> - escape($item->extends_name); ?> - - escape($item->extends_name); ?> - extends === '-1') : ?>
    : - escape($item->extends_custom); ?>
    : - approved); ?> -
    - - - escape($item->power_version); ?> - - - get('power.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'powers.', true, 'cb'); ?> - - published, $i, 'powers.', false, 'cb'); ?> - - - published, $i, 'powers.', true, 'cb'); ?> - - - published, $i, 'powers.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/powers/tmpl/default_foot.php b/admin/views/powers/tmpl/default_foot.php deleted file mode 100644 index 5a05d8cfd..000000000 --- a/admin/views/powers/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/powers/tmpl/default_head.php b/admin/views/powers/tmpl/default_head.php deleted file mode 100644 index 9d10cdafa..000000000 --- a/admin/views/powers/tmpl/default_head.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/powers/tmpl/default_toolbar.php b/admin/views/powers/tmpl/default_toolbar.php deleted file mode 100644 index fe0b58175..000000000 --- a/admin/views/powers/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/powers/view.html.php b/admin/views/powers/view.html.php deleted file mode 100644 index 8855f4ef7..000000000 --- a/admin/views/powers/view.html.php +++ /dev/null @@ -1,279 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Powers - */ -class ComponentbuilderViewPowers extends HtmlView -{ - /** - * Powers view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('powers'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('power'); - $this->canEdit = $this->canDo->get('power.edit'); - $this->canState = $this->canDo->get('power.edit.state'); - $this->canCreate = $this->canDo->get('power.create'); - $this->canDelete = $this->canDo->get('power.delete'); - $this->canBatch = ($this->canDo->get('power.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_POWERS'), 'flash'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=powers'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('power.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('power.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('powers.publish'); - JToolBarHelper::unpublishList('powers.unpublish'); - JToolBarHelper::archiveList('powers.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('powers.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'powers.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('powers.trash'); - } - } - if ($this->user->authorise('power.run_expansion', 'com_componentbuilder')) - { - // add Run Expansion button. - JToolBarHelper::custom('powers.runExpansion', 'expand-2 custom-button-runexpansion', '', 'COM_COMPONENTBUILDER_RUN_EXPANSION', false); - } - if ($this->user->authorise('power.init', 'com_componentbuilder')) - { - // add Init button. - JToolBarHelper::custom('powers.initPowers', 'health custom-button-initpowers', '', 'COM_COMPONENTBUILDER_INIT', false); - } - if ($this->user->authorise('power.reset', 'com_componentbuilder')) - { - // add Reset button. - JToolBarHelper::custom('powers.resetPowers', 'joomla custom-button-resetpowers', '', 'COM_COMPONENTBUILDER_RESET', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('powers'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - - // Only load Type batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Type Selection - $this->typeOptions = JFormHelper::loadFieldType('powersfiltertype')->options; - // We do some sanitation for Type filter - if (ComponentbuilderHelper::checkArray($this->typeOptions) && - isset($this->typeOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->typeOptions[0]->value)) - { - unset($this->typeOptions[0]); - } - // Type Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_POWER_TYPE_LABEL').' -', - 'batch[type]', - JHtml::_('select.options', $this->typeOptions, 'value', 'text') - ); - } - - // Only load Approved batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Approved Selection - $this->approvedOptions = JFormHelper::loadFieldType('powersfilterapproved')->options; - // We do some sanitation for Approved filter - if (ComponentbuilderHelper::checkArray($this->approvedOptions) && - isset($this->approvedOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->approvedOptions[0]->value)) - { - unset($this->approvedOptions[0]); - } - // Approved Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_POWER_APPROVED_LABEL').' -', - 'batch[approved]', - JHtml::_('select.options', $this->approvedOptions, 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_POWERS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/powers.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.system_name' => JText::_('COM_COMPONENTBUILDER_POWER_SYSTEM_NAME_LABEL'), - 'a.namespace' => JText::_('COM_COMPONENTBUILDER_POWER_NAMESPACE_LABEL'), - 'a.type' => JText::_('COM_COMPONENTBUILDER_POWER_TYPE_LABEL'), - 'a.power_version' => JText::_('COM_COMPONENTBUILDER_POWER_POWER_VERSION_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/search/tmpl/default.php b/admin/views/search/tmpl/default.php deleted file mode 100644 index bd9da3ca1..000000000 --- a/admin/views/search/tmpl/default.php +++ /dev/null @@ -1,342 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); -use VDM\Joomla\Utilities\ArrayHelper; - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); - -// allow main menu selection -$this->app->input->set('hidemainmenu', false); - -// set the basu URL -$url_base = JUri::base() . 'index.php?option=com_componentbuilder'; -$url_search = $url_base . '&view=search'; - -// get main search input field -$search_value = $this->form->getField('search_value'); -?> -canDo->get('search.access')): ?> - -item->id)) ? '&id='. (int) $this->item->id : ''; ?> - -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - form): ?> -
    -
    - - - -
    -
    - form->renderField('type_search'); ?> -
    - input; ?> - - -
    - form->renderField('replace_value'); ?> - -
    -
    - form->renderFieldset('settings'); ?> -
    -
    -
    -
    -
    - 'search_results_table', 'headers' => $this->table_headers, 'items' => 7, 'init' => false]); ?> -
    -
    -
    - -
    - form->getInput('item_code'); ?> -
    -
    - - -
    - -
    -item['tables']) && ArrayHelper::check($this->item['tables'])) : ?> - - - -

    - - diff --git a/admin/views/search/view.html.php b/admin/views/search/view.html.php deleted file mode 100644 index 0b4849dc3..000000000 --- a/admin/views/search/view.html.php +++ /dev/null @@ -1,440 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; -use Joomla\CMS\Filesystem\File; -use VDM\Joomla\Componentbuilder\Search\Factory as SearchFactory; -use Joomla\CMS\Form\Form; -use VDM\Joomla\Utilities\ArrayHelper; - -/** - * Componentbuilder Html View class for the Search - */ -class ComponentbuilderViewSearch extends HtmlView -{ - // Overwriting JView display method - function display($tpl = null) - { - // get component params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // get the application - $this->app = JFactory::getApplication(); - // get the user object - $this->user = JFactory::getUser(); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('search'); - // Initialise variables. - $this->item = $this->get('Item'); - $this->urlvalues = $this->get('UrlValues'); - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('search'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=search'); - $this->sidebar = JHtmlSidebar::render(); - } - - // get the needed form fields - $this->form = $this->getDynamicForm(); - - // build our table headers - $this->table_headers = array( - 'edit' => 'E', - 'code' => JText::_('COM_COMPONENTBUILDER_FOUND_TEXT'), - 'table' => JText::_('COM_COMPONENTBUILDER_TABLE'), - 'field' => JText::_('COM_COMPONENTBUILDER_FIELD'), - 'id' => JText::_('ID'), - 'line' => JText::_('COM_COMPONENTBUILDER_LINE') - ); - - // set some JavaScript Language - JText::script('COM_COMPONENTBUILDER_YOUR_ARE_ABOUT_TO_UPDATE_ROW'); - JText::script('COM_COMPONENTBUILDER_FIELD_IN_THE'); - JText::script('COM_COMPONENTBUILDER_TABLE'); - JText::script('COM_COMPONENTBUILDER_THIS_CAN_NOT_BE_UNDONE_ARE_YOU_SURE_YOU_WANT_TO_CONTINUE'); - JText::script('COM_COMPONENTBUILDER_YOUR_ARE_ABOUT_TO_UPDATE_BALLB_VALUES_THAT_CAN_BE_FOUND_IN_THE_DATABASE'); - JText::script('COM_COMPONENTBUILDER_YOU_WILL_REPLACE'); - JText::script('COM_COMPONENTBUILDER_WITH'); - JText::script('COM_COMPONENTBUILDER_THIS_CAN_NOT_BE_UNDONE_BYOU_HAVE_BEEN_WARNEDB'); - JText::script('COM_COMPONENTBUILDER_ARE_YOU_THEREFORE_ABSOLUTELY_SURE_YOU_WANT_TO_CONTINUE'); - JText::script('COM_COMPONENTBUILDER_THE_SEARCH_PROCESS_HAD_AN_ERROR_WITH_TABLE'); - JText::script('COM_COMPONENTBUILDER_THE_REPLACE_PROCESS_HAD_AN_ERROR_WITH_TABLE'); - JText::script('COM_COMPONENTBUILDER_REPLACE_PROCESS_COMPLETE'); - JText::script('COM_COMPONENTBUILDER_SEARCHING'); - JText::script('COM_COMPONENTBUILDER_TABLES_WITH'); - JText::script('COM_COMPONENTBUILDER_FIELDS_THAT_HAD'); - JText::script('COM_COMPONENTBUILDER_LINES'); - JText::script('COM_COMPONENTBUILDER_AND_FINISHED_THE_SEARCH_IN'); - JText::script('COM_COMPONENTBUILDER_SECONDS'); - JText::script('COM_COMPONENTBUILDER_WOULD_YOU_LIKE_TO_DO_A_REVERSE_SEARCH'); - JText::script('COM_COMPONENTBUILDER_WOULD_YOU_LIKE_TO_REPEAT_THE_SAME_SEARCH'); - JText::script('COM_COMPONENTBUILDER_YES_UPDATE_ALL'); - JText::script('COM_COMPONENTBUILDER_NO'); - JText::script('COM_COMPONENTBUILDER_YES'); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - // add the tool bar - $this->addToolBar(); - } - - // set the document - $this->setDocument(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode(PHP_EOL, $errors), 500); - } - - parent::display($tpl); - } - - /** - * Get the dynamic build form fields needed on the page - * - * @return Form|null The array of form fields - * - * @since 3.2.0 - */ - public function getDynamicForm(): ?Form - { - if(ArrayHelper::check($this->item) && - ArrayHelper::check($this->item['tables']) && - ArrayHelper::check($this->item['components'])) - { - // start the form - $form = new Form('Search'); - - $form->load('
    -
    -
    -
    -
    '); - - // Search Mode - $attributes = [ - 'type' => 'radio', - 'name' => 'type_search', - 'hiddenLabel' => true, - 'label' => 'COM_COMPONENTBUILDER_MODE', - 'class' => 'btn-group', - 'description' => 'COM_COMPONENTBUILDER_SEARCH_OR_SEARCH_AND_REPLACE', - 'default' => $this->urlvalues['type_search']]; - // set the mode options - $options = [ - 1 => 'COM_COMPONENTBUILDER_SEARCH', - 2 => 'COM_COMPONENTBUILDER_REPLACE', - 0 => 'COM_COMPONENTBUILDER_CLEAR']; - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes, $options); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'search'); - } - - // search text attributes - $attributes = [ - 'type' => 'text', - 'name' => 'search_value', - 'hiddenLabel' => true, - 'label' => 'COM_COMPONENTBUILDER_SEARCH', - 'size' => 150, - 'maxlength' => 200, - 'description' => 'COM_COMPONENTBUILDER_HERE_YOU_CAN_ENTER_YOUR_SEARCH_TEXT', - 'filter' => 'RAW', - 'class' => 'search-value span11', - 'hint' => 'COM_COMPONENTBUILDER_ENTER_YOUR_SEARCH_TEXT', - 'autocomplete' => true, - 'default' => $this->urlvalues['search_value']]; - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'search'); - } - - // replace text attributes - $attributes = [ - 'type' => 'text', - 'name' => 'replace_value', - 'hiddenLabel' => true, - 'label' => 'COM_COMPONENTBUILDER_REPLACE', - 'size' => 150, - 'maxlength' => 200, - 'description' => 'COM_COMPONENTBUILDER_HERE_YOU_CAN_ENTER_THE_REPLACE_TEXT_THAT_YOU_WOULD_LIKE_TO_USE_AS_REPLACEMENT_FOR_THE_SEARCH_TEXT_FOUND', - 'filter' => 'RAW', - 'class' => 'replace-value span11', - 'hint' => 'COM_COMPONENTBUILDER_ENTER_YOUR_REPLACE_TEXT', - 'autocomplete' => true, - 'showon' => 'type_search:2', - 'default' => $this->urlvalues['replace_value']]; - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'search'); - } - - // Search Behaviour - $default = []; - if ($this->urlvalues['match_case'] == 1) - { - $default[] = 'match_case'; - } - if ($this->urlvalues['whole_word'] == 1) - { - $default[] = 'whole_word'; - } - if ($this->urlvalues['regex_search'] == 1) - { - $default[] = 'regex_search'; - } - $attributes = [ - 'type' => 'checkboxes', - 'name' => 'search_behaviour', - 'label' => 'COM_COMPONENTBUILDER_BEHAVIOUR', - 'description' => 'COM_COMPONENTBUILDER_SET_THE_SEARCH_BEHAVIOUR_HERE']; - if (ArrayHelper::check($default)) - { - $attributes['default'] = implode(',', $default); - } - // set the mode options - $options = [ - 'match_case' => 'COM_COMPONENTBUILDER_MATCH_CASE', - 'whole_word' => 'COM_COMPONENTBUILDER_WHOLE_WORD', - 'regex_search' => 'COM_COMPONENTBUILDER_REGEX_SEARCH']; - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes, $options); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'settings'); - } - - // component attributes - $attributes = [ - 'type' => 'list', - 'name' => 'component_id', - 'label' => 'COM_COMPONENTBUILDER_COMPONENTS_BR_SMALLDISABLED_SOONSMALL', - 'class' => 'list_class', - 'description' => 'COM_COMPONENTBUILDER_SELECT_THE_COMPONENT_TO_SEARCH', - 'required' => 'true', - 'disable' => 'true', - 'readonly' => 'true', - 'default' => -1]; - // start the component options - $options = []; - $options['-1'] = 'COM_COMPONENTBUILDER__SEARCH_ALL_'; - // load component options from array - foreach($this->item['components'] as $component) - { - $options[(int) $component->id] = $this->escape($component->name); - } - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes, $options); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'settings'); - } - - // table attributes - $attributes = [ - 'type' => 'list', - 'name' => 'table_name', - 'label' => 'COM_COMPONENTBUILDER_TABLES', - 'class' => 'list_class', - 'description' => 'COM_COMPONENTBUILDER_SELECT_THE_TABLE_TO_SEARCH', - 'required' => 'true', - 'default' => $this->urlvalues['table_name']]; - // start the component options - $options = []; - $options['-1'] = 'COM_COMPONENTBUILDER__SEARCH_ALL_'; - // load table options from array - foreach($this->item['tables'] as $table) - { - $options[$table] = $this->escape($table); - } - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes, $options); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'settings'); - } - - // editor attributes - $attributes = [ - 'type' => 'editor', - 'name' => 'item_code', - 'label' => 'COM_COMPONENTBUILDER_ITEM_CODE', - 'width' => '100%', - 'height' => '150px', - 'class' => 'item_code_editor', - 'syntax' => 'php', - 'buttons' => 'false', - 'filter' => 'raw', - 'editor' => 'codemirror|none']; - // add to form - $xml = ComponentbuilderHelper::getFieldXML($attributes, $options); - if ($xml instanceof SimpleXMLElement) - { - $form->setField($xml, null, true, 'view'); - } - - // return the form array - return $form; - } - - return null; - } - - - /** - * Prepares the document - */ - protected function setDocument() - { - - // Only load jQuery if needed. (default is true) - if ($this->params->get('add_jquery_framework', 1) == 1) - { - JHtml::_('jquery.framework'); - } - // Load the header checker class. - require_once( JPATH_COMPONENT_ADMINISTRATOR.'/helpers/headercheck.php' ); - // Initialize the header checker. - $HeaderCheck = new componentbuilderHeaderCheck; - - // always load these files. - JHtml::_('stylesheet', "media/com_componentbuilder/datatable/css/datatables.min.css", ['version' => 'auto']); - JHtml::_('script', "media/com_componentbuilder/datatable/js/pdfmake.min.js", ['version' => 'auto']); - JHtml::_('script', "media/com_componentbuilder/datatable/js/vfs_fonts.js", ['version' => 'auto']); - JHtml::_('script', "media/com_componentbuilder/datatable/js/datatables.min.js", ['version' => 'auto']); - - // Add View JavaScript File - JHtml::_('script', "administrator/components/com_componentbuilder/assets/js/search.js", ['version' => 'auto']); - - // Load uikit options. - $uikit = $this->params->get('uikit_load'); - // Set script size. - $size = $this->params->get('uikit_min'); - // Set css style. - $style = $this->params->get('uikit_style'); - - // The uikit css. - if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) - { - JHtml::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit'.$style.$size.'.css', ['version' => 'auto']); - } - // The uikit js. - if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) - { - JHtml::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit'.$size.'.js', ['version' => 'auto']); - } - - // Load the script to find all uikit components needed. - if ($uikit != 2) - { - // Set the default uikit components in this view. - $uikitComp = array(); - $uikitComp[] = 'UIkit.notify'; - $uikitComp[] = 'uk-progress'; - } - - // Load the needed uikit components in this view. - if ($uikit != 2 && isset($uikitComp) && ComponentbuilderHelper::checkArray($uikitComp)) - { - // load just in case. - jimport('joomla.filesystem.file'); - // loading... - foreach ($uikitComp as $class) - { - foreach (ComponentbuilderHelper::$uk_components[$class] as $name) - { - // check if the CSS file exists. - if (File::exists(JPATH_ROOT.'/media/com_componentbuilder/uikit-v2/css/components/'.$name.$style.$size.'.css')) - { - // load the css. - JHtml::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/'.$name.$style.$size.'.css', ['version' => 'auto']); - } - // check if the JavaScript file exists. - if (File::exists(JPATH_ROOT.'/media/com_componentbuilder/uikit-v2/js/components/'.$name.$size.'.js')) - { - // load the js. - JHtml::_('script', 'media/com_componentbuilder/uikit-v2/js/components/'.$name.$size.'.js', ['version' => 'auto'], ['type' => 'text/javascript', 'async' => 'async']); - } - } - } - } - // add the document default css file - JHtml::_('stylesheet', 'administrator/components/com_componentbuilder/assets/css/search.css', ['version' => 'auto']); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - // hide the main menu - $this->app->input->set('hidemainmenu', true); - // set the title - if (isset($this->item->name) && $this->item->name) - { - $title = $this->item->name; - } - // Check for empty title and add view name if param is set - if (empty($title)) - { - $title = JText::_('COM_COMPONENTBUILDER_SEARCH'); - } - // add title to the page - JToolbarHelper::title($title,'search'); - // add cpanel button - JToolBarHelper::custom('search.dashboard', 'grid-2', '', 'COM_COMPONENTBUILDER_DASH', false); - if ($this->canDo->get('search.compiler')) - { - // add Compiler button. - JToolBarHelper::custom('search.openCompiler', 'cogs custom-button-opencompiler', '', 'COM_COMPONENTBUILDER_COMPILER', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('search'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } -} -?> diff --git a/admin/views/server/submitbutton.js b/admin/views/server/submitbutton.js deleted file mode 100644 index 4986c28fe..000000000 --- a/admin/views/server/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('server, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/server/tmpl/edit.php b/admin/views/server/tmpl/edit.php deleted file mode 100644 index bd675e67e..000000000 --- a/admin/views/server/tmpl/edit.php +++ /dev/null @@ -1,293 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/server/view.html.php b/admin/views/server/view.html.php deleted file mode 100644 index b7e642b5a..000000000 --- a/admin/views/server/view.html.php +++ /dev/null @@ -1,210 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Server Html View class - */ -class ComponentbuilderViewServer extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('server', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Get Linked view data - $this->vymlinked_components = $this->get('Vymlinked_components'); - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_SERVER_NEW' : 'COM_COMPONENTBUILDER_SERVER_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('server.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('server.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('server.edit')) - { - // We can save the record. - JToolBarHelper::save('server.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('server.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('server.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('server.create')) - { - JToolBarHelper::apply('server.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('server.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('server.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('server.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('server.edit')) - { - // We can save the new record - JToolBarHelper::apply('server.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('server.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('server.create')) - { - JToolBarHelper::custom('server.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('server.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('server.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.server', $this->item->id); - } - if ($this->canDo->get('server.create')) - { - JToolBarHelper::custom('server.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('server.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('server'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_SERVER_NEW' : 'COM_COMPONENTBUILDER_SERVER_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/server.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - - // Add the CSS for Footable - $this->document->addStyleSheet('https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css'); - JHtml::_('stylesheet', 'media/com_componentbuilder/footable-v3/css/footable.standalone.min.css', ['version' => 'auto']); - // Add the JavaScript for Footable (adding all functions) - JHtml::_('script', 'media/com_componentbuilder/footable-v3/js/footable.min.js', ['version' => 'auto']); - - $footable = "jQuery(document).ready(function() { jQuery(function () { jQuery('.footable').footable();});});"; - $this->document->addScriptDeclaration($footable); - - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/server/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/servers/tmpl/default.php b/admin/views/servers/tmpl/default.php deleted file mode 100644 index b84cf54a0..000000000 --- a/admin/views/servers/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=servers.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'serverList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_SERVERS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/servers/tmpl/default_batch_body.php b/admin/views/servers/tmpl/default_batch_body.php deleted file mode 100644 index f91464307..000000000 --- a/admin/views/servers/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/servers/tmpl/default_batch_footer.php b/admin/views/servers/tmpl/default_batch_footer.php deleted file mode 100644 index 0692a5c57..000000000 --- a/admin/views/servers/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/servers/tmpl/default_body.php b/admin/views/servers/tmpl/default_body.php deleted file mode 100644 index f2a7974ca..000000000 --- a/admin/views/servers/tmpl/default_body.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=servers&task=server.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('server',$item,'servers'); - ?> - - - get('server.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('server.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('server.edit')): ?> - escape($item->name); ?> - checked_out): ?> - name, $item->checked_out_time, 'servers.', $canCheckin); ?> - - - escape($item->name); ?> - -
    - - - protocol); ?> - - - get('server.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'servers.', true, 'cb'); ?> - - published, $i, 'servers.', false, 'cb'); ?> - - - published, $i, 'servers.', true, 'cb'); ?> - - - published, $i, 'servers.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/servers/tmpl/default_foot.php b/admin/views/servers/tmpl/default_foot.php deleted file mode 100644 index 95317c3bb..000000000 --- a/admin/views/servers/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/servers/tmpl/default_head.php b/admin/views/servers/tmpl/default_head.php deleted file mode 100644 index 06760984f..000000000 --- a/admin/views/servers/tmpl/default_head.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/servers/tmpl/default_toolbar.php b/admin/views/servers/tmpl/default_toolbar.php deleted file mode 100644 index 4bc821545..000000000 --- a/admin/views/servers/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/servers/view.html.php b/admin/views/servers/view.html.php deleted file mode 100644 index 7db0acf89..000000000 --- a/admin/views/servers/view.html.php +++ /dev/null @@ -1,272 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Servers - */ -class ComponentbuilderViewServers extends HtmlView -{ - /** - * Servers view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('servers'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('server'); - $this->canEdit = $this->canDo->get('server.edit'); - $this->canState = $this->canDo->get('server.edit.state'); - $this->canCreate = $this->canDo->get('server.create'); - $this->canDelete = $this->canDo->get('server.delete'); - $this->canBatch = ($this->canDo->get('server.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_SERVERS'), 'flash'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=servers'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('server.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('server.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('servers.publish'); - JToolBarHelper::unpublishList('servers.unpublish'); - JToolBarHelper::archiveList('servers.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('servers.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'servers.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('servers.trash'); - } - - if ($this->canDo->get('core.export') && $this->canDo->get('server.export')) - { - JToolBarHelper::custom('servers.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); - } - } - - if ($this->canDo->get('core.import') && $this->canDo->get('server.import')) - { - JToolBarHelper::custom('servers.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('servers'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - - // Only load Name batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Name Selection - $this->nameOptions = JFormHelper::loadFieldType('serversfiltername')->options; - // We do some sanitation for Name filter - if (ComponentbuilderHelper::checkArray($this->nameOptions) && - isset($this->nameOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->nameOptions[0]->value)) - { - unset($this->nameOptions[0]); - } - // Name Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_SERVER_NAME_LABEL').' -', - 'batch[name]', - JHtml::_('select.options', $this->nameOptions, 'value', 'text') - ); - } - - // Only load Protocol batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Protocol Selection - $this->protocolOptions = JFormHelper::loadFieldType('serversfilterprotocol')->options; - // We do some sanitation for Protocol filter - if (ComponentbuilderHelper::checkArray($this->protocolOptions) && - isset($this->protocolOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->protocolOptions[0]->value)) - { - unset($this->protocolOptions[0]); - } - // Protocol Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_SERVER_PROTOCOL_LABEL').' -', - 'batch[protocol]', - JHtml::_('select.options', $this->protocolOptions, 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_SERVERS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/servers.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.name' => JText::_('COM_COMPONENTBUILDER_SERVER_NAME_LABEL'), - 'a.protocol' => JText::_('COM_COMPONENTBUILDER_SERVER_PROTOCOL_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/site_view/submitbutton.js b/admin/views/site_view/submitbutton.js deleted file mode 100644 index ec8dff93c..000000000 --- a/admin/views/site_view/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('site_view, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/site_view/tmpl/edit.php b/admin/views/site_view/tmpl/edit.php deleted file mode 100644 index 60cf44aee..000000000 --- a/admin/views/site_view/tmpl/edit.php +++ /dev/null @@ -1,452 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/site_view/view.html.php b/admin/views/site_view/view.html.php deleted file mode 100644 index c62307a87..000000000 --- a/admin/views/site_view/view.html.php +++ /dev/null @@ -1,215 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Site_view Html View class - */ -class ComponentbuilderViewSite_view extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('site_view', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_SITE_VIEW_NEW' : 'COM_COMPONENTBUILDER_SITE_VIEW_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('core.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('site_view.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('core.edit')) - { - // We can save the record. - JToolBarHelper::save('site_view.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('site_view.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('site_view.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('core.create')) - { - JToolBarHelper::apply('site_view.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('site_view.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('site_view.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('site_view.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('core.edit')) - { - // We can save the new record - JToolBarHelper::apply('site_view.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('site_view.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('core.create')) - { - JToolBarHelper::custom('site_view.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('site_view.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('core.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.site_view', $this->item->id); - } - if ($this->canDo->get('core.create')) - { - JToolBarHelper::custom('site_view.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('site_view.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('site_view'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_SITE_VIEW_NEW' : 'COM_COMPONENTBUILDER_SITE_VIEW_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/site_view.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/site_view/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/site_views/tmpl/default.php b/admin/views/site_views/tmpl/default.php deleted file mode 100644 index f2899e4aa..000000000 --- a/admin/views/site_views/tmpl/default.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleMaingets', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_MAIN_GET') . ' -')); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=site_views.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'site_viewList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_SITE_VIEWS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/site_views/tmpl/default_batch_body.php b/admin/views/site_views/tmpl/default_batch_body.php deleted file mode 100644 index 402dc69ff..000000000 --- a/admin/views/site_views/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/site_views/tmpl/default_batch_footer.php b/admin/views/site_views/tmpl/default_batch_footer.php deleted file mode 100644 index 906f1ca8f..000000000 --- a/admin/views/site_views/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/site_views/tmpl/default_body.php b/admin/views/site_views/tmpl/default_body.php deleted file mode 100644 index 53f6fd84c..000000000 --- a/admin/views/site_views/tmpl/default_body.php +++ /dev/null @@ -1,123 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); -use VDM\Joomla\Utilities\StringHelper; - -$edit = "index.php?option=com_componentbuilder&view=site_views&task=site_view.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('site_view',$item,'site_views'); - ?> - - - get('core.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('core.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('core.edit')): ?> - escape($item->system_name); ?> - checked_out): ?> - name, $item->checked_out_time, 'site_views.', $canCheckin); ?> - - - escape($item->system_name); ?> - -
    - - -
    : - escape($item->name); ?>
    - : - escape($item->codename); ?>
    - context)): ?> - : - escape($item->context); ?> - -
    - - -
    - escape($item->description); ?> -
      -
    • : - add_custom_button); ?>
    • -
    • : - add_php_ajax); ?>
    • -
    -
    - - -
    - user->authorise('dynamic_get.edit', 'com_componentbuilder.dynamic_get.' . (int) $item->main_get)): ?> - escape($item->main_get_name); ?> - - escape($item->main_get_name); ?> - -
    - - - get('core.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'site_views.', true, 'cb'); ?> - - published, $i, 'site_views.', false, 'cb'); ?> - - - published, $i, 'site_views.', true, 'cb'); ?> - - - published, $i, 'site_views.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/site_views/tmpl/default_foot.php b/admin/views/site_views/tmpl/default_foot.php deleted file mode 100644 index 5a05d8cfd..000000000 --- a/admin/views/site_views/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/site_views/tmpl/default_head.php b/admin/views/site_views/tmpl/default_head.php deleted file mode 100644 index 5e43218c0..000000000 --- a/admin/views/site_views/tmpl/default_head.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/site_views/tmpl/default_toolbar.php b/admin/views/site_views/tmpl/default_toolbar.php deleted file mode 100644 index 8d1b9b7f4..000000000 --- a/admin/views/site_views/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/site_views/view.html.php b/admin/views/site_views/view.html.php deleted file mode 100644 index 02a3b2ece..000000000 --- a/admin/views/site_views/view.html.php +++ /dev/null @@ -1,300 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Site_views - */ -class ComponentbuilderViewSite_views extends HtmlView -{ - /** - * Site_views view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('site_views'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('site_view'); - $this->canEdit = $this->canDo->get('core.edit'); - $this->canState = $this->canDo->get('core.edit.state'); - $this->canCreate = $this->canDo->get('core.create'); - $this->canDelete = $this->canDo->get('core.delete'); - $this->canBatch = ($this->canDo->get('site_view.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_SITE_VIEWS'), 'palette'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=site_views'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('site_view.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('site_view.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('site_views.publish'); - JToolBarHelper::unpublishList('site_views.unpublish'); - JToolBarHelper::archiveList('site_views.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('site_views.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'site_views.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('site_views.trash'); - } - - if ($this->canDo->get('core.export') && $this->canDo->get('site_view.export')) - { - JToolBarHelper::custom('site_views.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); - } - } - if ($this->user->authorise('site_view.get_snippets', 'com_componentbuilder')) - { - // add Get Snippets button. - JToolBarHelper::custom('site_views.getSnippets', 'search custom-button-getsnippets', '', 'COM_COMPONENTBUILDER_GET_SNIPPETS', false); - } - - if ($this->canDo->get('core.import') && $this->canDo->get('site_view.import')) - { - JToolBarHelper::custom('site_views.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('site_views'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - - // Only load Main Get Name batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Main Get Name Selection - $this->main_getNameOptions = JFormHelper::loadFieldType('Maingets')->options; - // We do some sanitation for Main Get Name filter - if (ComponentbuilderHelper::checkArray($this->main_getNameOptions) && - isset($this->main_getNameOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->main_getNameOptions[0]->value)) - { - unset($this->main_getNameOptions[0]); - } - // Main Get Name Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_SITE_VIEW_MAIN_GET_LABEL').' -', - 'batch[main_get]', - JHtml::_('select.options', $this->main_getNameOptions, 'value', 'text') - ); - } - - // Only load Add Php Ajax batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Add Php Ajax Selection - $this->add_php_ajaxOptions = JFormHelper::loadFieldType('siteviewsfilteraddphpajax')->options; - // We do some sanitation for Add Php Ajax filter - if (ComponentbuilderHelper::checkArray($this->add_php_ajaxOptions) && - isset($this->add_php_ajaxOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->add_php_ajaxOptions[0]->value)) - { - unset($this->add_php_ajaxOptions[0]); - } - // Add Php Ajax Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_SITE_VIEW_ADD_PHP_AJAX_LABEL').' -', - 'batch[add_php_ajax]', - JHtml::_('select.options', $this->add_php_ajaxOptions, 'value', 'text') - ); - } - - // Only load Add Custom Button batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Add Custom Button Selection - $this->add_custom_buttonOptions = JFormHelper::loadFieldType('siteviewsfilteraddcustombutton')->options; - // We do some sanitation for Add Custom Button filter - if (ComponentbuilderHelper::checkArray($this->add_custom_buttonOptions) && - isset($this->add_custom_buttonOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->add_custom_buttonOptions[0]->value)) - { - unset($this->add_custom_buttonOptions[0]); - } - // Add Custom Button Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_SITE_VIEW_ADD_CUSTOM_BUTTON_LABEL').' -', - 'batch[add_custom_button]', - JHtml::_('select.options', $this->add_custom_buttonOptions, 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_SITE_VIEWS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/site_views.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.system_name' => JText::_('COM_COMPONENTBUILDER_SITE_VIEW_SYSTEM_NAME_LABEL'), - 'a.name' => JText::_('COM_COMPONENTBUILDER_SITE_VIEW_NAME_LABEL'), - 'a.description' => JText::_('COM_COMPONENTBUILDER_SITE_VIEW_DESCRIPTION_LABEL'), - 'g.name' => JText::_('COM_COMPONENTBUILDER_SITE_VIEW_MAIN_GET_LABEL'), - 'a.context' => JText::_('COM_COMPONENTBUILDER_SITE_VIEW_CONTEXT_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/snippet/submitbutton.js b/admin/views/snippet/submitbutton.js deleted file mode 100644 index 58fb3c4da..000000000 --- a/admin/views/snippet/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('snippet, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/snippet/tmpl/edit.php b/admin/views/snippet/tmpl/edit.php deleted file mode 100644 index 68e658b81..000000000 --- a/admin/views/snippet/tmpl/edit.php +++ /dev/null @@ -1,115 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> -
    -
    - - -
    - - 'details')); ?> - - -
    -
    - -
    -
    - -
    -
    - - - -
    -
    - -
    -
    - -
    -
    -
    -
    - -
    -
    - - - ignore_fieldsets = array('details','metadata','vdmmetadata','accesscontrol'); ?> - tab_name = 'snippetTab'; ?> - - - canDo->get('core.edit.created_by') || $this->canDo->get('core.edit.created') || $this->canDo->get('core.edit.state') || ($this->canDo->get('core.delete') && $this->canDo->get('core.edit.state'))) : ?> - -
    -
    - -
    -
    - -
    -
    - - - - canDo->get('core.admin')) : ?> - -
    -
    -
    -
    - form->getFieldset('accesscontrol') as $field): ?> -
    - label; echo $field->input;?> -
    -
    - -
    -
    -
    -
    - - - - - -
    - - -
    -
    -
    -
    - - diff --git a/admin/views/snippet/view.html.php b/admin/views/snippet/view.html.php deleted file mode 100644 index bd2f57932..000000000 --- a/admin/views/snippet/view.html.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Snippet Html View class - */ -class ComponentbuilderViewSnippet extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('snippet', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_SNIPPET_NEW' : 'COM_COMPONENTBUILDER_SNIPPET_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('core.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('snippet.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('core.edit')) - { - // We can save the record. - JToolBarHelper::save('snippet.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('snippet.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('snippet.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('core.create')) - { - JToolBarHelper::apply('snippet.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('snippet.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('snippet.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('snippet.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('core.edit')) - { - // We can save the new record - JToolBarHelper::apply('snippet.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('snippet.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('core.create')) - { - JToolBarHelper::custom('snippet.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('snippet.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('core.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.snippet', $this->item->id); - } - if ($this->canDo->get('core.create')) - { - JToolBarHelper::custom('snippet.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('snippet.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('snippet'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_SNIPPET_NEW' : 'COM_COMPONENTBUILDER_SNIPPET_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/snippet.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/snippet/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/snippet_type/submitbutton.js b/admin/views/snippet_type/submitbutton.js deleted file mode 100644 index e6ec4067a..000000000 --- a/admin/views/snippet_type/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('snippet_type, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/snippet_type/tmpl/edit.php b/admin/views/snippet_type/tmpl/edit.php deleted file mode 100644 index c5bbebb1a..000000000 --- a/admin/views/snippet_type/tmpl/edit.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - diff --git a/admin/views/snippet_type/view.html.php b/admin/views/snippet_type/view.html.php deleted file mode 100644 index fd0884e5d..000000000 --- a/admin/views/snippet_type/view.html.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Snippet_type Html View class - */ -class ComponentbuilderViewSnippet_type extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('snippet_type', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_SNIPPET_TYPE_NEW' : 'COM_COMPONENTBUILDER_SNIPPET_TYPE_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('snippet_type.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('snippet_type.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('snippet_type.edit')) - { - // We can save the record. - JToolBarHelper::save('snippet_type.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('snippet_type.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('snippet_type.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('snippet_type.create')) - { - JToolBarHelper::apply('snippet_type.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('snippet_type.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('snippet_type.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('snippet_type.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('snippet_type.edit')) - { - // We can save the new record - JToolBarHelper::apply('snippet_type.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('snippet_type.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('snippet_type.create')) - { - JToolBarHelper::custom('snippet_type.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('snippet_type.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('snippet_type.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.snippet_type', $this->item->id); - } - if ($this->canDo->get('snippet_type.create')) - { - JToolBarHelper::custom('snippet_type.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('snippet_type.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('snippet_type'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_SNIPPET_TYPE_NEW' : 'COM_COMPONENTBUILDER_SNIPPET_TYPE_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/snippet_type.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/snippet_type/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/snippet_types/tmpl/default.php b/admin/views/snippet_types/tmpl/default.php deleted file mode 100644 index 2313c0fee..000000000 --- a/admin/views/snippet_types/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=snippet_types.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'snippet_typeList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_SNIPPET_TYPES_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/snippet_types/tmpl/default_batch_body.php b/admin/views/snippet_types/tmpl/default_batch_body.php deleted file mode 100644 index 7f99c8ee8..000000000 --- a/admin/views/snippet_types/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/snippet_types/tmpl/default_batch_footer.php b/admin/views/snippet_types/tmpl/default_batch_footer.php deleted file mode 100644 index 4ef1c3200..000000000 --- a/admin/views/snippet_types/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/snippet_types/tmpl/default_body.php b/admin/views/snippet_types/tmpl/default_body.php deleted file mode 100644 index f5f925e37..000000000 --- a/admin/views/snippet_types/tmpl/default_body.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=snippet_types&task=snippet_type.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('snippet_type',$item,'snippet_types'); - ?> - - - get('snippet_type.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('snippet_type.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('snippet_type.edit')): ?> - escape($item->name); ?> - checked_out): ?> - name, $item->checked_out_time, 'snippet_types.', $canCheckin); ?> - - - escape($item->name); ?> - -
    - - - escape($item->description); ?> - - - get('snippet_type.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'snippet_types.', true, 'cb'); ?> - - published, $i, 'snippet_types.', false, 'cb'); ?> - - - published, $i, 'snippet_types.', true, 'cb'); ?> - - - published, $i, 'snippet_types.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/snippet_types/tmpl/default_foot.php b/admin/views/snippet_types/tmpl/default_foot.php deleted file mode 100644 index 95317c3bb..000000000 --- a/admin/views/snippet_types/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/snippet_types/tmpl/default_head.php b/admin/views/snippet_types/tmpl/default_head.php deleted file mode 100644 index 9b9cc7562..000000000 --- a/admin/views/snippet_types/tmpl/default_head.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/snippet_types/tmpl/default_toolbar.php b/admin/views/snippet_types/tmpl/default_toolbar.php deleted file mode 100644 index f00b63647..000000000 --- a/admin/views/snippet_types/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/snippet_types/view.html.php b/admin/views/snippet_types/view.html.php deleted file mode 100644 index 79f1fe119..000000000 --- a/admin/views/snippet_types/view.html.php +++ /dev/null @@ -1,222 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Snippet_types - */ -class ComponentbuilderViewSnippet_types extends HtmlView -{ - /** - * Snippet_types view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('snippet_types'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('snippet_type'); - $this->canEdit = $this->canDo->get('snippet_type.edit'); - $this->canState = $this->canDo->get('snippet_type.edit.state'); - $this->canCreate = $this->canDo->get('snippet_type.create'); - $this->canDelete = $this->canDo->get('snippet_type.delete'); - $this->canBatch = ($this->canDo->get('snippet_type.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_SNIPPET_TYPES'), 'joomla'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=snippet_types'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('snippet_type.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('snippet_type.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('snippet_types.publish'); - JToolBarHelper::unpublishList('snippet_types.unpublish'); - JToolBarHelper::archiveList('snippet_types.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('snippet_types.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'snippet_types.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('snippet_types.trash'); - } - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('snippet_types'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_SNIPPET_TYPES')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/snippet_types.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.name' => JText::_('COM_COMPONENTBUILDER_SNIPPET_TYPE_NAME_LABEL'), - 'a.description' => JText::_('COM_COMPONENTBUILDER_SNIPPET_TYPE_DESCRIPTION_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/snippets/tmpl/default.php b/admin/views/snippets/tmpl/default.php deleted file mode 100644 index aa14100b5..000000000 --- a/admin/views/snippets/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=snippets.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'snippetList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_SNIPPETS_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/snippets/tmpl/default_batch_body.php b/admin/views/snippets/tmpl/default_batch_body.php deleted file mode 100644 index 1289a64ac..000000000 --- a/admin/views/snippets/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/snippets/tmpl/default_batch_footer.php b/admin/views/snippets/tmpl/default_batch_footer.php deleted file mode 100644 index 3929f071f..000000000 --- a/admin/views/snippets/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/snippets/tmpl/default_body.php b/admin/views/snippets/tmpl/default_body.php deleted file mode 100644 index b99415f89..000000000 --- a/admin/views/snippets/tmpl/default_body.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=snippets&task=snippet.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('snippet',$item,'snippets'); - ?> - - - get('core.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('core.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('core.edit')): ?> - escape($item->name); ?> - checked_out): ?> - name, $item->checked_out_time, 'snippets.', $canCheckin); ?> - - - escape($item->name); ?> - -
    - - - escape($item->url); ?> - - - escape($item->type_name); ?> - - - escape($item->heading); ?> - - -
    - user->authorise('library.edit', 'com_componentbuilder.library.' . (int) $item->library)): ?> - escape($item->library_name); ?> - - escape($item->library_name); ?> - -
    - - - get('core.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'snippets.', true, 'cb'); ?> - - published, $i, 'snippets.', false, 'cb'); ?> - - - published, $i, 'snippets.', true, 'cb'); ?> - - - published, $i, 'snippets.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/snippets/tmpl/default_foot.php b/admin/views/snippets/tmpl/default_foot.php deleted file mode 100644 index 729d85997..000000000 --- a/admin/views/snippets/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/snippets/tmpl/default_head.php b/admin/views/snippets/tmpl/default_head.php deleted file mode 100644 index d5cddf81e..000000000 --- a/admin/views/snippets/tmpl/default_head.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/snippets/tmpl/default_toolbar.php b/admin/views/snippets/tmpl/default_toolbar.php deleted file mode 100644 index 99aa7ae7b..000000000 --- a/admin/views/snippets/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/snippets/view.html.php b/admin/views/snippets/view.html.php deleted file mode 100644 index 8e4745b49..000000000 --- a/admin/views/snippets/view.html.php +++ /dev/null @@ -1,285 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Snippets - */ -class ComponentbuilderViewSnippets extends HtmlView -{ - /** - * Snippets view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('snippets'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('snippet'); - $this->canEdit = $this->canDo->get('core.edit'); - $this->canState = $this->canDo->get('core.edit.state'); - $this->canCreate = $this->canDo->get('core.create'); - $this->canDelete = $this->canDo->get('core.delete'); - $this->canBatch = ($this->canDo->get('snippet.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_SNIPPETS'), 'pin'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=snippets'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('snippet.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('snippet.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('snippets.publish'); - JToolBarHelper::unpublishList('snippets.unpublish'); - JToolBarHelper::archiveList('snippets.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('snippets.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - if ($this->user->authorise('snippet.share_snippets', 'com_componentbuilder')) - { - // add Share Snippets button. - JToolBarHelper::custom('snippets.shareSnippets', 'share custom-button-sharesnippets', '', 'COM_COMPONENTBUILDER_SHARE_SNIPPETS', 'true'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'snippets.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('snippets.trash'); - } - - if ($this->canDo->get('core.export') && $this->canDo->get('snippet.export')) - { - JToolBarHelper::custom('snippets.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); - } - } - if ($this->user->authorise('snippet.get_snippets', 'com_componentbuilder')) - { - // add Get Snippets button. - JToolBarHelper::custom('snippets.getSnippets', 'search custom-button-getsnippets', '', 'COM_COMPONENTBUILDER_GET_SNIPPETS', false); - } - - if ($this->canDo->get('core.import') && $this->canDo->get('snippet.import')) - { - JToolBarHelper::custom('snippets.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('snippets'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - - // Only load Type Name batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Type Name Selection - $this->typeNameOptions = JFormHelper::loadFieldType('Snippettype')->options; - // We do some sanitation for Type Name filter - if (ComponentbuilderHelper::checkArray($this->typeNameOptions) && - isset($this->typeNameOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->typeNameOptions[0]->value)) - { - unset($this->typeNameOptions[0]); - } - // Type Name Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_SNIPPET_TYPE_LABEL').' -', - 'batch[type]', - JHtml::_('select.options', $this->typeNameOptions, 'value', 'text') - ); - } - - // Only load Library Name batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Library Name Selection - $this->libraryNameOptions = JFormHelper::loadFieldType('Library')->options; - // We do some sanitation for Library Name filter - if (ComponentbuilderHelper::checkArray($this->libraryNameOptions) && - isset($this->libraryNameOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->libraryNameOptions[0]->value)) - { - unset($this->libraryNameOptions[0]); - } - // Library Name Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_SNIPPET_LIBRARY_LABEL').' -', - 'batch[library]', - JHtml::_('select.options', $this->libraryNameOptions, 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_SNIPPETS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/snippets.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.name' => JText::_('COM_COMPONENTBUILDER_SNIPPET_NAME_LABEL'), - 'a.url' => JText::_('COM_COMPONENTBUILDER_SNIPPET_URL_LABEL'), - 'g.name' => JText::_('COM_COMPONENTBUILDER_SNIPPET_TYPE_LABEL'), - 'a.heading' => JText::_('COM_COMPONENTBUILDER_SNIPPET_HEADING_LABEL'), - 'h.name' => JText::_('COM_COMPONENTBUILDER_SNIPPET_LIBRARY_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/template/submitbutton.js b/admin/views/template/submitbutton.js deleted file mode 100644 index 74723b633..000000000 --- a/admin/views/template/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('template, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/template/tmpl/edit.php b/admin/views/template/tmpl/edit.php deleted file mode 100644 index 2adb04b73..000000000 --- a/admin/views/template/tmpl/edit.php +++ /dev/null @@ -1,233 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/template/view.html.php b/admin/views/template/view.html.php deleted file mode 100644 index 2d5340c42..000000000 --- a/admin/views/template/view.html.php +++ /dev/null @@ -1,215 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Template Html View class - */ -class ComponentbuilderViewTemplate extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('template', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_TEMPLATE_NEW' : 'COM_COMPONENTBUILDER_TEMPLATE_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('core.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('template.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('core.edit')) - { - // We can save the record. - JToolBarHelper::save('template.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('template.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('template.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('core.create')) - { - JToolBarHelper::apply('template.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('template.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('template.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('template.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('core.edit')) - { - // We can save the new record - JToolBarHelper::apply('template.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('template.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('core.create')) - { - JToolBarHelper::custom('template.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('template.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('core.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.template', $this->item->id); - } - if ($this->canDo->get('core.create')) - { - JToolBarHelper::custom('template.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('template.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('template'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_TEMPLATE_NEW' : 'COM_COMPONENTBUILDER_TEMPLATE_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/template.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/template/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/templates/tmpl/default.php b/admin/views/templates/tmpl/default.php deleted file mode 100644 index 6394bb236..000000000 --- a/admin/views/templates/tmpl/default.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=templates.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'templateList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_TEMPLATES_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - - diff --git a/admin/views/templates/tmpl/default_batch_body.php b/admin/views/templates/tmpl/default_batch_body.php deleted file mode 100644 index ae13ab003..000000000 --- a/admin/views/templates/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/templates/tmpl/default_batch_footer.php b/admin/views/templates/tmpl/default_batch_footer.php deleted file mode 100644 index fb4335da5..000000000 --- a/admin/views/templates/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/templates/tmpl/default_body.php b/admin/views/templates/tmpl/default_body.php deleted file mode 100644 index 75559d769..000000000 --- a/admin/views/templates/tmpl/default_body.php +++ /dev/null @@ -1,111 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); -use VDM\Joomla\Utilities\StringHelper; - -$edit = "index.php?option=com_componentbuilder&view=templates&task=template.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('template',$item,'templates'); - ?> - - - get('core.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('core.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('core.edit')): ?> - escape($item->name); ?> - checked_out): ?> - name, $item->checked_out_time, 'templates.', $canCheckin); ?> - - - escape($item->name); ?> -
    - <?php echo $this->loadTemplate('alias); ?>'); ?> -
    - - -
    - escape($item->description); ?> -
      -
    • : - add_php_view); ?>
    • -
    -
    - - -
    - user->authorise('dynamic_get.edit', 'com_componentbuilder.dynamic_get.' . (int) $item->dynamic_get)): ?> - escape($item->dynamic_get_name); ?> - - escape($item->dynamic_get_name); ?> - -
    - - - get('core.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'templates.', true, 'cb'); ?> - - published, $i, 'templates.', false, 'cb'); ?> - - - published, $i, 'templates.', true, 'cb'); ?> - - - published, $i, 'templates.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/templates/tmpl/default_foot.php b/admin/views/templates/tmpl/default_foot.php deleted file mode 100644 index eff41e725..000000000 --- a/admin/views/templates/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/templates/tmpl/default_head.php b/admin/views/templates/tmpl/default_head.php deleted file mode 100644 index e8b9ce803..000000000 --- a/admin/views/templates/tmpl/default_head.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/templates/tmpl/default_toolbar.php b/admin/views/templates/tmpl/default_toolbar.php deleted file mode 100644 index 2d0034fdb..000000000 --- a/admin/views/templates/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/templates/view.html.php b/admin/views/templates/view.html.php deleted file mode 100644 index a478b3ac8..000000000 --- a/admin/views/templates/view.html.php +++ /dev/null @@ -1,278 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Templates - */ -class ComponentbuilderViewTemplates extends HtmlView -{ - /** - * Templates view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('templates'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('template'); - $this->canEdit = $this->canDo->get('core.edit'); - $this->canState = $this->canDo->get('core.edit.state'); - $this->canCreate = $this->canDo->get('core.create'); - $this->canDelete = $this->canDo->get('core.delete'); - $this->canBatch = ($this->canDo->get('template.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_TEMPLATES'), 'brush'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=templates'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('template.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('template.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('templates.publish'); - JToolBarHelper::unpublishList('templates.unpublish'); - JToolBarHelper::archiveList('templates.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('templates.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'templates.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('templates.trash'); - } - - if ($this->canDo->get('core.export') && $this->canDo->get('template.export')) - { - JToolBarHelper::custom('templates.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); - } - } - if ($this->user->authorise('template.get_snippets', 'com_componentbuilder')) - { - // add Get Snippets button. - JToolBarHelper::custom('templates.getSnippets', 'search custom-button-getsnippets', '', 'COM_COMPONENTBUILDER_GET_SNIPPETS', false); - } - - if ($this->canDo->get('core.import') && $this->canDo->get('template.import')) - { - JToolBarHelper::custom('templates.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('templates'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - - // Only load Dynamic Get Name batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Dynamic Get Name Selection - $this->dynamic_getNameOptions = JFormHelper::loadFieldType('Dynamicget')->options; - // We do some sanitation for Dynamic Get Name filter - if (ComponentbuilderHelper::checkArray($this->dynamic_getNameOptions) && - isset($this->dynamic_getNameOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->dynamic_getNameOptions[0]->value)) - { - unset($this->dynamic_getNameOptions[0]); - } - // Dynamic Get Name Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_TEMPLATE_DYNAMIC_GET_LABEL').' -', - 'batch[dynamic_get]', - JHtml::_('select.options', $this->dynamic_getNameOptions, 'value', 'text') - ); - } - - // Only load Add Php View batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Add Php View Selection - $this->add_php_viewOptions = JFormHelper::loadFieldType('templatesfilteraddphpview')->options; - // We do some sanitation for Add Php View filter - if (ComponentbuilderHelper::checkArray($this->add_php_viewOptions) && - isset($this->add_php_viewOptions[0]->value) && - !ComponentbuilderHelper::checkString($this->add_php_viewOptions[0]->value)) - { - unset($this->add_php_viewOptions[0]); - } - // Add Php View Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.JText::_('COM_COMPONENTBUILDER_TEMPLATE_ADD_PHP_VIEW_LABEL').' -', - 'batch[add_php_view]', - JHtml::_('select.options', $this->add_php_viewOptions, 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_TEMPLATES')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/templates.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.name' => JText::_('COM_COMPONENTBUILDER_TEMPLATE_NAME_LABEL'), - 'a.description' => JText::_('COM_COMPONENTBUILDER_TEMPLATE_DESCRIPTION_LABEL'), - 'g.name' => JText::_('COM_COMPONENTBUILDER_TEMPLATE_DYNAMIC_GET_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/admin/views/validation_rule/submitbutton.js b/admin/views/validation_rule/submitbutton.js deleted file mode 100644 index d91920818..000000000 --- a/admin/views/validation_rule/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('validation_rule, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/admin/views/validation_rule/tmpl/edit.php b/admin/views/validation_rule/tmpl/edit.php deleted file mode 100644 index 8d624b30d..000000000 --- a/admin/views/validation_rule/tmpl/edit.php +++ /dev/null @@ -1,159 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -JHtml::_('behavior.formvalidator'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead -?> - - - - diff --git a/admin/views/validation_rule/view.html.php b/admin/views/validation_rule/view.html.php deleted file mode 100644 index 2e5835a80..000000000 --- a/admin/views/validation_rule/view.html.php +++ /dev/null @@ -1,218 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Validation_rule Html View class - */ -class ComponentbuilderViewValidation_rule extends HtmlView -{ - /** - * display method of View - * @return void - */ - public function display($tpl = null) - { - // set params - $this->params = JComponentHelper::getParams('com_componentbuilder'); - // Assign the variables - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->script = $this->get('Script'); - $this->state = $this->get('State'); - // get action permissions - $this->canDo = ComponentbuilderHelper::getActions('validation_rule', $this->item); - // get input - $jinput = JFactory::getApplication()->input; - $this->ref = $jinput->get('ref', 0, 'word'); - $this->refid = $jinput->get('refid', 0, 'int'); - $return = $jinput->get('return', null, 'base64'); - // set the referral string - $this->referral = ''; - if ($this->refid && $this->ref) - { - // return to the item that referred to this item - $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; - } - elseif($this->ref) - { - // return to the list view that referred to this item - $this->referral = '&ref=' . (string)$this->ref; - } - // check return value - if (!is_null($return)) - { - // add the return value - $this->referral .= '&return=' . (string)$return; - } - - // Set the toolbar - $this->addToolBar(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); - $userId = $user->id; - $isNew = $this->item->id == 0; - - JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_VALIDATION_RULE_NEW' : 'COM_COMPONENTBUILDER_VALIDATION_RULE_EDIT'), 'pencil-2 article-add'); - // Built the actions for new and existing records. - if (ComponentbuilderHelper::checkString($this->referral)) - { - if ($this->canDo->get('validation_rule.create') && $isNew) - { - // We can create the record. - JToolBarHelper::save('validation_rule.save', 'JTOOLBAR_SAVE'); - } - elseif ($this->canDo->get('validation_rule.edit')) - { - // We can save the record. - JToolBarHelper::save('validation_rule.save', 'JTOOLBAR_SAVE'); - } - if ($isNew) - { - // Do not creat but cancel. - JToolBarHelper::cancel('validation_rule.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - // We can close it. - JToolBarHelper::cancel('validation_rule.cancel', 'JTOOLBAR_CLOSE'); - } - } - else - { - if ($isNew) - { - // For new records, check the create permission. - if ($this->canDo->get('validation_rule.create')) - { - JToolBarHelper::apply('validation_rule.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('validation_rule.save', 'JTOOLBAR_SAVE'); - JToolBarHelper::custom('validation_rule.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - }; - JToolBarHelper::cancel('validation_rule.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - if ($this->canDo->get('validation_rule.edit')) - { - // We can save the new record - JToolBarHelper::apply('validation_rule.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('validation_rule.save', 'JTOOLBAR_SAVE'); - // We can save this record, but check the create permission to see - // if we can return to make a new one. - if ($this->canDo->get('validation_rule.create')) - { - JToolBarHelper::custom('validation_rule.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - } - $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('validation_rule.version')); - if ($this->state->params->get('save_history', 1) && $this->canDo->get('validation_rule.edit') && $canVersion) - { - JToolbarHelper::versions('com_componentbuilder.validation_rule', $this->item->id); - } - if ($this->canDo->get('validation_rule.create')) - { - JToolBarHelper::custom('validation_rule.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - JToolBarHelper::cancel('validation_rule.cancel', 'JTOOLBAR_CLOSE'); - } - } - JToolbarHelper::divider(); - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('validation_rule'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 30) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_VALIDATION_RULE_NEW' : 'COM_COMPONENTBUILDER_VALIDATION_RULE_EDIT')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/validation_rule.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // Add Ajax Token - $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); - $this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - $this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/validation_rule/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - - // add the Uikit v2 style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); - - // add the Uikit v2 extra style sheets - $this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - // add Uikit v2 extra JavaScripts - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - $this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true); - // add var key - $this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';"); - // add return_here - $this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';"); - // need to add some language strings - JText::script('COM_COMPONENTBUILDER_VALIDATION_RULE_NAME_ALREADY_TAKEN_PLEASE_TRY_AGAIN'); - JText::script('COM_COMPONENTBUILDER_YOU_MUST_ADD_AN_UNIQUE_VALIDATION_RULE_NAME'); - JText::script('view not acceptable. Error'); - } -} diff --git a/admin/views/validation_rules/tmpl/default.php b/admin/views/validation_rules/tmpl/default.php deleted file mode 100644 index 50d328c3f..000000000 --- a/admin/views/validation_rules/tmpl/default.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -JHtml::_('behavior.multiselect'); -JHtml::_('dropdown.init'); -JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -')); -JHtml::_('formbehavior.chosen', 'select'); -if ($this->saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_componentbuilder&task=validation_rules.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'validation_ruleList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); -} -?> -
    -sidebar)): ?> -
    - sidebar; ?> -
    -
    - -
    - - $this)); -?> -items)): ?> -
    - -
    - - - loadTemplate('head');?> - loadTemplate('foot');?> - loadTemplate('body');?> -
    - - canCreate && $this->canEdit) : ?> - JText::_('COM_COMPONENTBUILDER_VALIDATION_RULES_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer') - ), - $this->loadTemplate('batch_body') - ); ?> - - -
    - - - - diff --git a/admin/views/validation_rules/tmpl/default_batch_body.php b/admin/views/validation_rules/tmpl/default_batch_body.php deleted file mode 100644 index 4e532f5bd..000000000 --- a/admin/views/validation_rules/tmpl/default_batch_body.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - -

    -batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/validation_rules/tmpl/default_batch_footer.php b/admin/views/validation_rules/tmpl/default_batch_footer.php deleted file mode 100644 index 86676cf46..000000000 --- a/admin/views/validation_rules/tmpl/default_batch_footer.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - - - \ No newline at end of file diff --git a/admin/views/validation_rules/tmpl/default_body.php b/admin/views/validation_rules/tmpl/default_body.php deleted file mode 100644 index ca5f83162..000000000 --- a/admin/views/validation_rules/tmpl/default_body.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_componentbuilder&view=validation_rules&task=validation_rule.edit"; - -?> -items as $i => $item): ?> - user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; - $userChkOut = JFactory::getUser($item->checked_out); - $canDo = ComponentbuilderHelper::getActions('validation_rule',$item,'validation_rules'); - ?> - - - get('validation_rule.edit.state')): ?> - saveOrder) - { - $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); - } - ?> - - - - saveOrder) : ?> - - - - ⋮ - - - - get('validation_rule.edit')): ?> - checked_out) : ?> - - id); ?> - - □ - - - id); ?> - - - □ - - - -
    - get('validation_rule.edit')): ?> - escape($item->name); ?> - checked_out): ?> - name, $item->checked_out_time, 'validation_rules.', $canCheckin); ?> - - - escape($item->name); ?> - -
    - - - escape($item->short_description); ?> - - - get('validation_rule.edit.state')) : ?> - checked_out) : ?> - - published, $i, 'validation_rules.', true, 'cb'); ?> - - published, $i, 'validation_rules.', false, 'cb'); ?> - - - published, $i, 'validation_rules.', true, 'cb'); ?> - - - published, $i, 'validation_rules.', false, 'cb'); ?> - - - - id; ?> - - - \ No newline at end of file diff --git a/admin/views/validation_rules/tmpl/default_foot.php b/admin/views/validation_rules/tmpl/default_foot.php deleted file mode 100644 index 95317c3bb..000000000 --- a/admin/views/validation_rules/tmpl/default_foot.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - pagination->getListFooter(); ?> - \ No newline at end of file diff --git a/admin/views/validation_rules/tmpl/default_head.php b/admin/views/validation_rules/tmpl/default_head.php deleted file mode 100644 index a61421d16..000000000 --- a/admin/views/validation_rules/tmpl/default_head.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> - - canEdit&& $this->canState): ?> - - listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> - - - - - - - ▾ - - - ■ - - - - listDirn, $this->listOrder); ?> - - - listDirn, $this->listOrder); ?> - - canState): ?> - - listDirn, $this->listOrder); ?> - - - - - - - - listDirn, $this->listOrder); ?> - - \ No newline at end of file diff --git a/admin/views/validation_rules/tmpl/default_toolbar.php b/admin/views/validation_rules/tmpl/default_toolbar.php deleted file mode 100644 index b6eeda570..000000000 --- a/admin/views/validation_rules/tmpl/default_toolbar.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> -
    - -
    - - -
    -
    - - pagination->getLimitBox(); ?> -
    -
    - - -
    -
    - - -
    -
    -
    \ No newline at end of file diff --git a/admin/views/validation_rules/view.html.php b/admin/views/validation_rules/view.html.php deleted file mode 100644 index 7b5467f0d..000000000 --- a/admin/views/validation_rules/view.html.php +++ /dev/null @@ -1,237 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Validation_rules - */ -class ComponentbuilderViewValidation_rules extends HtmlView -{ - /** - * Validation_rules view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - ComponentbuilderHelper::addSubmenu('validation_rules'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); - $this->user = JFactory::getUser(); - // Load the filter form from xml. - $this->filterForm = $this->get('FilterForm'); - // Load the active filters. - $this->activeFilters = $this->get('ActiveFilters'); - // Add the list ordering clause. - $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); - $this->saveOrder = $this->listOrder == 'a.ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions - $this->canDo = ComponentbuilderHelper::getActions('validation_rule'); - $this->canEdit = $this->canDo->get('validation_rule.edit'); - $this->canState = $this->canDo->get('validation_rule.edit.state'); - $this->canCreate = $this->canDo->get('validation_rule.create'); - $this->canDelete = $this->canDo->get('validation_rule.delete'); - $this->canBatch = ($this->canDo->get('validation_rule.batch') && $this->canDo->get('core.batch')); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_VALIDATION_RULES'), 'shield'); - JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=validation_rules'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('validation_rule.add'); - } - - // Only load if there are items - if (ComponentbuilderHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('validation_rule.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('validation_rules.publish'); - JToolBarHelper::unpublishList('validation_rules.unpublish'); - JToolBarHelper::archiveList('validation_rules.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('validation_rules.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'validation_rules.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('validation_rules.trash'); - } - - if ($this->canDo->get('core.export') && $this->canDo->get('validation_rule.export')) - { - JToolBarHelper::custom('validation_rules.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); - } - } - if ($this->user->authorise('validation_rule.run_expansion', 'com_componentbuilder')) - { - // add Run Expansion button. - JToolBarHelper::custom('validation_rules.runExpansion', 'expand-2 custom-button-runexpansion', '', 'COM_COMPONENTBUILDER_RUN_EXPANSION', false); - } - - if ($this->canDo->get('core.import') && $this->canDo->get('validation_rule.import')) - { - JToolBarHelper::custom('validation_rules.importData', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_DATA', false); - } - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('validation_rules'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_componentbuilder'); - } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - - // Only load access batch if create, edit and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_COMPONENTBUILDER_VALIDATION_RULES')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/validation_rules.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { - return array( - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.published' => JText::_('JSTATUS'), - 'a.name' => JText::_('COM_COMPONENTBUILDER_VALIDATION_RULE_NAME_LABEL'), - 'a.short_description' => JText::_('COM_COMPONENTBUILDER_VALIDATION_RULE_SHORT_DESCRIPTION_LABEL'), - 'a.id' => JText::_('JGRID_HEADING_ID') - ); - } -} diff --git a/componentbuilder.xml b/componentbuilder.xml index cec731d25..5a57c5f11 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,38 +1,39 @@ - + COM_COMPONENTBUILDER - 24th October, 2023 + 9th March, 2024 Llewellyn van der Merwe joomla@vdm.io https://dev.vdm.io Copyright (C) 2015 Vast Development Method. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt - 3.1.28 + 5.0.0-alpha1 Component Builder (v.3.1.28) +

    Component Builder (v.5.0.0-alpha1)

    The Component Builder for [Joomla](https://extensions.joomla.org/extension/component-builder/) is highly advanced tool that is truly able to build extremely complex components in a fraction of the time. Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have!

    Created by Llewellyn van der Merwe
    Development started 30th April, 2015

    ]]>
    + VDM\Component\Componentbuilder - + sql/install.mysql.utf8.sql - + sql/uninstall.mysql.utf8.sql - - script.php + + ComponentbuilderInstallerScript.php index.html @@ -44,36 +45,22 @@ Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/compo footable-v3 - + sql/updates/mysql/ - - controller.php - index.html - router.php - componentbuilder.php - router.php - assets - helpers - controllers - models - views - layouts - + - - language/en-GB/en-GB.com_componentbuilder.ini - language/en-GB/en-GB.com_componentbuilder.sys.ini - + COM_COMPONENTBUILDER_MENU + COM_COMPONENTBUILDER_MENU_DASHBOARD COM_COMPONENTBUILDER_MENU_COMPILER COM_COMPONENTBUILDER_MENU_JOOMLA_COMPONENTS COM_COMPONENTBUILDER_MENU_JOOMLA_MODULES @@ -99,18 +86,16 @@ Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/compo access.xml config.xml - controller.php index.html - componentbuilder.php README.txt assets - controllers - helpers - models - sql - tables - views + forms layouts + presets + services + sql + src + tmpl custom compiler @@ -122,6 +107,6 @@ Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/compo - https://git.vdm.dev/joomla/Component-Builder/raw/branch/master/componentbuilder_update_server.xml + https://git.vdm.dev/joomla/Component-Builder/raw/branch/5.x/componentbuilder_update_server.xml
    \ No newline at end of file diff --git a/componentbuilder_update_server.xml b/componentbuilder_update_server.xml index 0130d0525..4562db26e 100644 --- a/componentbuilder_update_server.xml +++ b/componentbuilder_update_server.xml @@ -1,1142 +1,14 @@ - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.5.1 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.5.1/JCB_v2.5.1.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.5.2 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.5.4/JCB_v2.5.4.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.5.3 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.5.4/JCB_v2.5.4.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.5.5 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.5.5/JCB_v2.5.5.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.5.6 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.5.6/JCB_v2.5.6.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.5.7 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.5.8/JCB_v2.5.8.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.5.8 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.5.8/JCB_v2.5.8.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.6.3 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.6.3/JCB_v2.6.3.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.6.4 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.6.5/JCB_v2.6.5.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.6.5 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.6.5/JCB_v2.6.5.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.6.6 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.6.6/JCB_v2.6.6.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.6.9 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.6.9/JCB_v2.6.9.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.6.11 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.6.11/JCB_v2.6.11.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.6.12 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.6.12/JCB_v2.6.12.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.6.13 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.6.13/JCB_v2.6.13.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.6.14 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.6.14/JCB_v2.6.14.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.6.16 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.6.16/JCB_v2.6.16.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.6.17 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.6.17/JCB_v2.6.17.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.7.0 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.7.0/JCB_v2.7.0.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.7.5 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.7.5/JCB_v2.7.5.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.7.8 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.7.8/JCB_v2.7.8.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.7.9 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.7.9/JCB_v2.7.9.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.7.10 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.7.10/JCB_v2.7.10.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.8.1 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.8.2/JCB_v2.8.2.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.8.2 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.8.2/JCB_v2.8.2.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.8.5 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.8.5/JCB_v2.8.5.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.8.6 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.9.0/JCB_v2.9.0.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.8.7 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.9.0/JCB_v2.9.0.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.8.8 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.9.0/JCB_v2.9.0.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.8.9 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.9.0/JCB_v2.9.0.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.9.1 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.9.1/JCB_v2.9.1.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.9.4 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.9.7/JCB_v2.9.7.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.9.8 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.9.8/JCB_v2.9.8.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.9.9 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.9.10/JCB_v2.9.10.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.9.11 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.9.11/JCB_v2.9.11.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.9.12 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.9.12/JCB_v2.9.12.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.9.14 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.9.14/JCB_v2.9.14.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.9.15 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.9.18/JCB_v2.9.18.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.9.16 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.9.18/JCB_v2.9.18.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.9.18 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.9.18/JCB_v2.9.18.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.9.19 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.9.21/JCB_v2.9.21.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.9.21 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.9.21/JCB_v2.9.21.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.9.31 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.10.0/JCB_v2.10.0.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.9.32 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.10.0/JCB_v2.10.0.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.9.33 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.10.0/JCB_v2.10.0.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.9.34 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.10.0/JCB_v2.10.0.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.9.35 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.10.0/JCB_v2.10.0.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.10.1 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.10.1/JCB_v2.10.1.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.10.2 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.10.4/JCB_v2.10.4.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.10.5 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.10.5/JCB_v2.10.5.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.10.6 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.10.9/JCB_v2.10.9.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.10.7 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.10.9/JCB_v2.10.9.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.10.9 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.10.9/JCB_v2.10.9.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.10.10 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.10.11/JCB_v2.10.11.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.10.11 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.10.11/JCB_v2.10.11.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.10.12 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.10.13/JCB_v2.10.13.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.11.4 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.11.4/JCB_v2.11.4.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.11.5 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.11.7/JCB_v2.11.7.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.12.1 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.12.4/JCB_v2.12.4.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - 2.12.4 - https://dev.vdm.io - - https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.12.4/JCB_v2.12.4.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - Component Builder Builds Complex Joomla Components pkg_component_builder package site - 2.12.10 + 3.2.0-beta4 https://dev.vdm.io - https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v2.12.10.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - pkg_component_builder - package - site - 2.12.16 - https://dev.vdm.io - - https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v2.12.16.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - com_componentbuilder - component - site - 2.13.1 - https://dev.vdm.io - - https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v2.13.1.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - pkg_component_builder - package - site - 3.1.5 - https://dev.vdm.io - - https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.1.5.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - pkg_component_builder - package - site - 3.1.12 - https://dev.vdm.io - - https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.1.12.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - pkg_component_builder - package - site - 3.1.19 - https://dev.vdm.io - - https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.1.19.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - pkg_component_builder - package - site - 3.1.21 - https://dev.vdm.io - - https://git.vdm.dev/api/v1/repos/joomla-beta/pkg-component-builder/archive/v3.1.22.zip + https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.2.0-beta4.zip beta @@ -1151,17 +23,17 @@ pkg_component_builder package site - 3.1.24 + 4.0.0-alpha1 https://dev.vdm.io - https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.1.24.zip + https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v5.0.0-alpha1.zip stable Llewellyn van der Merwe https://dev.vdm.io - + Component Builder @@ -1169,70 +41,16 @@ pkg_component_builder package site - 3.1.25 + 5.0.0-alpha1 https://dev.vdm.io - https://git.vdm.dev/api/v1/repos/joomla-beta/pkg-component-builder/archive/v3.1.25.zip + https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v5.0.0-alpha1.zip beta Llewellyn van der Merwe https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - pkg_component_builder - package - site - 3.1.26 - https://dev.vdm.io - - https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.1.26.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - pkg_component_builder - package - site - 3.1.27 - https://dev.vdm.io - - https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.1.27.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - - - - Component Builder - Builds Complex Joomla Components - pkg_component_builder - package - site - 3.1.28 - https://dev.vdm.io - - https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.1.28.zip - - - stable - - Llewellyn van der Merwe - https://dev.vdm.io - + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Utilities/Http.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Utilities/Http.php index 6c5b3c6e4..ea65e1c7e 100644 --- a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Utilities/Http.php +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Utilities/Http.php @@ -52,7 +52,7 @@ final class Http extends JoomlaHttp // add the token if given if (is_string($token)) { - $config['headers']['Authorization'] = 'token ' . $token; + $config['headers']['Authorization'] = $token; $this->_token_ = $token; } @@ -78,7 +78,7 @@ final class Http extends JoomlaHttp ); // add the token - $headers['Authorization'] = 'token ' . $token; + $headers['Authorization'] = $token; $this->_token_ = $token; $this->setOption('headers', $headers); diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Utilities/Response.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Utilities/Response.php index 4b3574efb..ed98fff86 100644 --- a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Utilities/Response.php +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Utilities/Response.php @@ -12,7 +12,7 @@ namespace VDM\Joomla\Gitea\Utilities; -use Joomla\CMS\Http\Response as JoomlaResponse; +use Joomla\Http\Response as JoomlaResponse; use VDM\Joomla\Utilities\JsonHelper; use VDM\Joomla\Utilities\StringHelper; @@ -36,7 +36,7 @@ final class Response * @since 3.2.0 * @throws \DomainException **/ - public function get(JoomlaResponse $response, int $expectedCode = 200, $default = null) + public function get($response, int $expectedCode = 200, $default = null) { // Validate the response code. if ($response->code != $expectedCode) @@ -62,7 +62,7 @@ final class Response * @since 3.2.0 * @throws \DomainException **/ - public function get_(JoomlaResponse $response, array $validate = [200 => null]) + public function get_($response, array $validate = [200 => null]) { // Validate the response code. if (!isset($validate[$response->code])) @@ -86,24 +86,23 @@ final class Response * @return mixed * @since 3.2.0 **/ - protected function body(JoomlaResponse $response, $default = null) + protected function body($response, $default = null) { - // check that we have a body and that its JSON - if (isset($response->body) && StringHelper::check($response->body)) + $body = $response->body ?? null; + // check that we have a body + if (StringHelper::check($body)) { - if (JsonHelper::check($response->body)) + if (JsonHelper::check($body)) { - $body = json_decode((string) $response->body); + $body = json_decode((string) $body); if (isset($body->content_base64)) { $body->content = base64_decode((string) $body->content_base64); } - - return $body; } - return $response->body; + return $body; } return $default; @@ -117,7 +116,7 @@ final class Response * @return string * @since 3.2.0 **/ - protected function error(JoomlaResponse $response): string + protected function error($response): string { // do we have a json string if (isset($response->body) && JsonHelper::check($response->body)) @@ -140,7 +139,6 @@ final class Response } return ''; - } - + } } diff --git a/libraries/jcb_powers/VDM.Joomla.Openai/src/Utilities/Response.php b/libraries/jcb_powers/VDM.Joomla.Openai/src/Utilities/Response.php index b07d31d96..826f8060f 100644 --- a/libraries/jcb_powers/VDM.Joomla.Openai/src/Utilities/Response.php +++ b/libraries/jcb_powers/VDM.Joomla.Openai/src/Utilities/Response.php @@ -12,7 +12,7 @@ namespace VDM\Joomla\Openai\Utilities; -use Joomla\CMS\Http\Response as JoomlaResponse; +use Joomla\Http\Response as JoomlaResponse; use VDM\Joomla\Utilities\JsonHelper; use VDM\Joomla\Utilities\StringHelper; @@ -36,7 +36,7 @@ final class Response * @since 3.2.0 * @throws \DomainException **/ - public function get(JoomlaResponse $response, int $expectedCode = 200, $default = null) + public function get($response, int $expectedCode = 200, $default = null) { // Validate the response code. if ($response->code != $expectedCode) @@ -62,7 +62,7 @@ final class Response * @since 3.2.0 * @throws \DomainException **/ - public function get_(JoomlaResponse $response, array $validate = [200 => null]) + public function get_($response, array $validate = [200 => null]) { // Validate the response code. if (!isset($validate[$response->code])) @@ -87,17 +87,18 @@ final class Response * @return mixed * @since 3.2.0 **/ - protected function body(JoomlaResponse $response, $default = null) + protected function body($response, $default = null) { - // check that we have a body and that its JSON - if (isset($response->body) && StringHelper::check($response->body)) + $body = $response->body ?? null; + // check that we have a body + if (StringHelper::check($body)) { - if (JsonHelper::check($response->body)) + if (JsonHelper::check($body)) { - return json_decode((string) $response->body); + $body = json_decode((string) $body); } - return $response->body; + return $body; } return $default; @@ -111,7 +112,7 @@ final class Response * @return string * @since 3.2.0 **/ - protected function error(JoomlaResponse $response): string + protected function error($response): string { // do we have a json string if (isset($response->body) && JsonHelper::check($response->body)) diff --git a/libraries/jcb_powers/VDM.Joomla/src/Abstraction/ActiveRegistry.php b/libraries/jcb_powers/VDM.Joomla/src/Abstraction/ActiveRegistry.php index 0eeb531d3..861fcf962 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Abstraction/ActiveRegistry.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Abstraction/ActiveRegistry.php @@ -32,6 +32,14 @@ abstract class ActiveRegistry implements Activeregistryinterface **/ protected array $active = []; + /** + * Base switch to add values as string or array + * + * @var boolean + * @since 3.2.0 + **/ + protected bool $addAsArray = false; + /** * Check if the registry has any content. * @@ -95,21 +103,29 @@ abstract class ActiveRegistry implements Activeregistryinterface * Adds content into the registry. If a key exists, * it either appends or concatenates based on the value's type. * - * @param mixed $value The value to set. - * @param bool $asArray Determines if the new value should be treated as an array. - * @param string ...$keys The keys to determine the location. + * @param mixed $value The value to set. + * @param bool|null $asArray Determines if the new value should be treated as an array. + * Default is $addAsArray = false (if null) in base class. + * Override in child class allowed set class property $addAsArray = true. + * @param string ...$keys The keys to determine the location. * * @throws \InvalidArgumentException If any of the keys are not a number or string. * @return void * @since 3.2.0 */ - public function addActive($value, bool $asArray, string ...$keys): void + public function addActive($value, ?bool $asArray, string ...$keys): void { if (!$this->validActiveKeys($keys)) { throw new \InvalidArgumentException("Keys must only be strings or numbers to add any value."); } + // null fallback to class value + if ($asArray === null) + { + $asArray = $this->addAsArray; + } + $array = &$this->active; foreach ($keys as $key) diff --git a/libraries/jcb_powers/VDM.Joomla/src/Abstraction/BaseConfig.php b/libraries/jcb_powers/VDM.Joomla/src/Abstraction/BaseConfig.php index fbd3c09ab..c4debc288 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Abstraction/BaseConfig.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Abstraction/BaseConfig.php @@ -42,7 +42,7 @@ abstract class BaseConfig extends JoomlaRegistry * * @since 3.2.0 */ - public function __set(string $key, $value) + public function __set($key, $value) { $this->set($key, $value); } @@ -50,12 +50,12 @@ abstract class BaseConfig extends JoomlaRegistry /** * getting any valid value * - * @param string $key The value's key/path name + * @param string $key The value's key/path name * * @since 3.2.0 * @throws \InvalidArgumentException If $key is not a valid function name. */ - public function __get(string $key) + public function __get($key) { // check if it has been set if (($value = $this->get($key, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_') diff --git a/libraries/jcb_powers/VDM.Joomla/src/Abstraction/Database.php b/libraries/jcb_powers/VDM.Joomla/src/Abstraction/Database.php index f615e709e..7e2a21657 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Abstraction/Database.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Abstraction/Database.php @@ -26,10 +26,9 @@ abstract class Database /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 */ - protected \JDatabaseDriver $db; + protected $db; /** * Core Component Table Name @@ -42,14 +41,12 @@ abstract class Database /** * Constructor * - * @param \JDatabaseDriver|null $db The database driver - * * @throws \Exception * @since 3.2.0 */ - public function __construct(?\JDatabaseDriver $db = null) + public function __construct() { - $this->db = $db ?: JoomlaFactory::getDbo(); + $this->db = JoomlaFactory::getDbo(); // set the component table $this->table = '#__' . Helper::getCode(); diff --git a/libraries/jcb_powers/VDM.Joomla/src/Abstraction/Registry.php b/libraries/jcb_powers/VDM.Joomla/src/Abstraction/Registry.php index bbe1daba9..fe113289c 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Abstraction/Registry.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Abstraction/Registry.php @@ -58,15 +58,17 @@ abstract class Registry extends ActiveRegistry implements Activeregistryinterfac * Adds content into the registry. If a key exists, * it either appends or concatenates based on $asArray switch. * - * @param string $path Registry path (e.g. vdm.content.builder) - * @param mixed $value Value of entry - * @param bool $asArray Determines if the new value should be treated as an array. Default is false. + * @param string $path Registry path (e.g. vdm.content.builder) + * @param mixed $value Value of entry + * @param bool|null $asArray Determines if the new value should be treated as an array. + * Default is $addAsArray = false (if null) in base class. + * Override in child class allowed set class property $addAsArray = true. * * @throws \InvalidArgumentException If any of the path values are not a number or string. * @return void * @since 3.2.0 */ - public function add(string $path, $value, bool $asArray = false): void + public function add(string $path, $value, ?bool $asArray = null): void { if (($keys = $this->getActiveKeys($path)) === null) { diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Adminview/Data.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Adminview/Data.php index bda82d831..3f82ff0b0 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Adminview/Data.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Adminview/Data.php @@ -17,7 +17,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Config; use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event; use VDM\Joomla\Componentbuilder\Compiler\Placeholder; use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser; -use VDM\Joomla\Componentbuilder\Compiler\Model\Customtabs; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Model\CustomtabsInterface as Customtabs; use VDM\Joomla\Componentbuilder\Compiler\Model\Tabs; use VDM\Joomla\Componentbuilder\Compiler\Model\Fields; use VDM\Joomla\Componentbuilder\Compiler\Model\Historyadminview as History; @@ -226,10 +226,9 @@ class Data /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 **/ - protected \JDatabaseDriver $db; + protected $db; /** * Constructor. @@ -256,14 +255,13 @@ class Data * @param Sql $sql The Sql Class. * @param Mysqlsettings $mysqlsettings The Mysqlsettings Class. * @param SiteEditView $siteeditview The SiteEditView Class. - * @param \JDatabaseDriver|null $db The Database Class. * * @since 3.2.0 */ public function __construct(Config $config, Event $event, Placeholder $placeholder, Dispenser $dispenser, Customtabs $customtabs, Tabs $tabs, Fields $fields, History $history, Permissions $permissions, Conditions $conditions, Relations $relations, Linkedviews $linkedviews, Javascript $javascript, Css $css, Php $php, Custombuttons $custombuttons, Customimportscripts $customimportscripts, Ajax $ajax, Customalias $customalias, Sql $sql, - Mysqlsettings $mysqlsettings, SiteEditView $siteeditview, ?\JDatabaseDriver $db = null) + Mysqlsettings $mysqlsettings, SiteEditView $siteeditview) { $this->config = $config; $this->event = $event; @@ -287,7 +285,7 @@ class Data $this->sql = $sql; $this->mysqlsettings = $mysqlsettings; $this->siteeditview = $siteeditview; - $this->db = $db ?: Factory::getDbo(); + $this->db = Factory::getDbo(); } /** @@ -357,12 +355,9 @@ class Data $query->where($this->db->quoteName('a.id') . ' = ' . (int) $id); - // for plugin event TODO change event api signatures - $component_context = $this->config->component_context; // Trigger Event: jcb_ce_onBeforeQueryViewData $this->event->trigger( - 'jcb_ce_onBeforeQueryViewData', - array(&$component_context, &$id, &$query, &$this->db) + 'jcb_ce_onBeforeQueryViewData', [&$id, &$query, &$this->db] ); // Reset the query using our newly populated query object. @@ -423,16 +418,10 @@ class Data $view->name_list, 'U' )); - // for plugin event TODO change event api signatures - $placeholders = $this->placeholder->active; - $component_context = $this->config->component_context; - // Trigger Event: jcb_ce_onBeforeModelViewData $this->event->trigger( - 'jcb_ce_onBeforeModelViewData', - array(&$component_context, &$view, &$placeholders) + 'jcb_ce_onBeforeModelViewData', [&$view] ); - unset($placeholders); // add the tables $view->addtables = (isset($view->addtables) @@ -502,13 +491,9 @@ class Data // set mySql Table Settings $this->mysqlsettings->set($view); - // for plugin event TODO change event api signatures - $placeholders = $this->placeholder->active; - // Trigger Event: jcb_ce_onAfterModelViewData $this->event->trigger( - 'jcb_ce_onAfterModelViewData', - array(&$component_context, &$view, &$placeholders) + 'jcb_ce_onAfterModelViewData', [&$view] ); // clear placeholders diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Alias/Data.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Alias/Data.php index 42bf0d31a..c01caa196 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Alias/Data.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Alias/Data.php @@ -82,10 +82,9 @@ class Data /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 **/ - protected \JDatabaseDriver $db; + protected $db; /** * Constructor @@ -102,8 +101,7 @@ class Data */ public function __construct(?Config $config = null, ?Registry $registry = null, ?Customcode $customcode = null, ?Gui $gui = null, - ?Loader $loader = null, ?Libraries $libraries = null, - ?\JDatabaseDriver $db = null) + ?Loader $loader = null, ?Libraries $libraries = null) { $this->config = $config ?: Compiler::_('Config'); $this->registry = $registry ?: Compiler::_('Registry'); @@ -111,7 +109,7 @@ class Data $this->gui = $gui ?: Compiler::_('Customcode.Gui'); $this->loader = $loader ?: Compiler::_('Model.Loader'); $this->libraries = $libraries ?: Compiler::_('Model.Libraries'); - $this->db = $db ?: Factory::getDbo(); + $this->db = Factory::getDbo(); } /** diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Controller/AllowAdd.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Controller/AllowAdd.php new file mode 100644 index 000000000..2b7fbdbae --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Controller/AllowAdd.php @@ -0,0 +1,129 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Controller; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission; +use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowAddInterface; + + +/** + * Controller Allow Add Class for Joomla 5 + * + * @since 3.2.0 + */ +final class AllowAdd implements AllowAddInterface +{ + /** + * The Component code name. + * + * @var String + * @since 3.2.0 + */ + protected String $component; + + /** + * The Permission Class. + * + * @var Permission + * @since 3.2.0 + */ + protected Permission $permission; + + /** + * The Dispenser Class. + * + * @var Dispenser + * @since 3.2.0 + */ + protected Dispenser $dispenser; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Permission $permission The Permission Class. + * @param Dispenser $dispenser The Dispenser Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Permission $permission, + Dispenser $dispenser) + { + $this->component = $config->component_code_name; + $this->permission = $permission; + $this->dispenser = $dispenser; + } + + /** + * Get Allow Add Function Code + * + * @param string $nameSingleCode The single code name of the view. + * + * @since 3.2.0 + * @return string The allow add method code + */ + public function get(string $nameSingleCode): string + { + $allow = []; + + // prepare custom permission script + $custom_allow = $this->dispenser->get( + 'php_allowadd', $nameSingleCode, '', null, true + ); + + $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Get user object."; + $allow[] = Indent::_(2) . "\$user = \$this->app->getIdentity();"; + // check if the item has permissions. + if ($this->permission->globalExist($nameSingleCode, 'core.access')) + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Access check."; + $allow[] = Indent::_(2) . "\$access = \$user->authorise('" + . $this->permission->getGlobal($nameSingleCode, 'core.access') + . "', 'com_" . $this->component . "');"; + $allow[] = Indent::_(2) . "if (!\$access)"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "return false;"; + $allow[] = Indent::_(2) . "}"; + } + + // load custom permission script + $allow[] = $custom_allow; + + // check if the item has permissions. + if ($this->permission->globalExist($nameSingleCode, 'core.create')) + { + // setup the default script + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " In the absence of better information, revert to the component permissions."; + $allow[] = Indent::_(2) . "return \$user->authorise('" + . $this->permission->getGlobal($nameSingleCode, 'core.create') + . "', \$this->option);"; + } + else + { + // setup the default script + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " In the absence of better information, revert to the component permissions."; + $allow[] = Indent::_(2) . "return parent::allowAdd(\$data);"; + } + + return implode(PHP_EOL, $allow); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Controller/AllowEdit.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Controller/AllowEdit.php new file mode 100644 index 000000000..39a2d363c --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Controller/AllowEdit.php @@ -0,0 +1,300 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Controller; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission; +use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Category; +use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryOtherName; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowEditInterface; + + +/** + * Controller Allow Edit Class for Joomla 5 + * + * @since 3.2.0 + */ +final class AllowEdit implements AllowEditInterface +{ + /** + * The Component code name. + * + * @var String + * @since 3.2.0 + */ + protected String $component; + + /** + * The Permission Class. + * + * @var Permission + * @since 3.2.0 + */ + protected Permission $permission; + + /** + * The Dispenser Class. + * + * @var Dispenser + * @since 3.2.0 + */ + protected Dispenser $dispenser; + + /** + * The Category Class. + * + * @var Category + * @since 3.2.0 + */ + protected Category $category; + + /** + * The CategoryOtherName Class. + * + * @var CategoryOtherName + * @since 3.2.0 + */ + protected CategoryOtherName $categoryothername; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Permission $permission The Permission Class. + * @param Dispenser $dispenser The Dispenser Class. + * @param Category $category The Category Class. + * @param CategoryOtherName $categoryothername The CategoryOtherName Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Permission $permission, + Dispenser $dispenser, Category $category, + CategoryOtherName $categoryothername) + { + $this->component = $config->component_code_name; + $this->permission = $permission; + $this->dispenser = $dispenser; + $this->category = $category; + $this->categoryothername = $categoryothername; + } + + /** + * Get Allow Edit Function Code + * + * @param string $nameSingleCode The single code name of the view. + * @param string $nameListCode The list code name of the view. + * + * @since 3.2.0 + * @return string The allow edit method code + */ + public function get(string $nameSingleCode, string $nameListCode): string + { + $allow = []; + + // prepare custom permission script + $customAllow = $this->dispenser->get( + 'php_allowedit', $nameSingleCode, '', null, true + ); + + if ($this->category->exists("{$nameListCode}")) + { + // check if category has another name + $otherViews = $this->categoryothername-> + get($nameListCode . '.views', $nameListCode); + $otherView = $this->categoryothername-> + get($nameListCode . '.view', $nameSingleCode); + // setup the category script + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get user object."; + $allow[] = Indent::_(2) . "\$user = \$this->app->getIdentity();"; + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get record id."; + $allow[] = Indent::_(2) + . "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;"; + // load custom permission script + $allow[] = $customAllow; + // check if the item has permissions. + if ($this->permission->globalExist($otherView, 'core.access')) + { + $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Access check."; + $allow[] = Indent::_(2) . "\$access = (\$user->authorise('" + . $this->permission->getGlobal($otherView, 'core.access') + . "', 'com_" . $this->component . "." . $otherView + . ".' . (int) \$recordId) && \$user->authorise('" + . $this->permission->getGlobal($otherView, 'core.access') + . "', 'com_" . $this->component . "'));"; + $allow[] = Indent::_(2) . "if (!\$access)"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "return false;"; + $allow[] = Indent::_(2) . "}"; + } + $allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " The record has been set. Check the record permissions."; + // check if the item has permissions. + $allow[] = Indent::_(3) . "\$permission = \$user->authorise('" + . $this->permission->getAction($otherView, 'core.edit') . "', 'com_" . $this->component . "." + . $otherView . ".' . (int) \$recordId);"; + $allow[] = Indent::_(3) . "if (!\$permission)"; + $allow[] = Indent::_(3) . "{"; + // check if the item has permissions. + $allow[] = Indent::_(4) . "if (\$user->authorise('" + . $this->permission->getAction($otherView, 'core.edit.own') . "', 'com_" . $this->component . "." + . $otherView . ".' . \$recordId))"; + $allow[] = Indent::_(4) . "{"; + $allow[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " Fallback on edit.own. Now test the owner is the user."; + $allow[] = Indent::_(5) + . "\$ownerId = (int) isset(\$data['created_by']) ? \$data['created_by'] : 0;"; + $allow[] = Indent::_(5) . "if (empty(\$ownerId))"; + $allow[] = Indent::_(5) . "{"; + $allow[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__) + . " Need to do a lookup from the model."; + $allow[] = Indent::_(6) + . "\$record = \$this->getModel()->getItem(\$recordId);"; + $allow[] = PHP_EOL . Indent::_(6) . "if (empty(\$record))"; + $allow[] = Indent::_(6) . "{"; + $allow[] = Indent::_(7) . "return false;"; + $allow[] = Indent::_(6) . "}"; + $allow[] = Indent::_(6) . "\$ownerId = \$record->created_by;"; + $allow[] = Indent::_(5) . "}"; + $allow[] = PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " If the owner matches 'me' then do the test."; + $allow[] = Indent::_(5) . "if (\$ownerId == \$user->id)"; + $allow[] = Indent::_(5) . "{"; + // check if the item has permissions. + $allow[] = Indent::_(6) . "if (\$user->authorise('" + . $this->permission->getGlobal($otherView, 'core.edit.own') . "', 'com_" . $this->component . "'))"; + $allow[] = Indent::_(6) . "{"; + $allow[] = Indent::_(7) . "return true;"; + $allow[] = Indent::_(6) . "}"; + $allow[] = Indent::_(5) . "}"; + $allow[] = Indent::_(4) . "}"; + $allow[] = Indent::_(4) . "return false;"; + $allow[] = Indent::_(3) . "}"; + $allow[] = Indent::_(2) . "}"; + if ($this->permission->globalExist($otherView, 'core.edit')) + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Since there is no permission, revert to the component permissions."; + $allow[] = Indent::_(2) . "return \$user->authorise('" + . $this->permission->getGlobal($otherView, 'core.edit') . "', \$this->option);"; + } + else + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Since there is no permission, revert to the component permissions."; + $allow[] = Indent::_(2) + . "return parent::allowEdit(\$data, \$key);"; + } + } + else + { + // setup the category script + $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get user object."; + $allow[] = Indent::_(2) . "\$user = \$this->app->getIdentity();"; + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get record id."; + $allow[] = Indent::_(2) + . "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;"; + // load custom permission script + $allow[] = $customAllow; + // check if the item has permissions. + if ($this->permission->actionExist($nameSingleCode, 'core.access')) + { + $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Access check."; + $allow[] = Indent::_(2) . "\$access = (\$user->authorise('" + . $this->permission->getAction($nameSingleCode, 'core.access') . "', 'com_" . $this->component . "." + . $nameSingleCode + . ".' . (int) \$recordId) && \$user->authorise('" + . $this->permission->getAction($nameSingleCode, 'core.access') . "', 'com_" . $this->component . "'));"; + $allow[] = Indent::_(2) . "if (!\$access)"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "return false;"; + $allow[] = Indent::_(2) . "}"; + } + $allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " The record has been set. Check the record permissions."; + // check if the item has permissions. + $allow[] = Indent::_(3) . "\$permission = \$user->authorise('" + . $this->permission->getAction($nameSingleCode, 'core.edit') . "', 'com_" . $this->component . "." + . $nameSingleCode . ".' . (int) \$recordId);"; + $allow[] = Indent::_(3) . "if (!\$permission)"; + $allow[] = Indent::_(3) . "{"; + // check if the item has permissions. + $allow[] = Indent::_(4) . "if (\$user->authorise('" + . $this->permission->getAction($nameSingleCode, 'core.edit.own') . "', 'com_" . $this->component . "." + . $nameSingleCode . ".' . \$recordId))"; + $allow[] = Indent::_(4) . "{"; + $allow[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " Now test the owner is the user."; + $allow[] = Indent::_(5) + . "\$ownerId = (int) isset(\$data['created_by']) ? \$data['created_by'] : 0;"; + $allow[] = Indent::_(5) . "if (empty(\$ownerId))"; + $allow[] = Indent::_(5) . "{"; + $allow[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__) + . " Need to do a lookup from the model."; + $allow[] = Indent::_(6) + . "\$record = \$this->getModel()->getItem(\$recordId);"; + $allow[] = PHP_EOL . Indent::_(6) . "if (empty(\$record))"; + $allow[] = Indent::_(6) . "{"; + $allow[] = Indent::_(7) . "return false;"; + $allow[] = Indent::_(6) . "}"; + $allow[] = Indent::_(6) . "\$ownerId = \$record->created_by;"; + $allow[] = Indent::_(5) . "}"; + $allow[] = PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " If the owner matches 'me' then allow."; + $allow[] = Indent::_(5) . "if (\$ownerId == \$user->id)"; + $allow[] = Indent::_(5) . "{"; + // check if the item has permissions. + $allow[] = Indent::_(6) . "if (\$user->authorise('" + . $this->permission->getGlobal($nameSingleCode, 'core.edit.own') . "', 'com_" . $this->component . "'))"; + $allow[] = Indent::_(6) . "{"; + $allow[] = Indent::_(7) . "return true;"; + $allow[] = Indent::_(6) . "}"; + $allow[] = Indent::_(5) . "}"; + $allow[] = Indent::_(4) . "}"; + $allow[] = Indent::_(4) . "return false;"; + $allow[] = Indent::_(3) . "}"; + $allow[] = Indent::_(2) . "}"; + if ($this->permission->globalExist($nameSingleCode, 'core.edit')) + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Since there is no permission, revert to the component permissions."; + $allow[] = Indent::_(2) . "return \$user->authorise('" + . $this->permission->getGlobal($nameSingleCode, 'core.edit') . "', \$this->option);"; + } + else + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Since there is no permission, revert to the component permissions."; + $allow[] = Indent::_(2) + . "return parent::allowEdit(\$data, \$key);"; + } + } + + return implode(PHP_EOL, $allow); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Controller/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Controller/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Controller/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Model/CanDelete.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Model/CanDelete.php new file mode 100644 index 000000000..b9cf8d994 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Model/CanDelete.php @@ -0,0 +1,87 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Model; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CanDeleteInterface; + + +/** + * Model Can Delete Class for Joomla 5 + * + * @since 3.2.0 + */ +final class CanDelete implements CanDeleteInterface +{ + /** + * The Component code name. + * + * @var String + * @since 3.2.0 + */ + protected String $component; + + /** + * The Permission Class. + * + * @var Permission + * @since 3.2.0 + */ + protected Permission $permission; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Permission $permission The Permission Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Permission $permission) + { + $this->component = $config->component_code_name; + $this->permission = $permission; + } + + /** + * Get Can Delete Function Code + * + * @param string $nameSingleCode The single code name of the view. + * + * @since 3.2.0 + * @return string The can delete method code + */ + public function get(string $nameSingleCode): string + { + $allow = []; + + // setup the default script + $allow[] = PHP_EOL . Indent::_(2) . "if (empty(\$record->id) || (\$record->published != -2))"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "return false;"; + $allow[] = Indent::_(2) . "}" . PHP_EOL; + + // check if the item has permissions. + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " The record has been set. Check the record permissions."; + $allow[] = Indent::_(2) . "return \$this->getCurrentUser()->authorise('" + . $this->permission->getAction($nameSingleCode, 'core.delete') . "', 'com_" . $this->component . "." + . $nameSingleCode . ".' . (int) \$record->id);"; + + return implode(PHP_EOL, $allow); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Model/CanEditState.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Model/CanEditState.php new file mode 100644 index 000000000..318644a3c --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Model/CanEditState.php @@ -0,0 +1,108 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Model; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CanEditStateInterface; + + +/** + * Model Can Edit State Class for Joomla 5 + * + * @since 3.2.0 + */ +final class CanEditState implements CanEditStateInterface +{ + /** + * The Component code name. + * + * @var String + * @since 3.2.0 + */ + protected String $component; + + /** + * The Permission Class. + * + * @var Permission + * @since 3.2.0 + */ + protected Permission $permission; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Permission $permission The Permission Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Permission $permission) + { + $this->component = $config->component_code_name; + $this->permission = $permission; + } + + /** + * Get Can Edit State Function Code + * + * @param string $nameSingleCode The single code name of the view. + * + * @since 3.2.0 + * @return string The can edit state method code + */ + public function get(string $nameSingleCode): string + { + $allow = []; + + // setup the default script + $allow[] = PHP_EOL . Indent::_(2) . "\$user = \$this->getCurrentUser();"; + $allow[] = Indent::_(2) + . "\$recordId = \$record->id ?? 0;"; + $allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " The record has been set. Check the record permissions."; + // check if the item has permissions. + $allow[] = Indent::_(3) . "\$permission = \$user->authorise('" + . $this->permission->getAction($nameSingleCode, 'core.edit.state') + . "', 'com_" . $this->component . "." . $nameSingleCode . ".' . (int) \$recordId);"; + $allow[] = Indent::_(3) + . "if (!\$permission && !is_null(\$permission))"; + $allow[] = Indent::_(3) . "{"; + $allow[] = Indent::_(4) . "return false;"; + $allow[] = Indent::_(3) . "}"; + $allow[] = Indent::_(2) . "}"; + if ($this->permission->globalExist($nameSingleCode, 'core.edit.state')) + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " In the absence of better information, revert to the component permissions."; + $allow[] = Indent::_(2) . "return \$user->authorise('" + . $this->permission->getGlobal($nameSingleCode, 'core.edit.state') . "', 'com_" . $this->component + . "');"; + } + else + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " In the absence of better information, revert to the component permissions."; + $allow[] = Indent::_(2) + . "return parent::canEditState(\$record);"; + } + + return implode(PHP_EOL, $allow); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Model/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Model/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFive/Model/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Controller/AllowAdd.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Controller/AllowAdd.php new file mode 100644 index 000000000..8e3e47888 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Controller/AllowAdd.php @@ -0,0 +1,129 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Controller; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission; +use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowAddInterface; + + +/** + * Controller Allow Add Class for Joomla 4 + * + * @since 3.2.0 + */ +final class AllowAdd implements AllowAddInterface +{ + /** + * The Component code name. + * + * @var String + * @since 3.2.0 + */ + protected String $component; + + /** + * The Permission Class. + * + * @var Permission + * @since 3.2.0 + */ + protected Permission $permission; + + /** + * The Dispenser Class. + * + * @var Dispenser + * @since 3.2.0 + */ + protected Dispenser $dispenser; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Permission $permission The Permission Class. + * @param Dispenser $dispenser The Dispenser Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Permission $permission, + Dispenser $dispenser) + { + $this->component = $config->component_code_name; + $this->permission = $permission; + $this->dispenser = $dispenser; + } + + /** + * Get Allow Add Function Code + * + * @param string $nameSingleCode The single code name of the view. + * + * @since 3.2.0 + * @return string The allow add method code + */ + public function get(string $nameSingleCode): string + { + $allow = []; + + // prepare custom permission script + $custom_allow = $this->dispenser->get( + 'php_allowadd', $nameSingleCode, '', null, true + ); + + $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Get user object."; + $allow[] = Indent::_(2) . "\$user = \$this->app->getIdentity();"; + // check if the item has permissions. + if ($this->permission->globalExist($nameSingleCode, 'core.access')) + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Access check."; + $allow[] = Indent::_(2) . "\$access = \$user->authorise('" + . $this->permission->getGlobal($nameSingleCode, 'core.access') + . "', 'com_" . $this->component . "');"; + $allow[] = Indent::_(2) . "if (!\$access)"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "return false;"; + $allow[] = Indent::_(2) . "}"; + } + + // load custom permission script + $allow[] = $custom_allow; + + // check if the item has permissions. + if ($this->permission->globalExist($nameSingleCode, 'core.create')) + { + // setup the default script + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " In the absence of better information, revert to the component permissions."; + $allow[] = Indent::_(2) . "return \$user->authorise('" + . $this->permission->getGlobal($nameSingleCode, 'core.create') + . "', \$this->option);"; + } + else + { + // setup the default script + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " In the absence of better information, revert to the component permissions."; + $allow[] = Indent::_(2) . "return parent::allowAdd(\$data);"; + } + + return implode(PHP_EOL, $allow); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Controller/AllowEdit.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Controller/AllowEdit.php new file mode 100644 index 000000000..0c5e0d5ba --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Controller/AllowEdit.php @@ -0,0 +1,300 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Controller; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission; +use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Category; +use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryOtherName; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowEditInterface; + + +/** + * Controller Allow Edit Class for Joomla 4 + * + * @since 3.2.0 + */ +final class AllowEdit implements AllowEditInterface +{ + /** + * The Component code name. + * + * @var String + * @since 3.2.0 + */ + protected String $component; + + /** + * The Permission Class. + * + * @var Permission + * @since 3.2.0 + */ + protected Permission $permission; + + /** + * The Dispenser Class. + * + * @var Dispenser + * @since 3.2.0 + */ + protected Dispenser $dispenser; + + /** + * The Category Class. + * + * @var Category + * @since 3.2.0 + */ + protected Category $category; + + /** + * The CategoryOtherName Class. + * + * @var CategoryOtherName + * @since 3.2.0 + */ + protected CategoryOtherName $categoryothername; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Permission $permission The Permission Class. + * @param Dispenser $dispenser The Dispenser Class. + * @param Category $category The Category Class. + * @param CategoryOtherName $categoryothername The CategoryOtherName Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Permission $permission, + Dispenser $dispenser, Category $category, + CategoryOtherName $categoryothername) + { + $this->component = $config->component_code_name; + $this->permission = $permission; + $this->dispenser = $dispenser; + $this->category = $category; + $this->categoryothername = $categoryothername; + } + + /** + * Get Allow Edit Function Code + * + * @param string $nameSingleCode The single code name of the view. + * @param string $nameListCode The list code name of the view. + * + * @since 3.2.0 + * @return string The allow edit method code + */ + public function get(string $nameSingleCode, string $nameListCode): string + { + $allow = []; + + // prepare custom permission script + $customAllow = $this->dispenser->get( + 'php_allowedit', $nameSingleCode, '', null, true + ); + + if ($this->category->exists("{$nameListCode}")) + { + // check if category has another name + $otherViews = $this->categoryothername-> + get($nameListCode . '.views', $nameListCode); + $otherView = $this->categoryothername-> + get($nameListCode . '.view', $nameSingleCode); + // setup the category script + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get user object."; + $allow[] = Indent::_(2) . "\$user = \$this->app->getIdentity();"; + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get record id."; + $allow[] = Indent::_(2) + . "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;"; + // load custom permission script + $allow[] = $customAllow; + // check if the item has permissions. + if ($this->permission->globalExist($otherView, 'core.access')) + { + $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Access check."; + $allow[] = Indent::_(2) . "\$access = (\$user->authorise('" + . $this->permission->getGlobal($otherView, 'core.access') + . "', 'com_" . $this->component . "." . $otherView + . ".' . (int) \$recordId) && \$user->authorise('" + . $this->permission->getGlobal($otherView, 'core.access') + . "', 'com_" . $this->component . "'));"; + $allow[] = Indent::_(2) . "if (!\$access)"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "return false;"; + $allow[] = Indent::_(2) . "}"; + } + $allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " The record has been set. Check the record permissions."; + // check if the item has permissions. + $allow[] = Indent::_(3) . "\$permission = \$user->authorise('" + . $this->permission->getAction($otherView, 'core.edit') . "', 'com_" . $this->component . "." + . $otherView . ".' . (int) \$recordId);"; + $allow[] = Indent::_(3) . "if (!\$permission)"; + $allow[] = Indent::_(3) . "{"; + // check if the item has permissions. + $allow[] = Indent::_(4) . "if (\$user->authorise('" + . $this->permission->getAction($otherView, 'core.edit.own') . "', 'com_" . $this->component . "." + . $otherView . ".' . \$recordId))"; + $allow[] = Indent::_(4) . "{"; + $allow[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " Fallback on edit.own. Now test the owner is the user."; + $allow[] = Indent::_(5) + . "\$ownerId = (int) isset(\$data['created_by']) ? \$data['created_by'] : 0;"; + $allow[] = Indent::_(5) . "if (empty(\$ownerId))"; + $allow[] = Indent::_(5) . "{"; + $allow[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__) + . " Need to do a lookup from the model."; + $allow[] = Indent::_(6) + . "\$record = \$this->getModel()->getItem(\$recordId);"; + $allow[] = PHP_EOL . Indent::_(6) . "if (empty(\$record))"; + $allow[] = Indent::_(6) . "{"; + $allow[] = Indent::_(7) . "return false;"; + $allow[] = Indent::_(6) . "}"; + $allow[] = Indent::_(6) . "\$ownerId = \$record->created_by;"; + $allow[] = Indent::_(5) . "}"; + $allow[] = PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " If the owner matches 'me' then do the test."; + $allow[] = Indent::_(5) . "if (\$ownerId == \$user->id)"; + $allow[] = Indent::_(5) . "{"; + // check if the item has permissions. + $allow[] = Indent::_(6) . "if (\$user->authorise('" + . $this->permission->getGlobal($otherView, 'core.edit.own') . "', 'com_" . $this->component . "'))"; + $allow[] = Indent::_(6) . "{"; + $allow[] = Indent::_(7) . "return true;"; + $allow[] = Indent::_(6) . "}"; + $allow[] = Indent::_(5) . "}"; + $allow[] = Indent::_(4) . "}"; + $allow[] = Indent::_(4) . "return false;"; + $allow[] = Indent::_(3) . "}"; + $allow[] = Indent::_(2) . "}"; + if ($this->permission->globalExist($otherView, 'core.edit')) + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Since there is no permission, revert to the component permissions."; + $allow[] = Indent::_(2) . "return \$user->authorise('" + . $this->permission->getGlobal($otherView, 'core.edit') . "', \$this->option);"; + } + else + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Since there is no permission, revert to the component permissions."; + $allow[] = Indent::_(2) + . "return parent::allowEdit(\$data, \$key);"; + } + } + else + { + // setup the category script + $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get user object."; + $allow[] = Indent::_(2) . "\$user = \$this->app->getIdentity();"; + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get record id."; + $allow[] = Indent::_(2) + . "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;"; + // load custom permission script + $allow[] = $customAllow; + // check if the item has permissions. + if ($this->permission->actionExist($nameSingleCode, 'core.access')) + { + $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Access check."; + $allow[] = Indent::_(2) . "\$access = (\$user->authorise('" + . $this->permission->getAction($nameSingleCode, 'core.access') . "', 'com_" . $this->component . "." + . $nameSingleCode + . ".' . (int) \$recordId) && \$user->authorise('" + . $this->permission->getAction($nameSingleCode, 'core.access') . "', 'com_" . $this->component . "'));"; + $allow[] = Indent::_(2) . "if (!\$access)"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "return false;"; + $allow[] = Indent::_(2) . "}"; + } + $allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " The record has been set. Check the record permissions."; + // check if the item has permissions. + $allow[] = Indent::_(3) . "\$permission = \$user->authorise('" + . $this->permission->getAction($nameSingleCode, 'core.edit') . "', 'com_" . $this->component . "." + . $nameSingleCode . ".' . (int) \$recordId);"; + $allow[] = Indent::_(3) . "if (!\$permission)"; + $allow[] = Indent::_(3) . "{"; + // check if the item has permissions. + $allow[] = Indent::_(4) . "if (\$user->authorise('" + . $this->permission->getAction($nameSingleCode, 'core.edit.own') . "', 'com_" . $this->component . "." + . $nameSingleCode . ".' . \$recordId))"; + $allow[] = Indent::_(4) . "{"; + $allow[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " Now test the owner is the user."; + $allow[] = Indent::_(5) + . "\$ownerId = (int) isset(\$data['created_by']) ? \$data['created_by'] : 0;"; + $allow[] = Indent::_(5) . "if (empty(\$ownerId))"; + $allow[] = Indent::_(5) . "{"; + $allow[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__) + . " Need to do a lookup from the model."; + $allow[] = Indent::_(6) + . "\$record = \$this->getModel()->getItem(\$recordId);"; + $allow[] = PHP_EOL . Indent::_(6) . "if (empty(\$record))"; + $allow[] = Indent::_(6) . "{"; + $allow[] = Indent::_(7) . "return false;"; + $allow[] = Indent::_(6) . "}"; + $allow[] = Indent::_(6) . "\$ownerId = \$record->created_by;"; + $allow[] = Indent::_(5) . "}"; + $allow[] = PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " If the owner matches 'me' then allow."; + $allow[] = Indent::_(5) . "if (\$ownerId == \$user->id)"; + $allow[] = Indent::_(5) . "{"; + // check if the item has permissions. + $allow[] = Indent::_(6) . "if (\$user->authorise('" + . $this->permission->getGlobal($nameSingleCode, 'core.edit.own') . "', 'com_" . $this->component . "'))"; + $allow[] = Indent::_(6) . "{"; + $allow[] = Indent::_(7) . "return true;"; + $allow[] = Indent::_(6) . "}"; + $allow[] = Indent::_(5) . "}"; + $allow[] = Indent::_(4) . "}"; + $allow[] = Indent::_(4) . "return false;"; + $allow[] = Indent::_(3) . "}"; + $allow[] = Indent::_(2) . "}"; + if ($this->permission->globalExist($nameSingleCode, 'core.edit')) + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Since there is no permission, revert to the component permissions."; + $allow[] = Indent::_(2) . "return \$user->authorise('" + . $this->permission->getGlobal($nameSingleCode, 'core.edit') . "', \$this->option);"; + } + else + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Since there is no permission, revert to the component permissions."; + $allow[] = Indent::_(2) + . "return parent::allowEdit(\$data, \$key);"; + } + } + + return implode(PHP_EOL, $allow); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Controller/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Controller/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Controller/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Model/CanDelete.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Model/CanDelete.php new file mode 100644 index 000000000..69208e39f --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Model/CanDelete.php @@ -0,0 +1,87 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Model; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CanDeleteInterface; + + +/** + * Model Can Delete Class for Joomla 4 + * + * @since 3.2.0 + */ +final class CanDelete implements CanDeleteInterface +{ + /** + * The Component code name. + * + * @var String + * @since 3.2.0 + */ + protected String $component; + + /** + * The Permission Class. + * + * @var Permission + * @since 3.2.0 + */ + protected Permission $permission; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Permission $permission The Permission Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Permission $permission) + { + $this->component = $config->component_code_name; + $this->permission = $permission; + } + + /** + * Get Can Delete Function Code + * + * @param string $nameSingleCode The single code name of the view. + * + * @since 3.2.0 + * @return string The can delete method code + */ + public function get(string $nameSingleCode): string + { + $allow = []; + + // setup the default script + $allow[] = PHP_EOL . Indent::_(2) . "if (empty(\$record->id) || (\$record->published != -2))"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "return false;"; + $allow[] = Indent::_(2) . "}" . PHP_EOL; + + // check if the item has permissions. + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " The record has been set. Check the record permissions."; + $allow[] = Indent::_(2) . "return \$this->getCurrentUser()->authorise('" + . $this->permission->getAction($nameSingleCode, 'core.delete') . "', 'com_" . $this->component . "." + . $nameSingleCode . ".' . (int) \$record->id);"; + + return implode(PHP_EOL, $allow); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Model/CanEditState.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Model/CanEditState.php new file mode 100644 index 000000000..aab38ca27 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Model/CanEditState.php @@ -0,0 +1,108 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Model; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CanEditStateInterface; + + +/** + * Model Can Edit State Class for Joomla 4 + * + * @since 3.2.0 + */ +final class CanEditState implements CanEditStateInterface +{ + /** + * The Component code name. + * + * @var String + * @since 3.2.0 + */ + protected String $component; + + /** + * The Permission Class. + * + * @var Permission + * @since 3.2.0 + */ + protected Permission $permission; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Permission $permission The Permission Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Permission $permission) + { + $this->component = $config->component_code_name; + $this->permission = $permission; + } + + /** + * Get Can Edit State Function Code + * + * @param string $nameSingleCode The single code name of the view. + * + * @since 3.2.0 + * @return string The can edit state method code + */ + public function get(string $nameSingleCode): string + { + $allow = []; + + // setup the default script + $allow[] = PHP_EOL . Indent::_(2) . "\$user = \$this->getCurrentUser();"; + $allow[] = Indent::_(2) + . "\$recordId = \$record->id ?? 0;"; + $allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " The record has been set. Check the record permissions."; + // check if the item has permissions. + $allow[] = Indent::_(3) . "\$permission = \$user->authorise('" + . $this->permission->getAction($nameSingleCode, 'core.edit.state') + . "', 'com_" . $this->component . "." . $nameSingleCode . ".' . (int) \$recordId);"; + $allow[] = Indent::_(3) + . "if (!\$permission && !is_null(\$permission))"; + $allow[] = Indent::_(3) . "{"; + $allow[] = Indent::_(4) . "return false;"; + $allow[] = Indent::_(3) . "}"; + $allow[] = Indent::_(2) . "}"; + if ($this->permission->globalExist($nameSingleCode, 'core.edit.state')) + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " In the absence of better information, revert to the component permissions."; + $allow[] = Indent::_(2) . "return \$user->authorise('" + . $this->permission->getGlobal($nameSingleCode, 'core.edit.state') . "', 'com_" . $this->component + . "');"; + } + else + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " In the absence of better information, revert to the component permissions."; + $allow[] = Indent::_(2) + . "return parent::canEditState(\$record);"; + } + + return implode(PHP_EOL, $allow); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Model/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Model/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaFour/Model/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Controller/AllowAdd.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Controller/AllowAdd.php new file mode 100644 index 000000000..7bb855a36 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Controller/AllowAdd.php @@ -0,0 +1,129 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Controller; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission; +use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowAddInterface; + + +/** + * Controller Allow Add Class for Joomla 3 + * + * @since 3.2.0 + */ +final class AllowAdd implements AllowAddInterface +{ + /** + * The Component code name. + * + * @var String + * @since 3.2.0 + */ + protected String $component; + + /** + * The Permission Class. + * + * @var Permission + * @since 3.2.0 + */ + protected Permission $permission; + + /** + * The Dispenser Class. + * + * @var Dispenser + * @since 3.2.0 + */ + protected Dispenser $dispenser; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Permission $permission The Permission Class. + * @param Dispenser $dispenser The Dispenser Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Permission $permission, + Dispenser $dispenser) + { + $this->component = $config->component_code_name; + $this->permission = $permission; + $this->dispenser = $dispenser; + } + + /** + * Get Allow Add Function Code + * + * @param string $nameSingleCode The single code name of the view. + * + * @since 3.2.0 + * @return string The allow add method code + */ + public function get(string $nameSingleCode): string + { + $allow = []; + + // prepare custom permission script + $custom_allow = $this->dispenser->get( + 'php_allowadd', $nameSingleCode, '', null, true + ); + + $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Get user object."; + $allow[] = Indent::_(2) . "\$user = Factory::getUser();"; + // check if the item has permissions. + if ($this->permission->globalExist($nameSingleCode, 'core.access')) + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Access check."; + $allow[] = Indent::_(2) . "\$access = \$user->authorise('" + . $this->permission->getGlobal($nameSingleCode, 'core.access') + . "', 'com_" . $this->component . "');"; + $allow[] = Indent::_(2) . "if (!\$access)"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "return false;"; + $allow[] = Indent::_(2) . "}"; + } + + // load custom permission script + $allow[] = $custom_allow; + + // check if the item has permissions. + if ($this->permission->globalExist($nameSingleCode, 'core.create')) + { + // setup the default script + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " In the absence of better information, revert to the component permissions."; + $allow[] = Indent::_(2) . "return \$user->authorise('" + . $this->permission->getGlobal($nameSingleCode, 'core.create') + . "', \$this->option);"; + } + else + { + // setup the default script + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " In the absence of better information, revert to the component permissions."; + $allow[] = Indent::_(2) . "return parent::allowAdd(\$data);"; + } + + return implode(PHP_EOL, $allow); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Controller/AllowEdit.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Controller/AllowEdit.php new file mode 100644 index 000000000..b41909b7b --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Controller/AllowEdit.php @@ -0,0 +1,300 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Controller; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission; +use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Category; +use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryOtherName; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowEditInterface; + + +/** + * Controller Allow Edit Class for Joomla 3 + * + * @since 3.2.0 + */ +final class AllowEdit implements AllowEditInterface +{ + /** + * The Component code name. + * + * @var String + * @since 3.2.0 + */ + protected String $component; + + /** + * The Permission Class. + * + * @var Permission + * @since 3.2.0 + */ + protected Permission $permission; + + /** + * The Dispenser Class. + * + * @var Dispenser + * @since 3.2.0 + */ + protected Dispenser $dispenser; + + /** + * The Category Class. + * + * @var Category + * @since 3.2.0 + */ + protected Category $category; + + /** + * The CategoryOtherName Class. + * + * @var CategoryOtherName + * @since 3.2.0 + */ + protected CategoryOtherName $categoryothername; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Permission $permission The Permission Class. + * @param Dispenser $dispenser The Dispenser Class. + * @param Category $category The Category Class. + * @param CategoryOtherName $categoryothername The CategoryOtherName Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Permission $permission, + Dispenser $dispenser, Category $category, + CategoryOtherName $categoryothername) + { + $this->component = $config->component_code_name; + $this->permission = $permission; + $this->dispenser = $dispenser; + $this->category = $category; + $this->categoryothername = $categoryothername; + } + + /** + * Get Allow Edit Function Code + * + * @param string $nameSingleCode The single code name of the view. + * @param string $nameListCode The list code name of the view. + * + * @since 3.2.0 + * @return string The allow edit method code + */ + public function get(string $nameSingleCode, string $nameListCode): string + { + $allow = []; + + // prepare custom permission script + $customAllow = $this->dispenser->get( + 'php_allowedit', $nameSingleCode, '', null, true + ); + + if ($this->category->exists("{$nameListCode}")) + { + // check if category has another name + $otherViews = $this->categoryothername-> + get($nameListCode . '.views', $nameListCode); + $otherView = $this->categoryothername-> + get($nameListCode . '.view', $nameSingleCode); + // setup the category script + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get user object."; + $allow[] = Indent::_(2) . "\$user = Factory::getUser();"; + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get record id."; + $allow[] = Indent::_(2) + . "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;"; + // load custom permission script + $allow[] = $customAllow; + // check if the item has permissions. + if ($this->permission->globalExist($otherView, 'core.access')) + { + $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Access check."; + $allow[] = Indent::_(2) . "\$access = (\$user->authorise('" + . $this->permission->getGlobal($otherView, 'core.access') + . "', 'com_" . $this->component . "." . $otherView + . ".' . (int) \$recordId) && \$user->authorise('" + . $this->permission->getGlobal($otherView, 'core.access') + . "', 'com_" . $this->component . "'));"; + $allow[] = Indent::_(2) . "if (!\$access)"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "return false;"; + $allow[] = Indent::_(2) . "}"; + } + $allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " The record has been set. Check the record permissions."; + // check if the item has permissions. + $allow[] = Indent::_(3) . "\$permission = \$user->authorise('" + . $this->permission->getAction($otherView, 'core.edit') . "', 'com_" . $this->component . "." + . $otherView . ".' . (int) \$recordId);"; + $allow[] = Indent::_(3) . "if (!\$permission)"; + $allow[] = Indent::_(3) . "{"; + // check if the item has permissions. + $allow[] = Indent::_(4) . "if (\$user->authorise('" + . $this->permission->getAction($otherView, 'core.edit.own') . "', 'com_" . $this->component . "." + . $otherView . ".' . \$recordId))"; + $allow[] = Indent::_(4) . "{"; + $allow[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " Fallback on edit.own. Now test the owner is the user."; + $allow[] = Indent::_(5) + . "\$ownerId = (int) isset(\$data['created_by']) ? \$data['created_by'] : 0;"; + $allow[] = Indent::_(5) . "if (empty(\$ownerId))"; + $allow[] = Indent::_(5) . "{"; + $allow[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__) + . " Need to do a lookup from the model."; + $allow[] = Indent::_(6) + . "\$record = \$this->getModel()->getItem(\$recordId);"; + $allow[] = PHP_EOL . Indent::_(6) . "if (empty(\$record))"; + $allow[] = Indent::_(6) . "{"; + $allow[] = Indent::_(7) . "return false;"; + $allow[] = Indent::_(6) . "}"; + $allow[] = Indent::_(6) . "\$ownerId = \$record->created_by;"; + $allow[] = Indent::_(5) . "}"; + $allow[] = PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " If the owner matches 'me' then do the test."; + $allow[] = Indent::_(5) . "if (\$ownerId == \$user->id)"; + $allow[] = Indent::_(5) . "{"; + // check if the item has permissions. + $allow[] = Indent::_(6) . "if (\$user->authorise('" + . $this->permission->getGlobal($otherView, 'core.edit.own') . "', 'com_" . $this->component . "'))"; + $allow[] = Indent::_(6) . "{"; + $allow[] = Indent::_(7) . "return true;"; + $allow[] = Indent::_(6) . "}"; + $allow[] = Indent::_(5) . "}"; + $allow[] = Indent::_(4) . "}"; + $allow[] = Indent::_(4) . "return false;"; + $allow[] = Indent::_(3) . "}"; + $allow[] = Indent::_(2) . "}"; + if ($this->permission->globalExist($otherView, 'core.edit')) + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Since there is no permission, revert to the component permissions."; + $allow[] = Indent::_(2) . "return \$user->authorise('" + . $this->permission->getGlobal($otherView, 'core.edit') . "', \$this->option);"; + } + else + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Since there is no permission, revert to the component permissions."; + $allow[] = Indent::_(2) + . "return parent::allowEdit(\$data, \$key);"; + } + } + else + { + // setup the category script + $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get user object."; + $allow[] = Indent::_(2) . "\$user = Factory::getUser();"; + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get record id."; + $allow[] = Indent::_(2) + . "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;"; + // load custom permission script + $allow[] = $customAllow; + // check if the item has permissions. + if ($this->permission->actionExist($nameSingleCode, 'core.access')) + { + $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Access check."; + $allow[] = Indent::_(2) . "\$access = (\$user->authorise('" + . $this->permission->getAction($nameSingleCode, 'core.access') . "', 'com_" . $this->component . "." + . $nameSingleCode + . ".' . (int) \$recordId) && \$user->authorise('" + . $this->permission->getAction($nameSingleCode, 'core.access') . "', 'com_" . $this->component . "'));"; + $allow[] = Indent::_(2) . "if (!\$access)"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "return false;"; + $allow[] = Indent::_(2) . "}"; + } + $allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " The record has been set. Check the record permissions."; + // check if the item has permissions. + $allow[] = Indent::_(3) . "\$permission = \$user->authorise('" + . $this->permission->getAction($nameSingleCode, 'core.edit') . "', 'com_" . $this->component . "." + . $nameSingleCode . ".' . (int) \$recordId);"; + $allow[] = Indent::_(3) . "if (!\$permission)"; + $allow[] = Indent::_(3) . "{"; + // check if the item has permissions. + $allow[] = Indent::_(4) . "if (\$user->authorise('" + . $this->permission->getAction($nameSingleCode, 'core.edit.own') . "', 'com_" . $this->component . "." + . $nameSingleCode . ".' . \$recordId))"; + $allow[] = Indent::_(4) . "{"; + $allow[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " Now test the owner is the user."; + $allow[] = Indent::_(5) + . "\$ownerId = (int) isset(\$data['created_by']) ? \$data['created_by'] : 0;"; + $allow[] = Indent::_(5) . "if (empty(\$ownerId))"; + $allow[] = Indent::_(5) . "{"; + $allow[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__) + . " Need to do a lookup from the model."; + $allow[] = Indent::_(6) + . "\$record = \$this->getModel()->getItem(\$recordId);"; + $allow[] = PHP_EOL . Indent::_(6) . "if (empty(\$record))"; + $allow[] = Indent::_(6) . "{"; + $allow[] = Indent::_(7) . "return false;"; + $allow[] = Indent::_(6) . "}"; + $allow[] = Indent::_(6) . "\$ownerId = \$record->created_by;"; + $allow[] = Indent::_(5) . "}"; + $allow[] = PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " If the owner matches 'me' then allow."; + $allow[] = Indent::_(5) . "if (\$ownerId == \$user->id)"; + $allow[] = Indent::_(5) . "{"; + // check if the item has permissions. + $allow[] = Indent::_(6) . "if (\$user->authorise('" + . $this->permission->getGlobal($nameSingleCode, 'core.edit.own') . "', 'com_" . $this->component . "'))"; + $allow[] = Indent::_(6) . "{"; + $allow[] = Indent::_(7) . "return true;"; + $allow[] = Indent::_(6) . "}"; + $allow[] = Indent::_(5) . "}"; + $allow[] = Indent::_(4) . "}"; + $allow[] = Indent::_(4) . "return false;"; + $allow[] = Indent::_(3) . "}"; + $allow[] = Indent::_(2) . "}"; + if ($this->permission->globalExist($nameSingleCode, 'core.edit')) + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Since there is no permission, revert to the component permissions."; + $allow[] = Indent::_(2) . "return \$user->authorise('" + . $this->permission->getGlobal($nameSingleCode, 'core.edit') . "', \$this->option);"; + } + else + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Since there is no permission, revert to the component permissions."; + $allow[] = Indent::_(2) + . "return parent::allowEdit(\$data, \$key);"; + } + } + + return implode(PHP_EOL, $allow); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Controller/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Controller/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Controller/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Model/CanDelete.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Model/CanDelete.php new file mode 100644 index 000000000..ff67ae8f7 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Model/CanDelete.php @@ -0,0 +1,91 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Model; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CanDeleteInterface; + + +/** + * Model Can Delete Class for Joomla 3 + * + * @since 3.2.0 + */ +final class CanDelete implements CanDeleteInterface +{ + /** + * The Component code name. + * + * @var String + * @since 3.2.0 + */ + protected String $component; + + /** + * The Permission Class. + * + * @var Permission + * @since 3.2.0 + */ + protected Permission $permission; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Permission $permission The Permission Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Permission $permission) + { + $this->component = $config->component_code_name; + $this->permission = $permission; + } + + /** + * Get Model Can Delete Function Code + * + * @param string $nameSingleCode The single code name of the view. + * + * @since 3.2.0 + * @return string The can delete method code + */ + public function get(string $nameSingleCode): string + { + $allow = []; + // setup the default script + $allow[] = PHP_EOL . Indent::_(2) . "if (!empty(\$record->id))"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "if (\$record->published != -2)"; + $allow[] = Indent::_(3) . "{"; + $allow[] = Indent::_(4) . "return;"; + $allow[] = Indent::_(3) . "}"; + // check if the item has permissions. + $allow[] = PHP_EOL . Indent::_(3) + . "\$user = Factory::getUser();"; + $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " The record has been set. Check the record permissions."; + $allow[] = Indent::_(3) . "return \$user->authorise('" + . $this->permission->getAction($nameSingleCode, 'core.delete') . "', 'com_" . $this->component . "." + . $nameSingleCode . ".' . (int) \$record->id);"; + $allow[] = Indent::_(2) . "}"; + $allow[] = Indent::_(2) . "return false;"; + + return implode(PHP_EOL, $allow); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Model/CanEditState.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Model/CanEditState.php new file mode 100644 index 000000000..6088d4d22 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Model/CanEditState.php @@ -0,0 +1,108 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Model; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CanEditStateInterface; + + +/** + * Model Can Edit State Class for Joomla 3 + * + * @since 3.2.0 + */ +final class CanEditState implements CanEditStateInterface +{ + /** + * The Component code name. + * + * @var String + * @since 3.2.0 + */ + protected String $component; + + /** + * The Permission Class. + * + * @var Permission + * @since 3.2.0 + */ + protected Permission $permission; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Permission $permission The Permission Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Permission $permission) + { + $this->component = $config->component_code_name; + $this->permission = $permission; + } + + /** + * Get Can Edit State Function Code + * + * @param string $nameSingleCode The single code name of the view. + * + * @since 3.2.0 + * @return string The can edit state method code + */ + public function get(string $nameSingleCode): string + { + $allow = []; + + // setup the default script + $allow[] = PHP_EOL . Indent::_(2) . "\$user = Factory::getUser();"; + $allow[] = Indent::_(2) + . "\$recordId = \$record->id ?? 0;"; + $allow[] = PHP_EOL . Indent::_(2) . "if (\$recordId)"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " The record has been set. Check the record permissions."; + // check if the item has permissions. + $allow[] = Indent::_(3) . "\$permission = \$user->authorise('" + . $this->permission->getAction($nameSingleCode, 'core.edit.state') + . "', 'com_" . $this->component . "." . $nameSingleCode . ".' . (int) \$recordId);"; + $allow[] = Indent::_(3) + . "if (!\$permission && !is_null(\$permission))"; + $allow[] = Indent::_(3) . "{"; + $allow[] = Indent::_(4) . "return false;"; + $allow[] = Indent::_(3) . "}"; + $allow[] = Indent::_(2) . "}"; + if ($this->permission->globalExist($nameSingleCode, 'core.edit.state')) + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " In the absence of better information, revert to the component permissions."; + $allow[] = Indent::_(2) . "return \$user->authorise('" + . $this->permission->getGlobal($nameSingleCode, 'core.edit.state') . "', 'com_" . $this->component + . "');"; + } + else + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " In the absence of better information, revert to the component permissions."; + $allow[] = Indent::_(2) + . "return parent::canEditState(\$record);"; + } + + return implode(PHP_EOL, $allow); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Model/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Model/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Architecture/JoomlaThree/Model/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/AssetsRules.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/AssetsRules.php new file mode 100644 index 000000000..0d24e0942 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/AssetsRules.php @@ -0,0 +1,42 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Builder; + + +use VDM\Joomla\Abstraction\Registry\Traits\IsArray; +use VDM\Joomla\Interfaces\Registryinterface; +use VDM\Joomla\Abstraction\Registry; + + +/** + * Assets Rules Builder Class + * + * @since 3.2.0 + */ +final class AssetsRules extends Registry implements Registryinterface +{ + /** + * Is an Array + * + * @since 3.2.0 + */ + use IsArray; + + /** + * Base switch to add values as string or array + * + * @var boolean + * @since 3.2.0 + **/ + protected bool $addAsArray = true; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/ConfigFieldsets.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/ConfigFieldsets.php new file mode 100644 index 000000000..26a0c6469 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/ConfigFieldsets.php @@ -0,0 +1,34 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Builder; + + +use VDM\Joomla\Interfaces\Registryinterface; +use VDM\Joomla\Abstraction\Registry; + + +/** + * Config Field Sets Builder Class + * + * @since 3.2.0 + */ +final class ConfigFieldsets extends Registry implements Registryinterface +{ + /** + * Base switch to add values as string or array + * + * @var boolean + * @since 3.2.0 + **/ + protected bool $addAsArray = true; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/ConfigFieldsetsCustomfield.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/ConfigFieldsetsCustomfield.php new file mode 100644 index 000000000..19f10f9d0 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/ConfigFieldsetsCustomfield.php @@ -0,0 +1,34 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Builder; + + +use VDM\Joomla\Abstraction\Registry\Traits\IsArray; +use VDM\Joomla\Interfaces\Registryinterface; +use VDM\Joomla\Abstraction\Registry; + + +/** + * Config Field Sets Custom Field Builder Class + * + * @since 3.2.0 + */ +final class ConfigFieldsetsCustomfield extends Registry implements Registryinterface +{ + /** + * Is an Array + * + * @since 3.2.0 + */ + use IsArray; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/Contributors.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/Contributors.php new file mode 100644 index 000000000..80bdc078b --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/Contributors.php @@ -0,0 +1,27 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Builder; + + +use VDM\Joomla\Interfaces\Registryinterface; +use VDM\Joomla\Abstraction\Registry; + + +/** + * Contributors Builder Class + * + * @since 3.2.0 + */ +final class Contributors extends Registry implements Registryinterface +{ +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/DatabaseUninstall.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/DatabaseUninstall.php new file mode 100644 index 000000000..5b4bab5ff --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/DatabaseUninstall.php @@ -0,0 +1,42 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Builder; + + +use VDM\Joomla\Abstraction\Registry\Traits\IsArray; +use VDM\Joomla\Interfaces\Registryinterface; +use VDM\Joomla\Abstraction\Registry; + + +/** + * Database Uninstall Builder Class + * + * @since 3.2.0 + */ +final class DatabaseUninstall extends Registry implements Registryinterface +{ + /** + * Is an Array + * + * @since 3.2.0 + */ + use IsArray; + + /** + * Base switch to add values as string or array + * + * @var boolean + * @since 3.2.0 + **/ + protected bool $addAsArray = true; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/ExtensionsParams.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/ExtensionsParams.php new file mode 100644 index 000000000..072de740c --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/ExtensionsParams.php @@ -0,0 +1,42 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Builder; + + +use VDM\Joomla\Abstraction\Registry\Traits\IsArray; +use VDM\Joomla\Interfaces\Registryinterface; +use VDM\Joomla\Abstraction\Registry; + + +/** + * Extensions Params Builder Class + * + * @since 3.2.0 + */ +final class ExtensionsParams extends Registry implements Registryinterface +{ + /** + * Is an Array + * + * @since 3.2.0 + */ + use IsArray; + + /** + * Base switch to add values as string or array + * + * @var boolean + * @since 3.2.0 + **/ + protected bool $addAsArray = true; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/FrontendParams.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/FrontendParams.php new file mode 100644 index 000000000..4e56ac038 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/FrontendParams.php @@ -0,0 +1,27 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Builder; + + +use VDM\Joomla\Interfaces\Registryinterface; +use VDM\Joomla\Abstraction\Registry; + + +/** + * Front-end Params Builder Class + * + * @since 3.2.0 + */ +final class FrontendParams extends Registry implements Registryinterface +{ +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/HasMenuGlobal.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/HasMenuGlobal.php new file mode 100644 index 000000000..56e2590f5 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/HasMenuGlobal.php @@ -0,0 +1,27 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Builder; + + +use VDM\Joomla\Interfaces\Registryinterface; +use VDM\Joomla\Abstraction\Registry; + + +/** + * Has Menu Global Builder Class + * + * @since 3.2.0 + */ +final class HasMenuGlobal extends Registry implements Registryinterface +{ +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/LanguageMessages.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/LanguageMessages.php new file mode 100644 index 000000000..5197adae8 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/LanguageMessages.php @@ -0,0 +1,34 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Builder; + + +use VDM\Joomla\Abstraction\Registry\Traits\IsArray; +use VDM\Joomla\Interfaces\Registryinterface; +use VDM\Joomla\Abstraction\Registry; + + +/** + * Language Messages Builder Class + * + * @since 3.2.0 + */ +final class LanguageMessages extends Registry implements Registryinterface +{ + /** + * Is an Array + * + * @since 3.2.0 + */ + use IsArray; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/PermissionFields.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/PermissionFields.php new file mode 100644 index 000000000..198ebad7a --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/PermissionFields.php @@ -0,0 +1,34 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Builder; + + +use VDM\Joomla\Abstraction\Registry\Traits\IsArray; +use VDM\Joomla\Interfaces\Registryinterface; +use VDM\Joomla\Abstraction\Registry; + + +/** + * Permission Fields Builder Class + * + * @since 3.2.0 + */ +final class PermissionFields extends Registry implements Registryinterface +{ + /** + * Is an Array + * + * @since 3.2.0 + */ + use IsArray; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/Request.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/Request.php new file mode 100644 index 000000000..3ee1100b7 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/Request.php @@ -0,0 +1,42 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Builder; + + +use VDM\Joomla\Abstraction\Registry\Traits\IsArray; +use VDM\Joomla\Interfaces\Registryinterface; +use VDM\Joomla\Abstraction\Registry; + + +/** + * Permission Strict Per Field Builder Class + * + * @since 3.2.0 + */ +final class Request extends Registry implements Registryinterface +{ + /** + * Is an Array + * + * @since 3.2.0 + */ + use IsArray; + + /** + * Base switch to add values as string or array + * + * @var boolean + * @since 3.2.0 + **/ + protected bool $addAsArray = true; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/Router.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/Router.php new file mode 100644 index 000000000..c9bc4ef17 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/Router.php @@ -0,0 +1,27 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Builder; + + +use VDM\Joomla\Interfaces\Registryinterface; +use VDM\Joomla\Abstraction\Registry; + + +/** + * Database Uninstall Builder Class + * + * @since 3.2.0 + */ +final class Router extends Registry implements Registryinterface +{ +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/ViewsDefaultOrdering.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/ViewsDefaultOrdering.php new file mode 100644 index 000000000..4013459c3 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Builder/ViewsDefaultOrdering.php @@ -0,0 +1,27 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Builder; + + +use VDM\Joomla\Interfaces\Registryinterface; +use VDM\Joomla\Abstraction\Registry; + + +/** + * Views Default Ordering Builder Class + * + * @since 3.2.0 + */ +final class ViewsDefaultOrdering extends Registry implements Registryinterface +{ +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component.php index 211abf268..687450ccc 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component.php @@ -45,7 +45,7 @@ final class Component extends BaseRegistry * * @since 3.2.0 */ - public function __get(string $path) + public function __get($path) { // check if it has been set if (($value = $this->get($path, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_') diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Data.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Data.php index e4d2927ca..541af4c40 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Data.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Data.php @@ -34,6 +34,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Model\Customadminviews; use VDM\Joomla\Componentbuilder\Compiler\Model\Updateserver; use VDM\Joomla\Componentbuilder\Compiler\Model\Joomlamodules; use VDM\Joomla\Componentbuilder\Compiler\Model\Joomlaplugins; +use VDM\Joomla\Componentbuilder\Compiler\Model\Router; use VDM\Joomla\Utilities\StringHelper; use VDM\Joomla\Utilities\JsonHelper; use VDM\Joomla\Utilities\ArrayHelper; @@ -207,13 +208,20 @@ final class Data */ protected Joomlaplugins $plugins; + /** + * The modelling Joomla Site Router + * + * @var Router + * @since 3.2.0 + */ + protected Router $router; + /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 **/ - protected \JDatabaseDriver $db; + protected $db; /** * Constructor @@ -238,7 +246,7 @@ final class Data * @param Updateserver|null $updateserver The modelling update server object. * @param Joomlamodules|null $modules The modelling modules object. * @param Joomlaplugins|null $plugins The modelling plugins object. - * @param \JDatabaseDriver|null $db The database object. + * @param Router|null $router The modelling router object. * * @since 3.2.0 */ @@ -249,7 +257,7 @@ final class Data ?Filesfolders $filesFolders = null, ?Historycomponent $history = null, ?Whmcs $whmcs = null, ?Sqltweaking $sqltweaking = null, ?Adminviews $adminviews = null, ?Siteviews $siteviews = null, ?Customadminviews $customadminviews = null, ?Updateserver $updateserver = null, - ?Joomlamodules $modules = null, ?Joomlaplugins $plugins = null, ?\JDatabaseDriver $db = null) + ?Joomlamodules $modules = null, ?Joomlaplugins $plugins = null, ?Router $router = null) { $this->config = $config ?: Compiler::_('Config'); $this->event = $event ?: Compiler::_('Event'); @@ -271,7 +279,8 @@ final class Data $this->updateserver = $updateserver ?: Compiler::_('Model.Updateserver'); $this->modules = $modules ?: Compiler::_('Model.Joomlamodules'); $this->plugins = $plugins ?: Compiler::_('Model.Joomlaplugins'); - $this->db = $db ?: Factory::getDbo(); + $this->router = $router ?: Compiler::_('Model.Router'); + $this->db = Factory::getDbo(); } /** @@ -286,27 +295,34 @@ final class Data $query = $this->db->getQuery(true); // selection - $selection = array( - 'b.addadmin_views' => 'addadmin_views', - 'b.id' => 'addadmin_views_id', - 'h.addconfig' => 'addconfig', - 'd.addcustom_admin_views' => 'addcustom_admin_views', - 'g.addcustommenus' => 'addcustommenus', - 'j.addfiles' => 'addfiles', - 'j.addfolders' => 'addfolders', - 'j.addfilesfullpath' => 'addfilesfullpath', - 'j.addfoldersfullpath' => 'addfoldersfullpath', - 'c.addsite_views' => 'addsite_views', - 'l.addjoomla_plugins' => 'addjoomla_plugins', - 'k.addjoomla_modules' => 'addjoomla_modules', - 'i.dashboard_tab' => 'dashboard_tab', - 'i.php_dashboard_methods' => 'php_dashboard_methods', - 'i.params' => 'dashboard_params', - 'i.id' => 'component_dashboard_id', - 'f.sql_tweak' => 'sql_tweak', - 'e.version_update' => 'version_update', - 'e.id' => 'version_update_id' - ); + $selection = [ + 'b.addadmin_views' => 'addadmin_views', + 'b.id' => 'addadmin_views_id', + 'h.addconfig' => 'addconfig', + 'd.addcustom_admin_views' => 'addcustom_admin_views', + 'g.addcustommenus' => 'addcustommenus', + 'j.addfiles' => 'addfiles', + 'j.addfolders' => 'addfolders', + 'j.addfilesfullpath' => 'addfilesfullpath', + 'j.addfoldersfullpath' => 'addfoldersfullpath', + 'c.addsite_views' => 'addsite_views', + 'l.addjoomla_plugins' => 'addjoomla_plugins', + 'k.addjoomla_modules' => 'addjoomla_modules', + 'i.dashboard_tab' => 'dashboard_tab', + 'i.php_dashboard_methods' => 'php_dashboard_methods', + 'i.params' => 'dashboard_params', + 'i.id' => 'component_dashboard_id', + 'f.sql_tweak' => 'sql_tweak', + 'e.version_update' => 'version_update', + 'e.id' => 'version_update_id', + 'm.mode_constructor_before_parent' => 'router_mode_constructor_before_parent', + 'm.mode_constructor_after_parent' => 'router_mode_constructor_after_parent', + 'm.mode_methods' => 'router_mode_methods', + 'm.constructor_before_parent_code' => 'router_constructor_before_parent_code', + 'm.constructor_before_parent_manual' => 'router_constructor_before_parent_manual', + 'm.constructor_after_parent_code' => 'router_constructor_after_parent_code', + 'm.methods_code' => 'router_methods_code' + ]; $query->select('a.*'); $query->select( $this->db->quoteName( @@ -318,7 +334,7 @@ final class Data $query->from('#__componentbuilder_joomla_component AS a'); // jointer-map - $joiners = array( + $joiners = [ 'b' => 'component_admin_views', 'c' => 'component_site_views', 'd' => 'component_custom_admin_views', @@ -328,9 +344,10 @@ final class Data 'h' => 'component_config', 'i' => 'component_dashboard', 'j' => 'component_files_folders', + 'k' => 'component_modules', 'l' => 'component_plugins', - 'k' => 'component_modules' - ); + 'm' => 'component_router' + ]; // load the joins foreach ($joiners as $as => $join) @@ -346,15 +363,9 @@ final class Data $this->db->quoteName('a.id') . ' = ' . (int) $this->config->component_id ); - // for plugin event TODO change event api signatures - $component_context = $this->config->component_context; - $component_id = $this->config->component_id; - // Trigger Event: jcb_ce_onBeforeQueryComponentData $this->event->trigger( - 'jcb_ce_onBeforeQueryComponentData', - array(&$component_context, &$component_id, &$query, - &$this->db) + 'jcb_ce_onBeforeQueryComponentData', [&$query, &$this->db] ); // Reset the query using our newly populated query object. @@ -371,8 +382,7 @@ final class Data // Trigger Event: jcb_ce_onBeforeModelComponentData $this->event->trigger( - 'jcb_ce_onBeforeModelComponentData', - array(&$component_context, &$component) + 'jcb_ce_onBeforeModelComponentData', [&$component] ); // load the global placeholders @@ -390,7 +400,7 @@ final class Data // ensure version naming is correct $this->config->set('component_version', preg_replace( - '/[^0-9.]+/', '', (string) $component->component_version + '/^v/i', '', (string) $component->component_version ) ); @@ -863,15 +873,17 @@ final class Data // set all plugins $this->plugins->set($component); + // set the site router + $this->router->set($component); + // Trigger Event: jcb_ce_onAfterModelComponentData $this->event->trigger( 'jcb_ce_onAfterModelComponentData', - array(&$component_context, &$component) + [&$component] ); // return found component data return $component; - } - + } } diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaFive/Settings.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaFive/Settings.php new file mode 100644 index 000000000..1feea907d --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaFive/Settings.php @@ -0,0 +1,748 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Component\JoomlaFive; + + +use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Registry; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Component; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Dynamicpath; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Pathfix; +use VDM\Joomla\Utilities\FileHelper; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\SettingsInterface; + + +/** + * Compiler Component (Joomla Version) Settings + * + * @since 3.2.0 + */ +final class Settings implements SettingsInterface +{ + /** + * The standard folders + * + * @var array + * @since 3.2.0 + */ + protected array $standardFolders = [ + 'site', + 'admin', + 'media' + ]; + + /** + * The standard root files + * + * @var array + * @since 3.2.0 + */ + protected array $standardRootFiles = [ + 'access.xml', + 'config.xml', + 'controller.php', + 'index.html', + 'README.txt' + ]; + + /** + * Compiler Joomla Version Data + * + * @var object|null + * @since 3.2.0 + */ + protected ?object $data = null; + + /** + * Compiler Config + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The compiler registry + * + * @var Registry + * @since 3.2.0 + */ + protected Registry $registry; + + /** + * Compiler Event + * + * @var EventInterface + * @since 3.2.0 + */ + protected EventInterface $event; + + /** + * Compiler Placeholder + * + * @var Placeholder + * @since 3.2.0 + */ + protected Placeholder $placeholder; + + /** + * Compiler Component + * + * @var Component + * @since 3.2.0 + **/ + protected Component $component; + + /** + * Compiler Utilities Paths + * + * @var Paths + * @since 3.2.0 + */ + protected Paths $paths; + + /** + * Compiler Component Dynamic Path + * + * @var Dynamicpath + * @since 3.2.0 + **/ + protected Dynamicpath $dynamicpath; + + /** + * Compiler Component Pathfix + * + * @var Pathfix + * @since 3.2.0 + **/ + protected Pathfix $pathfix; + + /** + * Constructor + * + * @param Config|null $config The compiler config object. + * @param Registry|null $registry The compiler registry object. + * @param EventInterface|null $event The compiler event api object. + * @param Placeholder|null $placeholder The compiler placeholder object. + * @param Component|null $component The component class. + * @param Paths|null $paths The compiler paths object. + * @param Dynamicpath|null $dynamicpath The compiler dynamic path object. + * @param Pathfix|null $pathfix The compiler path fixing object. + * + * @since 3.2.0 + */ + public function __construct(?Config $config = null, ?Registry $registry = null, + ?EventInterface $event = null, ?Placeholder $placeholder = null, + ?Component $component = null, ?Paths $paths = null, + ?Dynamicpath $dynamicpath = null, ?Pathfix $pathfix = null) + { + $this->config = $config ?: Compiler::_('Config'); + $this->registry = $registry ?: Compiler::_('Registry'); + $this->event = $event ?: Compiler::_('Event'); + $this->placeholder = $placeholder ?: Compiler::_('Placeholder'); + $this->component = $component ?: Compiler::_('Component'); + $this->paths = $paths ?: Compiler::_('Utilities.Paths'); + $this->dynamicpath = $dynamicpath ?: Compiler::_('Utilities.Dynamicpath'); + $this->pathfix = $pathfix ?: Compiler::_('Utilities.Pathfix'); + + // add component endpoint file to stander list of root files + $this->standardRootFiles[] = $this->component->get('name_code') . '.php'; + } + + /** + * Check if data set is loaded + * + * @return bool + * @since 3.2.0 + */ + public function exists(): bool + { + if (!$this->isSet()) + { + // load the data + $this->data = $this->get(); + + if (!$this->isSet()) + { + return false; + } + } + + return true; + } + + /** + * Get Joomla - Folder Structure to Create + * + * @return object The version related structure + * @since 3.2.0 + */ + public function structure(): object + { + return $this->data->create; + } + + /** + * Get Joomla - Move Multiple Structure + * + * @return object The version related multiple structure + * @since 3.2.0 + */ + public function multiple(): object + { + return $this->data->move->dynamic; + } + + /** + * Get Joomla - Move Single Structure + * + * @return object The version related single structure + * @since 3.2.0 + */ + public function single(): object + { + return $this->data->move->static; + } + + /** + * Check if Folder is a Standard Folder + * + * @param string $folder The folder name + * + * @return bool true if the folder exists + * @since 3.2.0 + */ + public function standardFolder(string $folder): bool + { + return in_array($folder, $this->standardFolders); + } + + /** + * Check if File is a Standard Root File + * + * @param string $file The file name + * + * @return bool true if the file exists + * @since 3.2.0 + */ + public function standardRootFile(string $file): bool + { + return in_array($file, $this->standardRootFiles); + } + + /** + * Check if Data is Set + * + * @return bool + * @since 3.2.0 + */ + private function isSet(): bool + { + return is_object($this->data) && + isset($this->data->create) && + isset($this->data->move) && + isset($this->data->move->static) && + isset($this->data->move->dynamic); + } + + /** + * get the Joomla Version Data + * + * @return object|null The version data + * @since 3.2.0 + */ + private function get(): ?object + { + // override option + $customSettings = $this->paths->template_path . '/settings_' . + $this->config->component_code_name . '.json'; + + // get the data + $version_data = $this->readJsonFile($customSettings); + + if (is_null($version_data) || !$this->isValidData($version_data)) + { + return null; + } + + $this->loadExtraFolders(); + $this->loadExtraFiles(); + + $this->addFolders($version_data); + $this->addFiles($version_data); + + // Trigger Event: jcb_ce_onAfterSetJoomlaVersionData + $this->event->trigger( + 'jcb_ce_onAfterSetJoomlaVersionData', [&$version_data] + ); + + return $version_data; + } + + /** + * Read the Json file data + * + * @param string $filePath + * + * @return object|null The version data + * @since 3.2.0 + */ + private function readJsonFile(string $filePath): ?object + { + if (FileHelper::exists($filePath)) + { + $jsonContent = FileHelper::getContent($filePath); + } + else + { + $jsonContent = FileHelper::getContent($this->paths->template_path . '/settings.json'); + } + + if (JsonHelper::check($jsonContent)) + { + return json_decode((string) $jsonContent); + } + + return null; + } + + /** + * Check if this is valid data + * + * @param object $versionData + * + * @return bool + * @since 3.2.0 + */ + private function isValidData(object $versionData): bool + { + return isset($versionData->create) && + isset($versionData->move) && + isset($versionData->move->static) && + isset($versionData->move->dynamic); + } + + /** + * Add Extra/Dynamic folders + * + * @return void + * @since 3.2.0 + */ + private function loadExtraFolders() + { + if ($this->component->isArray('folders') || + $this->config->get('add_eximport', false) || + $this->config->get('uikit', 0) || + $this->config->get('footable', false)) + { + $this->addImportViewFolder(); + $this->addPhpSpreadsheetFolder(); + $this->addUikitFolder(); + $this->addFooTableFolder(); + } + } + + /** + * Add Import and Export Folder + * + * @return void + * @since 3.2.0 + */ + private function addImportViewFolder() + { + if ($this->config->get('add_eximport', false)) + { + // soon + } + } + + /** + * Add Php Spreadsheet Folder + * + * @return void + * @since 3.2.0 + */ + private function addPhpSpreadsheetFolder() + { + // move the phpspreadsheet Folder (TODO we must move this to a library package) + if ($this->config->get('add_eximport', false)) + { + $this->component->appendArray('folders', [ + 'folderpath' => 'JPATH_LIBRARIES/phpspreadsheet/vendor', + 'path' => '/libraries/phpspreadsheet/', + 'rename' => 0 + ]); + } + } + + /** + * Add Uikit Folders + * + * @return void + * @since 3.2.0 + */ + private function addUikitFolder() + { + $uikit = $this->config->get('uikit', 0); + if (2 == $uikit || 1 == $uikit) + { + // move the UIKIT Folder into place + $this->component->appendArray('folders', [ + 'folder' => 'uikit-v2', + 'path' => 'media', + 'rename' => 0 + ]); + } + if (2 == $uikit || 3 == $uikit) + { + // move the UIKIT-3 Folder into place + $this->component->appendArray('folders', [ + 'folder' => 'uikit-v3', + 'path' => 'media', + 'rename' => 0 + ]); + } + } + + /** + * Add Foo Table Folder + * + * @return void + * @since 3.2.0 + */ + private function addFooTableFolder() + { + if (!$this->config->get('footable', false)) + { + return; + } + + $footable_version = $this->config->get('footable_version', 2); + + if (2 == $footable_version) + { + // move the footable folder into place + $this->component->appendArray('folders', [ + 'folder' => 'footable-v2', + 'path' => 'media', + 'rename' => 0 + ]); + } + elseif (3 == $footable_version) + { + // move the footable folder into place + $this->component->appendArray('folders', [ + 'folder' => 'footable-v3', + 'path' => 'media', + 'rename' => 0 + ]); + } + } + + /** + * Add Extra/Dynamic files + * + * @return void + * @since 3.2.0 + */ + private function loadExtraFiles() + { + if ($this->component->isArray('files') || + $this->config->get('google_chart', false)) + { + $this->addGoogleChartFiles(); + } + } + + /** + * Add Google Chart Files + * + * @return void + * @since 3.2.0 + */ + private function addGoogleChartFiles() + { + if ($this->config->get('google_chart', false)) + { + // move the google chart files + $this->component->appendArray('files', [ + 'file' => 'google.jsapi.js', + 'path' => 'media/js', + 'rename' => 0 + ]); + $this->component->appendArray('files', [ + 'file' => 'chartbuilder.php', + 'path' => 'admin/helpers', + 'rename' => 0 + ]); + } + } + + /** + * Add Folders + * + * @param object $versionData + * + * @return void + * @since 3.2.0 + */ + private function addFolders(object &$versionData) + { + if (!$this->component->isArray('folders')) + { + return; + } + + // pointer tracker + $pointer_tracker = 'h'; + foreach ($this->component->get('folders') as $custom) + { + // check type of target type + $_target_type = 'c0mp0n3nt'; + if (isset($custom['target_type'])) + { + $_target_type = $custom['target_type']; + } + + // for good practice + $this->pathfix->set( + $custom, ['path', 'folder', 'folderpath'] + ); + + // fix custom path + if (isset($custom['path']) + && StringHelper::check($custom['path'])) + { + $custom['path'] = trim((string) $custom['path'], '/'); + } + + // by default custom path is true + $customPath = 'custom'; + + // set full path if this is a full path folder + if (!isset($custom['folder']) && isset($custom['folderpath'])) + { + // update the dynamic path + $custom['folderpath'] = $this->dynamicpath->update( + $custom['folderpath'] + ); + + // set the folder path with / if does not have a drive/windows full path + $custom['folder'] = (preg_match( + '/^[a-z]:/i', $custom['folderpath'] + )) ? trim($custom['folderpath'], '/') + : '/' . trim($custom['folderpath'], '/'); + + // remove the file path + unset($custom['folderpath']); + + // triget fullpath + $customPath = 'full'; + } + + // make sure we use the correct name + $pathArray = (array) explode('/', (string) $custom['path']); + $lastFolder = end($pathArray); + + // only rename folder if last has folder name + if (isset($custom['rename']) && $custom['rename'] == 1) + { + $custom['path'] = str_replace( + '/' . $lastFolder, '', (string) $custom['path'] + ); + $rename = 'new'; + $newname = $lastFolder; + } + elseif ('full' === $customPath) + { + // make sure we use the correct name + $folderArray = (array) explode('/', (string) $custom['folder']); + $lastFolder = end($folderArray); + $rename = 'new'; + $newname = $lastFolder; + } + else + { + $rename = false; + $newname = ''; + } + + // insure we have no duplicates + $key_pointer = StringHelper::safe( + $custom['folder'] + ) . '_f' . $pointer_tracker; + + $pointer_tracker++; + + // fix custom path + $custom['path'] = ltrim((string) $custom['path'], '/'); + + // set new folder to object + $versionData->move->static->{$key_pointer} = new \stdClass(); + $versionData->move->static->{$key_pointer}->naam = str_replace('//', '/', (string) $custom['folder']); + $versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path']; + $versionData->move->static->{$key_pointer}->rename = $rename; + $versionData->move->static->{$key_pointer}->newName = $newname; + $versionData->move->static->{$key_pointer}->type = 'folder'; + $versionData->move->static->{$key_pointer}->custom = $customPath; + + // set the target if type and id is found + if (isset($custom['target_id']) && isset($custom['target_type'])) + { + $versionData->move->static->{$key_pointer}->_target = [ + 'key' => $custom['target_id'] . '_' . $custom['target_type'], + 'type' => $custom['target_type'] + ]; + } + } + + $this->component->remove('folders'); + } + + /** + * Add Files + * + * @param object $versionData + * + * @return void + * @since 3.2.0 + */ + private function addFiles(object &$versionData) + { + if (!$this->component->isArray('files')) { + return; + } + + // pointer tracker + $pointer_tracker = 'h'; + foreach ($this->component->get('files') as $custom) + { + // check type of target type + $_target_type = 'c0mp0n3nt'; + if (isset($custom['target_type'])) + { + $_target_type = $custom['target_type']; + } + + // for good practice + $this->pathfix->set( + $custom, ['path', 'file', 'filepath'] + ); + + // by default custom path is true + $customPath = 'custom'; + + // set full path if this is a full path file + if (!isset($custom['file']) && isset($custom['filepath'])) + { + // update the dynamic path + $custom['filepath'] = $this->dynamicpath->update( + $custom['filepath'] + ); + + // set the file path with / if does not have a drive/windows full path + $custom['file'] = (preg_match('/^[a-z]:/i', $custom['filepath'])) + ? trim($custom['filepath'], '/') : '/' . trim($custom['filepath'], '/'); + + // remove the file path + unset($custom['filepath']); + + // triget fullpath + $customPath = 'full'; + } + + // make sure we have not duplicates + $key_pointer = StringHelper::safe( + $custom['file'] + ) . '_g' . $pointer_tracker; + + $pointer_tracker++; + + // set new file to object + $versionData->move->static->{$key_pointer} = new \stdClass(); + $versionData->move->static->{$key_pointer}->naam = str_replace('//', '/', (string) $custom['file']); + + // update the dynamic component name placholders in file names + $custom['path'] = $this->placeholder->update_( + $custom['path'] + ); + + // get the path info + $pathInfo = pathinfo((string) $custom['path']); + if (isset($pathInfo['extension']) && $pathInfo['extension']) + { + $pathInfo['dirname'] = trim($pathInfo['dirname'], '/'); + + // set the info + $versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $pathInfo['dirname']; + $versionData->move->static->{$key_pointer}->rename = 'new'; + $versionData->move->static->{$key_pointer}->newName = $pathInfo['basename']; + } + elseif ('full' === $customPath) + { + // fix custom path + $custom['path'] = ltrim((string) $custom['path'], '/'); + + // get file array + $fileArray = (array) explode('/', (string) $custom['file']); + + // set the info + $versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path']; + $versionData->move->static->{$key_pointer}->rename = 'new'; + $versionData->move->static->{$key_pointer}->newName = end($fileArray); + } + else + { + // fix custom path + $custom['path'] = ltrim((string) $custom['path'], '/'); + + // set the info + $versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path']; + $versionData->move->static->{$key_pointer}->rename = false; + } + + $versionData->move->static->{$key_pointer}->type = 'file'; + $versionData->move->static->{$key_pointer}->custom = $customPath; + + // set the target if type and id is found + if (isset($custom['target_id']) + && isset($custom['target_type'])) + { + $versionData->move->static->{$key_pointer}->_target = [ + 'key' => $custom['target_id'] . '_' . $custom['target_type'], + 'type' => $custom['target_type'] + ]; + } + + // check if file should be updated + if (!isset($custom['notnew']) || $custom['notnew'] == 0 + || $custom['notnew'] != 1) + { + $this->registry->appendArray('files.not.new', $key_pointer); + } + else + { + // update the file content + $this->registry->set('update.file.content.' . $key_pointer, true); + } + } + + $this->component->remove('files'); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaFive/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaFive/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaFive/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaFour/Settings.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaFour/Settings.php new file mode 100644 index 000000000..15b900407 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaFour/Settings.php @@ -0,0 +1,748 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Component\JoomlaFour; + + +use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Registry; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Component; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Dynamicpath; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Pathfix; +use VDM\Joomla\Utilities\FileHelper; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\SettingsInterface; + + +/** + * Compiler Component (Joomla Version) Settings + * + * @since 3.2.0 + */ +final class Settings implements SettingsInterface +{ + /** + * The standard folders + * + * @var array + * @since 3.2.0 + */ + protected array $standardFolders = [ + 'site', + 'admin', + 'media' + ]; + + /** + * The standard root files + * + * @var array + * @since 3.2.0 + */ + protected array $standardRootFiles = [ + 'access.xml', + 'config.xml', + 'controller.php', + 'index.html', + 'README.txt' + ]; + + /** + * Compiler Joomla Version Data + * + * @var object|null + * @since 3.2.0 + */ + protected ?object $data = null; + + /** + * Compiler Config + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The compiler registry + * + * @var Registry + * @since 3.2.0 + */ + protected Registry $registry; + + /** + * Compiler Event + * + * @var EventInterface + * @since 3.2.0 + */ + protected EventInterface $event; + + /** + * Compiler Placeholder + * + * @var Placeholder + * @since 3.2.0 + */ + protected Placeholder $placeholder; + + /** + * Compiler Component + * + * @var Component + * @since 3.2.0 + **/ + protected Component $component; + + /** + * Compiler Utilities Paths + * + * @var Paths + * @since 3.2.0 + */ + protected Paths $paths; + + /** + * Compiler Component Dynamic Path + * + * @var Dynamicpath + * @since 3.2.0 + **/ + protected Dynamicpath $dynamicpath; + + /** + * Compiler Component Pathfix + * + * @var Pathfix + * @since 3.2.0 + **/ + protected Pathfix $pathfix; + + /** + * Constructor + * + * @param Config|null $config The compiler config object. + * @param Registry|null $registry The compiler registry object. + * @param EventInterface|null $event The compiler event api object. + * @param Placeholder|null $placeholder The compiler placeholder object. + * @param Component|null $component The component class. + * @param Paths|null $paths The compiler paths object. + * @param Dynamicpath|null $dynamicpath The compiler dynamic path object. + * @param Pathfix|null $pathfix The compiler path fixing object. + * + * @since 3.2.0 + */ + public function __construct(?Config $config = null, ?Registry $registry = null, + ?EventInterface $event = null, ?Placeholder $placeholder = null, + ?Component $component = null, ?Paths $paths = null, + ?Dynamicpath $dynamicpath = null, ?Pathfix $pathfix = null) + { + $this->config = $config ?: Compiler::_('Config'); + $this->registry = $registry ?: Compiler::_('Registry'); + $this->event = $event ?: Compiler::_('Event'); + $this->placeholder = $placeholder ?: Compiler::_('Placeholder'); + $this->component = $component ?: Compiler::_('Component'); + $this->paths = $paths ?: Compiler::_('Utilities.Paths'); + $this->dynamicpath = $dynamicpath ?: Compiler::_('Utilities.Dynamicpath'); + $this->pathfix = $pathfix ?: Compiler::_('Utilities.Pathfix'); + + // add component endpoint file to stander list of root files + $this->standardRootFiles[] = $this->component->get('name_code') . '.php'; + } + + /** + * Check if data set is loaded + * + * @return bool + * @since 3.2.0 + */ + public function exists(): bool + { + if (!$this->isSet()) + { + // load the data + $this->data = $this->get(); + + if (!$this->isSet()) + { + return false; + } + } + + return true; + } + + /** + * Get Joomla - Folder Structure to Create + * + * @return object The version related structure + * @since 3.2.0 + */ + public function structure(): object + { + return $this->data->create; + } + + /** + * Get Joomla - Move Multiple Structure + * + * @return object The version related multiple structure + * @since 3.2.0 + */ + public function multiple(): object + { + return $this->data->move->dynamic; + } + + /** + * Get Joomla - Move Single Structure + * + * @return object The version related single structure + * @since 3.2.0 + */ + public function single(): object + { + return $this->data->move->static; + } + + /** + * Check if Folder is a Standard Folder + * + * @param string $folder The folder name + * + * @return bool true if the folder exists + * @since 3.2.0 + */ + public function standardFolder(string $folder): bool + { + return in_array($folder, $this->standardFolders); + } + + /** + * Check if File is a Standard Root File + * + * @param string $file The file name + * + * @return bool true if the file exists + * @since 3.2.0 + */ + public function standardRootFile(string $file): bool + { + return in_array($file, $this->standardRootFiles); + } + + /** + * Check if Data is Set + * + * @return bool + * @since 3.2.0 + */ + private function isSet(): bool + { + return is_object($this->data) && + isset($this->data->create) && + isset($this->data->move) && + isset($this->data->move->static) && + isset($this->data->move->dynamic); + } + + /** + * get the Joomla Version Data + * + * @return object|null The version data + * @since 3.2.0 + */ + private function get(): ?object + { + // override option + $customSettings = $this->paths->template_path . '/settings_' . + $this->config->component_code_name . '.json'; + + // get the data + $version_data = $this->readJsonFile($customSettings); + + if (is_null($version_data) || !$this->isValidData($version_data)) + { + return null; + } + + $this->loadExtraFolders(); + $this->loadExtraFiles(); + + $this->addFolders($version_data); + $this->addFiles($version_data); + + // Trigger Event: jcb_ce_onAfterSetJoomlaVersionData + $this->event->trigger( + 'jcb_ce_onAfterSetJoomlaVersionData', [&$version_data] + ); + + return $version_data; + } + + /** + * Read the Json file data + * + * @param string $filePath + * + * @return object|null The version data + * @since 3.2.0 + */ + private function readJsonFile(string $filePath): ?object + { + if (FileHelper::exists($filePath)) + { + $jsonContent = FileHelper::getContent($filePath); + } + else + { + $jsonContent = FileHelper::getContent($this->paths->template_path . '/settings.json'); + } + + if (JsonHelper::check($jsonContent)) + { + return json_decode((string) $jsonContent); + } + + return null; + } + + /** + * Check if this is valid data + * + * @param object $versionData + * + * @return bool + * @since 3.2.0 + */ + private function isValidData(object $versionData): bool + { + return isset($versionData->create) && + isset($versionData->move) && + isset($versionData->move->static) && + isset($versionData->move->dynamic); + } + + /** + * Add Extra/Dynamic folders + * + * @return void + * @since 3.2.0 + */ + private function loadExtraFolders() + { + if ($this->component->isArray('folders') || + $this->config->get('add_eximport', false) || + $this->config->get('uikit', 0) || + $this->config->get('footable', false)) + { + $this->addImportViewFolder(); + $this->addPhpSpreadsheetFolder(); + $this->addUikitFolder(); + $this->addFooTableFolder(); + } + } + + /** + * Add Import and Export Folder + * + * @return void + * @since 3.2.0 + */ + private function addImportViewFolder() + { + if ($this->config->get('add_eximport', false)) + { + // soon + } + } + + /** + * Add Php Spreadsheet Folder + * + * @return void + * @since 3.2.0 + */ + private function addPhpSpreadsheetFolder() + { + // move the phpspreadsheet Folder (TODO we must move this to a library package) + if ($this->config->get('add_eximport', false)) + { + $this->component->appendArray('folders', [ + 'folderpath' => 'JPATH_LIBRARIES/phpspreadsheet/vendor', + 'path' => '/libraries/phpspreadsheet/', + 'rename' => 0 + ]); + } + } + + /** + * Add Uikit Folders + * + * @return void + * @since 3.2.0 + */ + private function addUikitFolder() + { + $uikit = $this->config->get('uikit', 0); + if (2 == $uikit || 1 == $uikit) + { + // move the UIKIT Folder into place + $this->component->appendArray('folders', [ + 'folder' => 'uikit-v2', + 'path' => 'media', + 'rename' => 0 + ]); + } + if (2 == $uikit || 3 == $uikit) + { + // move the UIKIT-3 Folder into place + $this->component->appendArray('folders', [ + 'folder' => 'uikit-v3', + 'path' => 'media', + 'rename' => 0 + ]); + } + } + + /** + * Add Foo Table Folder + * + * @return void + * @since 3.2.0 + */ + private function addFooTableFolder() + { + if (!$this->config->get('footable', false)) + { + return; + } + + $footable_version = $this->config->get('footable_version', 2); + + if (2 == $footable_version) + { + // move the footable folder into place + $this->component->appendArray('folders', [ + 'folder' => 'footable-v2', + 'path' => 'media', + 'rename' => 0 + ]); + } + elseif (3 == $footable_version) + { + // move the footable folder into place + $this->component->appendArray('folders', [ + 'folder' => 'footable-v3', + 'path' => 'media', + 'rename' => 0 + ]); + } + } + + /** + * Add Extra/Dynamic files + * + * @return void + * @since 3.2.0 + */ + private function loadExtraFiles() + { + if ($this->component->isArray('files') || + $this->config->get('google_chart', false)) + { + $this->addGoogleChartFiles(); + } + } + + /** + * Add Google Chart Files + * + * @return void + * @since 3.2.0 + */ + private function addGoogleChartFiles() + { + if ($this->config->get('google_chart', false)) + { + // move the google chart files + $this->component->appendArray('files', [ + 'file' => 'google.jsapi.js', + 'path' => 'media/js', + 'rename' => 0 + ]); + $this->component->appendArray('files', [ + 'file' => 'chartbuilder.php', + 'path' => 'admin/helpers', + 'rename' => 0 + ]); + } + } + + /** + * Add Folders + * + * @param object $versionData + * + * @return void + * @since 3.2.0 + */ + private function addFolders(object &$versionData) + { + if (!$this->component->isArray('folders')) + { + return; + } + + // pointer tracker + $pointer_tracker = 'h'; + foreach ($this->component->get('folders') as $custom) + { + // check type of target type + $_target_type = 'c0mp0n3nt'; + if (isset($custom['target_type'])) + { + $_target_type = $custom['target_type']; + } + + // for good practice + $this->pathfix->set( + $custom, ['path', 'folder', 'folderpath'] + ); + + // fix custom path + if (isset($custom['path']) + && StringHelper::check($custom['path'])) + { + $custom['path'] = trim((string) $custom['path'], '/'); + } + + // by default custom path is true + $customPath = 'custom'; + + // set full path if this is a full path folder + if (!isset($custom['folder']) && isset($custom['folderpath'])) + { + // update the dynamic path + $custom['folderpath'] = $this->dynamicpath->update( + $custom['folderpath'] + ); + + // set the folder path with / if does not have a drive/windows full path + $custom['folder'] = (preg_match( + '/^[a-z]:/i', $custom['folderpath'] + )) ? trim($custom['folderpath'], '/') + : '/' . trim($custom['folderpath'], '/'); + + // remove the file path + unset($custom['folderpath']); + + // triget fullpath + $customPath = 'full'; + } + + // make sure we use the correct name + $pathArray = (array) explode('/', (string) $custom['path']); + $lastFolder = end($pathArray); + + // only rename folder if last has folder name + if (isset($custom['rename']) && $custom['rename'] == 1) + { + $custom['path'] = str_replace( + '/' . $lastFolder, '', (string) $custom['path'] + ); + $rename = 'new'; + $newname = $lastFolder; + } + elseif ('full' === $customPath) + { + // make sure we use the correct name + $folderArray = (array) explode('/', (string) $custom['folder']); + $lastFolder = end($folderArray); + $rename = 'new'; + $newname = $lastFolder; + } + else + { + $rename = false; + $newname = ''; + } + + // insure we have no duplicates + $key_pointer = StringHelper::safe( + $custom['folder'] + ) . '_f' . $pointer_tracker; + + $pointer_tracker++; + + // fix custom path + $custom['path'] = ltrim((string) $custom['path'], '/'); + + // set new folder to object + $versionData->move->static->{$key_pointer} = new \stdClass(); + $versionData->move->static->{$key_pointer}->naam = str_replace('//', '/', (string) $custom['folder']); + $versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path']; + $versionData->move->static->{$key_pointer}->rename = $rename; + $versionData->move->static->{$key_pointer}->newName = $newname; + $versionData->move->static->{$key_pointer}->type = 'folder'; + $versionData->move->static->{$key_pointer}->custom = $customPath; + + // set the target if type and id is found + if (isset($custom['target_id']) && isset($custom['target_type'])) + { + $versionData->move->static->{$key_pointer}->_target = [ + 'key' => $custom['target_id'] . '_' . $custom['target_type'], + 'type' => $custom['target_type'] + ]; + } + } + + $this->component->remove('folders'); + } + + /** + * Add Files + * + * @param object $versionData + * + * @return void + * @since 3.2.0 + */ + private function addFiles(object &$versionData) + { + if (!$this->component->isArray('files')) { + return; + } + + // pointer tracker + $pointer_tracker = 'h'; + foreach ($this->component->get('files') as $custom) + { + // check type of target type + $_target_type = 'c0mp0n3nt'; + if (isset($custom['target_type'])) + { + $_target_type = $custom['target_type']; + } + + // for good practice + $this->pathfix->set( + $custom, ['path', 'file', 'filepath'] + ); + + // by default custom path is true + $customPath = 'custom'; + + // set full path if this is a full path file + if (!isset($custom['file']) && isset($custom['filepath'])) + { + // update the dynamic path + $custom['filepath'] = $this->dynamicpath->update( + $custom['filepath'] + ); + + // set the file path with / if does not have a drive/windows full path + $custom['file'] = (preg_match('/^[a-z]:/i', $custom['filepath'])) + ? trim($custom['filepath'], '/') : '/' . trim($custom['filepath'], '/'); + + // remove the file path + unset($custom['filepath']); + + // triget fullpath + $customPath = 'full'; + } + + // make sure we have not duplicates + $key_pointer = StringHelper::safe( + $custom['file'] + ) . '_g' . $pointer_tracker; + + $pointer_tracker++; + + // set new file to object + $versionData->move->static->{$key_pointer} = new \stdClass(); + $versionData->move->static->{$key_pointer}->naam = str_replace('//', '/', (string) $custom['file']); + + // update the dynamic component name placholders in file names + $custom['path'] = $this->placeholder->update_( + $custom['path'] + ); + + // get the path info + $pathInfo = pathinfo((string) $custom['path']); + if (isset($pathInfo['extension']) && $pathInfo['extension']) + { + $pathInfo['dirname'] = trim($pathInfo['dirname'], '/'); + + // set the info + $versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $pathInfo['dirname']; + $versionData->move->static->{$key_pointer}->rename = 'new'; + $versionData->move->static->{$key_pointer}->newName = $pathInfo['basename']; + } + elseif ('full' === $customPath) + { + // fix custom path + $custom['path'] = ltrim((string) $custom['path'], '/'); + + // get file array + $fileArray = (array) explode('/', (string) $custom['file']); + + // set the info + $versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path']; + $versionData->move->static->{$key_pointer}->rename = 'new'; + $versionData->move->static->{$key_pointer}->newName = end($fileArray); + } + else + { + // fix custom path + $custom['path'] = ltrim((string) $custom['path'], '/'); + + // set the info + $versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path']; + $versionData->move->static->{$key_pointer}->rename = false; + } + + $versionData->move->static->{$key_pointer}->type = 'file'; + $versionData->move->static->{$key_pointer}->custom = $customPath; + + // set the target if type and id is found + if (isset($custom['target_id']) + && isset($custom['target_type'])) + { + $versionData->move->static->{$key_pointer}->_target = [ + 'key' => $custom['target_id'] . '_' . $custom['target_type'], + 'type' => $custom['target_type'] + ]; + } + + // check if file should be updated + if (!isset($custom['notnew']) || $custom['notnew'] == 0 + || $custom['notnew'] != 1) + { + $this->registry->appendArray('files.not.new', $key_pointer); + } + else + { + // update the file content + $this->registry->set('update.file.content.' . $key_pointer, true); + } + } + + $this->component->remove('files'); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaFour/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaFour/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaFour/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaThree/Settings.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaThree/Settings.php new file mode 100644 index 000000000..fe5632838 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaThree/Settings.php @@ -0,0 +1,752 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Component\JoomlaThree; + + +use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Registry; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Component; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Dynamicpath; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Pathfix; +use VDM\Joomla\Utilities\FileHelper; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\SettingsInterface; + + +/** + * Compiler Component (Joomla Version) Settings + * + * @since 3.2.0 + */ +final class Settings implements SettingsInterface +{ + /** + * The standard folders + * + * @var array + * @since 3.2.0 + */ + protected array $standardFolders = [ + 'site', + 'admin', + 'media' + ]; + + /** + * The standard root files + * + * @var array + * @since 3.2.0 + */ + protected array $standardRootFiles = [ + 'access.xml', + 'config.xml', + 'controller.php', + 'index.html', + 'README.txt' + ]; + + /** + * Compiler Joomla Version Data + * + * @var object|null + * @since 3.2.0 + */ + protected ?object $data = null; + + /** + * Compiler Config + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The compiler registry + * + * @var Registry + * @since 3.2.0 + */ + protected Registry $registry; + + /** + * Compiler Event + * + * @var EventInterface + * @since 3.2.0 + */ + protected EventInterface $event; + + /** + * Compiler Placeholder + * + * @var Placeholder + * @since 3.2.0 + */ + protected Placeholder $placeholder; + + /** + * Compiler Component + * + * @var Component + * @since 3.2.0 + **/ + protected Component $component; + + /** + * Compiler Utilities Paths + * + * @var Paths + * @since 3.2.0 + */ + protected Paths $paths; + + /** + * Compiler Component Dynamic Path + * + * @var Dynamicpath + * @since 3.2.0 + **/ + protected Dynamicpath $dynamicpath; + + /** + * Compiler Component Pathfix + * + * @var Pathfix + * @since 3.2.0 + **/ + protected Pathfix $pathfix; + + /** + * Constructor + * + * @param Config|null $config The compiler config object. + * @param Registry|null $registry The compiler registry object. + * @param EventInterface|null $event The compiler event api object. + * @param Placeholder|null $placeholder The compiler placeholder object. + * @param Component|null $component The component class. + * @param Paths|null $paths The compiler paths object. + * @param Dynamicpath|null $dynamicpath The compiler dynamic path object. + * @param Pathfix|null $pathfix The compiler path fixing object. + * + * @since 3.2.0 + */ + public function __construct(?Config $config = null, ?Registry $registry = null, + ?EventInterface $event = null, ?Placeholder $placeholder = null, + ?Component $component = null, ?Paths $paths = null, + ?Dynamicpath $dynamicpath = null, ?Pathfix $pathfix = null) + { + $this->config = $config ?: Compiler::_('Config'); + $this->registry = $registry ?: Compiler::_('Registry'); + $this->event = $event ?: Compiler::_('Event'); + $this->placeholder = $placeholder ?: Compiler::_('Placeholder'); + $this->component = $component ?: Compiler::_('Component'); + $this->paths = $paths ?: Compiler::_('Utilities.Paths'); + $this->dynamicpath = $dynamicpath ?: Compiler::_('Utilities.Dynamicpath'); + $this->pathfix = $pathfix ?: Compiler::_('Utilities.Pathfix'); + + // add component endpoint file to stander list of root files + $this->standardRootFiles[] = $this->component->get('name_code') . '.php'; + } + + /** + * Check if data set is loaded + * + * @return bool + * @since 3.2.0 + */ + public function exists(): bool + { + if (!$this->isSet()) + { + // load the data + $this->data = $this->get(); + + if (!$this->isSet()) + { + return false; + } + } + + return true; + } + + /** + * Get Joomla - Folder Structure to Create + * + * @return object The version related structure + * @since 3.2.0 + */ + public function structure(): object + { + return $this->data->create; + } + + /** + * Get Joomla - Move Multiple Structure + * + * @return object The version related multiple structure + * @since 3.2.0 + */ + public function multiple(): object + { + return $this->data->move->dynamic; + } + + /** + * Get Joomla - Move Single Structure + * + * @return object The version related single structure + * @since 3.2.0 + */ + public function single(): object + { + return $this->data->move->static; + } + + /** + * Check if Folder is a Standard Folder + * + * @param string $folder The folder name + * + * @return bool true if the folder exists + * @since 3.2.0 + */ + public function standardFolder(string $folder): bool + { + return in_array($folder, $this->standardFolders); + } + + /** + * Check if File is a Standard Root File + * + * @param string $file The file name + * + * @return bool true if the file exists + * @since 3.2.0 + */ + public function standardRootFile(string $file): bool + { + return in_array($file, $this->standardRootFiles); + } + + /** + * Check if Data is Set + * + * @return bool + * @since 3.2.0 + */ + private function isSet(): bool + { + return is_object($this->data) && + isset($this->data->create) && + isset($this->data->move) && + isset($this->data->move->static) && + isset($this->data->move->dynamic); + } + + /** + * get the Joomla Version Data + * + * @return object|null The version data + * @since 3.2.0 + */ + private function get(): ?object + { + // override option + $customSettings = $this->paths->template_path . '/settings_' . + $this->config->component_code_name . '.json'; + + // get the data + $version_data = $this->readJsonFile($customSettings); + + if (is_null($version_data) || !$this->isValidData($version_data)) + { + return null; + } + + $this->loadExtraFolders(); + $this->loadExtraFiles(); + + $this->addFolders($version_data); + $this->addFiles($version_data); + + // Trigger Event: jcb_ce_onAfterSetJoomlaVersionData + $this->event->trigger( + 'jcb_ce_onAfterSetJoomlaVersionData', [&$version_data] + ); + + return $version_data; + } + + /** + * Read the Json file data + * + * @param string $filePath + * + * @return object|null The version data + * @since 3.2.0 + */ + private function readJsonFile(string $filePath): ?object + { + if (FileHelper::exists($filePath)) + { + $jsonContent = FileHelper::getContent($filePath); + } + else + { + $jsonContent = FileHelper::getContent($this->paths->template_path . '/settings.json'); + } + + if (JsonHelper::check($jsonContent)) + { + return json_decode((string) $jsonContent); + } + + return null; + } + + /** + * Check if this is valid data + * + * @param object $versionData + * + * @return bool + * @since 3.2.0 + */ + private function isValidData(object $versionData): bool + { + return isset($versionData->create) && + isset($versionData->move) && + isset($versionData->move->static) && + isset($versionData->move->dynamic); + } + + /** + * Add Extra/Dynamic folders + * + * @return void + * @since 3.2.0 + */ + private function loadExtraFolders() + { + if ($this->component->isArray('folders') || + $this->config->get('add_eximport', false) || + $this->config->get('uikit', 0) || + $this->config->get('footable', false)) + { + $this->addImportViewFolder(); + $this->addPhpSpreadsheetFolder(); + $this->addUikitFolder(); + $this->addFooTableFolder(); + } + } + + /** + * Add Import and Export Folder + * + * @return void + * @since 3.2.0 + */ + private function addImportViewFolder() + { + if ($this->config->get('add_eximport', false)) + { + $this->component->appendArray('folders', [ + 'folder' => 'importViews', + 'path' => 'admin/views/import', + 'rename' => 1 + ]); + } + } + + /** + * Add Php Spreadsheet Folder + * + * @return void + * @since 3.2.0 + */ + private function addPhpSpreadsheetFolder() + { + // move the phpspreadsheet Folder (TODO we must move this to a library package) + if ($this->config->get('add_eximport', false)) + { + $this->component->appendArray('folders', [ + 'folderpath' => 'JPATH_LIBRARIES/phpspreadsheet/vendor', + 'path' => '/libraries/phpspreadsheet/', + 'rename' => 0 + ]); + } + } + + /** + * Add Uikit Folders + * + * @return void + * @since 3.2.0 + */ + private function addUikitFolder() + { + $uikit = $this->config->get('uikit', 0); + if (2 == $uikit || 1 == $uikit) + { + // move the UIKIT Folder into place + $this->component->appendArray('folders', [ + 'folder' => 'uikit-v2', + 'path' => 'media', + 'rename' => 0 + ]); + } + if (2 == $uikit || 3 == $uikit) + { + // move the UIKIT-3 Folder into place + $this->component->appendArray('folders', [ + 'folder' => 'uikit-v3', + 'path' => 'media', + 'rename' => 0 + ]); + } + } + + /** + * Add Foo Table Folder + * + * @return void + * @since 3.2.0 + */ + private function addFooTableFolder() + { + if (!$this->config->get('footable', false)) + { + return; + } + + $footable_version = $this->config->get('footable_version', 2); + + if (2 == $footable_version) + { + // move the footable folder into place + $this->component->appendArray('folders', [ + 'folder' => 'footable-v2', + 'path' => 'media', + 'rename' => 0 + ]); + } + elseif (3 == $footable_version) + { + // move the footable folder into place + $this->component->appendArray('folders', [ + 'folder' => 'footable-v3', + 'path' => 'media', + 'rename' => 0 + ]); + } + } + + /** + * Add Extra/Dynamic files + * + * @return void + * @since 3.2.0 + */ + private function loadExtraFiles() + { + if ($this->component->isArray('files') || + $this->config->get('google_chart', false)) + { + $this->addGoogleChartFiles(); + } + } + + /** + * Add Google Chart Files + * + * @return void + * @since 3.2.0 + */ + private function addGoogleChartFiles() + { + if ($this->config->get('google_chart', false)) + { + // move the google chart files + $this->component->appendArray('files', [ + 'file' => 'google.jsapi.js', + 'path' => 'media/js', + 'rename' => 0 + ]); + $this->component->appendArray('files', [ + 'file' => 'chartbuilder.php', + 'path' => 'admin/helpers', + 'rename' => 0 + ]); + } + } + + /** + * Add Folders + * + * @param object $versionData + * + * @return void + * @since 3.2.0 + */ + private function addFolders(object &$versionData) + { + if (!$this->component->isArray('folders')) + { + return; + } + + // pointer tracker + $pointer_tracker = 'h'; + foreach ($this->component->get('folders') as $custom) + { + // check type of target type + $_target_type = 'c0mp0n3nt'; + if (isset($custom['target_type'])) + { + $_target_type = $custom['target_type']; + } + + // for good practice + $this->pathfix->set( + $custom, ['path', 'folder', 'folderpath'] + ); + + // fix custom path + if (isset($custom['path']) + && StringHelper::check($custom['path'])) + { + $custom['path'] = trim((string) $custom['path'], '/'); + } + + // by default custom path is true + $customPath = 'custom'; + + // set full path if this is a full path folder + if (!isset($custom['folder']) && isset($custom['folderpath'])) + { + // update the dynamic path + $custom['folderpath'] = $this->dynamicpath->update( + $custom['folderpath'] + ); + + // set the folder path with / if does not have a drive/windows full path + $custom['folder'] = (preg_match( + '/^[a-z]:/i', $custom['folderpath'] + )) ? trim($custom['folderpath'], '/') + : '/' . trim($custom['folderpath'], '/'); + + // remove the file path + unset($custom['folderpath']); + + // triget fullpath + $customPath = 'full'; + } + + // make sure we use the correct name + $pathArray = (array) explode('/', (string) $custom['path']); + $lastFolder = end($pathArray); + + // only rename folder if last has folder name + if (isset($custom['rename']) && $custom['rename'] == 1) + { + $custom['path'] = str_replace( + '/' . $lastFolder, '', (string) $custom['path'] + ); + $rename = 'new'; + $newname = $lastFolder; + } + elseif ('full' === $customPath) + { + // make sure we use the correct name + $folderArray = (array) explode('/', (string) $custom['folder']); + $lastFolder = end($folderArray); + $rename = 'new'; + $newname = $lastFolder; + } + else + { + $rename = false; + $newname = ''; + } + + // insure we have no duplicates + $key_pointer = StringHelper::safe( + $custom['folder'] + ) . '_f' . $pointer_tracker; + + $pointer_tracker++; + + // fix custom path + $custom['path'] = ltrim((string) $custom['path'], '/'); + + // set new folder to object + $versionData->move->static->{$key_pointer} = new \stdClass(); + $versionData->move->static->{$key_pointer}->naam = str_replace('//', '/', (string) $custom['folder']); + $versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path']; + $versionData->move->static->{$key_pointer}->rename = $rename; + $versionData->move->static->{$key_pointer}->newName = $newname; + $versionData->move->static->{$key_pointer}->type = 'folder'; + $versionData->move->static->{$key_pointer}->custom = $customPath; + + // set the target if type and id is found + if (isset($custom['target_id']) && isset($custom['target_type'])) + { + $versionData->move->static->{$key_pointer}->_target = [ + 'key' => $custom['target_id'] . '_' . $custom['target_type'], + 'type' => $custom['target_type'] + ]; + } + } + + $this->component->remove('folders'); + } + + /** + * Add Files + * + * @param object $versionData + * + * @return void + * @since 3.2.0 + */ + private function addFiles(object &$versionData) + { + if (!$this->component->isArray('files')) { + return; + } + + // pointer tracker + $pointer_tracker = 'h'; + foreach ($this->component->get('files') as $custom) + { + // check type of target type + $_target_type = 'c0mp0n3nt'; + if (isset($custom['target_type'])) + { + $_target_type = $custom['target_type']; + } + + // for good practice + $this->pathfix->set( + $custom, ['path', 'file', 'filepath'] + ); + + // by default custom path is true + $customPath = 'custom'; + + // set full path if this is a full path file + if (!isset($custom['file']) && isset($custom['filepath'])) + { + // update the dynamic path + $custom['filepath'] = $this->dynamicpath->update( + $custom['filepath'] + ); + + // set the file path with / if does not have a drive/windows full path + $custom['file'] = (preg_match('/^[a-z]:/i', $custom['filepath'])) + ? trim($custom['filepath'], '/') : '/' . trim($custom['filepath'], '/'); + + // remove the file path + unset($custom['filepath']); + + // triget fullpath + $customPath = 'full'; + } + + // make sure we have not duplicates + $key_pointer = StringHelper::safe( + $custom['file'] + ) . '_g' . $pointer_tracker; + + $pointer_tracker++; + + // set new file to object + $versionData->move->static->{$key_pointer} = new \stdClass(); + $versionData->move->static->{$key_pointer}->naam = str_replace('//', '/', (string) $custom['file']); + + // update the dynamic component name placholders in file names + $custom['path'] = $this->placeholder->update_( + $custom['path'] + ); + + // get the path info + $pathInfo = pathinfo((string) $custom['path']); + if (isset($pathInfo['extension']) && $pathInfo['extension']) + { + $pathInfo['dirname'] = trim($pathInfo['dirname'], '/'); + + // set the info + $versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $pathInfo['dirname']; + $versionData->move->static->{$key_pointer}->rename = 'new'; + $versionData->move->static->{$key_pointer}->newName = $pathInfo['basename']; + } + elseif ('full' === $customPath) + { + // fix custom path + $custom['path'] = ltrim((string) $custom['path'], '/'); + + // get file array + $fileArray = (array) explode('/', (string) $custom['file']); + + // set the info + $versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path']; + $versionData->move->static->{$key_pointer}->rename = 'new'; + $versionData->move->static->{$key_pointer}->newName = end($fileArray); + } + else + { + // fix custom path + $custom['path'] = ltrim((string) $custom['path'], '/'); + + // set the info + $versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path']; + $versionData->move->static->{$key_pointer}->rename = false; + } + + $versionData->move->static->{$key_pointer}->type = 'file'; + $versionData->move->static->{$key_pointer}->custom = $customPath; + + // set the target if type and id is found + if (isset($custom['target_id']) + && isset($custom['target_type'])) + { + $versionData->move->static->{$key_pointer}->_target = [ + 'key' => $custom['target_id'] . '_' . $custom['target_type'], + 'type' => $custom['target_type'] + ]; + } + + // check if file should be updated + if (!isset($custom['notnew']) || $custom['notnew'] == 0 + || $custom['notnew'] != 1) + { + $this->registry->appendArray('files.not.new', $key_pointer); + } + else + { + // update the file content + $this->registry->set('update.file.content.' . $key_pointer, true); + } + } + + $this->component->remove('files'); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaThree/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaThree/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/JoomlaThree/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Placeholder.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Placeholder.php index 39cc7e5ff..b987c521a 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Placeholder.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Placeholder.php @@ -49,7 +49,6 @@ final class Placeholder implements PlaceholderInterface /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 **/ protected $db; @@ -62,10 +61,10 @@ final class Placeholder implements PlaceholderInterface * * @since 3.2.0 **/ - public function __construct(?Config $config = null, ?\JDatabaseDriver $db = null) + public function __construct(?Config $config = null) { $this->config = $config ?: Compiler::_('Config'); - $this->db = $db ?: Factory::getDbo(); + $this->db = Factory::getDbo(); } /** @@ -131,7 +130,7 @@ final class Placeholder implements PlaceholderInterface { foreach ($_placeholders as $row) { - $bucket[$row['target']] = $row['value']; + $bucket[$row['target']] = str_replace(array_keys($bucket), array_values($bucket), $row['value']); } } } diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Settings.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Settings.php deleted file mode 100644 index 63b53483e..000000000 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Settings.php +++ /dev/null @@ -1,756 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -namespace VDM\Joomla\Componentbuilder\Compiler\Component; - - -use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; -use VDM\Joomla\Componentbuilder\Compiler\Config; -use VDM\Joomla\Componentbuilder\Compiler\Registry; -use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface; -use VDM\Joomla\Componentbuilder\Compiler\Placeholder; -use VDM\Joomla\Componentbuilder\Compiler\Component; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Dynamicpath; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Pathfix; -use VDM\Joomla\Utilities\FileHelper; -use VDM\Joomla\Utilities\JsonHelper; -use VDM\Joomla\Utilities\StringHelper; - - -/** - * Compiler Component (Joomla Version) Settings - * - * @since 3.2.0 - */ -final class Settings -{ - /** - * The standard folders - * - * @var array - * @since 3.2.0 - */ - protected array $standardFolders = [ - 'site', - 'admin', - 'media' - ]; - - /** - * The standard root files - * - * @var array - * @since 3.2.0 - */ - protected array $standardRootFiles = [ - 'access.xml', - 'config.xml', - 'controller.php', - 'index.html', - 'README.txt' - ]; - - /** - * Compiler Joomla Version Data - * - * @var object|null - * @since 3.2.0 - */ - protected ?object $data = null; - - /** - * Compiler Config - * - * @var Config - * @since 3.2.0 - */ - protected Config $config; - - /** - * The compiler registry - * - * @var Registry - * @since 3.2.0 - */ - protected Registry $registry; - - /** - * Compiler Event - * - * @var EventInterface - * @since 3.2.0 - */ - protected EventInterface $event; - - /** - * Compiler Placeholder - * - * @var Placeholder - * @since 3.2.0 - */ - protected Placeholder $placeholder; - - /** - * Compiler Component - * - * @var Component - * @since 3.2.0 - **/ - protected Component $component; - - /** - * Compiler Utilities Paths - * - * @var Paths - * @since 3.2.0 - */ - protected Paths $paths; - - /** - * Compiler Component Dynamic Path - * - * @var Dynamicpath - * @since 3.2.0 - **/ - protected Dynamicpath $dynamicpath; - - /** - * Compiler Component Pathfix - * - * @var Pathfix - * @since 3.2.0 - **/ - protected Pathfix $pathfix; - - /** - * Constructor - * - * @param Config|null $config The compiler config object. - * @param Registry|null $registry The compiler registry object. - * @param EventInterface|null $event The compiler event api object. - * @param Placeholder|null $placeholder The compiler placeholder object. - * @param Component|null $component The component class. - * @param Paths|null $paths The compiler paths object. - * @param Dynamicpath|null $dynamicpath The compiler dynamic path object. - * @param Pathfix|null $pathfix The compiler path fixing object. - * - * @since 3.2.0 - */ - public function __construct(?Config $config = null, ?Registry $registry = null, - ?EventInterface $event = null, ?Placeholder $placeholder = null, - ?Component $component = null, ?Paths $paths = null, - ?Dynamicpath $dynamicpath = null, ?Pathfix $pathfix = null) - { - $this->config = $config ?: Compiler::_('Config'); - $this->registry = $registry ?: Compiler::_('Registry'); - $this->event = $event ?: Compiler::_('Event'); - $this->placeholder = $placeholder ?: Compiler::_('Placeholder'); - $this->component = $component ?: Compiler::_('Component'); - $this->paths = $paths ?: Compiler::_('Utilities.Paths'); - $this->dynamicpath = $dynamicpath ?: Compiler::_('Utilities.Dynamicpath'); - $this->pathfix = $pathfix ?: Compiler::_('Utilities.Pathfix'); - - // add component endpoint file to stander list of root files - $this->standardRootFiles[] = $this->component->get('name_code') . '.php'; - } - - /** - * Check if data set is loaded - * - * @return bool - * @since 3.2.0 - */ - public function exists(): bool - { - if (!$this->isSet()) - { - // load the data - $this->data = $this->get(); - - if (!$this->isSet()) - { - return false; - } - } - - return true; - } - - /** - * Get Joomla - Folder Structure to Create - * - * @return object The version related structure - * @since 3.2.0 - */ - public function structure(): object - { - return $this->data->create; - } - - /** - * Get Joomla - Move Multiple Structure - * - * @return object The version related multiple structure - * @since 3.2.0 - */ - public function multiple(): object - { - return $this->data->move->dynamic; - } - - /** - * Get Joomla - Move Single Structure - * - * @return object The version related single structure - * @since 3.2.0 - */ - public function single(): object - { - return $this->data->move->static; - } - - /** - * Check if Folder is a Standard Folder - * - * @param string $folder The folder name - * - * @return bool true if the folder exists - * @since 3.2.0 - */ - public function standardFolder(string $folder): bool - { - return in_array($folder, $this->standardFolders); - } - - /** - * Check if File is a Standard Root File - * - * @param string $file The file name - * - * @return bool true if the file exists - * @since 3.2.0 - */ - public function standardRootFile(string $file): bool - { - return in_array($file, $this->standardRootFiles); - } - - /** - * Check if Data is Set - * - * @return bool - * @since 3.2.0 - */ - private function isSet(): bool - { - return is_object($this->data) && - isset($this->data->create) && - isset($this->data->move) && - isset($this->data->move->static) && - isset($this->data->move->dynamic); - } - - /** - * get the Joomla Version Data - * - * @return object|null The version data - * @since 3.2.0 - */ - private function get(): ?object - { - // override option - $customSettings = $this->paths->template_path . '/settings_' . - $this->config->component_code_name . '.json'; - - // get the data - $version_data = $this->readJsonFile($customSettings); - - if (is_null($version_data) || !$this->isValidData($version_data)) - { - return null; - } - - $this->loadExtraFolders(); - $this->loadExtraFiles(); - - $this->addFolders($version_data); - $this->addFiles($version_data); - - // for plugin event TODO change event api signatures - $component_context = $this->config->component_context; - - // Trigger Event: jcb_ce_onAfterSetJoomlaVersionData - $this->event->trigger( - 'jcb_ce_onAfterSetJoomlaVersionData', - array(&$component_context, &$version_data) - ); - - return $version_data; - } - - /** - * Read the Json file data - * - * @param string $filePath - * - * @return object|null The version data - * @since 3.2.0 - */ - private function readJsonFile(string $filePath): ?object - { - if (FileHelper::exists($filePath)) - { - $jsonContent = FileHelper::getContent($filePath); - } - else - { - $jsonContent = FileHelper::getContent($this->paths->template_path . '/settings.json'); - } - - if (JsonHelper::check($jsonContent)) - { - return json_decode((string) $jsonContent); - } - - return null; - } - - /** - * Check if this is valid data - * - * @param object $versionData - * - * @return bool - * @since 3.2.0 - */ - private function isValidData(object $versionData): bool - { - return isset($versionData->create) && - isset($versionData->move) && - isset($versionData->move->static) && - isset($versionData->move->dynamic); - } - - /** - * Add Extra/Dynamic folders - * - * @return void - * @since 3.2.0 - */ - private function loadExtraFolders() - { - if ($this->component->isArray('folders') || - $this->config->get('add_eximport', false) || - $this->config->get('uikit', 0) || - $this->config->get('footable', false)) - { - $this->addImportViewFolder(); - $this->addPhpSpreadsheetFolder(); - $this->addUikitFolder(); - $this->addFooTableFolder(); - } - } - - /** - * Add Import and Export Folder - * - * @return void - * @since 3.2.0 - */ - private function addImportViewFolder() - { - if ($this->config->get('add_eximport', false)) - { - $this->component->appendArray('folders', [ - 'folder' => 'importViews', - 'path' => 'admin/views/import', - 'rename' => 1 - ]); - } - } - - /** - * Add Php Spreadsheet Folder - * - * @return void - * @since 3.2.0 - */ - private function addPhpSpreadsheetFolder() - { - // move the phpspreadsheet Folder (TODO we must move this to a library package) - if ($this->config->get('add_eximport', false)) - { - $this->component->appendArray('folders', [ - 'folderpath' => 'JPATH_LIBRARIES/phpspreadsheet/vendor', - 'path' => '/libraries/phpspreadsheet/', - 'rename' => 0 - ]); - } - } - - /** - * Add Uikit Folders - * - * @return void - * @since 3.2.0 - */ - private function addUikitFolder() - { - $uikit = $this->config->get('uikit', 0); - if (2 == $uikit || 1 == $uikit) - { - // move the UIKIT Folder into place - $this->component->appendArray('folders', [ - 'folder' => 'uikit-v2', - 'path' => 'media', - 'rename' => 0 - ]); - } - if (2 == $uikit || 3 == $uikit) - { - // move the UIKIT-3 Folder into place - $this->component->appendArray('folders', [ - 'folder' => 'uikit-v3', - 'path' => 'media', - 'rename' => 0 - ]); - } - } - - /** - * Add Foo Table Folder - * - * @return void - * @since 3.2.0 - */ - private function addFooTableFolder() - { - if (!$this->config->get('footable', false)) - { - return; - } - - $footable_version = $this->config->get('footable_version', 2); - - if (2 == $footable_version) - { - // move the footable folder into place - $this->component->appendArray('folders', [ - 'folder' => 'footable-v2', - 'path' => 'media', - 'rename' => 0 - ]); - } - elseif (3 == $footable_version) - { - // move the footable folder into place - $this->component->appendArray('folders', [ - 'folder' => 'footable-v3', - 'path' => 'media', - 'rename' => 0 - ]); - } - } - - /** - * Add Extra/Dynamic files - * - * @return void - * @since 3.2.0 - */ - private function loadExtraFiles() - { - if ($this->component->isArray('files') || - $this->config->get('google_chart', false)) - { - $this->addGoogleChartFiles(); - } - } - - /** - * Add Google Chart Files - * - * @return void - * @since 3.2.0 - */ - private function addGoogleChartFiles() - { - if ($this->config->get('google_chart', false)) - { - // move the google chart files - $this->component->appendArray('files', [ - 'file' => 'google.jsapi.js', - 'path' => 'media/js', - 'rename' => 0 - ]); - $this->component->appendArray('files', [ - 'file' => 'chartbuilder.php', - 'path' => 'admin/helpers', - 'rename' => 0 - ]); - } - } - - /** - * Add Folders - * - * @param object $versionData - * - * @return void - * @since 3.2.0 - */ - private function addFolders(object &$versionData) - { - if (!$this->component->isArray('folders')) - { - return; - } - - // pointer tracker - $pointer_tracker = 'h'; - foreach ($this->component->get('folders') as $custom) - { - // check type of target type - $_target_type = 'c0mp0n3nt'; - if (isset($custom['target_type'])) - { - $_target_type = $custom['target_type']; - } - - // for good practice - $this->pathfix->set( - $custom, ['path', 'folder', 'folderpath'] - ); - - // fix custom path - if (isset($custom['path']) - && StringHelper::check($custom['path'])) - { - $custom['path'] = trim((string) $custom['path'], '/'); - } - - // by default custom path is true - $customPath = 'custom'; - - // set full path if this is a full path folder - if (!isset($custom['folder']) && isset($custom['folderpath'])) - { - // update the dynamic path - $custom['folderpath'] = $this->dynamicpath->update( - $custom['folderpath'] - ); - - // set the folder path with / if does not have a drive/windows full path - $custom['folder'] = (preg_match( - '/^[a-z]:/i', $custom['folderpath'] - )) ? trim($custom['folderpath'], '/') - : '/' . trim($custom['folderpath'], '/'); - - // remove the file path - unset($custom['folderpath']); - - // triget fullpath - $customPath = 'full'; - } - - // make sure we use the correct name - $pathArray = (array) explode('/', (string) $custom['path']); - $lastFolder = end($pathArray); - - // only rename folder if last has folder name - if (isset($custom['rename']) && $custom['rename'] == 1) - { - $custom['path'] = str_replace( - '/' . $lastFolder, '', (string) $custom['path'] - ); - $rename = 'new'; - $newname = $lastFolder; - } - elseif ('full' === $customPath) - { - // make sure we use the correct name - $folderArray = (array) explode('/', (string) $custom['folder']); - $lastFolder = end($folderArray); - $rename = 'new'; - $newname = $lastFolder; - } - else - { - $rename = false; - $newname = ''; - } - - // insure we have no duplicates - $key_pointer = StringHelper::safe( - $custom['folder'] - ) . '_f' . $pointer_tracker; - - $pointer_tracker++; - - // fix custom path - $custom['path'] = ltrim((string) $custom['path'], '/'); - - // set new folder to object - $versionData->move->static->{$key_pointer} = new \stdClass(); - $versionData->move->static->{$key_pointer}->naam = str_replace('//', '/', (string) $custom['folder']); - $versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path']; - $versionData->move->static->{$key_pointer}->rename = $rename; - $versionData->move->static->{$key_pointer}->newName = $newname; - $versionData->move->static->{$key_pointer}->type = 'folder'; - $versionData->move->static->{$key_pointer}->custom = $customPath; - - // set the target if type and id is found - if (isset($custom['target_id']) && isset($custom['target_type'])) - { - $versionData->move->static->{$key_pointer}->_target = [ - 'key' => $custom['target_id'] . '_' . $custom['target_type'], - 'type' => $custom['target_type'] - ]; - } - } - - $this->component->remove('folders'); - } - - /** - * Add Files - * - * @param object $versionData - * - * @return void - * @since 3.2.0 - */ - private function addFiles(object &$versionData) - { - if (!$this->component->isArray('files')) { - return; - } - - // pointer tracker - $pointer_tracker = 'h'; - foreach ($this->component->get('files') as $custom) - { - // check type of target type - $_target_type = 'c0mp0n3nt'; - if (isset($custom['target_type'])) - { - $_target_type = $custom['target_type']; - } - - // for good practice - $this->pathfix->set( - $custom, ['path', 'file', 'filepath'] - ); - - // by default custom path is true - $customPath = 'custom'; - - // set full path if this is a full path file - if (!isset($custom['file']) && isset($custom['filepath'])) - { - // update the dynamic path - $custom['filepath'] = $this->dynamicpath->update( - $custom['filepath'] - ); - - // set the file path with / if does not have a drive/windows full path - $custom['file'] = (preg_match('/^[a-z]:/i', $custom['filepath'])) - ? trim($custom['filepath'], '/') : '/' . trim($custom['filepath'], '/'); - - // remove the file path - unset($custom['filepath']); - - // triget fullpath - $customPath = 'full'; - } - - // make sure we have not duplicates - $key_pointer = StringHelper::safe( - $custom['file'] - ) . '_g' . $pointer_tracker; - - $pointer_tracker++; - - // set new file to object - $versionData->move->static->{$key_pointer} = new \stdClass(); - $versionData->move->static->{$key_pointer}->naam = str_replace('//', '/', (string) $custom['file']); - - // update the dynamic component name placholders in file names - $custom['path'] = $this->placeholder->update_( - $custom['path'] - ); - - // get the path info - $pathInfo = pathinfo((string) $custom['path']); - if (isset($pathInfo['extension']) && $pathInfo['extension']) - { - $pathInfo['dirname'] = trim($pathInfo['dirname'], '/'); - - // set the info - $versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $pathInfo['dirname']; - $versionData->move->static->{$key_pointer}->rename = 'new'; - $versionData->move->static->{$key_pointer}->newName = $pathInfo['basename']; - } - elseif ('full' === $customPath) - { - // fix custom path - $custom['path'] = ltrim((string) $custom['path'], '/'); - - // get file array - $fileArray = (array) explode('/', (string) $custom['file']); - - // set the info - $versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path']; - $versionData->move->static->{$key_pointer}->rename = 'new'; - $versionData->move->static->{$key_pointer}->newName = end($fileArray); - } - else - { - // fix custom path - $custom['path'] = ltrim((string) $custom['path'], '/'); - - // set the info - $versionData->move->static->{$key_pointer}->path = $_target_type . '/' . $custom['path']; - $versionData->move->static->{$key_pointer}->rename = false; - } - - $versionData->move->static->{$key_pointer}->type = 'file'; - $versionData->move->static->{$key_pointer}->custom = $customPath; - - // set the target if type and id is found - if (isset($custom['target_id']) - && isset($custom['target_type'])) - { - $versionData->move->static->{$key_pointer}->_target = [ - 'key' => $custom['target_id'] . '_' . $custom['target_type'], - 'type' => $custom['target_type'] - ]; - } - - // check if file should be updated - if (!isset($custom['notnew']) || $custom['notnew'] == 0 - || $custom['notnew'] != 1) - { - $this->registry->appendArray('files.not.new', $key_pointer); - } - else - { - // update the file content - $this->registry->set('update.file.content.' . $key_pointer, true); - } - } - - $this->component->remove('files'); - } - -} - diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Structure.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Structure.php index dee9d57c4..c07ccf99e 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Structure.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Structure.php @@ -13,7 +13,7 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Component; use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; -use VDM\Joomla\Componentbuilder\Compiler\Component\Settings; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\SettingsInterface as Settings; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder; use VDM\Joomla\Utilities\ObjectHelper; diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Structuremultiple.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Structuremultiple.php index 4bd1fc9a8..45f11cf58 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Structuremultiple.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Structuremultiple.php @@ -15,7 +15,7 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Component; use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; use VDM\Joomla\Componentbuilder\Compiler\Config; use VDM\Joomla\Componentbuilder\Compiler\Registry; -use VDM\Joomla\Componentbuilder\Compiler\Component\Settings; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\SettingsInterface as Settings; use VDM\Joomla\Componentbuilder\Compiler\Component; use VDM\Joomla\Componentbuilder\Compiler\Model\Createdate; use VDM\Joomla\Componentbuilder\Compiler\Model\Modifieddate; diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Structuresingle.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Structuresingle.php index 7f9b33d22..3e88c3ad6 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Structuresingle.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Component/Structuresingle.php @@ -19,7 +19,8 @@ use Joomla\CMS\Filesystem\Folder; use Joomla\CMS\Filesystem\File; use VDM\Joomla\Componentbuilder\Compiler\Config; use VDM\Joomla\Componentbuilder\Compiler\Registry; -use VDM\Joomla\Componentbuilder\Compiler\Component\Settings; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\SettingsInterface as Settings; use VDM\Joomla\Componentbuilder\Compiler\Component; use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Content; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter; @@ -85,7 +86,15 @@ final class Structuresingle protected Registry $registry; /** - * The Settings Class. + * The Placeholder Class. + * + * @var Placeholder + * @since 3.2.0 + */ + protected Placeholder $placeholder; + + /** + * The SettingsInterface Class. * * @var Settings * @since 3.2.0 @@ -143,24 +152,27 @@ final class Structuresingle /** * Constructor. * - * @param Config $config The Config Class. - * @param Registry $registry The Registry Class. - * @param Settings $settings The Settings Class. - * @param Component $component The Component Class. - * @param Content $content The ContentOne Class. - * @param Counter $counter The Counter Class. - * @param Paths $paths The Paths Class. - * @param Files $files The Files Class. - * @param CMSApplication|null $app The CMS Application object. + * @param Config $config The Config Class. + * @param Registry $registry The Registry Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Settings $settings The SettingsInterface Class. + * @param Component $component The Component Class. + * @param Content $content The ContentOne Class. + * @param Counter $counter The Counter Class. + * @param Paths $paths The Paths Class. + * @param Files $files The Files Class. + * @param CMSApplication|null $app The CMS Application object. * * @since 3.2.0 */ - public function __construct(Config $config, Registry $registry, Settings $settings, + public function __construct(Config $config, Registry $registry, + Placeholder $placeholder, Settings $settings, Component $component, Content $content, Counter $counter, Paths $paths, Files $files, ?CMSApplication $app = null) { $this->config = $config; $this->registry = $registry; + $this->placeholder = $placeholder; $this->settings = $settings; $this->component = $component; $this->content = $content; @@ -299,21 +311,24 @@ final class Structuresingle { if ($details->rename === 'new') { - $this->newName = $details->newName; + $newName = $details->newName; } else { - $this->newName = str_replace( + $naam = $details->naam ?? 'error'; + $newName = str_replace( $details->rename, $this->config->component_code_name, - (string) $details->naam + (string) $naam ); } } else { - $this->newName = $details->naam; + $newName = $details->naam ?? 'error'; } + + $this->newName = $this->placeholder->update_($newName); } /** @@ -605,13 +620,24 @@ final class Structuresingle // add the setDynamicF0ld3rs() method to the install scipt.php file $this->registry->set('set_move_folders_install_script', true); + $function = 'setDynamicF0ld3rs'; + $script = 'script.php'; + if ($this->config->get('joomla_version', 3) != 3) + { + $function = 'moveFolders'; + $script = 'ComponentnameInstallerScript.php'; + } + // set message that this was done (will still add a tutorial link later) $this->app->enqueueMessage( Text::_('COM_COMPONENTBUILDER_HR_HTHREEDYNAMIC_FOLDERS_WERE_DETECTEDHTHREE'), 'Notice' ); + $this->app->enqueueMessage( - Text::sprintf('COM_COMPONENTBUILDER_A_METHOD_SETDYNAMICFZEROLDTHREERS_WAS_ADDED_TO_THE_INSTALL_BSCRIPTPHPB_OF_THIS_PACKAGE_TO_INSURE_THAT_THE_FOLDERS_ARE_COPIED_INTO_THE_CORRECT_PLACE_WHEN_THIS_COMPONENT_IS_INSTALLED'), + Text::sprintf('COM_COMPONENTBUILDER_A_METHOD_S_WAS_ADDED_TO_THE_INSTALL_BSB_OF_THIS_PACKAGE_TO_INSURE_THAT_THE_FOLDERS_ARE_COPIED_INTO_THE_CORRECT_PLACE_WHEN_THIS_COMPONENT_IS_INSTALLED', + $function, $script + ), 'Notice' ); } diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Config.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Config.php index 475959753..9868f0ed3 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Config.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Config.php @@ -293,6 +293,42 @@ class Config extends BaseConfig return strlen((string) $this->component_code_name); } + /** + * get add namespace prefix + * + * @return bool The add namespace prefix switch + * @since 3.2.0 + */ + protected function getAddnamespaceprefix(): bool + { + // get components override switch + $value = GetHelper::var( + 'joomla_component', $this->component_id, 'id', 'add_namespace_prefix' + ); + + return $value == 1 ? true : false; + } + + /** + * get namespace prefix + * + * @return string The namespace prefix + * @since 3.2.0 + */ + protected function getNamespaceprefix(): string + { + // load based on component settings + $prefix = null; + if ($this->add_namespace_prefix) + { + $prefix = GetHelper::var( + 'joomla_component', $this->component_id, 'id', 'namespace_prefix' + ); + } + + return $prefix ?? $this->params->get('namespace_prefix', 'JCB'); + } + /** * get posted Joomla version * @@ -301,7 +337,7 @@ class Config extends BaseConfig */ protected function getJoomlaversion(): int { - return 3; // $this->input->post->get('joomla_version', 3, 'INT'); + return $this->input->post->get('joomla_version', 3, 'INT'); } /** @@ -313,8 +349,9 @@ class Config extends BaseConfig protected function getJoomlaversions(): array { return [ - 3 => ['folder_key' => 3, 'xml_version' => 3.9], // only joomla 3 - 3.10 => ['folder_key' => 3, 'xml_version' => 4.0] // legacy joomla 4 + 3 => ['folder_key' => 3, 'xml_version' => '3.10'], + 4 => ['folder_key' => 4, 'xml_version' => '4.0'], + 5 => ['folder_key' => 4, 'xml_version' => '5.0'] // for now we build 4 and 5 from same templates ;) ]; } @@ -524,6 +561,18 @@ class Config extends BaseConfig return true; } + /** + * get percentage when a language should be added + * + * @return int The percentage value + * @since 3.2.0 + */ + protected function getPercentagelanguageadd(): int + { + // get the global language + return $this->params->get('percentagelanguageadd', 50); + } + /** * get language tag * @@ -586,7 +635,7 @@ class Config extends BaseConfig // these strings are used to search for language strings in all content return [ 'jjt' => 'Joomla' . '.JText._(', - 'js' => 'JText:' . ':script(', + 'js' => 'Text:' . ':script(', 't' => 'Text:' . ':_(', // namespace and J version will be found 'ts' => 'Text:' . ':sprintf(', // namespace and J version will be found 'jt' => 'JustTEXT:' . ':_(' @@ -659,6 +708,18 @@ class Config extends BaseConfig return $this->params->get('jcb_powers_path', 'libraries/jcb_powers'); } + /** + * get jcb powers path + * + * @return string The jcb powers path + * @since 3.2.0 + */ + protected function getPowerlibraryfolder(): string + { + // get power library folder path + return trim(str_replace('libraries/', '', $this->jcb_powers_path), '/'); + } + /** * Get local super powers repository path * @@ -1005,6 +1066,28 @@ class Config extends BaseConfig protected function getFootableversion(): int { return 2; // default is version 2 + } + + /** + * The Permission Strict Per Field Switch + * + * @return bool Switch to control the Strict Permission Per/Field + * @since 3.2.0 + */ + protected function getPermissionstrictperfield(): bool + { + return false; + } + + /** + * The Export Text Only Switch + * + * @return int Switch to control the export text only + * @since 3.2.0 + */ + protected function getExporttextonly(): int + { + return 0; } } diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/AccessSections.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/AccessSections.php new file mode 100644 index 000000000..28fe04300 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/AccessSections.php @@ -0,0 +1,709 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Creator; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Component; +use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName; +use VDM\Joomla\Componentbuilder\Compiler\Field\TypeName; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter; +use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission; +use VDM\Joomla\Componentbuilder\Compiler\Builder\AssetsRules; +use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomTabs; +use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionViews; +use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionFields; +use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionComponent; +use VDM\Joomla\Componentbuilder\Compiler\Creator\CustomButtonPermissions; +use VDM\Joomla\Utilities\MathHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + + +/** + * Access Sections Creator Class + * + * @since 3.2.0 + */ +final class AccessSections +{ + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The EventInterface Class. + * + * @var Event + * @since 3.2.0 + */ + protected Event $event; + + /** + * The Language Class. + * + * @var Language + * @since 3.2.0 + */ + protected Language $language; + + /** + * The Component Class. + * + * @var Component + * @since 3.2.0 + */ + protected Component $component; + + /** + * The Name Class. + * + * @var FieldName + * @since 3.2.0 + */ + protected FieldName $fieldname; + + /** + * The TypeName Class. + * + * @var TypeName + * @since 3.2.0 + */ + protected TypeName $typename; + + /** + * The Counter Class. + * + * @var Counter + * @since 3.2.0 + */ + protected Counter $counter; + + /** + * The Permission Class. + * + * @var Permission + * @since 3.2.0 + */ + protected Permission $permission; + + /** + * The AssetsRules Class. + * + * @var AssetsRules + * @since 3.2.0 + */ + protected AssetsRules $assetsrules; + + /** + * The CustomTabs Class. + * + * @var CustomTabs + * @since 3.2.0 + */ + protected CustomTabs $customtabs; + + /** + * The PermissionViews Class. + * + * @var PermissionViews + * @since 3.2.0 + */ + protected PermissionViews $permissionviews; + + /** + * The PermissionFields Class. + * + * @var PermissionFields + * @since 3.2.0 + */ + protected PermissionFields $permissionfields; + + /** + * The PermissionComponent Class. + * + * @var PermissionComponent + * @since 3.2.0 + */ + protected PermissionComponent $permissioncomponent; + + /** + * The CustomButtonPermissions Class. + * + * @var CustomButtonPermissions + * @since 3.2.0 + */ + protected CustomButtonPermissions $custombuttonpermissions; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Event $event The EventInterface Class. + * @param Language $language The Language Class. + * @param Component $component The Component Class. + * @param FieldName $fieldname The Name Class. + * @param TypeName $typename The TypeName Class. + * @param Counter $counter The Counter Class. + * @param Permission $permission The Permission Class. + * @param AssetsRules $assetsrules The AssetsRules Class. + * @param CustomTabs $customtabs The CustomTabs Class. + * @param PermissionViews $permissionviews The PermissionViews Class. + * @param PermissionFields $permissionfields The PermissionFields Class. + * @param PermissionComponent $permissioncomponent The PermissionComponent Class. + * @param CustomButtonPermissions $custombuttonpermissions The CustomButtonPermissions Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Event $event, Language $language, + Component $component, FieldName $fieldname, + TypeName $typename, Counter $counter, + Permission $permission, AssetsRules $assetsrules, + CustomTabs $customtabs, PermissionViews $permissionviews, + PermissionFields $permissionfields, + PermissionComponent $permissioncomponent, + CustomButtonPermissions $custombuttonpermissions) + { + $this->config = $config; + $this->event = $event; + $this->language = $language; + $this->component = $component; + $this->fieldname = $fieldname; + $this->typename = $typename; + $this->counter = $counter; + $this->permission = $permission; + $this->assetsrules = $assetsrules; + $this->customtabs = $customtabs; + $this->permissionviews = $permissionviews; + $this->permissionfields = $permissionfields; + $this->permissioncomponent = $permissioncomponent; + $this->custombuttonpermissions = $custombuttonpermissions; + } + + /** + * Get Access Sections + * + * @return string + * @since 3.2.0 + */ + public function get(): string + { + // access size counter + $this->counter->accessSize = 12; // ;) + + // Trigger Event: jcb_ce_onBeforeBuildAccessSections + $this->event->trigger( + 'jcb_ce_onBeforeBuildAccessSections' + ); + + // Get the default fields + $default_fields = $this->config->default_fields; + $this->permissioncomponent->add('->HEAD<-', [ + 'name' => 'core.admin', + 'title' => 'JACTION_ADMIN', + 'description' => 'JACTION_ADMIN_COMPONENT_DESC' + ], true); + $this->permissioncomponent->add('->HEAD<-', [ + 'name' => 'core.options', + 'title' => 'JACTION_OPTIONS', + 'description' => 'JACTION_OPTIONS_COMPONENT_DESC' + ], true); + $this->permissioncomponent->add('->HEAD<-', [ + 'name' => 'core.manage', + 'title' => 'JACTION_MANAGE', + 'description' => 'JACTION_MANAGE_COMPONENT_DESC' + ], true); + + if ($this->config->get('add_eximport', false)) + { + $exportTitle = $this->config->lang_prefix . '_' + . StringHelper::safe('Export Data', 'U'); + $exportDesc = $this->config->lang_prefix . '_' + . StringHelper::safe('Export Data', 'U') + . '_DESC'; + $this->language->set('bothadmin', $exportTitle, 'Export Data'); + $this->language->set( + 'bothadmin', $exportDesc, + ' Allows users in this group to export data.' + ); + $this->permissioncomponent->add('->HEAD<-', [ + 'name' => 'core.export', + 'title' => $exportTitle, + 'description' => $exportDesc + ], true); + + // the size needs increase + $this->counter->accessSize++; + $importTitle = $this->config->lang_prefix . '_' + . StringHelper::safe('Import Data', 'U'); + $importDesc = $this->config->lang_prefix . '_' + . StringHelper::safe('Import Data', 'U') + . '_DESC'; + $this->language->set('bothadmin', $importTitle, 'Import Data'); + $this->language->set( + 'bothadmin', $importDesc, + ' Allows users in this group to import data.' + ); + $this->permissioncomponent->add('->HEAD<-', [ + 'name' => 'core.import', + 'title' => $importTitle, + 'description' => $importDesc + ], true); + + // the size needs increase + $this->counter->accessSize++; + } + + // version permission + $batchTitle = $this->config->lang_prefix . '_' + . StringHelper::safe('Use Batch', 'U'); + $batchDesc = $this->config->lang_prefix . '_' + . StringHelper::safe('Use Batch', 'U') . '_DESC'; + $this->language->set('bothadmin', $batchTitle, 'Use Batch'); + $this->language->set( + 'bothadmin', $batchDesc, + ' Allows users in this group to use batch copy/update method.' + ); + $this->permissioncomponent->add('->HEAD<-', [ + 'name' => 'core.batch', + 'title' => $batchTitle, + 'description' => $batchDesc + ], true); + + // version permission + $importTitle = $this->config->lang_prefix . '_' + . StringHelper::safe('Edit Versions', 'U'); + $importDesc = $this->config->lang_prefix . '_' + . StringHelper::safe('Edit Versions', 'U') + . '_DESC'; + $this->language->set('bothadmin', $importTitle, 'Edit Version'); + $this->language->set( + 'bothadmin', $importDesc, + ' Allows users in this group to edit versions.' + ); + $this->permissioncomponent->add('->HEAD<-', [ + 'name' => 'core.version', + 'title' => $importTitle, + 'description' => $importDesc + ], true); + + // set the defaults + $this->permissioncomponent->add('->HEAD<-', [ + 'name' => 'core.create', + 'title' => 'JACTION_CREATE', + 'description' => 'JACTION_CREATE_COMPONENT_DESC' + ], true); + $this->permissioncomponent->add('->HEAD<-', [ + 'name' => 'core.delete', + 'title' => 'JACTION_DELETE', + 'description' => 'JACTION_DELETE_COMPONENT_DESC' + ], true); + $this->permissioncomponent->add('->HEAD<-', [ + 'name' => 'core.edit', + 'title' => 'JACTION_EDIT', + 'description' => 'JACTION_EDIT_COMPONENT_DESC' + ], true); + $this->permissioncomponent->add('->HEAD<-', [ + 'name' => 'core.edit.state', + 'title' => 'JACTION_EDITSTATE', + 'description' => 'JACTION_ACCESS_EDITSTATE_DESC' + ], true); + $this->permissioncomponent->add('->HEAD<-', [ + 'name' => 'core.edit.own', + 'title' => 'JACTION_EDITOWN', + 'description' => 'JACTION_EDITOWN_COMPONENT_DESC' + ], true); + + // set the Joomla fields + if ($this->config->get('set_joomla_fields', false)) + { + $this->permissioncomponent->add('->HEAD<-', [ + 'name' => 'core.edit.value', + 'title' => 'JACTION_EDITVALUE', + 'description' => 'JACTION_EDITVALUE_COMPONENT_DESC' + ], true); + + // the size needs increase + $this->counter->accessSize++; + } + + // new custom created by permissions + $created_byTitle = $this->config->lang_prefix . '_' + . StringHelper::safe('Edit Created By', 'U'); + $created_byDesc = $this->config->lang_prefix . '_' + . StringHelper::safe('Edit Created By', 'U') + . '_DESC'; + $this->language->set('bothadmin', $created_byTitle, 'Edit Created By'); + $this->language->set( + 'bothadmin', $created_byDesc, + ' Allows users in this group to edit created by.' + ); + $this->permissioncomponent->add('->HEAD<-', [ + 'name' => 'core.edit.created_by', + 'title' => $created_byTitle, + 'description' => $created_byDesc + ], true); + + // new custom created date permissions + $createdTitle = $this->config->lang_prefix . '_' + . StringHelper::safe('Edit Created Date', 'U'); + $createdDesc = $this->config->lang_prefix . '_' + . StringHelper::safe('Edit Created Date', 'U') + . '_DESC'; + $this->language->set('bothadmin', $createdTitle, 'Edit Created Date'); + $this->language->set( + 'bothadmin', $createdDesc, + ' Allows users in this group to edit created date.' + ); + $this->permissioncomponent->add('->HEAD<-', [ + 'name' => 'core.edit.created', + 'title' => $createdTitle, + 'description' => $createdDesc + ], true); + + // set the menu controller lookup + $menuControllers = ['access', 'submenu', 'dashboard_list', 'dashboard_add']; + + // set the custom admin views permissions + if ($this->component->isArray('custom_admin_views')) + { + foreach ($this->component->get('custom_admin_views') as $custom_admin_view) + { + // new custom permissions to access this view + $customAdminName = $custom_admin_view['settings']->name; + $customAdminCode = $custom_admin_view['settings']->code; + $customAdminTitle = $this->config->lang_prefix . '_' + . StringHelper::safe( + $customAdminName . ' Access', 'U' + ); + $customAdminDesc = $this->config->lang_prefix . '_' + . StringHelper::safe( + $customAdminName . ' Access', 'U' + ) . '_DESC'; + $sortKey = StringHelper::safe( + $customAdminName . ' Access' + ); + $this->language->set( + 'bothadmin', $customAdminTitle, $customAdminName . ' Access' + ); + $this->language->set( + 'bothadmin', $customAdminDesc, + ' Allows the users in this group to access ' + . StringHelper::safe($customAdminName, 'w') + . '.' + ); + $this->permissioncomponent->set($sortKey, [ + 'name' => "$customAdminCode.access", + 'title' => $customAdminTitle, + 'description' => $customAdminDesc + ]); + + // the size needs increase + $this->counter->accessSize++; + + // add the custom permissions to use the buttons of this view + $this->custombuttonpermissions->add( + $custom_admin_view['settings'], $customAdminName, + $customAdminCode + ); + + // add menu controll view that has menus options + foreach ($menuControllers as $menuController) + { + // add menu controll view that has menus options + if (isset($custom_admin_view[$menuController]) + && $custom_admin_view[$menuController]) + { + $targetView_ = 'views.'; + if ($menuController === 'dashboard_add') + { + $targetView_ = 'view.'; + } + + // menucontroller + $menucontrollerView['action'] = $targetView_ + . $menuController; + $menucontrollerView['implementation'] = '2'; + if (isset($custom_admin_view['settings']->permissions) + && ArrayHelper::check( + $custom_admin_view['settings']->permissions + )) + { + array_push( + $custom_admin_view['settings']->permissions, + $menucontrollerView + ); + } + else + { + $custom_admin_view['settings']->permissions + = []; + $custom_admin_view['settings']->permissions[] + = $menucontrollerView; + } + unset($menucontrollerView); + } + } + + $this->permission ->set( + $custom_admin_view, $customAdminCode, $customAdminCode, + $menuControllers, 'customAdmin' + ); + } + } + + // set the site views permissions + if ($this->component->isArray('site_views')) + { + foreach ($this->component->get('site_views') as $site_view) + { + // new custom permissions to access this view + $siteName = $site_view['settings']->name; + $siteCode = $site_view['settings']->code; + $siteTitle = $this->config->lang_prefix . '_' + . StringHelper::safe( + $siteName . ' Access Site', 'U' + ); + $siteDesc = $this->config->lang_prefix . '_' + . StringHelper::safe( + $siteName . ' Access Site', 'U' + ) . '_DESC'; + $sortKey = StringHelper::safe( + $siteName . ' Access Site' + ); + + if (isset($site_view['access']) && $site_view['access'] == 1) + { + $this->language->set( + 'bothadmin', $siteTitle, $siteName . ' (Site) Access' + ); + $this->language->set( + 'bothadmin', $siteDesc, + ' Allows the users in this group to access site ' + . StringHelper::safe($siteName, 'w') + . '.' + ); + $this->permissioncomponent->set($sortKey, [ + 'name' => "site.$siteCode.access", + 'title' => $siteTitle, + 'description' => $siteDesc + ]); + + // the size needs increase + $this->counter->accessSize++; + + // check if this site view requires access rule to default to public + if (isset($site_view['public_access']) + && $site_view['public_access'] == 1) + { + // we use one as public group (TODO we see if we run into any issues) + $this->assetsrules->add('site', '"site.' . $siteCode + . '.access":{"1":1}'); + } + } + + // add the custom permissions to use the buttons of this view + $this->custombuttonpermissions->add( + $site_view['settings'], $siteName, $siteCode + ); + } + } + + if ($this->component->isArray('admin_views')) + { + foreach ($this->component->get('admin_views') as $view) + { + // set view name + $nameView = StringHelper::safe( + $view['settings']->name_single + ); + $nameViews = StringHelper::safe( + $view['settings']->name_list + ); + + // add custom tab permissions if found + if (($tabs_ = $this->customtabs->get($nameView)) !== null + && ArrayHelper::check($tabs_)) + { + foreach ($tabs_ as $_customTab) + { + if (isset($_customTab['permission']) + && $_customTab['permission'] == 1) + { + $this->permissioncomponent->set($_customTab['sortKey'], [ + 'name' => $_customTab['view'] . '.' . $_customTab['code'] . '.viewtab', + 'title' => $_customTab['lang_permission'], + 'description' => $_customTab['lang_permission_desc'] + ]); + + // the size needs increase + $this->counter->accessSize++; + } + } + } + + // add the custom permissions to use the buttons of this view + $this->custombuttonpermissions->add( + $view['settings'], $view['settings']->name_single, $nameView + ); + + if ($nameView != 'component') + { + // add menu controll view that has menus options + foreach ($menuControllers as $menuController) + { + // add menu controll view that has menus options + if (isset($view[$menuController]) + && $view[$menuController]) + { + $targetView_ = 'views.'; + if ($menuController === 'dashboard_add') + { + $targetView_ = 'view.'; + } + // menucontroller + $menucontrollerView['action'] = $targetView_ . $menuController; + $menucontrollerView['implementation'] = '2'; + if (isset($view['settings']->permissions) + && ArrayHelper::check( + $view['settings']->permissions + )) + { + array_push( + $view['settings']->permissions, + $menucontrollerView + ); + } + else + { + $view['settings']->permissions = []; + $view['settings']->permissions[] = $menucontrollerView; + } + unset($menucontrollerView); + } + } + + // check if there are fields + if (ArrayHelper::check($view['settings']->fields)) + { + // field permission options + $permission_options = [1 => 'edit', 2 => 'access', 3 => 'view']; + + // check the fields for their permission settings + foreach ($view['settings']->fields as $field) + { + // see if field require permissions to be set + if (isset($field['permission']) + && ArrayHelper::check( + $field['permission'] + )) + { + if (ArrayHelper::check( + $field['settings']->properties + )) + { + $fieldType = $this->typename->get($field); + $fieldName = $this->fieldname->get( + $field, $nameViews + ); + + // loop the permission options + foreach ($field['permission'] as $permission_id) + { + // set the permission key word + $permission_option = $permission_options[(int) $permission_id]; + + // reset the bucket + $fieldView = []; + + // set the permission for this field + $fieldView['action'] = 'view.' . $permission_option . '.' . $fieldName; + $fieldView['implementation'] = '3'; + + // check if persmissions was already set + if (isset($view['settings']->permissions) + && ArrayHelper::check( + $view['settings']->permissions + )) + { + array_push($view['settings']->permissions, $fieldView); + } + else + { + $view['settings']->permissions = []; + $view['settings']->permissions[] = $fieldView; + } + + // ensure that no default field get loaded + if (!in_array($fieldName, $default_fields)) + { + // load to global field permission set + $this->permissionfields-> + set("$nameView.$fieldName.$permission_option", $fieldType); + } + } + } + } + } + } + $this->permission ->set( + $view, $nameView, $nameViews, $menuControllers + ); + } + } + + // Trigger Event: jcb_ce_onAfterBuildAccessSections + $this->event->trigger( + 'jcb_ce_onAfterBuildAccessSections' + ); + + /// now build the section + $component = $this->permissioncomponent->build(); + + // add views to the component section + $component .= $this->permissionviews->build(); + + // remove the fix, is not needed + if ($this->counter->accessSize < 30) + { + // since we have less than 30 actions + // we do not need the fix for this component + $this->config->set('add_assets_table_fix', 0); + } + else + { + // get the worst case column size required (can be worse I know) + // access/action size x 20 characters x 8 groups + $character_length = (int) MathHelper::bc( + 'mul', $this->counter->accessSize, 20, 0 + ); + + // set worse case + $this->config->set('access_worse_case', (int) MathHelper::bc( + 'mul', $character_length, 8, 0 + )); + } + + // return the build + return $component; + } + + return false; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/AccessSectionsCategory.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/AccessSectionsCategory.php new file mode 100644 index 000000000..2f621a693 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/AccessSectionsCategory.php @@ -0,0 +1,80 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Creator; + + +use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryCode; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; + + +/** + * Access Sections Category Creator Class + * + * @since 3.2.0 + */ +final class AccessSectionsCategory +{ + /** + * The CategoryCode Class. + * + * @var CategoryCode + * @since 3.2.0 + */ + protected CategoryCode $categorycode; + + /** + * Constructor. + * + * @param CategoryCode $categorycode The CategoryCode Class. + * + * @since 3.2.0 + */ + public function __construct(CategoryCode $categorycode) + { + $this->categorycode = $categorycode; + } + + /** + * Get Access Sections Category + * + * @param string $nameSingleCode + * @param string $nameListCode + * + * @return string + * @since 3.2.0 + */ + public function get(string $nameSingleCode, string $nameListCode): string + { + $component = ''; + // check if view has category + $otherViews = $this->categorycode->getString("{$nameSingleCode}.views"); + if ($otherViews !== null && $otherViews == $nameListCode) + { + $component .= PHP_EOL . Indent::_(1) + . '
    '; + $component .= PHP_EOL . Indent::_(2) + . ''; + $component .= PHP_EOL . Indent::_(2) + . ''; + $component .= PHP_EOL . Indent::_(2) + . ''; + $component .= PHP_EOL . Indent::_(2) + . ''; + $component .= PHP_EOL . Indent::_(2) + . ''; + $component .= PHP_EOL . Indent::_(1) . "
    "; + } + + return $component; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/AccessSectionsJoomlaFields.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/AccessSectionsJoomlaFields.php new file mode 100644 index 000000000..c6f722562 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/AccessSectionsJoomlaFields.php @@ -0,0 +1,63 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Creator; + + +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; + + +/** + * Access Sections Joomla Fields Creator Class + * + * @since 3.2.0 + */ +final class AccessSectionsJoomlaFields +{ + /** + * Set Access Sections Joomla Fields + * + * @return string + * @since 3.2.0 + */ + public function get(): string + { + $component = ''; + // set all the core field permissions + $component .= PHP_EOL . Indent::_(1) . '
    '; + $component .= PHP_EOL . Indent::_(2) + . ''; + $component .= PHP_EOL . Indent::_(2) + . ''; + $component .= PHP_EOL . Indent::_(2) + . ''; + $component .= PHP_EOL . Indent::_(2) + . ''; + $component .= PHP_EOL . Indent::_(2) + . ''; + $component .= PHP_EOL . Indent::_(2) + . ''; + $component .= PHP_EOL . Indent::_(1) . '
    '; + $component .= PHP_EOL . Indent::_(1) . '
    '; + $component .= PHP_EOL . Indent::_(2) + . ''; + $component .= PHP_EOL . Indent::_(2) + . ''; + $component .= PHP_EOL . Indent::_(2) + . ''; + $component .= PHP_EOL . Indent::_(2) + . ''; + $component .= PHP_EOL . Indent::_(1) . '
    '; + + return $component; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/Builders.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/Builders.php index 016921747..ee79b9a8c 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/Builders.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/Builders.php @@ -16,6 +16,7 @@ use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\Application\CMSApplication; use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Power; use VDM\Joomla\Componentbuilder\Compiler\Language; use VDM\Joomla\Componentbuilder\Compiler\Placeholder; use VDM\Joomla\Componentbuilder\Compiler\Creator\Layout; @@ -82,6 +83,14 @@ final class Builders */ protected Config $config; + /** + * The Power Class. + * + * @var Power + * @since 3.2.0 + */ + protected Power $power; + /** * The Language Class. * @@ -454,6 +463,7 @@ final class Builders * Constructor. * * @param Config $config The Config Class. + * @param Power $power The Power Class. * @param Language $language The Language Class. * @param Placeholder $placeholder The Placeholder Class. * @param Layout $layout The Layout Class. @@ -503,7 +513,7 @@ final class Builders * * @since 3.2.0 */ - public function __construct(Config $config, Language $language, + public function __construct(Config $config, Power $power, Language $language, Placeholder $placeholder, Layout $layout, SiteFieldData $sitefielddata, Tags $tags, DatabaseTables $databasetables, @@ -536,6 +546,7 @@ final class Builders ComponentFields $componentfields, ?CMSApplication $app = null) { $this->config = $config; + $this->power = $power; $this->language = $language; $this->placeholder = $placeholder; $this->layout = $layout; @@ -789,6 +800,8 @@ final class Builders ); } } + // extends value + $extends_field = $custom['extends'] ?? ''; // build the list values if (($listSwitch || $listJoin) && $typeName != 'repeatable' && $typeName != 'subform') @@ -914,7 +927,7 @@ final class Builders ); } // build script switch for user - if ($custom['extends'] === 'user') + if ($extends_field === 'user') { $this->scriptuserswitch->set($typeName, $typeName); } @@ -986,7 +999,7 @@ final class Builders } // setup checkbox for this view if ($dbSwitch && ($typeName === 'checkbox' || - (ArrayHelper::check($custom) && isset($custom['extends']) && $custom['extends'] === 'checkboxes'))) + (ArrayHelper::check($custom) && $extends_field === 'checkboxes'))) { $this->checkbox->add($nameSingleCode, $name, true); } @@ -1029,6 +1042,8 @@ final class Builders $this->sitefielddata->set( $nameSingleCode, $name, 'basic_encryption', $typeName ); + // make sure to load FOF encryption (power) + $this->power->get('99175f6d-dba8-4086-8a65-5c4ec175e61d', 1); // add open close method to field data $field['store'] = 'basic_encryption'; break; @@ -1039,6 +1054,8 @@ final class Builders $this->sitefielddata->set( $nameSingleCode, $name, 'whmcs_encryption', $typeName ); + // make sure to load FOF encryption (power) + $this->power->get('99175f6d-dba8-4086-8a65-5c4ec175e61d', 1); // add open close method to field data $field['store'] = 'whmcs_encryption'; break; @@ -1049,6 +1066,8 @@ final class Builders $this->sitefielddata->set( $nameSingleCode, $name, 'medium_encryption', $typeName ); + // make sure to load FOF encryption (power) + $this->power->get('99175f6d-dba8-4086-8a65-5c4ec175e61d', 1); // add open close method to field data $field['store'] = 'medium_encryption'; break; diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsets.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsets.php new file mode 100644 index 000000000..23aaf3945 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsets.php @@ -0,0 +1,388 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Creator; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Component; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Component\Placeholder as CPlaceholder; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ExtensionsParams; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsetsCustomfield as Customfield; +use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldAsString; +use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsGlobal; +use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsSiteControl; +use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsGroupControl; +use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsUikit; +use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsGooglechart; +use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsEmailHelper; +use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsEncryption; +use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsCustomfield; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; +use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Utilities\MathHelper; + + +/** + * Config Fieldsets Creator Class + * + * @since 3.2.0 + */ +final class ConfigFieldsets +{ + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The Component Class. + * + * @var Component + * @since 3.2.0 + */ + protected Component $component; + + /** + * The EventInterface Class. + * + * @var Event + * @since 3.2.0 + */ + protected Event $event; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 3.2.0 + */ + protected Placeholder $placeholder; + + /** + * The Placeholder Class. + * + * @var CPlaceholder + * @since 3.2.0 + */ + protected CPlaceholder $cplaceholder; + + /** + * The ExtensionsParams Class. + * + * @var ExtensionsParams + * @since 3.2.0 + */ + protected ExtensionsParams $extensionsparams; + + /** + * The ConfigFieldsetsCustomfield Class. + * + * @var Customfield + * @since 3.2.0 + */ + protected Customfield $customfield; + + /** + * The FieldAsString Class. + * + * @var FieldAsString + * @since 3.2.0 + */ + protected FieldAsString $fieldasstring; + + /** + * The ConfigFieldsetsGlobal Class. + * + * @var ConfigFieldsetsGlobal + * @since 3.2.0 + */ + protected ConfigFieldsetsGlobal $configfieldsetsglobal; + + /** + * The ConfigFieldsetsSiteControl Class. + * + * @var ConfigFieldsetsSiteControl + * @since 3.2.0 + */ + protected ConfigFieldsetsSiteControl $configfieldsetssitecontrol; + + /** + * The ConfigFieldsetsGroupControl Class. + * + * @var ConfigFieldsetsGroupControl + * @since 3.2.0 + */ + protected ConfigFieldsetsGroupControl $configfieldsetsgroupcontrol; + + /** + * The ConfigFieldsetsUikit Class. + * + * @var ConfigFieldsetsUikit + * @since 3.2.0 + */ + protected ConfigFieldsetsUikit $configfieldsetsuikit; + + /** + * The ConfigFieldsetsGooglechart Class. + * + * @var ConfigFieldsetsGooglechart + * @since 3.2.0 + */ + protected ConfigFieldsetsGooglechart $configfieldsetsgooglechart; + + /** + * The ConfigFieldsetsEmailHelper Class. + * + * @var ConfigFieldsetsEmailHelper + * @since 3.2.0 + */ + protected ConfigFieldsetsEmailHelper $configfieldsetsemailhelper; + + /** + * The ConfigFieldsetsEncryption Class. + * + * @var ConfigFieldsetsEncryption + * @since 3.2.0 + */ + protected ConfigFieldsetsEncryption $configfieldsetsencryption; + + /** + * The ConfigFieldsetsCustomfield Class. + * + * @var ConfigFieldsetsCustomfield + * @since 3.2.0 + */ + protected ConfigFieldsetsCustomfield $configfieldsetscustomfield; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Component $component The Component Class. + * @param Event $event The EventInterface Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param CPlaceholder $cplaceholder The Placeholder Class. + * @param ExtensionsParams $extensionsparams The ExtensionsParams Class. + * @param Customfield $customfield The ConfigFieldsetsCustomfield Class. + * @param FieldAsString $fieldasstring The FieldAsString Class. + * @param ConfigFieldsetsGlobal $configfieldsetsglobal The ConfigFieldsetsGlobal Class. + * @param ConfigFieldsetsSiteControl $configfieldsetssitecontrol The ConfigFieldsetsSiteControl Class. + * @param ConfigFieldsetsGroupControl $configfieldsetsgroupcontrol The ConfigFieldsetsGroupControl Class. + * @param ConfigFieldsetsUikit $configfieldsetsuikit The ConfigFieldsetsUikit Class. + * @param ConfigFieldsetsGooglechart $configfieldsetsgooglechart The ConfigFieldsetsGooglechart Class. + * @param ConfigFieldsetsEmailHelper $configfieldsetsemailhelper The ConfigFieldsetsEmailHelper Class. + * @param ConfigFieldsetsEncryption $configfieldsetsencryption The ConfigFieldsetsEncryption Class. + * @param ConfigFieldsetsCustomfield $configfieldsetscustomfield The ConfigFieldsetsCustomfield Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Component $component, Event $event, + Placeholder $placeholder, CPlaceholder $cplaceholder, + ExtensionsParams $extensionsparams, + Customfield $customfield, FieldAsString $fieldasstring, + ConfigFieldsetsGlobal $configfieldsetsglobal, + ConfigFieldsetsSiteControl $configfieldsetssitecontrol, + ConfigFieldsetsGroupControl $configfieldsetsgroupcontrol, + ConfigFieldsetsUikit $configfieldsetsuikit, + ConfigFieldsetsGooglechart $configfieldsetsgooglechart, + ConfigFieldsetsEmailHelper $configfieldsetsemailhelper, + ConfigFieldsetsEncryption $configfieldsetsencryption, + ConfigFieldsetsCustomfield $configfieldsetscustomfield) + { + $this->config = $config; + $this->component = $component; + $this->event = $event; + $this->placeholder = $placeholder; + $this->cplaceholder = $cplaceholder; + $this->extensionsparams = $extensionsparams; + $this->customfield = $customfield; + $this->fieldasstring = $fieldasstring; + $this->configfieldsetsglobal = $configfieldsetsglobal; + $this->configfieldsetssitecontrol = $configfieldsetssitecontrol; + $this->configfieldsetsgroupcontrol = $configfieldsetsgroupcontrol; + $this->configfieldsetsuikit = $configfieldsetsuikit; + $this->configfieldsetsgooglechart = $configfieldsetsgooglechart; + $this->configfieldsetsemailhelper = $configfieldsetsemailhelper; + $this->configfieldsetsencryption = $configfieldsetsencryption; + $this->configfieldsetscustomfield = $configfieldsetscustomfield; + } + + /** + * Set Config Fieldsets + * + * @param int $timer + * + * @since 1.0 + */ + public function set(int $timer = 0): void + { + // main lang prefix + $lang = $this->config->lang_prefix . '_CONFIG'; + if (1 == $timer) // this is before the admin views are build + { + // start loading Global params + $autorName = StringHelper::html( + $this->component->get('author') + ); + $autorEmail = StringHelper::html( + $this->component->get('email') + ); + $this->extensionsparams->add('component', '"autorName":"' . $autorName + . '","autorEmail":"' . $autorEmail . '"'); + + // set the custom fields + if ($this->component->isArray('config')) + { + // set component code name + $component = $this->config->component_code_name; + $nameSingleCode = 'config'; + $nameListCode = 'configs'; + + // set place holders + $placeholders = []; + $placeholders[Placefix::_h('component')] + = $this->config->component_code_name; + $placeholders[Placefix::_h('Component')] + = StringHelper::safe( + $this->component->get('name_code'), 'F' + ); + $placeholders[Placefix::_h('COMPONENT')] + = StringHelper::safe( + $this->component->get('name_code'), 'U' + ); + $placeholders[Placefix::_h('view')] + = $nameSingleCode; + $placeholders[Placefix::_h('views')] + = $nameListCode; + $placeholders[Placefix::_('component')] + = $this->config->component_code_name; + $placeholders[Placefix::_('Component')] + = $placeholders[Placefix::_h('Component')]; + $placeholders[Placefix::_('COMPONENT')] + = $placeholders[Placefix::_h('COMPONENT')]; + $placeholders[Placefix::_('view')] + = $nameSingleCode; + $placeholders[Placefix::_('views')] + = $nameListCode; + + // load the global placeholders + foreach ($this->cplaceholder->get() as $globalPlaceholder => $gloabalValue) + { + $placeholders[$globalPlaceholder] = $gloabalValue; + } + $view = []; + $viewType = 0; + // set the custom table key + $dbkey = 'g'; + + // Trigger Event: jcb_ce_onBeforeSetConfigFieldsets + $this->event->trigger( + 'jcb_ce_onBeforeSetConfigFieldsets', [&$timer] + ); + + // build the config fields + foreach ($this->component->get('config') as $field) + { + // get the xml string + $xmlField = $this->fieldasstring->get( + $field, $view, $viewType, $lang, $nameSingleCode, + $nameListCode, $placeholders, $dbkey, false + ); + + // make sure the xml is set and a string + if (isset($xmlField) && StringHelper::check($xmlField)) + { + $this->customfield->add($field['tabname'], $xmlField, true); + // set global params to db on install + $fieldName = StringHelper::safe( + $this->placeholder->update( + GetHelper::between( + $xmlField, 'name="', '"' + ), $placeholders + ) + ); + $fieldDefault = $this->placeholder->update( + GetHelper::between( + $xmlField, 'default="', '"' + ), $placeholders + ); + if (isset($field['custom_value']) + && StringHelper::check( + $field['custom_value'] + )) + { + // add array if found + if ((strpos((string) $field['custom_value'], '["') !== false) + && (strpos((string) $field['custom_value'], '"]') + !== false)) + { + // load the Global checkin defautls + $this->extensionsparams->add('component', '"' . $fieldName + . '":' . $field['custom_value']); + } + else + { + // load the Global checkin defautls + $this->extensionsparams->add('component', '"' . $fieldName + . '":"' . $field['custom_value'] . '"'); + } + } + elseif (StringHelper::check($fieldDefault)) + { + // load the Global checkin defautls + $this->extensionsparams->add('component', '"' . $fieldName . '":"' + . $fieldDefault . '"'); + } + } + } + } + + // first run we must set the global + $this->configfieldsetsglobal->set($lang, $autorName, $autorEmail); + $this->configfieldsetssitecontrol->set($lang); + } + elseif (2 == $timer) // this is after the admin views are build + { + // Trigger Event: jcb_ce_onBeforeSetConfigFieldsets + $this->event->trigger( + 'jcb_ce_onBeforeSetConfigFieldsets', [&$timer] + ); + + // these field sets can only be added after admin view is build + $this->configfieldsetsgroupcontrol->set($lang); + + // these can be added anytime really (but looks best after groups + $this->configfieldsetsuikit->set($lang); + $this->configfieldsetsgooglechart->set($lang); + $this->configfieldsetsemailhelper->set($lang); + $this->configfieldsetsencryption->set($lang); + + // these are the custom settings + $this->configfieldsetscustomfield->set($lang); + } + + // Trigger Event: jcb_ce_onAfterSetConfigFieldsets + $this->event->trigger( + 'jcb_ce_onAfterSetConfigFieldsets', [&$timer] + ); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsCustomfield.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsCustomfield.php new file mode 100644 index 000000000..2c6b68bf5 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsCustomfield.php @@ -0,0 +1,142 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Creator; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsetsCustomfield as Customfield; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsets; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; + + +/** + * Config Fieldsets Customfield Creator Class + * + * @since 3.2.0 + */ +final class ConfigFieldsetsCustomfield +{ + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The Language Class. + * + * @var Language + * @since 3.2.0 + */ + protected Language $language; + + /** + * The ConfigFieldsetsCustomfield Class. + * + * @var Customfield + * @since 3.2.0 + */ + protected Customfield $customfield; + + /** + * The ConfigFieldsets Class. + * + * @var ConfigFieldsets + * @since 3.2.0 + */ + protected ConfigFieldsets $configfieldsets; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Language $language The Language Class. + * @param Customfield $customfield The ConfigFieldsetsCustomfield Class. + * @param ConfigFieldsets $configfieldsets The ConfigFieldsets Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Language $language, + Customfield $customfield, + ConfigFieldsets $configfieldsets) + { + $this->config = $config; + $this->language = $language; + $this->customfield = $customfield; + $this->configfieldsets = $configfieldsets; + } + + /** + * Set Custom Control Config Fieldsets + * + * @param string $lang + * + * @since 1.0 + */ + public function set(string $lang): void + { + // add custom new global fields set + if ($this->customfield->isActive()) + { + foreach ($this->customfield->allActive() as $tab => $tabFields) + { + $tabCode = StringHelper::safe($tab) + . '_custom_config'; + $tabUpper = StringHelper::safe($tab, 'U'); + $tabLower = StringHelper::safe($tab); + // remove display targeted fields + $bucket = []; + foreach ($tabFields as $tabField) + { + $display = GetHelper::between( + $tabField, 'display="', '"' + ); + if (!StringHelper::check($display) + || $display === 'config') + { + // remove this display since it is not used in Joomla + $bucket[] = str_replace( + 'display="config"', '', (string) $tabField + ); + } + } + // only add the tab if it has values + if (ArrayHelper::check($bucket)) + { + // setup lang + $this->language->set( + $this->config->lang_target, $lang . '_' . $tabUpper, $tab + ); + // start field set + $this->configfieldsets->add('component', Indent::_(1) . "configfieldsets->add('component', Indent::_(2) . 'name="' + . $tabCode . '"'); + $this->configfieldsets->add('component', Indent::_(2) . 'label="' . $lang + . '_' . $tabUpper . '">'); + // set the fields + $this->configfieldsets->add('component', implode("", $bucket)); + // close field set + $this->configfieldsets->add('component', Indent::_(1) . ""); + } + // remove after loading + $this->customfield->remove($tab); + } + } + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsEmailHelper.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsEmailHelper.php new file mode 100644 index 000000000..f78f261be --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsEmailHelper.php @@ -0,0 +1,916 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Creator; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Component; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsets; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsetsCustomfield as Customfield; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; + + +/** + * Config Fieldsets Email Helper Creator Class + * + * @since 3.2.0 + */ +final class ConfigFieldsetsEmailHelper +{ + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The Language Class. + * + * @var Language + * @since 3.2.0 + */ + protected Language $language; + + /** + * The Component Class. + * + * @var Component + * @since 3.2.0 + */ + protected Component $component; + + /** + * The ConfigFieldsets Class. + * + * @var ConfigFieldsets + * @since 3.2.0 + */ + protected ConfigFieldsets $configfieldsets; + + /** + * The ConfigFieldsetsCustomfield Class. + * + * @var Customfield + * @since 3.2.0 + */ + protected Customfield $customfield; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Language $language The Language Class. + * @param Component $component The Component Class. + * @param ConfigFieldsets $configfieldsets The ConfigFieldsets Class. + * @param Customfield $customfield The ConfigFieldsetsCustomfield Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Language $language, Component $component, + ConfigFieldsets $configfieldsets, + Customfield $customfield) + { + $this->config = $config; + $this->language = $language; + $this->component = $component; + $this->configfieldsets = $configfieldsets; + $this->customfield = $customfield; + } + + /** + * Set Email Helper Config Fieldsets + * + * @param string $lang + * + * @since 3.2.0 + */ + public function set(string $lang): void + { + if ($this->component->get('add_email_helper')) + { + // main lang prefix + $lang = $lang . ''; + + // set main lang string + $this->language->set( + $this->config->lang_target, $lang . '_MAIL_CONFIGURATION', "Mail Configuration" + ); + + $this->language->set($this->config->lang_target, $lang . '_DKIM', "DKIM"); + + // start building field set for email helper functions + $this->configfieldsets->add('component', PHP_EOL . Indent::_(1) . "configfieldsets->add('component', Indent::_(2) + . "name=\"mail_configuration_custom_config\""); + $this->configfieldsets->add('component', Indent::_(2) . "label=\"" . $lang + . "_MAIL_CONFIGURATION\">"); + + // add custom Mail Configurations + if ($this->customfield->isArray('Mail Configuration')) + { + $this->configfieldsets->add('component', implode( + "", $this->customfield->get('Mail Configuration') + )); + $this->customfield->remove('Mail Configuration'); + } + else + { + // set all the laguage strings + $this->language->set( + $this->config->lang_target, $lang . '_MAILONLINE_LABEL', "Mailer Status" + ); + $this->language->set( + $this->config->lang_target, $lang . '_MAILONLINE_DESCRIPTION', + "Warning this will stop all emails from going out." + ); + $this->language->set($this->config->lang_target, $lang . '_ON', "On"); + $this->language->set($this->config->lang_target, $lang . '_OFF', "Off"); + $this->language->set( + $this->config->lang_target, $lang . '_MAILER_LABEL', "Mailer" + ); + $this->language->set( + $this->config->lang_target, $lang . '_MAILER_DESCRIPTION', + "Select what mailer you would like to use to send emails." + ); + $this->language->set($this->config->lang_target, $lang . '_GLOBAL', "Global"); + $this->language->set( + $this->config->lang_target, $lang . '_PHP_MAIL', "PHP Mail" + ); + $this->language->set( + $this->config->lang_target, $lang . '_SENDMAIL', "Sendmail" + ); + $this->language->set($this->config->lang_target, $lang . '_SMTP', "SMTP"); + $this->language->set( + $this->config->lang_target, $lang . '_EMAILFROM_LABEL', " From Email" + ); + $this->language->set( + $this->config->lang_target, $lang . '_EMAILFROM_DESCRIPTION', + "The global email address that will be used to send system email." + ); + $this->language->set( + $this->config->lang_target, $lang . '_EMAILFROM_HINT', "Email Address Here" + ); + $this->language->set( + $this->config->lang_target, $lang . '_FROMNAME_LABEL', "From Name" + ); + $this->language->set( + $this->config->lang_target, $lang . '_FROMNAME_DESCRIPTION', + "Text displayed in the header "From:" field when sending a site email. Usually the site name." + ); + $this->language->set( + $this->config->lang_target, $lang . '_FROMNAME_HINT', "From Name Here" + ); + $this->language->set( + $this->config->lang_target, $lang . '_EMAILREPLY_LABEL', " Reply to Email" + ); + $this->language->set( + $this->config->lang_target, $lang . '_EMAILREPLY_DESCRIPTION', + "The global email address that will be used to set as the reply email. (leave blank for none)" + ); + $this->language->set( + $this->config->lang_target, $lang . '_EMAILREPLY_HINT', + "Email Address Here" + ); + $this->language->set( + $this->config->lang_target, $lang . '_REPLYNAME_LABEL', "Reply to Name" + ); + $this->language->set( + $this->config->lang_target, $lang . '_REPLYNAME_DESCRIPTION', + "Text displayed in the header "Reply To:" field when replying to the site email. Usually the the person that receives the response. (leave blank for none)" + ); + $this->language->set( + $this->config->lang_target, $lang . '_REPLYNAME_HINT', "Reply Name Here" + ); + $this->language->set( + $this->config->lang_target, $lang . '_SENDMAIL_LABEL', "Sendmail Path" + ); + $this->language->set( + $this->config->lang_target, $lang . '_SENDMAIL_DESCRIPTION', + "Enter the path to the sendmail program directory on your host server." + ); + $this->language->set( + $this->config->lang_target, $lang . '_SENDMAIL_HINT', "/usr/sbin/sendmail" + ); + $this->language->set( + $this->config->lang_target, $lang . '_SMTPAUTH_LABEL', + "SMTP Authentication" + ); + $this->language->set( + $this->config->lang_target, $lang . '_SMTPAUTH_DESCRIPTION', + "Select yes if your SMTP host requires SMTP Authentication." + ); + $this->language->set($this->config->lang_target, $lang . '_YES', "Yes"); + $this->language->set($this->config->lang_target, $lang . '_NO', "No"); + $this->language->set( + $this->config->lang_target, $lang . '_SMTPSECURE_LABEL', "SMTP Security" + ); + $this->language->set( + $this->config->lang_target, $lang . '_SMTPSECURE_DESCRIPTION', + "Select the security model that your SMTP server uses." + ); + $this->language->set($this->config->lang_target, $lang . '_NONE', "None"); + $this->language->set($this->config->lang_target, $lang . '_SSL', "SSL"); + $this->language->set($this->config->lang_target, $lang . '_TLS', "TLS"); + $this->language->set( + $this->config->lang_target, $lang . '_SMTPPORT_LABEL', "SMTP Port" + ); + $this->language->set( + $this->config->lang_target, $lang . '_SMTPPORT_DESCRIPTION', + "Enter the port number of your SMTP server. Use 25 for most unsecured servers and 465 for most secure servers." + ); + $this->language->set( + $this->config->lang_target, $lang . '_SMTPPORT_HINT', "25" + ); + $this->language->set( + $this->config->lang_target, $lang . '_SMTPUSER_LABEL', "SMTP Username" + ); + $this->language->set( + $this->config->lang_target, $lang . '_SMTPUSER_DESCRIPTION', + "Enter the username for access to the SMTP host." + ); + $this->language->set( + $this->config->lang_target, $lang . '_SMTPUSER_HINT', "email@demo.com" + ); + $this->language->set( + $this->config->lang_target, $lang . '_SMTPPASS_LABEL', "SMTP Password" + ); + $this->language->set( + $this->config->lang_target, $lang . '_SMTPPASS_DESCRIPTION', + "Enter the password for access to the SMTP host." + ); + $this->language->set( + $this->config->lang_target, $lang . '_SMTPHOST_LABEL', "SMTP Host" + ); + $this->language->set( + $this->config->lang_target, $lang . '_SMTPHOST_DESCRIPTION', + "Enter the name of the SMTP host." + ); + $this->language->set( + $this->config->lang_target, $lang . '_SMTPHOST_HINT', "localhost" + ); + + // set the mailer fields + $this->configfieldsets->add('component', PHP_EOL . Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"radio\""); + $this->configfieldsets->add('component', Indent::_(3) . "name=\"mailonline\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_MAILONLINE_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_MAILONLINE_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) + . "class=\"btn-group btn-group-yesno\""); + $this->configfieldsets->add('component', Indent::_(3) . "default=\"1\">"); + $this->configfieldsets->add('component', Indent::_(3) . ""); + $this->configfieldsets->add('component', Indent::_(3) + . ""); + $this->configfieldsets->add('component', Indent::_(3) + . ""); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"list\""); + $this->configfieldsets->add('component', Indent::_(3) . "name=\"mailer\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_MAILER_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_MAILER_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) + . "class=\"list_class\""); + $this->configfieldsets->add('component', Indent::_(3) . "multiple=\"false\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"WORD\""); + $this->configfieldsets->add('component', Indent::_(3) . "required=\"true\""); + $this->configfieldsets->add('component', Indent::_(3) . "default=\"global\">"); + $this->configfieldsets->add('component', Indent::_(3) . ""); + $this->configfieldsets->add('component', Indent::_(3) + . ""); + $this->configfieldsets->add('component', Indent::_(3) + . ""); + $this->configfieldsets->add('component', Indent::_(3) + . ""); + $this->configfieldsets->add('component', Indent::_(3) + . ""); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) . "name=\"emailfrom\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_EMAILFROM_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"60\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_EMAILFROM_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"STRING\""); + $this->configfieldsets->add('component', Indent::_(3) . "validate=\"email\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add email address here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_EMAILFROM_HINT\""); + $this->configfieldsets->add('component', Indent::_(3) + . "showon=\"mailer:smtp,sendmail,default\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) . "name=\"fromname\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_FROMNAME_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"60\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_FROMNAME_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"STRING\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add some name here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_FROMNAME_HINT\""); + $this->configfieldsets->add('component', Indent::_(3) + . "showon=\"mailer:smtp,sendmail,default\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) . "name=\"replyto\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_EMAILREPLY_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"60\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_EMAILREPLY_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"STRING\""); + $this->configfieldsets->add('component', Indent::_(3) . "validate=\"email\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add email address here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_EMAILREPLY_HINT\""); + $this->configfieldsets->add('component', Indent::_(3) + . "showon=\"mailer:smtp,sendmail,default\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"replytoname\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_REPLYNAME_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"60\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_REPLYNAME_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"STRING\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add some name here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_REPLYNAME_HINT\""); + $this->configfieldsets->add('component', Indent::_(3) + . "showon=\"mailer:smtp,sendmail,default\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) . "name=\"sendmail\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_SENDMAIL_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"60\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_SENDMAIL_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "required=\"false\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"PATH\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add path to you local sendmail here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_SENDMAIL_HINT\""); + $this->configfieldsets->add('component', Indent::_(3) + . "showon=\"mailer:sendmail\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"radio\""); + $this->configfieldsets->add('component', Indent::_(3) . "name=\"smtpauth\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_SMTPAUTH_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_SMTPAUTH_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) + . "class=\"btn-group btn-group-yesno\""); + $this->configfieldsets->add('component', Indent::_(3) . "default=\"0\""); + $this->configfieldsets->add('component', Indent::_(3) + . "showon=\"mailer:smtp\">"); + $this->configfieldsets->add('component', Indent::_(3) . ""); + $this->configfieldsets->add('component', Indent::_(3) + . ""); + $this->configfieldsets->add('component', Indent::_(3) + . ""); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"list\""); + $this->configfieldsets->add('component', Indent::_(3) . "name=\"smtpsecure\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_SMTPSECURE_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_SMTPSECURE_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) + . "class=\"list_class\""); + $this->configfieldsets->add('component', Indent::_(3) . "multiple=\"false\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"WORD\""); + $this->configfieldsets->add('component', Indent::_(3) . "default=\"none\""); + $this->configfieldsets->add('component', Indent::_(3) + . "showon=\"mailer:smtp\">"); + $this->configfieldsets->add('component', Indent::_(3) . ""); + $this->configfieldsets->add('component', Indent::_(3) + . ""); + $this->configfieldsets->add('component', Indent::_(3) + . ""); + $this->configfieldsets->add('component', Indent::_(3) + . ""); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) . "name=\"smtpport\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_SMTPPORT_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"60\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\""); + $this->configfieldsets->add('component', Indent::_(3) . "default=\"25\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_SMTPPORT_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add the port number of your SMTP server here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_SMTPPORT_HINT\""); + $this->configfieldsets->add('component', Indent::_(3) + . "showon=\"mailer:smtp\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) . "name=\"smtpuser\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_SMTPUSER_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"60\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_SMTPUSER_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"STRING\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add the username for SMTP server here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_SMTPUSER_HINT\""); + $this->configfieldsets->add('component', Indent::_(3) + . "showon=\"mailer:smtp\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"password\""); + $this->configfieldsets->add('component', Indent::_(3) . "name=\"smtppass\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_SMTPPASS_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"60\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_SMTPPASS_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"raw\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add the password for SMTP server here.\""); + $this->configfieldsets->add('component', Indent::_(3) + . "showon=\"mailer:smtp\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) . "name=\"smtphost\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_SMTPHOST_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"60\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\""); + $this->configfieldsets->add('component', Indent::_(3) + . "default=\"localhost\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_SMTPHOST_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"STRING\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add the name of the SMTP host here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_SMTPHOST_HINT\""); + $this->configfieldsets->add('component', Indent::_(3) + . "showon=\"mailer:smtp\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + } + // close that fieldset + $this->configfieldsets->add('component', Indent::_(1) . ""); + + // start dkim field set + $this->configfieldsets->add('component', Indent::_(1) . "configfieldsets->add('component', Indent::_(2) + . "name=\"dkim_custom_config\""); + $this->configfieldsets->add('component', Indent::_(2) . "label=\"" . $lang + . "_DKIM\">"); + // add custom DKIM fields + if ($this->customfield->isArray('DKIM')) + { + $this->configfieldsets->add('component', implode( + "", $this->customfield->get('DKIM') + )); + $this->customfield->remove('DKIM'); + } + else + { + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_LABEL', "Enable DKIM" + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_DESCRIPTION', + "Set this option to Yes if you want to sign your emails using DKIM." + ); + $this->language->set($this->config->lang_target, $lang . '_YES', "Yes"); + $this->language->set($this->config->lang_target, $lang . '_NO', "No"); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_DOMAIN_LABEL', "Domain" + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_DOMAIN_DESCRIPTION', + "Set the domain. Eg. domain.com" + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_DOMAIN_HINT', "domain.com" + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_SELECTOR_LABEL', "Selector" + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_SELECTOR_DESCRIPTION', + "Set your DKIM/DNS selector." + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_SELECTOR_HINT', "vdm" + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_PASSPHRASE_LABEL', "Passphrase" + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_PASSPHRASE_DESCRIPTION', + "Enter your passphrase here." + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_IDENTITY_LABEL', "Identity" + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_IDENTITY_DESCRIPTION', + "Set DKIM identity. This can be in the format of an email address 'you@yourdomain.com' typically used as the source of the email." + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_IDENTITY_HINT', + "you@yourdomain.com" + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_PRIVATE_KEY_LABEL', + "Private key" + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_PRIVATE_KEY_DESCRIPTION', + "set private key" + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_PUBLIC_KEY_LABEL', "Public key" + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_PUBLIC_KEY_DESCRIPTION', + "set public key" + ); + $this->language->set( + $this->config->lang_target, $lang . '_NOTE_DKIM_USE_LABEL', + "Server Configuration" + ); + $this->language->set( + $this->config->lang_target, $lang . '_NOTE_DKIM_USE_DESCRIPTION', "

    Using the below details, you need to configure your DNS by adding a TXT record on your domain:

    +" + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_KEY_LABEL', "Key" + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_KEY_DESCRIPTION', + "This is the KEY to use in the DNS record." + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_KEY_HINT', "vdm._domainkey" + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_VALUE_LABEL', "Value" + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_VALUE_DESCRIPTION', + "This is the TXT value to use in the DNS. Replace the PUBLICKEY with your public key." + ); + $this->language->set( + $this->config->lang_target, $lang . '_DKIM_VALUE_HINT', + "v=DKIM1;k=rsa;g=*;s=email;h=sha1;t=s;p=PUBLICKEY" + ); + + $this->configfieldsets->add('component', PHP_EOL . Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"radio\""); + $this->configfieldsets->add('component', Indent::_(3) . "name=\"dkim\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_DKIM_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_DKIM_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) + . "class=\"btn-group btn-group-yesno\""); + $this->configfieldsets->add('component', Indent::_(3) . "default=\"0\""); + $this->configfieldsets->add('component', Indent::_(3) . "required=\"true\">"); + $this->configfieldsets->add('component', Indent::_(3) . ""); + $this->configfieldsets->add('component', Indent::_(3) + . ""); + $this->configfieldsets->add('component', Indent::_(3) + . ""); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"dkim_domain\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_DKIM_DOMAIN_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"60\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_DKIM_DOMAIN_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"STRING\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add DKIM Domain here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_DKIM_DOMAIN_HINT\""); + $this->configfieldsets->add('component', Indent::_(3) . "showon=\"dkim:1\""); + $this->configfieldsets->add('component', Indent::_(3) + . "onchange=\"vdm_dkim();\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"dkim_selector\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_DKIM_SELECTOR_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"60\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\""); + $this->configfieldsets->add('component', Indent::_(3) . "default=\"vdm\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_DKIM_SELECTOR_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"STRING\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add DKIM/DNS selector here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_DKIM_SELECTOR_HINT\""); + $this->configfieldsets->add('component', Indent::_(3) . "showon=\"dkim:1\""); + $this->configfieldsets->add('component', Indent::_(3) + . "onchange=\"vdm_dkim();\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"password\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"dkim_passphrase\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_DKIM_PASSPHRASE_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"60\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_DKIM_PASSPHRASE_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"raw\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add passphrase here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "showon=\"dkim:1\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"dkim_identity\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_DKIM_IDENTITY_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"60\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_DKIM_IDENTITY_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"raw\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add DKIM Identity here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_DKIM_IDENTITY_HINT\""); + $this->configfieldsets->add('component', Indent::_(3) . "showon=\"dkim:1\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"textarea\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"dkim_private_key\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_DKIM_PRIVATE_KEY_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "rows=\"15\""); + $this->configfieldsets->add('component', Indent::_(3) . "cols=\"5\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_DKIM_PRIVATE_KEY_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) + . "class=\"input-xxlarge span12\""); + $this->configfieldsets->add('component', Indent::_(3) . "showon=\"dkim:1\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"textarea\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"dkim_public_key\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_DKIM_PUBLIC_KEY_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "rows=\"5\""); + $this->configfieldsets->add('component', Indent::_(3) . "cols=\"5\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_DKIM_PUBLIC_KEY_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) + . "class=\"input-xxlarge span12\""); + $this->configfieldsets->add('component', Indent::_(3) . "showon=\"dkim:1\""); + $this->configfieldsets->add('component', Indent::_(3) + . "onchange=\"vdm_dkim();\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) + . ""); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) . "name=\"dkim_key\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_DKIM_KEY_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"40\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"150\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_DKIM_KEY_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"STRING\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add KEY here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_DKIM_KEY_HINT\""); + $this->configfieldsets->add('component', Indent::_(3) . "showon=\"dkim:1\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) . "name=\"dkim_value\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_DKIM_VALUE_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"80\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"350\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" + . $lang . "_DKIM_VALUE_DESCRIPTION\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"STRING\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add TXT record here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_DKIM_VALUE_HINT\""); + $this->configfieldsets->add('component', Indent::_(3) . "showon=\"dkim:1\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + } + + // close that fieldset + $this->configfieldsets->add('component', Indent::_(1) . ""); + } + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsEncryption.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsEncryption.php new file mode 100644 index 000000000..b2be9651a --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsEncryption.php @@ -0,0 +1,414 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Creator; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Component; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsets; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsetsCustomfield as Customfield; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; + + +/** + * Config Fieldsets Encryption Creator Class + * + * @since 3.2.0 + */ +final class ConfigFieldsetsEncryption +{ + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The Language Class. + * + * @var Language + * @since 3.2.0 + */ + protected Language $language; + + /** + * The Component Class. + * + * @var Component + * @since 3.2.0 + */ + protected Component $component; + + /** + * The ConfigFieldsets Class. + * + * @var ConfigFieldsets + * @since 3.2.0 + */ + protected ConfigFieldsets $configfieldsets; + + /** + * The ConfigFieldsetsCustomfield Class. + * + * @var Customfield + * @since 3.2.0 + */ + protected Customfield $customfield; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Language $language The Language Class. + * @param Component $component The Component Class. + * @param ConfigFieldsets $configfieldsets The ConfigFieldsets Class. + * @param Customfield $customfield The ConfigFieldsetsCustomfield Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Language $language, Component $component, + ConfigFieldsets $configfieldsets, + Customfield $customfield) + { + $this->config = $config; + $this->language = $language; + $this->component = $component; + $this->configfieldsets = $configfieldsets; + $this->customfield = $customfield; + } + + /** + * Set Encryption Config Fieldsets + * + * @param string $lang + * + * @since 3.2.0 + */ + public function set(string $lang): void + { + // enable the loading of dynamic field sets + $dynamicAddFields = []; + + // Add encryption if needed + if ($this->config->basic_encryption + || $this->config->whmcs_encryption + || $this->config->medium_encryption + || $this->component->get('add_license') + || $this->customfield->isArray('Encryption Settings')) + { + $dynamicAddFields[] = "Encryption Settings"; + // start building field set for encryption functions + $this->configfieldsets->add('component', Indent::_(1) . "configfieldsets->add('component', Indent::_(2) + . 'name="encryption_config"'); + $this->configfieldsets->add('component', Indent::_(2) . 'label="' . $lang + . '_ENCRYPTION_LABEL"'); + $this->configfieldsets->add('component', Indent::_(2) . 'description="' . $lang + . '_ENCRYPTION_DESC">'); + + // set tab lang + if (($this->config->basic_encryption + || $this->config->medium_encryption + || $this->config->whmcs_encryption) + && $this->component->get('add_license') + && $this->component->get('license_type', 0) == 3) + { + $this->language->set( + $this->config->lang_target, $lang . '_ENCRYPTION_LABEL', + "License & Encryption Settings" + ); + $this->language->set( + $this->config->lang_target, $lang . '_ENCRYPTION_DESC', + "The license & encryption keys are set here." + ); + // add the next dynamic option + $dynamicAddFields[] = "License & Encryption Settings"; + } + elseif (($this->config->basic_encryption + || $this->config->medium_encryption + || $this->config->whmcs_encryption) + && $this->component->get('add_license') + && $this->component->get('license_type', 0) == 2) + { + $this->language->set( + $this->config->lang_target, $lang . '_ENCRYPTION_LABEL', + "Update & Encryption Settings" + ); + $this->language->set( + $this->config->lang_target, $lang . '_ENCRYPTION_DESC', + "The update & encryption keys are set here." + ); + // add the next dynamic option + $dynamicAddFields[] = "Update & Encryption Settings"; + } + elseif ($this->component->get('add_license') + && $this->component->get('license_type', 0) == 3) + { + $this->language->set( + $this->config->lang_target, $lang . '_ENCRYPTION_LABEL', "License Settings" + ); + $this->language->set( + $this->config->lang_target, $lang . '_ENCRYPTION_DESC', + "The license key is set here." + ); + // add the next dynamic option + $dynamicAddFields[] = "License Settings"; + } + elseif ($this->component->get('add_license') + && $this->component->get('license_type', 0) == 2) + { + $this->language->set( + $this->config->lang_target, $lang . '_ENCRYPTION_LABEL', "Update Settings" + ); + $this->language->set( + $this->config->lang_target, $lang . '_ENCRYPTION_DESC', + "The update key is set here." + ); + // add the next dynamic option + $dynamicAddFields[] = "Update Settings"; + } + else + { + $this->language->set( + $this->config->lang_target, $lang . '_ENCRYPTION_LABEL', + "Encryption Settings" + ); + $this->language->set( + $this->config->lang_target, $lang . '_ENCRYPTION_DESC', + "The encryption key for the field encryption is set here." + ); + } + + if ($this->config->basic_encryption) + { + // set field lang + $this->language->set( + $this->config->lang_target, $lang . '_BASIC_KEY_LABEL', "Basic Key" + ); + $this->language->set( + $this->config->lang_target, $lang . '_BASIC_KEY_DESC', + "Set the basic local key here." + ); + $this->language->set( + $this->config->lang_target, $lang . '_BASIC_KEY_NOTE_LABEL', + "Basic Encryption" + ); + $this->language->set( + $this->config->lang_target, $lang . '_BASIC_KEY_NOTE_DESC', + "When using the basic encryption please use set a 32 character passphrase.
    Never change this passphrase once it is set! DATA WILL GET CORRUPTED IF YOU DO!" + ); + + // set the field + $this->configfieldsets->add('component', Indent::_(2) + . ''); + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="text"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang + . '_BASIC_KEY_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' + . $lang . '_BASIC_KEY_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) . 'size="60"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default=""'); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + } + + if ($this->config->medium_encryption) + { + // set field lang + $this->language->set( + $this->config->lang_target, $lang . '_MEDIUM_KEY_LABEL', + "Medium Key (Path)" + ); + $this->language->set( + $this->config->lang_target, $lang . '_MEDIUM_KEY_DESC', + "Set the full path to where the key file must be stored. Make sure it is behind the root folder of your website, so that it is not public accessible." + ); + $this->language->set( + $this->config->lang_target, $lang . '_MEDIUM_KEY_NOTE_LABEL', + "Medium Encryption" + ); + $this->language->set( + $this->config->lang_target, $lang . '_MEDIUM_KEY_NOTE_DESC', + "When using the medium encryption option, the system generates its own key and stores it in a file at the folder/path you set here.
    Never change this key once it is set, or remove the key file! DATA WILL GET CORRUPTED IF YOU DO! Also make sure the full path to where the the key file should be stored, is behind the root folder of your website/system, so that it is not public accessible. Making a backup of this key file over a secure connection is recommended!" + ); + + // set the field + $this->configfieldsets->add('component', Indent::_(2) + . ''); + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="text"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang + . '_MEDIUM_KEY_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' + . $lang . '_MEDIUM_KEY_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) . 'size="160"'); + $this->configfieldsets->add('component', Indent::_(3) . 'filter="PATH"'); + $this->configfieldsets->add('component', Indent::_(3) + . 'hint="/home/user/hiddenfolder123/"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default=""'); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + // set some error message if the path does not exist + $this->language->set( + $this->config->lang_target, $lang . '_MEDIUM_KEY_PATH_ERROR', + "Medium key path (for encryption of various fields) does not exist, or is not writable. Please check the path and update it in the global option of this component." + ); + } + + if ($this->config->whmcs_encryption + || $this->component->get('add_license')) + { + // set field lang label and description + if ($this->component->get('add_license') + && $this->component->get('license_type', 0) == 3) + { + $this->language->set( + $this->config->lang_target, $lang . '_WHMCS_KEY_LABEL', + $this->component->get('companyname', '') . " License Key" + ); + $this->language->set( + $this->config->lang_target, $lang . '_WHMCS_KEY_DESC', + "Add the license key you recieved from " + . $this->component->get('companyname', '') . " here." + ); + } + elseif ($this->component->get('add_license') + && $this->component->get('license_type', 0) == 2) + { + $this->language->set( + $this->config->lang_target, $lang . '_WHMCS_KEY_LABEL', + $this->component->get('companyname', '') . " Update Key" + ); + $this->language->set( + $this->config->lang_target, $lang . '_WHMCS_KEY_DESC', + "Add the update key you recieved from " + . $this->component->get('companyname', '') . " here." + ); + } + else + { + $this->language->set( + $this->config->lang_target, $lang . '_WHMCS_KEY_LABEL', + $this->component->get('companyname', '') . " Key" + ); + $this->language->set( + $this->config->lang_target, $lang . '_WHMCS_KEY_DESC', + "Add the key you recieved from " + . $this->component->get('companyname', '') . " here." + ); + } + + // adjust the notice based on license + if ($this->component->get('license_type',0) == 3) + { + $this->language->set( + $this->config->lang_target, $lang . '_WHMCS_KEY_NOTE_LABEL', + "Your " . $this->component->get('companyname','') + . " License Key" + ); + } + elseif ($this->component->get('license_type',0) == 2) + { + $this->language->set( + $this->config->lang_target, $lang . '_WHMCS_KEY_NOTE_LABEL', + "Your " . $this->component->get('companyname','') + . " Update Key" + ); + } + else + { + if ($this->config->whmcs_encryption) + { + $this->language->set( + $this->config->lang_target, $lang . '_WHMCS_KEY_NOTE_LABEL', + "Your " . $this->component->get('companyname','') + . " Field Encryption Key" + ); + } + else + { + $this->language->set( + $this->config->lang_target, $lang . '_WHMCS_KEY_NOTE_LABEL', + "Your " . $this->component->get('companyname','') . " Key" + ); + } + } + + // add the description based on global settings + if ($this->config->whmcs_encryption) + { + $this->language->set( + $this->config->lang_target, $lang . '_WHMCS_KEY_NOTE_DESC', + "You need to get this key from " + . $this->component->get('companyname','') + . ".
    When using the " + . $this->component->get('companyname','') + . " field encryption you can never change this key once it is set! DATA WILL GET CORRUPTED IF YOU DO!" + ); + } + else + { + $this->language->set( + $this->config->lang_target, $lang . '_WHMCS_KEY_NOTE_DESC', + "You need to get this key from " + . $this->component->get('companyname','') . "." + ); + } + + // set the fields + $this->configfieldsets->add('component', Indent::_(2) + . ''); + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="text"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang + . '_WHMCS_KEY_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' + . $lang . '_WHMCS_KEY_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) . 'size="60"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default=""'); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + } + + // load the dynamic field sets + foreach ($dynamicAddFields as $dynamicAddField) + { + // add custom Encryption Settings fields + if ($this->customfield->isArray($dynamicAddField)) + { + $this->configfieldsets->add('component', implode( + "", $this->customfield->get($dynamicAddField) + )); + $this->customfield->remove($dynamicAddField); + } + } + + // close that fieldset + $this->configfieldsets->add('component', Indent::_(1) . ""); + } + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsGlobal.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsGlobal.php new file mode 100644 index 000000000..343fdb01f --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsGlobal.php @@ -0,0 +1,634 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Creator; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Component; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Contributors; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsets; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ExtensionsParams; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsetsCustomfield as Customfield; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; + + +/** + * Config Fieldsets Global Creator Class + * + * @since 3.2.0 + */ +final class ConfigFieldsetsGlobal +{ + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The Language Class. + * + * @var Language + * @since 3.2.0 + */ + protected Language $language; + + /** + * The Component Class. + * + * @var Component + * @since 3.2.0 + */ + protected Component $component; + + /** + * The Contributors Class. + * + * @var Contributors + * @since 3.2.0 + */ + protected Contributors $contributors; + + /** + * The ConfigFieldsets Class. + * + * @var ConfigFieldsets + * @since 3.2.0 + */ + protected ConfigFieldsets $configfieldsets; + + /** + * The ExtensionsParams Class. + * + * @var ExtensionsParams + * @since 3.2.0 + */ + protected ExtensionsParams $extensionsparams; + + /** + * The ConfigFieldsetsCustomfield Class. + * + * @var Customfield + * @since 3.2.0 + */ + protected Customfield $customfield; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Language $language The Language Class. + * @param Component $component The Component Class. + * @param Contributors $contributors The Contributors Class. + * @param ConfigFieldsets $configfieldsets The ConfigFieldsets Class. + * @param ExtensionsParams $extensionsparams The ExtensionsParams Class. + * @param Customfield $customfield The ConfigFieldsetsCustomfield Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Language $language, Component $component, + Contributors $contributors, + ConfigFieldsets $configfieldsets, + ExtensionsParams $extensionsparams, + Customfield $customfield) + { + $this->config = $config; + $this->language = $language; + $this->component = $component; + $this->contributors = $contributors; + $this->configfieldsets = $configfieldsets; + $this->extensionsparams = $extensionsparams; + $this->customfield = $customfield; + } + + /** + * Set Global Config Fieldsets + * + * @param string $lang + * @param string $authorName + * @param string $authorEmail + * + * @since 3.2.0 + */ + public function set(string $lang, string $authorName, string $authorEmail): void + { + // start building field set for config + $this->configfieldsets->add('component', 'config->get('joomla_version', 3) == 3) + { + $this->configfieldsets->add('component', Indent::_(2) + . 'addrulepath="/administrator/components/com_' . $this->config->component_code_name + . '/models/rules"'); + $this->configfieldsets->add('component', Indent::_(2) + . 'addfieldpath="/administrator/components/com_' . $this->config->component_code_name + . '/models/fields"'); + } + else + { + $this->configfieldsets->add('component', Indent::_(2) + . 'addruleprefix="' . $this->config->namespace_prefix + . '\Component\\' . StringHelper::safe($this->config->component_code_name, 'F') + . '\Administrator\Rule"'); + $this->configfieldsets->add('component', Indent::_(2) + . 'addfieldprefix="' . $this->config->namespace_prefix + . '\Component\\' . StringHelper::safe($this->config->component_code_name, 'F') + . '\Administrator\Field"'); + } + $this->configfieldsets->add('component', Indent::_(2) . 'name="global_config"'); + $this->configfieldsets->add('component', Indent::_(2) . 'label="' . $lang + . '_GLOBAL_LABEL"'); + $this->configfieldsets->add('component', Indent::_(2) . 'description="' . $lang + . '_GLOBAL_DESC">'); + // setup lang + $this->language->set($this->config->lang_target, $lang . '_GLOBAL_LABEL', "Global"); + $this->language->set( + $this->config->lang_target, $lang . '_GLOBAL_DESC', "The Global Parameters" + ); + + // add auto checkin if required + if ($this->config->get('add_checkin', false)) + { + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . 'name="check_in"'); + $this->configfieldsets->add('component', Indent::_(3) . 'type="list"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default="0"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang + . '_CHECK_TIMER_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' . $lang + . '_CHECK_TIMER_DESC">'); + $this->configfieldsets->add('component', Indent::_(3) . 'configfieldsets->add('component', Indent::_(4) . 'value="-5 hours">' + . $lang . '_CHECK_TIMER_OPTION_ONE'); + $this->configfieldsets->add('component', Indent::_(3) . 'configfieldsets->add('component', Indent::_(4) . 'value="-12 hours">' + . $lang . '_CHECK_TIMER_OPTION_TWO'); + $this->configfieldsets->add('component', Indent::_(3) . 'configfieldsets->add('component', Indent::_(4) . 'value="-1 day">' . $lang + . '_CHECK_TIMER_OPTION_THREE'); + $this->configfieldsets->add('component', Indent::_(3) . 'configfieldsets->add('component', Indent::_(4) . 'value="-2 day">' . $lang + . '_CHECK_TIMER_OPTION_FOUR'); + $this->configfieldsets->add('component', Indent::_(3) . 'configfieldsets->add('component', Indent::_(4) . 'value="-1 week">' . $lang + . '_CHECK_TIMER_OPTION_FIVE'); + $this->configfieldsets->add('component', Indent::_(3) . 'configfieldsets->add('component', Indent::_(4) . 'value="0">' . $lang + . '_CHECK_TIMER_OPTION_SIX'); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) + . ''); + // setup lang + $this->language->set( + $this->config->lang_target, $lang . '_CHECK_TIMER_LABEL', "Check in timer" + ); + $this->language->set( + $this->config->lang_target, $lang . '_CHECK_TIMER_DESC', + "Set the intervals for the auto checkin fuction of tables that checks out the items to an user." + ); + $this->language->set( + $this->config->lang_target, $lang . '_CHECK_TIMER_OPTION_ONE', + "Every five hours" + ); + $this->language->set( + $this->config->lang_target, $lang . '_CHECK_TIMER_OPTION_TWO', + "Every twelve hours" + ); + $this->language->set( + $this->config->lang_target, $lang . '_CHECK_TIMER_OPTION_THREE', "Once a day" + ); + $this->language->set( + $this->config->lang_target, $lang . '_CHECK_TIMER_OPTION_FOUR', + "Every second day" + ); + $this->language->set( + $this->config->lang_target, $lang . '_CHECK_TIMER_OPTION_FIVE', "Once a week" + ); + $this->language->set( + $this->config->lang_target, $lang . '_CHECK_TIMER_OPTION_SIX', "Never" + ); + // load the Global checkin defautls + $this->extensionsparams->add('component', '"check_in":"-1 day"'); + } + + // set history control + if ($this->config->get('set_tag_history', false)) + { + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . 'name="save_history"'); + $this->configfieldsets->add('component', Indent::_(3) . 'type="radio"'); + $this->configfieldsets->add('component', Indent::_(3) + . 'class="btn-group btn-group-yesno"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default="1"'); + $this->configfieldsets->add('component', Indent::_(3) + . 'label="JGLOBAL_SAVE_HISTORY_OPTIONS_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) + . 'description="JGLOBAL_SAVE_HISTORY_OPTIONS_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) . ">"); + $this->configfieldsets->add('component', Indent::_(3) + . ''); + $this->configfieldsets->add('component', Indent::_(3) + . ''); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . 'name="history_limit"'); + $this->configfieldsets->add('component', Indent::_(3) . 'type="text"'); + $this->configfieldsets->add('component', Indent::_(3) . 'filter="integer"'); + $this->configfieldsets->add('component', Indent::_(3) + . 'label="JGLOBAL_HISTORY_LIMIT_OPTIONS_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) + . 'description="JGLOBAL_HISTORY_LIMIT_OPTIONS_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default="10"'); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) + . ''); + // load the Global checkin defautls + $this->extensionsparams->add('component', '"save_history":"1","history_limit":"10"'); + } + // add custom global fields + if ($this->customfield->isArray('Global')) + { + $this->configfieldsets->add('component', implode( + "", $this->customfield->get('Global') + )); + $this->customfield->remove('Global'); + } + // set the author details + $this->configfieldsets->add('component', Indent::_(2) . 'configfieldsets->add('component', Indent::_(3) . 'type="spacer"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang + . '_AUTHOR"'); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . 'configfieldsets->add('component', Indent::_(3) . 'type="text"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang + . '_AUTHOR_NAME_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' . $lang + . '_AUTHOR_NAME_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) . 'size="60"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default="' . $authorName . '"'); + $this->configfieldsets->add('component', Indent::_(3) . 'readonly="true"'); + $this->configfieldsets->add('component', Indent::_(3) . 'class="readonly"'); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . 'configfieldsets->add('component', Indent::_(3) . 'type="email"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang + . '_AUTHOR_EMAIL_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' . $lang + . '_AUTHOR_EMAIL_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) . 'size="60"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default="' . $authorEmail . '"'); + $this->configfieldsets->add('component', Indent::_(3) . 'readonly="true"'); + $this->configfieldsets->add('component', Indent::_(3) . 'class="readonly"'); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + // setup lang + $this->language->set($this->config->lang_target, $lang . '_AUTHOR', "Author Info"); + $this->language->set( + $this->config->lang_target, $lang . '_AUTHOR_NAME_LABEL', "Author Name" + ); + $this->language->set( + $this->config->lang_target, $lang . '_AUTHOR_NAME_DESC', + "The name of the author of this component." + ); + $this->language->set( + $this->config->lang_target, $lang . '_AUTHOR_EMAIL_LABEL', "Author Email" + ); + $this->language->set( + $this->config->lang_target, $lang . '_AUTHOR_EMAIL_DESC', + "The email address of the author of this component." + ); + + // set if contributors were added + $langCont = $lang . '_CONTRIBUTOR'; + if ($this->config->get('add_contributors', false) + && $this->component->isArray('contributors')) + { + foreach ( + $this->component->get('contributors') as $counter => $contributor + ) + { + // make sure we dont use 0 + $counter++; + // get the word for this number + $COUNTER = StringHelper::safe($counter, 'U'); + // set the dynamic values + $cbTitle = htmlspecialchars( + (string) $contributor['title'], ENT_XML1, 'UTF-8' + ); + $cbName = htmlspecialchars( + (string) $contributor['name'], ENT_XML1, 'UTF-8' + ); + $cbEmail = htmlspecialchars( + (string) $contributor['email'], ENT_XML1, 'UTF-8' + ); + $cbWebsite = htmlspecialchars( + (string) $contributor['website'], ENT_XML1, 'UTF-8' + ); // StringHelper::html($contributor['website']); + // load to the $fieldsets + $this->configfieldsets->add('component', Indent::_(2) + . ''); + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="spacer"'); + $this->configfieldsets->add('component', Indent::_(3) . 'class="text"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont + . '_' . $COUNTER . '"'); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="text"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont + . '_TITLE_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' + . $langCont . '_TITLE_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) . 'size="60"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default="' . $cbTitle + . '"'); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="text"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont + . '_NAME_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' + . $langCont . '_NAME_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) . 'size="60"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default="' . $cbName + . '"'); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="email"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont + . '_EMAIL_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' + . $langCont . '_EMAIL_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) . 'size="60"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default="' . $cbEmail + . '"'); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="url"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont + . '_LINK_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' + . $langCont . '_LINK_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) . 'size="60"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default="' + . $cbWebsite . '"'); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="list"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default="' + . (int) $contributor['use'] . '"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont + . '_USE_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' + . $langCont . '_USE_DESC">'); + $this->configfieldsets->add('component', Indent::_(3) . ''); + $this->configfieldsets->add('component', Indent::_(3) . ''); + $this->configfieldsets->add('component', Indent::_(3) . ''); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="list"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default="' + . (int) $contributor['show'] . '"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont + . '_SHOW_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' + . $langCont . '_SHOW_DESC">'); + $this->configfieldsets->add('component', Indent::_(3) . ''); + $this->configfieldsets->add('component', Indent::_(3) . ''); + $this->configfieldsets->add('component', Indent::_(3) . ''); + $this->configfieldsets->add('component', Indent::_(3) . ''); + $this->configfieldsets->add('component', Indent::_(2) . ""); + // add the contributor + $this->contributors->add('bom', PHP_EOL . Indent::_(1) . "@" + . strtolower((string) $contributor['title']) . Indent::_(2) + . $contributor['name'] . ' <' . $contributor['website'] + . '>'); + // setup lang + $Counter = StringHelper::safe($counter, 'Ww'); + $this->language->set( + $this->config->lang_target, $langCont . '_' . $COUNTER, + "Contributor " . $Counter + ); + // load the Global checkin defautls + $this->extensionsparams->add('component', '"titleContributor' . $counter + . '":"' . $cbTitle . '"'); + $this->extensionsparams->add('component', '"nameContributor' . $counter + . '":"' . $cbName . '"'); + $this->extensionsparams->add('component', '"emailContributor' . $counter + . '":"' . $cbEmail . '"'); + $this->extensionsparams->add('component', '"linkContributor' . $counter + . '":"' . $cbWebsite . '"'); + $this->extensionsparams->add('component', '"useContributor' . $counter . '":"' + . (int) $contributor['use'] . '"'); + $this->extensionsparams->add('component', '"showContributor' . $counter + . '":"' . (int) $contributor['show'] . '"'); + } + } + + // add more contributors if required + if (1 == $this->component->get('emptycontributors', 0)) + { + if (isset($counter)) + { + $min = $counter + 1; + unset($counter); + } + else + { + $min = 1; + } + $max = $min + $this->component->get('number') - 1; + $moreContributerFields = range($min, $max, 1); + foreach ($moreContributerFields as $counter) + { + $COUNTER = StringHelper::safe($counter, 'U'); + + $this->configfieldsets->add('component', Indent::_(2) + . ''); + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="spacer"'); + $this->configfieldsets->add('component', Indent::_(3) . 'class="text"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont + . '_' . $COUNTER . '"'); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="text"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont + . '_TITLE_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' + . $langCont . '_TITLE_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) . 'size="60"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default=""'); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="text"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont + . '_NAME_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' + . $langCont . '_NAME_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) . 'size="60"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default=""'); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="email"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont + . '_EMAIL_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' + . $langCont . '_EMAIL_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) . 'size="60"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default=""'); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="url"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont + . '_LINK_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' + . $langCont . '_LINK_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) . 'size="60"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default=""'); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="list"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default="0"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont + . '_USE_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' + . $langCont . '_USE_DESC">'); + $this->configfieldsets->add('component', Indent::_(3) . ''); + $this->configfieldsets->add('component', Indent::_(3) . ''); + $this->configfieldsets->add('component', Indent::_(3) . ''); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="list"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default="0"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $langCont + . '_SHOW_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' + . $langCont . '_SHOW_DESC">'); + $this->configfieldsets->add('component', Indent::_(3) . ''); + $this->configfieldsets->add('component', Indent::_(3) . ''); + $this->configfieldsets->add('component', Indent::_(3) . ''); + $this->configfieldsets->add('component', Indent::_(3) . ''); + $this->configfieldsets->add('component', Indent::_(2) . ""); + // setup lang + $Counter = StringHelper::safe($counter, 'Ww'); + $this->language->set( + $this->config->lang_target, $langCont . '_' . $COUNTER, + "Contributor " . $Counter + ); + } + } + + if ($this->config->get('add_contributors', false) + || $this->component->get('emptycontributors', 0) == 1) + { + // setup lang + $this->language->set( + $this->config->lang_target, $langCont . '_TITLE_LABEL', "Contributor Job Title" + ); + $this->language->set( + $this->config->lang_target, $langCont . '_TITLE_DESC', + "The job title that best describes the contributor's relationship to this component." + ); + $this->language->set( + $this->config->lang_target, $langCont . '_NAME_LABEL', "Contributor Name" + ); + $this->language->set( + $this->config->lang_target, $langCont . '_NAME_DESC', + "The name of this contributor." + ); + $this->language->set( + $this->config->lang_target, $langCont . '_EMAIL_LABEL', "Contributor Email" + ); + $this->language->set( + $this->config->lang_target, $langCont . '_EMAIL_DESC', + "The email of this contributor." + ); + $this->language->set( + $this->config->lang_target, $langCont . '_LINK_LABEL', "Contributor Website" + ); + $this->language->set( + $this->config->lang_target, $langCont . '_LINK_DESC', + "The link to this contributor's website." + ); + $this->language->set($this->config->lang_target, $langCont . '_USE_LABEL', "Use"); + $this->language->set( + $this->config->lang_target, $langCont . '_USE_DESC', + "How should we link to this contributor." + ); + $this->language->set($this->config->lang_target, $langCont . '_USE_NONE', "None"); + $this->language->set( + $this->config->lang_target, $langCont . '_USE_EMAIL', "Email" + ); + $this->language->set( + $this->config->lang_target, $langCont . '_USE_WWW', "Website" + ); + $this->language->set( + $this->config->lang_target, $langCont . '_SHOW_LABEL', "Show" + ); + $this->language->set( + $this->config->lang_target, $langCont . '_SHOW_DESC', + "Select where you want this contributor's details to show in the component." + ); + $this->language->set( + $this->config->lang_target, $langCont . '_SHOW_NONE', "Hide" + ); + $this->language->set( + $this->config->lang_target, $langCont . '_SHOW_BACK', "Back-end" + ); + $this->language->set( + $this->config->lang_target, $langCont . '_SHOW_FRONT', "Front-end" + ); + $this->language->set( + $this->config->lang_target, $langCont . '_SHOW_ALL', "Both Front & Back-end" + ); + } + + // close that fieldset + $this->configfieldsets->add('component', Indent::_(1) . ""); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsGooglechart.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsGooglechart.php new file mode 100644 index 000000000..da6cc16a5 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsGooglechart.php @@ -0,0 +1,633 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Creator; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsets; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsetsCustomfield as Customfield; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ExtensionsParams; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; + + +/** + * Config Fieldsets Googlechart Creator Class + * + * @since 3.2.0 + */ +final class ConfigFieldsetsGooglechart +{ + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The Language Class. + * + * @var Language + * @since 3.2.0 + */ + protected Language $language; + + /** + * The ConfigFieldsets Class. + * + * @var ConfigFieldsets + * @since 3.2.0 + */ + protected ConfigFieldsets $configfieldsets; + + /** + * The ConfigFieldsetsCustomfield Class. + * + * @var Customfield + * @since 3.2.0 + */ + protected Customfield $customfield; + + /** + * The ExtensionsParams Class. + * + * @var ExtensionsParams + * @since 3.2.0 + */ + protected ExtensionsParams $extensionsparams; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Language $language The Language Class. + * @param ConfigFieldsets $configfieldsets The ConfigFieldsets Class. + * @param Customfield $customfield The ConfigFieldsetsCustomfield Class. + * @param ExtensionsParams $extensionsparams The ExtensionsParams Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Language $language, + ConfigFieldsets $configfieldsets, + Customfield $customfield, + ExtensionsParams $extensionsparams) + { + $this->config = $config; + $this->language = $language; + $this->configfieldsets = $configfieldsets; + $this->customfield = $customfield; + $this->extensionsparams = $extensionsparams; + } + + /** + * Set Email Helper Config Fieldsets + * + * @param string $lang + * + * @since 3.2.0 + */ + public function set(string $lang): void + { + if ($this->config->get('google_chart', false)) + { + $this->configfieldsets->add('component', PHP_EOL . Indent::_(1) . "configfieldsets->add('component', Indent::_(2) + . "name=\"googlechart_config\""); + $this->configfieldsets->add('component', Indent::_(2) . "label=\"" . $lang + . "_CHART_SETTINGS_LABEL\""); + $this->configfieldsets->add('component', Indent::_(2) . "description=\"" . $lang + . "_CHART_SETTINGS_DESC\">"); + $this->configfieldsets->add('component', Indent::_(2)); + $this->configfieldsets->add('component', Indent::_(2) + . ""); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"color\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"admin_chartbackground\""); + $this->configfieldsets->add('component', Indent::_(3) . "default=\"#F7F7FA\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_CHARTBACKGROUND_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang + . "_CHARTBACKGROUND_DESC\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"admin_mainwidth\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_MAINWIDTH_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"20\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"50\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang + . "_MAINWIDTH_DESC\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add area width here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_MAINWIDTH_HINT\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) + . ""); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"admin_chartareatop\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_CHARTAREATOP_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"20\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"50\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang + . "_CHARTAREATOP_DESC\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add top spacing here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_CHARTAREATOP_HINT\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"admin_chartarealeft\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_CHARTAREALEFT_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"20\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"50\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang + . "_CHARTAREALEFT_DESC\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add left spacing here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_CHARTAREALEFT_HINT\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"admin_chartareawidth\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_CHARTAREAWIDTH_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"20\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"50\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang + . "_CHARTAREAWIDTH_DESC\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add chart width here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_CHARTAREAWIDTH_HINT\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) + . ""); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"color\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"admin_legendtextstylefontcolor\""); + $this->configfieldsets->add('component', Indent::_(3) . "default=\"#63B1F2\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_LEGENDTEXTSTYLEFONTCOLOR_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang + . "_LEGENDTEXTSTYLEFONTCOLOR_DESC\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"admin_legendtextstylefontsize\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_LEGENDTEXTSTYLEFONTSIZE_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"20\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"50\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang + . "_LEGENDTEXTSTYLEFONTSIZE_DESC\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add size of the legend here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_LEGENDTEXTSTYLEFONTSIZE_HINT\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) + . ""); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"color\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"admin_vaxistextstylefontcolor\""); + $this->configfieldsets->add('component', Indent::_(3) . "default=\"#63B1F2\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_VAXISTEXTSTYLEFONTCOLOR_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang + . "_VAXISTEXTSTYLEFONTCOLOR_DESC\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) + . ""); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"color\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"admin_haxistextstylefontcolor\""); + $this->configfieldsets->add('component', Indent::_(3) . "default=\"#63B1F2\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_HAXISTEXTSTYLEFONTCOLOR_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang + . "_HAXISTEXTSTYLEFONTCOLOR_DESC\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"color\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"admin_haxistitletextstylefontcolor\""); + $this->configfieldsets->add('component', Indent::_(3) . "default=\"#63B1F2\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_HAXISTITLETEXTSTYLEFONTCOLOR_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang + . "_HAXISTITLETEXTSTYLEFONTCOLOR_DESC\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2)); + $this->configfieldsets->add('component', Indent::_(2) + . ""); + $this->configfieldsets->add('component', Indent::_(2)); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"color\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"site_chartbackground\""); + $this->configfieldsets->add('component', Indent::_(3) . "default=\"#F7F7FA\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_CHARTBACKGROUND_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang + . "_CHARTBACKGROUND_DESC\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) . "name=\"site_mainwidth\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_MAINWIDTH_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"20\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"50\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang + . "_MAINWIDTH_DESC\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add area width here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_MAINWIDTH_HINT\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) + . ""); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"site_chartareatop\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_CHARTAREATOP_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"20\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"50\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang + . "_CHARTAREATOP_DESC\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add top spacing here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_CHARTAREATOP_HINT\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"site_chartarealeft\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_CHARTAREALEFT_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"20\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"50\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang + . "_CHARTAREALEFT_DESC\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add left spacing here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_CHARTAREALEFT_HINT\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"site_chartareawidth\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_CHARTAREAWIDTH_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"20\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"50\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang + . "_CHARTAREAWIDTH_DESC\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add chart width here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_CHARTAREAWIDTH_HINT\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) + . ""); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"color\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"site_legendtextstylefontcolor\""); + $this->configfieldsets->add('component', Indent::_(3) . "default=\"#63B1F2\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_LEGENDTEXTSTYLEFONTCOLOR_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang + . "_LEGENDTEXTSTYLEFONTCOLOR_DESC\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"text\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"site_legendtextstylefontsize\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_LEGENDTEXTSTYLEFONTSIZE_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "size=\"20\""); + $this->configfieldsets->add('component', Indent::_(3) . "maxlength=\"50\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang + . "_LEGENDTEXTSTYLEFONTSIZE_DESC\""); + $this->configfieldsets->add('component', Indent::_(3) . "class=\"text_area\""); + $this->configfieldsets->add('component', Indent::_(3) . "filter=\"INT\""); + $this->configfieldsets->add('component', Indent::_(3) + . "message=\"Error! Please add size of the legend here.\""); + $this->configfieldsets->add('component', Indent::_(3) . "hint=\"" . $lang + . "_LEGENDTEXTSTYLEFONTSIZE_HINT\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) + . ""); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"color\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"site_vaxistextstylefontcolor\""); + $this->configfieldsets->add('component', Indent::_(3) . "default=\"#63B1F2\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_VAXISTEXTSTYLEFONTCOLOR_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang + . "_VAXISTEXTSTYLEFONTCOLOR_DESC\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) + . ""); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"color\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"site_haxistextstylefontcolor\""); + $this->configfieldsets->add('component', Indent::_(3) . "default=\"#63B1F2\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_HAXISTEXTSTYLEFONTCOLOR_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang + . "_HAXISTEXTSTYLEFONTCOLOR_DESC\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + $this->configfieldsets->add('component', Indent::_(2) . ""); + $this->configfieldsets->add('component', Indent::_(2) . "configfieldsets->add('component', Indent::_(3) . "type=\"color\""); + $this->configfieldsets->add('component', Indent::_(3) + . "name=\"site_haxistitletextstylefontcolor\""); + $this->configfieldsets->add('component', Indent::_(3) . "default=\"#63B1F2\""); + $this->configfieldsets->add('component', Indent::_(3) . "label=\"" . $lang + . "_HAXISTITLETEXTSTYLEFONTCOLOR_LABEL\""); + $this->configfieldsets->add('component', Indent::_(3) . "description=\"" . $lang + . "_HAXISTITLETEXTSTYLEFONTCOLOR_DESC\""); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + + // add custom Encryption Settings fields + if ($this->customfield->isArray('Chart Settings')) + { + $this->configfieldsets->add('component', implode( + "", $this->customfield->get('Chart Settings') + )); + $this->customfield->remove('Chart Settings'); + } + + $this->configfieldsets->add('component', Indent::_(1) . ""); + + // set params defaults + $this->extensionsparams->add('component', + '"admin_chartbackground":"#F7F7FA","admin_mainwidth":"1000","admin_chartareatop":"20","admin_chartarealeft":"20","admin_chartareawidth":"170","admin_legendtextstylefontcolor":"10","admin_legendtextstylefontsize":"20","admin_vaxistextstylefontcolor":"#63B1F2","admin_haxistextstylefontcolor":"#63B1F2","admin_haxistitletextstylefontcolor":"#63B1F2","site_chartbackground":"#F7F7FA","site_mainwidth":"1000","site_chartareatop":"20","site_chartarealeft":"20","site_chartareawidth":"170","site_legendtextstylefontcolor":"10","site_legendtextstylefontsize":"20","site_vaxistextstylefontcolor":"#63B1F2","site_haxistextstylefontcolor":"#63B1F2","site_haxistitletextstylefontcolor":"#63B1F2"' + ); + + // set field lang + $this->language->set( + $this->config->lang_target, $lang . '_CHART_SETTINGS_LABEL', "Chart Settings" + ); + $this->language->set( + $this->config->lang_target, $lang . '_CHART_SETTINGS_DESC', + "The Google Chart Display Settings Are Made Here." + ); + $this->language->set( + $this->config->lang_target, $lang . '_ADMIN_CHART_NOTE_LABEL', "Admin Settings" + ); + $this->language->set( + $this->config->lang_target, $lang . '_ADMIN_CHART_NOTE_DESC', + "The following settings are used on the back-end of the site called (admin)." + ); + $this->language->set( + $this->config->lang_target, $lang . '_SITE_CHART_NOTE_LABEL', "Site Settings" + ); + $this->language->set( + $this->config->lang_target, $lang . '_SITE_CHART_NOTE_DESC', + "The following settings are used on the front-end of the site called (site)." + ); + + $this->language->set( + $this->config->lang_target, $lang . '_CHARTAREALEFT_DESC', + "Set in pixels the spacing from the left of the chart area to the beginning of the chart it self. Please don't add the px sign" + ); + $this->language->set( + $this->config->lang_target, $lang . '_CHARTAREALEFT_HINT', "170" + ); + $this->language->set( + $this->config->lang_target, $lang . '_CHARTAREALEFT_LABEL', "Left Spacing" + ); + $this->language->set( + $this->config->lang_target, $lang . '_CHARTAREATOP_DESC', + "Set in pixels the spacing from the top of the chart area to the beginning of the chart it self. Please don't add the px sign" + ); + $this->language->set( + $this->config->lang_target, $lang . '_CHARTAREATOP_HINT', "20" + ); + $this->language->set( + $this->config->lang_target, $lang . '_CHARTAREATOP_LABEL', "Top Spacing" + ); + $this->language->set( + $this->config->lang_target, $lang . '_CHARTAREAWIDTH_DESC', + "Set in % the width of the chart it self inside the chart area. Please don't add the % sign" + ); + $this->language->set( + $this->config->lang_target, $lang . '_CHARTAREAWIDTH_HINT', "60" + ); + $this->language->set( + $this->config->lang_target, $lang . '_CHARTAREAWIDTH_LABEL', "Chart Width" + ); + $this->language->set( + $this->config->lang_target, $lang . '_CHARTBACKGROUND_DESC', + "Select the chart background color here." + ); + $this->language->set( + $this->config->lang_target, $lang . '_CHARTBACKGROUND_LABEL', + "Chart Background" + ); + $this->language->set( + $this->config->lang_target, $lang . '_HAXISTEXTSTYLEFONTCOLOR_DESC', + "Select the horizontal axis font color." + ); + $this->language->set( + $this->config->lang_target, $lang . '_HAXISTEXTSTYLEFONTCOLOR_LABEL', + "hAxis Font Color" + ); + $this->language->set( + $this->config->lang_target, $lang . '_HAXISTITLETEXTSTYLEFONTCOLOR_DESC', + "Select the horizontal axis title's font color." + ); + $this->language->set( + $this->config->lang_target, $lang . '_HAXISTITLETEXTSTYLEFONTCOLOR_LABEL', + "hAxis Title Font Color" + ); + $this->language->set( + $this->config->lang_target, $lang . '_LEGENDTEXTSTYLEFONTCOLOR_DESC', + "Select the legend font color." + ); + $this->language->set( + $this->config->lang_target, $lang . '_LEGENDTEXTSTYLEFONTCOLOR_LABEL', + "Legend Font Color" + ); + $this->language->set( + $this->config->lang_target, $lang . '_LEGENDTEXTSTYLEFONTSIZE_DESC', + "Set in pixels the font size of the legend" + ); + $this->language->set( + $this->config->lang_target, $lang . '_LEGENDTEXTSTYLEFONTSIZE_HINT', "10" + ); + $this->language->set( + $this->config->lang_target, $lang . '_LEGENDTEXTSTYLEFONTSIZE_LABEL', + "Legend Font Size" + ); + $this->language->set( + $this->config->lang_target, $lang . '_MAINWIDTH_DESC', + "Set the width of the entire chart area" + ); + $this->language->set( + $this->config->lang_target, $lang . '_MAINWIDTH_HINT', "1000" + ); + $this->language->set( + $this->config->lang_target, $lang . '_MAINWIDTH_LABEL', "Chart Area Width" + ); + $this->language->set( + $this->config->lang_target, $lang . '_VAXISTEXTSTYLEFONTCOLOR_DESC', + "Select the vertical axis font color." + ); + $this->language->set( + $this->config->lang_target, $lang . '_VAXISTEXTSTYLEFONTCOLOR_LABEL', + "vAxis Font Color" + ); + } + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsGroupControl.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsGroupControl.php new file mode 100644 index 000000000..3904bf70d --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsGroupControl.php @@ -0,0 +1,163 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Creator; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Builder\FieldGroupControl; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsets; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ExtensionsParams; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsetsCustomfield as Customfield; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; + + +/** + * Config Fieldsets Group Control Creator Class + * + * @since 3.2.0 + */ +final class ConfigFieldsetsGroupControl +{ + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The Language Class. + * + * @var Language + * @since 3.2.0 + */ + protected Language $language; + + /** + * The FieldGroupControl Class. + * + * @var FieldGroupControl + * @since 3.2.0 + */ + protected FieldGroupControl $fieldgroupcontrol; + + /** + * The ConfigFieldsets Class. + * + * @var ConfigFieldsets + * @since 3.2.0 + */ + protected ConfigFieldsets $configfieldsets; + + /** + * The ExtensionsParams Class. + * + * @var ExtensionsParams + * @since 3.2.0 + */ + protected ExtensionsParams $extensionsparams; + + /** + * The ConfigFieldsetsCustomfield Class. + * + * @var Customfield + * @since 3.2.0 + */ + protected Customfield $customfield; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Language $language The Language Class. + * @param FieldGroupControl $fieldgroupcontrol The FieldGroupControl Class. + * @param ConfigFieldsets $configfieldsets The ConfigFieldsets Class. + * @param ExtensionsParams $extensionsparams The ExtensionsParams Class. + * @param Customfield $customfield The ConfigFieldsetsCustomfield Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Language $language, + FieldGroupControl $fieldgroupcontrol, + ConfigFieldsets $configfieldsets, + ExtensionsParams $extensionsparams, + Customfield $customfield) + { + $this->config = $config; + $this->language = $language; + $this->fieldgroupcontrol = $fieldgroupcontrol; + $this->configfieldsets = $configfieldsets; + $this->extensionsparams = $extensionsparams; + $this->customfield = $customfield; + } + + /** + * Set Group Control Config Fieldsets + * + * @param string $lang + * + * @since 1.0 + */ + public function set(string $lang): void + { + // start loading Group control params if needed + if ($this->fieldgroupcontrol->isActive()) + { + // start building field set for config + $this->configfieldsets->add('component', Indent::_(1) . "configfieldsets->add('component', Indent::_(2) . 'name="group_config"'); + $this->configfieldsets->add('component', Indent::_(2) . 'label="' . $lang + . '_GROUPS_LABEL"'); + $this->configfieldsets->add('component', Indent::_(2) . 'description="' . $lang + . '_GROUPS_DESC">'); + // setup lang + $this->language->set( + $this->config->lang_target, $lang . '_GROUPS_LABEL', "Target Groups" + ); + $this->language->set( + $this->config->lang_target, $lang . '_GROUPS_DESC', + "The Parameters for the targeted groups are set here." + ); + $this->language->set( + $this->config->lang_target, $lang . '_TARGET_GROUP_DESC', + "Set the group/s being targeted by this user type." + ); + + foreach ($this->fieldgroupcontrol->allActive() as $selector => $label) + { + $this->configfieldsets->add('component', Indent::_(2) . 'configfieldsets->add('component', Indent::_(3) . 'type="usergroup"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $label . '"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' + . $lang . '_TARGET_GROUP_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) . 'multiple="true"'); + $this->configfieldsets->add('component', Indent::_(2) . "/>"); + // set params defaults + $this->extensionsparams->add('component', '"' . $selector . '":["2"]'); + } + // add custom Target Groups fields + if ($this->customfield->isArray('Target Groups')) + { + $this->configfieldsets->add('component', implode( + "", $this->customfield->get('Target Groups') + )); + $this->customfield->remove('Target Groups'); + } + // close that fieldse + $this->configfieldsets->add('component', Indent::_(1) . ""); + } + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsSiteControl.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsSiteControl.php new file mode 100644 index 000000000..fc0944120 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsSiteControl.php @@ -0,0 +1,225 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Creator; + + +use VDM\Joomla\Componentbuilder\Compiler\Component; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsets; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsetsCustomfield as Customfield; +use VDM\Joomla\Componentbuilder\Compiler\Builder\HasMenuGlobal; +use VDM\Joomla\Componentbuilder\Compiler\Builder\FrontendParams; +use VDM\Joomla\Componentbuilder\Compiler\Creator\Request; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\GetHelper; + + +/** + * Config Fieldsets Site Control Creator Class + * + * @since 3.2.0 + */ +final class ConfigFieldsetsSiteControl +{ + /** + * The Component Class. + * + * @var Component + * @since 3.2.0 + */ + protected Component $component; + + /** + * The ConfigFieldsets Class. + * + * @var ConfigFieldsets + * @since 3.2.0 + */ + protected ConfigFieldsets $configfieldsets; + + /** + * The ConfigFieldsetsCustomfield Class. + * + * @var Customfield + * @since 3.2.0 + */ + protected Customfield $customfield; + + /** + * The HasMenuGlobal Class. + * + * @var HasMenuGlobal + * @since 3.2.0 + */ + protected HasMenuGlobal $hasmenuglobal; + + /** + * The FrontendParams Class. + * + * @var FrontendParams + * @since 3.2.0 + */ + protected FrontendParams $frontendparams; + + /** + * The Request Class. + * + * @var Request + * @since 3.2.0 + */ + protected Request $request; + + /** + * Constructor. + * + * @param Component $component The Component Class. + * @param ConfigFieldsets $configfieldsets The ConfigFieldsets Class. + * @param Customfield $customfield The ConfigFieldsetsCustomfield Class. + * @param HasMenuGlobal $hasmenuglobal The HasMenuGlobal Class. + * @param FrontendParams $frontendparams The FrontendParams Class. + * @param Request $request The Request Class. + * + * @since 3.2.0 + */ + public function __construct(Component $component, ConfigFieldsets $configfieldsets, + Customfield $customfield, HasMenuGlobal $hasmenuglobal, + FrontendParams $frontendparams, Request $request) + { + $this->component = $component; + $this->configfieldsets = $configfieldsets; + $this->customfield = $customfield; + $this->hasmenuglobal = $hasmenuglobal; + $this->frontendparams = $frontendparams; + $this->request = $request; + } + + /** + * Set Site Control Config Fieldsets + * + * @param string $lang + * + * @since 3.2.0 + */ + public function set(string $lang): void + { + $front_end = []; + // do quick build of front-end views + if ($this->component->isArray('site_views')) + { + // load the names only to link the page params + foreach ($this->component->get('site_views') as $siteView) + { + // now load the view name to the front-end array + $front_end[] = $siteView['settings']->name; + } + } + + // add frontend view stuff including menus + if ($this->customfield->isActive()) + { + foreach ($this->customfield->allActive() as $tab => $tabFields) + { + $tabCode = StringHelper::safe($tab) . '_custom_config'; + $tabUpper = StringHelper::safe($tab, 'U'); + $tabLower = StringHelper::safe($tab); + + // load the request id setters for menu views + $viewRequest = 'name="' . $tabLower . '_request_id'; + foreach ($tabFields as $et => $id_field) + { + if (strpos((string) $id_field, $viewRequest) !== false) + { + $this->request->set( + $tabLower, $id_field, $viewRequest, 'id' + ); + $this->customfield->remove("$tab.$et"); + unset($tabFields[$et]); + } + elseif (strpos((string) $id_field, '_request_id') !== false) + { + // not loaded to a tab "view" name + $_viewRequest = GetHelper::between( + $id_field, 'name="', '_request_id' + ); + $searchIdKe = 'name="' . $_viewRequest + . '_request_id'; + $this->request->set( + $_viewRequest, $id_field, $searchIdKe, 'id' + ); + $this->customfield->remove("$tab.$et"); + unset($tabFields[$et]); + } + } + + // load the request catid setters for menu views + $viewRequestC = 'name="' . $tabLower . '_request_catid'; + foreach ($tabFields as $ci => $catid_field) + { + if (strpos((string) $catid_field, $viewRequestC) !== false) + { + + $this->request->set( + $tabLower, $catid_field, $viewRequestC, 'catid' + ); + $this->customfield->remove("$tab.$ci"); + unset($tabFields[$ci]); + } + elseif (strpos((string) $catid_field, '_request_catid') !== false) + { + // not loaded to a tab "view" name + $_viewRequestC = GetHelper::between( + $catid_field, 'name="', '_request_catid' + ); + $searchCatidKe = 'name="' . $_viewRequestC + . '_request_catid'; + $this->request->set( + $_viewRequestC, $catid_field, $searchCatidKe, 'catid' + ); + $this->customfield->remove("$tab.$ci"); + unset($tabFields[$ci]); + } + } + + // load the global menu setters for single fields + $menuSetter = $tabLower . '_menu'; + $pageSettings = []; + foreach ($tabFields as $ct => $field) + { + if (strpos((string) $field, $menuSetter) !== false) + { + // set the values needed to insure route is done correclty + $this->hasmenuglobal->set($tabLower, $menuSetter); + } + elseif (strpos((string) $field, '_menu"') !== false) + { + // not loaded to a tab "view" name + $_tabLower = GetHelper::between( + $field, 'name="', '_menu"' + ); + // set the values needed to insure route is done correclty + $this->hasmenuglobal->set($_tabLower, $_tabLower . '_menu'); + } + else + { + $pageSettings[$ct] = $field; + } + } + + // insure we load the needed params + if (in_array($tab, $front_end)) + { + $this->frontendparams->set($tab, $pageSettings); + } + } + } + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsUikit.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsUikit.php new file mode 100644 index 000000000..e67c8a37f --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/ConfigFieldsetsUikit.php @@ -0,0 +1,367 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Creator; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsets; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ExtensionsParams; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsetsCustomfield as Customfield; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; + + +/** + * Config Fieldsets Uikit Creator Class + * + * @since 3.2.0 + */ +final class ConfigFieldsetsUikit +{ + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The Language Class. + * + * @var Language + * @since 3.2.0 + */ + protected Language $language; + + /** + * The ConfigFieldsets Class. + * + * @var ConfigFieldsets + * @since 3.2.0 + */ + protected ConfigFieldsets $configfieldsets; + + /** + * The ExtensionsParams Class. + * + * @var ExtensionsParams + * @since 3.2.0 + */ + protected ExtensionsParams $extensionsparams; + + /** + * The ConfigFieldsetsCustomfield Class. + * + * @var Customfield + * @since 3.2.0 + */ + protected Customfield $customfield; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Language $language The Language Class. + * @param ConfigFieldsets $configfieldsets The ConfigFieldsets Class. + * @param ExtensionsParams $extensionsparams The ExtensionsParams Class. + * @param Customfield $customfield The ConfigFieldsetsCustomfield Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Language $language, + ConfigFieldsets $configfieldsets, + ExtensionsParams $extensionsparams, + Customfield $customfield) + { + $this->config = $config; + $this->language = $language; + $this->configfieldsets = $configfieldsets; + $this->extensionsparams = $extensionsparams; + $this->customfield = $customfield; + } + + /** + * Set Uikit Config Fieldsets + * + * @param string $lang + * + * @since 3.2.0 + */ + public function set(string $lang): void + { + if ($this->config->uikit > 0) + { + // main lang prefix + $lang = $lang . ''; + // start building field set for uikit functions + $this->configfieldsets->add('component', Indent::_(1) . "configfieldsets->add('component', Indent::_(2) . 'name="uikit_config"'); + $this->configfieldsets->add('component', Indent::_(2) . 'label="' . $lang + . '_UIKIT_LABEL"'); + $this->configfieldsets->add('component', Indent::_(2) . 'description="' . $lang + . '_UIKIT_DESC">'); + // set tab lang + if (1 == $this->config->uikit) + { + $this->language->set( + $this->config->lang_target, $lang . '_UIKIT_LABEL', "Uikit2 Settings" + ); + $this->language->set( + $this->config->lang_target, $lang . '_UIKIT_DESC', "The Parameters for the uikit are set here.
    Uikit is a lightweight and modular front-end framework +for developing fast and powerful web interfaces. For more info visit https://getuikit.com/v2/" + ); + } + elseif (2 == $this->config->uikit) + { + $this->language->set( + $this->config->lang_target, $lang . '_UIKIT_LABEL', + "Uikit2 and Uikit3 Settings" + ); + $this->language->set( + $this->config->lang_target, $lang . '_UIKIT_DESC', "The Parameters for the uikit are set here.
    Uikit is a lightweight and modular front-end framework +for developing fast and powerful web interfaces. For more info visit version 2 or version 3" + ); + } + elseif (3 == $this->config->uikit) + { + $this->language->set( + $this->config->lang_target, $lang . '_UIKIT_LABEL', "Uikit3 Settings" + ); + $this->language->set( + $this->config->lang_target, $lang . '_UIKIT_DESC', "The Parameters for the uikit are set here.
    Uikit is a lightweight and modular front-end framework +for developing fast and powerful web interfaces. For more info visit https://getuikit.com/" + ); + } + + // set field lang + $this->language->set( + $this->config->lang_target, $lang . '_JQUERY_LOAD_LABEL', "Load Joomla jQuery" + ); + $this->language->set( + $this->config->lang_target, $lang . '_JQUERY_LOAD_DESC', + "Would you like to load the Joomla jQuery Framework?" + ); + $this->language->set($this->config->lang_target, $lang . '_JQUERY_LOAD', "Load jQuery"); + $this->language->set($this->config->lang_target, $lang . '_JQUERY_REMOVE', "Remove jQuery"); + + // set the field + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="radio"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang + . '_JQUERY_LOAD_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' . $lang + . '_JQUERY_LOAD_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) + . 'class="btn-group btn-group-yesno"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default="">'); + $this->configfieldsets->add('component', Indent::_(3) . ''); + $this->configfieldsets->add('component', Indent::_(3) . '"'); + $this->configfieldsets->add('component', Indent::_(3) . '"'); + $this->configfieldsets->add('component', Indent::_(2) . ""); + // set params defaults + $this->extensionsparams->add('component', '"add_jquery_framework":"1"'); + + // add version selection + if (2 == $this->config->uikit) + { + // set field lang + $this->language->set( + $this->config->lang_target, $lang . '_UIKIT_VERSION_LABEL', + "Uikit Versions" + ); + $this->language->set( + $this->config->lang_target, $lang . '_UIKIT_VERSION_DESC', + "Select what version you would like to use" + ); + $this->language->set( + $this->config->lang_target, $lang . '_UIKIT_V2', "Version 2" + ); + $this->language->set( + $this->config->lang_target, $lang . '_UIKIT_V3', "Version 3" + ); + // set the field + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="radio"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang + . '_UIKIT_VERSION_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' + . $lang . '_UIKIT_VERSION_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) + . 'class="btn-group btn-group-yesno"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default="2">'); + $this->configfieldsets->add('component', Indent::_(3) . ''); + $this->configfieldsets->add('component', Indent::_(3) . '"'); + $this->configfieldsets->add('component', Indent::_(3) . '"'); + $this->configfieldsets->add('component', Indent::_(2) . ""); + // set params defaults + $this->extensionsparams->add('component', '"uikit_version":"2"'); + } + + // set field lang + $this->language->set( + $this->config->lang_target, $lang . '_UIKIT_LOAD_LABEL', "Loading Options" + ); + $this->language->set( + $this->config->lang_target, $lang . '_UIKIT_LOAD_DESC', + "Set the uikit loading option." + ); + $this->language->set($this->config->lang_target, $lang . '_AUTO_LOAD', "Auto"); + $this->language->set($this->config->lang_target, $lang . '_FORCE_LOAD', "Force"); + $this->language->set($this->config->lang_target, $lang . '_DONT_LOAD', "Not"); + $this->language->set( + $this->config->lang_target, $lang . '_ONLY_EXTRA', "Only Extra" + ); + // set the field + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="radio"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang + . '_UIKIT_LOAD_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' . $lang + . '_UIKIT_LOAD_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) + . 'class="btn-group btn-group-yesno"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default="">'); + $this->configfieldsets->add('component', Indent::_(3) . ''); + $this->configfieldsets->add('component', Indent::_(3) . '"'); + $this->configfieldsets->add('component', Indent::_(3) . '"'); + if (2 == $this->config->uikit || 1 == $this->config->uikit) + { + $this->configfieldsets->add('component', Indent::_(3) . '"'); + } + $this->configfieldsets->add('component', Indent::_(3) . '"'); + $this->configfieldsets->add('component', Indent::_(2) . ""); + // set params defaults + $this->extensionsparams->add('component', '"uikit_load":"1"'); + + // set field lang + $this->language->set( + $this->config->lang_target, $lang . '_UIKIT_MIN_LABEL', "Load Minified" + ); + $this->language->set( + $this->config->lang_target, $lang . '_UIKIT_MIN_DESC', + "Should the minified version of uikit files be loaded?" + ); + $this->language->set($this->config->lang_target, $lang . '_YES', "Yes"); + $this->language->set($this->config->lang_target, $lang . '_NO', "No"); + // set the field + $this->configfieldsets->add('component', Indent::_(2) . 'configfieldsets->add('component', Indent::_(3) . 'type="radio"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang + . '_UIKIT_MIN_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' . $lang + . '_UIKIT_MIN_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) + . 'class="btn-group btn-group-yesno"'); + $this->configfieldsets->add('component', Indent::_(3) . 'default="">'); + $this->configfieldsets->add('component', Indent::_(3) . ''); + $this->configfieldsets->add('component', Indent::_(3) . '"'); + $this->configfieldsets->add('component', Indent::_(3) . '"'); + $this->configfieldsets->add('component', Indent::_(2) . ""); + // set params defaults + $this->extensionsparams->add('component', '"uikit_min":""'); + + if (2 == $this->config->uikit || 1 == $this->config->uikit) + { + // set field lang + $this->language->set( + $this->config->lang_target, $lang . '_UIKIT_STYLE_LABEL', "css Style" + ); + $this->language->set( + $this->config->lang_target, $lang . '_UIKIT_STYLE_DESC', + "Set the css style that should be used." + ); + $this->language->set( + $this->config->lang_target, $lang . '_FLAT_LOAD', "Flat" + ); + $this->language->set( + $this->config->lang_target, $lang . '_ALMOST_FLAT_LOAD', "Almost Flat" + ); + $this->language->set( + $this->config->lang_target, $lang . '_GRADIANT_LOAD', "Gradient" + ); + // set the field + $this->configfieldsets->add('component', Indent::_(2) + . 'configfieldsets->add('component', Indent::_(3) . 'type="radio"'); + $this->configfieldsets->add('component', Indent::_(3) . 'label="' . $lang + . '_UIKIT_STYLE_LABEL"'); + $this->configfieldsets->add('component', Indent::_(3) . 'description="' + . $lang . '_UIKIT_STYLE_DESC"'); + $this->configfieldsets->add('component', Indent::_(3) + . 'class="btn-group btn-group-yesno"'); + if (2 == $this->config->uikit) + { + $this->configfieldsets->add('component', Indent::_(3) + . 'showon="uikit_version:2"'); + } + $this->configfieldsets->add('component', Indent::_(3) . 'default="">'); + $this->configfieldsets->add('component', Indent::_(3) . ''); + $this->configfieldsets->add('component', Indent::_(3) . '"'); + $this->configfieldsets->add('component', Indent::_(3) + . '"'); + $this->configfieldsets->add('component', Indent::_(3) + . '"'); + $this->configfieldsets->add('component', Indent::_(2) . ""); + // set params defaults + $this->extensionsparams->add('component', '"uikit_style":""'); + } + // add custom Uikit Settings fields + if ($this->customfield->isArray('Uikit Settings')) + { + $this->configfieldsets->add('component', implode( + "", $this->customfield->get('Uikit Settings') + )); + $this->customfield->remove('Uikit Settings'); + } + // close that fieldset + $this->configfieldsets->add('component', Indent::_(1) . ""); + } + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/CustomButtonPermissions.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/CustomButtonPermissions.php new file mode 100644 index 000000000..5458913e1 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/CustomButtonPermissions.php @@ -0,0 +1,141 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Creator; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionComponent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + + +/** + * Custom Button Permissions Creator Class + * + * @since 3.2.0 + */ +final class CustomButtonPermissions +{ + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The Language Class. + * + * @var Language + * @since 3.2.0 + */ + protected Language $language; + + /** + * The PermissionComponent Class. + * + * @var PermissionComponent + * @since 3.2.0 + */ + protected PermissionComponent $permissioncomponent; + + /** + * The Counter Class. + * + * @var Counter + * @since 3.2.0 + */ + protected Counter $counter; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Language $language The Language Class. + * @param PermissionComponent $permissioncomponent The PermissionComponent Class. + * @param Counter $counter The Counter Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Language $language, + PermissionComponent $permissioncomponent, + Counter $counter) + { + $this->config = $config; + $this->language = $language; + $this->permissioncomponent = $permissioncomponent; + $this->counter = $counter; + } + + /** + * Add Custom Button Permissions + * + * @param object $settings The view settings + * @param string $nameView The view name + * @param string $code The view code name. + * + * @since 3.2.0 + */ + public function add(object $settings, string $nameView, string $code): void + { + // add the custom permissions to use the buttons of this view + if (isset($settings->custom_buttons) + && ArrayHelper::check($settings->custom_buttons)) + { + foreach ($settings->custom_buttons as $custom_buttons) + { + $customButtonName = $custom_buttons['name']; + $customButtonCode = StringHelper::safe( + $customButtonName + ); + $customButtonTitle = $this->config->lang_prefix . '_' + . StringHelper::safe( + $nameView . ' ' . $customButtonName . ' Button Access', + 'U' + ); + $customButtonDesc = $this->config->lang_prefix . '_' + . StringHelper::safe( + $nameView . ' ' . $customButtonName . ' Button Access', + 'U' + ) . '_DESC'; + $sortButtonKey = StringHelper::safe( + $nameView . ' ' . $customButtonName . ' Button Access' + ); + + $this->language->set( + 'bothadmin', $customButtonTitle, + $nameView . ' ' . $customButtonName . ' Button Access' + ); + + $this->language->set( + 'bothadmin', $customButtonDesc, + ' Allows the users in this group to access the ' + . StringHelper::safe($customButtonName, 'w') + . ' button.' + ); + + $this->permissioncomponent->set($sortButtonKey, [ + 'name' => "$code.$customButtonCode", + 'title' => $customButtonTitle, + 'description' => $customButtonDesc + ]); + + // the size needs increase + $this->counter->accessSize++; + } + } + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/CustomFieldTypeFile.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/CustomFieldTypeFile.php index 6fc8ca30e..2ec77fed4 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/CustomFieldTypeFile.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/CustomFieldTypeFile.php @@ -23,11 +23,14 @@ use VDM\Joomla\Componentbuilder\Compiler\Placeholder; use VDM\Joomla\Componentbuilder\Compiler\Language; use VDM\Joomla\Componentbuilder\Compiler\Component\Placeholder as ComponentPlaceholder; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Structure; -use VDM\Joomla\Componentbuilder\Compiler\Field\InputButton; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\InputButtonInterface as InputButton; use VDM\Joomla\Componentbuilder\Compiler\Builder\FieldGroupControl; use VDM\Joomla\Componentbuilder\Compiler\Builder\ExtensionCustomFields; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface as Header; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreFieldInterface as CoreField; use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\String\ClassfunctionHelper; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; @@ -129,6 +132,30 @@ final class CustomFieldTypeFile */ protected ExtensionCustomFields $extensioncustomfields; + /** + * The HeaderInterface Class. + * + * @var Header + * @since 3.2.0 + */ + protected Header $header; + + /** + * The CoreFieldInterface Class. + * + * @var CoreField + * @since 3.2.0 + */ + protected CoreField $corefield; + + /** + * The core field mapper. + * + * @var array + * @since 3.2.0 + */ + protected array $fieldmap = []; + /** * Application object. * @@ -138,12 +165,93 @@ final class CustomFieldTypeFile protected CMSApplication $app; /** - * Array of php fields Allowed (16) + * Array of php fields Allowed (15) * * @var array * @since 3.2.0 **/ - protected array $phpFieldArray = ['', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'x', 'HEADER']; + protected array $phpFieldArray = ['', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'x']; + + /** + * The Local Placeholder Values. + * + * @var array + * @since 3.2.0 + */ + protected array $placeholders = []; + + /** + * The field data values. + * + * @var array + * @since 3.2.0 + */ + protected array $data; + + /** + * The List Code Name value. + * + * @var string + * @since 3.2.0 + */ + protected string $nameListCode; + + /** + * The Single Code Name value. + * + * @var string + * @since 3.2.0 + */ + protected string $nameSingleCode; + + /** + * The contents key value. + * + * @var string + * @since 3.2.0 + */ + protected string $contentsKey; + + /** + * The type field value. + * + * @var string + * @since 3.2.0 + */ + protected string $type; + + /** + * The base type field value. + * + * @var string + * @since 3.2.0 + */ + protected string $baseType; + + /** + * The raw type field value. + * + * @var string + * @since 3.2.0 + */ + protected string $rawType; + + /** + * The switch to check if the custom + * type field value was set. + * + * @var bool + * @since 3.2.0 + */ + protected bool $customTypeWasSet; + + /** + * The extends field value. + * + * @var string + * @since 3.2.0 + */ + protected string $extends; /** * Constructor. @@ -159,6 +267,8 @@ final class CustomFieldTypeFile * @param InputButton $inputbutton The InputButton Class. * @param FieldGroupControl $fieldgroupcontrol The FieldGroupControl Class. * @param ExtensionCustomFields $extensioncustomfields The ExtensionCustomFields Class. + * @param Header $header The HeaderInterface Class. + * @param CoreField $corefield The CoreFieldInterface Class. * @param CMSApplication|null $app The app object. * * @since 3.2.0 @@ -170,7 +280,7 @@ final class CustomFieldTypeFile Structure $structure, InputButton $inputbutton, FieldGroupControl $fieldgroupcontrol, ExtensionCustomFields $extensioncustomfields, - ?CMSApplication $app = null) + Header $header, CoreField $corefield, ?CMSApplication $app = null) { $this->config = $config; $this->content = $content; @@ -183,11 +293,17 @@ final class CustomFieldTypeFile $this->inputbutton = $inputbutton; $this->fieldgroupcontrol = $fieldgroupcontrol; $this->extensioncustomfields = $extensioncustomfields; + $this->header = $header; + $this->corefield = $corefield; $this->app = $app ?: Factory::getApplication(); } /** - * set Custom Field Type File + * Set Custom Field Type File + * + * This method handles the setting of a custom field type. It checks if the field has already been built, + * handles namespace in the custom field type name, sets various placeholders, and loads the global placeholders. + * Additionally, it manages the setting of dynamic contents based on the field type and other configurations. * * @param array $data The field complete data set * @param string $nameListCode The list view code name @@ -198,335 +314,713 @@ final class CustomFieldTypeFile */ public function set(array $data, string $nameListCode, string $nameSingleCode): void { - // make sure it is not already been build or if it is prime - if (isset($data['custom']) && isset($data['custom']['extends']) - && ((isset($data['custom']['prime_php']) && $data['custom']['prime_php'] == 1) - || !$this->contents->isArray('customfield_' . $data['type'])) - ) + $this->setTypeName($data); + + if (!$this->isFieldBuildable($data)) { - // set J prefix - $jprefix = 'J'; - // check if this field has a dot in field type name - if (strpos((string) $data['type'], '.') !== false) + return; + } + + $this->init($data, $nameSingleCode, $nameListCode); + + if (isset($data['custom']['own_custom'])) + { + $this->handleOwnCustomField(); + } + else + { + $this->handleStandardCustomField(); + } + + // Extension custom fields tracking for plugins or modules + $this->trackExtensionCustomFields(); + } + + /** + * Set the type name of the custom field. + * + * This function checks if there is a namespace in the field type name (indicated by a dot). + * If a namespace exists, it extracts and removes the namespace from the type name. + * + * @param array $data The field data which contains the type name. + * + * @return void + * @since 3.2.0 + */ + private function setTypeName(array $data): void + { + $type_name = $this->rawType = $data['type'] ?? ''; + + $this->customTypeWasSet = isset($data['custom']['type']); + + // Check if the field type name contains a dot, indicating a namespace + if (strpos($type_name, '.') !== false) + { + $dot_type_array = explode('.', $type_name); + + // If there are more than one parts, remove the first part (namespace) + if (count($dot_type_array) > 1) { - // so we have name spacing in custom field type name - $dotTypeArray = explode('.', (string) $data['type']); - // set the J prefix - if (count((array) $dotTypeArray) > 1) - { - $jprefix = strtoupper(array_shift($dotTypeArray)); - } - // update the type name now - $data['type'] = implode('', $dotTypeArray); - $data['custom']['type'] = $data['type']; + array_shift($dot_type_array); // Remove the namespace part } - // set the contents key - $contents_key = "customfield_{$data['type']}|"; + + // Update the type name by concatenating the remaining parts + $type_name = implode('', $dot_type_array); + $data['custom']['type'] = ClassfunctionHelper::safe($type_name); + } + + $base_type = $data['custom']['type'] ?? $type_name; + + $this->baseType = ClassfunctionHelper::safe($base_type); + $this->type = ClassfunctionHelper::safe($type_name); + } + + /** + * Checks if the field is eligible to be built. + * + * This method examines the 'custom' attribute of the field data to determine if the field has + * already been built or if it is marked as 'prime'. It returns true if the field should be built, + * and false otherwise. + * + * @param array $data The field data. + * + * @return bool True if the field is buildable, false otherwise. + * @since 3.2.0 + */ + private function isFieldBuildable(array $data): bool + { + // Check if 'custom' key is set in the data. + if (!isset($data['custom'])) + { + return false; + } + + // Check if 'extends' key is set under 'custom'. + if (!isset($data['custom']['extends'])) + { + return false; + } + + // Check if the field is marked as 'prime' or if it hasn't been built yet. + $isPrime = isset($data['custom']['prime_php']) && $data['custom']['prime_php'] == 1; + $notBuilt = !$this->contents->isArray('customfield_' . $this->type); + + return $isPrime || $notBuilt; + } + + /** + * The function to set the class values to the current field being build. + * + * @param array $data The field complete data set + * @param string $nameListCode The list view code name + * @param string $nameSingleCode The single view code name + * + * @return void + * @since 3.2.0 + */ + private function init(array $data, string $nameListCode, string $nameSingleCode): void + { + $this->data = $data; + $this->nameListCode = $nameListCode; + $this->nameSingleCode = $nameSingleCode; + $this->contentsKey = "customfield_{$this->baseType}|"; + + $this->jprefix = $this->determineJPrefix(); + $this->extends = ClassfunctionHelper::safe($data['custom']['extends']); + + $this->setLocalPlaceholders(); + $this->setContentPlaceholders(); + } + + /** + * The function to set the default content placeholder. + * + * @return void + * @since 3.2.0 + */ + private function setContentPlaceholders(): void + { + $contents_key = $this->contentsKey; + + // Start loading the field type + $this->contents->set("{$contents_key}JPREFIX", $this->jprefix); + + $this->contents->set("{$contents_key}JFORM_extends", $this->extends); + $this->contents->set("{$contents_key}JFORM_EXTENDS", + StringHelper::safe($this->extends, 'F') + ); + + // if own custom field + if (isset($this->data['custom']['own_custom'])) + { + $this->contents->set("{$contents_key}FORM_EXTENDS", + $this->getClassNameExtends() + ); + } + + $this->contents->set("{$contents_key}type", $this->baseType); + $this->contents->set("{$contents_key}Type", + StringHelper::safe($this->baseType, 'F') + ); + } + + /** + * Determines the J prefix for the field type. + * + * This method extracts the prefix from the field type name if it contains a dot, indicating namespace usage. + * If no dot is present, it defaults to 'J'. + * + * @return string The determined J prefix. + * @since 3.2.0 + */ + private function determineJPrefix(): string + { + // Default prefix + $jprefix = 'J'; + + // Check if the field type name contains a dot, indicating namespace usage + if (strpos($this->rawType, '.') !== false) + { + // Explode the type by dot to get the namespace parts + $dot_type_array = explode('.', $this->rawType); + + // If there are multiple parts, use the first part as the prefix + if (count($dot_type_array) > 1) + { + $jprefix = strtoupper(array_shift($dot_type_array)); + } + } + + return $jprefix; + } + + /** + * Set placeholder options for the custom field. + * + * This method maps various data points to their corresponding placeholders. + * It takes custom field data, view codes, and a J prefix, and prepares an associative array + * of placeholders and their values. + * + * @return void + * @since 3.2.0 + */ + private function setLocalPlaceholders(): void + { + // The data set for the custom field + $data = $this->data; + + // Initialize the array for placeholder options + $placeholders = []; + + // Populate the array with specific placeholder options + $placeholders[Placefix::_('JPREFIX')] = $this->jprefix; + + $placeholders[Placefix::_('JFORM_extends')] = $this->extends; + $placeholders[Placefix::_('JFORM_EXTENDS')] = StringHelper::safe($this->extends, 'F'); + + // if own custom field + if (isset($data['custom']['own_custom'])) + { + $placeholders[Placefix::_('FORM_EXTENDS')] = $this->getClassNameExtends(); + } + + $placeholders[Placefix::_('TABLE')] = $data['custom']['table'] ?? ''; + $placeholders[Placefix::_('ID')] = $data['custom']['id'] ?? ''; + $placeholders[Placefix::_('TEXT')] = $data['custom']['text'] ?? ''; + $placeholders[Placefix::_('CODE_TEXT')] = + isset($data['code'], $data['custom']['text']) ? $data['code'] . '_' . $data['custom']['text'] : ''; + $placeholders[Placefix::_('CODE')] = $data['code'] ?? ''; + + $placeholders[Placefix::_('com_component')] = $this->getComComponentName(); + $placeholders[Placefix::_('component')] = $this->config->component_code_name; + $placeholders[Placefix::_('Component')] = $this->content->get('Component'); + + $placeholders[Placefix::_('type')] = $this->baseType; + $placeholders[Placefix::_('Type')] = StringHelper::safe($this->baseType, 'F'); + + $placeholders[Placefix::_('view_type')] = $this->getViewName() . '_' . $this->baseType; + $placeholders[Placefix::_('view')] = $this->getViewName(); + $placeholders[Placefix::_('views')] = $this->getViewsName(); + + // Gymnastics to help with transition to Joomla 4 and above + if ($this->config->get('joomla_version', 3) != 3) + { + $placeholders['JFactory::getUser()'] = 'Factory::getApplication()->getIdentity()'; + $placeholders['Factory::getUser()'] = 'Factory::getApplication()->getIdentity()'; + $placeholders['JFactory::'] = 'Factory::'; + $placeholders['JHtml::'] = 'Html::'; + $placeholders['JText::'] = 'Text::'; + $placeholders['JComponentHelper::'] = 'ComponentHelper::'; + $placeholders['\JComponentHelper::'] = 'ComponentHelper::'; + } + + $this->placeholders = $placeholders; + + $this->updatePlaceholderValues(); + $this->loadGlobalPlaceholders(); + } + + /** + * Gets the component name for the custom field. + * + * This method extracts the component name from the custom field data. + * If the component name is explicitly set in the custom field data, + * it returns that name after ensuring it's a safe string. Otherwise, + * it defaults to a name constructed from the component code name in the configuration. + * + * @return string The name of the component. + * @since 3.2.0 + */ + private function getComComponentName(): string + { + // Check if the component name is explicitly set in the custom field data + if (isset($this->data['custom']['component']) && StringHelper::check($this->data['custom']['component'])) + { + // Return the safe version of the component name + return StringHelper::safe($this->data['custom']['component']); + } + + // Default to a component name constructed from the component code name in the configuration + return 'com_' . $this->config->component_code_name; + } + + /** + * Determines the view name for a custom field. + * + * This method extracts the view name from the custom field data, with a fallback + * to a provided single view code name if the view name is not explicitly set in the data. + * + * @return string The determined view name. + * @since 3.2.0 + */ + private function getViewName(): string + { + // Check if a specific view name is set in the custom field data + if (isset($this->data['custom']['view']) && StringHelper::check($this->data['custom']['view'])) + { + // If a specific view name is set, use it after sanitizing + return StringHelper::safe($this->data['custom']['view']); + } + + // If no specific view name is set, use the single view code name as a fallback + return $this->nameSingleCode; + } + + /** + * Gets the formatted name for the views associated with the custom field. + * + * This method checks if a specific views name is provided in the custom field data. + * If it is, it formats and returns this name. If not, it defaults to the provided list view name. + * + * @return string The formatted name for the views. + * @since 3.2.0 + */ + private function getViewsName(): string + { + // Check if specific views name is provided in the custom field data + if (isset($this->data['custom']['views']) && StringHelper::check($this->data['custom']['views'])) + { + // If yes, use the provided name after ensuring it is properly formatted + return StringHelper::safe($this->data['custom']['views']); + } + + // If no specific name is provided, default to the provided list view name + return $this->nameListCode; + } + + /** + * Gets the class name being extended. + * + * This method is for the new namespace class name in Joomla 4 and above. + * + * @return string The class being name extended. + * @since 3.2.0 + */ + private function getClassNameExtends(): string + { + if (isset($this->fieldmap[$this->extends])) + { + return $this->fieldmap[$this->extends]; + } + + $core_fields = $this->corefield->get(); + $extends = $this->extends; + $found = null; + foreach ($core_fields as $core_field) + { + $field = strtolower((string) $core_field); + if ($extends === $field) + { + $found = $core_field; + break; + } + } + + $extends = $found ?? StringHelper::safe($extends, 'F'); + + if ($this->config->get('joomla_version', 3) != 3) + { + $fix = strtolower($extends); + + if ('checkboxes' === $fix) + { + $extends = 'CheckboxesField'; + } + elseif ('list' === $fix) + { + $extends = 'FormField'; + } + elseif ('radio' === $fix) + { + $extends = 'RadioField'; + } + elseif ('combo' === $fix) + { + $extends = 'ComboField'; + } + elseif (strpos($extends, 'Field') === false) + { + $extends = StringHelper::safe($extends, 'F') . 'Field'; + } + } + + $this->fieldmap[$this->extends] = $extends; + + return $extends; + } + + /** + * Update placeholder values in the field data. + * + * This function iterates over the given replacements and applies them to the placeholders. + * It updates both the key and value of each placeholder, ensuring that they are correctly set. + * + * @return void + * @since 3.2.0 + */ + private function updatePlaceholderValues(): void + { + foreach ($this->placeholders as $placeholder => $value) + { + // Update the key by replacing the placeholders for before and after + $updatedPlaceholder = str_replace( + [Placefix::b(), Placefix::d()], + [Placefix::h(), Placefix::h()], + $placeholder + ); + + // Update the value in the replacements array + $this->placeholders[$updatedPlaceholder] = $value; + } + } + + /** + * Load global placeholders into the placeholders array. + * + * This method iterates over the global placeholders and adds them to the replace array. + * + * @return void + * @since 3.2.0 + */ + private function loadGlobalPlaceholders(): void + { + foreach ($this->componentplaceholder->get() as $globalPlaceholder => $globalValue) + { + $this->placeholders[$globalPlaceholder] = $globalValue; + } + } + + /** + * Handle the setting of a own custom field. + * + * This method manages the building of the custom field type file, the handling of PHP scripts, + * and specific operations for certain field types like user fields. + * + * @return void + * @since 3.2.0 + */ + private function handleOwnCustomField(): void + { + if ($this->isButtonOptionSet()) + { + $this->setButtonOptionErrorMessages(); + } + + $targets = [['admin' => 'customfield'], ['site' => 'customfield']]; + foreach ($targets as $target) + { + $this->structure->build($target, 'fieldcustom', $this->baseType); + } + + $this->prepareCustomFieldHeader(); + $this->prepareCustomFieldBody(); + } + + /** + * Handle the setting of a standard custom field. + * + * This method manages the building of the custom field type file, the handling of PHP scripts, + * and specific operations for certain field types like user fields. + * + * @return void + * @since 3.2.0 + */ + private function handleStandardCustomField(): void + { + // The key used for setting contents. + $contents_key = $this->contentsKey; + + // Build the custom field type file + $targets = [['admin' => 'customfield'], ['site' => 'customfield']]; + foreach ($targets as $target) + { + $this->structure->build( + $target, 'field' . $this->extends, $this->baseType + ); + } + + $php_code = $this->loadPhpScript('php'); + + if ($this->extends === 'user') + { + $this->fieldgroupcontrol->set( + $this->type, $this->generateGroupLanguageName() + ); + + $phpx_code = $this->loadPhpScript('phpx'); + + $this->contents->set("{$contents_key}JFORM_GETGROUPS_PHP", $php_code); + $this->contents->set("{$contents_key}JFORM_GETEXCLUDED_PHP", $phpx_code); + } + else + { + $this->contents->set("{$contents_key}JFORM_GETOPTIONS_PHP", $php_code); + } + + $this->contents->set("{$contents_key}ADD_BUTTON", $this->inputbutton->get($this->data['custom'])); + } + + /** + * Checks if the button option is set for the custom field. + * + * This function examines the custom field data to determine if the 'add_button' option + * is set and configured to a truthy value. It's used to manage specific behaviors or + * display messages related to the button option in custom fields. + * + * @return bool Returns true if the button option is set and true, otherwise false. + * @since 3.2.0 + */ + private function isButtonOptionSet(): bool + { + // Check if 'own_custom' field is set and if 'add_button' option is available and truthy + if (isset($this->data['custom']['own_custom'], $this->data['custom']['add_button'])) + { + $addButton = $this->data['custom']['add_button']; + return $addButton === 'true' || $addButton === 1; + } + + return false; + } + + /** + * Enqueue error messages related to the dynamic button option in custom fields. + * + * This method adds error messages to the queue when there's an attempt to use the dynamic button + * option in custom field types where it's not supported. It's specifically used in the context of 'own custom' + * field types. + * + * @return void + * @since 3.2.0 + */ + private function setButtonOptionErrorMessages(): void + { + $headerMessage = '

    ' . Text::_('COM_COMPONENTBUILDER_DYNAMIC_BUTTON_ERROR') . '

    '; + $detailMessage = Text::_('COM_COMPONENTBUILDER_THE_OPTION_TO_ADD_A_DYNAMIC_BUTTON_IS_NOT_AVAILABLE_IN_BOWN_CUSTOM_FIELD_TYPESB_YOU_WILL_HAVE_TO_CUSTOM_CODE_IT'); + + $this->app->enqueueMessage($headerMessage, 'Error'); + $this->app->enqueueMessage($detailMessage, 'Error'); + } + + /** + * Prepare the header for a custom field file. + * + * This method sets up the necessary imports and configurations for the header section of a custom field. + * It handles the dynamic setting of comments and import statements based on the field's extension name. + * + * @return void + * @since 3.2.0 + */ + private function prepareCustomFieldHeader(): void + { + // The data set for the custom field + $data = $this->data['custom']; + + // get the default headers + $headers = array_map(function ($h) { + return $this->placeholder->update($h, $this->placeholders); + }, explode( + PHP_EOL, $this->header->get('form.custom.field', $this->baseType) + ) + ); + + if (isset($data['phpHEADER']) && + ArrayHelper::check($data['phpHEADER'])) + { // set tab and break replacements - $tabBreak = array( + $tab_break = array( '\t' => Indent::_(1), '\n' => PHP_EOL ); - // set the [[[PLACEHOLDER]]] options - $replace = array( - Placefix::_('JPREFIX') => $jprefix, - Placefix::_('TABLE') => (isset($data['custom']['table'])) - ? $data['custom']['table'] : '', - Placefix::_('ID') => (isset($data['custom']['id'])) - ? $data['custom']['id'] : '', - Placefix::_('TEXT') => (isset($data['custom']['text'])) - ? $data['custom']['text'] : '', - Placefix::_('CODE_TEXT') => (isset($data['code'], $data['custom']['text'])) - ? $data['code'] . '_' . $data['custom']['text'] : '', - Placefix::_('CODE') => (isset($data['code'])) - ? $data['code'] : '', - Placefix::_('view_type') => $nameSingleCode - . '_' . $data['type'], - Placefix::_('type') => (isset($data['type'])) - ? $data['type'] : '', - Placefix::_('com_component') => (isset($data['custom']['component']) - && StringHelper::check( - $data['custom']['component'] - )) ? StringHelper::safe( - $data['custom']['component'] - ) : 'com_' . $this->config->component_code_name, - // set the generic values - Placefix::_('component') => $this->config->component_code_name, - Placefix::_('Component') => $this->content->get('Component'), - Placefix::_('view') => (isset($data['custom']['view']) - && StringHelper::check( - $data['custom']['view'] - )) ? StringHelper::safe( - $data['custom']['view'] - ) : $nameSingleCode, - Placefix::_('views') => (isset($data['custom']['views']) - && StringHelper::check( - $data['custom']['views'] - )) ? StringHelper::safe( - $data['custom']['views'] - ) : $nameListCode - ); - // now set the ###PLACEHOLDER### options - foreach ($replace as $replacekey => $replacevalue) - { - // update the key value - $replacekey = str_replace( - array(Placefix::b(), Placefix::d()), - array(Placefix::h(), Placefix::h()), $replacekey - ); - // now set the value - $replace[$replacekey] = $replacevalue; - } - // load the global placeholders - foreach ($this->componentplaceholder->get() as $globalPlaceholder => $gloabalValue) - { - $replace[$globalPlaceholder] = $gloabalValue; - } - // start loading the field type - // JPREFIX <<>> - $this->contents->set("{$contents_key}JPREFIX", $jprefix); - // Type <<>> - $this->contents->set("{$contents_key}Type", - StringHelper::safe( - $data['custom']['type'], 'F' - ) - ); - // type <<>> - $this->contents->set("{$contents_key}type", StringHelper::safe($data['custom']['type'])); - // is this a own custom field - if (isset($data['custom']['own_custom'])) + foreach ($data['phpHEADER'] as $line => $code) { - // make sure the button option notice is set to notify the developer that the button option is not available in own custom field types - if (isset($data['custom']['add_button']) - && ($data['custom']['add_button'] === 'true' - || 1 == $data['custom']['add_button'])) + if (StringHelper::check($code)) { - // set error - $this->app->enqueueMessage( - Text::_('COM_COMPONENTBUILDER_HR_HTHREEDYNAMIC_BUTTON_ERRORHTHREE'), 'Error' - ); - $this->app->enqueueMessage( - Text::_('COM_COMPONENTBUILDER_THE_OPTION_TO_ADD_A_DYNAMIC_BUTTON_IS_NOT_AVAILABLE_IN_BOWN_CUSTOM_FIELD_TYPESB_YOU_WILL_HAVE_TO_CUSTOM_CODE_IT'), 'Error' - ); + $h = array_map(function ($h) { + return $this->placeholder->update($h, $this->placeholders); + }, explode(PHP_EOL, $this->placeholder->update( + $code, $tab_break + ))); + + $headers = array_merge($headers, $h); } - // load another file - $target = array('admin' => 'customfield'); - $this->structure->build( - $target, 'fieldcustom', $data['custom']['type'] - ); - // get the extends name - $JFORM_extends = StringHelper::safe( - $data['custom']['extends'] - ); - // JFORM_TYPE_HEADER <<>> - $add_default_header = true; - $this->contents->set("{$contents_key}JFORM_TYPE_HEADER", - "//" . Line::_( - __LINE__,__CLASS__ - ) . " Import the " . $JFORM_extends - . " field type classes needed" - ); - // JFORM_extens <<>> - $this->contents->set("{$contents_key}JFORM_extends", $JFORM_extends - ); - // JFORM_EXTENDS <<>> - $this->contents->set("{$contents_key}JFORM_EXTENDS", - StringHelper::safe( - $data['custom']['extends'], 'F' - ) - ); - // JFORM_TYPE_PHP <<>> - $this->contents->set("{$contents_key}JFORM_TYPE_PHP", - PHP_EOL . PHP_EOL . Indent::_(1) . "//" . Line::_( - __LINE__,__CLASS__ - ) . " A " . $data['custom']['own_custom'] . " Field" - ); - // load the other PHP options - foreach ($this->phpFieldArray as $x) - { - // reset the php bucket - $phpBucket = ''; - // only set if available - if (isset($data['custom']['php' . $x]) - && ArrayHelper::check( - $data['custom']['php' . $x] - )) - { - foreach ($data['custom']['php' . $x] as $line => $code) - { - if (StringHelper::check($code)) - { - $phpBucket .= PHP_EOL . $this->placeholder->update( - $code, $tabBreak - ); - } - } - // check if this is header text - if ('HEADER' === $x) - { - $this->contents->add("{$contents_key}JFORM_TYPE_HEADER", - PHP_EOL . $this->placeholder->update( - $phpBucket, $replace - ), false - ); - // stop default headers from loading - $add_default_header = false; - } - else - { - // JFORM_TYPE_PHP <<>> - $this->contents->add("{$contents_key}JFORM_TYPE_PHP", - PHP_EOL . $this->placeholder->update( - $phpBucket, $replace - ), false - ); - } - } - } - // check if we should add default header - if ($add_default_header) - { - $this->contents->add("{$contents_key}JFORM_TYPE_HEADER", - PHP_EOL . "jimport('joomla.form.helper');", - false - ); - $this->contents->add("{$contents_key}JFORM_TYPE_HEADER", - PHP_EOL . "JFormHelper::loadFieldClass('" . $JFORM_extends . "');", - false - ); - } - // check the the JFormHelper::loadFieldClass(..) was set - elseif (strpos((string) $this->contents->get("{$contents_key}JFORM_TYPE_HEADER"), - 'JFormHelper::loadFieldClass(') === false) - { - $this->contents->add("{$contents_key}JFORM_TYPE_HEADER", - PHP_EOL . "JFormHelper::loadFieldClass('" - . $JFORM_extends . "');", false - ); - } - } - else - { - // first build the custom field type file - $target = array('admin' => 'customfield'); - $this->structure->build( - $target, 'field' . $data['custom']['extends'], - $data['custom']['type'] - ); - // make sure the value is reset - $phpCode = ''; - // now load the php script - if (isset($data['custom']['php']) - && ArrayHelper::check( - $data['custom']['php'] - )) - { - foreach ($data['custom']['php'] as $line => $code) - { - if (StringHelper::check($code)) - { - if ($line == 1) - { - $phpCode .= $this->placeholder->update( - $code, $tabBreak - ); - } - else - { - $phpCode .= PHP_EOL . Indent::_(2) - . $this->placeholder->update($code, $tabBreak); - } - } - } - // replace the placholders - $phpCode = $this->placeholder->update($phpCode, $replace); - } - // catch empty stuff - if (!StringHelper::check($phpCode)) - { - $phpCode = 'return null;'; - } - // some house cleaning for users - if ($data['custom']['extends'] === 'user') - { - // make sure the value is reset - $phpxCode = ''; - // now load the php xclude script - if (ArrayHelper::check( - $data['custom']['phpx'] - )) - { - foreach ($data['custom']['phpx'] as $line => $code) - { - if (StringHelper::check($code)) - { - if ($line == 1) - { - $phpxCode .= $this->placeholder->update( - $code, $tabBreak - ); - } - else - { - $phpxCode .= PHP_EOL . Indent::_(2) - . $this->placeholder->update( - $code, $tabBreak - ); - } - } - } - // replace the placholders - $phpxCode = $this->placeholder->update($phpxCode, $replace); - } - // catch empty stuff - if (!StringHelper::check($phpxCode)) - { - $phpxCode = 'return null;'; - } - // temp holder for name - $tempName = $data['custom']['label'] . ' Group'; - // set lang - $groupLangName = $this->config->lang_prefix . '_' - . FieldHelper::safe( - $tempName, true - ); - // add to lang array - $this->language->set( - $this->config->lang_target, $groupLangName, - StringHelper::safe($tempName, 'W') - ); - // build the Group Control - $this->fieldgroupcontrol->set($data['type'], $groupLangName); - // JFORM_GETGROUPS_PHP <<>> - $this->contents->set("{$contents_key}JFORM_GETGROUPS_PHP", - $phpCode - ); - // JFORM_GETEXCLUDED_PHP <<>> - $this->contents->set("{$contents_key}JFORM_GETEXCLUDED_PHP", - $phpxCode - ); - } - else - { - // JFORM_GETOPTIONS_PHP <<>> - $this->contents->set("{$contents_key}JFORM_GETOPTIONS_PHP", - $phpCode - ); - } - // type <<>> - $this->contents->set("{$contents_key}ADD_BUTTON", - $this->inputbutton->get($data['custom']) - ); } } - // if this field gets used in plug-in or module we should track it so if needed we can copy it over - if ((strpos($nameSingleCode, 'pLuG!n') !== false || strpos($nameSingleCode, 'M0dUl3') !== false) - && isset($data['custom']) - && isset($data['custom']['type'])) + + // Remove duplicate values + $headers = array_unique($headers); + + // add to the content updating engine + $this->contents->set("{$this->contentsKey}FORM_CUSTOM_FIELD_HEADER", + implode(PHP_EOL, $headers) + ); + } + + /** + * Prepare the body for a custom field file. + * + * This method sets up the necessary imports and configurations for the body section of a custom field. + * It handles the dynamic setting of php code. + * + * @return void + * @since 3.2.0 + */ + private function prepareCustomFieldBody(): void + { + // The own custom string value + $own_custom = $this->data['custom']['own_custom'] ?? $this->baseType; + + // reset the body + $body = []; + + // load the other PHP options + foreach ($this->phpFieldArray as $x) { - $this->extensioncustomfields->set($data['type'], $data['custom']['type']); + if (($code = $this->loadPhpScript('php' . $x, null)) !== null) + { + $body[] = $code; + } } + + $php_body = PHP_EOL . PHP_EOL . Indent::_(1) . "//" . + Line::_(__LINE__,__CLASS__) . + " A " . $own_custom . " Field" . PHP_EOL; + + $php_body .= $this->placeholder->update( + implode(PHP_EOL, $body), + $this->placeholders + ); + + // add to the content updating engine + $this->contents->set("{$this->contentsKey}FORM_CUSTOM_FIELD_PHP", $php_body); + } + + /** + * Load and process a PHP script for the custom field. + * + * @param string $scriptType The type of script to load ('php' or 'phpx'). + * @param string|null $default The default if none is found + * + * @return string|null The processed PHP code. + * @since 3.2.0 + */ + private function loadPhpScript(string $scriptType, ?string $default = 'return null;'): ?string + { + $php_code = ''; + + // The data set for the custom field + $data = $this->data['custom']; + + if (isset($data[$scriptType]) && ArrayHelper::check($data[$scriptType])) + { + $tab_break = [ + '\t' => Indent::_(1), + '\n' => PHP_EOL + ]; + + foreach ($data[$scriptType] as $line => $code) + { + if (StringHelper::check($code)) + { + $php_code .= $line == 1 ? $this->placeholder->update($code, $tab_break) + : PHP_EOL . Indent::_(2) . $this->placeholder->update($code, $tab_break); + } + } + + $php_code = $this->placeholder->update($php_code, $this->placeholders); + } + + return StringHelper::check($php_code) ? $php_code : $default; + } + + /** + * Generate a group language name for the custom field. + * + * @return string The generated group language name. + * @since 3.2.0 + */ + private function generateGroupLanguageName(): string + { + $label = $this->data['custom']['label'] ?? '(error: label not set)'; + $temp_name = $label . ' Group'; + $group_lang_name = $this->config->lang_prefix . '_' . FieldHelper::safe($temp_name, true); + + $this->language->set( + $this->config->lang_target, + $group_lang_name, + StringHelper::safe($temp_name, 'W') + ); + + return $group_lang_name; + } + + /** + * Tracks extension custom fields for plugins or modules. + * + * This method is used to track custom fields when they are utilized in plugins or modules. + * If the field is used in a plugin or module, it records this information, potentially to facilitate + * actions like copying the field over to other parts of the system. + * + * @return void + * @since 3.2.0 + */ + private function trackExtensionCustomFields(): void + { + if ($this->isUsedInPluginOrModule() && $this->customTypeWasSet) + { + $this->extensioncustomfields->set($this->type, $this->baseType); + } + } + + /** + * Determines if the field is used in a plugin or module. + * + * @return bool Returns true if the field is used in a plugin or module, false otherwise. + * @since 3.2.0 + */ + private function isUsedInPluginOrModule(): bool + { + return strpos($this->nameSingleCode, 'pLuG!n') !== false || strpos($this->nameSingleCode, 'M0dUl3') !== false; } } diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/FieldsetString.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/FieldsetString.php index 270627e53..3076bac33 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/FieldsetString.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/FieldsetString.php @@ -231,18 +231,16 @@ final class FieldsetString implements Fieldsetinterface $dynamic_fields = ''; // set the custom table key $dbkey = 'g'; - // for plugin event TODO change event api signatures - $placeholders = $this->placeholder->active; - $component_context = $this->config->component_context; + // Trigger Event: jcb_ce_onBeforeBuildFields $this->event->trigger( 'jcb_ce_onBeforeBuildFields', - array(&$component_context, &$dynamic_fields, &$read_only, + [&$dynamic_fields, &$read_only, &$dbkey, &$view, &$component, &$nameSingleCode, - &$nameListCode, &$placeholders, &$lang_view, - &$lang_views) + &$nameListCode, &$lang_view, + &$lang_views] ); - unset($placeholders); + // TODO we should add the global and local view switch if field for front end foreach ($view['settings']->fields as $field) { @@ -252,17 +250,16 @@ final class FieldsetString implements Fieldsetinterface true ); } - // for plugin event TODO change event api signatures - $placeholders = $this->placeholder->active; + // Trigger Event: jcb_ce_onAfterBuildFields $this->event->trigger( 'jcb_ce_onAfterBuildFields', - array(&$component_context, &$dynamic_fields, &$read_only, + [&$dynamic_fields, &$read_only, &$dbkey, &$view, &$component, &$nameSingleCode, - &$nameListCode, &$placeholders, &$lang_view, - &$lang_views) + &$nameListCode, &$lang_view, + &$lang_views] ); - unset($placeholders); + // set the default fields $field_set = array(); $field_set[] = '
    '; @@ -444,6 +441,7 @@ final class FieldsetString implements Fieldsetinterface $field_set[] = Indent::_(3) . 'description="' . $lang_view . '_VERSION_DESC"'; $field_set[] = Indent::_(3) . 'size="6"'; + $field_set[] = Indent::_(3) . 'default="1"'; $field_set[] = Indent::_(3) . 'readonly="true"'; $field_set[] = Indent::_(3) . 'filter="unset"'; $field_set[] = Indent::_(2) . "/>"; diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/FieldsetXML.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/FieldsetXML.php index 4e5292c67..72eaaa8c7 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/FieldsetXML.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/FieldsetXML.php @@ -239,18 +239,16 @@ final class FieldsetXML implements Fieldsetinterface $dynamic_fields_xml = []; // set the custom table key $dbkey = 'g'; - // for plugin event TODO change event api signatures - $placeholders = $this->placeholder->active; - $component_context = $this->config->component_context; + // Trigger Event: jcb_ce_onBeforeBuildFields $this->event->trigger( 'jcb_ce_onBeforeBuildFields', - array(&$component_context, &$dynamic_fields_xml, &$read_only_xml, + [&$dynamic_fields_xml, &$read_only_xml, &$dbkey, &$view, &$component, &$nameSingleCode, - &$nameListCode, &$placeholders, &$lang_view, - &$lang_views) + &$nameListCode, &$lang_view, + &$lang_views] ); - unset($placeholders); + // TODO we should add the global and local view switch if field for front end foreach ($view['settings']->fields as $field) { @@ -260,17 +258,16 @@ final class FieldsetXML implements Fieldsetinterface true ); } - // for plugin event TODO change event api signatures - $placeholders = $this->placeholder->active; + // Trigger Event: jcb_ce_onAfterBuildFields $this->event->trigger( 'jcb_ce_onAfterBuildFields', - array(&$component_context, &$dynamic_fields_xml, &$read_only_xml, + [&$dynamic_fields_xml, &$read_only_xml, &$dbkey, &$view, &$component, &$nameSingleCode, - &$nameListCode, &$placeholders, &$lang_view, - &$lang_views) + &$nameListCode, &$lang_view, + &$lang_views] ); - unset($placeholders); + // set the default fields $main_xml = new \simpleXMLElement(''); $field_set_xml = $main_xml->addChild('fieldset'); @@ -466,6 +463,7 @@ final class FieldsetXML implements Fieldsetinterface 'label' => $lang_view . '_VERSION_LABEL', 'description' => $lang_view . '_VERSION_DESC', 'size' => 6, + 'default' => 1, 'readonly' => "true", 'filter' => 'unset' ]; diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/Request.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/Request.php new file mode 100644 index 000000000..7ec05eeaa --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/Request.php @@ -0,0 +1,79 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Creator; + + +use VDM\Joomla\Componentbuilder\Compiler\Builder\Request as RequestBuilder; +use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Utilities\StringHelper; + + +/** + * Request Creator Class + * + * @since 3.2.0 + */ +final class Request +{ + /** + * The Request Class. + * + * @var RequestBuilder + * @since 3.2.0 + */ + protected RequestBuilder $requestbuilder; + + /** + * Constructor. + * + * @param RequestBuilder $requestbuilder The Request Class. + * + * @since 3.2.0 + */ + public function __construct(RequestBuilder $requestbuilder) + { + $this->requestbuilder = $requestbuilder; + } + + /** + * Set the request values + * + * @param string $view + * @param string $field + * @param string $search + * @param string $target + * + * @since 3.2.0 + */ + public function set(string $view, string $field, string $search, string $target): void + { + $key = GetHelper::between($field, $search, '"'); + if (!StringHelper::check($key)) + { + // is not having special var + $key = $target; + // update field + $field = str_replace($search . '"', 'name="' . $key . '"', (string) $field); + } + else + { + // update field + $field = str_replace( + $search . $key . '"', 'name="' . $key . '"', (string) $field + ); + } + + // set the values needed for view requests to be made + $this->requestbuilder->set("$target.$view.$key", $field); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/Router.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/Router.php new file mode 100644 index 000000000..eeddd6349 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/Router.php @@ -0,0 +1,263 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Creator; + + +use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Request; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Router as Builder; +use VDM\Joomla\Componentbuilder\Compiler\Creator\RouterConstructorDefault as DefaultConstructor; +use VDM\Joomla\Componentbuilder\Compiler\Creator\RouterConstructorManual as ManualConstructor; +use VDM\Joomla\Componentbuilder\Compiler\Creator\RouterMethodsDefault as DefaultMethods; +use VDM\Joomla\Componentbuilder\Compiler\Creator\RouterMethodsManual as ManualMethods; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + + +/** + * Router Creator Class + * + * @since 3.2.0 + */ +final class Router +{ + /** + * The Dispenser Class. + * + * @var Dispenser + * @since 3.2.0 + */ + protected Dispenser $dispenser; + + /** + * The Request Class. + * + * @var Request + * @since 3.2.0 + */ + protected Request $request; + + /** + * The Router Class. + * + * @var Builder + * @since 3.2.0 + */ + protected Builder $builder; + + /** + * The RouterConstructorDefault Class. + * + * @var DefaultConstructor + * @since 3.2.0 + */ + protected DefaultConstructor $defaultconstructor; + + /** + * The RouterConstructorManual Class. + * + * @var ManualConstructor + * @since 3.2.0 + */ + protected ManualConstructor $manualconstructor; + + /** + * The RouterMethodsDefault Class. + * + * @var DefaultMethods + * @since 3.2.0 + */ + protected DefaultMethods $defaultmethods; + + /** + * The RouterMethodsManual Class. + * + * @var ManualMethods + * @since 3.2.0 + */ + protected ManualMethods $manualmethods; + + /** + * The Router Build Mode Before Parent Construct. + * + * @var int|null + * @since 3.2.0 + */ + protected ?int $mode_before = null; + + /** + * The Router Build Mode Methods. + * + * @var int|null + * @since 3.2.0 + */ + protected ?int $mode_method = null; + + /** + * Constructor. + * + * @param Dispenser $dispenser The Dispenser Class. + * @param Request $request The Request Class. + * @param Builder $builder The Router Class. + * @param DefaultConstructor $defaultconstructor The RouterConstructorDefault Class. + * @param ManualConstructor $manualconstructor The RouterConstructorManual Class. + * @param DefaultMethods $defaultmethods The RouterMethodsDefault Class. + * @param ManualMethods $manualmethods The RouterMethodsManual Class. + * + * @since 3.2.0 + */ + public function __construct(Dispenser $dispenser, Request $request, + Builder $builder, DefaultConstructor $defaultconstructor, + ManualConstructor $manualconstructor, + DefaultMethods $defaultmethods, + ManualMethods $manualmethods) + { + $this->dispenser = $dispenser; + $this->request = $request; + $this->builder = $builder; + $this->defaultconstructor = $defaultconstructor; + $this->manualconstructor = $manualconstructor; + $this->defaultmethods = $defaultmethods; + $this->manualmethods = $manualmethods; + } + + /** + * Get Constructor Before Parent Call + * + * @return string + * @since 3.2.0 + */ + public function getConstructor(): string + { + $this->init(); + + if ($this->mode_before == 3) + { + return $this->dispenser->get( + '_site_router_', 'constructor_before_parent', + PHP_EOL . PHP_EOL, null, true + ); + } + + if ($this->mode_before == 2) + { + return $this->manualconstructor->get(); + } + + return $this->defaultconstructor->get(); + } + + /** + * Get Constructor After Parent Call + * + * @return string + * @since 3.2.0 + */ + public function getConstructorAfterParent(): string + { + return $this->dispenser->get( + '_site_router_', 'constructor_after_parent', + PHP_EOL . PHP_EOL, null, true + ); + } + + /** + * Get Methods + * + * @return string + * @since 3.2.0 + */ + public function getMethods(): string + { + $this->init(); + + if ($this->mode_method == 0) + { + return ''; + } + + if ($this->mode_method == 3) + { + return $this->dispenser->get( + '_site_router_', 'methods', + PHP_EOL . PHP_EOL, null, true + ); + } + + if ($this->mode_before == 2 && $this->mode_method == 1) + { + return $this->manualmethods->get(); + } + + if ($this->mode_method == 1) + { + return $this->defaultmethods->get(); + } + + return ''; + } + + /** + * Get Constructor Before Parent Call + * + * @return void + * @since 3.2.0 + */ + private function init(): void + { + if ($this->mode_before === null) + { + $this->mode_before = (int) $this->builder->get('mode_before', 0); + $this->mode_method = (int) $this->builder->get('mode_method', 0); + + $this->updateKeys(); + } + } + + /** + * Update the keys + * + * @return void + * @since 3.2.0 + */ + private function updateKeys(): void + { + if (($requests = $this->request->allActive()) === [] || + ($views = $this->builder->get('views')) === null) + { + return; + } + + foreach ($views as &$router) + { + // if the key is null, and not 'id' + // then we must not update it + // since this is a list view and + // should not add an ID as key value + if ($router->key === 'id') + { + foreach ($requests as $key => $request) + { + if (isset($request[$router->view])) + { + $router->key = $key; + } + } + } + } + + unset($router); + + $this->request->set('views', $views); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/RouterConstructorDefault.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/RouterConstructorDefault.php new file mode 100644 index 000000000..709fc9e20 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/RouterConstructorDefault.php @@ -0,0 +1,77 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Creator; + + +use VDM\Joomla\Componentbuilder\Compiler\Builder\Router; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; + + +/** + * Router Constructor Default Creator Class + * + * @since 3.2.0 + */ +final class RouterConstructorDefault +{ + /** + * The Router Class. + * + * @var Router + * @since 3.2.0 + */ + protected Router $router; + + /** + * Constructor. + * + * @param Router $router The Router Class. + * + * @since 3.2.0 + */ + public function __construct(Router $router) + { + $this->router = $router; + } + + /** + * Get Construct Code + * + * @return string + * @since 3.2.0 + */ + public function get(): string + { + $views = $this->router->get('views'); + if ($views !== null) + { + $code = []; + foreach ($views as $view) + { + $code[] = ''; + $code[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Add the ({$view->view}:view) router configuration"; + $code[] = Indent::_(2) . "\${$view->view} = new RouterViewConfiguration('{$view->view}');"; + // add key only if we have one see: ...Compiler\Creator\Router->updateKeys(); + if (!empty($view->key) && !empty($view->alias)) + { + $code[] = Indent::_(2) . "\${$view->view}->setKey('{$view->key}');"; + } + $code[] = Indent::_(2) . "\$this->registerView(\${$view->view});"; + } + return PHP_EOL . implode(PHP_EOL, $code); + } + return ''; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/RouterConstructorManual.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/RouterConstructorManual.php new file mode 100644 index 000000000..e2a47a02f --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/RouterConstructorManual.php @@ -0,0 +1,77 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Creator; + + +use VDM\Joomla\Componentbuilder\Compiler\Builder\Router; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; + + +/** + * Router Constructor Default Creator Class + * + * @since 3.2.0 + */ +final class RouterConstructorManual +{ + /** + * The Router Class. + * + * @var Router + * @since 3.2.0 + */ + protected Router $router; + + /** + * Constructor. + * + * @param Router $router The Router Class. + * + * @since 3.2.0 + */ + public function __construct(Router $router) + { + $this->router = $router; + } + + /** + * Get Construct Code (SOON) + * + * @return string + * @since 3.2.0 + */ + public function get(): string + { + $views = $this->router->get('views'); + if ($views !== null) + { + $code = []; + foreach ($views as $view) + { + $code[] = ''; + $code[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Add the ({$view->view}:view) router configuration"; + $code[] = Indent::_(2) . "\${$view->view} = new RouterViewConfiguration('{$view->view}');"; + // add key only if we have one see: ...Compiler\Creator\Router->updateKeys(); + if (!empty($view->key) && !empty($view->alias)) + { + $code[] = Indent::_(2) . "\${$view->view}->setKey('{$view->key}');"; + } + $code[] = Indent::_(2) . "\$this->registerView(\${$view->view});"; + } + return PHP_EOL . implode(PHP_EOL, $code); + } + return ''; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/RouterMethodsDefault.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/RouterMethodsDefault.php new file mode 100644 index 000000000..59ec6e36e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/RouterMethodsDefault.php @@ -0,0 +1,137 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Creator; + + +use VDM\Joomla\Componentbuilder\Compiler\Builder\Router; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; + + +/** + * Router Methods Default Creator Class + * + * @since 3.2.0 + */ +final class RouterMethodsDefault +{ + /** + * The Router Class. + * + * @var Router + * @since 3.2.0 + */ + protected Router $router; + + /** + * Constructor. + * + * @param Router $router The Router Class. + * + * @since 3.2.0 + */ + public function __construct(Router $router) + { + $this->router = $router; + } + + /** + * Get Methods Code + * + * @return string + * @since 3.2.0 + */ + public function get(): string + { + $views = $this->router->get('views'); + if ($views !== null) + { + $code = []; + foreach ($views as $view) + { + // we only add these if we can get an ID (int) value + // else you will need to use the manual or customcode options + if (empty($view->key) || empty($view->alias)) + { + continue; + } + $code[] = ''; + $code[] = Indent::_(1) . "/**"; + $code[] = Indent::_(1) . " * Method to get the segment(s) for {$view->view}"; + $code[] = Indent::_(1) . " *"; + $code[] = Indent::_(1) . " * @param string \$segment Segment of the article to retrieve the ID for"; + $code[] = Indent::_(1) . " * @param array \$query The request that is parsed right now"; + $code[] = Indent::_(1) . " *"; + $code[] = Indent::_(1) . " * @return mixed The {$view->key} of this item or false"; + $code[] = Indent::_(1) . " * @since 4.4.0"; + $code[] = Indent::_(1) . " */"; + $code[] = Indent::_(1) . "public function get{$view->View}Id(\$segment, \$query)"; + $code[] = Indent::_(1) . "{"; + $code[] = Indent::_(2) . "if (\$this->noIDs)"; + $code[] = Indent::_(2) . "{"; + $code[] = Indent::_(3) . "\$dbquery = \$this->db->getQuery(true);"; + $code[] = Indent::_(3) . "\$dbquery->select(\$this->db->quoteName('{$view->key}'))"; + $code[] = Indent::_(4) . "->from(\$this->db->quoteName('{$view->table}'))"; + $code[] = Indent::_(4) . "->where("; + $code[] = Indent::_(5) . "["; + $code[] = Indent::_(6) . "\$this->db->quoteName('{$view->alias}') . ' = :alias'"; + $code[] = Indent::_(5) . "]"; + $code[] = Indent::_(4) . ")"; + $code[] = Indent::_(4) . "->bind(':alias', \$segment);"; + $code[] = Indent::_(3) . "\$this->db->setQuery(\$dbquery);"; + $code[] = ''; + $code[] = Indent::_(3) . "return (int) \$this->db->loadResult();"; + $code[] = Indent::_(2) . "}"; + $code[] = ''; + $code[] = Indent::_(2) . "return (int) \$segment;"; + $code[] = Indent::_(1) . "}"; + $code[] = ''; + $code[] = Indent::_(1) . "/**"; + $code[] = Indent::_(1) . " * Method to get the segment(s) for {$view->view}"; + $code[] = Indent::_(1) . " *"; + $code[] = Indent::_(1) . " * @param string \$id ID of the contact to retrieve the segments for"; + $code[] = Indent::_(1) . " * @param array \$query The request that is built right now"; + $code[] = Indent::_(1) . " *"; + $code[] = Indent::_(1) . " * @return array|string The segments of this item"; + $code[] = Indent::_(1) . " * @since 4.4.0"; + $code[] = Indent::_(1) . " */"; + $code[] = Indent::_(1) . "public function get{$view->View}Segment(\$id, \$query)"; + $code[] = Indent::_(1) . "{"; + $code[] = Indent::_(2) . "if (strpos(\$id, ':') === false)"; + $code[] = Indent::_(2) . "{"; + $code[] = Indent::_(3) . "\$id = (int) \$id;"; + $code[] = Indent::_(3) . "\$dbquery = \$this->db->getQuery(true);"; + $code[] = Indent::_(3) . "\$dbquery->select(\$this->db->quoteName('{$view->alias}'))"; + $code[] = Indent::_(4) . "->from(\$this->db->quoteName('{$view->table}'))"; + $code[] = Indent::_(4) . "->where(\$this->db->quoteName('{$view->key}') . ' = :id')"; + $code[] = Indent::_(4) . "->bind(':id', \$id, ParameterType::INTEGER);"; + $code[] = Indent::_(3) . "\$this->db->setQuery(\$dbquery);"; + $code[] = ''; + $code[] = Indent::_(3) . "\$id .= ':' . \$this->db->loadResult();"; + $code[] = Indent::_(2) . "}"; + $code[] = ''; + $code[] = Indent::_(2) . "if (\$this->noIDs)"; + $code[] = Indent::_(2) . "{"; + $code[] = Indent::_(3) . "list(\$void, \$segment) = explode(':', \$id, 2);"; + $code[] = ''; + $code[] = Indent::_(3) . "return [\$void => \$segment];"; + $code[] = Indent::_(2) . "}"; + $code[] = ''; + $code[] = Indent::_(2) . "return [(int) \$id => \$id];"; + $code[] = Indent::_(1) . "}"; + } + return PHP_EOL . implode(PHP_EOL, $code); + } + return ''; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/RouterMethodsManual.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/RouterMethodsManual.php new file mode 100644 index 000000000..c36271f14 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Creator/RouterMethodsManual.php @@ -0,0 +1,137 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Creator; + + +use VDM\Joomla\Componentbuilder\Compiler\Builder\Router; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; + + +/** + * Router Methods Manual Creator Class + * + * @since 3.2.0 + */ +final class RouterMethodsManual +{ + /** + * The Router Class. + * + * @var Router + * @since 3.2.0 + */ + protected Router $router; + + /** + * Constructor. + * + * @param Router $router The Router Class. + * + * @since 3.2.0 + */ + public function __construct(Router $router) + { + $this->router = $router; + } + + /** + * Get Methods Code (SOON) + * + * @return string + * @since 3.2.0 + */ + public function get(): string + { + $views = $this->router->get('views'); + if ($views !== null) + { + $code = []; + foreach ($views as $view) + { + // we only add these if we can get an ID (int) value + // else you will need to use the manual or customcode options + if (empty($view->key) || empty($view->alias)) + { + continue; + } + $code[] = ''; + $code[] = Indent::_(1) . "/**"; + $code[] = Indent::_(1) . " * Method to get the segment(s) for an {$view->view}"; + $code[] = Indent::_(1) . " *"; + $code[] = Indent::_(1) . " * @param string \$segment Segment of the article to retrieve the ID for"; + $code[] = Indent::_(1) . " * @param array \$query The request that is parsed right now"; + $code[] = Indent::_(1) . " *"; + $code[] = Indent::_(1) . " * @return mixed The {$view->key} of this item or false"; + $code[] = Indent::_(1) . " * @since 4.4.0"; + $code[] = Indent::_(1) . " */"; + $code[] = Indent::_(1) . "public function get{$view->View}Id(\$segment, \$query)"; + $code[] = Indent::_(1) . "{"; + $code[] = Indent::_(2) . "if (\$this->noIDs)"; + $code[] = Indent::_(2) . "{"; + $code[] = Indent::_(3) . "\$dbquery = \$this->db->getQuery(true);"; + $code[] = Indent::_(3) . "\$dbquery->select(\$this->db->quoteName('{$view->key}'))"; + $code[] = Indent::_(4) . "->from(\$this->db->quoteName('{$view->table}'))"; + $code[] = Indent::_(4) . "->where("; + $code[] = Indent::_(5) . "["; + $code[] = Indent::_(6) . "\$this->db->quoteName('{$view->alias}') . ' = :alias'"; + $code[] = Indent::_(5) . "]"; + $code[] = Indent::_(4) . ")"; + $code[] = Indent::_(4) . "->bind(':alias', \$segment);"; + $code[] = Indent::_(3) . "\$this->db->setQuery(\$dbquery);"; + $code[] = ''; + $code[] = Indent::_(3) . "return (int) \$this->db->loadResult();"; + $code[] = Indent::_(2) . "}"; + $code[] = ''; + $code[] = Indent::_(2) . "return (int) \$segment;"; + $code[] = Indent::_(1) . "}"; + $code[] = ''; + $code[] = Indent::_(1) . "/**"; + $code[] = Indent::_(1) . " * Method to get the segment(s) for a {$view->view}"; + $code[] = Indent::_(1) . " *"; + $code[] = Indent::_(1) . " * @param string \$id ID of the contact to retrieve the segments for"; + $code[] = Indent::_(1) . " * @param array \$query The request that is built right now"; + $code[] = Indent::_(1) . " *"; + $code[] = Indent::_(1) . " * @return array|string The segments of this item"; + $code[] = Indent::_(1) . " * @since 4.4.0"; + $code[] = Indent::_(1) . " */"; + $code[] = Indent::_(1) . "public function get{$view->View}Segment(\$id, \$query)"; + $code[] = Indent::_(1) . "{"; + $code[] = Indent::_(2) . "if (strpos(\$id, ':') === false)"; + $code[] = Indent::_(2) . "{"; + $code[] = Indent::_(3) . "\$id = (int) \$id;"; + $code[] = Indent::_(3) . "\$dbquery = \$this->db->getQuery(true);"; + $code[] = Indent::_(3) . "\$dbquery->select(\$this->db->quoteName('{$view->alias}'))"; + $code[] = Indent::_(4) . "->from(\$this->db->quoteName('{$view->table}'))"; + $code[] = Indent::_(4) . "->where(\$this->db->quoteName('{$view->key}') . ' = :id')"; + $code[] = Indent::_(4) . "->bind(':id', \$id, ParameterType::INTEGER);"; + $code[] = Indent::_(3) . "\$this->db->setQuery(\$dbquery);"; + $code[] = ''; + $code[] = Indent::_(3) . "\$id .= ':' . \$this->db->loadResult();"; + $code[] = Indent::_(2) . "}"; + $code[] = ''; + $code[] = Indent::_(2) . "if (\$this->noIDs)"; + $code[] = Indent::_(2) . "{"; + $code[] = Indent::_(3) . "list(\$void, \$segment) = explode(':', \$id, 2);"; + $code[] = ''; + $code[] = Indent::_(3) . "return [\$void => \$segment];"; + $code[] = Indent::_(2) . "}"; + $code[] = ''; + $code[] = Indent::_(2) . "return [(int) \$id => \$id];"; + $code[] = Indent::_(1) . "}"; + } + return PHP_EOL . implode(PHP_EOL, $code); + } + return ''; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode.php index 54510fd05..d6d21a4cd 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode.php @@ -13,9 +13,6 @@ namespace VDM\Joomla\Componentbuilder\Compiler; use Joomla\CMS\Factory; -use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\StringHelper; -use VDM\Joomla\Utilities\GetHelper; use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; use VDM\Joomla\Componentbuilder\Compiler\Config; use VDM\Joomla\Componentbuilder\Compiler\Placeholder; @@ -23,6 +20,9 @@ use VDM\Joomla\Componentbuilder\Compiler\Language\Extractor; use VDM\Joomla\Componentbuilder\Compiler\Power\Extractor as Power; use VDM\Joomla\Componentbuilder\Compiler\Customcode\External; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\GetHelper; use VDM\Joomla\Componentbuilder\Compiler\Interfaces\CustomcodeInterface; @@ -122,7 +122,6 @@ class Customcode implements CustomcodeInterface /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 **/ protected $db; @@ -140,14 +139,14 @@ class Customcode implements CustomcodeInterface * @since 3.2.0 */ public function __construct(?Config $config = null, ?Placeholder $placeholder = null, - ?Extractor $extractor = null, ?Power $power = null, ?External $external = null, ?\JDatabaseDriver $db = null) + ?Extractor $extractor = null, ?Power $power = null, ?External $external = null) { $this->config = $config ?: Compiler::_('Config'); $this->placeholder = $placeholder ?: Compiler::_('Placeholder'); $this->extractor = $extractor ?: Compiler::_('Language.Extractor'); $this->power = $power ?: Compiler::_('Power.Extractor'); $this->external = $external ?: Compiler::_('Customcode.External'); - $this->db = $db ?: Factory::getDbo(); + $this->db = Factory::getDbo(); } /** @@ -423,6 +422,10 @@ class Customcode implements CustomcodeInterface $query->where( $this->db->quoteName('a.target') . ' = 1' ); // <--- to load the correct target + $query->where( + $this->db->quoteName('a.joomla_version') . ' = ' + . (int) $this->config->get('joomla_version', 3) + ); // <--- to load the correct joomla target $query->order( $this->db->quoteName('a.from_line') . ' ASC' ); // <--- insure we always add code from top of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Dispenser.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Dispenser.php index 5e0b85de2..ed919e284 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Dispenser.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Dispenser.php @@ -196,9 +196,7 @@ class Dispenser implements DispenserInterface $script .= $note; } // load the actual script - $script .= $prefix . str_replace( - array_keys($this->placeholder->active), - array_values($this->placeholder->active), + $script .= $prefix . $this->placeholder->update_( (string) $this->hub[$first][$second] ) . $suffix; // clear some memory diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/External.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/External.php index 1b8acfc19..c3d677299 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/External.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/External.php @@ -60,45 +60,38 @@ class External implements ExternalInterface /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 **/ - protected \JDatabaseDriver $db; + protected $db; /** * User object * - * @var User * @since 3.2.0 **/ - protected User $user; + protected $user; /** * Database object to query local DB * - * @var CMSApplication * @since 3.2.0 **/ - protected CMSApplication $app; + protected $app; /** * Constructor. * * @param Placeholder|null $placeholder The compiler placeholder object. - * @param \JDatabaseDriver|null $db The Database Driver object. - * @param User|null $user The User object. - * @param CMSApplication|null $app The CMS Application object. * * @throws \Exception * @since 3.2.0 */ - public function __construct(?Placeholder $placeholder = null, - ?\JDatabaseDriver $db = null, ?User $user = null, ?CMSApplication $app = null) + public function __construct(?Placeholder $placeholder = null) { $this->placeholder = $placeholder ?: Compiler::_('Placeholder'); - $this->db = $db ?: Factory::getDbo(); - $this->user = $user ?: Factory::getUser(); - $this->app = $app ?: Factory::getApplication(); + $this->db = Factory::getDbo(); + $this->user = Factory::getUser(); + $this->app = Factory::getApplication(); } /** diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Extractor.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Extractor.php index bc52c6801..0ef7008dd 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Extractor.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Extractor.php @@ -16,7 +16,8 @@ use Joomla\CMS\Factory; use Joomla\CMS\User\User; use Joomla\CMS\Filesystem\Folder; use Joomla\CMS\Application\CMSApplication; -use Joomla\CMS\Language\Text; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Version; use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Utilities\StringHelper; use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; @@ -83,6 +84,14 @@ class Extractor implements ExtractorInterface 4 => 'INSERTED<>$$$$]' ]; + /** + * Current Joomla Version We are IN + * + * @var int + * @since 3.2.0 + **/ + protected int $currentVersion; + /** * The custom code in local files that already exist in system * @@ -190,26 +199,23 @@ class Extractor implements ExtractorInterface /** * Current User Object * - * @var User * @since 3.2.0 **/ - protected User $user; + protected $user; /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 **/ - protected \JDatabaseDriver $db; + protected $db; /** * Database object to query local DB * - * @var CMSApplication * @since 3.2.0 **/ - protected CMSApplication $app; + protected $app; /** * Constructor. @@ -220,16 +226,12 @@ class Extractor implements ExtractorInterface * @param Reverse|null $reverse The compiler placeholder reverse object. * @param Placeholder|null $placeholder The compiler component placeholder object. * @param Pathfix|null $pathfix The compiler path fixing object. - * @param User|null $user The current User object. - * @param \JDatabaseDriver|null $db The Database Driver object. - * @param CMSApplication|null $app The CMS Application object. * * @throws \Exception * @since 3.2.0 */ public function __construct(?Config $config = null, ?Gui $gui = null, ?Paths $paths = null, - ?Reverse $reverse = null, ?Placeholder $placeholder = null, ?Pathfix $pathfix = null, - ?User $user = null, ?\JDatabaseDriver $db = null, ?CMSApplication $app = null) + ?Reverse $reverse = null, ?Placeholder $placeholder = null, ?Pathfix $pathfix = null) { $this->config = $config ?: Compiler::_('Config'); $this->gui = $gui ?: Compiler::_('Customcode.Gui'); @@ -237,9 +239,9 @@ class Extractor implements ExtractorInterface $this->reverse = $reverse ?: Compiler::_('Placeholder.Reverse'); $this->componentPlaceholder = $placeholder ?: Compiler::_('Component.Placeholder'); $this->pathfix = $pathfix ?: Compiler::_('Utilities.Pathfix'); - $this->user = $user ?: Factory::getUser(); - $this->db = $db ?: Factory::getDbo(); - $this->app = $app ?: Factory::getApplication(); + $this->user = Factory::getUser(); + $this->db = Factory::getDbo(); + $this->app = Factory::getApplication(); // set today's date $this->today = Factory::getDate()->toSql(); @@ -261,6 +263,9 @@ class Extractor implements ExtractorInterface // set the local placeholders $this->placeholders = array_reverse($placeholders, true); + + // set the current version + $this->currentVersion = (int) Version::MAJOR_VERSION; } /** @@ -613,6 +618,11 @@ class Extractor implements ExtractorInterface 1 ); // 'target' + $this->new[$pointer[$targetKey]][] + = $this->db->quote( + $this->currentVersion + ); // 'joomla_version' + $this->new[$pointer[$targetKey]][] = $this->db->quote( $commentType @@ -766,7 +776,7 @@ class Extractor implements ExtractorInterface $query = $this->db->getQuery(true); $continue = false; // Insert columns. - $columns = array('path', 'type', 'target', 'comment_type', + $columns = array('path', 'type', 'target', 'joomla_version', 'comment_type', 'component', 'published', 'created', 'created_by', 'version', 'access', 'hashtarget', 'from_line', 'to_line', 'code', 'hashendtarget'); diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Extractor/Paths.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Extractor/Paths.php index f4eac22b1..ed873b066 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Extractor/Paths.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Extractor/Paths.php @@ -84,10 +84,9 @@ class Paths /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 **/ - protected \JDatabaseDriver $db; + protected $db; /** * Constructor. @@ -97,14 +96,13 @@ class Paths * @param ComponentPlaceholder|null $componentPlaceholder The compiler component placeholder object. * @param Customcode|null $customcode The compiler customcode object. * @param Extractor|null $extractor The compiler language extractor object. - * @param \JDatabaseDriver|null $db The Database Driver object. * * @throws \Exception * @since 3.2.0 */ public function __construct(?Config $config = null, ?Placeholder $placeholder = null, ?ComponentPlaceholder $componentPlaceholder = null, ?Customcode $customcode = null, - ?Extractor $extractor = null, ?\JDatabaseDriver $db = null) + ?Extractor $extractor = null) { $this->config = $config ?: Compiler::_('Config'); $this->placeholder = $placeholder ?: Compiler::_('Placeholder'); @@ -112,7 +110,7 @@ class Paths $componentPlaceholder = $componentPlaceholder ?: Compiler::_('Component.Placeholder'); $this->customcode = $customcode ?: Compiler::_('Customcode'); $this->extractor = $extractor ?: Compiler::_('Language.Extractor'); - $this->db = $db ?: Factory::getDbo(); + $this->db = Factory::getDbo(); // load the placeholders to local array $this->componentPlaceholder = $componentPlaceholder->get(); diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Gui.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Gui.php index 36553af87..93982514f 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Gui.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customcode/Gui.php @@ -61,18 +61,16 @@ class Gui implements GuiInterface /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 **/ - protected \JDatabaseDriver $db; + protected $db; /** * Database object to query local DB * - * @var CMSApplication * @since 3.2.0 **/ - protected CMSApplication $app; + protected $app; /** * Constructor. @@ -80,20 +78,17 @@ class Gui implements GuiInterface * @param Config|null $config The compiler config object. * @param Reverse|null $reverse The compiler placeholder reverse object. * @param Parser|null $parser The powers parser object. - * @param \JDatabaseDriver|null $db The Database Driver object. - * @param CMSApplication|null $app The CMS Application object. * * @throws \Exception * @since 3.2.0 */ - public function __construct(?Config $config = null, ?Reverse $reverse = null, ?Parser $parser = null, - ?\JDatabaseDriver $db = null, ?CMSApplication $app = null) + public function __construct(?Config $config = null, ?Reverse $reverse = null, ?Parser $parser = null) { $this->config = $config ?: Compiler::_('Config'); $this->reverse = $reverse ?: Compiler::_('Placeholder.Reverse'); $this->parser = $parser ?: Compiler::_('Power.Parser'); - $this->db = $db ?: Factory::getDbo(); - $this->app = $app ?: Factory::getApplication(); + $this->db = Factory::getDbo(); + $this->app = Factory::getApplication(); } /** diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customview/Data.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customview/Data.php index 709581696..f3ac65786 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customview/Data.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Customview/Data.php @@ -155,10 +155,9 @@ class Data /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 **/ - protected \JDatabaseDriver $db; + protected $db; /** * Constructor @@ -176,7 +175,6 @@ class Data * @param Phpcustomview|null $php The modelling php admin view object. * @param Ajaxcustomview|null $ajax The modelling ajax object. * @param Custombuttons|null $custombuttons The modelling custombuttons object. - * @param \JDatabaseDriver|null $db The database object. * * @since 3.2.0 */ @@ -184,7 +182,7 @@ class Data ?Customcode $customcode = null, ?Gui $gui = null, ?Libraries $libraries = null, ?Templatelayout $templateLayout = null, ?Dynamicget $dynamic = null, ?Loader $loader = null, ?Javascriptcustomview $javascript = null, ?Csscustomview $css = null, ?Phpcustomview $php = null, - ?Ajaxcustomview $ajax = null, ?Custombuttons $custombuttons = null, ?\JDatabaseDriver $db = null) + ?Ajaxcustomview $ajax = null, ?Custombuttons $custombuttons = null) { $this->config = $config ?: Compiler::_('Config'); $this->event = $event ?: Compiler::_('Event'); @@ -199,7 +197,7 @@ class Data $this->php = $php ?: Compiler::_('Model.Phpcustomview'); $this->ajax = $ajax ?: Compiler::_('Model.Ajaxcustomview'); $this->custombuttons = $custombuttons ?: Compiler::_('Model.Custombuttons'); - $this->db = $db ?: Factory::getDbo(); + $this->db = Factory::getDbo(); } /** @@ -222,13 +220,9 @@ class Data $query->from('#__componentbuilder_' . $table . ' AS a'); $query->where($this->db->quoteName('a.id') . ' = ' . (int) $id); - // for plugin event TODO change event api signatures - $component_context = $this->config->component_context; - // Trigger Event: jcb_ce_onBeforeQueryCustomViewData $this->event->trigger( - 'jcb_ce_onBeforeQueryCustomViewData', - array(&$component_context, &$id, &$table, &$query, &$this->db) + 'jcb_ce_onBeforeQueryCustomViewData', [&$id, &$table, &$query, &$this->db] ); // Reset the query using our newly populated query object. @@ -246,8 +240,7 @@ class Data // Trigger Event: jcb_ce_onBeforeModelCustomViewData $this->event->trigger( - 'jcb_ce_onBeforeModelCustomViewData', - array(&$component_context, &$item, &$id, &$table) + 'jcb_ce_onBeforeModelCustomViewData', [&$item, &$id, &$table] ); // set GUI mapper @@ -325,8 +318,7 @@ class Data // Trigger Event: jcb_ce_onAfterModelCustomViewData $this->event->trigger( - 'jcb_ce_onAfterModelCustomViewData', - array(&$component_context, &$item) + 'jcb_ce_onAfterModelCustomViewData', [&$item] ); // set the found data diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Dynamicget/Data.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Dynamicget/Data.php index 1d269f767..25d55ac25 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Dynamicget/Data.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Dynamicget/Data.php @@ -104,10 +104,9 @@ class Data /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 **/ - protected \JDatabaseDriver $db; + protected $db; /** * Constructor @@ -119,14 +118,13 @@ class Data * @param Dispenser|null $dispenser The compiler customcode dispenser object. * @param Gui|null $gui The compiler customcode gui. * @param Dynamicget|null $dynamic The compiler dynamicget modeller object. - * @param \JDatabaseDriver|null $db The database object. * * @since 3.2.0 */ public function __construct(?Config $config = null, ?Registry $registry = null, ?EventInterface $event = null, ?Customcode $customcode = null, ?Dispenser $dispenser = null, ?Gui $gui = null, - ?Dynamicget $dynamic = null, ?\JDatabaseDriver $db = null) + ?Dynamicget $dynamic = null) { $this->config = $config ?: Compiler::_('Config'); $this->registry = $registry ?: Compiler::_('Registry'); @@ -135,7 +133,7 @@ class Data $this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser'); $this->gui = $gui ?: Compiler::_('Customcode.Gui'); $this->dynamic = $dynamic ?: Compiler::_('Model.Dynamicget'); - $this->db = $db ?: Factory::getDbo(); + $this->db = Factory::getDbo(); } /** @@ -157,9 +155,6 @@ class Data $ids = implode(',', $ids); - // for plugin event TODO change event api signatures - $component_context = $this->config->component_context; - // Create a new query object. $query = $this->db->getQuery(true); $query->select('a.*'); @@ -176,8 +171,7 @@ class Data { // Trigger Event: jcb_ce_onBeforeModelDynamicGetData $this->event->trigger( - 'jcb_ce_onBeforeModelDynamicGetData', - array(&$component_context, &$result, &$result->id, &$view_code, &$context) + 'jcb_ce_onBeforeModelDynamicGetData', [&$result, &$result->id, &$view_code, &$context] ); // set GUI mapper id @@ -310,8 +304,7 @@ class Data // Trigger Event: jcb_ce_onAfterModelDynamicGetData $this->event->trigger( - 'jcb_ce_onAfterModelDynamicGetData', - array(&$component_context, &$result, &$result->id, &$view_code, &$context) + 'jcb_ce_onAfterModelDynamicGetData', [&$result, &$result->id, &$view_code, &$context] ); } diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Dynamicget/Selection.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Dynamicget/Selection.php index f2153ec0d..f1daa8543 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Dynamicget/Selection.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Dynamicget/Selection.php @@ -65,10 +65,9 @@ class Selection /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 **/ - protected \JDatabaseDriver $db; + protected $db; /** * Constructor. @@ -76,17 +75,15 @@ class Selection * @param Config $config The Config Class. * @param GetAsLookup $getaslookup The GetAsLookup Class. * @param SiteFields $sitefields The SiteFields Class. - * @param \JDatabaseDriver|null $db The database object. * * @since 3.2.0 */ - public function __construct(Config $config, GetAsLookup $getaslookup, SiteFields $sitefields, - ?\JDatabaseDriver $db = null) + public function __construct(Config $config, GetAsLookup $getaslookup, SiteFields $sitefields) { $this->config = $config; $this->getaslookup = $getaslookup; $this->sitefields = $sitefields; - $this->db = $db ?: Factory::getDbo(); + $this->db = Factory::getDbo(); } /** @@ -251,6 +248,7 @@ class Selection return [ 'select' => $querySelect, 'from' => $queryFrom, + 'view' => $viewCode, 'name' => $queryName, 'table' => $table, 'type' => $type, diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaFive/InstallScript.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaFive/InstallScript.php new file mode 100644 index 000000000..b93f4750d --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaFive/InstallScript.php @@ -0,0 +1,374 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Extension\JoomlaFive; + + +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Extension\InstallInterface; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\GetScriptInterface; + + +/** + * Loading the Extension Installation Script Class + * + * @since 3.2.0 + */ +final class InstallScript implements GetScriptInterface +{ + /** + * The extension + * + * @var InstallInterface|Object + * @since 3.2.0 + */ + protected object $extension; + + /** + * The methods + * + * @var array + * @since 3.2.0 + */ + protected array $methods = ['php_script', 'php_preflight', 'php_postflight', 'php_method']; + + /** + * The types + * + * @var array + * @since 3.2.0 + */ + protected array $types = ['construct', 'install', 'update', 'uninstall', 'discover_install']; + + /** + * The construct bucket + * + * @var array + * @since 3.2.0 + */ + protected array $construct = []; + + /** + * The install bucket + * + * @var array + * @since 3.2.0 + */ + protected array $install = []; + + /** + * The update bucket + * + * @var array + * @since 3.2.0 + */ + protected array $update = []; + + /** + * The uninstall bucket + * + * @var array + * @since 3.2.0 + */ + protected array $uninstall = []; + + /** + * The preflight switch + * + * @var bool + * @since 3.2.0 + */ + protected bool $preflightActive = false; + + /** + * The preflight bucket + * + * @var array + * @since 3.2.0 + */ + protected array $preflightBucket = ['install' => [], 'uninstall' => [], 'discover_install' => [], 'update' => []]; + + /** + * The postflight switch + * + * @var bool + * @since 3.2.0 + */ + protected bool $postflightActive = false; + + /** + * The postflight bucket + * + * @var array + * @since 3.2.0 + */ + protected array $postflightBucket = ['install' => [], 'uninstall' => [], 'discover_install' => [], 'update' => []]; + + /** + * get install script + * + * @param Object $extension The extension object + * + * @return string + * @since 3.2.0 + */ + public function get(object $extension): string + { + // loop over methods and types + foreach ($this->methods as $method) + { + foreach ($this->types as $type) + { + if (isset($extension->{'add_' . $method . '_' . $type}) + && $extension->{'add_' . $method . '_' . $type} == 1 + && StringHelper::check( + $extension->{$method . '_' . $type} + )) + { + // add to the main methods + if ('php_method' === $method || 'php_script' === $method) + { + $this->{$type}[] = $extension->{$method . '_' . $type}; + } + else + { + // get the flight key + $flight = str_replace('php_', '', (string) $method); + // load the script to our bucket + $this->{$flight . 'Bucket'}[$type][] = $extension->{$method . '_' . $type}; + // show that the method is active + $this->{$flight . 'Active'} = true; + } + } + } + } + + $this->extension = $extension; + + // return the class + return $this->build(); + } + + /** + * build the install class + * + * @return string + * @since 3.2.0 + */ + protected function build(): string + { + // start build + $script = $this->head(); + + // load constructor if set + $script .= $this->construct(); + + // load install method if set + $script .= $this->main('install'); + + // load update method if set + $script .= $this->main('update'); + + // load uninstall method if set + $script .= $this->main('uninstall'); + + // load preflight method if set + $script .= $this->flight('preflight'); + + // load postflight method if set + $script .= $this->flight('postflight'); + + // close the class + $script .= PHP_EOL . '}' . PHP_EOL; + + return $script; + } + + /** + * get install script head + * + * @return string + * @since 3.2.0 + */ + protected function head(): string + { + // get the extension + $extension = $this->extension; + + // start build + $script = PHP_EOL . 'use Joomla\CMS\Factory;'; + $script .= PHP_EOL . 'use Joomla\CMS\Language\Text;'; + $script .= PHP_EOL . 'use Joomla\CMS\Filesystem\File;'; + $script .= PHP_EOL . 'use Joomla\CMS\Filesystem\Folder;' . PHP_EOL; + $script .= PHP_EOL . '/**'; + $script .= PHP_EOL . ' * ' . $extension->official_name + . ' script file.'; + $script .= PHP_EOL . ' *'; + $script .= PHP_EOL . ' * @package ' . $extension->class_name; + $script .= PHP_EOL . ' */'; + $script .= PHP_EOL . 'class ' . $extension->installer_class_name; + $script .= PHP_EOL . '{'; + + return $script; + } + + /** + * get constructor + * + * @return string + * @since 3.2.0 + */ + protected function construct(): string + { + // return empty string if not set + if (!ArrayHelper::check($this->construct)) + { + return ''; + } + + // the __construct script + $script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; + $script .= PHP_EOL . Indent::_(1) . ' * Constructor'; + $script .= PHP_EOL . Indent::_(1) . ' *'; + $script .= PHP_EOL . Indent::_(1) + . ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script'; + $script .= PHP_EOL . Indent::_(1) . ' */'; + $script .= PHP_EOL . Indent::_(1) + . 'public function __construct($adapter)'; + $script .= PHP_EOL . Indent::_(1) . '{'; + $script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->construct); + // close the function + $script .= PHP_EOL . Indent::_(1) . '}'; + + return $script; + } + + /** + * build main methods + * + * @param string $name the method being called + * + * @return string + * @since 3.2.0 + */ + protected function main(string $name): string + { + // return empty string if not set + if (!ArrayHelper::check($this->{$name})) + { + return ''; + } + // load the install method + $script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; + $script .= PHP_EOL . Indent::_(1) . " * Called on $name"; + $script .= PHP_EOL . Indent::_(1) . ' *'; + $script .= PHP_EOL . Indent::_(1) + . ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script'; + $script .= PHP_EOL . Indent::_(1) . ' *'; + $script .= PHP_EOL . Indent::_(1) + . ' * @return boolean True on success'; + $script .= PHP_EOL . Indent::_(1) . ' */'; + $script .= PHP_EOL . Indent::_(1) . 'public function ' + . $name . '($adapter)'; + $script .= PHP_EOL . Indent::_(1) . '{'; + $script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->{$name}); + // return true + if ('uninstall' !== $name) + { + $script .= PHP_EOL . Indent::_(2) . 'return true;'; + } + // close the function + $script .= PHP_EOL . Indent::_(1) . '}'; + + return $script; + } + + /** + * build flight methods + * + * @param string $name the method being called + * + * @return string + * @since 3.2.0 + */ + protected function flight(string $name): string + { + // return empty string if not set + if (empty($this->{$name . 'Active'})) + { + return ''; + } + + // the pre/post function types + $script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; + $script .= PHP_EOL . Indent::_(1) + . ' * Called before any type of action'; + $script .= PHP_EOL . Indent::_(1) . ' *'; + $script .= PHP_EOL . Indent::_(1) + . ' * @param string $route Which action is happening (install|uninstall|discover_install|update)'; + $script .= PHP_EOL . Indent::_(1) + . ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script'; + $script .= PHP_EOL . Indent::_(1) . ' *'; + $script .= PHP_EOL . Indent::_(1) + . ' * @return boolean True on success'; + $script .= PHP_EOL . Indent::_(1) . ' */'; + $script .= PHP_EOL . Indent::_(1) . 'public function ' + . $name . '($route, $adapter)'; + $script .= PHP_EOL . Indent::_(1) . '{'; + $script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__) + . ' get application'; + $script .= PHP_EOL . Indent::_(2) + . '$app = Factory::getApplication();' . PHP_EOL; + + // add the default version check (TODO) must make this dynamic + if ('preflight' === $name) + { + $script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__) + .' the default for both install and update'; + $script .= PHP_EOL . Indent::_(2) + . '$jversion = new JVersion();'; + $script .= PHP_EOL . Indent::_(2) + . "if (!\$jversion->isCompatible('3.8.0'))"; + $script .= PHP_EOL . Indent::_(2) . '{'; + $script .= PHP_EOL . Indent::_(3) + . "\$app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error');"; + $script .= PHP_EOL . Indent::_(3) . 'return false;'; + $script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL; + } + + // now add the scripts + foreach ($this->{$name . 'Bucket'} as $route => $_script) + { + if (ArrayHelper::check($_script)) + { + // set the if and script + $script .= PHP_EOL . Indent::_(2) . "if ('" . $route + . "' === \$route)"; + $script .= PHP_EOL . Indent::_(2) . '{'; + $script .= PHP_EOL . implode( + PHP_EOL . PHP_EOL, $_script + ); + $script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL; + } + } + + // return true + $script .= PHP_EOL . Indent::_(2) . 'return true;'; + // close the function + $script .= PHP_EOL . Indent::_(1) . '}'; + + return $script; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaFive/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaFive/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaFive/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaFour/InstallScript.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaFour/InstallScript.php new file mode 100644 index 000000000..ce1d45be7 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaFour/InstallScript.php @@ -0,0 +1,374 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Extension\JoomlaFour; + + +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Extension\InstallInterface; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\GetScriptInterface; + + +/** + * Loading the Extension Installation Script Class + * + * @since 3.2.0 + */ +final class InstallScript implements GetScriptInterface +{ + /** + * The extension + * + * @var InstallInterface|Object + * @since 3.2.0 + */ + protected object $extension; + + /** + * The methods + * + * @var array + * @since 3.2.0 + */ + protected array $methods = ['php_script', 'php_preflight', 'php_postflight', 'php_method']; + + /** + * The types + * + * @var array + * @since 3.2.0 + */ + protected array $types = ['construct', 'install', 'update', 'uninstall', 'discover_install']; + + /** + * The construct bucket + * + * @var array + * @since 3.2.0 + */ + protected array $construct = []; + + /** + * The install bucket + * + * @var array + * @since 3.2.0 + */ + protected array $install = []; + + /** + * The update bucket + * + * @var array + * @since 3.2.0 + */ + protected array $update = []; + + /** + * The uninstall bucket + * + * @var array + * @since 3.2.0 + */ + protected array $uninstall = []; + + /** + * The preflight switch + * + * @var bool + * @since 3.2.0 + */ + protected bool $preflightActive = false; + + /** + * The preflight bucket + * + * @var array + * @since 3.2.0 + */ + protected array $preflightBucket = ['install' => [], 'uninstall' => [], 'discover_install' => [], 'update' => []]; + + /** + * The postflight switch + * + * @var bool + * @since 3.2.0 + */ + protected bool $postflightActive = false; + + /** + * The postflight bucket + * + * @var array + * @since 3.2.0 + */ + protected array $postflightBucket = ['install' => [], 'uninstall' => [], 'discover_install' => [], 'update' => []]; + + /** + * get install script + * + * @param Object $extension The extension object + * + * @return string + * @since 3.2.0 + */ + public function get(object $extension): string + { + // loop over methods and types + foreach ($this->methods as $method) + { + foreach ($this->types as $type) + { + if (isset($extension->{'add_' . $method . '_' . $type}) + && $extension->{'add_' . $method . '_' . $type} == 1 + && StringHelper::check( + $extension->{$method . '_' . $type} + )) + { + // add to the main methods + if ('php_method' === $method || 'php_script' === $method) + { + $this->{$type}[] = $extension->{$method . '_' . $type}; + } + else + { + // get the flight key + $flight = str_replace('php_', '', (string) $method); + // load the script to our bucket + $this->{$flight . 'Bucket'}[$type][] = $extension->{$method . '_' . $type}; + // show that the method is active + $this->{$flight . 'Active'} = true; + } + } + } + } + + $this->extension = $extension; + + // return the class + return $this->build(); + } + + /** + * build the install class + * + * @return string + * @since 3.2.0 + */ + protected function build(): string + { + // start build + $script = $this->head(); + + // load constructor if set + $script .= $this->construct(); + + // load install method if set + $script .= $this->main('install'); + + // load update method if set + $script .= $this->main('update'); + + // load uninstall method if set + $script .= $this->main('uninstall'); + + // load preflight method if set + $script .= $this->flight('preflight'); + + // load postflight method if set + $script .= $this->flight('postflight'); + + // close the class + $script .= PHP_EOL . '}' . PHP_EOL; + + return $script; + } + + /** + * get install script head + * + * @return string + * @since 3.2.0 + */ + protected function head(): string + { + // get the extension + $extension = $this->extension; + + // start build + $script = PHP_EOL . 'use Joomla\CMS\Factory;'; + $script .= PHP_EOL . 'use Joomla\CMS\Language\Text;'; + $script .= PHP_EOL . 'use Joomla\CMS\Filesystem\File;'; + $script .= PHP_EOL . 'use Joomla\CMS\Filesystem\Folder;' . PHP_EOL; + $script .= PHP_EOL . '/**'; + $script .= PHP_EOL . ' * ' . $extension->official_name + . ' script file.'; + $script .= PHP_EOL . ' *'; + $script .= PHP_EOL . ' * @package ' . $extension->class_name; + $script .= PHP_EOL . ' */'; + $script .= PHP_EOL . 'class ' . $extension->installer_class_name; + $script .= PHP_EOL . '{'; + + return $script; + } + + /** + * get constructor + * + * @return string + * @since 3.2.0 + */ + protected function construct(): string + { + // return empty string if not set + if (!ArrayHelper::check($this->construct)) + { + return ''; + } + + // the __construct script + $script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; + $script .= PHP_EOL . Indent::_(1) . ' * Constructor'; + $script .= PHP_EOL . Indent::_(1) . ' *'; + $script .= PHP_EOL . Indent::_(1) + . ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script'; + $script .= PHP_EOL . Indent::_(1) . ' */'; + $script .= PHP_EOL . Indent::_(1) + . 'public function __construct($adapter)'; + $script .= PHP_EOL . Indent::_(1) . '{'; + $script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->construct); + // close the function + $script .= PHP_EOL . Indent::_(1) . '}'; + + return $script; + } + + /** + * build main methods + * + * @param string $name the method being called + * + * @return string + * @since 3.2.0 + */ + protected function main(string $name): string + { + // return empty string if not set + if (!ArrayHelper::check($this->{$name})) + { + return ''; + } + // load the install method + $script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; + $script .= PHP_EOL . Indent::_(1) . " * Called on $name"; + $script .= PHP_EOL . Indent::_(1) . ' *'; + $script .= PHP_EOL . Indent::_(1) + . ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script'; + $script .= PHP_EOL . Indent::_(1) . ' *'; + $script .= PHP_EOL . Indent::_(1) + . ' * @return boolean True on success'; + $script .= PHP_EOL . Indent::_(1) . ' */'; + $script .= PHP_EOL . Indent::_(1) . 'public function ' + . $name . '($adapter)'; + $script .= PHP_EOL . Indent::_(1) . '{'; + $script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->{$name}); + // return true + if ('uninstall' !== $name) + { + $script .= PHP_EOL . Indent::_(2) . 'return true;'; + } + // close the function + $script .= PHP_EOL . Indent::_(1) . '}'; + + return $script; + } + + /** + * build flight methods + * + * @param string $name the method being called + * + * @return string + * @since 3.2.0 + */ + protected function flight(string $name): string + { + // return empty string if not set + if (empty($this->{$name . 'Active'})) + { + return ''; + } + + // the pre/post function types + $script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**'; + $script .= PHP_EOL . Indent::_(1) + . ' * Called before any type of action'; + $script .= PHP_EOL . Indent::_(1) . ' *'; + $script .= PHP_EOL . Indent::_(1) + . ' * @param string $route Which action is happening (install|uninstall|discover_install|update)'; + $script .= PHP_EOL . Indent::_(1) + . ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script'; + $script .= PHP_EOL . Indent::_(1) . ' *'; + $script .= PHP_EOL . Indent::_(1) + . ' * @return boolean True on success'; + $script .= PHP_EOL . Indent::_(1) . ' */'; + $script .= PHP_EOL . Indent::_(1) . 'public function ' + . $name . '($route, $adapter)'; + $script .= PHP_EOL . Indent::_(1) . '{'; + $script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__) + . ' get application'; + $script .= PHP_EOL . Indent::_(2) + . '$app = Factory::getApplication();' . PHP_EOL; + + // add the default version check (TODO) must make this dynamic + if ('preflight' === $name) + { + $script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__) + .' the default for both install and update'; + $script .= PHP_EOL . Indent::_(2) + . '$jversion = new JVersion();'; + $script .= PHP_EOL . Indent::_(2) + . "if (!\$jversion->isCompatible('3.8.0'))"; + $script .= PHP_EOL . Indent::_(2) . '{'; + $script .= PHP_EOL . Indent::_(3) + . "\$app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error');"; + $script .= PHP_EOL . Indent::_(3) . 'return false;'; + $script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL; + } + + // now add the scripts + foreach ($this->{$name . 'Bucket'} as $route => $_script) + { + if (ArrayHelper::check($_script)) + { + // set the if and script + $script .= PHP_EOL . Indent::_(2) . "if ('" . $route + . "' === \$route)"; + $script .= PHP_EOL . Indent::_(2) . '{'; + $script .= PHP_EOL . implode( + PHP_EOL . PHP_EOL, $_script + ); + $script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL; + } + } + + // return true + $script .= PHP_EOL . Indent::_(2) . 'return true;'; + // close the function + $script .= PHP_EOL . Indent::_(1) . '}'; + + return $script; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaFour/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaFour/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaFour/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaThree/InstallScript.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaThree/InstallScript.php index 3e34d4130..04a820576 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaThree/InstallScript.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Extension/JoomlaThree/InstallScript.php @@ -25,7 +25,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Interfaces\GetScriptInterface; * * @since 3.2.0 */ -class InstallScript implements GetScriptInterface +final class InstallScript implements GetScriptInterface { /** * The extension @@ -207,7 +207,11 @@ class InstallScript implements GetScriptInterface $extension = $this->extension; // start build - $script = PHP_EOL . '/**'; + $script = PHP_EOL . 'use Joomla\CMS\Factory;'; + $script .= PHP_EOL . 'use Joomla\CMS\Language\Text;'; + $script .= PHP_EOL . 'use Joomla\CMS\Filesystem\File;'; + $script .= PHP_EOL . 'use Joomla\CMS\Filesystem\Folder;' . PHP_EOL; + $script .= PHP_EOL . '/**'; $script .= PHP_EOL . ' * ' . $extension->official_name . ' script file.'; $script .= PHP_EOL . ' *'; @@ -325,7 +329,7 @@ class InstallScript implements GetScriptInterface $script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__) . ' get application'; $script .= PHP_EOL . Indent::_(2) - . '$app = JFactory::getApplication();' . PHP_EOL; + . '$app = Factory::getApplication();' . PHP_EOL; // add the default version check (TODO) must make this dynamic if ('preflight' === $name) diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Factory.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Factory.php index 8126e09b6..d244e1d4f 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Factory.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Factory.php @@ -19,6 +19,7 @@ use VDM\Joomla\Componentbuilder\Service\Database; use VDM\Joomla\Componentbuilder\Compiler\Service\Model; use VDM\Joomla\Componentbuilder\Compiler\Service\Compiler; use VDM\Joomla\Componentbuilder\Compiler\Service\Event; +use VDM\Joomla\Componentbuilder\Compiler\Service\Header; use VDM\Joomla\Componentbuilder\Compiler\Service\History; use VDM\Joomla\Componentbuilder\Compiler\Service\Language; use VDM\Joomla\Componentbuilder\Compiler\Service\Placeholder; @@ -34,8 +35,11 @@ use VDM\Joomla\Componentbuilder\Compiler\Service\Field; use VDM\Joomla\Componentbuilder\Compiler\Service\Joomlamodule; use VDM\Joomla\Componentbuilder\Compiler\Service\Joomlaplugin; use VDM\Joomla\Componentbuilder\Compiler\Service\Utilities; -use VDM\Joomla\Componentbuilder\Compiler\Service\Builder; +use VDM\Joomla\Componentbuilder\Compiler\Service\BuilderAJ; +use VDM\Joomla\Componentbuilder\Compiler\Service\BuilderLZ; use VDM\Joomla\Componentbuilder\Compiler\Service\Creator; +use VDM\Joomla\Componentbuilder\Compiler\Service\ArchitectureController; +use VDM\Joomla\Componentbuilder\Compiler\Service\ArchitectureModel; use VDM\Joomla\Componentbuilder\Service\Gitea; use VDM\Joomla\Gitea\Service\Utilities as GiteaUtilities; use VDM\Joomla\Gitea\Service\Settings as GiteaSettings; @@ -146,6 +150,7 @@ abstract class Factory implements FactoryInterface ->registerServiceProvider(new Model()) ->registerServiceProvider(new Compiler()) ->registerServiceProvider(new Event()) + ->registerServiceProvider(new Header()) ->registerServiceProvider(new History()) ->registerServiceProvider(new Language()) ->registerServiceProvider(new Placeholder()) @@ -161,8 +166,11 @@ abstract class Factory implements FactoryInterface ->registerServiceProvider(new Joomlamodule()) ->registerServiceProvider(new Joomlaplugin()) ->registerServiceProvider(new Utilities()) - ->registerServiceProvider(new Builder()) + ->registerServiceProvider(new BuilderAJ()) + ->registerServiceProvider(new BuilderLZ()) ->registerServiceProvider(new Creator()) + ->registerServiceProvider(new ArchitectureController()) + ->registerServiceProvider(new ArchitectureModel()) ->registerServiceProvider(new Gitea()) ->registerServiceProvider(new GiteaUtilities()) ->registerServiceProvider(new GiteaSettings()) diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/Data.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/Data.php index bc52a6379..f2f0b22b2 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/Data.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/Data.php @@ -13,17 +13,16 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Field; use Joomla\CMS\Factory; -use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; -use VDM\Joomla\Utilities\JsonHelper; -use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\StringHelper; use VDM\Joomla\Componentbuilder\Compiler\Config; -use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface; -use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HistoryInterface; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HistoryInterface as History; use VDM\Joomla\Componentbuilder\Compiler\Placeholder; use VDM\Joomla\Componentbuilder\Compiler\Customcode; use VDM\Joomla\Componentbuilder\Compiler\Field\Customcode as FieldCustomcode; -use VDM\Joomla\Componentbuilder\Compiler\Field\Validation; +use VDM\Joomla\Componentbuilder\Compiler\Field\Rule; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; /** @@ -42,95 +41,93 @@ class Data protected array $fields; /** - * Compiler Config + * The Config Class. * - * @var Config + * @var Config * @since 3.2.0 */ protected Config $config; /** - * Compiler Event + * The EventInterface Class. * - * @var EventInterface + * @var Event * @since 3.2.0 */ - protected EventInterface $event; + protected Event $event; /** - * Compiler History + * The HistoryInterface Class. * - * @var HistoryInterface + * @var History * @since 3.2.0 */ - protected HistoryInterface $history; + protected History $history; /** - * Compiler Placeholder + * The Placeholder Class. * - * @var Placeholder + * @var Placeholder * @since 3.2.0 */ protected Placeholder $placeholder; /** - * Compiler Customcode + * The Customcode Class. * - * @var Customcode + * @var Customcode * @since 3.2.0 */ protected Customcode $customcode; /** - * Compiler Field Customcode + * The Customcode Class. * - * @var FieldCustomcode + * @var FieldCustomcode * @since 3.2.0 */ - protected FieldCustomcode $fieldCustomcode; + protected FieldCustomcode $fieldcustomcode; /** - * Compiler Field Validation + * The Rule Class. * - * @var Validation + * @var Rule * @since 3.2.0 */ - protected Validation $validation; + protected Rule $rule; /** - * Database object to query local DB - * - * @var \JDatabaseDriver - * @since 3.2.0 - **/ - protected \JDatabaseDriver $db; - - /** - * Constructor - * - * @param Config|null $config The compiler config object. - * @param EventInterface|null $event The compiler event api object. - * @param HistoryInterface|null $history The compiler history object. - * @param Placeholder|null $placeholder The compiler placeholder object. - * @param Customcode|null $customcode The compiler customcode object. - * @param FieldCustomcode|null $fieldCustomcode The field customcode object. - * @param Validation|null $validation The field validation rule object. - * @param \JDatabaseDriver|null $db The database object. + * The database class. * * @since 3.2.0 */ - public function __construct(?Config $config = null, ?EventInterface $event = null, ?HistoryInterface $history = null, - ?Placeholder $placeholder = null, ?Customcode $customcode = null, ?FieldCustomcode $fieldCustomcode = null, - ?Validation $validation = null, ?\JDatabaseDriver $db = null) + protected $db; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Event $event The EventInterface Class. + * @param History $history The HistoryInterface Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Customcode $customcode The Customcode Class. + * @param FieldCustomcode $fieldcustomcode The Customcode Class. + * @param Rule $rule The Rule Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Event $event, History $history, + Placeholder $placeholder, Customcode $customcode, + FieldCustomcode $fieldcustomcode, Rule $rule) { - $this->config = $config ?: Compiler::_('Config'); - $this->event = $event ?: Compiler::_('Event'); - $this->history = $history ?: Compiler::_('History'); - $this->placeholder = $placeholder ?: Compiler::_('Placeholder'); - $this->customcode = $customcode ?: Compiler::_('Customcode'); - $this->fieldCustomcode = $fieldCustomcode ?: Compiler::_('Field.Customcode'); - $this->validation = $validation ?: Compiler::_('Field.Validation'); - $this->db = $db ?: Factory::getDbo(); + $this->config = $config; + $this->event = $event; + $this->history = $history; + $this->placeholder = $placeholder; + $this->customcode = $customcode; + $this->fieldcustomcode = $fieldcustomcode; + $this->rule = $rule; + $this->db = Factory::getDbo(); } /** @@ -169,13 +166,9 @@ class Data $this->db->quoteName('a.id') . ' = ' . $this->db->quote($id) ); - // TODO we need to update the event signatures - $context = $this->config->component_context; - // Trigger Event: jcb_ce_onBeforeQueryFieldData $this->event->trigger( - 'jcb_ce_onBeforeQueryFieldData', - array(&$context, &$id, &$query, &$this->db) + 'jcb_ce_onBeforeQueryFieldData', [&$id, &$query, &$this->db] ); // Reset the query using our newly populated query object. @@ -188,8 +181,7 @@ class Data // Trigger Event: jcb_ce_onBeforeModelFieldData $this->event->trigger( - 'jcb_ce_onBeforeModelFieldData', - array(&$context, &$field) + 'jcb_ce_onBeforeModelFieldData', [&$field] ); // adding a fix for the changed name of type to fieldtype @@ -199,7 +191,7 @@ class Data $field->xml = $this->customcode->update(json_decode((string) $field->xml)); // check if we have validate (validation rule and set it if found) - $this->validation->set($id, $field->xml); + $this->rule->set($id, $field->xml); // load the type values form type params $field->properties = (isset($field->properties) @@ -301,8 +293,7 @@ class Data // Trigger Event: jcb_ce_onAfterModelFieldData $this->event->trigger( - 'jcb_ce_onAfterModelFieldData', - array(&$context, &$field) + 'jcb_ce_onAfterModelFieldData', [&$field] ); $this->fields[$id] = $field; @@ -316,14 +307,13 @@ class Data if ($id > 0 && isset($this->fields[$id])) { // update the customcode of the field - $this->fieldCustomcode->update($id, $this->fields[$id], $singleViewName, $listViewName); + $this->fieldcustomcode->update($id, $this->fields[$id], $singleViewName, $listViewName); // return the field return $this->fields[$id]; } return null; - } - + } } diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/Groups.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/Groups.php index 76e661e7a..ddf57c236 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/Groups.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/Groups.php @@ -71,21 +71,18 @@ final class Groups /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 */ - protected \JDatabaseDriver $db; + protected $db; /** * Constructor * - * @param \JDatabaseDriver|null $db The Database Driver object. - * * @since 3.2.0 */ - public function __construct(?\JDatabaseDriver $db = null) + public function __construct() { - $this->db = $db ?: Factory::getDbo(); + $this->db = Factory::getDbo(); } /** diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/InputButton.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/InputButton.php deleted file mode 100644 index d8754d2b6..000000000 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/InputButton.php +++ /dev/null @@ -1,338 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -namespace VDM\Joomla\Componentbuilder\Compiler\Field; - - -use VDM\Joomla\Componentbuilder\Compiler\Config; -use VDM\Joomla\Componentbuilder\Compiler\Placeholder; -use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission; -use VDM\Joomla\Utilities\StringHelper; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; - - -/** - * Compiler Field Input Button - * - * @since 3.2.0 - */ -final class InputButton -{ - /** - * The Config Class. - * - * @var Config - * @since 3.2.0 - */ - protected Config $config; - - /** - * The Placeholder Class. - * - * @var Placeholder - * @since 3.2.0 - */ - protected Placeholder $placeholder; - - /** - * The Permission Class. - * - * @var Permission - * @since 3.2.0 - */ - protected Permission $permission; - - /** - * Constructor. - * - * @param Config $config The Config Class. - * @param Placeholder $placeholder The Placeholder Class. - * @param Permission $permission The Permission Class. - * - * @since 3.2.0 - */ - public function __construct(Config $config, Placeholder $placeholder, - Permission $permission) - { - $this->config = $config; - $this->placeholder = $placeholder; - $this->permission = $permission; - } - - /** - * get Add Button To List Field Input (getInput tweak) - * - * @param array $fieldData The field custom data - * - * @return string of getInput class on success empty string otherwise - * @since 3.2.0 - */ - public function get(array $fieldData): string - { - // make sure hte view values are set - if (isset($fieldData['add_button']) - && ($fieldData['add_button'] === 'true' - || 1 == $fieldData['add_button']) - && isset($fieldData['view']) - && isset($fieldData['views']) - && StringHelper::check($fieldData['view']) - && StringHelper::check($fieldData['views'])) - { - // set local component - $local_component = "com_" . $this->config->component_code_name; - // check that the component value is set - if (!isset($fieldData['component']) - || !StringHelper::check( - $fieldData['component'] - )) - { - $fieldData['component'] = $local_component; - } - // check that the component has the com_ value in it - if (strpos((string) $fieldData['component'], 'com_') === false - || strpos((string) $fieldData['component'], '=') !== false) - { - $fieldData['component'] = "com_" . $fieldData['component']; - } - // make sure the component is update if # # # or [ [ [ component placeholder is used - if (strpos((string) $fieldData['component'], (string) Placefix::h()) !== false - || strpos((string) $fieldData['component'], (string) Placefix::b()) !== false) // should not be needed... but - { - $fieldData['component'] = $this->placeholder->update_( - $fieldData['component'] - ); - } - // get core permissions - $coreLoad = false; - // add ref tags - $refLoad = true; - // fall back on the field component - $component = $fieldData['component']; - // check if we should add ref tags (since it only works well on local views) - if ($local_component !== $component) - { - // do not add ref tags - $refLoad = false; - } - // start building the add buttons/s - $addButton = array(); - $addButton[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; - $addButton[] = Indent::_(1) . " * Override to add new button"; - $addButton[] = Indent::_(1) . " *"; - $addButton[] = Indent::_(1) - . " * @return string The field input markup."; - $addButton[] = Indent::_(1) . " *"; - $addButton[] = Indent::_(1) . " * @since 3.2"; - $addButton[] = Indent::_(1) . " */"; - $addButton[] = Indent::_(1) . "protected function getInput()"; - $addButton[] = Indent::_(1) . "{"; - $addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " see if we should add buttons"; - $addButton[] = Indent::_(2) - . "\$set_button = \$this->getAttribute('button');"; - $addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " get html"; - $addButton[] = Indent::_(2) . "\$html = parent::getInput();"; - $addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) - . " if true set button"; - $addButton[] = Indent::_(2) . "if (\$set_button === 'true')"; - $addButton[] = Indent::_(2) . "{"; - $addButton[] = Indent::_(3) . "\$button = array();"; - $addButton[] = Indent::_(3) . "\$script = array();"; - $addButton[] = Indent::_(3) - . "\$button_code_name = \$this->getAttribute('name');"; - $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " get the input from url"; - $addButton[] = Indent::_(3) . "\$app = JFactory::getApplication();"; - $addButton[] = Indent::_(3) . "\$jinput = \$app->input;"; - $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " get the view name & id"; - $addButton[] = Indent::_(3) - . "\$values = \$jinput->getArray(array("; - $addButton[] = Indent::_(4) . "'id' => 'int',"; - $addButton[] = Indent::_(4) . "'view' => 'word'"; - $addButton[] = Indent::_(3) . "));"; - $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " check if new item"; - $addButton[] = Indent::_(3) . "\$ref = '';"; - $addButton[] = Indent::_(3) . "\$refJ = '';"; - if ($refLoad) - { - $addButton[] = Indent::_(3) - . "if (!is_null(\$values['id']) && strlen(\$values['view']))"; - $addButton[] = Indent::_(3) . "{"; - $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " only load referral if not new item."; - $addButton[] = Indent::_(4) - . "\$ref = '&ref=' . \$values['view'] . '&refid=' . \$values['id'];"; - $addButton[] = Indent::_(4) - . "\$refJ = '&ref=' . \$values['view'] . '&refid=' . \$values['id'];"; - $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " get the return value."; - $addButton[] = Indent::_(4) - . "\$_uri = (string) JUri::getInstance();"; - $addButton[] = Indent::_(4) - . "\$_return = urlencode(base64_encode(\$_uri));"; - $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " load return value."; - $addButton[] = Indent::_(4) - . "\$ref .= '&return=' . \$_return;"; - $addButton[] = Indent::_(4) - . "\$refJ .= '&return=' . \$_return;"; - $addButton[] = Indent::_(3) . "}"; - } - else - { - $addButton[] = Indent::_(3) - . "if (!is_null(\$values['id']) && strlen(\$values['view']))"; - $addButton[] = Indent::_(3) . "{"; - $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " only load field details if not new item."; - $addButton[] = Indent::_(4) - . "\$ref = '&field=' . \$values['view'] . '&field_id=' . \$values['id'];"; - $addButton[] = Indent::_(4) - . "\$refJ = '&field=' . \$values['view'] . '&field_id=' . \$values['id'];"; - $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " get the return value."; - $addButton[] = Indent::_(4) - . "\$_uri = (string) JUri::getInstance();"; - $addButton[] = Indent::_(4) - . "\$_return = urlencode(base64_encode(\$_uri));"; - $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " load return value."; - $addButton[] = Indent::_(4) - . "\$ref = '&return=' . \$_return;"; - $addButton[] = Indent::_(4) - . "\$refJ = '&return=' . \$_return;"; - $addButton[] = Indent::_(3) . "}"; - } - $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " get button label"; - $addButton[] = Indent::_(3) - . "\$button_label = trim(\$button_code_name);"; - $addButton[] = Indent::_(3) - . "\$button_label = preg_replace('/_+/', ' ', \$button_label);"; - $addButton[] = Indent::_(3) - . "\$button_label = preg_replace('/\s+/', ' ', \$button_label);"; - $addButton[] = Indent::_(3) - . "\$button_label = preg_replace(\"/[^A-Za-z ]/\", '', \$button_label);"; - $addButton[] = Indent::_(3) - . "\$button_label = ucfirst(strtolower(\$button_label));"; - $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " get user object"; - $addButton[] = Indent::_(3) . "\$user = JFactory::getUser();"; - $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " only add if user allowed to create " . $fieldData['view']; - // check if the item has permissions. - $addButton[] = Indent::_(3) . "if (\$user->authorise('" - . $this->permission->getGlobal($fieldData['view'], 'core.create') - . "', '" . $component . "') && \$app->isAdmin()) // TODO for now only in admin area."; - $addButton[] = Indent::_(3) . "{"; - $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " build Create button"; - $addButton[] = Indent::_(4) - . "\$button[] = 'config->lang_prefix - . "_CREATE_NEW_S', \$button_label).'\" style=\"border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;\""; - $addButton[] = Indent::_(5) . "href=\"index.php?option=" - . $fieldData['component'] . "&view=" . $fieldData['view'] - . "&layout=edit'.\$ref.'\" >"; - $addButton[] = Indent::_(5) - . "';"; - $addButton[] = Indent::_(3) . "}"; - $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " only add if user allowed to edit " . $fieldData['view']; - // check if the item has permissions. - $addButton[] = Indent::_(3) . "if (\$user->authorise('" - . $this->permission->getGlobal($fieldData['view'], 'core.edit') - . "', '" . $component . "') && \$app->isAdmin()) // TODO for now only in admin area."; - $addButton[] = Indent::_(3) . "{"; - $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " build edit button"; - $addButton[] = Indent::_(4) - . "\$button[] = 'config->lang_prefix - . "_EDIT_S', \$button_label).'\" style=\"display: none; padding: 4px 4px 4px 7px;\" href=\"#\" >"; - $addButton[] = Indent::_(5) - . "';"; - $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " build script"; - $addButton[] = Indent::_(4) . "\$script[] = \""; - $addButton[] = Indent::_(5) . "jQuery(document).ready(function() {"; - $addButton[] = Indent::_(6) - . "jQuery('#adminForm').on('change', '#jform_\".\$button_code_name.\"',function (e) {"; - $addButton[] = Indent::_(7) . "e.preventDefault();"; - $addButton[] = Indent::_(7) - . "var \".\$button_code_name.\"Value = jQuery('#jform_\".\$button_code_name.\"').val();"; - $addButton[] = Indent::_(7) - . "\".\$button_code_name.\"Button(\".\$button_code_name.\"Value);"; - $addButton[] = Indent::_(6) . "});"; - $addButton[] = Indent::_(6) - . "var \".\$button_code_name.\"Value = jQuery('#jform_\".\$button_code_name.\"').val();"; - $addButton[] = Indent::_(6) - . "\".\$button_code_name.\"Button(\".\$button_code_name.\"Value);"; - $addButton[] = Indent::_(5) . "});"; - $addButton[] = Indent::_(5) - . "function \".\$button_code_name.\"Button(value) {"; - $addButton[] = Indent::_(6) - . "if (value > 0) {"; // TODO not ideal since value may not be an (int) - $addButton[] = Indent::_(7) . "// hide the create button"; - $addButton[] = Indent::_(7) - . "jQuery('#\".\$button_code_name.\"Create').hide();"; - $addButton[] = Indent::_(7) . "// show edit button"; - $addButton[] = Indent::_(7) - . "jQuery('#\".\$button_code_name.\"Edit').show();"; - $addButton[] = Indent::_(7) . "var url = 'index.php?option=" - . $fieldData['component'] . "&view=" . $fieldData['views'] - . "&task=" . $fieldData['view'] - . ".edit&id='+value+'\".\$refJ.\"';"; // TODO this value may not be the ID - $addButton[] = Indent::_(7) - . "jQuery('#\".\$button_code_name.\"Edit').attr('href', url);"; - $addButton[] = Indent::_(6) . "} else {"; - $addButton[] = Indent::_(7) . "// show the create button"; - $addButton[] = Indent::_(7) - . "jQuery('#\".\$button_code_name.\"Create').show();"; - $addButton[] = Indent::_(7) . "// hide edit button"; - $addButton[] = Indent::_(7) - . "jQuery('#\".\$button_code_name.\"Edit').hide();"; - $addButton[] = Indent::_(6) . "}"; - $addButton[] = Indent::_(5) . "}\";"; - $addButton[] = Indent::_(3) . "}"; - $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) - . " check if button was created for " . $fieldData['view'] - . " field."; - $addButton[] = Indent::_(3) - . "if (is_array(\$button) && count(\$button) > 0)"; - $addButton[] = Indent::_(3) . "{"; - $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " Load the needed script."; - $addButton[] = Indent::_(4) - . "\$document = JFactory::getDocument();"; - $addButton[] = Indent::_(4) - . "\$document->addScriptDeclaration(implode(' ',\$script));"; - $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) - . " return the button attached to input field."; - $addButton[] = Indent::_(4) - . "return '
    ' .\$html . implode('',\$button).'
    ';"; - $addButton[] = Indent::_(3) . "}"; - $addButton[] = Indent::_(2) . "}"; - $addButton[] = Indent::_(2) . "return \$html;"; - $addButton[] = Indent::_(1) . "}"; - - return implode(PHP_EOL, $addButton); - } - - return ''; - } -} - diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFive/CoreField.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFive/CoreField.php new file mode 100644 index 000000000..591fd5304 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFive/CoreField.php @@ -0,0 +1,129 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFive; + + +use Joomla\CMS\Filesystem\Folder; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreFieldInterface; + + +/** + * Core Joomla Fields + * + * @since 3.2.0 + */ +final class CoreField implements CoreFieldInterface +{ + /** + * Local Core Joomla Fields + * + * @var array|null + * @since 3.2.0 + **/ + protected array $fields = []; + + /** + * Local Core Joomla Fields Path + * + * @var array + * @since 3.2.0 + **/ + protected array $paths = []; + + /** + * Constructor + * + * @since 3.2.0 + */ + public function __construct() + { + // set the path to the form validation fields + $this->paths[] = JPATH_LIBRARIES . '/src/Form/Field'; + } + + /** + * Get the Array of Existing Validation Field Names + * + * @param bool $lowercase Switch to set fields lowercase + * + * @return array + * @since 3.2.0 + */ + public function get(bool $lowercase = false): array + { + if ($this->fields === []) + { + // check if the path exist + foreach ($this->paths as $path) + { + $this->set($path); + } + } + + // return fields if found + if ($this->fields !== []) + { + // check if the names should be all lowercase + if ($lowercase) + { + return array_map( + fn($item): string => strtolower((string) $item), + $this->fields + ); + } + + return $this->fields; + } + + // return empty array + return []; + } + + /** + * Set the fields found in a path + * + * @param string $path The path to load fields from + * @return void + * @since 3.2.0 + */ + private function set(string $path): void + { + // Check if the path exists + if (!Folder::exists($path)) + { + return; + } + + // Load all PHP files in this path + $fields = Folder::files($path, '\.php$', true, true); + + // Process the files to extract field names + $processedFields = array_map(function ($name) { + $fileName = basename($name); + + // Remove 'Field.php' if it exists or just '.php' otherwise + if (substr($fileName, -9) === 'Field.php') + { + return str_replace('Field.php', '', $fileName); + } + else + { + return str_replace('.php', '', $fileName); + } + }, $fields); + + // Merge with existing fields and remove duplicates + $this->fields = array_unique(array_merge($processedFields, $this->fields)); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFive/CoreRule.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFive/CoreRule.php new file mode 100644 index 000000000..9aee380d1 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFive/CoreRule.php @@ -0,0 +1,125 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFive; + + +use Joomla\CMS\Filesystem\Folder; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreRuleInterface; + + +/** + * Core Joomla Field Rules + * + * @since 3.2.0 + */ +final class CoreRule implements CoreRuleInterface +{ + /** + * Local Core Joomla Rules + * + * @var array + * @since 3.2.0 + **/ + protected array $rules = []; + + /** + * Local Core Joomla Rules Path + * + * @var string + * @since 3.2.0 + **/ + protected string $path; + + /** + * Constructor + * + * @since 3.2.0 + */ + public function __construct() + { + // set the path to the form validation rules + $this->path = JPATH_LIBRARIES . '/src/Form/Rule'; + } + + /** + * Get the Array of Existing Validation Rule Names + * + * @param bool $lowercase Switch to set rules lowercase + * + * @return array + * @since 3.2.0 + */ + public function get(bool $lowercase = false): array + { + if ($this->rules === []) + { + $this->set($this->path); + } + + // return rules if found + if ($this->rules !== []) + { + // check if the names should be all lowercase + if ($lowercase) + { + return array_map( + fn($item): string => strtolower((string) $item), + $this->rules + ); + } + + return $this->rules; + } + + // return empty array + return []; + } + + /** + * Set the rules found in a path + * + * @param string $path The path to load rules from + * @return void + * @since 3.2.0 + */ + private function set(string $path): void + { + // Check if the path exists + if (!Folder::exists($path)) + { + return; + } + + // Load all PHP files in this path + $rules = Folder::files($path, '\.php$', true, true); + + // Process the files to extract rule names + $processedRules = array_map(function ($name) { + $fileName = basename($name); + + // Remove 'Rule.php' if it exists or just '.php' otherwise + if (substr($fileName, -8) === 'Rule.php') + { + return str_replace('Rule.php', '', $fileName); + } + else + { + return str_replace('.php', '', $fileName); + } + }, $rules); + + // Merge with existing rules and remove duplicates + $this->rules = array_unique(array_merge($processedRules, $this->rules)); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFive/InputButton.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFive/InputButton.php new file mode 100644 index 000000000..54a9b7bd6 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFive/InputButton.php @@ -0,0 +1,345 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFive; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\InputButtonInterface; + + +/** + * Compiler Field Input Button + * + * @since 3.2.0 + */ +final class InputButton implements InputButtonInterface +{ + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 3.2.0 + */ + protected Placeholder $placeholder; + + /** + * The Permission Class. + * + * @var Permission + * @since 3.2.0 + */ + protected Permission $permission; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Permission $permission The Permission Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Placeholder $placeholder, + Permission $permission) + { + $this->config = $config; + $this->placeholder = $placeholder; + $this->permission = $permission; + } + + /** + * get Add Button To List Field Input (getInput tweak) + * + * @param array $fieldData The field custom data + * + * @return string of getInput class on success empty string otherwise + * @since 3.2.0 + */ + public function get(array $fieldData): string + { + // make sure hte view values are set + if (isset($fieldData['add_button']) + && ($fieldData['add_button'] === 'true' + || 1 == $fieldData['add_button']) + && isset($fieldData['view']) + && isset($fieldData['views']) + && StringHelper::check($fieldData['view']) + && StringHelper::check($fieldData['views'])) + { + // set local component + $local_component = "com_" . $this->config->component_code_name; + // check that the component value is set + if (!isset($fieldData['component']) + || !StringHelper::check( + $fieldData['component'] + )) + { + $fieldData['component'] = $local_component; + } + // check that the component has the com_ value in it + if (strpos((string) $fieldData['component'], 'com_') === false + || strpos((string) $fieldData['component'], '=') !== false) + { + $fieldData['component'] = "com_" . $fieldData['component']; + } + // make sure the component is update if # # # or [ [ [ component placeholder is used + if (strpos((string) $fieldData['component'], (string) Placefix::h()) !== false + || strpos((string) $fieldData['component'], (string) Placefix::b()) !== false) // should not be needed... but + { + $fieldData['component'] = $this->placeholder->update_( + $fieldData['component'] + ); + } + // get core permissions + $coreLoad = false; + // add ref tags + $refLoad = true; + // fall back on the field component + $component = $fieldData['component']; + // check if we should add ref tags (since it only works well on local views) + if ($local_component !== $component) + { + // do not add ref tags + $refLoad = false; + } + // start building the add buttons/s + $addButton = array(); + $addButton[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $addButton[] = Indent::_(1) . " * Override to add new button"; + $addButton[] = Indent::_(1) . " *"; + $addButton[] = Indent::_(1) + . " * @return string The field input markup."; + $addButton[] = Indent::_(1) . " *"; + $addButton[] = Indent::_(1) . " * @since 3.2"; + $addButton[] = Indent::_(1) . " */"; + $addButton[] = Indent::_(1) . "protected function getInput()"; + $addButton[] = Indent::_(1) . "{"; + $addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " see if we should add buttons"; + $addButton[] = Indent::_(2) + . "\$set_button = \$this->getAttribute('button');"; + $addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get html"; + $addButton[] = Indent::_(2) . "\$html = parent::getInput();"; + $addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " if true set button"; + $addButton[] = Indent::_(2) . "if (\$set_button === 'true')"; + $addButton[] = Indent::_(2) . "{"; + $addButton[] = Indent::_(3) . "\$button = array();"; + $addButton[] = Indent::_(3) . "\$script = array();"; + $addButton[] = Indent::_(3) + . "\$button_code_name = \$this->getAttribute('name');"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " get the input from url"; + $addButton[] = Indent::_(3) . "\$app = Factory::getApplication();"; + $addButton[] = Indent::_(3) . "\$jinput = \$app->input;"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " get the view name & id"; + $addButton[] = Indent::_(3) + . "\$values = \$jinput->getArray(array("; + $addButton[] = Indent::_(4) . "'id' => 'int',"; + $addButton[] = Indent::_(4) . "'view' => 'word'"; + $addButton[] = Indent::_(3) . "));"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " check if new item"; + $addButton[] = Indent::_(3) . "\$ref = '';"; + $addButton[] = Indent::_(3) . "\$refJ = '';"; + if ($refLoad) + { + $addButton[] = Indent::_(3) + . "if (!is_null(\$values['id']) && strlen(\$values['view']))"; + $addButton[] = Indent::_(3) . "{"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " only load referral if not new item."; + $addButton[] = Indent::_(4) + . "\$ref = '&ref=' . \$values['view'] . '&refid=' . \$values['id'];"; + $addButton[] = Indent::_(4) + . "\$refJ = '&ref=' . \$values['view'] . '&refid=' . \$values['id'];"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " get the return value."; + $addButton[] = Indent::_(4) + . "\$_uri = (string) \Joomla\CMS\Uri\Uri::getInstance();"; + $addButton[] = Indent::_(4) + . "\$_return = urlencode(base64_encode(\$_uri));"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " load return value."; + $addButton[] = Indent::_(4) + . "\$ref .= '&return=' . \$_return;"; + $addButton[] = Indent::_(4) + . "\$refJ .= '&return=' . \$_return;"; + $addButton[] = Indent::_(3) . "}"; + } + else + { + $addButton[] = Indent::_(3) + . "if (!is_null(\$values['id']) && strlen(\$values['view']))"; + $addButton[] = Indent::_(3) . "{"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " only load field details if not new item."; + $addButton[] = Indent::_(4) + . "\$ref = '&field=' . \$values['view'] . '&field_id=' . \$values['id'];"; + $addButton[] = Indent::_(4) + . "\$refJ = '&field=' . \$values['view'] . '&field_id=' . \$values['id'];"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " get the return value."; + $addButton[] = Indent::_(4) + . "\$_uri = (string) \Joomla\CMS\Uri\Uri::getInstance();"; + $addButton[] = Indent::_(4) + . "\$_return = urlencode(base64_encode(\$_uri));"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " load return value."; + $addButton[] = Indent::_(4) + . "\$ref = '&return=' . \$_return;"; + $addButton[] = Indent::_(4) + . "\$refJ = '&return=' . \$_return;"; + $addButton[] = Indent::_(3) . "}"; + } + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " get button label"; + $addButton[] = Indent::_(3) + . "\$button_label = trim(\$button_code_name);"; + $addButton[] = Indent::_(3) + . "\$button_label = preg_replace('/_+/', ' ', \$button_label);"; + $addButton[] = Indent::_(3) + . "\$button_label = preg_replace('/\s+/', ' ', \$button_label);"; + $addButton[] = Indent::_(3) + . "\$button_label = preg_replace(\"/[^A-Za-z ]/\", '', \$button_label);"; + $addButton[] = Indent::_(3) + . "\$button_label = ucfirst(strtolower(\$button_label));"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " get user object"; + $addButton[] = Indent::_(3) . "\$user = Factory::getApplication()->getIdentity();"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " only add if user allowed to create " . $fieldData['view']; + // check if the item has permissions. + $addButton[] = Indent::_(3) . "if (\$user->authorise('" + . $this->permission->getGlobal($fieldData['view'], 'core.create') + . "', '" . $component . "') && \$app->isClient('administrator')) // TODO for now only in admin area."; + $addButton[] = Indent::_(3) . "{"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " build Create button"; + $addButton[] = Indent::_(4) + . "\$button[] = 'config->lang_prefix + . "_CREATE_NEW_S', \$button_label).'\" style=\"border-radius: 0px 4px 4px 0px;\""; + $addButton[] = Indent::_(5) . "href=\"index.php?option=" + . $fieldData['component'] . "&view=" . $fieldData['view'] + . "&layout=edit'.\$ref.'\" >"; + $addButton[] = Indent::_(5) + . "';"; + $addButton[] = Indent::_(3) . "}"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " only add if user allowed to edit " . $fieldData['view']; + // check if the item has permissions. + $addButton[] = Indent::_(3) . "if (\$user->authorise('" + . $this->permission->getGlobal($fieldData['view'], 'core.edit') + . "', '" . $component . "') && \$app->isClient('administrator')) // TODO for now only in admin area."; + $addButton[] = Indent::_(3) . "{"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " build edit button"; + $addButton[] = Indent::_(4) + . "\$button[] = 'config->lang_prefix + . "_EDIT_S', \$button_label).'\" style=\"display: none; border-radius: 0px 4px 4px 0px;\" href=\"#\" >"; + $addButton[] = Indent::_(5) + . "';"; + + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " build script"; +$addButton[] = Indent::_(4) . "\$script[] = \""; + $addButton[] = Indent::_(5) . "document.addEventListener('DOMContentLoaded', function() {"; + $addButton[] = Indent::_(6) + . "document.getElementById('jform_\".\$button_code_name.\"').addEventListener('change', function(e) {"; + $addButton[] = Indent::_(7) . "e.preventDefault();"; + $addButton[] = Indent::_(7) + . "let \".\$button_code_name.\"Value = this.value;"; + $addButton[] = Indent::_(7) + . "\".\$button_code_name.\"Button(\".\$button_code_name.\"Value);"; + $addButton[] = Indent::_(6) . "});"; + $addButton[] = Indent::_(6) + . "let \".\$button_code_name.\"Value = document.getElementById('jform_\".\$button_code_name.\"').value;"; + $addButton[] = Indent::_(6) + . "\".\$button_code_name.\"Button(\".\$button_code_name.\"Value);"; + $addButton[] = Indent::_(5) . "});"; + $addButton[] = Indent::_(5) + . "function \".\$button_code_name.\"Button(value) {"; + $addButton[] = Indent::_(6) + . "var createButton = document.getElementById('\".\$button_code_name.\"Create');"; + $addButton[] = Indent::_(6) + . "var editButton = document.getElementById('\".\$button_code_name.\"Edit');"; + $addButton[] = Indent::_(6) + . "if (value > 0) {"; // TODO not ideal since value may not be an (int) + $addButton[] = Indent::_(7) . "// hide the create button"; + $addButton[] = Indent::_(7) + . "createButton.style.display = 'none';"; + $addButton[] = Indent::_(7) . "// show edit button"; + $addButton[] = Indent::_(7) + . "editButton.style.display = 'block';"; + $addButton[] = Indent::_(7) . "let url = 'index.php?option=" + . $fieldData['component'] . "&view=" . $fieldData['views'] + . "&task=" . $fieldData['view'] + . ".edit&id='+value+'\".\$refJ.\"';"; // TODO this value may not be the ID + $addButton[] = Indent::_(7) + . "editButton.setAttribute('href', url);"; + $addButton[] = Indent::_(6) . "} else {"; + $addButton[] = Indent::_(7) . "// show the create button"; + $addButton[] = Indent::_(7) + . "createButton.style.display = 'block';"; + $addButton[] = Indent::_(7) . "// hide edit button"; + $addButton[] = Indent::_(7) + . "editButton.style.display = 'none';"; + $addButton[] = Indent::_(6) . "}"; + $addButton[] = Indent::_(5) . "}\";"; + + $addButton[] = Indent::_(3) . "}"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " check if button was created for " . $fieldData['view'] + . " field."; + $addButton[] = Indent::_(3) + . "if (is_array(\$button) && count(\$button) > 0)"; + $addButton[] = Indent::_(3) . "{"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Load the needed script."; + $addButton[] = Indent::_(4) + . "\$document = Factory::getApplication()->getDocument();"; + $addButton[] = Indent::_(4) + . "\$document->addScriptDeclaration(implode(' ',\$script));"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " return the button attached to input field."; + $addButton[] = Indent::_(4) + . "return '
    ' .\$html . implode('',\$button).'
    ';"; + $addButton[] = Indent::_(3) . "}"; + $addButton[] = Indent::_(2) . "}"; + $addButton[] = Indent::_(2) . "return \$html;"; + $addButton[] = Indent::_(1) . "}"; + + return implode(PHP_EOL, $addButton); + } + + return ''; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFive/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFive/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFive/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFour/CoreField.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFour/CoreField.php new file mode 100644 index 000000000..529142d7f --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFour/CoreField.php @@ -0,0 +1,129 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFour; + + +use Joomla\CMS\Filesystem\Folder; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreFieldInterface; + + +/** + * Core Joomla Fields + * + * @since 3.2.0 + */ +final class CoreField implements CoreFieldInterface +{ + /** + * Local Core Joomla Fields + * + * @var array|null + * @since 3.2.0 + **/ + protected array $fields = []; + + /** + * Local Core Joomla Fields Path + * + * @var array + * @since 3.2.0 + **/ + protected array $paths = []; + + /** + * Constructor + * + * @since 3.2.0 + */ + public function __construct() + { + // set the path to the form validation fields + $this->paths[] = JPATH_LIBRARIES . '/src/Form/Field'; + } + + /** + * Get the Array of Existing Validation Field Names + * + * @param bool $lowercase Switch to set fields lowercase + * + * @return array + * @since 3.2.0 + */ + public function get(bool $lowercase = false): array + { + if ($this->fields === []) + { + // check if the path exist + foreach ($this->paths as $path) + { + $this->set($path); + } + } + + // return fields if found + if ($this->fields !== []) + { + // check if the names should be all lowercase + if ($lowercase) + { + return array_map( + fn($item): string => strtolower((string) $item), + $this->fields + ); + } + + return $this->fields; + } + + // return empty array + return []; + } + + /** + * Set the fields found in a path + * + * @param string $path The path to load fields from + * @return void + * @since 3.2.0 + */ + private function set(string $path): void + { + // Check if the path exists + if (!Folder::exists($path)) + { + return; + } + + // Load all PHP files in this path + $fields = Folder::files($path, '\.php$', true, true); + + // Process the files to extract field names + $processedFields = array_map(function ($name) { + $fileName = basename($name); + + // Remove 'Field.php' if it exists or just '.php' otherwise + if (substr($fileName, -9) === 'Field.php') + { + return str_replace('Field.php', '', $fileName); + } + else + { + return str_replace('.php', '', $fileName); + } + }, $fields); + + // Merge with existing fields and remove duplicates + $this->fields = array_unique(array_merge($processedFields, $this->fields)); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFour/CoreRule.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFour/CoreRule.php new file mode 100644 index 000000000..0da51e405 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFour/CoreRule.php @@ -0,0 +1,125 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFour; + + +use Joomla\CMS\Filesystem\Folder; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreRuleInterface; + + +/** + * Core Joomla Field Rules + * + * @since 3.2.0 + */ +final class CoreRule implements CoreRuleInterface +{ + /** + * Local Core Joomla Rules + * + * @var array + * @since 3.2.0 + **/ + protected array $rules = []; + + /** + * Local Core Joomla Rules Path + * + * @var string + * @since 3.2.0 + **/ + protected string $path; + + /** + * Constructor + * + * @since 3.2.0 + */ + public function __construct() + { + // set the path to the form validation rules + $this->path = JPATH_LIBRARIES . '/src/Form/Rule'; + } + + /** + * Get the Array of Existing Validation Rule Names + * + * @param bool $lowercase Switch to set rules lowercase + * + * @return array + * @since 3.2.0 + */ + public function get(bool $lowercase = false): array + { + if ($this->rules === []) + { + $this->set($this->path); + } + + // return rules if found + if ($this->rules !== []) + { + // check if the names should be all lowercase + if ($lowercase) + { + return array_map( + fn($item): string => strtolower((string) $item), + $this->rules + ); + } + + return $this->rules; + } + + // return empty array + return []; + } + + /** + * Set the rules found in a path + * + * @param string $path The path to load rules from + * @return void + * @since 3.2.0 + */ + private function set(string $path): void + { + // Check if the path exists + if (!Folder::exists($path)) + { + return; + } + + // Load all PHP files in this path + $rules = Folder::files($path, '\.php$', true, true); + + // Process the files to extract rule names + $processedRules = array_map(function ($name) { + $fileName = basename($name); + + // Remove 'Rule.php' if it exists or just '.php' otherwise + if (substr($fileName, -8) === 'Rule.php') + { + return str_replace('Rule.php', '', $fileName); + } + else + { + return str_replace('.php', '', $fileName); + } + }, $rules); + + // Merge with existing rules and remove duplicates + $this->rules = array_unique(array_merge($processedRules, $this->rules)); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFour/InputButton.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFour/InputButton.php new file mode 100644 index 000000000..fe5846455 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFour/InputButton.php @@ -0,0 +1,345 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFour; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\InputButtonInterface; + + +/** + * Compiler Field Input Button + * + * @since 3.2.0 + */ +final class InputButton implements InputButtonInterface +{ + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 3.2.0 + */ + protected Placeholder $placeholder; + + /** + * The Permission Class. + * + * @var Permission + * @since 3.2.0 + */ + protected Permission $permission; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Permission $permission The Permission Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Placeholder $placeholder, + Permission $permission) + { + $this->config = $config; + $this->placeholder = $placeholder; + $this->permission = $permission; + } + + /** + * get Add Button To List Field Input (getInput tweak) + * + * @param array $fieldData The field custom data + * + * @return string of getInput class on success empty string otherwise + * @since 3.2.0 + */ + public function get(array $fieldData): string + { + // make sure hte view values are set + if (isset($fieldData['add_button']) + && ($fieldData['add_button'] === 'true' + || 1 == $fieldData['add_button']) + && isset($fieldData['view']) + && isset($fieldData['views']) + && StringHelper::check($fieldData['view']) + && StringHelper::check($fieldData['views'])) + { + // set local component + $local_component = "com_" . $this->config->component_code_name; + // check that the component value is set + if (!isset($fieldData['component']) + || !StringHelper::check( + $fieldData['component'] + )) + { + $fieldData['component'] = $local_component; + } + // check that the component has the com_ value in it + if (strpos((string) $fieldData['component'], 'com_') === false + || strpos((string) $fieldData['component'], '=') !== false) + { + $fieldData['component'] = "com_" . $fieldData['component']; + } + // make sure the component is update if # # # or [ [ [ component placeholder is used + if (strpos((string) $fieldData['component'], (string) Placefix::h()) !== false + || strpos((string) $fieldData['component'], (string) Placefix::b()) !== false) // should not be needed... but + { + $fieldData['component'] = $this->placeholder->update_( + $fieldData['component'] + ); + } + // get core permissions + $coreLoad = false; + // add ref tags + $refLoad = true; + // fall back on the field component + $component = $fieldData['component']; + // check if we should add ref tags (since it only works well on local views) + if ($local_component !== $component) + { + // do not add ref tags + $refLoad = false; + } + // start building the add buttons/s + $addButton = array(); + $addButton[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $addButton[] = Indent::_(1) . " * Override to add new button"; + $addButton[] = Indent::_(1) . " *"; + $addButton[] = Indent::_(1) + . " * @return string The field input markup."; + $addButton[] = Indent::_(1) . " *"; + $addButton[] = Indent::_(1) . " * @since 3.2"; + $addButton[] = Indent::_(1) . " */"; + $addButton[] = Indent::_(1) . "protected function getInput()"; + $addButton[] = Indent::_(1) . "{"; + $addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " see if we should add buttons"; + $addButton[] = Indent::_(2) + . "\$set_button = \$this->getAttribute('button');"; + $addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get html"; + $addButton[] = Indent::_(2) . "\$html = parent::getInput();"; + $addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " if true set button"; + $addButton[] = Indent::_(2) . "if (\$set_button === 'true')"; + $addButton[] = Indent::_(2) . "{"; + $addButton[] = Indent::_(3) . "\$button = array();"; + $addButton[] = Indent::_(3) . "\$script = array();"; + $addButton[] = Indent::_(3) + . "\$button_code_name = \$this->getAttribute('name');"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " get the input from url"; + $addButton[] = Indent::_(3) . "\$app = Factory::getApplication();"; + $addButton[] = Indent::_(3) . "\$jinput = \$app->input;"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " get the view name & id"; + $addButton[] = Indent::_(3) + . "\$values = \$jinput->getArray(array("; + $addButton[] = Indent::_(4) . "'id' => 'int',"; + $addButton[] = Indent::_(4) . "'view' => 'word'"; + $addButton[] = Indent::_(3) . "));"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " check if new item"; + $addButton[] = Indent::_(3) . "\$ref = '';"; + $addButton[] = Indent::_(3) . "\$refJ = '';"; + if ($refLoad) + { + $addButton[] = Indent::_(3) + . "if (!is_null(\$values['id']) && strlen(\$values['view']))"; + $addButton[] = Indent::_(3) . "{"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " only load referral if not new item."; + $addButton[] = Indent::_(4) + . "\$ref = '&ref=' . \$values['view'] . '&refid=' . \$values['id'];"; + $addButton[] = Indent::_(4) + . "\$refJ = '&ref=' . \$values['view'] . '&refid=' . \$values['id'];"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " get the return value."; + $addButton[] = Indent::_(4) + . "\$_uri = (string) \Joomla\CMS\Uri\Uri::getInstance();"; + $addButton[] = Indent::_(4) + . "\$_return = urlencode(base64_encode(\$_uri));"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " load return value."; + $addButton[] = Indent::_(4) + . "\$ref .= '&return=' . \$_return;"; + $addButton[] = Indent::_(4) + . "\$refJ .= '&return=' . \$_return;"; + $addButton[] = Indent::_(3) . "}"; + } + else + { + $addButton[] = Indent::_(3) + . "if (!is_null(\$values['id']) && strlen(\$values['view']))"; + $addButton[] = Indent::_(3) . "{"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " only load field details if not new item."; + $addButton[] = Indent::_(4) + . "\$ref = '&field=' . \$values['view'] . '&field_id=' . \$values['id'];"; + $addButton[] = Indent::_(4) + . "\$refJ = '&field=' . \$values['view'] . '&field_id=' . \$values['id'];"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " get the return value."; + $addButton[] = Indent::_(4) + . "\$_uri = (string) \Joomla\CMS\Uri\Uri::getInstance();"; + $addButton[] = Indent::_(4) + . "\$_return = urlencode(base64_encode(\$_uri));"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " load return value."; + $addButton[] = Indent::_(4) + . "\$ref = '&return=' . \$_return;"; + $addButton[] = Indent::_(4) + . "\$refJ = '&return=' . \$_return;"; + $addButton[] = Indent::_(3) . "}"; + } + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " get button label"; + $addButton[] = Indent::_(3) + . "\$button_label = trim(\$button_code_name);"; + $addButton[] = Indent::_(3) + . "\$button_label = preg_replace('/_+/', ' ', \$button_label);"; + $addButton[] = Indent::_(3) + . "\$button_label = preg_replace('/\s+/', ' ', \$button_label);"; + $addButton[] = Indent::_(3) + . "\$button_label = preg_replace(\"/[^A-Za-z ]/\", '', \$button_label);"; + $addButton[] = Indent::_(3) + . "\$button_label = ucfirst(strtolower(\$button_label));"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " get user object"; + $addButton[] = Indent::_(3) . "\$user = Factory::getApplication()->getIdentity();"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " only add if user allowed to create " . $fieldData['view']; + // check if the item has permissions. + $addButton[] = Indent::_(3) . "if (\$user->authorise('" + . $this->permission->getGlobal($fieldData['view'], 'core.create') + . "', '" . $component . "') && \$app->isClient('administrator')) // TODO for now only in admin area."; + $addButton[] = Indent::_(3) . "{"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " build Create button"; + $addButton[] = Indent::_(4) + . "\$button[] = 'config->lang_prefix + . "_CREATE_NEW_S', \$button_label).'\" style=\"border-radius: 0px 4px 4px 0px;\""; + $addButton[] = Indent::_(5) . "href=\"index.php?option=" + . $fieldData['component'] . "&view=" . $fieldData['view'] + . "&layout=edit'.\$ref.'\" >"; + $addButton[] = Indent::_(5) + . "';"; + $addButton[] = Indent::_(3) . "}"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " only add if user allowed to edit " . $fieldData['view']; + // check if the item has permissions. + $addButton[] = Indent::_(3) . "if (\$user->authorise('" + . $this->permission->getGlobal($fieldData['view'], 'core.edit') + . "', '" . $component . "') && \$app->isClient('administrator')) // TODO for now only in admin area."; + $addButton[] = Indent::_(3) . "{"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " build edit button"; + $addButton[] = Indent::_(4) + . "\$button[] = 'config->lang_prefix + . "_EDIT_S', \$button_label).'\" style=\"display: none; border-radius: 0px 4px 4px 0px;\" href=\"#\" >"; + $addButton[] = Indent::_(5) + . "';"; + + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " build script"; +$addButton[] = Indent::_(4) . "\$script[] = \""; + $addButton[] = Indent::_(5) . "document.addEventListener('DOMContentLoaded', function() {"; + $addButton[] = Indent::_(6) + . "document.getElementById('jform_\".\$button_code_name.\"').addEventListener('change', function(e) {"; + $addButton[] = Indent::_(7) . "e.preventDefault();"; + $addButton[] = Indent::_(7) + . "let \".\$button_code_name.\"Value = this.value;"; + $addButton[] = Indent::_(7) + . "\".\$button_code_name.\"Button(\".\$button_code_name.\"Value);"; + $addButton[] = Indent::_(6) . "});"; + $addButton[] = Indent::_(6) + . "let \".\$button_code_name.\"Value = document.getElementById('jform_\".\$button_code_name.\"').value;"; + $addButton[] = Indent::_(6) + . "\".\$button_code_name.\"Button(\".\$button_code_name.\"Value);"; + $addButton[] = Indent::_(5) . "});"; + $addButton[] = Indent::_(5) + . "function \".\$button_code_name.\"Button(value) {"; + $addButton[] = Indent::_(6) + . "var createButton = document.getElementById('\".\$button_code_name.\"Create');"; + $addButton[] = Indent::_(6) + . "var editButton = document.getElementById('\".\$button_code_name.\"Edit');"; + $addButton[] = Indent::_(6) + . "if (value > 0) {"; // TODO not ideal since value may not be an (int) + $addButton[] = Indent::_(7) . "// hide the create button"; + $addButton[] = Indent::_(7) + . "createButton.style.display = 'none';"; + $addButton[] = Indent::_(7) . "// show edit button"; + $addButton[] = Indent::_(7) + . "editButton.style.display = 'block';"; + $addButton[] = Indent::_(7) . "let url = 'index.php?option=" + . $fieldData['component'] . "&view=" . $fieldData['views'] + . "&task=" . $fieldData['view'] + . ".edit&id='+value+'\".\$refJ.\"';"; // TODO this value may not be the ID + $addButton[] = Indent::_(7) + . "editButton.setAttribute('href', url);"; + $addButton[] = Indent::_(6) . "} else {"; + $addButton[] = Indent::_(7) . "// show the create button"; + $addButton[] = Indent::_(7) + . "createButton.style.display = 'block';"; + $addButton[] = Indent::_(7) . "// hide edit button"; + $addButton[] = Indent::_(7) + . "editButton.style.display = 'none';"; + $addButton[] = Indent::_(6) . "}"; + $addButton[] = Indent::_(5) . "}\";"; + + $addButton[] = Indent::_(3) . "}"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " check if button was created for " . $fieldData['view'] + . " field."; + $addButton[] = Indent::_(3) + . "if (is_array(\$button) && count(\$button) > 0)"; + $addButton[] = Indent::_(3) . "{"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Load the needed script."; + $addButton[] = Indent::_(4) + . "\$document = Factory::getApplication()->getDocument();"; + $addButton[] = Indent::_(4) + . "\$document->addScriptDeclaration(implode(' ',\$script));"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " return the button attached to input field."; + $addButton[] = Indent::_(4) + . "return '
    ' .\$html . implode('',\$button).'
    ';"; + $addButton[] = Indent::_(3) . "}"; + $addButton[] = Indent::_(2) . "}"; + $addButton[] = Indent::_(2) . "return \$html;"; + $addButton[] = Indent::_(1) . "}"; + + return implode(PHP_EOL, $addButton); + } + + return ''; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFour/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFour/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaFour/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaThree/CoreField.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaThree/CoreField.php new file mode 100644 index 000000000..4b3a42fff --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaThree/CoreField.php @@ -0,0 +1,130 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaThree; + + +use Joomla\CMS\Filesystem\Folder; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreFieldInterface; + + +/** + * Core Joomla Fields + * + * @since 3.2.0 + */ +final class CoreField implements CoreFieldInterface +{ + /** + * Local Core Joomla Fields + * + * @var array|null + * @since 3.2.0 + **/ + protected array $fields = []; + + /** + * Local Core Joomla Fields Path + * + * @var array + * @since 3.2.0 + **/ + protected array $paths = []; + + /** + * Constructor + * + * @since 3.2.0 + */ + public function __construct() + { + // set the path to the form validation fields + $this->paths[] = JPATH_LIBRARIES . '/src/Form/Field'; + $this->paths[] = JPATH_LIBRARIES . '/joomla/form/fields'; + } + + /** + * Get the Array of Existing Validation Field Names + * + * @param bool $lowercase Switch to set fields lowercase + * + * @return array + * @since 3.2.0 + */ + public function get(bool $lowercase = false): array + { + if ($this->fields === []) + { + // check if the path exist + foreach ($this->paths as $path) + { + $this->set($path); + } + } + + // return fields if found + if ($this->fields !== []) + { + // check if the names should be all lowercase + if ($lowercase) + { + return array_map( + fn($item): string => strtolower((string) $item), + $this->fields + ); + } + + return $this->fields; + } + + // return empty array + return []; + } + + /** + * Set the fields found in a path + * + * @param string $path The path to load fields from + * @return void + * @since 3.2.0 + */ + private function set(string $path): void + { + // Check if the path exists + if (!Folder::exists($path)) + { + return; + } + + // Load all PHP files in this path + $fields = Folder::files($path, '\.php$', true, true); + + // Process the files to extract field names + $processedFields = array_map(function ($name) { + $fileName = basename($name); + + // Remove 'Field.php' if it exists or just '.php' otherwise + if (substr($fileName, -9) === 'Field.php') + { + return str_replace('Field.php', '', $fileName); + } + else + { + return str_replace('.php', '', $fileName); + } + }, $fields); + + // Merge with existing fields and remove duplicates + $this->fields = array_unique(array_merge($processedFields, $this->fields)); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaThree/CoreRule.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaThree/CoreRule.php new file mode 100644 index 000000000..378f9f926 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaThree/CoreRule.php @@ -0,0 +1,125 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaThree; + + +use Joomla\CMS\Filesystem\Folder; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreRuleInterface; + + +/** + * Core Joomla Field Rules + * + * @since 3.2.0 + */ +final class CoreRule implements CoreRuleInterface +{ + /** + * Local Core Joomla Rules + * + * @var array + * @since 3.2.0 + **/ + protected array $rules = []; + + /** + * Local Core Joomla Rules Path + * + * @var string + * @since 3.2.0 + **/ + protected string $path; + + /** + * Constructor + * + * @since 3.2.0 + */ + public function __construct() + { + // set the path to the form validation rules + $this->path = JPATH_LIBRARIES . '/src/Form/Rule'; + } + + /** + * Get the Array of Existing Validation Rule Names + * + * @param bool $lowercase Switch to set rules lowercase + * + * @return array + * @since 3.2.0 + */ + public function get(bool $lowercase = false): array + { + if ($this->rules === []) + { + $this->set($this->path); + } + + // return rules if found + if ($this->rules !== []) + { + // check if the names should be all lowercase + if ($lowercase) + { + return array_map( + fn($item): string => strtolower((string) $item), + $this->rules + ); + } + + return $this->rules; + } + + // return empty array + return []; + } + + /** + * Set the rules found in a path + * + * @param string $path The path to load rules from + * @return void + * @since 3.2.0 + */ + private function set(string $path): void + { + // Check if the path exists + if (!Folder::exists($path)) + { + return; + } + + // Load all PHP files in this path + $rules = Folder::files($path, '\.php$', true, true); + + // Process the files to extract rule names + $processedRules = array_map(function ($name) { + $fileName = basename($name); + + // Remove 'Rule.php' if it exists or just '.php' otherwise + if (substr($fileName, -8) === 'Rule.php') + { + return str_replace('Rule.php', '', $fileName); + } + else + { + return str_replace('.php', '', $fileName); + } + }, $rules); + + // Merge with existing rules and remove duplicates + $this->rules = array_unique(array_merge($processedRules, $this->rules)); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaThree/CoreValidation.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaThree/CoreValidation.php deleted file mode 100644 index 7583cd684..000000000 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaThree/CoreValidation.php +++ /dev/null @@ -1,116 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -namespace VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaThree; - - -use Joomla\CMS\Filesystem\Folder; -use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreValidationInterface; - - -/** - * Core Joomla Field Validation Rules - * - * @since 3.2.0 - */ -class CoreValidation implements CoreValidationInterface -{ - /** - * Local Core Joomla Rules - * - * @var array|null - * @since 3.2.0 - **/ - protected ?array $rules = null; - - /** - * Local Core Joomla Rules Path - * - * @var string - * @since 3.2.0 - **/ - protected string $path; - - /** - * Constructor - * - * @since 3.2.0 - */ - public function __construct() - { - // set the path to the form validation rules - $this->path = JPATH_LIBRARIES . '/src/Form/Rule'; - } - - /** - * Get the Array of Existing Validation Rule Names - * - * @param bool $lowercase Switch to set rules lowercase - * - * @return array - * @since 3.2.0 - */ - public function get(bool $lowercase = false): array - { - if (!$this->rules) - { - // check if the path exist - if (!Folder::exists($this->path)) - { - return []; - } - - // we must first store the current working directory - $joomla = getcwd(); - - // go to that folder - chdir($this->path); - - // load all the files in this path - $rules = Folder::files('.', '\.php', true, true); - - // change back to Joomla working directory - chdir($joomla); - - // make sure we have an array - if (!ArrayHelper::check($rules)) - { - return false; - } - - // remove the Rule.php from the name - $this->rules = array_map( - fn($name): string => str_replace(array('./','Rule.php'), '', (string) $name), - $rules - ); - } - - // return rules if found - if (is_array($this->rules)) - { - // check if the names should be all lowercase - if ($lowercase) - { - return array_map( - fn($item): string => strtolower((string) $item), - $this->rules - ); - } - return $this->rules; - } - - // return empty array - return []; - } - -} - diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaThree/InputButton.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaThree/InputButton.php new file mode 100644 index 000000000..fb3ac3a87 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/JoomlaThree/InputButton.php @@ -0,0 +1,339 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaThree; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\InputButtonInterface; + + +/** + * Compiler Field Input Button + * + * @since 3.2.0 + */ +final class InputButton implements InputButtonInterface +{ + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 3.2.0 + */ + protected Placeholder $placeholder; + + /** + * The Permission Class. + * + * @var Permission + * @since 3.2.0 + */ + protected Permission $permission; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Permission $permission The Permission Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Placeholder $placeholder, + Permission $permission) + { + $this->config = $config; + $this->placeholder = $placeholder; + $this->permission = $permission; + } + + /** + * get Add Button To List Field Input (getInput tweak) + * + * @param array $fieldData The field custom data + * + * @return string of getInput class on success empty string otherwise + * @since 3.2.0 + */ + public function get(array $fieldData): string + { + // make sure hte view values are set + if (isset($fieldData['add_button']) + && ($fieldData['add_button'] === 'true' + || 1 == $fieldData['add_button']) + && isset($fieldData['view']) + && isset($fieldData['views']) + && StringHelper::check($fieldData['view']) + && StringHelper::check($fieldData['views'])) + { + // set local component + $local_component = "com_" . $this->config->component_code_name; + // check that the component value is set + if (!isset($fieldData['component']) + || !StringHelper::check( + $fieldData['component'] + )) + { + $fieldData['component'] = $local_component; + } + // check that the component has the com_ value in it + if (strpos((string) $fieldData['component'], 'com_') === false + || strpos((string) $fieldData['component'], '=') !== false) + { + $fieldData['component'] = "com_" . $fieldData['component']; + } + // make sure the component is update if # # # or [ [ [ component placeholder is used + if (strpos((string) $fieldData['component'], (string) Placefix::h()) !== false + || strpos((string) $fieldData['component'], (string) Placefix::b()) !== false) // should not be needed... but + { + $fieldData['component'] = $this->placeholder->update_( + $fieldData['component'] + ); + } + // get core permissions + $coreLoad = false; + // add ref tags + $refLoad = true; + // fall back on the field component + $component = $fieldData['component']; + // check if we should add ref tags (since it only works well on local views) + if ($local_component !== $component) + { + // do not add ref tags + $refLoad = false; + } + // start building the add buttons/s + $addButton = array(); + $addButton[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $addButton[] = Indent::_(1) . " * Override to add new button"; + $addButton[] = Indent::_(1) . " *"; + $addButton[] = Indent::_(1) + . " * @return string The field input markup."; + $addButton[] = Indent::_(1) . " *"; + $addButton[] = Indent::_(1) . " * @since 3.2"; + $addButton[] = Indent::_(1) . " */"; + $addButton[] = Indent::_(1) . "protected function getInput()"; + $addButton[] = Indent::_(1) . "{"; + $addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " see if we should add buttons"; + $addButton[] = Indent::_(2) + . "\$set_button = \$this->getAttribute('button');"; + $addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get html"; + $addButton[] = Indent::_(2) . "\$html = parent::getInput();"; + $addButton[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " if true set button"; + $addButton[] = Indent::_(2) . "if (\$set_button === 'true')"; + $addButton[] = Indent::_(2) . "{"; + $addButton[] = Indent::_(3) . "\$button = array();"; + $addButton[] = Indent::_(3) . "\$script = array();"; + $addButton[] = Indent::_(3) + . "\$button_code_name = \$this->getAttribute('name');"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " get the input from url"; + $addButton[] = Indent::_(3) . "\$app = Factory::getApplication();"; + $addButton[] = Indent::_(3) . "\$jinput = \$app->input;"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " get the view name & id"; + $addButton[] = Indent::_(3) + . "\$values = \$jinput->getArray(array("; + $addButton[] = Indent::_(4) . "'id' => 'int',"; + $addButton[] = Indent::_(4) . "'view' => 'word'"; + $addButton[] = Indent::_(3) . "));"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " check if new item"; + $addButton[] = Indent::_(3) . "\$ref = '';"; + $addButton[] = Indent::_(3) . "\$refJ = '';"; + if ($refLoad) + { + $addButton[] = Indent::_(3) + . "if (!is_null(\$values['id']) && strlen(\$values['view']))"; + $addButton[] = Indent::_(3) . "{"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " only load referral if not new item."; + $addButton[] = Indent::_(4) + . "\$ref = '&ref=' . \$values['view'] . '&refid=' . \$values['id'];"; + $addButton[] = Indent::_(4) + . "\$refJ = '&ref=' . \$values['view'] . '&refid=' . \$values['id'];"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " get the return value."; + $addButton[] = Indent::_(4) + . "\$_uri = (string) \Joomla\CMS\Uri\Uri::getInstance();"; + $addButton[] = Indent::_(4) + . "\$_return = urlencode(base64_encode(\$_uri));"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " load return value."; + $addButton[] = Indent::_(4) + . "\$ref .= '&return=' . \$_return;"; + $addButton[] = Indent::_(4) + . "\$refJ .= '&return=' . \$_return;"; + $addButton[] = Indent::_(3) . "}"; + } + else + { + $addButton[] = Indent::_(3) + . "if (!is_null(\$values['id']) && strlen(\$values['view']))"; + $addButton[] = Indent::_(3) . "{"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " only load field details if not new item."; + $addButton[] = Indent::_(4) + . "\$ref = '&field=' . \$values['view'] . '&field_id=' . \$values['id'];"; + $addButton[] = Indent::_(4) + . "\$refJ = '&field=' . \$values['view'] . '&field_id=' . \$values['id'];"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " get the return value."; + $addButton[] = Indent::_(4) + . "\$_uri = (string) \Joomla\CMS\Uri\Uri::getInstance();"; + $addButton[] = Indent::_(4) + . "\$_return = urlencode(base64_encode(\$_uri));"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " load return value."; + $addButton[] = Indent::_(4) + . "\$ref = '&return=' . \$_return;"; + $addButton[] = Indent::_(4) + . "\$refJ = '&return=' . \$_return;"; + $addButton[] = Indent::_(3) . "}"; + } + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " get button label"; + $addButton[] = Indent::_(3) + . "\$button_label = trim(\$button_code_name);"; + $addButton[] = Indent::_(3) + . "\$button_label = preg_replace('/_+/', ' ', \$button_label);"; + $addButton[] = Indent::_(3) + . "\$button_label = preg_replace('/\s+/', ' ', \$button_label);"; + $addButton[] = Indent::_(3) + . "\$button_label = preg_replace(\"/[^A-Za-z ]/\", '', \$button_label);"; + $addButton[] = Indent::_(3) + . "\$button_label = ucfirst(strtolower(\$button_label));"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " get user object"; + $addButton[] = Indent::_(3) . "\$user = Factory::getUser();"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " only add if user allowed to create " . $fieldData['view']; + // check if the item has permissions. + $addButton[] = Indent::_(3) . "if (\$user->authorise('" + . $this->permission->getGlobal($fieldData['view'], 'core.create') + . "', '" . $component . "') && \$app->isClient('administrator')) // TODO for now only in admin area."; + $addButton[] = Indent::_(3) . "{"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " build Create button"; + $addButton[] = Indent::_(4) + . "\$button[] = 'config->lang_prefix + . "_CREATE_NEW_S', \$button_label).'\" style=\"border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;\""; + $addButton[] = Indent::_(5) . "href=\"index.php?option=" + . $fieldData['component'] . "&view=" . $fieldData['view'] + . "&layout=edit'.\$ref.'\" >"; + $addButton[] = Indent::_(5) + . "';"; + $addButton[] = Indent::_(3) . "}"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " only add if user allowed to edit " . $fieldData['view']; + // check if the item has permissions. + $addButton[] = Indent::_(3) . "if (\$user->authorise('" + . $this->permission->getGlobal($fieldData['view'], 'core.edit') + . "', '" . $component . "') && \$app->isClient('administrator')) // TODO for now only in admin area."; + $addButton[] = Indent::_(3) . "{"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " build edit button"; + $addButton[] = Indent::_(4) + . "\$button[] = 'config->lang_prefix + . "_EDIT_S', \$button_label).'\" style=\"display: none; padding: 4px 4px 4px 7px;\" href=\"#\" >"; + $addButton[] = Indent::_(5) + . "';"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " build script"; + $addButton[] = Indent::_(4) . "\$script[] = \""; + $addButton[] = Indent::_(5) . "jQuery(document).ready(function() {"; + $addButton[] = Indent::_(6) + . "jQuery('#adminForm').on('change', '#jform_\".\$button_code_name.\"',function (e) {"; + $addButton[] = Indent::_(7) . "e.preventDefault();"; + $addButton[] = Indent::_(7) + . "var \".\$button_code_name.\"Value = jQuery('#jform_\".\$button_code_name.\"').val();"; + $addButton[] = Indent::_(7) + . "\".\$button_code_name.\"Button(\".\$button_code_name.\"Value);"; + $addButton[] = Indent::_(6) . "});"; + $addButton[] = Indent::_(6) + . "var \".\$button_code_name.\"Value = jQuery('#jform_\".\$button_code_name.\"').val();"; + $addButton[] = Indent::_(6) + . "\".\$button_code_name.\"Button(\".\$button_code_name.\"Value);"; + $addButton[] = Indent::_(5) . "});"; + $addButton[] = Indent::_(5) + . "function \".\$button_code_name.\"Button(value) {"; + $addButton[] = Indent::_(6) + . "if (value > 0) {"; // TODO not ideal since value may not be an (int) + $addButton[] = Indent::_(7) . "// hide the create button"; + $addButton[] = Indent::_(7) + . "jQuery('#\".\$button_code_name.\"Create').hide();"; + $addButton[] = Indent::_(7) . "// show edit button"; + $addButton[] = Indent::_(7) + . "jQuery('#\".\$button_code_name.\"Edit').show();"; + $addButton[] = Indent::_(7) . "var url = 'index.php?option=" + . $fieldData['component'] . "&view=" . $fieldData['views'] + . "&task=" . $fieldData['view'] + . ".edit&id='+value+'\".\$refJ.\"';"; // TODO this value may not be the ID + $addButton[] = Indent::_(7) + . "jQuery('#\".\$button_code_name.\"Edit').attr('href', url);"; + $addButton[] = Indent::_(6) . "} else {"; + $addButton[] = Indent::_(7) . "// show the create button"; + $addButton[] = Indent::_(7) + . "jQuery('#\".\$button_code_name.\"Create').show();"; + $addButton[] = Indent::_(7) . "// hide edit button"; + $addButton[] = Indent::_(7) + . "jQuery('#\".\$button_code_name.\"Edit').hide();"; + $addButton[] = Indent::_(6) . "}"; + $addButton[] = Indent::_(5) . "}\";"; + $addButton[] = Indent::_(3) . "}"; + $addButton[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " check if button was created for " . $fieldData['view'] + . " field."; + $addButton[] = Indent::_(3) + . "if (is_array(\$button) && count(\$button) > 0)"; + $addButton[] = Indent::_(3) . "{"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Load the needed script."; + $addButton[] = Indent::_(4) + . "\$document = Factory::getDocument();"; + $addButton[] = Indent::_(4) + . "\$document->addScriptDeclaration(implode(' ',\$script));"; + $addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " return the button attached to input field."; + $addButton[] = Indent::_(4) + . "return '
    ' .\$html . implode('',\$button).'
    ';"; + $addButton[] = Indent::_(3) . "}"; + $addButton[] = Indent::_(2) . "}"; + $addButton[] = Indent::_(2) . "return \$html;"; + $addButton[] = Indent::_(1) . "}"; + + return implode(PHP_EOL, $addButton); + } + + return ''; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/Rule.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/Rule.php new file mode 100644 index 000000000..a563a2618 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/Rule.php @@ -0,0 +1,166 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Field; + + +use VDM\Joomla\Componentbuilder\Compiler\Registry; +use VDM\Joomla\Componentbuilder\Compiler\Customcode; +use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreRuleInterface as CoreRule; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\GetHelper; + + +/** + * Compiler Field Rules + * + * @since 3.2.0 + */ +class Rule +{ + /** + * The Registry Class. + * + * @var Registry + * @since 3.2.0 + */ + protected Registry $registry; + + /** + * The Customcode Class. + * + * @var Customcode + * @since 3.2.0 + */ + protected Customcode $customcode; + + /** + * The Gui Class. + * + * @var Gui + * @since 3.2.0 + */ + protected Gui $gui; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 3.2.0 + */ + protected Placeholder $placeholder; + + /** + * The CoreRuleInterface Class. + * + * @var CoreRule + * @since 3.2.0 + */ + protected CoreRule $corerule; + + /** + * Constructor. + * + * @param Registry $registry The Registry Class. + * @param Customcode $customcode The Customcode Class. + * @param Gui $gui The Gui Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param CoreRule $corerule The CoreRuleInterface Class. + * + * @since 3.2.0 + */ + public function __construct(Registry $registry, Customcode $customcode, Gui $gui, + Placeholder $placeholder, CoreRule $corerule) + { + $this->registry = $registry; + $this->customcode = $customcode; + $this->gui = $gui; + $this->placeholder = $placeholder; + $this->corerule = $corerule; + } + + /** + * Set the validation rule + * + * @param int $id The field id + * @param string $field The field string + * + * @return void + * @since 3.2.0 + */ + public function set(int $id, string $field) + { + // check if we have validate (validation rule set) + $validation_rule = GetHelper::between( + $field, 'validate="', '"' + ); + + if (StringHelper::check($validation_rule)) + { + // make sure it is lowercase + $validation_rule = StringHelper::safe( + $validation_rule + ); + + // link this field to this validation (don't move this down) + $this->registry->set("validation.linked.${id}", $validation_rule); + + // make sure it is not already set + if ($this->registry->get("validation.rules.${validation_rule}") === null) + { + // get joomla core validation names and make sure this rule is not a core validation rule + if (!in_array($validation_rule, (array) $this->corerule->get(true))) + { + // get the class methods for this rule if it exists + if (($php_code = GetHelper::var( + 'validation_rule', $validation_rule, 'name', 'php' + )) !== false) + { + // open and set the validation rule + $this->registry->set("validation.rules.${validation_rule}", + $this->gui->set( + $this->placeholder->update_( + $this->customcode->update( + base64_decode( + (string) $php_code + ) + ) + ), + array( + 'table' => 'validation_rule', + 'field' => 'php', + 'id' => GetHelper::var( + 'validation_rule', + $validation_rule, 'name', 'id' + ), + 'type' => 'php' + ) + ) + ); + } + else + { + // TODO set the notice that this validation rule is custom and was not found + $this->registry->remove("validation.linked.${id}"); + } + } + else + { + // remove link (we only want custom validations linked) + $this->registry->remove("validation.linked.${id}"); + } + } + } + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/Validation.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/Validation.php deleted file mode 100644 index afe05dca4..000000000 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Field/Validation.php +++ /dev/null @@ -1,168 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -namespace VDM\Joomla\Componentbuilder\Compiler\Field; - - -use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; -use VDM\Joomla\Utilities\StringHelper; -use VDM\Joomla\Utilities\GetHelper; -use VDM\Joomla\Componentbuilder\Compiler\Registry; -use VDM\Joomla\Componentbuilder\Compiler\Customcode; -use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui; -use VDM\Joomla\Componentbuilder\Compiler\Placeholder; -use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreValidationInterface; - - -/** - * Compiler Field Validation Rules - * - * @since 3.2.0 - */ -class Validation -{ - /** - * Compiler registry - * - * @var Registry - * @since 3.2.0 - */ - protected Registry $registry; - - /** - * Compiler Gui - * - * @var Gui - * @since 3.2.0 - */ - protected Gui $gui; - - /** - * Compiler Placeholder - * - * @var Placeholder - * @since 3.2.0 - */ - protected Placeholder $placeholder; - - /** - * Compiler Customcode - * - * @var Customcode - * @since 3.2.0 - */ - protected Customcode $customcode; - - /** - * Compiler Field Core Validation - * - * @var CoreValidationInterface - * @since 3.2.0 - */ - protected CoreValidationInterface $validation; - - /** - * Constructor - * - * @param Registry|null $registry The compiler registry object. - * @param Gui|null $gui The compiler customcode gui object. - * @param Placeholder|null $placeholder The compiler placeholder object. - * @param Customcode|null $customcode The compiler customcode object. - * @param CoreValidationInterface|null $validation The core validation rule object. - * - * @since 3.2.0 - */ - public function __construct(?Registry $registry = null, ?Gui $gui = null, ?Placeholder $placeholder = null, - ?Customcode $customcode = null, ?CoreValidationInterface $validation = null) - { - $this->registry = $registry ?: Compiler::_('Registry'); - $this->gui = $gui ?: Compiler::_('Customcode.Gui'); - $this->placeholder = $placeholder ?: Compiler::_('Placeholder'); - $this->customcode = $customcode ?: Compiler::_('Customcode'); - $this->validation = $validation ?: Compiler::_('Field.Core.Validation'); - } - - /** - * Set the validation rule - * - * @param int $id The field id - * @param string $field The field string - * - * @return void - * @since 3.2.0 - */ - public function set(int $id, string $field) - { - // check if we have validate (validation rule set) - $validation_rule = GetHelper::between( - $field, 'validate="', '"' - ); - - if (StringHelper::check($validation_rule)) - { - // make sure it is lowercase - $validation_rule = StringHelper::safe( - $validation_rule - ); - - // link this field to this validation (don't move this down) - $this->registry->set("validation.linked.${id}", $validation_rule); - - // make sure it is not already set - if ($this->registry->get("validation.rules.${validation_rule}") === null) - { - // get joomla core validation names and make sure this rule is not a core validation rule - if (!in_array($validation_rule, (array) $this->validation->get(true))) - { - // get the class methods for this rule if it exists - if (($php_code = GetHelper::var( - 'validation_rule', $validation_rule, 'name', 'php' - )) !== false) - { - // open and set the validation rule - $this->registry->set("validation.rules.${validation_rule}", - $this->gui->set( - $this->placeholder->update_( - $this->customcode->update( - base64_decode( - (string) $php_code - ) - ) - ), - array( - 'table' => 'validation_rule', - 'field' => 'php', - 'id' => GetHelper::var( - 'validation_rule', - $validation_rule, 'name', 'id' - ), - 'type' => 'php' - ) - ) - ); - } - else - { - // TODO set the notice that this validation rule is custom and was not found - $this->registry->remove("validation.linked.${id}"); - } - } - else - { - // remove link (we only want custom validations linked) - $this->registry->remove("validation.linked.${id}"); - } - } - } - } - -} - diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Compiler.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Compiler.php new file mode 100644 index 000000000..47bd9f70c --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Compiler.php @@ -0,0 +1,1667 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Helper; + + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Filesystem\Folder; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\FileHelper; +use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Utilities\MathHelper; +use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; +use VDM\Joomla\Componentbuilder\Compiler\Helper\Infusion; + + +/** + * Compiler class + * + * @deprecated 3.3 + */ +class Compiler extends Infusion +{ + /** + * The Temp path + * + * @var string + */ + public $tempPath; + + /** + * The timer + * + * @var string + */ + private $time_start; + private $time_end; + public $secondsCompiled; + + /** + * The file path array + * + * @var string + */ + public $filepath + = array( + 'component' => '', + 'component-folder' => '', + 'package' => '', + 'plugins' => array(), + 'plugins-folders' => array(), + 'modules' => array() + ); + + // fixed pathes + protected $dynamicIntegration = false; + protected $backupPath = false; + protected $repoPath = false; + protected $addCustomCodeAt = array(); + + /** + * Constructor + */ + public function __construct($config = array()) + { + // to check the compiler speed + $this->time_start = microtime(true); + CFactory::_('Utilities.Counter')->start(); + // first we run the parent constructors + if (parent::__construct()) + { + // set temp directory + $comConfig = Factory::getConfig(); + $this->tempPath = $comConfig->get('tmp_path'); + // set some folder paths in relation to distribution + if (CFactory::_('Config')->backup) + { + $this->backupPath = $this->params->get( + 'backup_folder_path', $this->tempPath + ); + // see if component has overriding options set + if (CFactory::_('Component')->get('add_backup_folder_path', 0) == 1) + { + $this->backupPath = CFactory::_('Component')->get('backup_folder_path', $this->backupPath); + } + $this->dynamicIntegration = true; + } + // set local repos switch + if (CFactory::_('Config')->repository) + { + $this->repoPath = $this->params->get('git_folder_path', null); + + // see if component has overriding options set + if (CFactory::_('Component')->get('add_git_folder_path', 0) == 1) + { + $this->repoPath = CFactory::_('Component')->get('git_folder_path', $this->repoPath); + } + } + // remove site folder if not needed (TODO add check if custom script was moved to site folder then we must do a more complex cleanup here) + if (CFactory::_('Config')->remove_site_folder && CFactory::_('Config')->remove_site_edit_folder) + { + // first remove the files and folders + CFactory::_('Utilities.Folder')->remove(CFactory::_('Utilities.Paths')->component_path . '/site'); + // clear form component xml + $xmlPath = CFactory::_('Utilities.Paths')->component_path . '/' + . CFactory::_('Compiler.Builder.Content.One')->get('component') . '.xml'; + $componentXML = FileHelper::getContent($xmlPath); + $textToSite = GetHelper::between( + $componentXML, '', '' + ); + $textToSiteLang = GetHelper::between( + $componentXML, '', '' + ); + $componentXML = str_replace( + array('' . $textToSite . "", + '' . $textToSiteLang + . ""), array('', ''), (string) $componentXML + ); + CFactory::_('Utilities.File')->write($xmlPath, $componentXML); + } + + // Trigger Event: jcb_ce_onBeforeUpdateFiles + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeUpdateFiles', [$this] // TODO move setGetItemsModelMethod to its own class + ); + + // now update the files + if (!$this->updateFiles()) + { + return false; + } + // Trigger Event: jcb_ce_onBeforeGetCustomCode + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeGetCustomCode' + ); + // now insert into the new files + if (CFactory::_('Customcode')->get()) + { + // Trigger Event: jcb_ce_onBeforeAddCustomCode + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeAddCustomCode' + ); + + $this->addCustomCode(); + } + // Trigger Event: jcb_ce_onBeforeSetLangFileData + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeSetLangFileData' + ); + // set the lang data now + $this->setLangFileData(); + // set the language notice if it was set + if (CFactory::_('Compiler.Builder.Language.Messages')->isActive()) + { + if (CFactory::_('Compiler.Builder.Language.Messages')->isArray('exclude')) + { + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_HR_HTHREELANGUAGE_WARNINGHTHREE'), 'Warning' + ); + foreach (CFactory::_('Compiler.Builder.Language.Messages')->get('exclude') as $tag => $targets) + { + foreach ($targets as $extention => $files) + { + foreach ($files as $file => $percentage) + { + $this->app->enqueueMessage( + Text::sprintf( + 'The [%s].%s %s language has %s% translated, you will need to translate %s% of the language strings before it will be added.', + $extention, $file, $tag, $percentage, CFactory::_('Config')->percentage_language_add + ), 'Warning' + ); + } + } + } + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_HR_HTHREELANGUAGE_NOTICEHTHREE'), 'Notice' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'You can change this percentage of translated strings required in the global options of JCB.
    Please watch this tutorial for more help surrounding the JCB translations manager.', + '"https://youtu.be/zzAcVkn_cWU?list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE" target="_blank" title="JCB Tutorial surrounding Translation Manager"' + ), 'Notice' + ); + } + // set why the strings were added + $whyAddedLang = Text::sprintf( + 'because more then %s% of the strings have been translated.', + CFactory::_('Config')->percentage_language_add + ); + if (CFactory::_('Config')->get('debug_line_nr', false)) + { + $whyAddedLang = Text::_( + 'because the debugging mode is on. (debug line numbers)' + ); + } + // show languages that were added + if (CFactory::_('Compiler.Builder.Language.Messages')->isArray('include')) + { + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_HR_HTHREELANGUAGE_NOTICEHTHREE'), 'Notice' + ); + foreach (CFactory::_('Compiler.Builder.Language.Messages')->get('include') as $tag => $targets) + { + foreach ($targets as $extention => $files) + { + foreach ($files as $file => $percentage) + { + $this->app->enqueueMessage( + Text::sprintf( + 'The [%s].%s %s language has %s% translated. Was added %s', + $extention, $file, $tag, $percentage, $whyAddedLang + ), 'Notice' + ); + } + } + } + } + } + // set assets table column fix type messages + $message_fix['intelligent'] = Text::_( + 'The intelligent fix only updates the #__assets table\'s column when it detects that it is too small for the worse case. The intelligent fix also only reverse the #__assets table\'s update on uninstall of the component if it detects that no other component needs the rules column to be larger any longer. This options also shows a notice to the end user of all that it does to the #__assets table on installation and uninstalling of the component.' + ); + $message_fix['sql'] = Text::_( + 'The SQL fix updates the #__assets table\'s column size on installation of the component and reverses it back to the Joomla default on uninstall of the component.' + ); + // get the asset table fix switch + $add_assets_table_fix = CFactory::_('Config')->get('add_assets_table_fix', 0); + // set assets table rules column notice + if ($add_assets_table_fix) + { + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_HR_HTHREEASSETS_TABLE_NOTICEHTHREE'), 'Notice' + ); + $asset_table_fix_type = ($add_assets_table_fix == 2) + ? 'intelligent' : 'sql'; + $this->app->enqueueMessage( + Text::sprintf( + 'The #__assets table %s fix has been added to this component. %s', + $asset_table_fix_type, + $message_fix[$asset_table_fix_type] + ), 'Notice' + ); + } + // set assets table rules column Warning + elseif (CFactory::_('Utilities.Counter')->accessSize >= 30) + { + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_HR_HTHREEASSETS_TABLE_WARNINGHTHREE'), 'Warning' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'The Joomla #__assets table\'s rules column has to be fixed for this component to work coherently. JCB has detected that in worse case the rules column in the #__assets table may require %s characters, and yet the Joomla default is only varchar(5120). JCB has three option to resolve this issue, first use less permissions in your component, second use the SQL fix, or the intelligent fix. %s %s', + CFactory::_('Config')->access_worse_case, $message_fix['intelligent'], + $message_fix['sql'] + ), 'Warning' + ); + } + // set assets table name column warning if not set + if (!$add_assets_table_fix && CFactory::_('Config')->add_assets_table_name_fix) + { + // only add if not already added + if (CFactory::_('Utilities.Counter')->accessSize < 30) + { + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_HR_HTHREEASSETS_TABLE_WARNINGHTHREE'), + 'Warning' + ); + } + $this->app->enqueueMessage( + Text::sprintf( + 'The Joomla #__assets table\'s name column has to be fixed for this component to work correctly. JCB has detected that the #__assets table name column will need to be enlarged because this component\'s own naming convention is larger than varchar(50) which is the Joomla default. JCB has three option to resolve this issue, first shorter names for your component and/or its admin views, second use the SQL fix, or the intelligent fix. %s %s', + $message_fix['intelligent'], + $message_fix['sql'] + ), 'Warning' + ); + } + // move the update server into place + $this->setUpdateServer(); + // build read me + $this->buildReadMe(); + // set local repos + $this->setLocalRepos(); + // zip the component + if (!$this->zipComponent()) + { + // done with error + return false; + } + // if there are modules zip them + $this->zipModules(); + // if there are plugins zip them + $this->zipPlugins(); + // do lang mismatch check + if (ArrayHelper::check(CFactory::_('Language.Extractor')->langMismatch)) + { + if (ArrayHelper::check(CFactory::_('Language.Extractor')->langMatch)) + { + $mismatch = array_diff( + array_unique(CFactory::_('Language.Extractor')->langMismatch), + array_unique(CFactory::_('Language.Extractor')->langMatch) + ); + } + else + { + $mismatch = array_unique(CFactory::_('Language.Extractor')->langMismatch); + } + // set a notice if we have a mismatch + if (isset($mismatch) + && ArrayHelper::check( + $mismatch + )) + { + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_HR_HTHREELANGUAGE_WARNINGHTHREE'), 'Warning' + ); + if (count((array) $mismatch) > 1) + { + $this->app->enqueueMessage( + Text::_( + '

    Please check the following mismatching Joomla.JText language constants.

    ' + ), 'Warning' + ); + } + else + { + $this->app->enqueueMessage( + Text::_( + '

    Please check the following mismatch Joomla.JText language constant.

    ' + ), 'Warning' + ); + } + // add the mismatching issues + foreach ($mismatch as $string) + { + $constant = CFactory::_('Config')->lang_prefix . '_' + . StringHelper::safe($string, 'U'); + $this->app->enqueueMessage( + Text::sprintf( + 'The Joomla.JText._('%s') language constant for %s does not have a corresponding Text::script('%s') decalaration, please add it.', + $constant, $string, $string + ), 'Warning' + ); + } + } + } + // check if we should add a EXTERNALCODE notice + if (ArrayHelper::check($this->externalCodeString)) + { + // number of external code strings + $externalCount = count($this->externalCodeString); + // the correct string + $externalCodeString = ($externalCount == 1) ? Text::_( + 'code/string' + ) : Text::_('COM_COMPONENTBUILDER_CODESTRINGS'); + // the notice + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_NOTICEHTHREE'), 'Notice' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'There has been %s - %s added to this component as EXTERNALCODE. To avoid shipping your component with malicious %s always make sure that the correct code/string values were used.', + $externalCount, $externalCodeString, $externalCodeString + ), 'Notice' + ); + } + // end the timer here + $this->time_end = microtime(true); + $this->secondsCompiled = $this->time_end - $this->time_start; + CFactory::_('Utilities.Counter')->end(); + + // completed the compilation + return true; + } + + return false; + } + + /** + * Set the dynamic data to the created files + * + * @return bool true on success + * + */ + protected function updateFiles() + { + if (CFactory::_('Utilities.Files')->exists('static') + && CFactory::_('Utilities.Files')->exists('dynamic')) + { + // load any other super powers that was already found + if (($super_powers = CFactory::_('Power.Extractor')->get_()) !== null) + { + CFactory::_('Power')->load($super_powers); + } + // set the autoloader for Powers + CFactory::_('Power.Autoloader')->set(); + // get the bom file + $bom = FileHelper::getContent(CFactory::_('Config')->bom_path); + // first we do the static files + foreach (CFactory::_('Utilities.Files')->get('static') as $static) + { + if (File::exists($static['path'])) + { + $this->setFileContent( + $static['name'], $static['path'], $bom + ); + } + } + // now we do the dynamic files + foreach (CFactory::_('Utilities.Files')->get('dynamic') as $view => $files) + { + if (CFactory::_('Compiler.Builder.Content.Multi')->isArray($view)) + { + foreach ($files as $file) + { + if ($file['view'] == $view) + { + if (File::exists($file['path'])) + { + $this->setFileContent( + $file['name'], $file['path'], $bom, + $file['view'] + ); + } + } + } + } + // free up some memory + CFactory::_('Compiler.Builder.Content.Multi')->remove($view); + } + // free up some memory + CFactory::_('Utilities.Files')->remove('dynamic'); + // do modules if found + if (CFactory::_('Joomlamodule.Data')->exists()) + { + foreach (CFactory::_('Joomlamodule.Data')->get() as $module) + { + if (ObjectHelper::check($module) + && CFactory::_('Utilities.Files')->exists($module->key)) + { + // move field or rule if needed + if (isset($module->fields_rules_paths) + && $module->fields_rules_paths == 2) + { + // check the config fields + if (isset($module->config_fields) + && ArrayHelper::check( + $module->config_fields + )) + { + foreach ( + $module->config_fields as $field_name => + $fieldsets + ) + { + foreach ($fieldsets as $fieldset => $fields) + { + foreach ($fields as $field) + { + $this->moveFieldsRules( + $field, $module->folder_path + ); + } + } + } + } + // check the fieldsets + if (isset($module->form_files) + && ArrayHelper::check( + $module->form_files + )) + { + foreach ($module->form_files as $file => $files) + { + foreach ( + $files as $field_name => $fieldsets + ) + { + foreach ( + $fieldsets as $fieldset => $fields + ) + { + foreach ($fields as $field) + { + $this->moveFieldsRules( + $field, $module->folder_path + ); + } + } + } + } + } + } + // update the module files + foreach (CFactory::_('Utilities.Files')->get($module->key) as $module_file) + { + if (File::exists($module_file['path'])) + { + $this->setFileContent( + $module_file['name'], $module_file['path'], + $bom, $module->key + ); + } + } + // free up some memory + CFactory::_('Utilities.Files')->remove($module->key); + CFactory::_('Compiler.Builder.Content.Multi')->remove($module->key); + } + } + } + // do plugins if found + if (CFactory::_('Joomlaplugin.Data')->exists()) + { + foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin) + { + if (ObjectHelper::check($plugin) + && CFactory::_('Utilities.Files')->exists($plugin->key)) + { + // move field or rule if needed + if (isset($plugin->fields_rules_paths) + && $plugin->fields_rules_paths == 2) + { + // check the config fields + if (isset($plugin->config_fields) + && ArrayHelper::check( + $plugin->config_fields + )) + { + foreach ( + $plugin->config_fields as $field_name => + $fieldsets + ) + { + foreach ($fieldsets as $fieldset => $fields) + { + foreach ($fields as $field) + { + $this->moveFieldsRules( + $field, $plugin->folder_path + ); + } + } + } + } + // check the fieldsets + if (isset($plugin->form_files) + && ArrayHelper::check( + $plugin->form_files + )) + { + foreach ($plugin->form_files as $file => $files) + { + foreach ( + $files as $field_name => $fieldsets + ) + { + foreach ( + $fieldsets as $fieldset => $fields + ) + { + foreach ($fields as $field) + { + $this->moveFieldsRules( + $field, $plugin->folder_path + ); + } + } + } + } + } + } + // update the plugin files + foreach (CFactory::_('Utilities.Files')->get($plugin->key) as $plugin_file) + { + if (File::exists($plugin_file['path'])) + { + $this->setFileContent( + $plugin_file['name'], $plugin_file['path'], + $bom, $plugin->key + ); + } + } + // free up some memory + CFactory::_('Utilities.Files')->remove($plugin->key); + CFactory::_('Compiler.Builder.Content.Multi')->remove($plugin->key); + } + } + } + // load any other super powers that was found + if (($super_powers = CFactory::_('Power.Extractor')->get_()) !== null) + { + CFactory::_('Power')->load($super_powers); + } + // load the powers files/folders + CFactory::_('Power.Structure')->build(); + // Infuse POWERS + CFactory::_('Power.Infusion')->set(); + // do powers if found + if (ArrayHelper::check(CFactory::_('Power')->active)) + { + foreach (CFactory::_('Power')->active as $power) + { + if (ObjectHelper::check($power) + && CFactory::_('Utilities.Files')->exists($power->key)) + { + // update the power files + foreach (CFactory::_('Utilities.Files')->get($power->key) as $power_file) + { + if (File::exists($power_file['path'])) + { + $this->setFileContent( + $power_file['name'], $power_file['path'], + $bom, $power->key + ); + } + } + // free up some memory + CFactory::_('Utilities.Files')->remove($power->key); + CFactory::_('Compiler.Builder.Content.Multi')->remove($power->key); + } + } + } + // do super powers details if found + if (ArrayHelper::check(CFactory::_('Power')->superpowers)) + { + foreach (CFactory::_('Power')->superpowers as $path => $powers) + { + $key = StringHelper::safe($path); + if (CFactory::_('Utilities.Files')->exists($key)) + { + // update the power files + foreach (CFactory::_('Utilities.Files')->get($key) as $power_file) + { + if (File::exists($power_file['path'])) + { + $this->setFileContent( + $power_file['name'], $power_file['path'], + $bom, $key + ); + } + } + // free up some memory + CFactory::_('Utilities.Files')->remove($key); + CFactory::_('Compiler.Builder.Content.Multi')->remove($key); + } + } + } + + return true; + } + + return false; + } + + /** + * set the file content + * + * @return void + * + */ + protected function setFileContent(&$name, &$path, &$bom, $view = null) + { + // Trigger Event: jcb_ce_onBeforeSetFileContent + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeSetFileContent', [&$name, &$path, &$bom, &$view] + ); + + // set the file name + CFactory::_('Compiler.Builder.Content.One')->set('FILENAME', $name); + + // check if the file should get PHP opening + $php = ''; + if (ComponentbuilderHelper::checkFileType($name, 'php')) + { + $php = "trigger( + 'jcb_ce_onGetFileContents', [&$string, &$name, &$path, &$bom, &$view] + ); + + // see if we should add a BOM + if (strpos((string) $string, (string) Placefix::_h('BOM')) !== false) + { + list($wast, $code) = explode( + Placefix::_h('BOM'), (string) $string + ); + $string = $php . $bom . $code; + } + + // set the answer + $answer = CFactory::_('Placeholder')->update($string, CFactory::_('Compiler.Builder.Content.One')->allActive(), 3); + + // set the dynamic answer + if ($view) + { + $placeholders = CFactory::_('Compiler.Builder.Content.Multi')->get($view, []); + if (is_array($placeholders)) + { + $answer = CFactory::_('Placeholder')->update( + $answer, $placeholders, 3 + ); + } + else + { + echo '
    ';
    +				var_dump($view, $placeholders);
    +				exit;
    +			}
    +			unset($placeholders);
    +		}
    +
    +		// check if this file needs extra care :)
    +		if (CFactory::_('Registry')->exists('update.file.content.' . $path))
    +		{
    +			$answer = CFactory::_('Customcode')->update($answer);
    +		}
    +
    +		// Trigger Event: jcb_ce_onBeforeSetFileContent
    +		CFactory::_('Event')->trigger(
    +			'jcb_ce_onBeforeWriteFileContent', [&$answer, &$name, &$path, &$bom, &$view]
    +		);
    +
    +		// inject any super powers found
    +		$answer = CFactory::_('Power.Injector')->power($answer);
    +
    +		// add answer back to file
    +		CFactory::_('Utilities.File')->write($path, $answer);
    +
    +		// count the file lines
    +		CFactory::_('Utilities.Counter')->line += substr_count((string) $answer, PHP_EOL);
    +	}
    +
    +	/**
    +	 * move the local update server xml file to a remote ftp server
    +	 *
    +	 * @return  void
    +	 *
    +	 */
    +	protected function setUpdateServer()
    +	{
    +		// move the component update server to host
    +		if (CFactory::_('Component')->get('add_update_server', 0) == 1
    +			&& CFactory::_('Component')->get('update_server_target', 0) == 1
    +			&& isset($this->updateServerFileName)
    +			&& $this->dynamicIntegration)
    +		{
    +			$update_server_xml_path = CFactory::_('Utilities.Paths')->component_path . '/'
    +				. $this->updateServerFileName . '.xml';
    +			// make sure we have the correct file
    +			if (File::exists($update_server_xml_path)
    +				&& ($update_server = CFactory::_('Component')->get('update_server')) !== null)
    +			{
    +				// move to server
    +				if (!CFactory::_('Server')->legacyMove(
    +					$update_server_xml_path,
    +					$this->updateServerFileName . '.xml',
    +					(int) $update_server,
    +					CFactory::_('Component')->get('update_server_protocol')
    +				))
    +				{
    +					$this->app->enqueueMessage(
    +						Text::sprintf(
    +							'Upload of component (%s) update server XML failed.',
    +							CFactory::_('Component')->get('system_name')
    +						), 'Error'
    +					);
    +				}
    +				// remove the local file
    +				File::delete($update_server_xml_path);
    +			}
    +		}
    +		// move the modules update server to host
    +		if (CFactory::_('Joomlamodule.Data')->exists())
    +		{
    +			foreach (CFactory::_('Joomlamodule.Data')->get() as $module)
    +			{
    +				if (ObjectHelper::check($module)
    +					&& isset($module->add_update_server)
    +					&& $module->add_update_server == 1
    +					&& isset($module->update_server_target)
    +					&& $module->update_server_target == 1
    +					&& isset($module->update_server)
    +					&& is_numeric($module->update_server)
    +					&& $module->update_server > 0
    +					&& isset($module->update_server_xml_path)
    +					&& File::exists($module->update_server_xml_path)
    +					&& isset($module->update_server_xml_file_name)
    +					&& StringHelper::check(
    +						$module->update_server_xml_file_name
    +					))
    +				{
    +					// move to server
    +					if (!CFactory::_('Server')->legacyMove(
    +						$module->update_server_xml_path,
    +						$module->update_server_xml_file_name,
    +						(int) $module->update_server,
    +						$module->update_server_protocol
    +					))
    +					{
    +						$this->app->enqueueMessage(
    +							Text::sprintf(
    +								'Upload of module (%s) update server XML failed.',
    +								$module->name
    +							), 'Error'
    +						);
    +					}
    +					// remove the local file
    +					File::delete($module->update_server_xml_path);
    +				}
    +				// var_dump($module->update_server_xml_path);exit;
    +			}
    +		}
    +		// move the plugins update server to host
    +		if (CFactory::_('Joomlaplugin.Data')->exists())
    +		{
    +			foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin)
    +			{
    +				if (ObjectHelper::check($plugin)
    +					&& isset($plugin->add_update_server)
    +					&& $plugin->add_update_server == 1
    +					&& isset($plugin->update_server_target)
    +					&& $plugin->update_server_target == 1
    +					&& isset($plugin->update_server)
    +					&& is_numeric($plugin->update_server)
    +					&& $plugin->update_server > 0
    +					&& isset($plugin->update_server_xml_path)
    +					&& File::exists($plugin->update_server_xml_path)
    +					&& isset($plugin->update_server_xml_file_name)
    +					&& StringHelper::check(
    +						$plugin->update_server_xml_file_name
    +					))
    +				{
    +					// move to server
    +					if (!CFactory::_('Server')->legacyMove(
    +						$plugin->update_server_xml_path,
    +						$plugin->update_server_xml_file_name,
    +						(int) $plugin->update_server,
    +						$plugin->update_server_protocol
    +					))
    +					{
    +						$this->app->enqueueMessage(
    +							Text::sprintf(
    +								'Upload of plugin (%s) update server XML failed.',
    +								$plugin->name
    +							), 'Error'
    +						);
    +					}
    +					// remove the local file
    +					File::delete($plugin->update_server_xml_path);
    +				}
    +			}
    +		}
    +	}
    +
    +	// link changes made to views into the file license
    +	protected function fixLicenseValues($data)
    +	{
    +		// check if these files have its own config data)
    +		if (isset($data['config'])
    +			&& ArrayHelper::check(
    +				$data['config']
    +			)
    +			&& CFactory::_('Component')->get('mvc_versiondate', 0) == 1)
    +		{
    +			foreach ($data['config'] as $key => $value)
    +			{
    +				if (Placefix::_h('VERSION') === $key)
    +				{
    +					// hmm we sould in some way make it known that this version number
    +					// is not in relation the the project but to the file only... any ideas?
    +					// this is the best for now...
    +					if (1 == $value)
    +					{
    +						$value = '@first version of this MVC';
    +					}
    +					else
    +					{
    +						$value = '@update number ' . $value . ' of this MVC';
    +					}
    +				}
    +				CFactory::_('Compiler.Builder.Content.One')->set($key, $value);
    +			}
    +
    +			return true;
    +		}
    +		// else insure to reset to global
    +		CFactory::_('Compiler.Builder.Content.One')->set('CREATIONDATE', CFactory::_('Compiler.Builder.Content.One')->get('GLOBALCREATIONDATE'));
    +		CFactory::_('Compiler.Builder.Content.One')->set('BUILDDATE', CFactory::_('Compiler.Builder.Content.One')->get('GLOBALBUILDDATE'));
    +		CFactory::_('Compiler.Builder.Content.One')->set('VERSION', CFactory::_('Compiler.Builder.Content.One')->get('GLOBALVERSION'));
    +	}
    +
    +	/**
    +	 * Set all global numbers
    +	 *
    +	 * @return  void
    +	 * @deprecated 3.3
    +	 */
    +	protected function setCountingStuff()
    +	{
    +		// set notice that we could not get a valid string from the target
    +		$this->app->enqueueMessage(
    +			Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error'
    +		);
    +		$this->app->enqueueMessage(
    +			Text::sprintf(
    +				'Use of a deprecated method (%s)!', __METHOD__
    +			), 'Error'
    +		);
    +	}
    +
    +	private function buildReadMe()
    +	{
    +		// do a final run to update the readme file
    +		$two = 0;
    +		// counter data if not set already
    +		if (!CFactory::_('Compiler.Builder.Content.One')->exists('LINE_COUNT')
    +			|| CFactory::_('Compiler.Builder.Content.One')->get('LINE_COUNT') != CFactory::_('Utilities.Counter')->line)
    +		{
    +			CFactory::_('Utilities.Counter')->set();
    +		}
    +		// search for the readme
    +		foreach (CFactory::_('Utilities.Files')->get('static') as $static)
    +		{
    +			if (('README.md' === $static['name']
    +					|| 'README.txt' === $static['name'])
    +				&& CFactory::_('Component')->get('addreadme')
    +				&& File::exists($static['path']))
    +			{
    +				$this->setReadMe($static['path']);
    +				$two++;
    +			}
    +			if ($two == 2)
    +			{
    +				break;
    +			}
    +		}
    +		CFactory::_('Utilities.Files')->remove('static');
    +	}
    +
    +	private function setReadMe($path)
    +	{
    +		// get the file
    +		$string = FileHelper::getContent($path);
    +		// update the file
    +		$answer = CFactory::_('Placeholder')->update($string, CFactory::_('Compiler.Builder.Content.One')->allActive());
    +		// add to zip array
    +		CFactory::_('Utilities.File')->write($path, $answer);
    +	}
    +
    +	/**
    +	 * Build README data
    +	 *
    +	 * @return  void
    +	 * @deprecated 3.3
    +	 */
    +	private function buildReadMeData()
    +	{
    +		// set notice that we could not get a valid string from the target
    +		$this->app->enqueueMessage(
    +			Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error'
    +		);
    +		$this->app->enqueueMessage(
    +			Text::sprintf(
    +				'Use of a deprecated method (%s)!', __METHOD__
    +			), 'Error'
    +		);
    +	}
    +
    +	private function setLocalRepos()
    +	{
    +		// move it to the repo folder if set
    +		if (isset($this->repoPath)
    +			&& StringHelper::check(
    +				$this->repoPath
    +			))
    +		{
    +			// set the repo path
    +			$repoFullPath = $this->repoPath . '/com_'
    +				. CFactory::_('Component')->get('sales_name') . '__joomla_'
    +				. CFactory::_('Config')->get('joomla_version', 3);
    +			// for plugin event TODO change event api signatures
    +			$component_context = CFactory::_('Config')->component_context;
    +			$component_path = CFactory::_('Utilities.Paths')->component_path;
    +			// Trigger Event: jcb_ce_onBeforeUpdateRepo
    +			CFactory::_('Event')->trigger(
    +				'jcb_ce_onBeforeUpdateRepo',
    +				array(&$component_context, &$component_path,
    +				      &$repoFullPath, &$this->componentData)
    +			);
    +			// remove old data
    +			CFactory::_('Utilities.Folder')->remove($repoFullPath, CFactory::_('Component')->get('toignore'));
    +			// set the new data
    +			try {
    +				Folder::copy(CFactory::_('Utilities.Paths')->component_path, $repoFullPath, '', true);
    +			} catch (\RuntimeException $e) {
    +				$this->app->enqueueMessage(
    +					Text::_('COM_COMPONENTBUILDER_WE_WHERE_WAS_UNABLE_TO_TRANSFER_THE_COMPONENT_TO_THE_GIT_REPOSITORY') . ' ' . $e->getMessage()
    +					, 'Error'
    +				);
    +			}
    +			// Trigger Event: jcb_ce_onAfterUpdateRepo
    +			CFactory::_('Event')->trigger(
    +				'jcb_ce_onAfterUpdateRepo',
    +				array(&$component_context, &$component_path,
    +				      &$repoFullPath, &$this->componentData)
    +			);
    +
    +			// move the modules to local folder repos
    +			if (CFactory::_('Joomlamodule.Data')->exists())
    +			{
    +				foreach (CFactory::_('Joomlamodule.Data')->get() as $module)
    +				{
    +					if (ObjectHelper::check($module)
    +						&& isset($module->file_name))
    +					{
    +						$module_context = 'module.' . $module->file_name . '.'
    +							. $module->id;
    +						// set the repo path
    +						$repoFullPath = $this->repoPath . '/'
    +							. $module->folder_name . '__joomla_'
    +							. CFactory::_('Config')->get('joomla_version', 3);
    +						// Trigger Event: jcb_ce_onBeforeUpdateRepo
    +						CFactory::_('Event')->trigger(
    +							'jcb_ce_onBeforeUpdateRepo',
    +							array(&$module_context, &$module->folder_path,
    +							      &$repoFullPath, &$module)
    +						);
    +						// remove old data
    +						CFactory::_('Utilities.Folder')->remove(
    +							$repoFullPath, CFactory::_('Component')->get('toignore')
    +						);
    +						// set the new data
    +						try {
    +							Folder::copy(
    +								$module->folder_path, $repoFullPath, '', true
    +							);
    +						} catch (\RuntimeException $e) {
    +							$this->app->enqueueMessage(
    +								Text::sprintf('COM_COMPONENTBUILDER_WE_WHERE_WAS_UNABLE_TO_TRANSFER_THE_S_MODULE_TO_THE_GIT_REPOSITORY', $module->name) . ' ' . $e->getMessage()
    +								, 'Error'
    +							);
    +						}
    +						// Trigger Event: jcb_ce_onAfterUpdateRepo
    +						CFactory::_('Event')->trigger(
    +							'jcb_ce_onAfterUpdateRepo',
    +							array(&$module_context, &$module->folder_path,
    +							      &$repoFullPath, &$module)
    +						);
    +					}
    +				}
    +			}
    +			// move the plugins to local folder repos
    +			if (CFactory::_('Joomlaplugin.Data')->exists())
    +			{
    +				foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin)
    +				{
    +					if (ObjectHelper::check($plugin)
    +						&& isset($plugin->file_name))
    +					{
    +						$plugin_context = 'plugin.' . $plugin->file_name . '.'
    +							. $plugin->id;
    +						// set the repo path
    +						$repoFullPath = $this->repoPath . '/'
    +							. $plugin->folder_name . '__joomla_'
    +							. CFactory::_('Config')->get('joomla_version', 3);
    +						// Trigger Event: jcb_ce_onBeforeUpdateRepo
    +						CFactory::_('Event')->trigger(
    +							'jcb_ce_onBeforeUpdateRepo',
    +							array(&$plugin_context, &$plugin->folder_path,
    +							      &$repoFullPath, &$plugin)
    +						);
    +						// remove old data
    +						CFactory::_('Utilities.Folder')->remove(
    +							$repoFullPath, CFactory::_('Component')->get('toignore')
    +						);
    +						// set the new data
    +						try {
    +							Folder::copy(
    +								$plugin->folder_path, $repoFullPath, '', true
    +							);
    +						} catch (\RuntimeException $e) {
    +							$this->app->enqueueMessage(
    +								Text::sprintf('COM_COMPONENTBUILDER_WE_WHERE_WAS_UNABLE_TO_TRANSFER_THE_S_PLUGIN_TO_THE_GIT_REPOSITORY', $plugin->name) . ' ' . $e->getMessage()
    +								, 'Error'
    +							);
    +						}
    +						// Trigger Event: jcb_ce_onAfterUpdateRepo
    +						CFactory::_('Event')->trigger(
    +							'jcb_ce_onAfterUpdateRepo',
    +							array(&$plugin_context, &$plugin->folder_path,
    +							      &$repoFullPath, &$plugin)
    +						);
    +					}
    +				}
    +			}
    +		}
    +	}
    +
    +	private function zipComponent()
    +	{
    +		// Component Folder Name
    +		$this->filepath['component-folder'] = CFactory::_('Utilities.Paths')->component_folder_name;
    +		// the name of the zip file to create
    +		$this->filepath['component'] = $this->tempPath . '/'
    +			. $this->filepath['component-folder'] . '.zip';
    +		// for plugin event TODO change event api signatures
    +		$component_context = CFactory::_('Config')->component_context;
    +		$component_path = CFactory::_('Utilities.Paths')->component_path;
    +		$component_sales_name = CFactory::_('Utilities.Paths')->component_sales_name;
    +		$component_folder_name = CFactory::_('Utilities.Paths')->component_folder_name;
    +		// Trigger Event: jcb_ce_onBeforeZipComponent
    +		CFactory::_('Event')->trigger(
    +			'jcb_ce_onBeforeZipComponent', [&$component_path, &$this->filepath['component'],
    +				&$this->tempPath,  &$component_folder_name]
    +		);
    +		//create the zip file
    +		if (FileHelper::zip(
    +			CFactory::_('Utilities.Paths')->component_path,
    +			$this->filepath['component']
    +		))
    +		{
    +			// now move to backup if zip was made and backup is required
    +			if ($this->backupPath && $this->dynamicIntegration)
    +			{
    +				// Trigger Event: jcb_ce_onBeforeBackupZip
    +				CFactory::_('Event')->trigger(
    +					'jcb_ce_onBeforeBackupZip', [&$this->filepath['component'], &$this->tempPath, &$this->backupPath]
    +				);
    +				// copy the zip to backup path
    +				try {
    +					File::copy(
    +						$this->filepath['component'],
    +						$this->backupPath . '/' . CFactory::_('Utilities.Paths')->component_backup_name
    +						. '.zip'
    +					);
    +				} catch (\RuntimeException $e) {
    +					$this->app->enqueueMessage(
    +						Text::_('COM_COMPONENTBUILDER_WE_WHERE_WAS_UNABLE_TO_TRANSFER_THE_COMPONENT_ZIP_FILE_TO_THE_BACKUP_FOLDER') . ' ' . $e->getMessage()
    +						, 'Error'
    +					);
    +				}
    +			}
    +			// move to sales server host
    +			if (CFactory::_('Component')->get('add_sales_server', 0) == 1
    +				&& $this->dynamicIntegration)
    +			{
    +				// make sure we have the correct file
    +				if (CFactory::_('Component')->get('sales_server'))
    +				{
    +					// Trigger Event: jcb_ce_onBeforeMoveToServer
    +					CFactory::_('Event')->trigger(
    +						'jcb_ce_onBeforeMoveToServer', [&$this->filepath['component'], &$this->tempPath, &$component_sales_name]
    +					);
    +					// move to server
    +					if (!CFactory::_('Server')->legacyMove(
    +						$this->filepath['component'],
    +						$component_sales_name . '.zip',
    +						(int) CFactory::_('Component')->get('sales_server'),
    +						CFactory::_('Component')->get('sales_server_protocol')
    +					))
    +					{
    +						$this->app->enqueueMessage(
    +							Text::sprintf(
    +								'Upload of component (%s) zip file failed.',
    +								CFactory::_('Component')->get('system_name')
    +							), 'Error'
    +						);
    +					}
    +				}
    +			}
    +			// Trigger Event: jcb_ce_onAfterZipComponent
    +			CFactory::_('Event')->trigger(
    +				'jcb_ce_onAfterZipComponent', [&$this->filepath['component'],  &$this->tempPath, &$component_folder_name]
    +			);
    +			// remove the component folder since we are done
    +			if (CFactory::_('Utilities.Folder')->remove(CFactory::_('Utilities.Paths')->component_path))
    +			{
    +				return true;
    +			}
    +		}
    +
    +		return false;
    +	}
    +
    +	private function zipModules()
    +	{
    +		if (CFactory::_('Joomlamodule.Data')->exists())
    +		{
    +			foreach (CFactory::_('Joomlamodule.Data')->get() as $module)
    +			{
    +				if (ObjectHelper::check($module)
    +					&& isset($module->zip_name)
    +					&& StringHelper::check($module->zip_name)
    +					&& isset($module->folder_path)
    +					&& StringHelper::check(
    +						$module->folder_path
    +					))
    +				{
    +					// set module context
    +					$module_context = $module->file_name . '.' . $module->id;
    +					// Component Folder Name
    +					$this->filepath['modules-folder'][$module->id]
    +						= $module->zip_name;
    +					// the name of the zip file to create
    +					$this->filepath['modules'][$module->id] = $this->tempPath
    +						. '/' . $module->zip_name . '.zip';
    +					// Trigger Event: jcb_ce_onBeforeZipModule
    +					CFactory::_('Event')->trigger(
    +						'jcb_ce_onBeforeZipModule',
    +						array(&$module_context, &$module->folder_path,
    +						      &$this->filepath['modules'][$module->id],
    +						      &$this->tempPath, &$module->zip_name, &$module)
    +					);
    +					//create the zip file
    +					if (FileHelper::zip(
    +						$module->folder_path,
    +						$this->filepath['modules'][$module->id]
    +					))
    +					{
    +						// now move to backup if zip was made and backup is required
    +						if ($this->backupPath)
    +						{
    +							$__module_context = 'module.' . $module_context;
    +							// Trigger Event: jcb_ce_onBeforeBackupZip
    +							CFactory::_('Event')->trigger(
    +								'jcb_ce_onBeforeBackupZip',
    +								array(&$__module_context,
    +								      &$this->filepath['modules'][$module->id],
    +								      &$this->tempPath, &$this->backupPath,
    +								      &$module)
    +							);
    +							// copy the zip to backup path
    +							try {
    +								File::copy(
    +									$this->filepath['modules'][$module->id],
    +									$this->backupPath . '/' . $module->zip_name
    +									. '.zip'
    +								);
    +							} catch (\RuntimeException $e) {
    +								$this->app->enqueueMessage(
    +									Text::sprintf('COM_COMPONENTBUILDER_WE_WHERE_WAS_UNABLE_TO_TRANSFER_THE_S_MODULE_ZIP_FILE_TO_THE_BACKUP_FOLDER', $module->name) . ' ' . $e->getMessage()
    +									, 'Error'
    +								);
    +							}
    +						}
    +						// move to sales server host
    +						if ($module->add_sales_server == 1)
    +						{
    +							// make sure we have the correct file
    +							if (isset($module->sales_server))
    +							{
    +								// Trigger Event: jcb_ce_onBeforeMoveToServer
    +								CFactory::_('Event')->trigger(
    +									'jcb_ce_onBeforeMoveToServer',
    +									array(&$__module_context,
    +									      &$this->filepath['modules'][$module->id],
    +									      &$this->tempPath, &$module->zip_name,
    +									      &$module)
    +								);
    +								// move to server
    +								if (!CFactory::_('Server')->legacyMove(
    +									$this->filepath['modules'][$module->id],
    +									$module->zip_name . '.zip',
    +									(int) $module->sales_server,
    +									$module->sales_server_protocol
    +								))
    +								{
    +									$this->app->enqueueMessage(
    +										Text::sprintf(
    +											'Upload of module (%s) zip file failed.',
    +											$module->name
    +										), 'Error'
    +									);
    +								}
    +							}
    +						}
    +						// Trigger Event: jcb_ce_onAfterZipModule
    +						CFactory::_('Event')->trigger(
    +							'jcb_ce_onAfterZipModule', array(&$module_context,
    +							                                 &$this->filepath['modules'][$module->id],
    +							                                 &$this->tempPath,
    +							                                 &$module->zip_name,
    +							                                 &$module)
    +						);
    +						// remove the module folder since we are done
    +						CFactory::_('Utilities.Folder')->remove($module->folder_path);
    +					}
    +				}
    +			}
    +		}
    +	}
    +
    +	private function zipPlugins()
    +	{
    +		if (CFactory::_('Joomlaplugin.Data')->exists())
    +		{
    +			foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin)
    +			{
    +				if (ObjectHelper::check($plugin)
    +					&& isset($plugin->zip_name)
    +					&& StringHelper::check($plugin->zip_name)
    +					&& isset($plugin->folder_path)
    +					&& StringHelper::check(
    +						$plugin->folder_path
    +					))
    +				{
    +					// set plugin context
    +					$plugin_context = $plugin->file_name . '.' . $plugin->id;
    +					// Component Folder Name
    +					$this->filepath['plugins-folder'][$plugin->id]
    +						= $plugin->zip_name;
    +					// the name of the zip file to create
    +					$this->filepath['plugins'][$plugin->id] = $this->tempPath
    +						. '/' . $plugin->zip_name . '.zip';
    +					// Trigger Event: jcb_ce_onBeforeZipPlugin
    +					CFactory::_('Event')->trigger(
    +						'jcb_ce_onBeforeZipPlugin',
    +						array(&$plugin_context, &$plugin->folder_path,
    +						      &$this->filepath['plugins'][$plugin->id],
    +						      &$this->tempPath, &$plugin->zip_name, &$plugin)
    +					);
    +					//create the zip file
    +					if (FileHelper::zip(
    +						$plugin->folder_path,
    +						$this->filepath['plugins'][$plugin->id]
    +					))
    +					{
    +						// now move to backup if zip was made and backup is required
    +						if ($this->backupPath)
    +						{
    +							$__plugin_context = 'plugin.' . $plugin_context;
    +							// Trigger Event: jcb_ce_onBeforeBackupZip
    +							CFactory::_('Event')->trigger(
    +								'jcb_ce_onBeforeBackupZip',
    +								array(&$__plugin_context,
    +								      &$this->filepath['plugins'][$plugin->id],
    +								      &$this->tempPath, &$this->backupPath,
    +								      &$plugin)
    +							);
    +							// copy the zip to backup path
    +							try {
    +								File::copy(
    +									$this->filepath['plugins'][$plugin->id],
    +									$this->backupPath . '/' . $plugin->zip_name
    +									. '.zip'
    +								);
    +							} catch (\RuntimeException $e) {
    +								$this->app->enqueueMessage(
    +									Text::sprintf('COM_COMPONENTBUILDER_WE_WHERE_WAS_UNABLE_TO_TRANSFER_THE_S_PLUGIN_ZIP_FILE_TO_THE_BACKUP_FOLDER', $plugin->name) . ' ' . $e->getMessage()
    +									, 'Error'
    +								);
    +							}
    +						}
    +
    +						// move to sales server host
    +						if ($plugin->add_sales_server == 1)
    +						{
    +							// make sure we have the correct file
    +							if (isset($plugin->sales_server))
    +							{
    +								// Trigger Event: jcb_ce_onBeforeMoveToServer
    +								CFactory::_('Event')->trigger(
    +									'jcb_ce_onBeforeMoveToServer',
    +									array(&$__plugin_context,
    +									      &$this->filepath['plugins'][$plugin->id],
    +									      &$this->tempPath, &$plugin->zip_name,
    +									      &$plugin)
    +								);
    +								// move to server
    +								if (!CFactory::_('Server')->legacyMove(
    +									$this->filepath['plugins'][$plugin->id],
    +									$plugin->zip_name . '.zip',
    +									(int) $plugin->sales_server,
    +									$plugin->sales_server_protocol
    +								))
    +								{
    +									$this->app->enqueueMessage(
    +										Text::sprintf(
    +											'Upload of plugin (%s) zip file failed.',
    +											$plugin->name
    +										), 'Error'
    +									);
    +								}
    +							}
    +						}
    +						// Trigger Event: jcb_ce_onAfterZipPlugin
    +						CFactory::_('Event')->trigger(
    +							'jcb_ce_onAfterZipPlugin', array(&$plugin_context,
    +							                                 &$this->filepath['plugins'][$plugin->id],
    +							                                 &$this->tempPath,
    +							                                 &$plugin->zip_name,
    +							                                 &$plugin)
    +						);
    +						// remove the plugin folder since we are done
    +						CFactory::_('Utilities.Folder')->remove($plugin->folder_path);
    +					}
    +				}
    +			}
    +		}
    +	}
    +
    +	protected function addCustomCode()
    +	{
    +		// reset all these
    +		CFactory::_('Placeholder')->clearType('view');
    +		CFactory::_('Placeholder')->clearType('arg');
    +		foreach (CFactory::_('Customcode')->active as $nr => $target)
    +		{
    +			// reset each time per custom code
    +			$fingerPrint = array();
    +			if (isset($target['hashtarget'][0]) && $target['hashtarget'][0] > 3
    +				&& isset($target['path'])
    +				&& StringHelper::check($target['path'])
    +				&& isset($target['hashtarget'][1])
    +				&& StringHelper::check(
    +					$target['hashtarget'][1]
    +				))
    +			{
    +				$file      = CFactory::_('Utilities.Paths')->component_path . '/' . $target['path'];
    +				$size      = (int) $target['hashtarget'][0];
    +				$hash      = $target['hashtarget'][1];
    +				$cut       = $size - 1;
    +				$found     = false;
    +				$bites     = 0;
    +				$lineBites = array();
    +				$replace   = array();
    +				if ($target['type'] == 1 && isset($target['hashendtarget'][0])
    +					&& $target['hashendtarget'][0] > 0)
    +				{
    +					$foundEnd = false;
    +					$sizeEnd  = (int) $target['hashendtarget'][0];
    +					$hashEnd  = $target['hashendtarget'][1];
    +					$cutEnd   = $sizeEnd - 1;
    +				}
    +				else
    +				{
    +					// replace to the end of the file
    +					$foundEnd = true;
    +				}
    +				$counter = 0;
    +				// check if file exist			
    +				if (File::exists($file))
    +				{
    +					foreach (
    +						new \SplFileObject($file) as $lineNumber => $lineContent
    +					)
    +					{
    +						// if not found we need to load line bites per line
    +						$lineBites[$lineNumber] = (int) mb_strlen(
    +							$lineContent, '8bit'
    +						);
    +						if (!$found)
    +						{
    +							$bites = (int) MathHelper::bc(
    +								'add', $lineBites[$lineNumber], $bites
    +							);
    +						}
    +						if ($found && !$foundEnd)
    +						{
    +							$replace[] = (int) $lineBites[$lineNumber];
    +							// we must keep last three lines to dynamic find target entry
    +							$fingerPrint[$lineNumber] = trim($lineContent);
    +							// check lines each time if it fits our target
    +							if (count((array) $fingerPrint) === $sizeEnd
    +								&& !$foundEnd)
    +							{
    +								$fingerTest = md5(implode('', $fingerPrint));
    +								if ($fingerTest === $hashEnd)
    +								{
    +									// we are done here
    +									$foundEnd = true;
    +									$replace  = array_slice(
    +										$replace, 0, count($replace) - $sizeEnd
    +									);
    +									break;
    +								}
    +								else
    +								{
    +									$fingerPrint = array_slice(
    +										$fingerPrint, -$cutEnd, $cutEnd, true
    +									);
    +								}
    +							}
    +							continue;
    +						}
    +						if ($found && $foundEnd)
    +						{
    +							$replace[] = (int) $lineBites[$lineNumber];
    +						}
    +						// we must keep last three lines to dynamic find target entry
    +						$fingerPrint[$lineNumber] = trim($lineContent);
    +						// check lines each time if it fits our target
    +						if (count((array) $fingerPrint) === $size && !$found)
    +						{
    +							$fingerTest = md5(implode('', $fingerPrint));
    +							if ($fingerTest === $hash)
    +							{
    +								// we are done here
    +								$found = true;
    +								// reset in case
    +								$fingerPrint = array();
    +								// break if it is insertion
    +								if ($target['type'] == 2)
    +								{
    +									break;
    +								}
    +							}
    +							else
    +							{
    +								$fingerPrint = array_slice(
    +									$fingerPrint, -$cut, $cut, true
    +								);
    +							}
    +						}
    +					}
    +					if ($found)
    +					{
    +						$placeholder = CFactory::_('Placeholder')->keys(
    +							(int) $target['comment_type'] . $target['type'],
    +							$target['id']
    +						);
    +						$data        = $placeholder['start'] . PHP_EOL
    +							. CFactory::_('Placeholder')->update_(
    +								$target['code']
    +							) . $placeholder['end'] . PHP_EOL;
    +						if ($target['type'] == 2)
    +						{
    +							// found it now add code from the next line
    +							CFactory::_('Utilities.FileInjector')->add($file, $data, $bites);
    +						}
    +						elseif ($target['type'] == 1 && $foundEnd)
    +						{
    +							// found it now add code from the next line
    +							CFactory::_('Utilities.FileInjector')->add(
    +								$file, $data, $bites, (int) array_sum($replace)
    +							);
    +						}
    +						else
    +						{
    +							// Load escaped code since the target endhash has changed
    +							$this->loadEscapedCode($file, $target, $lineBites);
    +							$this->app->enqueueMessage(
    +								Text::_('COM_COMPONENTBUILDER_HR_HTHREECUSTOM_CODE_WARNINGHTHREE'),
    +								'Warning'
    +							);
    +							$this->app->enqueueMessage(
    +								Text::sprintf(
    +									'Custom code %s could not be added to %s please review the file after install at line %s and reposition the code, remove the comments and recompile to fix the issue. The issue could be due to a change to lines below the custom code.',
    +									'#'
    +									. $target['id'] . '', $target['path'],
    +									$target['from_line']
    +								), 'Warning'
    +							);
    +						}
    +					}
    +					else
    +					{
    +						// Load escaped code since the target hash has changed
    +						$this->loadEscapedCode($file, $target, $lineBites);
    +						$this->app->enqueueMessage(
    +							Text::_('COM_COMPONENTBUILDER_HR_HTHREECUSTOM_CODE_WARNINGHTHREE'),
    +							'Warning'
    +						);
    +						$this->app->enqueueMessage(
    +							Text::sprintf(
    +								'Custom code %s could not be added to %s please review the file after install at line %s and reposition the code, remove the comments and recompile to fix the issue. The issue could be due to a change to lines above the custom code.',
    +								'#'
    +								. $target['id'] . '', $target['path'],
    +								$target['from_line']
    +							), 'Warning'
    +						);
    +					}
    +				}
    +				else
    +				{
    +					// Give developer a notice that file is not found.
    +					$this->app->enqueueMessage(
    +						Text::_('COM_COMPONENTBUILDER_HR_HTHREECUSTOM_CODE_WARNINGHTHREE'),
    +						'Warning'
    +					);
    +					$this->app->enqueueMessage(
    +						Text::sprintf(
    +							'File %s could not be found, so the custom code for this file could not be addded.',
    +							$target['path']
    +						), 'Warning'
    +					);
    +				}
    +			}
    +		}
    +	}
    +
    +	protected function loadEscapedCode($file, $target, $lineBites)
    +	{
    +		// get comment type
    +		if ($target['comment_type'] == 1)
    +		{
    +			$commentType  = "// ";
    +			$_commentType = "";
    +		}
    +		else
    +		{
    +			$commentType  = "";
    +		}
    +		// escape the code
    +		$code = explode(PHP_EOL, (string) $target['code']);
    +		$code = PHP_EOL . $commentType . implode(
    +				$_commentType . PHP_EOL . $commentType, $code
    +			) . $_commentType . PHP_EOL;
    +		// get placeholders
    +		$placeholder = CFactory::_('Placeholder')->keys(
    +			(int) $target['comment_type'] . $target['type'], $target['id']
    +		);
    +		// build the data
    +		$data = $placeholder['start'] . $code . $placeholder['end'] . PHP_EOL;
    +		// get the bites before insertion
    +		$bitBucket = array();
    +		foreach ($lineBites as $line => $value)
    +		{
    +			if ($line < $target['from_line'])
    +			{
    +				$bitBucket[] = $value;
    +			}
    +		}
    +		// add to the file
    +		CFactory::_('Utilities.FileInjector')->add($file, $data, (int) array_sum($bitBucket));
    +	}
    +
    +	/**
    +	 * Inserts or replaces data in a file at a specific position.
    +	 *    Thanks to http://stackoverflow.com/a/16813550/1429677
    +	 *
    +	 * @param string    $file      The path of the file to modify
    +	 * @param string    $data      The data to insert or replace
    +	 * @param int       $position  The position in the file where the data should be inserted or replaced
    +	 * @param int|null  $replace   The number of bytes to replace; if null, data will be inserted
    +	 *
    +	 * @return void
    +	 * @throws RuntimeException if unable to open the file
    +	 * @deprecated 3.3 Use CFactory::_('Utilities.FileInjector')->add($file, $data, $position, $replace);
    +	 */
    +	protected function addDataToFile(string $file, string $data, int $position, ?int $replace = null)
    +	{
    +		CFactory::_('Utilities.FileInjector')->add($file, $data, $position, $replace);
    +	}
    +}
    +
    diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Fields.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Fields.php
    new file mode 100644
    index 000000000..01323d7aa
    --- /dev/null
    +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Fields.php
    @@ -0,0 +1,1585 @@
    +
    + * @git        Joomla Component Builder 
    + * @copyright  Copyright (C) 2015 Vast Development Method. All rights reserved.
    + * @license    GNU General Public License version 2 or later; see LICENSE.txt
    + */
    +
    +namespace VDM\Joomla\Componentbuilder\Compiler\Helper;
    +
    +
    +use Joomla\CMS\Language\Text;
    +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
    +use VDM\Joomla\Utilities\ArrayHelper;
    +use VDM\Joomla\Utilities\StringHelper;
    +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
    +use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory;
    +use VDM\Joomla\Componentbuilder\Compiler\Helper\Structure;
    +
    +
    +/**
    + * Fields class
    + * 
    + * @deprecated 3.3
    + */
    +class Fields extends Structure
    +{
    +	/**
    +	 * Metadate Switch
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Meta.Data')->get($key);
    +	 */
    +	public $metadataBuilder = [];
    +
    +	/**
    +	 * View access Switch
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Access.Switch')->get($key);
    +	 */
    +	public $accessBuilder = [];
    +
    +	/**
    +	 * edit view tabs counter
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Tab.Counter')->get($key);
    +	 */
    +	public $tabCounter = [];
    +
    +	/**
    +	 * layout builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Layout')->get($key);
    +	 */
    +	public $layoutBuilder = [];
    +
    +	/**
    +	 * permissions builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Has.Permissions')->get($key);
    +	 */
    +	public $hasPermissions = [];
    +
    +	/**
    +	 * used to fix the zero order
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Order.Zero')->get($key);
    +	 */
    +	private $zeroOrderFix = [];
    +
    +	/**
    +	 * Site field data
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Site.Field.Data')->get($key);
    +	 */
    +	public $siteFieldData = [];
    +
    +	/**
    +	 * list of fields that are not being escaped
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Do.Not.Escape')->get($key);
    +	 */
    +	public $doNotEscape = [];
    +
    +	/**
    +	 * list of classes used in the list view for the fields
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.List.Field.Class')->set($key, true);
    +	 */
    +	public $listFieldClass = [];
    +
    +	/**
    +	 * tags builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Tags')->get($key);
    +	 */
    +	public $tagsBuilder = [];
    +
    +	/**
    +	 * query builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Database.Tables')->get($key);
    +	 */
    +	public $queryBuilder = [];
    +
    +	/**
    +	 * unique keys for database field
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Database.Unique.Keys')->get($key);
    +	 */
    +	public $dbUniqueKeys = [];
    +
    +	/**
    +	 * unique guid swtich
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Database.Unique.Guid')->get($key);
    +	 */
    +	public $dbUniqueGuid = [];
    +
    +	/**
    +	 * keys for database field
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Database.Keys')->get($key);
    +	 */
    +	public $dbKeys = [];
    +
    +	/**
    +	 * history builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.History')->get($key);
    +	 */
    +	public $historyBuilder = [];
    +
    +	/**
    +	 * alias builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 CFactory::_('Compiler.Builder.Alias')->get($key);
    +	 */
    +	public $aliasBuilder = [];
    +
    +	/**
    +	 * title builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 CFactory::_('Compiler.Builder.Title')->get($key);
    +	 */
    +	public $titleBuilder = [];
    +
    +	/**
    +	 * list builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Lists')->get($key);
    +	 */
    +	public $listBuilder = [];
    +
    +	/**
    +	 * custom Builder List
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Custom.List')->get($key);
    +	 */
    +	public $customBuilderList = [];
    +
    +	/**
    +	 * Hidden Fields Builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Hidden.Fields')->get($key);
    +	 */
    +	public $hiddenFieldsBuilder = [];
    +
    +	/**
    +	 * INT Field Builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Integer.Fields')->get($key);
    +	 */
    +	public $intFieldsBuilder = [];
    +
    +	/**
    +	 * Dynamic Fields Builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Dynamic.Fields')->get($key);
    +	 */
    +	public $dynamicfieldsBuilder = [];
    +
    +	/**
    +	 * Main text Builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Main.Text.Field')->get($key);
    +	 */
    +	public $maintextBuilder = [];
    +
    +	/**
    +	 * Custom Builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Custom.Field')->get($key);
    +	 */
    +	public $customBuilder = [];
    +
    +	/**
    +	 * Custom Field Links Builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Custom.Field.Links')->get($key);
    +	 */
    +	public $customFieldLinksBuilder = [];
    +
    +	/**
    +	 * Set Script for User Switch
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Script.User.Switch')->get($key);
    +	 */
    +	public $setScriptUserSwitch = [];
    +
    +	/**
    +	 * Set Script for Media Switch
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Script.Media.Switch')->get($key);
    +	 */
    +	public $setScriptMediaSwitch = [];
    +
    +	/**
    +	 * Category builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Category')->get($key);
    +	 */
    +	public $categoryBuilder = [];
    +
    +	/**
    +	 * Category Code builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Category.Code')->get($key);
    +	 */
    +	public $catCodeBuilder = [];
    +
    +	/**
    +	 * Check Box builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Check.Box')->get($key);
    +	 */
    +	public $checkboxBuilder = [];
    +
    +	/**
    +	 * Json String Builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Json.String')->get($key);
    +	 */
    +	public $jsonStringBuilder = [];
    +
    +	/**
    +	 * Json String Builder for return values to array
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Json.Item.Array')->get($key);
    +	 */
    +	public $jsonItemBuilderArray = [];
    +
    +	/**
    +	 * Json Item Builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Json.Item')->get($key);
    +	 */
    +	public $jsonItemBuilder = [];
    +
    +	/**
    +	 * Base 64 Builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Base.Six.Four')->get($key);
    +	 */
    +	public $base64Builder = [];
    +
    +	/**
    +	 * Basic Encryption Field Modeling
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Model.Basic.Field')->get($key);
    +	 */
    +	public $basicFieldModeling = [];
    +
    +	/**
    +	 * WHMCS Encryption Field Modeling
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Model.Whmcs.Field')->get($key);
    +	 */
    +	public $whmcsFieldModeling = [];
    +
    +	/**
    +	 * Medium Encryption Field Modeling
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Model.Medium.Field')->get($key);
    +	 */
    +	public $mediumFieldModeling = [];
    +
    +	/**
    +	 * Expert Field Modeling
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Model.Expert.Field')->get($key);
    +	 */
    +	public $expertFieldModeling = [];
    +
    +	/**
    +	 * Expert Mode Initiator
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Model.Expert.Field.Initiator')->get($key);
    +	 */
    +	public $expertFieldModelInitiator = [];
    +
    +	/**
    +	 * Get Items Method List String Fix Builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Items.Method.List.String')->get($key);
    +	 */
    +	public $getItemsMethodListStringFixBuilder = [];
    +
    +	/**
    +	 * Get Items Method Eximport String Fix Builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Items.Method.Eximport.String')->get($key);
    +	 */
    +	public $getItemsMethodEximportStringFixBuilder = [];
    +
    +	/**
    +	 * Selection Translation Fix Builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Selection.Translation')->get($key);
    +	 */
    +	public $selectionTranslationFixBuilder = [];
    +
    +	/**
    +	 * Sort Builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Sort')->get($key);
    +	 */
    +	public $sortBuilder = [];
    +
    +	/**
    +	 * Search Builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Search')->get($key);
    +	 */
    +	public $searchBuilder = [];
    +
    +	/**
    +	 * Filter Builder
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Filter')->get($key);
    +	 */
    +	public $filterBuilder = [];
    +
    +	/**
    +	 * Set Group Control
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Field.Group.Control')->get($key);
    +	 */
    +	public $setGroupControl = [];
    +
    +	/**
    +	 * Set Field Names
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Field.Names')->get($key);
    +	 */
    +	public $fieldsNames = [];
    +
    +	/**
    +	 * Default Fields set to publishing
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.New.Publishing.Fields')->set($key);
    +	 */
    +	public $newPublishingFields = [];
    +
    +	/**
    +	 * Default Fields set to publishing
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Moved.Publishing.Fields')->set($key);
    +	 */
    +	public $movedPublishingFields = [];
    +
    +	/**
    +	 * set the Field set of a view
    +	 *
    +	 * @param   array   $view            The view data
    +	 * @param   string  $component       The component name
    +	 * @param   string  $nameSingleCode  The single view name
    +	 * @param   string  $nameListCode    The list view name
    +	 *
    +	 * @return  string The fields set in xml
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Fieldset')->get(...);
    +	 */
    +	public function setFieldSet(array $view, string $component, string $nameSingleCode, string $nameListCode)
    +	{
    +		return CFactory::_('Compiler.Creator.Fieldset')->
    +			get($view, $component, $nameSingleCode, $nameListCode);
    +	}
    +
    +	/**
    +	 * build field set using string manipulation
    +	 *
    +	 * @param   array   $view            The view data
    +	 * @param   string  $component       The component name
    +	 * @param   string  $nameSingleCode  The single view name
    +	 * @param   string  $nameListCode    The list view name
    +	 * @param   string  $langView        The language string of the view
    +	 * @param   string  $langViews       The language string of the views
    +	 *
    +	 * @return  string The fields set in xml
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Fieldset.String')->get(...);
    +	 */
    +	protected function stringFieldSet(array $view, string $component, string $nameSingleCode, string $nameListCode,
    +		string $langView, string $langViews): string
    +	{
    +		return CFactory::_('Compiler.Creator.Fieldset.String')->get(
    +			$view,
    +			$component,
    +			$nameSingleCode,
    +			$nameListCode,
    +			$langView,
    +			$langViews
    +		);
    +	}
    +
    +	/**
    +	 * build field set with simpleXMLElement class
    +	 *
    +	 * @param   array   $view            The view data
    +	 * @param   string  $component       The component name
    +	 * @param   string  $nameSingleCode  The single view name
    +	 * @param   string  $nameListCode    The list view name
    +	 * @param   string  $langView        The language string of the view
    +	 * @param   string  $langViews       The language string of the views
    +	 *
    +	 * @return  string The fields set in string xml
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Fieldset.XML')->get(...);
    +	 */
    +	protected function simpleXMLFieldSet(array $view, string $component, string $nameSingleCode,
    +		string $nameListCode, string $langView, string $langViews): string
    +	{
    +		return CFactory::_('Compiler.Creator.Fieldset.XML')->get(
    +			$view,
    +			$component,
    +			$nameSingleCode,
    +			$nameListCode,
    +			$langView,
    +			$langViews
    +		);
    +	}
    +
    +	/**
    +	 * Check to see if a view has permissions
    +	 *
    +	 * @param   array   $view            View details
    +	 * @param   string  $nameSingleCode  View Single Code Name
    +	 *
    +	 * @return  boolean true if it has permisssions
    +	 * @deprecated 3.3 Use CFactory::_('Adminview.Permission')->check($view, $nameSingleCode);
    +	 */
    +	protected function hasPermissionsSet(&$view, &$nameSingleCode)
    +	{
    +		return CFactory::_('Adminview.Permission')->check($view, $nameSingleCode);
    +	}
    +
    +	/**
    +	 * set Field Names
    +	 *
    +	 * @param   string  $view  View the field belongs to
    +	 * @param   string  $name  The name of the field
    +	 *
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Field.Names')->set($view . '.' . $name, $name);
    +	 */
    +	public function setFieldsNames(&$view, &$name)
    +	{
    +		CFactory::_('Compiler.Builder.Field.Names')->set($view . '.' . $name, $name);
    +	}
    +
    +	/**
    +	 * set Dynamic field
    +	 *
    +	 * @param   array    $field           The field data
    +	 * @param   array    $view            The view data
    +	 * @param   int      $viewType        The view type
    +	 * @param   string   $langView        The language string of the view
    +	 * @param   string   $nameSingleCode  The single view name
    +	 * @param   string   $nameListCode    The list view name
    +	 * @param   array    $placeholders    The place holder and replace values
    +	 * @param   string   $dbkey           The the custom table key
    +	 * @param   boolean  $build           The switch to set the build option
    +	 *
    +	 * @return  mixed The complete field
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Field.Names')->get(...);
    +	 */
    +	public function setDynamicField(&$field, &$view, &$viewType, &$langView,
    +		&$nameSingleCode, &$nameListCode, &$placeholders, &$dbkey, $build)
    +	{
    +		CFactory::_('Compiler.Creator.Field.Dynamic')->get($field, $view, $viewType, $langView,
    +			$nameSingleCode, $nameListCode, $placeholders, $dbkey, $build);
    +	}
    +
    +	/**
    +	 * build field set
    +	 *
    +	 * @param   array    $fields          The fields data
    +	 * @param   string   $langView        The language string of the view
    +	 * @param   string   $nameSingleCode  The single view name
    +	 * @param   string   $nameListCode    The list view name
    +	 * @param   array    $placeholders    The place holder and replace values
    +	 * @param   string   $dbkey           The the custom table key
    +	 * @param   boolean  $build           The switch to set the build option
    +	 * @param   int      $return_type     The return type 1 = string, 2 = array
    +	 *
    +	 * @return  mixed   The complete field in string or array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Fieldset.Dynamic')->get(...);
    +	 */
    +	public function getFieldsetXML(array &$fields, string &$langView, string &$nameSingleCode,
    +		string &$nameListCode, array &$placeholders, string &$dbkey, bool $build = false,
    +		int $returnType = 1)
    +	{
    +		return CFactory::_('Compiler.Creator.Fieldset.Dynamic')->get(
    +			$fields, $langView, $nameSingleCode,
    +			$nameListCode, $placeholders, $dbkey, $build, $returnType
    +		);
    +	}
    +
    +	/**
    +	 * build field string
    +	 *
    +	 * @param   array    $field           The field data
    +	 * @param   array    $view            The view data
    +	 * @param   int      $viewType        The view type
    +	 * @param   string   $langView        The language string of the view
    +	 * @param   string   $nameSingleCode  The single view name
    +	 * @param   string   $nameListCode    The list view name
    +	 * @param   array    $placeholders    The place holder and replace values
    +	 * @param   string   $dbkey           The the custom table key
    +	 * @param   boolean  $build           The switch to set the build option
    +	 *
    +	 * @return  string  The complete field in xml-string
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Field.As.String')->get(...);
    +	 */
    +	public function getFieldXMLString(array &$field, array &$view, int &$viewType, string &$langView,
    +		string &$nameSingleCode, string &$nameListCode, array &$placeholders, string &$dbkey,
    +		bool $build = false): string
    +	{
    +		// get field
    +		return CFactory::_('Compiler.Creator.Field.As.String')->get(
    +			$field, $view, $viewType, $langView,
    +			$nameSingleCode, $nameListCode, $placeholders, $dbkey, $build
    +		);
    +	}
    +
    +	/**
    +	 * set a field
    +	 *
    +	 * @param   string  $setType          The set of fields type
    +	 * @param   array   $fieldAttributes  The field values
    +	 * @param   string  $name             The field name
    +	 * @param   string  $typeName         The field type
    +	 * @param   string  $langView         The language string of the view
    +	 * @param   string  $nameSingleCode   The single view name
    +	 * @param   string  $nameListCode     The list view name
    +	 * @param   array   $placeholders     The place holder and replace values
    +	 * @param   array|null  $optionArray      The option bucket array used to set the field options if needed.
    +	 * @param   array   $custom           Used when field is from config
    +	 * @param   string  $taber            The tabs to add in layout (only in string manipulation)
    +	 *
    +	 * @return  SimpleXMLElement The field in xml
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Field.Type')->get(...);
    +	 */
    +	private function setField($setType, &$fieldAttributes, &$name, &$typeName,
    +	                          &$langView, &$nameSingleCode, &$nameListCode, $placeholders,
    +	                          &$optionArray, $custom = null, $taber = ''
    +	) {
    +		return CFactory::_('Compiler.Creator.Field.Type')->get(
    +			$setType, $fieldAttributes, $name, $typeName,
    +			$langView, $nameSingleCode, $nameListCode, $placeholders,
    +			$optionArray, $custom, $taber
    +		);
    +	}
    +
    +	/**
    +	 * set a field using string manipulation
    +	 *
    +	 * @param   string  $setType          The set of fields type
    +	 * @param   array   $fieldAttributes  The field values
    +	 * @param   string  $name             The field name
    +	 * @param   string  $typeName         The field type
    +	 * @param   string  $langView         The language string of the view
    +	 * @param   string  $nameSingleCode   The single view name
    +	 * @param   string  $nameListCode     The list view name
    +	 * @param   array   $placeholders     The place holder and replace values
    +	 * @param   array|null  $optionArray      The option bucket array used to set the field options if needed.
    +	 * @param   array   $custom           Used when field is from config
    +	 * @param   string  $taber            The tabs to add in layout
    +	 *
    +	 * @return  SimpleXMLElement The field in xml
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Field.String')->get(...);
    +	 */
    +	protected function stringSetField($setType, &$fieldAttributes, &$name,
    +		&$typeName, &$langView, &$nameSingleCode, &$nameListCode,
    +		$placeholders, &$optionArray, $custom = null, $taber = '')
    +	{
    +		return CFactory::_('Compiler.Creator.Field.String')->get(
    +			$setType, $fieldAttributes, $name,
    +			$typeName, $langView, $nameSingleCode, $nameListCode,
    +			$placeholders, $optionArray, $custom, $taber
    +		);
    +	}
    +
    +	/**
    +	 * set a field with simpleXMLElement class
    +	 *
    +	 * @param   string  $setType          The set of fields type
    +	 * @param   array   $fieldAttributes  The field values
    +	 * @param   string  $name             The field name
    +	 * @param   string  $typeName         The field type
    +	 * @param   string  $langView         The language string of the view
    +	 * @param   string  $nameSingleCode   The single view name
    +	 * @param   string  $nameListCode     The list view name
    +	 * @param   array   $placeholders     The place holder and replace values
    +	 * @param   string  $optionArray      The option bucket array used to set the field options if needed.
    +	 * @param   array   $custom           Used when field is from config
    +	 *
    +	 * @return  SimpleXMLElement The field in xml
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Field.XML')->get(...);
    +	 */
    +	protected function simpleXMLSetField($setType, &$fieldAttributes, &$name,
    +		&$typeName, &$langView, &$nameSingleCode, &$nameListCode,
    +		$placeholders, &$optionArray, $custom = null)
    +	{
    +		return CFactory::_('Compiler.Creator.Field.XML')->get(
    +			$setType, $fieldAttributes, $name,
    +			$typeName, $langView, $nameSingleCode, $nameListCode,
    +			$placeholders, $optionArray, $custom
    +		);
    +	}
    +
    +	/**
    +	 * set the layout builder
    +	 *
    +	 * @param   string  $nameSingleCode  The single edit view code name
    +	 * @param   string  $tabName         The tab code name
    +	 * @param   string  $name            The field code name
    +	 * @param   array   $field           The field details
    +	 *
    +	 * @return  void
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Layout')->set(...);
    +	 */
    +	public function setLayoutBuilder($nameSingleCode, $tabName, $name, &$field)
    +	{
    +		CFactory::_('Compiler.Creator.Layout')->set($nameSingleCode, $tabName, $name, $field);
    +	}
    +
    +	/**
    +	 * build the site field data needed
    +	 *
    +	 * @param   string  $view   The single edit view code name
    +	 * @param   string  $field  The field name
    +	 * @param   string  $set    The decoding set this field belongs to
    +	 * @param   string  $type   The field type
    +	 *
    +	 * @return  void
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Site.Field.Data')->set(...);
    +	 */
    +	public function buildSiteFieldData($view, $field, $set, $type)
    +	{
    +		CFactory::_('Compiler.Creator.Site.Field.Data')->set($view, $field, $set, $type);
    +	}
    +
    +	/**
    +	 * set field attributes
    +	 *
    +	 * @param   array    $field           The field data
    +	 * @param   int      $viewType        The view type
    +	 * @param   string   $name            The field name
    +	 * @param   string   $typeName        The field type
    +	 * @param   boolean  $multiple        The switch to set multiple selection option
    +	 * @param   string   $langLabel       The language string for field label
    +	 * @param   string   $langView        The language string of the view
    +	 * @param   string   $nameListCode    The list view name
    +	 * @param   string   $nameSingleCode  The single view name
    +	 * @param   array    $placeholders    The place holder and replace values
    +	 * @param   boolean  $repeatable      The repeatable field switch
    +	 *
    +	 * @return  array The field attributes
    +	 * @deprecated 3.3 Use CFactory::_('Field.Attributes')->set(...);
    +	 */
    +	private function setFieldAttributes(&$field, &$viewType, &$name, &$typeName,
    +		&$multiple, &$langLabel, $langView, $nameListCode, $nameSingleCode,
    +		$placeholders, $repeatable = false
    +	)
    +	{
    +		// set notice that we could not get a valid string from the target
    +		$this->app->enqueueMessage(
    +			Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error'
    +		);
    +		$this->app->enqueueMessage(
    +			Text::sprintf(
    +				'Use of a deprecated method (%s)!', __METHOD__
    +			), 'Error'
    +		);
    +
    +		return false;
    +	}
    +
    +	/**
    +	 * set Builders
    +	 *
    +	 * @param   string       $langLabel       The language string for field label
    +	 * @param   string       $langView        The language string of the view
    +	 * @param   string       $nameSingleCode  The single view name
    +	 * @param   string       $nameListCode    The list view name
    +	 * @param   string       $name            The field name
    +	 * @param   array        $view            The view data
    +	 * @param   array        $field           The field data
    +	 * @param   string       $typeName        The field type
    +	 * @param   bool         $multiple        The switch to set multiple selection option
    +	 * @param   array|null   $custom          The custom field switch
    +	 * @param   array|null   $options         The options switch
    +	 *
    +	 * @return  void
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Builders')->set(...);
    +	 */
    +	public function setBuilders($langLabel, $langView, $nameSingleCode,
    +		$nameListCode, $name, $view, $field, $typeName, $multiple,
    +		$custom = null, $options = null
    +	): void
    +	{
    +		CFactory::_('Compiler.Creator.Builders')->set($langLabel, $langView, $nameSingleCode,
    +			$nameListCode, $name, $view, $field, $typeName, $multiple, $custom, $options);
    +	}
    +
    +	/**
    +	 * set Custom Field Type File
    +	 *
    +	 * @param   array   $data            The field complete data set
    +	 * @param   string  $nameListCode    The list view code name
    +	 * @param   string  $nameSingleCode  The single view code name
    +	 *
    +	 * @return  void
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Custom.Field.Type.File')->set(...);
    +	 */
    +	public function setCustomFieldTypeFile($data, $nameListCode,$nameSingleCode)
    +	{
    +		CFactory::_('Compiler.Creator.Custom.Field.Type.File')->set($data, $nameListCode,$nameSingleCode);
    +	}
    +
    +	/**
    +	 * This is just to get the code.
    +	 * Don't use this to build the field
    +	 *
    +	 * @param   array  $custom  The field complete data set
    +	 *
    +	 * @return  array with the code
    +	 *
    +	 */
    +	public function getCustomFieldCode($custom)
    +	{
    +		// the code bucket
    +		$code_bucket = array(
    +			'JFORM_TYPE_HEADER' => '',
    +			'JFORM_TYPE_PHP'    => ''
    +		);
    +		// set tab and break replacements
    +		$tabBreak = array(
    +			'\t' => Indent::_(1),
    +			'\n' => PHP_EOL
    +		);
    +		// load the other PHP options
    +		foreach (ComponentbuilderHelper::$phpFieldArray as $x)
    +		{
    +			// reset the php bucket
    +			$phpBucket = '';
    +			// only set if available
    +			if (isset($custom['php' . $x])
    +				&& ArrayHelper::check(
    +					$custom['php' . $x]
    +				))
    +			{
    +				foreach ($custom['php' . $x] as $line => $code)
    +				{
    +					if (StringHelper::check($code))
    +					{
    +						$phpBucket .= PHP_EOL . CFactory::_('Placeholder')->update(
    +								$code, $tabBreak
    +							);
    +					}
    +				}
    +				// check if this is header text
    +				if ('HEADER' === $x)
    +				{
    +					$code_bucket['JFORM_TYPE_HEADER']
    +						.= PHP_EOL . $phpBucket;
    +				}
    +				else
    +				{
    +					// JFORM_TYPE_PHP <<>>
    +					$code_bucket['JFORM_TYPE_PHP']
    +						.= PHP_EOL . $phpBucket;
    +				}
    +			}
    +		}
    +
    +		return $code_bucket;
    +	}
    +
    +	/**
    +	 * set the Filter Field set of a view
    +	 *
    +	 * @param   string  $nameSingleCode  The single view name
    +	 * @param   string  $nameListCode    The list view name
    +	 *
    +	 * @return  string The fields set in xml
    +	 *
    +	 */
    +	public function setFieldFilterSet(&$nameSingleCode, &$nameListCode)
    +	{
    +		if (CFactory::_('Config')->get('joomla_version', 3) == 3)
    +		{
    +			return $this->setFieldFilterSetJ3($nameSingleCode, $nameListCode);
    +		}
    +		return $this->setFieldFilterSetJ4($nameSingleCode, $nameListCode);
    +	}
    +
    +	/**
    +	 * set the Filter List set of a view
    +	 *
    +	 * @param   string  $nameSingleCode  The single view name
    +	 * @param   string  $nameListCode    The list view name
    +	 *
    +	 * @return  string The fields set in xml
    +	 *
    +	 */
    +	public function setFieldFilterListSet(&$nameSingleCode, &$nameListCode)
    +	{
    +		if (CFactory::_('Config')->get('joomla_version', 3) == 3)
    +		{
    +			return $this->setFieldFilterListSetJ3($nameSingleCode, $nameListCode);
    +		}
    +		return $this->setFieldFilterListSetJ4($nameSingleCode, $nameListCode);
    +	}
    +
    +	/**
    +	 * set the Filter Field set of a view
    +	 *
    +	 * @param   string  $nameSingleCode  The single view name
    +	 * @param   string  $nameListCode    The list view name
    +	 *
    +	 * @return  string The fields set in xml
    +	 *
    +	 */
    +	public function setFieldFilterSetJ3(&$nameSingleCode, &$nameListCode)
    +	{
    +		// check if this is the above/new filter option
    +		if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2)
    +		{
    +			// we first create the file
    +			$target = array('admin' => 'filter_' . $nameListCode);
    +			CFactory::_('Utilities.Structure')->build(
    +				$target, 'filter'
    +			);
    +			// the search language string
    +			$lang_search = CFactory::_('Config')->lang_prefix . '_FILTER_SEARCH';
    +			// and to translation
    +			CFactory::_('Language')->set(
    +				CFactory::_('Config')->lang_target, $lang_search, 'Search'
    +				. StringHelper::safe($nameListCode, 'w')
    +			);
    +			// the search description language string
    +			$lang_search_desc = CFactory::_('Config')->lang_prefix . '_FILTER_SEARCH_'
    +				. strtoupper($nameListCode);
    +			// and to translation
    +			CFactory::_('Language')->set(
    +				CFactory::_('Config')->lang_target, $lang_search_desc, 'Search the '
    +				. StringHelper::safe($nameSingleCode, 'w')
    +				. ' items. Prefix with ID: to search for an item by ID.'
    +			);
    +			// now build the XML
    +			$field_filter_sets   = [];
    +			$field_filter_sets[] = Indent::_(1) . '';
    +			// we first add the search
    +			$field_filter_sets[] = Indent::_(2) . '';
    +			// add the published filter if published is not set
    +			if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.published'))
    +			{
    +				// the published language string
    +				$lang_published = CFactory::_('Config')->lang_prefix . '_FILTER_PUBLISHED';
    +				// and to translation
    +				CFactory::_('Language')->set(
    +					CFactory::_('Config')->lang_target, $lang_published, 'Status'
    +				);
    +				// the published description language string
    +				$lang_published_desc = CFactory::_('Config')->lang_prefix . '_FILTER_PUBLISHED_'
    +					. strtoupper($nameListCode);
    +				// and to translation
    +				CFactory::_('Language')->set(
    +					CFactory::_('Config')->lang_target, $lang_published_desc, 'Status options for '
    +					. StringHelper::safe($nameListCode, 'w')
    +				);
    +				$field_filter_sets[] = Indent::_(2) . '';
    +				$field_filter_sets[] = Indent::_(3)
    +					. '';
    +				$field_filter_sets[] = Indent::_(2) . '';
    +			}
    +			// add the category if found
    +			if (CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.extension")
    +				&& CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.filter", 0) >= 1)
    +			{
    +				$field_filter_sets[] = Indent::_(2) . '';
    +			}
    +			// add the access filter if this view has access
    +			// and if access manually is not set
    +			if (CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode)
    +				&& !CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.access'))
    +			{
    +				$field_filter_sets[] = Indent::_(2) . '';
    +			}
    +			// now add the dynamic fields
    +			if (CFactory::_('Compiler.Builder.Filter')->exists($nameListCode))
    +			{
    +				foreach (CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as $n => $filter)
    +				{
    +					if ($filter['type'] != 'category')
    +					{
    +						$field_filter_sets[] = Indent::_(2) . 'set("{$nameListCode}.{$n}.class", $filter_class);
    +
    +						$field_filter_sets[] = Indent::_(3) . 'name="'
    +							. $filter['code'] . '"';
    +						$field_filter_sets[] = Indent::_(3) . 'label="'
    +							. $filter['label'] . '"';
    +
    +						// if this is a multi field
    +						if ($filter['multi'] == 2)
    +						{
    +							$field_filter_sets[] = Indent::_(3) . 'class="multiple' . $filter_class . '"';
    +							$field_filter_sets[] = Indent::_(3) . 'multiple="true"';
    +						}
    +						else
    +						{
    +							$field_filter_sets[] = Indent::_(3) . 'multiple="false"';
    +						}
    +
    +						$field_filter_sets[] = Indent::_(3)
    +							. 'onchange="this.form.submit();"';
    +						$field_filter_sets[] = Indent::_(2) . '/>';
    +					}
    +				}
    +			}
    +			$field_filter_sets[] = Indent::_(2)
    +				. '';
    +			$field_filter_sets[] = Indent::_(1) . '';
    +
    +			// now update the file
    +			return implode(PHP_EOL, $field_filter_sets);
    +		}
    +
    +		return '';
    +	}
    +
    +	/**
    +	 * set the Filter List set of a view
    +	 *
    +	 * @param   string  $nameSingleCode  The single view name
    +	 * @param   string  $nameListCode    The list view name
    +	 *
    +	 * @return  string The fields set in xml
    +	 *
    +	 */
    +	public function setFieldFilterListSetJ3(&$nameSingleCode, &$nameListCode)
    +	{
    +		// check if this is the above/new filter option
    +		if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2)
    +		{
    +			// keep track of all fields already added
    +			$donelist = array('ordering' => true, 'id' => true);
    +			// now build the XML
    +			$list_sets   = [];
    +			$list_sets[] = Indent::_(1) . '';
    +			$list_sets[] = Indent::_(2) . 'getListViewDefaultOrdering(
    +				$nameListCode
    +			);
    +			// set the default ordering
    +			$list_sets[] = Indent::_(3) . 'default="'
    +				. $default_ordering['name'] . ' '
    +				. $default_ordering['direction'] . '"';
    +			$list_sets[] = Indent::_(3) . 'validate="options"';
    +			$list_sets[] = Indent::_(2) . '>';
    +			$list_sets[] = Indent::_(3)
    +				. '';
    +			$list_sets[] = Indent::_(3)
    +				. '';
    +			$list_sets[] = Indent::_(3)
    +				. '';
    +			// add the published filter if published is not set
    +			if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.published'))
    +			{
    +				// add to done list
    +				$donelist['published'] = true;
    +				// add to xml :)
    +				$list_sets[] = Indent::_(3)
    +					. '';
    +				$list_sets[] = Indent::_(3)
    +					. '';
    +			}
    +
    +			// add the rest of the set filters
    +			if (CFactory::_('Compiler.Builder.Sort')->exists($nameListCode))
    +			{
    +				foreach (CFactory::_('Compiler.Builder.Sort')->get($nameListCode) as $filter)
    +				{
    +					if (!isset($donelist[$filter['code']]))
    +					{
    +						if ($filter['type'] === 'category')
    +						{
    +							$list_sets[] = Indent::_(3)
    +								. '';
    +							$list_sets[] = Indent::_(3)
    +								. '';
    +						}
    +						elseif (ArrayHelper::check(
    +							$filter['custom']
    +						))
    +						{
    +							$list_sets[] = Indent::_(3) . '';
    +							$list_sets[] = Indent::_(3) . '';
    +						}
    +						else
    +						{
    +							$list_sets[] = Indent::_(3) . '';
    +							$list_sets[] = Indent::_(3) . '';
    +						}
    +						// do not add again
    +						$donelist[$filter['code']] = true;
    +					}
    +				}
    +			}
    +
    +			$list_sets[] = Indent::_(3)
    +				. '';
    +			$list_sets[] = Indent::_(3)
    +				. '';
    +			$list_sets[] = Indent::_(2) . '' . PHP_EOL;
    +
    +			$list_sets[] = Indent::_(2) . '';
    +			$list_sets[] = Indent::_(1) . '';
    +
    +			return implode(PHP_EOL, $list_sets);
    +		}
    +
    +		return '';
    +	}
    +
    +	/**
    +	 * set the Filter Field set of a view
    +	 *
    +	 * @param   string  $nameSingleCode  The single view name
    +	 * @param   string  $nameListCode    The list view name
    +	 *
    +	 * @return  string The fields set in xml
    +	 *
    +	 */
    +	public function setFieldFilterSetJ4(&$nameSingleCode, &$nameListCode)
    +	{
    +		// check if this is the above/new filter option
    +		if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2)
    +		{
    +			// we first create the file
    +			$target = ['admin' => 'filter_' . $nameListCode];
    +			CFactory::_('Utilities.Structure')->build(
    +				$target, 'filter'
    +			);
    +			// the search language string
    +			$lang_search = CFactory::_('Config')->lang_prefix . '_FILTER_SEARCH';
    +			// and to translation
    +			CFactory::_('Language')->set(
    +				CFactory::_('Config')->lang_target, $lang_search, 'Search'
    +				. StringHelper::safe($nameListCode, 'w')
    +			);
    +			// the search description language string
    +			$lang_search_desc = CFactory::_('Config')->lang_prefix . '_FILTER_SEARCH_'
    +				. strtoupper($nameListCode);
    +			// and to translation
    +			CFactory::_('Language')->set(
    +				CFactory::_('Config')->lang_target, $lang_search_desc, 'Search the '
    +				. StringHelper::safe($nameSingleCode, 'w')
    +				. ' items. Prefix with ID: to search for an item by ID.'
    +			);
    +			// now build the XML
    +			$field_filter_sets   = [];
    +			$field_filter_sets[] = Indent::_(1) . '';
    +			// we first add the search
    +			$field_filter_sets[] = Indent::_(2) . '';
    +			// add the published filter if published is not set
    +			if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.published'))
    +			{
    +				// the published language string
    +				$lang_published = CFactory::_('Config')->lang_prefix . '_FILTER_PUBLISHED';
    +				// and to translation
    +				CFactory::_('Language')->set(
    +					CFactory::_('Config')->lang_target, $lang_published, 'Status'
    +				);
    +				// the published description language string
    +				$lang_published_desc = CFactory::_('Config')->lang_prefix . '_FILTER_PUBLISHED_'
    +					. strtoupper($nameListCode);
    +				// and to translation
    +				CFactory::_('Language')->set(
    +					CFactory::_('Config')->lang_target, $lang_published_desc, 'Status options for '
    +					. StringHelper::safe($nameListCode, 'w')
    +				);
    +				$field_filter_sets[] = Indent::_(2) . '';
    +				$field_filter_sets[] = Indent::_(3)
    +					. '';
    +				$field_filter_sets[] = Indent::_(2) . '';
    +			}
    +			// add the category if found
    +			if (CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.extension")
    +				&& CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.filter", 0) >= 1)
    +			{
    +				$field_filter_sets[] = Indent::_(2) . '';
    +			}
    +			// add the access filter if this view has access
    +			// and if access manually is not set
    +			if (CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode)
    +				&& !CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.access'))
    +			{
    +				$field_filter_sets[] = Indent::_(2) . '';
    +			}
    +			// now add the dynamic fields
    +			if (CFactory::_('Compiler.Builder.Filter')->exists($nameListCode))
    +			{
    +				foreach (CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as $n => $filter)
    +				{
    +					if ($filter['type'] != 'category')
    +					{
    +						$field_filter_sets[] = Indent::_(2) . '';
    +					}
    +				}
    +			}
    +			$field_filter_sets[] = Indent::_(2)
    +				. '';
    +			$field_filter_sets[] = Indent::_(1) . '';
    +
    +			// now update the file
    +			return implode(PHP_EOL, $field_filter_sets);
    +		}
    +
    +		return '';
    +	}
    +
    +	/**
    +	 * set the Filter List set of a view
    +	 *
    +	 * @param   string  $nameSingleCode  The single view name
    +	 * @param   string  $nameListCode    The list view name
    +	 *
    +	 * @return  string The fields set in xml
    +	 *
    +	 */
    +	public function setFieldFilterListSetJ4(&$nameSingleCode, &$nameListCode)
    +	{
    +		// check if this is the above/new filter option
    +		if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2)
    +		{
    +			// keep track of all fields already added
    +			$donelist = ['ordering' => true, 'id' => true];
    +			// now build the XML
    +			$list_sets   = [];
    +			$list_sets[] = Indent::_(1) . '';
    +			$list_sets[] = Indent::_(2) . 'getListViewDefaultOrdering(
    +				$nameListCode
    +			);
    +			// set the default ordering
    +			$list_sets[] = Indent::_(3) . 'default="'
    +				. $default_ordering['name'] . ' '
    +				. $default_ordering['direction'] . '"';
    +			$list_sets[] = Indent::_(3) . 'validate="options"';
    +			$list_sets[] = Indent::_(2) . '>';
    +			$list_sets[] = Indent::_(3)
    +				. '';
    +			$list_sets[] = Indent::_(3)
    +				. '';
    +			$list_sets[] = Indent::_(3)
    +				. '';
    +			// add the published filter if published is not set
    +			if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.published'))
    +			{
    +				// add to done list
    +				$donelist['published'] = true;
    +				// add to xml :)
    +				$list_sets[] = Indent::_(3)
    +					. '';
    +				$list_sets[] = Indent::_(3)
    +					. '';
    +			}
    +
    +			// add the rest of the set filters
    +			if (CFactory::_('Compiler.Builder.Sort')->exists($nameListCode))
    +			{
    +				foreach (CFactory::_('Compiler.Builder.Sort')->get($nameListCode) as $filter)
    +				{
    +					if (!isset($donelist[$filter['code']]))
    +					{
    +						if ($filter['type'] === 'category')
    +						{
    +							$list_sets[] = Indent::_(3)
    +								. '';
    +							$list_sets[] = Indent::_(3)
    +								. '';
    +						}
    +						elseif (ArrayHelper::check(
    +							$filter['custom']
    +						))
    +						{
    +							$list_sets[] = Indent::_(3) . '';
    +							$list_sets[] = Indent::_(3) . '';
    +						}
    +						else
    +						{
    +							$list_sets[] = Indent::_(3) . '';
    +							$list_sets[] = Indent::_(3) . '';
    +						}
    +						// do not add again
    +						$donelist[$filter['code']] = true;
    +					}
    +				}
    +			}
    +
    +			$list_sets[] = Indent::_(3)
    +				. '';
    +			$list_sets[] = Indent::_(3)
    +				. '';
    +			$list_sets[] = Indent::_(2) . '' . PHP_EOL;
    +
    +			$list_sets[] = Indent::_(2) . '';
    +			$list_sets[] = Indent::_(1) . '';
    +
    +			return implode(PHP_EOL, $list_sets);
    +		}
    +
    +		return '';
    +	}
    +
    +	/**
    +	 * set Custom Field for Filter
    +	 *
    +	 * @param   string  $getOptions  The get options php string/code
    +	 * @param   array   $filter      The filter details
    +	 *
    +	 * @return  void
    +	 *
    +	 */
    +	public function setFilterFieldFile($getOptions, $filter)
    +	{
    +		// make sure it is not already been build
    +		if (!CFactory::_('Compiler.Builder.Content.Multi')->
    +			isArray('customfilterfield_' . $filter['filter_type']))
    +		{
    +			// start loading the field type
    +			// $this->fileContentDynamic['customfilterfield_'
    +			// . $filter['filter_type']]
    +			// = [];
    +			// JPREFIX <>>
    +			CFactory::_('Compiler.Builder.Content.Multi')->set('customfilterfield_' . $filter['filter_type'] . '|JPREFIX', 'J');
    +			// Type <<>>
    +			CFactory::_('Compiler.Builder.Content.Multi')->set('customfilterfield_' . $filter['filter_type'] . '|Type',
    +				StringHelper::safe(
    +					$filter['filter_type'], 'F'
    +				)
    +			);
    +			// type <<>>
    +			CFactory::_('Compiler.Builder.Content.Multi')->set('customfilterfield_' . $filter['filter_type'] . '|type',
    +				StringHelper::safe($filter['filter_type'])
    +			);
    +			// JFORM_GETOPTIONS_PHP <<>>
    +			CFactory::_('Compiler.Builder.Content.Multi')->set('customfilterfield_' . $filter['filter_type'] . '|JFORM_GETOPTIONS_PHP',
    +				$getOptions
    +			);
    +			// ADD_BUTTON <<>>
    +			CFactory::_('Compiler.Builder.Content.Multi')->set('customfilterfield_' . $filter['filter_type'] . '|ADD_BUTTON', '');
    +			// now build the custom filter field type file
    +			$target = array('admin' => 'customfilterfield');
    +			CFactory::_('Utilities.Structure')->build(
    +				$target, 'fieldlist',
    +				$filter['filter_type']
    +			);
    +		}
    +	}
    +
    +	/**
    +	 * set Add Button To List Field (getInput tweak)
    +	 *
    +	 * @param   array  $fieldData  The field custom data
    +	 *
    +	 * @return  string of getInput class on success empty string otherwise
    +	 * @deprecated 3.3 Use CFactory::_('Field.Input.Button')->get($fieldData);
    +	 */
    +	protected function setAddButtonToListField($fieldData)
    +	{
    +		return CFactory::_('Field.Input.Button')->get($fieldData);
    +	}
    +
    +	/**
    +	 * xmlPrettyPrint
    +	 *
    +	 * @param   SimpleXMLElement  $xml       The XML element containing a node to be output
    +	 * @param   string            $nodename  node name of the input xml element to print out.  this is done to omit the pretty($xml, $nodename);
    +	 */
    +	public function xmlPrettyPrint($xml, $nodename)
    +	{
    +		return CFactory::_('Utilities.Xml')->pretty($xml, $nodename);
    +	}
    +
    +	/**
    +	 * xmlIndent
    +	 *
    +	 * @param   string   $string     The XML input
    +	 * @param   string   $char       Character or characters to use as the repeated indent
    +	 * @param   integer  $depth      number of times to repeat the indent character
    +	 * @param   boolean  $skipfirst  Skip the first line of the input.
    +	 * @param   boolean  $skiplast   Skip the last line of the input;
    +	 *
    +	 * @return  string XML output
    +	 * @deprecated 3.3 Use CFactory::_('Utilities.Xml')->indent(...);
    +	 */
    +	public function xmlIndent($string, $char = ' ', $depth = 0,
    +	                          $skipfirst = false, $skiplast = false
    +	) {
    +		return CFactory::_('Utilities.Xml')->indent($string, $char, $depth, $skipfirst, $skiplast);
    +	}
    +}
    +
    diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Get.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Get.php
    new file mode 100644
    index 000000000..30506c31c
    --- /dev/null
    +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Get.php
    @@ -0,0 +1,3157 @@
    +
    + * @git        Joomla Component Builder 
    + * @copyright  Copyright (C) 2015 Vast Development Method. All rights reserved.
    + * @license    GNU General Public License version 2 or later; see LICENSE.txt
    + */
    +
    +namespace VDM\Joomla\Componentbuilder\Compiler\Helper;
    +
    +
    +use Joomla\CMS\Factory;
    +use Joomla\CMS\Language\Text;
    +use Joomla\CMS\Component\ComponentHelper;
    +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
    +use VDM\Joomla\Utilities\StringHelper;
    +use VDM\Joomla\Utilities\JsonHelper;
    +use VDM\Joomla\Utilities\ArrayHelper;
    +use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory;
    +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
    +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
    +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Unique;
    +
    +
    +/**
    + * Get class as the main compilers class
    + * 
    + * @deprecated 3.3
    + */
    +class Get
    +{
    +	/**
    +	 * The Joomla Version
    +	 *
    +	 * @var     string
    +	 * @deprecated 3.3 Use CFactory::_('Config')->joomla_version;
    +	 */
    +	public $joomlaVersion;
    +
    +	/**
    +	 * The Joomla Versions
    +	 *
    +	 * @var     array
    +	 * @deprecated 3.3 Use CFactory::_('Config')->joomla_versions;
    +	 */
    +	public $joomlaVersions = array(
    +		3    => array('folder_key' => 3, 'xml_version' => 3.9), // only joomla 3
    +		3.10 => array('folder_key' => 3, 'xml_version' => 4.0) // legacy joomla 4
    +	);
    +
    +	/**
    +	 * The hash placeholder
    +	 *
    +	 * @var     string
    +	 * @deprecated 3.3 Use Placefix::h();
    +	 */
    +	public $hhh = '#' . '#' . '#';
    +
    +	/**
    +	 * The open bracket placeholder
    +	 *
    +	 * @var     string
    +	 * @deprecated 3.3 Use Placefix::b();
    +	 */
    +	public $bbb = '[' . '[' . '[';
    +
    +	/**
    +	 * The close bracket placeholder
    +	 *
    +	 * @var     string
    +	 * @deprecated 3.3 Use Placefix::d();
    +	 */
    +	public $ddd = ']' . ']' . ']';
    +
    +	/**
    +	 * The app
    +	 *
    +	 * @var     object
    +	 */
    +	public $app;
    +
    +	/**
    +	 * The Params
    +	 *
    +	 * @var     object
    +	 */
    +	public $params;
    +
    +	/**
    +	 * Add strict field export permissions
    +	 *
    +	 * @var     boolean
    +	 */
    +	public $strictFieldExportPermissions = false;
    +
    +	/**
    +	 * Add text only export options
    +	 *
    +	 * @var     boolean
    +	 */
    +	public $exportTextOnly = false;
    +
    +	/**
    +	 * The global placeholders
    +	 *
    +	 * @var     array
    +	 * @deprecated 3.3 Use CFactory::_('Component.Placeholder')->get();
    +	 */
    +	public $globalPlaceholders = [];
    +
    +	/**
    +	 * The placeholders
    +	 *
    +	 * @var     array
    +	 * @deprecated 3.3 Use CFactory::_('Placeholder')->active[];
    +	 */
    +	public $placeholders = [];
    +
    +	/**
    +	 * The Compiler Path
    +	 *
    +	 * @var     object
    +	 * @deprecated 3.3 Use CFactory::_('Config')->compiler_path;
    +	 */
    +	public $compilerPath;
    +
    +	/**
    +	 * The JCB Powers Path
    +	 *
    +	 * @var     object
    +	 * @deprecated 3.3 Use CFactory::_('Config')->jcb_powers_path;
    +	 */
    +	public $jcbPowersPath;
    +
    +	/**
    +	 * Switch to add assets table fix
    +	 *
    +	 * @var     int
    +	 * @deprecated 3.3 Use CFactory::_('Config')->add_assets_table_fix;
    +	 */
    +	public $addAssetsTableFix = 1;
    +
    +	/**
    +	 * Assets table worse case
    +	 *
    +	 * @var     int
    +	 * @deprecated 3.3 Use CFactory::_('Config')->access_worse_case;
    +	 */
    +	public $accessWorseCase;
    +
    +	/**
    +	 * Switch to add assets table name fix
    +	 *
    +	 * @var     bool
    +	 * @deprecated 3.3 Use CFactory::_('Config')->add_assets_table_name_fix;
    +	 */
    +	public $addAssetsTableNameFix = false;
    +
    +	/**
    +	 * Switch to add custom code placeholders
    +	 *
    +	 * @var     bool
    +	 * @deprecated 3.3 Use CFactory::_('Config')->add_placeholders;
    +	 */
    +	public $addPlaceholders = false;
    +
    +	/**
    +	 * Switch to remove line breaks from language strings
    +	 *
    +	 * @var     bool
    +	 * @deprecated 3.3 Use CFactory::_('Config')->remove_line_breaks;
    +	 */
    +	public $removeLineBreaks = false;
    +
    +	/**
    +	 * The placeholders for custom code keys
    +	 *
    +	 * @var     array
    +	 * @deprecated 3.3
    +	 */
    +	protected $customCodeKeyPlacholders
    +		= array(
    +			'[' => '[',
    +			']' => ']',
    +			',' => ',',
    +			'+' => '+',
    +			'=' => '='
    +		);
    +
    +	/**
    +	 * The Component data
    +	 *
    +	 * @var      object
    +	 * @deprecated 3.3 Use CFactory::_('Component');
    +	 */
    +	public $componentData;
    +
    +	/**
    +	 * The Switch to add Powers data
    +	 *
    +	 * @var      boolean
    +	 * @deprecated 3.3 Use CFactory::_('Config')->add_power;
    +	 */
    +	public $addPower;
    +
    +	/**
    +	 * The Powers data
    +	 *
    +	 * @var      array
    +	 * @deprecated 3.3 Use CFactory::_('Power')->active;
    +	 */
    +	public $powers = [];
    +
    +	/**
    +	 * The state of all Powers
    +	 *
    +	 * @var      array
    +	 * @deprecated 3.3
    +	 */
    +	public $statePowers = [];
    +
    +	/**
    +	 * The linked Powers
    +	 *
    +	 * @var      array
    +	 */
    +	public $linkedPowers = [];
    +
    +	/**
    +	 * The Plugins data
    +	 *
    +	 * @var      array
    +	 * @deprecated 3.3 Use CFactory::_('Joomlaplugin.Data')->get();
    +	 */
    +	public $joomlaPlugins = [];
    +
    +	/**
    +	 * The Modules data
    +	 *
    +	 * @var      array
    +	 * @deprecated 3.3 Use CFactory::_('Joomlamodule.Data')->get();
    +	 */
    +	public $joomlaModules = [];
    +
    +	/**
    +	 *    The custom script placeholders - we use the (xxx) to avoid detection it should be (***)
    +	 *    ##################################--->  PHP/JS  <---####################################
    +	 *
    +	 *    New Insert Code        = /xxx[INSERT<>$$$$]xxx/                /xxx[/INSERT<>$$$$]xxx/
    +	 *    New Replace Code    = /xxx[REPLACE<>$$$$]xxx/               /xxx[/REPLACE<>$$$$]xxx/
    +	 *
    +	 *    //////////////////////////////// when JCB adds it back //////////////////////////////////
    +	 *    JCB Add Inserted Code    = /xxx[INSERTED$$$$]xxx//xx23xx/          /xxx[/INSERTED$$$$]xxx/
    +	 *    JCB Add Replaced Code    = /xxx[REPLACED$$$$]xxx//xx25xx/          /xxx[/REPLACED$$$$]xxx/
    +	 *
    +	 *    /////////////////////////////// changeing existing custom code /////////////////////////
    +	 *    Update Inserted Code    = /xxx[INSERTED<>$$$$]xxx//xx23xx/        /xxx[/INSERTED<>$$$$]xxx/
    +	 *    Update Replaced Code    = /xxx[REPLACED<>$$$$]xxx//xx25xx/        /xxx[/REPLACED<>$$$$]xxx/
    +	 *
    +	 *    The custom script placeholders - we use the (==) to avoid detection it should be (--)
    +	 *    ###################################--->  HTML  <---#####################################
    +	 *
    +	 *    New Insert Code        = $$$$]==>                 $$$$]==>
    +	 *    New Replace Code    = $$$$]==>                $$$$]==>
    +	 *
    +	 *    ///////////////////////////////// when JCB adds it back ///////////////////////////////
    +	 *    JCB Add Inserted Code    =         
    +	 *    JCB Add Replaced Code    =         
    +	 *
    +	 *    //////////////////////////// changeing existing custom code ///////////////////////////
    +	 *    Update Inserted Code    = $$$$]==>      $$$$]==>
    +	 *    Update Replaced Code    = $$$$]==>      $$$$]==>
    +	 *
    +	 *    ////////23 is the ID of the code in the system don't change it!!!!!!!!!!!!!!!!!!!!!!!!!!
    +	 *
    +	 * @var      array
    +	 * @deprecated 3.3
    +	 */
    +	protected $customCodePlaceholders
    +		= array(
    +			1 => 'REPLACE<>$$$$]',
    +			2 => 'INSERT<>$$$$]',
    +			3 => 'REPLACED<>$$$$]',
    +			4 => 'INSERTED<>$$$$]'
    +		);
    +
    +	/**
    +	 * The custom code to be added
    +	 *
    +	 * @var      array
    +	 * @deprecated 3.3 Use CFactory::_('Customcode')->active
    +	 */
    +	public $customCode;
    +
    +	/**
    +	 * The custom code to be added
    +	 *
    +	 * @var      array
    +	 * @deprecated 3.3
    +	 */
    +	protected $customCodeData = [];
    +
    +	/**
    +	 * The function name memory ids
    +	 *
    +	 * @var      array
    +	 * @deprecated 3.3 Use CFactory::_('Customcode')->functionNameMemory
    +	 */
    +	public $functionNameMemory = [];
    +
    +	/**
    +	 * The custom code for local memory
    +	 *
    +	 * @var      array
    +	 * @deprecated 3.3 Use CFactory::_('Customcode')->memory
    +	 */
    +	public $customCodeMemory = [];
    +
    +	/**
    +	 * The custom code in local files that already exist in system
    +	 *
    +	 * @var      array
    +	 * @deprecated 3.3
    +	 */
    +	protected $existingCustomCode = [];
    +
    +	/**
    +	 * The custom code in local files this are new
    +	 *
    +	 * @var      array
    +	 * @deprecated 3.3
    +	 */
    +	protected $newCustomCode = [];
    +
    +	/**
    +	 * The index of code already loaded
    +	 *
    +	 * @var      array
    +	 * @deprecated 3.3
    +	 */
    +	protected $codeAreadyDone = [];
    +
    +	/**
    +	 * The external code/string to be added
    +	 *
    +	 * @var      array
    +	 * @deprecated 3.3
    +	 */
    +	protected $externalCodeString = [];
    +
    +	/**
    +	 * The external code/string cutter
    +	 *
    +	 * @var      array
    +	 * @deprecated 3.3
    +	 */
    +	protected $externalCodeCutter = [];
    +
    +	/*
    +	 * The line numbers Switch
    +	 *
    +	 * @var      boolean
    +	 * @deprecated 3.3 Use CFactory::_('Config')->debug_line_nr;
    +	 */
    +	public $debugLinenr = false;
    +
    +	/*
    +	 * The percentage when a language should be added
    +	 *
    +	 * @var      int
    +	 * @deprecated 3.3 Use CFactory::_('Config')->percentage_language_add
    +	 */
    +	public $percentageLanguageAdd = 0;
    +
    +	/**
    +	 * The Placholder Language prefix
    +	 *
    +	 * @var      string
    +	 * @deprecated 3.3 Use CFactory::_('Config')->lang_prefix;
    +	 */
    +	public $langPrefix;
    +
    +	/**
    +	 * The Language content
    +	 *
    +	 * @var      array
    +	 * @deprecated 3.3
    +	 */
    +	public $langContent = [];
    +
    +	/**
    +	 * The Languages bucket
    +	 *
    +	 * @var      array
    +	 */
    +	public $languages
    +		= array('components' => array(), 'modules' => array(),
    +		        'plugins'    => array());
    +
    +	/**
    +	 * The Main Languages
    +	 *
    +	 * @var      string
    +	 * @deprecated 3.3 Use CFactory::_('Config')->lang_tag;
    +	 */
    +	public $langTag = 'en-GB';
    +
    +	/**
    +	 * The Multi Languages bucket
    +	 *
    +	 * @var      array
    +	 */
    +	public $multiLangString = [];
    +
    +	/**
    +	 * The new lang to add
    +	 *
    +	 * @var      array
    +	 */
    +	protected $newLangStrings = [];
    +
    +	/**
    +	 * The existing lang to update
    +	 *
    +	 * @var      array
    +	 */
    +	protected $existingLangStrings = [];
    +
    +	/**
    +	 * The Language JS matching check
    +	 *
    +	 * @var      array
    +	 * @deprecated 3.3 Use CFactory::_('Language.Extractor')->langMismatch;
    +	 */
    +	public $langMismatch = [];
    +
    +	/**
    +	 * The Language SC matching check
    +	 *
    +	 * @var      array
    +	 * @deprecated 3.3 Use CFactory::_('Language.Extractor')->langMatch;
    +	 */
    +	public $langMatch = [];
    +
    +	/**
    +	 * The Language string targets
    +	 *
    +	 * @var      array
    +	 * @deprecated 3.3 Use CFactory::_('Config')->lang_string_targets;
    +	 */
    +	public $langStringTargets
    +		= array(
    +			'Joomla' . '.JText._(',
    +			'JText:' . ':script(',
    +			'Text:' . ':_(',        // namespace and J version will be found
    +			'Text:' . ':sprintf(',  // namespace and J version will be found
    +			'JustTEXT:' . ':_('
    +		);
    +
    +	/**
    +	 * The Component Code Name
    +	 *
    +	 * @var      string
    +	 * @deprecated 3.3 Use CFactory::_('Config')->component_code_name;
    +	 */
    +	public $componentCodeName;
    +
    +	/**
    +	 * The Component Context
    +	 *
    +	 * @var      string
    +	 * @deprecated 3.3 Use CFactory::_('Config')->component_context;
    +	 */
    +	public $componentContext;
    +
    +	/**
    +	 * The Component Code Name Length
    +	 *
    +	 * @var      int
    +	 * @deprecated 3.3 Use CFactory::_('Config')->component_code_name_length;
    +	 */
    +	public $componentCodeNameLength;
    +
    +	/**
    +	 * The Component ID
    +	 *
    +	 * @var      int
    +	 * @deprecated 3.3 Use CFactory::_('Config')->component_id;
    +	 */
    +	public $componentID;
    +
    +	/**
    +	 * The current user
    +	 *
    +	 * @var      array
    +	 */
    +	public $user;
    +
    +	/**
    +	 * The database object
    +	 *
    +	 * @var      array
    +	 */
    +	public $db;
    +
    +	/**
    +	 * The Component version
    +	 *
    +	 * @var      string
    +	 * @deprecated 3.3 Use CFactory::_('Config')->component_version;
    +	 */
    +	public $component_version;
    +
    +	/**
    +	 * The UIKIT Switch
    +	 *
    +	 * @var    boolean
    +	 * @deprecated 3.3 Use CFactory::_('Config')->uikit;
    +	 */
    +	public $uikit = 0;
    +
    +	/**
    +	 * The UIKIT component checker
    +	 *
    +	 * @var     array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Uikit.Comp')->get($key);
    +	 */
    +	public $uikitComp = [];
    +
    +	/**
    +	 * The FOOTABLE Switch
    +	 *
    +	 * @var      boolean
    +	 * @deprecated 3.3 Use CFactory::_('Config')->footable;
    +	 */
    +	public $footable = false;
    +
    +	/**
    +	 * The FOOTABLE Version
    +	 *
    +	 * @var      int
    +	 * @deprecated 3.3 Use CFactory::_('Config')->footable_version;
    +	 */
    +	public $footableVersion;
    +
    +	/**
    +	 * The Google Chart Switch per view
    +	 *
    +	 * @var     array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Google.Chart')->get($key);
    +	 */
    +	public $googleChart = [];
    +
    +	/**
    +	 * The Google Chart Switch
    +	 *
    +	 * @var     boolean
    +	 * @deprecated 3.3 Use CFactory::_('Config')->google_chart;
    +	 */
    +	public $googlechart = false;
    +
    +	/**
    +	 * The Import & Export Switch
    +	 *
    +	 * @var      boolean
    +	 * @deprecated 3.3 Use CFactory::_('Config')->add_eximport;
    +	 */
    +	public $addEximport = false;
    +
    +	/**
    +	 * The Import & Export View
    +	 *
    +	 * @var      array
    +	 */
    +	public $eximportView = [];
    +
    +	/**
    +	 * The Import & Export Custom Script
    +	 *
    +	 * @var      array
    +	 */
    +	public $importCustomScripts = [];
    +
    +	/**
    +	 * The Tag & History Switch
    +	 *
    +	 * @var      boolean
    +	 * @deprecated 3.3 Use CFactory::_('Config')->set_tag_history;
    +	 */
    +	public $setTagHistory = false;
    +
    +	/**
    +	 * The Joomla Fields Switch
    +	 *
    +	 * @var      boolean
    +	 * @deprecated 3.3 Use CFactory::_('Config')->set_joomla_fields;
    +	 */
    +	public $setJoomlaFields = false;
    +
    +	/**
    +	 * The site edit views
    +	 *
    +	 * @var     array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Site.Edit.View')->get($key);
    +	 */
    +	public $siteEditView = [];
    +
    +	/**
    +	 * The admin list view filter type
    +	 *
    +	 * @var     array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($key);
    +	 */
    +	public $adminFilterType = [];
    +
    +	/**
    +	 * The Language target
    +	 *
    +	 * @var     string
    +	 * @deprecated 3.3 Use CFactory::_('Config')->lang_target;
    +	 */
    +	public $lang = 'admin';
    +
    +	/**
    +	 * The lang keys for extentions
    +	 *
    +	 * @var     array
    +	 * @deprecated 3.3 Use CFactory::_('Language.Extractor')->langKeys;
    +	 */
    +	public $langKeys = [];
    +
    +	/**
    +	 * The Build target Switch
    +	 *
    +	 * @var     string
    +	 * @deprecated 3.3 Use CFactory::_('Config')->build_target;
    +	 */
    +	public $target;
    +
    +	/**
    +	 * The unique codes
    +	 *
    +	 * @var     array
    +	 * @deprecated 3.3
    +	 */
    +	public $uniquecodes = [];
    +
    +	/**
    +	 * The unique keys
    +	 *
    +	 * @var     array
    +	 * @deprecated 3.3
    +	 */
    +	public $uniquekeys = [];
    +
    +	/**
    +	 * The Add contributors Switch
    +	 *
    +	 * @var     boolean
    +	 * @deprecated 3.3 Use CFactory::_('Config')->add_contributors;
    +	 */
    +	public $addContributors = false;
    +
    +	/**
    +	 * The Custom Script Builder
    +	 *
    +	 * @var     array
    +	 * @deprecated 3.3 Use CFactory::_('Customcode.Dispenser')->hub;
    +	 */
    +	public $customScriptBuilder = [];
    +
    +	/**
    +	 * The Footable Script Builder
    +	 *
    +	 * @var     array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Footable.Scripts')->get($key);
    +	 */
    +	public $footableScripts = [];
    +
    +	/**
    +	 * The pathe to the bom file to be used
    +	 *
    +	 * @var     string
    +	 * @deprecated 3.3 Use CFactory::_('Config')->bom_path;
    +	 */
    +	public $bomPath;
    +
    +	/**
    +	 * The SQL Tweak of admin views
    +	 *
    +	 * @var     array
    +	 * @deprecated 3.3 Use CFactory::_('Registry')->get('builder.sql_tweak');
    +	 */
    +	public $sqlTweak = [];
    +
    +	/**
    +	 * The validation rules that should be added
    +	 *
    +	 * @var     array
    +	 * @deprecated 3.3 Use CFactory::_('Registry')->get('validation.rules');
    +	 */
    +	public $validationRules = [];
    +
    +	/**
    +	 * The validation linked to fields
    +	 *
    +	 * @var     array
    +	 * @deprecated 3.3 Use CFactory::_('Registry')->get('validation.linked');
    +	 */
    +	public $validationLinkedFields = [];
    +
    +	/**
    +	 * The admin views data array
    +	 *
    +	 * @var     array
    +	 * @deprecated 3.3
    +	 */
    +	private $_adminViewData = [];
    +
    +	/**
    +	 * The field data array
    +	 *
    +	 * @var     array
    +	 * @deprecated 3.3
    +	 */
    +	private $_fieldData = [];
    +
    +	/**
    +	 * The custom alias builder
    +	 *
    +	 * @var     array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Custom.Alias')->get($key);
    +	 */
    +	public $customAliasBuilder = [];
    +
    +	/**
    +	 * The field builder type
    +	 *
    +	 * 1 = StringManipulation
    +	 * 2 = SimpleXMLElement
    +	 *
    +	 * @var     int
    +	 * @deprecated 3.3 Use CFactory::_('Config')->field_builder_type;
    +	 */
    +	public $fieldBuilderType;
    +
    +	/**
    +	 * Set unique Names
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Registry')->get('unique.names');
    +	 */
    +	public $uniqueNames = [];
    +
    +	/**
    +	 * Set unique Names
    +	 *
    +	 * @var    array
    +	 * @deprecated
    +	 */
    +	protected $uniqueFieldNames = [];
    +
    +	/**
    +	 * Category other name bucket
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Category.Other.Name')->get($key);
    +	 */
    +	public $catOtherName = [];
    +
    +	/**
    +	 * The field relations values
    +	 *
    +	 * @var     array
    +	 * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Field.Relations')->get($key);
    +	 */
    +	public $fieldRelations = [];
    +
    +	/**
    +	 * The views default ordering
    +	 *
    +	 * @var     array
    +	 * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Views.Default.Ordering')->get($key);
    +	 */
    +	public $viewsDefaultOrdering = [];
    +
    +	/**
    +	 * Default Fields
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Config')->default_fields;
    +	 */
    +	public $defaultFields
    +		= array('created', 'created_by', 'modified', 'modified_by', 'published',
    +			'ordering', 'access', 'version', 'hits', 'id');
    +
    +	/**
    +	 * The list join fields
    +	 *
    +	 * @var     array
    +	 * @deprecate 3.3 Use CFactory::_('Compiler.Builder.List.Join')->get($key);
    +	 */
    +	public $listJoinBuilder = [];
    +
    +	/**
    +	 * The list head over ride
    +	 *
    +	 * @var     array
    +	 * @deprecate 3.3 Use CFactory::_('Compiler.Builder.List.Head.Override')->get($key);
    +	 */
    +	public $listHeadOverRide = [];
    +
    +	/**
    +	 * The linked admin view tabs
    +	 *
    +	 * @var     array
    +	 * @deprecate 3.3 Use CFactory::_('Registry')->get('builder.linked_admin_views');
    +	 */
    +	public $linkedAdminViews = [];
    +
    +	/**
    +	 * The custom admin view tabs
    +	 *
    +	 * @var     array
    +	 * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Custom.Tabs')->get($key);
    +	 */
    +	public $customTabs = [];
    +
    +	/**
    +	 * The Add Ajax Switch
    +	 *
    +	 * @var    boolean
    +	 * @deprecate 3.3 Use CFactory::_('Config')->add_ajax
    +	 */
    +	public $addAjax = false;
    +
    +	/**
    +	 * The Add Site Ajax Switch
    +	 *
    +	 * @var     boolean
    +	 * @deprecate 3.3 Use CFactory::_('Config')->add_site_ajax;
    +	 */
    +	public $addSiteAjax = false;
    +
    +	/**
    +	 * The get Module Script Switch
    +	 *
    +	 * @var    array
    +	 * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Get.Module')->get($key);
    +	 */
    +	public $getModule = [];
    +
    +	/**
    +	 * The template data
    +	 *
    +	 * @var    array
    +	 * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Template.Data')->get($key);
    +	 */
    +	public $templateData = [];
    +
    +	/**
    +	 * The layout data
    +	 *
    +	 * @var    array
    +	 * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Layout.Data')->get($key);
    +	 */
    +	public $layoutData = [];
    +
    +	/**
    +	 * The Encryption Types
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Config')->cryption_types;
    +	 */
    +	public $cryptionTypes = array('basic', 'medium', 'whmcs', 'expert');
    +
    +	/**
    +	 * The WHMCS Encryption Switch
    +	 *
    +	 * @var    boolean
    +	 * @deprecated 3.3 Use CFactory::_('Config')->whmcs_encryption;
    +	 */
    +	public $whmcsEncryption = false;
    +
    +	/**
    +	 * The Basic Encryption Switch
    +	 *
    +	 * @var    boolean
    +	 * @deprecated 3.3 Use CFactory::_('Config')->basic_encryption;
    +	 */
    +	public $basicEncryption = false;
    +
    +	/**
    +	 * The Medium Encryption Switch
    +	 *
    +	 * @var    boolean
    +	 * @deprecated 3.3 Use CFactory::_('Config')->medium_encryption;
    +	 */
    +	public $mediumEncryption = false;
    +
    +	/**
    +	 * The Custom field Switch per view
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3
    +	 */
    +	public $customFieldScript = [];
    +
    +	/**
    +	 * The site main get
    +	 *
    +	 * @var    array
    +	 * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Site.Main.Get')->get($key);
    +	 */
    +	public $siteMainGet = [];
    +
    +	/**
    +	 * The site dynamic get
    +	 *
    +	 * @var    array
    +	 * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Site.Dynamic.Get')->get($key);
    +	 */
    +	public $siteDynamicGet = [];
    +
    +	/**
    +	 * The get AS lookup
    +	 *
    +	 * @var    array
    +	 * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Get.As.Lookup')->get($key);
    +	 */
    +	public $getAsLookup = [];
    +
    +	/**
    +	 * The site fields
    +	 *
    +	 * @var    array
    +	 * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Site.Fields')->get($key);
    +	 */
    +	public $siteFields = [];
    +
    +	/**
    +	 * The add SQL
    +	 *
    +	 * @var    array
    +	 * @deprecate 3.3 Use CFactory::_('Registry')->get('builder.add_sql');
    +	 */
    +	public $addSQL = [];
    +
    +	/**
    +	 * The update SQL
    +	 *
    +	 * @var    array
    +	 * @deprecate 3.3 Use CFactory::_('Registry')->get('builder.update_sql');
    +	 */
    +	public $updateSQL = [];
    +
    +	/**
    +	 * The data by alias keys
    +	 *
    +	 * @var    array
    +	 * @deprecate 3.3 Use CFactory::_('Registry')->get('builder.data_with_alias_keys');
    +	 */
    +	protected $dataWithAliasKeys = [];
    +
    +	/**
    +	 * The Library Manager
    +	 *
    +	 * @var    array
    +	 * @deprecate 3.3 Use CFactory::_('Compiler.Builder.Library.Manager')->get($key);
    +	 */
    +	public $libManager = [];
    +
    +	/**
    +	 * The Libraries
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Registry')->get('builder.libraries');
    +	 */
    +	public $libraries = [];
    +
    +	/**
    +	 * Is minify Enabled
    +	 *
    +	 * @var    int
    +	 * @deprecated 3.3 Use CFactory::_('Config')->minify;
    +	 */
    +	public $minify = 0;
    +
    +	/**
    +	 * Is Tidy Enabled
    +	 *
    +	 * @var    bool
    +	 * @deprecated 3.3 Use CFactory::_('Config')->tidy;
    +	 */
    +	public $tidy = false;
    +
    +	/**
    +	 * Set Tidy warning once switch
    +	 *
    +	 * @var    bool
    +	 * @deprecated 3.3 Use CFactory::_('Config')->set_tidy_warning;
    +	 */
    +	public $setTidyWarning = false;
    +
    +	/**
    +	 * mysql table setting keys
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Config')->mysql_table_keys;
    +	 */
    +	public $mysqlTableKeys
    +		= array(
    +			'engine'     => array('default' => 'MyISAM'),
    +			'charset'    => array('default' => 'utf8'),
    +			'collate'    => array('default' => 'utf8_general_ci'),
    +			'row_format' => array('default' => '')
    +		);
    +
    +	/**
    +	 * mysql table settings
    +	 *
    +	 * @var    array
    +	 * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Mysql.Table.Setting')->get($key);
    +	 */
    +	public $mysqlTableSetting = [];
    +
    +	/**
    +	 * Constructor
    +	 */
    +	public function __construct()
    +	{
    +		// we do not yet have this set as an option
    +		$config['remove_line_breaks']
    +			= 2; // 2 is global (use the components value)
    +		// load application
    +		$this->app = Factory::getApplication();
    +		// Set the params
    +		$this->params = ComponentHelper::getParams('com_componentbuilder');
    +		// Trigger Event: jcb_ce_onBeforeGet
    +		CFactory::_('Event')->trigger('jcb_ce_onBeforeGet', array(&$config, &$this));
    +		// set the Joomla version @deprecated
    +		$this->joomlaVersion = CFactory::_('Config')->joomla_version;
    +		// set the minfy switch of the JavaScript @deprecated
    +		$this->minify = CFactory::_('Config')->get('minify', 0);
    +		// set the global language @deprecated
    +		$this->langTag = CFactory::_('Config')->get('lang_tag', 'en-GB');
    +		// also set the helper class langTag (for safeStrings)
    +		ComponentbuilderHelper::$langTag = CFactory::_('Config')->get('lang_tag', 'en-GB');
    +		// setup the main language array
    +		$this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')] = [];
    +		// check if we have Tidy enabled @deprecated
    +		$this->tidy = CFactory::_('Config')->get('tidy', false);
    +		// set the field type builder @deprecated
    +		$this->fieldBuilderType = CFactory::_('Config')->get('field_builder_type', 2);
    +		// check the field builder type logic
    +		if (!CFactory::_('Config')->get('tidy', false) && CFactory::_('Config')->get('field_builder_type', 2) == 2)
    +		{
    +			// we do not have the tidy extension set fall back to StringManipulation
    +			$this->fieldBuilderType = 1;
    +			// load the sugestion to use string manipulation
    +			$this->app->enqueueMessage(
    +				Text::_('COM_COMPONENTBUILDER_HR_HTHREEFIELD_NOTICEHTHREE'), 'Notice'
    +			);
    +			$this->app->enqueueMessage(
    +				Text::_(
    +					'Since you do not have Tidy extentsion setup on your system, we could not use the SimpleXMLElement class. We instead used string manipulation to build all your fields, this is a faster method, you must inspect the xml files in your component package to see if you are satisfied with the result.
    You can make this method your default by opening the global options of JCB and under the Global tab set the Field Builder Type to string manipulation.' + ), 'Notice' + ); + } + CFactory::_('Config')->set('field_builder_type', $this->fieldBuilderType); + // load the compiler path @deprecated + $this->compilerPath = CFactory::_('Config')->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler'); + // load the jcb powers path @deprecated + $this->jcbPowersPath = CFactory::_('Config')->get('jcb_powers_path', 'libraries/jcb_powers'); + // set the component ID @deprecated + $this->componentID = CFactory::_('Config')->component_id; + // set lang prefix @deprecated + $this->langPrefix = CFactory::_('Config')->lang_prefix; + // set component code name @deprecated + $this->componentCodeName = CFactory::_('Config')->component_code_name; + // set component context @deprecated + $this->componentContext = CFactory::_('Config')->component_context; + // set the component name length @deprecated + $this->componentCodeNameLength = CFactory::_('Config')->component_code_name_length; + // set if language strings line breaks should be removed @deprecated + $this->removeLineBreaks = CFactory::_('Config')->remove_line_breaks; + // set if placeholders should be added to customcode @deprecated + $this->addPlaceholders = CFactory::_('Config')->get('add_placeholders', false); + // set if line numbers should be added to comments @deprecated + $this->debugLinenr = CFactory::_('Config')->get('debug_line_nr', false); + // set if powers should be added to component (default is true) @deprecated + $this->addPower = CFactory::_('Config')->get('add_power', true); + // set the current user + $this->user = Factory::getUser(); + // Get a db connection. + $this->db = Factory::getDbo(); + // get global placeholders @deprecated + $this->globalPlaceholders = CFactory::_('Component.Placeholder')->get(); + + // get the custom code from installed files + CFactory::_('Customcode.Extractor')->run(); + + // Trigger Event: jcb_ce_onBeforeGetComponentData + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeGetComponentData' + ); + + // get the component data @deprecated + $this->componentData = CFactory::_('Component'); + + // Trigger Event: jcb_ce_onAfterGetComponentData + CFactory::_('Event')->trigger( + 'jcb_ce_onAfterGetComponentData' + ); + + // make sure we have a version + if (strpos((string) CFactory::_('Component')->component_version, '.') + === false) + { + CFactory::_('Component')->set('component_version ', '1.0.0'); + } + // update the version + if (!CFactory::_('Component')->exists('old_component_version') + && (CFactory::_('Registry')->get('builder.add_sql', null) + || CFactory::_('Registry')->get('builder.update_sql', null))) + { + // set the new version + $version = (array) explode( + '.', (string) CFactory::_('Component')->component_version + ); + // get last key + end($version); + $key = key($version); + // just increment the last + $version[$key]++; + // set the old version + CFactory::_('Component')->set('old_component_version', CFactory::_('Component')->component_version); + // set the new version, and set update switch + CFactory::_('Component')->set('component_version', implode( + '.', $version + )); + } + + // FOR THE HELPER CLASS POWERS + // Utilities String Helper + CFactory::_('Power')->get('1f28cb53-60d9-4db1-b517-3c7dc6b429ef', 1); + // Utilities Array Helper + CFactory::_('Power')->get('0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a', 1); + // Utilities Component Helper + CFactory::_('Power')->get('640b5352-fb09-425f-a26e-cd44eda03f15', 1); + // Utilities Object Helper + CFactory::_('Power')->get('91004529-94a9-4590-b842-e7c6b624ecf5', 1); + // Utilities GetHelper + CFactory::_('Power')->get('db87c339-5bb6-4291-a7ef-2c48ea1b06bc', 1); + // Utilities Json Helper + CFactory::_('Power')->get('4b225c51-d293-48e4-b3f6-5136cf5c3f18', 1); + // Utilities FormHelper + CFactory::_('Power')->get('1198aecf-84c6-45d2-aea8-d531aa4afdfa', 1); + + // load powers *+*+*+*+*+*+*+* + CFactory::_('Power')->load($this->linkedPowers); + // set the percentage when a language can be added + $this->percentageLanguageAdd = (int) CFactory::_('Config')->get('percentage_language_add', 50); + + // Trigger Event: jcb_ce_onBeforeGet + CFactory::_('Event')->trigger( + 'jcb_ce_onAfterGet' + ); + + return true; + } + + /** + * Set the tab/space + * + * @param int $nr The number of tag/space + * + * @return string + * @deprecated 3.3 Use Indent::_($nr); + */ + public function _t($nr) + { + // use global method for conformity + return Indent::_($nr); + } + + /** + * Trigger events + * + * @param string $event The event to trigger + * @param mix $data The values to pass to the event/plugin + * + * @return void + * @deprecated 3.3 Use CFactory::_('Event')->trigger($event, $data); + */ + public function triggerEvent($event, $data = null) + { + return CFactory::_('Event')->trigger($event, $data); + } + + /** + * get all System Placeholders + * + * @return array The global placeholders + * @deprecated 3.3 Use CFactory::_('Component.Placeholder')->get(); + */ + public function getGlobalPlaceholders() + { + return CFactory::_('Component.Placeholder')->get(); + } + + /** + * get all Component Data + * + * @return oject The component data + * @deprecated 3.3 Use CFactory::_('Component'); + */ + public function getComponentData() + { + return CFactory::_('Component'); + } + + /** + * set the language content values to language content array + * + * @param string $target The target area for the language string + * @param string $language The language key string + * @param string $string The language string + * @param boolean $addPrefix The switch to add langPrefix + * + * @return void + * @deprecated 3.3 Use CFactory::_('Language')->set($target, $language, $string, $addPrefix); + */ + public function setLangContent($target, $language, $string, $addPrefix = false) + { + CFactory::_('Language')->set($target, $language, $string, $addPrefix); + } + + /** + * We need to remove all text breaks from all language strings + * + * @param string $string The language string + * + * @return string + * @deprecated 3.3 + */ + public function fixLangString(&$string) + { + if (CFactory::_('Config')->remove_line_breaks) + { + return trim(str_replace(array(PHP_EOL, "\r", "\n"), '', $string)); + } + + return trim($string); + } + + /** + * Get all Admin View Data + * + * @param int $id The view ID + * + * @return oject The view data + * @deprecated 3.3 Use CFactory::_('Adminview.Data')->get($id); + */ + public function getAdminViewData($id) + { + return CFactory::_('Adminview.Data')->get($id); + } + + /** + * Get all Custom View Data + * + * @param int $id The view ID + * @param string $table The view table + * + * @return oject The view data + * @deprecated 3.3 Use CFactory::_('Customview.Data')->get($id, $table); + */ + public function getCustomViewData($id, $table = 'site_view') + { + return CFactory::_('Customview.Data')->get($id, $table); + } + + /** + * Get all Field Data + * + * @param int $id The field ID + * @param string $name_single The view edit or single name + * @param string $name_list The view list name + * + * @return oject The field data + * @deprecated 3.3 Use CFactory::_('Field.Data')->get($id, $name_single, $name_list); + */ + public function getFieldData($id, $name_single = null, $name_list = null) + { + return CFactory::_('Field.Data')->get($id, $name_single, $name_list); + } + + /** + * set Field details + * + * @param object $field The field object + * @param string $singleViewName The single view name + * @param string $listViewName The list view name + * @param string $amicably The peaceful resolve + * + * @return void + * @deprecated 3.3 Use CFactory::_('Field')->set($field, $singleViewName, $listViewName, $amicably); + */ + public function setFieldDetails(&$field, $singleViewName = null, $listViewName = null, $amicably = '') + { + CFactory::_('Field')->set($field, $singleViewName, $listViewName, $amicably); + } + + /** + * get the list default ordering values + * + * @param string $nameListCode The list view name + * + * @return array + * + */ + public function getListViewDefaultOrdering(&$nameListCode) + { + if (CFactory::_('Compiler.Builder.Views.Default.Ordering')-> + get("$nameListCode.add_admin_ordering", 0) == 1) + { + foreach (CFactory::_('Compiler.Builder.Views.Default.Ordering')-> + get("$nameListCode.admin_ordering_fields", []) as $order_field) + { + if (($order_field_name = CFactory::_('Field.Database.Name')->get( + $nameListCode, $order_field['field'] + )) !== false) + { + // just the first field is the based ordering state + return array( + 'name' => $order_field_name, + 'direction' => $order_field['direction'] + ); + } + } + } + + // the default + return array( + 'name' => 'a.id', + 'direction' => 'DESC' + ); + } + + /** + * get the field database name and AS prefix + * + * @param string $nameListCode The list view name + * @param int $fieldId The field ID + * @param string $targetArea The area being targeted + * + * @return string + * @deprecated 3.3 Use CFactory::_('Field.Database.Name')->get($nameListCode, $fieldId, $targetArea); + */ + public function getFieldDatabaseName($nameListCode, int $fieldId, $targetArea = 'builder.list') + { + return CFactory::_('Field.Database.Name')->get($nameListCode, $fieldId, $targetArea); + } + + /** + * Get the field's actual type + * + * @param object $field The field object + * + * @return string Success returns field type + * @deprecated 3.3 Use CFactory::_('Field.Type.Name')->get($field); + */ + public function getFieldType(&$field) + { + return CFactory::_('Field.Type.Name')->get($field); + } + + /** + * Get the field's actual name + * + * @param object $field The field object + * @param string $listViewName The list view name + * @param string $amicably The peaceful resolve (for fields in subforms in same view :) + * + * @return string Success returns field name + * @deprecated 3.3 Use CFactory::_('Field.Name')->get($field, $listViewName, $amicably); + */ + public function getFieldName(&$field, $listViewName = null, $amicably = '') + { + return CFactory::_('Field.Name')->get($field, $listViewName, $amicably); + } + + /** + * Count how many times the same field is used per view + * + * @param string $name The name of the field + * @param string $view The name of the view + * + * @return void + * @deprecated Use CFactory::_('Field.Unique.Name')->set($name, $view); + */ + protected function setUniqueNameCounter($name, $view) + { + CFactory::_('Field.Unique.Name')->set($name, $view); + } + + /** + * Naming each field with an unique name + * + * @param string $name The name of the field + * @param string $view The name of the view + * + * @return string the name + * @deprecated + */ + protected function uniqueName($name, $view) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * Set get Data + * + * @param array $ids The ids of the dynamic get + * @param string $view_code The view code name + * @param string $context The context for events + * + * @return oject the get dynamicGet data + * @deprecated Use CFactory::_('Dynamicget.Data')->get($ids, $view_code, $context); + */ + public function setGetData($ids, $view_code, $context) + { + return CFactory::_('Dynamicget.Data')->get($ids, $view_code, $context); + } + + /** + * Set the script for the customcode dispenser + * + * @param string $script The script + * @param string $first The first key + * @param string|null $second The second key (if not set we use only first key) + * @param string|null $third The third key (if not set we use only first and second key) + * @param array $config The config options + * @param bool $base64 The switch to decode base64 the script + * default: true + * @param bool $dynamic The switch to dynamic update the script + * default: true + * @param bool $add The switch to add to exiting instead of replace + * default: false + * + * @return bool true on success + * @deprecated 3.3 Use CFactory::_('Customcode.Dispenser')->set($script, $first, $second, $third, $config, $base64, $dynamic, $add); + */ + public function setCustomScriptBuilder( + &$script, + string $first, + ?string $second = null, + ?string $third = null, + array $config = array(), + bool $base64 = true, + bool $dynamic = true, + bool $add = false + ): bool + { + return CFactory::_('Customcode.Dispenser')->set($script, $first, $second, $third, $config, $base64, $dynamic, $add); + } + + /** + * get the a script from the custom script builder + * + * @param string $first The first key + * @param string $second The second key + * @param string $prefix The prefix to add in front of the script if found + * @param string $note The switch/note to add to the script + * @param bool $unset The switch to unset the value if found + * @param string $default The switch/string to use as default return if script not found + * @param string $sufix The sufix to add after the script if found + * + * @return mix The string/script if found or the default value if not found + * @deprecated 3.3 Use CFactory::_('Customcode.Dispenser')->get($first, $second, $prefix, $note, $unset, $default, $sufix); + */ + public function getCustomScriptBuilder($first, $second, $prefix = '', + $note = null, $unset = null, $default = null, $sufix = '' + ) + { + return CFactory::_('Customcode.Dispenser')->get($first, $second, $prefix, $note, $unset, $default, $sufix); + } + + /** + * To limit the SQL Demo date build in the views + * + * @param array $settings Tweaking array. + * + * @return void + * @deprecated 3.3 + */ + public function setSqlTweaking($settings) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * check if an update SQL is needed + * + * @param mix $old The old values + * @param mix $new The new values + * @param string $type The type of values + * @param int $key The id/key where values changed + * @param array $ignore The ids to ignore + * + * @return void + * @deprecated 3.3 Use CFactory::_('Model.Updatesql')->set($old, $new, $type, $key, $ignore); + */ + protected function setUpdateSQL($old, $new, $type, $key = null, + $ignore = null + ) + { + CFactory::_('Model.Updatesql')->set($old, $new, $type, $key, $ignore); + } + + /** + * Set the add sql + * + * @param string $type The type of values + * @param int $item The item id to add + * @param int|null $key The id/key where values changed + * + * @return void + * @deprecated 3.3 + */ + protected function setAddSQL(string $type, int $item, ?int $key = null) + { + // add key if found + if ($key) + { + CFactory::_('Registry')->set('builder.add_sql.' . $type . '.' . $key . '.' . $item, $item); + } + else + { + // convert adminview id to name + if ('adminview' === $type) + { + CFactory::_('Registry')->set('builder.add_sql.' . $type, StringHelper::safe( + $this->getAdminViewData($item)->name_single + )); + } + else + { + CFactory::_('Registry')->set('builder.add_sql.' . $type, $item); + } + } + } + + /** + * Get Item History values + * + * @param string $type The type of item + * @param int $id The item ID + * + * @return object The history + * @deprecated 3.3 Use CFactory::_('History')->get($type, $id); + */ + protected function getHistoryWatch($type, $id) + { + return CFactory::_('History')->get($type, $id); + } + + /** + * Set Item History Watch + * + * @param Object $object The history object + * @param int $action The action to take + * 0 = remove watch + * 1 = add watch + * @param string $type The type of item + * + * @return bool + * @deprecated 3.3 + */ + protected function setHistoryWatch($object, $action) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * Set Template and Layout Data + * + * @param string $default The content to check + * @param string $view The view code name + * @param boolean $found The proof that something was found + * @param array $templates The option to pass templates keys (to avoid search) + * @param array $layouts The option to pass layout keys (to avoid search) + * + * @return boolean if something was found true + * @deprecated 3.3 Use CFactory::_('Templatelayout.Data')->set($default, $view, $found, $templates, $layouts); + */ + public function setTemplateAndLayoutData($default, $view, $found = false, + $templates = array(), $layouts = array() + ) + { + return CFactory::_('Templatelayout.Data')->set($default, $view, $found, $templates, $layouts); + } + + /** + * Get Data With Alias + * + * @param string $n_ame The alias name + * @param string $table The table where to find the alias + * @param string $view The view code name + * + * @return array The data found with the alias + * @deprecated 3.3 Use CFactory::_('Alias.Data')->get($n_ame, $table, $view); + */ + protected function getDataWithAlias($n_ame, $table, $view) + { + return CFactory::_('Alias.Data')->get($n_ame, $table, $view); + } + + /** + * set Data With Alias Keys + * + * @param string $table The table where to find the alias + * + * @return void + * @deprecated 3.3 + */ + protected function setDataWithAliasKeys($table) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * Get Media Library Data and store globally + * + * @param string $id the library id + * + * @return bool true on success + * @deprecated 3.3 Use CFactory::_('Library.Data')->get($id); + */ + protected function getMediaLibrary($id) + { + return CFactory::_('Library.Data')->get($id); + } + + /** + * Set Language Place Holders + * + * @param string $content The content + * + * @return string The content with the updated Language place holder + * @deprecated 3.3 Use CFactory::_('Language.Extractor')->engine($content) + */ + public function setLangStrings($content) + { + return CFactory::_('Language.Extractor')->engine($content); + } + + /** + * Set the language String + * + * @param string $string The plan text string (English) + * + * @return string The key language string (all uppercase) + * @deprecated 3.3 Use CFactory::_('Language')->key($string); + */ + public function setLang($string) + { + return CFactory::_('Language')->key($string); + } + + /** + * Set Data Selection of the dynamic get + * + * @param string $method_key The method unique key + * @param string $view_code The code name of the view + * @param string $string The data string + * @param string $asset The asset in question + * @param string $as The as string + * @param int $row_type The row type + * @param string $type The target type (db||view) + * + * @return array the select query + * @deprecated 3.3 Use CFactory::_('Dynamicget.Selection')->get($method_key, $view_code, $string, $asset, $as, $type, $row_type); + */ + public function setDataSelection($method_key, $view_code, $string, $asset, + $as, $row_type, $type + ) + { + return CFactory::_('Dynamicget.Selection')->get( + $method_key, $view_code, $string, $asset, + $as, $type, $row_type); + } + + /** + * Get the View Table Name + * + * @param int $id The admin view in + * + * @return string view code name + * @deprecated 3.3 + */ + public function getViewTableName($id) + { + // Create a new query object. + $query = $this->db->getQuery(true); + $query->select($this->db->quoteName(array('a.name_single'))); + $query->from( + $this->db->quoteName('#__componentbuilder_admin_view', 'a') + ); + $query->where($this->db->quoteName('a.id') . ' = ' . (int) $id); + $this->db->setQuery($query); + + return StringHelper::safe($this->db->loadResult()); + } + + /** + * Build the SQL dump String for a view + * + * @param string $tables The tables to use in build + * @param string $view The target view/table to dump in + * @param int $view_id The id of the target view + * + * @return string on success with the Dump SQL + * @deprecated 3.3 Use CFactory::_('Model.Sqldump')->key($tables, $view, $view_id); + */ + public function buildSqlDump($tables, $view, $view_id) + { + return CFactory::_('Model.Sqldump')->key($tables, $view, $view_id); + } + + /** + * Escape the values for a SQL dump + * + * @param string $value the value to escape + * + * @return string on success with escaped string + * @deprecated 3.3 + */ + public function mysql_escape($value) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * Creating an uniqueCode + * + * @param string $code The planed code + * + * @return string The unique code + * @deprecated 3.3 use Unique::code($code); + */ + public function uniqueCode($code) + { + return Unique::code($code); + } + + /** + * Creating an unique local key + * + * @param int $size The key size + * + * @return string The unique localkey + * @deprecated 3.3 use Unique::get($size); + */ + public function uniquekey($size, $random = false, + $newBag = "vvvvvvvvvvvvvvvvvvv" + ) + { + return Unique::get($size); + } + + /** + * Check for footable scripts + * + * @param string $content The content to check + * + * @return boolean True if found + * @deprecated 3.3 + */ + public function getFootableScripts($content) + { + if (strpos($content, 'footable') !== false) + { + return true; + } + + return false; + } + + /** + * Check for getModules script + * + * @param string $content The content to check + * + * @return boolean True if found + * @deprecated 3.3 + */ + public function getGetModule($content) + { + if (strpos($content, 'this->getModules(') !== false) + { + return true; + } + + return false; + } + + /** + * Check for get Google Chart script + * + * @param string $content The content to check + * + * @return boolean True if found + * @deprecated 3.3 + */ + public function getGoogleChart($content) + { + if (strpos($content, 'Chartbuilder(') !== false) + { + return true; + } + + return false; + } + + /** + * Set the dynamic values in strings here + * + * @param string $string The content to check + * @param int $debug The switch to debug the update + * We can now at any time debug the + * dynamic build values if it gets broken + * + * @return string + * @deprecated 3.3 Use CFactory::_('Customcode')->update($string, $debug); + */ + public function setDynamicValues($string, $debug = 0) + { + return CFactory::_('Customcode')->update($string, $debug); + } + + /** + * Set the external code string & load it in to string + * + * @param string $string The content to check + * @param int $debug The switch to debug the update + * + * @return string + * @deprecated 3.3 Use CFactory::_('Customcode.External')->set($string, $debug); + */ + public function setExternalCodeString($string, $debug = 0) + { + return CFactory::_('Customcode.External')->set($string, $debug); + } + + /** + * Get the External Code/String + * + * @param string $string The content to check + * @param array $bucket The Placeholders bucket + * + * @return void + * @deprecated 3.3 + */ + protected function getExternalCodeString($target, &$bucket) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * Cut the External Code/String + * + * @param string $string The content to cut + * @param string $sequence The cutting sequence + * @param string $key The content key + * + * @return string + * @deprecated 3.3 + */ + protected function cutExternalCodeString($string, $sequence, $key) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + + return ''; + } + + /** + * We start set the custom code data & can load it in to string + * + * @param string $string The content to check + * @param int $debug The switch to debug the update + * + * @return string + * @deprecated 3.3 Use CFactory::_('Customcode')->set($string, $debug, $not); + */ + public function setCustomCodeData($string, $debug = 0, $not = null) + { + return CFactory::_('Customcode')->set($string, $debug, $not); + } + + /** + * Insert the custom code into the string + * + * @param string $string The content to check + * @param int $debug The switch to debug the update + * + * @return string on success + * @deprecated 3.3 + */ + protected function insertCustomCode($ids, $string, $debug = 0) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + + return ''; + } + + /** + * Insert the custom code into the string + * + * @param string $string The content to check + * @param int $debug The switch to debug the update + * + * @return string on success + * @deprecated 3.3 + */ + protected function buildCustomCodePlaceholders($item, &$code, $debug = 0) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + + return ''; + } + + /** + * Set a type of placeholder with set of values + * + * @param string $key The main string for placeholder key + * @param array $values The values to add + * + * @return void + * @deprecated 3.3 Use CFactory::_('Placeholder')->setType($key, $values); + */ + public function setThesePlaceHolders($key, $values) + { + // use the new container class + CFactory::_('Placeholder')->setType($key, $values); + } + + /** + * Remove a type of placeholder by main string + * + * @param string $like The main string for placeholder key + * + * @return void + * @deprecated 3.3 Use CFactory::_('Placeholder')->clearType($key); + */ + public function clearFromPlaceHolders($like) + { + // use the new container class + CFactory::_('Placeholder')->clearType($like); + } + + /** + * to unset stuff that are private or protected + * + */ + public function unsetNow($remove) + { + unset($this->$remove); + } + + /** + * Get the other languages + * + * @param array $values The lang strings to get + * + * + * @return void + * + */ + public function getMultiLangStrings($values) + { + // Create a new query object. + $query = $this->db->getQuery(true); + $query->from( + $this->db->quoteName( + '#__componentbuilder_language_translation', 'a' + ) + ); + if (ArrayHelper::check($values)) + { + $query->select( + $this->db->quoteName( + array('a.id', 'a.translation', 'a.source', 'a.components', + 'a.modules', 'a.plugins', 'a.published') + ) + ); + $query->where( + $this->db->quoteName('a.source') . ' IN (' . implode( + ',', array_map( + fn($a) => $this->db->quote($a), $values + ) + ) . ')' + ); + $this->db->setQuery($query); + $this->db->execute(); + if ($this->db->getNumRows()) + { + return $this->db->loadAssocList('source'); + } + } + + return false; + } + + /** + * Set the Current language values to DB + * + * + * @return void + * + */ + public function setLangPlaceholders($strings, int $target_id, + $target = 'components' + ) + { + $counterInsert = 0; + $counterUpdate = 0; + $today = Factory::getDate()->toSql(); + foreach ( + $this->languages[$target][CFactory::_('Config')->get('lang_tag', 'en-GB')] as $area => $placeholders + ) + { + foreach ($placeholders as $placeholder => $string) + { + // to keep or remove + $remove = false; + // build the translations + if (StringHelper::check($string) + && isset($this->multiLangString[$string])) + { + // make sure we have converted the string to array + if (isset($this->multiLangString[$string]['translation']) + && JsonHelper::check( + $this->multiLangString[$string]['translation'] + )) + { + $this->multiLangString[$string]['translation'] + = json_decode( + (string) $this->multiLangString[$string]['translation'], true + ); + } + // if we have an array continue + if (isset($this->multiLangString[$string]['translation']) + && ArrayHelper::check( + $this->multiLangString[$string]['translation'] + )) + { + // great lets build the multi languages strings + foreach ( + $this->multiLangString[$string]['translation'] as + $translations + ) + { + if (isset($translations['language']) + && isset($translations['translation'])) + { + // build arrays + if (!isset($this->languages[$target][$translations['language']])) + { + $this->languages[$target][$translations['language']] + = []; + } + if (!isset($this->languages[$target][$translations['language']][$area])) + { + $this->languages[$target][$translations['language']][$area] + = []; + } + $this->languages[$target][$translations['language']][$area][$placeholder] + = CFactory::_('Language')->fix($translations['translation']); + } + } + } + else + { + // remove this string not to be checked again + $remove = true; + } + } + // do the database management + if (StringHelper::check($string) + && ($key = array_search($string, $strings)) !== false) + { + if (isset($this->multiLangString[$string])) + { + // update the existing placeholder in db + $id = $this->multiLangString[$string]['id']; + if (JsonHelper::check( + $this->multiLangString[$string][$target] + )) + { + $targets = (array) json_decode( + (string) $this->multiLangString[$string][$target], true + ); + // check if we should add the target ID + if (in_array($target_id, $targets)) + { + // only skip the update if the string is published and has the target ID + if ($this->multiLangString[$string]['published'] + == 1) + { + continue; + } + } + else + { + $targets[] = $target_id; + } + } + else + { + $targets = array($target_id); + } + // start the bucket for this lang + $this->setUpdateExistingLangStrings( + $id, $target, $targets, 1, $today, $counterUpdate + ); + + $counterUpdate++; + + // load to db + $this->setExistingLangStrings(50); + // remove string if needed + if ($remove) + { + unset($this->multiLangString[$string]); + } + } + else + { + // add the new lang placeholder to the db + if (!isset($this->newLangStrings[$target])) + { + $this->newLangStrings[$target] = []; + } + $this->newLangStrings[$target][$counterInsert] + = []; + $this->newLangStrings[$target][$counterInsert][] + = $this->db->quote( + json_encode(array($target_id)) + ); // 'target' + $this->newLangStrings[$target][$counterInsert][] + = $this->db->quote( + $string + ); // 'source' + $this->newLangStrings[$target][$counterInsert][] + = $this->db->quote( + 1 + ); // 'published' + $this->newLangStrings[$target][$counterInsert][] + = $this->db->quote( + $today + ); // 'created' + $this->newLangStrings[$target][$counterInsert][] + = $this->db->quote( + (int) $this->user->id + ); // 'created_by' + $this->newLangStrings[$target][$counterInsert][] + = $this->db->quote( + 1 + ); // 'version' + $this->newLangStrings[$target][$counterInsert][] + = $this->db->quote( + 1 + ); // 'access' + + $counterInsert++; + + // load to db + $this->setNewLangStrings($target, 100); + } + // only set the string once + unset($strings[$key]); + } + } + } + // just to make sure all is done + $this->setExistingLangStrings(); + $this->setNewLangStrings($target); + } + + /** + * store the language placeholders + * + * @param string $target The target extention type + * @param int $when To set when to update + * + * @return void + * + */ + protected function setNewLangStrings($target, $when = 1) + { + if (isset($this->newLangStrings[$target]) + && count( + (array) $this->newLangStrings[$target] + ) >= $when) + { + // Create a new query object. + $query = $this->db->getQuery(true); + $continue = false; + // Insert columns. + $columns = array($target, 'source', 'published', 'created', + 'created_by', 'version', 'access'); + // Prepare the insert query. + $query->insert( + $this->db->quoteName('#__componentbuilder_language_translation') + ); + $query->columns($this->db->quoteName($columns)); + foreach ($this->newLangStrings[$target] as $values) + { + if (count((array) $values) == 7) + { + $query->values(implode(',', $values)); + $continue = true; + } + else + { + // TODO line mismatch... should not happen + } + } + // clear the values array + $this->newLangStrings[$target] = []; + if (!$continue) + { + return false; // insure we dont continue if no values were loaded + } + // Set the query using our newly populated query object and execute it. + $this->db->setQuery($query); + $this->db->execute(); + } + } + + /** + * update the language placeholders + * + * @param int $when To set when to update + * + * @return void + * + */ + protected function setExistingLangStrings($when = 1) + { + if (count((array) $this->existingLangStrings) >= $when) + { + foreach ($this->existingLangStrings as $values) + { + // Create a new query object. + $query = $this->db->getQuery(true); + // Prepare the update query. + $query->update( + $this->db->quoteName( + '#__componentbuilder_language_translation' + ) + )->set($values['fields'])->where($values['conditions']); + // Set the query using our newly populated query object and execute it. + $this->db->setQuery($query); + $this->db->execute(); + } + // clear the values array + $this->existingLangStrings = []; + } + } + + /** + * Remove exiting language translation stings + * + * @param int $id To string ID to remove + * + * @return void + * + */ + protected function removeExitingLangString($id) + { + // Create a new query object. + $query = $this->db->getQuery(true); + + // delete all custom keys for user 1001. + $conditions = array( + $this->db->quoteName('id') . ' = ' . (int) $id + ); + + $query->delete( + $this->db->quoteName('#__componentbuilder_language_translation') + ); + $query->where($conditions); + + $this->db->setQuery($query); + $this->db->execute(); + } + + /** + * Function to purge the unused languge strings + * + * @param string $values the active strings + * + * @return void + * + */ + public function purgeLanuageStrings($values, $target_id, + $target = 'components' + ) + { + // the target types are + $target_types = array('components' => 'components', + 'modules' => 'modules', + 'plugins' => 'plugins'); + // make sure we only work with preset targets + if (isset($target_types[$target])) + { + // remove the current target + unset($target_types[$target]); + // Create a new query object. + $query = $this->db->getQuery(true); + $query->from( + $this->db->quoteName( + '#__componentbuilder_language_translation', 'a' + ) + ); + $query->select( + $this->db->quoteName( + array('a.id', 'a.translation', 'a.components', 'a.modules', + 'a.plugins') + ) + ); + // get all string that are not linked to this component + $query->where( + $this->db->quoteName('a.source') . ' NOT IN (' . implode( + ',', array_map( + fn($a) => $this->db->quote($a), $values + ) + ) . ')' + ); + $query->where($this->db->quoteName('a.published') . ' = 1'); + $this->db->setQuery($query); + $this->db->execute(); + if ($this->db->getNumRows()) + { + $counterUpdate = 0; + $otherStrings = $this->db->loadAssocList(); + $today = Factory::getDate()->toSql(); + foreach ($otherStrings as $item) + { + if (JsonHelper::check($item[$target])) + { + $targets = (array) json_decode((string) $item[$target], true); + // if component is not found ignore this string, and do nothing + if (($key = array_search($target_id, $targets)) + !== false) + { + // first remove the component from the string + unset($targets[$key]); + // check if there are more components + if (ArrayHelper::check($targets)) + { + // just update the string to unlink the current component + $this->setUpdateExistingLangStrings( + $item['id'], $target, $targets, 1, $today, + $counterUpdate + ); + + $counterUpdate++; + + // load to db + $this->setExistingLangStrings(50); + } + // check if this string has been worked on or is linked to other extensions + else + { + // the action (1 = remove, 2 = archive, 0 = do nothing) + $action_with_string = 1; + // now check if it is linked to other extensions + foreach ($target_types as $other_target) + { + // just one linked extension type is enough to stop the search + if ($action_with_string + && JsonHelper::check( + $item[$other_target] + )) + { + $other_targets = (array) json_decode( + (string) $item[$other_target], true + ); + // check if linked to other extensions + if (ArrayHelper::check( + $other_targets + )) + { + $action_with_string + = 0; // do nothing + } + } + } + // check we should just archive or remove string + if ($action_with_string + && JsonHelper::check( + $item['translation'] + )) + { + $translation = json_decode( + (string) $item['translation'], true + ); + if (ArrayHelper::check( + $translation + )) + { + // only archive the item and update the string to unlink the current component + $this->setUpdateExistingLangStrings( + $item['id'], $target, $targets, 2, + $today, $counterUpdate + ); + + $counterUpdate++; + + // load to db + $this->setExistingLangStrings(50); + + $action_with_string + = 2; // we archived it + } + } + // remove the string since no translation found and not linked to any other extensions + if ($action_with_string == 1) + { + $this->removeExitingLangString($item['id']); + } + } + } + } + } + // load to db + $this->setExistingLangStrings(); + } + } + } + + /** + * just to add lang string to the existing Lang Strings array + * + * @return void + * + */ + protected function setUpdateExistingLangStrings($id, $target, $targets, + $published, $today, $counterUpdate + ) + { + // start the bucket for this lang + $this->existingLangStrings[$counterUpdate] = []; + $this->existingLangStrings[$counterUpdate]['id'] = (int) $id; + $this->existingLangStrings[$counterUpdate]['conditions'] = []; + $this->existingLangStrings[$counterUpdate]['conditions'][] + = $this->db->quoteName( + 'id' + ) . ' = ' . $this->db->quote($id); + $this->existingLangStrings[$counterUpdate]['fields'] = []; + $this->existingLangStrings[$counterUpdate]['fields'][] + = $this->db->quoteName( + $target + ) . ' = ' . $this->db->quote(json_encode($targets)); + $this->existingLangStrings[$counterUpdate]['fields'][] + = $this->db->quoteName( + 'published' + ) . ' = ' . $this->db->quote($published); + $this->existingLangStrings[$counterUpdate]['fields'][] + = $this->db->quoteName( + 'modified' + ) . ' = ' . $this->db->quote($today); + $this->existingLangStrings[$counterUpdate]['fields'][] + = $this->db->quoteName( + 'modified_by' + ) . ' = ' . $this->db->quote((int) $this->user->id); + } + + /** + * get the custom code from the system + * + * @param array|null $ids The custom code ides if known + * @param int|null $setLang The set lang switch + * @param int $debug The switch to debug the update + * + * @return void + * @deprecated 3.3 Use CFactory::_('Customcode')->get($ids, $setLang, $debug); + */ + public function getCustomCode(?array $ids = null, bool $setLang = true, int $debug = 0) + { + CFactory::_('Customcode')->get($ids, $setLang, $debug); + } + + /** + * check if we already have these ids in local memory + * + * @return void + * @deprecated 3.3 + */ + protected function checkCustomCodeMemory($ids) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * get all the powers linkd to this component + * + * @return void + * @deprecated 3.3 Use CFactory::_('Power')->load($guids); + */ + protected function getPowers($guids) + { + CFactory::_('Power')->load($guids); + } + + /** + * get a power linkd to this component + * + * @return mixed + * @deprecated 3.3 Use CFactory::_('Power')->get($guid, $build); + */ + public function getPower($guid, $build = 0) + { + CFactory::_('Power')->get($guid, $build); + } + + /** + * set a power linkd to this component + * + * @return bool + * @deprecated 3.3 + */ + protected function setPower($guid) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + + return false; + } + + /** + * get the Joomla module path + * + * @return string of module path and target site area on success + * @deprecated 3.3 + */ + protected function getModulePath($id) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + + return ''; + } + + /** + * get the Joomla Modules IDs + * + * @return array of IDs on success + * @deprecated 3.3 + */ + protected function getModuleIDs() + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + + return []; + } + + /** + * set the Joomla modules + * + * @return true + * @deprecated 3.3 Use CFactory::_('Joomlamodule.Data')->set($id); + */ + public function setJoomlaModule($id, &$component) + { + return CFactory::_('Joomlamodule.Data')->set($id); + } + + /** + * get the module xml template + * + * @return string + * @deprecated 3.3 + */ + public function getModuleXMLTemplate(&$module) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * get the module admin custom script field + * + * @return string + * @deprecated 3.3 + */ + public function getModAdminVvvvvvvdm($fieldScriptBucket) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * get the Joomla plugins IDs + * + * @return array of IDs on success + * @deprecated 3.3 + */ + protected function getPluginIDs() + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + + return []; + } + + /** + * get the Joomla plugin path + * + * @return string of plugin path on success + * @deprecated 3.3 + */ + protected function getPluginPath($id) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + + return ''; + } + + /** + * set the Joomla plugins + * + * @return true + * @deprecated 3.3 Use CFactory::_('Joomlamodule.Data')->set($id); + */ + public function setJoomlaPlugin($id, &$component) + { + return CFactory::_('Joomlaplugin.Data')->set($id); + } + + /** + * get the plugin xml template + * + * @return string + * @deprecated 3.3 + */ + public function getPluginXMLTemplate(&$plugin) + { + $xml = ''; + $xml .= PHP_EOL . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . $plugin->lang_prefix + . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('BUILDDATE') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHOR') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHOREMAIL') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHORWEBSITE') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('COPYRIGHT') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('LICENSE') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . $plugin->plugin_version + . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . $plugin->lang_prefix + . '_XML_DESCRIPTION'; + $xml .= Placefix::_h('MAINXML'); + $xml .= PHP_EOL . ''; + + return $xml; + } + + /** + * store the code + * + * @param int $when To set when to update + * + * @return void + * @deprecated 3.3 + */ + protected function setNewCustomCode($when = 1) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * store the code + * + * @param int $when To set when to update + * + * @return void + * @deprecated 3.3 + */ + protected function setExistingCustomCode($when = 1) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * get the custom code from the local files + * + * @param array $paths The local paths to parse + * @param string $today The date for today + * + * @return void + * @deprecated 3.3 Use CFactory::_('Customcode.Extractor')->run(); + */ + protected function customCodeFactory(&$paths, &$today) + { + CFactory::_('Customcode.Extractor')->run(); + } + + /** + * search a file for placeholders and store result + * + * @param array $counter The counter for the arrays + * @param string $file The file path to search + * @param array $searchArray The values to search for + * @param array $placeholders The values to replace in the code being stored + * @param string $today The date for today + * + * @return array on success + * + * @deprecated 3.3 + */ + protected function searchFileContent(&$counter, &$file, &$target, + &$searchArray, &$placeholders, &$today + ) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + + return []; + } + + /** + * Set a hash of a file and/or string + * + * @param string $string The code string + * + * @return string + * @deprecated 3.3 Use CFactory::_('Customcode.Hash')->set($script); + */ + protected function setDynamicHASHING($script) + { + return CFactory::_('Customcode.Hash')->set($script); + } + + /** + * Lock a string with bsae64 (basic) + * + * @param string $string The code string + * + * @return string + * @deprecated 3.3 Use CFactory::_('Customcode.LockBase')->set($script); + */ + protected function setBase64LOCK($script) + { + return CFactory::_('Customcode.LockBase')->set($script); + } + + /** + * Set the JCB GUI code placeholder + * + * @param string $string The code string + * @param array $config The placeholder config values + * + * @return string + * @deprecated 3.3 Use CFactory::_('Customcode.Gui')->set($string, $config); + */ + public function setGuiCodePlaceholder($string, $config) + { + return CFactory::_('Customcode.Gui')->set($string, $config); + } + + /** + * search a code to see if there is already any custom + * code or other reasons not to add the GUI code placeholders + * + * @param string $code The code to check + * + * @return boolean true if GUI code placeholders can be added + * @deprecated 3.3 + */ + protected function canAddGuiCodePlaceholder(&$code) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + + return false; + } + + /** + * search a file for gui code blocks that were updated in the IDE + * + * @param string $file The file path to search + * @param array $placeholders The values to replace in the code being stored + * @param string $today The date for today + * @param string $target The target path type + * + * @return void + * @deprecated 3.3 Use CFactory::_('Customcode.Gui')->search($file, $placeholders, $today, $target); + */ + protected function guiCodeSearch(&$file, &$placeholders, &$today, &$target) + { + CFactory::_('Customcode.Gui')->search($file, $placeholders, $today, $target); + } + + /** + * Check if this line should be added + * + * @param string $replaceKey The key to remove from line + * @param int $type The line type + * @param string $lineContent The line to check + * + * @return bool true on success + * + * @deprecated 3.3 + */ + protected function addLineChecker($replaceKey, $type, $lineContent) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + + return false; + } + + /** + * set the start replace placeholder + * + * @param int $id The comment id + * @param int $commentType The comment type + * @param string $startReplace The main replace string + * + * @return array on success + * + * @deprecated 3.3 + */ + protected function setStartReplace($id, $commentType, $startReplace) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + + return []; + } + + /** + * search for the system id in the line given + * + * @param string $lineContent The file path to search + * @param string $placeholders The values to search for + * @param int $commentType The comment type + * + * @return int on success + * + * @deprecated 3.3 + */ + protected function getSystemID(&$lineContent, $placeholders, $commentType) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + + return null; + } + + /** + * Reverse Engineer the dynamic placeholders (TODO hmmmm this is not ideal) + * + * @param string $string The string to revers + * @param array $placeholders The values to search for + * @param string $target The target path type + * @param int $id The custom code id + * @param string $field The field name + * @param string $table The table name + * + * @return string + * @deprecated 3.3 Use CFactory::_('Placeholder.Reverse')->engine($string, $placeholders, $target, $id, $field, $table); + */ + protected function reversePlaceholders($string, &$placeholders, &$target, + $id = null, $field = 'code', $table = 'custom_code' + ) + { + // use the new container class + CFactory::_('Placeholder.Reverse')->engine($string, $placeholders, $target, $id, $field, $table); + } + + /** + * Set the langs strings for the reveres process + * + * @param string $updateString The string to update + * @param string $string The string to use lang update + * @param string $target The target path type + * + * @return string + * @deprecated 3.3 See $this->reversePlaceholders(); + */ + protected function setReverseLangPlaceholders($updateString, $string, + &$target + ) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + + return ''; + } + + /** + * Update the data with the placeholders + * + * @param string $data The actual data + * @param array $placeholder The placeholders + * @param int $action The action to use + * + * THE ACTION OPTIONS ARE + * 1 -> Just replace (default) + * 2 -> Check if data string has placeholders + * 3 -> Remove placeholders not in data string + * + * @return string + * @deprecated 3.3 Use CFactory::_('Placeholder')->update($data, $placeholder, $action); + */ + public function setPlaceholders($data, &$placeholder, $action = 1) + { + // use the new container class + CFactory::_('Placeholder')->update($data, $placeholder, $action); + } + + /** + * return the placeholders for inserted and replaced code + * + * @param int $type The type of placement + * @param int $id The code id in the system + * + * @return array on success + * @deprecated 3.3 Use CFactory::_('Placeholder')->keys($type, $id); + */ + public function getPlaceHolder($type, $id) + { + return CFactory::_('Placeholder')->keys($type, $id); + } + + /** + * get the local installed path of this component + * + * @return array of paths on success + * @deprecated 3.3 + */ + protected function getLocalInstallPaths() + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + + return []; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Infusion.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Infusion.php new file mode 100644 index 000000000..8d32386c1 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Infusion.php @@ -0,0 +1,2572 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Helper; + + +use Joomla\CMS\Factory; +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Filesystem\Folder; +use Joomla\Filter\OutputFilter; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\FileHelper; +use VDM\Joomla\Utilities\String\NamespaceHelper; +use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Minify; +use VDM\Joomla\Componentbuilder\Compiler\Helper\Interpretation; + + +/** + * Infusion class + * + * @deprecated 3.3 + */ +class Infusion extends Interpretation +{ + public $langFiles = []; + + /** + * Switch to remove site folder + * + * @var bool + * @deprecated 3.3 Use CFactory::_('Config')->remove_site_folder; + */ + public $removeSiteFolder = false; + + /** + * Switch to remove site edit folder + * + * @var bool + * @deprecated 3.3 Use CFactory::_('Config')->remove_site_edit_folder; + */ + public $removeSiteEditFolder = true; + + /** + * Constructor + */ + public function __construct() + { + // first we run the perent constructor + if (parent::__construct()) + { + // infuse the data into the structure + return $this->buildFileContent(); + } + + return false; + } + + /** + * Build the content for the structure + * + * + * @return boolean on success + * + */ + protected function buildFileContent() + { + if (CFactory::_('Component')->isArray('admin_views')) + { + // Trigger Event: jcb_ce_onBeforeBuildFilesContent + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeBuildFilesContent' + ); + + // COMPONENT + CFactory::_('Compiler.Builder.Content.One')->set('COMPONENT', + CFactory::_('Placeholder')->get('COMPONENT') + ); + + // Component + CFactory::_('Compiler.Builder.Content.One')->set('Component', + CFactory::_('Placeholder')->get('Component') + ); + + // component + CFactory::_('Compiler.Builder.Content.One')->set('component', + CFactory::_('Placeholder')->get('component') + ); + + // ComponentNameSpace + CFactory::_('Compiler.Builder.Content.One')->set('ComponentNameSpace', + NamespaceHelper::safeSegment(CFactory::_('Placeholder')->get('Component')) + ); + + // COMPANYNAME + $companyname = CFactory::_('Component')->get('companyname'); + CFactory::_('Compiler.Builder.Content.One')->set('COMPANYNAME', trim( + (string) \JFilterOutput::cleanText($companyname) + )); + + // POWER_LIBRARY_FOLDER + CFactory::_('Compiler.Builder.Content.One')->set('POWER_LIBRARY_FOLDER', + CFactory::_('Config')->power_library_folder + ); + + // CREATIONDATE + CFactory::_('Compiler.Builder.Content.One')->set('CREATIONDATE', + Factory::getDate(CFactory::_('Component')->get('created'))->format( + 'jS F, Y' + )); + CFactory::_('Compiler.Builder.Content.One')->set('GLOBALCREATIONDATE', + CFactory::_('Compiler.Builder.Content.One')->get('CREATIONDATE')); + + // BUILDDATE + CFactory::_('Compiler.Builder.Content.One')->set('BUILDDATE', Factory::getDate( + CFactory::_('Config')->get('build_date', 'now'))->format('jS F, Y')); + CFactory::_('Compiler.Builder.Content.One')->set('GLOBALBUILDDATE', + CFactory::_('Compiler.Builder.Content.One')->get('BUILDDATE')); + + // AUTHOR + $author = CFactory::_('Component')->get('author'); + CFactory::_('Compiler.Builder.Content.One')->set('AUTHOR', trim( + (string) OutputFilter::cleanText($author) + )); + + // AUTHOREMAIL + CFactory::_('Compiler.Builder.Content.One')->set('AUTHOREMAIL', + trim((string) CFactory::_('Component')->get('email', '')) + ); + + // AUTHORWEBSITE + CFactory::_('Compiler.Builder.Content.One')->set('AUTHORWEBSITE', + trim((string) CFactory::_('Component')->get('website', '')) + ); + + // COPYRIGHT + CFactory::_('Compiler.Builder.Content.One')->set('COPYRIGHT', + trim((string) CFactory::_('Component')->get('copyright', '')) + ); + + // LICENSE + CFactory::_('Compiler.Builder.Content.One')->set('LICENSE', + trim((string) CFactory::_('Component')->get('license', '')) + ); + + // VERSION + CFactory::_('Compiler.Builder.Content.One')->set('VERSION', + trim((string) CFactory::_('Component')->get('component_version', '')) + ); + // set the actual global version + CFactory::_('Compiler.Builder.Content.One')->set('ACTUALVERSION', + CFactory::_('Compiler.Builder.Content.One')->get('VERSION') + ); + + // do some Tweaks to the version based on selected options + if (strpos((string) CFactory::_('Compiler.Builder.Content.One')->get('VERSION'), '.') !== false) + { + $versionArray = explode( + '.', (string) CFactory::_('Compiler.Builder.Content.One')->get('VERSION') + ); + } + // load only first two values + if (isset($versionArray) + && ArrayHelper::check( + $versionArray + ) && CFactory::_('Component')->get('mvc_versiondate', 0) == 2) + { + CFactory::_('Compiler.Builder.Content.One')->set('VERSION', + $versionArray[0] . '.' . $versionArray[1] . '.x' + ); + } + // load only the first value + elseif (isset($versionArray) + && ArrayHelper::check( + $versionArray + ) && CFactory::_('Component')->get('mvc_versiondate', 0) == 3) + { + CFactory::_('Compiler.Builder.Content.One')->set('VERSION', + $versionArray[0] . '.x.x' + ); + } + unset($versionArray); + + // set the namespace prefix + CFactory::_('Compiler.Builder.Content.One')->set('NAMESPACEPREFIX', + CFactory::_('Config')->namespace_prefix + ); + + // set the global version in case + CFactory::_('Compiler.Builder.Content.One')->set('GLOBALVERSION', + CFactory::_('Compiler.Builder.Content.One')->get('VERSION') + ); + + // set the joomla target xml version + CFactory::_('Compiler.Builder.Content.One')->set('XMLVERSION', + CFactory::_('Config')->joomla_versions[CFactory::_('Config')->joomla_version]['xml_version'] + ); + + // Component_name + $name = CFactory::_('Component')->get('name'); + CFactory::_('Compiler.Builder.Content.One')->set('Component_name', + OutputFilter::cleanText($name) + ); + + // SHORT_DISCRIPTION + $short_description = CFactory::_('Component')->get('short_description'); + CFactory::_('Compiler.Builder.Content.One')->set('SHORT_DESCRIPTION', trim( + (string) OutputFilter::cleanText( + $short_description + ) + )); + + // DESCRIPTION + CFactory::_('Compiler.Builder.Content.One')->set('DESCRIPTION', + trim((string) CFactory::_('Component')->get('description')) + ); + + // COMP_IMAGE_TYPE + CFactory::_('Compiler.Builder.Content.One')->set('COMP_IMAGE_TYPE', + $this->setComponentImageType(CFactory::_('Component')->get('image')) + ); + + // ACCESS_SECTIONS + CFactory::_('Compiler.Builder.Content.One')->set('ACCESS_SECTIONS', + CFactory::_('Compiler.Creator.Access.Sections')->get() + ); + + // CONFIG_FIELDSETS + $keepLang = CFactory::_('Config')->lang_target; + CFactory::_('Config')->lang_target = 'admin'; + + // start loading the category tree scripts + CFactory::_('Compiler.Builder.Content.One')->set('CATEGORY_CLASS_TREES', ''); + // run the field sets for first time + CFactory::_('Compiler.Creator.Config.Fieldsets')->set(1); + CFactory::_('Config')->lang_target = $keepLang; + + // ADMINJS + CFactory::_('Compiler.Builder.Content.One')->set('ADMINJS', + CFactory::_('Placeholder')->update_( + CFactory::_('Customcode.Dispenser')->hub['component_js'] + )); + // SITEJS + CFactory::_('Compiler.Builder.Content.One')->set('SITEJS', + CFactory::_('Placeholder')->update_( + CFactory::_('Customcode.Dispenser')->hub['component_js'] + )); + + // ADMINCSS + CFactory::_('Compiler.Builder.Content.One')->set('ADMINCSS', + CFactory::_('Placeholder')->update_( + CFactory::_('Customcode.Dispenser')->hub['component_css_admin'] + )); + // SITECSS + CFactory::_('Compiler.Builder.Content.One')->set('SITECSS', + CFactory::_('Placeholder')->update_( + CFactory::_('Customcode.Dispenser')->hub['component_css_site'] + )); + + // CUSTOM_HELPER_SCRIPT + CFactory::_('Compiler.Builder.Content.One')->set('CUSTOM_HELPER_SCRIPT', + CFactory::_('Placeholder')->update_( + CFactory::_('Customcode.Dispenser')->hub['component_php_helper_admin'] + )); + + // BOTH_CUSTOM_HELPER_SCRIPT + CFactory::_('Compiler.Builder.Content.One')->set('BOTH_CUSTOM_HELPER_SCRIPT', + CFactory::_('Placeholder')->update_( + CFactory::_('Customcode.Dispenser')->hub['component_php_helper_both'] + )); + + // ADMIN_GLOBAL_EVENT_HELPER + if (!CFactory::_('Compiler.Builder.Content.One')->exists('ADMIN_GLOBAL_EVENT')) + { + CFactory::_('Compiler.Builder.Content.One')->set('ADMIN_GLOBAL_EVENT', ''); + } + if (!CFactory::_('Compiler.Builder.Content.One')->exists('ADMIN_GLOBAL_EVENT_HELPER')) + { + CFactory::_('Compiler.Builder.Content.One')->set('ADMIN_GLOBAL_EVENT_HELPER', ''); + } + // now load the data for the global event if needed + if (CFactory::_('Component')->get('add_admin_event', 0) == 1) + { + // ADMIN_GLOBAL_EVENT + CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT', + PHP_EOL . PHP_EOL . '// Trigger the Global Admin Event' + ); + CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT', + PHP_EOL . CFactory::_('Compiler.Builder.Content.One')->get('Component') + . 'Helper::globalEvent(Factory::getDocument());'); + // ADMIN_GLOBAL_EVENT_HELPER + CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER', + PHP_EOL . PHP_EOL . Indent::_(1) . '/**' + ); + CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER', + PHP_EOL . Indent::_(1) + . '* The Global Admin Event Method.'); + CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER', + PHP_EOL . Indent::_(1) . '**/' + ); + CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER', + PHP_EOL . Indent::_(1) + . 'public static function globalEvent($document)'); + CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER', + PHP_EOL . Indent::_(1) . '{' + ); + CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER', + PHP_EOL . CFactory::_('Placeholder')->update_( + CFactory::_('Customcode.Dispenser')->hub['component_php_admin_event'] + )); + CFactory::_('Compiler.Builder.Content.One')->add('ADMIN_GLOBAL_EVENT_HELPER', + PHP_EOL . Indent::_(1) . '}' + ); + } + + // now load the readme file if needed + if (CFactory::_('Component')->get('addreadme', 0) == 1) + { + CFactory::_('Compiler.Builder.Content.One')->add('EXSTRA_ADMIN_FILES', + PHP_EOL . Indent::_(3) + . "README.txt"); + } + + // HELPER_CREATEUSER + CFactory::_('Compiler.Builder.Content.One')->add('HELPER_CREATEUSER', + $this->setCreateUserHelperMethod( + CFactory::_('Component')->get('creatuserhelper') + )); + + // HELP + CFactory::_('Compiler.Builder.Content.One')->set('HELP', $this->noHelp()); + // HELP_SITE + CFactory::_('Compiler.Builder.Content.One')->set('HELP_SITE', $this->noHelp()); + + // build route parse switch + CFactory::_('Compiler.Builder.Content.One')->set('ROUTER_PARSE_SWITCH', ''); + // build route views + CFactory::_('Compiler.Builder.Content.One')->set('ROUTER_BUILD_VIEWS', ''); + + // add the helper emailer if set + CFactory::_('Compiler.Builder.Content.One')->set('HELPER_EMAIL', $this->addEmailHelper()); + + // load the global placeholders + foreach (CFactory::_('Component.Placeholder')->get() as $globalPlaceholder => + $gloabalValue + ) + { + CFactory::_('Compiler.Builder.Content.One')->set($globalPlaceholder, $gloabalValue); + } + + // reset view array + $viewarray = []; + $site_edit_view_array = []; + // start dynamic build + foreach (CFactory::_('Component')->get('admin_views') as $view) + { + // set the target + CFactory::_('Config')->build_target = 'admin'; + CFactory::_('Config')->lang_target = 'admin'; + + // set local names + $nameSingleCode = $view['settings']->name_single_code; + $nameListCode = $view['settings']->name_list_code; + + // set the view placeholders + $this->setViewPlaceholders($view['settings']); + + // set site edit view array + if (isset($view['edit_create_site_view']) + && is_numeric( + $view['edit_create_site_view'] + ) + && $view['edit_create_site_view'] > 0) + { + $site_edit_view_array[] = Indent::_(4) . "'" + . $nameSingleCode . "'"; + CFactory::_('Config')->lang_target = 'both'; + // insure site view does not get removed + CFactory::_('Config')->remove_site_edit_folder = false; + } + // check if help is being loaded + $this->checkHelp($nameSingleCode); + // set custom admin view list links + $this->setCustomAdminViewListLink( + $view, $nameListCode + ); + + // set view array + $viewarray[] = Indent::_(4) . "'" + . $nameSingleCode . "' => '" + . $nameListCode . "'"; + // set the view names + if (isset($view['settings']->name_single) + && $view['settings']->name_single != 'null') + { + // set license per view if needed + $this->setLockLicensePer( + $nameSingleCode, CFactory::_('Config')->build_target + ); + $this->setLockLicensePer( + $nameListCode, CFactory::_('Config')->build_target + ); + + // Trigger Event: jcb_ce_onBeforeBuildAdminEditViewContent + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeBuildAdminEditViewContent', [&$view, &$nameSingleCode, &$nameListCode] + ); + + // FIELDSETS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|FIELDSETS', + CFactory::_('Compiler.Creator.Fieldset')->get( + $view, + CFactory::_('Config')->component_code_name, + $nameSingleCode, + $nameListCode + ) + ); + + // ACCESSCONTROL <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|ACCESSCONTROL', + $this->setFieldSetAccessControl( + $nameSingleCode + ) + ); + + // LINKEDVIEWITEMS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|LINKEDVIEWITEMS', ''); + + // ADDTOOLBAR <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|ADDTOOLBAR', + $this->setAddToolBar($view) + ); + + // set the script for this view + $this->buildTheViewScript($view); + + // VIEW_SCRIPT + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|VIEW_SCRIPT', + $this->setViewScript( + $nameSingleCode, 'fileScript' + ) + ); + + // EDITBODYSCRIPT + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|EDITBODYSCRIPT', + $this->setViewScript( + $nameSingleCode, 'footerScript' + ) + ); + + // AJAXTOKE <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|AJAXTOKE', + $this->setAjaxToke( + $nameSingleCode + ) + ); + + // DOCUMENT_CUSTOM_PHP <<>> + if ($phpDocument = CFactory::_('Customcode.Dispenser')->get( + 'php_document', $nameSingleCode, + PHP_EOL, null, true, + false + )) + { + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|DOCUMENT_CUSTOM_PHP', + str_replace( + '$document->', '$this->document->', (string) $phpDocument + ) + ); + // clear some memory + unset($phpDocument); + } + else + { + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|DOCUMENT_CUSTOM_PHP', ''); + } + // LINKEDVIEWTABLESCRIPTS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|LINKEDVIEWTABLESCRIPTS', ''); + + // VALIDATEFIX <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|VALIDATIONFIX', + $this->setValidationFix( + $nameSingleCode, + CFactory::_('Compiler.Builder.Content.One')->get('Component') + ) + ); + + // EDITBODY <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|EDITBODY', + $this->setEditBody($view) + ); + + // EDITBODYFADEIN <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|EDITBODYFADEIN', + $this->setFadeInEfect($view) + ); + + // JTABLECONSTRUCTOR <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JTABLECONSTRUCTOR', + $this->setJtableConstructor( + $nameSingleCode + ) + ); + + // JTABLEALIASCATEGORY <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JTABLEALIASCATEGORY', + $this->setJtableAliasCategory( + $nameSingleCode + ) + ); + + // METHOD_GET_ITEM <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|METHOD_GET_ITEM', + $this->setMethodGetItem( + $nameSingleCode + ) + ); + + // LINKEDVIEWGLOBAL <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|LINKEDVIEWGLOBAL', ''); + + // LINKEDVIEWMETHODS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|LINKEDVIEWMETHODS', ''); + + // JMODELADMIN_BEFORE_DELETE <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JMODELADMIN_BEFORE_DELETE', + CFactory::_('Customcode.Dispenser')->get( + 'php_before_delete', + $nameSingleCode, PHP_EOL + ) + ); + + // JMODELADMIN_AFTER_DELETE <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JMODELADMIN_AFTER_DELETE', + CFactory::_('Customcode.Dispenser')->get( + 'php_after_delete', $nameSingleCode, + PHP_EOL . PHP_EOL + ) + ); + + // JMODELADMIN_BEFORE_DELETE <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JMODELADMIN_BEFORE_PUBLISH', + CFactory::_('Customcode.Dispenser')->get( + 'php_before_publish', + $nameSingleCode, PHP_EOL + ) + ); + + // JMODELADMIN_AFTER_DELETE <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JMODELADMIN_AFTER_PUBLISH', + CFactory::_('Customcode.Dispenser')->get( + 'php_after_publish', + $nameSingleCode, PHP_EOL . PHP_EOL + ) + ); + + // CHECKBOX_SAVE <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|CHECKBOX_SAVE', + $this->setCheckboxSave( + $nameSingleCode + ) + ); + + // METHOD_ITEM_SAVE <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|METHOD_ITEM_SAVE', + $this->setMethodItemSave( + $nameSingleCode + ) + ); + + // POSTSAVEHOOK <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|POSTSAVEHOOK', + CFactory::_('Customcode.Dispenser')->get( + 'php_postsavehook', $nameSingleCode, + PHP_EOL, null, + true, PHP_EOL . Indent::_(2) . "return;", + PHP_EOL . PHP_EOL . Indent::_(2) . "return;" + ) + ); + + // VIEWCSS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|VIEWCSS', + CFactory::_('Customcode.Dispenser')->get( + 'css_view', $nameSingleCode, '', + null, true + ) + ); + + // AJAXTOKE <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|AJAXTOKE', + $this->setAjaxToke( + $nameSingleCode + ) + ); + + // add css to front end + if (isset($view['edit_create_site_view']) + && is_numeric($view['edit_create_site_view']) + && $view['edit_create_site_view'] > 0) + { + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|SITE_VIEWCSS', + CFactory::_('Compiler.Builder.Content.Multi')->get($nameSingleCode . '|VIEWCSS', '') + ); + // check if we should add a create menu + if ($view['edit_create_site_view'] == 2) + { + // SITE_MENU_XML <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|SITE_MENU_XML', + $this->setAdminViewMenu( + $nameSingleCode, $view + ) + ); + } + // SITE_ADMIN_VIEW_CONTROLLER_HEADER <<>> add the header details for the controller + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|SITE_ADMIN_VIEW_CONTROLLER_HEADER', + CFactory::_('Header')->get( + 'site.admin.view.controller', + $nameSingleCode + ) + ); + // SITE_ADMIN_VIEW_MODEL_HEADER <<>> add the header details for the model + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|SITE_ADMIN_VIEW_MODEL_HEADER', + CFactory::_('Header')->get( + 'site.admin.view.model', + $nameSingleCode + ) + ); + // SITE_ADMIN_VIEW_HTML_HEADER <<>> add the header details for the view + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|SITE_ADMIN_VIEW_HTML_HEADER', + CFactory::_('Header')->get( + 'site.admin.view.html', + $nameSingleCode + ) + ); + // SITE_ADMIN_VIEW_HEADER <<>> add the header details for the view + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|SITE_ADMIN_VIEW_HEADER', + CFactory::_('Header')->get( + 'site.admin.view', + $nameSingleCode + ) + ); + } + + // TABLAYOUTFIELDSARRAY <<>> add the tab layout fields array to the model + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|TABLAYOUTFIELDSARRAY', + $this->getTabLayoutFieldsArray( + $nameSingleCode + ) + ); + + // ADMIN_VIEW_CONTROLLER_HEADER <<>> add the header details for the controller + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|ADMIN_VIEW_CONTROLLER_HEADER', + CFactory::_('Header')->get( + 'admin.view.controller', + $nameSingleCode + ) + ); + // ADMIN_VIEW_MODEL_HEADER <<>> add the header details for the model + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|ADMIN_VIEW_MODEL_HEADER', + CFactory::_('Header')->get( + 'admin.view.model', $nameSingleCode + ) + ); + // ADMIN_VIEW_HTML_HEADER <<>> add the header details for the view + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|ADMIN_VIEW_HTML_HEADER', + CFactory::_('Header')->get( + 'admin.view.html', $nameSingleCode + ) + ); + // ADMIN_VIEW_HEADER <<>> add the header details for the view + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|ADMIN_VIEW_HEADER', + CFactory::_('Header')->get( + 'admin.view', $nameSingleCode + ) + ); + + // JQUERY <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JQUERY', + $this->setJquery( + $nameSingleCode + ) + ); + + // Trigger Event: jcb_ce_onAfterBuildAdminEditViewContent + CFactory::_('Event')->trigger( + 'jcb_ce_onAfterBuildAdminEditViewContent',[&$view, &$nameSingleCode, &$nameListCode] + ); + } + // set the views names + if (isset($view['settings']->name_list) + && $view['settings']->name_list != 'null') + { + CFactory::_('Config')->lang_target = 'admin'; + + // ICOMOON <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ICOMOON', $view['icomoon']); + + // Trigger Event: jcb_ce_onBeforeBuildAdminListViewContent + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeBuildAdminListViewContent', [&$view, &$nameSingleCode, &$nameListCode] + ); + + // set the export/import option + if (isset($view['port']) && $view['port'] + || 1 == $view['settings']->add_custom_import) + { + $this->eximportView[$nameListCode] = true; + if (1 == $view['settings']->add_custom_import) + { + // this view has custom import scripting + $this->importCustomScripts[$nameListCode] + = true; + // set all custom scripts + $this->setImportCustomScripts( + $nameListCode + ); + } + } + else + { + $this->eximportView[$nameListCode] + = false; + } + + // set Auto check in function + if (isset($view['checkin']) && $view['checkin'] == 1) + { + // AUTOCHECKIN <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|AUTOCHECKIN', + $this->setAutoCheckin( + $nameSingleCode, + CFactory::_('Config')->component_code_name + ) + ); + // CHECKINCALL <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|CHECKINCALL', + $this->setCheckinCall() + ); + } + else + { + // AUTOCHECKIN <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|AUTOCHECKIN', ''); + // CHECKINCALL <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|CHECKINCALL', ''); + } + // admin list file contnet + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_JAVASCRIPT_FILE', + $this->setViewScript( + $nameListCode, 'list_fileScript' + ) + ); + // ADMIN_CUSTOM_BUTTONS_LIST + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_CUSTOM_BUTTONS_LIST', + $this->setCustomButtons($view, 3, Indent::_(1))); + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_CUSTOM_FUNCTION_ONLY_BUTTONS_LIST', + $this->setFunctionOnlyButtons( + $nameListCode + ) + ); + + // GET_ITEMS_METHOD_STRING_FIX <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|GET_ITEMS_METHOD_STRING_FIX', + $this->setGetItemsMethodStringFix( + $nameSingleCode, + $nameListCode, + CFactory::_('Compiler.Builder.Content.One')->get('Component') + ) + ); + + // GET_ITEMS_METHOD_AFTER_ALL <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|GET_ITEMS_METHOD_AFTER_ALL', + CFactory::_('Customcode.Dispenser')->get( + 'php_getitems_after_all', + $nameSingleCode, PHP_EOL + ) + ); + + // SELECTIONTRANSLATIONFIX <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|SELECTIONTRANSLATIONFIX', + $this->setSelectionTranslationFix( + $nameListCode, + CFactory::_('Compiler.Builder.Content.One')->get('Component') + ) + ); + + // SELECTIONTRANSLATIONFIXFUNC <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|SELECTIONTRANSLATIONFIXFUNC', + $this->setSelectionTranslationFixFunc( + $nameListCode, + CFactory::_('Compiler.Builder.Content.One')->get('Component') + ) + ); + + // FILTER_FIELDS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|FILTER_FIELDS', + $this->setFilterFieldsArray( + $nameSingleCode, + $nameListCode + ) + ); + + // STOREDID <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|STOREDID', + $this->setStoredId( + $nameSingleCode, $nameListCode + ) + ); + + // POPULATESTATE <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|POPULATESTATE', + $this->setPopulateState( + $nameSingleCode, $nameListCode + ) + ); + + // SORTFIELDS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|SORTFIELDS', + $this->setSortFields( + $nameListCode + ) + ); + + // CATEGORY_VIEWS + CFactory::_('Compiler.Builder.Content.One')->add('ROUTER_CATEGORY_VIEWS', + $this->setRouterCategoryViews( + $nameSingleCode, + $nameListCode + )); + + // FILTERFIELDDISPLAYHELPER <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|FILTERFIELDDISPLAYHELPER', + $this->setFilterFieldSidebarDisplayHelper( + $nameSingleCode, + $nameListCode + ) + ); + + // BATCHDISPLAYHELPER <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|BATCHDISPLAYHELPER', + $this->setBatchDisplayHelper( + $nameSingleCode, + $nameListCode + ) + ); + + // FILTERFUNCTIONS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|FILTERFUNCTIONS', + $this->setFilterFieldHelper( + $nameSingleCode, + $nameListCode + ) + ); + + // FIELDFILTERSETS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set('filter_' . $nameListCode . '|FIELDFILTERSETS', + $this->setFieldFilterSet( + $nameSingleCode, + $nameListCode + )); + + // FIELDLISTSETS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set('filter_' . $nameListCode . '|FIELDLISTSETS', + $this->setFieldFilterListSet( + $nameSingleCode, + $nameListCode + )); + + // LISTQUERY <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|LISTQUERY', + $this->setListQuery( + $nameSingleCode, + $nameListCode + ) + ); + + // MODELEXPORTMETHOD <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|MODELEXPORTMETHOD', + $this->setGetItemsModelMethod( + $nameSingleCode, + $nameListCode + ) + ); + + // MODELEXIMPORTMETHOD <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|CONTROLLEREXIMPORTMETHOD', + $this->setControllerEximportMethod( + $nameSingleCode, + $nameListCode + ) + ); + + // EXPORTBUTTON <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|EXPORTBUTTON', + $this->setExportButton( + $nameSingleCode, + $nameListCode + ) + ); + + // IMPORTBUTTON <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|IMPORTBUTTON', + $this->setImportButton( + $nameSingleCode, + $nameListCode + ) + ); + + // VIEWS_DEFAULT_BODY <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|VIEWS_DEFAULT_BODY', + $this->setDefaultViewsBody( + $nameSingleCode, + $nameListCode + ) + ); + + // LISTHEAD <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|LISTHEAD', + $this->setListHead( + $nameSingleCode, + $nameListCode + ) + ); + + // LISTBODY <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|LISTBODY', + $this->setListBody( + $nameSingleCode, + $nameListCode + ) + ); + + // LISTCOLNR <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|LISTCOLNR', + $this->setListColnr( + $nameListCode + ) + ); + + // JVIEWLISTCANDO <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|JVIEWLISTCANDO', + $this->setJviewListCanDo( + $nameSingleCode, + $nameListCode + ) + ); + + // VIEWSCSS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|VIEWSCSS', + CFactory::_('Customcode.Dispenser')->get( + 'css_views', $nameSingleCode, '', + null, true + ) + ); + + // ADMIN_DIPLAY_METHOD <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_DIPLAY_METHOD', + $this->setAdminViewDisplayMethod( + $nameListCode + ) + ); + + // VIEWS_FOOTER_SCRIPT <<>> + $scriptNote = PHP_EOL . '//' . Line::_(__Line__, __Class__) + . ' ' . $nameListCode + . ' footer script'; + if (($footerScript = CFactory::_('Customcode.Dispenser')->get( + 'views_footer', $nameSingleCode, '', + $scriptNote, true, + false, PHP_EOL + )) !== false + && StringHelper::check($footerScript)) + { + // only minfy if no php is added to the footer script + if (CFactory::_('Config')->get('minify', 0) + && strpos((string) $footerScript, 'set($nameListCode . '|VIEWS_FOOTER_SCRIPT', + PHP_EOL . '"); + // clear some memory + unset($footerScript); + } + else + { + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|VIEWS_FOOTER_SCRIPT', ''); + } + + // ADMIN_VIEWS_CONTROLLER_HEADER <<>> add the header details for the controller + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_VIEWS_CONTROLLER_HEADER', + CFactory::_('Header')->get( + 'admin.views.controller', + $nameListCode + ) + ); + // ADMIN_VIEWS_MODEL_HEADER <<>> add the header details for the model + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_VIEWS_MODEL_HEADER', + CFactory::_('Header')->get( + 'admin.views.model', $nameListCode + ) + ); + // ADMIN_VIEWS_HTML_HEADER <<>> add the header details for the views + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_VIEWS_HTML_HEADER', + CFactory::_('Header')->get( + 'admin.views.html', $nameListCode + ) + ); + // ADMIN_VIEWS_HEADER <<>> add the header details for the views + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_VIEWS_HEADER', + CFactory::_('Header')->get( + 'admin.views', $nameListCode + ) + ); + + // JQUERY <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|JQUERY', + $this->setJquery( + $nameSingleCode + ) + ); + + // Trigger Event: jcb_ce_onAfterBuildAdminListViewContent + CFactory::_('Event')->trigger( + 'jcb_ce_onAfterBuildAdminListViewContent', [&$view, &$nameSingleCode, &$nameListCode] + ); + } + + // set u fields used in batch + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|UNIQUEFIELDS', + $this->setUniqueFields( + $nameSingleCode + ) + ); + + // TITLEALIASFIX <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|TITLEALIASFIX', + $this->setAliasTitleFix( + $nameSingleCode + ) + ); + + // GENERATENEWTITLE <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|GENERATENEWTITLE', + $this->setGenerateNewTitle( + $nameSingleCode + ) + ); + + // GENERATENEWALIAS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|GENERATENEWALIAS', + $this->setGenerateNewAlias( + $nameSingleCode + ) + ); + + // MODEL_BATCH_COPY <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|MODEL_BATCH_COPY', + $this->setBatchCopy($nameSingleCode) + ); + + // MODEL_BATCH_MOVE <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|MODEL_BATCH_MOVE', + $this->setBatchMove($nameSingleCode) + ); + + // BATCH_ONCLICK_CANCEL_SCRIPT <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|BATCH_ONCLICK_CANCEL_SCRIPT', ''); // TODO <-- must still be build + + // JCONTROLLERFORM_ALLOWADD <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JCONTROLLERFORM_ALLOWADD', + CFactory::_('Architecture.Controller.AllowAdd')->get( + $nameSingleCode, + ) + ); + + // JCONTROLLERFORM_BEFORECANCEL <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JCONTROLLERFORM_BEFORECANCEL', + CFactory::_('Customcode.Dispenser')->get( + 'php_before_cancel', $nameSingleCode, + PHP_EOL, null, false, + '' + ) + ); + + // JCONTROLLERFORM_AFTERCANCEL <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JCONTROLLERFORM_AFTERCANCEL', + CFactory::_('Customcode.Dispenser')->get( + 'php_after_cancel', $nameSingleCode, + PHP_EOL, null, false, + '' + ) + ); + + // JCONTROLLERFORM_ALLOWEDIT <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JCONTROLLERFORM_ALLOWEDIT', + CFactory::_('Architecture.Controller.AllowEdit')->get( + $nameSingleCode, + $nameListCode + ) + ); + + // JMODELADMIN_GETFORM <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JMODELADMIN_GETFORM', + $this->setJmodelAdminGetForm( + $nameSingleCode, + $nameListCode + ) + ); + + // JMODELADMIN_ALLOWEDIT <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JMODELADMIN_ALLOWEDIT', + $this->setJmodelAdminAllowEdit( + $nameSingleCode, + $nameListCode + ) + ); + + // JMODELADMIN_CANDELETE <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JMODELADMIN_CANDELETE', + CFactory::_('Architecture.Model.CanDelete')->get( + $nameSingleCode + ) + ); + + // JMODELADMIN_CANEDITSTATE <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JMODELADMIN_CANEDITSTATE', + CFactory::_('Architecture.Model.CanEditState')->get( + $nameSingleCode + ) + ); + + // set custom admin view Toolbare buttons + // CUSTOM_ADMIN_DYNAMIC_BUTTONS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|CUSTOM_ADMIN_DYNAMIC_BUTTONS', + $this->setCustomAdminDynamicButton( + $nameListCode + ) + ); + // CUSTOM_ADMIN_DYNAMIC_BUTTONS_CONTROLLER <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|CUSTOM_ADMIN_DYNAMIC_BUTTONS_CONTROLLER', + $this->setCustomAdminDynamicButtonController( + $nameListCode + ) + ); + + // set helper router + CFactory::_('Compiler.Builder.Content.One')->add('ROUTEHELPER', + $this->setRouterHelp( + $nameSingleCode, + $nameListCode + )); + + if (isset($view['edit_create_site_view']) + && is_numeric( + $view['edit_create_site_view'] + ) + && $view['edit_create_site_view'] > 0) + { + // add needed router stuff for front edit views + CFactory::_('Compiler.Builder.Content.One')->add('ROUTER_PARSE_SWITCH', + $this->routerParseSwitch( + $nameSingleCode, null, false + )); + CFactory::_('Compiler.Builder.Content.One')->add('ROUTER_BUILD_VIEWS', + $this->routerBuildViews( + $nameSingleCode + )); + } + + // ACCESS_SECTIONS + CFactory::_('Compiler.Builder.Content.One')->add('ACCESS_SECTIONS', + CFactory::_('Compiler.Creator.Access.Sections.Category')->get( + $nameSingleCode, + $nameListCode + ) + ); + // set the Joomla Fields ACCESS section if needed + if (isset($view['joomla_fields']) + && $view['joomla_fields'] == 1) + { + CFactory::_('Compiler.Builder.Content.One')->add('ACCESS_SECTIONS', + CFactory::_('Compiler.Creator.Access.Sections.Joomla.Fields')->get() + ); + } + + // Trigger Event: jcb_ce_onAfterBuildAdminViewContent + CFactory::_('Event')->trigger( + 'jcb_ce_onAfterBuildAdminViewContent', [&$view, &$nameSingleCode, &$nameListCode] + ); + } + + // all fields stored in database + CFactory::_('Compiler.Builder.Content.One')->set('ALL_COMPONENT_FIELDS', + CFactory::_('Compiler.Builder.Component.Fields')->varExport(null, 1) + ); + + // setup the layouts + $this->setCustomViewLayouts(); + + // setup custom_admin_views and all needed stuff for the site + if (CFactory::_('Component')->isArray('custom_admin_views')) + { + CFactory::_('Config')->build_target = 'custom_admin'; + CFactory::_('Config')->lang_target = 'admin'; + // start dynamic build + foreach (CFactory::_('Component')->get('custom_admin_views') as $view) + { + // for single views + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SView', $view['settings']->Code); + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|sview', $view['settings']->code); + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SVIEW', $view['settings']->CODE); + // for list views + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SViews', $view['settings']->Code); + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|sviews', $view['settings']->code); + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SVIEWS', $view['settings']->CODE); + // add to lang array + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, + CFactory::_('Config')->lang_prefix . '_' . $view['settings']->CODE, + $view['settings']->name + ); + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, + CFactory::_('Config')->lang_prefix . '_' . $view['settings']->CODE + . '_DESC', $view['settings']->description + ); + // ICOMOON <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|ICOMOON', $view['icomoon']); + + // set placeholders + CFactory::_('Placeholder')->set('SView', $view['settings']->Code); + CFactory::_('Placeholder')->set('sview', $view['settings']->code); + CFactory::_('Placeholder')->set('SVIEW', $view['settings']->CODE); + + CFactory::_('Placeholder')->set('SViews', $view['settings']->Code); + CFactory::_('Placeholder')->set('sviews', $view['settings']->code); + CFactory::_('Placeholder')->set('SVIEWS', $view['settings']->CODE); + + // Trigger Event: jcb_ce_onBeforeBuildCustomAdminViewContent + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeBuildCustomAdminViewContent', [&$view, &$view['settings']->code] + ); + + // set license per view if needed + $this->setLockLicensePer( + $view['settings']->code, CFactory::_('Config')->build_target + ); + + // check if this custom admin view is the default view + if (CFactory::_('Registry')->get('build.dashboard.type', '') === 'custom_admin_views' + && CFactory::_('Registry')->get('build.dashboard', '') === $view['settings']->code) + { + // HIDEMAINMENU <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|HIDEMAINMENU', ''); + } + else + { + // HIDEMAINMENU <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|HIDEMAINMENU', + PHP_EOL . Indent::_(2) . '//' . Line::_( + __LINE__,__CLASS__ + ) . " hide the main menu" + . PHP_EOL . Indent::_(2) + . "\$this->app->input->set('hidemainmenu', true);" + ); + } + + if ($view['settings']->main_get->gettype == 1) + { + // CUSTOM_ADMIN_BEFORE_GET_ITEM <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_BEFORE_GET_ITEM', + CFactory::_('Customcode.Dispenser')->get( + CFactory::_('Config')->build_target . '_php_before_getitem', + $view['settings']->code, '', null, true + ) + ); + + // CUSTOM_ADMIN_GET_ITEM <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_GET_ITEM', + $this->setCustomViewGetItem( + $view['settings']->main_get, + $view['settings']->code, Indent::_(2) + ) + ); + + // CUSTOM_ADMIN_AFTER_GET_ITEM <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_AFTER_GET_ITEM', + CFactory::_('Customcode.Dispenser')->get( + CFactory::_('Config')->build_target . '_php_after_getitem', + $view['settings']->code, '', null, true + ) + ); + } + elseif ($view['settings']->main_get->gettype == 2) + { + // CUSTOM_ADMIN_GET_LIST_QUERY <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_GET_LIST_QUERY', + $this->setCustomViewListQuery( + $view['settings']->main_get, $view['settings']->code + ) + ); + + // CUSTOM_ADMIN_CUSTOM_BEFORE_LIST_QUERY <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_CUSTOM_BEFORE_LIST_QUERY', + CFactory::_('Customcode.Dispenser')->get( + CFactory::_('Config')->build_target . '_php_getlistquery', + $view['settings']->code, PHP_EOL, null, true + ) + ); + + // CUSTOM_ADMIN_BEFORE_GET_ITEMS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_BEFORE_GET_ITEMS', + CFactory::_('Customcode.Dispenser')->get( + CFactory::_('Config')->build_target . '_php_before_getitems', + $view['settings']->code, PHP_EOL, null, true + ) + ); + + // CUSTOM_ADMIN_GET_ITEMS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_GET_ITEMS', + $this->setCustomViewGetItems( + $view['settings']->main_get, $view['settings']->code + ) + ); + + // CUSTOM_ADMIN_AFTER_GET_ITEMS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_AFTER_GET_ITEMS', + CFactory::_('Customcode.Dispenser')->get( + CFactory::_('Config')->build_target . '_php_after_getitems', + $view['settings']->code, PHP_EOL, null, true + ) + ); + } + + // CUSTOM_ADMIN_CUSTOM_METHODS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_CUSTOM_METHODS', + $this->setCustomViewCustomItemMethods( + $view['settings']->main_get, $view['settings']->code + ) + ); + CFactory::_('Compiler.Builder.Content.Multi')->add($view['settings']->code . '|CUSTOM_ADMIN_CUSTOM_METHODS', + $this->setCustomViewCustomMethods( + $view, $view['settings']->code + ). false + ); + // CUSTOM_ADMIN_DIPLAY_METHOD <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_DIPLAY_METHOD', + $this->setCustomViewDisplayMethod($view) + ); + // set document details + $this->setPrepareDocument($view); + // CUSTOM_ADMIN_EXTRA_DIPLAY_METHODS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_EXTRA_DIPLAY_METHODS', + $this->setCustomViewExtraDisplayMethods($view) + ); + // CUSTOM_ADMIN_CODE_BODY <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_CODE_BODY', + $this->setCustomViewCodeBody($view) + ); + // CUSTOM_ADMIN_BODY <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_BODY', + $this->setCustomViewBody($view) + ); + // CUSTOM_ADMIN_SUBMITBUTTON_SCRIPT <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_SUBMITBUTTON_SCRIPT', + $this->setCustomViewSubmitButtonScript($view) + ); + + // setup the templates + $this->setCustomViewTemplateBody($view); + + // set the site form if needed + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_TOP_FORM', + $this->setCustomViewForm( + $view['settings']->code, + $view['settings']->main_get->gettype, 1 + ) + ); + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_BOTTOM_FORM', + $this->setCustomViewForm( + $view['settings']->code, + $view['settings']->main_get->gettype, 2 + ) + ); + + // set headers based on the main get type + if ($view['settings']->main_get->gettype == 1) + { + // CUSTOM_ADMIN_VIEW_CONTROLLER_HEADER <<>> add the header details for the controller + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_VIEW_CONTROLLER_HEADER', + CFactory::_('Header')->get( + 'custom.admin.view.controller', + $view['settings']->code + ) + ); + // CUSTOM_ADMIN_VIEW_MODEL_HEADER <<>> add the header details for the model + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_VIEW_MODEL_HEADER', + CFactory::_('Header')->get( + 'custom.admin.view.model', $view['settings']->code + ) + ); + // CUSTOM_ADMIN_VIEW_HTML_HEADER <<>> add the header details for the view + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_VIEW_HTML_HEADER', + CFactory::_('Header')->get( + 'custom.admin.view.html', $view['settings']->code + ) + ); + // CUSTOM_ADMIN_VIEW_HEADER <<>> add the header details for the view + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_VIEW_HEADER', + CFactory::_('Header')->get( + 'custom.admin.view', $view['settings']->code + ) + ); + } + elseif ($view['settings']->main_get->gettype == 2) + { + // CUSTOM_ADMIN_VIEWS_CONTROLLER_HEADER <<>> add the header details for the controller + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_VIEWS_CONTROLLER_HEADER', + CFactory::_('Header')->get( + 'custom.admin.views.controller', + $view['settings']->code + ) + ); + // CUSTOM_ADMIN_VIEWS_MODEL_HEADER <<>> add the header details for the model + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_VIEWS_MODEL_HEADER', + CFactory::_('Header')->get( + 'custom.admin.views.model', $view['settings']->code + ) + ); + // CUSTOM_ADMIN_VIEWS_HTML_HEADER <<>> add the header details for the view + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_VIEWS_HTML_HEADER', + CFactory::_('Header')->get( + 'custom.admin.views.html', $view['settings']->code + ) + ); + // CUSTOM_ADMIN_VIEWS_HEADER <<>> add the header details for the view + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|CUSTOM_ADMIN_VIEWS_HEADER', + CFactory::_('Header')->get( + 'custom.admin.views', $view['settings']->code + ) + ); + } + + // Trigger Event: jcb_ce_onAfterBuildCustomAdminViewContent + CFactory::_('Event')->trigger( + 'jcb_ce_onAfterBuildCustomAdminViewContent', [&$view, &$view['settings']->code] + ); + } + + // setup the layouts + $this->setCustomViewLayouts(); + } + + // ADMIN_HELPER_CLASS_HEADER + CFactory::_('Compiler.Builder.Content.One')->set('ADMIN_HELPER_CLASS_HEADER', + CFactory::_('Header')->get( + 'admin.helper', 'admin' + )); + + // ADMIN_COMPONENT_HEADER + CFactory::_('Compiler.Builder.Content.One')->set('ADMIN_COMPONENT_HEADER', + CFactory::_('Header')->get( + 'admin.component', 'admin' + )); + + // SITE_HELPER_CLASS_HEADER + CFactory::_('Compiler.Builder.Content.One')->set('SITE_HELPER_CLASS_HEADER', + CFactory::_('Header')->get( + 'site.helper', 'site' + )); + + // SITE_COMPONENT_HEADER + CFactory::_('Compiler.Builder.Content.One')->set('SITE_COMPONENT_HEADER', + CFactory::_('Header')->get( + 'site.component', 'site' + )); + + // SITE_ROUTER_HEADER (Joomla 4 and above) + CFactory::_('Compiler.Builder.Content.One')->set('SITE_ROUTER_HEADER', + CFactory::_('Header')->get( + 'site.router', 'site' + )); + + // HELPER_EXEL + CFactory::_('Compiler.Builder.Content.One')->set('HELPER_EXEL', $this->setHelperExelMethods()); + + // VIEWARRAY + CFactory::_('Compiler.Builder.Content.One')->set('VIEWARRAY', + PHP_EOL . implode("," . PHP_EOL, $viewarray) + ); + + // CUSTOM_ADMIN_EDIT_VIEW_ARRAY + CFactory::_('Compiler.Builder.Content.One')->set('SITE_EDIT_VIEW_ARRAY', + PHP_EOL . implode("," . PHP_EOL, $site_edit_view_array) + ); + + // MAINMENUS + CFactory::_('Compiler.Builder.Content.One')->set('MAINMENUS', $this->setMainMenus()); + + // SUBMENU + CFactory::_('Compiler.Builder.Content.One')->set('SUBMENU', $this->setSubMenus()); + + // GET_CRYPT_KEY + CFactory::_('Compiler.Builder.Content.One')->set('GET_CRYPT_KEY', $this->setGetCryptKey()); + + // set the license locker + $this->setLockLicense(); + + // CONTRIBUTORS + CFactory::_('Compiler.Builder.Content.One')->set('CONTRIBUTORS', + CFactory::_('Compiler.Builder.Contributors')->get('bom', '') + ); + + // INSTALL + CFactory::_('Compiler.Builder.Content.One')->set('INSTALL', $this->setInstall()); + + // UNINSTALL + CFactory::_('Compiler.Builder.Content.One')->set('UNINSTALL', $this->setUninstall()); + + // UPDATE_VERSION_MYSQL + $this->setVersionController(); + + // only set these if default dashboard it used + if (!CFactory::_('Registry')->get('build.dashboard')) + { + // DASHBOARDVIEW + CFactory::_('Compiler.Builder.Content.One')->set('DASHBOARDVIEW', + CFactory::_('Config')->component_code_name + ); + + // DASHBOARDICONS + CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '|DASHBOARDICONS', + $this->setDashboardIcons() + ); + + // DASHBOARDICONACCESS + CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '|DASHBOARDICONACCESS', + $this->setDashboardIconAccess() + ); + + // DASH_MODEL_METHODS + CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '|DASH_MODEL_METHODS', + $this->setDashboardModelMethods() + ); + + // DASH_GET_CUSTOM_DATA + CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '|DASH_GET_CUSTOM_DATA', + $this->setDashboardGetCustomData() + ); + + // DASH_DISPLAY_DATA + CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '|DASH_DISPLAY_DATA', + $this->setDashboardDisplayData() + ); + + // DASH_VIEW_HEADER + CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '|DASH_VIEW_HEADER', + CFactory::_('Header')->get('dashboard.view', 'dashboard') + ); + // DASH_VIEW_HTML_HEADER + CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '|DASH_VIEW_HTML_HEADER', + CFactory::_('Header')->get('dashboard.view.html', 'dashboard') + ); + // DASH_MODEL_HEADER + CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '|DASH_MODEL_HEADER', + CFactory::_('Header')->get('dashboard.model', 'dashboard') + ); + // DASH_CONTROLLER_HEADER + CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '|DASH_CONTROLLER_HEADER', + CFactory::_('Header')->get('dashboard.controller', 'dashboard') + ); + } + else + { + // DASHBOARDVIEW + CFactory::_('Compiler.Builder.Content.One')->set('DASHBOARDVIEW', + CFactory::_('Registry')->get('build.dashboard') + ); + } + + // add import + if (CFactory::_('Config')->get('add_eximport', false)) + { + // setup import files + $target = array('admin' => 'import'); + CFactory::_('Utilities.Structure')->build($target, 'import'); + // IMPORT_EXT_METHOD <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set('import' . '|IMPORT_EXT_METHOD', + PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( + ComponentbuilderHelper::getDynamicScripts('ext') + ) + ); + // IMPORT_SETDATA_METHOD <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set('import' . '|IMPORT_SETDATA_METHOD', + PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( + ComponentbuilderHelper::getDynamicScripts('setdata') + ) + ); + // IMPORT_SAVE_METHOD <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set('import' . '|IMPORT_SAVE_METHOD', + PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( + ComponentbuilderHelper::getDynamicScripts('save') + ) + ); + // IMPORT_CONTROLLER_HEADER <<>> add the header details for the controller + CFactory::_('Compiler.Builder.Content.Multi')->set('import' . '|IMPORT_CONTROLLER_HEADER', + CFactory::_('Header')->get( + 'import.controller', 'import' + ) + ); + // IMPORT_MODEL_HEADER <<>> add the header details for the model + CFactory::_('Compiler.Builder.Content.Multi')->set('import' . '|IMPORT_MODEL_HEADER', + CFactory::_('Header')->get( + 'import.model', 'import' + ) + ); + } + + // ensure that the ajax model and controller is set if needed + if (CFactory::_('Config')->get('add_ajax', false)) + { + // setup Ajax files + $target = array('admin' => 'ajax'); + CFactory::_('Utilities.Structure')->build($target, 'ajax'); + // set the controller + CFactory::_('Compiler.Builder.Content.Multi')->set('ajax' . '|REGISTER_AJAX_TASK', + $this->setRegisterAjaxTask('admin') + ); + CFactory::_('Compiler.Builder.Content.Multi')->set('ajax' . '|AJAX_INPUT_RETURN', + $this->setAjaxInputReturn('admin') + ); + // set the model header + CFactory::_('Compiler.Builder.Content.Multi')->set('ajax' . '|AJAX_ADMIN_MODEL_HEADER', + CFactory::_('Header')->get('ajax.admin.model', 'ajax') + ); + // set the module + CFactory::_('Compiler.Builder.Content.Multi')->set('ajax' . '|AJAX_MODEL_METHODS', + $this->setAjaxModelMethods('admin') + ); + } + + // ensure that the site ajax model and controller is set if needed + if (CFactory::_('Config')->get('add_site_ajax', false)) + { + // setup Ajax files + $target = array('site' => 'ajax'); + CFactory::_('Utilities.Structure')->build($target, 'ajax'); + // set the controller + CFactory::_('Compiler.Builder.Content.Multi')->set('ajax' . '|REGISTER_SITE_AJAX_TASK', + $this->setRegisterAjaxTask('site') + ); + CFactory::_('Compiler.Builder.Content.Multi')->set('ajax' . '|AJAX_SITE_INPUT_RETURN', + $this->setAjaxInputReturn('site') + ); + // set the model header + CFactory::_('Compiler.Builder.Content.Multi')->set('ajax' . '|AJAX_SITE_MODEL_HEADER', + CFactory::_('Header')->get('ajax.site.model', 'ajax') + ); + // set the module + CFactory::_('Compiler.Builder.Content.Multi')->set('ajax' . '|AJAX_SITE_MODEL_METHODS', + $this->setAjaxModelMethods('site') + ); + } + + // build the validation rules + if (($validationRules = CFactory::_('Registry')->_('validation.rules')) !== null) + { + foreach ($validationRules as $rule => $_php) + { + // setup rule file + $target = array('admin' => 'a_rule_zi'); + CFactory::_('Utilities.Structure')->build($target, 'rule', $rule); + // set the JFormRule Name + CFactory::_('Compiler.Builder.Content.Multi')->set('a_rule_zi_' . $rule . '|Name', + ucfirst((string) $rule) + ); + // set the JFormRule PHP + CFactory::_('Compiler.Builder.Content.Multi')->set('a_rule_zi_' . $rule . '|VALIDATION_RULE_METHODS', + PHP_EOL . $_php + ); + } + } + + // run the second run if needed + if (isset($this->secondRunAdmin) + && ArrayHelper::check($this->secondRunAdmin)) + { + // start dynamic build + foreach ($this->secondRunAdmin as $function => $arrays) + { + if (ArrayHelper::check($arrays) + && StringHelper::check($function)) + { + foreach ($arrays as $array) + { + $this->{$function}($array); + } + } + } + } + + // CONFIG_FIELDSETS + $keepLang = CFactory::_('Config')->lang_target; + CFactory::_('Config')->lang_target = 'admin'; + // run field sets for second time + CFactory::_('Compiler.Creator.Config.Fieldsets')->set(2); + CFactory::_('Config')->lang_target = $keepLang; + + // setup front-views and all needed stuff for the site + if (CFactory::_('Component')->isArray('site_views')) + { + CFactory::_('Config')->build_target = 'site'; + // start dynamic build + foreach (CFactory::_('Component')->get('site_views') as $view) + { + // for list views + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SViews', + $view['settings']->Code + ); + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|sviews', + $view['settings']->code + ); + // for single views + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SView', + $view['settings']->Code + ); + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|sview', + $view['settings']->code + ); + + // set placeholders + CFactory::_('Placeholder')->set('SView', $view['settings']->Code); + CFactory::_('Placeholder')->set('sview', $view['settings']->code); + CFactory::_('Placeholder')->set('SVIEW', $view['settings']->CODE); + + CFactory::_('Placeholder')->set('SViews', $view['settings']->Code); + CFactory::_('Placeholder')->set('sviews', $view['settings']->code); + CFactory::_('Placeholder')->set('SVIEWS', $view['settings']->CODE); + + // Trigger Event: jcb_ce_onBeforeBuildSiteViewContent + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeBuildSiteViewContent', [&$view, &$view['settings']->code] + ); + + // set license per view if needed + $this->setLockLicensePer( + $view['settings']->code, CFactory::_('Config')->build_target + ); + + // set the site default view + if (isset($view['default_view']) + && $view['default_view'] == 1) + { + CFactory::_('Compiler.Builder.Content.One')->set('SITE_DEFAULT_VIEW', + $view['settings']->code + ); + } + // add site menu + if (isset($view['menu']) && $view['menu'] == 1) + { + // SITE_MENU_XML <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_MENU_XML', + $this->setCustomViewMenu($view) + ); + } + + // insure the needed route helper is loaded + CFactory::_('Compiler.Builder.Content.One')->add('ROUTEHELPER', + $this->setRouterHelp( + $view['settings']->code, $view['settings']->code, true + )); + // build route details + CFactory::_('Compiler.Builder.Content.One')->add('ROUTER_PARSE_SWITCH', + $this->routerParseSwitch( + $view['settings']->code, $view + )); + CFactory::_('Compiler.Builder.Content.One')->add('ROUTER_BUILD_VIEWS', + $this->routerBuildViews($view['settings']->code) + ); + + if ($view['settings']->main_get->gettype == 1) + { + // set user permission access check USER_PERMISSION_CHECK_ACCESS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|USER_PERMISSION_CHECK_ACCESS', + $this->setUserPermissionCheckAccess($view, 1) + ); + + // SITE_BEFORE_GET_ITEM <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_BEFORE_GET_ITEM', + CFactory::_('Customcode.Dispenser')->get( + CFactory::_('Config')->build_target . '_php_before_getitem', + $view['settings']->code, '', null, true + ) + ); + + // SITE_GET_ITEM <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_GET_ITEM', + $this->setCustomViewGetItem( + $view['settings']->main_get, + $view['settings']->code, Indent::_(2) + ) + ); + + // SITE_AFTER_GET_ITEM <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_AFTER_GET_ITEM', + CFactory::_('Customcode.Dispenser')->get( + CFactory::_('Config')->build_target . '_php_after_getitem', + $view['settings']->code, '', null, true + ) + ); + } + elseif ($view['settings']->main_get->gettype == 2) + { + // set user permission access check USER_PERMISSION_CHECK_ACCESS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|USER_PERMISSION_CHECK_ACCESS', + $this->setUserPermissionCheckAccess($view, 2) + ); + // SITE_GET_LIST_QUERY <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_GET_LIST_QUERY', + $this->setCustomViewListQuery( + $view['settings']->main_get, $view['settings']->code + ) + ); + + // SITE_BEFORE_GET_ITEMS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_BEFORE_GET_ITEMS', CFactory::_('Customcode.Dispenser')->get( + CFactory::_('Config')->build_target . '_php_before_getitems', + $view['settings']->code, PHP_EOL, null, true + )); + + // SITE_GET_ITEMS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_GET_ITEMS', + $this->setCustomViewGetItems( + $view['settings']->main_get, $view['settings']->code + ) + ); + + // SITE_AFTER_GET_ITEMS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_AFTER_GET_ITEMS', + CFactory::_('Customcode.Dispenser')->get( + CFactory::_('Config')->build_target . '_php_after_getitems', + $view['settings']->code, PHP_EOL, null, true + ) + ); + } + // add to lang array + CFactory::_('Language')->set( + 'site', + CFactory::_('Config')->lang_prefix . '_' . $view['settings']->CODE, + $view['settings']->name + ); + CFactory::_('Language')->set( + 'site', + CFactory::_('Config')->lang_prefix . '_' . $view['settings']->CODE + . '_DESC', $view['settings']->description + ); + // SITE_CUSTOM_METHODS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_CUSTOM_METHODS', + $this->setCustomViewCustomItemMethods( + $view['settings']->main_get, $view['settings']->code + ) + ); + CFactory::_('Compiler.Builder.Content.Multi')->add($view['settings']->code . '|SITE_CUSTOM_METHODS', + $this->setCustomViewCustomMethods( + $view, $view['settings']->code + ), false + ); + // SITE_DIPLAY_METHOD <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_DIPLAY_METHOD', + $this->setCustomViewDisplayMethod($view) + ); + // set document details + $this->setPrepareDocument($view); + // SITE_EXTRA_DIPLAY_METHODS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_EXTRA_DIPLAY_METHODS', + $this->setCustomViewExtraDisplayMethods($view) + ); + // SITE_CODE_BODY <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_CODE_BODY', + $this->setCustomViewCodeBody($view) + ); + // SITE_BODY <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_BODY', + $this->setCustomViewBody($view) + ); + + // setup the templates + $this->setCustomViewTemplateBody($view); + + // set the site form if needed + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_TOP_FORM', + $this->setCustomViewForm( + $view['settings']->code, + $view['settings']->main_get->gettype, 1 + ) + ); + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_BOTTOM_FORM', + $this->setCustomViewForm( + $view['settings']->code, + $view['settings']->main_get->gettype, 2 + ) + ); + + // set headers based on the main get type + if ($view['settings']->main_get->gettype == 1) + { + // insure the controller headers are added + if (StringHelper::check( + $view['settings']->php_controller + ) + && $view['settings']->php_controller != '//') + { + // SITE_VIEW_CONTROLLER_HEADER <<>> add the header details for the model + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_VIEW_CONTROLLER_HEADER', + CFactory::_('Header')->get( + 'site.view.controller', $view['settings']->code + ) + ); + } + // SITE_VIEW_MODEL_HEADER <<>> add the header details for the model + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_VIEW_MODEL_HEADER', + CFactory::_('Header')->get( + 'site.view.model', $view['settings']->code + ) + ); + // SITE_VIEW_HTML_HEADER <<>> add the header details for the view + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_VIEW_HTML_HEADER', + CFactory::_('Header')->get( + 'site.view.html', $view['settings']->code + ) + ); + // SITE_VIEW_HEADER <<>> add the header details for the view + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_VIEW_HEADER', + CFactory::_('Header')->get( + 'site.view', $view['settings']->code + ) + ); + } + elseif ($view['settings']->main_get->gettype == 2) + { + // insure the controller headers are added + if (StringHelper::check( + $view['settings']->php_controller + ) + && $view['settings']->php_controller != '//') + { + // SITE_VIEW_CONTROLLER_HEADER <<>> add the header details for the model + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_VIEW_CONTROLLER_HEADER', + CFactory::_('Header')->get( + 'site.views.controller', $view['settings']->code + ) + ); + } + // SITE_VIEWS_MODEL_HEADER <<>> add the header details for the model + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_VIEWS_MODEL_HEADER', + CFactory::_('Header')->get( + 'site.views.model', $view['settings']->code + ) + ); + // SITE_VIEWS_HTML_HEADER <<>> add the header details for the view + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_VIEWS_HTML_HEADER', + CFactory::_('Header')->get( + 'site.views.html', $view['settings']->code + ) + ); + // SITE_VIEWS_HEADER <<>> add the header details for the view + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_VIEWS_HEADER', + CFactory::_('Header')->get( + 'site.views', $view['settings']->code + ) + ); + } + + // Trigger Event: jcb_ce_onAfterBuildSiteViewContent + CFactory::_('Event')->trigger( + 'jcb_ce_onAfterBuildSiteViewContent', [&$view, &$view['settings']->code] + ); + } + + // setup the layouts + $this->setCustomViewLayouts(); + } + else + { + // clear all site folder since none is needed + CFactory::_('Config')->remove_site_folder = true; + } + // load the site statics + if (!CFactory::_('Config')->remove_site_folder || !CFactory::_('Config')->remove_site_edit_folder) + { + CFactory::_('Config')->build_target = 'site'; + // if no default site view was set, the redirect to root + if (!CFactory::_('Compiler.Builder.Content.One')->exists('SITE_DEFAULT_VIEW')) + { + CFactory::_('Compiler.Builder.Content.One')->set('SITE_DEFAULT_VIEW', ''); + } + // set site custom script to helper class + // SITE_CUSTOM_HELPER_SCRIPT + CFactory::_('Compiler.Builder.Content.One')->set('SITE_CUSTOM_HELPER_SCRIPT', + CFactory::_('Placeholder')->update_( + CFactory::_('Customcode.Dispenser')->hub['component_php_helper_site'] + )); + // SITE_GLOBAL_EVENT_HELPER + if (!CFactory::_('Compiler.Builder.Content.One')->exists('SITE_GLOBAL_EVENT')) + { + CFactory::_('Compiler.Builder.Content.One')->set('SITE_GLOBAL_EVENT', ''); + } + if (!CFactory::_('Compiler.Builder.Content.One')->exists('SITE_GLOBAL_EVENT_HELPER')) + { + CFactory::_('Compiler.Builder.Content.One')->set('SITE_GLOBAL_EVENT_HELPER', ''); + } + // now load the data for the global event if needed + if (CFactory::_('Component')->get('add_site_event', 0) == 1) + { + CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT', PHP_EOL . PHP_EOL . "//" . Line::_( + __LINE__,__CLASS__ + ) . "Trigger the Global Site Event"); + CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT', + PHP_EOL . CFactory::_('Compiler.Builder.Content.One')->get('Component') + . 'Helper::globalEvent(Factory::getDocument());'); + // SITE_GLOBAL_EVENT_HELPER + CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER', + PHP_EOL . PHP_EOL . Indent::_(1) . '/**' + ); + CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER', + PHP_EOL . Indent::_(1) + . '* The Global Site Event Method.'); + CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER', + PHP_EOL . Indent::_(1) . '**/' + ); + CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER', + PHP_EOL . Indent::_(1) + . 'public static function globalEvent($document)'); + CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER', + PHP_EOL . Indent::_(1) . '{' + ); + CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER', + PHP_EOL . CFactory::_('Placeholder')->update_( + CFactory::_('Customcode.Dispenser')->hub['component_php_site_event'] + )); + CFactory::_('Compiler.Builder.Content.One')->add('SITE_GLOBAL_EVENT_HELPER', + PHP_EOL . Indent::_(1) . '}' + ); + } + } + + // PREINSTALLSCRIPT + CFactory::_('Compiler.Builder.Content.One')->add('PREINSTALLSCRIPT', + CFactory::_('Customcode.Dispenser')->get( + 'php_preflight', 'install', PHP_EOL, null, true + )); + + // PREUPDATESCRIPT + CFactory::_('Compiler.Builder.Content.One')->add('PREUPDATESCRIPT', + CFactory::_('Customcode.Dispenser')->get( + 'php_preflight', 'update', PHP_EOL, null, true + )); + + // POSTINSTALLSCRIPT + CFactory::_('Compiler.Builder.Content.One')->add('POSTINSTALLSCRIPT', $this->setPostInstallScript()); + + // POSTUPDATESCRIPT + CFactory::_('Compiler.Builder.Content.One')->add('POSTUPDATESCRIPT', $this->setPostUpdateScript()); + + // UNINSTALLSCRIPT + CFactory::_('Compiler.Builder.Content.One')->add('UNINSTALLSCRIPT', $this->setUninstallScript()); + + // MOVEFOLDERSSCRIPT + CFactory::_('Compiler.Builder.Content.One')->set('MOVEFOLDERSSCRIPT', $this->setMoveFolderScript()); + + // MOVEFOLDERSMETHOD + CFactory::_('Compiler.Builder.Content.One')->set('MOVEFOLDERSMETHOD', $this->setMoveFolderMethod()); + + // HELPER_UIKIT + CFactory::_('Compiler.Builder.Content.One')->set('HELPER_UIKIT', $this->setUikitHelperMethods()); + + // CONFIG_FIELDSETS + CFactory::_('Compiler.Builder.Content.One')->set('CONFIG_FIELDSETS', + implode(PHP_EOL, + CFactory::_('Compiler.Builder.Config.Fieldsets')->get('component', []) + ) + ); + + // check if this has been set + if (!CFactory::_('Compiler.Builder.Content.One')->exists('ROUTER_BUILD_VIEWS') + || !StringHelper::check( + CFactory::_('Compiler.Builder.Content.One')->get('ROUTER_BUILD_VIEWS') + )) + { + CFactory::_('Compiler.Builder.Content.One')->set('ROUTER_BUILD_VIEWS', 0); + } + else + { + CFactory::_('Compiler.Builder.Content.One')->set('ROUTER_BUILD_VIEWS', + '(' . CFactory::_('Compiler.Builder.Content.One')->get('ROUTER_BUILD_VIEWS') . ')' + ); + } + + // README + if (CFactory::_('Component')->get('addreadme')) + { + CFactory::_('Compiler.Builder.Content.One')->set('README', + CFactory::_('Component')->get('readme') + ); + } + + // CHANGELOG + if (($changelog = CFactory::_('Component')->get('changelog')) !== null) + { + CFactory::_('Compiler.Builder.Content.One')->set('CHANGELOG', $changelog); + } + + // ROUTER + if (CFactory::_('Config')->get('joomla_version', 3) != 3) + { + // build route constructor before parent call + CFactory::_('Compiler.Builder.Content.One')->set('SITE_ROUTER_CONSTRUCTOR_BEFORE_PARENT', + CFactory::_('Compiler.Creator.Router')->getConstructor() + ); + // build route constructor after parent call + CFactory::_('Compiler.Builder.Content.One')->set('SITE_ROUTER_CONSTRUCTOR_AFTER_PARENT', + CFactory::_('Compiler.Creator.Router')->getConstructorAfterParent() + ); + // build route methods + CFactory::_('Compiler.Builder.Content.One')->set('SITE_ROUTER_METHODS', + CFactory::_('Compiler.Creator.Router')->getMethods() + ); + } + + // tweak system to set stuff to the module domain + $_backup_target = CFactory::_('Config')->build_target; + $_backup_lang = CFactory::_('Config')->lang_target; + $_backup_langPrefix = CFactory::_('Config')->lang_prefix; + // infuse module data if set + if (CFactory::_('Joomlamodule.Data')->exists()) + { + foreach (CFactory::_('Joomlamodule.Data')->get() as $module) + { + if (ObjectHelper::check($module)) + { + // Trigger Event: jcb_ce_onBeforeInfuseModuleData + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeInfuseModuleData', [&$module] + ); + + CFactory::_('Config')->build_target = $module->key; + CFactory::_('Config')->lang_target = $module->key; + $this->langPrefix = $module->lang_prefix; + CFactory::_('Config')->set('lang_prefix', $module->lang_prefix); + // MODCODE + CFactory::_('Compiler.Builder.Content.Multi')->set($module->key . '|MODCODE', + $this->getModCode($module) + ); + // DYNAMICGET + CFactory::_('Compiler.Builder.Content.Multi')->set($module->key . '|DYNAMICGETS', + $this->setCustomViewCustomMethods( + $module, $module->key + ) + ); + // HELPERCODE + if ($module->add_class_helper >= 1) + { + CFactory::_('Compiler.Builder.Content.Multi')->set($module->key . '|HELPERCODE', + $this->getModHelperCode($module) + ); + } + // MODDEFAULT + CFactory::_('Compiler.Builder.Content.Multi')->set($module->key . '|MODDEFAULT', + $this->getModDefault($module, $module->key) + ); + // MODDEFAULT_XXX + $this->setModTemplates($module); + // only add install script if needed + if ($module->add_install_script) + { + // INSTALLCLASS + CFactory::_('Compiler.Builder.Content.Multi')->set($module->key . '|INSTALLCLASS', + CFactory::_('Extension.InstallScript')->get($module) + ); + } + // FIELDSET + if (isset($module->form_files) + && ArrayHelper::check( + $module->form_files + )) + { + foreach ($module->form_files as $file => $files) + { + foreach ($files as $field_name => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + // FIELDSET_ . $file.$field_name.$fieldset + CFactory::_('Compiler.Builder.Content.Multi')->set($module->key . + '|FIELDSET_' . $file . $field_name . $fieldset, + $this->getExtensionFieldsetXML( + $module, $fields + ) + ); + } + } + } + } + // MAINXML + CFactory::_('Compiler.Builder.Content.Multi')->set($module->key . '|MAINXML', + $this->getModuleMainXML($module) + ); + // Trigger Event: jcb_ce_onAfterInfuseModuleData + CFactory::_('Event')->trigger( + 'jcb_ce_onAfterInfuseModuleData', [&$module] + ); + } + } + } + // infuse plugin data if set + if (CFactory::_('Joomlaplugin.Data')->exists()) + { + foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin) + { + if (ObjectHelper::check($plugin)) + { + // Trigger Event: jcb_ce_onBeforeInfusePluginData + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeInfusePluginData', [&$plugin] + ); + + CFactory::_('Config')->build_target = $plugin->key; + CFactory::_('Config')->lang_target = $plugin->key; + $this->langPrefix = $plugin->lang_prefix; + CFactory::_('Config')->set('lang_prefix', $plugin->lang_prefix); + // MAINCLASS + CFactory::_('Compiler.Builder.Content.Multi')->set($plugin->key . '|MAINCLASS', + $this->getPluginMainClass($plugin) + ); + // only add install script if needed + if ($plugin->add_install_script) + { + // INSTALLCLASS + CFactory::_('Compiler.Builder.Content.Multi')->set($plugin->key . '|INSTALLCLASS', + CFactory::_('Extension.InstallScript')->get($plugin) + ); + } + // FIELDSET + if (isset($plugin->form_files) + && ArrayHelper::check( + $plugin->form_files + )) + { + foreach ($plugin->form_files as $file => $files) + { + foreach ($files as $field_name => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + // FIELDSET_ . $file.$field_name.$fieldset + CFactory::_('Compiler.Builder.Content.Multi')->set($plugin->key . + '|FIELDSET_' . $file . $field_name . $fieldset, + $this->getExtensionFieldsetXML( + $plugin, $fields + ) + ); + } + } + } + } + // MAINXML + CFactory::_('Compiler.Builder.Content.Multi')->set($plugin->key . '|MAINXML', + $this->getPluginMainXML($plugin) + ); + // Trigger Event: jcb_ce_onAfterInfusePluginData + CFactory::_('Event')->trigger( + 'jcb_ce_onAfterInfusePluginData', [&$plugin] + ); + } + } + } + // rest globals + CFactory::_('Config')->build_target = $_backup_target; + CFactory::_('Config')->lang_target = $_backup_lang; + $this->langPrefix = $_backup_langPrefix; + CFactory::_('Config')->set('lang_prefix', $_backup_langPrefix); + + // Trigger Event: jcb_ce_onAfterBuildFilesContent + CFactory::_('Event')->trigger( + 'jcb_ce_onAfterBuildFilesContent' + ); + return true; + } + + return false; + } + + /** + * Set the view place holders to global scope + * + * @param object $view The view settings + * + * @ return void + */ + protected function setViewPlaceholders(&$view) + { + // just to be safe, lets clear previous view placeholders + CFactory::_('Placeholder')->clearType('view'); + CFactory::_('Placeholder')->clearType('views'); + + // VIEW <<>> + if (isset($view->name_single) && $view->name_single != 'null') + { + // set main keys + $nameSingleCode = $view->name_single_code; + $name_single_uppercase = StringHelper::safe( + $view->name_single, 'U' + ); + $name_single_first_uppercase = StringHelper::safe( + $view->name_single, 'F' + ); + + // set some place holder for the views + CFactory::_('Placeholder')->set('view', $nameSingleCode); + CFactory::_('Placeholder')->set('View', $name_single_first_uppercase); + CFactory::_('Placeholder')->set('VIEW', $name_single_uppercase); + } + + // VIEWS <<>> + if (isset($view->name_list) && $view->name_list != 'null') + { + $nameListCode = $view->name_list_code; + $name_list_uppercase = StringHelper::safe( + $view->name_list, 'U' + ); + $name_list_first_uppercase = StringHelper::safe( + $view->name_list, 'F' + ); + + // set some place holder for the views + CFactory::_('Placeholder')->set('views', $nameListCode); + CFactory::_('Placeholder')->set('Views', $name_list_first_uppercase); + CFactory::_('Placeholder')->set('VIEWS', $name_list_uppercase); + } + + // view <<>> + if (isset($nameSingleCode)) + { + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|view', $nameSingleCode); + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|VIEW', $name_single_uppercase); + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|View', $name_single_first_uppercase); + + if (isset($nameListCode)) + { + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|view', $nameSingleCode); + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|VIEW', $name_single_uppercase); + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|View', $name_single_first_uppercase); + } + } + + // views <<>> + if (isset($nameListCode)) + { + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|views', $nameListCode); + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|VIEWS', $name_list_uppercase); + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|Views', $name_list_first_uppercase); + + if (isset($nameSingleCode)) + { + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|views', $nameListCode); + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|VIEWS', $name_list_uppercase); + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|Views', $name_list_first_uppercase); + } + } + } + + /** + * Build the language values and insert into file + * + * @return void + */ + public function setLangFileData(): void + { + // add final list of needed lang strings + $componentName = CFactory::_('Component')->get('name'); + $componentName = OutputFilter::cleanText($componentName); + + // Trigger Event: jcb_ce_onBeforeLoadingAllLangStrings + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeLoadingAllLangStrings', [&$componentName] + ); + + // reset values + $values = []; + $mainLangLoader = []; + // check the admin lang is set + if ($this->setLangAdmin($componentName)) + { + $values[] = array_values( + $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['admin'] + ); + $mainLangLoader['admin'] = count( + $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['admin'] + ); + } + // check the admin system lang is set + if ($this->setLangAdminSys()) + { + $values[] = array_values( + $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['adminsys'] + ); + $mainLangLoader['adminsys'] = count( + $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['adminsys'] + ); + } + // check the site lang is set + if ((!CFactory::_('Config')->remove_site_folder || !CFactory::_('Config')->remove_site_edit_folder) + && $this->setLangSite($componentName)) + { + $values[] = array_values( + $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['site'] + ); + $mainLangLoader['site'] = count( + $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['site'] + ); + } + // check the site system lang is set + if ((!CFactory::_('Config')->remove_site_folder || !CFactory::_('Config')->remove_site_edit_folder) + && $this->setLangSiteSys($componentName)) + { + $values[] = array_values( + $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['sitesys'] + ); + $mainLangLoader['sitesys'] = count( + $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['sitesys'] + ); + } + $values = array_unique(ArrayHelper::merge($values)); + // get the other lang strings if there is any + $this->multiLangString = $this->getMultiLangStrings($values); + // update insert the current lang in to DB + $this->setLangPlaceholders($values, CFactory::_('Config')->component_id); + // remove old unused language strings + $this->purgeLanuageStrings($values, CFactory::_('Config')->component_id); + // path to INI file + $getPAth = CFactory::_('Utilities.Paths')->template_path . '/en-GB.com_admin.ini'; + + // Trigger Event: jcb_ce_onBeforeBuildAllLangFiles + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeBuildAllLangFiles', [&$this->languages['components']] + ); + + // now we insert the values into the files + if (ArrayHelper::check($this->languages['components'])) + { + // rest xml array + $langXML = []; + foreach ($this->languages['components'] as $tag => $areas) + { + // trim the tag + $tag = trim((string) $tag); + foreach ($areas as $area => $languageStrings) + { + // set naming convention + $p = 'admin'; + $t = ''; + if (strpos((string) $area, 'site') !== false) + { + if (CFactory::_('Config')->remove_site_folder + && CFactory::_('Config')->remove_site_edit_folder) + { + continue; + } + $p = 'site'; + } + if (strpos((string) $area, 'sys') !== false) + { + $t = '.sys'; + } + // build the file name + $file_name = $tag . '.com_' . CFactory::_('Config')->component_code_name . $t + . '.ini'; + // check if language should be added + if ($this->shouldLanguageBeAdded( + $tag, $languageStrings, $mainLangLoader[$area], + $file_name + )) + { + // build the path to place the lang file + $path = CFactory::_('Utilities.Paths')->component_path . '/' . $p . '/language/' + . $tag . '/'; + if (!Folder::exists($path)) + { + Folder::create($path); + // count the folder created + CFactory::_('Utilities.Counter')->folder++; + } + // move the file to its place + File::copy($getPAth, $path . $file_name); + // count the file created + CFactory::_('Utilities.Counter')->file++; + // add content to it + $lang = array_map( + fn($langstring, $placeholder) => $placeholder . '="' . $langstring . '"', + array_values($languageStrings), + array_keys($languageStrings) + ); + // add to language file + CFactory::_('Utilities.File')->write( + $path . $file_name, implode(PHP_EOL, $lang) + ); + // set the line counter + CFactory::_('Utilities.Counter')->line += count( + (array) $lang + ); + unset($lang); + // build xml strings + if (!isset($langXML[$p])) + { + $langXML[$p] = []; + } + $langXML[$p][] = 'language/' + . $tag . '/' . $file_name . ''; + } + } + } + // load the lang xml + if (ArrayHelper::check($langXML)) + { + $replace = []; + if (isset($langXML['admin']) + && ArrayHelper::check($langXML['admin'])) + { + $replace[Placefix::_h('ADMIN_LANGUAGES')] + = implode(PHP_EOL . Indent::_(3), $langXML['admin']); + } + if ((!CFactory::_('Config')->remove_site_folder || !CFactory::_('Config')->remove_site_edit_folder) + && isset($langXML['site']) + && ArrayHelper::check($langXML['site'])) + { + $replace[Placefix::_h('SITE_LANGUAGES')] + = implode(PHP_EOL . Indent::_(2), $langXML['site']); + } + // build xml path + $xmlPath = CFactory::_('Utilities.Paths')->component_path . '/' . CFactory::_('Config')->component_code_name + . '.xml'; + // get the content in xml + $componentXML = FileHelper::getContent( + $xmlPath + ); + // update the xml content + $componentXML = CFactory::_('Placeholder')->update($componentXML, $replace); + // store the values back to xml + CFactory::_('Utilities.File')->write($xmlPath, $componentXML); + } + } + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Interpretation.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Interpretation.php new file mode 100644 index 000000000..1fffe1db4 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Interpretation.php @@ -0,0 +1,23808 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Helper; + + +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Filesystem\Folder; +use Joomla\CMS\Language\Text; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\FOF\Encrypt\AES; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Utilities\FileHelper; +use VDM\Joomla\Utilities\MathHelper; +use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Minify; +use VDM\Joomla\Componentbuilder\Compiler\Helper\Fields; + + +/** + * Interpretation class + * + * @deprecated 3.3 + */ +class Interpretation extends Fields +{ + /** + * The global config Field Sets + * + * @var array + * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Config.Fieldsets')->add($key, $value); + */ + public $configFieldSets = []; + + /** + * The global config Field Sets Custom Fields + * + * @var array + * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Config.Fieldsets.Customfield')->add($key, $value); + */ + public $configFieldSetsCustomField = []; + + /** + * The contributors + * + * @var string + */ + public $theContributors = ''; + + /** + * The unistall builder + * + * @var array + * @deprecated 3.3 Use CFactory::_('Builder.Database.Uninstall')->set(...); + */ + public $uninstallBuilder = []; + + /** + * The update SQL builder + * + * @var array + * @deprecated 3.3 Use CFactory::_('Model.Updatesql')->set($old, $new, string $type, $key = null, ?array $ignore = null); + */ + public $updateSQLBuilder = []; + + /** + * The List Column Builder + * + * @var array + */ + public $listColnrBuilder = []; + + /** + * The permissions Builder + * + * @var array + * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Permission.Action')->set($action, $nameView, $nameView); + * @deprecated 3.3 or Use CFactory::_('Compiler.Builder.Permission.Global')->set($action, $nameView, $nameView); + */ + public $permissionBuilder = []; + + /** + * The dashboard permissions builder + * + * @var array + * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Permission.Dashboard')->add('icon', $key, $value) + */ + public $permissionDashboard = []; + + /** + * The permissions core + * + * @var array + * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Permission.Core')->set($nameView, $coreTarget, $action); + */ + public $permissionCore = []; + + /** + * The customs field builder + * + * @var array + */ + public $customFieldBuilder = []; + + /** + * The category builder + * + * @var array + */ + public $buildCategories = []; + + /** + * The icon builder + * + * @var array + */ + public $iconBuilder = []; + + /** + * The validation fix builder + * + * @var array + */ + public $validationFixBuilder = []; + + /** + * The view script builder + * + * @var array + */ + public $viewScriptBuilder = []; + + /** + * The target relation control + * + * @var array + */ + public $targetRelationControl = []; + + /** + * The target control script checker + * + * @var array + */ + public $targetControlsScriptChecker = []; + + /** + * The router helper + * + * @var array + */ + public $setRouterHelpDone = []; + + /** + * The other where + * + * @var array + */ + public $otherWhere = []; + + /** + * The dashboard get custom data + * + * @var array + */ + public $DashboardGetCustomData = []; + + /** + * The custom admin added + * + * @var array + */ + public $customAdminAdded = []; + + /** + * Switch to add form to views + * + * @var array + */ + public $addCustomForm = []; + + /** + * The extensions params + * + * @var array + * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Extensions.Params') + */ + protected $extensionsParams = []; + + /** + * The asset rules + * + * @var array + * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Assets.Rules') + */ + public $assetsRules = []; + + /** + * View Has Category Request + * + * @var array + * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Request')->get("catid.$key") + */ + protected $hasCatIdRequest = []; + + /** + * All fields with permissions + * + * @var array + * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Permission.Fields') + */ + public $permissionFields = []; + + /** + * Custom Admin View List Link + * + * @var array + */ + protected $customAdminViewListLink = []; + + /** + * load Tracker of fields to fix + * + * @var array + */ + protected $loadTracker = []; + + /** + * View Has Id Request + * + * @var array + * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Request')->get("id.$key") + */ + protected $hasIdRequest = []; + + /** + * Library warning + * + * @var array + * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Library.Warning') + */ + protected $libwarning = []; + + /** + * Language message bucket + * + * @var array + * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Language.Messages') + */ + public $langNot = []; + + /** + * Language message bucket + * + * @var array + * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Language.Messages') + */ + public $langSet = []; + + /** + * alignment names + * + * @var array + */ + protected $alignmentOptions + = array(1 => 'left', 2 => 'right', 3 => 'fullwidth', 4 => 'above', + 5 => 'under', 6 => 'leftside', 7 => 'rightside'); + + /** + * Constructor + */ + public function __construct() + { + // first we run the parent constructor + if (parent::__construct()) + { + return true; + } + + return false; + } + + /** + * add email helper + */ + public function addEmailHelper() + { + if (CFactory::_('Component')->get('add_email_helper')) + { + // set email helper in place with component name + $component = CFactory::_('Config')->component_code_name; + $Component = CFactory::_('Compiler.Builder.Content.One')->get('Component'); + $target = array('admin' => 'emailer'); + $done = CFactory::_('Utilities.Structure')->build($target, 'emailer', $component); + if ($done) + { + // the text for the file BAKING + CFactory::_('Compiler.Builder.Content.Multi')->set('emailer_' . $component . '|BAKING', ''); // <<-- to insure it gets updated + // return the code need to load the abstract class + return PHP_EOL . "\JLoader::register('" . $Component + . "Email', JPATH_COMPONENT_ADMINISTRATOR . '/helpers/" + . $component . "email.php'); "; + } + } + + return ''; + } + + /** + * set the lock license (NOT OKAY) + */ + public function setLockLicense() + { + if (CFactory::_('Component')->get('add_license', 0) == 3) + { + if (!CFactory::_('Compiler.Builder.Content.One')->exists('HELPER_SITE_LICENSE_LOCK')) + { + $_WHMCS = '_' . StringHelper::safe( + $this->uniquekey(10), 'U' + ); + // add it to the system + CFactory::_('Compiler.Builder.Content.One')->set('HELPER_SITE_LICENSE_LOCK', $this->setHelperLicenseLock($_WHMCS, 'site')); + CFactory::_('Compiler.Builder.Content.One')->set('HELPER_LICENSE_LOCK', $this->setHelperLicenseLock($_WHMCS, 'admin')); + CFactory::_('Compiler.Builder.Content.One')->set('LICENSE_LOCKED_INT', $this->setInitLicenseLock($_WHMCS)); + CFactory::_('Compiler.Builder.Content.One')->set('LICENSE_LOCKED_DEFINED', + PHP_EOL . PHP_EOL . 'defined(\'' . $_WHMCS + . '\') or die(Text:' . ':_(\'NIE_REG_NIE\'));'); + } + } + else + { + // don't add it to the system + CFactory::_('Compiler.Builder.Content.One')->set('HELPER_SITE_LICENSE_LOCK', ''); + CFactory::_('Compiler.Builder.Content.One')->set('HELPER_LICENSE_LOCK', ''); + CFactory::_('Compiler.Builder.Content.One')->set('LICENSE_LOCKED_INT', ''); + CFactory::_('Compiler.Builder.Content.One')->set('LICENSE_LOCKED_DEFINED', ''); + } + } + + /** + * set Lock License Per + * + * @param string $view + * @param string $target + */ + public function setLockLicensePer(&$view, $target) + { + if (CFactory::_('Component')->get('add_license', 0) == 3) + { + if (!CFactory::_('Compiler.Builder.Content.Multi')->exists($view . '|BOOLMETHOD')) + { + $boolMethod = 'get' . StringHelper::safe( + $this->uniquekey(3, false, 'ddd'), 'W' + ); + $globalbool = 'set' . StringHelper::safe( + $this->uniquekey(3), 'W' + ); + // add it to the system + CFactory::_('Compiler.Builder.Content.Multi')->set($view . '|LICENSE_LOCKED_SET_BOOL', + $this->setBoolLicenseLock($boolMethod, $globalbool)); + CFactory::_('Compiler.Builder.Content.Multi')->set($view . '|LICENSE_LOCKED_CHECK', + $this->checkStatmentLicenseLocked($boolMethod)); + CFactory::_('Compiler.Builder.Content.Multi')->set($view . '|LICENSE_TABLE_LOCKED_CHECK', + $this->checkStatmentLicenseLocked($boolMethod, '$table')); + CFactory::_('Compiler.Builder.Content.Multi')->set($view . '|BOOLMETHOD', $boolMethod); + } + } + else + { + // don't add it to the system + CFactory::_('Compiler.Builder.Content.Multi')->set($view . '|LICENSE_LOCKED_SET_BOOL', ''); + CFactory::_('Compiler.Builder.Content.Multi')->set($view . '|LICENSE_LOCKED_CHECK', ''); + CFactory::_('Compiler.Builder.Content.Multi')->set($view . '|LICENSE_TABLE_LOCKED_CHECK', ''); + } + } + + /** + * Check statment license locked + * + * @param type $boolMethod + * @param type $thIIS + * + * @return string + */ + public function checkStatmentLicenseLocked($boolMethod, $thIIS = '$this') + { + $statment[] = PHP_EOL . Indent::_(2) . "if (!" . $thIIS . "->" + . $boolMethod . "())"; + $statment[] = Indent::_(2) . "{"; + $statment[] = Indent::_(3) . "\$app = Factory::getApplication();"; + $statment[] = Indent::_(3) . "\$app->enqueueMessage(Text:" + . ":_('NIE_REG_NIE'), 'error');"; + $statment[] = Indent::_(3) . "\$app->redirect('index.php');"; + $statment[] = Indent::_(3) . "return false;"; + $statment[] = Indent::_(2) . "}"; + + // return the genuine mentod statement + 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 . Indent::_(1) . "/**"; + $bool[] = Indent::_(1) . " * The private bool."; + $bool[] = Indent::_(1) . " **/"; + $bool[] = Indent::_(1) . "private $" . $globalbool . ";"; + $bool[] = PHP_EOL . Indent::_(1) . "/**"; + $bool[] = Indent::_(1) . " * Check if this install has a license."; + $bool[] = Indent::_(1) . " **/"; + $bool[] = Indent::_(1) . "public function " . $boolMethod . "()"; + $bool[] = Indent::_(1) . "{"; + $bool[] = Indent::_(2) . "if(!empty(\$this->" . $globalbool . "))"; + $bool[] = Indent::_(2) . "{"; + $bool[] = Indent::_(3) . "return \$this->" . $globalbool . ";"; + $bool[] = Indent::_(2) . "}"; + $bool[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Get the global params"; + $bool[] = Indent::_(2) . "\$params = ComponentHelper::getParams('com_" + . CFactory::_('Config')->component_code_name . "', true);"; + $bool[] = Indent::_(2) + . "\$whmcs_key = \$params->get('whmcs_key', null);"; + $bool[] = Indent::_(2) . "if (\$whmcs_key)"; + $bool[] = Indent::_(2) . "{"; + $bool[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " load the file"; + $bool[] = Indent::_(3) + . "JLoader::import( 'whmcs', JPATH_ADMINISTRATOR .'/components/com_" + . CFactory::_('Config')->component_code_name . "');"; + $bool[] = Indent::_(3) . "\$the = new \WHMCS(\$whmcs_key);"; + $bool[] = Indent::_(3) . "\$this->" . $globalbool . " = \$the->_is;"; + $bool[] = Indent::_(3) . "return \$this->" . $globalbool . ";"; + $bool[] = Indent::_(2) . "}"; + $bool[] = Indent::_(2) . "return false;"; + $bool[] = Indent::_(1) . "}"; + + // return the genuine method statement + return implode(PHP_EOL, $bool); + } + + /** + * set Helper License Lock + * + * @param type $_WHMCS + * @param type $target + * + * @return string + */ + public function setHelperLicenseLock($_WHMCS, $target) + { + $helper[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $helper[] = Indent::_(1) . " * Check if this install has a license."; + $helper[] = Indent::_(1) . " **/"; + $helper[] = Indent::_(1) . "public static function isGenuine()"; + $helper[] = Indent::_(1) . "{"; + $helper[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Get the global params"; + $helper[] = Indent::_(2) + . "\$params = ComponentHelper::getParams('com_" + . CFactory::_('Config')->component_code_name . "', true);"; + $helper[] = Indent::_(2) + . "\$whmcs_key = \$params->get('whmcs_key', null);"; + $helper[] = Indent::_(2) . "if (\$whmcs_key)"; + $helper[] = Indent::_(2) . "{"; + $helper[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " load the file"; + $helper[] = Indent::_(3) + . "JLoader::import( 'whmcs', JPATH_ADMINISTRATOR .'/components/com_" + . CFactory::_('Config')->component_code_name . "');"; + $helper[] = Indent::_(3) . "\$the = new \WHMCS(\$whmcs_key);"; + $helper[] = Indent::_(3) . "return \$the->_is;"; + $helper[] = Indent::_(2) . "}"; + $helper[] = Indent::_(2) . "return false;"; + $helper[] = Indent::_(1) . "}"; + + // return the genuine mentod statement + return implode(PHP_EOL, $helper); + } + + /** + * set Init License Lock + * + * @param type $_WHMCS + * + * @return string + */ + public function setInitLicenseLock($_WHMCS) + { + $init[] = PHP_EOL . "if (!defined('" . $_WHMCS . "'))"; + $init[] = "{"; + $init[] = Indent::_(1) . "\$allow = " + . CFactory::_('Compiler.Builder.Content.One')->get('Component') + . "Helper::isGenuine();"; + $init[] = Indent::_(1) . "if (\$allow)"; + $init[] = Indent::_(1) . "{"; + $init[] = Indent::_(2) . "define('" . $_WHMCS . "', 1);"; + $init[] = Indent::_(1) . "}"; + $init[] = "}"; + + // return the initializing statement + return implode(PHP_EOL, $init); + } + + /** + * set WHMCS Cryption + * + * @return string + */ + public function setWHMCSCryption() + { + // make sure we have the correct file + if (CFactory::_('Component')->isString('whmcs_key')) + { + // Get the basic encryption. + $basickey = ComponentbuilderHelper::getCryptKey('basic'); + $key = CFactory::_('Component')->get('whmcs_key'); + + // Get the encryption object. + $basic = new AES($basickey); + if ($basickey && $key === base64_encode( + base64_decode((string) $key, true) + )) + { + // basic decrypt data whmcs_key. + $key = rtrim( + (string) $basic->decryptString($key), "\0" + ); + // set the needed string to connect to whmcs + $key["kasier"] = CFactory::_('Component')->get('whmcs_url', ''); + $key["geheim"] = $key; + $key["onthou"] = 1; + // prep the call info + $theKey = base64_encode(serialize($key)); + // set the script + $encrypt[] = "/**"; + $encrypt[] = "* " . Line::_(__Line__, __Class__) . "WHMCS Class "; + $encrypt[] = "**/"; + $encrypt[] = "class WHMCS"; + $encrypt[] = "{"; + $encrypt[] = Indent::_(1) . "public \$_key = false;"; + $encrypt[] = Indent::_(1) . "public \$_is = false;"; + $encrypt[] = PHP_EOL . Indent::_(1) + . "public function __construct(\$Vk5smi0wjnjb)"; + $encrypt[] = Indent::_(1) . "{"; + $encrypt[] = Indent::_(2) . "// get the session"; + $encrypt[] = Indent::_(2) + . "\$session = Factory::getSession();"; + $encrypt[] = Indent::_(2) + . "\$V2uekt2wcgwk = \$session->get(\$Vk5smi0wjnjb, null);"; + $encrypt[] = Indent::_(2) + . "\$h4sgrGsqq = \$this->get(\$Vk5smi0wjnjb,\$V2uekt2wcgwk);"; + $encrypt[] = Indent::_(2) + . "if (isset(\$h4sgrGsqq['nuut']) && \$h4sgrGsqq['nuut'] && (isset(\$h4sgrGsqq['status']) && 'Active' === \$h4sgrGsqq['status']) && isset(\$h4sgrGsqq['eiegrendel']) && strlen(\$h4sgrGsqq['eiegrendel']) > 300)"; + $encrypt[] = Indent::_(2) . "{"; + $encrypt[] = Indent::_(3) + . "\$session->set(\$Vk5smi0wjnjb, \$h4sgrGsqq['eiegrendel']);"; + $encrypt[] = Indent::_(2) . "}"; + $encrypt[] = Indent::_(2) + . "if ((isset(\$h4sgrGsqq['status']) && 'Active' === \$h4sgrGsqq['status']) && isset(\$h4sgrGsqq['md5hash']) && strlen(\$h4sgrGsqq['md5hash']) == 32 && isset(\$h4sgrGsqq['customfields']) && strlen(\$h4sgrGsqq['customfields']) > 4)"; + $encrypt[] = Indent::_(2) . "{"; + $encrypt[] = Indent::_(3) + . "\$this->_key = md5(\$h4sgrGsqq['customfields']);"; + $encrypt[] = Indent::_(2) . "}"; + $encrypt[] = Indent::_(2) + . "if ((isset(\$h4sgrGsqq['status']) && 'Active' === \$h4sgrGsqq['status']) && isset(\$h4sgrGsqq['md5hash']) && strlen(\$h4sgrGsqq['md5hash']) == 32 )"; + $encrypt[] = Indent::_(2) . "{"; + $encrypt[] = Indent::_(3) . "\$this->_is = true;"; + $encrypt[] = Indent::_(2) . "}"; + $encrypt[] = Indent::_(1) . "}"; + $encrypt[] = PHP_EOL . Indent::_(1) + . "private function get(\$Vk5smi0wjnjb,\$V2uekt2wcgwk)"; + $encrypt[] = Indent::_(1) . "{"; + $encrypt[] = Indent::_(2) + . "\$Viioj50xuqu2 = unserialize(base64_decode('" . $theKey + . "'));"; + $encrypt[] = Indent::_(2) + . "\$Visqfrd1caus = time() . md5(mt_rand(1000000000, 9999999999) . \$Vk5smi0wjnjb);"; + $encrypt[] = Indent::_(2) . "\$Vo4tezfgcf3e = date(\"Ymd\");"; + $encrypt[] = Indent::_(2) + . "\$Vozblwvfym2f = \$_SERVER['SERVER_NAME'];"; + $encrypt[] = Indent::_(2) + . "\$Vozblwvfym2fdie = isset(\$_SERVER['SERVER_ADDR']) ? \$_SERVER['SERVER_ADDR'] : \$_SERVER['LOCAL_ADDR'];"; + $encrypt[] = Indent::_(2) + . "\$V343jp03dxco = dirname(__FILE__);"; + $encrypt[] = Indent::_(2) + . "\$Vc2rayehw4f0 = unserialize(base64_decode('czozNjoibW9kdWxlcy9zZXJ2ZXJzL2xpY2Vuc2luZy92ZXJpZnkucGhwIjs='));"; + $encrypt[] = Indent::_(2) . "\$Vlpolphukogz = false;"; + $encrypt[] = Indent::_(2) . "if (\$V2uekt2wcgwk) {"; + $encrypt[] = Indent::_(3) . "\$V2uekt2wcgwk = str_replace(\"" + . '".PHP_EOL."' . "\", '', \$V2uekt2wcgwk);"; + $encrypt[] = Indent::_(3) + . "\$Vm5cxjdc43g4 = substr(\$V2uekt2wcgwk, 0, strlen(\$V2uekt2wcgwk) - 32);"; + $encrypt[] = Indent::_(3) + . "\$Vbgx0efeu2sy = substr(\$V2uekt2wcgwk, strlen(\$V2uekt2wcgwk) - 32);"; + $encrypt[] = Indent::_(3) + . "if (\$Vbgx0efeu2sy == md5(\$Vm5cxjdc43g4 . \$Viioj50xuqu2['geheim'])) {"; + $encrypt[] = Indent::_(4) + . "\$Vm5cxjdc43g4 = strrev(\$Vm5cxjdc43g4);"; + $encrypt[] = Indent::_(4) + . "\$Vbgx0efeu2sy = substr(\$Vm5cxjdc43g4, 0, 32);"; + $encrypt[] = Indent::_(4) + . "\$Vm5cxjdc43g4 = substr(\$Vm5cxjdc43g4, 32);"; + $encrypt[] = Indent::_(4) + . "\$Vm5cxjdc43g4 = base64_decode(\$Vm5cxjdc43g4);"; + $encrypt[] = Indent::_(4) + . "\$Vm5cxjdc43g4finding = unserialize(\$Vm5cxjdc43g4);"; + $encrypt[] = Indent::_(4) + . "\$V3qqz0p00fbq = \$Vm5cxjdc43g4finding['dan'];"; + $encrypt[] = Indent::_(4) + . "if (\$Vbgx0efeu2sy == md5(\$V3qqz0p00fbq . \$Viioj50xuqu2['geheim'])) {"; + $encrypt[] = Indent::_(5) + . "\$Vbfbwv2y4kre = date(\"Ymd\", mktime(0, 0, 0, date(\"m\"), date(\"d\") - \$Viioj50xuqu2['onthou'], date(\"Y\")));"; + $encrypt[] = Indent::_(5) + . "if (\$V3qqz0p00fbq > \$Vbfbwv2y4kre) {"; + $encrypt[] = Indent::_(6) . "\$Vlpolphukogz = true;"; + $encrypt[] = Indent::_(6) + . "\$Vwasqoybpyed = \$Vm5cxjdc43g4finding;"; + $encrypt[] = Indent::_(6) + . "\$Vcixw3trerrt = explode(',', \$Vwasqoybpyed['validdomain']);"; + $encrypt[] = Indent::_(6) + . "if (!in_array(\$_SERVER['SERVER_NAME'], \$Vcixw3trerrt)) {"; + $encrypt[] = Indent::_(7) . "\$Vlpolphukogz = false;"; + $encrypt[] = Indent::_(7) + . "\$Vm5cxjdc43g4finding['status'] = \"sleg\";"; + $encrypt[] = Indent::_(7) . "\$Vwasqoybpyed = [];"; + $encrypt[] = Indent::_(6) . "}"; + $encrypt[] = Indent::_(6) + . "\$Vkni3xyhkqzv = explode(',', \$Vwasqoybpyed['validip']);"; + $encrypt[] = Indent::_(6) + . "if (!in_array(\$Vozblwvfym2fdie, \$Vkni3xyhkqzv)) {"; + $encrypt[] = Indent::_(7) . "\$Vlpolphukogz = false;"; + $encrypt[] = Indent::_(7) + . "\$Vm5cxjdc43g4finding['status'] = \"sleg\";"; + $encrypt[] = Indent::_(7) . "\$Vwasqoybpyed = [];"; + $encrypt[] = Indent::_(6) . "}"; + $encrypt[] = Indent::_(6) + . "\$Vckfvnepoaxj = explode(',', \$Vwasqoybpyed['validdirectory']);"; + $encrypt[] = Indent::_(6) + . "if (!in_array(\$V343jp03dxco, \$Vckfvnepoaxj)) {"; + $encrypt[] = Indent::_(7) . "\$Vlpolphukogz = false;"; + $encrypt[] = Indent::_(7) + . "\$Vm5cxjdc43g4finding['status'] = \"sleg\";"; + $encrypt[] = Indent::_(7) . "\$Vwasqoybpyed = [];"; + $encrypt[] = Indent::_(6) . "}"; + $encrypt[] = Indent::_(5) . "}"; + $encrypt[] = Indent::_(4) . "}"; + $encrypt[] = Indent::_(3) . "}"; + $encrypt[] = Indent::_(2) . "}"; + $encrypt[] = Indent::_(2) . "if (!\$Vlpolphukogz) {"; + $encrypt[] = Indent::_(3) . "\$V1u0c4dl3ehp = array("; + $encrypt[] = Indent::_(4) . "'licensekey' => \$Vk5smi0wjnjb,"; + $encrypt[] = Indent::_(4) . "'domain' => \$Vozblwvfym2f,"; + $encrypt[] = Indent::_(4) . "'ip' => \$Vozblwvfym2fdie,"; + $encrypt[] = Indent::_(4) . "'dir' => \$V343jp03dxco,"; + $encrypt[] = Indent::_(3) . ");"; + $encrypt[] = Indent::_(3) + . "if (\$Visqfrd1caus) \$V1u0c4dl3ehp['check_token'] = \$Visqfrd1caus;"; + $encrypt[] = Indent::_(3) . "\$Vdsjeyjmpq2o = '';"; + $encrypt[] = Indent::_(3) + . "foreach (\$V1u0c4dl3ehp AS \$V2sgyscukmgi=>\$V1u00zkzmb1d) {"; + $encrypt[] = Indent::_(4) + . "\$Vdsjeyjmpq2o .= \$V2sgyscukmgi.'='.urlencode(\$V1u00zkzmb1d).'&';"; + $encrypt[] = Indent::_(3) . "}"; + $encrypt[] = Indent::_(3) + . "if (function_exists('curl_exec')) {"; + $encrypt[] = Indent::_(4) . "\$Vdathuqgjyf0 = curl_init();"; + $encrypt[] = Indent::_(4) + . "curl_setopt(\$Vdathuqgjyf0, CURLOPT_URL, \$Viioj50xuqu2['kasier'] . \$Vc2rayehw4f0);"; + $encrypt[] = Indent::_(4) + . "curl_setopt(\$Vdathuqgjyf0, CURLOPT_POST, 1);"; + $encrypt[] = Indent::_(4) + . "curl_setopt(\$Vdathuqgjyf0, CURLOPT_POSTFIELDS, \$Vdsjeyjmpq2o);"; + $encrypt[] = Indent::_(4) + . "curl_setopt(\$Vdathuqgjyf0, CURLOPT_TIMEOUT, 30);"; + $encrypt[] = Indent::_(4) + . "curl_setopt(\$Vdathuqgjyf0, CURLOPT_RETURNTRANSFER, 1);"; + $encrypt[] = Indent::_(4) + . "\$Vqojefyeohg5 = curl_exec(\$Vdathuqgjyf0);"; + $encrypt[] = Indent::_(4) . "curl_close(\$Vdathuqgjyf0);"; + $encrypt[] = Indent::_(3) . "} else {"; + $encrypt[] = Indent::_(4) + . "\$Vrpmu4bvnmkp = fsockopen(\$Viioj50xuqu2['kasier'], 80, \$Vc0t5kmpwkwk, \$Va3g41fnofhu, 5);"; + $encrypt[] = Indent::_(4) . "if (\$Vrpmu4bvnmkp) {"; + $encrypt[] = Indent::_(5) . "\$Vznkm0a0me1y = \"\r" . PHP_EOL + . "\";"; + $encrypt[] = Indent::_(5) + . "\$V2sgyscukmgiop = \"POST \".\$Viioj50xuqu2['kasier'] . \$Vc2rayehw4f0 . \" HTTP/1.0\" . \$Vznkm0a0me1y;"; + $encrypt[] = Indent::_(5) + . "\$V2sgyscukmgiop .= \"Host: \".\$Viioj50xuqu2['kasier'] . \$Vznkm0a0me1y;"; + $encrypt[] = Indent::_(5) + . "\$V2sgyscukmgiop .= \"Content-type: application/x-www-form-urlencoded\" . \$Vznkm0a0me1y;"; + $encrypt[] = Indent::_(5) + . "\$V2sgyscukmgiop .= \"Content-length: \".@strlen(\$Vdsjeyjmpq2o) . \$Vznkm0a0me1y;"; + $encrypt[] = Indent::_(5) + . "\$V2sgyscukmgiop .= \"Connection: close\" . \$Vznkm0a0me1y . \$Vznkm0a0me1y;"; + $encrypt[] = Indent::_(5) + . "\$V2sgyscukmgiop .= \$Vdsjeyjmpq2o;"; + $encrypt[] = Indent::_(5) . "\$Vqojefyeohg5 = '';"; + $encrypt[] = Indent::_(5) + . "@stream_set_timeout(\$Vrpmu4bvnmkp, 20);"; + $encrypt[] = Indent::_(5) + . "@fputs(\$Vrpmu4bvnmkp, \$V2sgyscukmgiop);"; + $encrypt[] = Indent::_(5) + . "\$V2czq24pjexf = @socket_get_status(\$Vrpmu4bvnmkp);"; + $encrypt[] = Indent::_(5) + . "while (!@feof(\$Vrpmu4bvnmkp)&&\$V2czq24pjexf) {"; + $encrypt[] = Indent::_(6) + . "\$Vqojefyeohg5 .= @fgets(\$Vrpmu4bvnmkp, 1024);"; + $encrypt[] = Indent::_(6) + . "\$V2czq24pjexf = @socket_get_status(\$Vrpmu4bvnmkp);"; + $encrypt[] = Indent::_(5) . "}"; + $encrypt[] = Indent::_(5) . "@fclose (\$Vqojefyeohg5);"; + $encrypt[] = Indent::_(4) . "}"; + $encrypt[] = Indent::_(3) . "}"; + $encrypt[] = Indent::_(3) . "if (!\$Vqojefyeohg5) {"; + $encrypt[] = Indent::_(4) + . "\$Vbfbwv2y4kre = date(\"Ymd\", mktime(0, 0, 0, date(\"m\"), date(\"d\") - \$Viioj50xuqu2['onthou'], date(\"Y\")));"; + $encrypt[] = Indent::_(4) + . "if (isset(\$V3qqz0p00fbq) && \$V3qqz0p00fbq > \$Vbfbwv2y4kre) {"; + $encrypt[] = Indent::_(5) + . "\$Vwasqoybpyed = \$Vm5cxjdc43g4finding;"; + $encrypt[] = Indent::_(4) . "} else {"; + $encrypt[] = Indent::_(5) . "\$Vwasqoybpyed = [];"; + $encrypt[] = Indent::_(5) + . "\$Vwasqoybpyed['status'] = \"sleg\";"; + $encrypt[] = Indent::_(5) + . "\$Vwasqoybpyed['description'] = \"Remote Check Failed\";"; + $encrypt[] = Indent::_(5) . "return \$Vwasqoybpyed;"; + $encrypt[] = Indent::_(4) . "}"; + $encrypt[] = Indent::_(3) . "} else {"; + $encrypt[] = Indent::_(4) . "preg_match_all('" + . '/<(.*?)>([^<]+)<\/\\1>/i' + . "', \$Vqojefyeohg5, \$V1ot20wob03f);"; + $encrypt[] = Indent::_(4) . "\$Vwasqoybpyed = [];"; + $encrypt[] = Indent::_(4) + . "foreach (\$V1ot20wob03f[1] AS \$V2sgyscukmgi=>\$V1u00zkzmb1d) {"; + $encrypt[] = Indent::_(5) + . "\$Vwasqoybpyed[\$V1u00zkzmb1d] = \$V1ot20wob03f[2][\$V2sgyscukmgi];"; + $encrypt[] = Indent::_(4) . "}"; + $encrypt[] = Indent::_(3) . "}"; + $encrypt[] = Indent::_(3) . "if (!is_array(\$Vwasqoybpyed)) {"; + $encrypt[] = Indent::_(4) + . "die(\"Invalid License Server Response\");"; + $encrypt[] = Indent::_(3) . "}"; + $encrypt[] = Indent::_(3) + . "if (isset(\$Vwasqoybpyed['md5hash']) && \$Vwasqoybpyed['md5hash']) {"; + $encrypt[] = Indent::_(4) + . "if (\$Vwasqoybpyed['md5hash'] != md5(\$Viioj50xuqu2['geheim'] . \$Visqfrd1caus)) {"; + $encrypt[] = Indent::_(5) + . "\$Vwasqoybpyed['status'] = \"sleg\";"; + $encrypt[] = Indent::_(5) + . "\$Vwasqoybpyed['description'] = \"MD5 Checksum Verification Failed\";"; + $encrypt[] = Indent::_(5) . "return \$Vwasqoybpyed;"; + $encrypt[] = Indent::_(4) . "}"; + $encrypt[] = Indent::_(3) . "}"; + $encrypt[] = Indent::_(3) + . "if (isset(\$Vwasqoybpyed['status']) && \$Vwasqoybpyed['status'] == \"Active\") {"; + $encrypt[] = Indent::_(4) + . "\$Vwasqoybpyed['dan'] = \$Vo4tezfgcf3e;"; + $encrypt[] = Indent::_(4) + . "\$Vqojefyeohg5ing = serialize(\$Vwasqoybpyed);"; + $encrypt[] = Indent::_(4) + . "\$Vqojefyeohg5ing = base64_encode(\$Vqojefyeohg5ing);"; + $encrypt[] = Indent::_(4) + . "\$Vqojefyeohg5ing = md5(\$Vo4tezfgcf3e . \$Viioj50xuqu2['geheim']) . \$Vqojefyeohg5ing;"; + $encrypt[] = Indent::_(4) + . "\$Vqojefyeohg5ing = strrev(\$Vqojefyeohg5ing);"; + $encrypt[] = Indent::_(4) + . "\$Vqojefyeohg5ing = \$Vqojefyeohg5ing . md5(\$Vqojefyeohg5ing . \$Viioj50xuqu2['geheim']);"; + $encrypt[] = Indent::_(4) + . "\$Vqojefyeohg5ing = wordwrap(\$Vqojefyeohg5ing, 80, \"" + . '".PHP_EOL."' . "\", true);"; + $encrypt[] = Indent::_(4) + . "\$Vwasqoybpyed['eiegrendel'] = \$Vqojefyeohg5ing;"; + $encrypt[] = Indent::_(3) . "}"; + $encrypt[] = Indent::_(3) . "\$Vwasqoybpyed['nuut'] = true;"; + $encrypt[] = Indent::_(2) . "}"; + $encrypt[] = Indent::_(2) + . "unset(\$V1u0c4dl3ehp,\$Vqojefyeohg5,\$V1ot20wob03f,\$Viioj50xuqu2['kasier'],\$Viioj50xuqu2['geheim'],\$Vo4tezfgcf3e,\$Vozblwvfym2fdie,\$Viioj50xuqu2['onthou'],\$Vbgx0efeu2sy);"; + $encrypt[] = Indent::_(2) . "return \$Vwasqoybpyed;"; + $encrypt[] = Indent::_(1) . "}"; + $encrypt[] = "}"; + + // return the help methods + return implode(PHP_EOL, $encrypt); + } + } + // give notice of this issue + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_HR_HTHREEWHMCS_ERRORHTHREE'), 'Error' + ); + $this->app->enqueueMessage( + Text::_( + 'The WHMCS class could not be added to this component. You will need to enable the add-on in the Joomla Component area (Add WHMCS)->Yes. If you have done this, then please check that you have your own Basic Encryption set in the global settings of JCB. Then open and save this component again, making sure that your WHMCS settings are still correct.' + ), 'Error' + ); + + return "//" . Line::_(__Line__, __Class__) + . " The WHMCS class could not be added to this component." . PHP_EOL + . "//" . Line::_(__Line__, __Class__) + . " Please note that you will need to enable the add-on in the Joomla Component area (Add WHMCS)->Yes."; + } + + /** + * set Get Crypt Key + * + * @return string + */ + public function setGetCryptKey() + { + // WHMCS_ENCRYPT_FILE + CFactory::_('Compiler.Builder.Content.One')->set('WHMCS_ENCRYPT_FILE', ''); + // check if encryption is ative + if (CFactory::_('Compiler.Builder.Model.Basic.Field')->isActive() + || CFactory::_('Compiler.Builder.Model.Medium.Field')->isActive() + || CFactory::_('Compiler.Builder.Model.Whmcs.Field')->isActive() + || CFactory::_('Component')->get('add_license')) + { + if (CFactory::_('Compiler.Builder.Model.Whmcs.Field')->isActive() + || CFactory::_('Component')->get('add_license')) + { + // set whmcs encrypt file into place + $target = array('admin' => 'whmcs'); + $done = CFactory::_('Utilities.Structure')->build($target, 'whmcs'); + // the text for the file WHMCS_ENCRYPTION_BODY + CFactory::_('Compiler.Builder.Content.Multi')->set('whmcs' . '|WHMCS_ENCRYPTION_BODY', $this->setWHMCSCryption()); + // ENCRYPT_FILE + CFactory::_('Compiler.Builder.Content.One')->set('WHMCS_ENCRYPT_FILE', PHP_EOL . Indent::_(3) . "whmcs.php"); + } + // get component name + $component = CFactory::_('Config')->component_code_name; + // set the getCryptKey function to the helper class + $function = []; + // start building the getCryptKey function/class method + $function[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $function[] = Indent::_(1) . " * Get The Encryption Keys"; + $function[] = Indent::_(1) . " *"; + $function[] = Indent::_(1) + . " * @param string \$type The type of key"; + $function[] = Indent::_(1) + . " * @param string/bool \$default The return value if no key was found"; + $function[] = Indent::_(1) . " *"; + $function[] = Indent::_(1) . " * @return string On success"; + $function[] = Indent::_(1) . " *"; + $function[] = Indent::_(1) . " **/"; + $function[] = Indent::_(1) + . "public static function getCryptKey(\$type, \$default = false)"; + $function[] = Indent::_(1) . "{"; + $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Get the global params"; + $function[] = Indent::_(2) + . "\$params = ComponentHelper::getParams('com_" . $component + . "', true);"; + // add the basic option + if (CFactory::_('Compiler.Builder.Model.Basic.Field')->isActive()) + { + $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Basic Encryption Type"; + $function[] = Indent::_(2) . "if ('basic' === \$type)"; + $function[] = Indent::_(2) . "{"; + $function[] = Indent::_(3) + . "\$basic_key = \$params->get('basic_key', \$default);"; + $function[] = Indent::_(3) + . "if (Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$basic_key))"; + $function[] = Indent::_(3) . "{"; + $function[] = Indent::_(4) . "return \$basic_key;"; + $function[] = Indent::_(3) . "}"; + $function[] = Indent::_(2) . "}"; + } + // add the medium option + if (CFactory::_('Compiler.Builder.Model.Medium.Field')->isActive()) + { + $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Medium Encryption Type"; + $function[] = Indent::_(2) . "if ('medium' === \$type)"; + $function[] = Indent::_(2) . "{"; + $function[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " check if medium key is already loaded."; + $function[] = Indent::_(3) + . "if (Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(self::\$mediumCryptKey))"; + $function[] = Indent::_(3) . "{"; + $function[] = Indent::_(4) + . "return (self::\$mediumCryptKey !== 'none') ? trim(self::\$mediumCryptKey) : \$default;"; + $function[] = Indent::_(3) . "}"; + $function[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " get the path to the medium encryption key."; + $function[] = Indent::_(3) + . "\$medium_key_path = \$params->get('medium_key_path', null);"; + $function[] = Indent::_(3) + . "if (Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$medium_key_path))"; + $function[] = Indent::_(3) . "{"; + $function[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " load the key from the file."; + $function[] = Indent::_(4) + . "if (self::getMediumCryptKey(\$medium_key_path))"; + $function[] = Indent::_(4) . "{"; + $function[] = Indent::_(5) + . "return trim(self::\$mediumCryptKey);"; + $function[] = Indent::_(4) . "}"; + $function[] = Indent::_(3) . "}"; + $function[] = Indent::_(2) . "}"; + } + // add the whmcs option + if (CFactory::_('Compiler.Builder.Model.Whmcs.Field')->isActive() + || CFactory::_('Component')->get('add_license')) + { + $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " WHMCS Encryption Type"; + $function[] = Indent::_(2) + . "if ('whmcs' === \$type || 'advanced' === \$type)"; + $function[] = Indent::_(2) . "{"; + $function[] = Indent::_(3) + . "\$key = \$params->get('whmcs_key', \$default);"; + $function[] = Indent::_(3) . "if (Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$key))"; + $function[] = Indent::_(3) . "{"; + $function[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " load the file"; + $function[] = Indent::_(4) + . "JLoader::import( 'whmcs', JPATH_COMPONENT_ADMINISTRATOR);"; + $function[] = PHP_EOL . Indent::_(4) + . "\$the = new \WHMCS(\$key);"; + $function[] = PHP_EOL . Indent::_(4) . "return \$the->_key;"; + $function[] = Indent::_(3) . "}"; + $function[] = Indent::_(2) . "}"; + } + // end the function + $function[] = PHP_EOL . Indent::_(2) . "return \$default;"; + $function[] = Indent::_(1) . "}"; + // set the getMediumCryptKey class/method + if (CFactory::_('Compiler.Builder.Model.Medium.Field')->isActive()) + { + $function[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $function[] = Indent::_(1) . " * The Medium Encryption Key"; + $function[] = Indent::_(1) . " *"; + $function[] = Indent::_(1) . " * @var string/bool"; + $function[] = Indent::_(1) . " **/"; + $function[] = Indent::_(1) + . "protected static \$mediumCryptKey = false;"; + $function[] = PHP_EOL . Indent::_(1) . "/**"; + $function[] = Indent::_(1) + . " * Get The Medium Encryption Key"; + $function[] = Indent::_(1) . " *"; + $function[] = Indent::_(1) + . " * @param string \$path The path to the medium crypt key folder"; + $function[] = Indent::_(1) . " *"; + $function[] = Indent::_(1) + . " * @return string On success"; + $function[] = Indent::_(1) . " *"; + $function[] = Indent::_(1) . " **/"; + $function[] = Indent::_(1) + . "public static function getMediumCryptKey(\$path)"; + $function[] = Indent::_(1) . "{"; + $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Prep the path a little"; + $function[] = Indent::_(2) + . "\$path = '/'. trim(str_replace('//', '/', \$path), '/');"; + $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Check if folder exist"; + $function[] = Indent::_(2) . "if (!Folder::exists(\$path))"; + $function[] = Indent::_(2) . "{"; + $function[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Lock key."; + $function[] = Indent::_(3) . "self::\$mediumCryptKey = 'none';"; + $function[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Set the error message."; + $function[] = Indent::_(3) + . "Factory::getApplication()->enqueueMessage(Text:" . ":_('" + . CFactory::_('Config')->lang_prefix + . "_CONFIG_MEDIUM_KEY_PATH_ERROR'), 'Error');"; + $function[] = Indent::_(3) . "return false;"; + $function[] = Indent::_(2) . "}"; + $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Create FileName and set file path"; + $function[] = Indent::_(2) + . "\$filePath = \$path.'/.'.md5('medium_crypt_key_file');"; + $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Check if we already have the file set"; + $function[] = Indent::_(2) + . "if ((self::\$mediumCryptKey = @file_get_contents(\$filePath)) !== FALSE)"; + $function[] = Indent::_(2) . "{"; + $function[] = Indent::_(3) . "return true;"; + $function[] = Indent::_(2) . "}"; + $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Set the key for the first time"; + $function[] = Indent::_(2) + . "self::\$mediumCryptKey = self::randomkey(128);"; + $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Open the key file"; + $function[] = Indent::_(2) . "\$fh = @fopen(\$filePath, 'w');"; + $function[] = Indent::_(2) . "if (!is_resource(\$fh))"; + $function[] = Indent::_(2) . "{"; + $function[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Lock key."; + $function[] = Indent::_(3) . "self::\$mediumCryptKey = 'none';"; + $function[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Set the error message."; + $function[] = Indent::_(3) + . "Factory::getApplication()->enqueueMessage(Text:" . ":_('" + . CFactory::_('Config')->lang_prefix + . "_CONFIG_MEDIUM_KEY_PATH_ERROR'), 'Error');"; + $function[] = Indent::_(3) . "return false;"; + $function[] = Indent::_(2) . "}"; + $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Write to the key file"; + $function[] = Indent::_(2) + . "if (!fwrite(\$fh, self::\$mediumCryptKey))"; + $function[] = Indent::_(2) . "{"; + $function[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Close key file."; + $function[] = Indent::_(3) . "fclose(\$fh);"; + $function[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Lock key."; + $function[] = Indent::_(3) . "self::\$mediumCryptKey = 'none';"; + $function[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Set the error message."; + $function[] = Indent::_(3) + . "Factory::getApplication()->enqueueMessage(Text:" . ":_('" + . CFactory::_('Config')->lang_prefix + . "_CONFIG_MEDIUM_KEY_PATH_ERROR'), 'Error');"; + $function[] = Indent::_(3) . "return false;"; + $function[] = Indent::_(2) . "}"; + $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Close key file."; + $function[] = Indent::_(2) . "fclose(\$fh);"; + $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Key is set."; + $function[] = Indent::_(2) . "return true;"; + $function[] = Indent::_(1) . "}"; + } + + // return the help methods + return implode(PHP_EOL, $function); + } + + return ''; + } + + /** + * set Version Controller + */ + public function setVersionController() + { + if (CFactory::_('Component')->isArray('version_update') + || CFactory::_('Compiler.Builder.Update.Mysql')->isActive()) + { + $updateXML = []; + // add the update server + if (CFactory::_('Component')->get('update_server_target', 3) != 3) + { + $updateXML[] = ''; + } + + // add the dynamic sql switch + $addDynamicSQL = true; + $addActive = true; + if (CFactory::_('Component')->isArray('version_update')) + { + $updates = CFactory::_('Component')->get('version_update'); + foreach ($updates as $nr => &$update) + { + $this->setUpdateXMLSQL($update, $updateXML, $addDynamicSQL); + + if ($update['version'] + == CFactory::_('Component')->get('component_version')) + { + $addActive = false; + } + } + CFactory::_('Component')->set('version_update', $updates); + } + // add the dynamic sql if not already added + if ($addDynamicSQL + && CFactory::_('Compiler.Builder.Update.Mysql')->isActive()) + { + // add the dynamic sql + $this->setDynamicUpdateXMLSQL($updateXML); + } + // add the new active version if needed + if ($addActive && CFactory::_('Compiler.Builder.Update.Mysql')->isActive()) + { + // add the dynamic sql + $this->setDynamicUpdateXMLSQL($updateXML, $addActive); + } + // add the update server file + if (CFactory::_('Component')->get('update_server_target', 3) != 3) + { + $updateXML[] = ''; + // UPDATE_SERVER_XML + $name = substr( + (string) CFactory::_('Component')->get('update_server_url'), + strrpos((string) CFactory::_('Component')->get('update_server_url'), '/') + + 1 + ); + $name = explode('.xml', $name)[0]; + $target = array('admin' => $name); + CFactory::_('Utilities.Structure')->build($target, 'update_server'); + CFactory::_('Compiler.Builder.Content.Multi')->set($name . '|UPDATE_SERVER_XML', implode(PHP_EOL, $updateXML)); + + // set the Update server file name + $this->updateServerFileName = $name; + } + } + // add the update server link to component XML + if (CFactory::_('Component')->get('add_update_server') + && CFactory::_('Component')->isString('update_server_url')) + { + // UPDATESERVER + $updateServer = []; + $updateServer[] = PHP_EOL . Indent::_(1) . ""; + $updateServer[] = Indent::_(2) + . '' . CFactory::_('Component')->get('update_server_url') + . ''; + $updateServer[] = Indent::_(1) . ''; + // return the array to string + $updateServer = implode(PHP_EOL, $updateServer); + // add update server details to component XML file + CFactory::_('Compiler.Builder.Content.One')->set('UPDATESERVER', $updateServer); + } + else + { + // add update server details to component XML file + CFactory::_('Compiler.Builder.Content.One')->set('UPDATESERVER', ''); + } + // ensure to update Component version data + if (CFactory::_('Compiler.Builder.Update.Mysql')->isActive()) + { + $buket = []; + $nr = 0; + foreach (CFactory::_('Component')->get('version_update') as $values) + { + $buket['version_update' . $nr] = $values; + $nr++; + } + // update the joomla component table + $newJ = []; + $newJ['id'] = (int) CFactory::_('Config')->component_id; + $newJ['component_version'] + = CFactory::_('Component')->get('component_version'); + // update the component with the new dynamic SQL + $modelJ = ComponentbuilderHelper::getModel('joomla_component'); + $modelJ->save($newJ); // <-- to insure the history is also updated + // reset the watch here + CFactory::_('History')->get('joomla_component', CFactory::_('Config')->component_id); + + // update the component update table + $newU = []; + if (CFactory::_('Component')->get('version_update_id', 0) > 0) + { + $newU['id'] = (int) CFactory::_('Component')->get('version_update_id', 0); + } + else + { + $newU['joomla_component'] = (int) CFactory::_('Config')->component_id; + } + $newU['version_update'] = json_encode($buket); + // update the component with the new dynamic SQL + $modelU = ComponentbuilderHelper::getModel('component_updates'); + $modelU->save($newU); // <-- to insure the history is also updated + } + } + + /** + * set Dynamic Update XML SQL + * + * @param array $updateXML + * @param bool $current_version + */ + public function setDynamicUpdateXMLSQL(&$updateXML, $current_version = false + ) + { + // start building the update + $update_ = []; + if ($current_version) + { + // setup new version + $update_['version'] = CFactory::_('Component')->get('component_version'); + // setup SQL + $update_['mysql'] = ''; + // setup URL + $update_['url'] = 'http://domain.com/demo.zip'; + } + else + { + // setup new version + $update_['version'] = CFactory::_('Component')->get('old_component_version'); + // setup SQL + $update_['mysql'] = trim( + implode(PHP_EOL . PHP_EOL, CFactory::_('Compiler.Builder.Update.Mysql')->allActive()) + ); + // setup URL + if (isset($this->lastupdateURL)) + { + $paceholders = array( + CFactory::_('Component')->get('component_version') => CFactory::_('Component')->get('old_component_version'), + str_replace( + '.', '-', (string) CFactory::_('Component')->get('component_version') + ) => str_replace( + '.', '-', (string) CFactory::_('Component')->get('old_component_version') + ), + str_replace( + '.', '_', (string) CFactory::_('Component')->get('component_version') + ) => str_replace( + '.', '_', (string) CFactory::_('Component')->get('old_component_version') + ), + str_replace( + '.', '', (string) CFactory::_('Component')->get('component_version') + ) => str_replace( + '.', '', (string) CFactory::_('Component')->get('old_component_version') + ) + ); + $update_['url'] = CFactory::_('Placeholder')->update( + $this->lastupdateURL, $paceholders + ); + } + else + { + // setup URL + $update_['url'] = 'http://domain.com/demo.zip'; + } + } + // stop it from being added double + $addDynamicSQL = false; + // add dynamic SQL + $this->setUpdateXMLSQL($update_, $updateXML, $addDynamicSQL); + + CFactory::_('Component')->appendArray('version_update', $update_); + } + + /** + * set Update XML SQL + * + * @param array $update + * @param array $updateXML + * @param boolean $addDynamicSQL + */ + public function setUpdateXMLSQL(&$update, &$updateXML, &$addDynamicSQL) + { + // ensure version naming is correct + $update['version'] = preg_replace('/^v/i', '', (string) $update['version']); + // setup SQL + if (StringHelper::check($update['mysql'])) + { + $update['mysql'] = CFactory::_('Placeholder')->update_( + $update['mysql'] + ); + } + // add dynamic SQL + $force = false; + if ($addDynamicSQL + && CFactory::_('Compiler.Builder.Update.Mysql')->isActive() + && CFactory::_('Component')->get('old_component_version') == $update['version']) + { + $searchMySQL = preg_replace('/\s+/', '', (string) $update['mysql']); + // add the updates to the SQL only if not found + foreach (CFactory::_('Compiler.Builder.Update.Mysql')->allActive() as $search => $query) + { + if (strpos($searchMySQL, $search) === false) + { + $update['mysql'] .= PHP_EOL . PHP_EOL . $query; + } + } + // make sure no unneeded white space is added + $update['mysql'] = trim((string) $update['mysql']); + // update has been added + $addDynamicSQL = false; + } + // setup import files + if ($update['version'] != CFactory::_('Component')->get('component_version')) + { + $name = StringHelper::safe($update['version']); + $target = array('admin' => $name); + CFactory::_('Utilities.Structure')->build($target, 'sql_update', $update['version']); + $_name = preg_replace('/[\.]+/', '_', (string) $update['version']); + CFactory::_('Compiler.Builder.Content.Multi')->set($name . '_' . $_name . '|UPDATE_VERSION_MYSQL', + $update['mysql'] + ); + } + elseif (isset($update['url']) + && StringHelper::check( + $update['url'] + )) + { + $this->lastupdateURL = $update['url']; + } + // add the update server + if (CFactory::_('Component')->get('add_update_server', 3) != 3) + { + // we set the defaults + $u_element = 'com_' . CFactory::_('Config')->component_code_name; + $u_server_type = 'component'; + $u_state = 'stable'; + $u_target_version = '3.*'; + $u_client = null; + // check if we have advance options set + if (isset($update['update_server_adv']) && $update['update_server_adv']) + { + $u_element = (isset($update['update_element']) && strlen((string) $update['update_element']) > 0) + ? $update['update_element'] : $u_element; + $u_server_type = (isset($update['update_server_type']) && strlen((string) $update['update_server_type']) > 0) + ? $update['update_server_type'] : $u_server_type; + $u_state = (isset($update['update_state']) && strlen((string) $update['update_state']) > 0) + ? $update['update_state'] : $u_state; + $u_target_version = (isset($update['update_target_version']) && strlen((string) $update['update_target_version']) > 0) + ? $update['update_target_version'] : $u_target_version; + $u_client = (isset($update['update_client']) && strlen((string) $update['update_client']) > 0) + ? $update['update_client'] : $u_client; + } + // build update xml + $updateXML[] = Indent::_(1) . ""; + $updateXML[] = Indent::_(2) . "" + . CFactory::_('Compiler.Builder.Content.One')->get('Component_name') . ""; + $updateXML[] = Indent::_(2) . "" + . CFactory::_('Compiler.Builder.Content.One')->get('SHORT_DESCRIPTION') . ""; + $updateXML[] = Indent::_(2) . "$u_element"; + $updateXML[] = Indent::_(2) . "$u_server_type"; + // check if we should add the target client value + if ($u_client) + { + $updateXML[] = Indent::_(2) . "$u_client"; + } + $updateXML[] = Indent::_(2) . "" . $update['version'] + . ""; + $updateXML[] = Indent::_(2) . '' . CFactory::_('Compiler.Builder.Content.One')->get('AUTHORWEBSITE') . ''; + $updateXML[] = Indent::_(2) . ""; + if (!isset($update['url']) + || !StringHelper::check( + $update['url'] + )) + { + $update['url'] = 'http://domain.com/demo.zip'; + } + $updateXML[] = Indent::_(3) + . '' . $update['url'] + . ''; + $updateXML[] = Indent::_(2) . ""; + $updateXML[] = Indent::_(2) . ""; + $updateXML[] = Indent::_(3) . "$u_state"; + $updateXML[] = Indent::_(2) . ""; + $updateXML[] = Indent::_(2) . "" + . CFactory::_('Compiler.Builder.Content.One')->get('AUTHOR') + . ""; + $updateXML[] = Indent::_(2) . "" + . CFactory::_('Compiler.Builder.Content.One')->get('AUTHORWEBSITE') . ""; + $updateXML[] = Indent::_(2) + . ''; + $updateXML[] = Indent::_(1) . ""; + } + } + + /** + * no Help + * + * @return string + */ + public function noHelp() + { + $help = []; + $help[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $help[] = Indent::_(1) . " * Can be used to build help urls."; + $help[] = Indent::_(1) . " **/"; + $help[] = Indent::_(1) . "public static function getHelpUrl(\$view)"; + $help[] = Indent::_(1) . "{"; + $help[] = Indent::_(2) . "return false;"; + $help[] = Indent::_(1) . "}"; + + // return the no help method + return implode(PHP_EOL, $help); + } + + public function checkHelp($nameSingleCode) + { + if ($nameSingleCode == "help_document") + { + // set help file into admin place + $target = array('admin' => 'help'); + $admindone = CFactory::_('Utilities.Structure')->build($target, 'help'); + // set the help file into site place + $target = array('site' => 'help'); + $sitedone = CFactory::_('Utilities.Structure')->build($target, 'help'); + if ($admindone && $sitedone) + { + // HELP + CFactory::_('Compiler.Builder.Content.One')->set('HELP', $this->setHelp(1)); + // HELP_SITE + CFactory::_('Compiler.Builder.Content.One')->set('HELP_SITE', $this->setHelp(2)); + // to make sure the file is updated TODO + CFactory::_('Compiler.Builder.Content.Multi')->set('help' . '|BLABLA', 'blabla'); + + return true; + } + } + + return false; + } + + public function setHelp($location) + { + // set hte help function to the helper class + $target = 'admin_view'; + if ($location == 2) + { + $target = 'site_view'; + } + $help = []; + $help[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $help[] = Indent::_(1) . " * Load the Component Help URLs."; + $help[] = Indent::_(1) . " **/"; + $help[] = Indent::_(1) . "public static function getHelpUrl(\$view)"; + $help[] = Indent::_(1) . "{"; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $help[] = Indent::_(2) . "\$user = Factory::getUser();"; + } + else + { + $help[] = Indent::_(2) . "\$user = Factory::getApplication()->getIdentity();"; + } + $help[] = Indent::_(2) . "\$groups = \$user->get('groups');"; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $help[] = Indent::_(2) . "\$db = Factory::getDbo();"; + } + else + { + $help[] = Indent::_(2) . "\$db = Factory::getContainer()->get(DatabaseInterface::class);"; + } + $help[] = Indent::_(2) . "\$query = \$db->getQuery(true);"; + $help[] = Indent::_(2) + . "\$query->select(array('a.id','a.groups','a.target','a.type','a.article','a.url'));"; + $help[] = Indent::_(2) . "\$query->from('#__" . CFactory::_('Config')->component_code_name + . "_help_document AS a');"; + $help[] = Indent::_(2) . "\$query->where('a." . $target + . " = '.\$db->quote(\$view));"; + $help[] = Indent::_(2) . "\$query->where('a.location = " + . (int) $location . "');"; + $help[] = Indent::_(2) . "\$query->where('a.published = 1');"; + $help[] = Indent::_(2) . "\$db->setQuery(\$query);"; + $help[] = Indent::_(2) . "\$db->execute();"; + $help[] = Indent::_(2) . "if(\$db->getNumRows())"; + $help[] = Indent::_(2) . "{"; + $help[] = Indent::_(3) . "\$helps = \$db->loadObjectList();"; + $help[] = Indent::_(3) . "if (Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$helps))"; + $help[] = Indent::_(3) . "{"; + $help[] = Indent::_(4) . "foreach (\$helps as \$nr => \$help)"; + $help[] = Indent::_(4) . "{"; + $help[] = Indent::_(5) . "if (\$help->target == 1)"; + $help[] = Indent::_(5) . "{"; + $help[] = Indent::_(6) + . "\$targetgroups = json_decode(\$help->groups, true);"; + $help[] = Indent::_(6) + . "if (!array_intersect(\$targetgroups, \$groups))"; + $help[] = Indent::_(6) . "{"; + $help[] = Indent::_(7) . "//" . Line::_(__Line__, __Class__) + . " if user not in those target groups then remove the item"; + $help[] = Indent::_(7) . "unset(\$helps[\$nr]);"; + $help[] = Indent::_(7) . "continue;"; + $help[] = Indent::_(6) . "}"; + $help[] = Indent::_(5) . "}"; + $help[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " set the return type"; + $help[] = Indent::_(5) . "switch (\$help->type)"; + $help[] = Indent::_(5) . "{"; + $help[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__) + . " set joomla article"; + $help[] = Indent::_(6) . "case 1:"; + $help[] = Indent::_(7) + . "return self::loadArticleLink(\$help->article);"; + $help[] = Indent::_(7) . "break;"; + $help[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__) + . " set help text"; + $help[] = Indent::_(6) . "case 2:"; + $help[] = Indent::_(7) . "return self::loadHelpTextLink(\$help->id);"; + $help[] = Indent::_(7) . "break;"; + $help[] = Indent::_(6) . "//" . Line::_(__Line__, __Class__) . " set Link"; + $help[] = Indent::_(6) . "case 3:"; + $help[] = Indent::_(7) . "return \$help->url;"; + $help[] = Indent::_(7) . "break;"; + $help[] = Indent::_(5) . "}"; + $help[] = Indent::_(4) . "}"; + $help[] = Indent::_(3) . "}"; + $help[] = Indent::_(2) . "}"; + $help[] = Indent::_(2) . "return false;"; + $help[] = Indent::_(1) . "}"; + $help[] = PHP_EOL . Indent::_(1) . "/**"; + $help[] = Indent::_(1) . " * Get the Article Link."; + $help[] = Indent::_(1) . " **/"; + $help[] = Indent::_(1) + . "protected static function loadArticleLink(\$id)"; + $help[] = Indent::_(1) . "{"; + $help[] = Indent::_(2) + . "return Uri::root() . 'index.php?option=com_content&view=article&id='.\$id.'&tmpl=component&layout=modal';"; + $help[] = Indent::_(1) . "}"; + $help[] = PHP_EOL . Indent::_(1) . "/**"; + $help[] = Indent::_(1) . " * Get the Help Text Link."; + $help[] = Indent::_(1) . " **/"; + $help[] = Indent::_(1) + . "protected static function loadHelpTextLink(\$id)"; + $help[] = Indent::_(1) . "{"; + $help[] = Indent::_(2) . "\$token = Session::getFormToken();"; + $help[] = Indent::_(2) . "return 'index.php?option=com_" + . CFactory::_('Config')->component_code_name + . "&task=help.getText&id=' . (int) \$id . '&' . \$token . '=1';"; + $help[] = Indent::_(1) . "}"; + + // return the help methods + return implode(PHP_EOL, $help); + } + + public function setHelperExelMethods() + { + if (CFactory::_('Config')->get('add_eximport', false)) + { + // we use the company name set in the GUI + $company_name = CFactory::_('Compiler.Builder.Content.One')->get('COMPANYNAME'); + // start building the xml function + $exel = []; + $exel[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $exel[] = Indent::_(1) . "* Prepares the xml document"; + $exel[] = Indent::_(1) . "*/"; + $exel[] = Indent::_(1) + . "public static function xls(\$rows, \$fileName = null, \$title = null, \$subjectTab = null, \$creator = '$company_name', \$description = null, \$category = null,\$keywords = null, \$modified = null)"; + $exel[] = Indent::_(1) . "{"; + $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " set the user"; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $exel[] = Indent::_(2) . "\$user = Factory::getUser();"; + } + else + { + $help[] = Indent::_(2) . "\$user = Factory::getApplication()->getIdentity();"; + } + $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " set fileName if not set"; + $exel[] = Indent::_(2) . "if (!\$fileName)"; + $exel[] = Indent::_(2) . "{"; + $exel[] = Indent::_(3) + . "\$fileName = 'exported_'.Factory::getDate()->format('jS_F_Y');"; + $exel[] = Indent::_(2) . "}"; + $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " set modified if not set"; + $exel[] = Indent::_(2) . "if (!\$modified)"; + $exel[] = Indent::_(2) . "{"; + $exel[] = Indent::_(3) . "\$modified = \$user->name;"; + $exel[] = Indent::_(2) . "}"; + $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " set title if not set"; + $exel[] = Indent::_(2) . "if (!\$title)"; + $exel[] = Indent::_(2) . "{"; + $exel[] = Indent::_(3) . "\$title = 'Book1';"; + $exel[] = Indent::_(2) . "}"; + $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " set tab name if not set"; + $exel[] = Indent::_(2) . "if (!\$subjectTab)"; + $exel[] = Indent::_(2) . "{"; + $exel[] = Indent::_(3) . "\$subjectTab = 'Sheet1';"; + $exel[] = Indent::_(2) . "}"; + $exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " make sure we have the composer classes loaded"; + $exel[] = Indent::_(2) + . "self::composerAutoload('phpspreadsheet');"; + $exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Create new Spreadsheet object"; + $exel[] = Indent::_(2) . "\$spreadsheet = new Spreadsheet();"; + $exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Set document properties"; + $exel[] = Indent::_(2) . "\$spreadsheet->getProperties()"; + $exel[] = Indent::_(3) . "->setCreator(\$creator)"; + $exel[] = Indent::_(3) . "->setCompany('$company_name')"; + $exel[] = Indent::_(3) . "->setLastModifiedBy(\$modified)"; + $exel[] = Indent::_(3) . "->setTitle(\$title)"; + $exel[] = Indent::_(3) . "->setSubject(\$subjectTab);"; + $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " The file type"; + $exel[] = Indent::_(2) . "\$file_type = 'Xls';"; + $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " set description"; + $exel[] = Indent::_(2) . "if (\$description)"; + $exel[] = Indent::_(2) . "{"; + $exel[] = Indent::_(3) + . "\$spreadsheet->getProperties()->setDescription(\$description);"; + $exel[] = Indent::_(2) . "}"; + $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " set keywords"; + $exel[] = Indent::_(2) . "if (\$keywords)"; + $exel[] = Indent::_(2) . "{"; + $exel[] = Indent::_(3) + . "\$spreadsheet->getProperties()->setKeywords(\$keywords);"; + $exel[] = Indent::_(2) . "}"; + $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " set category"; + $exel[] = Indent::_(2) . "if (\$category)"; + $exel[] = Indent::_(2) . "{"; + $exel[] = Indent::_(3) + . "\$spreadsheet->getProperties()->setCategory(\$category);"; + $exel[] = Indent::_(2) . "}"; + $exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Some styles"; + $exel[] = Indent::_(2) . "\$headerStyles = array("; + $exel[] = Indent::_(3) . "'font' => array("; + $exel[] = Indent::_(4) . "'bold' => true,"; + $exel[] = Indent::_(4) . "'color' => array('rgb' => '1171A3'),"; + $exel[] = Indent::_(4) . "'size' => 12,"; + $exel[] = Indent::_(4) . "'name' => 'Verdana'"; + $exel[] = Indent::_(2) . "));"; + $exel[] = Indent::_(2) . "\$sideStyles = array("; + $exel[] = Indent::_(3) . "'font' => array("; + $exel[] = Indent::_(4) . "'bold' => true,"; + $exel[] = Indent::_(4) . "'color' => array('rgb' => '444444'),"; + $exel[] = Indent::_(4) . "'size' => 11,"; + $exel[] = Indent::_(4) . "'name' => 'Verdana'"; + $exel[] = Indent::_(2) . "));"; + $exel[] = Indent::_(2) . "\$normalStyles = array("; + $exel[] = Indent::_(3) . "'font' => array("; + $exel[] = Indent::_(4) . "'color' => array('rgb' => '444444'),"; + $exel[] = Indent::_(4) . "'size' => 11,"; + $exel[] = Indent::_(4) . "'name' => 'Verdana'"; + $exel[] = Indent::_(2) . "));"; + $exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Add some data"; + $exel[] = Indent::_(2) + . "if ((\$size = Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$rows)) !== false)"; + $exel[] = Indent::_(2) . "{"; + $exel[] = Indent::_(3) . "\$i = 1;"; + $exel[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Based on data size we adapt the behaviour."; + $exel[] = Indent::_(3) . "\$xls_mode = 1;"; + $exel[] = Indent::_(3) . "if (\$size > 3000)"; + $exel[] = Indent::_(3) . "{"; + $exel[] = Indent::_(4) . "\$xls_mode = 3;"; + $exel[] = Indent::_(4) . "\$file_type = 'Csv';"; + $exel[] = Indent::_(3) . "}"; + $exel[] = Indent::_(3) . "elseif (\$size > 2000)"; + $exel[] = Indent::_(3) . "{"; + $exel[] = Indent::_(4) . "\$xls_mode = 2;"; + $exel[] = Indent::_(3) . "}"; + $exel[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Set active sheet and get it."; + $exel[] = Indent::_(3) + . "\$active_sheet = \$spreadsheet->setActiveSheetIndex(0);"; + $exel[] = Indent::_(3) . "foreach (\$rows as \$array)"; + $exel[] = Indent::_(3) . "{"; + $exel[] = Indent::_(4) . "\$a = 'A';"; + $exel[] = Indent::_(4) . "foreach (\$array as \$value)"; + $exel[] = Indent::_(4) . "{"; + $exel[] = Indent::_(5) + . "\$active_sheet->setCellValue(\$a.\$i, \$value);"; + $exel[] = Indent::_(5) . "if (\$xls_mode != 3)"; + $exel[] = Indent::_(5) . "{"; + $exel[] = Indent::_(6) . "if (\$i == 1)"; + $exel[] = Indent::_(6) . "{"; + $exel[] = Indent::_(7) + . "\$active_sheet->getColumnDimension(\$a)->setAutoSize(true);"; + $exel[] = Indent::_(7) + . "\$active_sheet->getStyle(\$a.\$i)->applyFromArray(\$headerStyles);"; + $exel[] = Indent::_(7) + . "\$active_sheet->getStyle(\$a.\$i)->getAlignment()->setHorizontal(PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);"; + $exel[] = Indent::_(6) . "}"; + $exel[] = Indent::_(6) . "elseif (\$a === 'A')"; + $exel[] = Indent::_(6) . "{"; + $exel[] = Indent::_(7) + . "\$active_sheet->getStyle(\$a.\$i)->applyFromArray(\$sideStyles);"; + $exel[] = Indent::_(6) . "}"; + $exel[] = Indent::_(6) . "elseif (\$xls_mode == 1)"; + $exel[] = Indent::_(6) . "{"; + $exel[] = Indent::_(7) + . "\$active_sheet->getStyle(\$a.\$i)->applyFromArray(\$normalStyles);"; + $exel[] = Indent::_(6) . "}"; + $exel[] = Indent::_(5) . "}"; + $exel[] = Indent::_(5) . "\$a++;"; + $exel[] = Indent::_(4) . "}"; + $exel[] = Indent::_(4) . "\$i++;"; + $exel[] = Indent::_(3) . "}"; + $exel[] = Indent::_(2) . "}"; + $exel[] = Indent::_(2) . "else"; + $exel[] = Indent::_(2) . "{"; + $exel[] = Indent::_(3) . "return false;"; + $exel[] = Indent::_(2) . "}"; + $exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Rename worksheet"; + $exel[] = Indent::_(2) + . "\$spreadsheet->getActiveSheet()->setTitle(\$subjectTab);"; + $exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Set active sheet index to the first sheet, so Excel opens this as the first sheet"; + $exel[] = Indent::_(2) . "\$spreadsheet->setActiveSheetIndex(0);"; + $exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Redirect output to a client's web browser (Excel5)"; + $exel[] = Indent::_(2) + . "header('Content-Type: application/vnd.ms-excel');"; + $exel[] = Indent::_(2) + . "header('Content-Disposition: attachment;filename=\"' . \$fileName . '.' . strtolower(\$file_type) .'\"');"; + $exel[] = Indent::_(2) . "header('Cache-Control: max-age=0');"; + $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " If you're serving to IE 9, then the following may be needed"; + $exel[] = Indent::_(2) . "header('Cache-Control: max-age=1');"; + $exel[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " If you're serving to IE over SSL, then the following may be needed"; + $exel[] = Indent::_(2) + . "header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); //" + . Line::_(__Line__, __Class__) . " Date in the past"; + $exel[] = Indent::_(2) + . "header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); //" + . Line::_(__Line__, __Class__) . " always modified"; + $exel[] = Indent::_(2) + . "header ('Cache-Control: cache, must-revalidate'); //" + . Line::_(__Line__, __Class__) . " HTTP/1.1"; + $exel[] = Indent::_(2) . "header ('Pragma: public'); //" + . Line::_(__Line__, __Class__) . " HTTP/1.0"; + $exel[] = PHP_EOL . Indent::_(2) + . "\$writer = IOFactory::createWriter(\$spreadsheet, \$file_type);"; + $exel[] = Indent::_(2) . "\$writer->save('php://output');"; + $exel[] = Indent::_(2) . "jexit();"; + $exel[] = Indent::_(1) . "}"; + $exel[] = PHP_EOL . Indent::_(1) . "/**"; + $exel[] = Indent::_(1) . "* Get CSV Headers"; + $exel[] = Indent::_(1) . "*/"; + $exel[] = Indent::_(1) + . "public static function getFileHeaders(\$dataType)"; + $exel[] = Indent::_(1) . "{"; + $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " make sure we have the composer classes loaded"; + $exel[] = Indent::_(2) + . "self::composerAutoload('phpspreadsheet');"; + $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get session object"; + $exel[] = Indent::_(2) . "\$session = Factory::getSession();"; + $exel[] = Indent::_(2) + . "\$package = \$session->get('package', null);"; + $exel[] = Indent::_(2) + . "\$package = json_decode(\$package, true);"; + $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " set the headers"; + $exel[] = Indent::_(2) . "if(isset(\$package['dir']))"; + $exel[] = Indent::_(2) . "{"; + $exel[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " only load first three rows"; + $exel[] = Indent::_(3) + . "\$chunkFilter = new PhpOffice\PhpSpreadsheet\Reader\chunkReadFilter(2,1);"; + $exel[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " identify the file type"; + $exel[] = Indent::_(3) + . "\$inputFileType = IOFactory::identify(\$package['dir']);"; + $exel[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " create the reader for this file type"; + $exel[] = Indent::_(3) + . "\$excelReader = IOFactory::createReader(\$inputFileType);"; + $exel[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " load the limiting filter"; + $exel[] = Indent::_(3) + . "\$excelReader->setReadFilter(\$chunkFilter);"; + $exel[] = Indent::_(3) . "\$excelReader->setReadDataOnly(true);"; + $exel[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " load the rows (only first three)"; + $exel[] = Indent::_(3) + . "\$excelObj = \$excelReader->load(\$package['dir']);"; + $exel[] = Indent::_(3) . "\$headers = [];"; + $exel[] = Indent::_(3) + . "foreach (\$excelObj->getActiveSheet()->getRowIterator() as \$row)"; + $exel[] = Indent::_(3) . "{"; + $exel[] = Indent::_(4) . "if(\$row->getRowIndex() == 1)"; + $exel[] = Indent::_(4) . "{"; + $exel[] = Indent::_(5) + . "\$cellIterator = \$row->getCellIterator();"; + $exel[] = Indent::_(5) + . "\$cellIterator->setIterateOnlyExistingCells(false);"; + $exel[] = Indent::_(5) . "foreach (\$cellIterator as \$cell)"; + $exel[] = Indent::_(5) . "{"; + $exel[] = Indent::_(6) . "if (!is_null(\$cell))"; + $exel[] = Indent::_(6) . "{"; + $exel[] = Indent::_(7) + . "\$headers[\$cell->getColumn()] = \$cell->getValue();"; + $exel[] = Indent::_(6) . "}"; + $exel[] = Indent::_(5) . "}"; + $exel[] = Indent::_(5) . "\$excelObj->disconnectWorksheets();"; + $exel[] = Indent::_(5) . "unset(\$excelObj);"; + $exel[] = Indent::_(5) . "break;"; + $exel[] = Indent::_(4) . "}"; + $exel[] = Indent::_(3) . "}"; + $exel[] = Indent::_(3) . "return \$headers;"; + $exel[] = Indent::_(2) . "}"; + $exel[] = Indent::_(2) . "return false;"; + $exel[] = Indent::_(1) . "}"; + $exel[] = PHP_EOL . Indent::_(1) . "/**"; + $exel[] = Indent::_(1) + . "* Load the Composer Vendor phpspreadsheet"; + $exel[] = Indent::_(1) . "*/"; + $exel[] = Indent::_(1) + . "protected static function composephpspreadsheet()"; + $exel[] = Indent::_(1) . "{"; + $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " load the autoloader for phpspreadsheet"; + $exel[] = Indent::_(2) + . "require_once JPATH_SITE . '/libraries/phpspreadsheet/vendor/autoload.php';"; + $exel[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " do not load again"; + $exel[] = Indent::_(2) + . "self::\$composer['phpspreadsheet'] = true;"; + $exel[] = PHP_EOL . Indent::_(2) . "return true;"; + $exel[] = Indent::_(1) . "}"; + + // return the help methods + return implode(PHP_EOL, $exel); + } + + return ''; + } + + public function setCreateUserHelperMethod($add) + { + if ($add) + { + $method = []; + $method[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $method[] = Indent::_(1) . " * Greate user and update given table"; + $method[] = Indent::_(1) . " *"; + $method[] = Indent::_(1) + . " * @param array \$credentials Array('name' => string, 'username' => string, 'email' => string, 'password' => string, 'password2' => string)"; + $method[] = Indent::_(1) . " * @param int \$autologin"; + $method[] = Indent::_(1) + . " * @param array \$params Array('useractivation' => int, 'sendpassword' => int, 'allowUserRegistration' => int)"; + $method[] = Indent::_(1) + . " * @param array \$mode 1 = Site Registrations; 0 = Admin Registration; 2 = Custom Helper Method Called registerUser"; + $method[] = Indent::_(1) . " *"; + $method[] = Indent::_(1) + . " * @return int|Error User ID on success, or an error."; + $method[] = Indent::_(1) . " */"; + $method[] = Indent::_(1) + . "public static function createUser(\$credentials, \$autologin = 0,"; + $method[] = Indent::_(2) . "\$params = array("; + $method[] = Indent::_(3) + . "'useractivation' => 0, 'sendpassword' => 1"; + $method[] = Indent::_(2) . "), \$mode = 1"; + $method[] = Indent::_(1) . ")"; + $method[] = Indent::_(1) . "{"; + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Override mode"; + $method[] = Indent::_(2) + . "if (\$mode == 2 && method_exists(__CLASS__, 'registerUser'))"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Update params"; + $method[] = Indent::_(3) . "\$params['autologin'] = \$autologin;"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Now Register User"; + $method[] = Indent::_(3) + . "return self::registerUser(\$credentials, \$params);"; + $method[] = Indent::_(2) . "}"; + $method[] = Indent::_(2) . "elseif (\$mode == 2)"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Fallback to Site Registrations"; + $method[] = Indent::_(3) . "\$mode = 1;"; + $method[] = Indent::_(2) . "}"; + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " load the user component language files if there is an error."; + $method[] = Indent::_(2) . "\$lang = Factory::getLanguage();"; + $method[] = Indent::_(2) . "\$extension = 'com_users';"; + $method[] = Indent::_(2) . "\$base_dir = JPATH_SITE;"; + $method[] = Indent::_(2) . "\$language_tag = '" . CFactory::_('Config')->get('lang_tag', 'en-GB') + . "';"; + $method[] = Indent::_(2) . "\$reload = true;"; + $method[] = Indent::_(2) + . "\$lang->load(\$extension, \$base_dir, \$language_tag, \$reload);"; + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Load the correct user model."; + $method[] = Indent::_(2) . "if (\$mode == 1) //" . Line::_( + __LINE__,__CLASS__ + ) + . " 1 = Site Registrations"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Load the user site-registration model"; + $method[] = Indent::_(3) + . "\$model = self::getModel('registration', \$base_dir . '/components/' . \$extension, 'Users');"; + $method[] = Indent::_(2) . "}"; + $method[] = Indent::_(2) . "else //" . Line::_(__Line__, __Class__) + . " 0 = Admin Registration"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Load the backend-user model"; + $method[] = Indent::_(3) + . "\$model = self::getModel('user', JPATH_ADMINISTRATOR . '/components/' . \$extension, 'Users');"; + $method[] = Indent::_(2) . "}"; + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Check if we have params/config"; + $method[] = Indent::_(2) . "if (Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$params))"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Make changes to user config"; + $method[] = Indent::_(3) + . "foreach (\$params as \$param => \$set)"; + $method[] = Indent::_(3) . "{"; + $method[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " If you know of a better path, let me know"; + $method[] = Indent::_(4) + . "\$params[\$param] = self::setParams(\$extension, \$param, \$set);"; + $method[] = Indent::_(3) . "}"; + $method[] = Indent::_(2) . "}"; + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Set username to email if not set"; + $method[] = Indent::_(2) + . "if (!isset(\$credentials['username']) || !Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$credentials['username']))"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) + . "\$credentials['username'] = \$credentials['email'];"; + $method[] = Indent::_(2) . "}"; + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Lineup new user data array"; + $method[] = Indent::_(2) . "\$data = array("; + $method[] = Indent::_(3) + . "'username' => \$credentials['username'],"; + $method[] = Indent::_(3) . "'name' => \$credentials['name'],"; + $method[] = Indent::_(3) . "'block' => 0 );"; + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Added details based on mode"; + $method[] = Indent::_(2) . "if (\$mode == 1) //" . Line::_( + __LINE__,__CLASS__ + ) + . " 1 = Site-registration mode"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) + . "\$data['email1'] = \$credentials['email'];"; + $method[] = Indent::_(2) . "}"; + $method[] = Indent::_(2) . "else //" . Line::_(__Line__, __Class__) + . " 0 = Admin-registration mode"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) + . "\$data['email'] = \$credentials['email'];"; + $method[] = Indent::_(3) + . "\$data['registerDate'] = Factory::getDate()->toSql();"; + $method[] = Indent::_(2) . "}"; + + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Check if password was set"; + $method[] = Indent::_(2) + . "if (\$mode == 1 && (!isset(\$credentials['password']) || !isset(\$credentials['password2']) || !Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$credentials['password']) || !Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$credentials['password2'])))"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Set random password when empty password was submitted,"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " when using the 1 = site-registration mode"; + $method[] = Indent::_(3) + . "\$credentials['password'] = self::randomkey(8);"; + $method[] = Indent::_(3) + . "\$credentials['password2'] = \$credentials['password'];"; + $method[] = Indent::_(2) . "}"; + + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Now Add password if set"; + $method[] = Indent::_(2) + . "if (isset(\$credentials['password']) && isset(\$credentials['password2']) && Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$credentials['password']) && Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$credentials['password2']))"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) . "if (\$mode == 1) //" . Line::_( + __LINE__,__CLASS__ + ) + . " 1 = Site-registration mode"; + $method[] = Indent::_(3) . "{"; + $method[] = Indent::_(4) + . "\$data['password1'] = \$credentials['password'];"; + $method[] = Indent::_(3) . "}"; + $method[] = Indent::_(3) . "else //" . Line::_(__Line__, __Class__) + . " 0 = Admin-registration mode"; + $method[] = Indent::_(3) . "{"; + $method[] = Indent::_(4) + . "\$data['password'] = \$credentials['password'];"; + $method[] = Indent::_(3) . "}"; + $method[] = Indent::_(3) + . "\$data['password2'] = \$credentials['password2'];"; + $method[] = Indent::_(2) . "}"; + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Load the group/s value if set, only for Admin Registration (\$mode == 0)"; + $method[] = Indent::_(2) + . "if (\$mode == 0 && isset(\$credentials['groups']) && Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$credentials['groups']))"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) + . "\$data['groups'] = \$credentials['groups'];"; + $method[] = Indent::_(2) . "}"; + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Create the new user"; + $method[] = Indent::_(2) . "if (\$mode == 1) //" . Line::_( + __LINE__,__CLASS__ + ) + . " 1 = Site-registration mode"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) . "\$userId = \$model->register(\$data);"; + $method[] = Indent::_(2) . "}"; + $method[] = Indent::_(2) . "else //" . Line::_(__Line__, __Class__) + . " 0 = Admin-registration mode"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) . "\$model->save(\$data);"; + $method[] = Indent::_(3) + . "\$userId = \$model->getState('user.id', 0);"; + $method[] = Indent::_(2) . "}"; + + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Check if we have params"; + $method[] = Indent::_(2) . "if (Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$params))"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Change user params/config back"; + $method[] = Indent::_(3) + . "foreach (\$params as \$param => \$set)"; + $method[] = Indent::_(3) . "{"; + $method[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " If you know of a better path, let me know"; + $method[] = Indent::_(4) + . "self::setParams(\$extension, \$param, \$set);"; + $method[] = Indent::_(3) . "}"; + $method[] = Indent::_(2) . "}"; + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " if user is created"; + $method[] = Indent::_(2) . "if (\$userId > 0)"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Auto Login if Needed"; + $method[] = Indent::_(3) + . "if (\$autologin && isset(\$credentials['password']))"; + $method[] = Indent::_(3) . "{"; + $method[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Try to login"; + $method[] = Indent::_(4) . "try{"; + $method[] = Indent::_(5) + . "Factory::getApplication()->login(\$credentials);"; + $method[] = Indent::_(4) . "} catch (\Exception \$exception){"; + $method[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " Do noting for now, may want to set redirect."; + $method[] = Indent::_(4) . "}"; + $method[] = Indent::_(3) . "}"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Return ID"; + $method[] = Indent::_(3) . "return \$userId;"; + $method[] = Indent::_(2) . "}"; + $method[] = Indent::_(2) . "return \$model->getError();"; + $method[] = Indent::_(1) . "}"; + + $method[] = PHP_EOL . Indent::_(1) + . "public static function setParams(\$component,\$target,\$value)"; + $method[] = Indent::_(1) . "{"; + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Get the params and set the new values"; + $method[] = Indent::_(2) + . "\$params = ComponentHelper::getParams(\$component);"; + $method[] = Indent::_(2) . "\$was = \$params->get(\$target, null);"; + $method[] = Indent::_(2) . "if (\$was != \$value)"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) . "\$params->set(\$target, \$value);"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Get a new database query instance"; + + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $method[] = Indent::_(3) . "\$db = Factory::getDBO();"; + } + else + { + $method[] = Indent::_(3) . "\$db = Factory::getContainer()->get(DatabaseInterface::class);"; + } + + $method[] = Indent::_(3) . "\$query = \$db->getQuery(true);"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Build the query"; + $method[] = Indent::_(3) . "\$query->update('#__extensions AS a');"; + $method[] = Indent::_(3) + . "\$query->set('a.params = ' . \$db->quote((string)\$params));"; + $method[] = Indent::_(3) + . "\$query->where('a.element = ' . \$db->quote((string)\$component));"; + $method[] = Indent::_(3); + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Execute the query"; + $method[] = Indent::_(3) . "\$db->setQuery(\$query);"; + $method[] = Indent::_(3) . "\$db->execute();"; + $method[] = Indent::_(2) . "}"; + $method[] = Indent::_(2) . "return \$was;"; + $method[] = Indent::_(1) . "}"; + + $method[] = PHP_EOL . Indent::_(1) . "/**"; + $method[] = Indent::_(1) . " * Update user values"; + $method[] = Indent::_(1) . " */"; + $method[] = Indent::_(1) + . "public static function updateUser(\$new)"; + $method[] = Indent::_(1) . "{"; + $method[] = Indent::_(2) + . "// load the user component language files if there is an error."; + $method[] = Indent::_(2) . "\$lang = Factory::getLanguage();"; + $method[] = Indent::_(2) . "\$extension = 'com_users';"; + $method[] = Indent::_(2) . "\$base_dir = JPATH_ADMINISTRATOR;"; + $method[] = Indent::_(2) . "\$language_tag = '" . CFactory::_('Config')->get('lang_tag', 'en-GB') + . "';"; + $method[] = Indent::_(2) . "\$reload = true;"; + $method[] = Indent::_(2) + . "\$lang->load(\$extension, \$base_dir, \$language_tag, \$reload);"; + $method[] = Indent::_(2) . "// load the user model"; + $method[] = Indent::_(2) + . "\$model = self::getModel('user', JPATH_ADMINISTRATOR . '/components/com_users', 'Users');"; + $method[] = Indent::_(2) . "// Check if password was set"; + $method[] = Indent::_(2) + . "if (isset(\$new['password']) && isset(\$new['password2']) && Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$new['password']) && Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$new['password2']))"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) . "// Use the users passwords"; + $method[] = Indent::_(3) . "\$password = \$new['password'];"; + $method[] = Indent::_(3) . "\$password2 = \$new['password2'];"; + $method[] = Indent::_(2) . "}"; + $method[] = Indent::_(2) . "// set username"; + $method[] = Indent::_(2) + . "if (!isset(\$new['username']) || !Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$new['username']))"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) + . "\$new['username'] = \$new['email'];"; + $method[] = Indent::_(2) . "}"; + $method[] = Indent::_(2) . "// lineup update user data"; + $method[] = Indent::_(2) . "\$data = array("; + $method[] = Indent::_(3) . "'id' => \$new['id'],"; + $method[] = Indent::_(3) . "'username' => \$new['username'],"; + $method[] = Indent::_(3) . "'name' => \$new['name'],"; + $method[] = Indent::_(3) . "'email' => \$new['email'],"; + $method[] = Indent::_(3) + . "'password' => \$password, // First password field"; + $method[] = Indent::_(3) + . "'password2' => \$password2, // Confirm password field"; + $method[] = Indent::_(3) . "'block' => 0 );"; + $method[] = Indent::_(2) . "// set groups if found"; + $method[] = Indent::_(2) + . "if (isset(\$new['groups']) && Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$new['groups']))"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) . "\$data['groups'] = \$new['groups'];"; + $method[] = Indent::_(2) . "}"; + $method[] = Indent::_(2) . "// register the new user"; + $method[] = Indent::_(2) . "\$done = \$model->save(\$data);"; + $method[] = Indent::_(2) . "// if user is updated"; + $method[] = Indent::_(2) . "if (\$done)"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) . "return \$new['id'];"; + $method[] = Indent::_(2) . "}"; + $method[] = Indent::_(2) . "return \$model->getError();"; + $method[] = Indent::_(1) . "}"; + + // return the help method + return implode(PHP_EOL, $method); + } + + return ''; + } + + public function setAdminViewMenu(&$nameSingleCode, &$view) + { + $xml = ''; + // build the file target values + $target = array('site' => $nameSingleCode); + // build the edit.xml file + if (CFactory::_('Utilities.Structure')->build($target, 'admin_menu')) + { + // set the lang + $lang = StringHelper::safe( + 'com_' . CFactory::_('Config')->component_code_name . '_menu_' + . $nameSingleCode, + 'U' + ); + CFactory::_('Language')->set( + 'adminsys', $lang . '_TITLE', + 'Create ' . $view['settings']->name_single + ); + CFactory::_('Language')->set( + 'adminsys', $lang . '_OPTION', + 'Create ' . $view['settings']->name_single + ); + CFactory::_('Language')->set( + 'adminsys', $lang . '_DESC', + $view['settings']->short_description + ); + //start loading xml + $xml = ''; + $xml .= PHP_EOL . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(3) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . ''; + } + else + { + $this->app->enqueueMessage( + Text::sprintf( + '

    Site menu for %s was not build.

    ', + $nameSingleCode + ), 'Warning' + ); + } + + return $xml; + } + + public function setCustomViewMenu(&$view) + { + $target_area = 'Administrator'; + if (CFactory::_('Config')->build_target === 'site') + { + $target_area = 'Site'; + } + $xml = ''; + // build the file target values + $target = array('site' => $view['settings']->code); + // build the default.xml file + if (CFactory::_('Utilities.Structure')->build($target, 'menu')) + { + // set the lang + $lang = StringHelper::safe( + 'com_' . CFactory::_('Config')->component_code_name . '_menu_' + . $view['settings']->code, 'U' + ); + CFactory::_('Language')->set( + 'adminsys', $lang . '_TITLE', $view['settings']->name + ); + CFactory::_('Language')->set( + 'adminsys', $lang . '_OPTION', $view['settings']->name + ); + CFactory::_('Language')->set( + 'adminsys', $lang . '_DESC', $view['settings']->description + ); + //start loading xml + $xml = ''; + $xml .= PHP_EOL . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(3) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + if (CFactory::_('Compiler.Builder.Request')->isArray("id.{$view['settings']->code}") + || CFactory::_('Compiler.Builder.Request')->isArray("catid.{$view['settings']->code}")) + { + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . '
    get('joomla_version', 3) == 3) + { + $xml .= PHP_EOL . Indent::_(3) + . 'addrulepath="/administrator/components/com_' + . CFactory::_('Config')->component_code_name . '/models/rules"'; + $xml .= PHP_EOL . Indent::_(3) + . 'addfieldpath="/administrator/components/com_' + . CFactory::_('Config')->component_code_name . '/models/fields">'; + } + else + { + $xml .= PHP_EOL . Indent::_(3) + . 'addruleprefix="' . CFactory::_('Config')->namespace_prefix + . '\Component\\' . CFactory::_('Compiler.Builder.Content.One')->get('ComponentNameSpace') + . '\\'. $target_area . '\Rule"'; + $xml .= PHP_EOL . Indent::_(3) + . 'addfieldprefix="' . CFactory::_('Config')->namespace_prefix + . '\Component\\' . CFactory::_('Compiler.Builder.Content.One')->get('ComponentNameSpace') + . '\\'. $target_area . '\Field">'; + } + + if (CFactory::_('Compiler.Builder.Request')->isArray("id.{$view['settings']->code}")) + { + foreach (CFactory::_('Compiler.Builder.Request')-> + get("id.{$view['settings']->code}") as $requestFieldXML) + { + $xml .= PHP_EOL . Indent::_(3) . $requestFieldXML; + } + } + if (CFactory::_('Compiler.Builder.Request')->isArray("catid.{$view['settings']->code}")) + { + foreach (CFactory::_('Compiler.Builder.Request')-> + get("catid.{$view['settings']->code}") as $requestFieldXML) + { + $xml .= PHP_EOL . Indent::_(3) . $requestFieldXML; + } + } + $xml .= PHP_EOL . Indent::_(2) . '
    '; + $xml .= PHP_EOL . Indent::_(1) . '
    '; + } + if (CFactory::_('Compiler.Builder.Frontend.Params')->exists($view['settings']->name)) + { + // first we must setup the fields for the page use + $params = $this->setupFrontendParamFields( + CFactory::_('Compiler.Builder.Frontend.Params')->get($view['settings']->name), + $view['settings']->code + ); + // now load the fields + if (ArrayHelper::check($params)) + { + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) + . '
    get('joomla_version', 3) == 3) + { + $xml .= PHP_EOL . Indent::_(3) + . 'addrulepath="/administrator/components/com_' + . CFactory::_('Config')->component_code_name . '/models/rules"'; + $xml .= PHP_EOL . Indent::_(3) + . 'addfieldpath="/administrator/components/com_' + . CFactory::_('Config')->component_code_name . '/models/fields">'; + } + else + { + $xml .= PHP_EOL . Indent::_(3) + . 'addruleprefix="' . CFactory::_('Config')->namespace_prefix + . '\Component\\' . CFactory::_('Compiler.Builder.Content.One')->get('ComponentNameSpace') + . '\\'. $target_area . '\Rule"'; + $xml .= PHP_EOL . Indent::_(3) + . 'addfieldprefix="' . CFactory::_('Config')->namespace_prefix + . '\Component\\' . CFactory::_('Compiler.Builder.Content.One')->get('ComponentNameSpace') + . '\\'. $target_area . '\Field">'; + } + $xml .= implode(Indent::_(3), $params); + $xml .= PHP_EOL . Indent::_(2) . '
    '; + $xml .= PHP_EOL . Indent::_(1) . '
    '; + } + } + $xml .= PHP_EOL . '
    '; + } + else + { + $this->app->enqueueMessage( + Text::sprintf( + '

    Site menu for %s was not build.

    ', + $view['settings']->code + ), 'Warning' + ); + } + + return $xml; + } + + public function setupFrontendParamFields($params, $view) + { + $keep = []; + $menuSetter = $view . '_menu'; + foreach ($params as $field) + { + // some switch to see if it should be added to front end params + $target = GetHelper::between( + $field, 'display="', '"' + ); + if (!StringHelper::check($target) + || $target === 'menu') + { + $field = str_replace('display="menu"', '', (string) $field); + // we update fields that have options if not only added to menu + if ($target !== 'menu' + && strpos($field, 'Option Set. -->') !== false + && strpos($field, $menuSetter) === false + && !StringHelper::check($target)) + { + // we add the global option + $field = str_replace( + 'Option Set. -->', + Line::_(__Line__, __Class__) . ' Global & Option Set. -->' + . PHP_EOL . Indent::_(3) . '', $field + ); + // update the default to be global + $field = preg_replace( + '/default=".+"/', 'default=""', $field + ); + // update the default to be filter + $field = preg_replace( + '/filter=".+"/', 'filter="string"', $field + ); + // update required + $field = str_replace( + 'required="true"', 'required="false"', $field + ); + // add to keeper array + $keep[] = $field; + } + else + { + $keep[] = $field; + } + } + } + + return $keep; + } + + public function setCustomViewQuery(&$gets, &$code, $tab = '', $type = 'main' + ) + { + $query = ''; + if (ArrayHelper::check($gets)) + { + $mainAsArray = []; + $check = 'zzz'; + foreach ($gets as $nr => $the_get) + { + // to insure that there be no double entries of a call + $checker = md5(serialize($the_get) . $code); + if (!isset($this->customViewQueryChecker[CFactory::_('Config')->build_target]) + || !isset($checker, $this->customViewQueryChecker[CFactory::_('Config')->build_target][$checker])) + { + // load this unuiqe key + $this->customViewQueryChecker[CFactory::_('Config')->build_target][$checker] + = true; + if (isset($the_get['selection']['type']) + && StringHelper::check( + $the_get['selection']['type'] + )) + { + $getItem = PHP_EOL . PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "//" . Line::_(__Line__, __Class__) + . " Get from " . $the_get['selection']['table'] + . " as " . $the_get['as']; + // set the selection + $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . $the_get['selection']['select']; + } + else + { + $getItem = PHP_EOL . PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "//" . Line::_(__Line__, __Class__) + . " Get data"; + // set the selection + $getItem .= PHP_EOL . CFactory::_('Placeholder')->update_( + $the_get['selection']['select'] + ); + } + // load the from selection + if (($nr == 0 + && (!isset($the_get['join_field']) + || !StringHelper::check( + $the_get['join_field'] + )) + && (isset($the_get['selection']['type']) + && StringHelper::check( + $the_get['selection']['type'] + ))) + || ($type === 'custom' + && (isset($the_get['selection']['type']) + && StringHelper::check( + $the_get['selection']['type'] + )))) + { + $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . '$query->from(' . $the_get['selection']['from'] + . ');'; + } + elseif (isset($the_get['join_field']) + && StringHelper::check( + $the_get['join_field'] + ) + && isset($the_get['selection']['type']) + && StringHelper::check( + $the_get['selection']['type'] + )) + { + $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "\$query->join('" . $the_get['type']; + $getItem .= "', (" . $the_get['selection']['from']; + $getItem .= ") . ' ON (' . \$db->quoteName('" + . $the_get['on_field']; + $getItem .= "') . ' " . $the_get['operator']; + $getItem .= " ' . \$db->quoteName('" + . $the_get['join_field'] . "') . ')');"; + + $check = current(explode(".", (string) $the_get['on_field'])); + } + + // set the method defaults + if (($default = $this->setCustomViewMethodDefaults($the_get, $code)) !== false) + { + if (($join_field_ = CFactory::_('Compiler.Builder.Site.Dynamic.Get')->get(CFactory::_('Config')->build_target . + '.' . $default['code'] . '.' . $default['as'] . '.' . $default['join_field'])) !== null + && !in_array($check, $mainAsArray)) + { + // load to other query + CFactory::_('Compiler.Builder.Other.Query')->add( + CFactory::_('Config')->build_target . '.' . $default['code'] . '.' . $join_field_ . '.' . $default['valueName'], + $getItem, + false + ); + } + else + { + $mainAsArray[] = $default['as']; + $query .= $getItem; + } + } + } + } + } + + return $query; + } + + public function setCustomViewFieldDecodeFilter(&$get, &$filters, $string, + $removeString, $code, $tab + ) + { + $filter = ''; + // check if filter is set for this field + if (ArrayHelper::check($filters)) + { + foreach ($filters as $field => $ter) + { + // build load counter + $key = md5( + 'setCustomViewFieldDecodeFilter' . $code . $get['key'] + . $string . $ter['table_key'] + ); + // check if we should load this again + if (strpos((string) $get['selection']['select'], (string) $ter['table_key']) + !== false + && !isset($this->loadTracker[$key])) + { + // set the key + $this->loadTracker[$key] = $key; + $as = ''; + $felt = ''; + list($as, $felt) = array_map( + 'trim', explode('.', (string) $ter['table_key']) + ); + if ($get['as'] == $as) + { + switch ($ter['filter_type']) + { + case 4: + // COM_COMPONENTBUILDER_DYNAMIC_GET_USER_GROUPS + $filter .= PHP_EOL . PHP_EOL . Indent::_(1) + . $tab . Indent::_(1) . "//" + . Line::_(__Line__, __Class__) . " filter " + . $as . " based on user groups"; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) + . "\$remove = (count(array_intersect((array) \$this->groups, (array) " + . $string . "->" . $field + . "))) ? false : true;"; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "if (\$remove)"; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "{"; + if ($removeString == $string) + { + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Remove " . $string + . " if user not in groups"; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . $string . " = null;"; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . "return false;"; + } + else + { + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Unset " . $string + . " if user not in groups"; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . "unset(" + . $removeString . ");"; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . "continue;"; + } + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "}"; + break; + case 9: + // COM_COMPONENTBUILDER_DYNAMIC_GET_ARRAY_VALUE + + $filter .= PHP_EOL . PHP_EOL . Indent::_(1) + . $tab . Indent::_(1) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(" . $string . "->" + . $field . "))"; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "{"; + + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " do your thing here"; + + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "}"; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "else"; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "{"; + + if ($removeString == $string) + { + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Remove " . $string + . " if not array."; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . $string . " = null;"; + } + else + { + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Unset " . $string + . " if not array."; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . "unset(" + . $removeString . ");"; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . "continue;"; + } + + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "}"; + break; + case 10: + // COM_COMPONENTBUILDER_DYNAMIC_GET_REPEATABLE_VALUE + $filter .= PHP_EOL . PHP_EOL . Indent::_(1) + . $tab . Indent::_(1) . "//" + . Line::_(__Line__, __Class__) . " filter " + . $as . " based on repeatable value"; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "if (" + . "Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(" . $string . "->" + . $field . "))"; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "{"; + + $filter .= PHP_EOL . Indent::_(2) . $tab + . Indent::_(1) . "\$array = json_decode(" + . $string . "->" . $field . ",true);"; + $filter .= PHP_EOL . Indent::_(2) . $tab + . Indent::_(1) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$array))"; + $filter .= PHP_EOL . Indent::_(2) . $tab + . Indent::_(1) . "{"; + + $filter .= PHP_EOL . Indent::_(2) . $tab + . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " do your thing here"; + + $filter .= PHP_EOL . Indent::_(2) . $tab + . Indent::_(1) . "}"; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . "else"; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . "{"; + + if ($removeString == $string) + { + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Remove " . $string + . " if not array."; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(3) . $string . " = null;"; + } + else + { + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Unset " . $string + . " if not array."; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(3) . "unset(" + . $removeString . ");"; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(3) . "continue;"; + } + + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . "}"; + + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "}"; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "else"; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "{"; + + if ($removeString == $string) + { + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Remove " . $string + . " if not string."; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . $string . " = null;"; + } + else + { + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Unset " . $string + . " if not string."; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . "unset(" + . $removeString . ");"; + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . "continue;"; + } + + $filter .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "}"; + break; + } + } + } + } + } + + return $filter; + } + + public function setCustomViewFieldDecode(&$get, $checker, $string, $code, + $tab = '' + ) + { + $fieldDecode = ''; + foreach ($checker as $field => $array) + { + // build load counter + $key = md5( + 'setCustomViewFieldDecode' . $code . $get['key'] . $string + . $field + ); + // check if we should load this again + if (strpos((string) $get['selection']['select'], (string) $field) !== false + && !isset($this->loadTracker[$key]) + && ArrayHelper::check($array['decode'])) + { + // set the key + $this->loadTracker[$key] = $key; + // insure it is unique + $array['decode'] = (array) array_unique( + array_reverse((array) $array['decode']) + ); + // now loop the array + foreach ($array['decode'] as $decode) + { + $if = ''; + $decoder = ''; + if ('json' === $decode) + { + $if = PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "if (isset(" . $string . "->" . $field . ") && " + . "Super_" . "__4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::check(" + . $string . "->" . $field . "))" . PHP_EOL + . Indent::_(1) . $tab . Indent::_(1) . "{"; + // json_decode + $decoder = $string . "->" . $field . " = json_decode(" + . $string . "->" . $field . ", true);"; + } + elseif ('base64' === $decode) + { + $if = PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "if (!empty(" . $string . "->" . $field . ") && " + . $string . "->" . $field + . " === base64_encode(base64_decode(" . $string + . "->" . $field . ")))" . PHP_EOL . Indent::_(1) + . $tab . Indent::_(1) . "{"; + // base64_decode + $decoder = $string . "->" . $field . " = base64_decode(" + . $string . "->" . $field . ");"; + } + elseif (strpos((string) $decode, '_encryption') !== false + || 'expert_mode' === $decode) + { + foreach (CFactory::_('Config')->cryption_types as $cryptionType) + { + if ($cryptionType . '_encryption' === $decode + || $cryptionType . '_mode' === $decode) + { + if ('expert' !== $cryptionType) + { + $if = PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "if (!empty(" . $string + . "->" . $field . ") && \$" + . $cryptionType . "key && !is_numeric(" + . $string . "->" . $field . ") && " + . $string . "->" . $field + . " === base64_encode(base64_decode(" + . $string . "->" . $field . ", true)))" + . PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "{"; + // set decryption + $decoder = $string . "->" . $field + . " = rtrim(\$" . $cryptionType + . "->decryptString(" . $string . "->" + . $field . "), " . '"\0"' . ");"; + } + elseif (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field')-> + exists($array['admin_view'] . '.' . $field)) + { + $_placeholder_for_field + = array('[[[field]]]' => $string + . "->" . $field); + $fieldDecode .= CFactory::_('Placeholder')->update( + PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . implode( + PHP_EOL . Indent::_(1) . $tab + . Indent::_(1), + CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field')->get( + $array['admin_view'] . '.' . $field . '.get', ['error']) + ), $_placeholder_for_field + ); + } + // activate site decryption + CFactory::_('Compiler.Builder.Site.Decrypt')->set("{$cryptionType}.{$code}", true); + } + } + } + // check if we have found the details + if (StringHelper::check($if)) + { + // build decoder string + $fieldDecode .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "//" . Line::_(__Line__, __Class__) + . " Check if we can decode " . $field . $if + . PHP_EOL . Indent::_(1) . $tab . Indent::_(2) + . "//" . Line::_(__Line__, __Class__) . " Decode " + . $field; + } + if (StringHelper::check($decoder)) + { + // build decoder string + $fieldDecode .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(2) . $decoder . PHP_EOL . Indent::_(1) + . $tab . Indent::_(1) . "}"; + } + } + } + } + + return $fieldDecode; + } + + public function setCustomViewFieldonContentPrepareChecker(&$get, $checker, + $string, $code, $tab = '' + ) + { + $fieldPrepare = ''; + $runplugins = false; + // set component + $Component = CFactory::_('Compiler.Builder.Content.One')->get('Component'); + // set context + $context = (isset($get['context'])) ? $get['context'] : $code; + $context = 'com_' . CFactory::_('Config')->component_code_name . '.' . $context; + // load parms builder only once + $params = false; + foreach ($checker as $field => $array) + { + // build load counter + $key = md5( + 'setCustomViewFieldonContentPrepareChecker' . $code + . $get['key'] . $string . $field + ); + // check if we should load this again + if (strpos((string) $get['selection']['select'], (string) $field) !== false + && !isset($this->loadTracker[$key])) + { + // set the key + $this->loadTracker[$key] = $key; + // build decoder string + if (!$runplugins) + { + $runplugins = PHP_EOL . $tab . Indent::_(1) . "//" + . Line::_(__Line__, __Class__) + . " Load the JEvent Dispatcher"; + $runplugins .= PHP_EOL . $tab . Indent::_(1) + . "PluginHelper::importPlugin('content');"; + $runplugins .= PHP_EOL . $tab . Indent::_(1) + . '$this->_dispatcher = Factory::getApplication();'; + } + if (!$params) + { + $fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_( + 1 + ) . "//" . Line::_(__Line__, __Class__) + . " Check if item has params, or pass whole item."; + $fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_( + 1 + ) . "\$params = (isset(" . $string . "->params) && " + . "Super_" . "__4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::check(" . $string + . "->params)) ? json_decode(" . $string . "->params) : " + . $string . ";"; + $params = true; + } + $fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "//" . Line::_(__Line__, __Class__) + . " Make sure the content prepare plugins fire on " + . $field; + $fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "\$_" . $field . " = new \stdClass();"; + $fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "\$_" . $field . '->text =& ' . $string . '->' . $field + . '; //' . Line::_(__Line__, __Class__) + . ' value must be in text'; + $fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "//" . Line::_(__Line__, __Class__) + . " Since all values are now in text (Joomla Limitation), we also add the field name (" + . $field . ") to context"; + $fieldPrepare .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . '$this->_dispatcher->triggerEvent("onContentPrepare", array(\'' + . $context . '.' . $field . '\', &$_' . $field + . ', &$params, 0));'; + } + } + // load dispatcher + if ($runplugins) + { + $this->JEventDispatcher = array(Placefix::_h('DISPATCHER') => $runplugins); + } + + // return content prepare fix + return $fieldPrepare; + } + + public function setCustomViewFieldUikitChecker(&$get, $checker, $string, + $code, $tab = '' + ) + { + $fieldUikit = ''; + foreach ($checker as $field => $array) + { + // build load counter + $key = md5( + 'setCustomViewFieldUikitChecker' . $code . $get['key'] . $string + . $field + ); + // check if we should load this again + if (strpos((string) $get['selection']['select'], (string) $field) !== false + && !isset($this->loadTracker[$key])) + { + // set the key + $this->loadTracker[$key] = $key; + // only load for uikit version 2 (TODO) we may need to add another check here + if (2 == CFactory::_('Config')->uikit || 1 == CFactory::_('Config')->uikit) + { + $fieldUikit .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "//" . Line::_(__Line__, __Class__) . " Checking if " + . $field . " has uikit components that must be loaded."; + $fieldUikit .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "\$this->uikitComp = " + . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::getUikitComp(" . $string . "->" + . $field . ",\$this->uikitComp);"; + } + } + } + + // return UIKIT fix + return $fieldUikit; + } + + public function setCustomViewCustomJoin(&$gets, $string, $code, &$asBucket, + $tab = '' + ) + { + if (ArrayHelper::check($gets)) + { + $customJoin = ''; + foreach ($gets as $get) + { + // set the value name $default + if (($default = $this->setCustomViewMethodDefaults($get, $code)) + !== false) + { + if ($this->checkJoint($default, $get, $asBucket)) + { + // build custom join string + $otherJoin = PHP_EOL . Indent::_(1) . Placefix::_h("TAB") + . Indent::_(1) . "//" . Line::_(__LINE__,__CLASS__) + . " set " . $default['valueName'] . " to the " + . Placefix::_h("STRING") . " object."; + $otherJoin .= PHP_EOL . Indent::_(1) . Placefix::_h("TAB") + . Indent::_(1) . Placefix::_h("STRING") . "->" + . $default['valueName'] . " = \$this->get" + . $default['methodName'] . "(" . Placefix::_h("STRING") . "->" + . CFactory::_('Compiler.Builder.Get.As.Lookup')-> + get($get['key'] . '.' . $get['on_field'], 'Error') + . ");"; + $join_field_ = CFactory::_('Compiler.Builder.Site.Dynamic.Get')->get(CFactory::_('Config')->build_target . + '.' . $default['code'] . '.' . $default['as'] . '.' . $default['join_field'], 'ZZZ'); + // load to other join + CFactory::_('Compiler.Builder.Other.Join')->add( + CFactory::_('Config')->build_target . '.' . $default['code'] . '.' . $join_field_ . '.' . $default['valueName'], + $otherJoin, + false + ); + } + else + { + // build custom join string + $customJoin .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "//" . Line::_(__Line__, __Class__) + . " set " . $default['valueName'] . " to the " + . $string . " object."; + $customJoin .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . $string . "->" + . $default['valueName'] . " = \$this->get" + . $default['methodName'] . "(" . $string . "->" + . CFactory::_('Compiler.Builder.Get.As.Lookup')-> + get($get['key'] . '.' . $get['on_field'], 'Error') + . ");"; + } + } + } + + return $customJoin; + } + + return ''; + } + + public function checkJoint(&$default, &$get, &$asBucket) + { + // check if this function is not linked to the main call + list($aJoin) = explode('.', (string) $get['on_field']); + if (ArrayHelper::check($asBucket) && in_array($aJoin, $asBucket)) + { + return false; + } + // default fallback + elseif (CFactory::_('Compiler.Builder.Site.Dynamic.Get')->exists( + CFactory::_('Config')->build_target . '.' . $default['code'] . '.' . + $default['as'] . '.' . $default['join_field'] + )) + { + return true; + } + + return false; + } + + public function setCustomViewFilter(&$filter, &$code, $tab = '') + { + $filters = ''; + if (ArrayHelper::check($filter)) + { + foreach ($filter as $ter) + { + $as = ''; + $field = ''; + $string = ''; + if (strpos((string) $ter['table_key'], '.') !== false) + { + list($as, $field) = array_map( + 'trim', explode('.', (string) $ter['table_key']) + ); + } + $path = $code . '.' . $ter['key'] . '.' . $as . '.' . $field; + switch ($ter['filter_type']) + { + case 1: + // COM_COMPONENTBUILDER_DYNAMIC_GET_ID + $string = PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "\$query->where('" . $ter['table_key'] . " " + . $ter['operator'] . " ' . (int) \$pk);"; + break; + case 2: + // COM_COMPONENTBUILDER_DYNAMIC_GET_USER + $string = PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "\$query->where('" . $ter['table_key'] . " " + . $ter['operator'] . " ' . (int) \$this->userId);"; + break; + case 3: + // COM_COMPONENTBUILDER_DYNAMIC_GET_ACCESS_LEVEL + $string = PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "\$query->where('" . $ter['table_key'] . " " + . $ter['operator'] + . " (' . implode(',', \$this->levels) . ')');"; + break; + case 4: + // COM_COMPONENTBUILDER_DYNAMIC_GET_USER_GROUPS + $decodeChecker = CFactory::_('Compiler.Builder.Site.Field.Data')-> + get('decode.' . $path); + if (ArrayHelper::check($decodeChecker) + || $ter['state_key'] === 'array') + { + // set needed fields to filter after query + CFactory::_('Compiler.Builder.Site.Field.Decode.Filter')-> + set(CFactory::_('Config')->build_target . '.' . $path, $ter); + } + else + { + $string = PHP_EOL . Indent::_(1) . $tab . Indent::_( + 1 + ) . "\$query->where('" . $ter['table_key'] . " " + . $ter['operator'] + . " (' . implode(',', \$this->groups) . ')');"; + } + break; + case 5: + // COM_COMPONENTBUILDER_DYNAMIC_GET_CATEGORIES + $string = PHP_EOL . Indent::_(2) . $tab . "//" + . Line::_(__Line__, __Class__) + . " (TODO) The dynamic category filter is not ready."; + break; + case 6: + // COM_COMPONENTBUILDER_DYNAMIC_GET_TAGS + $string = PHP_EOL . Indent::_(2) . $tab . "//" + . Line::_(__Line__, __Class__) + . " (TODO) The dynamic tags filter is not ready."; + break; + case 7: + // COM_COMPONENTBUILDER_DYNAMIC_GET_DATE + $string = PHP_EOL . Indent::_(2) . $tab . "//" + . Line::_(__Line__, __Class__) + . " (TODO) The dynamic date filter is not ready."; + break; + case 8: + // COM_COMPONENTBUILDER_DYNAMIC_GET_FUNCTIONVAR + if ($ter['operator'] === 'IN' + || $ter['operator'] === 'NOT IN') + { + $string = PHP_EOL . Indent::_(2) . $tab . "//" + . Line::_(__Line__, __Class__) . " Check if " + . $ter['state_key'] + . " is an array with values."; + $string .= PHP_EOL . Indent::_(2) . $tab + . "\$array = " . $ter['state_key'] . ";"; + $string .= PHP_EOL . Indent::_(2) . $tab + . "if (isset(\$array) && " + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$array))"; + $string .= PHP_EOL . Indent::_(2) . $tab . "{"; + $string .= PHP_EOL . Indent::_(2) . $tab + . Indent::_(1) . "\$query->where('" + . $ter['table_key'] . " " . $ter['operator'] + . " (' . implode(',', \$array) . ')');"; + $string .= PHP_EOL . Indent::_(2) . $tab . "}"; + // check if empty is allowed + if (!isset($ter['empty']) || !$ter['empty']) + { + $string .= PHP_EOL . Indent::_(2) . $tab + . "else"; + $string .= PHP_EOL . Indent::_(2) . $tab . "{"; + $string .= PHP_EOL . Indent::_(2) . $tab + . Indent::_(1) . "return false;"; + $string .= PHP_EOL . Indent::_(2) . $tab . "}"; + } + } + else + { + $string = PHP_EOL . Indent::_(2) . $tab . "//" + . Line::_(__Line__, __Class__) . " Check if " + . $ter['state_key'] + . " is a string or numeric value."; + $string .= PHP_EOL . Indent::_(2) . $tab + . "\$checkValue = " . $ter['state_key'] . ";"; + $string .= PHP_EOL . Indent::_(2) . $tab + . "if (isset(\$checkValue) && " + . "Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$checkValue))"; + $string .= PHP_EOL . Indent::_(2) . $tab . "{"; + $string .= PHP_EOL . Indent::_(2) . $tab + . Indent::_(1) . "\$query->where('" + . $ter['table_key'] . " " . $ter['operator'] + . " ' . \$db->quote(\$checkValue));"; + $string .= PHP_EOL . Indent::_(2) . $tab . "}"; + $string .= PHP_EOL . Indent::_(2) . $tab + . "elseif (is_numeric(\$checkValue))"; + $string .= PHP_EOL . Indent::_(2) . $tab . "{"; + $string .= PHP_EOL . Indent::_(2) . $tab + . Indent::_(1) . "\$query->where('" + . $ter['table_key'] . " " . $ter['operator'] + . " ' . \$checkValue);"; + $string .= PHP_EOL . Indent::_(2) . $tab . "}"; + // check if empty is allowed + if (!isset($ter['empty']) || !$ter['empty']) + { + $string .= PHP_EOL . Indent::_(2) . $tab + . "else"; + $string .= PHP_EOL . Indent::_(2) . $tab . "{"; + $string .= PHP_EOL . Indent::_(2) . $tab + . Indent::_(1) . "return false;"; + $string .= PHP_EOL . Indent::_(2) . $tab . "}"; + } + } + break; + case 9: + case 10: + // COM_COMPONENTBUILDER_DYNAMIC_GET_ARRAY_VALUE + // COM_COMPONENTBUILDER_DYNAMIC_GET_REPEATABLE_VALUE + $string = ""; + // set needed fields to filter after query + CFactory::_('Compiler.Builder.Site.Field.Decode.Filter')-> + set(CFactory::_('Config')->build_target . '.' . $path, $ter); + break; + case 11: + // COM_COMPONENTBUILDER_DYNAMIC_GET_OTHER + if (strpos($as, '(') !== false) + { + // TODO (for now we only fix extra sql methods here) + list($dump, $as) = array_map( + 'trim', explode('(', $as) + ); + $field = trim(str_replace(')', '', $field)); + } + $string = PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "\$query->where('" . $ter['table_key'] . " " + . $ter['operator'] . " " . $ter['state_key'] + . "');"; + break; + } + // only add if the filter is set + if (StringHelper::check($string)) + { + // sort where + if ($as === 'a' || CFactory::_('Compiler.Builder.Site.Main.Get')-> + exists(CFactory::_('Config')->build_target . '.' . $code . '.' . $as)) + { + $filters .= $string; + } + elseif ($as !== 'a') + { + CFactory::_('Compiler.Builder.Other.Filter')-> + set(CFactory::_('Config')->build_target . '.' . $code . '.' . $as . '.' . $field, $string);; + } + } + } + } + + return $filters; + } + + public function setCustomViewGroup(&$group, &$code, $tab = '') + { + $grouping = ''; + if (ArrayHelper::check($group)) + { + foreach ($group as $gr) + { + list($as, $field) = array_map( + 'trim', explode('.', (string) $gr['table_key']) + ); + // set the string + $string = "\$query->group('" . $gr['table_key'] . "');"; + // sort where + if ($as === 'a' || CFactory::_('Compiler.Builder.Site.Main.Get')-> + exists(CFactory::_('Config')->build_target . '.' . $code . '.' . $as)) + { + $grouping .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . $string; + } + else + { + CFactory::_('Compiler.Builder.Other.Group')->set( + CFactory::_('Config')->build_target . '.' . $code . '.' . $as . '.' . $field, + PHP_EOL . Indent::_(2) . $string + ); + } + } + } + + return $grouping; + } + + public function setCustomViewOrder(&$order, &$code, $tab = '') + { + $ordering = ''; + if (ArrayHelper::check($order)) + { + foreach ($order as $or) + { + list($as, $field) = array_map( + 'trim', explode('.', (string) $or['table_key']) + ); + // check if random + if ('RAND' === $or['direction']) + { + // set the string + $string = "\$query->order('RAND()');"; + } + else + { + // set the string + $string = "\$query->order('" . $or['table_key'] . " " + . $or['direction'] . "');"; + } + // sort where + if ($as === 'a' || CFactory::_('Compiler.Builder.Site.Main.Get')-> + exists(CFactory::_('Config')->build_target . '.' . $code . '.' . $as)) + { + $ordering .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . $string; + } + else + { + CFactory::_('Compiler.Builder.Other.Order')->set( + CFactory::_('Config')->build_target . '.' . $code . '.' . $as . '.' . $field, + PHP_EOL . Indent::_(2) . $string + ); + } + } + } + + return $ordering; + } + + public function setCustomViewWhere(&$where, &$code, $tab = '') + { + $wheres = ''; + if (ArrayHelper::check($where)) + { + foreach ($where as $whe) + { + $as = ''; + $field = ''; + $value = ''; + list($as, $field) = array_map( + 'trim', explode('.', (string) $whe['table_key']) + ); + if (is_numeric($whe['value_key'])) + { + $value = " " . $whe['value_key'] . "');"; + } + elseif (strpos((string) $whe['value_key'], '$') !== false) + { + if ($whe['operator'] === 'IN' + || $whe['operator'] === 'NOT IN') + { + $value = " (' . implode(',', " . $whe['value_key'] + . ") . ')');"; + } + else + { + $value = " ' . \$db->quote(" . $whe['value_key'] + . "));"; + } + } + elseif (strpos((string) $whe['value_key'], '.') !== false) + { + if (strpos((string) $whe['value_key'], "'") !== false) + { + $value = " ' . \$db->quote(" . $whe['value_key'] + . "));"; + } + else + { + $value = " " . $whe['value_key'] . "');"; + } + } + elseif (StringHelper::check($whe['value_key'])) + { + $value = " " . $whe['value_key'] . "');"; + } + // only load if there is a value + if (StringHelper::check($value)) + { + $tabe = ''; + if ($as === 'a') + { + $tabe = $tab; + } + // set the string + if ($whe['operator'] === 'IN' + || $whe['operator'] === 'NOT IN') + { + $string = "if (isset(" . $whe['value_key'] . ") && " + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(" + . $whe['value_key'] . "))"; + $string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(1) + . "{"; + $string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(2) + . "//" . Line::_(__Line__, __Class__) . " Get where " + . $whe['table_key'] . " is " . $whe['value_key']; + $string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(2) + . "\$query->where('" . $whe['table_key'] . " " + . $whe['operator'] . $value; + $string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(1) + . "}"; + $string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(1) + . "else"; + $string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(1) + . "{"; + $string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(2) + . "return false;"; + $string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(1) + . "}"; + } + else + { + $string = "//" . Line::_(__Line__, __Class__) + . " Get where " . $whe['table_key'] . " is " + . $whe['value_key']; + $string .= PHP_EOL . Indent::_(1) . $tabe . Indent::_(1) + . "\$query->where('" . $whe['table_key'] . " " + . $whe['operator'] . $value; + } + // sort where + if ($as === 'a' || CFactory::_('Compiler.Builder.Site.Main.Get')-> + exists(CFactory::_('Config')->build_target . '.' . $code . '.' . $as)) + { + $wheres .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . $string; + } + elseif ($as !== 'a') + { + CFactory::_('Compiler.Builder.Other.Where')->set( + CFactory::_('Config')->build_target . '.' . $code . '.' . $as . '.' . $field, + PHP_EOL . Indent::_(2) . $string + ); + } + } + } + } + + return $wheres; + } + + public function setCustomViewGlobals(&$global, $string, $as, $tab = '') + { + $globals = ''; + if (ArrayHelper::check($global)) + { + $as = array_unique($as); + foreach ($global as $glo) + { + if (in_array($glo['as'], $as)) + { + switch ($glo['type']) + { + case 1: + // SET STATE + $value = "\$this->setState('" . $glo['as'] . "." + . $glo['name'] . "', " . $string . "->" + . $glo['key'] . ");"; + break; + case 2: + // SET THIS + $value = "\$this->" . $glo['as'] . "_" + . $glo['name'] . " = " . $string . "->" + . $glo['key'] . ";"; + break; + } + // only add if the filter is set + if (StringHelper::check($value)) + { + $globals .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "//" . Line::_(__Line__, __Class__) + . " set the global " . $glo['name'] . " value." + . PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . $value; + } + } + } + } + + return $globals; + } + + /** + * @param $string + * @param string $type + * + * @return mixed + */ + public function removeAsDot($string, $type = '') + { + if (strpos((string) $string, '.') !== false) + { + list($dump, $field) = array_map('trim', explode('.', (string) $string)); + } + else + { + $field = $string; + } + + return $field; + } + + /** + * @param type $view + * @param type $type + */ + public function setUserPermissionCheckAccess($view, $type) + { + if (isset($view['access']) && $view['access'] == 1) + { + switch ($type) + { + case 1: + $userString = '$this->user'; + break; + default: + $userString = '$user'; + break; + } + // check that the default and the redirect page is not the same + if (CFactory::_('Compiler.Builder.Content.One')->exists('SITE_DEFAULT_VIEW') + && CFactory::_('Compiler.Builder.Content.One')->get('SITE_DEFAULT_VIEW') != $view['settings']->code) + { + $redirectMessage = Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) + . " redirect away to the default view if no access allowed."; + $redirectString = "Route::_('index.php?option=com_" + . CFactory::_('Config')->component_code_name . "&view=" + . CFactory::_('Compiler.Builder.Content.One')->get('SITE_DEFAULT_VIEW') . "')"; + } + else + { + $redirectMessage = Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " redirect away to the home page if no access allowed."; + $redirectString = 'Uri::root()'; + } + $accessCheck[] = PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " check if this user has permission to access item"; + $accessCheck[] = Indent::_(2) . "if (!" . $userString + . "->authorise('site." . $view['settings']->code + . ".access', 'com_" . CFactory::_('Config')->component_code_name . "'))"; + $accessCheck[] = Indent::_(2) . "{"; + $accessCheck[] = Indent::_(3) + . "\$app = Factory::getApplication();"; + // set lang + $langKeyWord = CFactory::_('Config')->lang_prefix . '_' + . StringHelper::safe( + 'Not authorised to view ' . $view['settings']->code . '!', + 'U' + ); + CFactory::_('Language')->set( + 'site', $langKeyWord, + 'Not authorised to view ' . $view['settings']->code . '!' + ); + $accessCheck[] = Indent::_(3) . "\$app->enqueueMessage(Text:" + . ":_('" . $langKeyWord . "'), 'error');"; + $accessCheck[] = $redirectMessage; + $accessCheck[] = Indent::_(3) . "\$app->redirect(" . $redirectString + . ");"; + $accessCheck[] = Indent::_(3) . "return false;"; + $accessCheck[] = Indent::_(2) . "}"; + + // return the access check + return implode(PHP_EOL, $accessCheck); + } + + return ''; + } + + /** + * @param $get + * @param $code + * @param string $tab + * @param string $type + * + * @return string + */ + public function setCustomViewGetItem(&$get, &$code, $tab = '', $type = 'main') + { + if (ObjectHelper::check($get)) + { + // set the site decription switches + foreach (CFactory::_('Config')->cryption_types as $cryptionType) + { + CFactory::_('Compiler.Builder.Site.Decrypt')->set("{$cryptionType}.{$code}", false); + } + // start the get Item + $getItem = ''; + // set before item php + if (isset($get->add_php_before_getitem) + && $get->add_php_before_getitem == 1 + && isset($get->php_before_getitem) + && StringHelper::check( + $get->php_before_getitem + )) + { + $getItem .= CFactory::_('Placeholder')->update_( + $get->php_before_getitem + ); + } + // start loadin the get Item + $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "//" + . Line::_(__Line__, __Class__) . " Get a db connection."; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "\$db = Factory::getDbo();"; + } + else + { + $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "\$db = \$this->getDatabase();"; + } + $getItem .= PHP_EOL . PHP_EOL . $tab . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Create a new query object."; + $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "\$query = \$db->getQuery(true);"; + // set main get query + $getItem .= $this->setCustomViewQuery($get->main_get, $code, $tab); + // setup filters + if (isset($get->filter)) + { + $getItem .= $this->setCustomViewFilter( + $get->filter, $code, $tab + ); + } + // setup Where + if (isset($get->where)) + { + $getItem .= $this->setCustomViewWhere($get->where, $code, $tab); + } + // setup ordering + if (isset($get->order)) + { + $getItem .= $this->setCustomViewOrder($get->order, $code, $tab); + } + // setup grouping + if (isset($get->group)) + { + $getItem .= $this->setCustomViewGroup($get->group, $code, $tab); + } + // db set query data placeholder + $getItem .= Placefix::_h("DB_SET_QUERY_DATA") ; + // set after item php + if (isset($get->add_php_after_getitem) + && $get->add_php_after_getitem == 1 + && isset($get->php_after_getitem) + && StringHelper::check($get->php_after_getitem)) + { + $getItem .= CFactory::_('Placeholder')->update_( + $get->php_after_getitem + ); + } + // check the getItem string to see if we should still add set query to data + if (strpos($getItem, '$data =') === false) + { + // get ready to get query + $setQuery[Placefix::_h("DB_SET_QUERY_DATA")] = + PHP_EOL . PHP_EOL . $tab . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " Reset the query using our newly populated query object."; + $setQuery[Placefix::_h("DB_SET_QUERY_DATA")] .= + PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "\$db->setQuery(\$query);"; + $setQuery[Placefix::_h("DB_SET_QUERY_DATA")] .= + PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "//" + . Line::_(__Line__, __Class__) + . " Load the results as a stdClass object."; + $setQuery[Placefix::_h("DB_SET_QUERY_DATA")] .= + PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "\$data = \$db->loadObject();"; + // add the db set query to data + } + else + { + // remove our placeholder + $setQuery[Placefix::_h("DB_SET_QUERY_DATA")] = ''; + } + // add the db set query to data + $getItem = str_replace( + array_keys($setQuery), + array_values($setQuery), $getItem + ); + $getItem .= PHP_EOL . PHP_EOL . $tab . Indent::_(2) + . "if (empty(\$data))"; + $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "{"; + if ($type === 'main') + { + $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) + . "\$app = Factory::getApplication();"; + $langKeyWoord = CFactory::_('Config')->lang_prefix . '_' + . StringHelper::safe( + 'Not found or access denied', 'U' + ); + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, $langKeyWoord, 'Not found, or access denied.' + ); + $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " If no data is found redirect to default page and show warning."; + $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) + . "\$app->enqueueMessage(Text:" . ":_('" . $langKeyWoord + . "'), 'warning');"; + if ('site' === CFactory::_('Config')->build_target) + { + // check that the default and the redirect page is not the same + if (CFactory::_('Compiler.Builder.Content.One')->exists('SITE_DEFAULT_VIEW') + && CFactory::_('Compiler.Builder.Content.One')->get('SITE_DEFAULT_VIEW') != $code) + { + $redirectString = "Route::_('index.php?option=com_" + . CFactory::_('Config')->component_code_name . "&view=" + . CFactory::_('Compiler.Builder.Content.One')->get('SITE_DEFAULT_VIEW') . "')"; + } + else + { + $redirectString = 'Uri::root()'; + } + $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) + . "\$app->redirect(" . $redirectString . ");"; + } + else + { + $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) + . "\$app->redirect('index.php?option=com_" + . CFactory::_('Config')->component_code_name . "');"; + } + $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) + . "return false;"; + } + else + { + $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) + . "return false;"; + } + $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "}"; + // dispatcher placeholder + $getItem .= Placefix::_h("DISPATCHER") ; + if (ArrayHelper::check($get->main_get)) + { + $asBucket = []; + foreach ($get->main_get as $main_get) + { + if (isset($main_get['key']) && isset($main_get['as'])) + { + // build path + $path = $code . '.' . $main_get['key'] . '.' . $main_get['as']; + + $decodeChecker = CFactory::_('Compiler.Builder.Site.Field.Data')->get('decode.' . $path); + if (ArrayHelper::check($decodeChecker)) + { + // set decoding of needed fields + $getItem .= $this->setCustomViewFieldDecode( + $main_get, $decodeChecker, '$data', $code, + $tab + ); + } + + $decodeFilter = CFactory::_('Compiler.Builder.Site.Field.Decode.Filter')-> + get(CFactory::_('Config')->build_target . '.' . $path); + if (ArrayHelper::check($decodeFilter)) + { + // also filter fields if needed + $getItem .= $this->setCustomViewFieldDecodeFilter( + $main_get, $decodeFilter, '$data', '$data', + $code, $tab + ); + } + + $contentprepareChecker = CFactory::_('Compiler.Builder.Site.Field.Data')-> + get('textareas.' . $path); + if (ArrayHelper::check($contentprepareChecker)) + { + // set contentprepare checkers on needed fields + $getItem .= $this->setCustomViewFieldonContentPrepareChecker( + $main_get, $contentprepareChecker, '$data', + $code, $tab + ); + } + + $uikitChecker = CFactory::_('Compiler.Builder.Site.Field.Data')->get('uikit.' . $path); + if (ArrayHelper::check($uikitChecker)) + { + // set uikit checkers on needed fields + $getItem .= $this->setCustomViewFieldUikitChecker( + $main_get, $uikitChecker, '$data', $code, + $tab + ); + } + + $asBucket[] = $main_get['as']; + } + } + } + // set the scripts + $Component = CFactory::_('Compiler.Builder.Content.One')->get('Component'); + $script = ''; + foreach (CFactory::_('Config')->cryption_types as $cryptionType) + { + if (CFactory::_('Compiler.Builder.Site.Decrypt')->get("{$cryptionType}.{$code}", false)) + { + if ('expert' !== $cryptionType) + { + $script .= PHP_EOL . PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "//" . Line::_(__Line__, __Class__) + . " Get the " . $cryptionType . " encryption."; + $script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "\$" . $cryptionType . "key = " . $Component + . "Helper::getCryptKey('" . $cryptionType . "');"; + $script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "//" . Line::_(__Line__, __Class__) + . " Get the encryption object."; + $script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "\$" . $cryptionType . " = new Super_" . "__99175f6d_dba8_4086_8a65_5c4ec175e61d___Power(\$" + . $cryptionType . "key);"; + } + elseif (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> + exists("{$code}.get")) + { + foreach (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> + get("{$code}.get") as $block) + { + $script .= PHP_EOL . Indent::_(1) . implode( + PHP_EOL . Indent::_(1), $block + ); + } + } + } + } + $getItem = $script . $getItem; + // setup Globals + $getItem .= $this->setCustomViewGlobals( + $get->global, '$data', $asBucket, $tab + ); + // setup the custom gets that returns multiple values + $getItem .= $this->setCustomViewCustomJoin( + $get->custom_get, '$data', $code, $asBucket, $tab + ); + // set calculations + if ($get->addcalculation == 1) + { + $get->php_calculation = (array) explode( + PHP_EOL, (string) CFactory::_('Placeholder')->update_( + $get->php_calculation + ) + ); + $getItem .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . implode( + PHP_EOL . Indent::_(1) . $tab . Indent::_(1), + $get->php_calculation + ); + } + if ($type === 'custom') + { + // return the object + $getItem .= PHP_EOL . PHP_EOL . Indent::_(1) . $tab . Indent::_( + 1 + ) . "//" . Line::_(__Line__, __Class__) + . " return data object."; + $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "return \$data;"; + } + else + { + // set the object + $getItem .= PHP_EOL . PHP_EOL . Indent::_(1) . $tab . Indent::_( + 1 + ) . "//" . Line::_(__Line__, __Class__) + . " set data object to item."; + $getItem .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "\$this->_item[\$pk] = \$data;"; + } + // only update if dispacher placholder is found + if (strpos($getItem, (string) Placefix::_h('DISPATCHER')) + !== false) + { + // check if the dispather should be added + if (!isset($this->JEventDispatcher) + || !ArrayHelper::check( + $this->JEventDispatcher + )) + { + $this->JEventDispatcher = array(Placefix::_h('DISPATCHER') => ''); + } + $getItem = str_replace( + array_keys($this->JEventDispatcher), + array_values($this->JEventDispatcher), $getItem + ); + } + + return $getItem; + } + + return PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "//" + . Line::_(__Line__, __Class__) . "add your custom code here."; + } + + public function setCustomViewCustomMethods($main_view, $code) + { + $methods = ''; + // then set the needed custom methods + if (ArrayHelper::check($main_view) + && isset($main_view['settings']) + && ObjectHelper::check($main_view['settings']) + && isset($main_view['settings']->custom_get)) + { + $_dynamic_get = $main_view['settings']->custom_get; + } + elseif (ObjectHelper::check($main_view) + && isset($main_view->custom_get)) + { + $_dynamic_get = $main_view->custom_get; + } + // check if we have an array + if (isset($_dynamic_get) + && ArrayHelper::check( + $_dynamic_get + )) + { + // start dynamic build + foreach ($_dynamic_get as $view) + { + // fix alias to use in code + $view->code = StringHelper::safe($code); + $view->Code = StringHelper::safe( + $view->code, 'F' + ); + $view->CODE = StringHelper::safe( + $view->code, 'U' + ); + $main = ''; + if ($view->gettype == 3) + { + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + // SITE_GET_ITEM <<>> + $main .= PHP_EOL . PHP_EOL . Indent::_(2) + . "if (!isset(\$this->initSet) || !\$this->initSet)"; + $main .= PHP_EOL . Indent::_(2) . "{"; + $main .= PHP_EOL . Indent::_(3) + . "\$this->user = Factory::getUser();"; + $main .= PHP_EOL . Indent::_(3) + . "\$this->userId = \$this->user->get('id');"; + $main .= PHP_EOL . Indent::_(3) + . "\$this->guest = \$this->user->get('guest');"; + $main .= PHP_EOL . Indent::_(3) + . "\$this->groups = \$this->user->get('groups');"; + $main .= PHP_EOL . Indent::_(3) + . "\$this->authorisedGroups = \$this->user->getAuthorisedGroups();"; + $main .= PHP_EOL . Indent::_(3) + . "\$this->levels = \$this->user->getAuthorisedViewLevels();"; + $main .= PHP_EOL . Indent::_(3) . "\$this->initSet = true;"; + $main .= PHP_EOL . Indent::_(2) . "}"; + } + $main .= $this->setCustomViewGetItem( + $view, $view->code, '', 'custom' + ); + $type + = 'mixed item data object on success, false on failure.'; + } + elseif ($view->gettype == 4) + { + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $main .= PHP_EOL . PHP_EOL . Indent::_(2) + . "if (!isset(\$this->initSet) || !\$this->initSet)"; + $main .= PHP_EOL . Indent::_(2) . "{"; + $main .= PHP_EOL . Indent::_(3) + . "\$this->user = Factory::getUser();"; + $main .= PHP_EOL . Indent::_(3) + . "\$this->userId = \$this->user->get('id');"; + $main .= PHP_EOL . Indent::_(3) + . "\$this->guest = \$this->user->get('guest');"; + $main .= PHP_EOL . Indent::_(3) + . "\$this->groups = \$this->user->get('groups');"; + $main .= PHP_EOL . Indent::_(3) + . "\$this->authorisedGroups = \$this->user->getAuthorisedGroups();"; + $main .= PHP_EOL . Indent::_(3) + . "\$this->levels = \$this->user->getAuthorisedViewLevels();"; + $main .= PHP_EOL . Indent::_(3) . "\$this->initSet = true;"; + $main .= PHP_EOL . Indent::_(2) . "}"; + } + $main .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Get the global params"; + $main .= PHP_EOL . Indent::_(2) + . "\$globalParams = ComponentHelper::getParams('com_" + . CFactory::_('Config')->component_code_name . "', true);"; + // set php before listquery + if (isset($view->add_php_getlistquery) + && $view->add_php_getlistquery == 1 + && isset($view->php_getlistquery) + && StringHelper::check( + $view->php_getlistquery + )) + { + $main .= CFactory::_('Placeholder')->update_( + $view->php_getlistquery + ); + } + // SITE_GET_LIST_QUERY <<>> + $main .= $this->setCustomViewListQuery( + $view, $view->code, false + ); + // set before items php + if (isset($view->add_php_before_getitems) + && $view->add_php_before_getitems == 1 + && isset($view->php_before_getitems) + && StringHelper::check( + $view->php_before_getitems + )) + { + $main .= CFactory::_('Placeholder')->update_( + $view->php_before_getitems + ); + } + // load the object list + $main .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " Reset the query using our newly populated query object."; + $main .= PHP_EOL . Indent::_(2) + . "\$db->setQuery(\$query);"; + $main .= PHP_EOL . Indent::_(2) + . "\$items = \$db->loadObjectList();"; + // set after items php + if (isset($view->add_php_after_getitems) + && $view->add_php_after_getitems == 1 + && isset($view->php_after_getitems) + && StringHelper::check( + $view->php_after_getitems + )) + { + $main .= CFactory::_('Placeholder')->update_( + $view->php_after_getitems + ); + } + $main .= PHP_EOL . PHP_EOL . Indent::_(2) + . "if (empty(\$items))"; + $main .= PHP_EOL . Indent::_(2) . "{"; + $main .= PHP_EOL . Indent::_(3) . "return false;"; + $main .= PHP_EOL . Indent::_(2) . "}"; + // SITE_GET_ITEMS <<>> + $main .= $this->setCustomViewGetItems($view, $view->code); + $main .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " return items"; + $main .= PHP_EOL . Indent::_(2) . "return \$items;"; + $type + = 'mixed An array of objects on success, false on failure.'; + } + // load the main mehtod + $methods .= $this->setMainCustomMehtod( + $main, $view->getcustom, $type + ); + // SITE_CUSTOM_METHODS <<>> + $methods .= $this->setCustomViewCustomItemMethods( + $view, $view->code + ); + } + } + // load uikit get method + if (ArrayHelper::check($main_view) + && isset($main_view['settings'])) + { + $methods .= $this->setUikitGetMethod(); + } + + return $methods; + } + + public function setUikitHelperMethods() + { + // only load for uikit version 2 + if (2 == CFactory::_('Config')->uikit || 1 == CFactory::_('Config')->uikit) + { + // build uikit get method + $ukit = []; + $ukit[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $ukit[] = Indent::_(1) . " * UIKIT Component Classes"; + $ukit[] = Indent::_(1) . " **/"; + $ukit[] = Indent::_(1) . "public static \$uk_components = array("; + $ukit[] = Indent::_(3) . "'data-uk-grid' => array("; + $ukit[] = Indent::_(4) . "'grid' ),"; + $ukit[] = Indent::_(3) . "'uk-accordion' => array("; + $ukit[] = Indent::_(4) . "'accordion' ),"; + $ukit[] = Indent::_(3) . "'uk-autocomplete' => array("; + $ukit[] = Indent::_(4) . "'autocomplete' ),"; + $ukit[] = Indent::_(3) . "'data-uk-datepicker' => array("; + $ukit[] = Indent::_(4) . "'datepicker' ),"; + $ukit[] = Indent::_(3) . "'uk-form-password' => array("; + $ukit[] = Indent::_(4) . "'form-password' ),"; + $ukit[] = Indent::_(3) . "'uk-form-select' => array("; + $ukit[] = Indent::_(4) . "'form-select' ),"; + $ukit[] = Indent::_(3) . "'data-uk-htmleditor' => array("; + $ukit[] = Indent::_(4) . "'htmleditor' ),"; + $ukit[] = Indent::_(3) . "'data-uk-lightbox' => array("; + $ukit[] = Indent::_(4) . "'lightbox' ),"; + $ukit[] = Indent::_(3) . "'uk-nestable' => array("; + $ukit[] = Indent::_(4) . "'nestable' ),"; + $ukit[] = Indent::_(3) . "'UIkit.notify' => array("; + $ukit[] = Indent::_(4) . "'notify' ),"; + $ukit[] = Indent::_(3) . "'data-uk-parallax' => array("; + $ukit[] = Indent::_(4) . "'parallax' ),"; + $ukit[] = Indent::_(3) . "'uk-search' => array("; + $ukit[] = Indent::_(4) . "'search' ),"; + $ukit[] = Indent::_(3) . "'uk-slider' => array("; + $ukit[] = Indent::_(4) . "'slider' ),"; + $ukit[] = Indent::_(3) . "'uk-slideset' => array("; + $ukit[] = Indent::_(4) . "'slideset' ),"; + $ukit[] = Indent::_(3) . "'uk-slideshow' => array("; + $ukit[] = Indent::_(4) . "'slideshow',"; + $ukit[] = Indent::_(4) . "'slideshow-fx' ),"; + $ukit[] = Indent::_(3) . "'uk-sortable' => array("; + $ukit[] = Indent::_(4) . "'sortable' ),"; + $ukit[] = Indent::_(3) . "'data-uk-sticky' => array("; + $ukit[] = Indent::_(4) . "'sticky' ),"; + $ukit[] = Indent::_(3) . "'data-uk-timepicker' => array("; + $ukit[] = Indent::_(4) . "'timepicker' ),"; + $ukit[] = Indent::_(3) . "'data-uk-tooltip' => array("; + $ukit[] = Indent::_(4) . "'tooltip' ),"; + $ukit[] = Indent::_(3) . "'uk-placeholder' => array("; + $ukit[] = Indent::_(4) . "'placeholder' ),"; + $ukit[] = Indent::_(3) . "'uk-dotnav' => array("; + $ukit[] = Indent::_(4) . "'dotnav' ),"; + $ukit[] = Indent::_(3) . "'uk-slidenav' => array("; + $ukit[] = Indent::_(4) . "'slidenav' ),"; + $ukit[] = Indent::_(3) . "'uk-form' => array("; + $ukit[] = Indent::_(4) . "'form-advanced' ),"; + $ukit[] = Indent::_(3) . "'uk-progress' => array("; + $ukit[] = Indent::_(4) . "'progress' ),"; + $ukit[] = Indent::_(3) . "'upload-drop' => array("; + $ukit[] = Indent::_(4) . "'upload', 'form-file' )"; + $ukit[] = Indent::_(3) . ");"; + $ukit[] = PHP_EOL . Indent::_(1) . "/**"; + $ukit[] = Indent::_(1) . " * Add UIKIT Components"; + $ukit[] = Indent::_(1) . " **/"; + $ukit[] = Indent::_(1) . "public static \$uikit = false;"; + $ukit[] = ""; + $ukit[] = Indent::_(1) . "/**"; + $ukit[] = Indent::_(1) . " * Get UIKIT Components"; + $ukit[] = Indent::_(1) . " **/"; + $ukit[] = Indent::_(1) + . "public static function getUikitComp(\$content,\$classes = array())"; + $ukit[] = Indent::_(1) . "{"; + $ukit[] = Indent::_(2) + . "if (strpos(\$content,'class=\"uk-') !== false)"; + $ukit[] = Indent::_(2) . "{"; + $ukit[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " reset"; + $ukit[] = Indent::_(3) . "\$temp = [];"; + $ukit[] = Indent::_(3) + . "foreach (self::\$uk_components as \$looking => \$add)"; + $ukit[] = Indent::_(3) . "{"; + $ukit[] = Indent::_(4) + . "if (strpos(\$content,\$looking) !== false)"; + $ukit[] = Indent::_(4) . "{"; + $ukit[] = Indent::_(5) . "\$temp[] = \$looking;"; + $ukit[] = Indent::_(4) . "}"; + $ukit[] = Indent::_(3) . "}"; + $ukit[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " make sure uikit is loaded to config"; + $ukit[] = Indent::_(3) + . "if (strpos(\$content,'class=\"uk-') !== false)"; + $ukit[] = Indent::_(3) . "{"; + $ukit[] = Indent::_(4) . "self::\$uikit = true;"; + $ukit[] = Indent::_(3) . "}"; + $ukit[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " sorter"; + $ukit[] = Indent::_(3) . "if (Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$temp))"; + $ukit[] = Indent::_(3) . "{"; + $ukit[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " merger"; + $ukit[] = Indent::_(4) . "if (Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$classes))"; + $ukit[] = Indent::_(4) . "{"; + $ukit[] = Indent::_(5) + . "\$newTemp = array_merge(\$temp,\$classes);"; + $ukit[] = Indent::_(5) . "\$temp = array_unique(\$newTemp);"; + $ukit[] = Indent::_(4) . "}"; + $ukit[] = Indent::_(4) . "return \$temp;"; + $ukit[] = Indent::_(3) . "}"; + $ukit[] = Indent::_(2) . "}"; + $ukit[] = Indent::_(2) . "if (Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$classes))"; + $ukit[] = Indent::_(2) . "{"; + $ukit[] = Indent::_(3) . "return \$classes;"; + $ukit[] = Indent::_(2) . "}"; + $ukit[] = Indent::_(2) . "return false;"; + $ukit[] = Indent::_(1) . "}"; + + // return the help methods + return implode(PHP_EOL, $ukit); + } + + return ''; + } + + public function setUikitGetMethod() + { + $method = ''; + // only load for uikit version 2 + if (2 == CFactory::_('Config')->uikit || 1 == CFactory::_('Config')->uikit) + { + // build uikit get method + $method .= PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $method .= PHP_EOL . Indent::_(1) + . " * Get the uikit needed components"; + $method .= PHP_EOL . Indent::_(1) . " *"; + $method .= PHP_EOL . Indent::_(1) + . " * @return mixed An array of objects on success."; + $method .= PHP_EOL . Indent::_(1) . " *"; + $method .= PHP_EOL . Indent::_(1) . " */"; + $method .= PHP_EOL . Indent::_(1) + . "public function getUikitComp()"; + $method .= PHP_EOL . Indent::_(1) . "{"; + $method .= PHP_EOL . Indent::_(2) + . "if (isset(\$this->uikitComp) && " + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$this->uikitComp))"; + $method .= PHP_EOL . Indent::_(2) . "{"; + $method .= PHP_EOL . Indent::_(3) . "return \$this->uikitComp;"; + $method .= PHP_EOL . Indent::_(2) . "}"; + $method .= PHP_EOL . Indent::_(2) . "return false;"; + $method .= PHP_EOL . Indent::_(1) . "}"; + } + + return $method; + } + + public function setMainCustomMehtod(&$body, $nAme, $type) + { + $method = ''; + if (StringHelper::check($body)) + { + // build custom method + $method .= PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $method .= PHP_EOL . Indent::_(1) . " * Custom Method"; + $method .= PHP_EOL . Indent::_(1) . " *"; + $method .= PHP_EOL . Indent::_(1) . " * @return " . $type; + $method .= PHP_EOL . Indent::_(1) . " *"; + $method .= PHP_EOL . Indent::_(1) . " */"; + $method .= PHP_EOL . Indent::_(1) . "public function " . $nAme + . "()"; + $method .= PHP_EOL . Indent::_(1) . "{" . $body; + $method .= PHP_EOL . Indent::_(1) . "}"; + } + + return $method; + } + + public function setCustomViewCustomItemMethods(&$main_get, $code) + { + $methods = ''; + $this->JEventDispatcher = ''; + // first set the needed item/s methods + if (ObjectHelper::check($main_get)) + { + if (isset($main_get->custom_get) + && ArrayHelper::check($main_get->custom_get)) + { + foreach ($main_get->custom_get as $get) + { + // set the site decription switch + foreach (CFactory::_('Config')->cryption_types as $cryptionType) + { + CFactory::_('Compiler.Builder.Site.Decrypt')->set("{$cryptionType}.{$code}", false); + } + // set the method defaults + if (($default = $this->setCustomViewMethodDefaults($get, $code)) !== false) + { + // build custom method + $methods .= PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $methods .= PHP_EOL . Indent::_(1) + . " * Method to get an array of " . $default['name'] + . " Objects."; + $methods .= PHP_EOL . Indent::_(1) . " *"; + $methods .= PHP_EOL . Indent::_(1) + . " * @return mixed An array of " + . $default['name'] + . " Objects on success, false on failure."; + $methods .= PHP_EOL . Indent::_(1) . " *"; + $methods .= PHP_EOL . Indent::_(1) . " */"; + $methods .= PHP_EOL . Indent::_(1) + . "public function get" . $default['methodName'] + . "(\$" . $default['on_field'] . ")"; + $methods .= PHP_EOL . Indent::_(1) . "{" . Placefix::_h("CRYPT") ; + $methods .= PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " Get a db connection."; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $methods .= PHP_EOL . Indent::_(2) + . "\$db = Factory::getDbo();"; + } + else + { + $methods .= PHP_EOL . Indent::_(2) + . "\$db = \$this->getDatabase();"; + } + $methods .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " Create a new query object."; + $methods .= PHP_EOL . Indent::_(2) + . "\$query = \$db->getQuery(true);"; + $methods .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Get from " + . $get['selection']['table'] . " as " + . $default['as']; + $methods .= PHP_EOL . Indent::_(2) + . $get['selection']['select']; + $methods .= PHP_EOL . Indent::_(2) . '$query->from(' + . $get['selection']['from'] . ');'; + // set the string + if ($get['operator'] === 'IN' + || $get['operator'] === 'NOT IN') + { + $methods .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Check if \$" + . $default['on_field'] + . " is an array with values."; + $methods .= PHP_EOL . Indent::_(2) . "\$array = (" + . "Super_" . "__4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::check(\$" + . $default['on_field'] + . ", true)) ? json_decode(\$" + . $default['on_field'] . ",true) : \$" + . $default['on_field'] . ";"; + $methods .= PHP_EOL . Indent::_(2) + . "if (isset(\$array) && " + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$array, true))"; + $methods .= PHP_EOL . Indent::_(2) . "{"; + $methods .= PHP_EOL . Indent::_(3) + . "\$query->where('" . $get['join_field'] . " " + . $get['operator'] + . " (' . implode(',', \$array) . ')');"; + $methods .= PHP_EOL . Indent::_(2) . "}"; + $methods .= PHP_EOL . Indent::_(2) . "else"; + $methods .= PHP_EOL . Indent::_(2) . "{"; + $methods .= PHP_EOL . Indent::_(3) + . "return false;"; + $methods .= PHP_EOL . Indent::_(2) . "}"; + } + else + { + $methods .= PHP_EOL . Indent::_(2) + . "\$query->where('" . $get['join_field'] . " " + . $get['operator'] . " ' . \$db->quote(\$" + . $default['on_field'] . "));"; + } + // check if other queries should be loaded + foreach (CFactory::_('Compiler.Builder.Other.Query')-> + get(CFactory::_('Config')->build_target . '.' . $default['code'] . '.' . $default['as'], []) + as $query) + { + $methods .= $query; + } + // add any other filter that was set + foreach (CFactory::_('Compiler.Builder.Other.Filter')-> + get(CFactory::_('Config')->build_target . '.' . $default['code'] . '.' . $default['as'], []) + as $field => $string) + { + $methods .= $string; + } + // add any other where that was set + foreach (CFactory::_('Compiler.Builder.Other.Where')-> + get(CFactory::_('Config')->build_target . '.' . $default['code'] . '.' . $default['as'], []) + as $field => $string) + { + $methods .= $string; + } + // add any other order that was set + foreach (CFactory::_('Compiler.Builder.Other.Order')-> + get(CFactory::_('Config')->build_target . '.' . $default['code'] . '.' . $default['as'], []) + as $field => $string) + { + $methods .= $string; + } + // add any other grouping that was set + foreach (CFactory::_('Compiler.Builder.Other.Group')-> + get(CFactory::_('Config')->build_target . '.' . $default['code'] . '.' . $default['as'], []) + as $field => $string) + { + $methods .= $string; + } + $methods .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " Reset the query using our newly populated query object."; + $methods .= PHP_EOL . Indent::_(2) + . "\$db->setQuery(\$query);"; + $methods .= PHP_EOL . Indent::_(2) . "\$db->execute();"; + $methods .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " check if there was data returned"; + $methods .= PHP_EOL . Indent::_(2) + . "if (\$db->getNumRows())"; + $methods .= PHP_EOL . Indent::_(2) . "{"; + // set dispatcher placeholder + $methods .= Placefix::_h("DISPATCHER"); + // build path + $path = $default['code'] . '.' . $get['key'] . '.' . $default['as']; + // set decoding of needed fields + $decodeChecker = CFactory::_('Compiler.Builder.Site.Field.Data')->get('decode.' . $path); + // also filter fields if needed + $decodeFilter = CFactory::_('Compiler.Builder.Site.Field.Decode.Filter')-> + get(CFactory::_('Config')->build_target . '.' . $path); + // set uikit checkers on needed fields + $uikitChecker = CFactory::_('Compiler.Builder.Site.Field.Data')->get('uikit.' . $path); + // set content prepare on needed fields + $contentprepareChecker = CFactory::_('Compiler.Builder.Site.Field.Data')-> + get('textareas.' . $path); + // set placeholder values + $placeholders = [ + Placefix::_h('TAB') => Indent::_(2), + Placefix::_h('STRING') => '$item' + ]; + // set joined values + $joinedChecker = CFactory::_('Compiler.Builder.Other.Join')-> + get(CFactory::_('Config')->build_target . '.' . $default['code'] . '.' . $default['as']); + if ($decodeChecker !== null || $uikitChecker !== null + || $decodeFilter !== null || $contentprepareChecker !== null + || $joinedChecker !== null) + { + $decoder = ''; + if ($decodeChecker !== null && ArrayHelper::check($decodeChecker)) + { + // also filter fields if needed + $decoder = $this->setCustomViewFieldDecode( + $get, $decodeChecker, '$item', + $default['code'], Indent::_(2) + ); + } + $decoder_filter = ''; + if ($decodeFilter !== null && ArrayHelper::check($decodeFilter)) + { + $decoder_filter + = $this->setCustomViewFieldDecodeFilter( + $get, $decodeFilter, '$item', '$items[$nr]', + $default['code'], Indent::_(2) + ); + } + $contentprepare = ''; + if ($contentprepareChecker !== null && ArrayHelper::check($contentprepareChecker)) + { + $contentprepare + = $this->setCustomViewFieldonContentPrepareChecker( + $get, $contentprepareChecker, '$item', + $default['code'], Indent::_(2) + ); + } + $uikit = ''; + if ($uikitChecker !== null && ArrayHelper::check($uikitChecker)) + { + $uikit = $this->setCustomViewFieldUikitChecker( + $get, $uikitChecker, '$item', + $default['code'], Indent::_(2) + ); + } + $joine = ''; + if ($joinedChecker !== null && ArrayHelper::check($joinedChecker)) + { + foreach ($joinedChecker as $joinedString) + { + $joine .= CFactory::_('Placeholder')->update( + $joinedString, $placeholders + ); + } + } + if (StringHelper::check($decoder) || StringHelper::check($contentprepare) + || StringHelper::check($uikit) || StringHelper::check($decoder_filter) + || StringHelper::check($joine)) + { + $methods .= PHP_EOL . Indent::_(3) + . "\$items = \$db->loadObjectList();"; + $methods .= PHP_EOL . PHP_EOL . Indent::_(3) + . "//" . Line::_(__Line__, __Class__) + . " Convert the parameter fields into objects."; + $methods .= PHP_EOL . Indent::_(3) + . "foreach (\$items as \$nr => &\$item)"; + $methods .= PHP_EOL . Indent::_(3) . "{"; + if (StringHelper::check($decoder)) + { + $methods .= $decoder; + } + if (StringHelper::check($decoder_filter)) + { + $methods .= $decoder_filter; + } + if (StringHelper::check($contentprepare)) + { + $methods .= $contentprepare; + } + if (StringHelper::check($uikit)) + { + $methods .= $uikit; + } + if (StringHelper::check($joine)) + { + $methods .= $joine; + } + $methods .= PHP_EOL . Indent::_(3) . "}"; + $methods .= PHP_EOL . Indent::_(3) + . "return \$items;"; + } + else + { + $methods .= PHP_EOL . Indent::_(3) + . "return \$db->loadObjectList();"; + } + } + else + { + $methods .= PHP_EOL . Indent::_(3) + . "return \$db->loadObjectList();"; + } + $methods .= PHP_EOL . Indent::_(2) . "}"; + $methods .= PHP_EOL . Indent::_(2) . "return false;"; + $methods .= PHP_EOL . Indent::_(1) . "}"; + + // set the script if it was found + $Component = CFactory::_('Compiler.Builder.Content.One')->get('Component'); + $script = ''; + foreach (CFactory::_('Config')->cryption_types as $cryptionType) + { + if (CFactory::_('Compiler.Builder.Site.Decrypt')->get("{$cryptionType}.{$code}", false)) + { + if ('expert' !== $cryptionType) + { + $script .= PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Get the " + . $cryptionType . " encryption."; + $script .= PHP_EOL . Indent::_(2) . "\$" + . $cryptionType . "key = " . $Component + . "Helper::getCryptKey('" + . $cryptionType . "');"; + $script .= PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " Get the encryption object."; + $script .= PHP_EOL . Indent::_(2) . "\$" + . $cryptionType + . " = new Super_" . "__99175f6d_dba8_4086_8a65_5c4ec175e61d___Power(\$" + . $cryptionType . "key);" . PHP_EOL; + } + elseif (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> + exists("{$code}.get")) + { + foreach (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> + exists("{$code}.get") as $block) + { + $script .= PHP_EOL . Indent::_(2) . implode( + PHP_EOL . Indent::_(2), $block + ); + } + } + } + } + $methods = str_replace( + Placefix::_h('CRYPT'), $script, $methods + ); + } + } + // insure the crypt placeholder is removed + if (StringHelper::check($methods)) + { + $methods = str_replace( + Placefix::_h('CRYPT'), '', $methods + ); + } + } + } + // only update if dispacher placholder is found + if (strpos($methods, (string) Placefix::_h('DISPATCHER')) !== false) + { + // check if the dispather should be added + if (!isset($this->JEventDispatcher) + || !ArrayHelper::check($this->JEventDispatcher)) + { + $this->JEventDispatcher = array(Placefix::_h('DISPATCHER') => ''); + } + $methods = str_replace( + array_keys($this->JEventDispatcher), + array_values($this->JEventDispatcher), $methods + ); + } + // insure the crypt placeholder is removed + if (StringHelper::check($methods)) + { + return $methods . PHP_EOL; + } + + return ''; + } + + public function setCustomViewMethodDefaults($get, $code) + { + if (isset($get['key']) && isset($get['as'])) + { + $key = substr( + (string) StringHelper::safe( + preg_replace('/[0-9]+/', '', md5((string) $get['key'])), 'F' + ), 0, 4 + ); + $method['on_field'] = (isset($get['on_field'])) + ? $this->removeAsDot($get['on_field']) : null; + $method['join_field'] = (isset($get['join_field'])) + ? StringHelper::safe( + $this->removeAsDot($get['join_field']) + ) : null; + $method['Join_field'] = (isset($method['join_field'])) + ? StringHelper::safe($method['join_field'], 'F') + : null; + $method['name'] = StringHelper::safe( + $get['selection']['name'], 'F' + ); + $method['code'] = StringHelper::safe($code); + $method['AS'] = StringHelper::safe( + $get['as'], 'U' + ); + $method['as'] = StringHelper::safe( + $get['as'] + ); + $method['valueName'] = $method['on_field'] . $method['Join_field'] + . $method['name'] . $method['AS']; + $method['methodName'] = StringHelper::safe( + $method['on_field'], 'F' + ) . $method['Join_field'] . $method['name'] . $key . '_' + . $method['AS']; + + // return + return $method; + } + + return false; + } + + public function setCustomViewListQuery(&$get, $code, $return = true) + { + if (ObjectHelper::check($get)) + { + if ($get->pagination == 1) + { + $getItem = PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Get a db connection."; + } + else + { + $getItem = PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) + . " Make sure all records load, since no pagination allowed."; + $getItem .= PHP_EOL . Indent::_(2) + . "\$this->setState('list.limit', 0);"; + $getItem .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Get a db connection."; + } + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $getItem .= PHP_EOL . Indent::_(2) . "\$db = Factory::getDbo();"; + } + else + { + $getItem .= PHP_EOL . Indent::_(2) . "\$db = \$this->getDatabase();"; + } + $getItem .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Create a new query object."; + $getItem .= PHP_EOL . Indent::_(2) + . "\$query = \$db->getQuery(true);"; + // set main get query + $getItem .= $this->setCustomViewQuery($get->main_get, $code); + // check if there is any custom script + $getItem .= CFactory::_('Customcode.Dispenser')->get( + CFactory::_('Config')->build_target . '_php_getlistquery', $code, '', + PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Filtering.", true + ); + // setup filters + if (isset($get->filter)) + { + $getItem .= $this->setCustomViewFilter($get->filter, $code); + } + // setup where + if (isset($get->where)) + { + $getItem .= $this->setCustomViewWhere($get->where, $code); + } + // setup ordering + if (isset($get->order)) + { + $getItem .= $this->setCustomViewOrder($get->order, $code); + } + // setup grouping + if (isset($get->group)) + { + $getItem .= $this->setCustomViewGroup($get->group, $code); + } + if ($return) + { + // return the query object + $getItem .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " return the query object" + . PHP_EOL . Indent::_(2) . "return \$query;"; + } + + return $getItem; + } + + return PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . "add your custom code here."; + } + + /** + * @param $get + * @param $code + * + * @return string + */ + public function setCustomViewGetItems(&$get, $code) + { + $getItem = ''; + // set the site decrypt switch + foreach (CFactory::_('Config')->cryption_types as $cryptionType) + { + CFactory::_('Compiler.Builder.Site.Decrypt')->set("{$cryptionType}.{$code}", false); + } + // set the component name + $Component = CFactory::_('Compiler.Builder.Content.One')->get('Component'); + // start load the get item + if (ObjectHelper::check($get)) + { + $getItem .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " Insure all item fields are adapted where needed."; + $getItem .= PHP_EOL . Indent::_(2) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$items))"; + $getItem .= PHP_EOL . Indent::_(2) . "{"; + $getItem .= Placefix::_h("DISPATCHER") ; + $getItem .= PHP_EOL . Indent::_(3) + . "foreach (\$items as \$nr => &\$item)"; + $getItem .= PHP_EOL . Indent::_(3) . "{"; + $getItem .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Always create a slug for sef URL's"; + $getItem .= PHP_EOL . Indent::_(4) + . "\$item->slug = (\$item->id ?? '0') . (isset(\$item->alias) ? ':' . \$item->alias : '');"; + if (isset($get->main_get) + && ArrayHelper::check( + $get->main_get + )) + { + $asBucket = []; + foreach ($get->main_get as $main_get) + { + // build path + $path = $code . '.' . $main_get['key'] . '.' . $main_get['as']; + + $decodeChecker = CFactory::_('Compiler.Builder.Site.Field.Data')->get('decode.' . $path); + if (ArrayHelper::check($decodeChecker)) + { + // set decoding of needed fields + $getItem .= $this->setCustomViewFieldDecode( + $main_get, $decodeChecker, "\$item", $code, + Indent::_(2) + ); + } + + // also filter fields if needed + $decodeFilter = CFactory::_('Compiler.Builder.Site.Field.Decode.Filter')-> + get(CFactory::_('Config')->build_target . '.' . $path); + if (ArrayHelper::check($decodeFilter)) + { + $getItem .= $this->setCustomViewFieldDecodeFilter( + $main_get, $decodeFilter, "\$item", + '$items[$nr]', $code, Indent::_(2) + ); + } + + $contentprepareChecker = CFactory::_('Compiler.Builder.Site.Field.Data')->get('textareas.' . $path); + if (ArrayHelper::check($contentprepareChecker)) + { + // set contentprepare checkers on needed fields + $getItem .= $this->setCustomViewFieldonContentPrepareChecker( + $main_get, $contentprepareChecker, "\$item", + $code, Indent::_(2) + ); + } + + $uikitChecker = CFactory::_('Compiler.Builder.Site.Field.Data')->get('uikit.' . $path); + if (ArrayHelper::check($uikitChecker)) + { + // set uikit checkers on needed fields + $getItem .= $this->setCustomViewFieldUikitChecker( + $main_get, $uikitChecker, "\$item", $code, + Indent::_(2) + ); + } + + $asBucket[] = $main_get['as']; + } + } + // only update if dispacher placholder is found + if (strpos($getItem, (string) Placefix::_h('DISPATCHER')) + !== false) + { + // check if the dispather should be added + if (!isset($this->JEventDispatcher) + || !ArrayHelper::check( + $this->JEventDispatcher + )) + { + $this->JEventDispatcher = array(Placefix::_h('DISPATCHER') => ''); + } + $getItem = str_replace( + array_keys($this->JEventDispatcher), + array_values($this->JEventDispatcher), $getItem + ); + } + // setup Globals + $getItem .= $this->setCustomViewGlobals( + $get->global, '$item', $asBucket, Indent::_(2) + ); + // setup the custom gets that returns multipal values + $getItem .= $this->setCustomViewCustomJoin( + $get->custom_get, "\$item", $code, $asBucket, Indent::_(2) + ); + // set calculations + if ($get->addcalculation == 1) + { + $get->php_calculation = (array) explode( + PHP_EOL, (string) $get->php_calculation + ); + if (ArrayHelper::check($get->php_calculation)) + { + $_tmp = PHP_EOL . Indent::_(4) . implode( + PHP_EOL . Indent::_(4), $get->php_calculation + ); + $getItem .= CFactory::_('Placeholder')->update_( + $_tmp + ); + } + } + $getItem .= PHP_EOL . Indent::_(3) . "}"; + $getItem .= PHP_EOL . Indent::_(2) . "}"; + // remove empty foreach + if (strlen($getItem) <= 100) + { + $getItem = PHP_EOL; + } + } + + // set the script if found + $script = ''; + foreach (CFactory::_('Config')->cryption_types as $cryptionType) + { + if (CFactory::_('Compiler.Builder.Site.Decrypt')->get("{$cryptionType}.{$code}", false)) + { + if ('expert' !== $cryptionType) + { + $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Get the " . $cryptionType + . " encryption."; + $script .= PHP_EOL . Indent::_(2) . "\$" . $cryptionType + . "key = " . $Component . "Helper::getCryptKey('" + . $cryptionType . "');"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Get the encryption object."; + $script .= PHP_EOL . Indent::_(2) . "\$" . $cryptionType + . " = new Super_" . "__99175f6d_dba8_4086_8a65_5c4ec175e61d___Power(\$" . $cryptionType . "key);"; + } + elseif (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> + exists("{$code}.get")) + { + foreach (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> + get("{$code}.get") as $block) + { + $script .= PHP_EOL . Indent::_(2) . implode( + PHP_EOL . Indent::_(2), $block + ); + } + } + } + } + + return $script . $getItem; + } + + /** + * build code for the admin view display method + * + * @param string $nameListCode The list view name + * + * @return string The php to place in view.html.php + * + */ + public function setAdminViewDisplayMethod($nameListCode) + { + $script = ''; + // add the new filter methods for the search toolbar above the list view (2 = topbar) + if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2) + { + $script .= PHP_EOL . Indent::_(2) . "//" + . Line::_( + __LINE__,__CLASS__ + ) . " Load the filter form from xml."; + $script .= PHP_EOL . Indent::_(2) . "\$this->filterForm " + . "= \$this->get('FilterForm');"; + $script .= PHP_EOL . Indent::_(2) . "//" + . Line::_( + __LINE__,__CLASS__ + ) . " Load the active filters."; + $script .= PHP_EOL . Indent::_(2) . "\$this->activeFilters " + . "= \$this->get('ActiveFilters');"; + } + // get the default ordering values + $default_ordering = $this->getListViewDefaultOrdering($nameListCode); + // now add the default ordering + $script .= PHP_EOL . Indent::_(2) . "//" + . Line::_( + __LINE__,__CLASS__ + ) . " Add the list ordering clause."; + $script .= PHP_EOL . Indent::_(2) + . "\$this->listOrder = \$this->escape(\$this->state->get('list.ordering', '" + . $default_ordering['name'] . "'));"; + $script .= PHP_EOL . Indent::_(2) + . "\$this->listDirn = \$this->escape(\$this->state->get('list.direction', '" + . $default_ordering['direction'] . "'));"; + + return $script; + } + + public function setCustomViewDisplayMethod(&$view) + { + $method = ''; + if (isset($view['settings']->main_get) + && ObjectHelper::check($view['settings']->main_get)) + { + // add events if needed + if ($view['settings']->main_get->gettype == 1 + && ArrayHelper::check( + $view['settings']->main_get->plugin_events + )) + { + // load the dispatcher + $method .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Initialise dispatcher."; + $method .= PHP_EOL . Indent::_(2) + . "\$dispatcher = JEventDispatcher::getInstance();"; + } + if ($view['settings']->main_get->gettype == 1) + { + // for single views + $method .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Initialise variables."; + $method .= PHP_EOL . Indent::_(2) + . "\$this->item = \$this->get('Item');"; + } + elseif ($view['settings']->main_get->gettype == 2) + { + // for list views + $method .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Initialise variables."; + $method .= PHP_EOL . Indent::_(2) + . "\$this->items = \$this->get('Items');"; + // only add if pagination is requered + if ($view['settings']->main_get->pagination == 1) + { + $method .= PHP_EOL . Indent::_(2) + . "\$this->pagination = \$this->get('Pagination');"; + } + } + // add the custom get methods + if (isset($view['settings']->custom_get) + && ArrayHelper::check( + $view['settings']->custom_get + )) + { + foreach ($view['settings']->custom_get as $custom_get) + { + $custom_get_name = str_replace( + 'get', '', (string) $custom_get->getcustom + ); + $method .= PHP_EOL . Indent::_(2) . "\$this->" + . StringHelper::safe($custom_get_name) + . " = \$this->get('" . $custom_get_name . "');"; + } + } + // add custom script + if ($view['settings']->add_php_jview_display == 1) + { + $view['settings']->php_jview_display = (array) explode( + PHP_EOL, (string) $view['settings']->php_jview_display + ); + if (ArrayHelper::check( + $view['settings']->php_jview_display + )) + { + $_tmp = PHP_EOL . Indent::_(2) . implode( + PHP_EOL . Indent::_(2), + $view['settings']->php_jview_display + ); + $method .= CFactory::_('Placeholder')->update_( + $_tmp + ); + } + } + if ('site' === CFactory::_('Config')->build_target) + { + $method .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Set the toolbar"; + $method .= PHP_EOL . Indent::_(2) . "\$this->addToolBar();"; + $method .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Set the html view document stuff"; + $method .= PHP_EOL . Indent::_(2) + . "\$this->_prepareDocument();"; + } + elseif ('custom_admin' === CFactory::_('Config')->build_target) + { + $method .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " We don't need toolbar in the modal window."; + $method .= PHP_EOL . Indent::_(2) + . "if (\$this->getLayout() !== 'modal')"; + $method .= PHP_EOL . Indent::_(2) . "{"; + $method .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " add the tool bar"; + $method .= PHP_EOL . Indent::_(3) . "\$this->addToolBar();"; + $method .= PHP_EOL . Indent::_(2) . "}"; + + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $method .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " set the document"; + $method .= PHP_EOL . Indent::_(2) . "\$this->setDocument();"; + } + } + + $method .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Check for errors."; + $method .= PHP_EOL . Indent::_(2) + . "if (count(\$errors = \$this->get('Errors')))"; + $method .= PHP_EOL . Indent::_(2) . "{"; + $method .= PHP_EOL . Indent::_(3) + . "throw new \Exception(implode(PHP_EOL, \$errors), 500);"; + $method .= PHP_EOL . Indent::_(2) . "}"; + // add events if needed + if ($view['settings']->main_get->gettype == 1 + && ArrayHelper::check( + $view['settings']->main_get->plugin_events + )) + { + $method .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Process the content plugins."; + $method .= PHP_EOL . Indent::_(2) . "if (" + . "Super_" . "__91004529_94a9_4590_b842_e7c6b624ecf5___Power::check(\$this->item))"; + $method .= PHP_EOL . Indent::_(2) . "{"; + $method .= PHP_EOL . Indent::_(3) + . "PluginHelper::importPlugin('content');"; + $method .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Setup Event Object."; + $method .= PHP_EOL . Indent::_(3) + . "\$this->item->event = new \stdClass;"; + $method .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Check if item has params, or pass global params"; + $method .= PHP_EOL . Indent::_(3) + . "\$params = (isset(\$this->item->params) && " + . "Super_" . "__4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::check(\$this->item->params)) ? json_decode(\$this->item->params) : \$this->params;"; + // load the defaults + foreach ( + $view['settings']->main_get->plugin_events as $plugin_event + ) + { + // load the events + if ('onContentPrepare' === $plugin_event) + { + // TODO the onContentPrepare already gets triggered on the fields of its relation + // $method .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " onContentPrepare Event Trigger."; + // $method .= PHP_EOL . Indent::_(2) . "\$dispatcher->trigger('onContentPrepare', array ('com_" . CFactory::_('Config')->component_code_name . ".article', &\$this->item, &\$this->params, 0));"; + } + else + { + $method .= PHP_EOL . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) . " " . $plugin_event + . " Event Trigger."; + $method .= PHP_EOL . Indent::_(3) + . "\$results = \$dispatcher->trigger('" + . $plugin_event . "', array('com_" + . CFactory::_('Config')->component_code_name . "." + . $view['settings']->context + . "', &\$this->item, &\$params, 0));"; + $method .= PHP_EOL . Indent::_(3) + . '$this->item->event->' . $plugin_event + . ' = trim(implode("\n", $results));'; + } + } + $method .= PHP_EOL . Indent::_(2) . "}"; + } + $method .= PHP_EOL . PHP_EOL . Indent::_(2) + . "parent::display(\$tpl);"; + } + + return $method; + } + + public function setPrepareDocument(&$view) + { + // fix just incase we missed it somewhere + $tmp = CFactory::_('Config')->lang_target; + if ('site' === CFactory::_('Config')->build_target) + { + CFactory::_('Config')->lang_target = 'site'; + } + else + { + CFactory::_('Config')->lang_target = 'admin'; + } + + // ensure correct target is set + $TARGET = StringHelper::safe(CFactory::_('Config')->build_target, 'U'); + + // set libraries $TARGET.'_LIBRARIES_LOADER + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_LIBRARIES_LOADER', + $this->setLibrariesLoader($view) + ); + + // set uikit $TARGET.'_UIKIT_LOADER + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_UIKIT_LOADER', + $this->setUikitLoader($view) + ); + + // set Google Charts $TARGET.'_GOOGLECHART_LOADER + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' .$TARGET . '_GOOGLECHART_LOADER', + $this->setGoogleChartLoader($view) + ); + + // set Footable FOOTABLE_LOADER + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_FOOTABLE_LOADER', + $this->setFootableScriptsLoader($view) + ); + + // set metadata DOCUMENT_METADATA + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_DOCUMENT_METADATA', + $this->setDocumentMetadata($view) + ); + + // set custom php scripting DOCUMENT_CUSTOM_PHP + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_DOCUMENT_CUSTOM_PHP', + $this->setDocumentCustomPHP($view) + ); + + // set custom css DOCUMENT_CUSTOM_CSS + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' .$TARGET . '_DOCUMENT_CUSTOM_CSS', + $this->setDocumentCustomCSS($view) + ); + + // set custom javascript DOCUMENT_CUSTOM_JS + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_DOCUMENT_CUSTOM_JS', + $this->setDocumentCustomJS($view) + ); + + // set custom css file VIEWCSS + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_VIEWCSS', + $this->setCustomCSS($view) + ); + + // incase no buttons are found + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|SITE_JAVASCRIPT_FOR_BUTTONS', ''); + + // set the custom buttons CUSTOM_BUTTONS + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_CUSTOM_BUTTONS', + $this->setCustomButtons($view) + ); + + // see if we should add get modules to the view.html + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_GET_MODULE', + $this->setGetModules($view, $TARGET) + ); + + // set a JavaScript file if needed + CFactory::_('Compiler.Builder.Content.Multi')->add($view['settings']->code . '|' . $TARGET . '_LIBRARIES_LOADER', + $this->setJavaScriptFile($view, $TARGET), false + ); + // fix just incase we missed it somewhere + CFactory::_('Config')->lang_target = $tmp; + } + + public function setGetModules($view, $TARGET) + { + if (CFactory::_('Compiler.Builder.Get.Module')-> + exists(CFactory::_('Config')->build_target . '.' . $view['settings']->code)) + { + $addModule = []; + $addModule[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $addModule[] = Indent::_(1) + . " * Get the modules published in a position"; + $addModule[] = Indent::_(1) . " */"; + $addModule[] = Indent::_(1) + . "public function getModules(\$position, \$seperator = '', \$class = '')"; + $addModule[] = Indent::_(1) . "{"; + $addModule[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " set default"; + $addModule[] = Indent::_(2) . "\$found = false;"; + $addModule[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " check if we aleady have these modules loaded"; + $addModule[] = Indent::_(2) + . "if (isset(\$this->setModules[\$position]))"; + $addModule[] = Indent::_(2) . "{"; + $addModule[] = Indent::_(3) . "\$found = true;"; + $addModule[] = Indent::_(2) . "}"; + $addModule[] = Indent::_(2) . "else"; + $addModule[] = Indent::_(2) . "{"; + $addModule[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " this is where you want to load your module position"; + $addModule[] = Indent::_(3) + . "\$modules = ModuleHelper::getModules(\$position);"; + $addModule[] = Indent::_(3) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$modules, true))"; + $addModule[] = Indent::_(3) . "{"; + $addModule[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " set the place holder"; + $addModule[] = Indent::_(4) + . "\$this->setModules[\$position] = [];"; + $addModule[] = Indent::_(4) . "foreach(\$modules as \$module)"; + $addModule[] = Indent::_(4) . "{"; + $addModule[] = Indent::_(5) + . "\$this->setModules[\$position][] = ModuleHelper::renderModule(\$module);"; + $addModule[] = Indent::_(4) . "}"; + $addModule[] = Indent::_(4) . "\$found = true;"; + $addModule[] = Indent::_(3) . "}"; + $addModule[] = Indent::_(2) . "}"; + $addModule[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " check if modules were found"; + $addModule[] = Indent::_(2) + . "if (\$found && isset(\$this->setModules[\$position]) && " + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$this->setModules[\$position]))"; + $addModule[] = Indent::_(2) . "{"; + $addModule[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " set class"; + $addModule[] = Indent::_(3) . "if (" + . "Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$class))"; + $addModule[] = Indent::_(3) . "{"; + $addModule[] = Indent::_(4) + . "\$class = ' class=\"'.\$class.'\" ';"; + $addModule[] = Indent::_(3) . "}"; + $addModule[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " set seperating return values"; + $addModule[] = Indent::_(3) . "switch(\$seperator)"; + $addModule[] = Indent::_(3) . "{"; + $addModule[] = Indent::_(4) . "case 'none':"; + $addModule[] = Indent::_(5) + . "return implode('', \$this->setModules[\$position]);"; + $addModule[] = Indent::_(5) . "break;"; + $addModule[] = Indent::_(4) . "case 'div':"; + $addModule[] = Indent::_(5) + . "return ''.implode('
    ', \$this->setModules[\$position]).'
    ';"; + $addModule[] = Indent::_(5) . "break;"; + $addModule[] = Indent::_(4) . "case 'list':"; + $addModule[] = Indent::_(5) + . "return '
  • '.implode('
  • ', \$this->setModules[\$position]).'
  • ';"; + $addModule[] = Indent::_(5) . "break;"; + $addModule[] = Indent::_(4) . "case 'array':"; + $addModule[] = Indent::_(4) . "case 'Array':"; + $addModule[] = Indent::_(5) + . "return \$this->setModules[\$position];"; + $addModule[] = Indent::_(5) . "break;"; + $addModule[] = Indent::_(4) . "default:"; + $addModule[] = Indent::_(5) + . "return implode('
    ', \$this->setModules[\$position]);"; + $addModule[] = Indent::_(5) . "break;"; + $addModule[] = Indent::_(3) . "}"; + $addModule[] = Indent::_(2) . "}"; + $addModule[] = Indent::_(2) . "return false;"; + $addModule[] = Indent::_(1) . "}"; + + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_GET_MODULE_JIMPORT', + PHP_EOL . "use Joomla\CMS\Helper\ModuleHelper;" + ); + + return implode(PHP_EOL, $addModule); + } + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET . '_GET_MODULE_JIMPORT', ''); + + return ''; + } + + public function setDocumentCustomPHP(&$view) + { + if ($view['settings']->add_php_document == 1) + { + $view['settings']->php_document = (array) explode( + PHP_EOL, (string) $view['settings']->php_document + ); + if (ArrayHelper::check( + $view['settings']->php_document + )) + { + $_tmp = PHP_EOL . Indent::_(2) . implode( + PHP_EOL . Indent::_(2), $view['settings']->php_document + ); + + return CFactory::_('Placeholder')->update_($_tmp); + } + } + + return ''; + } + + public function setCustomButtons(&$view, $type = 1, $tab = '') + { + // do not validate selection + $validateSelection = 'false'; + // ensure correct target is set + $TARGET = StringHelper::safe(CFactory::_('Config')->build_target, 'U'); + if (1 == $type || 2 == $type) + { + if (1 == $type) + { + $viewCodeName = $view['settings']->code; + } + if (2 == $type) + { + $viewCodeName = $view['settings']->name_single_code; + } + } + elseif (3 == $type) + { + // set the names + $viewCodeName = $view['settings']->name_single_code; + $viewsCodeName = $view['settings']->name_list_code; + // if it's not been set before + if (!CFactory::_('Compiler.Builder.Content.Multi')->exists($viewsCodeName . '|' . $TARGET . '_CUSTOM_BUTTONS_METHOD_LIST')) + { + // set the custom buttons CUSTOM_BUTTONS_CONTROLLER_LIST + CFactory::_('Compiler.Builder.Content.Multi')->set($viewsCodeName . '|' . $TARGET . '_CUSTOM_BUTTONS_CONTROLLER_LIST', ''); + // set the custom buttons CUSTOM_BUTTONS_METHOD_LIST + CFactory::_('Compiler.Builder.Content.Multi')->set($viewsCodeName . '|' . $TARGET . '_CUSTOM_BUTTONS_METHOD_LIST', ''); + } + // validate selection + $validateSelection = 'true'; + } + // if it's not been set before + if (!CFactory::_('Compiler.Builder.Content.Multi')->exists($viewCodeName . '|' . $TARGET . '_CUSTOM_BUTTONS_METHOD')) + { + // set the custom buttons CUSTOM_BUTTONS_CONTROLLER + CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|' . $TARGET . '_CUSTOM_BUTTONS_CONTROLLER', ''); + // set the custom buttons CUSTOM_BUTTONS_METHOD + CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|' . $TARGET . '_CUSTOM_BUTTONS_METHOD', ''); + } + // reset buttons + $buttons = []; + // if site add buttons to view + if (CFactory::_('Config')->build_target === 'site') + { + // set the custom buttons SITE_TOP_BUTTON + CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|SITE_TOP_BUTTON', ''); + // set the custom buttons SITE_BOTTOM_BUTTON + CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|SITE_BOTTOM_BUTTON', ''); + // load into place + switch ($view['settings']->button_position) + { + case 1: + // set buttons to top right of the view + CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|SITE_TOP_BUTTON', + '
    toolbar->render(); ?>
    ' + ); + break; + case 2: + // set buttons to top left of the view + CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|SITE_TOP_BUTTON', 'toolbar->render(); ?>'); + break; + case 3: + // set buttons to buttom right of the view + CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|SITE_BOTTOM_BUTTON', + '
    toolbar->render(); ?>
    ' + ); + break; + case 4: + // set buttons to buttom left of the view + CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|SITE_BOTTOM_BUTTON', 'toolbar->render(); ?>'); + break; + case 5: + // set buttons to custom placement of the view + CFactory::_('Placeholder')->set_('SITE_TOOLBAR', + 'toolbar->render(); ?>'); + break; + } + } + // add some buttons if custom admin view + elseif (1 == $type) + { + // add this button only if this is not the default view + $dynamic_dashboard = CFactory::_('Registry')->get('build.dashboard', ''); + $dynamic_dashboard_type = CFactory::_('Registry')->get('build.dashboard.type', ''); + if ($dynamic_dashboard_type !== 'custom_admin_views' + || ($dynamic_dashboard_type === 'custom_admin_views' + && $dynamic_dashboard !== $viewCodeName)) + { + $buttons[] = $tab . Indent::_(2) + . "//" . Line::_(__Line__, __Class__) . " add cpanel button"; + $buttons[] = $tab . Indent::_(2) + . "ToolbarHelper::custom('" . $viewCodeName . "." + . "dashboard', 'grid-2', '', 'COM_" + . CFactory::_('Compiler.Builder.Content.One')->get('COMPONENT') + . "_DASH', false);"; + } + } + // check if custom button should be added + if (isset($view['settings']->add_custom_button) + && $view['settings']->add_custom_button == 1) + { + $this->onlyFunctionButton = []; + $functionNames = []; + if (isset($view['settings']->custom_buttons) + && ArrayHelper::check( + $view['settings']->custom_buttons + )) + { + foreach ($view['settings']->custom_buttons as $custom_button) + { + // Load to lang + $keyLang = CFactory::_('Config')->lang_prefix . '_' + . StringHelper::safe( + $custom_button['name'], 'U' + ); + $keyCode = StringHelper::safe( + $custom_button['name'] + ); + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, $keyLang, $custom_button['name'] + ); + // load the button + if (3 !== $type + && ($custom_button['target'] != 2 + || CFactory::_('Config')->build_target === 'site')) + { + // add cpanel button TODO does not work well on site with permissions + if ($custom_button['target'] == 2 + || CFactory::_('Config')->build_target === 'site') + { + $buttons[] = Indent::_(1) . $tab . Indent::_(1) + . "if (\$this->user->authorise('" + . $viewCodeName + . "." . $keyCode . "', 'com_" + . CFactory::_('Config')->component_code_name . "'))"; + } + else + { + $buttons[] = Indent::_(1) . $tab . Indent::_(1) + . "if (\$this->canDo->get('" . $viewCodeName + . "." + . $keyCode . "'))"; + } + $buttons[] = Indent::_(1) . $tab . Indent::_(1) . "{"; + $buttons[] = Indent::_(1) . $tab . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " add " + . $custom_button['name'] . " button."; + $buttons[] = Indent::_(1) . $tab . Indent::_(2) + . "ToolbarHelper::custom('" . $viewCodeName . "." + . $custom_button['method'] . "', '" + . $custom_button['icomoon'] . " custom-button-" + . strtolower((string) $custom_button['method']) . "', '', '" + . $keyLang + . "', false);"; + $buttons[] = Indent::_(1) . $tab . Indent::_(1) . "}"; + } + // load the list button + elseif (3 == $type && $custom_button['target'] != 1) + { + // This is only for list admin views + if (isset($custom_button['type']) + && $custom_button['type'] == 2) + { + if (!isset($this->onlyFunctionButton[$viewsCodeName])) + { + $this->onlyFunctionButton[$viewsCodeName] + = []; + } + $this->onlyFunctionButton[$viewsCodeName][] + = Indent::_( + 1 + ) . $tab . "if (\$this->user->authorise('" + . $viewCodeName . "." . $keyCode . "', 'com_" + . CFactory::_('Config')->component_code_name . "'))"; + $this->onlyFunctionButton[$viewsCodeName][] + = Indent::_( + 1 + ) . $tab . "{"; + $this->onlyFunctionButton[$viewsCodeName][] + = Indent::_( + 1 + ) . $tab . Indent::_(1) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " add " . $custom_button['name'] + . " button."; + $this->onlyFunctionButton[$viewsCodeName][] + = Indent::_( + 1 + ) . $tab . Indent::_(1) + . "ToolbarHelper::custom('" . $viewsCodeName + . "." + . $custom_button['method'] . "', '" + . $custom_button['icomoon'] . " custom-button-" + . strtolower((string) $custom_button['method']) + . "', '', '" + . $keyLang . "', false);"; + $this->onlyFunctionButton[$viewsCodeName][] + = Indent::_( + 1 + ) . $tab . "}"; + } + else + { + $buttons[] = Indent::_(1) . $tab . Indent::_(1) + . "if (\$this->user->authorise('" + . $viewCodeName + . "." . $keyCode . "', 'com_" + . CFactory::_('Config')->component_code_name . "'))"; + $buttons[] = Indent::_(1) . $tab . Indent::_(1) + . "{"; + $buttons[] = Indent::_(1) . $tab . Indent::_(2) + . "//" . Line::_(__Line__, __Class__) . " add " + . $custom_button['name'] . " button."; + $buttons[] = Indent::_(1) . $tab . Indent::_(2) + . "ToolbarHelper::custom('" . $viewsCodeName + . "." + . $custom_button['method'] . "', '" + . $custom_button['icomoon'] . " custom-button-" + . strtolower((string) $custom_button['method']) + . "', '', '" + . $keyLang . "', '" . $validateSelection + . "');"; + $buttons[] = Indent::_(1) . $tab . Indent::_(1) + . "}"; + } + } + } + } + // load the model and controller + if (3 == $type) + { + // insure the controller and model strings are added + if (isset($view['settings']->php_controller_list) + && StringHelper::check( + $view['settings']->php_controller_list + ) + && $view['settings']->php_controller_list != '//') + { + // set the custom buttons CUSTOM_BUTTONS_CONTROLLER + CFactory::_('Compiler.Builder.Content.Multi')->set($viewsCodeName . '|' . $TARGET . '_CUSTOM_BUTTONS_CONTROLLER_LIST', + PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( + $view['settings']->php_controller_list + )); + } + // load the model + if (isset($view['settings']->php_model_list) + && StringHelper::check( + $view['settings']->php_model_list + ) + && $view['settings']->php_model_list != '//') + { + // set the custom buttons CUSTOM_BUTTONS_METHOD + CFactory::_('Compiler.Builder.Content.Multi')->set($viewsCodeName . '|' . $TARGET + . '_CUSTOM_BUTTONS_METHOD_LIST', PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( + $view['settings']->php_model_list + )); + } + } + else + { + // insure the controller and model strings are added + if (StringHelper::check( + $view['settings']->php_controller + ) + && $view['settings']->php_controller != '//') + { + // set the custom buttons CUSTOM_BUTTONS_CONTROLLER + CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|' . $TARGET + . '_CUSTOM_BUTTONS_CONTROLLER', PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( + $view['settings']->php_controller + )); + if ('site' === CFactory::_('Config')->build_target) + { + // add the controller for this view + // build the file + $target = array(CFactory::_('Config')->build_target => $viewCodeName); + CFactory::_('Utilities.Structure')->build($target, 'custom_form'); + // GET_FORM_CUSTOM + } + } + // load the model + if (StringHelper::check( + $view['settings']->php_model + ) && $view['settings']->php_model != '//') + { + // set the custom buttons CUSTOM_BUTTONS_METHOD + CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|' . $TARGET + . '_CUSTOM_BUTTONS_METHOD', PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( + $view['settings']->php_model + ) + ); + } + } + } + // return buttons if they were build + if (ArrayHelper::check($buttons)) + { + // just to check if the submission script is manually added + if (!isset($view['settings']->php_document) + || (ArrayHelper::check( + $view['settings']->php_document + ) + && strpos( + implode(' ', $view['settings']->php_document), + '/submitbutton.js' + ) === false) + || (StringHelper::check( + $view['settings']->php_document + ) + && strpos( + (string) $view['settings']->php_document, + '/submitbutton.js' + ) === false)) + { + // set the custom get form method JAVASCRIPT_FOR_BUTTONS + CFactory::_('Compiler.Builder.Content.Multi')->set($viewCodeName . '|' . $TARGET + . '_JAVASCRIPT_FOR_BUTTONS', $this->setJavaScriptForButtons() + ); + } + // insure the form is added (only if no form exist) + if (isset($view['settings']->default) + && strpos( + (string) $view['settings']->default, 'addCustomForm[CFactory::_('Config')->build_target][$viewCodeName] + = true; + } + + return PHP_EOL . implode(PHP_EOL, $buttons); + } + + return ''; + } + + public function setJavaScriptForButtons() + { + // add behavior.framework to insure Joomla function is on the page + $script = []; + $script[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Add the needed Javascript to insure that the buttons work."; + $script[] = Indent::_(2) . "Html::_('behavior.framework', true);"; + $script[] = Indent::_(2) + . "\$this->getDocument()->addScriptDeclaration(\"Joomla.submitbutton = function(task){if (task == ''){ return false; } else { Joomla.submitform(task); return true; }}\");"; + + // return the script + return PHP_EOL . implode(PHP_EOL, $script); + } + + public function setFunctionOnlyButtons($nameListCode) + { + // return buttons if they were build + if (isset($this->onlyFunctionButton[$nameListCode]) + && ArrayHelper::check( + $this->onlyFunctionButton[$nameListCode] + )) + { + return PHP_EOL . implode( + PHP_EOL, $this->onlyFunctionButton[$nameListCode] + ); + } + + return ''; + } + + public function setCustomCSS(&$view) + { + if ($view['settings']->add_css == 1) + { + if (StringHelper::check($view['settings']->css)) + { + return CFactory::_('Placeholder')->update_( + $view['settings']->css + ); + } + } + + return ''; + } + + public function setDocumentCustomCSS(&$view) + { + if ($view['settings']->add_css_document == 1) + { + $view['settings']->css_document = (array) explode( + PHP_EOL, (string) $view['settings']->css_document + ); + if (ArrayHelper::check( + $view['settings']->css_document + )) + { + $script = PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Set the Custom CSS script to view" . PHP_EOL + . Indent::_(2) . '$this->document->addStyleDeclaration("'; + $cssDocument = PHP_EOL . Indent::_(3) . str_replace( + '"', '\"', implode( + PHP_EOL . Indent::_(3), + $view['settings']->css_document + ) + ); + + return $script . CFactory::_('Placeholder')->update_( + $cssDocument + ) . PHP_EOL . Indent::_(2) . '");'; + } + } + + return ''; + } + + public function setJavaScriptFile(&$view, $TARGET) + { + if ($view['settings']->add_javascript_file == 1 + && StringHelper::check( + $view['settings']->javascript_file + )) + { + // get dates + $created = CFactory::_('Model.Createdate')->get($view); + $modified = CFactory::_('Model.Modifieddate')->get($view); + // add file to view + $target = array(CFactory::_('Config')->build_target => $view['settings']->code); + $config = array(Placefix::_h('CREATIONDATE') => $created, + Placefix::_h('BUILDDATE') => $modified, + Placefix::_h('VERSION') => $view['settings']->version); + CFactory::_('Utilities.Structure')->build($target, 'javascript_file', false, $config); + // set path + if ('site' === CFactory::_('Config')->build_target) + { + $path = '/components/com_' . CFactory::_('Config')->component_code_name + . '/assets/js/' . $view['settings']->code . '.js'; + } + else + { + $path = '/administrator/components/com_' + . CFactory::_('Config')->component_code_name . '/assets/js/' + . $view['settings']->code . '.js'; + } + // add script to file + CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '|' . $TARGET + . '_JAVASCRIPT_FILE', CFactory::_('Placeholder')->update_( + $view['settings']->javascript_file + )); + + // add script to view + return PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Add View JavaScript File" . PHP_EOL . Indent::_(2) + . $this->setIncludeLibScript($path); + } + + return ''; + } + + public function setDocumentCustomJS(&$view) + { + if ($view['settings']->add_js_document == 1) + { + $view['settings']->js_document = (array) explode( + PHP_EOL, (string) $view['settings']->js_document + ); + if (ArrayHelper::check( + $view['settings']->js_document + )) + { + $script = PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Set the Custom JS script to view" . PHP_EOL + . Indent::_(2) . '$this->getDocument()->addScriptDeclaration("'; + $jsDocument = PHP_EOL . Indent::_(3) . str_replace( + '"', '\"', implode( + PHP_EOL . Indent::_(3), + $view['settings']->js_document + ) + ); + + return $script . CFactory::_('Placeholder')->update_( + $jsDocument + ) . PHP_EOL . Indent::_(2) . '");'; + } + } + + return ''; + } + + public function setFootableScriptsLoader(&$view) + { + if (CFactory::_('Compiler.Builder.Footable.Scripts')-> + exists(CFactory::_('Config')->build_target . '.' . $view['settings']->code)) + { + return $this->setFootableScripts(false); + } + + return ''; + } + + public function setDocumentMetadata(&$view) + { + if ($view['settings']->main_get->gettype == 1 + && isset($view['metadata']) + && $view['metadata'] == 1) + { + return $this->setMetadataItem(); + } + elseif (isset($view['metadata']) && $view['metadata'] == 1) + { + // lets check if we have a custom get method that has the same name as the view + // if we do then it posibly can be that the metadata is loaded via that method + // and we can load the full metadata structure with its vars + if (isset($view['settings']->custom_get) + && ArrayHelper::check( + $view['settings']->custom_get + )) + { + $found = false; + $searchFor = 'get' . $view['settings']->Code; + foreach ($view['settings']->custom_get as $custom_get) + { + if ($searchFor == $custom_get->getcustom) + { + $found = true; + break; + } + } + // now lets see + if ($found) + { + return $this->setMetadataItem($view['settings']->code); + } + else + { + return $this->setMetadataList(); + } + } + else + { + return $this->setMetadataList(); + } + } + + return ''; + } + + public function setMetadataItem($item = 'item') + { + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + return $this->setMetadataItemJ3($item); + } + return $this->setMetadataItemJ4($item); + } + + public function setMetadataList() + { + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + return $this->setMetadataListJ3(); + } + return $this->setMetadataListJ4(); + } + + public function setMetadataItemJ3($item = 'item') + { + $meta = []; + $meta[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " load the meta description"; + $meta[] = Indent::_(2) . "if (isset(\$this->" . $item + . "->metadesc) && \$this->" . $item . "->metadesc)"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) . "\$this->document->setDescription(\$this->" + . $item . "->metadesc);"; + $meta[] = Indent::_(2) . "}"; + $meta[] = Indent::_(2) + . "elseif (\$this->params->get('menu-meta_description'))"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) + . "\$this->document->setDescription(\$this->params->get('menu-meta_description'));"; + $meta[] = Indent::_(2) . "}"; + $meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " load the key words if set"; + $meta[] = Indent::_(2) . "if (isset(\$this->" . $item + . "->metakey) && \$this->" . $item . "->metakey)"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) + . "\$this->document->setMetadata('keywords', \$this->" . $item + . "->metakey);"; + $meta[] = Indent::_(2) . "}"; + $meta[] = Indent::_(2) + . "elseif (\$this->params->get('menu-meta_keywords'))"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) + . "\$this->document->setMetadata('keywords', \$this->params->get('menu-meta_keywords'));"; + $meta[] = Indent::_(2) . "}"; + $meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " check the robot params"; + $meta[] = Indent::_(2) . "if (isset(\$this->" . $item + . "->robots) && \$this->" . $item . "->robots)"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) + . "\$this->document->setMetadata('robots', \$this->" . $item + . "->robots);"; + $meta[] = Indent::_(2) . "}"; + $meta[] = Indent::_(2) . "elseif (\$this->params->get('robots'))"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) + . "\$this->document->setMetadata('robots', \$this->params->get('robots'));"; + $meta[] = Indent::_(2) . "}"; + $meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " check if autor is to be set"; + $meta[] = Indent::_(2) . "if (isset(\$this->" . $item + . "->created_by) && \$this->params->get('MetaAuthor') == '1')"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) + . "\$this->document->setMetaData('author', \$this->" . $item + . "->created_by);"; + $meta[] = Indent::_(2) . "}"; + $meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " check if metadata is available"; + $meta[] = Indent::_(2) . "if (isset(\$this->" . $item + . "->metadata) && \$this->" . $item . "->metadata)"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) . "\$mdata = json_decode(\$this->" . $item + . "->metadata,true);"; + $meta[] = Indent::_(3) . "foreach (\$mdata as \$k => \$v)"; + $meta[] = Indent::_(3) . "{"; + $meta[] = Indent::_(4) . "if (\$v)"; + $meta[] = Indent::_(4) . "{"; + $meta[] = Indent::_(5) . "\$this->document->setMetadata(\$k, \$v);"; + $meta[] = Indent::_(4) . "}"; + $meta[] = Indent::_(3) . "}"; + $meta[] = Indent::_(2) . "}"; + + return implode(PHP_EOL, $meta); + } + + public function setMetadataListJ3() + { + $meta = []; + $meta[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " load the meta description"; + $meta[] = Indent::_(2) + . "if (\$this->params->get('menu-meta_description'))"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) + . "\$this->document->setDescription(\$this->params->get('menu-meta_description'));"; + $meta[] = Indent::_(2) . "}"; + $meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " load the key words if set"; + $meta[] = Indent::_(2) + . "if (\$this->params->get('menu-meta_keywords'))"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) + . "\$this->document->setMetadata('keywords', \$this->params->get('menu-meta_keywords'));"; + $meta[] = Indent::_(2) . "}"; + $meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " check the robot params"; + $meta[] = Indent::_(2) . "if (\$this->params->get('robots'))"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) + . "\$this->document->setMetadata('robots', \$this->params->get('robots'));"; + $meta[] = Indent::_(2) . "}"; + + return implode(PHP_EOL, $meta); + } + + public function setMetadataItemJ4($item = 'item') + { + $meta = []; + $meta[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " load the meta description"; + $meta[] = Indent::_(2) . "if (isset(\$this->" . $item + . "->metadesc) && \$this->" . $item . "->metadesc)"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) . "\$this->getDocument()->setDescription(\$this->" + . $item . "->metadesc);"; + $meta[] = Indent::_(2) . "}"; + $meta[] = Indent::_(2) + . "elseif (\$this->params->get('menu-meta_description'))"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) + . "\$this->getDocument()->setDescription(\$this->params->get('menu-meta_description'));"; + $meta[] = Indent::_(2) . "}"; + $meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " load the key words if set"; + $meta[] = Indent::_(2) . "if (isset(\$this->" . $item + . "->metakey) && \$this->" . $item . "->metakey)"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) + . "\$this->getDocument()->setMetadata('keywords', \$this->" . $item + . "->metakey);"; + $meta[] = Indent::_(2) . "}"; + $meta[] = Indent::_(2) + . "elseif (\$this->params->get('menu-meta_keywords'))"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) + . "\$this->getDocument()->setMetadata('keywords', \$this->params->get('menu-meta_keywords'));"; + $meta[] = Indent::_(2) . "}"; + $meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " check the robot params"; + $meta[] = Indent::_(2) . "if (isset(\$this->" . $item + . "->robots) && \$this->" . $item . "->robots)"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) + . "\$this->getDocument()->setMetadata('robots', \$this->" . $item + . "->robots);"; + $meta[] = Indent::_(2) . "}"; + $meta[] = Indent::_(2) . "elseif (\$this->params->get('robots'))"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) + . "\$this->getDocument()->setMetadata('robots', \$this->params->get('robots'));"; + $meta[] = Indent::_(2) . "}"; + $meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " check if autor is to be set"; + $meta[] = Indent::_(2) . "if (isset(\$this->" . $item + . "->created_by) && \$this->params->get('MetaAuthor') == '1')"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) + . "\$this->getDocument()->setMetaData('author', \$this->" . $item + . "->created_by);"; + $meta[] = Indent::_(2) . "}"; + $meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " check if metadata is available"; + $meta[] = Indent::_(2) . "if (isset(\$this->" . $item + . "->metadata) && \$this->" . $item . "->metadata)"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) . "\$mdata = json_decode(\$this->" . $item + . "->metadata,true);"; + $meta[] = Indent::_(3) . "foreach (\$mdata as \$k => \$v)"; + $meta[] = Indent::_(3) . "{"; + $meta[] = Indent::_(4) . "if (\$v)"; + $meta[] = Indent::_(4) . "{"; + $meta[] = Indent::_(5) . "\$this->getDocument()->setMetadata(\$k, \$v);"; + $meta[] = Indent::_(4) . "}"; + $meta[] = Indent::_(3) . "}"; + $meta[] = Indent::_(2) . "}"; + + return implode(PHP_EOL, $meta); + } + + public function setMetadataListJ4() + { + $meta = []; + $meta[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " load the meta description"; + $meta[] = Indent::_(2) + . "if (\$this->params->get('menu-meta_description'))"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) + . "\$this->getDocument()->setDescription(\$this->params->get('menu-meta_description'));"; + $meta[] = Indent::_(2) . "}"; + $meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " load the key words if set"; + $meta[] = Indent::_(2) + . "if (\$this->params->get('menu-meta_keywords'))"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) + . "\$this->getDocument()->setMetadata('keywords', \$this->params->get('menu-meta_keywords'));"; + $meta[] = Indent::_(2) . "}"; + $meta[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " check the robot params"; + $meta[] = Indent::_(2) . "if (\$this->params->get('robots'))"; + $meta[] = Indent::_(2) . "{"; + $meta[] = Indent::_(3) + . "\$this->getDocument()->setMetadata('robots', \$this->params->get('robots'));"; + $meta[] = Indent::_(2) . "}"; + + return implode(PHP_EOL, $meta); + } + + public function setGoogleChartLoader(&$view) + { + if (CFactory::_('Compiler.Builder.Google.Chart')-> + exists(CFactory::_('Config')->build_target . '.' . $view['settings']->code)) + { + $chart = []; + $chart[] = PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " add the google chart builder class."; + $chart[] = Indent::_(2) + . "require_once JPATH_COMPONENT_ADMINISTRATOR.'/helpers/chartbuilder.php';"; + $chart[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " load the google chart js."; + $chart[] = Indent::_(2) + . "Html::_('script', 'media/com_" + . CFactory::_('Config')->component_code_name . "/js/google.jsapi.js', ['version' => 'auto']);"; + $chart[] = Indent::_(2) + . "Html::_('script', 'https://canvg.googlecode.com/svn/trunk/rgbcolor.js', ['version' => 'auto']);"; + $chart[] = Indent::_(2) + . "Html::_('script', 'https://canvg.googlecode.com/svn/trunk/canvg.js', ['version' => 'auto']);"; + + return implode(PHP_EOL, $chart); + } + + return ''; + } + + public function setLibrariesLoader($view) + { + // check call sig + if (isset($view['settings']) && isset($view['settings']->code)) + { + $code = $view['settings']->code; + $view_active = true; + } + elseif (isset($view->code_name)) + { + $code = $view->code_name; + $view_active = false; + } + // reset bucket + $setter = ''; + // always load these in + if ($view_active) + { + $setter .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Only load jQuery if needed. (default is true)"; + $setter .= PHP_EOL . Indent::_(2) . "if (\$this->params->get('add_jquery_framework', 1) == 1)"; + $setter .= PHP_EOL . Indent::_(2) . "{"; + $setter .= PHP_EOL . Indent::_(3) . "Html::_('jquery.framework');"; + $setter .= PHP_EOL . Indent::_(2) . "}"; + $setter .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Load the header checker class."; + + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + if (CFactory::_('Config')->build_target === 'site') + { + $setter .= PHP_EOL . Indent::_(2) + . "require_once( JPATH_COMPONENT_SITE.'/helpers/headercheck.php' );"; + } + else + { + $setter .= PHP_EOL . Indent::_(2) + . "require_once( JPATH_COMPONENT_ADMINISTRATOR.'/helpers/headercheck.php' );"; + } + $setter .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Initialize the header checker."; + $setter .= PHP_EOL . Indent::_(2) . "\$HeaderCheck = new " + . CFactory::_('Config')->component_code_name . "HeaderCheck();"; + } + else + { + $setter .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Initialize the header checker."; + $setter .= PHP_EOL . Indent::_(2) . "\$HeaderCheck = new HeaderCheck();"; + } + } + // check if this view should get libraries + if (($data = CFactory::_('Compiler.Builder.Library.Manager')-> + get(CFactory::_('Config')->build_target . '.' . $code)) !== null) + { + foreach ($data as $id => $true) + { + // get the library + $library = CFactory::_('Registry')->get("builder.libraries.$id", null); + if (is_object($library) && isset($library->document) + && StringHelper::check($library->document)) + { + $setter .= PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( + str_replace( + [ + '$document->', + '$this->document->' + ], + '$this->getDocument()->', + (string) $library->document + ) + ); + } + elseif (is_object($library) + && isset($library->how)) + { + $setter .= $this->setLibraryDocument($id); + } + } + } + // convert back to $document if module call (oops :) + if (!$view_active) + { + return str_replace(['$this->getDocument()->', '$this->document->'], '$document->', $setter); + } + + return $setter; + } + + protected function setLibraryDocument($id) + { + // get the library + $library = CFactory::_('Registry')->get("builder.libraries.$id", null); + // make sure we have an object + if (is_object($library)) + { + if (isset($library->how) && 2 == $library->how + && isset($library->conditions) + && ArrayHelper::check( + $library->conditions + )) + { + // build document with the conditions values + $this->setLibraryDocConditions( + $id, $this->setLibraryScripts($id, false) + ); + } + elseif (isset($library->how) && 1 == $library->how) + { + // build document to allways add all files and urls + $this->setLibraryScripts($id); + } + // check if the document was build + if (isset($library->document) + && StringHelper::check( + $library->document + )) + { + return PHP_EOL . PHP_EOL . $library->document; + } + } + + return ''; + } + + protected function setLibraryDocConditions($id, $scripts) + { + // Start script builder for library files + if (!isset($this->libwarning[$id])) + { + // set the warning only once + $this->libwarning[$id] = true; + + // get the library + $library = CFactory::_('Registry')->get("builder.libraries.$id", null); + + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_HR_HTHREECONDITIONAL_SCRIPT_WARNINGHTHREE'), 'Warning' + ); + + // message with name + if (is_object($library) && isset($library->name)) + { + $this->app->enqueueMessage( + Text::sprintf( + 'The conditional script builder for %s is not ready, sorry!', + $library->name + ), 'Warning' + ); + } + else + { + $this->app->enqueueMessage( + Text::_( + 'The conditional script builder for ID:%s is not ready, sorry!', + $id + ), 'Warning' + ); + } + } + } + + protected function setLibraryScripts($id, $buildDoc = true) + { + $scripts = []; + // get the library + $library = CFactory::_('Registry')->get("builder.libraries.$id", null); + // check that we have a library + if (is_object($library)) + { + // load the urls if found + if (isset($library->urls) + && ArrayHelper::check($library->urls)) + { + // set all the files + foreach ($library->urls as $url) + { + // if local path is set, then use it first + if (isset($url['path'])) + { + // update the root path + $path = $this->getScriptRootPath($url['path']); + // load document script + $scripts[md5((string) $url['path'])] = $this->setIncludeLibScript( + $path + ); + // load url also if not building document + if (!$buildDoc) + { + // load document script + $scripts[md5((string) $url['url'])] = $this->setIncludeLibScript( + $url['url'], false + ); + } + } + else + { + // load document script + $scripts[md5((string) $url['url'])] = $this->setIncludeLibScript( + $url['url'], false + ); + } + } + } + // load the local files if found + if (isset($library->files) + && ArrayHelper::check($library->files)) + { + // set all the files + foreach ($library->files as $file) + { + $path = '/' . trim((string) $file['path'], '/'); + // check if path has new file name (has extetion) + $pathInfo = pathinfo($path); + // update the root path + $_path = $this->getScriptRootPath($path); + if (isset($pathInfo['extension']) && $pathInfo['extension']) + { + // load document script + $scripts[md5($path)] = $this->setIncludeLibScript( + $_path, false, $pathInfo + ); + } + else + { + // load document script + $scripts[md5($path . '/' . trim((string) $file['file'], '/'))] + = $this->setIncludeLibScript( + $_path . '/' . trim((string) $file['file'], '/') + ); + } + } + } + // load the local folders if found + if (isset($library->folders) + && ArrayHelper::check( + $library->folders + )) + { + // get all the file paths + $files = []; + foreach ($library->folders as $folder) + { + if (isset($folder['path']) && isset($folder['folder'])) + { + $path = '/' . trim((string)$folder['path'], '/'); + if (isset($folder['rename']) && 1 == $folder['rename']) + { + if ($_paths = FileHelper::getPaths( + CFactory::_('Utilities.Paths')->component_path . $path + )) + { + $files[$path] = $_paths; + } + } + else + { + $path = $path . '/' . trim((string)$folder['folder'], '/'); + if ($_paths = FileHelper::getPaths( + CFactory::_('Utilities.Paths')->component_path . $path + )) + { + $files[$path] = $_paths; + } + } + } + } + // now load the script + if (ArrayHelper::check($files)) + { + foreach ($files as $root => $paths) + { + // update the root path + $_root = $this->getScriptRootPath($root); + // load per path + foreach ($paths as $path) + { + $scripts[md5($root . '/' . trim((string)$path, '/'))] + = $this->setIncludeLibScript( + $_root . '/' . trim((string)$path, '/') + ); + } + } + } + } + } + + // if there was any code added to document then set globally + if ($buildDoc && ArrayHelper::check($scripts)) + { + CFactory::_('Registry')->set("builder.libraries.${id}.document", Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " always load these files." + . PHP_EOL . Indent::_(2) . implode( + PHP_EOL . Indent::_(2), $scripts + ) + ); + + // success + return true; + } + elseif (ArrayHelper::check($scripts)) + { + return $scripts; + } + + return false; + } + + protected function setIncludeLibScript($path, $local = true, + $pathInfo = false + ) + { + // insure we have the path info + if (!$pathInfo) + { + $pathInfo = pathinfo((string) $path); + } + // use the path info to build the script + if (isset($pathInfo['extension']) && $pathInfo['extension']) + { + switch ($pathInfo['extension']) + { + case 'js': + return 'Html::_(\'script\', "' . ltrim($path, '/') + . '", [\'version\' => \'auto\']);'; + break; + case 'css': + case 'less': + return 'Html::_(\'stylesheet\', "' + . ltrim($path, '/') . '", [\'version\' => \'auto\']);'; + break; + case 'php': + if (strpos((string) $path, 'http') === false) + { + return 'require_once("' . $path . '");'; + } + break; + } + } + + return ''; + } + + protected function getScriptRootPath($root) + { + if (strpos((string) $root, '/media/') !== false + && strpos((string) $root, '/admin/') === false + && strpos((string) $root, '/site/') === false) + { + return str_replace( + '/media/', '/media/com_' . CFactory::_('Config')->component_code_name . '/', (string) $root + ); + } + elseif (strpos((string) $root, '/media/') === false + && strpos((string) $root, '/admin/') !== false + && strpos((string) $root, '/site/') === false) + { + return str_replace( + '/admin/', + '/administrator/components/com_' . CFactory::_('Config')->component_code_name + . '/', (string) $root + ); + } + elseif (strpos((string) $root, '/media/') === false + && strpos((string) $root, '/admin/') === false + && strpos((string) $root, '/site/') !== false) + { + return str_replace( + '/site/', '/components/com_' . CFactory::_('Config')->component_code_name . '/', + (string) $root + ); + } + + return $root; + } + + public function setUikitLoader(&$view) + { + // reset setter + $setter = ''; + // load the defaults needed + if (CFactory::_('Config')->uikit > 0) + { + $setter .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Load uikit options."; + $setter .= PHP_EOL . Indent::_(2) + . "\$uikit = \$this->params->get('uikit_load');"; + $setter .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Set script size."; + $setter .= PHP_EOL . Indent::_(2) + . "\$size = \$this->params->get('uikit_min');"; + $tabV = ""; + // if both versions should be loaded then add some more logic + if (2 == CFactory::_('Config')->uikit) + { + $setter .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Load uikit version."; + $setter .= PHP_EOL . Indent::_(2) + . "\$this->uikitVersion = \$this->params->get('uikit_version', 2);"; + $setter .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Use Uikit Version 2"; + $setter .= PHP_EOL . Indent::_(2) + . "if (2 == \$this->uikitVersion)"; + $setter .= PHP_EOL . Indent::_(2) . "{"; + $tabV = Indent::_(1); + } + } + // load the defaults needed + if (2 == CFactory::_('Config')->uikit || 1 == CFactory::_('Config')->uikit) + { + $setter .= PHP_EOL . $tabV . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Set css style."; + $setter .= PHP_EOL . $tabV . Indent::_(2) + . "\$style = \$this->params->get('uikit_style');"; + + $setter .= PHP_EOL . PHP_EOL . $tabV . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " The uikit css."; + $setter .= PHP_EOL . $tabV . Indent::_(2) + . "if ((!\$HeaderCheck->css_loaded('uikit.min') || \$uikit == 1) && \$uikit != 2 && \$uikit != 3)"; + $setter .= PHP_EOL . $tabV . Indent::_(2) . "{"; + $setter .= PHP_EOL . $tabV . Indent::_(3) + . "Html::_('stylesheet', 'media/com_" + . CFactory::_('Config')->component_code_name + . "/uikit-v2/css/uikit'.\$style.\$size.'.css', ['version' => 'auto']);"; + $setter .= PHP_EOL . $tabV . Indent::_(2) . "}"; + $setter .= PHP_EOL . $tabV . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " The uikit js."; + $setter .= PHP_EOL . $tabV . Indent::_(2) + . "if ((!\$HeaderCheck->js_loaded('uikit.min') || \$uikit == 1) && \$uikit != 2 && \$uikit != 3)"; + $setter .= PHP_EOL . $tabV . Indent::_(2) . "{"; + $setter .= PHP_EOL . $tabV . Indent::_(3) + . "Html::_('script', 'media/com_" + . CFactory::_('Config')->component_code_name + . "/uikit-v2/js/uikit'.\$size.'.js', ['version' => 'auto']);"; + $setter .= PHP_EOL . $tabV . Indent::_(2) . "}"; + } + // load the components need + if ((2 == CFactory::_('Config')->uikit || 1 == CFactory::_('Config')->uikit) + && ($data_ = CFactory::_('Compiler.Builder.Uikit.Comp')->get($view['settings']->code)) !== null) + { + $setter .= PHP_EOL . PHP_EOL . $tabV . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " Load the script to find all uikit components needed."; + $setter .= PHP_EOL . $tabV . Indent::_(2) . "if (\$uikit != 2)"; + $setter .= PHP_EOL . $tabV . Indent::_(2) . "{"; + $setter .= PHP_EOL . $tabV . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Set the default uikit components in this view."; + $setter .= PHP_EOL . $tabV . Indent::_(3) + . "\$uikitComp = [];"; + foreach ($data_ as $class) + { + $setter .= PHP_EOL . $tabV . Indent::_(3) . "\$uikitComp[] = '" + . $class . "';"; + } + // check content for more needed components + if (CFactory::_('Compiler.Builder.Site.Field.Data')->exists('uikit.' . $view['settings']->code)) + { + $setter .= PHP_EOL . PHP_EOL . $tabV . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) + . " Get field uikit components needed in this view."; + $setter .= PHP_EOL . $tabV . Indent::_(3) + . "\$uikitFieldComp = \$this->get('UikitComp');"; + $setter .= PHP_EOL . $tabV . Indent::_(3) + . "if (isset(\$uikitFieldComp) && " + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$uikitFieldComp))"; + $setter .= PHP_EOL . $tabV . Indent::_(3) . "{"; + $setter .= PHP_EOL . $tabV . Indent::_(4) + . "if (isset(\$uikitComp) && " + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$uikitComp))"; + $setter .= PHP_EOL . $tabV . Indent::_(4) . "{"; + $setter .= PHP_EOL . $tabV . Indent::_(5) + . "\$uikitComp = array_merge(\$uikitComp, \$uikitFieldComp);"; + $setter .= PHP_EOL . $tabV . Indent::_(5) + . "\$uikitComp = array_unique(\$uikitComp);"; + $setter .= PHP_EOL . $tabV . Indent::_(4) . "}"; + $setter .= PHP_EOL . $tabV . Indent::_(4) . "else"; + $setter .= PHP_EOL . $tabV . Indent::_(4) . "{"; + $setter .= PHP_EOL . $tabV . Indent::_(5) + . "\$uikitComp = \$uikitFieldComp;"; + $setter .= PHP_EOL . $tabV . Indent::_(4) . "}"; + $setter .= PHP_EOL . $tabV . Indent::_(3) . "}"; + } + $setter .= PHP_EOL . $tabV . Indent::_(2) . "}"; + $setter .= PHP_EOL . PHP_EOL . $tabV . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " Load the needed uikit components in this view."; + $setter .= PHP_EOL . $tabV . Indent::_(2) + . "if (\$uikit != 2 && isset(\$uikitComp) && " + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$uikitComp))"; + $setter .= PHP_EOL . $tabV . Indent::_(2) . "{"; + $setter .= PHP_EOL . $tabV . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " loading..."; + $setter .= PHP_EOL . $tabV . Indent::_(3) + . "foreach (\$uikitComp as \$class)"; + $setter .= PHP_EOL . $tabV . Indent::_(3) . "{"; + $setter .= PHP_EOL . $tabV . Indent::_(4) . "foreach (" + . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::\$uk_components[\$class] as \$name)"; + $setter .= PHP_EOL . $tabV . Indent::_(4) . "{"; + $setter .= PHP_EOL . $tabV . Indent::_(5) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " check if the CSS file exists."; + $setter .= PHP_EOL . $tabV . Indent::_(5) + . "if (File::exists(JPATH_ROOT.'/media/com_" + . CFactory::_('Config')->component_code_name + . "/uikit-v2/css/components/'.\$name.\$style.\$size.'.css'))"; + $setter .= PHP_EOL . $tabV . Indent::_(5) . "{"; + $setter .= PHP_EOL . $tabV . Indent::_(6) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " load the css."; + $setter .= PHP_EOL . $tabV . Indent::_(6) + . "Html::_('stylesheet', 'media/com_" + . CFactory::_('Config')->component_code_name + . "/uikit-v2/css/components/'.\$name.\$style.\$size.'.css', ['version' => 'auto']);"; + $setter .= PHP_EOL . $tabV . Indent::_(5) . "}"; + $setter .= PHP_EOL . $tabV . Indent::_(5) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " check if the JavaScript file exists."; + $setter .= PHP_EOL . $tabV . Indent::_(5) + . "if (File::exists(JPATH_ROOT.'/media/com_" + . CFactory::_('Config')->component_code_name + . "/uikit-v2/js/components/'.\$name.\$size.'.js'))"; + $setter .= PHP_EOL . $tabV . Indent::_(5) . "{"; + $setter .= PHP_EOL . $tabV . Indent::_(6) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " load the js."; + $setter .= PHP_EOL . $tabV . Indent::_(6) + . "Html::_('script', 'media/com_" + . CFactory::_('Config')->component_code_name + . "/uikit-v2/js/components/'.\$name.\$size.'.js', ['version' => 'auto'], ['type' => 'text/javascript', 'async' => 'async']);"; + $setter .= PHP_EOL . $tabV . Indent::_(5) . "}"; + $setter .= PHP_EOL . $tabV . Indent::_(4) . "}"; + $setter .= PHP_EOL . $tabV . Indent::_(3) . "}"; + $setter .= PHP_EOL . $tabV . Indent::_(2) . "}"; + } + elseif ((2 == CFactory::_('Config')->uikit || 1 == CFactory::_('Config')->uikit) + && CFactory::_('Compiler.Builder.Site.Field.Data')->exists('uikit.' . $view['settings']->code)) + { + $setter .= PHP_EOL . PHP_EOL . $tabV . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " Load the needed uikit components in this view."; + $setter .= PHP_EOL . $tabV . Indent::_(2) + . "\$uikitComp = \$this->get('UikitComp');"; + $setter .= PHP_EOL . $tabV . Indent::_(2) + . "if (\$uikit != 2 && isset(\$uikitComp) && " + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$uikitComp))"; + $setter .= PHP_EOL . $tabV . Indent::_(2) . "{"; + $setter .= PHP_EOL . $tabV . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " loading..."; + $setter .= PHP_EOL . $tabV . Indent::_(3) + . "foreach (\$uikitComp as \$class)"; + $setter .= PHP_EOL . $tabV . Indent::_(3) . "{"; + $setter .= PHP_EOL . $tabV . Indent::_(4) . "foreach (" + . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::\$uk_components[\$class] as \$name)"; + $setter .= PHP_EOL . $tabV . Indent::_(4) . "{"; + $setter .= PHP_EOL . $tabV . Indent::_(5) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " check if the CSS file exists."; + $setter .= PHP_EOL . $tabV . Indent::_(5) + . "if (File::exists(JPATH_ROOT.'/media/com_" + . CFactory::_('Config')->component_code_name + . "/uikit-v2/css/components/'.\$name.\$style.\$size.'.css'))"; + $setter .= PHP_EOL . $tabV . Indent::_(5) . "{"; + $setter .= PHP_EOL . $tabV . Indent::_(6) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " load the css."; + $setter .= PHP_EOL . $tabV . Indent::_(6) + . "Html::_('stylesheet', 'media/com_" + . CFactory::_('Config')->component_code_name + . "/uikit-v2/css/components/'.\$name.\$style.\$size.'.css', ['version' => 'auto']);"; + $setter .= PHP_EOL . $tabV . Indent::_(5) . "}"; + $setter .= PHP_EOL . $tabV . Indent::_(5) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " check if the JavaScript file exists."; + $setter .= PHP_EOL . $tabV . Indent::_(5) + . "if (File::exists(JPATH_ROOT.'/media/com_" + . CFactory::_('Config')->component_code_name + . "/uikit-v2/js/components/'.\$name.\$size.'.js'))"; + $setter .= PHP_EOL . $tabV . Indent::_(5) . "{"; + $setter .= PHP_EOL . $tabV . Indent::_(6) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " load the js."; + $setter .= PHP_EOL . $tabV . Indent::_(6) + . "Html::_('script', 'media/com_" + . CFactory::_('Config')->component_code_name + . "/uikit-v2/js/components/'.\$name.\$size.'.js', ['version' => 'auto'], ['type' => 'text/javascript', 'async' => 'async']);"; + $setter .= PHP_EOL . $tabV . Indent::_(5) . "}"; + $setter .= PHP_EOL . $tabV . Indent::_(4) . "}"; + $setter .= PHP_EOL . $tabV . Indent::_(3) . "}"; + $setter .= PHP_EOL . $tabV . Indent::_(2) . "}"; + } + // now set the version 3 + if (2 == CFactory::_('Config')->uikit || 3 == CFactory::_('Config')->uikit) + { + if (2 == CFactory::_('Config')->uikit) + { + $setter .= PHP_EOL . Indent::_(2) . "}"; + $setter .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Use Uikit Version 3"; + $setter .= PHP_EOL . Indent::_(2) + . "elseif (3 == \$this->uikitVersion)"; + $setter .= PHP_EOL . Indent::_(2) . "{"; + } + // add version 3 fiels to page + $setter .= PHP_EOL . $tabV . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " The uikit css."; + $setter .= PHP_EOL . $tabV . Indent::_(2) + . "if ((!\$HeaderCheck->css_loaded('uikit.min') || \$uikit == 1) && \$uikit != 2 && \$uikit != 3)"; + $setter .= PHP_EOL . $tabV . Indent::_(2) . "{"; + $setter .= PHP_EOL . $tabV . Indent::_(3) + . "Html::_('stylesheet', 'media/com_" + . CFactory::_('Config')->component_code_name + . "/uikit-v3/css/uikit'.\$size.'.css', ['version' => 'auto']);"; + $setter .= PHP_EOL . $tabV . Indent::_(2) . "}"; + $setter .= PHP_EOL . $tabV . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " The uikit js."; + $setter .= PHP_EOL . $tabV . Indent::_(2) + . "if ((!\$HeaderCheck->js_loaded('uikit.min') || \$uikit == 1) && \$uikit != 2 && \$uikit != 3)"; + $setter .= PHP_EOL . $tabV . Indent::_(2) . "{"; + $setter .= PHP_EOL . $tabV . Indent::_(3) + . "Html::_('script', 'media/com_" + . CFactory::_('Config')->component_code_name + . "/uikit-v3/js/uikit'.\$size.'.js', ['version' => 'auto']);"; + $setter .= PHP_EOL . $tabV . Indent::_(3) + . "Html::_('script', 'media/com_" + . CFactory::_('Config')->component_code_name + . "/uikit-v3/js/uikit-icons'.\$size.'.js', ['version' => 'auto']);"; + $setter .= PHP_EOL . $tabV . Indent::_(2) . "}"; + if (2 == CFactory::_('Config')->uikit) + { + $setter .= PHP_EOL . Indent::_(2) . "}"; + } + } + + return $setter; + } + + public function setCustomViewExtraDisplayMethods(&$view) + { + if ($view['settings']->add_php_jview == 1) + { + return PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( + $view['settings']->php_jview + ); + } + + return ''; + } + + public function setCustomViewBody(&$view) + { + if (StringHelper::check($view['settings']->default)) + { + if ($view['settings']->main_get->gettype == 2 + && $view['settings']->main_get->pagination == 1) + { + // does this view have a custom limitbox position + $has_limitbox = (strpos( + (string) $view['settings']->default, + (string) Placefix::_('LIMITBOX') + ) !== false); + // does this view have a custom pages counter position + $has_pagescounter = (strpos( + (string) $view['settings']->default, + (string) Placefix::_('PAGESCOUNTER') + ) !== false); + // does this view have a custom pages links position + $has_pageslinks = (strpos( + (string) $view['settings']->default, + (string) Placefix::_('PAGESLINKS') + ) !== false); + // does this view have a custom pagination start position + $has_pagination_start = (strpos( + (string) $view['settings']->default, + (string) Placefix::_('PAGINATIONSTART') + ) !== false); + // does this view have a custom pagination end position + $has_pagination_end = (strpos( + (string) $view['settings']->default, + (string) Placefix::_('PAGINATIONEND') + ) !== false); + + // add pagination start + CFactory::_('Placeholder')->add_('PAGINATIONSTART', PHP_EOL + . 'items) && isset($this->pagination) && isset($this->pagination->pagesTotal) && $this->pagination->pagesTotal > 1): ?>'); + CFactory::_('Placeholder')->add_('PAGINATIONSTART', + PHP_EOL . Indent::_(1) . ''); + CFactory::_('Placeholder')->add_('PAGINATIONEND', + PHP_EOL . ''); + + // add limit box + CFactory::_('Placeholder')->set_('LIMITBOX', + 'pagination->getLimitBox(); ?>'); + + // add pages counter + CFactory::_('Placeholder')->set_('PAGESCOUNTER', + 'pagination->getPagesCounter(); ?>'); + + // add pages links + if (CFactory::_('Config')->build_target === 'custom_admin') + { + CFactory::_('Placeholder')->set_('PAGESLINKS', + 'pagination->getListFooter(); ?>'); + } + else + { + CFactory::_('Placeholder')->set_('PAGESLINKS', + 'pagination->getPagesLinks(); ?>'); + } + + // build body + $body = []; + // Load the default values to the body + $body[] = CFactory::_('Placeholder')->update_( + $view['settings']->default + ); + + // add pagination start + if (!$has_pagination_start) + { + $body[] = CFactory::_('Placeholder')->get_('PAGINATIONSTART'); + } + + if (!$has_limitbox && !$has_pagescounter) + { + $body[] = Indent::_(3) + . '

    pagination->getPagesCounter(); ?> pagination->getLimitBox(); ?>

    '; + } + elseif (!$has_limitbox) + { + $body[] = Indent::_(3) + . '

    pagination->getLimitBox(); ?>

    '; + } + elseif (!$has_pagescounter) + { + $body[] = Indent::_(3) + . '

    pagination->getPagesCounter(); ?>

    '; + } + // add pagination end + if (!$has_pagination_end) + { + $body[] = CFactory::_('Placeholder')->get_('PAGINATIONEND'); + } + + // lets clear the placeholders just in case + CFactory::_('Placeholder')->remove_('LIMITBOX'); + CFactory::_('Placeholder')->remove_('PAGESCOUNTER'); + CFactory::_('Placeholder')->remove_('PAGESLINKS'); + CFactory::_('Placeholder')->remove_('PAGINATIONSTART'); + CFactory::_('Placeholder')->remove_('PAGINATIONEND'); + + // insure the form is added (only if no form exist) + if (strpos((string) $view['settings']->default, 'addCustomForm[CFactory::_('Config')->build_target][$view['settings']->code] + = true; + } + + // return the body + return implode(PHP_EOL, $body); + } + else + { + // insure the form is added (only if no form exist) + if ('site' !== CFactory::_('Config')->build_target + && strpos( + (string) $view['settings']->default, 'addCustomForm[CFactory::_('Config')->build_target][$view['settings']->code] + = true; + } + + return PHP_EOL . CFactory::_('Placeholder')->update_( + $view['settings']->default + ); + } + } + + return ''; + } + + public function setCustomViewForm(&$view, &$gettype, $type) + { + if (isset($this->addCustomForm[CFactory::_('Config')->build_target]) + && isset($this->addCustomForm[CFactory::_('Config')->build_target][$view]) + && $this->addCustomForm[CFactory::_('Config')->build_target][$view]) + { + switch ($type) + { + case 1: + // top + if ('site' === CFactory::_('Config')->build_target) + { + return '
    ' + . PHP_EOL; + } + else + { + if ($gettype == 2) + { + return '' + . PHP_EOL; + } + else + { + return '' + . PHP_EOL; + } + } + break; + case 2: + // bottom + $input = ''; + if ('admin' === CFactory::_('Config')->build_target + && isset($this->customAdminViewListId[$view])) + { + $input = PHP_EOL . Indent::_(1) + . ''; + } + + return $input . PHP_EOL + . '' + . PHP_EOL . "" + . PHP_EOL . '
    '; + break; + } + } + + return ''; + } + + public function setCustomViewSubmitButtonScript(&$view) + { + if (StringHelper::check($view['settings']->default)) + { + // add the script only if there is none set + if (strpos( + (string) $view['settings']->default, + 'Joomla.submitbutton = function(' + ) === false) + { + $script = []; + $script[] = PHP_EOL . ""; + + return implode(PHP_EOL, $script); + } + } + + return ''; + } + + public function setCustomViewCodeBody(&$view) + { + if ($view['settings']->add_php_view == 1) + { + $view['settings']->php_view = (array) explode( + PHP_EOL, (string) $view['settings']->php_view + ); + if (ArrayHelper::check($view['settings']->php_view)) + { + $_tmp = PHP_EOL . PHP_EOL . implode( + PHP_EOL, $view['settings']->php_view + ); + + return CFactory::_('Placeholder')->update_($_tmp); + } + } + + return ''; + } + + public function setCustomViewTemplateBody(&$view) + { + if (($data_ = CFactory::_('Compiler.Builder.Template.Data')-> + get(CFactory::_('Config')->build_target . '.' . $view['settings']->code)) !== null) + { + $created = CFactory::_('Model.Createdate')->get($view); + $modified = CFactory::_('Model.Modifieddate')->get($view); + foreach ($data_ as $template => $data) + { + // build the file + $target = [ + CFactory::_('Config')->build_target => $view['settings']->code + ]; + $config = [ + Placefix::_h('CREATIONDATE') => $created, + Placefix::_h('BUILDDATE') => $modified, + Placefix::_h('VERSION') => $view['settings']->version + ]; + CFactory::_('Utilities.Structure')->build($target, 'template', $template, $config); + // set the file data + $TARGET = StringHelper::safe( + CFactory::_('Config')->build_target, 'U' + ); + if (!isset($data['html']) || $data['html'] === null) + { + echo '
    ';
    +					var_dump($data);
    +					exit;
    +				}
    +				// SITE_TEMPLATE_BODY <<>>
    +				CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '_'
    +					. $template . '|' . $TARGET . '_TEMPLATE_BODY', PHP_EOL . CFactory::_('Placeholder')->update_(
    +						$data['html']
    +					));
    +				if (!isset($data['php_view']) || $data['php_view'] === null)
    +				{
    +					echo '
    ';
    +					var_dump($data);
    +					exit;
    +				}
    +				// SITE_TEMPLATE_CODE_BODY <<>>
    +				CFactory::_('Compiler.Builder.Content.Multi')->set($view['settings']->code . '_'
    +					. $template . '|' . $TARGET . '_TEMPLATE_CODE_BODY',
    +					$this->setTemplateCode($data['php_view'])
    +				);
    +			}
    +		}
    +	}
    +
    +	public function setTemplateCode(&$php)
    +	{
    +		if (StringHelper::check($php))
    +		{
    +			$php_view = (array) explode(PHP_EOL, (string) $php);
    +			if (ArrayHelper::check($php_view))
    +			{
    +				$php_view = PHP_EOL . PHP_EOL . implode(PHP_EOL, $php_view);
    +
    +				return CFactory::_('Placeholder')->update_($php_view);
    +			}
    +		}
    +
    +		return '';
    +	}
    +
    +	public function setCustomViewLayouts()
    +	{
    +		if (($data_ = CFactory::_('Compiler.Builder.Layout.Data')->
    +			get(CFactory::_('Config')->build_target)) !== null)
    +		{
    +			foreach ($data_ as $layout => $data)
    +			{
    +				// build the file
    +				$target = array(CFactory::_('Config')->build_target => $layout);
    +				CFactory::_('Utilities.Structure')->build($target, 'layout');
    +				// set the file data
    +				$TARGET = StringHelper::safe(
    +					CFactory::_('Config')->build_target, 'U'
    +				);
    +				// SITE_LAYOUT_CODE <<>>
    +				$php_view = (array) explode(PHP_EOL, (string) $data['php_view']);
    +				if (ArrayHelper::check($php_view))
    +				{
    +					$php_view = PHP_EOL . PHP_EOL . implode(PHP_EOL, $php_view);
    +					CFactory::_('Compiler.Builder.Content.Multi')->set($layout . '|' . $TARGET . '_LAYOUT_CODE',
    +						CFactory::_('Placeholder')->update_(
    +							$php_view
    +						)
    +					);
    +				}
    +				else
    +				{
    +					CFactory::_('Compiler.Builder.Content.Multi')->set($layout . '|' . $TARGET
    +						. '_LAYOUT_CODE',  '');
    +				}
    +				// SITE_LAYOUT_BODY <<>>
    +				CFactory::_('Compiler.Builder.Content.Multi')->set($layout . '|' . $TARGET . '_LAYOUT_BODY',
    +					PHP_EOL . CFactory::_('Placeholder')->update_(
    +						$data['html']
    +					)
    +				);
    +				// SITE_LAYOUT_HEADER <<>>
    +				CFactory::_('Compiler.Builder.Content.Multi')->set($layout . '|' . $TARGET . '_LAYOUT_HEADER',
    +					(($header = CFactory::_('Header')->get(
    +							str_replace('_', '.', (string) CFactory::_('Config')->build_target) . '.layout',
    +							$layout, false)) !== false) ? PHP_EOL . PHP_EOL . $header : ''
    +				);
    +			}
    +		}
    +	}
    +
    +	public function getReplacementNames()
    +	{
    +		foreach (CFactory::_('Utilities.Files')->toArray() as $type => $files)
    +		{
    +			foreach ($files as $view => $file)
    +			{
    +				if (isset($file['path'])
    +					&& ArrayHelper::check(
    +						$file
    +					))
    +				{
    +					if (File::exists($file['path']))
    +					{
    +						$string            = FileHelper::getContent(
    +							$file['path']
    +						);
    +						$buket['static'][] = $this->getInbetweenStrings(
    +							$string
    +						);
    +					}
    +				}
    +				elseif (ArrayHelper::check($file))
    +				{
    +					foreach ($file as $nr => $doc)
    +					{
    +						if (ArrayHelper::check($doc))
    +						{
    +							if (File::exists($doc['path']))
    +							{
    +								$string
    +									= FileHelper::getContent(
    +									$doc['path']
    +								);
    +								$buket[$view][] = $this->getInbetweenStrings(
    +									$string
    +								);
    +							}
    +						}
    +					}
    +				}
    +			}
    +		}
    +		foreach ($buket as $type => $array)
    +		{
    +			foreach ($array as $replacments)
    +			{
    +				$replacments = array_unique($replacments);
    +				foreach ($replacments as $replacment)
    +				{
    +					if ($type !== 'static')
    +					{
    +						$echos[$replacment] = "#" . "#" . "#" . $replacment
    +							. "#" . "#" . "#
    "; + } + elseif ($type === 'static') + { + $echos[$replacment] = "#" . "#" . "#" . $replacment + . "#" . "#" . "#
    "; + } + } + } + } + + foreach ($echos as $echo) + { + echo $echo . '
    '; + } + } + + public function setMethodGetItem(&$view) + { + $script = ''; + // get the component name + $Component = CFactory::_('Compiler.Builder.Content.One')->get('Component'); + $component = CFactory::_('Compiler.Builder.Content.One')->get('component'); + // go from base64 to string + if (CFactory::_('Compiler.Builder.Base.Six.Four')->exists($view)) + { + foreach (CFactory::_('Compiler.Builder.Base.Six.Four')->get($view) as $baseString) + { + $script .= PHP_EOL . PHP_EOL . Indent::_(3) + . "if (!empty(\$item->" . $baseString + . "))"; // TODO && base64_encode(base64_decode(\$item->".$baseString.", true)) === \$item->".$baseString.")"; + $script .= PHP_EOL . Indent::_(3) . "{"; + $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " base64 Decode " . $baseString . "."; + $script .= PHP_EOL . Indent::_(4) . "\$item->" . $baseString + . " = base64_decode(\$item->" . $baseString . ");"; + $script .= PHP_EOL . Indent::_(3) . "}"; + } + } + // decryption + foreach (CFactory::_('Config')->cryption_types as $cryptionType) + { + if (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field')->exists($view)) + { + if ('expert' !== $cryptionType) + { + $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) . " Get the " . $cryptionType + . " encryption."; + $script .= PHP_EOL . Indent::_(3) . "\$" . $cryptionType + . "key = " . $Component . "Helper::getCryptKey('" + . $cryptionType . "');"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Get the encryption object."; + $script .= PHP_EOL . Indent::_(3) . "\$" . $cryptionType + . " = new Super_" . "__99175f6d_dba8_4086_8a65_5c4ec175e61d___Power(\$" . $cryptionType . "key);"; + foreach (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field')->get($view) as $baseString) + { + $script .= PHP_EOL . PHP_EOL . Indent::_(3) + . "if (!empty(\$item->" . $baseString . ") && \$" + . $cryptionType . "key && !is_numeric(\$item->" + . $baseString . ") && \$item->" . $baseString + . " === base64_encode(base64_decode(\$item->" + . $baseString . ", true)))"; + $script .= PHP_EOL . Indent::_(3) . "{"; + $script .= PHP_EOL . Indent::_(4) . "//" + . Line::_(__Line__, __Class__) . " " . $cryptionType + . " decrypt data " . $baseString . "."; + $script .= PHP_EOL . Indent::_(4) . "\$item->" + . $baseString . " = rtrim(\$" . $cryptionType + . "->decryptString(\$item->" . $baseString . "), " + . '"\0"' . ");"; + $script .= PHP_EOL . Indent::_(3) . "}"; + } + } + else + { + if (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> + exists("{$view}.get")) + { + foreach (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> + get("{$view}.get") as $block + ) + { + $script .= PHP_EOL . Indent::_(3) . implode( + PHP_EOL . Indent::_(3), $block + ); + } + } + // set the expert script + foreach (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field')-> + get($view) as $baseString => $opener_) + { + $_placeholder_for_field = array('[[[field]]]' => '$item->' . $baseString); + $script .= CFactory::_('Placeholder')->update( + PHP_EOL . Indent::_(3) . implode( + PHP_EOL . Indent::_(3), $opener_['get'] + ), $_placeholder_for_field + ); + } + } + } + } + // go from json to array + if (CFactory::_('Compiler.Builder.Json.Item')->exists($view)) + { + foreach (CFactory::_('Compiler.Builder.Json.Item')->get($view) as $jsonItem) + { + $script .= PHP_EOL . PHP_EOL . Indent::_(3) + . "if (!empty(\$item->" . $jsonItem . "))"; + $script .= PHP_EOL . Indent::_(3) . "{"; + $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Convert the " . $jsonItem . " field to an array."; + $script .= PHP_EOL . Indent::_(4) . "\$" . $jsonItem + . " = new Registry;"; + $script .= PHP_EOL . Indent::_(4) . "\$" . $jsonItem + . "->loadString(\$item->" . $jsonItem . ");"; + $script .= PHP_EOL . Indent::_(4) . "\$item->" . $jsonItem + . " = \$" . $jsonItem . "->toArray();"; + $script .= PHP_EOL . Indent::_(3) . "}"; + } + } + // go from json to string + if (CFactory::_('Compiler.Builder.Json.String')->exists($view)) + { + $makeArray = ''; + foreach (CFactory::_('Compiler.Builder.Json.String')->get($view) as $jsonString) + { + $script .= PHP_EOL . PHP_EOL . Indent::_(3) + . "if (!empty(\$item->" . $jsonString . "))"; + $script .= PHP_EOL . Indent::_(3) . "{"; + $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " JSON Decode " . $jsonString . "."; + if (CFactory::_('Compiler.Builder.Json.Item.Array')->inArray($jsonString, $view) || + strpos((string) $jsonString, 'group') !== false) + { + $makeArray = ',true'; + } + $script .= PHP_EOL . Indent::_(4) . "\$item->" . $jsonString + . " = json_decode(\$item->" . $jsonString . $makeArray + . ");"; + $script .= PHP_EOL . Indent::_(3) . "}"; + } + } + // add the tag get options + if (CFactory::_('Compiler.Builder.Tags')->exists($view)) + { + $script .= PHP_EOL . PHP_EOL . Indent::_(3) + . "if (!empty(\$item->id))"; + $script .= PHP_EOL . Indent::_(3) . "{"; + $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Get Tag IDs."; + $script .= PHP_EOL . Indent::_(4) . "\$item->tags" + . " = new TagsHelper;"; + $script .= PHP_EOL . Indent::_(4) + . "\$item->tags->getTagIds(\$item->id, 'com_$component.$view');"; + $script .= PHP_EOL . Indent::_(3) . "}"; + } + // add custom php to getitem method + $script .= CFactory::_('Customcode.Dispenser')->get( + 'php_getitem', $view, PHP_EOL . PHP_EOL + ); + + return $script; + } + + public function setCheckboxSave(&$view) + { + $script = ''; + if (CFactory::_('Compiler.Builder.Check.Box')->exists($view)) + { + foreach (CFactory::_('Compiler.Builder.Check.Box')->get($view) as $checkbox) + { + $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Set the empty " . $checkbox + . " item to data"; + $script .= PHP_EOL . Indent::_(2) . "if (!isset(\$data['" + . $checkbox . "']))"; + $script .= PHP_EOL . Indent::_(2) . "{"; + $script .= PHP_EOL . Indent::_(3) . "\$data['" . $checkbox + . "'] = '';"; + $script .= PHP_EOL . Indent::_(2) . "}"; + } + } + + return $script; + } + + public function setMethodItemSave(&$view) + { + $script = ''; + // get component name + $Component = CFactory::_('Compiler.Builder.Content.One')->get('Component'); + $component = CFactory::_('Config')->component_code_name; + // check if there was script added before modeling of data + $script .= CFactory::_('Customcode.Dispenser')->get( + 'php_before_save', $view, PHP_EOL . PHP_EOL + ); + // turn array into JSON string + if (CFactory::_('Compiler.Builder.Json.Item')->exists($view)) + { + foreach (CFactory::_('Compiler.Builder.Json.Item')->get($view) as $jsonItem) + { + $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Set the " . $jsonItem + . " items to data."; + $script .= PHP_EOL . Indent::_(2) . "if (isset(\$data['" + . $jsonItem . "']) && is_array(\$data['" . $jsonItem + . "']))"; + $script .= PHP_EOL . Indent::_(2) . "{"; + $script .= PHP_EOL . Indent::_(3) . "\$" . $jsonItem + . " = new Registry;"; + $script .= PHP_EOL . Indent::_(3) . "\$" . $jsonItem + . "->loadArray(\$data['" . $jsonItem . "']);"; + $script .= PHP_EOL . Indent::_(3) . "\$data['" . $jsonItem + . "'] = (string) \$" . $jsonItem . ";"; + $script .= PHP_EOL . Indent::_(2) . "}"; + if (CFactory::_('Compiler.Builder.Permission.Fields')->isArray("$view.$jsonItem")) + { + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) + . " Also check permission since the value may be removed due to permissions"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) + . " Then we do not want to clear it out, but simple ignore the empty " + . $jsonItem; + $script .= PHP_EOL . Indent::_(2) + . "elseif (!isset(\$data['" . $jsonItem . "'])"; + // only add permission that are available + foreach (CFactory::_('Compiler.Builder.Permission.Fields')->get("$view.$jsonItem") + as $permission_option => $fieldType + ) + { + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $script .= PHP_EOL . Indent::_(3) + . "&& Factory::getUser()->authorise('" . $view + . "." . $permission_option . "." . $jsonItem + . "', 'com_" . $component . "')"; + } + else + { + $script .= PHP_EOL . Indent::_(3) + . "&& Factory::getApplication()->getIdentity()->authorise('" . $view + . "." . $permission_option . "." . $jsonItem + . "', 'com_" . $component . "')"; + } + } + $script .= ")"; + } + else + { + $script .= PHP_EOL . Indent::_(2) + . "elseif (!isset(\$data['" . $jsonItem . "']))"; + } + $script .= PHP_EOL . Indent::_(2) . "{"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Set the empty " . $jsonItem . " to data"; + $script .= PHP_EOL . Indent::_(3) . "\$data['" . $jsonItem + . "'] = '';"; + $script .= PHP_EOL . Indent::_(2) . "}"; + } + } + // turn string into json string + if (CFactory::_('Compiler.Builder.Json.String')->exists($view)) + { + foreach (CFactory::_('Compiler.Builder.Json.String')->get($view) as $jsonString) + { + $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Set the " . $jsonString + . " string to JSON string."; + $script .= PHP_EOL . Indent::_(2) . "if (isset(\$data['" + . $jsonString . "']))"; + $script .= PHP_EOL . Indent::_(2) . "{"; + $script .= PHP_EOL . Indent::_(3) . "\$data['" . $jsonString + . "'] = (string) json_encode(\$data['" . $jsonString + . "']);"; + $script .= PHP_EOL . Indent::_(2) . "}"; + } + } + // turn string into base 64 string + if (CFactory::_('Compiler.Builder.Base.Six.Four')->exists($view)) + { + foreach (CFactory::_('Compiler.Builder.Base.Six.Four')->get($view) as $baseString) + { + $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Set the " . $baseString + . " string to base64 string."; + $script .= PHP_EOL . Indent::_(2) . "if (isset(\$data['" + . $baseString . "']))"; + $script .= PHP_EOL . Indent::_(2) . "{"; + $script .= PHP_EOL . Indent::_(3) . "\$data['" . $baseString + . "'] = base64_encode(\$data['" . $baseString . "']);"; + $script .= PHP_EOL . Indent::_(2) . "}"; + } + } + // turn string into encrypted string + foreach (CFactory::_('Config')->cryption_types as $cryptionType) + { + if (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field')-> + exists($view)) + { + if ('expert' !== $cryptionType) + { + $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Get the " . $cryptionType + . " encryption key."; + $script .= PHP_EOL . Indent::_(2) . "\$" . $cryptionType + . "key = " . $Component . "Helper::getCryptKey('" + . $cryptionType . "');"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Get the encryption object"; + $script .= PHP_EOL . Indent::_(2) . "\$" . $cryptionType + . " = new Super_" . "__99175f6d_dba8_4086_8a65_5c4ec175e61d___Power(\$" . $cryptionType . "key);"; + foreach (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field')-> + get($view) as $baseString) + { + $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Encrypt data " + . $baseString . "."; + $script .= PHP_EOL . Indent::_(2) . "if (isset(\$data['" + . $baseString . "']) && \$" . $cryptionType + . "key)"; + $script .= PHP_EOL . Indent::_(2) . "{"; + $script .= PHP_EOL . Indent::_(3) . "\$data['" + . $baseString . "'] = \$" . $cryptionType + . "->encryptString(\$data['" . $baseString . "']);"; + $script .= PHP_EOL . Indent::_(2) . "}"; + } + } + else + { + if (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> + exists("{$view}.save")) + { + foreach (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> + get("{$view}.save") as $block) + { + $script .= PHP_EOL . Indent::_(2) . implode( + PHP_EOL . Indent::_(2), $block + ); + } + } + // set the expert script + foreach (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field')-> + get($view) as $baseString => $locker_) + { + $_placeholder_for_field + = array('[[[field]]]' => "\$data['" + . $baseString . "']"); + $script .= CFactory::_('Placeholder')->update( + PHP_EOL . Indent::_(2) . implode( + PHP_EOL . Indent::_(2), $locker_['save'] + ), $_placeholder_for_field + ); + } + } + } + } + // add custom PHP to the save method + $script .= CFactory::_('Customcode.Dispenser')->get( + 'php_save', $view, PHP_EOL . PHP_EOL + ); + + return $script; + } + + public function setJtableConstructor(&$view) + { + // reset + $oserver = ""; + // set component name + $component = CFactory::_('Config')->component_code_name; + // add the tags observer + if (CFactory::_('Compiler.Builder.Tags')->exists($view)) + { + $oserver .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Adding Tag Options"; + $oserver .= PHP_EOL . Indent::_(2) + . "TableObserverTags::createObserver(\$this, array('typeAlias' => 'com_" + . $component . "." . $view . "'));"; + } + // add the history/version observer + if (CFactory::_('Compiler.Builder.History')->exists($view)) + { + $oserver .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Adding History Options"; + $oserver .= PHP_EOL . Indent::_(2) + . "TableObserverContenthistory::createObserver(\$this, array('typeAlias' => 'com_" + . $component . "." . $view . "'));"; + } + + return $oserver; + } + + public function setJtableAliasCategory(&$view) + { + // only add Observers if both title, alias and category is available in view + $code = CFactory::_('Compiler.Builder.Category.Code')->get("{$view}.code"); + if ($code !== null) + { + return ", '" . $code . "' => \$this->" . $code; + } + + return ''; + } + + public function setComponentToContentTypes($action) + { + if (CFactory::_('Component')->isArray('admin_views')) + { + // set component name + $component = CFactory::_('Config')->component_code_name; + // reset + $dbStuff = []; + // start loading the content type data + foreach (CFactory::_('Component')->get('admin_views') as $viewData) + { + // set main keys + $view = StringHelper::safe( + $viewData['settings']->name_single + ); + // set list view keys + $views = StringHelper::safe( + $viewData['settings']->name_list + ); + // get this views content type data + $dbStuff[$view] = $this->getContentType($view, $component); + // get the correct views name + $checkViews = CFactory::_('Compiler.Builder.Category.Code')->getString("{$view}.views", $views); + if (ArrayHelper::check($dbStuff[$view]) + && CFactory::_('Compiler.Builder.Category.Code')->exists($view) + && ($checkViews == $views)) + { + $dbStuff[$view . ' category'] + = $this->getCategoryContentType( + $view, $views, $component + ); + } + elseif (!isset($dbStuff[$view]) + || !ArrayHelper::check($dbStuff[$view])) + { + // remove if not array + unset($dbStuff[$view]); + } + } + + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + return $this->setComponentToContentTypesJ3($action, $dbStuff); + } + + return $this->setComponentToContentTypesJ4($action, $dbStuff); + } + + return ''; + } + + protected function setComponentToContentTypesJ3($action, $dbStuff) + { + // build the db insert query + if (ArrayHelper::check($dbStuff)) + { + $script = ''; + $taabb = ''; + if ($action === 'update') + { + $taabb = Indent::_(1); + } + $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) . " Get The Database object"; + $script .= PHP_EOL . Indent::_(3) + . "\$db = Factory::getDbo();"; + foreach ($dbStuff as $name => $tables) + { + if (ArrayHelper::check($tables)) + { + $code = StringHelper::safe($name); + $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) . " Create the " . $name + . " content type object."; + $script .= PHP_EOL . Indent::_(3) . "\$" . $code + . " = new \stdClass();"; + foreach ($tables as $table => $data) + { + $script .= PHP_EOL . Indent::_(3) . "\$" . $code + . "->" . $table . " = '" . $data . "';"; + } + if ($action === 'update') + { + // we first load script to check if data exist + $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) . " Check if " + . $name + . " type is already in content_type DB."; + $script .= PHP_EOL . Indent::_(3) . "\$" . $code + . "_id = null;"; + $script .= PHP_EOL . Indent::_(3) + . "\$query = \$db->getQuery(true);"; + $script .= PHP_EOL . Indent::_(3) + . "\$query->select(\$db->quoteName(array('type_id')));"; + $script .= PHP_EOL . Indent::_(3) + . "\$query->from(\$db->quoteName('#__content_types'));"; + $script .= PHP_EOL . Indent::_(3) + . "\$query->where(\$db->quoteName('type_alias') . ' LIKE '. \$db->quote($" + . $code . "->type_alias));"; + $script .= PHP_EOL . Indent::_(3) + . "\$db->setQuery(\$query);"; + $script .= PHP_EOL . Indent::_(3) + . "\$db->execute();"; + } + $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) + . " Set the object into the content types table."; + if ($action === 'update') + { + $script .= PHP_EOL . Indent::_(3) + . "if (\$db->getNumRows())"; + $script .= PHP_EOL . Indent::_(3) . "{"; + $script .= PHP_EOL . Indent::_(4) . "\$" . $code + . "->type_id = \$db->loadResult();"; + $script .= PHP_EOL . Indent::_(4) . "\$" . $code + . "_Updated = \$db->updateObject('#__content_types', \$" + . $code . ", 'type_id');"; + $script .= PHP_EOL . Indent::_(3) . "}"; + $script .= PHP_EOL . Indent::_(3) . "else"; + $script .= PHP_EOL . Indent::_(3) . "{"; + } + $script .= PHP_EOL . Indent::_(3) . $taabb . "\$" + . $code + . "_Inserted = \$db->insertObject('#__content_types', \$" + . $code . ");"; + if ($action === 'update') + { + $script .= PHP_EOL . Indent::_(3) . "}"; + } + } + } + + $script .= PHP_EOL . PHP_EOL; + return $script; + } + + return ''; + } + + protected function setComponentToContentTypesJ4($action, $dbStuff) + { + // build the db insert query + if (ArrayHelper::check($dbStuff)) + { + $script = PHP_EOL; + foreach ($dbStuff as $name => $columns) + { + if (ArrayHelper::check($columns)) + { + $script .= PHP_EOL . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) . " " + . StringHelper::safe($action, 'Ww') . " " + . StringHelper::safe($name, 'Ww') . " Content Types."; + + $script .= PHP_EOL . Indent::_(3) . + '$this->setContentType('; + $script .= PHP_EOL . Indent::_(4) . + "//" . Line::_(__Line__, __Class__) . " typeTitle"; + $script .= PHP_EOL . Indent::_(4) . + "'{$columns['type_title']}',"; + $script .= PHP_EOL . Indent::_(4) . + "//" . Line::_(__Line__, __Class__) . " typeAlias"; + $script .= PHP_EOL . Indent::_(4) . + "'{$columns['type_alias']}',"; + $script .= PHP_EOL . Indent::_(4) . + "//" . Line::_(__Line__, __Class__) . " table"; + $script .= PHP_EOL . Indent::_(4) . + "'{$columns['table']}',"; + $script .= PHP_EOL . Indent::_(4) . + "//" . Line::_(__Line__, __Class__) . " rules"; + $script .= PHP_EOL . Indent::_(4) . + "'{$columns['rules']}',"; + $script .= PHP_EOL . Indent::_(4) . + "//" . Line::_(__Line__, __Class__) . " fieldMappings"; + $script .= PHP_EOL . Indent::_(4) . + "'{$columns['field_mappings']}',"; + $script .= PHP_EOL . Indent::_(4) . + "//" . Line::_(__Line__, __Class__) . " router"; + $script .= PHP_EOL . Indent::_(4) . + "'{$columns['router']}',"; + $script .= PHP_EOL . Indent::_(4) . + "//" . Line::_(__Line__, __Class__) . " contentHistoryOptions"; + $script .= PHP_EOL . Indent::_(4) . + "'{$columns['content_history_options']}'"; + $script .= PHP_EOL . Indent::_(3) . + ');'; + + } + } + $script .= PHP_EOL . PHP_EOL; + return $script; + } + + return ''; + } + + public function setPostInstallScript() + { + // reset script + $script = $this->setComponentToContentTypes('install'); + + // add the Intelligent Fix script if needed + $script .= $this->getAssetsTableIntelligentInstall(); + + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $script .= $this->setPostInstallScriptJ3(); + } + else + { + $script .= $this->setPostInstallScriptJ4(); + } + + // add the custom script + $script .= CFactory::_('Customcode.Dispenser')->get( + 'php_postflight', 'install', PHP_EOL . PHP_EOL, null, true + ); + + // add the component installation notice + if (StringHelper::check($script)) + { + $script .= PHP_EOL . PHP_EOL . Indent::_(3) + . 'echo \'\';'; + + return $script; + } + + return PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " noting to install."; + } + + public function setPostInstallScriptJ3() + { + // reset script + $script = ''; + + // set the component name + $component = CFactory::_('Config')->component_code_name; + + // add the assets table update for permissions rules + if (CFactory::_('Compiler.Builder.Assets.Rules')->isArray('site')) + { + if (StringHelper::check($script)) + { + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Install the global extenstion assets permission."; + } + else + { + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Install the global extension assets permission."; + $script .= PHP_EOL . Indent::_(3) + . "\$db = Factory::getDbo();"; + } + $script .= PHP_EOL . Indent::_(3) + . "\$query = \$db->getQuery(true);"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Field to update."; + $script .= PHP_EOL . Indent::_(3) . "\$fields = array("; + $script .= PHP_EOL . Indent::_(4) + . "\$db->quoteName('rules') . ' = ' . \$db->quote('{" . implode( + ',', CFactory::_('Compiler.Builder.Assets.Rules')->get('site') + ) . "}'),"; + $script .= PHP_EOL . Indent::_(3) . ");"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Condition."; + $script .= PHP_EOL . Indent::_(3) . "\$conditions = array("; + $script .= PHP_EOL . Indent::_(4) + . "\$db->quoteName('name') . ' = ' . \$db->quote('com_" + . $component . "')"; + $script .= PHP_EOL . Indent::_(3) . ");"; + $script .= PHP_EOL . Indent::_(3) + . "\$query->update(\$db->quoteName('#__assets'))->set(\$fields)->where(\$conditions);"; + $script .= PHP_EOL . Indent::_(3) . "\$db->setQuery(\$query);"; + $script .= PHP_EOL . Indent::_(3) . "\$allDone = \$db->execute();" + . PHP_EOL; + } + + // add the global params for the component global settings + if (CFactory::_('Compiler.Builder.Extensions.Params')->isArray('component')) + { + if (StringHelper::check($script)) + { + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Install the global extension params."; + } + else + { + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Install the global extension params."; + $script .= PHP_EOL . Indent::_(3) + . "\$db = Factory::getDbo();"; + } + $script .= PHP_EOL . Indent::_(3) + . "\$query = \$db->getQuery(true);"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Field to update."; + $script .= PHP_EOL . Indent::_(3) . "\$fields = array("; + $script .= PHP_EOL . Indent::_(4) + . "\$db->quoteName('params') . ' = ' . \$db->quote('{" + . implode(',', CFactory::_('Compiler.Builder.Extensions.Params')->get('component')) . "}'),"; + $script .= PHP_EOL . Indent::_(3) . ");"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Condition."; + $script .= PHP_EOL . Indent::_(3) . "\$conditions = array("; + $script .= PHP_EOL . Indent::_(4) + . "\$db->quoteName('element') . ' = ' . \$db->quote('com_" + . $component . "')"; + $script .= PHP_EOL . Indent::_(3) . ");"; + $script .= PHP_EOL . Indent::_(3) + . "\$query->update(\$db->quoteName('#__extensions'))->set(\$fields)->where(\$conditions);"; + $script .= PHP_EOL . Indent::_(3) . "\$db->setQuery(\$query);"; + $script .= PHP_EOL . Indent::_(3) . "\$allDone = \$db->execute();" + . PHP_EOL; + } + + return $script; + } + + public function setPostInstallScriptJ4() + { + // reset script + $script = ''; + + // add the assets table update for permissions rules + if (CFactory::_('Compiler.Builder.Assets.Rules')->isArray('site')) + { + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Install the global extension assets permission."; + $script .= PHP_EOL . Indent::_(3) . "\$this->setAssetsRules("; + $script .= PHP_EOL . Indent::_(4) . "'{" . implode( + ',', CFactory::_('Compiler.Builder.Assets.Rules')->get('site') + ) . "}'"; + $script .= PHP_EOL . Indent::_(3) . ");" . PHP_EOL; + } + + // add the global params for the component global settings + if (CFactory::_('Compiler.Builder.Extensions.Params')->isArray('component')) + { + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Install the global extension params."; + $script .= PHP_EOL . Indent::_(3) . "\$this->setExtensionsParams("; + $script .= PHP_EOL . Indent::_(4) . "'{" + . implode(',', CFactory::_('Compiler.Builder.Extensions.Params')->get('component') + ) . "}'"; + $script .= PHP_EOL . Indent::_(3) . ");" . PHP_EOL; + } + + return $script; + } + + public function setPostUpdateScript() + { + // reset script + $script = $this->setComponentToContentTypes('update'); + // add the custom script + $script .= CFactory::_('Customcode.Dispenser')->get( + 'php_postflight', 'update', PHP_EOL . PHP_EOL, null, true + ); + if (CFactory::_('Component')->isArray('admin_views')) + { + $script .= PHP_EOL . PHP_EOL . Indent::_(3) + . 'echo \'
    '; + $script .= PHP_EOL . Indent::_(4) . ''; + $script .= PHP_EOL . Indent::_(4) . ''; + $script .= PHP_EOL . Indent::_(4) . "

    Upgrade to Version " + . CFactory::_('Compiler.Builder.Content.One')->get('ACTUALVERSION') + . " Was Successful! Let us know if anything is not working as expected.

    ';"; + } + + if (StringHelper::check($script)) + { + return $script; + } + + return PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " noting to update."; + } + + public function setUninstallScript() + { + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + return $this->setUninstallScriptJ3(); + } + + return $this->setUninstallScriptJ4(); + } + + public function setUninstallScriptJ3() + { + // reset script + $script = ''; + if (isset($this->uninstallScriptBuilder) + && ArrayHelper::check( + $this->uninstallScriptBuilder + )) + { + $component = CFactory::_('Config')->component_code_name; + // start loading the data to delete + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Get Application object"; + $script .= PHP_EOL . Indent::_(2) + . "\$app = Factory::getApplication();"; + $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Get The Database object"; + $script .= PHP_EOL . Indent::_(2) . "\$db = Factory::getDbo();"; + + foreach ( + $this->uninstallScriptBuilder as $viewsCodeName => $typeAlias + ) + { + // set a var value + $view = StringHelper::safe($viewsCodeName); + + // check if it has field relations + if (isset($this->uninstallScriptFields) + && isset($this->uninstallScriptFields[$viewsCodeName])) + { + // First check if data is till in table + $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " Create a new query object."; + $script .= PHP_EOL . Indent::_(2) + . "\$query = \$db->getQuery(true);"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Select ids from fields"; + $script .= PHP_EOL . Indent::_(2) + . "\$query->select(\$db->quoteName('id'));"; + $script .= PHP_EOL . Indent::_(2) + . "\$query->from(\$db->quoteName('#__fields'));"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Where " . $viewsCodeName . " context is found"; + $script .= PHP_EOL . Indent::_(2) + . "\$query->where( \$db->quoteName('context') . ' = '. \$db->quote('" + . $typeAlias . "') );"; + $script .= PHP_EOL . Indent::_(2) + . "\$db->setQuery(\$query);"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Execute query to see if context is found"; + $script .= PHP_EOL . Indent::_(2) . "\$db->execute();"; + $script .= PHP_EOL . Indent::_(2) . "\$" . $view + . "_found = \$db->getNumRows();"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Now check if there were any rows"; + $script .= PHP_EOL . Indent::_(2) . "if (\$" . $view + . "_found)"; + $script .= PHP_EOL . Indent::_(2) . "{"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Since there are load the needed " . $view + . " field ids"; + $script .= PHP_EOL . Indent::_(3) . "\$" . $view + . "_field_ids = \$db->loadColumn();"; + + // Now remove the actual type entry + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Remove " . $viewsCodeName + . " from the field table"; + $script .= PHP_EOL . Indent::_(3) . "\$" . $view + . "_condition = array( \$db->quoteName('context') . ' = '. \$db->quote('" + . $typeAlias . "') );"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Create a new query object."; + $script .= PHP_EOL . Indent::_(3) + . "\$query = \$db->getQuery(true);"; + $script .= PHP_EOL . Indent::_(3) + . "\$query->delete(\$db->quoteName('#__fields'));"; + $script .= PHP_EOL . Indent::_(3) . "\$query->where(\$" + . $view . "_condition);"; + $script .= PHP_EOL . Indent::_(3) + . "\$db->setQuery(\$query);"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Execute the query to remove " . $viewsCodeName + . " items"; + $script .= PHP_EOL . Indent::_(3) . "\$" . $view + . "_done = \$db->execute();"; + $script .= PHP_EOL . Indent::_(3) . "if (\$" . $view + . "_done)"; + $script .= PHP_EOL . Indent::_(3) . "{"; + $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " If successfully remove " . $viewsCodeName + . " add queued success message."; + // TODO lang is not translated + $script .= PHP_EOL . Indent::_(4) + . "\$app->enqueueMessage(Text:" + . ":_('The fields with type (" . $typeAlias + . ") context was removed from the #__fields table'));"; + $script .= PHP_EOL . Indent::_(3) . "}"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Also Remove " . $viewsCodeName . " field values"; + $script .= PHP_EOL . Indent::_(3) . "\$" . $view + . "_condition = array( \$db->quoteName('field_id') . ' IN ('. implode(',', \$" + . $view . "_field_ids) .')');"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Create a new query object."; + $script .= PHP_EOL . Indent::_(3) + . "\$query = \$db->getQuery(true);"; + $script .= PHP_EOL . Indent::_(3) + . "\$query->delete(\$db->quoteName('#__fields_values'));"; + $script .= PHP_EOL . Indent::_(3) . "\$query->where(\$" + . $view . "_condition);"; + $script .= PHP_EOL . Indent::_(3) + . "\$db->setQuery(\$query);"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Execute the query to remove " . $viewsCodeName + . " field values"; + $script .= PHP_EOL . Indent::_(3) . "\$" . $view + . "_done = \$db->execute();"; + $script .= PHP_EOL . Indent::_(3) . "if (\$" . $view + . "_done)"; + $script .= PHP_EOL . Indent::_(3) . "{"; + $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " If successfully remove " . $viewsCodeName + . " add queued success message."; + // TODO lang is not translated + $script .= PHP_EOL . Indent::_(4) + . "\$app->enqueueMessage(Text:" + . ":_('The fields values for " . $viewsCodeName + . " was removed from the #__fields_values table'));"; + $script .= PHP_EOL . Indent::_(3) . "}"; + $script .= PHP_EOL . Indent::_(2) . "}"; + + // First check if data is till in table + $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " Create a new query object."; + $script .= PHP_EOL . Indent::_(2) + . "\$query = \$db->getQuery(true);"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Select ids from field groups"; + $script .= PHP_EOL . Indent::_(2) + . "\$query->select(\$db->quoteName('id'));"; + $script .= PHP_EOL . Indent::_(2) + . "\$query->from(\$db->quoteName('#__fields_groups'));"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Where " . $viewsCodeName . " context is found"; + $script .= PHP_EOL . Indent::_(2) + . "\$query->where( \$db->quoteName('context') . ' = '. \$db->quote('" + . $typeAlias . "') );"; + $script .= PHP_EOL . Indent::_(2) + . "\$db->setQuery(\$query);"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Execute query to see if context is found"; + $script .= PHP_EOL . Indent::_(2) . "\$db->execute();"; + $script .= PHP_EOL . Indent::_(2) . "\$" . $view + . "_found = \$db->getNumRows();"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Now check if there were any rows"; + $script .= PHP_EOL . Indent::_(2) . "if (\$" . $view + . "_found)"; + $script .= PHP_EOL . Indent::_(2) . "{"; + + // Now remove the actual type entry + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Remove " . $viewsCodeName + . " from the field groups table"; + $script .= PHP_EOL . Indent::_(3) . "\$" . $view + . "_condition = array( \$db->quoteName('context') . ' = '. \$db->quote('" + . $typeAlias . "') );"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Create a new query object."; + $script .= PHP_EOL . Indent::_(3) + . "\$query = \$db->getQuery(true);"; + $script .= PHP_EOL . Indent::_(3) + . "\$query->delete(\$db->quoteName('#__fields_groups'));"; + $script .= PHP_EOL . Indent::_(3) . "\$query->where(\$" + . $view . "_condition);"; + $script .= PHP_EOL . Indent::_(3) + . "\$db->setQuery(\$query);"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Execute the query to remove " . $viewsCodeName + . " items"; + $script .= PHP_EOL . Indent::_(3) . "\$" . $view + . "_done = \$db->execute();"; + $script .= PHP_EOL . Indent::_(3) . "if (\$" . $view + . "_done)"; + $script .= PHP_EOL . Indent::_(3) . "{"; + $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " If successfully remove " . $viewsCodeName + . " add queued success message."; + // TODO lang is not translated + $script .= PHP_EOL . Indent::_(4) + . "\$app->enqueueMessage(Text:" + . ":_('The field groups with type (" . $typeAlias + . ") context was removed from the #__fields_groups table'));"; + $script .= PHP_EOL . Indent::_(3) . "}"; + $script .= PHP_EOL . Indent::_(2) . "}"; + } + // First check if data is till in table + $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Create a new query object."; + $script .= PHP_EOL . Indent::_(2) + . "\$query = \$db->getQuery(true);"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Select id from content type table"; + $script .= PHP_EOL . Indent::_(2) + . "\$query->select(\$db->quoteName('type_id'));"; + $script .= PHP_EOL . Indent::_(2) + . "\$query->from(\$db->quoteName('#__content_types'));"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Where " . $viewsCodeName . " alias is found"; + $script .= PHP_EOL . Indent::_(2) + . "\$query->where( \$db->quoteName('type_alias') . ' = '. \$db->quote('" + . $typeAlias . "') );"; + $script .= PHP_EOL . Indent::_(2) . "\$db->setQuery(\$query);"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Execute query to see if alias is found"; + $script .= PHP_EOL . Indent::_(2) . "\$db->execute();"; + $script .= PHP_EOL . Indent::_(2) . "\$" . $view + . "_found = \$db->getNumRows();"; + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Now check if there were any rows"; + $script .= PHP_EOL . Indent::_(2) . "if (\$" . $view + . "_found)"; + $script .= PHP_EOL . Indent::_(2) . "{"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Since there are load the needed " . $view + . " type ids"; + $script .= PHP_EOL . Indent::_(3) . "\$" . $view + . "_ids = \$db->loadColumn();"; + + // Now remove the actual type entry + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Remove " . $viewsCodeName + . " from the content type table"; + $script .= PHP_EOL . Indent::_(3) . "\$" . $view + . "_condition = array( \$db->quoteName('type_alias') . ' = '. \$db->quote('" + . $typeAlias . "') );"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Create a new query object."; + $script .= PHP_EOL . Indent::_(3) + . "\$query = \$db->getQuery(true);"; + $script .= PHP_EOL . Indent::_(3) + . "\$query->delete(\$db->quoteName('#__content_types'));"; + $script .= PHP_EOL . Indent::_(3) . "\$query->where(\$" . $view + . "_condition);"; + $script .= PHP_EOL . Indent::_(3) . "\$db->setQuery(\$query);"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Execute the query to remove " . $viewsCodeName + . " items"; + $script .= PHP_EOL . Indent::_(3) . "\$" . $view + . "_done = \$db->execute();"; + $script .= PHP_EOL . Indent::_(3) . "if (\$" . $view . "_done)"; + $script .= PHP_EOL . Indent::_(3) . "{"; + $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " If successfully remove " . $viewsCodeName + . " add queued success message."; + // TODO lang is not translated + $script .= PHP_EOL . Indent::_(4) + . "\$app->enqueueMessage(Text:" . ":_('The (" . $typeAlias + . ") type alias was removed from the #__content_type table'));"; + $script .= PHP_EOL . Indent::_(3) . "}"; + + // Now remove the related items from contentitem tag map table + $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) . " Remove " . $viewsCodeName + . " items from the contentitem tag map table"; + $script .= PHP_EOL . Indent::_(3) . "\$" . $view + . "_condition = array( \$db->quoteName('type_alias') . ' = '. \$db->quote('" + . $typeAlias . "') );"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Create a new query object."; + $script .= PHP_EOL . Indent::_(3) + . "\$query = \$db->getQuery(true);"; + $script .= PHP_EOL . Indent::_(3) + . "\$query->delete(\$db->quoteName('#__contentitem_tag_map'));"; + $script .= PHP_EOL . Indent::_(3) . "\$query->where(\$" . $view + . "_condition);"; + $script .= PHP_EOL . Indent::_(3) . "\$db->setQuery(\$query);"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Execute the query to remove " . $viewsCodeName + . " items"; + $script .= PHP_EOL . Indent::_(3) . "\$" . $view + . "_done = \$db->execute();"; + $script .= PHP_EOL . Indent::_(3) . "if (\$" . $view . "_done)"; + $script .= PHP_EOL . Indent::_(3) . "{"; + $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " If successfully remove " . $viewsCodeName + . " add queued success message."; + // TODO lang is not translated + $script .= PHP_EOL . Indent::_(4) + . "\$app->enqueueMessage(Text:" . ":_('The (" . $typeAlias + . ") type alias was removed from the #__contentitem_tag_map table'));"; + $script .= PHP_EOL . Indent::_(3) . "}"; + + // Now remove the related items from ucm content table + $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) . " Remove " . $viewsCodeName + . " items from the ucm content table"; + $script .= PHP_EOL . Indent::_(3) . "\$" . $view + . "_condition = array( \$db->quoteName('core_type_alias') . ' = ' . \$db->quote('" + . $typeAlias . "') );"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Create a new query object."; + $script .= PHP_EOL . Indent::_(3) + . "\$query = \$db->getQuery(true);"; + $script .= PHP_EOL . Indent::_(3) + . "\$query->delete(\$db->quoteName('#__ucm_content'));"; + $script .= PHP_EOL . Indent::_(3) . "\$query->where(\$" . $view + . "_condition);"; + $script .= PHP_EOL . Indent::_(3) . "\$db->setQuery(\$query);"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Execute the query to remove " . $viewsCodeName + . " items"; + $script .= PHP_EOL . Indent::_(3) . "\$" . $view + . "_done = \$db->execute();"; + $script .= PHP_EOL . Indent::_(3) . "if (\$" . $view . "_done)"; + $script .= PHP_EOL . Indent::_(3) . "{"; + $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " If successfully removed " . $viewsCodeName + . " add queued success message."; + // TODO lang is not translated + $script .= PHP_EOL . Indent::_(4) + . "\$app->enqueueMessage(Text:" . ":_('The (" . $typeAlias + . ") type alias was removed from the #__ucm_content table'));"; + $script .= PHP_EOL . Indent::_(3) . "}"; + + // setup the foreach loop of ids + $script .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) . " Make sure that all the " + . $viewsCodeName . " items are cleared from DB"; + $script .= PHP_EOL . Indent::_(3) . "foreach (\$" . $view + . "_ids as \$" . $view . "_id)"; + $script .= PHP_EOL . Indent::_(3) . "{"; + + // Now remove the related items from ucm base table + $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Remove " . $viewsCodeName + . " items from the ucm base table"; + $script .= PHP_EOL . Indent::_(4) . "\$" . $view + . "_condition = array( \$db->quoteName('ucm_type_id') . ' = ' . \$" + . $view . "_id);"; + $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Create a new query object."; + $script .= PHP_EOL . Indent::_(4) + . "\$query = \$db->getQuery(true);"; + $script .= PHP_EOL . Indent::_(4) + . "\$query->delete(\$db->quoteName('#__ucm_base'));"; + $script .= PHP_EOL . Indent::_(4) . "\$query->where(\$" . $view + . "_condition);"; + $script .= PHP_EOL . Indent::_(4) . "\$db->setQuery(\$query);"; + $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Execute the query to remove " . $viewsCodeName + . " items"; + $script .= PHP_EOL . Indent::_(4) . "\$db->execute();"; + + // Now remove the related items from ucm history table + $script .= PHP_EOL . PHP_EOL . Indent::_(4) . "//" + . Line::_(__Line__, __Class__) . " Remove " . $viewsCodeName + . " items from the ucm history table"; + $script .= PHP_EOL . Indent::_(4) . "\$" . $view + . "_condition = array( \$db->quoteName('ucm_type_id') . ' = ' . \$" + . $view . "_id);"; + $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Create a new query object."; + $script .= PHP_EOL . Indent::_(4) + . "\$query = \$db->getQuery(true);"; + $script .= PHP_EOL . Indent::_(4) + . "\$query->delete(\$db->quoteName('#__ucm_history'));"; + $script .= PHP_EOL . Indent::_(4) . "\$query->where(\$" . $view + . "_condition);"; + $script .= PHP_EOL . Indent::_(4) . "\$db->setQuery(\$query);"; + $script .= PHP_EOL . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Execute the query to remove " . $viewsCodeName + . " items"; + $script .= PHP_EOL . Indent::_(4) . "\$db->execute();"; + + $script .= PHP_EOL . Indent::_(3) . "}"; + + $script .= PHP_EOL . Indent::_(2) . "}"; + } + + $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " If All related items was removed queued success message."; + // TODO lang is not translated + $script .= PHP_EOL . Indent::_(2) . "\$app->enqueueMessage(Text:" + . ":_('All related items was removed from the #__ucm_base table'));"; + $script .= PHP_EOL . Indent::_(2) . "\$app->enqueueMessage(Text:" + . ":_('All related items was removed from the #__ucm_history table'));"; + // finaly remove the assets from the assets table + $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Remove " . $component . " assets from the assets table"; + $script .= PHP_EOL . Indent::_(2) . "\$" . $component + . "_condition = array( \$db->quoteName('name') . ' LIKE ' . \$db->quote('com_" + . $component . "%') );"; + $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Create a new query object."; + $script .= PHP_EOL . Indent::_(2) + . "\$query = \$db->getQuery(true);"; + $script .= PHP_EOL . Indent::_(2) + . "\$query->delete(\$db->quoteName('#__assets'));"; + $script .= PHP_EOL . Indent::_(2) . "\$query->where(\$" . $component + . "_condition);"; + $script .= PHP_EOL . Indent::_(2) . "\$db->setQuery(\$query);"; + $script .= PHP_EOL . Indent::_(2) . "\$" . $view + . "_done = \$db->execute();"; + $script .= PHP_EOL . Indent::_(2) . "if (\$" . $view . "_done)"; + $script .= PHP_EOL . Indent::_(2) . "{"; + $script .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " If successfully removed " . $component + . " add queued success message."; + // TODO lang is not translated + $script .= PHP_EOL . Indent::_(3) . "\$app->enqueueMessage(Text:" + . ":_('All related items was removed from the #__assets table'));"; + $script .= PHP_EOL . Indent::_(2) . "}"; + // done + $script .= PHP_EOL; + } + elseif (CFactory::_('Config')->add_assets_table_fix == 2) + { + // start loading the data to delete (WE NEED THIS) + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Get Application object"; + $script .= PHP_EOL . Indent::_(2) + . "\$app = Factory::getApplication();"; + $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Get The Database object"; + $script .= PHP_EOL . Indent::_(2) . "\$db = Factory::getDbo();"; + } + // add the Intelligent Reversal script if needed + $script .= $this->getAssetsTableIntelligentUninstall(); + // add the custom uninstall script + $script .= CFactory::_('Customcode.Dispenser')->get( + 'php_method', 'uninstall', "", null, true, null, PHP_EOL + ); + + return $script; + } + + public function setUninstallScriptJ4() + { + // reset script + $script = ''; + if (isset($this->uninstallScriptBuilder) + && ArrayHelper::check( + $this->uninstallScriptBuilder + )) + { + // start loading the data to delete + $script .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Remove Related Component Data."; + foreach ($this->uninstallScriptBuilder as $viewsCodeName => $context) + { + // set a var value + $View = StringHelper::safe($viewsCodeName, 'Ww'); + // First check if data is till in table + $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " Remove $View Data"; + $field = ''; + // check if it has field relations + if (isset($this->uninstallScriptFields) + && isset($this->uninstallScriptFields[$viewsCodeName])) + { + $field = ', true'; + } + // First check if data is till in table + $script .= PHP_EOL . Indent::_(2) . "\$this->removeViewData(\"$context\"$field);"; + } + + $script .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Remove Asset Data."; + $script .= PHP_EOL . Indent::_(2) . "\$this->removeAssetData();"; + // done + $script .= PHP_EOL; + } + + // add the Intelligent Reversal script if needed + $script .= $this->getAssetsTableIntelligentUninstall(); + + // add the custom uninstallation script + $script .= CFactory::_('Customcode.Dispenser')->get( + 'php_method', 'uninstall', "", null, true, null, PHP_EOL + ); + + return $script; + } + + /** + * build code for the assets table script intelligent fix + * + * @return string The php to place in script.php + * + */ + protected function getAssetsTableIntelligentInstall() + { + // WHY DO WE NEED AN ASSET TABLE FIX? + // https://www.mysqltutorial.org/mysql-varchar/ + // https://stackoverflow.com/a/15227917/1429677 + // https://forums.mysql.com/read.php?24,105964,105964 + // https://git.vdm.dev/joomla/Component-Builder/issues/616#issuecomment-12085 + // 30 actions each +-20 characters with 8 groups + // that makes 4800 characters and the current Joomla + // column size is varchar(5120) + + // check if we should add the intelligent fix treatment for the assets table + if (CFactory::_('Config')->add_assets_table_fix == 2) + { + // get worse case + $access_worse_case = CFactory::_('Config')->get('access_worse_case', 0); + // get the type we will convert to + $data_type = ($access_worse_case > 64000) ? "MEDIUMTEXT" + : "TEXT"; + + if (CFactory::_('Config')->get('joomla_version', 3) != 3) + { + $script = []; + $script[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Fix the assets table rules column size."; + $script[] = Indent::_(3) . '$this->setDatabaseAssetsRulesFix(' + . (int) $access_worse_case . ', "' . $data_type . '");'; + + return PHP_EOL . implode(PHP_EOL, $script); + } + + // the if statement about $rule_length + $codeIF = "\$rule_length <= " . $access_worse_case; + // fix column size + $script = []; + $script[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " Fix the assets table rules column size"; + $script[] = Indent::_(5) + . '$fix_rules_size = "ALTER TABLE `#__assets` CHANGE `rules` `rules` ' + . $data_type + . ' NOT NULL COMMENT \'JSON encoded access control. Enlarged to ' + . $data_type . ' by JCB\';";'; + $script[] = Indent::_(5) . "\$db->setQuery(\$fix_rules_size);"; + $script[] = Indent::_(5) . "\$db->execute();"; + $codeA = implode(PHP_EOL, $script); + // fixed message + $messageA = Indent::_(5) + . "\$app->enqueueMessage(Text:" . ":_('The #__assets table rules column was resized to the " + . $data_type + . " datatype for the components possible large permission rules.'));"; + // do nothing + $codeB = ""; + // fix not needed so ignore + $messageB = ""; + + // done + return $this->getAssetsTableIntelligentCode( + $codeIF, $codeA, $codeB, $messageA, $messageB, 2 + ); + } + + return ''; + } + + /** + * build code for the assets table script intelligent reversal + * + * @return string The php to place in script.php + * + */ + protected function getAssetsTableIntelligentUninstall() + { + // check if we should add the intelligent uninstall treatment for the assets table + if (CFactory::_('Config')->add_assets_table_fix == 2) + { + if (CFactory::_('Config')->get('joomla_version', 3) != 3) + { + $script = []; + $script[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Revert the assets table rules column back to the default."; + $script[] = Indent::_(2) . '$this->removeDatabaseAssetsRulesFix();'; + + return PHP_EOL . implode(PHP_EOL, $script); + } + // the if statement about $rule_length + $codeIF = "\$rule_length < 5120"; + // reverse column size + $script = []; + $script[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Revert the assets table rules column back to the default"; + $script[] = Indent::_(4) + . '$revert_rule = "ALTER TABLE `#__assets` CHANGE `rules` `rules` varchar(5120) NOT NULL COMMENT \'JSON encoded access control.\';";'; + $script[] = Indent::_(4) . "\$db->setQuery(\$revert_rule);"; + $script[] = Indent::_(4) . "\$db->execute();"; + $codeA = implode(PHP_EOL, $script); + // reverted message + $messageA = Indent::_(4) + . "\$app->enqueueMessage(Text::_('COM_COMPONENTBUILDER_REVERTED_THE_B_ASSETSB_TABLE_RULES_COLUMN_BACK_TO_ITS_DEFAULT_SIZE_OF_VARCHARFIVE_THOUSAND_ONE_HUNDRED_AND_TWENTY'));"; + // do nothing + $codeB = ""; + // not reverted message + $messageB = Indent::_(4) + . "\$app->enqueueMessage(Text:" . ":_('Could not revert the #__assets table rules column back to its default size of varchar(5120), since there is still one or more components that still requires the column to be larger.'));"; + + // done + return $this->getAssetsTableIntelligentCode( + $codeIF, $codeA, $codeB, $messageA, $messageB + ); + } + + return ''; + } + + /** + * set code for both install, update and uninstall + * + * @param string $codeIF The IF code to fix this issue + * @param string $codeA The a code to fix this issue + * @param string $codeB The b code to fix this issue + * @param string $messageA The fix a message + * @param string $messageB The fix b message + * + * @return string + * + */ + protected function getAssetsTableIntelligentCode($codeIF, $codeA, $codeB, + $messageA, $messageB, $tab = 1 + ) + { + // reset script + $script = []; + $script[] = Indent::_($tab) . Indent::_(1) . "//" . Line::_( + __LINE__,__CLASS__ + ) + . " Get the biggest rule column in the assets table at this point."; + $script[] = Indent::_($tab) . Indent::_(1) + . '$get_rule_length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1";'; + $script[] = Indent::_($tab) . Indent::_(1) + . "\$db->setQuery(\$get_rule_length);"; + $script[] = Indent::_($tab) . Indent::_(1) . "if (\$db->execute())"; + $script[] = Indent::_($tab) . Indent::_(1) . "{"; + $script[] = Indent::_($tab) . Indent::_(2) + . "\$rule_length = \$db->loadResult();"; + // https://github.com/joomla/joomla-cms/blob/3.10.0-alpha3/installation/sql/mysql/joomla.sql#L22 + // Checked 1st December 2020 (let us know if this changes) + $script[] = Indent::_($tab) . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) + . " Check the size of the rules column"; + $script[] = Indent::_($tab) . Indent::_(2) . "if (" . $codeIF . ")"; + $script[] = Indent::_($tab) . Indent::_(2) . "{"; + $script[] = $codeA; + $script[] = $messageA; + $script[] = Indent::_($tab) . Indent::_(2) . "}"; + // only ad this if there is a B part + if (StringHelper::check($codeB) + || StringHelper::check($messageB)) + { + $script[] = Indent::_($tab) . Indent::_(2) . "else"; + $script[] = Indent::_($tab) . Indent::_(2) . "{"; + $script[] = $codeB; + $script[] = $messageB; + $script[] = Indent::_($tab) . Indent::_(2) . "}"; + } + $script[] = Indent::_($tab) . Indent::_(1) . "}"; + + // done + return PHP_EOL . implode(PHP_EOL, $script); + } + + public function setMoveFolderScript() + { + if (CFactory::_('Registry')->get('set_move_folders_install_script')) + { + $function = 'setDynamicF0ld3rs($app, $parent)'; + if (CFactory::_('Config')->get('joomla_version', 3) != 3) + { + $function = 'moveFolders($adapter)'; + } + // reset script + $script = []; + $script[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " We check if we have dynamic folders to copy"; + $script[] = Indent::_(2) + . "\$this->{$function};"; + + // done + return PHP_EOL . implode(PHP_EOL, $script); + } + + return ''; + } + + public function setMoveFolderMethod() + { + if (CFactory::_('Registry')->get('set_move_folders_install_script')) + { + // reset script + $script = []; + if (CFactory::_('Config')->get('joomla_version', 3) != 3) + { + $script[] = Indent::_(1) . "/**"; + $script[] = Indent::_(1) + . " * Method to move folders into place."; + $script[] = Indent::_(1) . " *"; + $script[] = Indent::_(1) . " * @param InstallerAdapter \$adapter The adapter calling this method"; + $script[] = Indent::_(1) . " *"; + $script[] = Indent::_(1) . " * @return void"; + $script[] = Indent::_(1) . " * @since 4.4.2"; + $script[] = Indent::_(1) . " */"; + $script[] = Indent::_(1) + . "protected function moveFolders(InstallerAdapter \$adapter): void"; + $script[] = Indent::_(1) . "{"; + $script[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get the installation path"; + $script[] = Indent::_(2) . "\$installer = \$adapter->getParent();"; + } + else + { + $script[] = Indent::_(1) . "/**"; + $script[] = Indent::_(1) + . " * Method to set/copy dynamic folders into place (use with caution)"; + $script[] = Indent::_(1) . " *"; + $script[] = Indent::_(1) . " * @return void"; + $script[] = Indent::_(1) . " */"; + $script[] = Indent::_(1) + . "protected function setDynamicF0ld3rs(\$app, \$parent)"; + $script[] = Indent::_(1) . "{"; + $script[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get the installation path"; + $script[] = Indent::_(2) . "\$installer = \$parent->getParent();"; + } + + $script[] = Indent::_(2) + . "\$installPath = \$installer->getPath('source');"; + $script[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get all the folders"; + $script[] = Indent::_(2) + . "\$folders = Folder::folders(\$installPath);"; + $script[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " check if we have folders we may want to copy"; + $script[] = Indent::_(2) + . "\$doNotCopy = ['media','admin','site']; // Joomla already deals with these"; + $script[] = Indent::_(2) . "if (count((array) \$folders) > 1)"; + $script[] = Indent::_(2) . "{"; + $script[] = Indent::_(3) . "foreach (\$folders as \$folder)"; + $script[] = Indent::_(3) . "{"; + $script[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Only copy if not a standard folders"; + $script[] = Indent::_(4) . "if (!in_array(\$folder, \$doNotCopy))"; + $script[] = Indent::_(4) . "{"; + $script[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " set the source path"; + $script[] = Indent::_(5) . "\$src = \$installPath.'/'.\$folder;"; + $script[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " set the destination path"; + $script[] = Indent::_(5) . "\$dest = JPATH_ROOT.'/'.\$folder;"; + $script[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " now try to copy the folder"; + $script[] = Indent::_(5) + . "if (!Folder::copy(\$src, \$dest, '', true))"; + $script[] = Indent::_(5) . "{"; + + if (CFactory::_('Config')->get('joomla_version', 3) != 3) + { + $script[] = Indent::_(6) + . "\$this->app->enqueueMessage('Could not copy '.\$folder.' folder into place, please make sure destination is writable!', 'error');"; + } + else + { + $script[] = Indent::_(6) + . "\$app->enqueueMessage('Could not copy '.\$folder.' folder into place, please make sure destination is writable!', 'error');"; + } + + $script[] = Indent::_(5) . "}"; + $script[] = Indent::_(4) . "}"; + $script[] = Indent::_(3) . "}"; + $script[] = Indent::_(2) . "}"; + $script[] = Indent::_(1) . "}"; + + // done + return PHP_EOL . PHP_EOL . implode(PHP_EOL, $script); + } + + return ''; + } + + public function getContentType($view, $component) + { + // add if history is to be kept or if tags is added + if (CFactory::_('Compiler.Builder.History')->exists($view) + || CFactory::_('Compiler.Builder.Tags')->exists($view)) + { + // reset array + $array = []; + // set needed defaults + $alias = CFactory::_('Compiler.Builder.Alias')->get($view, 'null'); + $title = CFactory::_('Compiler.Builder.Title')->get($view, 'null'); + $category = CFactory::_('Compiler.Builder.Category.Code')->getString("{$view}.code", 'null'); + $categoryHistory = (CFactory::_('Compiler.Builder.Category.Code')->exists($view)) + ? + '{"sourceColumn": "' . $category + . '","targetTable": "#__categories","targetColumn": "id","displayColumn": "title"},' + : ''; + $Component = StringHelper::safe( + $component, 'F' + ); + $View = StringHelper::safe($view, 'F'); + $maintext = CFactory::_('Compiler.Builder.Main.Text.Field')->get($view, 'null'); + $hiddenFields = CFactory::_('Compiler.Builder.Hidden.Fields')->toString($view, ''); + $dynamicfields = CFactory::_('Compiler.Builder.Dynamic.Fields')->toString($view, ','); + $intFields = CFactory::_('Compiler.Builder.Integer.Fields')->toString($view, ''); + $customfieldlinks = CFactory::_('Compiler.Builder.Custom.Field.Links')->toString($view, ''); + // build uninstall script for content types + $this->uninstallScriptBuilder[$View] = 'com_' . $component . '.' . $view; + $this->uninstallScriptContent[$view] = $view; + // check if this view has metadata + if (CFactory::_('Compiler.Builder.Meta.Data')->isString($view)) + { + $core_metadata = 'metadata'; + $core_metakey = 'metakey'; + $core_metadesc = 'metadesc'; + } + else + { + $core_metadata = 'null'; + $core_metakey = 'null'; + $core_metadesc = 'null'; + } + // check if view has access + if (CFactory::_('Compiler.Builder.Access.Switch')->exists($view)) + { + $core_access = 'access'; + $accessHistory + = ',{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"}'; + } + else + { + $core_access = 'null'; + $accessHistory = ''; + } + // set the title + $array['type_title'] = $Component . ' ' . $View; + // set the alias + $array['type_alias'] = 'com_' . $component . '.' . $view; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + // set the table + $array['table'] = '{"special": {"dbtable": "#__' . $component . '_' + . $view . '","key": "id","type": "' . $View . '","prefix": "' + . $component + . 'Table","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; + } + else + { + // set the table + $array['table'] = '{"special": {"dbtable": "#__' . $component . '_' + . $view . '","key": "id","type": "' . $View . 'Table","prefix": "' . CFactory::_('Config')->namespace_prefix + . '\\Component\\' . CFactory::_('Compiler.Builder.Content.One')->get('ComponentNameSpace') + . '\\Administrator\\Table"}}'; + + // set rules field + $array['rules'] = ''; + } + + // set field map + $array['field_mappings'] + = '{"common": {"core_content_item_id": "id","core_title": "' + . $title . '","core_state": "published","core_alias": "' + . $alias + . '","core_created_time": "created","core_modified_time": "modified","core_body": "' + . $maintext + . '","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "' + . $core_access + . '","core_params": "params","core_featured": "null","core_metadata": "' + . $core_metadata + . '","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "' + . $core_metakey . '","core_metadesc": "' . $core_metadesc + . '","core_catid": "' . $category + . '","core_xreference": "null","asset_id": "asset_id"},"special": {' + . $dynamicfields . '}}'; + + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + // set the router class method + $array['router'] = $Component . 'HelperRoute::get' . $View + . 'Route'; + } + else + { + // set the router class method + $array['router'] = ''; + } + + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + // set content history + $array['content_history_options'] + = '{"formFile": "administrator/components/com_' . $component + . '/models/forms/' . $view + . '.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"' + . $hiddenFields + . '],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits"' + . $intFields . '],"displayLookup": [' . $categoryHistory + . '{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}' + . $accessHistory + . ',{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}' + . $customfieldlinks . ']}'; + } + else + { + // set content history + $array['content_history_options'] + = '{"formFile": "administrator/components/com_' . $component + . '/forms/' . $view + . '.xml","hideFields": ["asset_id","checked_out","checked_out_time"' + . $hiddenFields + . '],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","version","hits"' + . $intFields . '],"displayLookup": [' . $categoryHistory + . '{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}' + . $accessHistory + . ',{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}' + . $customfieldlinks . ']}'; + } + + return $array; + } + + return false; + } + + public function getCategoryContentType($view, $views, $component) + { + // get the other view + $otherView = CFactory::_('Compiler.Builder.Category.Code')->getString("{$view}.view", 'error'); + $category = CFactory::_('Compiler.Builder.Category.Code')->getString("{$view}.code", 'error'); + $Component = StringHelper::safe($component, 'F'); + $View = StringHelper::safe($view, 'F'); + // build uninstall script for content types + $this->uninstallScriptBuilder[$View . ' ' . $category] = 'com_' + . $component . '.' . $otherView . '.category'; + $this->uninstallScriptContent[$View . ' ' . $category] = $View . ' ' + . $category; + // set the title + $array['type_title'] = $Component . ' ' . $View . ' ' + . StringHelper::safe($category, 'F'); + // set the alias + $array['type_alias'] = 'com_' . $component . '.' . $otherView + . '.category'; + // set the table + $array['table'] + = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}'; + if (CFactory::_('Config')->get('joomla_version', 3) != 3) + { + // set rules field + $array['rules'] = ''; + } + // set field map + $array['field_mappings'] + = '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}'; + + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + // set the router class method + $array['router'] = $Component . 'HelperRoute::getCategoryRoute'; + // set content history + $array['content_history_options'] + = '{"formFile":"administrator\/components\/com_categories\/models\/forms\/category.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"], "ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version", "hits", "path"],"convertToInt":["publish_up", "publish_down"], "displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}'; + } + else + { + // set the router class method + $array['router'] = ''; + // set content history + $array['content_history_options'] + = '{"formFile":"administrator\/components\/com_categories\/forms\/category.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"], "ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version", "hits", "path"],"convertToInt":["publish_up", "publish_down"], "displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}'; + } + + return $array; + } + + public function setRouterHelp($nameSingleCode, $nameListCode, + $front = false + ) + { + // add if tags is added, also for all front item views + if ((CFactory::_('Compiler.Builder.Tags')->exists($nameSingleCode) + || $front) + && (!in_array($nameSingleCode, $this->setRouterHelpDone))) + { + // insure we load a view only once + $this->setRouterHelpDone[] = $nameSingleCode; + // build view route helper + $View = StringHelper::safe( + $nameSingleCode, 'F' + ); + $routeHelper = []; + $routeHelper[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $routeHelper[] = Indent::_(1) . " * @param int The route of the " + . $View; + $routeHelper[] = Indent::_(1) . " */"; + if ('category' === $nameSingleCode + || 'categories' === $nameSingleCode) + { + $routeHelper[] = Indent::_(1) . "public static function get" + . $View . "Route(\$id = 0)"; + } + else + { + $routeHelper[] = Indent::_(1) . "public static function get" + . $View . "Route(\$id = 0, \$catid = 0)"; + } + $routeHelper[] = Indent::_(1) . "{"; + $routeHelper[] = Indent::_(2) . "if (\$id > 0)"; + $routeHelper[] = Indent::_(2) . "{"; + $routeHelper[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Initialize the needel array."; + $routeHelper[] = Indent::_(3) . "\$needles = array("; + $routeHelper[] = Indent::_(4) . "'" . $nameSingleCode + . "' => array((int) \$id)"; + $routeHelper[] = Indent::_(3) . ");"; + $routeHelper[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Create the link"; + $routeHelper[] = Indent::_(3) . "\$link = 'index.php?option=com_" + . CFactory::_('Config')->component_code_name . "&view=" . $nameSingleCode + . "&id='. \$id;"; + $routeHelper[] = Indent::_(2) . "}"; + $routeHelper[] = Indent::_(2) . "else"; + $routeHelper[] = Indent::_(2) . "{"; + $routeHelper[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Initialize the needel array."; + $routeHelper[] = Indent::_(3) . "\$needles = array("; + $routeHelper[] = Indent::_(4) . "'" . $nameSingleCode + . "' => array()"; + $routeHelper[] = Indent::_(3) . ");"; + $routeHelper[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Create the link but don't add the id."; + $routeHelper[] = Indent::_(3) . "\$link = 'index.php?option=com_" + . CFactory::_('Config')->component_code_name . "&view=" . $nameSingleCode + . "';"; + $routeHelper[] = Indent::_(2) . "}"; + if ('category' != $nameSingleCode + && 'categories' != $nameSingleCode) + { + $routeHelper[] = Indent::_(2) . "if (\$catid > 1)"; + $routeHelper[] = Indent::_(2) . "{"; + $routeHelper[] = Indent::_(3) + . "\$categories = Categories::getInstance('" + . CFactory::_('Config')->component_code_name . "." . $nameListCode . "');"; + $routeHelper[] = Indent::_(3) + . "\$category = \$categories->get(\$catid);"; + $routeHelper[] = Indent::_(3) . "if (\$category)"; + $routeHelper[] = Indent::_(3) . "{"; + $routeHelper[] = Indent::_(4) + . "\$needles['category'] = array_reverse(\$category->getPath());"; + $routeHelper[] = Indent::_(4) + . "\$needles['categories'] = \$needles['category'];"; + $routeHelper[] = Indent::_(4) . "\$link .= '&catid='.\$catid;"; + $routeHelper[] = Indent::_(3) . "}"; + $routeHelper[] = Indent::_(2) . "}"; + } + if (CFactory::_('Compiler.Builder.Has.Menu.Global')->exists($nameSingleCode)) + { + $routeHelper[] = PHP_EOL . Indent::_(2) + . "if (\$item = self::_findItem(\$needles, '" + . $nameSingleCode . "'))"; + } + else + { + $routeHelper[] = PHP_EOL . Indent::_(2) + . "if (\$item = self::_findItem(\$needles))"; + } + $routeHelper[] = Indent::_(2) . "{"; + $routeHelper[] = Indent::_(3) . "\$link .= '&Itemid='.\$item;"; + $routeHelper[] = Indent::_(2) . "}"; + $routeHelper[] = PHP_EOL . Indent::_(2) . "return \$link;"; + $routeHelper[] = Indent::_(1) . "}"; + + return implode(PHP_EOL, $routeHelper); + } + + return ''; + } + + public function routerParseSwitch(&$view, $viewArray = null, + $aliasView = true, $idView = true + ) + { + // reset buckets + $routerSwitch = []; + $isCategory = ''; + $viewTable = false; + if ($viewArray && ArrayHelper::check($viewArray) + && isset($viewArray['settings']) + && isset($viewArray['settings']->main_get)) + { + // check if we have custom script for this router parse switch case + if (isset($viewArray['settings']->main_get->add_php_router_parse) + && $viewArray['settings']->main_get->add_php_router_parse == 1 + && isset($viewArray['settings']->main_get->php_router_parse) + && StringHelper::check( + $viewArray['settings']->main_get->php_router_parse + )) + { + // load the custom script for the switch based on dynamic get + $routerSwitch[] = PHP_EOL . Indent::_(3) . "case '" . $view + . "':"; + $routerSwitch[] = CFactory::_('Placeholder')->update_( + $viewArray['settings']->main_get->php_router_parse + ); + $routerSwitch[] = Indent::_(4) . "break;"; + + return implode(PHP_EOL, $routerSwitch); + } + // is this a catogory + elseif (isset($viewArray['settings']->main_get->db_table_main) + && $viewArray['settings']->main_get->db_table_main + === 'categories') + { + $isCategory = ', true'; // TODO we will keep an eye on this.... + } + // get the main table name + elseif (isset($viewArray['settings']->main_get->main_get) + && ArrayHelper::check( + $viewArray['settings']->main_get->main_get + )) + { + foreach ($viewArray['settings']->main_get->main_get as $get) + { + if (isset($get['as']) && $get['as'] === 'a') + { + if (isset($get['selection']) + && ArrayHelper::check( + $get['selection'] + ) + && isset($get['selection']['select_gets']) + && ArrayHelper::check( + $get['selection']['select_gets'] + )) + { + if (isset($get['selection']['table'])) + { + $viewTable = str_replace( + '#__' . CFactory::_('Config')->component_code_name . '_', '', + (string) $get['selection']['table'] + ); + } + } + break; + } + } + } + } + // add if tags is added, also for all front item views + if ($aliasView) + { + $routerSwitch[] = PHP_EOL . Indent::_(3) . "case '" . $view . "':"; + $routerSwitch[] = Indent::_(4) . "\$vars['view'] = '" . $view + . "';"; + $routerSwitch[] = Indent::_(4) + . "if (is_numeric(\$segments[\$count-1]))"; + $routerSwitch[] = Indent::_(4) . "{"; + $routerSwitch[] = Indent::_(5) + . "\$vars['id'] = (int) \$segments[\$count-1];"; + $routerSwitch[] = Indent::_(4) . "}"; + $routerSwitch[] = Indent::_(4) . "elseif (\$segments[\$count-1])"; + $routerSwitch[] = Indent::_(4) . "{"; + // we need to get from the table of this views main get the alias so we need the table name + if ($viewTable) + { + $routerSwitch[] = Indent::_(5) . "\$id = \$this->getVar('" + . $viewTable . "', \$segments[\$count-1], 'alias', 'id'" + . $isCategory . ");"; + } + else + { + $routerSwitch[] = Indent::_(5) . "\$id = \$this->getVar('" + . $view . "', \$segments[\$count-1], 'alias', 'id'" + . $isCategory . ");"; + } + $routerSwitch[] = Indent::_(5) . "if(\$id)"; + $routerSwitch[] = Indent::_(5) . "{"; + $routerSwitch[] = Indent::_(6) . "\$vars['id'] = \$id;"; + $routerSwitch[] = Indent::_(5) . "}"; + $routerSwitch[] = Indent::_(4) . "}"; + $routerSwitch[] = Indent::_(4) . "break;"; + } + elseif ($idView) + { + $routerSwitch[] = PHP_EOL . Indent::_(3) . "case '" . $view . "':"; + $routerSwitch[] = Indent::_(4) . "\$vars['view'] = '" . $view + . "';"; + $routerSwitch[] = Indent::_(4) + . "if (is_numeric(\$segments[\$count-1]))"; + $routerSwitch[] = Indent::_(4) . "{"; + $routerSwitch[] = Indent::_(5) + . "\$vars['id'] = (int) \$segments[\$count-1];"; + $routerSwitch[] = Indent::_(4) . "}"; + $routerSwitch[] = Indent::_(4) . "break;"; + } + else + { + $routerSwitch[] = PHP_EOL . Indent::_(3) . "case '" . $view . "':"; + $routerSwitch[] = Indent::_(4) . "\$vars['view'] = '" . $view + . "';"; + $routerSwitch[] = Indent::_(4) . "break;"; + } + + return implode(PHP_EOL, $routerSwitch); + } + + public function routerBuildViews(&$view) + { + if (CFactory::_('Compiler.Builder.Content.One')->exists('ROUTER_BUILD_VIEWS') + && StringHelper::check( + CFactory::_('Compiler.Builder.Content.One')->get('ROUTER_BUILD_VIEWS') + )) + { + return " || \$view === '" . $view . "'"; + } + else + { + return "\$view === '" . $view . "'"; + } + } + + public function setBatchMove($nameSingleCode) + { + // set needed defaults + $category = CFactory::_('Compiler.Builder.Category.Code')->getString("{$nameSingleCode}.code"); + $batchmove = []; + $VIEW = StringHelper::safe($nameSingleCode, 'U'); + // component helper name + $Helper = CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper'; + // prepare custom script + $customScript = CFactory::_('Customcode.Dispenser')->get( + 'php_batchmove', $nameSingleCode, PHP_EOL . PHP_EOL, null, true + ); + + $batchmove[] = PHP_EOL . Indent::_(1) . "/**"; + $batchmove[] = Indent::_(1) . " * Batch move items to a new category"; + $batchmove[] = Indent::_(1) . " *"; + $batchmove[] = Indent::_(1) + . " * @param integer \$value The new category ID."; + $batchmove[] = Indent::_(1) + . " * @param array \$pks An array of row IDs."; + $batchmove[] = Indent::_(1) + . " * @param array \$contexts An array of item contexts."; + $batchmove[] = Indent::_(1) . " *"; + $batchmove[] = Indent::_(1) + . " * @return boolean True if successful, false otherwise and internal error is set."; + $batchmove[] = Indent::_(1) . " *"; + $batchmove[] = Indent::_(1) . " * @since 12.2"; + $batchmove[] = Indent::_(1) . " */"; + $batchmove[] = Indent::_(1) + . "protected function batchMove(\$values, \$pks, \$contexts)"; + $batchmove[] = Indent::_(1) . "{"; + $batchmove[] = Indent::_(2) . "if (empty(\$this->batchSet))"; + $batchmove[] = Indent::_(2) . "{"; + $batchmove[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Set some needed variables."; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $batchmove[] = Indent::_(3) + . "\$this->user = Factory::getUser();"; + } + else + { + $batchmove[] = Indent::_(3) + . "\$this->user = Factory::getApplication()->getIdentity();"; + } + $batchmove[] = Indent::_(3) + . "\$this->table = \$this->getTable();"; + $batchmove[] = Indent::_(3) + . "\$this->tableClassName = get_class(\$this->table);"; + $batchmove[] = Indent::_(3) . "\$this->canDo = " . $Helper + . "::getActions('" . $nameSingleCode . "');"; + $batchmove[] = Indent::_(2) . "}"; + + $batchmove[] = PHP_EOL . Indent::_(2) . "if (!\$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit') . "') && !\$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.batch') . "'))"; + + $batchmove[] = Indent::_(2) . "{"; + $batchmove[] = Indent::_(3) . "\$this->setError(Text:" + . ":_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));"; + $batchmove[] = Indent::_(3) . "return false;"; + $batchmove[] = Indent::_(2) . "}" . $customScript; + + $batchmove[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " make sure published only updates if user has the permission."; + $batchmove[] = Indent::_(2) + . "if (isset(\$values['published']) && !\$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit.state') . "'))"; + + $batchmove[] = Indent::_(2) . "{"; + $batchmove[] = Indent::_(3) . "unset(\$values['published']);"; + $batchmove[] = Indent::_(2) . "}"; + + $batchmove[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " remove move_copy from array"; + $batchmove[] = Indent::_(2) . "unset(\$values['move_copy']);"; + + if ($category !== null) + { + $batchmove[] = PHP_EOL . Indent::_(2) + . "if (isset(\$values['category']) && (int) \$values['category'] > 0 && !static::checkCategoryId(\$values['category']))"; + $batchmove[] = Indent::_(2) . "{"; + $batchmove[] = Indent::_(3) . "return false;"; + $batchmove[] = Indent::_(2) . "}"; + $batchmove[] = Indent::_(2) + . "elseif (isset(\$values['category']) && (int) \$values['category'] > 0)"; + $batchmove[] = Indent::_(2) . "{"; + $batchmove[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " move the category value to correct field name"; + $batchmove[] = Indent::_(3) . "\$values['" . $category + . "'] = \$values['category'];"; + $batchmove[] = Indent::_(3) . "unset(\$values['category']);"; + $batchmove[] = Indent::_(2) . "}"; + $batchmove[] = Indent::_(2) + . "elseif (isset(\$values['category']))"; + $batchmove[] = Indent::_(2) . "{"; + $batchmove[] = Indent::_(3) . "unset(\$values['category']);"; + $batchmove[] = Indent::_(2) . "}" . PHP_EOL; + } + + $batchmove[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Parent exists so we proceed"; + $batchmove[] = Indent::_(2) . "foreach (\$pks as \$pk)"; + $batchmove[] = Indent::_(2) . "{"; + $batchmove[] = Indent::_(3) . "if (!\$this->user->authorise('" + . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit') . "', \$contexts[\$pk]))"; + $batchmove[] = Indent::_(3) . "{"; + $batchmove[] = Indent::_(4) . "\$this->setError(Text:" + . ":_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));"; + + $batchmove[] = Indent::_(4) . "return false;"; + $batchmove[] = Indent::_(3) . "}"; + + $batchmove[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Check that the row actually exists"; + $batchmove[] = Indent::_(3) . "if (!\$this->table->load(\$pk))"; + $batchmove[] = Indent::_(3) . "{"; + $batchmove[] = Indent::_(4) + . "if (\$error = \$this->table->getError())"; + $batchmove[] = Indent::_(4) . "{"; + $batchmove[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " Fatal error"; + $batchmove[] = Indent::_(5) . "\$this->setError(\$error);"; + + $batchmove[] = Indent::_(5) . "return false;"; + $batchmove[] = Indent::_(4) . "}"; + $batchmove[] = Indent::_(4) . "else"; + $batchmove[] = Indent::_(4) . "{"; + $batchmove[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " Not fatal error"; + $batchmove[] = Indent::_(5) . "\$this->setError(Text:" + . ":sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', \$pk));"; + $batchmove[] = Indent::_(5) . "continue;"; + $batchmove[] = Indent::_(4) . "}"; + $batchmove[] = Indent::_(3) . "}"; + + $batchmove[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " insert all set values."; + $batchmove[] = Indent::_(3) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$values))"; + $batchmove[] = Indent::_(3) . "{"; + $batchmove[] = Indent::_(4) . "foreach (\$values as \$key => \$value)"; + $batchmove[] = Indent::_(4) . "{"; + $batchmove[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " Do special action for access."; + $batchmove[] = Indent::_(5) + . "if ('access' === \$key && strlen(\$value) > 0)"; + $batchmove[] = Indent::_(5) . "{"; + $batchmove[] = Indent::_(6) . "\$this->table->\$key = \$value;"; + $batchmove[] = Indent::_(5) . "}"; + $batchmove[] = Indent::_(5) + . "elseif (strlen(\$value) > 0 && isset(\$this->table->\$key))"; + $batchmove[] = Indent::_(5) . "{"; + $batchmove[] = Indent::_(6) . "\$this->table->\$key = \$value;"; + $batchmove[] = Indent::_(5) . "}"; + $batchmove[] = Indent::_(4) . "}"; + $batchmove[] = Indent::_(3) . "}" . PHP_EOL; + + $batchmove[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Check the row."; + $batchmove[] = Indent::_(3) . "if (!\$this->table->check())"; + $batchmove[] = Indent::_(3) . "{"; + $batchmove[] = Indent::_(4) + . "\$this->setError(\$this->table->getError());"; + + $batchmove[] = PHP_EOL . Indent::_(4) . "return false;"; + $batchmove[] = Indent::_(3) . "}"; + + $batchmove[] = PHP_EOL . Indent::_(3) . "if (!empty(\$this->type))"; + $batchmove[] = Indent::_(3) . "{"; + $batchmove[] = Indent::_(4) + . "\$this->createTagsHelper(\$this->tagsObserver, \$this->type, \$pk, \$this->typeAlias, \$this->table);"; + $batchmove[] = Indent::_(3) . "}"; + + $batchmove[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Store the row."; + $batchmove[] = Indent::_(3) . "if (!\$this->table->store())"; + $batchmove[] = Indent::_(3) . "{"; + $batchmove[] = Indent::_(4) + . "\$this->setError(\$this->table->getError());"; + + $batchmove[] = PHP_EOL . Indent::_(4) . "return false;"; + $batchmove[] = Indent::_(3) . "}"; + $batchmove[] = Indent::_(2) . "}"; + + $batchmove[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Clean the cache"; + $batchmove[] = Indent::_(2) . "\$this->cleanCache();"; + + $batchmove[] = PHP_EOL . Indent::_(2) . "return true;"; + $batchmove[] = Indent::_(1) . "}"; + + return PHP_EOL . implode(PHP_EOL, $batchmove); + } + + public function setBatchCopy($nameSingleCode) + { + // set needed defaults + $title = false; + $titles = []; + // only load alias if set in this view + $alias = CFactory::_('Compiler.Builder.Alias')->get($nameSingleCode); + $category = CFactory::_('Compiler.Builder.Category.Code')->getString("{$nameSingleCode}.code"); + $batchcopy = []; + $VIEW = StringHelper::safe($nameSingleCode, 'U'); + // component helper name + $Helper = CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper'; + + // only load title if set in this view + if (($customAliasBuilder = CFactory::_('Compiler.Builder.Custom.Alias')->get($nameSingleCode)) !== null) + { + $titles = array_values( + $customAliasBuilder + ); + $title = true; + } + elseif (CFactory::_('Compiler.Builder.Title')->exists($nameSingleCode)) + { + $titles = [CFactory::_('Compiler.Builder.Title')->get($nameSingleCode)]; + $title = true; + } + // se the dynamic title + if ($title) + { + // reset the bucket + $titleData = []; + // load the dynamic title builder + foreach ($titles as $_title) + { + $titleData[] = "\$this->table->" . $_title; + } + } + // prepare custom script + $customScript = CFactory::_('Customcode.Dispenser')->get( + 'php_batchcopy', $nameSingleCode, PHP_EOL . PHP_EOL, null, true + ); + + $batchcopy[] = PHP_EOL . Indent::_(1) . "/**"; + $batchcopy[] = Indent::_(1) + . " * Batch copy items to a new category or current."; + $batchcopy[] = Indent::_(1) . " *"; + $batchcopy[] = Indent::_(1) + . " * @param integer \$values The new values."; + $batchcopy[] = Indent::_(1) + . " * @param array \$pks An array of row IDs."; + $batchcopy[] = Indent::_(1) + . " * @param array \$contexts An array of item contexts."; + $batchcopy[] = Indent::_(1) . " *"; + $batchcopy[] = Indent::_(1) + . " * @return mixed An array of new IDs on success, boolean false on failure."; + $batchcopy[] = Indent::_(1) . " *"; + $batchcopy[] = Indent::_(1) . " * @since 12.2"; + $batchcopy[] = Indent::_(1) . " */"; + $batchcopy[] = Indent::_(1) + . "protected function batchCopy(\$values, \$pks, \$contexts)"; + $batchcopy[] = Indent::_(1) . "{"; + + $batchcopy[] = Indent::_(2) . "if (empty(\$this->batchSet))"; + $batchcopy[] = Indent::_(2) . "{"; + $batchcopy[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Set some needed variables."; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $batchcopy[] = Indent::_(3) + . "\$this->user = Factory::getUser();"; + } + else + { + $batchcopy[] = Indent::_(3) + . "\$this->user = Factory::getApplication()->getIdentity();"; + } + $batchcopy[] = Indent::_(3) + . "\$this->table = \$this->getTable();"; + $batchcopy[] = Indent::_(3) + . "\$this->tableClassName = get_class(\$this->table);"; + $batchcopy[] = Indent::_(3) . "\$this->canDo = " . $Helper + . "::getActions('" . $nameSingleCode . "');"; + $batchcopy[] = Indent::_(2) . "}"; + $batchcopy[] = PHP_EOL . Indent::_(2) . "if (!\$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.create') . "') && !\$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.batch') . "'))"; + $batchcopy[] = Indent::_(2) . "{"; + $batchcopy[] = Indent::_(3) . "return false;"; + $batchcopy[] = Indent::_(2) . "}" . $customScript; + + $batchcopy[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get list of unique fields"; + $batchcopy[] = Indent::_(2) + . "\$uniqueFields = \$this->getUniqueFields();"; + $batchcopy[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " remove move_copy from array"; + $batchcopy[] = Indent::_(2) . "unset(\$values['move_copy']);"; + + $batchcopy[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " make sure published is set"; + $batchcopy[] = Indent::_(2) . "if (!isset(\$values['published']))"; + $batchcopy[] = Indent::_(2) . "{"; + $batchcopy[] = Indent::_(3) . "\$values['published'] = 0;"; + $batchcopy[] = Indent::_(2) . "}"; + $batchcopy[] = Indent::_(2) + . "elseif (isset(\$values['published']) && !\$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit.state') . "'))"; + $batchcopy[] = Indent::_(2) . "{"; + $batchcopy[] = Indent::_(4) . "\$values['published'] = 0;"; + $batchcopy[] = Indent::_(2) . "}"; + + if ($category) + { + $batchcopy[] = PHP_EOL . Indent::_(2) + . "if (isset(\$values['category']) && (int) \$values['category'] > 0 && !static::checkCategoryId(\$values['category']))"; + $batchcopy[] = Indent::_(2) . "{"; + $batchcopy[] = Indent::_(3) . "return false;"; + $batchcopy[] = Indent::_(2) . "}"; + $batchcopy[] = Indent::_(2) + . "elseif (isset(\$values['category']) && (int) \$values['category'] > 0)"; + $batchcopy[] = Indent::_(2) . "{"; + $batchcopy[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " move the category value to correct field name"; + $batchcopy[] = Indent::_(3) . "\$values['" . $category + . "'] = \$values['category'];"; + $batchcopy[] = Indent::_(3) . "unset(\$values['category']);"; + $batchcopy[] = Indent::_(2) . "}"; + $batchcopy[] = Indent::_(2) + . "elseif (isset(\$values['category']))"; + $batchcopy[] = Indent::_(2) . "{"; + $batchcopy[] = Indent::_(3) . "unset(\$values['category']);"; + $batchcopy[] = Indent::_(2) . "}"; + } + + $batchcopy[] = PHP_EOL . Indent::_(2) . "\$newIds = [];"; + + $batchcopy[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Parent exists so let's proceed"; + $batchcopy[] = Indent::_(2) . "while (!empty(\$pks))"; + $batchcopy[] = Indent::_(2) . "{"; + $batchcopy[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Pop the first ID off the stack"; + $batchcopy[] = Indent::_(3) . "\$pk = array_shift(\$pks);"; + + $batchcopy[] = PHP_EOL . Indent::_(3) . "\$this->table->reset();"; + + $batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " only allow copy if user may edit this item."; + $batchcopy[] = Indent::_(3) . "if (!\$this->user->authorise('" + . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit') . "', \$contexts[\$pk]))"; + $batchcopy[] = Indent::_(3) . "{"; + $batchcopy[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Not fatal error"; + $batchcopy[] = Indent::_(4) . "\$this->setError(Text:" + . ":sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', \$pk));"; + $batchcopy[] = Indent::_(4) . "continue;"; + $batchcopy[] = Indent::_(3) . "}"; + + $batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Check that the row actually exists"; + $batchcopy[] = Indent::_(3) . "if (!\$this->table->load(\$pk))"; + $batchcopy[] = Indent::_(3) . "{"; + $batchcopy[] = Indent::_(4) + . "if (\$error = \$this->table->getError())"; + $batchcopy[] = Indent::_(4) . "{"; + $batchcopy[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " Fatal error"; + $batchcopy[] = Indent::_(5) . "\$this->setError(\$error);"; + + $batchcopy[] = Indent::_(5) . "return false;"; + $batchcopy[] = Indent::_(4) . "}"; + $batchcopy[] = Indent::_(4) . "else"; + $batchcopy[] = Indent::_(4) . "{"; + $batchcopy[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " Not fatal error"; + $batchcopy[] = Indent::_(5) . "\$this->setError(Text:" + . ":sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', \$pk));"; + $batchcopy[] = Indent::_(5) . "continue;"; + $batchcopy[] = Indent::_(4) . "}"; + $batchcopy[] = Indent::_(3) . "}"; + if ($category && $alias === 'alias' + && ($title && count($titles) == 1 + && in_array('title', $titles))) + { + $batchcopy[] = PHP_EOL . Indent::_(3) . "if (isset(\$values['" + . $category . "']))"; + $batchcopy[] = Indent::_(3) . "{"; + $batchcopy[] = Indent::_(4) + . "static::generateTitle((int) \$values['" . $category + . "'], \$this->table);"; + $batchcopy[] = Indent::_(3) . "}"; + $batchcopy[] = Indent::_(3) . "else"; + $batchcopy[] = Indent::_(3) . "{"; + $batchcopy[] = Indent::_(4) + . "static::generateTitle((int) \$this->table->" . $category + . ", \$this->table);"; + $batchcopy[] = Indent::_(3) . "}"; + } + elseif ($category && $alias && ($title && count($titles) == 1)) + { + $batchcopy[] = PHP_EOL . Indent::_(3) . "if (isset(\$values['" + . $category . "']))"; + $batchcopy[] = Indent::_(3) . "{"; + $batchcopy[] = Indent::_(4) . "list(\$this->table->" . implode( + '', $titles + ) . ", \$this->table->" . $alias + . ") = \$this->generateNewTitle(\$values['" . $category + . "'], \$this->table->" . $alias . ", \$this->table->" + . implode('', $titles) . ");"; + $batchcopy[] = Indent::_(3) . "}"; + $batchcopy[] = Indent::_(3) . "else"; + $batchcopy[] = Indent::_(3) . "{"; + $batchcopy[] = Indent::_(4) . "list(\$this->table->" . implode( + '', $titles + ) . ", \$this->table->" . $alias + . ") = \$this->generateNewTitle(\$this->table->" . $category + . ", \$this->table->" . $alias . ", \$this->table->" . implode( + '', $titles + ) . ");"; + $batchcopy[] = Indent::_(3) . "}"; + } + elseif (!$category && $alias && ($title && count($titles) == 1)) + { + $batchcopy[] = Indent::_(3) . "list(\$this->table->" . implode( + '', $titles + ) . ", \$this->table->" . $alias + . ") = \$this->_generateNewTitle(\$this->table->" . $alias + . ", \$this->table->" . implode('', $titles) . ");"; + } + elseif (!$category && $alias && $title) + { + $batchcopy[] = Indent::_(3) . "list(" . implode(', ', $titleData) + . ", \$this->table->" . $alias + . ") = \$this->_generateNewTitle(\$this->table->" . $alias + . ", array(" . implode(', ', $titleData) . "));"; + } + elseif (!$category && !$alias + && ($title && count($titles) == 1 + && !in_array('user', $titles) + && !in_array( + 'jobnumber', $titles + ))) // TODO [jobnumber] just for one project (not ideal) + { + $batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Only for strings"; + $batchcopy[] = Indent::_(3) . "if (" + . "Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$this->table->" . implode('', $titles) + . ") && !is_numeric(\$this->table->" . implode('', $titles) + . "))"; + $batchcopy[] = Indent::_(3) . "{"; + $batchcopy[] = Indent::_(4) . "\$this->table->" . implode( + '', $titles + ) . " = \$this->generateUnique('" . implode('', $titles) + . "',\$this->table->" . implode('', $titles) . ");"; + $batchcopy[] = Indent::_(3) . "}"; + } + + $batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " insert all set values"; + $batchcopy[] = Indent::_(3) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$values))"; + $batchcopy[] = Indent::_(3) . "{"; + $batchcopy[] = Indent::_(4) . "foreach (\$values as \$key => \$value)"; + $batchcopy[] = Indent::_(4) . "{"; + $batchcopy[] = Indent::_(5) + . "if (strlen(\$value) > 0 && isset(\$this->table->\$key))"; + $batchcopy[] = Indent::_(5) . "{"; + $batchcopy[] = Indent::_(6) . "\$this->table->\$key = \$value;"; + $batchcopy[] = Indent::_(5) . "}"; + $batchcopy[] = Indent::_(4) . "}"; + $batchcopy[] = Indent::_(3) . "}" . PHP_EOL; + + $batchcopy[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " update all unique fields"; + $batchcopy[] = Indent::_(3) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$uniqueFields))"; + $batchcopy[] = Indent::_(3) . "{"; + $batchcopy[] = Indent::_(4) + . "foreach (\$uniqueFields as \$uniqueField)"; + $batchcopy[] = Indent::_(4) . "{"; + $batchcopy[] = Indent::_(5) + . "\$this->table->\$uniqueField = \$this->generateUnique(\$uniqueField,\$this->table->\$uniqueField);"; + $batchcopy[] = Indent::_(4) . "}"; + $batchcopy[] = Indent::_(3) . "}"; + + $batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Reset the ID because we are making a copy"; + $batchcopy[] = Indent::_(3) . "\$this->table->id = 0;"; + + $batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " TODO: Deal with ordering?"; + $batchcopy[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " \$this->table->ordering = 1;"; + + $batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Check the row."; + $batchcopy[] = Indent::_(3) . "if (!\$this->table->check())"; + $batchcopy[] = Indent::_(3) . "{"; + $batchcopy[] = Indent::_(4) + . "\$this->setError(\$this->table->getError());"; + + $batchcopy[] = PHP_EOL . Indent::_(4) . "return false;"; + $batchcopy[] = Indent::_(3) . "}"; + + $batchcopy[] = PHP_EOL . Indent::_(3) . "if (!empty(\$this->type))"; + $batchcopy[] = Indent::_(3) . "{"; + $batchcopy[] = Indent::_(4) + . "\$this->createTagsHelper(\$this->tagsObserver, \$this->type, \$pk, \$this->typeAlias, \$this->table);"; + $batchcopy[] = Indent::_(3) . "}"; + + $batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Store the row."; + $batchcopy[] = Indent::_(3) . "if (!\$this->table->store())"; + $batchcopy[] = Indent::_(3) . "{"; + $batchcopy[] = Indent::_(4) + . "\$this->setError(\$this->table->getError());"; + + $batchcopy[] = PHP_EOL . Indent::_(4) . "return false;"; + $batchcopy[] = Indent::_(3) . "}"; + + $batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Get the new item ID"; + $batchcopy[] = Indent::_(3) . "\$newId = \$this->table->get('id');"; + + $batchcopy[] = PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Add the new ID to the array"; + $batchcopy[] = Indent::_(3) . "\$newIds[\$pk] = \$newId;"; + $batchcopy[] = Indent::_(2) . "}"; + + $batchcopy[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Clean the cache"; + $batchcopy[] = Indent::_(2) . "\$this->cleanCache();"; + + $batchcopy[] = PHP_EOL . Indent::_(2) . "return \$newIds;"; + $batchcopy[] = Indent::_(1) . "}"; + + return PHP_EOL . implode(PHP_EOL, $batchcopy); + } + + public function setAliasTitleFix($nameSingleCode) + { + $fixUnique = []; + // only load this if these two items are set + if (CFactory::_('Compiler.Builder.Alias')->exists($nameSingleCode) + && (CFactory::_('Compiler.Builder.Title')->exists($nameSingleCode) + || CFactory::_('Compiler.Builder.Custom.Alias')->exists($nameSingleCode))) + { + // set needed defaults + $category = CFactory::_('Compiler.Builder.Category.Code')->getString("{$nameSingleCode}.code"); + $alias = CFactory::_('Compiler.Builder.Alias')->get($nameSingleCode); + $VIEW = StringHelper::safe( + $nameSingleCode, 'U' + ); + // set the title stuff + if (($customAliasBuilder = CFactory::_('Compiler.Builder.Custom.Alias')->get($nameSingleCode)) !== null) + { + $titles = array_values( + $customAliasBuilder + ); + } + else + { + $titles = [CFactory::_('Compiler.Builder.Title')->get($nameSingleCode)]; + } + // start building the fix + $fixUnique[] = PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Alter the " . implode(', ', $titles) + . " for save as copy"; + $fixUnique[] = Indent::_(2) + . "if (\$input->get('task') === 'save2copy')"; + $fixUnique[] = Indent::_(2) . "{"; + $fixUnique[] = Indent::_(3) + . "\$origTable = clone \$this->getTable();"; + $fixUnique[] = Indent::_(3) + . "\$origTable->load(\$input->getInt('id'));"; + // reset the buckets + $ifStatment = []; + $titleVars = []; + $titleData = []; + $titleUpdate = []; + // load the dynamic title builder + foreach ($titles as $title) + { + $ifStatment[] = "\$data['" . $title . "'] == \$origTable->" + . $title; + $titleVars[] = "\$" . $title; + $titleData[] = "\$data['" . $title . "']"; + $titleUpdate[] = Indent::_(4) . "\$data['" . $title . "'] = \$" + . $title . ";"; + } + $fixUnique[] = PHP_EOL . Indent::_(3) . "if (" . implode( + ' || ', $ifStatment + ) . ")"; + $fixUnique[] = Indent::_(3) . "{"; + if ($category !== null && count((array) $titles) == 1) + { + $fixUnique[] = Indent::_(4) . "list(" . implode('', $titleVars) + . ", \$" . $alias . ") = \$this->generateNewTitle(\$data['" + . $category . "'], \$data['" . $alias . "'], " . implode( + '', $titleData + ) . ");"; + } + elseif (count((array) $titles) == 1) + { + $fixUnique[] = Indent::_(4) . "list(" . implode( + ', ', $titleVars + ) + . ", \$" . $alias . ") = \$this->_generateNewTitle(\$data['" + . $alias . "'], " . implode('', $titleData) . ");"; + } + else + { + $fixUnique[] = Indent::_(4) . "list(" . implode( + ', ', $titleVars + ) + . ", \$" . $alias . ") = \$this->_generateNewTitle(\$data['" + . $alias . "'], array(" . implode(', ', $titleData) . "));"; + } + $fixUnique[] = implode("\n", $titleUpdate); + $fixUnique[] = Indent::_(4) . "\$data['" . $alias . "'] = \$" + . $alias . ";"; + $fixUnique[] = Indent::_(3) . "}"; + $fixUnique[] = Indent::_(3) . "else"; + $fixUnique[] = Indent::_(3) . "{"; + $fixUnique[] = Indent::_(4) . "if (\$data['" . $alias + . "'] == \$origTable->" . $alias . ")"; + $fixUnique[] = Indent::_(4) . "{"; + $fixUnique[] = Indent::_(5) . "\$data['" . $alias . "'] = '';"; + $fixUnique[] = Indent::_(4) . "}"; + $fixUnique[] = Indent::_(3) . "}"; + $fixUnique[] = PHP_EOL . Indent::_(3) . "\$data['published'] = 0;"; + $fixUnique[] = Indent::_(2) . "}"; + $fixUnique[] = PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Automatic handling of " . $alias . " for empty fields"; + $fixUnique[] = Indent::_(2) + . "if (in_array(\$input->get('task'), array('apply', 'save', 'save2new')) && (int) \$input->get('id') == 0)"; + $fixUnique[] = Indent::_(2) . "{"; + $fixUnique[] = Indent::_(3) . "if (\$data['" . $alias + . "'] == null || empty(\$data['" . $alias . "']))"; + $fixUnique[] = Indent::_(3) . "{"; + $fixUnique[] = Indent::_(4) + . "if (Factory::getConfig()->get('unicodeslugs') == 1)"; + $fixUnique[] = Indent::_(4) . "{"; + $fixUnique[] = Indent::_(5) . "\$data['" . $alias + . "'] = OutputFilter::stringURLUnicodeSlug(" . implode( + ' . " " . ', $titleData + ) . ");"; + $fixUnique[] = Indent::_(4) . "}"; + $fixUnique[] = Indent::_(4) . "else"; + $fixUnique[] = Indent::_(4) . "{"; + $fixUnique[] = Indent::_(5) . "\$data['" . $alias + . "'] = OutputFilter::stringURLSafe(" . implode( + ' . " " . ', $titleData + ) . ");"; + $fixUnique[] = Indent::_(4) . "}"; + $fixUnique[] = PHP_EOL . Indent::_(4) + . "\$table = clone \$this->getTable();"; + if ($category !== null && count($titles) == 1) + { + $fixUnique[] = PHP_EOL . Indent::_(4) + . "if (\$table->load(['" . $alias . "' => \$data['" + . $alias . "'], '" . $category . "' => \$data['" . $category + . "']]) && (\$table->id != \$data['id'] || \$data['id'] == 0))"; + $fixUnique[] = Indent::_(4) . "{"; + $fixUnique[] = Indent::_(5) . "\$msg = Text:" . ":_('COM_" + . CFactory::_('Compiler.Builder.Content.One')->get('COMPONENT') . "_" . $VIEW . "_SAVE_WARNING');"; + $fixUnique[] = Indent::_(4) . "}"; + $fixUnique[] = PHP_EOL . Indent::_(4) . "list(" . implode( + '', $titleVars + ) . ", \$" . $alias + . ") = \$this->generateNewTitle(\$data['" . $category + . "'], \$data['" . $alias . "'], " . implode('', $titleData) + . ");"; + $fixUnique[] = Indent::_(4) . "\$data['" . $alias . "'] = \$" + . $alias . ";"; + } + else + { + $fixUnique[] = PHP_EOL . Indent::_(4) + . "if (\$table->load(array('" . $alias . "' => \$data['" + . $alias + . "'])) && (\$table->id != \$data['id'] || \$data['id'] == 0))"; + $fixUnique[] = Indent::_(4) . "{"; + $fixUnique[] = Indent::_(5) . "\$msg = Text:" . ":_('COM_" + . CFactory::_('Compiler.Builder.Content.One')->get('COMPONENT') . "_" . $VIEW . "_SAVE_WARNING');"; + $fixUnique[] = Indent::_(4) . "}"; + $fixUnique[] = PHP_EOL . Indent::_(4) . "\$data['" . $alias + . "'] = \$this->_generateNewTitle(\$data['" . $alias + . "']);"; + } + $fixUnique[] = PHP_EOL . Indent::_(4) . "if (isset(\$msg))"; + $fixUnique[] = Indent::_(4) . "{"; + $fixUnique[] = Indent::_(5) + . "Factory::getApplication()->enqueueMessage(\$msg, 'warning');"; + $fixUnique[] = Indent::_(4) . "}"; + $fixUnique[] = Indent::_(3) . "}"; + $fixUnique[] = Indent::_(2) . "}"; + +// $fixUnique[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Update alias if still empty at this point"; +// $fixUnique[] = Indent::_(2) . "if (\$data['" . $alias . "'] == null || empty(\$data['" . $alias . "']))"; +// $fixUnique[] = Indent::_(2) . "{"; +// $fixUnique[] = Indent::_(3) . "if (Factory::getConfig()->get('unicodeslugs') == 1)"; +// $fixUnique[] = Indent::_(3) . "{"; +// $fixUnique[] = Indent::_(4) . "\$data['" . $alias . "'] = OutputFilter::stringURLUnicodeSlug(" . implode(' . " " . ', $titleData) . ");"; +// $fixUnique[] = Indent::_(3) . "}"; +// $fixUnique[] = Indent::_(3) . "else"; +// $fixUnique[] = Indent::_(3) . "{"; +// $fixUnique[] = Indent::_(4) . "\$data['" . $alias . "'] = OutputFilter::stringURLSafe(" . implode(' . " " . ', $titleData) . ");"; +// $fixUnique[] = Indent::_(3) . "}"; +// $fixUnique[] = Indent::_(2) . "}"; + } + // handel other unique fields + $fixUnique[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Alter the unique field for save as copy"; + $fixUnique[] = Indent::_(2) + . "if (\$input->get('task') === 'save2copy')"; + $fixUnique[] = Indent::_(2) . "{"; + $fixUnique[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Automatic handling of other unique fields"; + $fixUnique[] = Indent::_(3) + . "\$uniqueFields = \$this->getUniqueFields();"; + $fixUnique[] = Indent::_(3) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$uniqueFields))"; + $fixUnique[] = Indent::_(3) . "{"; + $fixUnique[] = Indent::_(4) + . "foreach (\$uniqueFields as \$uniqueField)"; + $fixUnique[] = Indent::_(4) . "{"; + $fixUnique[] = Indent::_(5) + . "\$data[\$uniqueField] = \$this->generateUnique(\$uniqueField,\$data[\$uniqueField]);"; + $fixUnique[] = Indent::_(4) . "}"; + $fixUnique[] = Indent::_(3) . "}"; + $fixUnique[] = Indent::_(2) . "}"; + + return PHP_EOL . implode(PHP_EOL, $fixUnique); + } + + public function setGenerateNewTitle($nameSingleCode) + { + // if category is added to this view then do nothing + if (CFactory::_('Compiler.Builder.Alias')->exists($nameSingleCode) + && (CFactory::_('Compiler.Builder.Title')->exists($nameSingleCode) + || CFactory::_('Compiler.Builder.Custom.Alias')->exists($nameSingleCode))) + { + // get component name + $Component = CFactory::_('Compiler.Builder.Content.One')->get('Component'); + // rest the new function + $newFunction = []; + $newFunction[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $newFunction[] = Indent::_(1) + . " * Method to change the title/s & alias."; + $newFunction[] = Indent::_(1) . " *"; + $newFunction[] = Indent::_(1) + . " * @param string \$alias The alias."; + $newFunction[] = Indent::_(1) + . " * @param string/array \$title The title."; + $newFunction[] = Indent::_(1) . " *"; + $newFunction[] = Indent::_(1) + . " * @return array/string Contains the modified title/s and/or alias."; + $newFunction[] = Indent::_(1) . " *"; + $newFunction[] = Indent::_(1) . " */"; + $newFunction[] = Indent::_(1) + . "protected function _generateNewTitle(\$alias, \$title = null)"; + $newFunction[] = Indent::_(1) . "{"; + $newFunction[] = PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Alter the title/s & alias"; + $newFunction[] = Indent::_(2) . "\$table = \$this->getTable();"; + $newFunction[] = PHP_EOL . Indent::_(2) + . "while (\$table->load(['alias' => \$alias]))"; + $newFunction[] = Indent::_(2) . "{"; + $newFunction[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Check if this is an array of titles"; + $newFunction[] = Indent::_(3) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$title))"; + $newFunction[] = Indent::_(3) . "{"; + $newFunction[] = Indent::_(4) + . "foreach(\$title as \$nr => &\$_title)"; + $newFunction[] = Indent::_(4) . "{"; + $newFunction[] = Indent::_(5) + . "\$_title = StringHelper::increment(\$_title);"; + $newFunction[] = Indent::_(4) . "}"; + $newFunction[] = Indent::_(3) . "}"; + $newFunction[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Make sure we have a title"; + $newFunction[] = Indent::_(3) . "elseif (\$title)"; + $newFunction[] = Indent::_(3) . "{"; + $newFunction[] = Indent::_(4) + . "\$title = StringHelper::increment(\$title);"; + $newFunction[] = Indent::_(3) . "}"; + $newFunction[] = Indent::_(3) + . "\$alias = StringHelper::increment(\$alias, 'dash');"; + $newFunction[] = Indent::_(2) . "}"; + $newFunction[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Check if this is an array of titles"; + $newFunction[] = Indent::_(2) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$title))"; + $newFunction[] = Indent::_(2) . "{"; + $newFunction[] = Indent::_(3) . "\$title[] = \$alias;"; + $newFunction[] = Indent::_(3) . "return \$title;"; + $newFunction[] = Indent::_(2) . "}"; + $newFunction[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Make sure we have a title"; + $newFunction[] = Indent::_(2) . "elseif (\$title)"; + $newFunction[] = Indent::_(2) . "{"; + $newFunction[] = Indent::_(3) . "return array(\$title, \$alias);"; + $newFunction[] = Indent::_(2) . "}"; + $newFunction[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " We only had an alias"; + $newFunction[] = Indent::_(2) . "return \$alias;"; + $newFunction[] = Indent::_(1) . "}"; + + return implode(PHP_EOL, $newFunction); + } + elseif (CFactory::_('Compiler.Builder.Title')->exists($nameSingleCode)) + { + $newFunction = []; + $newFunction[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $newFunction[] = Indent::_(1) . " * Method to change the title"; + $newFunction[] = Indent::_(1) . " *"; + $newFunction[] = Indent::_(1) + . " * @param string \$title The title."; + $newFunction[] = Indent::_(1) . " *"; + $newFunction[] = Indent::_(1) + . " * @return array Contains the modified title and alias."; + $newFunction[] = Indent::_(1) . " *"; + $newFunction[] = Indent::_(1) . " */"; + $newFunction[] = Indent::_(1) + . "protected function _generateNewTitle(\$title)"; + $newFunction[] = Indent::_(1) . "{"; + $newFunction[] = PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Alter the title"; + $newFunction[] = Indent::_(2) . "\$table = \$this->getTable();"; + $newFunction[] = PHP_EOL . Indent::_(2) + . "while (\$table->load(['title' => \$title]))"; + $newFunction[] = Indent::_(2) . "{"; + $newFunction[] = Indent::_(3) + . "\$title = StringHelper::increment(\$title);"; + $newFunction[] = Indent::_(2) . "}"; + $newFunction[] = PHP_EOL . Indent::_(2) . "return \$title;"; + $newFunction[] = Indent::_(1) . "}"; + + return implode(PHP_EOL, $newFunction); + } + + return ''; + } + + public function setGenerateNewAlias($nameSingleCode) + { + // make sure this view has an alias + if (CFactory::_('Compiler.Builder.Alias')->exists($nameSingleCode)) + { + // set the title stuff + if (($customAliasBuilder = CFactory::_('Compiler.Builder.Custom.Alias')->get($nameSingleCode)) !== null) + { + $titles = array_values( + $customAliasBuilder + ); + } + elseif (CFactory::_('Compiler.Builder.Title')->exists($nameSingleCode)) + { + $titles = [CFactory::_('Compiler.Builder.Title')->get($nameSingleCode)]; + } + // reset the bucket + $titleData = []; + // load the dynamic title builder + if (isset($titles) && ArrayHelper::check($titles)) + { + foreach ($titles as $title) + { + $titleData[] = "\$this->" . $title; + } + } + else + { + $titleData + = array("'-'"); // just encase some mad man does not set a title/customAlias (we fall back on the date) + } + // rest the new function + $newFunction = []; + $newFunction[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $newFunction[] = Indent::_(1) + . " * Generate a valid alias from title / date."; + $newFunction[] = Indent::_(1) + . " * Remains public to be able to check for duplicated alias before saving"; + $newFunction[] = Indent::_(1) . " *"; + $newFunction[] = Indent::_(1) . " * @return string"; + $newFunction[] = Indent::_(1) . " */"; + $newFunction[] = Indent::_(1) . "public function generateAlias()"; + $newFunction[] = Indent::_(1) . "{"; + $newFunction[] = Indent::_(2) . "if (empty(\$this->alias))"; + $newFunction[] = Indent::_(2) . "{"; + $newFunction[] = Indent::_(3) . "\$this->alias = " . implode( + ".' '.", $titleData + ) . ';'; + $newFunction[] = Indent::_(2) . "}"; + $newFunction[] = PHP_EOL . Indent::_(2) + . "\$this->alias = ApplicationHelper::stringURLSafe(\$this->alias);"; + $newFunction[] = PHP_EOL . Indent::_(2) + . "if (trim(str_replace('-', '', \$this->alias)) == '')"; + $newFunction[] = Indent::_(2) . "{"; + $newFunction[] = Indent::_(3) + . "\$this->alias = Factory::getDate()->format('Y-m-d-H-i-s');"; + $newFunction[] = Indent::_(2) . "}"; + $newFunction[] = PHP_EOL . Indent::_(2) . "return \$this->alias;"; + $newFunction[] = Indent::_(1) . "}"; + + return implode(PHP_EOL, $newFunction); + } + // rest the new function + $newFunction = []; + $newFunction[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $newFunction[] = Indent::_(1) + . " * This view does not actually have an alias"; + $newFunction[] = Indent::_(1) . " *"; + $newFunction[] = Indent::_(1) . " * @return bool"; + $newFunction[] = Indent::_(1) . " */"; + $newFunction[] = Indent::_(1) . "public function generateAlias()"; + $newFunction[] = Indent::_(1) . "{"; + $newFunction[] = Indent::_(2) . "return false;"; + $newFunction[] = Indent::_(1) . "}"; + + return implode(PHP_EOL, $newFunction); + } + + public function setInstall() + { + if (($database_tables = CFactory::_('Compiler.Builder.Database.Tables')->allActive()) !== []) + { + // set the main db prefix + $component = CFactory::_('Config')->component_code_name; + // start building the db + $db = ''; + if (CFactory::_('Config')->get('joomla_version', 3) != 3) + { + $db .= 'SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";' . PHP_EOL; + $db .= 'SET time_zone = "+00:00";' . PHP_EOL . PHP_EOL;; + } + + foreach ($database_tables as $view => $fields) + { + // cast the object to an array TODO we must update all to use the object + $fields = (array) $fields; + // build the uninstallation array + CFactory::_('Compiler.Builder.Database.Uninstall')->add('table', "DROP TABLE IF EXISTS `#__" + . $component . "_" . $view . "`;"); + + // setup the table DB string + $db_ = ''; + $db_ .= "CREATE TABLE IF NOT EXISTS `#__" . $component . "_" + . $view . "` ("; + // check if the table name has changed + if (($old_table_name = CFactory::_('Registry')-> + get('builder.update_sql.table_name.' . $view . '.old', null)) !== null) + { + $key_ = "RENAMETABLE`#__" . $component . "_" . $old_table_name . "`"; + $value_ = "RENAME TABLE `#__" . $component . "_" . $old_table_name . "` to `#__" + . $component . "_" . $view . "`;"; + + CFactory::_('Compiler.Builder.Update.Mysql')->set($key_, $value_); + } + // check if default field was overwritten + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.id')) + { + $db_ .= PHP_EOL . Indent::_(1) + . "`id` INT(11) NOT NULL AUTO_INCREMENT,"; + } + $db_ .= PHP_EOL . Indent::_(1) + . "`asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.',"; + ksort($fields); + $last_name = 'asset_id'; + foreach ($fields as $field => $data) + { + // cast the object to an array TODO we must update all to use the object + $data = (array) $data; + // set default + $default = $data['default']; + if ($default === 'Other') + { + $default = $data['other']; + } + // to get just null value add EMPTY to other value. + if ($default === 'EMPTY') + { + $default = $data['null_switch']; + } + elseif ($default === 'DATETIME' + || $default === 'CURRENT_TIMESTAMP') + { + $default = $data['null_switch'] . ' DEFAULT ' + . $default; + } + elseif (is_numeric($default)) + { + $default = $data['null_switch'] . " DEFAULT " + . $default; + } + else + { + $default = $data['null_switch'] . " DEFAULT '" + . $default . "'"; + } + + // set the length (lenght) <-- TYPO :: LVDM :: DON'T TOUCH + $length = ''; + if (isset($data['lenght']) && $data['lenght'] === 'Other' + && isset($data['lenght_other']) + && $data['lenght_other'] > 0) + { + $length = '(' . $data['lenght_other'] . ')'; + } + elseif (isset($data['lenght']) && $data['lenght'] > 0) + { + $length = '(' . $data['lenght'] . ')'; + } + // set the field to db + $db_ .= PHP_EOL . Indent::_(1) . "`" . $field . "` " + . $data['type'] . $length . " " . $default . ","; + // check if this a new field that should be added via SQL update + if (CFactory::_('Registry')-> + get('builder.add_sql.field.' . $view . '.' . $data['ID'], null)) + { + // to soon.... + // $key_ = "ALTERTABLE`#__" . $component . "_" . $view . "`ADDCOLUMNIFNOTEXISTS`" . $field . "`"; + // $value_ = "ALTER TABLE `#__" . $component . "_" . $view . "` ADD COLUMN IF NOT EXISTS `" . $field . "` " . $data['type'] + // . length . " " . $default . " AFTER `" . $last_name . "`;"; + $key_ = "ALTERTABLE`#__" . $component . "_" . $view . "`ADD`" . $field . "`"; + $value_ = "ALTER TABLE `#__" . $component . "_" . $view . "` ADD `" . $field . "` " . $data['type'] + . $length . " " . $default . " AFTER `" . $last_name . "`;"; + + CFactory::_('Compiler.Builder.Update.Mysql')->set($key_, $value_); + } + // check if the field has changed name and/or data type and lenght + elseif (CFactory::_('Registry')-> + get('builder.update_sql.field.datatype.' . $view . '.' . $field, null) + || CFactory::_('Registry')-> + get('builder.update_sql.field.lenght.' . $view . '.' . $field, null) + || CFactory::_('Registry')-> + get('builder.update_sql.field.name.' . $view . '.' . $field, null)) + { + // if the name changed + if (($oldName = CFactory::_('Registry')-> + get('builder.update_sql.field.name.' . $view . '.' . $field . '.old', null)) === null) + { + $oldName = $field; + } + + // now set the update SQL + $key_ = "ALTERTABLE`#__" . $component . "_" . $view . "`CHANGE`" . $oldName . "``" + . $field . "`"; + $value_ = "ALTER TABLE `#__" . $component . "_" . $view . "` CHANGE `" . $oldName . "` `" + . $field . "` " . $data['type'] . $length . " " . $default . ";"; + + CFactory::_('Compiler.Builder.Update.Mysql')->set($key_, $value_); + } + // be sure to track the last name used :) + $last_name = $field; + } + // check if default field was overwritten + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.params')) + { + $db_ .= PHP_EOL . Indent::_(1) . "`params` text NULL,"; + } + // check if default field was overwritten + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.published')) + { + $db_ .= PHP_EOL . Indent::_(1) + . "`published` TINYINT(3) NOT NULL DEFAULT 1,"; + } + // check if default field was overwritten + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.created_by')) + { + $db_ .= PHP_EOL . Indent::_(1) + . "`created_by` INT(10) unsigned NOT NULL DEFAULT 0,"; + } + // check if default field was overwritten + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.modified_by')) + { + $db_ .= PHP_EOL . Indent::_(1) + . "`modified_by` INT(10) unsigned NOT NULL DEFAULT 0,"; + } + // check if default field was overwritten + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.created')) + { + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $db_ .= PHP_EOL . Indent::_(1) + . "`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',"; + } + else + { + $db_ .= PHP_EOL . Indent::_(1) + . "`created` DATETIME DEFAULT CURRENT_TIMESTAMP,"; + } + } + // check if default field was overwritten + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.modified')) + { + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $db_ .= PHP_EOL . Indent::_(1) + . "`modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',"; + } + else + { + $db_ .= PHP_EOL . Indent::_(1) + . "`modified` DATETIME DEFAULT NULL,"; + } + } + // check if default field was overwritten + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.checked_out')) + { + $db_ .= PHP_EOL . Indent::_(1) + . "`checked_out` int(11) unsigned NOT NULL DEFAULT 0,"; + } + // check if default field was overwritten + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.checked_out_time')) + { + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $db_ .= PHP_EOL . Indent::_(1) + . "`checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',"; + } + else + { + $db_ .= PHP_EOL . Indent::_(1) + . "`checked_out_time` DATETIME DEFAULT NULL,"; + } + } + // check if default field was overwritten + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.version')) + { + $db_ .= PHP_EOL . Indent::_(1) + . "`version` INT(10) unsigned NOT NULL DEFAULT 1,"; + } + // check if default field was overwritten + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.hits')) + { + $db_ .= PHP_EOL . Indent::_(1) + . "`hits` INT(10) unsigned NOT NULL DEFAULT 0,"; + } + // check if view has access + if (CFactory::_('Compiler.Builder.Access.Switch')->exists($view) + && !CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.access')) + { + $db_ .= PHP_EOL . Indent::_(1) + . "`access` INT(10) unsigned NOT NULL DEFAULT 0,"; + } + // check if default field was overwritten + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.ordering')) + { + $db_ .= PHP_EOL . Indent::_(1) + . "`ordering` INT(11) NOT NULL DEFAULT 0,"; + } + // check if metadata is added to this view + if (CFactory::_('Compiler.Builder.Meta.Data')->isString($view)) + { + // check if default field was overwritten + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.metakey')) + { + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $db_ .= PHP_EOL . Indent::_(1) + . "`metakey` TEXT NOT NULL,"; + } + else + { + $db_ .= PHP_EOL . Indent::_(1) + . "`metakey` TEXT,"; + } + } + // check if default field was overwritten + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.metadesc')) + { + $db_ .= PHP_EOL . Indent::_(1) + . "`metadesc` TEXT NOT NULL,"; + } + // check if default field was overwritten + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.metadata')) + { + $db_ .= PHP_EOL . Indent::_(1) + . "`metadata` TEXT NOT NULL,"; + } + } + // TODO (we may want this to be dynamicly set) + $db_ .= PHP_EOL . Indent::_(1) . "PRIMARY KEY (`id`)"; + // check if a key was set for any of the default fields then we should not set it again + $check_keys_set = []; + if (CFactory::_('Compiler.Builder.Database.Unique.Keys')->exists($view)) + { + foreach (CFactory::_('Compiler.Builder.Database.Unique.Keys')->get($view) as $nr => $key) + { + $db_ .= "," . PHP_EOL . Indent::_(1) + . "UNIQUE KEY `idx_" . $key . "` (`" . $key . "`)"; + $check_keys_set[$key] = $key; + } + } + if (CFactory::_('Compiler.Builder.Database.Keys')->exists($view)) + { + foreach (CFactory::_('Compiler.Builder.Database.Keys')->get($view) as $nr => $key) + { + $db_ .= "," . PHP_EOL . Indent::_(1) + . "KEY `idx_" . $key . "` (`" . $key . "`)"; + $check_keys_set[$key] = $key; + } + } + // check if view has access + if (!isset($check_keys_set['access']) + && CFactory::_('Compiler.Builder.Access.Switch')->exists($view)) + { + $db_ .= "," . PHP_EOL . Indent::_(1) + . "KEY `idx_access` (`access`)"; + } + // check if default field was overwritten + if (!isset($check_keys_set['checked_out'])) + { + $db_ .= "," . PHP_EOL . Indent::_(1) + . "KEY `idx_checkout` (`checked_out`)"; + } + // check if default field was overwritten + if (!isset($check_keys_set['created_by'])) + { + $db_ .= "," . PHP_EOL . Indent::_(1) + . "KEY `idx_createdby` (`created_by`)"; + } + // check if default field was overwritten + if (!isset($check_keys_set['modified_by'])) + { + $db_ .= "," . PHP_EOL . Indent::_(1) + . "KEY `idx_modifiedby` (`modified_by`)"; + } + // check if default field was overwritten + if (!isset($check_keys_set['published'])) + { + $db_ .= "," . PHP_EOL . Indent::_(1) + . "KEY `idx_state` (`published`)"; + } + // easy bucket + $easy = []; + // get the mysql table settings + foreach ( + CFactory::_('Config')->mysql_table_keys as $_mysqlTableKey => $_mysqlTableVal + ) + { + if (($easy[$_mysqlTableKey] = CFactory::_('Compiler.Builder.Mysql.Table.Setting')-> + get($view . '.' . $_mysqlTableKey)) === null) + { + $easy[$_mysqlTableKey] + = CFactory::_('Config')->mysql_table_keys[$_mysqlTableKey]['default']; + } + } + // add a little fix for the row_format + if (StringHelper::check($easy['row_format'])) + { + $easy['row_format'] = ' ROW_FORMAT=' . $easy['row_format']; + } + // now build db string + $db_ .= PHP_EOL . ") ENGINE=" . $easy['engine'] + . " AUTO_INCREMENT=0 DEFAULT CHARSET=" . $easy['charset'] + . " DEFAULT COLLATE=" . $easy['collate'] + . $easy['row_format'] . ";"; + + // check if this is a new table that should be added via update SQL + if (CFactory::_('Registry')-> + get('builder.add_sql.adminview.' . $view, null)) + { + // build the update array + $key_ = "CREATETABLEIFNOTEXISTS`#__" . $component . "_" . $view . "`"; + CFactory::_('Compiler.Builder.Update.Mysql')->set($key_, $db_); + } + // check if the table row_format has changed + if (StringHelper::check($easy['row_format']) + && CFactory::_('Registry')-> + get('builder.update_sql.table_row_format.' . $view, null)) + { + // build the update array + $key_ = "ALTERTABLE`#__" . $component . "_" . $view . "`" . trim((string) $easy['row_format']); + $value_ = "ALTER TABLE `#__" . $component . "_" . $view . "`" . $easy['row_format'] . ";"; + CFactory::_('Compiler.Builder.Update.Mysql')->set($key_, $value_); + } + // check if the table engine has changed + if (CFactory::_('Registry')-> + get('builder.update_sql.table_engine.' . $view, null)) + { + // build the update array + $key_ = "ALTERTABLE`#__" . $component . "_" . $view . "`ENGINE=" . $easy['engine']; + $value_ = "ALTER TABLE `#__" . $component . "_" . $view . "` ENGINE = " . $easy['engine'] . ";"; + CFactory::_('Compiler.Builder.Update.Mysql')->set($key_, $value_); + } + // check if the table charset OR collation has changed (must be updated together) + if (CFactory::_('Registry')-> + get('builder.update_sql.table_charset.' . $view, null) + || CFactory::_('Registry')-> + get('builder.update_sql.table_collate.' . $view, null)) + { + // build the update array + $key_ = "ALTERTABLE`#__" . $component . "_" . $view . "CONVERTTOCHARACTERSET" + . $easy['charset'] . "COLLATE" . $easy['collate']; + $value_ = "ALTER TABLE `#__" . $component . "_" . $view . "` CONVERT TO CHARACTER SET " + . $easy['charset'] . " COLLATE " . $easy['collate'] . ";"; + + CFactory::_('Compiler.Builder.Update.Mysql')->set($key_, $value_); + } + + // add to main DB string + $db .= $db_ . PHP_EOL . PHP_EOL; + } + // add custom sql dump to the file + if (isset(CFactory::_('Customcode.Dispenser')->hub['sql']) + && ArrayHelper::check( + CFactory::_('Customcode.Dispenser')->hub['sql'] + )) + { + foreach ( + CFactory::_('Customcode.Dispenser')->hub['sql'] as $for => $customSql + ) + { + $placeholders = array(Placefix::_('component') => $component, + Placefix::_('view') => $for); + $db .= CFactory::_('Placeholder')->update( + $customSql, $placeholders + ) . PHP_EOL . PHP_EOL; + } + unset(CFactory::_('Customcode.Dispenser')->hub['sql']); + } + + // WHY DO WE NEED AN ASSET TABLE FIX? + // https://www.mysqltutorial.org/mysql-varchar/ + // https://stackoverflow.com/a/15227917/1429677 + // https://forums.mysql.com/read.php?24,105964,105964 + // https://github.com/vdm-io/Joomla-Component-Builder/issues/616#issuecomment-741502980 + // 30 actions each +-20 characters with 8 groups + // that makes 4800 characters and the current Joomla + // column size is varchar(5120) + + // just a little event tracking in classes + // count actions = setAccessSections + // around line206 (infusion call) + // around line26454 (interpretation function) + // first fix = setInstall + // around line1600 (infusion call) + // around line10063 (interpretation function) + // second fix = setUninstallScript + // around line2161 (infusion call) + // around line8030 (interpretation function) + + // check if this component needs larger rules + // also check if the developer will allow this + // the access actions length must be checked before this + // only add this option if set to SQL fix + if (CFactory::_('Config')->add_assets_table_fix == 1) + { + // 400 actions worse case is larger the 65535 characters + if (CFactory::_('Utilities.Counter')->accessSize > 400) + { + $db .= PHP_EOL; + $db .= PHP_EOL . '--'; + $db .= PHP_EOL + . '--' . Line::_( + __LINE__,__CLASS__ + ) + . ' Always insure this column rules is large enough for all the access control values.'; + $db .= PHP_EOL . '--'; + $db .= PHP_EOL + . "ALTER TABLE `#__assets` CHANGE `rules` `rules` MEDIUMTEXT NOT NULL COMMENT 'JSON encoded access control. Enlarged to MEDIUMTEXT by JCB';"; + } + // smaller then 400 makes TEXT large enough + elseif (CFactory::_('Config')->add_assets_table_fix == 1) + { + $db .= PHP_EOL; + $db .= PHP_EOL . '--'; + $db .= PHP_EOL + . '--' . Line::_( + __LINE__,__CLASS__ + ) + . ' Always insure this column rules is large enough for all the access control values.'; + $db .= PHP_EOL . '--'; + $db .= PHP_EOL + . "ALTER TABLE `#__assets` CHANGE `rules` `rules` TEXT NOT NULL COMMENT 'JSON encoded access control. Enlarged to TEXT by JCB';"; + } + } + + // check if this component needs larger names + // also check if the developer will allow this + // the config length must be checked before this + // only add this option if set to SQL fix + if (CFactory::_('Config')->add_assets_table_fix && CFactory::_('Config')->add_assets_table_name_fix) + { + $db .= PHP_EOL; + $db .= PHP_EOL . '--'; + $db .= PHP_EOL + . '--' . Line::_( + __LINE__,__CLASS__ + ) + . ' Always insure this column name is large enough for long component and view names.'; + $db .= PHP_EOL . '--'; + $db .= PHP_EOL + . "ALTER TABLE `#__assets` CHANGE `name` `name` VARCHAR(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'The unique name for the asset.';"; + } + + return $db; + } + + return ''; + } + + public function setUninstall() + { + $db = ''; + if (CFactory::_('Compiler.Builder.Database.Uninstall')->isArray('table')) + { + $db .= implode(PHP_EOL, CFactory::_('Compiler.Builder.Database.Uninstall')->get('table')) . PHP_EOL; + } + // add custom sql uninstall dump to the file + if (isset(CFactory::_('Customcode.Dispenser')->hub['sql_uninstall']) + && StringHelper::check( + CFactory::_('Customcode.Dispenser')->hub['sql_uninstall'] + )) + { + $db .= CFactory::_('Placeholder')->update_( + CFactory::_('Customcode.Dispenser')->hub['sql_uninstall'] + ) . PHP_EOL; + unset(CFactory::_('Customcode.Dispenser')->hub['sql_uninstall']); + } + + // check if this component used larger rules + // now revert them back on uninstall + // only add this option if set to SQL fix + if (CFactory::_('Config')->add_assets_table_fix == 1) + { + // https://github.com/joomla/joomla-cms/blob/3.10.0-alpha3/installation/sql/mysql/joomla.sql#L22 + // Checked 1st December 2020 (let us know if this changes) + $db .= PHP_EOL; + $db .= PHP_EOL . '--'; + $db .= PHP_EOL + . '--' . Line::_( + __LINE__,__CLASS__ + ) + . ' Always insure this column rules is reversed to Joomla defaults on uninstall. (as on 1st Dec 2020)'; + $db .= PHP_EOL . '--'; + $db .= PHP_EOL + . "ALTER TABLE `#__assets` CHANGE `rules` `rules` varchar(5120) NOT NULL COMMENT 'JSON encoded access control.';"; + } + + // check if this component used larger names + // now revert them back on uninstall + // only add this option if set to SQL fix + if (CFactory::_('Config')->add_assets_table_fix == 1 && CFactory::_('Config')->add_assets_table_name_fix) + { + // https://github.com/joomla/joomla-cms/blob/3.10.0-alpha3/installation/sql/mysql/joomla.sql#L20 + // Checked 1st December 2020 (let us know if this changes) + $db .= PHP_EOL; + $db .= PHP_EOL . '--'; + $db .= PHP_EOL + . '--' . Line::_( + __LINE__,__CLASS__ + ) + . ' Always insure this column name is reversed to Joomla defaults on uninstall. (as on 1st Dec 2020).'; + $db .= PHP_EOL . '--'; + $db .= PHP_EOL + . "ALTER TABLE `#__assets` CHANGE `name` `name` VARCHAR(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'The unique name for the asset.';"; + } + + return $db; + } + + public function setLangAdmin(string $componentName): bool + { + // Trigger Event: jcb_ce_onBeforeBuildAdminLang + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeBuildAdminLang' + ); + + // start loading the defaults + CFactory::_('Language')->set('adminsys', CFactory::_('Config')->lang_prefix, $componentName); + CFactory::_('Language')->set( + 'adminsys', CFactory::_('Config')->lang_prefix . '_CONFIGURATION', + $componentName . ' Configuration' + ); + CFactory::_('Language')->set('admin', CFactory::_('Config')->lang_prefix, $componentName); + CFactory::_('Language')->set('admin', CFactory::_('Config')->lang_prefix . '_BACK', 'Back'); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_DASH', 'Dashboard' + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_VERSION', 'Version' + ); + CFactory::_('Language')->set('admin', CFactory::_('Config')->lang_prefix . '_DATE', 'Date'); + CFactory::_('Language')->set('admin', CFactory::_('Config')->lang_prefix . '_AUTHOR', 'Author'); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_WEBSITE', 'Website' + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_LICENSE', 'License' + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_CONTRIBUTORS', 'Contributors' + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_CONTRIBUTOR', 'Contributor' + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_DASHBOARD', + $componentName . ' Dashboard' + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_SAVE_SUCCESS', + "Great! Item successfully saved." + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_SAVE_WARNING', + "The value already existed so please select another." + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_HELP_MANAGER', "Help" + ); + CFactory::_('Language')->set('admin', CFactory::_('Config')->lang_prefix . '_NEW', "New"); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_CLOSE_NEW', "Close & New" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_CREATE_NEW_S', "Create New %s" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_EDIT_S', "Edit %s" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_KEEP_ORIGINAL_STATE', + "- Keep Original State -" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_KEEP_ORIGINAL_ACCESS', + "- Keep Original Access -" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_KEEP_ORIGINAL_CATEGORY', + "- Keep Original Category -" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_PUBLISHED', 'Published' + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_INACTIVE', 'Inactive' + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_ARCHIVED', 'Archived' + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_TRASHED', 'Trashed' + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_NO_ACCESS_GRANTED', + "No Access Granted!" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_NOT_FOUND_OR_ACCESS_DENIED', + "Not found or access denied!" + ); + + if (CFactory::_('Component')->get('add_license') + && CFactory::_('Component')->get('license_type') == 3) + { + CFactory::_('Language')->set( + 'admin', 'NIE_REG_NIE', + "

    License not set for " . $componentName + . ".

    Notify your administrator!
    The license can be obtained from get('whmcs_buy_link') . "' target='_blank'>" + . CFactory::_('Component')->get('companyname') . ".

    " + ); + } + + // add the langug files needed to import and export data + if (CFactory::_('Config')->get('add_eximport', false)) + { + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_EXPORT_FAILED', "Export Failed" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_FAILED', "Import Failed" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_TITLE', "Data Importer" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_NO_IMPORT_TYPE_FOUND', + "Import type not found." + ); + CFactory::_('Language')->set( + 'admin', + CFactory::_('Config')->lang_prefix . '_IMPORT_UNABLE_TO_FIND_IMPORT_PACKAGE', + "Package to import not found." + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_ERROR', "Import error." + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_SUCCESS', + "Great! Import successful." + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_MSG_WARNIMPORTFILE', + "Warning, import file error." + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_MSG_NO_FILE_SELECTED', + "No import file selected." + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_MSG_PLEASE_SELECT_A_FILE', + "Please select a file to import." + ); + CFactory::_('Language')->set( + 'admin', + CFactory::_('Config')->lang_prefix . '_IMPORT_MSG_PLEASE_SELECT_ALL_COLUMNS', + "Please link all columns." + ); + CFactory::_('Language')->set( + 'admin', + CFactory::_('Config')->lang_prefix . '_IMPORT_MSG_PLEASE_SELECT_A_DIRECTORY', + "Please enter the file directory." + ); + CFactory::_('Language')->set( + 'admin', + CFactory::_('Config')->lang_prefix . '_IMPORT_MSG_WARNIMPORTUPLOADERROR', + "Warning, import upload error." + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix + . '_IMPORT_MSG_PLEASE_ENTER_A_PACKAGE_DIRECTORY', + "Please enter the file directory." + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix + . '_IMPORT_MSG_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE', + "Path does not have a valid file." + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix + . '_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE', + "Does not have a valid file type." + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_MSG_ENTER_A_URL', + "Please enter a url." + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_MSG_INVALID_URL', + "Invalid url." + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_CONTINUE', "Continue" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_FROM_UPLOAD', "Upload" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_SELECT_FILE', + "Select File" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_UPLOAD_BOTTON', + "Upload File" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_FROM_DIRECTORY', + "Directory" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_SELECT_FILE_DIRECTORY', + "Set the path to file" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_GET_BOTTON', "Get File" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_FROM_URL', "URL" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_SELECT_FILE_URL', + "Enter file URL" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_UPDATE_DATA', + "Import Data" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_FORMATS_ACCEPTED', + "formats accepted" + ); + CFactory::_('Language')->set( + 'admin', + CFactory::_('Config')->lang_prefix . '_IMPORT_LINK_FILE_TO_TABLE_COLUMNS', + "Link File to Table Columns" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_TABLE_COLUMNS', + "Table Columns" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_FILE_COLUMNS', + "File Columns" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_PLEASE_SELECT_COLUMN', + "-- Please Select Column --" + ); + CFactory::_('Language')->set( + 'admin', CFactory::_('Config')->lang_prefix . '_IMPORT_IGNORE_COLUMN', + "-- Ignore This Column --" + ); + } + + // check if the both array is set + if (CFactory::_('Language')->exist('both')) + { + foreach (CFactory::_('Language')->getTarget('both') as $keylang => $langval) + { + CFactory::_('Language')->set('admin', $keylang, $langval); + } + } + + // check if the both admin array is set + if (CFactory::_('Language')->exist('bothadmin')) + { + foreach (CFactory::_('Language')->getTarget('bothadmin') as $keylang => $langval) + { + CFactory::_('Language')->set('admin', $keylang, $langval); + } + } + + if (CFactory::_('Language')->exist('admin')) + { + // Trigger Event: jcb_ce_onAfterBuildAdminLang + CFactory::_('Event')->trigger( + 'jcb_ce_onAfterBuildAdminLang' + ); + // get language content + $langContent = CFactory::_('Language')->getTarget('admin'); + // sort the strings + ksort($langContent); + // load to global languages + $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['admin'] + = $langContent; + // remove tmp array + CFactory::_('Language')->setTarget('admin', null); + + return true; + } + + return false; + } + + public function setLangSite(string $componentName): bool + { + // Trigger Event: jcb_ce_onBeforeBuildSiteLang + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeBuildSiteLang' + ); + + // add final list of needed lang strings + CFactory::_('Language')->set('site', CFactory::_('Config')->lang_prefix, $componentName); + // some more defaults + CFactory::_('Language')->set('site', 'JTOOLBAR_APPLY', "Save"); + CFactory::_('Language')->set('site', 'JTOOLBAR_SAVE_AS_COPY', "Save as Copy"); + CFactory::_('Language')->set('site', 'JTOOLBAR_SAVE', "Save & Close"); + CFactory::_('Language')->set('site', 'JTOOLBAR_SAVE_AND_NEW', "Save & New"); + CFactory::_('Language')->set('site', 'JTOOLBAR_CANCEL', "Cancel"); + CFactory::_('Language')->set('site', 'JTOOLBAR_CLOSE', "Close"); + CFactory::_('Language')->set('site', 'JTOOLBAR_HELP', "Help"); + CFactory::_('Language')->set('site', 'JGLOBAL_FIELD_ID_LABEL', "ID"); + CFactory::_('Language')->set( + 'site', 'JGLOBAL_FIELD_ID_DESC', "Record number in the database." + ); + CFactory::_('Language')->set( + 'site', 'JGLOBAL_FIELD_MODIFIED_LABEL', "Modified Date" + ); + CFactory::_('Language')->set( + 'site', 'COM_CONTENT_FIELD_MODIFIED_DESC', + "The last date this item was modified." + ); + CFactory::_('Language')->set( + 'site', 'JGLOBAL_FIELD_MODIFIED_BY_LABEL', "Modified By" + ); + CFactory::_('Language')->set( + 'site', 'JGLOBAL_FIELD_MODIFIED_BY_DESC', + "The user who did the last modification." + ); + CFactory::_('Language')->set('site', CFactory::_('Config')->lang_prefix . '_NEW', "New"); + CFactory::_('Language')->set( + 'site', CFactory::_('Config')->lang_prefix . '_CREATE_NEW_S', "Create New %s" + ); + CFactory::_('Language')->set('site', CFactory::_('Config')->lang_prefix . '_EDIT_S', "Edit %s"); + CFactory::_('Language')->set( + 'site', CFactory::_('Config')->lang_prefix . '_NO_ACCESS_GRANTED', + "No Access Granted!" + ); + CFactory::_('Language')->set( + 'site', CFactory::_('Config')->lang_prefix . '_NOT_FOUND_OR_ACCESS_DENIED', + "Not found or access denied!" + ); + + // check if the both array is set + if (CFactory::_('Language')->exist('both')) + { + foreach (CFactory::_('Language')->getTarget('both') as $keylang => $langval) + { + CFactory::_('Language')->set('site', $keylang, $langval); + } + } + + // check if the both site array is set + if (CFactory::_('Language')->exist('bothsite')) + { + foreach (CFactory::_('Language')->getTarget('bothsite') as $keylang => $langval) + { + CFactory::_('Language')->set('site', $keylang, $langval); + } + } + + if (CFactory::_('Language')->exist('site')) + { + // Trigger Event: jcb_ce_onAfterBuildSiteLang + CFactory::_('Event')->trigger( + 'jcb_ce_onAfterBuildSiteLang' + ); + + // Get the site language content + $langContent = CFactory::_('Language')->getTarget('site'); + // sort the strings + ksort($langContent); + // load to global languages + $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['site'] + = $langContent; + // remove tmp array + CFactory::_('Language')->setTarget('site', null); + + return true; + } + + return false; + } + + public function setLangSiteSys(string $componentName): bool + { + // Trigger Event: jcb_ce_onBeforeBuildSiteSysLang + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeBuildSiteSysLang' + ); + + // add final list of needed lang strings + CFactory::_('Language')->set('sitesys', CFactory::_('Config')->lang_prefix, $componentName); + CFactory::_('Language')->set( + 'sitesys', CFactory::_('Config')->lang_prefix . '_NO_ACCESS_GRANTED', + "No Access Granted!" + ); + CFactory::_('Language')->set( + 'sitesys', CFactory::_('Config')->lang_prefix . '_NOT_FOUND_OR_ACCESS_DENIED', + "Not found or access denied!" + ); + + // check if the both site array is set + if (CFactory::_('Language')->exist('bothsite')) + { + foreach (CFactory::_('Language')->getTarget('bothsite') as $keylang => $langval) + { + CFactory::_('Language')->set('sitesys', $keylang, $langval); + } + } + if (CFactory::_('Language')->exist('sitesys')) + { + // Trigger Event: jcb_ce_onAfterBuildSiteSysLang + CFactory::_('Event')->trigger( + 'jcb_ce_onAfterBuildSiteSysLang' + ); + // get site system language content + $langContent = CFactory::_('Language')->getTarget('sitesys'); + // sort strings + ksort($langContent); + // load to global languages + $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['sitesys'] + = $langContent; + // remove tmp array + CFactory::_('Language')->setTarget('sitesys', null); + + return true; + } + + return false; + } + + public function setLangAdminSys(): bool + { + // Trigger Event: jcb_ce_onBeforeBuildAdminSysLang + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeBuildAdminSysLang' + ); + + // check if the both admin array is set + if (CFactory::_('Language')->exist('bothadmin')) + { + foreach (CFactory::_('Language')->getTarget('bothadmin') as $keylang => $langval) + { + CFactory::_('Language')->set('adminsys', $keylang, $langval); + } + } + if (CFactory::_('Language')->exist('adminsys')) + { + // Trigger Event: jcb_ce_onAfterBuildAdminSysLang + CFactory::_('Event')->trigger( + 'jcb_ce_onAfterBuildAdminSysLang' + ); + // get admin system langauge content + $langContent = CFactory::_('Language')->getTarget('adminsys'); + // sort strings + ksort($langContent); + // load to global languages + $this->languages['components'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['adminsys'] + = $langContent; + // remove tmp array + CFactory::_('Language')->setTarget('adminsys', null); + + return true; + } + + return false; + } + + public function setCustomAdminViewListLink($view, $nameListCode) + { + if (CFactory::_('Component')->isArray('custom_admin_views')) + { + foreach (CFactory::_('Component')->get('custom_admin_views') as $custom_admin_view) + { + if (isset($custom_admin_view['adminviews']) + && ArrayHelper::check( + $custom_admin_view['adminviews'] + )) + { + foreach ($custom_admin_view['adminviews'] as $adminview) + { + if (isset($view['adminview']) + && $view['adminview'] == $adminview) + { + // set the needed keys + $setId = false; + if (ArrayHelper::check( + $custom_admin_view['settings']->main_get->filter + )) + { + foreach ( + $custom_admin_view['settings']->main_get->filter + as $filter + ) + { + if ($filter['filter_type'] == 1 + || '$id' == $filter['state_key']) + { + $setId = true; + } + } + } + // set the needed array values + $set = array( + 'icon' => $custom_admin_view['icomoon'], + 'link' => $custom_admin_view['settings']->code, + 'NAME' => $custom_admin_view['settings']->CODE, + 'name' => $custom_admin_view['settings']->name); + // only load to list if it has id filter + if ($setId) + { + // now load it to the global object for items list + $this->customAdminViewListLink[$nameListCode][] + = $set; + // add to set id for list view if needed + $this->customAdminViewListId[$custom_admin_view['settings']->code] + = true; + } + else + { + // now load it to the global object for tool bar + $this->customAdminDynamicButtons[$nameListCode][] + = $set; + } + // log that it has been added already + $this->customAdminAdded[$custom_admin_view['settings']->code] + = $adminview; + } + } + } + } + } + } + + /** + * set the list body + * + * @param string $nameSingleCode + * @param string $nameListCode + * + * @return string + */ + public function setListBody($nameSingleCode, $nameListCode) + { + if (($items = CFactory::_('Compiler.Builder.Lists')->get($nameListCode)) !== null) + { + // component helper name + $Helper = CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper'; + // make sure the custom links are only added once + $firstTimeBeingAdded = true; + // add the default + $body = "items as \$i => \$item): ?>"; + $body .= PHP_EOL . Indent::_(1) . "user->authorise('core.manage', 'com_checkin') || \$item->checked_out == \$this->user->id || \$item->checked_out == 0;"; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $body .= PHP_EOL . Indent::_(2) + . "\$userChkOut = Factory::getUser(\$item->checked_out);"; + } + else + { + $body .= PHP_EOL . Indent::_(2) + . "\$userChkOut = Factory::getContainer()->"; + $body .= PHP_EOL . Indent::_(3) + . "get(\Joomla\CMS\User\UserFactoryInterface::class)->"; + $body .= PHP_EOL . Indent::_(4) + . "loadUserById(\$item->checked_out);"; + } + $body .= PHP_EOL . Indent::_(2) . "\$canDo = " . $Helper + . "::getActions('" . $nameSingleCode . "',\$item,'" + . $nameListCode . "');"; + $body .= PHP_EOL . Indent::_(1) . "?>"; + $body .= PHP_EOL . Indent::_(1) + . ''; + // only load if not overwritten + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.ordering')) + { + $body .= PHP_EOL . Indent::_(2) + . ''; + // check if the item has permissions. + $body .= PHP_EOL . Indent::_(2) . "get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit.state') . "')): ?>"; + $body .= PHP_EOL . Indent::_(3) . "saveOrder)"; + $body .= PHP_EOL . Indent::_(4) . "{"; + $body .= PHP_EOL . Indent::_(5) + . "\$iconClass = ' inactive tip-top" + . '" hasTooltip" title="' + . "' . Html::tooltipText('JORDERINGDISABLED');"; + $body .= PHP_EOL . Indent::_(4) . "}"; + $body .= PHP_EOL . Indent::_(3) . "?>"; + $body .= PHP_EOL . Indent::_(3) + . ''; + $body .= PHP_EOL . Indent::_(4) . ''; + $body .= PHP_EOL . Indent::_(3) . ""; + $body .= PHP_EOL . Indent::_(3) + . "saveOrder) : ?>"; + $body .= PHP_EOL . Indent::_(4) + . ''; + $body .= PHP_EOL . Indent::_(3) . ""; + $body .= PHP_EOL . Indent::_(2) . ""; + $body .= PHP_EOL . Indent::_(3) . "⋮"; + $body .= PHP_EOL . Indent::_(2) . ""; + $body .= PHP_EOL . Indent::_(2) . ""; + } + $body .= PHP_EOL . Indent::_(2) . ''; + // check if the item has permissions. + $body .= PHP_EOL . Indent::_(2) . "get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit') . "')): ?>"; + $body .= PHP_EOL . Indent::_(4) + . "checked_out) : ?>"; + $body .= PHP_EOL . Indent::_(5) . ""; + $body .= PHP_EOL . Indent::_(6) + . "id); ?>"; + $body .= PHP_EOL . Indent::_(5) . ""; + $body .= PHP_EOL . Indent::_(6) . "□"; + $body .= PHP_EOL . Indent::_(5) . ""; + $body .= PHP_EOL . Indent::_(4) . ""; + $body .= PHP_EOL . Indent::_(5) + . "id); ?>"; + $body .= PHP_EOL . Indent::_(4) . ""; + $body .= PHP_EOL . Indent::_(2) . ""; + $body .= PHP_EOL . Indent::_(3) . "□"; + $body .= PHP_EOL . Indent::_(2) . ""; + $body .= PHP_EOL . Indent::_(2) . ""; + // check if this view has fields that should not be escaped + $doNotEscape = false; + if (CFactory::_('Compiler.Builder.Do.Not.Escape')->exists($nameListCode)) + { + $doNotEscape = true; + } + // start adding the dynamic + foreach ($items as $item) + { + // check if target is admin list + if (1 == $item['target'] || 3 == $item['target']) + { + // set some defaults + $customAdminViewButtons = ''; + // set the item default class + $itemClass = 'hidden-phone'; + // set the item row + $itemRow = $this->getListItemBuilder( + $item, $nameSingleCode, $nameListCode, $itemClass, $doNotEscape + ); + // check if buttons was already added + if ($firstTimeBeingAdded) // TODO we must improve this to allow more items to be targeted instead of just the first item :) + { + // get custom admin view buttons + $customAdminViewButtons + = $this->getCustomAdminViewButtons($nameListCode); + // make sure the custom admin view buttons are only added once + $firstTimeBeingAdded = false; + } + // add row to body + $body .= PHP_EOL . Indent::_(2) . "getListFieldClass( + $item['code'], $nameListCode, $itemClass + ) . "\">"; + $body .= $itemRow; + $body .= $customAdminViewButtons; + $body .= PHP_EOL . Indent::_(2) . ""; + } + } + // add the defaults + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.published')) + { + $body .= PHP_EOL . Indent::_(2) . ''; + // check if the item has permissions. + $body .= PHP_EOL . Indent::_(2) . "get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit.state') . "')) : ?>"; + $body .= PHP_EOL . Indent::_(4) + . "checked_out) : ?>"; + $body .= PHP_EOL . Indent::_(5) + . ""; + $body .= PHP_EOL . Indent::_(6) + . "published, \$i, '" + . $nameListCode . ".', true, 'cb'); ?>"; + $body .= PHP_EOL . Indent::_(5) . ""; + $body .= PHP_EOL . Indent::_(6) + . "published, \$i, '" + . $nameListCode . ".', false, 'cb'); ?>"; + $body .= PHP_EOL . Indent::_(5) . ""; + $body .= PHP_EOL . Indent::_(4) . ""; + $body .= PHP_EOL . Indent::_(5) + . "published, \$i, '" + . $nameListCode . ".', true, 'cb'); ?>"; + $body .= PHP_EOL . Indent::_(4) . ""; + $body .= PHP_EOL . Indent::_(2) . ""; + $body .= PHP_EOL . Indent::_(3) + . "published, \$i, '" + . $nameListCode . ".', false, 'cb'); ?>"; + $body .= PHP_EOL . Indent::_(2) . ""; + $body .= PHP_EOL . Indent::_(2) . ""; + } + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.id')) + { + $body .= PHP_EOL . Indent::_(2) . ''; + $body .= PHP_EOL . Indent::_(3) . "id; ?>"; + $body .= PHP_EOL . Indent::_(2) . ""; + } + $body .= PHP_EOL . Indent::_(1) . ""; + $body .= PHP_EOL . ""; + + // return the build + return $body; + } + + return ''; + } + + /** + * Get the list item dynamic row + * + * @param array $item The item array + * @param string $nameSingleCode The single view code name + * @param string $nameListCode The list view code name + * @param string $itemClass The table row default class + * @param bool $doNotEscape The do not escape global switch + * @param bool $class The dive class adding switch + * @param string $ref The link referral string + * @param string $escape The escape code name + * @param string $user The user code name + * @param string $refview The override of the referral view code name + * + * @return string of the completer item value for the table row + * + */ + protected function getListItemBuilder($item, $nameSingleCode, + $nameListCode, &$itemClass, $doNotEscape, + $class = true, $ref = null, $escape = '$this->escape', + $user = '$this->user', $refview = null + ) + { + // check if we have relation fields + if (($field_relations = + CFactory::_('Compiler.Builder.Field.Relations')->get($nameListCode . '.' . (int) $item['id'] . '.2')) !== null) + { + // set the fields array + $field = []; + // use custom code + $useCustomCode + = (isset($field_relations['join_type']) + && $field_relations['join_type'] + == 2 + && isset($field_relations['set']) + && StringHelper::check( + $field_relations['set'] + )); + // load the main list view field + $field['[field=' . (int) $item['id'] . ']'] = $this->getListItem( + $item, $nameSingleCode, $nameListCode, $itemClass, + $doNotEscape,false, $ref, $escape, $user, + $refview + ); + // code name + if (isset($item['code']) && $useCustomCode) + { + $field['$item->{' . (int) $item['id'] . '}'] = '$item->' + . $item['code']; + } + // now load the relations + if (isset($field_relations['joinfields']) + && ArrayHelper::check($field_relations['joinfields'])) + { + foreach ($field_relations['joinfields'] as $join) + { + $blankClass = ''; + if (($join_item = + CFactory::_('Compiler.Builder.List.Join')->get($nameListCode . '.' . (int) $join)) !== null) + { + // code block + $field['[field=' . (int) $join . ']'] + = $this->getListItem( + $join_item, $nameSingleCode, $nameListCode, $blankClass, + $doNotEscape, false, $ref, + $escape, $user, $refview + ); + // code name + if (isset($join_item['code']) + && $useCustomCode) + { + $field['$item->{' . (int) $join . '}'] = '$item->' + . $join_item['code']; + } + } + } + } + // join based on join type + if ($useCustomCode) + { + // custom code + return PHP_EOL . Indent::_(3) . "
    " + . CFactory::_('Placeholder')->update_( + str_replace( + array_keys($field), array_values($field), + (string) $field_relations['set'] + ) + ) . PHP_EOL . Indent::_(3) . "
    "; + } + elseif (isset($field_relations['set']) + && StringHelper::check( + $field_relations['set'] + )) + { + // concatenate + return PHP_EOL . Indent::_(3) . "
    " . implode( + $field_relations['set'], + $field + ) . PHP_EOL . Indent::_(3) . "
    "; + } + + // default + return PHP_EOL . Indent::_(3) . "
    " . implode('', $field) + . PHP_EOL . Indent::_(3) . "
    "; + } + + return $this->getListItem( + $item, $nameSingleCode, $nameListCode, $itemClass, $doNotEscape, + $class, $ref, $escape, $user, $refview + ); + } + + /** + * Get the list item row value + * + * @param array $item The item array + * @param string $nameSingleCode The single view code name + * @param string $nameListCode The list view code name + * @param string $itemClass The table row default class + * @param bool $doNotEscape The do not escape global switch + * @param bool $class The dive class adding switch + * @param string $ref The link referral string + * @param string $escape The escape code name + * @param string $user The user code name + * @param string $refview The override of the referral view code name + * + * @return string of the single item value for the table row + * + */ + protected function getListItem($item, $nameSingleCode, $nameListCode, + &$itemClass, $doNotEscape, $class = true, $ref = null, + $escape = '$this->escape', $user = '$this->user', $refview = null + ) + { + // get list item code + $itemCode = $this->getListItemCode( + $item, $nameListCode, $doNotEscape, $escape + ); + // add default links + $defaultLink = true; + if (StringHelper::check($refview) + && isset($item['custom']) + && isset($item['custom']['view']) + && $refview === $item['custom']['view']) + { + $defaultLink = false; + } + // is this a linked item + $extends_field = $item['custom']['extends'] ?? ''; + if (($item['link'] || $extends_field === 'user') && $defaultLink) + { + // set some defaults + $checkoutTriger = false; + // set the item default class + $itemClass = 'nowrap'; + // get list item link + $itemLink = $this->getListItemLink( + $item, $checkoutTriger, $nameSingleCode, $nameListCode, $ref + ); + // get list item link authority + $itemLinkAuthority = $this->getListItemLinkAuthority( + $item, $nameSingleCode, $nameListCode, $user + ); + + // set item row + return $this->getListItemLinkLogic( + $itemCode, $itemLink, $itemLinkAuthority, $nameListCode, + $checkoutTriger, $class + ); + } + + // return the default (no link) + return PHP_EOL . Indent::_(3) . ""; + } + + /** + * Get the list item link logic + * + * @param string $itemCode The item code string + * @param string $itemLink The item link string + * @param string $itemLinkAuthority The link authority string + * @param string $nameListCode The list view code name + * @param bool $checkoutTriger The check out trigger + * @param bool $class The dive class adding switch + * + * @return string of the complete link logic of row item + * + */ + protected function getListItemLinkLogic($itemCode, $itemLink, + $itemLinkAuthority, $nameListCode, $checkoutTriger, $class = true + ) + { + // build link + $link = ''; + // add class + $tab = ''; + if ($class) + { + $link .= PHP_EOL . Indent::_(3) . '
    '; + $tab = Indent::_(1); + } + // the link logic + $link .= PHP_EOL . $tab . Indent::_(3) . ""; + $link .= PHP_EOL . $tab . Indent::_(4) . ''; + if ($checkoutTriger) + { + $link .= PHP_EOL . $tab . Indent::_(4) + . "checked_out): ?>"; + $link .= PHP_EOL . $tab . Indent::_(5) + . "name, \$item->checked_out_time, '" + . $nameListCode . ".', \$canCheckin); ?>"; + $link .= PHP_EOL . $tab . Indent::_(4) . ""; + } + $link .= PHP_EOL . $tab . Indent::_(3) . ""; + $link .= PHP_EOL . $tab . Indent::_(4) . ""; + $link .= PHP_EOL . $tab . Indent::_(3) . ""; + // add class + if ($class) + { + $link .= PHP_EOL . Indent::_(3) . "
    "; + } + + // return the link logic + return $link; + } + + /** + * Get the custom admin view buttons + * + * @param string $nameListCode The list view code name + * @param string $ref The link referral string + * + * @return string of the custom admin view buttons + * + */ + protected function getCustomAdminViewButtons($nameListCode, $ref = '') + { + $customAdminViewButton = ''; + // check if custom links should be added to this list views + if (isset($this->customAdminViewListLink[$nameListCode]) + && ArrayHelper::check( + $this->customAdminViewListLink[$nameListCode] + )) + { + // start building the links + $customAdminViewButton .= PHP_EOL . Indent::_(3) + . '
    '; + foreach ( + $this->customAdminViewListLink[$nameListCode] as + $customLinkView + ) + { + $customAdminViewButton .= PHP_EOL . Indent::_(3) + . "get('" . $customLinkView['link'] + . ".access')): ?>"; + $customAdminViewButton .= PHP_EOL . Indent::_(4) + . 'get('COMPONENT') . '_' . $customLinkView['NAME'] . "'" + . '); ?>" >'; + $customAdminViewButton .= PHP_EOL . Indent::_(3) + . ""; + $customAdminViewButton .= PHP_EOL . Indent::_(4) + . 'get('COMPONENT') . '_' . $customLinkView['NAME'] + . "'" . '); ?>">'; + $customAdminViewButton .= PHP_EOL . Indent::_(3) + . ""; + } + $customAdminViewButton .= PHP_EOL . Indent::_(3) . '
    '; + } + + return $customAdminViewButton; + } + + /** + * Get the list item code value + * + * @param array $item The item array + * @param string $nameListCode The list view code name + * @param bool $doNotEscape The do not escape global switch + * @param string $escape The escape code name + * + * @return string of the single item code + * + */ + protected function getListItemCode(&$item, $nameListCode, $doNotEscape, + $escape = '$this->escape' + ) + { + // first update the code id needed + if (isset($item['custom']) + && ArrayHelper::check( + $item['custom'] + ) + && isset($item['custom']['table']) + && StringHelper::check($item['custom']['table'])) + { + $item['id_code'] = $item['code']; + if (!$item['multiple']) + { + $item['code'] = $item['code'] . '_' . $item['custom']['text']; + } + } + // set the extends value + $extends_field = $item['custom']['extends'] ?? ''; + $extends_text = $item['custom']['text'] ?? ''; + // check if category + if ($item['type'] === 'category' && !$item['title']) + { + return $escape . '($item->category_title)'; + } + // check if user + elseif ($item['type'] === 'user') + { + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + return 'Factory::getUser((int)$item->' . $item['code'] . ')->name'; + } + else + { + return 'Factory::getContainer()->' + . 'get(\Joomla\CMS\User\UserFactoryInterface::class)->' + . 'loadUserById((int) $item->' . $item['code'] . ')->name'; + } + } + // check if custom user + elseif (isset($item['custom']) + && ArrayHelper::check($item['custom']) + && $extends_field === 'user' + && isset($item['id_code'])) + { + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + return 'Factory::getUser((int)$item->' . $item['id_code'] . ')->name'; + } + else + { + return 'Factory::getContainer()->' + . 'get(\Joomla\CMS\User\UserFactoryInterface::class)->' + . 'loadUserById((int) $item->' . $item['id_code'] . ')->name'; + } + } + // check if translated value is used + elseif (CFactory::_('Compiler.Builder.Selection.Translation')-> + exists($nameListCode . '.' . $item['code'])) + { + return 'Text:' . ':_($item->' . $item['code'] . ')'; + } + elseif (isset($item['custom']) + && ArrayHelper::check($item['custom']) + && ($extends_text === 'user' || $extends_field === 'user')) + { + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + return 'Factory::getUser((int)$item->' . $item['code'] . ')->name'; + } + else + { + return 'Factory::getContainer()->' + . 'get(\Joomla\CMS\User\UserFactoryInterface::class)->' + . 'loadUserById((int) $item->' . $item['code'] . ')->name'; + } + } + elseif ($doNotEscape) + { + if (CFactory::_('Compiler.Builder.Do.Not.Escape')->exists($nameListCode . '.' . $item['code'])) + { + return '$item->' . $item['code']; + } + } + + // default + return $escape . '($item->' . $item['code'] . ')'; + } + + /** + * Get the list item link + * + * @param array $item The item array + * @param bool $checkoutTriger The checkout trigger switch + * @param string $nameSingleCode The single view code name + * @param string $nameListCode The list view code name + * @param string $ref The link referral string + * + * @return string of the single item link + * + */ + protected function getListItemLink($item, &$checkoutTriger, + $nameSingleCode, $nameListCode, $ref = null + ) + { + // set referal if not set + $referal = ''; + if (!$ref) + { + $ref = '&return=return_here; ?>'; + } + // in linked tab/view so must add ref to default + else + { + $referal = $ref; + } + // if to be linked + if ($item['type'] === 'category' && !$item['title']) + { + // return the link to category + return 'index.php?option=com_categories&task=category.edit&id=' + . $item['code'] . '; ?>&extension=' + . CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension", 'error'); + } + elseif ($item['type'] === 'user' && !$item['title']) + { + // return user link + return 'index.php?option=com_users&task=user.edit&id=' + . $item['code'] . ' ?>'; + } + elseif (isset($item['custom']) + && ArrayHelper::check( + $item['custom'] + ) + && $item['custom']['extends'] != 'user' + && !$item['title'] + && isset($item['id_code'])) + { + // build GUID link + if (isset($item['custom']['id']) && $item['custom']['id'] !== 'id') + { + // link to that linked item + return 'index.php?option=' . $item['custom']['component'] . '&view=' + . $item['custom']['views'] . '&task=' . $item['custom']['view'] + . '.edit&id=' . $item['id_code'] . '_id; ?>' + . $ref; + } + // link to that linked item + return 'index.php?option=' . $item['custom']['component'] . '&view=' + . $item['custom']['views'] . '&task=' . $item['custom']['view'] + . '.edit&id=' . $item['id_code'] . '; ?>' + . $ref; + } + elseif (isset($item['custom']) + && ArrayHelper::check( + $item['custom'] + ) + && $item['custom']['extends'] === 'user' + && !$item['title'] + && isset($item['id_code'])) + { + // return user link + return 'index.php?option=com_users&task=user.edit&id=' + . $item['id_code'] . ' ?>'; + } + // make sure to triger the checkout + $checkoutTriger = true; + + // basic default item link + return '&id=id; ?>' . $referal; + } + + /** + * Get the list item authority + * + * @param array $item The item array + * @param string $nameSingleCode The single view code name + * @param string $nameListCode The list view code name + * @param string $user The user code name + * + * @return string of the single item link authority + * + */ + protected function getListItemLinkAuthority($item, $nameSingleCode, $nameListCode, $user = '$this->user' + ) + { + // if to be linked + if ($item['type'] === 'category' && !$item['title']) + { + // get the other view + $otherView = CFactory::_('Compiler.Builder.Category.Code')->getString("{$nameSingleCode}.view", 'error'); + + // return the authority to category + return $user . "->authorise('core.edit', 'com_" + . CFactory::_('Config')->component_code_name . "." . $otherView + . ".category.' . (int)\$item->" . $item['code'] . ")"; + } + elseif ($item['type'] === 'user' && !$item['title']) + { + // return user authority + return $user . "->authorise('core.edit', 'com_users')"; + } + elseif (isset($item['custom']) + && ArrayHelper::check( + $item['custom'] + ) + && $item['custom']['extends'] != 'user' + && !$item['title'] + && isset($item['id_code'])) + { + // do this with GUID + if (isset($item['custom']['id']) && $item['custom']['id'] !== 'id') + { + return $user . "->authorise('" . CFactory::_('Compiler.Creator.Permission')->getAction($item['custom']['view'], 'core.edit') + . "', 'com_" . CFactory::_('Config')->component_code_name . "." + . $item['custom']['view'] . ".' . (int) \$item->" . $item['id_code'] . "_id)"; + } + else + { + return $user . "->authorise('" . CFactory::_('Compiler.Creator.Permission')->getAction($item['custom']['view'], 'core.edit') + . "', 'com_" . CFactory::_('Config')->component_code_name . "." + . $item['custom']['view'] . ".' . (int) \$item->" . $item['id_code'] . ")"; + } + } + elseif (isset($item['custom']) + && ArrayHelper::check( + $item['custom'] + ) + && $item['custom']['extends'] === 'user' + && !$item['title'] + && isset($item['id_code'])) + { + // return user link + return $user . "->authorise('core.edit', 'com_users')"; + } + + // set core permissions. + return "\$canDo->get('" . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit') . "')"; + } + + /** + * Get the list field class + * + * @param string $name The field code name + * @param string $nameListCode The list view code name + * @param string $default The default + * + * @return string The list field class + * + */ + protected function getListFieldClass($name, $nameListCode, $default = '') + { + return CFactory::_('Compiler.Builder.List.Field.Class')->get($nameListCode . '.' . $name, $default); + } + + /** + * set the default views body + * + * @param string $nameSingleCode + * @param string $nameListCode + * + * @return string + */ + public function setDefaultViewsBody(string $nameSingleCode, string $nameListCode): string + { + // set component name + $component = CFactory::_('Config')->component_code_name; + $Component = ucfirst((string) $component); + $COMPONENT = strtoupper((string) $component); + // set uppercase view + $VIEWS = strtoupper($nameListCode); + // build the body + $body = []; + // check if the filter type is sidebar (1 = sidebar) + if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 1) + { + $body[] = ""; + } + // Trigger Event: jcb_ce_onSetDefaultViewsBodyTop + CFactory::_('Event')->trigger( + 'jcb_ce_onSetDefaultViewsBodyTop', [&$body, &$nameSingleCode, &$nameListCode] + ); + $body[] = "
    \" method=\"post\" name=\"adminForm\" id=\"adminForm\">"; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $body[] = "sidebar)): ?>"; + $body[] = Indent::_(1) + . "
    "; + $body[] = Indent::_(2) . "sidebar; ?>"; + $body[] = Indent::_(1) . "
    "; + $body[] = Indent::_(1) + . "
    "; + $body[] = ""; + $body[] = Indent::_(1) . "
    "; + $body[] = ""; + } + else + { + $body[] = Indent::_(1) + . "
    "; + } + // Trigger Event: jcb_ce_onSetDefaultViewsFormTop + CFactory::_('Event')->trigger( + 'jcb_ce_onSetDefaultViewsFormTop', [&$body, &$nameSingleCode, &$nameListCode] + ); + // check if the filter type is sidebar (2 = topbar) + if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2) + { + $body[] = "set($addTrashHelper, $nameListCode)) + { + $body[] = Indent::_(1) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Add the trash helper layout"; + $body[] = $addTrashHelper; + } + // add the new search toolbar ;) + $body[] = Indent::_(1) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Add the searchtools"; + $body[] = Indent::_(1) + . "echo LayoutHelper::render('joomla.searchtools.default', array('view' => \$this));"; + $body[] = "?>"; + } + $body[] = "items)): ?>"; + // check if the filter type is sidebar (1 = sidebar) + if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 1) + { + $body[] = Indent::_(1) + . "loadTemplate('toolbar');?>"; + } + $body[] = Indent::_(1) + . "
    "; + $body[] = Indent::_(2) + . ""; + $body[] = Indent::_(1) . "
    "; + $body[] = ""; + // check if the filter type is sidebar (1 = sidebar) + if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 1) + { + $body[] = Indent::_(1) + . "loadTemplate('toolbar');?>"; + } + $body[] = Indent::_(1) . ""; + $body[] = Indent::_(2) + . "loadTemplate('head');?>"; + $body[] = Indent::_(2) + . "loadTemplate('foot');?>"; + $body[] = Indent::_(2) + . "loadTemplate('body');?>"; + $body[] = Indent::_(1) . "
    "; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $body[] = Indent::_(1) . ""; + $body[] = Indent::_(1) + . "canCreate && \$this->canEdit) : ?>"; + $body[] = Indent::_(2) . " Text:" . ":_('COM_" . $COMPONENT . "_" + . $VIEWS + . "_BATCH_OPTIONS'),"; + $body[] = Indent::_(4) + . "'footer' => \$this->loadTemplate('batch_footer')"; + $body[] = Indent::_(3) . "),"; + $body[] = Indent::_(3) . "\$this->loadTemplate('batch_body')"; + $body[] = Indent::_(2) . "); ?>"; + $body[] = Indent::_(1) . ""; + } + // check if the filter type is sidebar (1 = sidebar) + if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 1) + { + $body[] = Indent::_(1) + . "listOrder; ?>\" />"; + $body[] = Indent::_(1) + . "listDirn; ?>\" />"; + } + $body[] = Indent::_(1) + . ""; + $body[] = Indent::_(1) . "
    "; + $body[] = ""; + $body[] = Indent::_(1) + . ""; + $body[] = Indent::_(1) . ""; + // Trigger Event: jcb_ce_onSetDefaultViewsFormBottom + CFactory::_('Event')->trigger( + 'jcb_ce_onSetDefaultViewsFormBottom', [&$body, &$nameSingleCode, &$nameListCode] + ); + $body[] = ""; + // Trigger Event: jcb_ce_onSetDefaultViewsBodyBottom + CFactory::_('Event')->trigger( + 'jcb_ce_onSetDefaultViewsBodyBottom', [&$body, &$nameSingleCode, &$nameListCode] + ); + + return implode(PHP_EOL, $body); + } + + /** + * set the list body table head + * + * @param string $nameSingleCode + * @param string $nameListCode + * + * @return string + */ + public function setListHead($nameSingleCode, $nameListCode) + { + if (($items = CFactory::_('Compiler.Builder.Lists')->get($nameListCode)) !== null) + { + // set the Html values based on filter type + $jhtml_sort = "grid.sort"; + $jhtml_sort_icon = ""; + $jhtml_sort_icon_2 = ""; + // for the new filter (2 = topbar) + if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2) + { + $jhtml_sort = "searchtools.sort"; + $jhtml_sort_icon = ""; + $jhtml_sort_icon_2 = ", 'icon-menu-2'"; + } + // main lang prefix + $langView = CFactory::_('Config')->lang_prefix . '_' + . StringHelper::safe($nameSingleCode, 'U'); + // set status lang + $statusLangName = $langView . '_STATUS'; + // set id lang + $idLangName = $langView . '_ID'; + // add to lang array + CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $statusLangName, 'Status'); + // add to lang array + CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $idLangName, 'Id'); + // set default + $head = ''; + $head .= PHP_EOL . Indent::_(1) + . "canEdit&& \$this->canState): ?>"; + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.ordering')) + { + $head .= PHP_EOL . Indent::_(2) + . ''; + $head .= PHP_EOL . Indent::_(3) + . "listDirn, \$this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'" + . $jhtml_sort_icon_2 . "); ?>"; + $head .= PHP_EOL . Indent::_(2) . ""; + } + $head .= PHP_EOL . Indent::_(2) + . ''; + $head .= PHP_EOL . Indent::_(3) + . ""; + $head .= PHP_EOL . Indent::_(2) . ""; + $head .= PHP_EOL . Indent::_(1) . ""; + $head .= PHP_EOL . Indent::_(2) + . ''; + $head .= PHP_EOL . Indent::_(3) . "▾"; + $head .= PHP_EOL . Indent::_(2) . ""; + $head .= PHP_EOL . Indent::_(2) + . ''; + $head .= PHP_EOL . Indent::_(3) . "■"; + $head .= PHP_EOL . Indent::_(2) . ""; + $head .= PHP_EOL . Indent::_(1) . ""; + // set footer Column number + $this->listColnrBuilder[$nameListCode] = 4; + // build the dynamic fields + foreach ($items as $item) + { + // check if target is admin list + if (1 == $item['target'] || 3 == $item['target']) + { + // check if we have an over-ride + if (($list_head_override = CFactory::_('Compiler.Builder.List.Head.Override')-> + get($nameListCode . '.' . (int) $item['id'])) !== null) + { + $item['lang'] = $list_head_override; + } + $class = 'nowrap hidden-phone'; + if ($item['link']) + { + $class = 'nowrap'; + } + // add sort options if required + if ($item['sort']) + { + // if category + if ($item['type'] === 'category') + { + // only one category per/view allowed at this point + $title = "listDirn, \$this->listOrder); ?>"; + } + // set the custom code + elseif (ArrayHelper::check( + $item['custom'] + )) + { + // keep an eye on this + $title = "listDirn, \$this->listOrder); ?>"; + } + else + { + $title = "listDirn, \$this->listOrder); ?>"; + } + } + else + { + $title = ""; + } + $head .= PHP_EOL . Indent::_(1) . ''; + $head .= PHP_EOL . Indent::_(3) . $title; + $head .= PHP_EOL . Indent::_(1) . ""; + $this->listColnrBuilder[$nameListCode]++; + } + } + // set default + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.published')) + { + $head .= PHP_EOL . Indent::_(1) + . "canState): ?>"; + $head .= PHP_EOL . Indent::_(2) + . ''; + $head .= PHP_EOL . Indent::_(3) + . "listDirn, \$this->listOrder); ?>"; + $head .= PHP_EOL . Indent::_(2) . ""; + $head .= PHP_EOL . Indent::_(1) . ""; + $head .= PHP_EOL . Indent::_(2) + . ''; + $head .= PHP_EOL . Indent::_(3) . ""; + $head .= PHP_EOL . Indent::_(2) . ""; + $head .= PHP_EOL . Indent::_(1) . ""; + } + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.id')) + { + $head .= PHP_EOL . Indent::_(1) + . ''; + $head .= PHP_EOL . Indent::_(3) + . "listDirn, \$this->listOrder); ?>"; + $head .= PHP_EOL . Indent::_(1) . ""; + } + $head .= PHP_EOL . ""; + + return $head; + } + + return ''; + } + + public function setListColnr($nameListCode) + { + if (isset($this->listColnrBuilder[$nameListCode])) + { + return $this->listColnrBuilder[$nameListCode]; + } + + return ''; + } + + /** + * set Tabs Layouts Fields Array + * + * @param string $nameSingleCode The single view name + * + * @return string The array + * + */ + public function getTabLayoutFieldsArray($nameSingleCode) + { + // check if the load build is set for this view + if (CFactory::_('Compiler.Builder.Layout')->exists($nameSingleCode)) + { + $layout_builder = CFactory::_('Compiler.Builder.Layout')->get($nameSingleCode); + $layoutArray = []; + foreach ($layout_builder as $layout => $alignments) + { + $alignments = (array) $alignments; + // sort the alignments + ksort($alignments); + $alignmentArray = []; + foreach ($alignments as $alignment => $fields) + { + $fields = (array) $fields; + // sort the fields + ksort($fields); + $fieldArray = []; + foreach ($fields as $field) + { + // add each field + $fieldArray[] = PHP_EOL . Indent::_(4) . "'" . $field + . "'"; + } + // add the alignemnt key + $alignmentArray[] = PHP_EOL . Indent::_(3) . "'" + . $this->alignmentOptions[$alignment] . "' => array(" + . implode(',', $fieldArray) . PHP_EOL . Indent::_(3) + . ")"; + } + // add the layout key + $layoutArray[] = PHP_EOL . Indent::_(2) . "'" + . StringHelper::safe($layout) + . "' => array(" . implode(',', $alignmentArray) . PHP_EOL + . Indent::_(2) . ")"; + } + + return 'array(' . implode(',', $layoutArray) . PHP_EOL . Indent::_( + 1 + ) . ")"; + } + + return 'array()'; + } + + /** + * set Edit Body + * + * @param array $view The view data + * + * @return string The edit body + * + */ + public function setEditBody(&$view) + { + // set view name + $nameSingleCode = $view['settings']->name_single_code; + // main lang prefix + $langView = CFactory::_('Config')->lang_prefix . '_' + . StringHelper::safe($nameSingleCode, 'U'); + // check if the load build is set for this view + if (CFactory::_('Compiler.Builder.Layout')->exists($nameSingleCode)) + { + // reset the linked keys + $keys = []; + $linkedViewIdentifier = []; + // set the linked view tabs + $linkedTab = $this->getEditBodyLinkedAdminViewsTabs( + $view, $nameSingleCode, $keys, $linkedViewIdentifier + ); + // custom tab searching array + $searchTabs = []; + // reset tab values + $leftside = ''; + $rightside = ''; + $side_open = ''; + $side_close = ''; + $footer = ''; + $header = ''; + $mainwidth = 12; + $sidewidth = 0; + $width_class = 'span'; + $row_class = 'row-fluid form-horizontal-desktop'; + $form_class = 'form-horizontal'; + $uitab = 'bootstrap'; + if (CFactory::_('Config')->get('joomla_version', 3) != 3) + { + $width_class = 'col-md-'; + $row_class = 'row'; + $form_class = 'main-card'; + $uitab = 'uitab'; + $side_open = '
    '; + $side_close = '
    '; + } + // get the tabs with positions + $tabBucket = $this->getEditBodyTabs( + $nameSingleCode, $langView, $linkedTab, $keys, + $linkedViewIdentifier, $searchTabs, $leftside, $rightside, + $footer, $header, $mainwidth, $sidewidth + ); + // tab counter + $tabCounter = 0; + // check if width is still 12 + $span = ''; + if ($mainwidth != 12) + { + $span = $width_class . $mainwidth; + } + // start building body + $body = PHP_EOL . '
    '; + if (CFactory::_('Config')->get('joomla_version', 3) != 3 && + (strlen((string) $leftside) > 2 || strlen((string) $rightside) > 2)) + { + $body .= PHP_EOL . '
    '; + } + if (StringHelper::check($span)) + { + $body .= PHP_EOL . Indent::_(1) . '
    '; + } + // now build the dynamic tabs + foreach ($tabBucket as $tabCodeName => $positions) + { + // get lang string + $tabLangName = $positions['lang']; + // build main center position + $main = ''; + $mainbottom = ''; + $this->setEditBodyTabMainCenterPositionDiv( + $main, $mainbottom, $positions + ); + // set acctive tab (must be in side foreach loop to get active tab code name) + if ($tabCounter == 0) + { + $body .= PHP_EOL . PHP_EOL . Indent::_(1) + . " '" + . $tabCodeName . "', 'recall' => true]); ?>"; + } + // check if custom tab must be added + if (($_customTabHTML = $this->addCustomTabs( + $searchTabs[$tabCodeName], $nameSingleCode, 1 + )) !== false) + { + $body .= $_customTabHTML; + } + // if this is a linked view set permissions + $closeIT = false; + if (ArrayHelper::check($linkedViewIdentifier) + && in_array($tabCodeName, $linkedViewIdentifier)) + { + // get view name + $linkedViewId = array_search( + $tabCodeName, $linkedViewIdentifier + ); + $linkedViewData = CFactory::_('Adminview.Data')->get($linkedViewId); + $linkedCodeName = StringHelper::safe( + $linkedViewData->name_single + ); + // check if the item has permissions. + if (CFactory::_('Compiler.Creator.Permission')->globalExist($linkedCodeName, 'core.access')) + { + $body .= PHP_EOL . PHP_EOL . Indent::_(1) + . "canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($linkedCodeName, 'core.access') . "')) : ?>"; + $closeIT = true; + } + else + { + $body .= PHP_EOL; + } + } + else + { + $body .= PHP_EOL; + } + // start addtab body + $body .= PHP_EOL . Indent::_(1) + . ""; + // add the main + $body .= PHP_EOL . Indent::_(2) + . '
    '; + $body .= $main; + $body .= PHP_EOL . Indent::_(2) . "
    "; + // add main body bottom div if needed + if (strlen((string) $mainbottom) > 0) + { + // add the main bottom + $body .= PHP_EOL . Indent::_(2) + . '
    '; + $body .= $mainbottom; + $body .= PHP_EOL . Indent::_(2) . "
    "; + } + // end addtab body + $body .= PHP_EOL . Indent::_(1) + . ""; + // if we had permissions added + if ($closeIT) + { + $body .= PHP_EOL . Indent::_(1) . ""; + } + // check if custom tab must be added + if (($_customTabHTML = $this->addCustomTabs( + $searchTabs[$tabCodeName], $nameSingleCode, 2 + )) !== false) + { + $body .= $_customTabHTML; + } + // set counter + $tabCounter++; + } + // add option to load forms loaded in via plugins (TODO) we may want to move these tab locations + $body .= PHP_EOL . PHP_EOL . Indent::_(1) + . "ignore_fieldsets = array('details','metadata','vdmmetadata','accesscontrol'); ?>"; + $body .= PHP_EOL . Indent::_(1) . "tab_name = '" + . $nameSingleCode . "Tab'; ?>"; + $body .= PHP_EOL . Indent::_(1) + . ""; + // add the publish and meta data tabs + $body .= $this->getEditBodyPublishMetaTabs( + $nameSingleCode, $langView + ); + // end the tab set + $body .= PHP_EOL . PHP_EOL . Indent::_(1) + . ""; + $body .= PHP_EOL . PHP_EOL . Indent::_(1) . "
    "; + $body .= PHP_EOL . Indent::_(2) + . ''; + $body .= PHP_EOL . Indent::_(2) + . ""; + $body .= PHP_EOL . Indent::_(1) . "
    "; + // close divs + if (StringHelper::check($span)) + { + $body .= PHP_EOL . Indent::_(1) . "
    "; + } + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $body .= PHP_EOL . "
    "; + } + // check if left has been set + if (strlen((string) $leftside) > 2) + { + $left = PHP_EOL . Indent::_(1) . '
    ' . $side_open; + $left .= $leftside; + $left .= PHP_EOL . Indent::_(1) . $side_close . "
    "; + } + else + { + $left = ''; + } + // check if right has been set + if (strlen((string) $rightside) > 2) + { + $right = PHP_EOL . Indent::_(1) . '
    ' . $side_open; + $right .= $rightside; + $right .= PHP_EOL . Indent::_(1) . $side_close . "
    "; + } + else + { + $right = ''; + } + + if (CFactory::_('Config')->get('joomla_version', 3) != 3 && + (strlen((string) $leftside) > 2 || strlen((string) $rightside) > 2)) + { + $right .= PHP_EOL . '
    '; + $right .= PHP_EOL . '
    '; + } + elseif (CFactory::_('Config')->get('joomla_version', 3) != 3) + { + $body .= PHP_EOL . '
    '; + } + + // set active tab and return + return $header . $left . $body . $right . $footer; + } + + return ''; + } + + /** + * get Edit Body Linked Admin Views + * + * @param array $view The view data + * @param string $nameSingleCode The single view name + * @param array $keys The tabs to add in layout + * @param array $linkedViewIdentifier The linked view identifier + * + * @return array The linked Admin Views tabs + * + */ + protected function getEditBodyLinkedAdminViewsTabs(&$view, + &$nameSingleCode, &$keys, &$linkedViewIdentifier + ) + { + // start linked tabs bucket + $linkedTab = []; + // check if the view has linked admin view + if (($linkedAdminViews = CFactory::_('Registry')->get('builder.linked_admin_views.' . $nameSingleCode, null)) !== null + && ArrayHelper::check($linkedAdminViews)) + { + foreach ($linkedAdminViews as $linkedView) + { + // when this happens tell me. + if (!isset($view['settings']->tabs[(int) $linkedView['tab']])) + { + echo "Tab Mismatch Oops! Check your linked views in admin view ($nameSingleCode) that they line-up."; + echo '
    ';
    +					var_dump($view['settings']->tabs, $linkedView);
    +					exit;
    +				}
    +				// get the tab name
    +				$tabName = $view['settings']->tabs[(int) $linkedView['tab']];
    +				// update the tab counter
    +				CFactory::_('Compiler.Builder.Tab.Counter')->set($nameSingleCode . '.' . $linkedView['tab'], $tabName);
    +				// add the linked view
    +				$linkedTab[$linkedView['adminview']] = $linkedView['tab'];
    +				// set the keys if values are set
    +				if (StringHelper::check($linkedView['key'])
    +					&& StringHelper::check(
    +						$linkedView['parentkey']
    +					))
    +				{
    +					$keys[$linkedView['adminview']]
    +						= array('key'       => $linkedView['key'],
    +						'parentKey' => $linkedView['parentkey']);
    +				}
    +				else
    +				{
    +					$keys[$linkedView['adminview']] = array('key'       => null,
    +						'parentKey' => null);
    +				}
    +				// set the button switches
    +				if (isset($linkedView['addnew']))
    +				{
    +					$keys[$linkedView['adminview']]['addNewButton']
    +						= (int) $linkedView['addnew'];
    +				}
    +				else
    +				{
    +					$keys[$linkedView['adminview']]['addNewButton'] = 0;
    +				}
    +			}
    +		}
    +
    +		return $linkedTab;
    +	}
    +
    +	/**
    +	 * get Edit Body Tabs
    +	 *
    +	 * @param   string  $nameSingleCode        The single view name
    +	 * @param   string  $langView              The main lang prefix
    +	 * @param   array   $linkedTab             The linked admin view tabs
    +	 * @param   array   $keys                  The tabs to add in layout
    +	 * @param   array   $linkedViewIdentifier  The linked view identifier
    +	 * @param   array   $searchTabs            The tabs to add in layout
    +	 * @param   string  $leftside              The left side html string
    +	 * @param   string  $rightside             The right side html string
    +	 * @param   string  $footer                The footer html string
    +	 * @param   string  $header                The header html string
    +	 * @param   int     $mainwidth             The main width value
    +	 * @param   int     $sidewidth             The side width value
    +	 *
    +	 * @return  array   The linked tabs
    +	 *
    +	 */
    +	protected function getEditBodyTabs(&$nameSingleCode, &$langView,
    +	                                   &$linkedTab, &$keys, &$linkedViewIdentifier, &$searchTabs, &$leftside,
    +	                                   &$rightside, &$footer, &$header, &$mainwidth, &$sidewidth
    +	)
    +	{
    +		// start tabs
    +		$tabs = [];
    +		// sort the tabs based on key order
    +		$tab_counter = (array) CFactory::_('Compiler.Builder.Tab.Counter')->get($nameSingleCode, []);
    +		ksort($tab_counter);
    +		// start tab building loop
    +		foreach ($tab_counter as $tabNr => $tabName)
    +		{
    +			$tabWidth  = 12;
    +			$lrCounter = 0;
    +			// set tab lang
    +			$tabLangName = $langView . '_' . StringHelper::safe(
    +					$tabName, 'U'
    +				);
    +			// set tab code name
    +			$tabCodeName = StringHelper::safe($tabName);
    +			/// set the values to use in search latter
    +			$searchTabs[$tabCodeName] = $tabNr;
    +			// add to lang array
    +			CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $tabLangName, $tabName);
    +			// check if linked view belongs to this tab
    +			$buildLayout  = true;
    +			$linkedViewId = '';
    +			if (ArrayHelper::check($linkedTab))
    +			{
    +				if (($linkedViewId = array_search($tabNr, $linkedTab))
    +					!== false)
    +				{
    +					// don't build (since this is a linked view)
    +					$buildLayout = false;
    +				}
    +			}
    +			// build layout these are actual fields
    +			if ($buildLayout && CFactory::_('Compiler.Builder.Layout')->exists($nameSingleCode . '.' . $tabName))
    +			{
    +				// sort to make sure it loads left first
    +				$alignments = CFactory::_('Compiler.Builder.Layout')->get($nameSingleCode . '.' . $tabName);
    +				ksort($alignments);
    +				foreach ($alignments as $alignment => $names)
    +				{
    +					// set layout code name
    +					$layoutCodeName = $tabCodeName . '_'
    +						. $this->alignmentOptions[$alignment];
    +					// reset each time
    +					$items       = '';
    +					$itemCounter = 0;
    +					// sort the names based on order of keys
    +					$names = (array) $names;
    +					ksort($names);
    +					// build the items array for this alignment
    +					foreach ($names as $nr => $name)
    +					{
    +						if ($itemCounter == 0)
    +						{
    +							$items .= "'" . $name . "'";
    +						}
    +						else
    +						{
    +							$items .= "," . PHP_EOL . Indent::_(1) . "'" . $name
    +								. "'";
    +						}
    +						$itemCounter++;
    +					}
    +					// based on alignment build the layout
    +					switch ($alignment)
    +					{
    +						case 1: // left
    +						case 2: // right
    +							// count
    +							$lrCounter++;
    +							// set as items layout
    +							$this->setLayout(
    +								$nameSingleCode, $layoutCodeName, $items,
    +								'layoutitems'
    +							);
    +							// set the lang to tab
    +							$tabs[$tabCodeName]['lang'] = $tabLangName;
    +							// load the body
    +							if (!isset($tabs[$tabCodeName][(int) $alignment]))
    +							{
    +								$tabs[$tabCodeName][(int) $alignment] = '';
    +							}
    +							$tabs[$tabCodeName][(int) $alignment] .= "";
    +							break;
    +						case 3: // fullwidth
    +							// set as items layout
    +							$this->setLayout(
    +								$nameSingleCode, $layoutCodeName, $items,
    +								'layoutfull'
    +							);
    +							// set the lang to tab
    +							$tabs[$tabCodeName]['lang'] = $tabLangName;
    +							// load the body
    +							if (!isset($tabs[$tabCodeName][(int) $alignment]))
    +							{
    +								$tabs[$tabCodeName][(int) $alignment] = '';
    +							}
    +							$tabs[$tabCodeName][(int) $alignment] .= "";
    +							break;
    +						case 4: // above
    +							// set as title layout
    +							$this->setLayout(
    +								$nameSingleCode, $layoutCodeName, $items,
    +								'layouttitle'
    +							);
    +							// load to header
    +							$header .= PHP_EOL
    +								. "";
    +							break;
    +						case 5: // under
    +							// set as title layout
    +							$this->setLayout(
    +								$nameSingleCode, $layoutCodeName, $items,
    +								'layouttitle'
    +							);
    +							// load to footer
    +							$footer .= PHP_EOL . PHP_EOL
    +								. "
    " . PHP_EOL + . ""; + break; + case 6: // left side + $tabWidth = $tabWidth - 2; + // set as items layout + $this->setLayout( + $nameSingleCode, $layoutCodeName, $items, + 'layoutitems' + ); + // load the body + $leftside .= PHP_EOL . Indent::_(2) + . ""; + break; + case 7: // right side + $tabWidth = $tabWidth - 2; + // set as items layout + $this->setLayout( + $nameSingleCode, $layoutCodeName, $items, + 'layoutitems' + ); + // load the body + $rightside .= PHP_EOL . Indent::_(2) + . ""; + break; + } + } + } + else + { + // set layout code name + $layoutCodeName = $tabCodeName . '_fullwidth'; + // set identifiers + $linkedViewIdentifier[$linkedViewId] = $tabCodeName; + //set function name + $codeName = StringHelper::safe( + $this->uniquekey(3) . $tabCodeName + ); + // set as items layout + $this->setLayout( + $nameSingleCode, $layoutCodeName, $codeName, + 'layoutlinkedview' + ); + // set the lang to tab + $tabs[$tabCodeName]['lang'] = $tabLangName; + // set all the linked view stuff + $this->secondRunAdmin['setLinkedView'][] = array( + 'viewId' => $linkedViewId, + 'nameSingleCode' => $nameSingleCode, + 'codeName' => $codeName, + 'layoutCodeName' => $layoutCodeName, + 'key' => $keys[$linkedViewId]['key'], + 'parentKey' => $keys[$linkedViewId]['parentKey'], + 'addNewButon' => $keys[$linkedViewId]['addNewButton']); + // load the body + if (!isset($tabs[$tabCodeName][3])) + { + $tabs[$tabCodeName][3] = ''; + } + $tabs[$tabCodeName][3] .= ""; + } + // width calculator :) + if ($tabWidth == 8) + { + $mainwidth = 8; + $sidewidth = 2; + } + elseif ($tabWidth == 10 && $mainwidth != 8) + { + $mainwidth = 9; + $sidewidth = 3; + } + $tabs[$tabCodeName]['lr'] = $lrCounter; + } + + return $tabs; + } + + /** + * set Edit Body Main Center Positions Div + * + * @param string $main The main position of this tab + * @param string $mainbottom The main bottom position of this tab + * @param array $positions The build positions of this tab + * + * @return array The linked Admin Views tabs + * + */ + protected function setEditBodyTabMainCenterPositionDiv(&$main, &$mainbottom, + &$positions + ) + { + $width_class = 'span'; + if (CFactory::_('Config')->get('joomla_version', 3) != 3) + { + $width_class = 'col-md-'; + } + + foreach ($positions as $position => $string) + { + if ($positions['lr'] == 2) + { + switch ($position) + { + case 1: // left + case 2: // right + $main .= PHP_EOL . Indent::_(3) . '
    '; + $main .= PHP_EOL . Indent::_(4) . $string; + $main .= PHP_EOL . Indent::_(3) . '
    '; + break; + } + } + else + { + switch ($position) + { + case 1: // left + case 2: // right + $main .= PHP_EOL . Indent::_(3) + . '
    '; + $main .= PHP_EOL . Indent::_(4) . $string; + $main .= PHP_EOL . Indent::_(3) . '
    '; + break; + } + } + switch ($position) + { + case 3: // fullwidth + $mainbottom .= PHP_EOL . Indent::_(3) + . '
    '; + $mainbottom .= PHP_EOL . Indent::_(4) . $string; + $mainbottom .= PHP_EOL . Indent::_(3) . '
    '; + break; + } + } + } + + /** + * get Edit Body Publish and Meta Tab + * + * @param string $nameSingleCode The single view name + * @param string $langView The main lang prefix + * + * @return string The published and Meta Data Tabs + * + */ + protected function getEditBodyPublishMetaTabs(&$nameSingleCode, &$langView + ) + { + // build the two tabs + $tabs = ''; + // set default publishing tab lang + $tabLangName = $langView . '_PUBLISHING'; + // add to lang array + CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $tabLangName, 'Publishing'); + // the default publishing items + $items = array('left' => array(), 'right' => array()); + // Setup the default (custom) fields + // only load (1 => 'left', 2 => 'right') + $fieldsAddedRight = false; + $width_class = 'span'; + $row_class = 'row-fluid form-horizontal-desktop'; + $uitab = 'bootstrap'; + if (CFactory::_('Config')->get('joomla_version', 3) != 3) + { + $width_class = 'col-md-'; + $row_class = 'row'; + $uitab = 'uitab'; + } + if (CFactory::_('Compiler.Builder.New.Publishing.Fields')->exists($nameSingleCode)) + { + $new_published_fields = CFactory::_('Compiler.Builder.New.Publishing.Fields')->get($nameSingleCode); + foreach ($new_published_fields as $df_alignment => $df_items) + { + foreach ($df_items as $df_order => $df_name) + { + if ($df_alignment == 2 || $df_alignment == 1) + { + $items[$this->alignmentOptions[$df_alignment]][$df_order] + = $df_name; + } + else + { + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_HR_HTHREEFIELD_WARNINGHTHREE'), 'Warning' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Your %s field could not be added, since the %s alignment position is not available in the %s (publishing) tab. Please only target Left or right in the publishing tab.', + $df_name, + $this->alignmentOptions[$df_alignment], + $nameSingleCode + ), 'Warning' + ); + } + } + } + // set switch to trigger notice if custom fields added to right + if (ArrayHelper::check($items['right'])) + { + $fieldsAddedRight = true; + } + } + // load all defaults + $loadDefaultFields = array( + 'left' => array('created', 'created_by', 'modified', + 'modified_by'), + 'right' => array('published', 'ordering', 'access', 'version', + 'hits', 'id') + ); + foreach ($loadDefaultFields as $d_alignment => $defaultFields) + { + foreach ($defaultFields as $defaultField) + { + if (!CFactory::_('Compiler.Builder.Moved.Publishing.Fields')->exists($nameSingleCode . '.' . $defaultField)) + { + if ($defaultField != 'access') + { + $items[$d_alignment][] = $defaultField; + } + elseif ($defaultField === 'access' + && CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode)) + { + $items[$d_alignment][] = $defaultField; + } + } + } + } + // check if metadata is added to this view + if (CFactory::_('Compiler.Builder.Meta.Data')->exists($nameSingleCode)) + { + // set default publishing tab code name + $tabCodeNameLeft = 'publishing'; + $tabCodeNameRight = 'metadata'; + // the default publishing tiems + if (ArrayHelper::check($items['left']) + || ArrayHelper::check($items['right'])) + { + $items_one = ''; + // load the items into one side + if (ArrayHelper::check($items['left'])) + { + $items_one .= "'" . implode( + "'," . PHP_EOL . Indent::_(1) . "'", $items['left'] + ) . "'"; + } + if (ArrayHelper::check($items['right'])) + { + // there is already fields just add these + if (strlen($items_one) > 3) + { + $items_one .= "," . PHP_EOL . Indent::_(1) . "'" + . implode( + "'," . PHP_EOL . Indent::_(1) . "'", + $items['right'] + ) . "'"; + } + // no fields has been added yet + else + { + $items_one .= "'" . implode( + "'," . PHP_EOL . Indent::_(1) . "'", + $items['right'] + ) . "'"; + } + } + // only triger the info notice if there were custom fields targeted to the right alignment position. + if ($fieldsAddedRight) + { + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_HR_HTHREEFIELD_NOTICEHTHREE'), 'Notice' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Your field/s added to the right alignment position in the %s (publishing) tab was added to the left. Since we have metadata fields on the right. Fields can only be loaded to the right of the publishing tab if there is no metadata fields.', + $nameSingleCode + ), 'Notice' + ); + } + // set the publishing layout + $this->setLayout( + $nameSingleCode, $tabCodeNameLeft, $items_one, + 'layoutpublished' + ); + $items_one = true; + } + else + { + $items_one = false; + } + // set the metadata layout + $this->setLayout( + $nameSingleCode, $tabCodeNameRight, false, 'layoutmetadata' + ); + $items_two = true; + } + else + { + // set default publishing tab code name + $tabCodeNameLeft = 'publishing'; + $tabCodeNameRight = 'publlshing'; + // the default publishing tiems + if (ArrayHelper::check($items['left']) + || ArrayHelper::check($items['right'])) + { + // load left items that remain + if (ArrayHelper::check($items['left'])) + { + // load all items + $items_one = "'" . implode( + "'," . PHP_EOL . Indent::_(1) . "'", $items['left'] + ) . "'"; + // set the publishing layout + $this->setLayout( + $nameSingleCode, $tabCodeNameLeft, $items_one, + 'layoutpublished' + ); + $items_one = true; + } + // load right items that remain + if (ArrayHelper::check($items['right'])) + { + // load all items + $items_two = "'" . implode( + "'," . PHP_EOL . Indent::_(1) . "'", $items['right'] + ) . "'"; + // set the publishing layout + $this->setLayout( + $nameSingleCode, $tabCodeNameRight, $items_two, + 'layoutpublished' + ); + $items_two = true; + } + } + else + { + $items_one = false; + $items_two = false; + } + } + if ($items_one && $items_two) + { + $classs = "{$width_class}6"; + } + elseif ($items_one || $items_two) + { + $classs = "{$width_class}12"; + } + // only load this if needed + if ($items_one || $items_two) + { + // check if the item has permissions. + $publishingPerOR = []; + $allToBeChekcedOR = array('core.edit.created_by', + 'core.edit.created', + 'core.edit.state'); + foreach ($allToBeChekcedOR as $core_permission) + { + // set permissions. + $publishingPerOR[] = "\$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, $core_permission) . "')"; + } + $publishingPerAND = []; + $allToBeChekcedAND = array('core.delete', 'core.edit.state'); + foreach ($allToBeChekcedAND as $core_permission) + { + // set permissions. + $publishingPerAND[] = "\$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, $core_permission) . "')"; + } + // check if custom tab must be added + if (($_customTabHTML = $this->addCustomTabs( + 15, $nameSingleCode, 1 + )) !== false) + { + $tabs .= $_customTabHTML; + } + // add the AND values to OR + $publishingPerOR[] = '(' . implode(' && ', $publishingPerAND) . ')'; + // now build the complete showhide behaviour for the publishing area + $tabs .= PHP_EOL . PHP_EOL . Indent::_(1) . ""; + // set the default publishing tab + $tabs .= PHP_EOL . Indent::_(1) + . ""; + $tabs .= PHP_EOL . Indent::_(2) + . '
    '; + if ($items_one) + { + $tabs .= PHP_EOL . Indent::_(3) . '
    '; + $tabs .= PHP_EOL . Indent::_(4) + . ""; + $tabs .= PHP_EOL . Indent::_(3) . "
    "; + } + if ($items_two) + { + $tabs .= PHP_EOL . Indent::_(3) . '
    '; + $tabs .= PHP_EOL . Indent::_(4) + . ""; + $tabs .= PHP_EOL . Indent::_(3) . "
    "; + } + $tabs .= PHP_EOL . Indent::_(2) . "
    "; + $tabs .= PHP_EOL . Indent::_(1) + . ""; + $tabs .= PHP_EOL . Indent::_(1) . ""; + // check if custom tab must be added + if (($_customTabHTML = $this->addCustomTabs( + 15, $nameSingleCode, 2 + )) !== false) + { + $tabs .= $_customTabHTML; + } + } + + // make sure we don't load it to a view with the name component (as this will cause conflict with Joomla conventions) + if ($nameSingleCode != 'component' + && CFactory::_('Compiler.Builder.Has.Permissions')->exists($nameSingleCode)) + { + // set permissions tab lang + $tabLangName = $langView . '_PERMISSION'; + // set permissions tab code name + $tabCodeName = 'permissions'; + // add to lang array + CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $tabLangName, 'Permissions'); + // set the permissions tab + $tabs .= PHP_EOL . PHP_EOL . Indent::_(1) + . "canDo->get('core.admin')) : ?>"; + $tabs .= PHP_EOL . Indent::_(1) + . ""; + $tabs .= PHP_EOL . Indent::_(2) + . '
    '; + $tabs .= PHP_EOL . Indent::_(3) . '
    '; + $tabs .= PHP_EOL . Indent::_(4) . '
    '; + $tabs .= PHP_EOL . Indent::_(5) . '
    '; + $tabs .= PHP_EOL . Indent::_(5) + . "form->getFieldset('accesscontrol') as \$field): ?>"; + $tabs .= PHP_EOL . Indent::_(6) . "
    "; + $tabs .= PHP_EOL . Indent::_(7) + . "label; echo \$field->input;?>"; + $tabs .= PHP_EOL . Indent::_(6) . "
    "; + $tabs .= PHP_EOL . Indent::_(6) . '
    '; + $tabs .= PHP_EOL . Indent::_(5) . ""; + $tabs .= PHP_EOL . Indent::_(5) . "
    "; + $tabs .= PHP_EOL . Indent::_(4) . "
    "; + $tabs .= PHP_EOL . Indent::_(3) . "
    "; + $tabs .= PHP_EOL . Indent::_(2) . "
    "; + $tabs .= PHP_EOL . Indent::_(1) + . ""; + $tabs .= PHP_EOL . Indent::_(1) . ""; + } + + return $tabs; + } + + protected function addCustomTabs($nr, $name_single, $target) + { + // check if this view is having custom tabs + if (($tabs = CFactory::_('Compiler.Builder.Custom.Tabs')->get($name_single)) !== null + && ArrayHelper::check($tabs)) + { + $html = []; + foreach ($tabs as $customTab) + { + if (ArrayHelper::check($customTab) + && isset($customTab['html'])) + { + if ($customTab['tab'] == $nr + && $customTab['position'] == $target + && isset($customTab['html']) + && StringHelper::check( + $customTab['html'] + )) + { + $html[] = $customTab['html']; + } + } + } + // return if found + if (ArrayHelper::check($html)) + { + return PHP_EOL . implode(PHP_EOL, $html); + } + } + + return false; + } + + public function setFadeInEfect(&$view) + { + // check if we should load the fade in affect + if ($view['settings']->add_fadein == 1) + { + // set view name + $fadein[] = ""; + $fadein[] = "
    component_code_name . "_loader\" style=\"display: none;\">"; + + return implode(PHP_EOL, $fadein); + } + + return "
    component_code_name . "_loader\">"; + } + + /** + * @param $nameSingleCode + * @param $layoutName + * @param $items + * @param $type + */ + public function setLayout($nameSingleCode, $layoutName, $items, $type) + { + // we check if there is a local override + if (!$this->setLayoutOverride($nameSingleCode, $layoutName, $items)) + { + // first build the layout file + $target = array('admin' => $nameSingleCode); + CFactory::_('Utilities.Structure')->build($target, $type, $layoutName); + // add to front if needed + if (CFactory::_('Config')->lang_target === 'both') + { + $target = array('site' => $nameSingleCode); + CFactory::_('Utilities.Structure')->build($target, $type, $layoutName); + } + if (StringHelper::check($items)) + { + // LAYOUTITEMS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '_' . $layoutName . '|LAYOUTITEMS', $items); + } + else + { + // LAYOUTITEMS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '_' . $layoutName . '|bogus', 'boom'); + } + } + } + + /** + * @param string $nameSingleCode + * @param string $layoutName + * @param string $items + * + * @return boolean true if override was found + */ + protected function setLayoutOverride($nameSingleCode, $layoutName, $items) + { + if (($data = $this->getLayoutOverride($nameSingleCode, $layoutName)) + !== null) + { + // first build the layout file + $target = array('admin' => $nameSingleCode); + CFactory::_('Utilities.Structure')->build($target, 'layoutoverride', $layoutName); + // add to front if needed + if (CFactory::_('Config')->lang_target === 'both') + { + $target = array('site' => $nameSingleCode); + CFactory::_('Utilities.Structure')->build($target, 'layoutoverride', $layoutName); + } + // make sure items is an empty string (should not be needed.. but) + if (!StringHelper::check($items)) + { + $items = ''; + } + // set placeholder + $placeholder = CFactory::_('Placeholder')->active; + $placeholder[Placefix::_h('LAYOUTITEMS')] = $items; + // OVERRIDE_LAYOUT_CODE <<>> + $php_view = (array) explode(PHP_EOL, (string) $data['php_view'] ?? ''); + if (ArrayHelper::check($php_view)) + { + $php_view = PHP_EOL . PHP_EOL . implode(PHP_EOL, $php_view); + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '_' . $layoutName . '|OVERRIDE_LAYOUT_CODE', + CFactory::_('Placeholder')->update( + $php_view, $placeholder + ) + ); + } + else + { + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '_' . $layoutName . '|OVERRIDE_LAYOUT_CODE', ''); + } + // OVERRIDE_LAYOUT_BODY <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '_' . $layoutName . '|OVERRIDE_LAYOUT_BODY', + PHP_EOL . CFactory::_('Placeholder')->update( + $data['html'] ?? '', $placeholder + ) + ); + // OVERRIDE_LAYOUT_HEADER <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '_' . $layoutName . '|OVERRIDE_LAYOUT_HEADER', + (($header = CFactory::_('Header')->get( + 'override.layout', + $layoutName, false) + ) !== false) ? PHP_EOL . PHP_EOL . $header : '' + ); + + // since override was found + return true; + } + + return false; + } + + /** + * @param string $nameSingleCode + * @param string $layoutName + * + * @return array|null the layout data + */ + protected function getLayoutOverride($nameSingleCode, $layoutName): ?array + { + $get_key = null; + // check if there is an override by component name, view name, & layout name + if ($this->setTemplateAndLayoutData( + 'override', $nameSingleCode, false, array(''), + array(CFactory::_('Config')->component_code_name . $nameSingleCode . $layoutName) + )) + { + $get_key = CFactory::_('Config')->component_code_name . $nameSingleCode . $layoutName; + } + // check if there is an override by component name & layout name + elseif ($this->setTemplateAndLayoutData( + 'override', $nameSingleCode, false, array(''), + array(CFactory::_('Config')->component_code_name . $layoutName) + )) + { + $get_key = CFactory::_('Config')->component_code_name . $layoutName; + } + // check if there is an override by view & layout name + elseif ($this->setTemplateAndLayoutData( + 'override', $nameSingleCode, false, array(''), + array($nameSingleCode . $layoutName) + )) + { + $get_key = $nameSingleCode . $layoutName; + } + // check if there is an override by layout name (global layout) + elseif ($this->setTemplateAndLayoutData( + 'override', $nameSingleCode, false, array(''), + array($layoutName) + )) + { + $get_key = $layoutName; + } + + // check if we have a get key + if ($get_key) + { + $data = CFactory::_('Compiler.Builder.Layout.Data')-> + get(CFactory::_('Config')->build_target . '.' . $get_key); + + if ($data === null) + { + var_dump(CFactory::_('Config')->build_target . '.' . $get_key); + var_dump('admin.' .$get_key); + var_dump(CFactory::_('Compiler.Builder.Layout.Data')->get('admin.' .$get_key)); + var_dump('site.' .$get_key); + var_dump(CFactory::_('Compiler.Builder.Layout.Data')->get('site.' . $get_key)); + var_dump('both.' .$get_key); + var_dump(CFactory::_('Compiler.Builder.Layout.Data')->get('both.' . $get_key)); + exit; + } + // remove since we will add the layout now + if (CFactory::_('Config')->lang_target === 'both') + { + CFactory::_('Compiler.Builder.Layout.Data')-> + remove('admin.' . $get_key); + CFactory::_('Compiler.Builder.Layout.Data')-> + remove('site.' . $get_key); + CFactory::_('Compiler.Builder.Layout.Data')-> + remove('both.' . $get_key); + } + else + { + CFactory::_('Compiler.Builder.Layout.Data')-> + remove(CFactory::_('Config')->build_target . '.' . $get_key); + } + + return $data; + } + + return null; + } + + /** + * @param $args + */ + public function setLinkedView($args) + { + /** + * @var $viewId + * @var $nameSingleCode + * @var $codeName + * @var $layoutCodeName + * @var $key + * @var $parentKey + * @var $addNewButon + */ + extract($args, EXTR_PREFIX_SAME, "oops"); + $single = ''; + $name_list_code = ''; + foreach (CFactory::_('Component')->get('admin_views') as $array) + { + if ($array['adminview'] == $viewId) + { + $name_single_code = $array['settings']->name_single_code; + $name_list_code = $array['settings']->name_list_code; + break; + } + } + if (StringHelper::check($name_single_code) + && StringHelper::check($name_list_code)) + { + $head = $this->setListHeadLinked( + $name_single_code, $name_list_code, $addNewButon, + $nameSingleCode + ); + $body = $this->setListBodyLinked( + $name_single_code, $name_list_code, $nameSingleCode + ); + $functionName = StringHelper::safe($codeName, 'F'); + // LAYOUTITEMSTABLE <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '_' . $layoutCodeName . '|LAYOUTITEMSTABLE', + $head . $body + ); + // LAYOUTITEMSHEADER <<>> + $headerscript = '//' . Line::_(__Line__, __Class__) + . ' set the edit URL'; + $headerscript .= PHP_EOL . '$edit = "index.php?option=com_' + . CFactory::_('Config')->component_code_name . '&view=' . $name_list_code + . '&task=' + . $name_single_code . '.edit";'; + $headerscript .= PHP_EOL . '//' . Line::_(__Line__, __Class__) + . ' set a return value'; + $headerscript .= PHP_EOL + . '$return = ($id) ? "index.php?option=com_' + . CFactory::_('Config')->component_code_name . '&view=' . $nameSingleCode + . '&layout=edit&id=" . $id : "";'; + $headerscript .= PHP_EOL . '//' . Line::_(__Line__, __Class__) + . ' check for a return value'; + $headerscript .= PHP_EOL + . '$jinput = Factory::getApplication()->input;'; + $headerscript .= PHP_EOL + . "if (\$_return = \$jinput->get('return', null, 'base64'))"; + $headerscript .= PHP_EOL . '{'; + $headerscript .= PHP_EOL . Indent::_(1) + . '$return .= "&return=" . $_return;'; + $headerscript .= PHP_EOL . '}'; + $headerscript .= PHP_EOL . '//' . Line::_(__Line__, __Class__) + . ' check if return value was set'; + $headerscript .= PHP_EOL . 'if (' + . 'Super' . '___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($return))'; + $headerscript .= PHP_EOL . '{'; + $headerscript .= PHP_EOL . Indent::_(1) . '//' . Line::_( + __LINE__,__CLASS__ + ) . ' set the referral values'; + $headerscript .= PHP_EOL . Indent::_(1) . '$ref = ($id) ? "&ref=' + . $nameSingleCode + . '&refid=" . $id . "&return=" . urlencode(base64_encode($return)) : "&return=" . urlencode(base64_encode($return));'; + $headerscript .= PHP_EOL . '}'; + $headerscript .= PHP_EOL . 'else'; + $headerscript .= PHP_EOL . '{'; + $headerscript .= PHP_EOL . Indent::_(1) . '$ref = ($id) ? "&ref=' + . $nameSingleCode . '&refid=" . $id : "";'; + $headerscript .= PHP_EOL . '}'; + if ($addNewButon > 0) + { + // add the link for new + if ($addNewButon == 1 || $addNewButon == 2) + { + $headerscript .= PHP_EOL . '//' . Line::_(__Line__, __Class__) + . ' set the create new URL'; + $headerscript .= PHP_EOL . '$new = "index.php?option=com_' + . CFactory::_('Config')->component_code_name . '&view=' . $name_list_code + . '&task=' + . $name_single_code . '.edit" . $ref;'; + } + // and the link for close and new + if ($addNewButon == 2 || $addNewButon == 3) + { + $headerscript .= PHP_EOL . '//' . Line::_(__Line__, __Class__) + . ' set the create new and close URL'; + $headerscript .= PHP_EOL + . '$close_new = "index.php?option=com_' + . CFactory::_('Config')->component_code_name . '&view=' . $name_list_code + . '&task=' + . $name_single_code . '.edit";'; + } + $headerscript .= PHP_EOL . '//' . Line::_(__Line__, __Class__) + . ' load the action object'; + $headerscript .= PHP_EOL . '$can = ' + . CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper::getActions(' . "'" + . $name_single_code . "'" + . ');'; + } + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '_' . $layoutCodeName . '|LAYOUTITEMSHEADER', + $headerscript + ); + // LINKEDVIEWITEMS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->add($nameSingleCode . '|LINKEDVIEWITEMS', + PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Get Linked view data" . PHP_EOL . Indent::_(2) + . "\$this->" . $codeName . " = \$this->get('" . $functionName + . "');", false + ); + // LINKEDVIEWTABLESCRIPTS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|LINKEDVIEWTABLESCRIPTS', $this->setFootableScripts()); + if (strpos((string) $parentKey, '-R>') !== false + || strpos((string) $parentKey, '-A>') !== false) + { + list($parent_key) = explode('-', (string) $parentKey); + } + elseif (strpos((string) $parentKey, '-OR>') !== false) + { + // this is not good... (TODO) + $parent_keys = explode('-OR>', (string) $parentKey); + } + else + { + $parent_key = $parentKey; + } + + if (strpos((string) $key, '-R>') !== false || strpos((string) $key, '-A>') !== false) + { + list($_key) = explode('-', (string) $key); + } + elseif (strpos((string) $key, '-OR>') !== false) + { + $_key = str_replace('-OR>', '', (string) $key); + } + else + { + $_key = $key; + } + // LINKEDVIEWGLOBAL <<>> + if (isset($parent_keys) + && ArrayHelper::check( + $parent_keys + )) + { + $globalKey = []; + foreach ($parent_keys as $parent_key) + { + $globalKey[$parent_key] + = StringHelper::safe( + $_key . $this->uniquekey(4) + ); + CFactory::_('Compiler.Builder.Content.Multi')->add($nameSingleCode . '|LINKEDVIEWGLOBAL', + PHP_EOL . Indent::_(2) . "\$this->" + . $globalKey[$parent_key] . " = \$item->" . $parent_key . ";", false + ); + } + } + else + { + // set the global key + $globalKey = StringHelper::safe( + $_key . $this->uniquekey(4) + ); + CFactory::_('Compiler.Builder.Content.Multi')->add($nameSingleCode . '|LINKEDVIEWGLOBAL', + PHP_EOL . Indent::_(2) . "\$this->" . $globalKey + . " = \$item->" . $parent_key . ";", false + ); + } + // LINKEDVIEWMETHODS <<>> + CFactory::_('Compiler.Builder.Content.Multi')->add($nameSingleCode . '|LINKEDVIEWMETHODS', + $this->setListQueryLinked( + $name_single_code, $name_list_code, $functionName, $key, $_key, + $parentKey, + $parent_key, $globalKey + ), false + ); + } + else + { + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '_' . $layoutCodeName . '|LAYOUTITEMSTABLE', + 'oops! error.....' + ); + CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '_' . $layoutCodeName . '|LAYOUTITEMSHEADER', ''); + } + } + + /** + * @param bool $init + * + * @return string + */ + public function setFootableScripts($init = true) + { + $footable_version = CFactory::_('Config')->get('footable_version', 2); + if (2 == $footable_version) // loading version 2 + { + $foo = PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Add the CSS for Footable."; + $foo .= PHP_EOL . Indent::_(2) + . "Html::_('stylesheet', 'media/com_" + . CFactory::_('Config')->component_code_name + . "/footable-v2/css/footable.core.min.css', ['version' => 'auto']);"; + $foo .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Use the Metro Style"; + $foo .= PHP_EOL . Indent::_(2) + . "if (!isset(\$this->fooTableStyle) || 0 == \$this->fooTableStyle)"; + $foo .= PHP_EOL . Indent::_(2) . "{"; + $foo .= PHP_EOL . Indent::_(3) + . "Html::_('stylesheet', 'media/com_" + . CFactory::_('Config')->component_code_name + . "/footable-v2/css/footable.metro.min.css', ['version' => 'auto']);"; + $foo .= PHP_EOL . Indent::_(2) . "}"; + $foo .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Use the Legacy Style."; + $foo .= PHP_EOL . Indent::_(2) + . "elseif (isset(\$this->fooTableStyle) && 1 == \$this->fooTableStyle)"; + $foo .= PHP_EOL . Indent::_(2) . "{"; + $foo .= PHP_EOL . Indent::_(3) + . "Html::_('stylesheet', 'media/com_" + . CFactory::_('Config')->component_code_name + . "/footable-v2/css/footable.standalone.min.css', ['version' => 'auto']);"; + $foo .= PHP_EOL . Indent::_(2) . "}"; + $foo .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Add the JavaScript for Footable"; + $foo .= PHP_EOL . Indent::_(2) + . "Html::_('script', 'media/com_" + . CFactory::_('Config')->component_code_name . "/footable-v2/js/footable.js', ['version' => 'auto']);"; + $foo .= PHP_EOL . Indent::_(2) + . "Html::_('script', 'media/com_" + . CFactory::_('Config')->component_code_name + . "/footable-v2/js/footable.sort.js', ['version' => 'auto']);"; + $foo .= PHP_EOL . Indent::_(2) + . "Html::_('script', 'media/com_" + . CFactory::_('Config')->component_code_name + . "/footable-v2/js/footable.filter.js', ['version' => 'auto']);"; + $foo .= PHP_EOL . Indent::_(2) + . "Html::_('script', 'media/com_" + . CFactory::_('Config')->component_code_name + . "/footable-v2/js/footable.paginate.js', ['version' => 'auto']);"; + if ($init) + { + $foo .= PHP_EOL . PHP_EOL . Indent::_(2) + . '$footable = "jQuery(document).ready(function() { jQuery(function () { jQuery(' + . "'.footable'" . ').footable(); }); jQuery(' + . "'.nav-tabs'" . ').on(' . "'click'" . ', ' . "'li'" + . ', function() { setTimeout(tableFix, 10); }); }); function tableFix() { jQuery(' + . "'.footable'" . ').trigger(' . "'footable_resize'" + . '); }";'; + $foo .= PHP_EOL . Indent::_(2) + . "\$this->getDocument()->addScriptDeclaration(\$footable);" + . PHP_EOL; + } + } + elseif (3 == $footable_version) // loading version 3 + { + + $foo = PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Add the CSS for Footable"; + $foo .= PHP_EOL . Indent::_(2) + . "Html::_('stylesheet', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', ['version' => 'auto']);"; + $foo .= PHP_EOL . Indent::_(2) + . "Html::_('stylesheet', 'media/com_" + . CFactory::_('Config')->component_code_name + . "/footable-v3/css/footable.standalone.min.css', ['version' => 'auto']);"; + $foo .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Add the JavaScript for Footable (adding all functions)"; + $foo .= PHP_EOL . Indent::_(2) + . "Html::_('script', 'media/com_" + . CFactory::_('Config')->component_code_name + . "/footable-v3/js/footable.min.js', ['version' => 'auto']);"; + if ($init) + { + $foo .= PHP_EOL . PHP_EOL . Indent::_(2) + . '$footable = "jQuery(document).ready(function() { jQuery(function () { jQuery(' + . "'.footable'" . ').footable();});});";'; + $foo .= PHP_EOL . Indent::_(2) + . "\$this->getDocument()->addScriptDeclaration(\$footable);" + . PHP_EOL; + } + } + + return $foo; + } + + /** + * set the list body of the linked admin view + * + * @param string $nameSingleCode + * @param string $nameListCode + * @param string $refview + * + * @return string + */ + public function setListBodyLinked($nameSingleCode, $nameListCode, $refview) + { + if (($items = CFactory::_('Compiler.Builder.Lists')->get($nameListCode)) !== null) + { + // component helper name + $Helper = CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper'; + $footable_version = CFactory::_('Config')->get('footable_version', 2); + // make sure the custom links are only added once + $firstTimeBeingAdded = true; + $counter = 0; + // add the default + $body = PHP_EOL . ""; + $body .= PHP_EOL . " \$item): ?>"; + $body .= PHP_EOL . Indent::_(1) . "authorise('core.manage', 'com_checkin') || \$item->checked_out == \$user->id || \$item->checked_out == 0;"; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $body .= PHP_EOL . Indent::_(2) + . "\$userChkOut = Factory::getUser(\$item->checked_out);"; + } + else + { + $body .= PHP_EOL . Indent::_(2) + . "\$userChkOut = Factory::getContainer()->"; + $body .= PHP_EOL . Indent::_(3) + . "get(\Joomla\CMS\User\UserFactoryInterface::class)->"; + $body .= PHP_EOL . Indent::_(4) + . "loadUserById(\$item->checked_out);"; + } + $body .= PHP_EOL . Indent::_(2) . "\$canDo = " . $Helper + . "::getActions('" . $nameSingleCode . "',\$item,'" + . $nameListCode . "');"; + $body .= PHP_EOL . Indent::_(1) . "?>"; + $body .= PHP_EOL . Indent::_(1) . ''; + // check if this view has fields that should not be escaped + $doNotEscape = false; + if (CFactory::_('Compiler.Builder.Do.Not.Escape')->exists($nameListCode)) + { + $doNotEscape = true; + } + // start adding the dynamic + foreach ($items as $item) + { + // check if target is linked list view + if (1 == $item['target'] || 4 == $item['target']) + { + // set the ref + $ref = ''; + // set some defaults + $customAdminViewButtons = ''; + // set the item row + $itemRow = $this->getListItemBuilder( + $item, $nameSingleCode, $nameListCode, $itemClass, + $doNotEscape, false, $ref, + '$displayData->escape', '$user', $refview + ); + // check if buttons was aready added + if ($firstTimeBeingAdded) // TODO we must improve this to allow more items to be targeted instead of just the first item :) + { + // get custom admin view buttons + $customAdminViewButtons + = $this->getCustomAdminViewButtons( + $nameListCode, $ref + ); + // make sure the custom admin view buttons are only added once + $firstTimeBeingAdded = false; + } + // add row to body + $body .= PHP_EOL . Indent::_(2) . ""; + $body .= $itemRow; + $body .= $customAdminViewButtons; + $body .= PHP_EOL . Indent::_(2) . ""; + // increment counter + $counter++; + } + } + $data_value = (3 == $footable_version) ? 'data-sort-value' + : 'data-value'; + + // add the defaults + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.published')) + { + $counter++; + // add the defaults + $body .= PHP_EOL . Indent::_(2) + . "published == 1): ?>"; + $body .= PHP_EOL . Indent::_(3) . ''; + $body .= PHP_EOL . Indent::_(4) + . 'lang_prefix . "_PUBLISHED'" + . '); ?>">'; + $body .= PHP_EOL . Indent::_(5) . 'lang_prefix . "_PUBLISHED'" . '); ?>'; + $body .= PHP_EOL . Indent::_(4) . ''; + $body .= PHP_EOL . Indent::_(3) . ''; + + $body .= PHP_EOL . Indent::_(2) + . "published == 0): ?>"; + $body .= PHP_EOL . Indent::_(3) . ''; + $body .= PHP_EOL . Indent::_(4) + . 'lang_prefix . "_INACTIVE'" + . '); ?>">'; + $body .= PHP_EOL . Indent::_(5) . 'lang_prefix . "_INACTIVE'" . '); ?>'; + $body .= PHP_EOL . Indent::_(4) . ''; + $body .= PHP_EOL . Indent::_(3) . ''; + + $body .= PHP_EOL . Indent::_(2) + . "published == 2): ?>"; + $body .= PHP_EOL . Indent::_(3) . ''; + $body .= PHP_EOL . Indent::_(4) + . 'lang_prefix . "_ARCHIVED'" + . '); ?>">'; + $body .= PHP_EOL . Indent::_(5) . 'lang_prefix . "_ARCHIVED'" . '); ?>'; + $body .= PHP_EOL . Indent::_(4) . ''; + $body .= PHP_EOL . Indent::_(3) . ''; + + $body .= PHP_EOL . Indent::_(2) + . "published == -2): ?>"; + $body .= PHP_EOL . Indent::_(3) . ''; + $body .= PHP_EOL . Indent::_(4) + . 'lang_prefix . "_TRASHED'" + . '); ?>">'; + $body .= PHP_EOL . Indent::_(5) . 'lang_prefix . "_TRASHED'" . '); ?>'; + $body .= PHP_EOL . Indent::_(4) . ''; + $body .= PHP_EOL . Indent::_(3) . ''; + $body .= PHP_EOL . Indent::_(2) . ''; + } + + // add the defaults + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.id')) + { + $counter++; + $body .= PHP_EOL . Indent::_(2) + . ''; + $body .= PHP_EOL . Indent::_(3) . "id; ?>"; + $body .= PHP_EOL . Indent::_(2) . ""; + } + $body .= PHP_EOL . Indent::_(1) . ""; + $body .= PHP_EOL . ""; + $body .= PHP_EOL . ""; + if (2 == $footable_version) + { + $body .= PHP_EOL . ''; + $body .= PHP_EOL . Indent::_(1) . ''; + $body .= PHP_EOL . Indent::_(2) . ''; + $body .= PHP_EOL . Indent::_(3) + . ''; + $body .= PHP_EOL . Indent::_(2) . ''; + $body .= PHP_EOL . Indent::_(1) . ''; + $body .= PHP_EOL . ''; + } + $body .= PHP_EOL . ''; + $body .= PHP_EOL . ''; + $body .= PHP_EOL . Indent::_(1) + . '
    '; + $body .= PHP_EOL . Indent::_(2) . ''; + $body .= PHP_EOL . Indent::_(1) . '
    '; + $body .= PHP_EOL . ''; + + // return the build + return $body; + } + + return ''; + } + + /** + * set the list body table head linked admin view + * + * @param string $nameSingleCode + * @param string $nameListCode + * @param bool $addNewButon + * @param string $refview + * + * @return string + */ + public function setListHeadLinked($nameSingleCode, $nameListCode, + $addNewButon, $refview + ) + { + if (($items = CFactory::_('Compiler.Builder.Lists')->get($nameListCode)) !== null) + { + // component helper name + $Helper = CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper'; + $head = ''; + $footable_version = CFactory::_('Config')->get('footable_version', 2); + // only add new button if set + if ($addNewButon > 0) + { + // set permissions. + $accessCheck = "\$can->get('" . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.create') . "')"; + // add a button for new + $head = ''; + // make group button if needed + $tabB = ""; + if ($addNewButon == 2) + { + $head .= PHP_EOL . Indent::_(1) . '
    '; + $tabB = Indent::_(1); + } + // add the new buttons + if ($addNewButon == 1 || $addNewButon == 2) + { + $head .= PHP_EOL . $tabB . Indent::_(1) + . ' lang_prefix . "_NEW'" + . '); ?>'; + } + // add the close and new button + if ($addNewButon == 2 || $addNewButon == 3) + { + $head .= PHP_EOL . $tabB . Indent::_(1) + . ' lang_prefix . "_CLOSE_NEW'" + . '); ?>'; + } + // close group button if needed + if ($addNewButon == 2) + { + $head .= PHP_EOL . Indent::_(1) . '


    '; + } + else + { + $head .= '

    '; + } + $head .= PHP_EOL . '' . PHP_EOL; + } + $head .= ''; + // set the style for V2 + $metro_blue = (2 == $footable_version) ? ' metro-blue' : ''; + // set the toggle for V3 + $toggle = (3 == $footable_version) + ? ' data-show-toggle="true" data-toggle-column="first"' : ''; + // set paging + $paging = (2 == $footable_version) + ? ' data-page-size="20" data-filter="#filter_' . $nameListCode + . '"' + : ' data-sorting="true" data-paging="true" data-paging-size="20" data-filtering="true"'; + // add html fix for V3 + $htmlFix = (3 == $footable_version) + ? ' data-type="html" data-sort-use="text"' : ''; + $head .= PHP_EOL . ''; + $head .= PHP_EOL . ""; + // main lang prefix + $langView = CFactory::_('Config')->lang_prefix . '_' + . StringHelper::safe($nameSingleCode, 'U'); + // set status lang + $statusLangName = $langView . '_STATUS'; + // set id lang + $idLangName = $langView . '_ID'; + // make sure only first link is used as togeler + $firstLink = true; + // add to lang array + CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $statusLangName, 'Status'); + // add to lang array + CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $idLangName, 'Id'); + $head .= PHP_EOL . Indent::_(1) . ""; + // set controller for data hiding options + $controller = 1; + // build the dynamic fields + foreach ($items as $item) + { + // check if target is linked list view + if (1 == $item['target'] || 4 == $item['target']) + { + // check if we have an over-ride + if (($list_head_override = CFactory::_('Compiler.Builder.List.Head.Override')-> + get($nameListCode . '.' . (int) $item['id'])) !== null) + { + $item['lang'] = $list_head_override; + } + $setin = (2 == $footable_version) + ? ' data-hide="phone"' : ' data-breakpoints="xs sm"'; + if ($controller > 3) + { + $setin = (2 == $footable_version) + ? ' data-hide="phone,tablet"' + : ' data-breakpoints="xs sm md"'; + } + + if ($controller > 6) + { + $setin = (2 == $footable_version) + ? ' data-hide="all"' : ' data-breakpoints="all"'; + } + + if ($item['link'] && $firstLink) + { + $setin = (2 == $footable_version) + ? ' data-toggle="true"' : ''; + $firstLink = false; + } + $head .= PHP_EOL . Indent::_(2) . ""; + $head .= PHP_EOL . Indent::_(3) . ""; + $head .= PHP_EOL . Indent::_(2) . ""; + $controller++; + } + } + // set some V3 attr + $data_hide = (2 == $footable_version) + ? 'data-hide="phone,tablet"' : 'data-breakpoints="xs sm md"'; + // add the defaults + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.published')) + { + $head .= PHP_EOL . Indent::_(2) . '"; + } + + // add the defaults + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.id')) + { + $data_type = (2 == $footable_version) + ? 'data-type="numeric"' + : 'data-type="number"'; + $head .= PHP_EOL . Indent::_(2) . '"; + } + $head .= PHP_EOL . Indent::_(1) . ""; + $head .= PHP_EOL . ""; + + return $head; + } + + return ''; + } + + /** + * @param $nameSingleCode + * @param $nameListCode + * @param $functionName + * @param $key + * @param $_key + * @param $parentKey + * @param $parent_key + * @param $globalKey + * + * @return string + */ + public function setListQueryLinked($nameSingleCode, $nameListCode, + $functionName, $key, $_key, $parentKey, $parent_key, $globalKey) + { + // check if this view has category added + if (CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.code")) + { + $categoryCodeName = CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.code"); + $addCategory = true; + } + else + { + $addCategory = false; + } + $query = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $query .= PHP_EOL . Indent::_(1) . " * Method to get list data."; + $query .= PHP_EOL . Indent::_(1) . " *"; + $query .= PHP_EOL . Indent::_(1) + . " * @return mixed An array of data items on success, false on failure."; + $query .= PHP_EOL . Indent::_(1) . " */"; + $query .= PHP_EOL . Indent::_(1) . "public function get" . $functionName + . "()"; + $query .= PHP_EOL . Indent::_(1) . "{"; + // setup the query + $query .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Get the user object."; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $query .= PHP_EOL . Indent::_(2) . "\$user = Factory::getUser();"; + } + else + { + $query .= PHP_EOL . Indent::_(2) . "\$user = Factory::getApplication()->getIdentity();"; + } + $query .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Create a new query object."; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $query .= PHP_EOL . Indent::_(2) . "\$db = Factory::getDBO();"; + } + else + { + $query .= PHP_EOL . Indent::_(2) . "\$db = \$this->getDatabase();"; + } + $query .= PHP_EOL . Indent::_(2) . "\$query = \$db->getQuery(true);"; + $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Select some fields"; + $query .= PHP_EOL . Indent::_(2) . "\$query->select('a.*');"; + // add the category + if ($addCategory) + { + $query .= PHP_EOL . Indent::_(2) + . "\$query->select(\$db->quoteName('c.title','category_title'));"; + } + $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " From the " . CFactory::_('Config')->component_code_name . "_" + . $nameSingleCode + . " table"; + $query .= PHP_EOL . Indent::_(2) . "\$query->from(\$db->quoteName('#__" + . CFactory::_('Config')->component_code_name . "_" . $nameSingleCode . "', 'a'));"; + // add the category + if ($addCategory) + { + $query .= PHP_EOL . Indent::_(2) + . "\$query->join('LEFT', \$db->quoteName('#__categories', 'c') . ' ON (' . \$db->quoteName('a." + . $categoryCodeName + . "') . ' = ' . \$db->quoteName('c.id') . ')');"; + } + // add custom filtering php + $query .= CFactory::_('Customcode.Dispenser')->get( + 'php_getlistquery', $nameSingleCode, PHP_EOL . PHP_EOL + ); + // add the custom fields query + $query .= $this->setCustomQuery($nameListCode, $nameSingleCode); + if (StringHelper::check($globalKey) && $key + && strpos( + (string) $key, '-R>' + ) === false + && strpos((string) $key, '-A>') === false + && strpos((string) $key, '-OR>') === false + && $parentKey + && strpos((string) $parentKey, '-R>') === false + && strpos((string) $parentKey, '-A>') === false + && strpos((string) $parentKey, '-OR>') === false) + { + $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Filter by " . $globalKey . " global."; + $query .= PHP_EOL . Indent::_(2) . "\$" . $globalKey . " = \$this->" + . $globalKey . ";"; + $query .= PHP_EOL . Indent::_(2) . "if (is_numeric(\$" . $globalKey + . " ))"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) . "\$query->where('a." . $key + . " = ' . (int) \$" . $globalKey . " );"; + $query .= PHP_EOL . Indent::_(2) . "}"; + $query .= PHP_EOL . Indent::_(2) . "elseif (is_string(\$" + . $globalKey . "))"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) . "\$query->where('a." . $key + . " = ' . \$db->quote(\$" . $globalKey . "));"; + $query .= PHP_EOL . Indent::_(2) . "}"; + $query .= PHP_EOL . Indent::_(2) . "else"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) . "\$query->where('a." . $key + . " = -5');"; + $query .= PHP_EOL . Indent::_(2) . "}"; + } + elseif (strpos((string) $parentKey, '-OR>') !== false + || strpos((string) $key, '-OR>') !== false) + { + // get both strings + if (strpos((string) $key, '-OR>') !== false) + { + $ORarray = explode('-OR>', (string) $key); + } + else + { + $ORarray = array($key); + } + // make sure we have an array + if (!ArrayHelper::check($globalKey)) + { + $globalKey = array($globalKey); + } + // now load the query (this may be to much... but hey let it write the code :) + foreach ($globalKey as $_globalKey) + { + // now build the query + $ORquery = array('s' => array(), 'i' => array()); + foreach ($ORarray as $ORkey) + { + $ORquery['i'][] = "a." . $ORkey . " = ' . (int) \$" + . $_globalKey; + $ORquery['s'][] = "a." . $ORkey . " = ' . \$db->quote(\$" + . $_globalKey . ")"; + } + $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Filter by " . $_globalKey + . " global."; + $query .= PHP_EOL . Indent::_(2) . "\$" . $_globalKey + . " = \$this->" . $_globalKey . ";"; + $query .= PHP_EOL . Indent::_(2) . "if (is_numeric(\$" + . $_globalKey . " ))"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) . "\$query->where('" . implode( + " . ' OR ", $ORquery['i'] + ) . ", ' OR');"; + $query .= PHP_EOL . Indent::_(2) . "}"; + $query .= PHP_EOL . Indent::_(2) . "elseif (is_string(\$" + . $_globalKey . "))"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) . "\$query->where('" . implode( + " . ' OR ", $ORquery['s'] + ) . ", ' OR');"; + $query .= PHP_EOL . Indent::_(2) . "}"; + $query .= PHP_EOL . Indent::_(2) . "else"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) . "\$query->where('a." . $ORkey + . " = -5');"; + $query .= PHP_EOL . Indent::_(2) . "}"; + } + } + if (CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode)) + { + $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Join over the asset groups."; + $query .= PHP_EOL . Indent::_(2) + . "\$query->select('ag.title AS access_level');"; + $query .= PHP_EOL . Indent::_(2) + . "\$query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');"; + // check if the access field was over ridden + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.access')) + { + // component helper name + $Helper = CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper'; + // load the access filter query code + $query .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) + . " Filter by access level."; + $query .= PHP_EOL . Indent::_(2) + . "\$_access = \$this->getState('filter.access');"; + $query .= PHP_EOL . Indent::_(2) + . "if (\$_access && is_numeric(\$_access))"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) + . "\$query->where('a.access = ' . (int) \$_access);"; + $query .= PHP_EOL . Indent::_(2) . "}"; + $query .= PHP_EOL . Indent::_(2) . "elseif (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$_access))"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) + . " Secure the array for the query"; + $query .= PHP_EOL . Indent::_(3) + . "\$_access = ArrayHelper::toInteger(\$_access);"; + $query .= PHP_EOL . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) . " Filter by the Access Array."; + $query .= PHP_EOL . Indent::_(3) + . "\$query->where('a.access IN (' . implode(',', \$_access) . ')');"; + $query .= PHP_EOL . Indent::_(2) . "}"; + } + // TODO the following will fight against the above access filter + $query .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Implement View Level Access"; + $query .= PHP_EOL . Indent::_(2) + . "if (!\$user->authorise('core.options', 'com_" + . CFactory::_('Config')->component_code_name . "'))"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) + . "\$groups = implode(',', \$user->getAuthorisedViewLevels());"; + $query .= PHP_EOL . Indent::_(3) + . "\$query->where('a.access IN (' . \$groups . ')');"; + $query .= PHP_EOL . Indent::_(2) . "}"; + } + // add dynamic ordering (Linked view) + if (CFactory::_('Compiler.Builder.Views.Default.Ordering')-> + get("$nameListCode.add_linked_ordering", 0) == 1) + { + foreach (CFactory::_('Compiler.Builder.Views.Default.Ordering')-> + get("$nameListCode.linked_ordering_fields", []) as $order_field) + { + if (($order_field_name = CFactory::_('Field.Database.Name')->get( + $nameListCode, $order_field['field'] + // We Removed This 'listJoinBuilder' as targetArea + // we will keep an eye on this + )) !== false) + { + // default ordering is by publish and ordering + $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_( + __LINE__,__CLASS__ + ) . " Order the results by ordering"; + $query .= PHP_EOL . Indent::_(2) + . "\$query->order('" + . $order_field_name . " " . $order_field['direction'] + . "');"; + } + } + } + else + { + // default ordering is by publish and ordering + $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Order the results by ordering"; + $query .= PHP_EOL . Indent::_(2) + . "\$query->order('a.published ASC');"; + $query .= PHP_EOL . Indent::_(2) + . "\$query->order('a.ordering ASC');"; + } + $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Load the items"; + $query .= PHP_EOL . Indent::_(2) . "\$db->setQuery(\$query);"; + $query .= PHP_EOL . Indent::_(2) . "\$db->execute();"; + $query .= PHP_EOL . Indent::_(2) . "if (\$db->getNumRows())"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) . "\$items = \$db->loadObjectList();"; + // add the fixing strings method + $query .= $this->setGetItemsMethodStringFix( + $nameSingleCode, $nameListCode, + CFactory::_('Compiler.Builder.Content.One')->get('Component'), + Indent::_(1) + ); + // add translations + $query .= $this->setSelectionTranslationFix( + $nameListCode, + CFactory::_('Compiler.Builder.Content.One')->get('Component'), + Indent::_(1) + ); + // filter by child repetable field values + if (StringHelper::check($globalKey) && $key + && strpos( + (string) $key, '-R>' + ) !== false + && strpos((string) $key, '-A>') === false) + { + list($field, $target) = explode('-R>', (string) $key); + $query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Filter by " . $globalKey . " in this Repetable Field"; + $query .= PHP_EOL . Indent::_(3) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$items) && isset(\$this->" + . $globalKey . "))"; + $query .= PHP_EOL . Indent::_(3) . "{"; + $query .= PHP_EOL . Indent::_(4) + . "foreach (\$items as \$nr => &\$item)"; + $query .= PHP_EOL . Indent::_(4) . "{"; + $query .= PHP_EOL . Indent::_(5) . "if (isset(\$item->" . $field + . ") && Super_" . "__4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::check(\$item->" . $field . "))"; + $query .= PHP_EOL . Indent::_(5) . "{"; + $query .= PHP_EOL . Indent::_(6) + . "\$tmpArray = json_decode(\$item->" . $field . ",true);"; + $query .= PHP_EOL . Indent::_(6) . "if (!isset(\$tmpArray['" + . $target . "']) || !Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$tmpArray['" + . $target . "']) || !in_array(\$this->" . $globalKey + . ", \$tmpArray['" . $target . "']))"; + $query .= PHP_EOL . Indent::_(6) . "{"; + $query .= PHP_EOL . Indent::_(7) . "unset(\$items[\$nr]);"; + $query .= PHP_EOL . Indent::_(7) . "continue;"; + $query .= PHP_EOL . Indent::_(6) . "}"; + $query .= PHP_EOL . Indent::_(5) . "}"; + $query .= PHP_EOL . Indent::_(5) . "else"; + $query .= PHP_EOL . Indent::_(5) . "{"; + $query .= PHP_EOL . Indent::_(6) . "unset(\$items[\$nr]);"; + $query .= PHP_EOL . Indent::_(6) . "continue;"; + $query .= PHP_EOL . Indent::_(5) . "}"; + $query .= PHP_EOL . Indent::_(4) . "}"; + $query .= PHP_EOL . Indent::_(3) . "}"; + $query .= PHP_EOL . Indent::_(3) . "else"; + $query .= PHP_EOL . Indent::_(3) . "{"; + $query .= PHP_EOL . Indent::_(4) . "return false;"; + $query .= PHP_EOL . Indent::_(3) . "}"; + } + // filter by child array field values + if (StringHelper::check($globalKey) && $key + && strpos( + (string) $key, '-R>' + ) === false + && strpos((string) $key, '-A>') !== false) + { + $query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Filter by " . $globalKey . " Array Field"; + $query .= PHP_EOL . Indent::_(3) . "\$" . $globalKey . " = \$this->" + . $globalKey . ";"; + $query .= PHP_EOL . Indent::_(3) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$items) && \$" . $globalKey + . ")"; + $query .= PHP_EOL . Indent::_(3) . "{"; + $query .= PHP_EOL . Indent::_(4) + . "foreach (\$items as \$nr => &\$item)"; + $query .= PHP_EOL . Indent::_(4) . "{"; + list($bin, $target) = explode('-A>', (string) $key); + if (StringHelper::check($target)) + { + $query .= PHP_EOL . Indent::_(5) . "if (isset(\$item->" . $target + . ") && Super_" . "__4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::check(\$item->" . $target . "))"; + $query .= PHP_EOL . Indent::_(5) . "{"; + $query .= PHP_EOL . Indent::_(6) . "\$item->" . $target + . " = json_decode(\$item->" . $target . ", true);"; + $query .= PHP_EOL . Indent::_(5) . "}"; + $query .= PHP_EOL . Indent::_(5) . "elseif (!isset(\$item->" + . $target . ") || !Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$item->" + . $target . "))"; + $query .= PHP_EOL . Indent::_(5) . "{"; + $query .= PHP_EOL . Indent::_(6) . "unset(\$items[\$nr]);"; + $query .= PHP_EOL . Indent::_(6) . "continue;"; + $query .= PHP_EOL . Indent::_(5) . "}"; + $query .= PHP_EOL . Indent::_(5) . "if (!in_array(\$" + . $globalKey . ",\$item->" . $target . "))"; + } + else + { + $query .= PHP_EOL . Indent::_(5) . "if (isset(\$item->" . $_key . ") && " + . "Super_" . "__4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::check(\$item->" . $_key . "))"; + $query .= PHP_EOL . Indent::_(5) . "{"; + $query .= PHP_EOL . Indent::_(6) . "\$item->" . $_key + . " = json_decode(\$item->" . $_key . ", true);"; + $query .= PHP_EOL . Indent::_(5) . "}"; + $query .= PHP_EOL . Indent::_(5) . "elseif (!isset(\$item->" + . $_key . ") || !Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$item->" + . $_key . "))"; + $query .= PHP_EOL . Indent::_(5) . "{"; + $query .= PHP_EOL . Indent::_(6) . "unset(\$items[\$nr]);"; + $query .= PHP_EOL . Indent::_(6) . "continue;"; + $query .= PHP_EOL . Indent::_(5) . "}"; + $query .= PHP_EOL . Indent::_(5) . "if (!in_array(\$" + . $globalKey . ",\$item->" . $_key . "))"; + } + $query .= PHP_EOL . Indent::_(5) . "{"; + $query .= PHP_EOL . Indent::_(6) . "unset(\$items[\$nr]);"; + $query .= PHP_EOL . Indent::_(6) . "continue;"; + $query .= PHP_EOL . Indent::_(5) . "}"; + $query .= PHP_EOL . Indent::_(4) . "}"; + $query .= PHP_EOL . Indent::_(3) . "}"; + $query .= PHP_EOL . Indent::_(3) . "else"; + $query .= PHP_EOL . Indent::_(3) . "{"; + $query .= PHP_EOL . Indent::_(4) . "return false;"; + $query .= PHP_EOL . Indent::_(3) . "}"; + } + // filter by parent repetable field values + if (StringHelper::check($globalKey) && $key + && strpos( + (string) $parentKey, '-R>' + ) !== false + && strpos((string) $parentKey, '-A>') === false) + { + list($bin, $target) = explode('-R>', (string) $parentKey); + $query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Filter by " . $_key . " Repetable Field"; + $query .= PHP_EOL . Indent::_(3) . "\$" . $globalKey + . " = json_decode(\$this->" . $globalKey . ",true);"; + $query .= PHP_EOL . Indent::_(3) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$items) && isset(\$" + . $globalKey . ") && Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$" + . $globalKey . "))"; + $query .= PHP_EOL . Indent::_(3) . "{"; + $query .= PHP_EOL . Indent::_(4) + . "foreach (\$items as \$nr => &\$item)"; + $query .= PHP_EOL . Indent::_(4) . "{"; + $query .= PHP_EOL . Indent::_(5) . "if (\$item->" . $_key + . " && isset(\$" . $globalKey . "['" . $target . "']) && " + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$" . $globalKey . "['" + . $target . "']))"; + $query .= PHP_EOL . Indent::_(5) . "{"; + $query .= PHP_EOL . Indent::_(6) . "if (!in_array(\$item->" . $_key + . ",\$" . $globalKey . "['" . $target . "']))"; + $query .= PHP_EOL . Indent::_(6) . "{"; + $query .= PHP_EOL . Indent::_(7) . "unset(\$items[\$nr]);"; + $query .= PHP_EOL . Indent::_(7) . "continue;"; + $query .= PHP_EOL . Indent::_(6) . "}"; + $query .= PHP_EOL . Indent::_(5) . "}"; + $query .= PHP_EOL . Indent::_(5) . "else"; + $query .= PHP_EOL . Indent::_(5) . "{"; + $query .= PHP_EOL . Indent::_(6) . "unset(\$items[\$nr]);"; + $query .= PHP_EOL . Indent::_(6) . "continue;"; + $query .= PHP_EOL . Indent::_(5) . "}"; + $query .= PHP_EOL . Indent::_(4) . "}"; + $query .= PHP_EOL . Indent::_(3) . "}"; + $query .= PHP_EOL . Indent::_(3) . "else"; + $query .= PHP_EOL . Indent::_(3) . "{"; + $query .= PHP_EOL . Indent::_(4) . "return false;"; + $query .= PHP_EOL . Indent::_(3) . "}"; + } + // filter by parent array field values + if (StringHelper::check($globalKey) && $key + && strpos( + (string) $parentKey, '-R>' + ) === false + && strpos((string) $parentKey, '-A>') !== false) + { + $query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Filter by " . $globalKey . " Array Field"; + $query .= PHP_EOL . Indent::_(3) . "\$" . $globalKey . " = \$this->" + . $globalKey . ";"; + $query .= PHP_EOL . Indent::_(3) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$items) && " + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$" . $globalKey . "))"; + $query .= PHP_EOL . Indent::_(3) . "{"; + $query .= PHP_EOL . Indent::_(4) + . "foreach (\$items as \$nr => &\$item)"; + $query .= PHP_EOL . Indent::_(4) . "{"; + list($bin, $target) = explode('-A>', (string) $parentKey); + if (StringHelper::check($target)) + { + $query .= PHP_EOL . Indent::_(5) . "if (\$item->" . $_key + . " && Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$" . $globalKey . "['" + . $target . "']))"; + $query .= PHP_EOL . Indent::_(5) . "{"; + $query .= PHP_EOL . Indent::_(6) . "if (!in_array(\$item->" + . $_key . ",\$" . $globalKey . "['" . $target . "']))"; + } + else + { + $query .= PHP_EOL . Indent::_(5) . "if (\$item->" . $_key . ")"; + $query .= PHP_EOL . Indent::_(5) . "{"; + $query .= PHP_EOL . Indent::_(6) . "if (!in_array(\$item->" + . $_key . ",\$" . $globalKey . "))"; + } + $query .= PHP_EOL . Indent::_(6) . "{"; + $query .= PHP_EOL . Indent::_(7) . "unset(\$items[\$nr]);"; + $query .= PHP_EOL . Indent::_(7) . "continue;"; + $query .= PHP_EOL . Indent::_(6) . "}"; + $query .= PHP_EOL . Indent::_(5) . "}"; + $query .= PHP_EOL . Indent::_(5) . "else"; + $query .= PHP_EOL . Indent::_(5) . "{"; + $query .= PHP_EOL . Indent::_(6) . "unset(\$items[\$nr]);"; + $query .= PHP_EOL . Indent::_(6) . "continue;"; + $query .= PHP_EOL . Indent::_(5) . "}"; + $query .= PHP_EOL . Indent::_(4) . "}"; + $query .= PHP_EOL . Indent::_(3) . "}"; + $query .= PHP_EOL . Indent::_(3) . "else"; + $query .= PHP_EOL . Indent::_(3) . "{"; + $query .= PHP_EOL . Indent::_(4) . "return false;"; + $query .= PHP_EOL . Indent::_(3) . "}"; + } + // add custom php to getitems method after all + $query .= CFactory::_('Customcode.Dispenser')->get( + 'php_getitems_after_all', $nameSingleCode, + PHP_EOL . PHP_EOL . Indent::_(1) + ); + + $query .= PHP_EOL . Indent::_(3) . "return \$items;"; + $query .= PHP_EOL . Indent::_(2) . "}"; + $query .= PHP_EOL . Indent::_(2) . "return false;"; + $query .= PHP_EOL . Indent::_(1) . "}"; + // SELECTIONTRANSLATIONFIXFUNC<<>> + $query .= $this->setSelectionTranslationFixFunc( + $nameListCode, + CFactory::_('Compiler.Builder.Content.One')->get('Component') + ); + + // fixe mothod name clash + $query = str_replace( + 'selectionTranslation(', + 'selectionTranslation' . $functionName . '(', $query + ); + + return $query; + } + + /** + * @param $nameListCode + * + * @return array|string + */ + public function setCustomAdminDynamicButton($nameListCode) + { + $buttons = ''; + if (isset($this->customAdminDynamicButtons[$nameListCode]) + && ArrayHelper::check( + $this->customAdminDynamicButtons[$nameListCode] + )) + { + $buttons = []; + foreach ( + $this->customAdminDynamicButtons[$nameListCode] as + $custom_button + ) + { + // Load to lang + $keyLang = CFactory::_('Config')->lang_prefix . '_' . $custom_button['NAME']; + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, $keyLang, StringHelper::safe( + $custom_button['name'], 'Ww' + ) + ); + // add cpanel button + $buttons[] = Indent::_(2) . "if (\$this->canDo->get('" + . $custom_button['link'] . ".access'))"; + $buttons[] = Indent::_(2) . "{"; + $buttons[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " add " . $custom_button['name'] . " button."; + $buttons[] = Indent::_(3) . "ToolbarHelper::custom('" + . $nameListCode . ".redirectTo" + . StringHelper::safe( + $custom_button['link'], 'F' + ) . "', '" . $custom_button['icon'] . "', '', '" . $keyLang + . "', true);"; + $buttons[] = Indent::_(2) . "}"; + } + if (ArrayHelper::check($buttons)) + { + return implode(PHP_EOL, $buttons); + } + } + + return $buttons; + } + + /** + * @param $nameListCode + * + * @return array|string + */ + public function setCustomAdminDynamicButtonController($nameListCode) + { + $method = ''; + if (isset($this->customAdminDynamicButtons[$nameListCode]) + && ArrayHelper::check( + $this->customAdminDynamicButtons[$nameListCode] + )) + { + $method = []; + foreach ( + $this->customAdminDynamicButtons[$nameListCode] as + $custom_button + ) + { + // add the custom redirect method + $method[] = PHP_EOL . PHP_EOL . Indent::_(1) + . "public function redirectTo" + . StringHelper::safe( + $custom_button['link'], 'F' + ) . "()"; + $method[] = Indent::_(1) . "{"; + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Check for request forgeries"; + $method[] = Indent::_(2) + . "Session::checkToken() or die(Text:" + . ":_('JINVALID_TOKEN'));"; + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " check if export is allowed for this user."; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $method[] = Indent::_(2) . "\$user = Factory::getUser();"; + } + else + { + $method[] = Indent::_(2) . "\$user = Factory::getApplication()->getIdentity();"; + } + $method[] = Indent::_(2) . "if (\$user->authorise('" + . $custom_button['link'] . ".access', 'com_" + . CFactory::_('Config')->component_code_name . "'))"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Get the input"; + $method[] = Indent::_(3) + . "\$input = Factory::getApplication()->input;"; + $method[] = Indent::_(3) + . "\$pks = \$input->post->get('cid', array(), 'array');"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Sanitize the input"; + $method[] = Indent::_(3) + . "\$pks = ArrayHelper::toInteger(\$pks);"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " convert to string"; + $method[] = Indent::_(3) . "\$ids = implode('_', \$pks);"; + $method[] = Indent::_(3) + . "\$this->setRedirect(Route::_('index.php?option=com_" + . CFactory::_('Config')->component_code_name . "&view=" + . $custom_button['link'] . "&cid='.\$ids, false));"; + $method[] = Indent::_(3) . "return;"; + $method[] = Indent::_(2) . "}"; + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Redirect to the list screen with error."; + $method[] = Indent::_(2) . "\$message = Text:" . ":_('" + . CFactory::_('Config')->lang_prefix . "_ACCESS_TO_" . $custom_button['NAME'] + . "_FAILED');"; + $method[] = Indent::_(2) + . "\$this->setRedirect(Route::_('index.php?option=com_" + . CFactory::_('Config')->component_code_name . "&view=" . $nameListCode + . "', false), \$message, 'error');"; + $method[] = Indent::_(2) . "return;"; + $method[] = Indent::_(1) . "}"; + // add to lang array + $lankey = CFactory::_('Config')->lang_prefix . "_ACCESS_TO_" + . $custom_button['NAME'] . "_FAILED"; + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, $lankey, + 'Access to ' . $custom_button['link'] . ' was denied.' + ); + } + + return implode(PHP_EOL, $method); + } + + return $method; + } + + /** + * A function that builds get Items Method for model + * + * @param string $nameSingleCode The single view name + * @param string $nameListCode The list view name + * @param array $config The config details to adapt the method being build + * + * @return string + */ + public function setGetItemsModelMethod(&$nameSingleCode, &$nameListCode, + $config + = array('functionName' => 'getExportData', + 'docDesc' => 'Method to get list export data.', + 'type' => 'export') + ) + { + // start the query string + $query = ''; + // check if this is the export method + $isExport = ('export' === $config['type']); + // check if this view has export feature, and or if this is not an export method + if ((isset($this->eximportView[$nameListCode]) + && $this->eximportView[$nameListCode]) + || !$isExport) + { + $query = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $query .= PHP_EOL . Indent::_(1) . " * " . $config['docDesc']; + $query .= PHP_EOL . Indent::_(1) . " *"; + $query .= PHP_EOL . Indent::_(1) + . " * @param array \$pks The ids of the items to get"; + $query .= PHP_EOL . Indent::_(1) + . " * @param JUser \$user The user making the request"; + $query .= PHP_EOL . Indent::_(1) . " *"; + $query .= PHP_EOL . Indent::_(1) + . " * @return mixed An array of data items on success, false on failure."; + $query .= PHP_EOL . Indent::_(1) . " */"; + $query .= PHP_EOL . Indent::_(1) . "public function " + . $config['functionName'] . "(\$pks, \$user = null)"; + $query .= PHP_EOL . Indent::_(1) . "{"; + $query .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " setup the query"; + $query .= PHP_EOL . Indent::_(2) . "if ((\$pks_size = " + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$pks)) !== false || 'bulk' === \$pks)"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Set a value to know this is " . $config['type'] + . " method. (USE IN CUSTOM CODE TO ALTER OUTCOME)"; + $query .= PHP_EOL . Indent::_(3) . "\$_" . $config['type'] + . " = true;"; + $query .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Get the user object if not set."; + $query .= PHP_EOL . Indent::_(3) . "if (!isset(\$user) || !" + . "Super_" . "__91004529_94a9_4590_b842_e7c6b624ecf5___Power::check(\$user))"; + $query .= PHP_EOL . Indent::_(3) . "{"; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $query .= PHP_EOL . Indent::_(4) . "\$user = Factory::getUser();"; + } + else + { + $query .= PHP_EOL . Indent::_(4) . "\$user = \$this->getCurrentUser();"; + } + $query .= PHP_EOL . Indent::_(3) . "}"; + $query .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Create a new query object."; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $query .= PHP_EOL . Indent::_(3) . "\$db = Factory::getDBO();"; + } + else + { + $query .= PHP_EOL . Indent::_(3) . "\$db = \$this->getDatabase();"; + } + $query .= PHP_EOL . Indent::_(3) + . "\$query = \$db->getQuery(true);"; + $query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Select some fields"; + $query .= PHP_EOL . Indent::_(3) . "\$query->select('a.*');"; + $query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " From the " . CFactory::_('Config')->component_code_name . "_" + . $nameSingleCode . " table"; + $query .= PHP_EOL . Indent::_(3) + . "\$query->from(\$db->quoteName('#__" + . CFactory::_('Config')->component_code_name . "_" . $nameSingleCode + . "', 'a'));"; + $query .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " The bulk export path"; + $query .= PHP_EOL . Indent::_(3) . "if ('bulk' === \$pks)"; + $query .= PHP_EOL . Indent::_(3) + . "{"; + $query .= PHP_EOL . Indent::_(4) + . "\$query->where('a.id > 0');"; + $query .= PHP_EOL . Indent::_(3) + . "}"; + $query .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " A large array of ID's will not work out well"; + $query .= PHP_EOL . Indent::_(3) . "elseif (\$pks_size > 500)"; + $query .= PHP_EOL . Indent::_(3) + . "{"; + $query .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Use lowest ID"; + $query .= PHP_EOL . Indent::_(4) + . "\$query->where('a.id >= ' . (int) min(\$pks));"; + $query .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Use highest ID"; + $query .= PHP_EOL . Indent::_(4) + . "\$query->where('a.id <= ' . (int) max(\$pks));"; + $query .= PHP_EOL . Indent::_(3) + . "}"; + $query .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " The normal default path"; + $query .= PHP_EOL . Indent::_(3) . "else"; + $query .= PHP_EOL . Indent::_(3) + . "{"; + $query .= PHP_EOL . Indent::_(4) + . "\$query->where('a.id IN (' . implode(',',\$pks) . ')');"; + $query .= PHP_EOL . Indent::_(3) + . "}"; + // add custom filtering php + $query .= CFactory::_('Customcode.Dispenser')->get( + 'php_getlistquery', $nameSingleCode, + PHP_EOL . PHP_EOL . Indent::_(1) + ); + // first check if we export of text only is avalable + if (CFactory::_('Config')->get('export_text_only', 0)) + { + // add switch + $query .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Get global switch to activate text only export"; + $query .= PHP_EOL . Indent::_(3) + . "\$export_text_only = ComponentHelper::getParams('com_" + . CFactory::_('Config')->component_code_name + . "')->get('export_text_only', 0);"; + // first check if we have custom queries + $custom_query = $this->setCustomQuery( + $nameListCode, $nameSingleCode, Indent::_(2), true + ); + } + // if values were returned add the area + if (isset($custom_query) + && StringHelper::check( + $custom_query + )) + { + $query .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Add these queries only if text only is required"; + $query .= PHP_EOL . Indent::_(3) . "if (\$export_text_only)"; + $query .= PHP_EOL . Indent::_(3) . "{"; + // add the custom fields query + $query .= $custom_query; + $query .= PHP_EOL . Indent::_(3) . "}"; + } + // add access levels if the view has access set + if (CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode)) + { + $query .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Implement View Level Access"; + $query .= PHP_EOL . Indent::_(3) + . "if (!\$user->authorise('core.options', 'com_" + . CFactory::_('Config')->component_code_name . "'))"; + $query .= PHP_EOL . Indent::_(3) . "{"; + $query .= PHP_EOL . Indent::_(4) + . "\$groups = implode(',', \$user->getAuthorisedViewLevels());"; + $query .= PHP_EOL . Indent::_(4) + . "\$query->where('a.access IN (' . \$groups . ')');"; + $query .= PHP_EOL . Indent::_(3) . "}"; + } + // add dynamic ordering (Exported data) + if (CFactory::_('Compiler.Builder.Views.Default.Ordering')-> + get("$nameListCode.add_admin_ordering", 0) == 1) + { + foreach (CFactory::_('Compiler.Builder.Views.Default.Ordering')-> + get("$nameListCode.admin_ordering_fields", []) as $order_field) + { + if (($order_field_name = CFactory::_('Field.Database.Name')->get( + $nameListCode, $order_field['field'] + )) !== false) + { + $query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" + . Line::_( + __LINE__,__CLASS__ + ) . " Order the results by ordering"; + $query .= PHP_EOL . Indent::_(3) + . "\$query->order('" + . $order_field_name . " " + . $order_field['direction'] . "');"; + } + } + } + else + { + $query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" + . Line::_( + __LINE__,__CLASS__ + ) . " Order the results by ordering"; + $query .= PHP_EOL . Indent::_(3) + . "\$query->order('a.ordering ASC');"; + } + $query .= PHP_EOL . PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Load the items"; + $query .= PHP_EOL . Indent::_(3) . "\$db->setQuery(\$query);"; + $query .= PHP_EOL . Indent::_(3) . "\$db->execute();"; + $query .= PHP_EOL . Indent::_(3) . "if (\$db->getNumRows())"; + $query .= PHP_EOL . Indent::_(3) . "{"; + $query .= PHP_EOL . Indent::_(4) + . "\$items = \$db->loadObjectList();"; + // set the string fixing code + $query .= $this->setGetItemsMethodStringFix( + $nameSingleCode, $nameListCode, + CFactory::_('Compiler.Builder.Content.One')->get('Component'), + Indent::_(2), $isExport, true + ); + // first check if we export of text only is avalable + if (CFactory::_('Config')->get('export_text_only', 0)) + { + $query_translations = $this->setSelectionTranslationFix( + $nameListCode, + CFactory::_('Compiler.Builder.Content.One')->get('Component'), Indent::_(3) + ); + } + // add translations + if (isset($query_translations) + && StringHelper::check($query_translations)) + { + $query .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Add these translation only if text only is required"; + $query .= PHP_EOL . Indent::_(3) . "if (\$export_text_only)"; + $query .= PHP_EOL . Indent::_(3) . "{"; + $query .= $query_translations; + $query .= PHP_EOL . Indent::_(3) . "}"; + } + // add custom php to getItems method after all + $query .= CFactory::_('Customcode.Dispenser')->get( + 'php_getitems_after_all', $nameSingleCode, + PHP_EOL . PHP_EOL . Indent::_(2) + ); + // in privacy export we must return array of arrays + if ('privacy' === $config['type']) + { + $query .= PHP_EOL . Indent::_(4) + . "return json_decode(json_encode(\$items), true);"; + } + else + { + $query .= PHP_EOL . Indent::_(4) . "return \$items;"; + } + $query .= PHP_EOL . Indent::_(3) . "}"; + $query .= PHP_EOL . Indent::_(2) . "}"; + $query .= PHP_EOL . Indent::_(2) . "return false;"; + $query .= PHP_EOL . Indent::_(1) . "}"; + // get the header script + if ($isExport) + { + $header = ComponentbuilderHelper::getDynamicScripts('headers'); + + // add getExImPortHeaders + $query .= CFactory::_('Customcode.Dispenser')->get( + 'php_import_headers', 'import_' . $nameListCode, + PHP_EOL . PHP_EOL, null, true, + // set a default script for those with no custom script + PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( + $header + ) + ); + } + } + + return $query; + } + + public function setControllerEximportMethod($nameSingleCode, + $nameListCode + ) + { + $method = ''; + if (isset($this->eximportView[$nameListCode]) + && $this->eximportView[$nameListCode]) + { + $method = []; + + // add the export method + $method[] = PHP_EOL . PHP_EOL . Indent::_(1) + . "public function exportData()"; + $method[] = Indent::_(1) . "{"; + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Check for request forgeries"; + $method[] = Indent::_(2) . "Session::checkToken() or die(Text:" + . ":_('JINVALID_TOKEN'));"; + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " check if export is allowed for this user."; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $method[] = Indent::_(2) . "\$user = Factory::getUser();"; + } + else + { + $method[] = Indent::_(2) . "\$user = Factory::getApplication()->getIdentity();"; + } + $method[] = Indent::_(2) . "if (\$user->authorise('" + . $nameSingleCode . ".export', 'com_" + . CFactory::_('Config')->component_code_name + . "') && \$user->authorise('core.export', 'com_" + . CFactory::_('Config')->component_code_name . "'))"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Get the input"; + $method[] = Indent::_(3) + . "\$input = Factory::getApplication()->input;"; + $method[] = Indent::_(3) + . "\$pks = \$input->post->get('cid', array(), 'array');"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Sanitize the input"; + $method[] = Indent::_(3) . "\$pks = ArrayHelper::toInteger(\$pks);"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Get the model"; + $method[] = Indent::_(3) . "\$model = \$this->getModel('" + . StringHelper::safe($nameListCode, 'F') + . "');"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " get the data to export"; + $method[] = Indent::_(3) + . "\$data = \$model->getExportData(\$pks);"; + $method[] = Indent::_(3) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$data))"; + $method[] = Indent::_(3) . "{"; + $method[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " now set the data to the spreadsheet"; + $method[] = Indent::_(4) . "\$date = Factory::getDate();"; + $method[] = Indent::_(4) . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::xls(\$data,'" + . StringHelper::safe($nameListCode, 'F') + . "_'.\$date->format('jS_F_Y'),'" + . StringHelper::safe($nameListCode, 'Ww') + . " exported ('.\$date->format('jS F, Y').')','" + . StringHelper::safe($nameListCode, 'w') + . "');"; + $method[] = Indent::_(3) . "}"; + $method[] = Indent::_(2) . "}"; + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Redirect to the list screen with error."; + $method[] = Indent::_(2) . "\$message = Text:" . ":_('" + . CFactory::_('Config')->lang_prefix . "_EXPORT_FAILED');"; + $method[] = Indent::_(2) + . "\$this->setRedirect(Route::_('index.php?option=com_" + . CFactory::_('Config')->component_code_name . "&view=" . $nameListCode + . "', false), \$message, 'error');"; + $method[] = Indent::_(2) . "return;"; + $method[] = Indent::_(1) . "}"; + + // add the import method + $method[] = PHP_EOL . PHP_EOL . Indent::_(1) + . "public function importData()"; + $method[] = Indent::_(1) . "{"; + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Check for request forgeries"; + $method[] = Indent::_(2) . "Session::checkToken() or die(Text:" + . ":_('JINVALID_TOKEN'));"; + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " check if import is allowed for this user."; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $method[] = Indent::_(2) . "\$user = Factory::getUser();"; + } + else + { + $method[] = Indent::_(2) . "\$user = Factory::getApplication()->getIdentity();"; + } + $method[] = Indent::_(2) . "if (\$user->authorise('" + . $nameSingleCode . ".import', 'com_" + . CFactory::_('Config')->component_code_name + . "') && \$user->authorise('core.import', 'com_" + . CFactory::_('Config')->component_code_name . "'))"; + $method[] = Indent::_(2) . "{"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Get the import model"; + $method[] = Indent::_(3) . "\$model = \$this->getModel('" + . StringHelper::safe($nameListCode, 'F') + . "');"; + $method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " get the headers to import"; + $method[] = Indent::_(3) + . "\$headers = \$model->getExImPortHeaders();"; + $method[] = Indent::_(3) . "if (" + . "Super_" . "__91004529_94a9_4590_b842_e7c6b624ecf5___Power::check(\$headers))"; + $method[] = Indent::_(3) . "{"; + $method[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Load headers to session."; + $method[] = Indent::_(4) . "\$session = Factory::getSession();"; + $method[] = Indent::_(4) . "\$headers = json_encode(\$headers);"; + $method[] = Indent::_(4) . "\$session->set('" . $nameSingleCode + . "_VDM_IMPORTHEADERS', \$headers);"; + $method[] = Indent::_(4) . "\$session->set('backto_VDM_IMPORT', '" + . $nameListCode . "');"; + $method[] = Indent::_(4) + . "\$session->set('dataType_VDM_IMPORTINTO', '" + . $nameSingleCode . "');"; + $method[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Redirect to import view."; + // add to lang array + $selectImportFileNote = CFactory::_('Config')->lang_prefix + . "_IMPORT_SELECT_FILE_FOR_" + . StringHelper::safe($nameListCode, 'U'); + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, $selectImportFileNote, + 'Select the file to import data to ' . $nameListCode . '.' + ); + $method[] = Indent::_(4) . "\$message = Text:" . ":_('" + . $selectImportFileNote . "');"; + // if this view has custom script it must have as custom import (model, veiw, controller) + if (isset($this->importCustomScripts[$nameListCode]) + && $this->importCustomScripts[$nameListCode]) + { + $method[] = Indent::_(4) + . "\$this->setRedirect(Route::_('index.php?option=com_" + . CFactory::_('Config')->component_code_name . "&view=import_" + . $nameListCode . "', false), \$message);"; + } + else + { + $method[] = Indent::_(4) + . "\$this->setRedirect(Route::_('index.php?option=com_" + . CFactory::_('Config')->component_code_name + . "&view=import', false), \$message);"; + } + $method[] = Indent::_(4) . "return;"; + $method[] = Indent::_(3) . "}"; + $method[] = Indent::_(2) . "}"; + $method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Redirect to the list screen with error."; + $method[] = Indent::_(2) . "\$message = Text:" . ":_('" + . CFactory::_('Config')->lang_prefix . "_IMPORT_FAILED');"; + $method[] = Indent::_(2) + . "\$this->setRedirect(Route::_('index.php?option=com_" + . CFactory::_('Config')->component_code_name . "&view=" . $nameListCode + . "', false), \$message, 'error');"; + $method[] = Indent::_(2) . "return;"; + $method[] = Indent::_(1) . "}"; + + return implode(PHP_EOL, $method); + } + + return $method; + } + + public function setExportButton($nameSingleCode, $nameListCode) + { + $button = ''; + if (isset($this->eximportView[$nameListCode]) + && $this->eximportView[$nameListCode] + && CFactory::_('Config')->get('joomla_version', 3) == 3) // needs fixing for Joomla 4 and above + { + // main lang prefix + $langExport = CFactory::_('Config')->lang_prefix . '_' + . StringHelper::safe('Export Data', 'U'); + // add to lang array + CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $langExport, 'Export Data'); + $button = []; + $button[] = PHP_EOL . PHP_EOL . Indent::_(3) + . "if (\$this->canDo->get('core.export') && \$this->canDo->get('" + . $nameSingleCode . ".export'))"; + $button[] = Indent::_(3) . "{"; + $button[] = Indent::_(4) . "ToolbarHelper::custom('" + . $nameListCode . ".exportData', 'download', '', '" + . $langExport . "', true);"; + $button[] = Indent::_(3) . "}"; + + return implode(PHP_EOL, $button); + } + + return $button; + } + + public function setImportButton($nameSingleCode, $nameListCode) + { + $button = ''; + if (isset($this->eximportView[$nameListCode]) + && $this->eximportView[$nameListCode] + && CFactory::_('Config')->get('joomla_version', 3) == 3) // needs fixing for Joomla 4 and above + { + // main lang prefix + $langImport = CFactory::_('Config')->lang_prefix . '_' + . StringHelper::safe('Import Data', 'U'); + // add to lang array + CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $langImport, 'Import Data'); + $button = []; + $button[] = PHP_EOL . PHP_EOL . Indent::_(2) + . "if (\$this->canDo->get('core.import') && \$this->canDo->get('" + . $nameSingleCode . ".import'))"; + $button[] = Indent::_(2) . "{"; + $button[] = Indent::_(3) . "ToolbarHelper::custom('" + . $nameListCode . ".importData', 'upload', '', '" + . $langImport + . "', false);"; + $button[] = Indent::_(2) . "}"; + + return implode(PHP_EOL, $button); + } + + return $button; + } + + public function setImportCustomScripts($nameListCode) + { + // setup Ajax files + $target = array('admin' => 'import_' . $nameListCode); + CFactory::_('Utilities.Structure')->build($target, 'customimport'); + // load the custom script to the files + // IMPORT_EXT_METHOD <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|IMPORT_EXT_METHOD', CFactory::_('Customcode.Dispenser')->get( + 'php_import_ext', 'import_' . $nameListCode, PHP_EOL, null, + true + )); + // IMPORT_DISPLAY_METHOD_CUSTOM <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|IMPORT_DISPLAY_METHOD_CUSTOM', CFactory::_('Customcode.Dispenser')->get( + 'php_import_display', 'import_' . $nameListCode, PHP_EOL, + null, + true + )); + // IMPORT_SETDATA_METHOD <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|IMPORT_SETDATA_METHOD', CFactory::_('Customcode.Dispenser')->get( + 'php_import_setdata', 'import_' . $nameListCode, PHP_EOL, + null, + true + )); + // IMPORT_METHOD_CUSTOM <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|IMPORT_METHOD_CUSTOM', CFactory::_('Customcode.Dispenser')->get( + 'php_import', 'import_' . $nameListCode, PHP_EOL, null, + true + )); + // IMPORT_SAVE_METHOD <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|IMPORT_SAVE_METHOD', CFactory::_('Customcode.Dispenser')->get( + 'php_import_save', 'import_' . $nameListCode, PHP_EOL, + null, + true + )); + // IMPORT_DEFAULT_VIEW_CUSTOM <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|IMPORT_DEFAULT_VIEW_CUSTOM', CFactory::_('Customcode.Dispenser')->get( + 'html_import_view', 'import_' . $nameListCode, PHP_EOL, + null, + true + )); + + // insure we have the view placeholders setup + CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|VIEW', 'IMPORT_' . CFactory::_('Placeholder')->get_h('VIEWS')); + CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|View', 'Import_' . CFactory::_('Placeholder')->get_h('views')); + CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|view', 'import_' . CFactory::_('Placeholder')->get_h('views')); + CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|VIEWS', 'IMPORT_' . CFactory::_('Placeholder')->get_h('VIEWS')); + CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|Views', 'Import_' . CFactory::_('Placeholder')->get_h('views')); + CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|views', 'import_' . CFactory::_('Placeholder')->get_h('views')); + + // IMPORT_CUSTOM_CONTROLLER_HEADER <<>> add the header details for the controller + CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|IMPORT_CUSTOM_CONTROLLER_HEADER', CFactory::_('Header')->get( + 'import.custom.controller', + $nameListCode + )); + + // IMPORT_CUSTOM_MODEL_HEADER <<>> add the header details for the model + CFactory::_('Compiler.Builder.Content.Multi')->set('import_' . $nameListCode . '|IMPORT_CUSTOM_MODEL_HEADER', CFactory::_('Header')->get( + 'import.custom.model', + $nameListCode + )); + } + + public function setListQuery(&$nameSingleCode, &$nameListCode) + { + // check if this view has category added + if (CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.code")) + { + $categoryCodeName = CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.code"); + $addCategory = true; + $addCategoryFilter + = CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.filter", 'error'); + } + else + { + $addCategory = false; + $addCategoryFilter = 0; + } + // setup the query + $query = "//" . Line::_(__Line__, __Class__) . " Get the user object."; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $query .= PHP_EOL . Indent::_(2) . "\$user = Factory::getUser();"; + } + else + { + $query .= PHP_EOL . Indent::_(2) . "\$user = \$this->getCurrentUser();"; + } + $query .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Create a new query object."; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $query .= PHP_EOL . Indent::_(2) . "\$db = Factory::getDBO();"; + } + else + { + $query .= PHP_EOL . Indent::_(2) . "\$db = \$this->getDatabase();"; + } + $query .= PHP_EOL . Indent::_(2) . "\$query = \$db->getQuery(true);"; + $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Select some fields"; + $query .= PHP_EOL . Indent::_(2) . "\$query->select('a.*');"; + // add the category + if ($addCategory) + { + $query .= PHP_EOL . Indent::_(2) + . "\$query->select(\$db->quoteName('c.title','category_title'));"; + } + $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " From the " . CFactory::_('Config')->component_code_name . "_item table"; + $query .= PHP_EOL . Indent::_(2) . "\$query->from(\$db->quoteName('#__" + . CFactory::_('Config')->component_code_name . "_" . $nameSingleCode . "', 'a'));"; + // add the category + if ($addCategory) + { + $query .= PHP_EOL . Indent::_(2) + . "\$query->join('LEFT', \$db->quoteName('#__categories', 'c') . ' ON (' . \$db->quoteName('a." + . $categoryCodeName + . "') . ' = ' . \$db->quoteName('c.id') . ')');"; + } + // add custom filtering php + $query .= CFactory::_('Customcode.Dispenser')->get( + 'php_getlistquery', $nameSingleCode, PHP_EOL . PHP_EOL + ); + // add the custom fields query + $query .= $this->setCustomQuery($nameListCode, $nameSingleCode); + $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Filter by published state"; + $query .= PHP_EOL . Indent::_(2) + . "\$published = \$this->getState('filter.published');"; + $query .= PHP_EOL . Indent::_(2) . "if (is_numeric(\$published))"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) + . "\$query->where('a.published = ' . (int) \$published);"; + $query .= PHP_EOL . Indent::_(2) . "}"; + $query .= PHP_EOL . Indent::_(2) . "elseif (\$published === '')"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) + . "\$query->where('(a.published = 0 OR a.published = 1)');"; + $query .= PHP_EOL . Indent::_(2) . "}"; + if (CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode)) + { + $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Join over the asset groups."; + $query .= PHP_EOL . Indent::_(2) + . "\$query->select('ag.title AS access_level');"; + $query .= PHP_EOL . Indent::_(2) + . "\$query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');"; + // check if the access field was over ridden + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.access')) + { + // component helper name + $Helper = CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper'; + // load the access filter query code + $query .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) + . " Filter by access level."; + $query .= PHP_EOL . Indent::_(2) + . "\$_access = \$this->getState('filter.access');"; + $query .= PHP_EOL . Indent::_(2) + . "if (\$_access && is_numeric(\$_access))"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) + . "\$query->where('a.access = ' . (int) \$_access);"; + $query .= PHP_EOL . Indent::_(2) . "}"; + $query .= PHP_EOL . Indent::_(2) . "elseif (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$_access))"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) + . " Secure the array for the query"; + $query .= PHP_EOL . Indent::_(3) + . "\$_access = ArrayHelper::toInteger(\$_access);"; + $query .= PHP_EOL . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) . " Filter by the Access Array."; + $query .= PHP_EOL . Indent::_(3) + . "\$query->where('a.access IN (' . implode(',', \$_access) . ')');"; + $query .= PHP_EOL . Indent::_(2) . "}"; + } + // TODO the following will fight against the above access filter + $query .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Implement View Level Access"; + $query .= PHP_EOL . Indent::_(2) + . "if (!\$user->authorise('core.options', 'com_" + . CFactory::_('Config')->component_code_name . "'))"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) + . "\$groups = implode(',', \$user->getAuthorisedViewLevels());"; + $query .= PHP_EOL . Indent::_(3) + . "\$query->where('a.access IN (' . \$groups . ')');"; + $query .= PHP_EOL . Indent::_(2) . "}"; + } + // set the search query + $query .= $this->setSearchQuery($nameListCode); + // set other filters + $query .= $this->setFilterQuery($nameListCode); + // add the category + if ($addCategory && $addCategoryFilter >= 1) + { + $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Filter by a single or group of categories."; + $query .= PHP_EOL . Indent::_(2) . "\$baselevel = 1;"; + $query .= PHP_EOL . Indent::_(2) + . "\$categoryId = \$this->getState('filter.category_id');"; + $query .= PHP_EOL; + $query .= PHP_EOL . Indent::_(2) . "if (is_numeric(\$categoryId))"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) + . "\$cat_tbl = Table::getInstance('Category', 'JTable');"; + $query .= PHP_EOL . Indent::_(3) . "\$cat_tbl->load(\$categoryId);"; + $query .= PHP_EOL . Indent::_(3) . "\$rgt = \$cat_tbl->rgt;"; + $query .= PHP_EOL . Indent::_(3) . "\$lft = \$cat_tbl->lft;"; + $query .= PHP_EOL . Indent::_(3) + . "\$baselevel = (int) \$cat_tbl->level;"; + $query .= PHP_EOL . Indent::_(3) + . "\$query->where('c.lft >= ' . (int) \$lft)"; + $query .= PHP_EOL . Indent::_(4) + . "->where('c.rgt <= ' . (int) \$rgt);"; + $query .= PHP_EOL . Indent::_(2) . "}"; + $query .= PHP_EOL . Indent::_(2) + . "elseif (is_array(\$categoryId))"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) + . "\$categoryId = ArrayHelper::toInteger(\$categoryId);"; + $query .= PHP_EOL . Indent::_(3) + . "\$categoryId = implode(',', \$categoryId);"; + $query .= PHP_EOL . Indent::_(3) + . "\$query->where('a." . $categoryCodeName + . " IN (' . \$categoryId . ')');"; + $query .= PHP_EOL . Indent::_(2) . "}"; + $query .= PHP_EOL; + } + // setup values for the view ordering + // add dynamic ordering (Admin view) + if (CFactory::_('Compiler.Builder.Views.Default.Ordering')-> + get("$nameListCode.add_admin_ordering", 0) == 1) + { + // the first is from the state + $order_first = true; + foreach (CFactory::_('Compiler.Builder.Views.Default.Ordering')-> + get("$nameListCode.admin_ordering_fields", []) as $order_field) + { + if (($order_field_name = CFactory::_('Field.Database.Name')->get( + $nameListCode, $order_field['field'] + )) !== false) + { + if ($order_first) + { + // just the first field is based on state + $order_first = false; + $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_( + __LINE__,__CLASS__ + ) . " Add the list ordering clause."; + $query .= PHP_EOL . Indent::_(2) + . "\$orderCol = \$this->getState('list.ordering', '" + . $order_field_name . "');"; + $query .= PHP_EOL . Indent::_(2) + . "\$orderDirn = \$this->getState('list.direction', '" + . $order_field['direction'] . "');"; + $query .= PHP_EOL . Indent::_(2) + . "if (\$orderCol != '')"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) . "//" . Line::_(__LINE__,__CLASS__ + ) . " Check that the order direction is valid encase we have a field called direction as part of filers."; + $query .= PHP_EOL . Indent::_(3) + . "\$orderDirn = (is_string(\$orderDirn) && in_array(strtolower(\$orderDirn), ['asc', 'desc'])) ? \$orderDirn : '" + . $order_field['direction'] . "';"; + $query .= PHP_EOL . Indent::_(3) + . "\$query->order(\$db->escape(\$orderCol . ' ' . \$orderDirn));"; + $query .= PHP_EOL . Indent::_(2) . "}"; + } + else + { + $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_( + __LINE__,__CLASS__ + ) . " Add a permanent list ordering."; + $query .= PHP_EOL . Indent::_(2) + . "\$query->order(\$db->escape('" + . $order_field_name . " " + . $order_field['direction'] . "'));"; + } + } + } + } + else + { + $query .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Add the list ordering clause."; + $query .= PHP_EOL . Indent::_(2) + . "\$orderCol = \$this->getState('list.ordering', 'a.id');"; + $query .= PHP_EOL . Indent::_(2) + . "\$orderDirn = \$this->getState('list.direction', 'desc');"; + $query .= PHP_EOL . Indent::_(2) . "if (\$orderCol != '')"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) . "//" . Line::_(__LINE__,__CLASS__ + ) . " Check that the order direction is valid encase we have a field called direction as part of filers."; + $query .= PHP_EOL . Indent::_(3) + . "\$orderDirn = (is_string(\$orderDirn) && in_array(strtolower(\$orderDirn), ['asc', 'desc'])) ? \$orderDirn : 'desc';"; + $query .= PHP_EOL . Indent::_(3) + . "\$query->order(\$db->escape(\$orderCol . ' ' . \$orderDirn));"; + $query .= PHP_EOL . Indent::_(2) . "}"; + } + $query .= PHP_EOL; + $query .= PHP_EOL . Indent::_(2) . "return \$query;"; + + return $query; + } + + public function setSearchQuery($nameListCode) + { + if (CFactory::_('Compiler.Builder.Search')->exists($nameListCode)) + { + // setup the searh options + $search = "'("; + foreach (CFactory::_('Compiler.Builder.Search')->get($nameListCode) as $nr => $array) + { + // array( 'type' => $typeName, 'code' => $name, 'custom' => $custom, 'list' => $field['list']); + if ($nr == 0) + { + $search .= "a." . $array['code'] . " LIKE '.\$search.'"; + if (ArrayHelper::check($array['custom']) + && 1 == $array['list']) + { + $search .= " OR " . $array['custom']['db'] . "." + . $array['custom']['text'] . " LIKE '.\$search.'"; + } + } + else + { + $search .= " OR a." . $array['code'] . " LIKE '.\$search.'"; + if (ArrayHelper::check($array['custom']) + && 1 == $array['list']) + { + $search .= " OR " . $array['custom']['db'] . "." + . $array['custom']['text'] . " LIKE '.\$search.'"; + } + } + } + $search .= ")'"; + // now setup query + $query = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Filter by search."; + $query .= PHP_EOL . Indent::_(2) + . "\$search = \$this->getState('filter.search');"; + $query .= PHP_EOL . Indent::_(2) . "if (!empty(\$search))"; + $query .= PHP_EOL . Indent::_(2) . "{"; + $query .= PHP_EOL . Indent::_(3) + . "if (stripos(\$search, 'id:') === 0)"; + $query .= PHP_EOL . Indent::_(3) . "{"; + $query .= PHP_EOL . Indent::_(4) + . "\$query->where('a.id = ' . (int) substr(\$search, 3));"; + $query .= PHP_EOL . Indent::_(3) . "}"; + $query .= PHP_EOL . Indent::_(3) . "else"; + $query .= PHP_EOL . Indent::_(3) . "{"; + $query .= PHP_EOL . Indent::_(4) + . "\$search = \$db->quote('%' . \$db->escape(\$search) . '%');"; + $query .= PHP_EOL . Indent::_(4) . "\$query->where(" . $search + . ");"; + $query .= PHP_EOL . Indent::_(3) . "}"; + $query .= PHP_EOL . Indent::_(2) . "}"; + $query .= PHP_EOL; + + return $query; + } + + return ''; + } + + public function setCustomQuery($nameListCode, $nameSingleCode, + $tab = '', + $just_text = false + ) + { + if (CFactory::_('Compiler.Builder.Custom.Field')->exists($nameListCode)) + { + $query = ""; + foreach (CFactory::_('Compiler.Builder.Custom.Field')->get($nameListCode) as $filter) + { + // only load this if table is set + if ((CFactory::_('Compiler.Builder.Custom.List')->exists($nameSingleCode . '.' . $filter['code']) + && isset($filter['custom']['table']) + && StringHelper::check($filter['custom']['table']) + && $filter['method'] == 0) + || ($just_text && isset($filter['custom']['table']) + && StringHelper::check($filter['custom']['table']) + && $filter['method'] == 0)) + { + $query .= PHP_EOL . PHP_EOL . Indent::_(2) . $tab . "//" + . Line::_(__Line__, __Class__) . " From the " + . StringHelper::safe( + StringHelper::safe( + $filter['custom']['table'], 'w' + ) + ) . " table."; + // we must add some fix for none ID keys (I know this is horrible... but we need it) + // TODO we assume that all tables in admin has ids + if ($filter['custom']['id'] !== 'id') + { + // we want to at times just have the words and not the ids as well + if ($just_text) + { + $query .= PHP_EOL . Indent::_(2) . $tab + . "\$query->select(\$db->quoteName(['" + . $filter['custom']['db'] . "." + . $filter['custom']['text'] . "','" + . $filter['custom']['db'] . ".id'],['" + . $filter['code'] . "','" + . $filter['code'] . "_id']));"; + } + else + { + $query .= PHP_EOL . Indent::_(2) . $tab + . "\$query->select(\$db->quoteName(['" + . $filter['custom']['db'] . "." + . $filter['custom']['text'] . "','" + . $filter['custom']['db'] . ".id'],['" + . $filter['code'] . "_" . $filter['custom']['text'] + . "','" . $filter['code'] . "_id']));"; + } + } + else + { + // we want to at times just have the words and not the ids as well + if ($just_text) + { + $query .= PHP_EOL . Indent::_(2) . $tab + . "\$query->select(\$db->quoteName('" + . $filter['custom']['db'] . "." + . $filter['custom']['text'] . "','" + . $filter['code'] . "'));"; + } + else + { + $query .= PHP_EOL . Indent::_(2) . $tab + . "\$query->select(\$db->quoteName('" + . $filter['custom']['db'] . "." + . $filter['custom']['text'] . "','" + . $filter['code'] . "_" . $filter['custom']['text'] + . "'));"; + } + } + $query .= PHP_EOL . Indent::_(2) . $tab + . "\$query->join('LEFT', \$db->quoteName('" + . $filter['custom']['table'] . "', '" + . $filter['custom']['db'] + . "') . ' ON (' . \$db->quoteName('a." . $filter['code'] + . "') . ' = ' . \$db->quoteName('" + . $filter['custom']['db'] . "." + . $filter['custom']['id'] . "') . ')');"; + } + // build the field type file + CFactory::_('Compiler.Creator.Custom.Field.Type.File')->set( + $filter, $nameListCode, $nameSingleCode + ); + } + + return $query; + } + } + + /** + * build model filter per/field in the list view + * + * @param string $nameListCode The list view name + * + * @return string The php to place in model to filter + * + */ + public function setFilterQuery($nameListCode) + { + if (CFactory::_('Compiler.Builder.Filter')->exists($nameListCode)) + { + // component helper name + $Helper = CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper'; + // start building the filter query + $filterQuery = ""; + foreach (CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as $filter) + { + // only add for none category fields + if ($filter['type'] != 'category') + { + $filterQuery .= PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Filter by " + . ucwords((string) $filter['code']) . "."; + // we only add multi filter option if new filter type + // and we have multi filter set for this field (2 = topbar) + if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2 + && isset($filter['multi']) + && $filter['multi'] == 2) + { + $filterQuery .= $this->setMultiFilterQuery( + $filter, $Helper + ); + } + else + { + $filterQuery .= $this->setSingleFilterQuery( + $filter, $Helper + ); + } + } + } + + return $filterQuery; + } + + return ''; + } + + /** + * build single filter query + * + * @param array $filter The field/filter + * @param string $Helper The helper name of the component being build + * @param string $a The db table target name (a) + * + * @return string The php to place in model to filter this field + * + */ + protected function setSingleFilterQuery($filter, $Helper, $a = "a") + { + $filterQuery = PHP_EOL . Indent::_(2) . "\$_" + . $filter['code'] . " = \$this->getState('filter." + . $filter['code'] . "');"; + $filterQuery .= PHP_EOL . Indent::_(2) . "if (is_numeric(\$_" + . $filter['code'] . "))"; + $filterQuery .= PHP_EOL . Indent::_(2) . "{"; + $filterQuery .= PHP_EOL . Indent::_(3) . "if (is_float(\$_" + . $filter['code'] . "))"; + $filterQuery .= PHP_EOL . Indent::_(3) . "{"; + $filterQuery .= PHP_EOL . Indent::_(4) + . "\$query->where('" . $a . "." . $filter['code'] + . " = ' . (float) \$_" . $filter['code'] . ");"; + $filterQuery .= PHP_EOL . Indent::_(3) . "}"; + $filterQuery .= PHP_EOL . Indent::_(3) . "else"; + $filterQuery .= PHP_EOL . Indent::_(3) . "{"; + $filterQuery .= PHP_EOL . Indent::_(4) + . "\$query->where('" . $a . "." . $filter['code'] + . " = ' . (int) \$_" . $filter['code'] . ");"; + $filterQuery .= PHP_EOL . Indent::_(3) . "}"; + $filterQuery .= PHP_EOL . Indent::_(2) . "}"; + $filterQuery .= PHP_EOL . Indent::_(2) . "elseif (" + . "Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$_" . $filter['code'] . "))"; + $filterQuery .= PHP_EOL . Indent::_(2) . "{"; + $filterQuery .= PHP_EOL . Indent::_(3) + . "\$query->where('" . $a . "." . $filter['code'] + . " = ' . \$db->quote(\$db->escape(\$_" . $filter['code'] + . ")));"; + $filterQuery .= PHP_EOL . Indent::_(2) . "}"; + + return $filterQuery; + } + + /** + * build multiple filter query + * + * @param array $filter The field/filter + * @param string $Helper The helper name of the component being build + * @param string $a The db table target name (a) + * + * @return string The php to place in model to filter this field + * + */ + protected function setMultiFilterQuery($filter, $Helper, $a = "a") + { + $filterQuery = PHP_EOL . Indent::_(2) . "\$_" + . $filter['code'] . " = \$this->getState('filter." + . $filter['code'] . "');"; + $filterQuery .= PHP_EOL . Indent::_(2) . "if (is_numeric(\$_" + . $filter['code'] . "))"; + $filterQuery .= PHP_EOL . Indent::_(2) . "{"; + $filterQuery .= PHP_EOL . Indent::_(3) . "if (is_float(\$_" + . $filter['code'] . "))"; + $filterQuery .= PHP_EOL . Indent::_(3) . "{"; + $filterQuery .= PHP_EOL . Indent::_(4) + . "\$query->where('" . $a . "." . $filter['code'] + . " = ' . (float) \$_" . $filter['code'] . ");"; + $filterQuery .= PHP_EOL . Indent::_(3) . "}"; + $filterQuery .= PHP_EOL . Indent::_(3) . "else"; + $filterQuery .= PHP_EOL . Indent::_(3) . "{"; + $filterQuery .= PHP_EOL . Indent::_(4) + . "\$query->where('" . $a . "." . $filter['code'] + . " = ' . (int) \$_" . $filter['code'] . ");"; + $filterQuery .= PHP_EOL . Indent::_(3) . "}"; + $filterQuery .= PHP_EOL . Indent::_(2) . "}"; + $filterQuery .= PHP_EOL . Indent::_(2) . "elseif (" + . "Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$_" . $filter['code'] . "))"; + $filterQuery .= PHP_EOL . Indent::_(2) . "{"; + $filterQuery .= PHP_EOL . Indent::_(3) + . "\$query->where('" . $a . "." . $filter['code'] + . " = ' . \$db->quote(\$db->escape(\$_" . $filter['code'] + . ")));"; + $filterQuery .= PHP_EOL . Indent::_(2) . "}"; + $filterQuery .= PHP_EOL . Indent::_(2) . "elseif (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$_" . $filter['code'] . "))"; + $filterQuery .= PHP_EOL . Indent::_(2) . "{"; + + $filterQuery .= PHP_EOL . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) . " Secure the array for the query"; + + $filterQuery .= PHP_EOL . Indent::_(3) . "\$_" . $filter['code'] + . " = array_map( function (\$val) use(&\$db) {"; + $filterQuery .= PHP_EOL . Indent::_(4) . "if (is_numeric(\$val))"; + $filterQuery .= PHP_EOL . Indent::_(4) . "{"; + $filterQuery .= PHP_EOL . Indent::_(5) . "if (is_float(\$val))"; + $filterQuery .= PHP_EOL . Indent::_(5) . "{"; + $filterQuery .= PHP_EOL . Indent::_(6) . "return (float) \$val;"; + $filterQuery .= PHP_EOL . Indent::_(5) . "}"; + $filterQuery .= PHP_EOL . Indent::_(5) . "else"; + $filterQuery .= PHP_EOL . Indent::_(5) . "{"; + $filterQuery .= PHP_EOL . Indent::_(6) . "return (int) \$val;"; + $filterQuery .= PHP_EOL . Indent::_(5) . "}"; + $filterQuery .= PHP_EOL . Indent::_(4) . "}"; + $filterQuery .= PHP_EOL . Indent::_(4) . "elseif (" + . "Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$val))"; + $filterQuery .= PHP_EOL . Indent::_(4) . "{"; + $filterQuery .= PHP_EOL . Indent::_(5) + . "return \$db->quote(\$db->escape(\$val));"; + $filterQuery .= PHP_EOL . Indent::_(4) . "}"; + $filterQuery .= PHP_EOL . Indent::_(3) . "}, \$_" + . $filter['code'] . ");"; + + $filterQuery .= PHP_EOL . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) . " Filter by the " + . ucwords((string) $filter['code']) . " Array."; + + $filterQuery .= PHP_EOL . Indent::_(3) + . "\$query->where('" . $a . "." . $filter['code'] + . " IN (' . implode(',', \$_" . $filter['code'] . ") . ')');"; + $filterQuery .= PHP_EOL . Indent::_(2) . "}"; + + return $filterQuery; + } + + public function buildTheViewScript($viewArray) + { + // set the view name + $nameSingleCode = $viewArray['settings']->name_single_code; + // add conditions to this view + if (isset($viewArray['settings']->conditions) + && ArrayHelper::check( + $viewArray['settings']->conditions + )) + { + // reset defaults + $getValue = []; + $ifValue = []; + $targetControls = []; + $functions = []; + + foreach ($viewArray['settings']->conditions as $condition) + { + if (isset($condition['match_name']) + && StringHelper::check( + $condition['match_name'] + )) + { + $uniqueVar = $this->uniquekey(7); + $matchName = $condition['match_name'] . '_' + . $uniqueVar; + $targetBehavior = ($condition['target_behavior'] == 1 + || $condition['target_behavior'] == 3) ? 'show' + : 'hide'; + $targetDefault = ($condition['target_behavior'] == 1 + || $condition['target_behavior'] == 3) ? 'hide' + : 'show'; + + // set the realtation if any + if ($condition['target_relation']) + { + // chain to other items of the same target + $relations = $this->getTargetRelationScript( + $viewArray['settings']->conditions, $condition, + $nameSingleCode + ); + if (ArrayHelper::check($relations)) + { + // set behavior and default array + $behaviors[$matchName] = $targetBehavior; + $defaults[$matchName] = $targetDefault; + $toggleSwitch[$matchName] + = ($condition['target_behavior'] + == 1 + || $condition['target_behavior'] == 2) ? true + : false; + // set the type buket + $typeBuket[$matchName] = $condition['match_type']; + // set function array + $functions[$uniqueVar][0] = $matchName; + $matchNames[$matchName] + = $condition['match_name']; + // get the select value + $getValue[$matchName] = $this->getValueScript( + $condition['match_type'], + $condition['match_name'], + $condition['match_extends'], $uniqueVar + ); + // get the options + $options = $this->getOptionsScript( + $condition['match_type'], + $condition['match_options'] + ); + // set the if values + $ifValue[$matchName] = $this->ifValueScript( + $matchName, $condition['match_behavior'], + $condition['match_type'], $options + ); + // set the target controls + $targetControls[$matchName] + = $this->setTargetControlsScript( + $toggleSwitch[$matchName], + $condition['target_field'], $targetBehavior, + $targetDefault, $uniqueVar, $nameSingleCode + ); + + foreach ($relations as $relation) + { + if (StringHelper::check( + $relation['match_name'] + )) + { + $relationName = $relation['match_name'] + . '_' . $uniqueVar; + // set the type buket + $typeBuket[$relationName] + = $relation['match_type']; + // set function array + $functions[$uniqueVar][] = $relationName; + $matchNames[$relationName] + = $relation['match_name']; + // get the relation option + $relationOptions = $this->getOptionsScript( + $relation['match_type'], + $relation['match_options'] + ); + $getValue[$relationName] + = $this->getValueScript( + $relation['match_type'], + $relation['match_name'], + $condition['match_extends'], $uniqueVar + ); + $ifValue[$relationName] + = $this->ifValueScript( + $relationName, + $relation['match_behavior'], + $relation['match_type'], + $relationOptions + ); + } + } + } + } + else + { + // set behavior and default array + $behaviors[$matchName] = $targetBehavior; + $defaults[$matchName] = $targetDefault; + $toggleSwitch[$matchName] + = ($condition['target_behavior'] + == 1 + || $condition['target_behavior'] == 2) ? true + : false; + // set the type buket + $typeBuket[$matchName] = $condition['match_type']; + // set function array + $functions[$uniqueVar][0] = $matchName; + $matchNames[$matchName] = $condition['match_name']; + // get the select value + $getValue[$matchName] = $this->getValueScript( + $condition['match_type'], $condition['match_name'], + $condition['match_extends'], $uniqueVar + ); + // get the options + $options = $this->getOptionsScript( + $condition['match_type'], + $condition['match_options'] + ); + // set the if values + $ifValue[$matchName] = $this->ifValueScript( + $matchName, $condition['match_behavior'], + $condition['match_type'], $options + ); + // set the target controls + $targetControls[$matchName] + = $this->setTargetControlsScript( + $toggleSwitch[$matchName], + $condition['target_field'], $targetBehavior, + $targetDefault, $uniqueVar, $nameSingleCode + ); + } + } + } + // reset buckets + $initial = ''; + $func = ''; + $validation = ''; + $isSet = ''; + $listener = ''; + if (ArrayHelper::check($functions)) + { + // now build the initial script + $initial .= "//" . Line::_(__Line__, __Class__) . " Initial Script" + . PHP_EOL . "document.addEventListener('DOMContentLoaded', function()"; + $initial .= PHP_EOL . "{"; + foreach ($functions as $function => $matchKeys) + { + $func_call = $this->buildFunctionCall( + $function, $matchKeys, $getValue + ); + $initial .= $func_call['code']; + } + $initial .= "});" . PHP_EOL; + // for modal fields + $modal = ''; + // now build the listener scripts + foreach ($functions as $l_function => $l_matchKeys) + { + $funcCall = ''; + foreach ($l_matchKeys as $l_matchKey) + { + $name = $matchNames[$l_matchKey]; + $matchTypeKey = $typeBuket[$l_matchKey]; + $funcCall = $this->buildFunctionCall( + $l_function, $l_matchKeys, $getValue + ); + + if (CFactory::_('Compiler.Builder.Script.Media.Switch')->inArray($matchTypeKey)) + { + $modal .= $funcCall['code']; + } + else + { + if (CFactory::_('Compiler.Builder.Script.User.Switch')->inArray($matchTypeKey)) + { + $name = $name . '_id'; + } + + $listener .= PHP_EOL . "//" . Line::_( + __LINE__,__CLASS__ + ) . " #jform_" . $name . " listeners for " + . $l_matchKey . " function"; + $listener .= PHP_EOL . "jQuery('#jform_" . $name + . "').on('keyup',function()"; + $listener .= PHP_EOL . "{"; + $listener .= $funcCall['code']; + $listener .= PHP_EOL . "});"; + $listener .= PHP_EOL + . "jQuery('#adminForm').on('change', '#jform_" + . $name . "',function (e)"; + $listener .= PHP_EOL . "{"; + $listener .= PHP_EOL . Indent::_(1) + . "e.preventDefault();"; + $listener .= $funcCall['code']; + $listener .= PHP_EOL . "});" . PHP_EOL; + } + } + } + if (StringHelper::check($modal)) + { + $listener .= PHP_EOL . "window.SqueezeBox.initialize({"; + $listener .= PHP_EOL . Indent::_(1) . "onClose:function(){"; + $listener .= $modal; + $listener .= PHP_EOL . Indent::_(1) . "}"; + $listener .= PHP_EOL . "});" . PHP_EOL; + } + + // now build the function + $func = ''; + $head = ''; + foreach ($functions as $f_function => $f_matchKeys) + { + $map = ''; + // does this function require an array + $addArray = false; + $func_ = $this->buildFunctionCall( + $f_function, $f_matchKeys, $getValue + ); + // set array switch + if ($func_['array']) + { + $addArray = true; + } + $func .= PHP_EOL . "//" . Line::_(__Line__, __Class__) + . " the " . $f_function . " function"; + $func .= PHP_EOL . "function " . $f_function . "("; + $fucounter = 0; + foreach ($f_matchKeys as $fu_matchKey) + { + if (StringHelper::check($fu_matchKey)) + { + if ($fucounter == 0) + { + $func .= $fu_matchKey; + } + else + { + $func .= ',' . $fu_matchKey; + } + $fucounter++; + } + } + $func .= ")"; + $func .= PHP_EOL . "{"; + if ($addArray) + { + foreach ($f_matchKeys as $a_matchKey) + { + $name = $matchNames[$a_matchKey]; + $func .= PHP_EOL . Indent::_(1) . "if (isSet(" + . $a_matchKey . ") && " . $a_matchKey + . ".constructor !== Array)" . PHP_EOL + . Indent::_(1) . "{" . PHP_EOL . Indent::_(2) + . "var temp_" . $f_function . " = " + . $a_matchKey . ";" . PHP_EOL . Indent::_(2) + . "var " . $a_matchKey . " = [];" . PHP_EOL + . Indent::_(2) . $a_matchKey . ".push(temp_" + . $f_function . ");" . PHP_EOL . Indent::_(1) + . "}"; + $func .= PHP_EOL . Indent::_(1) . "else if (!isSet(" + . $a_matchKey . "))" . PHP_EOL . Indent::_(1) + . "{"; + $func .= PHP_EOL . Indent::_(2) . "var " + . $a_matchKey . " = [];"; + $func .= PHP_EOL . Indent::_(1) . "}"; + $func .= PHP_EOL . Indent::_(1) . "var " . $name + . " = " . $a_matchKey . ".some(" . $a_matchKey + . "_SomeFunc);" . PHP_EOL; + + // setup the map function + $map .= PHP_EOL . "//" . Line::_(__Line__, __Class__) + . " the " . $f_function . " Some function"; + $map .= PHP_EOL . "function " . $a_matchKey + . "_SomeFunc(" . $a_matchKey . ")"; + $map .= PHP_EOL . "{"; + $map .= PHP_EOL . Indent::_(1) . "//" + . Line::_(__Line__, __Class__) + . " set the function logic"; + $map .= PHP_EOL . Indent::_(1) . "if ("; + $if = $ifValue[$a_matchKey]; + if (StringHelper::check($if)) + { + $map .= $if; + } + $map .= ")"; + $map .= PHP_EOL . Indent::_(1) . "{"; + $map .= PHP_EOL . Indent::_(2) . "return true;"; + $map .= PHP_EOL . Indent::_(1) . "}" . PHP_EOL + . Indent::_(1) . "return false;"; + $map .= PHP_EOL . "}" . PHP_EOL; + } + $func .= PHP_EOL . PHP_EOL . Indent::_(1) . "//" + . Line::_(__Line__, __Class__) + . " set this function logic"; + $func .= PHP_EOL . Indent::_(1) . "if ("; + // set if counter + $aifcounter = 0; + foreach ($f_matchKeys as $af_matchKey) + { + $name = $matchNames[$af_matchKey]; + if ($aifcounter == 0) + { + $func .= $name; + } + else + { + $func .= ' && ' . $name; + } + $aifcounter++; + } + $func .= ")" . PHP_EOL . Indent::_(1) . "{"; + } + else + { + $func .= PHP_EOL . Indent::_(1) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " set the function logic"; + $func .= PHP_EOL . Indent::_(1) . "if ("; + // set if counter + $ifcounter = 0; + foreach ($f_matchKeys as $f_matchKey) + { + $if = $ifValue[$f_matchKey]; + if (StringHelper::check($if)) + { + if ($ifcounter == 0) + { + $func .= $if; + } + else + { + $func .= ' && ' . $if; + } + $ifcounter++; + } + } + $func .= ")" . PHP_EOL . Indent::_(1) . "{"; + } + // get the controles + $controls = $targetControls[$f_matchKeys[0]]; + // get target behavior and default + $targetBehavior = $behaviors[$f_matchKeys[0]]; + $targetDefault = $defaults[$f_matchKeys[0]]; + // load the target behavior + foreach ($controls as $target => $action) + { + $func .= $action['behavior']; + if (StringHelper::check( + $action[$targetBehavior] + )) + { + $func .= $action[$targetBehavior]; + $head .= $action['requiredVar']; + } + } + // check if this is a toggle switch + if ($toggleSwitch[$f_matchKeys[0]]) + { + $func .= PHP_EOL . Indent::_(1) . "}" . PHP_EOL + . Indent::_(1) . "else" . PHP_EOL . Indent::_(1) + . "{"; + // load the default behavior + foreach ($controls as $target => $action) + { + $func .= $action['default']; + if (StringHelper::check( + $action[$targetDefault] + )) + { + $func .= $action[$targetDefault]; + } + } + } + $func .= PHP_EOL . Indent::_(1) . "}" . PHP_EOL . "}" + . PHP_EOL . $map; + } + // add the needed validation to file + if (isset($this->validationFixBuilder[$nameSingleCode]) + && ArrayHelper::check( + $this->validationFixBuilder[$nameSingleCode] + )) + { + $validation .= PHP_EOL . "// update fields required"; + $validation .= PHP_EOL + . "function updateFieldRequired(name, status) {"; + $validation .= PHP_EOL . Indent::_(1) + . "// check if not_required exist"; + $validation .= PHP_EOL . Indent::_(1) + . "if (document.getElementById('jform_not_required')) {"; + $validation .= PHP_EOL . Indent::_(2) + . "var not_required = jQuery('#jform_not_required').val().split(\",\");"; + $validation .= PHP_EOL . PHP_EOL . Indent::_(2) + . "if(status == 1)"; + $validation .= PHP_EOL . Indent::_(2) . "{"; + $validation .= PHP_EOL . Indent::_(3) + . "not_required.push(name);"; + $validation .= PHP_EOL . Indent::_(2) . "}"; + $validation .= PHP_EOL . Indent::_(2) . "else"; + $validation .= PHP_EOL . Indent::_(2) . "{"; + $validation .= PHP_EOL . Indent::_(3) + . "not_required = removeFieldFromNotRequired(not_required, name);"; + $validation .= PHP_EOL . Indent::_(2) . "}"; + $validation .= PHP_EOL . PHP_EOL . Indent::_(2) + . "jQuery('#jform_not_required').val(fixNotRequiredArray(not_required).toString());"; + $validation .= PHP_EOL . Indent::_(1) . "}"; + $validation .= PHP_EOL . "}" . PHP_EOL; + $validation .= PHP_EOL + . "// remove field from not_required"; + $validation .= PHP_EOL + . "function removeFieldFromNotRequired(array, what) {"; + $validation .= PHP_EOL . Indent::_(1) + . "return array.filter(function(element){"; + $validation .= PHP_EOL . Indent::_(2) + . "return element !== what;"; + $validation .= PHP_EOL . Indent::_(1) . "});"; + $validation .= PHP_EOL . "}" . PHP_EOL; + $validation .= PHP_EOL . "// fix not required array"; + $validation .= PHP_EOL + . "function fixNotRequiredArray(array) {"; + $validation .= PHP_EOL . Indent::_(1) . "var seen = {};"; + $validation .= PHP_EOL . Indent::_(1) + . "return removeEmptyFromNotRequiredArray(array).filter(function(item) {"; + $validation .= PHP_EOL . Indent::_(2) + . "return seen.hasOwnProperty(item) ? false : (seen[item] = true);"; + $validation .= PHP_EOL . Indent::_(1) . "});"; + $validation .= PHP_EOL . "}" . PHP_EOL; + $validation .= PHP_EOL + . "// remove empty from not_required array"; + $validation .= PHP_EOL + . "function removeEmptyFromNotRequiredArray(array) {"; + $validation .= PHP_EOL . Indent::_(1) + . "return array.filter(function (el) {"; + $validation .= PHP_EOL . Indent::_(2) + . "// remove ( 一_一) as well - lol"; + $validation .= PHP_EOL . Indent::_(2) + . "return (el.length > 0 && '一_一' !== el);"; + $validation .= PHP_EOL . Indent::_(1) . "});"; + $validation .= PHP_EOL . "}" . PHP_EOL; + } + // set the isSet function + $isSet = PHP_EOL . "// the isSet function"; + $isSet .= PHP_EOL . "function isSet(val)"; + $isSet .= PHP_EOL . "{"; + $isSet .= PHP_EOL . Indent::_(1) + . "if ((val != undefined) && (val != null) && 0 !== val.length){"; + $isSet .= PHP_EOL . Indent::_(2) . "return true;"; + $isSet .= PHP_EOL . Indent::_(1) . "}"; + $isSet .= PHP_EOL . Indent::_(1) . "return false;"; + $isSet .= PHP_EOL . "}"; + } + // load to this buket + $fileScript = $initial . $func . $validation . $isSet; + $footerScript = $listener; + } + // add custom script to edit form JS file + if (!isset($fileScript)) + { + $fileScript = ''; + } + $fileScript .= CFactory::_('Customcode.Dispenser')->get( + 'view_file', $nameSingleCode, PHP_EOL . PHP_EOL, null, true, '' + ); + // add custom script to footer + if (isset(CFactory::_('Customcode.Dispenser')->hub['view_footer'][$nameSingleCode]) + && StringHelper::check( + CFactory::_('Customcode.Dispenser')->hub['view_footer'][$nameSingleCode] + )) + { + $customFooterScript = PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( + CFactory::_('Customcode.Dispenser')->hub['view_footer'][$nameSingleCode] + ); + if (strpos($customFooterScript, 'name_list_code; + // add custom script to list view JS file + if (($list_fileScript = CFactory::_('Customcode.Dispenser')->get( + 'views_file', $nameSingleCode, PHP_EOL . PHP_EOL, null, true, + false + )) !== false + && StringHelper::check($list_fileScript)) + { + // get dates + $_created = CFactory::_('Model.Createdate')->get($viewArray); + $_modified = CFactory::_('Model.Modifieddate')->get($viewArray); + // add file to view + $_target = array(CFactory::_('Config')->build_target => $nameListCode); + $_config = array(Placefix::_h('CREATIONDATE') => $_created, + Placefix::_h('BUILDDATE') => $_modified, + Placefix::_h('VERSION') => $viewArray['settings']->version); + CFactory::_('Utilities.Structure')->build($_target, 'javascript_file', false, $_config); + // set path + $_path = '/administrator/components/com_' . CFactory::_('Config')->component_code_name + . '/assets/js/' . $nameListCode . '.js'; + // load the file to the list view + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_ADD_JAVASCRIPT_FILE', PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Add List View JavaScript File" . PHP_EOL . Indent::_(2) + . $this->setIncludeLibScript($_path) + ); + } + else + { + $list_fileScript = ''; + CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_ADD_JAVASCRIPT_FILE', ''); + } + // minify the script + if (CFactory::_('Config')->get('minify', 0) && isset($list_fileScript) + && StringHelper::check($list_fileScript)) + { + // minify the fileScript javascript + $list_fileScript = Minify::js($list_fileScript); + } + // minify the script + if (CFactory::_('Config')->get('minify', 0) && isset($fileScript) + && StringHelper::check($fileScript)) + { + // minify the fileScript javascript + $fileScript = Minify::js($fileScript); + } + // minify the script + if (CFactory::_('Config')->get('minify', 0) && isset($footerScript) + && StringHelper::check($footerScript)) + { + // minify the footerScript javascript + $footerScript = Minify::js($footerScript); + } + // make sure there is script to add + if (isset($list_fileScript) + && StringHelper::check( + $list_fileScript + )) + { + // load the script + $this->viewScriptBuilder[$nameListCode]['list_fileScript'] + = $list_fileScript; + } + // make sure there is script to add + if (isset($fileScript) + && StringHelper::check( + $fileScript + )) + { + // add the head script if set + if (isset($head) && StringHelper::check($head)) + { + $fileScript = "// Some Global Values" . PHP_EOL . $head + . PHP_EOL . $fileScript; + } + // load the script + $this->viewScriptBuilder[$nameSingleCode]['fileScript'] + = $fileScript; + } + // make sure to add custom footer script if php was found in it, since we canot minfy it with php + if (isset($customFooterScript) + && StringHelper::check( + $customFooterScript + )) + { + if (!isset($footerScript)) + { + $footerScript = ''; + } + $footerScript .= $customFooterScript; + } + // make sure there is script to add + if (isset($footerScript) + && StringHelper::check( + $footerScript + )) + { + // add the needed script tags + $footerScript = PHP_EOL + . PHP_EOL . '"; + $this->viewScriptBuilder[$nameSingleCode]['footerScript'] + = $footerScript; + } + } + + public function buildFunctionCall($function, $matchKeys, $getValue) + { + $initial = ''; + $funcsets = []; + $array = false; + foreach ($matchKeys as $matchKey) + { + $value = $getValue[$matchKey]; + if ($value['isArray']) + { + $initial .= PHP_EOL . Indent::_(1) . $value['get']; + $funcsets[] = $matchKey; + $array = true; + } + else + { + $initial .= PHP_EOL . Indent::_(1) . $value['get']; + $funcsets[] = $matchKey; + } + } + + // make sure that the function is loaded only once + if (ArrayHelper::check($funcsets)) + { + $initial .= PHP_EOL . Indent::_(1) . $function . "("; + $initial .= implode(',', $funcsets); + $initial .= ");" . PHP_EOL; + } + + return array('code' => $initial, 'array' => $array); + } + + public function getTargetRelationScript($relations, $condition, $view) + { + // reset the buket + $buket = []; + // convert to name array + foreach ($condition['target_field'] as $targetField) + { + if (ArrayHelper::check($targetField) + && isset($targetField['name'])) + { + $currentTargets[] = $targetField['name']; + } + } + // start the search + foreach ($relations as $relation) + { + // reset found + $found = false; + // chain only none matching fields + if ($relation['match_field'] !== $condition['match_field'] + && $relation['target_relation']) // Made this change to see if it improves the expected result (TODO) + { + if (ArrayHelper::check( + $relation['target_field'] + )) + { + foreach ($relation['target_field'] as $target) + { + if (ArrayHelper::check($target) + && $this->checkRelationControl( + $target['name'], $relation['match_name'], + $condition['match_name'], $view + )) + { + if (in_array($target['name'], $currentTargets)) + { + $this->targetRelationControl[$view][$target['name']] + = array($relation['match_name'], + $condition['match_name']); + $found = true; + break; + } + } + } + if ($found) + { + $buket[] = $relation; + } + } + } + } + + return $buket; + } + + public function checkRelationControl($targetName, $relationMatchName, + $conditionMatchName, $view + ) + { + if (isset($this->targetRelationControl[$view]) + && ArrayHelper::check( + $this->targetRelationControl[$view] + )) + { + if (isset($this->targetRelationControl[$view][$targetName]) + && ArrayHelper::check( + $this->targetRelationControl[$view][$targetName] + )) + { + if (!in_array( + $relationMatchName, + $this->targetRelationControl[$view][$targetName] + ) + || !in_array( + $conditionMatchName, + $this->targetRelationControl[$view][$targetName] + )) + { + return true; + } + } + else + { + return true; + } + } + elseif (!isset($this->targetRelationControl[$view]) + || !ArrayHelper::check( + $this->targetRelationControl[$view] + )) + { + return true; + } + + return false; + } + + public function setTargetControlsScript($toggleSwitch, $targets, + $targetBehavior, $targetDefault, $uniqueVar, $nameSingleCode + ) + { + $bucket = []; + if (ArrayHelper::check($targets) + && !in_array( + $uniqueVar, $this->targetControlsScriptChecker + )) + { + foreach ($targets as $target) + { + if (ArrayHelper::check($target)) + { + // set the required var + if ($target['required'] === 'yes') + { + $unique = $uniqueVar + . $this->uniquekey(3); + $bucket[$target['name']]['requiredVar'] = "jform_" + . $unique . "_required = false;" . PHP_EOL; + } + else + { + $bucket[$target['name']]['requiredVar'] = ''; + } + // set target type + $targetTypeSufix = ""; + if (CFactory::_('Field.Groups')->check( + $target['type'], 'spacer' + )) + { + // target a class if this is a note or spacer + $targetType = "."; + } + elseif ($target['type'] === 'editor' + || $target['type'] === 'subform') + { + // target the label if editor field + $targetType = "#jform_"; + // since the id is not alway accessable we use the lable TODO (not best way) + $targetTypeSufix = "-lbl"; + } + else + { + // target an id if this is a field + $targetType = "#jform_"; + } + // set the target behavior + $bucket[$target['name']]['behavior'] = PHP_EOL . Indent::_( + 2 + ) . "jQuery('" . $targetType . $target['name'] + . $targetTypeSufix . "').closest('.control-group')." + . $targetBehavior . "();"; + // set the target default + $bucket[$target['name']]['default'] = PHP_EOL . Indent::_(2) + . "jQuery('" . $targetType . $target['name'] + . $targetTypeSufix . "').closest('.control-group')." + . $targetDefault . "();"; + // the hide required function + if ($target['required'] === 'yes') + { + if ($toggleSwitch) + { + $hide = PHP_EOL + . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " remove required attribute from " + . $target['name'] . " field"; + $hide .= PHP_EOL + . Indent::_(2) . "if (!jform_" . $unique + . "_required)"; + $hide .= PHP_EOL + . Indent::_(2) . "{"; + $hide .= PHP_EOL + . Indent::_(3) . "updateFieldRequired('" + . $target['name'] . "',1);"; + $hide .= PHP_EOL + . Indent::_(3) . "jQuery('#jform_" + . $target['name'] + . "').removeAttr('required');"; + $hide .= PHP_EOL + . Indent::_(3) . "jQuery('#jform_" + . $target['name'] + . "').removeAttr('aria-required');"; + $hide .= PHP_EOL + . Indent::_(3) . "jQuery('#jform_" + . $target['name'] + . "').removeClass('required');"; + $hide .= PHP_EOL + . Indent::_(3) . "jform_" . $unique + . "_required = true;"; + $hide .= PHP_EOL + . Indent::_(2) . "}"; + $bucket[$target['name']]['hide'] = $hide; + // the show required function + $show = PHP_EOL + . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " add required attribute to " + . $target['name'] . " field"; + $show .= PHP_EOL + . Indent::_(2) . "if (jform_" . $unique + . "_required)"; + $show .= PHP_EOL + . Indent::_(2) . "{"; + $show .= PHP_EOL + . Indent::_(3) . "updateFieldRequired('" + . $target['name'] . "',0);"; + $show .= PHP_EOL + . Indent::_(3) . "jQuery('#jform_" + . $target['name'] + . "').prop('required','required');"; + $show .= PHP_EOL + . Indent::_(3) . "jQuery('#jform_" + . $target['name'] + . "').attr('aria-required',true);"; + $show .= PHP_EOL + . Indent::_(3) . "jQuery('#jform_" + . $target['name'] . "').addClass('required');"; + $show .= PHP_EOL + . Indent::_(3) . "jform_" . $unique + . "_required = false;"; + $show .= PHP_EOL + . Indent::_(2) . "}"; + $bucket[$target['name']]['show'] = $show; + } + else + { + $hide = PHP_EOL + . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " remove required attribute from " + . $target['name'] . " field"; + $hide .= PHP_EOL + . Indent::_(2) . "updateFieldRequired('" + . $target['name'] . "',1);"; + $hide .= PHP_EOL + . Indent::_(2) . "jQuery('#jform_" + . $target['name'] + . "').removeAttr('required');"; + $hide .= PHP_EOL + . Indent::_(2) . "jQuery('#jform_" + . $target['name'] + . "').removeAttr('aria-required');"; + $hide .= PHP_EOL + . Indent::_(2) . "jQuery('#jform_" + . $target['name'] + . "').removeClass('required');"; + $hide .= PHP_EOL + . Indent::_(2) . "jform_" . $unique + . "_required = true;" . PHP_EOL; + $bucket[$target['name']]['hide'] = $hide; + // the show required function + $show = PHP_EOL + . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " add required attribute to " + . $target['name'] . " field"; + $show .= PHP_EOL + . Indent::_(2) . "updateFieldRequired('" + . $target['name'] . "',0);"; + $show .= PHP_EOL + . Indent::_(2) . "jQuery('#jform_" + . $target['name'] + . "').prop('required','required');"; + $show .= PHP_EOL + . Indent::_(2) . "jQuery('#jform_" + . $target['name'] + . "').attr('aria-required',true);"; + $show .= PHP_EOL + . Indent::_(2) . "jQuery('#jform_" + . $target['name'] . "').addClass('required');"; + $show .= PHP_EOL + . Indent::_(2) . "jform_" . $unique + . "_required = false;" . PHP_EOL; + $bucket[$target['name']]['show'] = $show; + } + // make sure that the axaj and other needed things for this view is loaded + $this->validationFixBuilder[$nameSingleCode][] + = $target['name']; + } + else + { + $bucket[$target['name']]['hide'] = ''; + $bucket[$target['name']]['show'] = ''; + } + } + } + $this->targetControlsScriptChecker[] = $uniqueVar; + } + + return $bucket; + } + + public function ifValueScript($value, $behavior, $type, $options) + { + // reset string + $string = ''; + switch ($behavior) + { + case 1: // Is + // only 4 list/radio/checkboxes + if (CFactory::_('Field.Groups')->check($type, 'list') + || CFactory::_('Field.Groups')->check($type, 'dynamic') + || !CFactory::_('Field.Groups')->check($type)) + { + if (ArrayHelper::check($options)) + { + foreach ($options as $option) + { + if (!is_numeric($option)) + { + if ($option != 'true' && $option != 'false') + { + $option = "'" . $option . "'"; + } + } + if (StringHelper::check($string)) + { + $string .= ' || ' . $value . ' == ' . $option; + } + else + { + $string .= $value . ' == ' . $option; + } + } + } + else + { + $string .= 'isSet(' . $value . ')'; + } + } + break; + case 2: // Is Not + // only 4 list/radio/checkboxes + if (CFactory::_('Field.Groups')->check($type, 'list') + || CFactory::_('Field.Groups')->check($type, 'dynamic') + || !CFactory::_('Field.Groups')->check($type)) + { + if (ArrayHelper::check($options)) + { + foreach ($options as $option) + { + if (!is_numeric($option)) + { + if ($option != 'true' && $option != 'false') + { + $option = "'" . $option . "'"; + } + } + if (StringHelper::check($string)) + { + $string .= ' || ' . $value . ' != ' . $option; + } + else + { + $string .= $value . ' != ' . $option; + } + } + } + else + { + $string .= '!isSet(' . $value . ')'; + } + } + break; + case 3: // Any Selection + // only 4 list/radio/checkboxes/dynamic_list + if (CFactory::_('Field.Groups')->check($type, 'list') + || CFactory::_('Field.Groups')->check($type, 'dynamic') + || !CFactory::_('Field.Groups')->check($type)) + { + if (ArrayHelper::check($options)) + { + foreach ($options as $option) + { + if (!is_numeric($option)) + { + if ($option != 'true' && $option != 'false') + { + $option = "'" . $option . "'"; + } + } + if (StringHelper::check($string)) + { + $string .= ' || ' . $value . ' == ' . $option; + } + else + { + $string .= $value . ' == ' . $option; + } + } + } + else + { + $userFix = ''; + if (CFactory::_('Compiler.Builder.Script.User.Switch')->inArray($type)) + { + // TODO this needs a closer look, a bit buggy + $userFix = " && " . $value . " != 0"; + } + $string .= 'isSet(' . $value . ')' . $userFix; + } + } + break; + case 4: // Active (not empty) + // only 4 text_field + if (CFactory::_('Field.Groups')->check($type, 'text')) + { + $string .= 'isSet(' . $value . ')'; + } + break; + case 5: // Unactive (empty) + // only 4 text_field + if (CFactory::_('Field.Groups')->check($type, 'text')) + { + $string .= '!isSet(' . $value . ')'; + } + break; + case 6: // Key Word All (case-sensitive) + // only 4 text_field + if (CFactory::_('Field.Groups')->check($type, 'text')) + { + if (ArrayHelper::check( + $options['keywords'] + )) + { + foreach ($options['keywords'] as $keyword) + { + if (StringHelper::check($string)) + { + $string .= ' && ' . $value . '.indexOf("' + . $keyword . '") >= 0'; + } + else + { + $string .= $value . '.indexOf("' . $keyword + . '") >= 0'; + } + } + } + if (!StringHelper::check($string)) + { + $string .= $value . ' == "error"'; + } + } + break; + case 7: // Key Word Any (case-sensitive) + // only 4 text_field + if (CFactory::_('Field.Groups')->check($type, 'text')) + { + if (ArrayHelper::check( + $options['keywords'] + )) + { + foreach ($options['keywords'] as $keyword) + { + if (StringHelper::check($string)) + { + $string .= ' || ' . $value . '.indexOf("' + . $keyword . '") >= 0'; + } + else + { + $string .= $value . '.indexOf("' . $keyword + . '") >= 0'; + } + } + } + if (!StringHelper::check($string)) + { + $string .= $value . ' == "error"'; + } + } + break; + case 8: // Key Word All (case-insensitive) + // only 4 text_field + if (CFactory::_('Field.Groups')->check($type, 'text')) + { + if (ArrayHelper::check( + $options['keywords'] + )) + { + foreach ($options['keywords'] as $keyword) + { + $keyword = StringHelper::safe( + $keyword, 'w' + ); + if (StringHelper::check($string)) + { + $string .= ' && ' . $value + . '.toLowerCase().indexOf("' . $keyword + . '") >= 0'; + } + else + { + $string .= $value . '.toLowerCase().indexOf("' + . $keyword . '") >= 0'; + } + } + } + if (!StringHelper::check($string)) + { + $string .= $value . ' == "error"'; + } + } + break; + case 9: // Key Word Any (case-insensitive) + // only 4 text_field + if (CFactory::_('Field.Groups')->check($type, 'text')) + { + if (ArrayHelper::check( + $options['keywords'] + )) + { + foreach ($options['keywords'] as $keyword) + { + $keyword = StringHelper::safe( + $keyword, 'w' + ); + if (StringHelper::check($string)) + { + $string .= ' || ' . $value + . '.toLowerCase().indexOf("' . $keyword + . '") >= 0'; + } + else + { + $string .= $value . '.toLowerCase().indexOf("' + . $keyword . '") >= 0'; + } + } + } + if (!StringHelper::check($string)) + { + $string .= $value . ' == "error"'; + } + } + break; + case 10: // Min Length + // only 4 text_field + if (CFactory::_('Field.Groups')->check($type, 'text')) + { + if (ArrayHelper::check($options)) + { + if ($options['length']) + { + $string .= $value . '.length >= ' + . (int) $options['length']; + } + } + if (!StringHelper::check($string)) + { + $string .= $value . '.length >= 5'; + } + } + break; + case 11: // Max Length + // only 4 text_field + if (CFactory::_('Field.Groups')->check($type, 'text')) + { + if (ArrayHelper::check($options)) + { + if ($options['length']) + { + $string .= $value . '.length <= ' + . (int) $options['length']; + } + } + if (!StringHelper::check($string)) + { + $string .= $value . '.length <= 5'; + } + } + break; + case 12: // Exact Length + // only 4 text_field + if (CFactory::_('Field.Groups')->check($type, 'text')) + { + if (ArrayHelper::check($options)) + { + if ($options['length']) + { + $string .= $value . '.length == ' + . (int) $options['length']; + } + } + if (!StringHelper::check($string)) + { + $string .= $value . '.length == 5'; + } + } + break; + } + if (!StringHelper::check($string)) + { + $string = 0; + } + + return $string; + } + + public function getOptionsScript($type, $options) + { + $buket = []; + if (StringHelper::check($options)) + { + if (CFactory::_('Field.Groups')->check($type, 'list') + || CFactory::_('Field.Groups')->check($type, 'dynamic') + || !CFactory::_('Field.Groups')->check($type)) + { + $optionsArray = array_map( + 'trim', (array) explode(PHP_EOL, (string) $options) + ); + if (!ArrayHelper::check($optionsArray)) + { + $optionsArray[] = $optionsArray; + } + foreach ($optionsArray as $option) + { + if (strpos($option, '|') !== false) + { + list($option) = array_map( + 'trim', (array) explode('|', $option) + ); + } + if ($option != 'dynamic_list') + { + // add option to return buket + $buket[] = $option; + } + } + } + elseif (CFactory::_('Field.Groups')->check($type, 'text')) + { + // check to get the key words if set + $keywords = GetHelper::between( + $options, 'keywords="', '"' + ); + if (StringHelper::check($keywords)) + { + if (strpos((string) $keywords, ',') !== false) + { + $keywords = array_map( + 'trim', (array) explode(',', (string) $keywords) + ); + foreach ($keywords as $keyword) + { + $buket['keywords'][] = trim($keyword); + } + } + else + { + $buket['keywords'][] = trim((string) $keywords); + } + } + // check to ket string length if set + $length = GetHelper::between( + $options, 'length="', '"' + ); + if (StringHelper::check($length)) + { + $buket['length'] = $length; + } + else + { + $buket['length'] = false; + } + } + } + + return $buket; + } + + public function getValueScript($type, $name, $extends, $unique) + { + $select = ''; + $isArray = false; + $keyName = $name . '_' . $unique; + if ($type === 'checkboxes' || $extends === 'checkboxes') + { + $select = "var " . $keyName . " = [];" . PHP_EOL . Indent::_(1) + . "jQuery('#jform_" . $name + . " input[type=checkbox]').each(function()" . PHP_EOL + . Indent::_(1) . "{" . PHP_EOL . Indent::_(2) + . "if (jQuery(this).is(':checked'))" . PHP_EOL . Indent::_(2) + . "{" . PHP_EOL . Indent::_(3) . $keyName + . ".push(jQuery(this).prop('value'));" . PHP_EOL . Indent::_(2) + . "}" . PHP_EOL . Indent::_(1) . "});"; + $isArray = true; + } + elseif ($type === 'checkbox') + { + $select = 'var ' . $keyName . ' = jQuery("#jform_' . $name + . '").prop(\'checked\');'; + } + elseif ($type === 'radio') + { + $select = 'var ' . $keyName . ' = jQuery("#jform_' . $name + . ' input[type=\'radio\']:checked").val();'; + } + elseif (CFactory::_('Compiler.Builder.Script.User.Switch')->inArray($type)) + { + // this is only since 3.3.4 + $select = 'var ' . $keyName . ' = jQuery("#jform_' . $name + . '_id").val();'; + } + elseif ($type === 'list' + || CFactory::_('Field.Groups')->check( + $type, 'dynamic' + ) + || !CFactory::_('Field.Groups')->check($type)) + { + $select = 'var ' . $keyName . ' = jQuery("#jform_' . $name + . '").val();'; + $isArray = true; + } + elseif (CFactory::_('Field.Groups')->check($type, 'text')) + { + $select = 'var ' . $keyName . ' = jQuery("#jform_' . $name + . '").val();'; + } + + return array('get' => $select, 'isArray' => $isArray); + } + + public function clearValueScript($type, $name, $unique) + { + $clear = ''; + $isArray = false; + $keyName = $name . '_' . $unique; + if ($type === 'text' || $type === 'password' || $type === 'textarea') + { + $clear = "jQuery('#jform_" . $name . "').value = '';"; + } + elseif ($type === 'radio') + { + $clear = "jQuery('#jform_" . $name . "').checked = false;"; + } + elseif ($type === 'checkboxes' || $type === 'checkbox' + || $type === 'checkbox') + { + $clear = "jQuery('#jform_" . $name . "').selectedIndex = -1;"; + } + + return $clear; + } + + public function setViewScript(&$view, $type) + { + if (isset($this->viewScriptBuilder[$view]) + && isset($this->viewScriptBuilder[$view][$type])) + { + return $this->viewScriptBuilder[$view][$type]; + } + + return ''; + } + + public function setValidationFix($view, $Component) + { + $fix = ''; + if (isset($this->validationFixBuilder[$view]) + && ArrayHelper::check( + $this->validationFixBuilder[$view] + )) + { + $fix .= PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $fix .= PHP_EOL . Indent::_(1) + . " * Method to validate the form data."; + $fix .= PHP_EOL . Indent::_(1) . " *"; + $fix .= PHP_EOL . Indent::_(1) + . " * @param JForm \$form The form to validate against."; + $fix .= PHP_EOL . Indent::_(1) + . " * @param array \$data The data to validate."; + $fix .= PHP_EOL . Indent::_(1) + . " * @param string \$group The name of the field group to validate."; + $fix .= PHP_EOL . Indent::_(1) . " *"; + $fix .= PHP_EOL . Indent::_(1) + . " * @return mixed Array of filtered data if valid, false otherwise."; + $fix .= PHP_EOL . Indent::_(1) . " *"; + $fix .= PHP_EOL . Indent::_(1) . " * @see JFormRule"; + $fix .= PHP_EOL . Indent::_(1) . " * @see JFilterInput"; + $fix .= PHP_EOL . Indent::_(1) . " * @since 12.2"; + $fix .= PHP_EOL . Indent::_(1) . " */"; + $fix .= PHP_EOL . Indent::_(1) + . "public function validate(\$form, \$data, \$group = null)"; + $fix .= PHP_EOL . Indent::_(1) . "{"; + $fix .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " check if the not_required field is set"; + $fix .= PHP_EOL . Indent::_(2) + . "if (isset(\$data['not_required']) && " + . "Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$data['not_required']))"; + $fix .= PHP_EOL . Indent::_(2) . "{"; + $fix .= PHP_EOL . Indent::_(3) + . "\$requiredFields = (array) explode(',',(string) \$data['not_required']);"; + $fix .= PHP_EOL . Indent::_(3) + . "\$requiredFields = array_unique(\$requiredFields);"; + $fix .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " now change the required field attributes value"; + $fix .= PHP_EOL . Indent::_(3) + . "foreach (\$requiredFields as \$requiredField)"; + $fix .= PHP_EOL . Indent::_(3) . "{"; + $fix .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " make sure there is a string value"; + $fix .= PHP_EOL . Indent::_(4) . "if (" + . "Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$requiredField))"; + $fix .= PHP_EOL . Indent::_(4) . "{"; + $fix .= PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " change to false"; + $fix .= PHP_EOL . Indent::_(5) + . "\$form->setFieldAttribute(\$requiredField, 'required', 'false');"; + $fix .= PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " also clear the data set"; + $fix .= PHP_EOL . Indent::_(5) . "\$data[\$requiredField] = '';"; + $fix .= PHP_EOL . Indent::_(4) . "}"; + $fix .= PHP_EOL . Indent::_(3) . "}"; + $fix .= PHP_EOL . Indent::_(2) . "}"; + $fix .= PHP_EOL . Indent::_(2) + . "return parent::validate(\$form, \$data, \$group);"; + $fix .= PHP_EOL . Indent::_(1) . "}"; + } + + return $fix; + } + + public function setAjaxToke(&$view) + { + $fix = ''; + if (isset(CFactory::_('Customcode.Dispenser')->hub['token'][$view]) + && CFactory::_('Customcode.Dispenser')->hub['token'][$view]) + { + $fix .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Add Ajax Token"; + $fix .= PHP_EOL . Indent::_(2) + . "\$this->getDocument()->addScriptDeclaration(\"var token = '\" . Session::getFormToken() . \"';\");"; + } + + return $fix; + } + + public function setRegisterAjaxTask($target) + { + $tasks = ''; + if (isset(CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller']) + && ArrayHelper::check( + CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller'] + )) + { + $taskArray = []; + foreach ( + CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller'] as $view + ) + { + foreach ($view as $task) + { + $taskArray[$task['task_name']] = $task['task_name']; + } + } + if (ArrayHelper::check($taskArray)) + { + foreach ($taskArray as $name) + { + $tasks .= PHP_EOL . Indent::_(2) . "\$this->registerTask('" + . $name . "', 'ajax');"; + } + } + } + + return $tasks; + } + + public function setAjaxInputReturn($target) + { + $cases = ''; + if (isset(CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller']) + && ArrayHelper::check( + CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller'] + )) + { + $input = []; + $valueArray = []; + $ifArray = []; + $getModel = []; + $userCheck = []; + $prefix = ($target == 'site') ? 'Site':'Administrator'; + $isJoomla3 = (CFactory::_('Config')->get('joomla_version', 3) == 3); + $failed = "false"; + if (!$isJoomla3) + { + $failed = "['error' => 'There was an error! [149]']"; + } + foreach ( + CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller'] as $view + ) + { + foreach ($view as $task) + { + $input[$task['task_name']][] = "\$" + . $task['value_name'] . "Value = \$jinput->get('" + . $task['value_name'] . "', " . $task['input_default'] + . ", '" . $task['input_filter'] . "');"; + $valueArray[$task['task_name']][] = "\$" + . $task['value_name'] . "Value"; + $getModel[$task['task_name']] = + "\$result = \$ajaxModule->" + . $task['method_name'] . "(" . Placefix::_("valueArray") . ");"; + // check if null or zero is allowed + if (!isset($task['allow_zero']) || 1 != $task['allow_zero']) + { + $ifArray[$task['task_name']][] = "\$" + . $task['value_name'] . "Value"; + } + // see user check is needed + if (!isset($userCheck[$task['task_name']]) + && isset($task['user_check']) + && 1 == $task['user_check']) + { + // add it since this means it was not set, and in the old method we assumed it was inplace + // or it is set and 1 means we still want it inplace + $ifArray[$task['task_name']][] = '$user->id != 0'; + // add it only once + $userCheck[$task['task_name']] = true; + } + } + } + if (ArrayHelper::check($getModel)) + { + foreach ($getModel as $task => $getMethod) + { + $cases .= PHP_EOL . Indent::_(4) . "case '" . $task . "':"; + $cases .= PHP_EOL . Indent::_(5) . "try"; + $cases .= PHP_EOL . Indent::_(5) . "{"; + foreach ($input[$task] as $string) + { + $cases .= PHP_EOL . Indent::_(6) . $string; + } + // set the values + $values = implode(', ', $valueArray[$task]); + // set the values to method + $getMethod = str_replace( + Placefix::_('valueArray'), $values, + $getMethod + ); + // check if we have some values to check + if (isset($ifArray[$task]) + && ArrayHelper::check($ifArray[$task])) + { + // set if string + $ifvalues = implode(' && ', $ifArray[$task]); + // add to case + $cases .= PHP_EOL . Indent::_(6) . "if(" . $ifvalues + . ")"; + $cases .= PHP_EOL . Indent::_(6) . "{"; + if ($isJoomla3) + { + $cases .= PHP_EOL . Indent::_(7) . "\$ajaxModule = \$this->getModel('ajax');"; + } + else + { + $cases .= PHP_EOL . Indent::_(7) . "\$ajaxModule = \$this->getModel('ajax', '$prefix');"; + } + $cases .= PHP_EOL . Indent::_(7) . "if (\$ajaxModule)"; + $cases .= PHP_EOL . Indent::_(7) . "{"; + $cases .= PHP_EOL . Indent::_(8) . $getMethod; + $cases .= PHP_EOL . Indent::_(7) . "}"; + $cases .= PHP_EOL . Indent::_(7) . "else"; + $cases .= PHP_EOL . Indent::_(7) . "{"; + $cases .= PHP_EOL . Indent::_(8) . "\$result = $failed;"; + $cases .= PHP_EOL . Indent::_(7) . "}"; + $cases .= PHP_EOL . Indent::_(6) . "}"; + $cases .= PHP_EOL . Indent::_(6) . "else"; + $cases .= PHP_EOL . Indent::_(6) . "{"; + $cases .= PHP_EOL . Indent::_(7) . "\$result = $failed;"; + $cases .= PHP_EOL . Indent::_(6) . "}"; + } + else + { + if ($isJoomla3) + { + $cases .= PHP_EOL . Indent::_(6) . "\$ajaxModule = \$this->getModel('ajax');"; + } + else + { + $cases .= PHP_EOL . Indent::_(6) . "\$ajaxModule = \$this->getModel('ajax', '$prefix');"; + } + $cases .= PHP_EOL . Indent::_(6) . "if (\$ajaxModule)"; + $cases .= PHP_EOL . Indent::_(6) . "{"; + $cases .= PHP_EOL . Indent::_(7) . $getMethod; + $cases .= PHP_EOL . Indent::_(6) . "}"; + $cases .= PHP_EOL . Indent::_(6) . "else"; + $cases .= PHP_EOL . Indent::_(6) . "{"; + $cases .= PHP_EOL . Indent::_(7) . "\$result = $failed;"; + $cases .= PHP_EOL . Indent::_(6) . "}"; + } + // continue the build + $cases .= PHP_EOL . Indent::_(6) + . "if(\$callback)"; + $cases .= PHP_EOL . Indent::_(6) . "{"; + $cases .= PHP_EOL . Indent::_(7) + . "echo \$callback . \"(\".json_encode(\$result).\");\";"; + $cases .= PHP_EOL . Indent::_(6) . "}"; + $cases .= PHP_EOL . Indent::_(6) . "elseif(\$returnRaw)"; + $cases .= PHP_EOL . Indent::_(6) . "{"; + $cases .= PHP_EOL . Indent::_(7) + . "echo json_encode(\$result);"; + $cases .= PHP_EOL . Indent::_(6) . "}"; + $cases .= PHP_EOL . Indent::_(6) . "else"; + $cases .= PHP_EOL . Indent::_(6) . "{"; + $cases .= PHP_EOL . Indent::_(7) + . "echo \"(\".json_encode(\$result).\");\";"; + $cases .= PHP_EOL . Indent::_(6) . "}"; + $cases .= PHP_EOL . Indent::_(5) . "}"; + $cases .= PHP_EOL . Indent::_(5) . "catch(\Exception \$e)"; + $cases .= PHP_EOL . Indent::_(5) . "{"; + $cases .= PHP_EOL . Indent::_(6) + . "if(\$callback)"; + $cases .= PHP_EOL . Indent::_(6) . "{"; + $cases .= PHP_EOL . Indent::_(7) + . "echo \$callback.\"(\".json_encode(\$e).\");\";"; + $cases .= PHP_EOL . Indent::_(6) . "}"; + $cases .= PHP_EOL . Indent::_(6) + . "elseif(\$returnRaw)"; + $cases .= PHP_EOL . Indent::_(6) . "{"; + $cases .= PHP_EOL . Indent::_(7) + . "echo json_encode(\$e);"; + $cases .= PHP_EOL . Indent::_(6) . "}"; + $cases .= PHP_EOL . Indent::_(6) . "else"; + $cases .= PHP_EOL . Indent::_(6) . "{"; + $cases .= PHP_EOL . Indent::_(7) + . "echo \"(\".json_encode(\$e).\");\";"; + $cases .= PHP_EOL . Indent::_(6) . "}"; + $cases .= PHP_EOL . Indent::_(5) . "}"; + $cases .= PHP_EOL . Indent::_(4) . "break;"; + } + } + } + + return $cases; + } + + public function setAjaxModelMethods($target) + { + $methods = ''; + if (isset(CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_model']) + && ArrayHelper::check( + CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_model'] + )) + { + foreach ( + CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_model'] as $view => + $method + ) + { + $methods .= PHP_EOL . PHP_EOL . Indent::_(1) . "//" + . Line::_(__Line__, __Class__) . " Used in " . $view . PHP_EOL; + $methods .= CFactory::_('Placeholder')->update_( + $method + ); + } + } + + return $methods; + } + + public function setJquery(&$view) + { + $addJQuery = ''; + if (true) // TODO we just add it everywhere for now. + { + $addJQuery .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Load jQuery"; + $addJQuery .= PHP_EOL . Indent::_(2) . "Html::_('jquery.framework');"; + } + + return $addJQuery; + } + + /** + * build filter functions + * + * @param string $nameSingleCode The single view name + * @param string $nameListCode The list view name + * + * @return string The php to place in view.html.php + * + */ + public function setFilterFieldHelper(&$nameSingleCode, &$nameListCode) + { + // the old filter type uses these functions + if (CFactory::_('Compiler.Builder.Filter')->exists($nameListCode)) + { + // set the function or file path (2 = topbar) + $funtion_path = true; + if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2) + { + $funtion_path = false; + } + $function = []; + // set component name + $component = CFactory::_('Config')->component_code_name; + $Component = ucfirst((string) $component); + foreach (CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as $filter) + { + if ($filter['type'] != 'category' + && ArrayHelper::check($filter['custom']) + && $filter['custom']['extends'] === 'user') + { + // add if this is a function path + if ($funtion_path) + { + $function[] = PHP_EOL . Indent::_(1) + . "protected function getThe" . $filter['function'] + . StringHelper::safe( + $filter['custom']['text'], 'F' + ) . "Selections()"; + $function[] = Indent::_(1) . "{"; + } + $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Get a db connection."; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $function[] = Indent::_(2) . "\$db = Factory::getDbo();"; + } + else + { + $function[] = Indent::_(2) . "\$db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class);"; + } + $function[] = PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " Create a new query object."; + $function[] = Indent::_(2) + . "\$query = \$db->getQuery(true);"; + $function[] = PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Select the text."; + $function[] = Indent::_(2) + . "\$query->select(\$db->quoteName(array('a." + . $filter['custom']['id'] . "','a." + . $filter['custom']['text'] . "')));"; + $function[] = Indent::_(2) + . "\$query->from(\$db->quoteName('" + . $filter['custom']['table'] . "', 'a'));"; + $function[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " get the targeted groups"; + $function[] = Indent::_(2) + . "\$groups= ComponentHelper::getParams('com_" + . $component . "')->get('" . $filter['type'] . "');"; + $function[] = Indent::_(2) + . "if (!empty(\$groups) && count((array) \$groups) > 0)"; + $function[] = Indent::_(2) . "{"; + $function[] = Indent::_(3) + . "\$query->join('LEFT', \$db->quoteName('#__user_usergroup_map', 'group') . ' ON (' . \$db->quoteName('group.user_id') . ' = ' . \$db->quoteName('a.id') . ')');"; + $function[] = Indent::_(3) + . "\$query->where('group.group_id IN (' . implode(',', \$groups) . ')');"; + $function[] = Indent::_(2) . "}"; + $function[] = Indent::_(2) . "\$query->order('a." + . $filter['custom']['text'] . " ASC');"; + $function[] = PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " Reset the query using our newly populated query object."; + $function[] = Indent::_(2) . "\$db->setQuery(\$query);"; + $function[] = PHP_EOL . Indent::_(2) + . "\$results = \$db->loadObjectList();"; + $function[] = Indent::_(2) . "\$_filter = [];"; + // if this is not a multi field + if (!$funtion_path && $filter['multi'] == 1) + { + $function[] = Indent::_(2) + . "\$_filter[] = Html::_('select.option', '', '- Select ' . Text:" + . ":_('" . $filter['lang'] . "') . ' -');"; + } + $function[] = Indent::_(2) . "if (\$results)"; + $function[] = Indent::_(2) . "{"; + $function[] = Indent::_(3) + . "foreach (\$results as \$result)"; + $function[] = Indent::_(3) . "{"; + $function[] = Indent::_(4) + . "\$_filter[] = Html::_('select.option', \$result->" + . $filter['custom']['id'] . ", \$result->" + . $filter['custom']['text'] . ");"; + $function[] = Indent::_(3) . "}"; + $function[] = Indent::_(2) . "}"; + $function[] = Indent::_(2) . "return \$_filter;"; + // add if this is a function path + if ($funtion_path) + { + $function[] = Indent::_(1) . "}"; + } + + /* else + { + $function[] = PHP_EOL.Indent::_(1) . "protected function getThe".$filter['function'].StringHelper::safe($filter['custom']['text'],'F')."Selections()"; + $function[] = Indent::_(1) . "{"; + $function[] = Indent::_(2) . "//".Line::_(__Line__, __Class__)." Get a db connection."; + $function[] = Indent::_(2) . "\$db = Factory::getDbo();"; + $function[] = PHP_EOL.Indent::_(2) . "//".Line::_(__Line__, __Class__)." Select the text."; + $function[] = Indent::_(2) . "\$query = \$db->getQuery(true);"; + $function[] = PHP_EOL.Indent::_(2) . "//".Line::_(__Line__, __Class__)." Select the text."; + $function[] = Indent::_(2) . "\$query->select(\$db->quoteName(array('".$filter['custom']['id']."','".$filter['custom']['text']."')));"; + $function[] = Indent::_(2) . "\$query->from(\$db->quoteName('".$filter['custom']['table']."'));"; + $function[] = Indent::_(2) . "\$query->where(\$db->quoteName('published') . ' = 1');"; + $function[] = Indent::_(2) . "\$query->order(\$db->quoteName('".$filter['custom']['text']."') . ' ASC');"; + $function[] = PHP_EOL.Indent::_(2) . "//".Line::_(__Line__, __Class__)." Reset the query using our newly populated query object."; + $function[] = Indent::_(2) . "\$db->setQuery(\$query);"; + $function[] = PHP_EOL.Indent::_(2) . "\$results = \$db->loadObjectList();"; + $function[] = PHP_EOL.Indent::_(2) . "if (\$results)"; + $function[] = Indent::_(2) . "{"; + $function[] = Indent::_(3) . "\$filter = [];"; + $function[] = Indent::_(3) . "\$batch = [];"; + $function[] = Indent::_(3) . "foreach (\$results as \$result)"; + $function[] = Indent::_(3) . "{"; + if ($filter['custom']['text'] === 'user') + { + $function[] = Indent::_(4) . "\$filter[] = Html::_('select.option', \$result->".$filter['custom']['text'].", Factory::getUser(\$result->".$filter['custom']['text'].")->name);"; + $function[] = Indent::_(4) . "\$batch[] = Html::_('select.option', \$result->".$filter['custom']['id'].", Factory::getUser(\$result->".$filter['custom']['text'].")->name);"; + } + else + { + $function[] = Indent::_(4) . "\$filter[] = Html::_('select.option', \$result->".$filter['custom']['text'].", \$result->".$filter['custom']['text'].");"; + $function[] = Indent::_(4) . "\$batch[] = Html::_('select.option', \$result->".$filter['custom']['id'].", \$result->".$filter['custom']['text'].");"; + } + $function[] = Indent::_(3) . "}"; + $function[] = Indent::_(3) . "return array('filter' => \$filter, 'batch' => \$batch);"; + $function[] = Indent::_(2) . "}"; + $function[] = Indent::_(2) . "return false;"; + $function[] = Indent::_(1) . "}"; + } */ + } + elseif ($filter['type'] != 'category' + && !ArrayHelper::check($filter['custom'])) + { + $translation = false; + if (CFactory::_('Compiler.Builder.Selection.Translation')-> + exists($nameListCode . '.' . $filter['code'])) + { + $translation = true; + } + // add if this is a function path + if ($funtion_path) + { + $function[] = PHP_EOL . Indent::_(1) + . "protected function getThe" . $filter['function'] + . "Selections()"; + $function[] = Indent::_(1) . "{"; + $function[] = Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) + . " Get a db connection."; + } + else + { + $function[] = "//" . Line::_(__Line__, __Class__) + . " Get a db connection."; + } + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $function[] = Indent::_(2) . "\$db = Factory::getDbo();"; + } + else + { + $function[] = Indent::_(2) . "\$db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class);"; + } + $function[] = PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " Create a new query object."; + $function[] = Indent::_(2) + . "\$query = \$db->getQuery(true);"; + + // check if usergroup as we change to an object query + if ($filter['type'] === 'usergroup') + { + $function[] = PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Select the text."; + $function[] = Indent::_(2) + . "\$query->select(\$db->quoteName('g." + . $filter['code'] . "', 'id'));"; + $function[] = Indent::_(2) + . "\$query->select(\$db->quoteName('ug.title', 'title'));"; + $function[] = Indent::_(2) + . "\$query->from(\$db->quoteName('#__" . $component + . "_" . $filter['database'] . "', 'g'));"; + $function[] = Indent::_(2) + . "\$query->join('LEFT', \$db->quoteName('#__usergroups', 'ug') . ' ON (' . (\$db->quoteName('g." + . $filter['code'] + . "') . ' = ' . \$db->quoteName('ug.id') . ')'));"; + $function[] = Indent::_(2) + . "\$query->order(\$db->quoteName('title') . ' ASC');"; + $function[] = Indent::_(2) + . "\$query->group(\$db->quoteName('ug.id'));"; + $function[] = PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " Reset the query using our newly populated query object."; + $function[] = Indent::_(2) . "\$db->setQuery(\$query);"; + $function[] = PHP_EOL . Indent::_(2) + . "\$_results = \$db->loadObjectList();"; + } + else + { + $function[] = PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Select the text."; + $function[] = Indent::_(2) + . "\$query->select(\$db->quoteName('" + . $filter['code'] . "'));"; + $function[] = Indent::_(2) + . "\$query->from(\$db->quoteName('#__" . $component + . "_" . $filter['database'] . "'));"; + $function[] = Indent::_(2) + . "\$query->order(\$db->quoteName('" + . $filter['code'] . "') . ' ASC');"; + $function[] = PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) + . " Reset the query using our newly populated query object."; + $function[] = Indent::_(2) . "\$db->setQuery(\$query);"; + $function[] = PHP_EOL . Indent::_(2) + . "\$_results = \$db->loadColumn();"; + } + $function[] = Indent::_(2) . "\$_filter = [];"; + // if this is not a multi field + if (!$funtion_path && $filter['multi'] == 1) + { + $function[] = Indent::_(2) + . "\$_filter[] = Html::_('select.option', '', '- ' . Text:" + . ":_('" . $filter['lang_select'] . "') . ' -');"; + } + $function[] = PHP_EOL . Indent::_(2) . "if (\$_results)"; + $function[] = Indent::_(2) . "{"; + + // check if translated value is used + if ($funtion_path && $translation) + { + $function[] = Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " get model"; + $function[] = Indent::_(3) + . "\$_model = \$this->getModel();"; + } + elseif ($translation) + { + $function[] = Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " get " . $nameListCode . "model"; + $function[] = Indent::_(3) + . "\$_model = " . $Component . "Helper::getModel('" + . $nameListCode . "');"; + } + // check if usergroup as we change to an object query + if ($filter['type'] !== 'usergroup') + { + $function[] = Indent::_(3) + . "\$_results = array_unique(\$_results);"; + } + $function[] = Indent::_(3) . "foreach (\$_results as \$" + . $filter['code'] . ")"; + $function[] = Indent::_(3) . "{"; + + // check if translated value is used + if ($translation) + { + $function[] = Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Translate the " . $filter['code'] + . " selection"; + $function[] = Indent::_(4) + . "\$_text = \$_model->selectionTranslation(\$" + . $filter['code'] . ",'" . $filter['code'] . "');"; + $function[] = Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Now add the " . $filter['code'] + . " and its text to the options array"; + $function[] = Indent::_(4) + . "\$_filter[] = Html::_('select.option', \$" + . $filter['code'] . ", Text:" . ":_(\$_text));"; + } + elseif ($filter['type'] === 'user') + { + $function[] = Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Now add the " . $filter['code'] + . " and its text to the options array"; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $function[] = Indent::_(4) + . "\$_filter[] = Html::_('select.option', \$" + . $filter['code'] . ", Factory::getUser(\$" + . $filter['code'] . ")->name);"; + } + else + { + $function[] = Indent::_(4) + . "\$_filter[] = Html::_('select.option', \$" + . $filter['code'] . ","; + $function[] = Indent::_(5) + . "Factory::getContainer()->"; + $function[] = Indent::_(5) + . "get(\Joomla\CMS\User\UserFactoryInterface::class)->"; + $function[] = Indent::_(5) + . "loadUserById(\$" + . $filter['code'] . ")->name"; + $function[] = Indent::_(5) + . ");"; + } + } + else + { + if ($filter['type'] === 'usergroup') + { + $function[] = Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Now add the " . $filter['code'] + . " and its text to the options array"; + $function[] = Indent::_(4) + . "\$_filter[] = Html::_('select.option', \$" + . $filter['code'] . "->id, \$" . $filter['code'] + . "->title);"; + } + else + { + $function[] = Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Now add the " . $filter['code'] + . " and its text to the options array"; + $function[] = Indent::_(4) + . "\$_filter[] = Html::_('select.option', \$" + . $filter['code'] . ", \$" . $filter['code'] + . ");"; + } + } + $function[] = Indent::_(3) . "}"; + $function[] = Indent::_(2) . "}"; + $function[] = Indent::_(2) . "return \$_filter;"; + // add if this is a function path + if ($funtion_path) + { + $function[] = Indent::_(1) . "}"; + } + } + // we check if this is a multi field + // and if there is a blank option + // and give a notice that this will cause an issue + elseif (!$funtion_path && $filter['type'] != 'category' + && $filter['multi'] == 2 + && ArrayHelper::check($filter['custom'])) + { + // get the field code + $field_code = $this->getCustomFieldCode( + $filter['custom'] + )['JFORM_TYPE_PHP']; + // check for the [Html::_('select.option', '',] code + if (strpos((string) $field_code, "Html::_('select.option', '',") + !== false + && strpos((string) $field_code, '($this->multiple === false)') + === false) + { + // for now we just give an error message (don't fix it) + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_HR_HTHREEMULTI_FILTER_ERRORHTHREE'), + 'Error' + ); + $field_url + = '"index.php?option=com_componentbuilder&view=fields&task=field.edit&id=' + . $filter['id'] . '" target="_blank"'; + $field_fix + = "
    if (\$this->multiple === false) { // <-- this if statement is needed";
    +						$field_fix .= PHP_EOL . Indent::_(1)
    +							. "\$options[] = Html::_('select.option', '', 'Select an option'); // <-- the empty option";
    +						$field_fix .= PHP_EOL . "}
    "; + $this->app->enqueueMessage( + Text::sprintf( + 'We detected that you have an empty option in a custom field (%s) that is used in a multi filter.
    This will cause a problem, you will need to add the following code to it.
    %s', + $field_url, + $filter['code'], + $field_fix + ), 'Error' + ); + } + } + // divert the code to a file if this is not a funtion path + if (!$funtion_path + && ArrayHelper::check( + $function + )) + { + // set the filter file + $this->setFilterFieldFile( + implode(PHP_EOL, $function), $filter + ); + // clear the filter out + $function = []; + } + } + // if this is a function path, return the function if set + if ($funtion_path && ArrayHelper::check($function)) + { + // return the function + return PHP_EOL . implode(PHP_EOL, $function); + } + } + + return ''; + } + + public function setUniqueFields(&$view) + { + $fields = []; + $fields[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $fields[] = Indent::_(1) + . " * Method to get the unique fields of this table."; + $fields[] = Indent::_(1) . " *"; + $fields[] = Indent::_(1) + . " * @return mixed An array of field names, boolean false if none is set."; + $fields[] = Indent::_(1) . " *"; + $fields[] = Indent::_(1) . " * @since 3.0"; + $fields[] = Indent::_(1) . " */"; + $fields[] = Indent::_(1) . "protected function getUniqueFields()"; + $fields[] = Indent::_(1) . "{"; + if (CFactory::_('Compiler.Builder.Database.Unique.Keys')->exists($view)) + { + // if guid should also be added + if (CFactory::_('Compiler.Builder.Database.Unique.Guid')->exists($view)) + { + $fields[] = Indent::_(2) . "return array('" . implode( + "','", CFactory::_('Compiler.Builder.Database.Unique.Keys')->get($view) + ) . "', 'guid');"; + } + else + { + $fields[] = Indent::_(2) . "return array('" . implode( + "','", CFactory::_('Compiler.Builder.Database.Unique.Keys')->get($view) + ) . "');"; + } + } + // if only GUID is found + elseif (CFactory::_('Compiler.Builder.Database.Unique.Guid')->exists($view)) + { + $fields[] = Indent::_(2) . "return array('guid');"; + } + else + { + $fields[] = Indent::_(2) . "return false;"; + } + $fields[] = Indent::_(1) . "}"; + + // return the unique fields + return implode(PHP_EOL, $fields); + } + + /** + * build sidebar filter loading scripts + * + * @param string $nameSingleCode The single view name + * @param string $nameListCode The list view name + * + * @return string The php to place in view.html.php + * + */ + public function setFilterFieldSidebarDisplayHelper(&$nameSingleCode, + &$nameListCode + ) + { + // start the filter bucket + $fieldFilters = []; + // add the default filter + $this->setDefaultSidebarFilterHelper( + $fieldFilters, $nameSingleCode, $nameListCode + ); + // add the category filter stuff + $this->setCategorySidebarFilterHelper($fieldFilters, $nameListCode); + // check if filter fields are added (1 = sidebar) + if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 1 + && CFactory::_('Compiler.Builder.Filter')->exists($nameListCode)) + { + // get component name + $Component = CFactory::_('Compiler.Builder.Content.One')->get('Component'); + // load the rest of the filters + foreach (CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as $filter) + { + if ($filter['type'] != 'category' + && ArrayHelper::check($filter['custom']) + && $filter['custom']['extends'] !== 'user') + { + $CodeName = StringHelper::safe( + $filter['code'] . ' ' . $filter['custom']['text'], 'W' + ); + $codeName = $filter['code'] + . StringHelper::safe( + $filter['custom']['text'], 'F' + ); + $type = StringHelper::safe( + $filter['custom']['type'], 'F' + ); + $fieldFilters[] = PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Set " . $CodeName + . " Selection"; + $fieldFilters[] = Indent::_(2) . "\$this->" . $codeName + . "Options = FormHelper::loadFieldType('" . $type + . "')->options;"; + $fieldFilters[] = Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " We do some sanitation for " . $CodeName + . " filter"; + $fieldFilters[] = Indent::_(2) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$this->" . $codeName + . "Options) &&"; + $fieldFilters[] = Indent::_(3) . "isset(\$this->" + . $codeName + . "Options[0]->value) &&"; + $fieldFilters[] = Indent::_(3) . "!" + . "Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$this->" . $codeName + . "Options[0]->value))"; + $fieldFilters[] = Indent::_(2) . "{"; + $fieldFilters[] = Indent::_(3) . "unset(\$this->" + . $codeName + . "Options[0]);"; + $fieldFilters[] = Indent::_(2) . "}"; + $fieldFilters[] = Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Only load " . $CodeName + . " filter if it has values"; + $fieldFilters[] = Indent::_(2) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$this->" . $codeName + . "Options))"; + $fieldFilters[] = Indent::_(2) . "{"; + $fieldFilters[] = Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " " . $CodeName . " Filter"; + $fieldFilters[] = Indent::_(3) . "\JHtmlSidebar::addFilter("; + $fieldFilters[] = Indent::_(4) . "'- Select ' . Text:" + . ":_('" . $filter['lang'] . "') . ' -',"; + $fieldFilters[] = Indent::_(4) . "'filter_" + . $filter['code'] + . "',"; + $fieldFilters[] = Indent::_(4) + . "Html::_('select.options', \$this->" . $codeName + . "Options, 'value', 'text', \$this->state->get('filter." + . $filter['code'] . "'))"; + $fieldFilters[] = Indent::_(3) . ");"; + $fieldFilters[] = Indent::_(2) . "}"; + } + elseif ($filter['type'] != 'category') + { + $Codename = StringHelper::safe( + $filter['code'], 'W' + ); + if (isset($filter['custom']) + && ArrayHelper::check($filter['custom']) + && $filter['custom']['extends'] === 'user') + { + $functionName = "\$this->getThe" . $filter['function'] + . StringHelper::safe( + $filter['custom']['text'], 'F' + ) . "Selections();"; + } + else + { + $functionName = "\$this->getThe" . $filter['function'] + . "Selections();"; + } + $fieldFilters[] = PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Set " . $Codename + . " Selection"; + $fieldFilters[] = Indent::_(2) . "\$this->" + . $filter['code'] + . "Options = " . $functionName; + $fieldFilters[] = Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " We do some sanitation for " . $Codename + . " filter"; + $fieldFilters[] = Indent::_(2) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$this->" . $filter['code'] + . "Options) &&"; + $fieldFilters[] = Indent::_(3) . "isset(\$this->" + . $filter['code'] . "Options[0]->value) &&"; + $fieldFilters[] = Indent::_(3) . "!" + . "Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$this->" . $filter['code'] + . "Options[0]->value))"; + $fieldFilters[] = Indent::_(2) . "{"; + $fieldFilters[] = Indent::_(3) . "unset(\$this->" + . $filter['code'] . "Options[0]);"; + $fieldFilters[] = Indent::_(2) . "}"; + $fieldFilters[] = Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Only load " . $Codename + . " filter if it has values"; + $fieldFilters[] = Indent::_(2) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$this->" . $filter['code'] + . "Options))"; + $fieldFilters[] = Indent::_(2) . "{"; + $fieldFilters[] = Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " " . $Codename . " Filter"; + $fieldFilters[] = Indent::_(3) . "\JHtmlSidebar::addFilter("; + $fieldFilters[] = Indent::_(4) . "'- Select '.Text:" + . ":_('" . $filter['lang'] . "').' -',"; + $fieldFilters[] = Indent::_(4) . "'filter_" + . $filter['code'] + . "',"; + $fieldFilters[] = Indent::_(4) + . "Html::_('select.options', \$this->" + . $filter['code'] + . "Options, 'value', 'text', \$this->state->get('filter." + . $filter['code'] . "'))"; + $fieldFilters[] = Indent::_(3) . ");"; + + $fieldFilters[] = Indent::_(2) . "}"; + } + } + } + // did we find filters + if (ArrayHelper::check($fieldFilters)) + { + // return the filter + return PHP_EOL . implode(PHP_EOL, $fieldFilters); + } + + return ''; + } + + /** + * add default filter helper + * + * @param array $filter The batch code array + * @param string $nameSingleCode The single view name + * @param string $nameListCode The list view name + * + * @return void + * + */ + protected function setDefaultSidebarFilterHelper(&$filter, &$nameSingleCode, + &$nameListCode + ) + { + // add the default filters if we are on the old filter paths (1 = sidebar) + if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 1) + { + // set batch + $filter[] = PHP_EOL . Indent::_(2) + . "//" . Line::_(__Line__, __Class__) + . " Only load publish filter if state change is allowed"; + $filter[] = Indent::_(2) + . "if (\$this->canState)"; + $filter[] = Indent::_(2) . "{"; + $filter[] = Indent::_(3) . "\JHtmlSidebar::addFilter("; + $filter[] = Indent::_(4) . "Text:" + . ":_('JOPTION_SELECT_PUBLISHED'),"; + $filter[] = Indent::_(4) . "'filter_published',"; + $filter[] = Indent::_(4) + . "Html::_('select.options', Html::_('jgrid.publishedOptions'), 'value', 'text', \$this->state->get('filter.published'), true)"; + $filter[] = Indent::_(3) . ");"; + $filter[] = Indent::_(2) . "}"; + // check if view has access + if (CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode) + && !CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.access')) + { + $filter[] = PHP_EOL . Indent::_(2) . "\JHtmlSidebar::addFilter("; + $filter[] = Indent::_(3) . "Text:" + . ":_('JOPTION_SELECT_ACCESS'),"; + $filter[] = Indent::_(3) . "'filter_access',"; + $filter[] = Indent::_(3) + . "Html::_('select.options', Html::_('access.assetgroups'), 'value', 'text', \$this->state->get('filter.access'))"; + $filter[] = Indent::_(2) . ");"; + } + } + } + + /** + * build category sidebar display filter helper + * + * @param array $filter The filter code array + * @param string $nameListCode The list view name + * + * @return void + * + */ + protected function setCategorySidebarFilterHelper(&$filter, &$nameListCode) + { + // add the category filter if we are on the old filter paths (1 = sidebar) + if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 1 + && CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.extension") + && CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.filter", 0) >= 1) + { + // set filter + $filter[] = PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Category Filter."; + $filter[] = Indent::_(2) . "\JHtmlSidebar::addFilter("; + $filter[] = Indent::_(3) . "Text:" + . ":_('JOPTION_SELECT_CATEGORY'),"; + $filter[] = Indent::_(3) . "'filter_category_id',"; + $filter[] = Indent::_(3) + . "Html::_('select.options', Html::_('category.options', '" + . CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension") + . "'), 'value', 'text', \$this->state->get('filter.category_id'))"; + $filter[] = Indent::_(2) . ");"; + } + } + + /** + * build batch loading helper scripts + * + * @param string $nameSingleCode The single view name + * @param string $nameListCode The list view name + * + * @return string The php to place in view.html.php + * + */ + public function setBatchDisplayHelper(&$nameSingleCode, &$nameListCode) + { + // temp fix + if (CFactory::_('Config')->get('joomla_version', 3) != 3) + { + return ''; + } + + // start the batch bucket + $fieldBatch = []; + // add the default batch + $this->setDefaultBatchHelper($fieldBatch, $nameSingleCode); + // add the category filter stuff + $this->setCategoryBatchHelper($fieldBatch, $nameListCode); + // check if we have other batch options to add + if (CFactory::_('Compiler.Builder.Filter')->exists($nameListCode)) + { + // check if we should add some help to get the values (2 = topbar) + $get_values = false; + if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2) + { + // since the old path is not used, we need to add those values here + $get_values = true; + } + // get component name + $Component = CFactory::_('Compiler.Builder.Content.One')->get('Component'); + // load the rest of the batch options + foreach (CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as $filter) + { + if ($filter['type'] != 'category' + && ArrayHelper::check($filter['custom']) + && $filter['custom']['extends'] !== 'user') + { + $CodeName = StringHelper::safe( + $filter['code'] . ' ' . $filter['custom']['text'], 'W' + ); + $codeName = $filter['code'] + . StringHelper::safe( + $filter['custom']['text'], 'F' + ); + $fieldBatch[] = PHP_EOL . Indent::_(2) + . "//" . Line::_(__Line__, __Class__) + . " Only load " . $CodeName + . " batch if create, edit, and batch is allowed"; + $fieldBatch[] = Indent::_(2) + . "if (\$this->canBatch && \$this->canCreate && \$this->canEdit)"; + $fieldBatch[] = Indent::_(2) . "{"; + // add the get values here + if ($get_values) + { + $type = StringHelper::safe( + $filter['custom']['type'], 'F' + ); + $fieldBatch[] = Indent::_(3) . "//" + . Line::_(__Line__, __Class__) . " Set " . $CodeName + . " Selection"; + $fieldBatch[] = Indent::_(3) . "\$this->" . $codeName + . "Options = FormHelper::loadFieldType('" . $type + . "')->options;"; + $fieldBatch[] = Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " We do some sanitation for " . $CodeName + . " filter"; + $fieldBatch[] = Indent::_(3) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$this->" . $codeName + . "Options) &&"; + $fieldBatch[] = Indent::_(4) . "isset(\$this->" + . $codeName + . "Options[0]->value) &&"; + $fieldBatch[] = Indent::_(4) . "!" + . "Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$this->" . $codeName + . "Options[0]->value))"; + $fieldBatch[] = Indent::_(3) . "{"; + $fieldBatch[] = Indent::_(4) . "unset(\$this->" + . $codeName + . "Options[0]);"; + $fieldBatch[] = Indent::_(3) . "}"; + } + $fieldBatch[] = Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " " . $CodeName . " Batch Selection"; + $fieldBatch[] = Indent::_(3) + . "JHtmlBatch_::addListSelection("; + $fieldBatch[] = Indent::_(4) . "'- Keep Original '.Text:" + . ":_('" . $filter['lang'] . "').' -',"; + $fieldBatch[] = Indent::_(4) . "'batch[" . $filter['code'] + . "]',"; + $fieldBatch[] = Indent::_(4) + . "Html::_('select.options', \$this->" . $codeName + . "Options, 'value', 'text')"; + $fieldBatch[] = Indent::_(3) . ");"; + $fieldBatch[] = Indent::_(2) . "}"; + } + elseif ($filter['type'] != 'category') + { + $CodeName = StringHelper::safe( + $filter['code'], 'W' + ); + + $fieldBatch[] = PHP_EOL . Indent::_(2) + . "//" . Line::_(__Line__, __Class__) + . " Only load " . $CodeName + . " batch if create, edit, and batch is allowed"; + $fieldBatch[] = Indent::_(2) + . "if (\$this->canBatch && \$this->canCreate && \$this->canEdit)"; + $fieldBatch[] = Indent::_(2) . "{"; + // add the get values here + if ($get_values) + { + $fieldBatch[] = Indent::_(3) . "//" + . Line::_(__Line__, __Class__) . " Set " . $CodeName + . " Selection"; + $fieldBatch[] = Indent::_(3) . "\$this->" + . $filter['code'] + . "Options = FormHelper::loadFieldType('" + . $filter['filter_type'] + . "')->options;"; + $fieldBatch[] = Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " We do some sanitation for " . $CodeName + . " filter"; + $fieldBatch[] = Indent::_(3) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$this->" . $filter['code'] + . "Options) &&"; + $fieldBatch[] = Indent::_(4) . "isset(\$this->" + . $filter['code'] . "Options[0]->value) &&"; + $fieldBatch[] = Indent::_(4) . "!" + . "Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$this->" . $filter['code'] + . "Options[0]->value))"; + $fieldBatch[] = Indent::_(3) . "{"; + $fieldBatch[] = Indent::_(4) . "unset(\$this->" + . $filter['code'] . "Options[0]);"; + $fieldBatch[] = Indent::_(3) . "}"; + } + $fieldBatch[] = Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " " . $CodeName . " Batch Selection"; + $fieldBatch[] = Indent::_(3) + . "JHtmlBatch_::addListSelection("; + $fieldBatch[] = Indent::_(4) . "'- Keep Original '.Text:" + . ":_('" . $filter['lang'] . "').' -',"; + $fieldBatch[] = Indent::_(4) . "'batch[" . $filter['code'] + . "]',"; + $fieldBatch[] = Indent::_(4) + . "Html::_('select.options', \$this->" + . $filter['code'] . "Options, 'value', 'text')"; + $fieldBatch[] = Indent::_(3) . ");"; + $fieldBatch[] = Indent::_(2) . "}"; + } + } + } + // did we find batch options + if (ArrayHelper::check($fieldBatch)) + { + // return the batch + return PHP_EOL . implode(PHP_EOL, $fieldBatch); + } + + return ''; + } + + /** + * add default batch helper + * + * @param array $batch The batch code array + * @param string $nameSingleCode The single view name + * + * @return void + * + */ + protected function setDefaultBatchHelper(&$batch, &$nameSingleCode) + { + // set component name + $COPMONENT = CFactory::_('Component')->get('name_code'); + $COPMONENT = StringHelper::safe( + $COPMONENT, 'U' + ); + // set batch + $batch[] = PHP_EOL . Indent::_(2) + . "//" . Line::_(__Line__, __Class__) + . " Only load published batch if state and batch is allowed"; + $batch[] = Indent::_(2) + . "if (\$this->canState && \$this->canBatch)"; + $batch[] = Indent::_(2) . "{"; + $batch[] = Indent::_(3) . "JHtmlBatch_::addListSelection("; + $batch[] = Indent::_(4) . "Text:" . ":_('COM_" . $COPMONENT + . "_KEEP_ORIGINAL_STATE'),"; + $batch[] = Indent::_(4) . "'batch[published]',"; + $batch[] = Indent::_(4) + . "Html::_('select.options', Html::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true)"; + $batch[] = Indent::_(3) . ");"; + $batch[] = Indent::_(2) . "}"; + // check if view has access + if (CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode) + && !CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.access')) + { + $batch[] = PHP_EOL . Indent::_(2) + . "//" . Line::_(__Line__, __Class__) + . " Only load access batch if create, edit and batch is allowed"; + $batch[] = Indent::_(2) + . "if (\$this->canBatch && \$this->canCreate && \$this->canEdit)"; + $batch[] = Indent::_(2) . "{"; + $batch[] = Indent::_(3) . "JHtmlBatch_::addListSelection("; + $batch[] = Indent::_(4) . "Text:" . ":_('COM_" . $COPMONENT + . "_KEEP_ORIGINAL_ACCESS'),"; + $batch[] = Indent::_(4) . "'batch[access]',"; + $batch[] = Indent::_(4) + . "Html::_('select.options', Html::_('access.assetgroups'), 'value', 'text')"; + $batch[] = Indent::_(3) . ");"; + $batch[] = Indent::_(2) . "}"; + } + } + + /** + * build category batch helper + * + * @param array $batch The batch code array + * @param string $nameListCode The list view name + * + * @return mixed The php to place in view.html.php + * + */ + protected function setCategoryBatchHelper(&$batch, &$nameListCode) + { + if (CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.extension")) + { + // set component name + $COPMONENT = CFactory::_('Component')->get('name_code'); + $COPMONENT = StringHelper::safe($COPMONENT, 'U'); + // set filter + $batch[] = PHP_EOL . Indent::_(2) + . "if (\$this->canBatch && \$this->canCreate && \$this->canEdit)"; + $batch[] = Indent::_(2) . "{"; + $batch[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Category Batch selection."; + $batch[] = Indent::_(3) . "JHtmlBatch_::addListSelection("; + $batch[] = Indent::_(4) . "Text:" . ":_('COM_" . $COPMONENT + . "_KEEP_ORIGINAL_CATEGORY'),"; + $batch[] = Indent::_(4) . "'batch[category]',"; + $batch[] = Indent::_(4) + . "Html::_('select.options', Html::_('category.options', '" + . CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension") + . "'), 'value', 'text')"; + $batch[] = Indent::_(3) . ");"; + $batch[] = Indent::_(2) . "}"; + } + } + + public function setRouterCategoryViews($nameSingleCode, $nameListCode) + { + if (CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.extension")) + { + // get the actual extension + $_extension = CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension"); + $_extension = explode('.', (string) $_extension); + // set component name + if (ArrayHelper::check($_extension)) + { + $component = str_replace('com_', '', $_extension[0]); + } + else + { + $component = CFactory::_('Config')->component_code_name; + } + // check if category has another name + $otherViews = CFactory::_('Compiler.Builder.Category.Other.Name')-> + get($nameListCode . '.views', $nameListCode); + $otherView = CFactory::_('Compiler.Builder.Category.Other.Name')-> + get($nameListCode . '.view', $nameSingleCode); + // set the OtherView value + CFactory::_('Compiler.Builder.Content.Multi')->set('category' . $otherView . '|otherview', $otherView); + // load the category helper details in not already loaded + if (!CFactory::_('Compiler.Builder.Content.Multi')->exists('category' . $otherView . '|view')) + { + // lets also set the category helper for this view + $target = array('site' => 'category' . $otherView); + CFactory::_('Utilities.Structure')->build($target, 'category'); + // insure the file gets updated + CFactory::_('Compiler.Builder.Content.Multi')->set('category' . $otherView . '|view', $otherView); + CFactory::_('Compiler.Builder.Content.Multi')->set('category' . $otherView . '|View', ucfirst((string) $otherView)); + CFactory::_('Compiler.Builder.Content.Multi')->set('category' . $otherView . '|views', $otherViews); + CFactory::_('Compiler.Builder.Content.Multi')->set('category' . $otherView . '|Views', ucfirst((string) $otherViews)); + // set script to global helper file + $includeHelper = []; + $includeHelper[] = "\n//" . Line::_(__Line__, __Class__) + . "Insure this view category file is loaded."; + $includeHelper[] = "\$classname = '" . ucfirst((string) $component) + . ucfirst((string) $otherView) . "Categories';"; + $includeHelper[] = "if (!class_exists(\$classname))"; + $includeHelper[] = "{"; + $includeHelper[] = Indent::_(1) + . "\$path = JPATH_SITE . '/components/com_" . $component + . "/helpers/category" . $otherView . ".php';"; + $includeHelper[] = Indent::_(1) . "if (is_file(\$path))"; + $includeHelper[] = Indent::_(1) . "{"; + $includeHelper[] = Indent::_(2) . "include_once \$path;"; + $includeHelper[] = Indent::_(1) . "}"; + $includeHelper[] = "}"; + CFactory::_('Compiler.Builder.Content.One')->add('CATEGORY_CLASS_TREES', implode("\n", $includeHelper)); + } + // return category view string + if (CFactory::_('Compiler.Builder.Content.One')->exists('ROUTER_CATEGORY_VIEWS') + && StringHelper::check( + CFactory::_('Compiler.Builder.Content.One')->get('ROUTER_CATEGORY_VIEWS') + )) + { + return "," . PHP_EOL . Indent::_(3) . '"' + . CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension") + . '" => "' . $otherView . '"'; + } + else + { + return PHP_EOL . Indent::_(3) . '"' + . CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension") + . '" => "' . $otherView . '"'; + } + } + + return ''; + } + + /** + * Get Admin Controller Allow Add + * + * @param string $nameSingleCode The view edit or single name + * @param string $nameListCode The view list name + * + * @return string The method code + * @deprecated 3.3 Use CFactory::_('Architecture.Controller.AllowAdd')->get($nameSingleCode); + */ + public function setJcontrollerAllowAdd($nameSingleCode, $nameListCode) + { + return CFactory::_('Architecture.Controller.AllowAdd')->get($nameSingleCode); + } + + /** + * Get Admin Controller Allow Edit + * + * @param string $nameSingleCode The view edit or single name + * @param string $nameListCode The view list name + * + * @return string The method code + * @deprecated 3.3 Use CFactory::_('Architecture.Controller.AllowEdit')->get($nameSingleCode, $nameListCode); + */ + public function setJcontrollerAllowEdit($nameSingleCode, $nameListCode) + { + return CFactory::_('Architecture.Controller.AllowEdit')->get($nameSingleCode, $nameListCode); + } + + public function setJmodelAdminGetForm($nameSingleCode, $nameListCode) + { + // set component name + $component = CFactory::_('Config')->component_code_name; + // allways load these + $getForm = []; + $getForm[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " check if xpath was set in options"; + $getForm[] = Indent::_(2) . "\$xpath = false;"; + $getForm[] = Indent::_(2) . "if (isset(\$options['xpath']))"; + $getForm[] = Indent::_(2) . "{"; + $getForm[] = Indent::_(3) . "\$xpath = \$options['xpath'];"; + $getForm[] = Indent::_(3) . "unset(\$options['xpath']);"; + $getForm[] = Indent::_(2) . "}"; + $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " check if clear form was set in options"; + $getForm[] = Indent::_(2) . "\$clear = false;"; + $getForm[] = Indent::_(2) . "if (isset(\$options['clear']))"; + $getForm[] = Indent::_(2) . "{"; + $getForm[] = Indent::_(3) . "\$clear = \$options['clear'];"; + $getForm[] = Indent::_(3) . "unset(\$options['clear']);"; + $getForm[] = Indent::_(2) . "}"; + $getForm[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Get the form."; + $getForm[] = Indent::_(2) . "\$form = \$this->loadForm('com_" + . $component . "." . $nameSingleCode . "', '" . $nameSingleCode + . "', \$options, \$clear, \$xpath);"; + $getForm[] = PHP_EOL . Indent::_(2) . "if (empty(\$form))"; + $getForm[] = Indent::_(2) . "{"; + $getForm[] = Indent::_(3) . "return false;"; + $getForm[] = Indent::_(2) . "}"; + // load license locker + if (CFactory::_('Component')->get('add_license') && CFactory::_('Component')->get('license_type') == 3 + && CFactory::_('Compiler.Builder.Content.Multi')->exists($nameSingleCode . '|BOOLMETHOD')) + { + $getForm[] = $this->checkStatmentLicenseLocked( + CFactory::_('Compiler.Builder.Content.Multi')->get($nameSingleCode . '|BOOLMETHOD', '') + ); + } + if (0) //CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}")) <-- remove category from check + { + // check if category has another name + $otherViews = CFactory::_('Compiler.Builder.Category.Other.Name')-> + get($nameListCode . '.views', $nameListCode); + $otherView = CFactory::_('Compiler.Builder.Category.Other.Name')-> + get($nameListCode . '.view', $nameSingleCode); + // setup the category script + $getForm[] = PHP_EOL . Indent::_(2) + . "\$jinput = Factory::getApplication()->input;"; + $getForm[] = PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) + . " The front end calls this model and uses a_id to avoid id clashes so we need to check for that first."; + $getForm[] = Indent::_(2) . "if (\$jinput->get('a_id'))"; + $getForm[] = Indent::_(2) . "{"; + $getForm[] = Indent::_(3) + . "\$id = \$jinput->get('a_id', 0, 'INT');"; + $getForm[] = Indent::_(2) . "}"; + $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " The back end uses id so we use that the rest of the time and set it to 0 by default."; + $getForm[] = Indent::_(2) . "else"; + $getForm[] = Indent::_(2) . "{"; + $getForm[] = Indent::_(3) . "\$id = \$jinput->get('id', 0, 'INT');"; + $getForm[] = Indent::_(2) . "}"; + $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Determine correct permissions to check."; + $getForm[] = Indent::_(2) . "if (\$this->getState('" + . $nameSingleCode . ".id'))"; + $getForm[] = Indent::_(2) . "{"; + $getForm[] = Indent::_(3) . "\$id = \$this->getState('" + . $nameSingleCode . ".id');"; + $getForm[] = PHP_EOL . Indent::_(3) . "\$catid = 0;"; + $getForm[] = Indent::_(3) + . "if (isset(\$this->getItem(\$id)->catid))"; + $getForm[] = Indent::_(3) . "{"; + $getForm[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " set category id"; + $getForm[] = Indent::_(4) + . "\$catid = \$this->getItem(\$id)->catid;"; + $getForm[] = PHP_EOL . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Existing record. Can only edit in selected categories."; + $getForm[] = Indent::_(4) + . "\$form->setFieldAttribute('catid', 'action', 'core.edit');"; + $getForm[] = PHP_EOL . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) + . " Existing record. Can only edit own items in selected categories."; + $getForm[] = Indent::_(4) + . "\$form->setFieldAttribute('catid', 'action', 'core.edit.own');"; + $getForm[] = Indent::_(3) . "}"; + $getForm[] = Indent::_(2) . "}"; + $getForm[] = Indent::_(2) . "else"; + $getForm[] = Indent::_(2) . "{"; + $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " New record. Can only create in selected categories."; + $getForm[] = Indent::_(3) + . "\$form->setFieldAttribute('catid', 'action', 'core.create');"; + $getForm[] = Indent::_(2) . "}"; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $getForm[] = PHP_EOL . Indent::_(2) + . "\$user = Factory::getUser();"; + } + else + { + $getForm[] = PHP_EOL . Indent::_(2) + . "\$user = Factory::getApplication()->getIdentity();"; + } + $getForm[] = PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Check for existing item."; + $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Modify the form based on Edit State access controls."; + // get the other view + $otherView = CFactory::_('Compiler.Builder.Category.Code')->getString("{$nameSingleCode}.view", 'error'); + // check if the item has permissions. + $getForm[] = Indent::_(2) + . "if (\$id != 0 && (!\$user->authorise('" + . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.state') + . "', 'com_" . $component . "." + . $nameSingleCode . ".' . (int) \$id))"; + $getForm[] = Indent::_(3) + . "|| (isset(\$catid) && \$catid != 0 && !\$user->authorise('core.edit.state', 'com_" + . $component . "." . $otherView + . ".category.' . (int) \$catid))"; + $getForm[] = Indent::_(3) + . "|| (\$id == 0 && !\$user->authorise('" + . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.state') + . "', 'com_" . $component . "')))"; + $getForm[] = Indent::_(2) . "{"; + $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Disable fields for display."; + $getForm[] = Indent::_(3) + . "\$form->setFieldAttribute('ordering', 'disabled', 'true');"; + $getForm[] = Indent::_(3) + . "\$form->setFieldAttribute('published', 'disabled', 'true');"; + $getForm[] = PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Disable fields while saving."; + $getForm[] = Indent::_(3) + . "\$form->setFieldAttribute('ordering', 'filter', 'unset');"; + $getForm[] = Indent::_(3) + . "\$form->setFieldAttribute('published', 'filter', 'unset');"; + $getForm[] = Indent::_(2) . "}"; + } + else + { + $getForm[] = PHP_EOL . Indent::_(2) + . "\$jinput = Factory::getApplication()->input;"; + $getForm[] = PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) + . " The front end calls this model and uses a_id to avoid id clashes so we need to check for that first."; + $getForm[] = Indent::_(2) . "if (\$jinput->get('a_id'))"; + $getForm[] = Indent::_(2) . "{"; + $getForm[] = Indent::_(3) + . "\$id = \$jinput->get('a_id', 0, 'INT');"; + $getForm[] = Indent::_(2) . "}"; + $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " The back end uses id so we use that the rest of the time and set it to 0 by default."; + $getForm[] = Indent::_(2) . "else"; + $getForm[] = Indent::_(2) . "{"; + $getForm[] = Indent::_(3) . "\$id = \$jinput->get('id', 0, 'INT');"; + $getForm[] = Indent::_(2) . "}"; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $getForm[] = PHP_EOL . Indent::_(2) + . "\$user = Factory::getUser();"; + } + else + { + $getForm[] = PHP_EOL . Indent::_(2) + . "\$user = Factory::getApplication()->getIdentity();"; + } + $getForm[] = PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Check for existing item."; + $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Modify the form based on Edit State access controls."; + // check if the item has permissions. + $getForm[] = Indent::_(2) + . "if (\$id != 0 && (!\$user->authorise('" + . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.state') . "', 'com_" . $component . "." + . $nameSingleCode . ".' . (int) \$id))"; + $getForm[] = Indent::_(3) + . "|| (\$id == 0 && !\$user->authorise('" + . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.state') . "', 'com_" . $component + . "')))"; + $getForm[] = Indent::_(2) . "{"; + $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Disable fields for display."; + $getForm[] = Indent::_(3) + . "\$form->setFieldAttribute('ordering', 'disabled', 'true');"; + $getForm[] = Indent::_(3) + . "\$form->setFieldAttribute('published', 'disabled', 'true');"; + $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Disable fields while saving."; + $getForm[] = Indent::_(3) + . "\$form->setFieldAttribute('ordering', 'filter', 'unset');"; + $getForm[] = Indent::_(3) + . "\$form->setFieldAttribute('published', 'filter', 'unset');"; + $getForm[] = Indent::_(2) . "}"; + } + $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " If this is a new item insure the greated by is set."; + $getForm[] = Indent::_(2) . "if (0 == \$id)"; + $getForm[] = Indent::_(2) . "{"; + $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Set the created_by to this user"; + $getForm[] = Indent::_(3) + . "\$form->setValue('created_by', null, \$user->id);"; + $getForm[] = Indent::_(2) . "}"; + $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Modify the form based on Edit Creaded By access controls."; + // check if the item has permissions. + if (CFactory::_('Compiler.Creator.Permission')->actionExist($nameSingleCode, 'core.edit.created_by')) + { + $getForm[] = Indent::_(2) . "if (\$id != 0 && (!\$user->authorise('" + . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.created_by') + . "', 'com_" . $component . "." . $nameSingleCode . ".' . (int) \$id))"; + $getForm[] = Indent::_(3) . "|| (\$id == 0 && !\$user->authorise('" + . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.created_by') + . "', 'com_" . $component . "')))"; + } + else + { + $getForm[] = Indent::_(2) + . "if (!\$user->authorise('core.edit.created_by', 'com_" . $component . "'))"; + } + $getForm[] = Indent::_(2) . "{"; + $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Disable fields for display."; + $getForm[] = Indent::_(3) + . "\$form->setFieldAttribute('created_by', 'disabled', 'true');"; + $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Disable fields for display."; + $getForm[] = Indent::_(3) + . "\$form->setFieldAttribute('created_by', 'readonly', 'true');"; + $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Disable fields while saving."; + $getForm[] = Indent::_(3) + . "\$form->setFieldAttribute('created_by', 'filter', 'unset');"; + $getForm[] = Indent::_(2) . "}"; + $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Modify the form based on Edit Creaded Date access controls."; + // check if the item has permissions. + if (CFactory::_('Compiler.Creator.Permission')->actionExist($nameSingleCode, 'core.edit.created')) + { + $getForm[] = Indent::_(2) . "if (\$id != 0 && (!\$user->authorise('" + . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.created') + . "', 'com_" . $component . "." . $nameSingleCode . ".' . (int) \$id))"; + $getForm[] = Indent::_(3) . "|| (\$id == 0 && !\$user->authorise('" + . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.created') + . "', 'com_" . $component . "')))"; + } + else + { + $getForm[] = Indent::_(2) + . "if (!\$user->authorise('core.edit.created', 'com_" + . $component . "'))"; + } + $getForm[] = Indent::_(2) . "{"; + $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Disable fields for display."; + $getForm[] = Indent::_(3) + . "\$form->setFieldAttribute('created', 'disabled', 'true');"; + $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Disable fields while saving."; + $getForm[] = Indent::_(3) + . "\$form->setFieldAttribute('created', 'filter', 'unset');"; + $getForm[] = Indent::_(2) . "}"; + // check if the item has access permissions. + if (CFactory::_('Compiler.Creator.Permission')->actionExist($nameSingleCode, 'core.edit.access')) + { + $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Modify the form based on Edit Access 'access' controls."; + $getForm[] = Indent::_(2) . "if (\$id != 0 && (!\$user->authorise('" + . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.access') + . "', 'com_" . $component . "." . $nameSingleCode . ".' . (int) \$id))"; + $getForm[] = Indent::_(3) . "|| (\$id == 0 && !\$user->authorise('" + . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit.access') + . "', 'com_" . $component . "')))"; + $getForm[] = Indent::_(2) . "{"; + $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Disable fields for display."; + $getForm[] = Indent::_(3) + . "\$form->setFieldAttribute('access', 'disabled', 'true');"; + $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Disable fields while saving."; + $getForm[] = Indent::_(3) + . "\$form->setFieldAttribute('access', 'filter', 'unset');"; + $getForm[] = Indent::_(2) . "}"; + } + // handel the fields permissions + if (CFactory::_('Compiler.Builder.Permission.Fields')->isArray($nameSingleCode)) + { + foreach (CFactory::_('Compiler.Builder.Permission.Fields')->get($nameSingleCode) + as $fieldName => $permission_options) + { + foreach ($permission_options as $permission_option => $fieldType) + { + switch ($permission_option) + { + case 'edit': + $this->setPermissionEditFields( + $getForm, $nameSingleCode, $fieldName, + $fieldType, $component + ); + break; + case 'access': + $this->setPermissionAccessFields( + $getForm, $nameSingleCode, $fieldName, + $fieldType, $component + ); + break; + case 'view': + $this->setPermissionViewFields( + $getForm, $nameSingleCode, $fieldName, + $fieldType, $component + ); + break; + case 'edit.own': + case 'access.own': + // this must still be build (TODO) + break; + } + } + } + } + // add the redirect trick to set the field of origin + $getForm[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Only load these values if no id is found"; + $getForm[] = Indent::_(2) . "if (0 == \$id)"; + $getForm[] = Indent::_(2) . "{"; + $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Set redirected view name"; + $getForm[] = Indent::_(3) + . "\$redirectedView = \$jinput->get('ref', null, 'STRING');"; + $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Set field name (or fall back to view name)"; + $getForm[] = Indent::_(3) + . "\$redirectedField = \$jinput->get('field', \$redirectedView, 'STRING');"; + $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Set redirected view id"; + $getForm[] = Indent::_(3) + . "\$redirectedId = \$jinput->get('refid', 0, 'INT');"; + $getForm[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Set field id (or fall back to redirected view id)"; + $getForm[] = Indent::_(3) + . "\$redirectedValue = \$jinput->get('field_id', \$redirectedId, 'INT');"; + $getForm[] = Indent::_(3) + . "if (0 != \$redirectedValue && \$redirectedField)"; + $getForm[] = Indent::_(3) . "{"; + $getForm[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Now set the local-redirected field default value"; + $getForm[] = Indent::_(4) + . "\$form->setValue(\$redirectedField, null, \$redirectedValue);"; + $getForm[] = Indent::_(3) . "}"; + // load custom script if found + $getForm[] = Indent::_(2) . "}" . CFactory::_('Customcode.Dispenser')->get( + 'php_getform', $nameSingleCode, PHP_EOL + ); + // setup the default script + $getForm[] = Indent::_(2) . "return \$form;"; + + return implode(PHP_EOL, $getForm); + } + + protected function setPermissionEditFields(&$allow, $nameSingleCode, + $fieldName, $fieldType, $component + ) + { + // only for fields that can be edited + if (!CFactory::_('Field.Groups')->check($fieldType, 'spacer')) + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Modify the form based on Edit " + . StringHelper::safe($fieldName, 'W') + . " access controls."; + $allow[] = Indent::_(2) . "if (\$id != 0 && (!\$user->authorise('" + . $nameSingleCode . ".edit." . $fieldName . "', 'com_" + . $component . "." . $nameSingleCode . ".' . (int) \$id))"; + $allow[] = Indent::_(3) . "|| (\$id == 0 && !\$user->authorise('" + . $nameSingleCode . ".edit." . $fieldName . "', 'com_" + . $component . "')))"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Disable fields for display."; + $allow[] = Indent::_(3) . "\$form->setFieldAttribute('" . $fieldName + . "', 'disabled', 'true');"; + $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Disable fields for display."; + $allow[] = Indent::_(3) . "\$form->setFieldAttribute('" . $fieldName + . "', 'readonly', 'true');"; + if ('radio' === $fieldType || 'repeatable' === $fieldType) + { + $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Disable radio button for display."; + $allow[] = Indent::_(3) + . "\$class = \$form->getFieldAttribute('" . $fieldName + . "', 'class', '');"; + $allow[] = Indent::_(3) . "\$form->setFieldAttribute('" + . $fieldName . "', 'class', \$class.' disabled no-click');"; + } + $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " If there is no value continue."; + $allow[] = Indent::_(3) . "if (!\$form->getValue('" . $fieldName + . "'))"; + $allow[] = Indent::_(3) . "{"; + $allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Disable fields while saving."; + $allow[] = Indent::_(4) . "\$form->setFieldAttribute('" . $fieldName + . "', 'filter', 'unset');"; + $allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Disable fields while saving."; + $allow[] = Indent::_(4) . "\$form->setFieldAttribute('" . $fieldName + . "', 'required', 'false');"; + $allow[] = Indent::_(3) . "}"; + $allow[] = Indent::_(2) . "}"; + } + } + + protected function setPermissionAccessFields(&$allow, $nameSingleCode, + $fieldName, $fieldType, $component + ) + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Modify the from the form based on " + . StringHelper::safe($fieldName, 'W') + . " access controls."; + $allow[] = Indent::_(2) . "if (\$id != 0 && (!\$user->authorise('" + . $nameSingleCode . ".access." . $fieldName . "', 'com_" + . $component . "." . $nameSingleCode . ".' . (int) \$id))"; + $allow[] = Indent::_(3) . "|| (\$id == 0 && !\$user->authorise('" + . $nameSingleCode . ".access." . $fieldName . "', 'com_" + . $component . "')))"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Remove the field"; + $allow[] = Indent::_(3) . "\$form->removeField('" . $fieldName . "');"; + $allow[] = Indent::_(2) . "}"; + } + + protected function setPermissionViewFields(&$allow, $nameSingleCode, + $fieldName, $fieldType, $component + ) + { + if (CFactory::_('Field.Groups')->check($fieldType, 'spacer')) + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Modify the form based on View " + . StringHelper::safe($fieldName, 'W') + . " access controls."; + $allow[] = Indent::_(2) . "if (\$id != 0 && (!\$user->authorise('" + . $nameSingleCode . ".view." . $fieldName . "', 'com_" + . $component . "." . $nameSingleCode . ".' . (int) \$id))"; + $allow[] = Indent::_(3) . "|| (\$id == 0 && !\$user->authorise('" + . $nameSingleCode . ".view." . $fieldName . "', 'com_" + . $component . "')))"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Remove the field"; + $allow[] = Indent::_(3) . "\$form->removeField('" . $fieldName + . "');"; + $allow[] = Indent::_(2) . "}"; + } + else + { + $allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Modify the form based on View " + . StringHelper::safe($fieldName, 'W') + . " access controls."; + $allow[] = Indent::_(2) . "if (\$id != 0 && (!\$user->authorise('" + . $nameSingleCode . ".view." . $fieldName . "', 'com_" + . $component . "." . $nameSingleCode . ".' . (int) \$id))"; + $allow[] = Indent::_(3) . "|| (\$id == 0 && !\$user->authorise('" + . $nameSingleCode . ".view." . $fieldName . "', 'com_" + . $component . "')))"; + $allow[] = Indent::_(2) . "{"; + $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Make the field hidded."; + $allow[] = Indent::_(3) . "\$form->setFieldAttribute('" . $fieldName + . "', 'type', 'hidden');"; + $allow[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " If there is no value continue."; + $allow[] = Indent::_(3) . "if (!(\$val = \$form->getValue('" + . $fieldName . "')))"; + $allow[] = Indent::_(3) . "{"; + $allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Disable fields while saving."; + $allow[] = Indent::_(4) . "\$form->setFieldAttribute('" . $fieldName + . "', 'filter', 'unset');"; + $allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Disable fields while saving."; + $allow[] = Indent::_(4) . "\$form->setFieldAttribute('" . $fieldName + . "', 'required', 'false');"; + $allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Make sure"; + $allow[] = Indent::_(4) . "\$form->setValue('" . $fieldName + . "', null, '');"; + $allow[] = Indent::_(3) . "}"; + $allow[] = Indent::_(3) . "elseif (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$val))"; + $allow[] = Indent::_(3) . "{"; + $allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " We have to unset then (TODO)"; + $allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Hiddend field can not handel array value"; + $allow[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Even if we convert to json we get an error"; + $allow[] = Indent::_(4) . "\$form->removeField('" . $fieldName + . "');"; + $allow[] = Indent::_(3) . "}"; + $allow[] = Indent::_(2) . "}"; + } + } + + public function setJmodelAdminAllowEdit($nameSingleCode, $nameListCode) + { + $allow = []; + // set component name + $component = CFactory::_('Config')->component_code_name; + // prepare custom permission script + $customAllow = CFactory::_('Customcode.Dispenser')->get( + 'php_allowedit', $nameSingleCode, Indent::_(2) + . "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;" + . PHP_EOL + ); + // check if the item has permissions. + if (CFactory::_('Compiler.Creator.Permission')->actionExist($nameSingleCode, 'core.edit')) + { + $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Check specific edit permission then general edit permission."; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $allow[] = Indent::_(2) . "\$user = Factory::getUser();"; + } + else + { + $allow[] = Indent::_(2) . "\$user = Factory::getApplication()->getIdentity();"; + } + // load custom permission script + $allow[] = $customAllow; + $allow[] = Indent::_(2) . "return \$user->authorise('" + . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit') + . "', 'com_" . $component . "." . $nameSingleCode + . ".'. ((int) isset(\$data[\$key]) ? \$data[\$key] : 0)) or \$user->authorise('" + . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.edit') + . "', 'com_" . $component . "');"; + } + else + { + $allow[] = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Check specific edit permission then general edit permission."; + if (StringHelper::check($customAllow)) + { + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $allow[] = Indent::_(2) . "\$user = Factory::getUser();"; + } + else + { + $allow[] = Indent::_(2) . "\$user = Factory::getApplication()->getIdentity();"; + } + } + // load custom permission script + $allow[] = $customAllow; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $allow[] = Indent::_(2) + . "return Factory::getUser()->authorise('core.edit', 'com_" + . $component . "." . $nameSingleCode + . ".'. ((int) isset(\$data[\$key]) ? \$data[\$key] : 0)) or parent::allowEdit(\$data, \$key);"; + } + else + { + $allow[] = Indent::_(2) + . "return Factory::getApplication()->getIdentity()->authorise('core.edit', 'com_" + . $component . "." . $nameSingleCode + . ".'. ((int) isset(\$data[\$key]) ? \$data[\$key] : 0)) or parent::allowEdit(\$data, \$key);"; + } + } + + return implode(PHP_EOL, $allow); + } + + /** + * Get Admin Module Can Delete + * + * @param string $nameSingleCode The view edit or single name + * @param string $nameListCode The view list name + * + * @return string The method code + * @deprecated 3.3 Use CFactory::_('Architecture.Model.CanDelete')->get($nameSingleCode); + */ + public function setJmodelAdminCanDelete($nameSingleCode, $nameListCode) + { + return CFactory::_('Architecture.Model.CanDelete')->get($nameSingleCode); + } + + /** + * Get Admin Module Can Delete + * + * @param string $nameSingleCode The view edit or single name + * @param string $nameListCode The view list name + * + * @return string The method code + * @deprecated 3.3 Use CFactory::_('Architecture.Model.CanEditState')->get($nameSingleCode); + */ + public function setJmodelAdminCanEditState($nameSingleCode, $nameListCode) + { + return CFactory::_('Architecture.Model.CanEditState')->get($nameSingleCode); + } + + public function setJviewListCanDo($nameSingleCode, $nameListCode) + { + $allow = []; + // set component name + $component = CFactory::_('Config')->component_code_name; + // check if the item has permissions for edit. + $allow[] = PHP_EOL . Indent::_(2) + . "\$this->canEdit = \$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit') + . "');"; + // check if the item has permissions for edit state. + $allow[] = Indent::_(2) . "\$this->canState = \$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit.state') + . "');"; + // check if the item has permissions for create. + $allow[] = Indent::_(2) . "\$this->canCreate = \$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.create') . "');"; + // check if the item has permissions for delete. + $allow[] = Indent::_(2) . "\$this->canDelete = \$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.delete') . "');"; + // check if the item has permissions for batch. + if (CFactory::_('Compiler.Creator.Permission')->globalExist($nameSingleCode, 'core.batch')) + { + $allow[] = Indent::_(2) . "\$this->canBatch = (\$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.batch') + . "') && \$this->canDo->get('core.batch'));"; + } + else + { + $allow[] = Indent::_(2) + . "\$this->canBatch = \$this->canDo->get('core.batch');"; + } + + return implode(PHP_EOL, $allow); + } + + public function setFieldSetAccessControl(&$view) + { + $access = ''; + if ($view != 'component') + { + // set component name + $component = CFactory::_('Config')->component_code_name; + // set label + $label = 'Permissions in relation to this ' . $view; + // set the access fieldset + $access = ""; + $access .= PHP_EOL . Indent::_(1) + . '
    '; + $access .= PHP_EOL . Indent::_(2) . ""; + $access .= PHP_EOL . Indent::_(2) . ''; + $access .= PHP_EOL . Indent::_(2) . ""; + $access .= PHP_EOL . Indent::_(2) . ''; + $access .= PHP_EOL . Indent::_(1) . '
    '; + } + + // return access field set + return $access; + } + + /** + * set the filter fields + * + * @param string $nameSingleCode The single view name + * @param string $nameListCode The list view name + * + * @return string The code for the filter fields array + * + */ + public function setFilterFieldsArray(&$nameSingleCode, &$nameListCode) + { + // keep track of all fields already added + $donelist = array('id' => true, 'search' => true, + 'published' => true, 'access' => true, + 'created_by' => true, 'modified_by' => true); + // default filter fields + $fields = "'a.id','id'"; + $fields .= "," . PHP_EOL . Indent::_(4) . "'a.published','published'"; + if (CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode)) + { + $fields .= "," . PHP_EOL . Indent::_(4) . "'a.access','access'"; + } + $fields .= "," . PHP_EOL . Indent::_(4) . "'a.ordering','ordering'"; + $fields .= "," . PHP_EOL . Indent::_(4) . "'a.created_by','created_by'"; + $fields .= "," . PHP_EOL . Indent::_(4) + . "'a.modified_by','modified_by'"; + + // add the rest of the set filters + if (CFactory::_('Compiler.Builder.Filter')->exists($nameListCode)) + { + foreach (CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as $filter) + { + if (!isset($donelist[$filter['code']])) + { + $fields .= $this->getFilterFieldCode( + $filter + ); + $donelist[$filter['code']] = true; + } + } + } + // add the rest of the set filters + if (CFactory::_('Compiler.Builder.Sort')->exists($nameListCode)) + { + foreach (CFactory::_('Compiler.Builder.Sort')->get($nameListCode) as $filter) + { + if (!isset($donelist[$filter['code']])) + { + $fields .= $this->getFilterFieldCode( + $filter + ); + $donelist[$filter['code']] = true; + } + } + } + + return $fields; + } + + /** + * Add the code of the filter field array + * + * @param array $filter The field/filter array + * + * @return string The code for the filter array + * + */ + protected function getFilterFieldCode(&$filter) + { + // add the category stuff (may still remove these) TODO + if ($filter['type'] === 'category') + { + $field = "," . PHP_EOL . Indent::_(4) + . "'c.title','category_title'"; + $field .= "," . PHP_EOL . Indent::_(4) + . "'c.id', 'category_id'"; + if ($filter['code'] != 'category') + { + $field .= "," . PHP_EOL . Indent::_(4) . "'a." + . $filter['code'] . "','" . $filter['code'] + . "'"; + } + } + else + { + // check if custom field is set + if (ArrayHelper::check( + $filter['custom'] + ) + && isset($filter['custom']['db']) + && StringHelper::check( + $filter['custom']['db'] + ) + && isset($filter['custom']['text']) + && StringHelper::check( + $filter['custom']['text'] + )) + { + $field = "," . PHP_EOL . Indent::_(4) . "'" + . $filter['custom']['db'] . "." + . $filter['custom']['text'] . "','" . $filter['code'] + . "'"; + } + else + { + $field = "," . PHP_EOL . Indent::_(4) . "'a." + . $filter['code'] . "','" . $filter['code'] + . "'"; + } + } + + return $field; + } + + /** + * set the sotred ids + * + * @param string $nameSingleCode The single view name + * @param string $nameListCode The list view name + * + * @return string The code for the populate state + * + */ + public function setStoredId(&$nameSingleCode, &$nameListCode) + { + // set component name + $Component = ucwords((string) CFactory::_('Config')->component_code_name); + // keep track of all fields already added + $donelist = array('id' => true, 'search' => true, + 'published' => true, 'access' => true, + 'created_by' => true, 'modified_by' => true); + // set the defaults first + $stored = "//" . Line::_(__Line__, __Class__) . " Compile the store id."; + $stored .= PHP_EOL . Indent::_(2) + . "\$id .= ':' . \$this->getState('filter.id');"; + $stored .= PHP_EOL . Indent::_(2) + . "\$id .= ':' . \$this->getState('filter.search');"; + // add this if not already added + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.published')) + { + $stored .= PHP_EOL . Indent::_(2) + . "\$id .= ':' . \$this->getState('filter.published');"; + } + // add if view calls for it, and not already added + if (CFactory::_('Compiler.Builder.Access.Switch')->exists($nameSingleCode) + && !CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.access')) + { + // the side bar option is single + if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 1) + { + $stored .= PHP_EOL . Indent::_(2) + . "\$id .= ':' . \$this->getState('filter.access');"; + } + else + { + // top bar selection can result in + // an array due to multi selection + $stored .= $this->getStoredIdCodeMulti('access', $Component); + } + } + $stored .= PHP_EOL . Indent::_(2) + . "\$id .= ':' . \$this->getState('filter.ordering');"; + // add this if not already added + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.created_by')) + { + $stored .= PHP_EOL . Indent::_(2) + . "\$id .= ':' . \$this->getState('filter.created_by');"; + } + // add this if not already added + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.modified_by')) + { + $stored .= PHP_EOL . Indent::_(2) + . "\$id .= ':' . \$this->getState('filter.modified_by');"; + } + // add the rest of the set filters + if (CFactory::_('Compiler.Builder.Filter')->exists($nameListCode)) + { + foreach (CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as $filter) + { + if (!isset($donelist[$filter['code']])) + { + $stored .= $this->getStoredIdCode( + $filter, $nameListCode, $Component + ); + $donelist[$filter['code']] = true; + } + } + } + // add the rest of the set filters + if (CFactory::_('Compiler.Builder.Sort')->exists($nameListCode)) + { + foreach (CFactory::_('Compiler.Builder.Sort')->get($nameListCode) as $filter) + { + if (!isset($donelist[$filter['code']])) + { + $stored .= $this->getStoredIdCode( + $filter, $nameListCode, $Component + ); + $donelist[$filter['code']] = true; + } + } + } + + return $stored; + } + + /** + * Add the code of the stored ids + * + * @param array $filter The field/filter array + * @param string $nameListCode The list view name + * @param string $Component The Component name + * + * @return string The code for the stored IDs + * + */ + protected function getStoredIdCode(&$filter, &$nameListCode, &$Component) + { + if ($filter['type'] === 'category') + { + // the side bar option is single (1 = sidebar) + if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 1) + { + $stored = PHP_EOL . Indent::_(2) + . "\$id .= ':' . \$this->getState('filter.category');"; + $stored .= PHP_EOL . Indent::_(2) + . "\$id .= ':' . \$this->getState('filter.category_id');"; + if ($filter['code'] != 'category') + { + $stored .= PHP_EOL . Indent::_(2) + . "\$id .= ':' . \$this->getState('filter." + . $filter['code'] . "');"; + } + } + else + { + $stored = $this->getStoredIdCodeMulti('category', $Component); + $stored .= $this->getStoredIdCodeMulti( + 'category_id', $Component + ); + if ($filter['code'] != 'category') + { + $stored .= $this->getStoredIdCodeMulti( + $filter['code'], $Component + ); + } + } + } + else + { + // check if this is the topbar filter, and multi option (2 = topbar) + if (isset($filter['multi']) && $filter['multi'] == 2 + && CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2) + { + // top bar selection can result in + // an array due to multi selection + $stored = $this->getStoredIdCodeMulti( + $filter['code'], $Component + ); + } + else + { + $stored = PHP_EOL . Indent::_(2) + . "\$id .= ':' . \$this->getState('filter." + . $filter['code'] . "');"; + } + } + + return $stored; + } + + /** + * Add the code of the stored multi ids + * + * @param string $key The key field name + * @param string $Component The Component name + * + * @return string The code for the stored IDs + * + */ + protected function getStoredIdCodeMulti($key, &$Component) + { + // top bar selection can result in + // an array due to multi selection + $stored = PHP_EOL . Indent::_(2) + . "//" . Line::_(__Line__, __Class__) + . " Check if the value is an array"; + $stored .= PHP_EOL . Indent::_(2) + . "\$_" . $key . " = \$this->getState('filter." + . $key . "');"; + $stored .= PHP_EOL . Indent::_(2) + . "if (Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$_" + . $key . "))"; + $stored .= PHP_EOL . Indent::_(2) + . "{"; + $stored .= PHP_EOL . Indent::_(3) + . "\$id .= ':' . implode(':', \$_" . $key . ");"; + $stored .= PHP_EOL . Indent::_(2) + . "}"; + $stored .= PHP_EOL . Indent::_(2) + . "//" . Line::_(__Line__, __Class__) + . " Check if this is only an number or string"; + $stored .= PHP_EOL . Indent::_(2) + . "elseif (is_numeric(\$_" . $key . ")"; + $stored .= PHP_EOL . Indent::_(2) + . " || Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$_" . $key . "))"; + $stored .= PHP_EOL . Indent::_(2) + . "{"; + $stored .= PHP_EOL . Indent::_(3) + . "\$id .= ':' . \$_" . $key . ";"; + $stored .= PHP_EOL . Indent::_(2) + . "}"; + + return $stored; + } + + public function setAddToolBar(&$view) + { + // set view name + $nameSingleCode = $view['settings']->name_single_code; + if (CFactory::_('Config')->get('joomla_version', 3) != 3) + { + $langViews = CFactory::_('Config')->lang_prefix . '_' + . StringHelper::safe( + $view['settings']->name_list_code, 'U' + ); + $name_list = strtolower($view['settings']->name_list); + $name_single = strtolower($view['settings']->name_single); + // add empty title + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, + $langViews . '_EMPTYSTATE_TITLE', + 'No ' . $name_list . ' have been created yet.' + ); + // add empty content + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, + $langViews . '_EMPTYSTATE_CONTENT', + $view['settings']->description + ); + // add empty button add + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, + $langViews . '_EMPTYSTATE_BUTTON_ADD', + 'Add your first ' . $name_single + ); + } + // check type + if ($view['settings']->type == 2) + { + // set lang strings + $viewNameLang_readonly = CFactory::_('Config')->lang_prefix . '_' + . StringHelper::safe( + $view['settings']->name_single . ' readonly', 'U' + ); + // load to lang + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, $viewNameLang_readonly, + $view['settings']->name_single . ' :: Readonly' + ); + + // build toolbar + $toolBar + = "Factory::getApplication()->input->set('hidemainmenu', true);"; + $toolBar .= PHP_EOL . Indent::_(2) . "ToolbarHelper::title(Text:" + . ":_('" . $viewNameLang_readonly . "'), '" . $nameSingleCode + . "');"; + $toolBar .= PHP_EOL . Indent::_(2) . "ToolbarHelper::cancel('" + . $nameSingleCode . ".cancel', 'JTOOLBAR_CLOSE');"; + } + else + { + // set lang strings + $viewNameLang_new = CFactory::_('Config')->lang_prefix . '_' + . StringHelper::safe( + $view['settings']->name_single . ' New', 'U' + ); + $viewNameLang_edit = CFactory::_('Config')->lang_prefix . '_' + . StringHelper::safe( + $view['settings']->name_single . ' Edit', 'U' + ); + // load to lang + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, $viewNameLang_new, + 'A New ' . $view['settings']->name_single + ); + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, $viewNameLang_edit, + 'Editing the ' . $view['settings']->name_single + ); + // build toolbar + $toolBar + = "Factory::getApplication()->input->set('hidemainmenu', true);"; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $toolBar .= PHP_EOL . Indent::_(2) + . "\$user = Factory::getUser();"; + } + else + { + $toolBar .= PHP_EOL . Indent::_(2) + . "\$user = Factory::getApplication()->getIdentity();"; + } + $toolBar .= PHP_EOL . Indent::_(2) . "\$userId = \$user->id;"; + $toolBar .= PHP_EOL . Indent::_(2) + . "\$isNew = \$this->item->id == 0;"; + $toolBar .= PHP_EOL . PHP_EOL . Indent::_(2) + . "ToolbarHelper::title( Text:" . ":_(\$isNew ? '" + . $viewNameLang_new . "' : '" . $viewNameLang_edit + . "'), 'pencil-2 article-add');"; + $toolBar .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Built the actions for new and existing records."; + $toolBar .= PHP_EOL . Indent::_(2) . "if (" + . "Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$this->referral))"; + $toolBar .= PHP_EOL . Indent::_(2) . "{"; + $toolBar .= PHP_EOL . Indent::_(3) . "if (\$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.create') . "') && \$isNew)"; + $toolBar .= PHP_EOL . Indent::_(3) . "{"; + $toolBar .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " We can create the record."; + $toolBar .= PHP_EOL . Indent::_(4) . "ToolbarHelper::save('" + . $nameSingleCode . ".save', 'JTOOLBAR_SAVE');"; + $toolBar .= PHP_EOL . Indent::_(3) . "}"; + $toolBar .= PHP_EOL . Indent::_(3) + . "elseif (\$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit') + . "'))"; + $toolBar .= PHP_EOL . Indent::_(3) . "{"; + $toolBar .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " We can save the record."; + $toolBar .= PHP_EOL . Indent::_(4) . "ToolbarHelper::save('" + . $nameSingleCode . ".save', 'JTOOLBAR_SAVE');"; + $toolBar .= PHP_EOL . Indent::_(3) . "}"; + $toolBar .= PHP_EOL . Indent::_(3) . "if (\$isNew)"; + $toolBar .= PHP_EOL . Indent::_(3) . "{"; + $toolBar .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Do not creat but cancel."; + $toolBar .= PHP_EOL . Indent::_(4) . "ToolbarHelper::cancel('" + . $nameSingleCode . ".cancel', 'JTOOLBAR_CANCEL');"; + $toolBar .= PHP_EOL . Indent::_(3) . "}"; + $toolBar .= PHP_EOL . Indent::_(3) . "else"; + $toolBar .= PHP_EOL . Indent::_(3) . "{"; + $toolBar .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " We can close it."; + $toolBar .= PHP_EOL . Indent::_(4) . "ToolbarHelper::cancel('" + . $nameSingleCode . ".cancel', 'JTOOLBAR_CLOSE');"; + $toolBar .= PHP_EOL . Indent::_(3) . "}"; + $toolBar .= PHP_EOL . Indent::_(2) . "}"; + $toolBar .= PHP_EOL . Indent::_(2) . "else"; + $toolBar .= PHP_EOL . Indent::_(2) . "{"; + $toolBar .= PHP_EOL . Indent::_(3) . "if (\$isNew)"; + $toolBar .= PHP_EOL . Indent::_(3) . "{"; + $toolBar .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " For new records, check the create permission."; + $toolBar .= PHP_EOL . Indent::_(4) . "if (\$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.create') . "'))"; + $toolBar .= PHP_EOL . Indent::_(4) . "{"; + $toolBar .= PHP_EOL . Indent::_(5) . "ToolbarHelper::apply('" + . $nameSingleCode . ".apply', 'JTOOLBAR_APPLY');"; + $toolBar .= PHP_EOL . Indent::_(5) . "ToolbarHelper::save('" + . $nameSingleCode . ".save', 'JTOOLBAR_SAVE');"; + $toolBar .= PHP_EOL . Indent::_(5) . "ToolbarHelper::custom('" + . $nameSingleCode + . ".save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);"; + $toolBar .= PHP_EOL . Indent::_(4) . "};"; + $toolBar .= PHP_EOL . Indent::_(4) . "ToolbarHelper::cancel('" + . $nameSingleCode . ".cancel', 'JTOOLBAR_CANCEL');"; + $toolBar .= PHP_EOL . Indent::_(3) . "}"; + $toolBar .= PHP_EOL . Indent::_(3) . "else"; + $toolBar .= PHP_EOL . Indent::_(3) . "{"; + $toolBar .= PHP_EOL . Indent::_(4) . "if (\$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit') . "'))"; + $toolBar .= PHP_EOL . Indent::_(4) . "{"; + $toolBar .= PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " We can save the new record"; + $toolBar .= PHP_EOL . Indent::_(5) . "ToolbarHelper::apply('" + . $nameSingleCode . ".apply', 'JTOOLBAR_APPLY');"; + $toolBar .= PHP_EOL . Indent::_(5) . "ToolbarHelper::save('" + . $nameSingleCode . ".save', 'JTOOLBAR_SAVE');"; + $toolBar .= PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " We can save this record, but check the create permission to see"; + $toolBar .= PHP_EOL . Indent::_(5) . "//" . Line::_(__Line__, __Class__) + . " if we can return to make a new one."; + $toolBar .= PHP_EOL . Indent::_(5) . "if (\$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.create') . "'))"; + $toolBar .= PHP_EOL . Indent::_(5) . "{"; + $toolBar .= PHP_EOL . Indent::_(6) . "ToolbarHelper::custom('" + . $nameSingleCode + . ".save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);"; + $toolBar .= PHP_EOL . Indent::_(5) . "}"; + $toolBar .= PHP_EOL . Indent::_(4) . "}"; + if (CFactory::_('Compiler.Creator.Permission')->globalExist($nameSingleCode, 'core.edit')) + { + if (CFactory::_('Compiler.Builder.History')->exists($nameSingleCode)) + { + $toolBar .= PHP_EOL . Indent::_(4) + . "\$canVersion = (\$this->canDo->get('core.version') && \$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.version') + . "'));"; + $toolBar .= PHP_EOL . Indent::_(4) + . "if (\$this->state->params->get('save_history', 1) && \$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.edit') + . "') && \$canVersion)"; + $toolBar .= PHP_EOL . Indent::_(4) . "{"; + $toolBar .= PHP_EOL . Indent::_(5) + . "ToolbarHelper::versions('com_" + . CFactory::_('Config')->component_code_name . "." . $nameSingleCode + . "', \$this->item->id);"; + $toolBar .= PHP_EOL . Indent::_(4) . "}"; + } + } + else + { + if (CFactory::_('Compiler.Builder.History')->exists($nameSingleCode)) + { + $toolBar .= PHP_EOL . Indent::_(4) + . "\$canVersion = (\$this->canDo->get('core.version') && \$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.version') . "'));"; + $toolBar .= PHP_EOL . Indent::_(4) + . "if (\$this->state->params->get('save_history', 1) && \$this->canDo->get('core.edit') && \$canVersion)"; + $toolBar .= PHP_EOL . Indent::_(4) . "{"; + $toolBar .= PHP_EOL . Indent::_(5) + . "ToolbarHelper::versions('com_" + . CFactory::_('Config')->component_code_name . "." . $nameSingleCode + . "', \$this->item->id);"; + $toolBar .= PHP_EOL . Indent::_(4) . "}"; + } + } + $toolBar .= PHP_EOL . Indent::_(4) . "if (\$this->canDo->get('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.create') . "'))"; + $toolBar .= PHP_EOL . Indent::_(4) . "{"; + $toolBar .= PHP_EOL . Indent::_(5) . "ToolbarHelper::custom('" + . $nameSingleCode + . ".save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);"; + $toolBar .= PHP_EOL . Indent::_(4) . "}"; + // add custom buttons + $toolBar .= $this->setCustomButtons($view, 2, Indent::_(2)); + $toolBar .= PHP_EOL . Indent::_(4) . "ToolbarHelper::cancel('" + . $nameSingleCode . ".cancel', 'JTOOLBAR_CLOSE');"; + $toolBar .= PHP_EOL . Indent::_(3) . "}"; + $toolBar .= PHP_EOL . Indent::_(2) . "}"; + $toolBar .= PHP_EOL . Indent::_(2) . "ToolbarHelper::divider();"; + if (CFactory::_('Config')->get('joomla_version', 3) != 3) + { + $toolBar .= PHP_EOL . Indent::_(2) . "ToolbarHelper::inlinehelp();"; + } + $toolBar .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " set help url for this view if found"; + $toolBar .= PHP_EOL . Indent::_(2) . "\$this->help_url = " + . CFactory::_('Compiler.Builder.Content.One')->get('Component') . "Helper::getHelpUrl('" . $nameSingleCode + . "');"; + $toolBar .= PHP_EOL . Indent::_(2) . "if (" + . "Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$this->help_url))"; + $toolBar .= PHP_EOL . Indent::_(2) . "{"; + $toolBar .= PHP_EOL . Indent::_(3) . "ToolbarHelper::help('" + . CFactory::_('Config')->lang_prefix . "_HELP_MANAGER', false, \$this->help_url);"; + $toolBar .= PHP_EOL . Indent::_(2) . "}"; + } + + return $toolBar; + } + + /** + * set the populate state code + * + * @param string $nameSingleCode The single view name + * @param string $nameListCode The list view name + * + * @return string The code for the populate state + * + */ + public function setPopulateState(&$nameSingleCode, &$nameListCode) + { + // reset bucket + $state = ''; + // keep track of all fields already added + $donelist = []; + // we must add the formSubmited code if new above filters is used (2 = topbar) + $new_filter = false; + if (CFactory::_('Compiler.Builder.Admin.Filter.Type')->get($nameListCode, 1) == 2) + { + $state .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" + . Line::_(__Line__, __Class__) . " Check if the form was submitted"; + $state .= PHP_EOL . Indent::_(2) . "\$formSubmited" + . " = \$app->input->post->get('form_submited');"; + $new_filter = true; + } + // add the default populate states (this must be added first) + $state .= $this->setDefaultPopulateState($nameSingleCode, $new_filter); + // add the filters + if (CFactory::_('Compiler.Builder.Filter')->exists($nameListCode)) + { + foreach (CFactory::_('Compiler.Builder.Filter')->get($nameListCode) as $filter) + { + if (!isset($donelist[$filter['code']])) + { + $state .= $this->getPopulateStateFilterCode( + $filter, $new_filter + ); + $donelist[$filter['code']] = true; + } + } + } + // add the rest of the set filters + if (CFactory::_('Compiler.Builder.Sort')->exists($nameListCode)) + { + foreach (CFactory::_('Compiler.Builder.Sort')->get($nameListCode) as $filter) + { + if (!isset($donelist[$filter['code']])) + { + $state .= $this->getPopulateStateFilterCode( + $filter, $new_filter + ); + $donelist[$filter['code']] = true; + } + } + } + + return $state; + } + + /** + * Add the code of the filter in the populate state + * + * @param array $filter The field/filter array + * @param bool $newFilter The switch to use the new filter + * @param string $extra The defaults/extra options of the filter + * + * @return string The code for the populate state + * + */ + protected function getPopulateStateFilterCode(&$filter, $newFilter, + $extra = '' + ) + { + $state = ''; + // add category stuff (may still remove these) TODO + if (isset($filter['type']) && $filter['type'] === 'category') + { + $state .= PHP_EOL . PHP_EOL . Indent::_(2) + . "\$category = \$app->getUserStateFromRequest(\$this->context . '.filter.category', 'filter_category');"; + $state .= PHP_EOL . Indent::_(2) + . "\$this->setState('filter.category', \$category);"; + $state .= PHP_EOL . PHP_EOL . Indent::_(2) + . "\$categoryId = \$this->getUserStateFromRequest(\$this->context . '.filter.category_id', 'filter_category_id');"; + $state .= PHP_EOL . Indent::_(2) + . "\$this->setState('filter.category_id', \$categoryId);"; + } + // always add the default filter + $state .= PHP_EOL . PHP_EOL . Indent::_(2) . "\$" . $filter['code'] + . " = \$this->getUserStateFromRequest(\$this->context . '.filter." + . $filter['code'] . "', 'filter_" . $filter['code'] + . "'" . $extra . ");"; + if ($newFilter) + { + // add the new filter option + $state .= PHP_EOL . Indent::_(2) + . "if (\$formSubmited)"; + $state .= PHP_EOL . Indent::_(2) . "{"; + $state .= PHP_EOL . Indent::_(3) . "\$" . $filter['code'] + . " = \$app->input->post->get('" . $filter['code'] . "');"; + $state .= PHP_EOL . Indent::_(3) + . "\$this->setState('filter." . $filter['code'] + . "', \$" . $filter['code'] . ");"; + $state .= PHP_EOL . Indent::_(2) . "}"; + } + else + { + // the old filter option + $state .= PHP_EOL . Indent::_(2) + . "\$this->setState('filter." . $filter['code'] + . "', \$" . $filter['code'] . ");"; + } + + return $state; + } + + /** + * set the default populate state code + * + * @param string $nameSingleCode The single view name + * @param bool $newFilter The switch to use the new filter + * + * @return string The state code added + * + */ + protected function setDefaultPopulateState(&$nameSingleCode, $newFilter) + { + $state = ''; + // start filter + $filter = array('type' => 'text'); + // if access is not set add its default filter here + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.access')) + { + $filter['code'] = "access"; + $state .= $this->getPopulateStateFilterCode( + $filter, $newFilter, ", 0, 'int'" + ); + } + // if published is not set add its default filter here + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.published')) + { + $filter['code'] = "published"; + $state .= $this->getPopulateStateFilterCode( + $filter, false, ", ''" + ); + } + // if created_by is not set add its default filter here + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.created_by')) + { + $filter['code'] = "created_by"; + $state .= $this->getPopulateStateFilterCode( + $filter, false, ", ''" + ); + } + // if created is not set add its default filter here + if (!CFactory::_('Compiler.Builder.Field.Names')->isString($nameSingleCode . '.created')) + { + $filter['code'] = "created"; + $state .= $this->getPopulateStateFilterCode( + $filter, false + ); + } + + // the sorting defaults are always added + $filter['code'] = "sorting"; + $state .= $this->getPopulateStateFilterCode( + $filter, false, ", 0, 'int'" + ); + // the search defaults are always added + $filter['code'] = "search"; + $state .= $this->getPopulateStateFilterCode($filter, false); + + return $state; + } + + /** + * set the sorted field array for the getSortFields method + * + * @param string $nameSingleCode The single view name + * + * @return string The array/string of fields to add to the getSortFields method + * + */ + public function setSortFields(&$nameListCode) + { + // keep track of all fields already added + $donelist = array('ordering', 'published'); + // set the default first + $fields = "return array("; + $fields .= PHP_EOL . Indent::_(3) . "'a.ordering' => Text:" + . ":_('JGRID_HEADING_ORDERING')"; + $fields .= "," . PHP_EOL . Indent::_(3) . "'a.published' => Text:" + . ":_('JSTATUS')"; + + // add the rest of the set filters + if (CFactory::_('Compiler.Builder.Sort')->exists($nameListCode)) + { + foreach (CFactory::_('Compiler.Builder.Sort')->get($nameListCode) as $filter) + { + if (!in_array($filter['code'], $donelist)) + { + if ($filter['type'] === 'category') + { + $fields .= "," . PHP_EOL . Indent::_(3) + . "'category_title' => Text:" . ":_('" + . $filter['lang'] . "')"; + } + elseif (ArrayHelper::check( + $filter['custom'] + )) + { + $fields .= "," . PHP_EOL . Indent::_(3) . "'" + . $filter['custom']['db'] . "." + . $filter['custom']['text'] . "' => Text:" . ":_('" + . $filter['lang'] . "')"; + } + else + { + $fields .= "," . PHP_EOL . Indent::_(3) . "'a." + . $filter['code'] . "' => Text:" . ":_('" + . $filter['lang'] . "')"; + } + } + } + } + $fields .= "," . PHP_EOL . Indent::_(3) . "'a.id' => Text:" + . ":_('JGRID_HEADING_ID')"; + $fields .= PHP_EOL . Indent::_(2) . ");"; + + // return fields + return $fields; + } + + public function setCheckinCall() + { + $call = PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Check in items"; + $call .= PHP_EOL . Indent::_(2) . "\$this->checkInNow();" . PHP_EOL; + + return $call; + } + + public function setAutoCheckin($view, $component) + { + $checkin = PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $checkin .= PHP_EOL . Indent::_(1) + . " * Build an SQL query to checkin all items left checked out longer then a set time."; + $checkin .= PHP_EOL . Indent::_(1) . " *"; + $checkin .= PHP_EOL . Indent::_(1) . " * @return bool"; + $checkin .= PHP_EOL . Indent::_(1) . " * @since 3.2.0"; + $checkin .= PHP_EOL . Indent::_(1) . " */"; + $checkin .= PHP_EOL . Indent::_(1) . "protected function checkInNow(): bool"; + $checkin .= PHP_EOL . Indent::_(1) . "{"; + $checkin .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) + . " Get set check in time"; + $checkin .= PHP_EOL . Indent::_(2) + . "\$time = ComponentHelper::getParams('com_" . $component + . "')->get('check_in');"; + $checkin .= PHP_EOL . PHP_EOL . Indent::_(2) . "if (\$time)"; + $checkin .= PHP_EOL . Indent::_(2) . "{"; + $checkin .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Get a db connection."; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $checkin .= PHP_EOL . Indent::_(3) . "\$db = Factory::getDbo();"; + } + else + { + $checkin .= PHP_EOL . Indent::_(3) . "\$db = \$this->getDatabase();"; + } + $checkin .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Reset query."; + $checkin .= PHP_EOL . Indent::_(3) . "\$query = \$db->getQuery(true);"; + $checkin .= PHP_EOL . Indent::_(3) . "\$query->select('*');"; + $checkin .= PHP_EOL . Indent::_(3) + . "\$query->from(\$db->quoteName('#__" . $component . "_" . $view + . "'));"; + $checkin .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Only select items that are checked out."; + $checkin .= PHP_EOL . Indent::_(3) + . "\$query->where(\$db->quoteName('checked_out') . '!=0');"; + Indent::_(3) . "//" . Line::_(__Line__, __Class__) + . " Query only to see if we have a rows"; + $checkin .= PHP_EOL . Indent::_(3) . "\$db->setQuery(\$query, 0, 1);"; + $checkin .= PHP_EOL . Indent::_(3) . "\$db->execute();"; + $checkin .= PHP_EOL . Indent::_(3) . "if (\$db->getNumRows())"; + $checkin .= PHP_EOL . Indent::_(3) . "{"; + $checkin .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Get Yesterdays date."; + $checkin .= PHP_EOL . Indent::_(4) + . "\$date = Factory::getDate()->modify(\$time)->toSql();"; + $checkin .= PHP_EOL . Indent::_(4) . "//" . Line::_(__Line__, __Class__) + . " Reset query."; + $checkin .= PHP_EOL . Indent::_(4) . "\$query = \$db->getQuery(true);"; + $checkin .= PHP_EOL . PHP_EOL . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Fields to update."; + $checkin .= PHP_EOL . Indent::_(4) . "\$fields = array("; + $checkin .= PHP_EOL . Indent::_(5) + . "\$db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'',"; + $checkin .= PHP_EOL . Indent::_(5) + . "\$db->quoteName('checked_out') . '=0'"; + $checkin .= PHP_EOL . Indent::_(4) . ");"; + $checkin .= PHP_EOL . PHP_EOL . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Conditions for which records should be updated."; + $checkin .= PHP_EOL . Indent::_(4) . "\$conditions = array("; + $checkin .= PHP_EOL . Indent::_(5) + . "\$db->quoteName('checked_out') . '!=0', "; + $checkin .= PHP_EOL . Indent::_(5) + . "\$db->quoteName('checked_out_time') . '<\''.\$date.'\''"; + $checkin .= PHP_EOL . Indent::_(4) . ");"; + $checkin .= PHP_EOL . PHP_EOL . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Check table."; + $checkin .= PHP_EOL . Indent::_(4) + . "\$query->update(\$db->quoteName('#__" . $component . "_" . $view + . "'))->set(\$fields)->where(\$conditions); "; + $checkin .= PHP_EOL . PHP_EOL . Indent::_(4) + . "\$db->setQuery(\$query);"; + $checkin .= PHP_EOL . PHP_EOL . Indent::_(4) . "return \$db->execute();"; + $checkin .= PHP_EOL . Indent::_(3) . "}"; + $checkin .= PHP_EOL . Indent::_(2) . "}"; + $checkin .= PHP_EOL . PHP_EOL . Indent::_(2) . "return false;"; + $checkin .= PHP_EOL . Indent::_(1) . "}"; + + return $checkin; + } + + public function setGetItemsMethodStringFix($nameSingleCode, $nameListCode, + $Component, $tab = '', $export = false, $all = false) + { + // add the fix if this view has the need for it + $fix = ''; + $forEachStart = ''; + $fix_access = ''; + // encryption switches + foreach (CFactory::_('Config')->cryption_types as $cryptionType) + { + ${$cryptionType . 'Crypt'} = false; + } + $component = StringHelper::safe($Component); + // check if the item has permissions. + if (CFactory::_('Compiler.Creator.Permission')->actionExist($nameSingleCode, 'core.access')) + { + $fix_access = PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) + . " Remove items the user can't access."; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "\$access = (\$user->authorise('" + . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.access') + . "', 'com_" . $component . "." . $nameSingleCode + . ".' . (int) \$item->id) && \$user->authorise('" + . CFactory::_('Compiler.Creator.Permission')->getAction($nameSingleCode, 'core.access') + . "', 'com_" . $component . "'));"; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "if (!\$access)"; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "{"; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) + . "unset(\$items[\$nr]);"; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) + . "continue;"; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "}" + . PHP_EOL; + } + // add the tags if needed + if (CFactory::_('Compiler.Builder.Tags')->exists($nameSingleCode)) + { + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//" + . Line::_( + __LINE__,__CLASS__ + ) . " Add the tags"; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "\$item->tags = new TagsHelper;"; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "\$item->tags->getTagIds("; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) + . "\$item->id, 'com_" + . CFactory::_('Compiler.Builder.Content.One')->get('component') . ".$nameSingleCode'"; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . ");"; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "if (\$item->tags->tags)"; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "{"; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) + . "\$item->tags = implode(', ',"; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) + . "\$item->tags->getTagNames("; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(6) + . "explode(',', \$item->tags->tags)"; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) . ")"; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) . ");"; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "}"; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "else"; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "{"; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) + . "\$item->tags = '';"; + $fix_access .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "}"; + } + // get the correct array + if ($export || $all) + { + $action_ = 'Eximport'; + } + else + { + $action_ = 'List'; + } + // load the relations before modeling + if (($field_relations = + CFactory::_('Compiler.Builder.Field.Relations')->get($nameListCode)) !== null) + { + foreach ($field_relations as $field_id => $fields) + { + foreach ($fields as $area => $field) + { + if ($area == 1 && isset($field['code'])) + { + $fix .= $this->setModelFieldRelation( + $field, $nameListCode, $tab + ); + } + } + } + } + // open the values + if (CFactory::_("Compiler.Builder.Items.Method.{$action_}.String")->exists($nameSingleCode)) + { + foreach (CFactory::_("Compiler.Builder.Items.Method.{$action_}.String")-> + get($nameSingleCode) as $item) + { + switch ($item['method']) + { + case 1: + // JSON_STRING_ENCODE + $decode = 'json_decode'; + $suffix_decode = ', true'; + break; + case 2: + // BASE_SIXTY_FOUR + $decode = 'base64_decode'; + $suffix_decode = ''; + break; + case 3: + // BASIC_ENCRYPTION_LOCALKEY + $decode = '$basic->decryptString'; + $basicCrypt = true; + $suffix_decode = ''; + break; + case 4: + // WHMCS_ENCRYPTION_WHMCS + $decode = '$whmcs->decryptString'; + $whmcsCrypt = true; + $suffix_decode = ''; + break; + case 5: + // MEDIUM_ENCRYPTION_LOCALFILE + $decode = '$medium->decryptString'; + $mediumCrypt = true; + $suffix_decode = ''; + break; + case 6: + // EXPERT_ENCRYPTION + $expertCrypt = true; + break; + default: + // JSON_ARRAY_ENCODE + $decode = 'json_decode'; + $suffix_decode = ', true'; + // fallback on json + $item['method'] = 1; + break; + } + + if ($item['type'] === 'usergroup' && !$export + && $item['method'] != 6) + { + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) . " decode " . $item['name']; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "\$" + . $item['name'] . "Array = " . $decode . "(\$item->" + . $item['name'] . $suffix_decode . ");"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "if (Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$" + . $item['name'] . "Array))"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "{"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) . "\$" + . $item['name'] . "Names = [];"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) + . "foreach (\$" . $item['name'] . "Array as \$" + . $item['name'] . ")"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) . "{"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) . "\$" + . $item['name'] . "Names[] = " . $Component + . "Helper::getGroupName(\$" . $item['name'] . ");"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) . "}"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) + . "\$item->" . $item['name'] . " = implode(', ', \$" + . $item['name'] . "Names);"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "}"; + } + /* elseif ($item['type'] === 'usergroup' && $export) + { + $fix .= PHP_EOL.Indent::_(1).$tab.Indent::_(3) . "//".Line::_(__Line__, __Class__)." decode ".$item['name']; + $fix .= PHP_EOL.Indent::_(1).$tab.Indent::_(3) . "\$".$item['name']."Array = ".$decode."(\$item->".$item['name'].$suffix_decode.");"; + $fix .= PHP_EOL.Indent::_(1).$tab.Indent::_(3) . "if (Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$".$item['name']."Array))"; + $fix .= PHP_EOL.Indent::_(1).$tab.Indent::_(3) . "{"; + $fix .= PHP_EOL.Indent::_(1).$tab.Indent::_(4) . "\$item->".$item['name']." = implode('|',\$".$item['name']."Array);"; + $fix .= PHP_EOL.Indent::_(1).$tab.Indent::_(3) . "}"; + } */ + elseif ($item['translation'] && !$export + && $item['method'] != 6) + { + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) . " decode " . $item['name']; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "\$" + . $item['name'] . "Array = " . $decode . "(\$item->" + . $item['name'] . $suffix_decode . ");"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "if (Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$" + . $item['name'] . "Array))"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "{"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) . "\$" + . $item['name'] . "Names = [];"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) + . "foreach (\$" . $item['name'] . "Array as \$" + . $item['name'] . ")"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) . "{"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) . "\$" + . $item['name'] . "Names[] = Text:" + . ":_(\$this->selectionTranslation(\$" . $item['name'] + . ", '" . $item['name'] . "'));"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) . "}"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) + . "\$item->" . $item['name'] . " = implode(', ', \$" + . $item['name'] . "Names);"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "}"; + } + else + { + if ($item['method'] == 2 || $item['method'] == 3 || $item['method'] == 4 + || $item['method'] == 5 || $item['method'] == 6) + { + // expert mode (dev must do it all) + if ($item['method'] == 6) + { + $_placeholder_for_field + = array('[[[field]]]' => "\$item->" . $item['name']); + $fix .= CFactory::_('Placeholder')->update( + PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . implode(PHP_EOL . Indent::_(1) . $tab . Indent::_(3), + CFactory::_('Compiler.Builder.Model.Expert.Field')->get( + $nameSingleCode . '.' . $item['name'] . '.get', [] + ) + ), $_placeholder_for_field + ); + } + else + { + $taber = ''; + if ($item['method'] == 3) + { + $taber = Indent::_(1); + $fix .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(3) + . "if (\$basickey && !is_numeric(\$item->" + . $item['name'] . ") && \$item->" + . $item['name'] + . " === base64_encode(base64_decode(\$item->" + . $item['name'] . ", true)))"; + $fix .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(3) . "{"; + } + elseif ($item['method'] == 5) + { + $taber = Indent::_(1); + $fix .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(3) + . "if (\$mediumkey && !is_numeric(\$item->" + . $item['name'] . ") && \$item->" + . $item['name'] + . " === base64_encode(base64_decode(\$item->" + . $item['name'] . ", true)))"; + $fix .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(3) . "{"; + } + elseif ($item['method'] == 4) + { + $taber = Indent::_(1); + $fix .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(3) + . "if (\$whmcskey && !is_numeric(\$item->" + . $item['name'] . ") && \$item->" + . $item['name'] + . " === base64_encode(base64_decode(\$item->" + . $item['name'] . ", true)))"; + $fix .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(3) . "{"; + } + if ($item['method'] == 3 || $item['method'] == 4 + || $item['method'] == 5) + { + $fix .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " decrypt " . $item['name']; + } + else + { + $fix .= PHP_EOL . Indent::_(1) . $tab . $taber + . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " decode " . $item['name']; + } + $fix .= PHP_EOL . Indent::_(1) . $tab . $taber + . Indent::_(3) . "\$item->" . $item['name'] + . " = " . $decode . "(\$item->" . $item['name'] + . ");"; + + if ($item['method'] == 3 || $item['method'] == 4 + || $item['method'] == 5) + { + $fix .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(3) . "}"; + } + } + } + else + { + if ($export && $item['type'] === 'repeatable') + { + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "//" . Line::_(__Line__, __Class__) + . " decode repeatable " . $item['name']; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "\$" . $item['name'] . "Array = " . $decode + . "(\$item->" . $item['name'] . $suffix_decode + . ");"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "if (Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$" + . $item['name'] . "Array))"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "{"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) + . "\$bucket" . $item['name'] . " = [];"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) + . "foreach (\$" . $item['name'] . "Array as \$" + . $item['name'] . "FieldName => \$" + . $item['name'] . ")"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) + . "{"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) + . "if (Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$" + . $item['name'] . "))"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) + . "{"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(6) + . "\$bucket" . $item['name'] . "[] = \$" + . $item['name'] + . "FieldName . '<||VDM||>' . implode('<|VDM|>',\$" + . $item['name'] . ");"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) + . "}"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) + . "}"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) + . "//" . Line::_(__Line__, __Class__) + . " make sure the bucket has values."; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) + . "if (Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$bucket" + . $item['name'] . "))"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) + . "{"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) + . "//" . Line::_(__Line__, __Class__) + . " clear the repeatable field."; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) + . "unset(\$item->" . $item['name'] . ");"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) + . "//" . Line::_(__Line__, __Class__) + . " set repeatable field for export."; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) + . "\$item->" . $item['name'] + . " = implode('<|||VDM|||>',\$bucket" + . $item['name'] . ");"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) + . "//" . Line::_(__Line__, __Class__) + . " unset the bucket."; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(5) + . "unset(\$bucket" . $item['name'] . ");"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(4) + . "}"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "}"; + } + elseif ($item['method'] == 1 && !$export) + { + // TODO we check if this works well. + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "//" . Line::_(__Line__, __Class__) . " convert " + . $item['name']; + if (isset($item['custom']['table'])) + { + // check if this is a local table + if (strpos( + (string) $item['custom']['table'], + '#__' . CFactory::_('Config')->component_code_name . '_' + ) !== false) + { + $keyTableNAme = str_replace( + '#__' . CFactory::_('Config')->component_code_name . '_', + '', (string) $item['custom']['table'] + ); + } + else + { + $keyTableNAme = $item['custom']['table']; + } + $fix .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(3) . "\$item->" . $item['name'] + . " = Super_" . "__4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::string(\$item->" + . $item['name'] . ", ', ', '" + . $keyTableNAme . "', '" + . $item['custom']['id'] . "', '" + . $item['custom']['text'] . "');"; + } + else + { + $fix .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(3) . "\$item->" . $item['name'] + . " = Super_" . "__4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::string(\$item->" + . $item['name'] . ", ', ', '" + . $item['name'] . "');"; + } + } + else + { + if (!$export) + { + // For those we have not cached yet. + $fix .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " convert " . $item['name']; + $fix .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(3) . "\$item->" . $item['name'] + . " = Super_" . "__4b225c51_d293_48e4_b3f6_5136cf5c3f18___Power::string(\$item->" + . $item['name'] . ");"; + } + } + } + } + } + } + /* // set translation (TODO) would be nice to cut down on double loops.. + if (!$export && CFactory::_('Compiler.Builder.Selection.Translation')->exists($nameListCode)) + { + foreach (CFactory::_('Compiler.Builder.Selection.Translation')->get($nameListCode) as $name => $values) + { + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " convert " . $name; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "\$item->" . $name . " = \$this->selectionTranslation(\$item->" . $name . ", '" . $name . "');"; + } + } */ + // load the relations after modeling + if (($field_relations = + CFactory::_('Compiler.Builder.Field.Relations')->get($nameListCode)) !== null) + { + foreach ($field_relations as $fields) + { + foreach ($fields as $area => $field) + { + if ($area == 3 && isset($field['code'])) + { + $fix .= $this->setModelFieldRelation( + $field, $nameListCode, $tab + ); + } + } + } + } + // close the foreach if needed + if (StringHelper::check($fix) || StringHelper::check($fix_access) || $export || $all) + { + // start the loop + $forEachStart = PHP_EOL . PHP_EOL . Indent::_(1) . $tab . Indent::_( + 1 + ) . "//" . Line::_(__Line__, __Class__) + . " Set values to display correctly."; + $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "if (Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$items))"; + $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "{"; + // do not add to export since it is already done + if (!$export) + { + $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) + . "//" . Line::_(__Line__, __Class__) + . " Get the user object if not set."; + $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) + . "if (!isset(\$user) || !" + . "Super_" . "__91004529_94a9_4590_b842_e7c6b624ecf5___Power::check(\$user))"; + $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) + . "{"; + if (CFactory::_('Config')->get('joomla_version', 3) == 3) + { + $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "\$user = Factory::getUser();"; + } + else + { + $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "\$user = \$this->getCurrentUser();"; + } + $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) + . "}"; + } + // the permissional acttion switch + $hasPermissional = false; + // add the permissional removal of values the user has not right to view or access + if (CFactory::_('Config')->get('permission_strict_per_field', false) + && CFactory::_('Compiler.Builder.Permission.Fields')->isArray($nameSingleCode)) + { + foreach (CFactory::_('Compiler.Builder.Permission.Fields')->get($nameSingleCode) + as $fieldName => $permission_options) + { + if (!$hasPermissional) + { + foreach ($permission_options as $permission_option => $fieldType) + { + if (!$hasPermissional) + { + switch ($permission_option) + { + case 'access': + case 'view': + $hasPermissional = true; + break; + } + } + } + } + } + // add the notes and get the global switch + if ($hasPermissional) + { + $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_( + 2 + ) . "//" . Line::_(__Line__, __Class__) + . " Get global permissional control activation. (default is inactive)"; + $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_( + 2 + ) + . "\$strict_permission_per_field = ComponentHelper::getParams('com_" + . $component + . "')->get('strict_permission_per_field', 0);" + . PHP_EOL; + } + } + $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) + . "foreach (\$items as \$nr => &\$item)"; + $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) . "{"; + // add the access options + $forEachStart .= $fix_access; + // add the permissional removal of values the user has not right to view or access + if ($hasPermissional) + { + $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "//" . Line::_(__Line__, __Class__) + . " use permissional control if globally set."; + $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "if (\$strict_permission_per_field)"; + $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "{"; + foreach (CFactory::_('Compiler.Builder.Permission.Fields')->get($nameSingleCode) + as $fieldName => $permission_options) + { + foreach ($permission_options as $permission_option => $fieldType) + { + switch ($permission_option) + { + case 'access': + case 'view': + $forEachStart .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(4) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " set " . $permission_option + . " permissional control for " . $fieldName + . " value."; + $forEachStart .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(4) . "if (isset(\$item->" + . $fieldName . ") && (!\$user->authorise('" + . $nameSingleCode . "." + . $permission_option . "." . $fieldName + . "', 'com_" . $component . "." + . $nameSingleCode + . ".' . (int) \$item->id)"; + $forEachStart .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(5) . "|| !\$user->authorise('" + . $nameSingleCode . "." + . $permission_option . "." . $fieldName + . "', 'com_" . $component . "')))"; + $forEachStart .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(4) . "{"; + $forEachStart .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(5) . "//" . Line::_( + __LINE__,__CLASS__ + ) + . " We JUST empty the value (do you have a better idea)"; + $forEachStart .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(5) . "\$item->" . $fieldName + . " = '';"; + $forEachStart .= PHP_EOL . Indent::_(1) . $tab + . Indent::_(4) . "}"; + break; + } + } + } + $forEachStart .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "}"; + } + // remove these values if export + if ($export) + { + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) + . " unset the values we don't want exported."; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "unset(\$item->asset_id);"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "unset(\$item->checked_out);"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "unset(\$item->checked_out_time);"; + } + + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) . "}"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "}"; + if ($export) + { + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "//" + . Line::_(__Line__, __Class__) . " Add headers to items array."; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "\$headers = \$this->getExImPortHeaders();"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "if (" + . "Super_" . "__91004529_94a9_4590_b842_e7c6b624ecf5___Power::check(\$headers))"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "{"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) + . "array_unshift(\$items,\$headers);"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "}"; + } + } + + // add custom php to getitems method + $fix .= CFactory::_('Customcode.Dispenser')->get( + 'php_getitems', $nameSingleCode, PHP_EOL . PHP_EOL . $tab + ); + + // load the encryption object if needed + $script = ''; + foreach (CFactory::_('Config')->cryption_types as $cryptionType) + { + if (${$cryptionType . 'Crypt'}) + { + if ('expert' !== $cryptionType) + { + $script .= PHP_EOL . PHP_EOL . Indent::_(1) . $tab + . Indent::_(1) . "//" . Line::_(__Line__, __Class__) + . " Get the " . $cryptionType . " encryption key."; + $script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "\$" . $cryptionType . "key = " . $Component + . "Helper::getCryptKey('" . $cryptionType . "');"; + $script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "//" . Line::_(__Line__, __Class__) + . " Get the encryption object."; + $script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "\$" . $cryptionType . " = new Super_" . "__99175f6d_dba8_4086_8a65_5c4ec175e61d___Power(\$" + . $cryptionType . "key);"; + } + elseif (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> + exists("{$nameSingleCode}.get")) + { + foreach (CFactory::_('Compiler.Builder.Model.' . ucfirst($cryptionType). '.Field.Initiator')-> + get("{$nameSingleCode}.get") as $block) + { + $script .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . implode( + PHP_EOL . Indent::_(1) . $tab . Indent::_(1), $block + ); + } + } + } + } + + // add the encryption script + return $script . $forEachStart . $fix; + } + + /** + * Build headers for the various files + * + * @param string $context The name of the context + * @param string $codeName The view, views, or layout code name + * @param string $default The default to return if none is found + * + * @return string The php to place in the header + * @deprecated 3.3 Use CFactory::_('Header')->get($context, $codeName, $default); + */ + public function setFileHeader($context, $codeName, $default = '') + { + return CFactory::_('Header')->get($context, $codeName, $default); + } + + /** + * set Helper Dynamic Headers + * + * @param array $headers The headers array + * @param string $target_client + * + * @return void + * @deprecated 3.3 + */ + protected function setHelperClassHeader(&$headers, $target_client) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * Build chosen multi selection headers for the view + * + * @param array $headers The headers array + * @param string $nameListCode The list view name + * + * @return void + * @deprecated 3.3 + */ + protected function setChosenMultiSelectionHeaders(&$headers, $nameListCode) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + protected function setModelFieldRelation($item, $nameListCode, $tab) + { + $fix = ''; + // set fields + $field = []; + // set list field name + $field['$item->{' . (int) $item['listfield'] . '}'] = '$item->' + . $item['code']; + // load joint field names + if (isset($item['joinfields']) + && ArrayHelper::check( + $item['joinfields'] + )) + { + foreach ($item['joinfields'] as $join) + { + $field['$item->{' . (int) $join . '}'] = '$item->' + . CFactory::_('Compiler.Builder.List.Join')->get($nameListCode . '.' . (int) $join . '.code', 'error'); + } + } + // set based on join_type + if ($item['join_type'] == 2) + { + // code + $code = (array) explode( + PHP_EOL, str_replace( + array_keys($field), array_values($field), (string) $item['set'] + ) + ); + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . implode( + PHP_EOL . Indent::_(1) . $tab . Indent::_(3), $code + ); + } + else + { + // concatenate + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) . " concatenate these fields"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "\$item->" + . $item['code'] . ' = ' . implode( + " . '" . str_replace("'", ''', (string) $item['set']) . "' . ", + $field + ) . ';'; + } + + return CFactory::_('Placeholder')->update_($fix); + } + + public function setSelectionTranslationFix($views, $Component, $tab = '') + { + // add the fix if this view has the need for it + $fix = ''; + if (CFactory::_('Compiler.Builder.Selection.Translation')->exists($views)) + { + $fix .= PHP_EOL . PHP_EOL . Indent::_(1) . $tab . Indent::_(1) + . "//" . Line::_(__Line__, __Class__) + . " set selection value to a translatable value"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "if (" + . "Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$items))"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "{"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) + . "foreach (\$items as \$nr => &\$item)"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) . "{"; + foreach (CFactory::_('Compiler.Builder.Selection.Translation')-> + get($views) as $name => $values) + { + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) . "//" + . Line::_(__Line__, __Class__) . " convert " . $name; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(3) + . "\$item->" . $name + . " = \$this->selectionTranslation(\$item->" . $name . ", '" + . $name . "');"; + } + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(2) . "}"; + $fix .= PHP_EOL . Indent::_(1) . $tab . Indent::_(1) . "}" + . PHP_EOL; + } + + return $fix; + } + + public function setSelectionTranslationFixFunc($views, $Component) + { + // add the fix if this view has the need for it + $fix = ''; + if (CFactory::_('Compiler.Builder.Selection.Translation')->exists($views)) + { + $fix .= PHP_EOL . PHP_EOL . Indent::_(1) . "/**"; + $fix .= PHP_EOL . Indent::_(1) + . " * Method to convert selection values to translatable string."; + $fix .= PHP_EOL . Indent::_(1) . " *"; + $fix .= PHP_EOL . Indent::_(1) . " * @return string The translatable string."; + $fix .= PHP_EOL . Indent::_(1) . " */"; + $fix .= PHP_EOL . Indent::_(1) + . "public function selectionTranslation(\$value,\$name)"; + $fix .= PHP_EOL . Indent::_(1) . "{"; + foreach (CFactory::_('Compiler.Builder.Selection.Translation')-> + get($views) as $name => $values) + { + if (ArrayHelper::check($values)) + { + $fix .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Array of " . $name . " language strings"; + $fix .= PHP_EOL . Indent::_(2) . "if (\$name === '" + . $name . "')"; + $fix .= PHP_EOL . Indent::_(2) . "{"; + $fix .= PHP_EOL . Indent::_(3) . "\$" . $name + . "Array = array("; + $counter = 0; + foreach ($values as $value => $translang) + { + // only add quotes to strings + if (StringHelper::check($value)) + { + $key = "'" . $value . "'"; + } + else + { + if ($value == '') + { + $value = 0; + } + $key = $value; + } + if ($counter == 0) + { + $fix .= PHP_EOL . Indent::_(4) . $key . " => '" + . $translang . "'"; + } + else + { + $fix .= "," . PHP_EOL . Indent::_(4) . $key + . " => '" . $translang . "'"; + } + $counter++; + } + $fix .= PHP_EOL . Indent::_(3) . ");"; + $fix .= PHP_EOL . Indent::_(3) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Now check if value is found in this array"; + $fix .= PHP_EOL . Indent::_(3) . "if (isset(\$" . $name + . "Array[\$value]) && " + . "Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$" . $name . "Array[\$value]))"; + $fix .= PHP_EOL . Indent::_(3) . "{"; + $fix .= PHP_EOL . Indent::_(4) . "return \$" . $name + . "Array[\$value];"; + $fix .= PHP_EOL . Indent::_(3) . "}"; + $fix .= PHP_EOL . Indent::_(2) . "}"; + } + } + $fix .= PHP_EOL . Indent::_(2) . "return \$value;"; + $fix .= PHP_EOL . Indent::_(1) . "}"; + } + + return $fix; + } + + public function setRouterCase($viewsCodeName) + { + if (strlen((string) $viewsCodeName) > 0) + { + $router = PHP_EOL . Indent::_(2) . "case '" . $viewsCodeName . "':"; + $router .= PHP_EOL . Indent::_(3) + . "\$id = explode(':', \$segments[\$count-1]);"; + $router .= PHP_EOL . Indent::_(3) . "\$vars['id'] = (int) \$id[0];"; + $router .= PHP_EOL . Indent::_(3) . "\$vars['view'] = '" + . $viewsCodeName + . "';"; + $router .= PHP_EOL . Indent::_(2) . "break;"; + + return $router; + } + + return ''; + } + + public function setComponentImageType($path) + { + $type = ComponentbuilderHelper::imageInfo($path); + if ($type) + { + $imagePath = CFactory::_('Utilities.Paths')->component_path . '/admin/assets/images'; + // move the image to its place + File::copy( + JPATH_SITE . '/' . $path, + $imagePath . '/vdm-component.' . $type + ); + // now set the type to global for re-use + $this->componentImageType = $type; + + // return image type + return $type; + } + $this->componentImageType = 'jpg'; + + return 'jpg'; + } + + public function setDashboardIconAccess() + { + return CFactory::_('Compiler.Builder.Permission.Dashboard')->build(); + } + + public function setDashboardIcons() + { + if (CFactory::_('Component')->isArray('admin_views')) + { + $icons = ''; + $counter = 0; + $catArray = []; + foreach (CFactory::_('Component')->get('admin_views') as $view) + { + $name_single = StringHelper::safe( + $view['settings']->name_single + ); + $name_list = StringHelper::safe( + $view['settings']->name_list + ); + + $icons .= $this->addCustomDashboardIcons($view, $counter); + if (isset($view['dashboard_add']) + && $view['dashboard_add'] == 1) + { + $type = ComponentbuilderHelper::imageInfo( + $view['settings']->icon_add + ); + if ($type) + { + $type = $type . "."; + // icon builder loader + $this->iconBuilder[$type . $name_single . ".add"] + = $view['settings']->icon_add; + } + else + { + $type = 'png.'; + } + if ($counter == 0) + { + $icons .= "'" . $type . $name_single . ".add'"; + } + else + { + $icons .= ", '" . $type . $name_single . ".add'"; + } + // build lang + $langName = 'Add ' + . StringHelper::safe( + $view['settings']->name_single, 'W' + ) . '

    '; + $langKey = CFactory::_('Config')->lang_prefix . '_DASHBOARD_' + . StringHelper::safe( + $view['settings']->name_single, 'U' + ) . '_ADD'; + // add to lang + CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $langKey, $langName); + $counter++; + } + if (isset($view['dashboard_list']) + && $view['dashboard_list'] == 1) + { + $type = ComponentbuilderHelper::imageInfo( + $view['settings']->icon + ); + if ($type) + { + $type = $type . "."; + // icon builder loader + $this->iconBuilder[$type . $name_list] + = $view['settings']->icon; + } + else + { + $type = 'png.'; + } + if ($counter == 0) + { + $icons .= "'" . $type . $name_list . "'"; + } + else + { + $icons .= ", '" . $type . $name_list . "'"; + } + // build lang + $langName = StringHelper::safe( + $view['settings']->name_list, 'W' + ) . '

    '; + $langKey = CFactory::_('Config')->lang_prefix . '_DASHBOARD_' + . StringHelper::safe( + $view['settings']->name_list, 'U' + ); + // add to lang + CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $langKey, $langName); + $counter++; + } + // dashboard link to category on dashboard is build here + if (CFactory::_('Compiler.Builder.Category')->exists("{$name_list}.code")) + { + $catCode = CFactory::_('Compiler.Builder.Category')->get("{$name_list}.code"); + + // check if category has another name + $otherViews = CFactory::_('Compiler.Builder.Category.Other.Name')-> + get($name_list . '.views', $name_list); + $otherNames = CFactory::_('Compiler.Builder.Category.Other.Name')-> + get($name_list . '.name'); + if ($otherNames !== null) + { + // build lang + $langName = StringHelper::safe( + $otherNames, 'W' + ); + } + else + { + // build lang + $langName = 'Categories For
    ' + . StringHelper::safe( + $otherViews, 'W' + ); + } + // only load this category once + if (!in_array($otherViews, $catArray)) + { + // set the extension key string, new convention (more stable) + $_key_extension = str_replace( + '.', '_po0O0oq_', + (string) CFactory::_('Compiler.Builder.Category')->get("{$name_list}.extension", 'error') + ); + + // add to lang + $langKey = CFactory::_('Config')->lang_prefix . '_DASHBOARD_' + . StringHelper::safe( + $otherViews, 'U' + ) . '_' . StringHelper::safe( + $catCode, 'U' + ); + CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $langKey, $langName); + // get image type + $type = ComponentbuilderHelper::imageInfo( + $view['settings']->icon_category + ); + if ($type) + { + $type = $type . "."; + // icon builder loader + $this->iconBuilder[$type . $otherViews . "." + . $catCode] + = $view['settings']->icon_category; + } + else + { + $type = 'png.'; + } + if ($counter == 0) + { + $icons .= "'" . $type . $otherViews . "." . $catCode + . '_qpo0O0oqp_' . $_key_extension . "'"; + } + else + { + $icons .= ", '" . $type . $otherViews . "." + . $catCode . '_qpo0O0oqp_' . $_key_extension + . "'"; + } + $counter++; + // make sure we add a category only once + $catArray[] = $otherViews; + } + } + } + if (isset($this->lastCustomDashboardIcon) + && ArrayHelper::check( + $this->lastCustomDashboardIcon + )) + { + foreach ($this->lastCustomDashboardIcon as $icon) + { + $icons .= $icon; + } + unset($this->lastCustomDashboardIcon); + } + if (isset($this->iconBuilder) + && ArrayHelper::check( + $this->iconBuilder + )) + { + $imagePath = CFactory::_('Utilities.Paths')->component_path + . '/admin/assets/images/icons'; + foreach ($this->iconBuilder as $icon => $path) + { + $array_buket = explode('.', (string) $icon); + if (count((array) $array_buket) == 3) + { + list($type, $name, $action) = $array_buket; + } + else + { + list($type, $name) = $array_buket; + $action = false; + } + // set the new image name + if ($action) + { + $imageName = $name . '_' . $action . '.' . $type; + } + else + { + $imageName = $name . '.' . $type; + } + // move the image to its place + File::copy( + JPATH_SITE . '/' . $path, $imagePath . '/' . $imageName + ); + } + } + + return $icons; + } + + return false; + } + + public function setDashboardModelMethods() + { + if (CFactory::_('Component')->isString('php_dashboard_methods')) + { + // get hte value + $php_dashboard_methods = CFactory::_('Component')->get('php_dashboard_methods'); + // get all the mothods that should load date to the view + $this->DashboardGetCustomData + = GetHelper::allBetween( + $php_dashboard_methods, + 'public function get', '()' + ); + + // return the methods + return PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update_( + $php_dashboard_methods + ); + } + + return ''; + } + + public function setDashboardGetCustomData() + { + if (isset($this->DashboardGetCustomData) + && ArrayHelper::check( + $this->DashboardGetCustomData + )) + { + // gets array reset + $gets = []; + // set dashboard gets + foreach ($this->DashboardGetCustomData as $get) + { + $string = StringHelper::safe($get); + $gets[] = "\$this->" . $string . " = \$this->get('" . $get + . "');"; + } + + // return the gets + return PHP_EOL . Indent::_(2) . implode( + PHP_EOL . Indent::_(2), $gets + ); + } + + return ''; + } + + public function setDashboardDisplayData() + { + // display array reset + $display = []; + $mainAccordianName = 'cPanel'; + $builder = []; + $tab = Indent::_(3); + $loadTabs = false; + $width_class = 'span'; + $row_class = 'row-fluid'; + $form_class = 'form-horizontal'; + $uitab = 'bootstrap'; + if (CFactory::_('Config')->get('joomla_version', 3) != 3) + { + $width_class = 'col-md-'; + $row_class = 'row'; + $form_class = 'main-card'; + $uitab = 'uitab'; + } + // check if we have custom tabs + if (CFactory::_('Component')->isArray('dashboard_tab')) + { + // build the tabs and accordians + foreach (CFactory::_('Component')->get('dashboard_tab') as $data) + { + $builder[$data['name']][$data['header']] + = CFactory::_('Placeholder')->update_( + $data['html'] + ); + } + // since we have custom tabs we must load the tab structure around the cpanel + $display[] = '
    '; + $display[] = Indent::_(1) . '
    '; + $display[] = Indent::_(1) + . " 'cpanel')); ?>"; + $display[] = PHP_EOL . Indent::_(2) + . ""; + $display[] = Indent::_(2) . '
    '; + // change the name of the main tab + $mainAccordianName = 'Control Panel'; + $loadTabs = true; + } + else + { + $display[] = '
    '; + $display[] = Indent::_(1) . '
    '; + $display[] = Indent::_(2) . '
    '; + } + // set dashboard display + $display[] = $tab . '
    '; + $display[] = $tab . Indent::_(1) + . " 'main')); ?>"; + $display[] = $tab . Indent::_(2) + . ""; + $display[] = $tab . Indent::_(3) + . "loadTemplate('main');?>"; + $display[] = $tab . Indent::_(2) + . ""; + $display[] = $tab . Indent::_(1) + . ""; + $display[] = $tab . "
    "; + $display[] = $tab . '
    '; + $display[] = $tab . Indent::_(1) + . " 'vdm')); ?>"; + $display[] = $tab . Indent::_(2) + . "get('COMPANYNAME') + . "', 'vdm'); ?>"; + $display[] = $tab . Indent::_(3) + . "loadTemplate('vdm');?>"; + $display[] = $tab . Indent::_(2) + . ""; + $display[] = $tab . Indent::_(1) + . ""; + $display[] = $tab . "
    "; + + if ($loadTabs) + { + $display[] = Indent::_(2) . "
    "; + $display[] = Indent::_(2) + . ""; + // load the new tabs + foreach ($builder as $tabname => $accordians) + { + $alias = StringHelper::safe($tabname); + $display[] = PHP_EOL . Indent::_(2) + . ""; + $display[] = Indent::_(2) . '
    '; + $display[] = $tab . '
    '; + $display[] = $tab . Indent::_(1) + . " '" . $alias + . "_one')); ?>"; + $slidecounter = 1; + foreach ($accordians as $accordianname => $html) + { + $ac_alias = StringHelper::safe( + $accordianname + ); + $counterName = StringHelper::safe( + $slidecounter + ); + $tempName = $alias . '_' . $ac_alias; + $display[] = $tab . Indent::_(2) + . ""; + $display[] = $tab . Indent::_(3) + . "loadTemplate('" . $tempName + . "');?>"; + $display[] = $tab . Indent::_(2) + . ""; + $slidecounter++; + // build the template file + $target = array('custom_admin' => CFactory::_('Config')->component_code_name); + CFactory::_('Utilities.Structure')->build($target, 'template', $tempName); + // set the file data + $TARGET = StringHelper::safe( + CFactory::_('Config')->build_target, 'U' + ); + // SITE_TEMPLATE_BODY <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '_' . $tempName . '|CUSTOM_ADMIN_TEMPLATE_BODY', PHP_EOL . $html); + // SITE_TEMPLATE_CODE_BODY <<>> + CFactory::_('Compiler.Builder.Content.Multi')->set(CFactory::_('Config')->component_code_name . '_' . $tempName . '|CUSTOM_ADMIN_TEMPLATE_CODE_BODY', ''); + } + $display[] = $tab . Indent::_(1) + . ""; + $display[] = $tab . "
    "; + $display[] = Indent::_(2) . "
    "; + $display[] = Indent::_(2) + . ""; + } + + $display[] = PHP_EOL . Indent::_(1) + . ""; + } + else + { + $display[] = Indent::_(2) . "
    "; + } + $display[] = Indent::_(1) . "
    "; + $display[] = "
    "; + + // return the display + return PHP_EOL . implode(PHP_EOL, $display); + } + + public function addCustomDashboardIcons(&$view, &$counter) + { + $icon = ''; + if (CFactory::_('Component')->isArray('custom_admin_views')) + { + foreach (CFactory::_('Component')->get('custom_admin_views') as $nr => $menu) + { + if (!isset($this->customAdminAdded[$menu['settings']->code]) + && isset($menu['dashboard_list']) + && $menu['dashboard_list'] == 1 + && $menu['before'] == $view['adminview']) + { + $type = ComponentbuilderHelper::imageInfo( + $menu['settings']->icon + ); + if ($type) + { + $type = $type . "."; + // icon builder loader + $this->iconBuilder[$type . $menu['settings']->code] + = $menu['settings']->icon; + } + else + { + $type = 'png.'; + } + // build lang + $langName = $menu['settings']->name . '

    '; + $langKey = CFactory::_('Config')->lang_prefix . '_DASHBOARD_' + . $menu['settings']->CODE; + // add to lang + CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $langKey, $langName); + // set icon + if ($counter == 0) + { + $counter++; + $icon .= "'" . $type . $menu['settings']->code . "'"; + } + else + { + $counter++; + $icon .= ", '" . $type . $menu['settings']->code . "'"; + } + } + elseif (!isset($this->customAdminAdded[$menu['settings']->code]) + && isset($menu['dashboard_list']) + && $menu['dashboard_list'] == 1 + && empty($menu['before'])) + { + $type = ComponentbuilderHelper::imageInfo( + $menu['settings']->icon + ); + if ($type) + { + $type = $type . "."; + // icon builder loader + $this->iconBuilder[$type . $menu['settings']->code] + = $menu['settings']->icon; + } + else + { + $type = 'png.'; + } + // build lang + $langName = $menu['settings']->name . '

    '; + $langKey = CFactory::_('Config')->lang_prefix . '_DASHBOARD_' + . $menu['settings']->CODE; + // add to lang + CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $langKey, $langName); + // set icon + $this->lastCustomDashboardIcon[$nr] = ", '" . $type + . $menu['settings']->code . "'"; + } + } + } + // see if we should have custom menus + if (CFactory::_('Component')->isArray('custommenus')) + { + foreach (CFactory::_('Component')->get('custommenus') as $nr => $menu) + { + $nr = $nr + 100; + $nameList = StringHelper::safe( + $menu['name_code'] + ); + $nameUpper = StringHelper::safe( + $menu['name_code'], 'U' + ); + if (isset($menu['dashboard_list']) + && $menu['dashboard_list'] == 1 + && $view['adminview'] == $menu['before']) + { + $type = ComponentbuilderHelper::imageInfo( + 'images/' . $menu['icon'] + ); + if ($type) + { + // icon builder loader + $this->iconBuilder[$type . "." . $nameList] = 'images/' + . $menu['icon']; + } + else + { + $type = 'png'; + } + // build lang + $langName = $menu['name'] . '

    '; + $langKey = CFactory::_('Config')->lang_prefix . '_DASHBOARD_' . $nameUpper; + // add to lang + CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $langKey, $langName); + + // if this is a link build the icon values with pipe + if (isset($menu['link']) + && StringHelper::check($menu['link'])) + { + // set icon + if ($counter == 0) + { + $counter++; + $icon .= "'" . $type . "||" . $nameList . "||" + . $menu['link'] . "'"; + } + else + { + $counter++; + $icon .= ", '" . $type . "||" . $nameList . "||" + . $menu['link'] . "'"; + } + } + else + { + // set icon + if ($counter == 0) + { + $counter++; + $icon .= "'" . $type . "." . $nameList . "'"; + } + else + { + $counter++; + $icon .= ", '" . $type . "." . $nameList . "'"; + } + } + } + elseif (isset($menu['dashboard_list']) + && $menu['dashboard_list'] == 1 + && empty($menu['before'])) + { + $type = ComponentbuilderHelper::imageInfo( + 'images/' . $menu['icon'] + ); + if ($type) + { + // icon builder loader + $this->iconBuilder[$type . "." . $nameList] = 'images/' + . $menu['icon']; + } + else + { + $type = 'png'; + } + // build lang + $langName = $menu['name'] . '

    '; + $langKey = CFactory::_('Config')->lang_prefix . '_DASHBOARD_' . $nameUpper; + // add to lang + CFactory::_('Language')->set(CFactory::_('Config')->lang_target, $langKey, $langName); + + // if this is a link build the icon values with pipe + if (isset($menu['link']) + && StringHelper::check($menu['link'])) + { + // set icon + $this->lastCustomDashboardIcon[$nr] = ", '" . $type + . "||" . $nameList . "||" . $menu['link'] . "'"; + } + else + { + // set icon + $this->lastCustomDashboardIcon[$nr] = ", '" . $type + . "." . $nameList . "'"; + } + } + } + } + + return $icon; + } + + public function setSubMenus() + { + if (CFactory::_('Component')->isArray('admin_views')) + { + $menus = ''; + // main lang prefix + $lang = CFactory::_('Config')->lang_prefix . '_SUBMENU'; + // set the code name + $codeName = CFactory::_('Config')->component_code_name; + // set default dashboard + if (!CFactory::_('Registry')->get('build.dashboard')) + { + $menus .= "\JHtmlSidebar::addEntry(Text:" . ":_('" . $lang + . "_DASHBOARD'), 'index.php?option=com_" . $codeName + . "&view=" . $codeName . "', \$submenu === '" . $codeName + . "');"; + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, $lang . '_DASHBOARD', 'Dashboard' + ); + } + $catArray = []; + // loop over all the admin views + foreach (CFactory::_('Component')->get('admin_views') as $view) + { + // set custom menu + $menus .= $this->addCustomSubMenu( + $view, $codeName, $lang + ); + $nameSingleCode = $view['settings']->name_single_code; + $nameListCode = $view['settings']->name_list_code; + $nameUpper = StringHelper::safe( + $view['settings']->name_list, 'U' + ); + // check if view is set to be in the sub-menu + if (isset($view['submenu']) && $view['submenu'] == 1) + { + // setup access defaults + $tab = ""; + $has_permissions = false; + // check if the item has permissions. + if (CFactory::_('Compiler.Creator.Permission')->globalExist($nameSingleCode, 'core.access')) + { + $menus .= PHP_EOL . Indent::_(2) + . "if (\$user->authorise('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingleCode, 'core.access') + . "', 'com_" . $codeName + . "') && \$user->authorise('" . $nameSingleCode + . ".submenu', 'com_" . $codeName . "'))"; + $menus .= PHP_EOL . Indent::_(2) . "{"; + // add tab to lines to follow + $tab = Indent::_(1); + $has_permissions = true; + } + $menus .= PHP_EOL . Indent::_(2) . $tab + . "\JHtmlSidebar::addEntry(Text:" . ":_('" . $lang . "_" + . $nameUpper . "'), 'index.php?option=com_" . $codeName + . "&view=" . $nameListCode . "', \$submenu === '" + . $nameListCode . "');"; + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, $lang . "_" . $nameUpper, + $view['settings']->name_list + ); + // check if category has another name + $otherViews = CFactory::_('Compiler.Builder.Category.Other.Name')-> + get($nameListCode . '.views', $nameListCode); + // first check if category sub-menu should be added + // then check if view has category, if true add sub-menu for it + if ($view['settings']->add_category_submenu == 1 + && CFactory::_('Compiler.Builder.Category')->exists("{$nameListCode}.extension") + && !in_array($otherViews, $catArray)) + { + // get the extension array + $_extension_array = (array) explode( + '.', + (string) CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension") + ); + // set the menu selection + if (isset($_extension_array[1])) + { + $_menu = "categories." . trim($_extension_array[1]); + } + else + { + $_menu = "categories"; + } + // now load the menus + $menus .= PHP_EOL . Indent::_(2) . $tab + . "\JHtmlSidebar::addEntry(Text:" . ":_('" + . CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.name", 'error') + . "'), 'index.php?option=com_categories&view=categories&extension=" + . CFactory::_('Compiler.Builder.Category')->get("{$nameListCode}.extension") + . "', \$submenu === '" . $_menu . "');"; + // make sure we add a category only once + $catArray[] = $otherViews; + } + // check if the item has permissions. + if ($has_permissions) + { + $menus .= PHP_EOL . Indent::_(2) . "}"; + } + } + // set the Joomla custom fields options + if (isset($view['joomla_fields']) + && $view['joomla_fields'] == 1) + { + $menus .= PHP_EOL . Indent::_(2) + . "if (ComponentHelper::isEnabled('com_fields'))"; + $menus .= PHP_EOL . Indent::_(2) . "{"; + $menus .= PHP_EOL . Indent::_(3) + . "\JHtmlSidebar::addEntry(Text:" . ":_('" . $lang . "_" + . $nameUpper + . "_FIELDS'), 'index.php?option=com_fields&context=com_" + . $codeName . "." . $nameSingleCode + . "', \$submenu === 'fields.fields');"; + $menus .= PHP_EOL . Indent::_(3) + . "\JHtmlSidebar::addEntry(Text:" . ":_('" . $lang . "_" + . $nameUpper + . "_FIELDS_GROUPS'), 'index.php?option=com_fields&view=groups&context=com_" + . $codeName . "." . $nameSingleCode + . "', \$submenu === 'fields.groups');"; + $menus .= PHP_EOL . Indent::_(2) . "}"; + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, $lang . "_" . $nameUpper . "_FIELDS", + $view['settings']->name_list . ' Fields' + ); + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, + $lang . "_" . $nameUpper . "_FIELDS_GROUPS", + $view['settings']->name_list . ' Field Groups' + ); + // build uninstall script for fields + $this->uninstallScriptBuilder[$nameSingleCode] = 'com_' + . $codeName . '.' . $nameSingleCode; + $this->uninstallScriptFields[$nameSingleCode] + = $nameSingleCode; + } + } + if (isset($this->lastCustomSubMenu) + && ArrayHelper::check($this->lastCustomSubMenu)) + { + foreach ($this->lastCustomSubMenu as $menu) + { + $menus .= $menu; + } + unset($this->lastCustomSubMenu); + } + + return $menus; + } + + return false; + } + + public function addCustomSubMenu(&$view, &$codeName, &$lang) + { + // see if we should have custom menus + $custom = ''; + if (CFactory::_('Component')->isArray('custom_admin_views')) + { + foreach (CFactory::_('Component')->get('custom_admin_views') as $nr => $menu) + { + if (!isset($this->customAdminAdded[$menu['settings']->code])) + { + if (($_custom = $this->setCustomAdminSubMenu( + $view, $codeName, $lang, $nr, $menu, 'customView' + )) !== false) + { + $custom .= $_custom; + } + } + } + } + if (CFactory::_('Component')->isArray('custommenus')) + { + foreach (CFactory::_('Component')->get('custommenus') as $nr => $menu) + { + if (($_custom = $this->setCustomAdminSubMenu( + $view, $codeName, $lang, $nr, $menu, 'customMenu' + )) !== false) + { + $custom .= $_custom; + } + } + } + + return $custom; + } + + public function setCustomAdminSubMenu(&$view, &$codeName, &$lang, &$nr, &$menu, $type) + { + if ($type === 'customMenu') + { + $name = $menu['name']; + $nameSingle = StringHelper::safe($menu['name']); + $nameList = StringHelper::safe($menu['name']); + $nameUpper = StringHelper::safe( + $menu['name'], 'U' + ); + } + elseif ($type === 'customView') + { + $name = $menu['settings']->name; + $nameSingle = $menu['settings']->code; + $nameList = $menu['settings']->code; + $nameUpper = $menu['settings']->CODE; + } + if (isset($menu['submenu']) && $menu['submenu'] == 1 + && $view['adminview'] == $menu['before']) + { + // setup access defaults + $tab = ""; + $custom = ''; + // check if the item has permissions. + if (CFactory::_('Compiler.Creator.Permission')->globalExist($nameSingle, 'core.access')) + { + $custom .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Access control (" . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingle, 'core.access') . " && " + . $nameSingle . ".submenu)."; + $custom .= PHP_EOL . Indent::_(2) . "if (\$user->authorise('" + . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingle, 'core.access') . "', 'com_" . $codeName + . "') && \$user->authorise('" . $nameSingle + . ".submenu', 'com_" . $codeName . "'))"; + $custom .= PHP_EOL . Indent::_(2) . "{"; + // add tab to lines to follow + $tab = Indent::_(1); + } + else + { + $custom .= PHP_EOL . Indent::_(2) . "//" . Line::_( + __LINE__,__CLASS__ + ) . " Access control (" . $nameSingle . ".submenu)."; + $custom .= PHP_EOL . Indent::_(2) . "if (\$user->authorise('" + . $nameSingle . ".submenu', 'com_" . $codeName . "'))"; + $custom .= PHP_EOL . Indent::_(2) . "{"; + // add tab to lines to follow + $tab = Indent::_(1); + } + if (isset($menu['link']) + && StringHelper::check( + $menu['link'] + )) + { + + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, $lang . '_' . $nameUpper, $name + ); + // add custom menu + $custom .= PHP_EOL . Indent::_(2) . $tab + . "\JHtmlSidebar::addEntry(Text:" . ":_('" . $lang . "_" + . $nameUpper . "'), '" . $menu['link'] + . "', \$submenu === '" . $nameList . "');"; + } + else + { + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, $lang . '_' . $nameUpper, $name + ); + // add custom menu + $custom .= PHP_EOL . Indent::_(2) . $tab + . "\JHtmlSidebar::addEntry(Text:" . ":_('" . $lang . "_" + . $nameUpper . "'), 'index.php?option=com_" . $codeName + . "&view=" . $nameList . "', \$submenu === '" . $nameList + . "');"; + } + // check if the item has permissions. + $custom .= PHP_EOL . Indent::_(2) . "}"; + + return $custom; + } + elseif (isset($menu['submenu']) && $menu['submenu'] == 1 + && empty($menu['before'])) + { + // setup access defaults + $tab = ""; + $nameSingle = StringHelper::safe($name); + $this->lastCustomSubMenu[$nr] = ''; + // check if the item has permissions. + if (CFactory::_('Compiler.Creator.Permission')->globalExist($nameSingle, 'core.access')) + { + $this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2) + . "if (\$user->authorise('" . CFactory::_('Compiler.Creator.Permission')->getGlobal($nameSingle, 'core.access') + . "', 'com_" . $codeName . "') && \$user->authorise('" + . $nameSingle . ".submenu', 'com_" . $codeName . "'))"; + $this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2) . "{"; + // add tab to lines to follow + $tab = Indent::_(1); + } + else + { + $this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2) + . "if (\$user->authorise('" . $nameSingle + . ".submenu', 'com_" . $codeName . "'))"; + $this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2) . "{"; + // add tab to lines to follow + $tab = Indent::_(1); + } + if (isset($menu['link']) + && StringHelper::check( + $menu['link'] + )) + { + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, $lang . '_' . $nameUpper, $name + ); + // add custom menu + $this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2) . $tab + . "\JHtmlSidebar::addEntry(Text:" . ":_('" . $lang . "_" + . $nameUpper . "'), '" . $menu['link'] + . "', \$submenu === '" . $nameList . "');"; + } + else + { + CFactory::_('Language')->set( + CFactory::_('Config')->lang_target, $lang . '_' . $nameUpper, $name + ); + // add custom menu + $this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2) . $tab + . "\JHtmlSidebar::addEntry(Text:" . ":_('" . $lang . "_" + . $nameUpper . "'), 'index.php?option=com_" . $codeName + . "&view=" . $nameList . "', \$submenu === '" . $nameList + . "');"; + } + // check if the item has permissions. + $this->lastCustomSubMenu[$nr] .= PHP_EOL . Indent::_(2) . "}"; + } + + return false; + } + + public function setMainMenus() + { + if (CFactory::_('Component')->isArray('admin_views')) + { + $menus = ''; + // main lang prefix + $lang = CFactory::_('Config')->lang_prefix . '_MENU'; + // set the code name + $codeName = CFactory::_('Config')->component_code_name; + // default prefix is none + $prefix = ''; + // check if local is set + if (CFactory::_('Component')->isNumeric('add_menu_prefix')) + { + // set main menu prefix switch + $addPrefix = CFactory::_('Component')->get('add_menu_prefix'); + if ($addPrefix == 1 && CFactory::_('Component')->isString('menu_prefix')) + { + $prefix = trim((string) CFactory::_('Component')->get('menu_prefix')) . ' '; + } + } + else + { + // set main menu prefix switch + $addPrefix = $this->params->get('add_menu_prefix', 1); + if ($addPrefix == 1) + { + $prefix = trim((string) $this->params->get('menu_prefix', '»')) + . ' '; + } + } + // add the prefix + if ($addPrefix == 1) + { + CFactory::_('Language')->set( + 'adminsys', $lang, $prefix . CFactory::_('Component')->get('name') + ); + } + else + { + CFactory::_('Language')->set( + 'adminsys', $lang, CFactory::_('Component')->get('name') + ); + } + + if (CFactory::_('Config')->get('joomla_version', 3) != 3 + && CFactory::_('Registry')->get('build.dashboard', null) === null) + { + $menus .= PHP_EOL . Indent::_(3) . '' . $lang + . '_DASHBOARD'; + + CFactory::_('Language')->set( + 'adminsys', $lang . '_DASHBOARD', + 'Dashboard' + ); + } + + // loop over the admin views + foreach (CFactory::_('Component')->get('admin_views') as $view) + { + // set custom menu + $menus .= $this->addCustomMainMenu($view, $codeName, $lang); + if (isset($view['mainmenu']) && $view['mainmenu'] == 1) + { + $nameList = StringHelper::safe( + $view['settings']->name_list + ); + $nameUpper = StringHelper::safe( + $view['settings']->name_list, 'U' + ); + $menus .= PHP_EOL . Indent::_(3) . '' . $lang + . '_' . $nameUpper . ''; + CFactory::_('Language')->set( + 'adminsys', $lang . '_' . $nameUpper, + $view['settings']->name_list + ); + } + } + if (isset($this->lastCustomMainMenu) + && ArrayHelper::check( + $this->lastCustomMainMenu + )) + { + foreach ($this->lastCustomMainMenu as $menu) + { + $menus .= $menu; + } + unset($this->lastCustomMainMenu); + } + + return $menus; + } + + return false; + } + + public function addCustomMainMenu(&$view, &$codeName, &$lang) + { + $customMenu = ''; + // see if we should have custom admin views + if (CFactory::_('Component')->isArray('custom_admin_views')) + { + foreach (CFactory::_('Component')->get('custom_admin_views') as $nr => $menu) + { + if (!isset($this->customAdminAdded[$menu['settings']->code])) + { + if (isset($menu['mainmenu']) && $menu['mainmenu'] == 1 + && $view['adminview'] == $menu['before']) + { + CFactory::_('Language')->set( + 'adminsys', $lang . '_' . $menu['settings']->CODE, + $menu['settings']->name + ); + // add custom menu + $customMenu .= PHP_EOL . Indent::_(3) + . '' . $lang . '_' + . $menu['settings']->CODE . ''; + } + elseif (isset($menu['mainmenu']) && $menu['mainmenu'] == 1 + && empty($menu['before'])) + { + CFactory::_('Language')->set( + 'adminsys', $lang . '_' . $menu['settings']->CODE, + $menu['settings']->name + ); + // add custom menu + $this->lastCustomMainMenu[$nr] = PHP_EOL . Indent::_(3) + . '' . $lang . '_' + . $menu['settings']->CODE . ''; + } + } + } + } + // see if we should have custom menus + if (CFactory::_('Component')->isArray('custommenus')) + { + foreach (CFactory::_('Component')->get('custommenus') as $nr => $menu) + { + $nr = $nr + 100; + if (isset($menu['mainmenu']) && $menu['mainmenu'] == 1 + && $view['adminview'] == $menu['before']) + { + if (isset($menu['link']) + && StringHelper::check($menu['link'])) + { + $nameList = StringHelper::safe( + $menu['name'] + ); + $nameUpper = StringHelper::safe( + $menu['name'], 'U' + ); + CFactory::_('Language')->set( + 'adminsys', $lang . '_' . $nameUpper, $menu['name'] + ); + // sanitize url + if (strpos((string) $menu['link'], 'http') === false) + { + $menu['link'] = str_replace( + '/administrator/index.php?', '', (string) $menu['link'] + ); + $menu['link'] = str_replace( + 'administrator/index.php?', '', $menu['link'] + ); + // check if the index is still there + if (strpos($menu['link'], 'index.php?') !== false) + { + $menu['link'] = str_replace( + '/index.php?', '', $menu['link'] + ); + $menu['link'] = str_replace( + 'index.php?', '', $menu['link'] + ); + } + } + // urlencode + $menu['link'] = htmlspecialchars( + (string) $menu['link'], ENT_XML1, 'UTF-8' + ); + // add custom menu + $customMenu .= PHP_EOL . Indent::_(3) . '' . $lang . '_' . $nameUpper + . ''; + } + else + { + $nameList = StringHelper::safe( + $menu['name_code'] + ); + $nameUpper = StringHelper::safe( + $menu['name_code'], 'U' + ); + CFactory::_('Language')->set( + 'adminsys', $lang . '_' . $nameUpper, $menu['name'] + ); + // add custom menu + $customMenu .= PHP_EOL . Indent::_(3) + . '' . $lang . '_' . $nameUpper + . ''; + } + } + elseif (isset($menu['mainmenu']) && $menu['mainmenu'] == 1 + && empty($menu['before'])) + { + if (isset($menu['link']) + && StringHelper::check($menu['link'])) + { + $nameList = StringHelper::safe( + $menu['name'] + ); + $nameUpper = StringHelper::safe( + $menu['name'], 'U' + ); + CFactory::_('Language')->set( + 'adminsys', $lang . '_' . $nameUpper, $menu['name'] + ); + // sanitize url + if (strpos((string) $menu['link'], 'http') === false) + { + $menu['link'] = str_replace( + '/administrator/index.php?', '', (string) $menu['link'] + ); + $menu['link'] = str_replace( + 'administrator/index.php?', '', $menu['link'] + ); + // check if the index is still there + if (strpos($menu['link'], 'index.php?') !== false) + { + $menu['link'] = str_replace( + '/index.php?', '', $menu['link'] + ); + $menu['link'] = str_replace( + 'index.php?', '', $menu['link'] + ); + } + } + // urlencode + $menu['link'] = htmlspecialchars( + (string) $menu['link'], ENT_XML1, 'UTF-8' + ); + // add custom menu + $this->lastCustomMainMenu[$nr] = PHP_EOL . Indent::_(3) + . '' . $lang + . '_' . $nameUpper . ''; + } + else + { + $nameList = StringHelper::safe( + $menu['name_code'] + ); + $nameUpper = StringHelper::safe( + $menu['name_code'], 'U' + ); + CFactory::_('Language')->set( + 'adminsys', $lang . '_' . $nameUpper, $menu['name'] + ); + // add custom menu + $this->lastCustomMainMenu[$nr] = PHP_EOL . Indent::_(3) + . '' . $lang . '_' . $nameUpper + . ''; + } + } + } + } + + return $customMenu; + } + + /** + * Set Config Fieldsets + * + * @param int $timer + * + * @since 1.0 + * @deprecated 3.3 CFactory::_('Compiler.Creator.Config.Fieldsets')->set($timer); + */ + public function setConfigFieldsets(int $timer = 0): void + { + CFactory::_('Compiler.Creator.Config.Fieldsets')->set($timer); + } + + /** + * Set Site Control Config Fieldsets + * + * @param string $lang + * + * @since 1.0 + * @deprecated 3.3 CFactory::_('Compiler.Creator.Config.Fieldsets.Site.Control')->set($lang); + */ + public function setSiteControlConfigFieldsets(string $lang): void + { + CFactory::_('Compiler.Creator.Config.Fieldsets.Site.Control')->set($lang); + } + + /** + * Set the request values + * + * @param string $view + * @param string $field + * @param string $search + * @param string $target + * + * @since 1.0 + * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Request')->set($view, $field, $search, $target); + */ + protected function setRequestValues(string $view, string $field, string $search, string $target): void + { + CFactory::_('Compiler.Creator.Request')->set($view, $field, $search, $target); + } + + /** + * Set Custom Control Config Fieldsets + * + * @param string $lang + * + * @since 1.0 + * @deprecated 3.3 CFactory::_('Compiler.Creator.Config.Fieldsets.Customfield')->set($lang); + */ + public function setCustomControlConfigFieldsets(string $lang): void + { + CFactory::_('Compiler.Creator.Config.Fieldsets.Customfield')->set($lang); + } + + /** + * Set Group Control Config Fieldsets + * + * @param string $lang + * + * @since 1.0 + * @deprecated 3.3 CFactory::_('Compiler.Creator.Config.Fieldsets.Group.Control')->set($lang); + */ + public function setGroupControlConfigFieldsets(string $lang): void + { + CFactory::_('Compiler.Creator.Config.Fieldsets.Group.Control')->set($lang); + } + + /** + * Set Global Config Fieldsets + * + * @param string $lang + * @param string $authorName + * @param string $authorEmail + * + * @since 1.0 + * @deprecated 3.3 CFactory::_('Compiler.Creator.Config.Fieldsets.Global')->set($lang, $authorName, $authorEmail); + */ + public function setGlobalConfigFieldsets(string $lang, string $authorName, string $authorEmail): void + { + CFactory::_('Compiler.Creator.Config.Fieldsets.Global')->set($lang, $authorName, $authorEmail); + } + + /** + * Set Uikit Config Fieldsets + * + * @param string $lang + * + * @since 1.0 + * @deprecated 3.3 CFactory::_('Compiler.Creator.Config.Fieldsets.Uikit')->set($lang); + */ + public function setUikitConfigFieldsets($lang) + { + CFactory::_('Compiler.Creator.Config.Fieldsets.Uikit')->set($lang); + } + + /** + * Set Email Helper Config Fieldsets + * + * @param string $lang + * + * @since 1.0 + * @deprecated 3.3 CFactory::_('Compiler.Creator.Config.Fieldsets.Email.Helper')->set($lang); + */ + public function setEmailHelperConfigFieldsets($lang) + { + CFactory::_('Compiler.Creator.Config.Fieldsets.Email.Helper')->set($lang); + } + + /** + * Set Googlechart Config Fieldsets + * + * @param string $lang + * + * @since 1.0 + * @deprecated 3.3 CFactory::_('Compiler.Creator.Config.Fieldsets.Googlechart')->set($lang); + */ + public function setGooglechartConfigFieldsets($lang) + { + CFactory::_('Compiler.Creator.Config.Fieldsets.Googlechart')->set($lang); + } + + /** + * Set Encryption Config Fieldsets + * + * @param string $lang + * + * @since 1.0 + * @deprecated 3.3 CFactory::_('Compiler.Creator.Config.Fieldsets.Encryption')->set($lang); + */ + public function setEncryptionConfigFieldsets($lang) + { + CFactory::_('Compiler.Creator.Config.Fieldsets.Encryption')->set($lang); + } + + /** + * Set Access Sections Category + * + * @param string $nameSingleCode + * @param string $nameListCode + * + * @return string + * @since 1.0 + * @deprecated 3.3 CFactory::_('Compiler.Creator.Access.Sections.Category')->get($nameSingleCode, $nameListCode); + */ + public function setAccessSectionsCategory(string $nameSingleCode, string $nameListCode): string + { + return CFactory::_('Compiler.Creator.Access.Sections.Category')->get($nameSingleCode, $nameListCode); + } + + /** + * Set Access Sections Joomla Fields + * + * @return string + * @since 1.0 + * @deprecated 3.3 CFactory::_('Compiler.Creator.Access.Sections.Joomla.Fields')->get(); + */ + public function setAccessSectionsJoomlaFields(): string + { + return CFactory::_('Compiler.Creator.Access.Sections.Joomla.Fields')->get(); + } + + /** + * Set Access Sections + * + * @return string + * @since 1.0 + * @deprecated 3.3 CFactory::_('Compiler.Creator.Access.Sections')->get(); + */ + public function setAccessSections() + { + return CFactory::_('Compiler.Creator.Access.Sections')->get(); + } + + /** + * Add Custom Button Permissions + * + * @param object $settings The view settings + * @param string $nameView The view name + * @param string $code The view code name. + * + * @since 1.0 + * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Custom.Button.Permissions')->add($settings, $nameView, $code); + */ + protected function addCustomButtonPermissions($settings, $nameView, $code) + { + CFactory::_('Compiler.Creator.Custom.Button.Permissions')->add($settings, $nameView, $code); + } + + /** + * Set the permissions + * + * @param array $view View details + * @param string $nameView View Single Code Name + * @param string $nameViews View List Code Name + * @param array $menuControllers Menu Controllers + * @param string $type Type of permissions area + * + * @return void + * @deprecated 3.3 Use CFactory::_('Compiler.Creator.Permission')->set($view, $nameView, $nameViews, $menuControllers, $type); + */ + public function buildPermissions(&$view, $nameView, $nameViews, $menuControllers, $type = 'admin') + { + CFactory::_('Compiler.Creator.Permission')->set($view, $nameView, $nameViews, $menuControllers, $type); + } + + public function getInbetweenStrings($str, $start = '#' . '#' . '#', $end = '#' . '#' . '#') + { + $matches = []; + $regex = "/$start([a-zA-Z0-9_]*)$end/"; + preg_match_all($regex, (string) $str, $matches); + + return $matches[1]; + } + + public function getModCode(&$module) + { + // get component helper string + $Helper = CFactory::_('Compiler.Builder.Content.One')->get('Component') . 'Helper'; + $component = CFactory::_('Compiler.Builder.Content.One')->get('component'); + $_helper = ''; + // get libraries code + $libraries = array(Placefix::_('MOD_LIBRARIES') => $this->getModLibCode($module)); + $code = CFactory::_('Placeholder')->update($module->mod_code, $libraries); + // check if component helper class should be added + if (strpos((string) $code, $Helper . '::') !== false + && strpos( + (string) $code, + "/components/com_" . $component . "/helpers/" . $component + . ".php" + ) === false) + { + $_helper = '//' . Line::_(__Line__, __Class__) + . ' Include the component helper functions only once'; + $_helper .= PHP_EOL . "JLoader::register('" . $Helper + . "', JPATH_ADMINISTRATOR . '/components/com_" . $component + . "/helpers/" . $component . ".php');"; + } + + return CFactory::_('Placeholder')->update($_helper . PHP_EOL . $code . PHP_EOL, CFactory::_('Compiler.Builder.Content.One')->allActive()); + } + + public function getModDefault(&$module, &$key) + { + // first add the header + $default = PHP_EOL . $module->default_header . PHP_EOL . '?>'; + // add any css from the fields + $default .= CFactory::_('Customcode.Dispenser')->get( + 'css_views', $key, PHP_EOL . '' . PHP_EOL + ); + // now add the body + $default .= PHP_EOL . $module->default . PHP_EOL; + // add any JavaScript from the fields + $default .= CFactory::_('Customcode.Dispenser')->get( + 'views_footer', $key, + PHP_EOL . '' . PHP_EOL + ); + + // return the default content for the model default area + return CFactory::_('Placeholder')->update($default, CFactory::_('Compiler.Builder.Content.One')->allActive()); + } + + public function setModTemplates(&$module) + { + if (($data_ = CFactory::_('Compiler.Builder.Template.Data')-> + get(CFactory::_('Config')->build_target . '.' . $module->code_name)) !== null) + { + foreach ($data_ as $template => $data) + { + $header = $data['php_view'] ?? ''; + $body = $data['html'] ?? ''; + $default = PHP_EOL . $header . PHP_EOL . '?>'; + $default .= PHP_EOL . $body; + $TARGET = StringHelper::safe("MODDEFAULT_{$template}", 'U'); + CFactory::_('Compiler.Builder.Content.Multi')->set($module->key . '|' . $TARGET, + CFactory::_('Placeholder')->update( + $default, CFactory::_('Compiler.Builder.Content.One')->allActive() + ) + ); + } + } + } + + public function getModHelperCode(&$module) + { + return + CFactory::_('Placeholder')->update($module->class_helper_header . PHP_EOL . + $module->class_helper_type . $module->class_helper_name . PHP_EOL + . '{' . PHP_EOL . + $module->class_helper_code . PHP_EOL . + "}" . PHP_EOL, CFactory::_('Compiler.Builder.Content.One')->allActive()); + } + + public function getModLibCode(&$module) + { + $setter = ''; + if (($data_ = CFactory::_('Compiler.Builder.Library.Manager')-> + get($module->key . '.' . $module->code_name)) !== null) + { + $setter .= '//' . Line::_(__Line__, __Class__) + . 'get the document object'; + $setter .= PHP_EOL . '$document = Factory::getDocument();'; + foreach ($data_ as $id => $true) + { + // get the library + $library = CFactory::_('Registry')->get("builder.libraries.$id", null); + if (is_object($library) + && isset($library->document) + && StringHelper::check( + $library->document + )) + { + $setter .= PHP_EOL . $library->document; + } + elseif (is_object($library) + && isset($library->how)) + { + $setter .= $this->setLibraryDocument($id); + } + } + } + // check if we have string + if (StringHelper::check($setter)) + { + return CFactory::_('Placeholder')->update( CFactory::_('Placeholder')->update_( + str_replace( + '$this->document->', '$document->', + implode( + PHP_EOL, + array_map( + 'trim', + (array) explode(PHP_EOL, $setter) + ) + ) + ) + ), CFactory::_('Compiler.Builder.Content.One')->allActive()); + } + + return ''; + } + + public function getModuleMainXML(&$module) + { + // set the custom table key + $dbkey = 'yyy'; + // build the xml + $xml = ''; + // search if we must add the component path + $add_component_path = false; + // build the config fields + $config_fields = []; + if (isset($module->config_fields) + && ArrayHelper::check( + $module->config_fields + )) + { + $add_scripts_field = true; + foreach ($module->config_fields as $field_name => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + // get the field set + $xmlFields = $this->getExtensionFieldsetXML( + $module, $fields, $dbkey + ); + // check if the custom script field must be set + if ($add_scripts_field && $module->add_scripts_field) + { + // get the custom script field + $xmlFields .= PHP_EOL . Indent::_(2) + . ""; + // don't add it again + $add_scripts_field = false; + } + // make sure the xml is set and a string + if (isset($xmlFields) + && StringHelper::check($xmlFields)) + { + $config_fields[$field_name . $fieldset] = $xmlFields; + } + $dbkey++; + // check if the fieldset path requiers component paths + if (!$add_component_path + && isset( + $module->fieldsets_paths[$field_name . $fieldset] + ) + && $module->fieldsets_paths[$field_name . $fieldset] + == 1) + { + $add_component_path = true; + } + } + } + } + // switch to add the language xml + $addLang = []; + // now build the language files + if (CFactory::_('Language')->exist($module->key)) + { + // get model lang content + $langContent = CFactory::_('Language')->getTarget($module->key); + // Trigger Event: jcb_ce_onBeforeBuildModuleLang + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeBuildModuleLang', [&$module, &$langContent] + ); + // get other languages + $values = array_unique($langContent); + // get the other lang strings if there is any + $this->multiLangString = $this->getMultiLangStrings($values); + // start the modules language bucket (must rest every time) + $this->languages['modules'] = []; + $this->languages['modules'][CFactory::_('Config')->get('lang_tag', 'en-GB')] = []; + $this->languages['modules'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['all'] + = $langContent; + CFactory::_('Language')->setTarget($module->key, null); + // update insert the current lang in to DB + $this->setLangPlaceholders($values, $module->id, 'modules'); + // remove old unused language strings + $this->purgeLanuageStrings($values, $module->id, 'modules'); + $total = count($values); + unset($values); + + // Trigger Event: jcb_ce_onBeforeBuildModuleLangFiles + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeBuildModuleLangFiles', [&$module, &$this->languages['modules']] + ); + + // now we insert the values into the files + if (ArrayHelper::check($this->languages['modules'])) + { + foreach ($this->languages['modules'] as $tag => $areas) + { + // trim the tag + $tag = trim($tag); + foreach ($areas as $area => $languageStrings) + { + $file_name = $tag . '.' . $module->file_name . '.ini'; + // check if language should be added + if ($this->shouldLanguageBeAdded( + $tag, $languageStrings, $total, + $file_name + )) + { + $lang = array_map( + fn($langstring, $placeholder) => $placeholder . '="' . $langstring . '"', + array_values($languageStrings), + array_keys($languageStrings) + ); + // set path + $path = $module->folder_path . '/language/' . $tag . '/'; + // create path if not exist + if (!Folder::exists($path)) + { + Folder::create($path); + // count the folder created + CFactory::_('Utilities.Counter')->folder++; + } + // add to language files (for now we add all to both TODO) + CFactory::_('Utilities.File')->write( + $path . $file_name, + implode(PHP_EOL, $lang) + ); + CFactory::_('Utilities.File')->write( + $path . $tag . '.' . $module->file_name + . '.sys.ini', + implode(PHP_EOL, $lang) + ); + // set the line counter + CFactory::_('Utilities.Counter')->line += count( + (array) $lang + ); + unset($lang); + // trigger to add language + $addLang[$tag] = $tag; + } + } + } + } + } + // get all files and folders in module folder + $files = Folder::files($module->folder_path); + $folders = Folder::folders($module->folder_path); + // the files/folders to ignore + $ignore = array('sql', 'language', 'script.php', + $module->file_name . '.xml', + $module->file_name . '.php'); + // should the scriptfile be added + if ($module->add_install_script) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) + . 'script.php'; + } + // should the sql install be added + if ($module->add_sql) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(3) + . 'sql/mysql/install.sql'; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + // should the sql uninstall be added + if ($module->add_sql_uninstall) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(3) + . 'sql/mysql/uninstall.sql'; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + // should the language xml be added + if (ArrayHelper::check($addLang)) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) + . ''; + // load all the language files to xml + foreach ($addLang as $addTag) + { + $xml .= PHP_EOL . Indent::_(2) . '' . $addTag . '/' . $addTag . '.' + . $module->file_name . '.ini'; + $xml .= PHP_EOL . Indent::_(2) . '' . $addTag . '/' . $addTag . '.' + . $module->file_name . '.sys.ini'; + } + $xml .= PHP_EOL . Indent::_(1) . ''; + } + // add the module files + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . '' . $module->file_name + . '.php'; + // add other files found + if (ArrayHelper::check($files)) + { + foreach ($files as $file) + { + // only add what is not ignored + if (!in_array($file, $ignore)) + { + $xml .= PHP_EOL . Indent::_(2) . '' . $file + . ''; + } + } + } + // add language folder + if (ArrayHelper::check($addLang)) + { + $xml .= PHP_EOL . Indent::_(2) . 'language'; + } + // add sql folder + if ($module->add_sql || $module->add_sql_uninstall) + { + $xml .= PHP_EOL . Indent::_(2) . 'sql'; + } + // add other files found + if (ArrayHelper::check($folders)) + { + foreach ($folders as $folder) + { + // only add what is not ignored + if (!in_array($folder, $ignore)) + { + $xml .= PHP_EOL . Indent::_(2) . '' . $folder + . ''; + } + } + } + $xml .= PHP_EOL . Indent::_(1) . ''; + // now add the Config Params if needed + if (ArrayHelper::check($config_fields)) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + // only add if part of the component field types path is required + if ($add_component_path) + { + // add path to module rules and custom fields + $xml .= PHP_EOL . Indent::_(1) . 'get('joomla_version', 3) == 3) + { + $xml .= PHP_EOL . Indent::_(2) + . 'addrulepath="/administrator/components/com_' + . CFactory::_('Config')->component_code_name . '/models/rules"'; + $xml .= PHP_EOL . Indent::_(2) + . 'addfieldpath="/administrator/components/com_' + . CFactory::_('Config')->component_code_name . '/models/fields"'; + } + else + { + $xml .= PHP_EOL . Indent::_(3) + . 'addruleprefix="' . CFactory::_('Config')->namespace_prefix + . '\Component\\' . CFactory::_('Compiler.Builder.Content.One')->get('ComponentNameSpace') + . '\Administrator\Rule"'; + $xml .= PHP_EOL . Indent::_(3) + . 'addfieldprefix="' . CFactory::_('Config')->namespace_prefix + . '\Component\\' . CFactory::_('Compiler.Builder.Content.One')->get('ComponentNameSpace') + . '\Administrator\Field">'; + } + $xml .= PHP_EOL . Indent::_(1) . '>'; + } + else + { + $xml .= PHP_EOL . Indent::_(1) . ''; + } + // add the fields + foreach ($module->config_fields as $field_name => $fieldsets) + { + $xml .= PHP_EOL . Indent::_(1) . ''; + foreach ($fieldsets as $fieldset => $fields) + { + // default to the field set name + $label = $fieldset; + if (isset($module->fieldsets_label[$field_name . $fieldset])) + { + $label = $module->fieldsets_label[$field_name . $fieldset]; + } + // add path to module rules and custom fields + if (isset($module->fieldsets_paths[$field_name . $fieldset]) + && ($module->fieldsets_paths[$field_name . $fieldset] == 2 + || $module->fieldsets_paths[$field_name . $fieldset] == 3)) + { + if ($module->target == 2) + { + if (!isset($module->add_rule_path[$field_name . $fieldset])) + { + $module->add_rule_path[$field_name . $fieldset] = + '/administrator/modules/' + . $module->file_name . '/rules'; + } + + if (!isset($module->add_field_path[$field_name . $fieldset])) + { + $module->add_field_path[$field_name . $fieldset] = + '/administrator/modules/' + . $module->file_name . '/fields'; + } + } + else + { + if (!isset($module->add_rule_path[$field_name . $fieldset])) + { + $module->add_rule_path[$field_name . $fieldset] = + '/modules/' . $module->file_name + . '/rules'; + } + + if (!isset($module->add_field_path[$field_name . $fieldset])) + { + $module->add_field_path[$field_name . $fieldset] = + '/modules/' . $module->file_name + . '/fields'; + } + } + } + // add path to module rules and custom fields + if (isset($module->add_rule_path[$field_name . $fieldset]) + || isset($module->add_field_path[$field_name . $fieldset])) + { + + $xml .= PHP_EOL . Indent::_(1) . ''; + + $xml .= PHP_EOL . Indent::_(1) . '
    add_rule_path[$field_name . $fieldset])) + { + $xml .= PHP_EOL . Indent::_(2) + . 'addrulepath="' . $module->add_rule_path[$field_name . $fieldset] . '"'; + } + + if (isset($module->add_field_path[$field_name . $fieldset])) + { + $xml .= PHP_EOL . Indent::_(2) + . 'addfieldpath="' . $module->add_field_path[$field_name . $fieldset] . '"'; + } + + $xml .= PHP_EOL . Indent::_(1) . '>'; + } + else + { + $xml .= PHP_EOL . Indent::_(1) . '
    '; + } + // load the fields + if (isset($config_fields[$field_name . $fieldset])) + { + $xml .= $config_fields[$field_name . $fieldset]; + unset($config_fields[$field_name . $fieldset]); + } + $xml .= PHP_EOL . Indent::_(1) . '
    '; + } + $xml .= PHP_EOL . Indent::_(1) . ''; + } + $xml .= PHP_EOL . Indent::_(1) . ''; + } + // set update server if found + if ($module->add_update_server) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) + . '' . $module->update_server_url + . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + return $xml; + } + + public function getPluginMainClass(&$plugin) + { + return CFactory::_('Placeholder')->update( + PHP_EOL . $plugin->head . PHP_EOL . + $plugin->comment . PHP_EOL . 'class ' . + $plugin->class_name . ' extends ' . + $plugin->extends . PHP_EOL . '{' . PHP_EOL . + $plugin->main_class_code . PHP_EOL . + "}" . PHP_EOL, + CFactory::_('Compiler.Builder.Content.One')->allActive() + ); + } + + public function getPluginMainXML(&$plugin) + { + // set the custom table key + $dbkey = 'yy'; + // build the xml + $xml = ''; + // search if we must add the component path + $add_component_path = false; + // build the config fields + $config_fields = []; + if (isset($plugin->config_fields) + && ArrayHelper::check( + $plugin->config_fields + )) + { + foreach ($plugin->config_fields as $field_name => $fieldsets) + { + foreach ($fieldsets as $fieldset => $fields) + { + // get the field set + $xmlFields = $this->getExtensionFieldsetXML( + $plugin, $fields, $dbkey + ); + // make sure the xml is set and a string + if (isset($xmlFields) + && StringHelper::check($xmlFields)) + { + $config_fields[$field_name . $fieldset] = $xmlFields; + } + $dbkey++; + // check if the fieldset path requiers component paths + if (!$add_component_path + && isset( + $plugin->fieldsets_paths[$field_name . $fieldset] + ) + && $plugin->fieldsets_paths[$field_name . $fieldset] + == 1) + { + $add_component_path = true; + } + } + } + } + // switch to add the language xml + $addLang = []; + // now build the language files + if (CFactory::_('Language')->exist($plugin->key)) + { + // get plugin lang content + $langContent = CFactory::_('Language')->getTarget($plugin->key); + // Trigger Event: jcb_ce_onBeforeBuildPluginLang + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeBuildPluginLang', [&$plugin, &$langContent] + ); + // get other languages + $values = array_unique($langContent); + // get the other lang strings if there is any + $this->multiLangString = $this->getMultiLangStrings($values); + // start the plugins language bucket (must rest every time) + $this->languages['plugins'] = []; + $this->languages['plugins'][CFactory::_('Config')->get('lang_tag', 'en-GB')] = []; + $this->languages['plugins'][CFactory::_('Config')->get('lang_tag', 'en-GB')]['all'] + = $langContent; + CFactory::_('Language')->setTarget($plugin->key, null); + // update insert the current lang in to DB + $this->setLangPlaceholders($values, $plugin->id, 'plugins'); + // remove old unused language strings + $this->purgeLanuageStrings($values, $plugin->id, 'plugins'); + $total = count($values); + unset($values); + // Trigger Event: jcb_ce_onBeforeBuildPluginLangFiles + CFactory::_('Event')->trigger( + 'jcb_ce_onBeforeBuildPluginLangFiles', [&$plugin, &$this->languages['plugins']] + ); + // now we insert the values into the files + if (ArrayHelper::check($this->languages['plugins'])) + { + foreach ($this->languages['plugins'] as $tag => $areas) + { + // trim the tag + $tag = trim($tag); + foreach ($areas as $area => $languageStrings) + { + $file_name = $tag . '.plg_' . strtolower((string) $plugin->group) + . '_' + . strtolower((string) $plugin->code_name) . '.ini'; + // check if language should be added + if ($this->shouldLanguageBeAdded( + $tag, $languageStrings, $total, + $file_name + )) + { + $lang = array_map( + fn($langstring, $placeholder) => $placeholder . '="' . $langstring . '"', + array_values($languageStrings), + array_keys($languageStrings) + ); + // set path + $path = $plugin->folder_path . '/language/' . $tag + . '/'; + // create path if not exist + if (!Folder::exists($path)) + { + Folder::create($path); + // count the folder created + CFactory::_('Utilities.Counter')->folder++; + } + // add to language file + CFactory::_('Utilities.File')->write( + $path . $file_name, + implode(PHP_EOL, $lang) + ); + CFactory::_('Utilities.File')->write( + $path . $tag . '.plg_' . strtolower( + (string) $plugin->group + ) + . '_' + . strtolower((string) $plugin->code_name) . '.sys.ini', + implode(PHP_EOL, $lang) + ); + // set the line counter + CFactory::_('Utilities.Counter')->line += count( + (array) $lang + ); + unset($lang); + // trigger to add language + $addLang[$tag] = $tag; + } + } + } + } + } + // get all files and folders in plugin folder + $files = Folder::files($plugin->folder_path); + $folders = Folder::folders($plugin->folder_path); + // the files/folders to ignore + $ignore = array('sql', 'language', 'script.php', + $plugin->file_name . '.xml', + $plugin->file_name . '.php'); + // should the scriptfile be added + if ($plugin->add_install_script) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) + . 'script.php'; + } + // should the sql install be added + if ($plugin->add_sql) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(3) + . 'sql/mysql/install.sql'; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + // should the sql uninstall be added + if ($plugin->add_sql_uninstall) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(3) + . 'sql/mysql/uninstall.sql'; + $xml .= PHP_EOL . Indent::_(2) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + // should the language xml be added + if (ArrayHelper::check($addLang)) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + // load all the language files to xml + foreach ($addLang as $addTag) + { + $xml .= PHP_EOL . Indent::_(2) . '' . $addTag . '/' . $addTag . '.plg_' + . strtolower((string) $plugin->group) . '_' . strtolower( + (string) $plugin->code_name + ) . '.ini'; + $xml .= PHP_EOL . Indent::_(2) . '' . $addTag . '/' . $addTag . '.plg_' + . strtolower((string) $plugin->group) . '_' . strtolower( + (string) $plugin->code_name + ) . '.sys.ini'; + } + $xml .= PHP_EOL . Indent::_(1) . ''; + } + // add the plugin files + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) . '' . $plugin->file_name + . '.php'; + // add other files found + if (ArrayHelper::check($files)) + { + foreach ($files as $file) + { + // only add what is not ignored + if (!in_array($file, $ignore)) + { + $xml .= PHP_EOL . Indent::_(2) . '' . $file + . ''; + } + } + } + // add language folder + if (ArrayHelper::check($addLang)) + { + $xml .= PHP_EOL . Indent::_(2) . 'language'; + } + // add sql folder + if ($plugin->add_sql || $plugin->add_sql_uninstall) + { + $xml .= PHP_EOL . Indent::_(2) . 'sql'; + } + // add other files found + if (ArrayHelper::check($folders)) + { + foreach ($folders as $folder) + { + // only add what is not ignored + if (!in_array($folder, $ignore)) + { + $xml .= PHP_EOL . Indent::_(2) . '' . $folder + . ''; + } + } + } + $xml .= PHP_EOL . Indent::_(1) . ''; + // now add the Config Params if needed + if (ArrayHelper::check($config_fields)) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + // only add if part of the component field types path is required + if ($add_component_path) + { + // add path to plugin rules and custom fields + $xml .= PHP_EOL . Indent::_(1) . 'get('joomla_version', 3) == 3) + { + $xml .= PHP_EOL . Indent::_(2) + . 'addrulepath="/administrator/components/com_' + . CFactory::_('Config')->component_code_name . '/models/rules"'; + $xml .= PHP_EOL . Indent::_(2) + . 'addfieldpath="/administrator/components/com_' + . CFactory::_('Config')->component_code_name . '/models/fields"'; + } + else + { + $xml .= PHP_EOL . Indent::_(3) + . 'addruleprefix="' . CFactory::_('Config')->namespace_prefix + . '\Component\\' . CFactory::_('Compiler.Builder.Content.One')->get('ComponentNameSpace') + . '\Administrator\Rule"'; + $xml .= PHP_EOL . Indent::_(3) + . 'addfieldprefix="' . CFactory::_('Config')->namespace_prefix + . '\Component\\' . CFactory::_('Compiler.Builder.Content.One')->get('ComponentNameSpace') + . '\Administrator\Field">'; + } + $xml .= PHP_EOL . Indent::_(1) . '>'; + } + else + { + $xml .= PHP_EOL . Indent::_(1) . ''; + } + // add the fields + foreach ($plugin->config_fields as $field_name => $fieldsets) + { + $xml .= PHP_EOL . Indent::_(1) . ''; + foreach ($fieldsets as $fieldset => $fields) + { + // default to the field set name + $label = $fieldset; + if (isset($plugin->fieldsets_label[$field_name . $fieldset])) + { + $label = $plugin->fieldsets_label[$field_name . $fieldset]; + } + // add path to plugin rules and custom fields + if (isset($plugin->fieldsets_paths[$field_name . $fieldset]) + && ($plugin->fieldsets_paths[$field_name . $fieldset] == 2 + || $plugin->fieldsets_paths[$field_name . $fieldset] == 3)) + { + if (!isset($plugin->add_rule_path[$field_name . $fieldset])) + { + $plugin->add_rule_path[$field_name . $fieldset] = + '/plugins/' . strtolower((string) $plugin->group + ) . '/' . strtolower((string) $plugin->code_name) + . '/rules'; + } + + if (!isset($plugin->add_field_path[$field_name . $fieldset])) + { + $plugin->add_field_path[$field_name . $fieldset] = + '/plugins/' . strtolower((string) $plugin->group + ) . '/' . strtolower((string) $plugin->code_name) + . '/fields'; + } + } + // add path to plugin rules and custom fields + if (isset($plugin->add_rule_path[$field_name . $fieldset]) + || isset($plugin->add_field_path[$field_name . $fieldset])) + { + $xml .= PHP_EOL . Indent::_(1) . ''; + + $xml .= PHP_EOL . Indent::_(1) . '
    add_rule_path[$field_name . $fieldset])) + { + $xml .= PHP_EOL . Indent::_(2) + . 'addrulepath="' . $plugin->add_rule_path[$field_name . $fieldset] . '"'; + } + + if (isset($plugin->add_field_path[$field_name . $fieldset])) + { + $xml .= PHP_EOL . Indent::_(2) + . 'addfieldpath="' . $plugin->add_field_path[$field_name . $fieldset] . '"'; + } + + $xml .= PHP_EOL . Indent::_(1) . '>'; + } + else + { + $xml .= PHP_EOL . Indent::_(1) . '
    '; + } + // load the fields + if (isset($config_fields[$field_name . $fieldset])) + { + $xml .= $config_fields[$field_name . $fieldset]; + unset($config_fields[$field_name . $fieldset]); + } + $xml .= PHP_EOL . Indent::_(1) . '
    '; + } + $xml .= PHP_EOL . Indent::_(1) . ''; + } + $xml .= PHP_EOL . Indent::_(1) . ''; + } + // set update server if found + if ($plugin->add_update_server) + { + $xml .= PHP_EOL . PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + $xml .= PHP_EOL . Indent::_(2) + . '' . $plugin->update_server_url + . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; + } + + return $xml; + } + + public function getPowerCode(&$power) + { + $code = []; + // set the name space + $code[] = 'namespace ' . $power->_namespace . ';' . PHP_EOL; + // check if we have header data + if (StringHelper::check($power->head)) + { + $code[] = PHP_EOL . $power->head; + } + // add description if set + if (StringHelper::check($power->description)) + { + // check if this is escaped + if (strpos((string) $power->description, '/*') === false) + { + // make this description escaped + $power->description = '/**' . PHP_EOL . ' * ' . implode(PHP_EOL . ' * ', explode(PHP_EOL, (string) $power->description)) . PHP_EOL . ' */'; + } + $code[] = PHP_EOL . $power->description; + } + // build power declaration + $declaration = $power->type . ' ' . $power->class_name; + // check if we have extends + if (StringHelper::check($power->extends_name)) + { + $declaration .= ' extends ' . $power->extends_name; + } + // check if we have implements + if (ArrayHelper::check($power->implement_names)) + { + $declaration .= ' implements ' . implode(', ', $power->implement_names); + } + $code[] = $declaration; + $code[] = '{'; + // add the main code if set + if (StringHelper::check($power->main_class_code)) + { + $code[] = $power->main_class_code; + } + $code[] = '}' . PHP_EOL . PHP_EOL; + + return CFactory::_('Placeholder')->update(implode(PHP_EOL, $code), CFactory::_('Compiler.Builder.Content.One')->allActive()); + } + + /** + * build field set for an extention + * + * @param object $extension The extention object + * @param array $fields The fields to build + * @param string $dbkey The database key + * + * @return string The fields set in xml + * + */ + public function getExtensionFieldsetXML(&$extension, &$fields, $dbkey = 'zz') + { + // get global placeholders + $placeholder = CFactory::_('Component.Placeholder')->get(); + // build the fieldset + return CFactory::_('Compiler.Creator.Fieldset.Dynamic')->get( + $fields, $extension->lang_prefix, $extension->key, $extension->key, + $placeholder, $dbkey + ); + } + + /** + * check if a translation should be added + * + * @return bool + * + */ + public function shouldLanguageBeAdded(&$tag, &$languageStrings, &$total, &$file_name) + { + // only log messages for none CFactory::_('Config')->get('lang_tag', 'en-GB') translations + if (CFactory::_('Config')->get('lang_tag', 'en-GB') !== $tag) + { + $langStringNr = count($languageStrings); + $langStringSum = MathHelper::bc( + 'mul', $langStringNr, 100 + ); + $percentage = MathHelper::bc( + 'div', $langStringSum, $total + ); + $stringNAme = ($langStringNr == 1) ? '(string ' + . $tag . ' translated)' + : '(strings ' . $tag . ' translated)'; + // force load if debug lines are added + if (!CFactory::_('Config')->get('debug_line_nr', false)) + { + // check if we should install this translation + if ($percentage < CFactory::_('Config')->percentage_language_add) + { + // languages that will be excluded + CFactory::_('Compiler.Builder.Language.Messages')->set("exclude.$file_name", + '' . $total . '(total ' + . CFactory::_('Config')->get('lang_tag', 'en-GB') . ' strings) only ' + . $langStringNr . '' . $stringNAme . ' = ' . $percentage + ); + + return false; + } + } + // languages that will be included + CFactory::_('Compiler.Builder.Language.Messages')->set("include.$file_name", + '' . $total . '(total ' + . CFactory::_('Config')->get('lang_tag', 'en-GB') . ' strings) and ' + . $langStringNr . '' . $stringNAme . ' = ' . $percentage + ); + } + + return true; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Structure.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Structure.php new file mode 100644 index 000000000..8e05da03b --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Structure.php @@ -0,0 +1,901 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Helper; + + +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Language\Text; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Utilities\FileHelper; +use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory; +use VDM\Joomla\Componentbuilder\Compiler\Helper\Get; + + +/** + * Structure class + * + * @deprecated 3.3 + */ +class Structure extends Get +{ + /** + * The folder counter + * + * @var int + * @deprecated 3.3 Use CFactory::_('Utilities.Counter')->folder; + */ + public $folderCount = 0; + + /** + * The file counter + * + * @var int + * @deprecated 3.3 Use CFactory::_('Utilities.Counter')->file; + */ + public $fileCount = 0; + + /** + * The page counter + * + * @var int + * @deprecated 3.3 + */ + public $pageCount = 0; + + /** + * The line counter + * + * @var int + * @deprecated 3.3 Use CFactory::_('Utilities.Counter')->line; + */ + public $lineCount = 0; + + /** + * The field counter + * + * @var int + * @deprecated 3.3 + */ + public $fieldCount = 0; + + /** + * The seconds counter + * + * @var int + * @deprecated 3.3 + */ + public $seconds = 0; + + /** + * The actual seconds counter + * + * @var int + * @deprecated 3.3 + */ + public $actualSeconds = 0; + + /** + * The folder seconds counter + * + * @var int + * @deprecated 3.3 + */ + public $folderSeconds = 0; + + /** + * The file seconds counter + * + * @var int + * @deprecated 3.3 + */ + public $fileSeconds = 0; + + /** + * The line seconds counter + * + * @var int + * @deprecated 3.3 + */ + public $lineSeconds = 0; + + /** + * The seconds debugging counter + * + * @var int + * @deprecated 3.3 + */ + public $secondsDebugging = 0; + + /** + * The seconds planning counter + * + * @var int + * @deprecated 3.3 + */ + public $secondsPlanning = 0; + + /** + * The seconds mapping counter + * + * @var int + * @deprecated 3.3 + */ + public $secondsMapping = 0; + + /** + * The seconds office counter + * + * @var int + * @deprecated 3.3 + */ + public $secondsOffice = 0; + + /** + * The total hours counter + * + * @var int + * @deprecated 3.3 + */ + public $totalHours = 0; + + /** + * The debugging hours counter + * + * @var int + * @deprecated 3.3 + */ + public $debuggingHours = 0; + + /** + * The planning hours counter + * + * @var int + * @deprecated 3.3 + */ + public $planningHours = 0; + + /** + * The mapping hours counter + * + * @var int + * @deprecated 3.3 + */ + public $mappingHours = 0; + + /** + * The office hours counter + * + * @var int + * @deprecated 3.3 + */ + public $officeHours = 0; + + /** + * The actual Total Hours counter + * + * @var int + * @deprecated 3.3 + */ + public $actualTotalHours = 0; + + /** + * The actual hours spent counter + * + * @var int + * @deprecated 3.3 + */ + public $actualHoursSpent = 0; + + /** + * The actual days spent counter + * + * @var int + * @deprecated 3.3 + */ + public $actualDaysSpent = 0; + + /** + * The total days counter + * + * @var int + * @deprecated 3.3 + */ + public $totalDays = 0; + + /** + * The actual Total Days counter + * + * @var int + * @deprecated 3.3 + */ + public $actualTotalDays = 0; + + /** + * The project week time counter + * + * @var int + * @deprecated 3.3 + */ + public $projectWeekTime = 0; + + /** + * The project month time counter + * + * @var int + * @deprecated 3.3 + */ + public $projectMonthTime = 0; + + /** + * The template path + * + * @var string + * @deprecated 3.3 Use CFactory::_('Utilities.Paths')->template_path; + */ + public $templatePath; + + /** + * The custom template path + * + * @var string + * @deprecated 3.3 Use CFactory::_('Utilities.Paths')->template_path_custom; + */ + public $templatePathCustom; + + /** + * The Joomla Version Data + * + * @var object + * @deprecated 3.3 Use CFactory::_('Component.Settings') + */ + public $joomlaVersionData; + + /** + * Static File Content + * + * @var array + * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Content.One')->allActive() + */ + public $fileContentStatic = []; + + /** + * Extention Custom Fields + * + * @var array + * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Extension.Custom.Fields')->get($key) + */ + public $extentionCustomfields = []; + + /** + * Extention Tracking Files Moved + * + * @var array + */ + public $extentionTrackingFilesMoved = []; + + /** + * The standard folders + * + * @var array + * @deprecated 3.3 + */ + public $stdFolders = array('site', 'admin', 'media'); + + /** + * The standard root files + * + * @var array + * @deprecated 3.3 + */ + public $stdRootFiles + = array('access.xml', 'config.xml', 'controller.php', 'index.html', 'README.txt'); + + /** + * Dynamic File Content + * + * @var array + * @deprecated 3.3 Use CFactory::_('Compiler.Builder.Content.Multi')->allActive() + */ + public $fileContentDynamic = []; + + /** + * The Component Sales name + * + * @var string + * @deprecated 3.3 Use CFactory::_('Utilities.Paths')->component_sales_name; + */ + public $componentSalesName; + + /** + * The Component Backup name + * + * @var string + * @deprecated 3.3 Use CFactory::_('Utilities.Paths')->component_backup_name; + */ + public $componentBackupName; + + /** + * The Component Folder name + * + * @var string + * @deprecated 3.3 Use CFactory::_('Utilities.Paths')->component_folder_name; + */ + public $componentFolderName; + + /** + * The Component path + * + * @var string + * @deprecated 3.3 Use CFactory::_('Utilities.Paths')->component_path; + */ + public $componentPath; + + /** + * The Dynamic paths + * + * @var array + * @deprecated 3.3 Use CFactory::_('Registry')->get('dynamic_paths'); + */ + public $dynamicPaths = []; + + /** + * The not new static items + * + * @var array + * @deprecated 3.3 Use CFactory::_('Registry')->get('files.not.new', []); + */ + public $notNew = []; + + /** + * Update the file content + * + * @var array + * @deprecated 3.3 Use CFactory::_('Registry')->get('update.file.content'); + */ + public $updateFileContent = []; + + /** + * The new files + * + * @var array + * @deprecated 3.3 Use CFactory::_('Utilities.Files'); + */ + public $newFiles = []; + + /** + * The Checkin Switch + * + * @var boolean + */ + public $addCheckin = false; + + /** + * The Move Folders Switch + * + * @var boolean + */ + public $setMoveFolders = false; + + /** + * The array of last modified dates + * + * @var array + * @deprecated 3.3 + */ + protected $lastModifiedDate = []; + + /** + * The default view switch + * + * @var bool/string + * @deprecated 3.3 Use CFactory::_('Registry')->get('build.dashboard'); + */ + public $dynamicDashboard = false; + + /** + * The default view type + * + * @var string + * @deprecated 3.3 Use CFactory::_('Registry')->get('build.dashboard.type'); + */ + public $dynamicDashboardType; + + /** + * Constructor + */ + public function __construct() + { + // first we run the parent constructor + if (parent::__construct()) + { + // set incase no extra admin folder are loaded + CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_ADMIN_FOLDERS', ''); + // set incase no extra site folder are loaded + CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_SITE_FOLDERS', ''); + // set incase no extra media folder are loaded + CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_MEDIA_FOLDERS', ''); + // set incase no extra admin files are loaded + CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_ADMIN_FILES', ''); + // set incase no extra site files are loaded + CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_SITE_FILES', ''); + // set incase no extra media files are loaded + CFactory::_('Compiler.Builder.Content.One')->set('EXSTRA_MEDIA_FILES', ''); + // make sure there is no old build + CFactory::_('Utilities.Folder')->remove(CFactory::_('Utilities.Paths')->component_path); + // load the libraries files/folders and url's + CFactory::_('Library.Structure')->build(); + // load the powers files/folders + CFactory::_('Power.Structure')->build(); + // load the module files/folders and url's + CFactory::_('Joomlamodule.Structure')->build(); + // load the plugin files/folders and url's + CFactory::_('Joomlaplugin.Structure')->build(); + // set the dashboard + CFactory::_('Component.Dashboard')->set(); + // set the component base structure + if (!CFactory::_('Component.Structure')->build()) + { + return false; + } + + // set all single instance folders and files + if (!CFactory::_('Component.Structure.Single')->build()) + { + return false; + } + + // set all the dynamic folders and files + if (!CFactory::_('Component.Structure.Multiple')->build()) + { + return false; + } + + return true; + } + + return false; + } + + /** + * Build the Powers files, folders + * + * @return void + * @deprecated 3.3 Use CFactory::_('Power.Structure')->build(); + */ + private function buildPowers() + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * Build the Modules files, folders, url's and config + * + * @return void + * @deprecated 3.3 Use CFactory::_('Joomlamodule.Structure')->build(); + */ + private function buildModules() + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * Build the Plugins files, folders, url's and config + * + * @return void + * @deprecated 3.3 Use CFactory::_('Joomlaplugin.Structure')->build(); + */ + private function buildPlugins() + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * Create Path if not exist + * + * @return void + * @deprecated 3.3 Use CFactory::_('Utilities.Folder')->create($path); + */ + private function createFolder($path) + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * Build the Libraries files, folders, url's and config + * + * @return void + * @deprecated 3.3 Use CFactory::_('Library.Structure')->build(); + */ + private function setLibraries() + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * set the dynamic dashboard if set + * + * @return void + * @deprecated 3.3 Use CFactory::_('Component.Dashboard')->set(); + */ + private function setDynamicDashboard() + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * Write data to file + * + * @return bool true on success + * @deprecated 3.3 + */ + public function writeFile($path, $data) + { + return FileHelper::write($path, $data); + } + + /** + * Build the Initial Folders + * + * @return void + * @deprecated 3.3 Use CFactory::_('Component.Structure')->build(); + */ + private function setFolders() + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * Set the Static File & Folder + * + * @return boolean + * @deprecated 3.3 Use CFactory::_('Component.Structure.Single')->build(); + */ + private function setStatic() + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * Set the Dynamic File & Folder + * + * @return boolean + * @deprecated 3.3 Use CFactory::_('Component.Structure.Multiple')->build(); + */ + private function setDynamique() + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + + return false; + } + + /** + * move the fields and Rules + * + * @param array $field The field data + * @param string $path The path to move to + * + * @return void + * + */ + public function moveFieldsRules($field, $path) + { + // check if we have a subform or repeatable field + if ($field['type_name'] === 'subform' + || $field['type_name'] === 'repeatable') + { + // since we could have a custom field or rule inside + $this->moveMultiFieldsRules($field, $path); + } + else + { + // check if this is a custom field that should be moved + if (CFactory::_('Compiler.Builder.Extension.Custom.Fields')->exists($field['type_name'])) + { + $check = md5($path . 'type' . $field['type_name']); + // lets check if we already moved this + if (CFactory::_('Config')->get('joomla_version', 3) == 3 && + !isset($this->extentionTrackingFilesMoved[$check])) + { + // check files exist + if (File::exists( + CFactory::_('Utilities.Paths')->component_path . '/admin/models/fields/' + . $field['type_name'] . '.php' + )) + { + // copy the custom field + File::copy( + CFactory::_('Utilities.Paths')->component_path . '/admin/models/fields/' + . $field['type_name'] . '.php', + $path . '/fields/' . $field['type_name'] . '.php' + ); + } + // stop from doing this again. + $this->extentionTrackingFilesMoved[$check] = true; + } + } + // check if this has validation that should be moved + if (CFactory::_('Registry')->get('validation.linked.' . $field['field']) !== null) + { + $check = md5( + $path . 'rule' + . CFactory::_('Registry')->get('validation.linked.' . $field['field']) + ); + // lets check if we already moved this + if (CFactory::_('Config')->get('joomla_version', 3) == 3 && + !isset($this->extentionTrackingFilesMoved[$check])) + { + // check files exist + if (File::exists( + CFactory::_('Utilities.Paths')->component_path . '/admin/models/rules/' + . CFactory::_('Registry')->get('validation.linked.' . $field['field']) + . '.php' + )) + { + // copy the custom field + File::copy( + CFactory::_('Utilities.Paths')->component_path . '/admin/models/rules/' + . CFactory::_('Registry')->get('validation.linked.' . $field['field']) + . '.php', $path . '/rules/' + . CFactory::_('Registry')->get('validation.linked.' . $field['field']) + . '.php' + ); + } + // stop from doing this again. + $this->extentionTrackingFilesMoved[$check] = true; + } + } + } + } + + /** + * move the fields and Rules of multi fields + * + * @param array $multi_field The field data + * @param string $path The path to move to + * + * @return void + * + */ + protected function moveMultiFieldsRules($multi_field, $path) + { + // get the fields ids + $ids = array_map( + 'trim', + explode( + ',', + (string) GetHelper::between( + $multi_field['settings']->xml, 'fields="', '"' + ) + ) + ); + if (ArrayHelper::check($ids)) + { + foreach ($ids as $id) + { + // setup the field + $field = []; + $field['field'] = $id; + CFactory::_('Field')->set($field); + // move field and rules if needed + $this->moveFieldsRules($field, $path); + } + } + } + + /** + * get the created date of the (view) + * + * @param array $view The view values + * + * @return string Last Modified Date + * @deprecated 3.3 Use CFactory::_('Model.Createdate')->get($view); + */ + public function getCreatedDate($view) + { + return CFactory::_('Model.Createdate')->get($view); + } + + /** + * get the last modified date of a MVC (view) + * + * @param array $view The view values + * + * @return string Last Modified Date + * @deprecated 3.3 Use CFactory::_('Model.Modifieddate')->get($view); + */ + public function getLastModifiedDate($view) + { + return CFactory::_('Model.Modifieddate')->get($view); + } + + /** + * Set the Static File & Folder + * + * @param array $target The main target and name + * @param string $type The type in the target + * @param string $fileName The custom file name + * @param array $cofig to add more data to the files info + * + * @return boolean + * @deprecated 3.3 Use CFactory::_('Utilities.Structure')->build($target, $type, $fileName, $config); + */ + public function buildDynamique($target, $type, $fileName = null, $config = null) + { + return CFactory::_('Utilities.Structure')->build($target, $type, $fileName, $config); + } + + /** + * set the Joomla Version Data + * + * @return object The version data + * @deprecated 3.3 + */ + private function setJoomlaVersionData() + { + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_HR_HTHREES_WARNINGHTHREE', __CLASS__), 'Error' + ); + $this->app->enqueueMessage( + Text::sprintf( + 'Use of a deprecated method (%s)!', __METHOD__ + ), 'Error' + ); + } + + /** + * Add the dynamic folders + */ + protected function setDynamicFolders() + { + // check if we should add the dynamic folder moving script to the installer script + if (!CFactory::_('Registry')->get('set_move_folders_install_script')) + { + // add the setDynamicF0ld3rs() method to the install scipt.php file + CFactory::_('Registry')->set('set_move_folders_install_script', true); + // set message that this was done (will still add a tutorial link later) + $this->app->enqueueMessage( + Text::_( + '

    Dynamic folder(s) were detected.

    ' + ), 'Notice' + ); + $_function = 'setDynamicF0ld3rs'; + $_script = 'script.php'; + if (CFactory::_('Config')->get('joomla_version', 3) != 3) + { + $_function = 'moveFolders'; + $_script = 'ComponentnameInstallerScript.php'; + } + $this->app->enqueueMessage( + Text::sprintf( + 'A method (%s) was added to the install %s of this package to insure that the folder(s) are copied into the correct place when this component is installed!', + $_function, $_script + ), 'Notice' + ); + } + } + + /** + * set the index.html file in a folder path + * + * @param string $path The path to place the index.html file in + * + * @return void + * @deprecated 3.3 Use CFactory::_('Utilities.File')->write($path, $root); + * + */ + private function indexHTML($path, $root = 'component') + { + CFactory::_('Utilities.File')->write($path, $root); + } + + /** + * Update paths with real value + * + * @param string $path The full path + * + * @return string The updated path + * @deprecated 3.3 Use CFactory::_('Utilities.Dynamicpath')->update($path); + */ + protected function updateDynamicPath($path) + { + return CFactory::_('Utilities.Dynamicpath')->update($path); + } + + /** + * Remove folders with files + * + * @param string $dir The path to folder to remove + * @param boolean $ignore The files and folders to ignore + * + * @return boolean True if all is removed + * @deprecated 3.3 Use CFactory::_('Utilities.Folder')->remove($dir, $ignore); + */ + protected function removeFolder($dir, $ignore = false) + { + return CFactory::_('Utilities.Folder')->remove($dir, $ignore); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Helper/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Controller/AllowAddInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Controller/AllowAddInterface.php new file mode 100644 index 000000000..56126a476 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Controller/AllowAddInterface.php @@ -0,0 +1,32 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller; + + +/** + * Controller Allow Add Interface + * + * @since 3.2.0 + */ +interface AllowAddInterface +{ + /** + * Get Allow Add Function Code + * + * @param string $nameSingleCode The single code name of the view. + * + * @since 3.2.0 + * @return string The allow add method code + */ + public function get(string $nameSingleCode): string; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Controller/AllowEditInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Controller/AllowEditInterface.php new file mode 100644 index 000000000..5b9af6ff8 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Controller/AllowEditInterface.php @@ -0,0 +1,33 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller; + + +/** + * Controller Allow Edit Interface + * + * @since 3.2.0 + */ +interface AllowEditInterface +{ + /** + * Get Allow Edit Function Code + * + * @param string $nameSingleCode The single code name of the view. + * @param string $nameListCode The list code name of the view. + * + * @since 3.2.0 + * @return string The allow edit method code + */ + public function get(string $nameSingleCode, string $nameListCode): string; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Controller/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Controller/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Controller/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Model/CanDeleteInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Model/CanDeleteInterface.php new file mode 100644 index 000000000..662905f11 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Model/CanDeleteInterface.php @@ -0,0 +1,32 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model; + + +/** + * Model Can Delete Interface + * + * @since 3.2.0 + */ +interface CanDeleteInterface +{ + /** + * Get Can Delete Function Code + * + * @param string $nameSingleCode The single code name of the view. + * + * @since 3.2.0 + * @return string The can delete method code + */ + public function get(string $nameSingleCode): string; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Model/CanEditStateInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Model/CanEditStateInterface.php new file mode 100644 index 000000000..4f2824765 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Model/CanEditStateInterface.php @@ -0,0 +1,32 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model; + + +/** + * Model Can Edit State Interface + * + * @since 3.2.0 + */ +interface CanEditStateInterface +{ + /** + * Get Can Edit State Function Code + * + * @param string $nameSingleCode The single code name of the view. + * + * @since 3.2.0 + * @return string The can edit state method code + */ + public function get(string $nameSingleCode): string; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Model/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Model/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Architecture/Model/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Component/SettingsInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Component/SettingsInterface.php new file mode 100644 index 000000000..f92ea46cb --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Component/SettingsInterface.php @@ -0,0 +1,74 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component; + + +/** + * Compiler Component Settings Interface + * + * @since 3.2.0 + */ +interface SettingsInterface +{ + /** + * Check if data set is loaded + * + * @return bool + * @since 3.2.0 + */ + public function exists(): bool; + + /** + * Get Joomla - Folder Structure to Create + * + * @return object The version related structure + * @since 3.2.0 + */ + public function structure(): object; + + /** + * Get Joomla - Move Multiple Structure + * + * @return object The version related multiple structure + * @since 3.2.0 + */ + public function multiple(): object; + + /** + * Get Joomla - Move Single Structure + * + * @return object The version related single structure + * @since 3.2.0 + */ + public function single(): object; + + /** + * Check if Folder is a Standard Folder + * + * @param string $folder The folder name + * + * @return bool true if the folder exists + * @since 3.2.0 + */ + public function standardFolder(string $folder): bool; + + /** + * Check if File is a Standard Root File + * + * @param string $file The file name + * + * @return bool true if the file exists + * @since 3.2.0 + */ + public function standardRootFile(string $file): bool; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/EventInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/EventInterface.php index 0f9b96010..12a9cee41 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/EventInterface.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/EventInterface.php @@ -28,6 +28,6 @@ interface EventInterface * @return void * @since 3.2.0 */ - public function trigger(string $event, $data); + public function trigger(string $event, $data = null); } diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Field/CoreFieldInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Field/CoreFieldInterface.php new file mode 100644 index 000000000..01f0a351a --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Field/CoreFieldInterface.php @@ -0,0 +1,32 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field; + + +/** + * Field Joomla Core Field Interface + * + * @since 3.2.0 + */ +interface CoreFieldInterface +{ + /** + * Get the Array of Existing Core Field Names + * + * @param bool $lowercase Switch to set field lowercase + * + * @return array + * @since 3.2.0 + */ + public function get(bool $lowercase = false): array; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Field/CoreRuleInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Field/CoreRuleInterface.php new file mode 100644 index 000000000..5e09c28ec --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Field/CoreRuleInterface.php @@ -0,0 +1,32 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field; + + +/** + * Field Joomla Core Rule Interface + * + * @since 3.2.0 + */ +interface CoreRuleInterface +{ + /** + * Get the Array of Existing Core Rule Names + * + * @param bool $lowercase Switch to set rules lowercase + * + * @return array + * @since 3.2.0 + */ + public function get(bool $lowercase = false): array; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Field/CoreValidationInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Field/CoreValidationInterface.php deleted file mode 100644 index 8bf9641d8..000000000 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Field/CoreValidationInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field; - - -/** - * Field Joomla Core Validation Interface - * - * @since 3.2.0 - */ -interface CoreValidationInterface -{ - /** - * Get the Array of Existing Validation Rule Names - * - * @param bool $lowercase Switch to set rules lowercase - * - * @return array - * @since 3.2.0 - */ - public function get(bool $lowercase = false): array; -} - diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Field/InputButtonInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Field/InputButtonInterface.php new file mode 100644 index 000000000..4bdd51393 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Field/InputButtonInterface.php @@ -0,0 +1,32 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field; + + +/** + * Compiler Field Input Button + * + * @since 3.2.0 + */ +interface InputButtonInterface +{ + /** + * get Add Button To List Field Input (getInput tweak) + * + * @param array $fieldData The field custom data + * + * @return string of getInput class on success empty string otherwise + * @since 3.2.0 + */ + public function get(array $fieldData): string; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/HeaderInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/HeaderInterface.php new file mode 100644 index 000000000..0188a0c1a --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/HeaderInterface.php @@ -0,0 +1,33 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces; + + +/** + * Compiler Header Interface + * + * @since 3.2.0 + */ +interface HeaderInterface +{ + /** + * Get the headers for a file + * + * @param string $context The name of the context + * @param string $codeName The view, views, or layout code name + * + * @return string The header string to place in the header of the file + * @since 3.2.0 + */ + public function get(string $context, string $codeName): string; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Model/CustomtabsInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Model/CustomtabsInterface.php new file mode 100644 index 000000000..3252aee63 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Model/CustomtabsInterface.php @@ -0,0 +1,32 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Model; + + +/** + * Model Custom Tabs Interface + * + * @since 3.2.0 + */ +interface CustomtabsInterface +{ + /** + * Set custom tabs + * + * @param object $item The view data + * + * @return void + * @since 3.2.0 + */ + public function set(object &$item); +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Model/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Model/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Interfaces/Model/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFive/Event.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFive/Event.php new file mode 100644 index 000000000..245cf05d9 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFive/Event.php @@ -0,0 +1,100 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\JoomlaFive; + + +use Joomla\Registry\Registry; +use Joomla\CMS\Plugin\PluginHelper; +use VDM\Joomla\Utilities\Component\Helper; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface; + + +/** + * Compiler Events + * + * @since 3.2.0 + */ +class Event implements EventInterface +{ + /** + * event plugin trigger switch + * + * @var boolean + * @since 3.2.0 + */ + protected $activePlugins = false; + + /** + * Constructor + * + * @param Registry|null $params The component parameters + * + * @since 3.2.0 + */ + public function __construct(?Registry $params = null) + { + // Set the params + $params = $params ?: Helper::getParams('com_componentbuilder'); + // get active plugins + if (($plugins = $params->get('compiler_plugin', false)) + !== false) + { + foreach ($plugins as $plugin) + { + // get possible plugins + if (PluginHelper::isEnabled('extension', $plugin)) + { + // Import the appropriate plugin group. + PluginHelper::importPlugin('extension', $plugin); + // activate events + $this->activePlugins = true; + } + } + } + } + + /** + * Trigger an event + * + * @param string $event The event to trigger + * @param mixed $data The values to pass to the event/plugin + * + * @return void + * @throws \Exception + * @since 3.2.0 + */ + public function trigger(string $event, $data = null) + { + // only execute if plugins were loaded (active) + if ($this->activePlugins) + { + // Get the dispatcher. + $dispatcher = \JEventDispatcher::getInstance(); + + // Trigger this compiler event. + $results = $dispatcher->trigger($event, $data); + + // Check for errors encountered while trigger the event + if (count((array) $results) && in_array(false, $results, true)) + { + // Get the last error. + $error = $dispatcher->getError(); + + if (!($error instanceof \Exception)) + { + throw new \Exception($error); + } + } + } + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFive/Header.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFive/Header.php new file mode 100644 index 000000000..cd95b8476 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFive/Header.php @@ -0,0 +1,584 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\JoomlaFive; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Builder\UikitComp; +use VDM\Joomla\Componentbuilder\Compiler\Builder\AdminFilterType; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Category; +use VDM\Joomla\Componentbuilder\Compiler\Builder\AccessSwitchList; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Filter; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Tags; +use VDM\Joomla\Utilities\String\NamespaceHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface; + + +/** + * Build headers for all Joomla 5 files + * + * @since 3.2.0 + */ +final class Header implements HeaderInterface +{ + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The EventInterface Class. + * + * @var Event + * @since 3.2.0 + */ + protected Event $event; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 3.2.0 + */ + protected Placeholder $placeholder; + + /** + * The Language Class. + * + * @var Language + * @since 3.2.0 + */ + protected Language $language; + + /** + * The UikitComp Class. + * + * @var UikitComp + * @since 3.2.0 + */ + protected UikitComp $uikitcomp; + + /** + * The AdminFilterType Class. + * + * @var AdminFilterType + * @since 3.2.0 + */ + protected AdminFilterType $adminfiltertype; + + /** + * The Category Class. + * + * @var Category + * @since 3.2.0 + */ + protected Category $category; + + /** + * The AccessSwitchList Class. + * + * @var AccessSwitchList + * @since 3.2.0 + */ + protected AccessSwitchList $accessswitchlist; + + /** + * The Filter Class. + * + * @var Filter + * @since 3.2.0 + */ + protected Filter $filter; + + /** + * The Tags Class. + * + * @var Tags + * @since 3.2.0 + */ + protected Tags $tags; + + /** + * The Header Context array + * + * @var array + * @since 3.2.0 + */ + protected array $headers = []; + + /** + * The Namespace Prefix + * + * @var string + * @since 3.2.0 + */ + protected string $NamespacePrefix; + + /** + * The Component Name (in code) + * + * @var string + * @since 3.2.0 + */ + protected string $ComponentName; + + /** + * The Component Namespace (in code) + * + * @var string + * @since 3.2.0 + */ + protected string $ComponentNameSpace; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Event $event The EventInterface Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Language $language The Language Class. + * @param UikitComp $uikitcomp The UikitComp Class. + * @param AdminFilterType $adminfiltertype The AdminFilterType Class. + * @param Category $category The Category Class. + * @param AccessSwitchList $accessswitchlist The AccessSwitchList Class. + * @param Filter $filter The Filter Class. + * @param Tags $tags The Tags Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Event $event, Placeholder $placeholder, + Language $language, UikitComp $uikitcomp, + AdminFilterType $adminfiltertype, Category $category, + AccessSwitchList $accessswitchlist, Filter $filter, + Tags $tags) + { + $this->config = $config; + $this->event = $event; + $this->placeholder = $placeholder; + $this->language = $language; + $this->uikitcomp = $uikitcomp; + $this->adminfiltertype = $adminfiltertype; + $this->category = $category; + $this->accessswitchlist = $accessswitchlist; + $this->filter = $filter; + $this->tags = $tags; + + // set some global values + $this->NamespacePrefix = $this->config->get('namespace_prefix'); + $this->ComponentName = $this->placeholder->get('Component'); + $this->ComponentNameSpace = NamespaceHelper::safeSegment($this->ComponentName); + } + + /** + * Get the headers for a file + * + * @param string $context The name of the context + * @param string $codeName The view, views, or layout code name + * + * @return string The header string to place in the header of the file + * @since 3.2.0 + */ + public function get(string $context, string $codeName): string + { + // get static headers + $headers = $this->getHeaders($context); + + // add to all except the helper classes + if ('admin.helper' !== $context && 'site.helper' !== $context) + { + $target = 'Administrator'; + if ($this->config->get('build_target', 'admin') === 'site') + { + $target = 'Site'; + } + + $headers[] = "use {$this->NamespacePrefix}\\Component\\{$this->ComponentNameSpace}\\{$target}\\Helper\\{$this->ComponentName}Helper;"; + + // we will add more as needed + switch ($context) + { + case 'site.view.model': + case 'site.views.model': + case 'site.view.html': + case 'site.views.html': + $headers[] = "use {$this->NamespacePrefix}\\Component\\{$this->ComponentNameSpace}\\Site\\Helper\\RouteHelper;"; + break; + + default: + break; + } + } + + // get dynamic headers + switch ($context) + { + case 'admin.helper': + case 'site.helper': + $this->setHelperClassHeader($headers, $codeName); + break; + + case 'admin.view.html': + case 'admin.views.html': + case 'custom.admin.view.html': + case 'custom.admin.views.html': + case 'site.admin.view.html': + case 'site.view.html': + case 'site.views.html': + if ((2 == $this->config->uikit || 1 == $this->config->uikit) + && $this->uikitcomp->exists($codeName)) + { + $headers[] = 'use Joomla\CMS\Filesystem\File;'; + } + break; + + case 'admin.view': + case 'custom.admin.view': + case 'custom.admin.views': + case 'site.admin.view': + $headers[] = ''; + $headers[] = '/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */'; + $headers[] = '$wa = $this->getDocument()->getWebAssetManager();'; + $headers[] = '$wa->useScript(\'keepalive\')->useScript(\'form.validate\');'; + $headers[] = 'Html::_(\'bootstrap.tooltip\');'; + break; + + case 'admin.view.model': + case 'site.admin.view.model': + case 'custom.admin.view.model': + case 'site.view.model': + case 'admin.views.model': + case 'site.views.model': + $headers[] = 'use Joomla\CMS\Helper\TagsHelper;'; + break; + + default: + break; + } + + // Trigger Event: jcb_ce_setClassHeader + $this->event->trigger( + 'jcb_ce_setClassHeader', [&$context, &$codeName, &$headers] + ); + + // return the headers + return $this->placeholder->update_(implode(PHP_EOL, $headers)); + } + + /** + * Get the headers for a file + * + * @param string $context The name of the context + * + * @return array The header string to place in the header of the file + * @since 3.2.0 + */ + protected function getHeaders(string $context): array + { + if (isset($this->headers[$context])) + { + return $this->headers[$context]; + } + + // set the defaults + $headers = []; + $headers[] = 'use Joomla\CMS\Factory;'; + $headers[] = 'use Joomla\CMS\Language\Text;'; + + switch ($context) + { + case 'admin.component': + $headers[] = 'use Joomla\CMS\Access\Exception\NotAllowed;'; + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\MVC\Controller\BaseController;'; + break; + + case 'admin.helper': + case 'site.helper': + $headers[] = 'use Joomla\CMS\Access\Access;'; + $headers[] = 'use Joomla\CMS\Access\Rules as AccessRules;'; + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\Filesystem\File;'; + $headers[] = 'use Joomla\CMS\Language\Language;'; + $headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;'; + $headers[] = 'use Joomla\CMS\Object\CMSObject;'; + $headers[] = 'use Joomla\CMS\Session\Session;'; + $headers[] = 'use Joomla\CMS\Table\Table;'; + $headers[] = 'use Joomla\CMS\Uri\Uri;'; + $headers[] = 'use Joomla\CMS\Version;'; + $headers[] = 'use Joomla\Database\DatabaseInterface;'; + $headers[] = 'use Joomla\Registry\Registry;'; + $headers[] = 'use Joomla\String\StringHelper;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + break; + + case 'admin.layout': + case 'site.layout': + case 'custom.admin.layout': + case 'override.layout': + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Layout\LayoutHelper;'; + break; + + case 'admin.view': + case 'custom.admin.view': + case 'custom.admin.views': + case 'site.admin.view': + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Layout\LayoutHelper;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + break; + + case 'admin.view.controller': + $headers[] = 'use Joomla\CMS\Form\FormFactoryInterface;'; + $headers[] = 'use Joomla\CMS\Application\CMSApplication;'; + $headers[] = 'use Joomla\CMS\MVC\Factory\MVCFactoryInterface;'; + $headers[] = 'use Joomla\Input\Input;'; + case 'site.admin.view.controller': + $headers[] = 'use Joomla\CMS\Versioning\VersionableControllerTrait;'; + case 'site.view.controller': + $headers[] = 'use Joomla\CMS\MVC\Controller\FormController;'; + $headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'use Joomla\CMS\Session\Session;'; + $headers[] = 'use Joomla\CMS\Uri\Uri;'; + break; + + case 'admin.view.html': + case 'admin.views.html': + case 'site.admin.view.html': + $headers[] = 'use Joomla\CMS\Toolbar\Toolbar;'; + $headers[] = 'use Joomla\CMS\Form\FormHelper;'; + $headers[] = 'use Joomla\CMS\Session\Session;'; + $headers[] = 'use Joomla\CMS\Uri\Uri;'; + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Layout\FileLayout;'; + $headers[] = 'use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;'; + $headers[] = 'use Joomla\CMS\Plugin\PluginHelper;'; + $headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;'; + $headers[] = 'use Joomla\CMS\Document\Document;'; + break; + + case 'site.view.html': + case 'site.views.html': + $headers[] = 'use Joomla\CMS\Toolbar\Toolbar;'; + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Layout\FileLayout;'; + $headers[] = 'use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;'; + $headers[] = 'use Joomla\CMS\Plugin\PluginHelper;'; + $headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;'; + $headers[] = 'use Joomla\CMS\Document\Document;'; + $headers[] = "use {$this->NamespacePrefix}\\Component\\{$this->ComponentNameSpace}\\Site\\Helper\\HeaderCheck;"; + break; + + case 'custom.admin.view.html': + case 'custom.admin.views.html': + $target = 'Administrator'; + if ($this->config->get('build_target', 'admin') === 'site') + { + $target = 'Site'; + } + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Layout\FileLayout;'; + $headers[] = 'use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;'; + $headers[] = 'use Joomla\CMS\Plugin\PluginHelper;'; + $headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;'; + $headers[] = 'use Joomla\CMS\Document\Document;'; + $headers[] = "use {$this->NamespacePrefix}\\Component\\{$this->ComponentNameSpace}\\{$target}\\Helper\\HeaderCheck;"; + break; + + case 'admin.view.model': + case 'site.admin.view.model': + $headers[] = 'use Joomla\CMS\Application\CMSApplicationInterface;'; + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\Form\Form;'; + $headers[] = 'use Joomla\CMS\Filter\InputFilter;'; + $headers[] = 'use Joomla\CMS\Filter\OutputFilter;'; + $headers[] = 'use Joomla\CMS\MVC\Model\AdminModel;'; + $headers[] = 'use Joomla\CMS\MVC\Factory\MVCFactoryInterface;'; + $headers[] = 'use Joomla\CMS\Table\Table;'; + $headers[] = 'use Joomla\CMS\UCM\UCMType;'; + $headers[] = 'use Joomla\CMS\Versioning\VersionableModelTrait;'; + $headers[] = 'use Joomla\CMS\User\User;'; + $headers[] = 'use Joomla\Registry\Registry;'; + $headers[] = 'use Joomla\String\StringHelper;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + $headers[] = 'use Joomla\Input\Input;'; + break; + + case 'admin.views': + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Layout\LayoutHelper;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + break; + + case 'admin.views.controller': + case 'custom.admin.views.controller': + case 'dashboard.controller': + $headers[] = 'use Joomla\CMS\MVC\Controller\AdminController;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'use Joomla\CMS\Session\Session;'; + break; + + case 'ajax.admin.model': + case 'ajax.site.model': + $headers[] = 'use Joomla\CMS\Application\CMSApplicationInterface;'; + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Layout\LayoutHelper;'; + $headers[] = 'use Joomla\CMS\MVC\Model\ListModel;'; + $headers[] = 'use Joomla\CMS\MVC\Factory\MVCFactoryInterface;'; + $headers[] = 'use Joomla\CMS\Plugin\PluginHelper;'; + $headers[] = 'use Joomla\CMS\User\User;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + $headers[] = 'use Joomla\Input\Input;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'use Joomla\CMS\Session\Session;'; + $headers[] = 'use Joomla\CMS\Uri\Uri;'; + $headers[] = 'use Joomla\Registry\Registry;'; + break; + + case 'dashboard.model': + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Session\Session;'; + $headers[] = 'use Joomla\CMS\Uri\Uri;'; + case 'admin.views.model': + case 'custom.admin.views.model': + case 'site.views.model': + $headers[] = 'use Joomla\CMS\Application\CMSApplicationInterface;'; + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\MVC\Model\ListModel;'; + $headers[] = 'use Joomla\CMS\MVC\Factory\MVCFactoryInterface;'; + $headers[] = 'use Joomla\CMS\Plugin\PluginHelper;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'use Joomla\CMS\User\User;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + $headers[] = 'use Joomla\Input\Input;'; + break; + + case 'custom.admin.view.controller': + case 'import.controller': + case 'import.custom.controller': + $headers[] = 'use Joomla\CMS\MVC\Controller\BaseController;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'use Joomla\CMS\Session\Session;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + break; + + case 'custom.admin.view.model': + case 'site.view.model': + $headers[] = 'use Joomla\CMS\Application\CMSApplicationInterface;'; + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\MVC\Model\ItemModel;'; + $headers[] = 'use Joomla\CMS\MVC\Factory\MVCFactoryInterface;'; + $headers[] = 'use Joomla\CMS\Plugin\PluginHelper;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'use Joomla\CMS\Uri\Uri;'; + $headers[] = 'use Joomla\CMS\User\User;'; + $headers[] = 'use Joomla\Input\Input;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + + break; + case 'import.custom.model': + case 'import.model': + $headers[] = 'use Joomla\CMS\Filesystem\File;'; + $headers[] = 'use Joomla\CMS\Filesystem\Folder;'; + $headers[] = 'use Joomla\CMS\Filesystem\Path;'; + $headers[] = 'use Joomla\CMS\Filter\OutputFilter;'; + $headers[] = 'use Joomla\CMS\Installer\InstallerHelper;'; + $headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;'; + $headers[] = 'use Joomla\String\StringHelper;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + $headers[] = 'use PhpOffice\PhpSpreadsheet\IOFactory;'; + break; + + case 'dashboard.view': + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + break; + + case 'dashboard.view.html': + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;'; + $headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;'; + $headers[] = 'use Joomla\CMS\Document\Document;'; + break; + + case 'site.router': + $headers[] = 'use Joomla\CMS\Application\SiteApplication;'; + $headers[] = 'use Joomla\CMS\Categories\CategoryFactoryInterface;'; + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\Component\Router\RouterView;'; + $headers[] = 'use Joomla\CMS\Component\Router\RouterViewConfiguration;'; + $headers[] = 'use Joomla\CMS\Component\Router\Rules\MenuRules;'; + $headers[] = 'use Joomla\CMS\Component\Router\Rules\NomenuRules;'; + $headers[] = 'use Joomla\CMS\Component\Router\Rules\StandardRules;'; + $headers[] = 'use Joomla\CMS\Menu\AbstractMenu;'; + $headers[] = 'use Joomla\Database\DatabaseInterface;'; + $headers[] = 'use Joomla\Database\ParameterType;'; + $headers[] = 'use Joomla\Registry\Registry;'; + break; + + case 'site.view': + case 'site.views': + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'use Joomla\CMS\Layout\LayoutHelper;'; + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + break; + + case 'form.custom.field': + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\Form\Field\###FORM_EXTENDS###;'; + break; + + default: + break; + } + + $this->headers[$context] = $headers; + + return $headers; + } + + /** + * set Helper Dynamic Headers + * + * @param array $headers The headers array + * @param string $target_client + * + * @return void + * @since 3.2.0 + */ + protected function setHelperClassHeader(&$headers, $target_client) + { + // add only to admin client + if ('admin' === $target_client && $this->config->get('add_eximport', false)) + { + $headers[] = 'use PhpOffice\PhpSpreadsheet\IOFactory;'; + $headers[] = 'use PhpOffice\PhpSpreadsheet\Spreadsheet;'; + $headers[] = 'use PhpOffice\PhpSpreadsheet\Writer\Xlsx;'; + } + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFive/History.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFive/History.php new file mode 100644 index 000000000..1a0c2f846 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFive/History.php @@ -0,0 +1,211 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\JoomlaFive; + + +use Joomla\CMS\Factory; +use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HistoryInterface; + + +/** + * Compiler History + * + * @since 3.2.0 + */ +final class History implements HistoryInterface +{ + /** + * History Item Object + * + * @var object|null + * @since 3.2.0 + */ + protected ?object $tmp; + + /** + * Compiler Config + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * Database object to query local DB + * + * @since 3.2.0 + */ + protected $db; + + /** + * Constructor + * + * @param Config|null $config The compiler config object. + * + * @since 3.2.0 + */ + public function __construct(?Config $config = null) + { + $this->config = $config ?: Compiler::_('Config'); + $this->db = Factory::getDbo(); + } + + /** + * Get Item History object + * + * @param string $type The type of item + * @param int $id The item ID + * + * @return ?object The history + * @since 3.2.0 + */ + public function get(string $type, int $id): ?object + { + // quick class object to store old history object + $this->tmp = null; + // Create a new query object. + $query = $this->db->getQuery(true); + + $query->select('h.*'); + $query->from('#__history AS h'); + $query->where( + $this->db->quoteName('h.item_id') . ' = ' . $this->db->quote('com_componentbuilder.' . $type . '.' . (int) $id) + ); + $query->order('h.save_date DESC'); + $this->db->setQuery($query, 0, 1); + $this->db->execute(); + if ($this->db->getNumRows()) + { + // new version of this item found + // so we need to mark it as the last compiled version + $newActive = $this->db->loadObject(); + // set the new version watch + $this->set($newActive, 1); + } + // Get last compiled verion + $query = $this->db->getQuery(true); + + $query->select('h.*'); + $query->from('#__history AS h'); + $query->where( + $this->db->quoteName('h.item_id') . ' = ' . $this->db->quote('com_componentbuilder.' . $type . '.' . (int) $id) + ); + $query->where('h.keep_forever = 1'); + $query->where('h.version_note LIKE ' . $this->db->quote('%component%')); + // make sure it does not return the active version + if (isset($newActive) && isset($newActive->version_id)) + { + $query->where('h.version_id != ' . (int) $newActive->version_id); + } + $query->order('h.save_date DESC'); + $this->db->setQuery($query); + $this->db->execute(); + if ($this->db->getNumRows()) + { + // the old active version was found + // so we may need to do an SQL update + // and unmark the old compiled version + $oldActives = $this->db->loadObjectList(); + foreach ($oldActives as $oldActive) + { + // remove old version watch + $this->set($oldActive, 0); + } + } + + // return the last used history record or null. + return $this->tmp; + } + + /** + * Set Item History Watch + * + * @param Object $object The history object + * @param int $action The action to take + * 0 = remove watch + * 1 = add watch + * + * @return bool + * @since 3.2.0 + */ + protected function set(object $object, int $action): bool + { + // check the note + if (JsonHelper::check($object->version_note)) + { + $version_note = json_decode((string) $object->version_note, true); + } + else + { + $version_note = array('component' => []); + } + // set watch + switch ($action) + { + case 0: + // remove watch + if (isset($version_note['component']) + && ($key = array_search( + $this->config->component_id, $version_note['component'] + )) !== false) + { + // last version that was used to build/compile + $this->tmp = json_decode((string) $object->version_data); + // remove it from this component + unset($version_note['component'][$key]); + } + else + { + // since it was not found, no need to update anything + return true; + } + break; + case 1: + // add watch + if (!in_array($this->config->component_id, $version_note['component'])) + { + $version_note['component'][] = $this->config->component_id; + } + else + { + // since it is there already, no need to update anything + return true; + } + break; + } + // check if we need to still keep this locked + if (isset($version_note['component']) + && ArrayHelper::check($version_note['component'])) + { + // insure component ids are only added once per item + $version_note['component'] = array_unique( + $version_note['component'] + ); + // we may change this, little risky (but since JCB does not have history notes it should be okay for now) + $object->version_note = json_encode($version_note); + $object->keep_forever = '1'; + } + else + { + $object->version_note = ''; + $object->keep_forever = '0'; + } + + // run the update + return $this->db->updateObject('#__history', $object, 'version_id'); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFive/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFive/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFive/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFour/Event.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFour/Event.php new file mode 100644 index 000000000..d15c3292d --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFour/Event.php @@ -0,0 +1,100 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\JoomlaFour; + + +use Joomla\Registry\Registry; +use Joomla\CMS\Plugin\PluginHelper; +use VDM\Joomla\Utilities\Component\Helper; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface; + + +/** + * Compiler Events + * + * @since 3.2.0 + */ +final class Event implements EventInterface +{ + /** + * event plugin trigger switch + * + * @var boolean + * @since 3.2.0 + */ + protected $activePlugins = false; + + /** + * Constructor + * + * @param Registry|null $params The component parameters + * + * @since 3.2.0 + */ + public function __construct(?Registry $params = null) + { + // Set the params + $params = $params ?: Helper::getParams('com_componentbuilder'); + // get active plugins + if (($plugins = $params->get('compiler_plugin', false)) + !== false) + { + foreach ($plugins as $plugin) + { + // get possible plugins + if (PluginHelper::isEnabled('extension', $plugin)) + { + // Import the appropriate plugin group. + PluginHelper::importPlugin('extension', $plugin); + // activate events + $this->activePlugins = true; + } + } + } + } + + /** + * Trigger an event + * + * @param string $event The event to trigger + * @param mixed $data The values to pass to the event/plugin + * + * @return void + * @throws \Exception + * @since 3.2.0 + */ + public function trigger(string $event, $data = null) + { + // only execute if plugins were loaded (active) + if ($this->activePlugins) + { + // Get the dispatcher. + $dispatcher = \JEventDispatcher::getInstance(); + + // Trigger this compiler event. + $results = $dispatcher->trigger($event, $data); + + // Check for errors encountered while trigger the event + if (count((array) $results) && in_array(false, $results, true)) + { + // Get the last error. + $error = $dispatcher->getError(); + + if (!($error instanceof \Exception)) + { + throw new \Exception($error); + } + } + } + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFour/Header.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFour/Header.php new file mode 100644 index 000000000..a187c5718 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFour/Header.php @@ -0,0 +1,584 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\JoomlaFour; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Builder\UikitComp; +use VDM\Joomla\Componentbuilder\Compiler\Builder\AdminFilterType; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Category; +use VDM\Joomla\Componentbuilder\Compiler\Builder\AccessSwitchList; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Filter; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Tags; +use VDM\Joomla\Utilities\String\NamespaceHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface; + + +/** + * Build headers for all Joomla 4 files + * + * @since 3.2.0 + */ +final class Header implements HeaderInterface +{ + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The EventInterface Class. + * + * @var Event + * @since 3.2.0 + */ + protected Event $event; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 3.2.0 + */ + protected Placeholder $placeholder; + + /** + * The Language Class. + * + * @var Language + * @since 3.2.0 + */ + protected Language $language; + + /** + * The UikitComp Class. + * + * @var UikitComp + * @since 3.2.0 + */ + protected UikitComp $uikitcomp; + + /** + * The AdminFilterType Class. + * + * @var AdminFilterType + * @since 3.2.0 + */ + protected AdminFilterType $adminfiltertype; + + /** + * The Category Class. + * + * @var Category + * @since 3.2.0 + */ + protected Category $category; + + /** + * The AccessSwitchList Class. + * + * @var AccessSwitchList + * @since 3.2.0 + */ + protected AccessSwitchList $accessswitchlist; + + /** + * The Filter Class. + * + * @var Filter + * @since 3.2.0 + */ + protected Filter $filter; + + /** + * The Tags Class. + * + * @var Tags + * @since 3.2.0 + */ + protected Tags $tags; + + /** + * The Header Context array + * + * @var array + * @since 3.2.0 + */ + protected array $headers = []; + + /** + * The Namespace Prefix + * + * @var string + * @since 3.2.0 + */ + protected string $NamespacePrefix; + + /** + * The Component Name (in code) + * + * @var string + * @since 3.2.0 + */ + protected string $ComponentName; + + /** + * The Component Namespace (in code) + * + * @var string + * @since 3.2.0 + */ + protected string $ComponentNameSpace; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Event $event The EventInterface Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Language $language The Language Class. + * @param UikitComp $uikitcomp The UikitComp Class. + * @param AdminFilterType $adminfiltertype The AdminFilterType Class. + * @param Category $category The Category Class. + * @param AccessSwitchList $accessswitchlist The AccessSwitchList Class. + * @param Filter $filter The Filter Class. + * @param Tags $tags The Tags Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Event $event, Placeholder $placeholder, + Language $language, UikitComp $uikitcomp, + AdminFilterType $adminfiltertype, Category $category, + AccessSwitchList $accessswitchlist, Filter $filter, + Tags $tags) + { + $this->config = $config; + $this->event = $event; + $this->placeholder = $placeholder; + $this->language = $language; + $this->uikitcomp = $uikitcomp; + $this->adminfiltertype = $adminfiltertype; + $this->category = $category; + $this->accessswitchlist = $accessswitchlist; + $this->filter = $filter; + $this->tags = $tags; + + // set some global values + $this->NamespacePrefix = $this->config->get('namespace_prefix'); + $this->ComponentName = $this->placeholder->get('Component'); + $this->ComponentNameSpace = NamespaceHelper::safeSegment($this->ComponentName); + } + + /** + * Get the headers for a file + * + * @param string $context The name of the context + * @param string $codeName The view, views, or layout code name + * + * @return string The header string to place in the header of the file + * @since 3.2.0 + */ + public function get(string $context, string $codeName): string + { + // get static headers + $headers = $this->getHeaders($context); + + // add to all except the helper classes + if ('admin.helper' !== $context && 'site.helper' !== $context) + { + $target = 'Administrator'; + if ($this->config->get('build_target', 'admin') === 'site') + { + $target = 'Site'; + } + + $headers[] = "use {$this->NamespacePrefix}\\Component\\{$this->ComponentNameSpace}\\{$target}\\Helper\\{$this->ComponentName}Helper;"; + + // we will add more as needed + switch ($context) + { + case 'site.view.model': + case 'site.views.model': + case 'site.view.html': + case 'site.views.html': + $headers[] = "use {$this->NamespacePrefix}\\Component\\{$this->ComponentNameSpace}\\Site\\Helper\\RouteHelper;"; + break; + + default: + break; + } + } + + // get dynamic headers + switch ($context) + { + case 'admin.helper': + case 'site.helper': + $this->setHelperClassHeader($headers, $codeName); + break; + + case 'admin.view.html': + case 'admin.views.html': + case 'custom.admin.view.html': + case 'custom.admin.views.html': + case 'site.admin.view.html': + case 'site.view.html': + case 'site.views.html': + if ((2 == $this->config->uikit || 1 == $this->config->uikit) + && $this->uikitcomp->exists($codeName)) + { + $headers[] = 'use Joomla\CMS\Filesystem\File;'; + } + break; + + case 'admin.view': + case 'custom.admin.view': + case 'custom.admin.views': + case 'site.admin.view': + $headers[] = ''; + $headers[] = '/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */'; + $headers[] = '$wa = $this->getDocument()->getWebAssetManager();'; + $headers[] = '$wa->useScript(\'keepalive\')->useScript(\'form.validate\');'; + $headers[] = 'Html::_(\'bootstrap.tooltip\');'; + break; + + case 'admin.view.model': + case 'site.admin.view.model': + case 'custom.admin.view.model': + case 'site.view.model': + case 'admin.views.model': + case 'site.views.model': + $headers[] = 'use Joomla\CMS\Helper\TagsHelper;'; + break; + + default: + break; + } + + // Trigger Event: jcb_ce_setClassHeader + $this->event->trigger( + 'jcb_ce_setClassHeader', [&$context, &$codeName, &$headers] + ); + + // return the headers + return $this->placeholder->update_(implode(PHP_EOL, $headers)); + } + + /** + * Get the headers for a file + * + * @param string $context The name of the context + * + * @return array The header string to place in the header of the file + * @since 3.2.0 + */ + protected function getHeaders(string $context): array + { + if (isset($this->headers[$context])) + { + return $this->headers[$context]; + } + + // set the defaults + $headers = []; + $headers[] = 'use Joomla\CMS\Factory;'; + $headers[] = 'use Joomla\CMS\Language\Text;'; + + switch ($context) + { + case 'admin.component': + $headers[] = 'use Joomla\CMS\Access\Exception\NotAllowed;'; + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\MVC\Controller\BaseController;'; + break; + + case 'admin.helper': + case 'site.helper': + $headers[] = 'use Joomla\CMS\Access\Access;'; + $headers[] = 'use Joomla\CMS\Access\Rules as AccessRules;'; + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\Filesystem\File;'; + $headers[] = 'use Joomla\CMS\Language\Language;'; + $headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;'; + $headers[] = 'use Joomla\CMS\Object\CMSObject;'; + $headers[] = 'use Joomla\CMS\Session\Session;'; + $headers[] = 'use Joomla\CMS\Table\Table;'; + $headers[] = 'use Joomla\CMS\Uri\Uri;'; + $headers[] = 'use Joomla\CMS\Version;'; + $headers[] = 'use Joomla\Database\DatabaseInterface;'; + $headers[] = 'use Joomla\Registry\Registry;'; + $headers[] = 'use Joomla\String\StringHelper;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + break; + + case 'admin.layout': + case 'site.layout': + case 'custom.admin.layout': + case 'override.layout': + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Layout\LayoutHelper;'; + break; + + case 'admin.view': + case 'custom.admin.view': + case 'custom.admin.views': + case 'site.admin.view': + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Layout\LayoutHelper;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + break; + + case 'admin.view.controller': + $headers[] = 'use Joomla\CMS\Form\FormFactoryInterface;'; + $headers[] = 'use Joomla\CMS\Application\CMSApplication;'; + $headers[] = 'use Joomla\CMS\MVC\Factory\MVCFactoryInterface;'; + $headers[] = 'use Joomla\Input\Input;'; + case 'site.admin.view.controller': + $headers[] = 'use Joomla\CMS\Versioning\VersionableControllerTrait;'; + case 'site.view.controller': + $headers[] = 'use Joomla\CMS\MVC\Controller\FormController;'; + $headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'use Joomla\CMS\Session\Session;'; + $headers[] = 'use Joomla\CMS\Uri\Uri;'; + break; + + case 'admin.view.html': + case 'admin.views.html': + case 'site.admin.view.html': + $headers[] = 'use Joomla\CMS\Toolbar\Toolbar;'; + $headers[] = 'use Joomla\CMS\Form\FormHelper;'; + $headers[] = 'use Joomla\CMS\Session\Session;'; + $headers[] = 'use Joomla\CMS\Uri\Uri;'; + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Layout\FileLayout;'; + $headers[] = 'use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;'; + $headers[] = 'use Joomla\CMS\Plugin\PluginHelper;'; + $headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;'; + $headers[] = 'use Joomla\CMS\Document\Document;'; + break; + + case 'site.view.html': + case 'site.views.html': + $headers[] = 'use Joomla\CMS\Toolbar\Toolbar;'; + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Layout\FileLayout;'; + $headers[] = 'use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;'; + $headers[] = 'use Joomla\CMS\Plugin\PluginHelper;'; + $headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;'; + $headers[] = 'use Joomla\CMS\Document\Document;'; + $headers[] = "use {$this->NamespacePrefix}\\Component\\{$this->ComponentNameSpace}\\Site\\Helper\\HeaderCheck;"; + break; + + case 'custom.admin.view.html': + case 'custom.admin.views.html': + $target = 'Administrator'; + if ($this->config->get('build_target', 'admin') === 'site') + { + $target = 'Site'; + } + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Layout\FileLayout;'; + $headers[] = 'use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;'; + $headers[] = 'use Joomla\CMS\Plugin\PluginHelper;'; + $headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;'; + $headers[] = 'use Joomla\CMS\Document\Document;'; + $headers[] = "use {$this->NamespacePrefix}\\Component\\{$this->ComponentNameSpace}\\{$target}\\Helper\\HeaderCheck;"; + break; + + case 'admin.view.model': + case 'site.admin.view.model': + $headers[] = 'use Joomla\CMS\Application\CMSApplicationInterface;'; + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\Form\Form;'; + $headers[] = 'use Joomla\CMS\Filter\InputFilter;'; + $headers[] = 'use Joomla\CMS\Filter\OutputFilter;'; + $headers[] = 'use Joomla\CMS\MVC\Model\AdminModel;'; + $headers[] = 'use Joomla\CMS\MVC\Factory\MVCFactoryInterface;'; + $headers[] = 'use Joomla\CMS\Table\Table;'; + $headers[] = 'use Joomla\CMS\UCM\UCMType;'; + $headers[] = 'use Joomla\CMS\Versioning\VersionableModelTrait;'; + $headers[] = 'use Joomla\CMS\User\User;'; + $headers[] = 'use Joomla\Registry\Registry;'; + $headers[] = 'use Joomla\String\StringHelper;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + $headers[] = 'use Joomla\Input\Input;'; + break; + + case 'admin.views': + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Layout\LayoutHelper;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + break; + + case 'admin.views.controller': + case 'custom.admin.views.controller': + case 'dashboard.controller': + $headers[] = 'use Joomla\CMS\MVC\Controller\AdminController;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'use Joomla\CMS\Session\Session;'; + break; + + case 'ajax.admin.model': + case 'ajax.site.model': + $headers[] = 'use Joomla\CMS\Application\CMSApplicationInterface;'; + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Layout\LayoutHelper;'; + $headers[] = 'use Joomla\CMS\MVC\Model\ListModel;'; + $headers[] = 'use Joomla\CMS\MVC\Factory\MVCFactoryInterface;'; + $headers[] = 'use Joomla\CMS\Plugin\PluginHelper;'; + $headers[] = 'use Joomla\CMS\User\User;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + $headers[] = 'use Joomla\Input\Input;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'use Joomla\CMS\Session\Session;'; + $headers[] = 'use Joomla\CMS\Uri\Uri;'; + $headers[] = 'use Joomla\Registry\Registry;'; + break; + + case 'dashboard.model': + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Session\Session;'; + $headers[] = 'use Joomla\CMS\Uri\Uri;'; + case 'admin.views.model': + case 'custom.admin.views.model': + case 'site.views.model': + $headers[] = 'use Joomla\CMS\Application\CMSApplicationInterface;'; + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\MVC\Model\ListModel;'; + $headers[] = 'use Joomla\CMS\MVC\Factory\MVCFactoryInterface;'; + $headers[] = 'use Joomla\CMS\Plugin\PluginHelper;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'use Joomla\CMS\User\User;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + $headers[] = 'use Joomla\Input\Input;'; + break; + + case 'custom.admin.view.controller': + case 'import.controller': + case 'import.custom.controller': + $headers[] = 'use Joomla\CMS\MVC\Controller\BaseController;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'use Joomla\CMS\Session\Session;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + break; + + case 'custom.admin.view.model': + case 'site.view.model': + $headers[] = 'use Joomla\CMS\Application\CMSApplicationInterface;'; + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\MVC\Model\ItemModel;'; + $headers[] = 'use Joomla\CMS\MVC\Factory\MVCFactoryInterface;'; + $headers[] = 'use Joomla\CMS\Plugin\PluginHelper;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'use Joomla\CMS\Uri\Uri;'; + $headers[] = 'use Joomla\CMS\User\User;'; + $headers[] = 'use Joomla\Input\Input;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + + break; + case 'import.custom.model': + case 'import.model': + $headers[] = 'use Joomla\CMS\Filesystem\File;'; + $headers[] = 'use Joomla\CMS\Filesystem\Folder;'; + $headers[] = 'use Joomla\CMS\Filesystem\Path;'; + $headers[] = 'use Joomla\CMS\Filter\OutputFilter;'; + $headers[] = 'use Joomla\CMS\Installer\InstallerHelper;'; + $headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;'; + $headers[] = 'use Joomla\String\StringHelper;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + $headers[] = 'use PhpOffice\PhpSpreadsheet\IOFactory;'; + break; + + case 'dashboard.view': + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + break; + + case 'dashboard.view.html': + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;'; + $headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;'; + $headers[] = 'use Joomla\CMS\Document\Document;'; + break; + + case 'site.router': + $headers[] = 'use Joomla\CMS\Application\SiteApplication;'; + $headers[] = 'use Joomla\CMS\Categories\CategoryFactoryInterface;'; + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\Component\Router\RouterView;'; + $headers[] = 'use Joomla\CMS\Component\Router\RouterViewConfiguration;'; + $headers[] = 'use Joomla\CMS\Component\Router\Rules\MenuRules;'; + $headers[] = 'use Joomla\CMS\Component\Router\Rules\NomenuRules;'; + $headers[] = 'use Joomla\CMS\Component\Router\Rules\StandardRules;'; + $headers[] = 'use Joomla\CMS\Menu\AbstractMenu;'; + $headers[] = 'use Joomla\Database\DatabaseInterface;'; + $headers[] = 'use Joomla\Database\ParameterType;'; + $headers[] = 'use Joomla\Registry\Registry;'; + break; + + case 'site.view': + case 'site.views': + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'use Joomla\CMS\Layout\LayoutHelper;'; + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + break; + + case 'form.custom.field': + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\Form\Field\###FORM_EXTENDS###;'; + break; + + default: + break; + } + + $this->headers[$context] = $headers; + + return $headers; + } + + /** + * set Helper Dynamic Headers + * + * @param array $headers The headers array + * @param string $target_client + * + * @return void + * @since 3.2.0 + */ + protected function setHelperClassHeader(&$headers, $target_client) + { + // add only to admin client + if ('admin' === $target_client && $this->config->get('add_eximport', false)) + { + $headers[] = 'use PhpOffice\PhpSpreadsheet\IOFactory;'; + $headers[] = 'use PhpOffice\PhpSpreadsheet\Spreadsheet;'; + $headers[] = 'use PhpOffice\PhpSpreadsheet\Writer\Xlsx;'; + } + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFour/History.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFour/History.php new file mode 100644 index 000000000..04126729a --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFour/History.php @@ -0,0 +1,211 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\JoomlaFour; + + +use Joomla\CMS\Factory; +use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HistoryInterface; + + +/** + * Compiler History + * + * @since 3.2.0 + */ +final class History implements HistoryInterface +{ + /** + * History Item Object + * + * @var object|null + * @since 3.2.0 + */ + protected ?object $tmp; + + /** + * Compiler Config + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * Database object to query local DB + * + * @since 3.2.0 + */ + protected $db; + + /** + * Constructor + * + * @param Config|null $config The compiler config object. + * + * @since 3.2.0 + */ + public function __construct(?Config $config = null) + { + $this->config = $config ?: Compiler::_('Config'); + $this->db = Factory::getDbo(); + } + + /** + * Get Item History object + * + * @param string $type The type of item + * @param int $id The item ID + * + * @return ?object The history + * @since 3.2.0 + */ + public function get(string $type, int $id): ?object + { + // quick class object to store old history object + $this->tmp = null; + // Create a new query object. + $query = $this->db->getQuery(true); + + $query->select('h.*'); + $query->from('#__history AS h'); + $query->where( + $this->db->quoteName('h.item_id') . ' = ' . $this->db->quote('com_componentbuilder.' . $type . '.' . (int) $id) + ); + $query->order('h.save_date DESC'); + $this->db->setQuery($query, 0, 1); + $this->db->execute(); + if ($this->db->getNumRows()) + { + // new version of this item found + // so we need to mark it as the last compiled version + $newActive = $this->db->loadObject(); + // set the new version watch + $this->set($newActive, 1); + } + // Get last compiled verion + $query = $this->db->getQuery(true); + + $query->select('h.*'); + $query->from('#__history AS h'); + $query->where( + $this->db->quoteName('h.item_id') . ' = ' . $this->db->quote('com_componentbuilder.' . $type . '.' . (int) $id) + ); + $query->where('h.keep_forever = 1'); + $query->where('h.version_note LIKE ' . $this->db->quote('%component%')); + // make sure it does not return the active version + if (isset($newActive) && isset($newActive->version_id)) + { + $query->where('h.version_id != ' . (int) $newActive->version_id); + } + $query->order('h.save_date DESC'); + $this->db->setQuery($query); + $this->db->execute(); + if ($this->db->getNumRows()) + { + // the old active version was found + // so we may need to do an SQL update + // and unmark the old compiled version + $oldActives = $this->db->loadObjectList(); + foreach ($oldActives as $oldActive) + { + // remove old version watch + $this->set($oldActive, 0); + } + } + + // return the last used history record or null. + return $this->tmp; + } + + /** + * Set Item History Watch + * + * @param Object $object The history object + * @param int $action The action to take + * 0 = remove watch + * 1 = add watch + * + * @return bool + * @since 3.2.0 + */ + protected function set(object $object, int $action): bool + { + // check the note + if (JsonHelper::check($object->version_note)) + { + $version_note = json_decode((string) $object->version_note, true); + } + else + { + $version_note = array('component' => []); + } + // set watch + switch ($action) + { + case 0: + // remove watch + if (isset($version_note['component']) + && ($key = array_search( + $this->config->component_id, $version_note['component'] + )) !== false) + { + // last version that was used to build/compile + $this->tmp = json_decode((string) $object->version_data); + // remove it from this component + unset($version_note['component'][$key]); + } + else + { + // since it was not found, no need to update anything + return true; + } + break; + case 1: + // add watch + if (!in_array($this->config->component_id, $version_note['component'])) + { + $version_note['component'][] = $this->config->component_id; + } + else + { + // since it is there already, no need to update anything + return true; + } + break; + } + // check if we need to still keep this locked + if (isset($version_note['component']) + && ArrayHelper::check($version_note['component'])) + { + // insure component ids are only added once per item + $version_note['component'] = array_unique( + $version_note['component'] + ); + // we may change this, little risky (but since JCB does not have history notes it should be okay for now) + $object->version_note = json_encode($version_note); + $object->keep_forever = '1'; + } + else + { + $object->version_note = ''; + $object->keep_forever = '0'; + } + + // run the update + return $this->db->updateObject('#__history', $object, 'version_id'); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFour/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFour/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaFour/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaThree/Event.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaThree/Event.php index 6dda2dc28..e376c4796 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaThree/Event.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaThree/Event.php @@ -22,7 +22,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface; * * @since 3.2.0 */ -class Event implements EventInterface +final class Event implements EventInterface { /** * event plugin trigger switch @@ -62,7 +62,7 @@ class Event implements EventInterface } /** - * Trigger and event + * Trigger an event * * @param string $event The event to trigger * @param mixed $data The values to pass to the event/plugin @@ -71,7 +71,7 @@ class Event implements EventInterface * @throws \Exception * @since 3.2.0 */ - public function trigger(string $event, $data) + public function trigger(string $event, $data = null) { // only execute if plugins were loaded (active) if ($this->activePlugins) diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaThree/Header.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaThree/Header.php new file mode 100644 index 000000000..b48b73b88 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaThree/Header.php @@ -0,0 +1,556 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\JoomlaThree; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Builder\UikitComp; +use VDM\Joomla\Componentbuilder\Compiler\Builder\AdminFilterType; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Category; +use VDM\Joomla\Componentbuilder\Compiler\Builder\AccessSwitchList; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Filter; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Tags; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface; + + +/** + * Build headers for all Joomla 3 files + * + * @since 3.2.0 + */ +final class Header implements HeaderInterface +{ + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The EventInterface Class. + * + * @var Event + * @since 3.2.0 + */ + protected Event $event; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 3.2.0 + */ + protected Placeholder $placeholder; + + /** + * The Language Class. + * + * @var Language + * @since 3.2.0 + */ + protected Language $language; + + /** + * The UikitComp Class. + * + * @var UikitComp + * @since 3.2.0 + */ + protected UikitComp $uikitcomp; + + /** + * The AdminFilterType Class. + * + * @var AdminFilterType + * @since 3.2.0 + */ + protected AdminFilterType $adminfiltertype; + + /** + * The Category Class. + * + * @var Category + * @since 3.2.0 + */ + protected Category $category; + + /** + * The AccessSwitchList Class. + * + * @var AccessSwitchList + * @since 3.2.0 + */ + protected AccessSwitchList $accessswitchlist; + + /** + * The Filter Class. + * + * @var Filter + * @since 3.2.0 + */ + protected Filter $filter; + + /** + * The Tags Class. + * + * @var Tags + * @since 3.2.0 + */ + protected Tags $tags; + + /** + * The Header Context array + * + * @var array + * @since 3.2.0 + */ + protected array $headers = []; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Event $event The EventInterface Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Language $language The Language Class. + * @param UikitComp $uikitcomp The UikitComp Class. + * @param AdminFilterType $adminfiltertype The AdminFilterType Class. + * @param Category $category The Category Class. + * @param AccessSwitchList $accessswitchlist The AccessSwitchList Class. + * @param Filter $filter The Filter Class. + * @param Tags $tags The Tags Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Event $event, Placeholder $placeholder, + Language $language, UikitComp $uikitcomp, + AdminFilterType $adminfiltertype, Category $category, + AccessSwitchList $accessswitchlist, Filter $filter, + Tags $tags) + { + $this->config = $config; + $this->event = $event; + $this->placeholder = $placeholder; + $this->language = $language; + $this->uikitcomp = $uikitcomp; + $this->adminfiltertype = $adminfiltertype; + $this->category = $category; + $this->accessswitchlist = $accessswitchlist; + $this->filter = $filter; + $this->tags = $tags; + } + + /** + * Get the headers for a file + * + * @param string $context The name of the context + * @param string $codeName The view, views, or layout code name + * + * @return string The header string to place in the header of the file + * @since 3.2.0 + */ + public function get(string $context, string $codeName): string + { + // get static headers + $headers = $this->getHeaders($context); + + // get dynamic headers + switch ($context) + { + case 'admin.helper': + case 'site.helper': + $this->setHelperClassHeader($headers, $codeName); + break; + + case 'admin.view.html': + case 'admin.views.html': + case 'custom.admin.view.html': + case 'custom.admin.views.html': + case 'site.admin.view.html': + case 'site.view.html': + case 'site.views.html': + if ((2 == $this->config->uikit || 1 == $this->config->uikit) + && $this->uikitcomp->exists($codeName)) + { + $headers[] = 'use Joomla\CMS\Filesystem\File;'; + } + break; + + case 'admin.views': + $this->setChosenMultiSelectionHeaders($headers, $codeName); + break; + + case 'admin.view.model': + case 'site.admin.view.model': + case 'custom.admin.view.model': + case 'site.view.model': + case 'admin.views.model': + case 'site.views.model': + $headers[] = 'use Joomla\CMS\Helper\TagsHelper;'; + break; + + default: + break; + } + + // Trigger Event: jcb_ce_setClassHeader + $this->event->trigger( + 'jcb_ce_setClassHeader', [&$context, &$codeName, &$headers] + ); + + // return the headers + return $this->placeholder->update_(implode(PHP_EOL, $headers)); + } + + /** + * Get the headers for a file + * + * @param string $context The name of the context + * + * @return array The header string to place in the header of the file + * @since 3.2.0 + */ + protected function getHeaders(string $context): array + { + if (isset($this->headers[$context])) + { + return $this->headers[$context]; + } + + // set the defaults + $headers = []; + $headers[] = 'use Joomla\CMS\Factory;'; + $headers[] = 'use Joomla\CMS\Language\Text;'; + + switch ($context) + { + case 'admin.component': + $headers[] = 'use Joomla\CMS\Access\Exception\NotAllowed;'; + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\MVC\Controller\BaseController;'; + break; + + case 'admin.helper': + case 'site.helper': + $headers[] = 'use Joomla\CMS\Access\Access;'; + $headers[] = 'use Joomla\CMS\Access\Rules as AccessRules;'; + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\Filesystem\File;'; + $headers[] = 'use Joomla\CMS\Language\Language;'; + $headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;'; + $headers[] = 'use Joomla\CMS\Object\CMSObject;'; + $headers[] = 'use Joomla\CMS\Table\Table;'; + $headers[] = 'use Joomla\CMS\Uri\Uri;'; + $headers[] = 'use Joomla\CMS\Version;'; + $headers[] = 'use Joomla\Registry\Registry;'; + $headers[] = 'use Joomla\String\StringHelper;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + break; + + case 'admin.layout': + case 'site.layout': + case 'custom.admin.layout': + case 'override.layout': + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Layout\LayoutHelper;'; + break; + + case 'admin.view': + case 'custom.admin.view': + case 'custom.admin.views': + case 'site.admin.view': + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Layout\LayoutHelper;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'Html::addIncludePath(JPATH_COMPONENT.\'/helpers/html\');'; + $headers[] = 'Html::_(\'behavior.formvalidator\');'; + $headers[] = 'Html::_(\'formbehavior.chosen\', \'select\');'; + $headers[] = 'Html::_(\'behavior.keepalive\');'; + break; + + case 'admin.view.controller': + case 'site.admin.view.controller': + case 'site.view.controller': + $headers[] = 'use Joomla\CMS\MVC\Controller\FormController;'; + $headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'use Joomla\CMS\Session\Session;'; + $headers[] = 'use Joomla\CMS\Uri\Uri;'; + break; + + case 'admin.view.html': + case 'admin.views.html': + case 'site.admin.view.html': + $headers[] = 'use Joomla\CMS\Form\FormHelper;'; + $headers[] = 'use Joomla\CMS\Session\Session;'; + $headers[] = 'use Joomla\CMS\Uri\Uri;'; + case 'site.view.html': + case 'site.views.html': + $headers[] = 'use Joomla\CMS\Toolbar\Toolbar;'; + case 'custom.admin.view.html': + case 'custom.admin.views.html': + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Layout\FileLayout;'; + $headers[] = 'use Joomla\CMS\MVC\View\HtmlView;'; + $headers[] = 'use Joomla\CMS\Plugin\PluginHelper;'; + $headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;'; + break; + + case 'admin.view.model': + case 'site.admin.view.model': + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\Filter\InputFilter;'; + $headers[] = 'use Joomla\CMS\Filter\OutputFilter;'; + $headers[] = 'use Joomla\CMS\MVC\Model\AdminModel;'; + $headers[] = 'use Joomla\CMS\Table\Table;'; + $headers[] = 'use Joomla\CMS\UCM\UCMType;'; + $headers[] = 'use Joomla\Registry\Registry;'; + $headers[] = 'use Joomla\String\StringHelper;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + break; + + case 'admin.views': + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\Layout\LayoutHelper;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'Html::_(\'behavior.multiselect\');'; + $headers[] = 'Html::_(\'dropdown.init\');'; + $headers[] = 'Html::_(\'formbehavior.chosen\', \'select\');'; + break; + + case 'admin.views.controller': + case 'custom.admin.views.controller': + case 'dashboard.controller': + $headers[] = 'use Joomla\CMS\MVC\Controller\AdminController;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'use Joomla\CMS\Session\Session;'; + break; + + case 'dashboard.model': + $headers[] = 'use Joomla\CMS\Uri\Uri;'; + $headers[] = 'use Joomla\CMS\Session\Session;'; + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + case 'admin.views.model': + case 'ajax.admin.model': + case 'ajax.site.model': + case 'custom.admin.views.model': + case 'site.views.model': + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\MVC\Model\ListModel;'; + $headers[] = 'use Joomla\CMS\Plugin\PluginHelper;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + break; + + case 'custom.admin.view.controller': + case 'import.controller': + case 'import.custom.controller': + $headers[] = 'use Joomla\CMS\MVC\Controller\BaseController;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'use Joomla\CMS\Session\Session;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + break; + + case 'custom.admin.view.model': + case 'site.view.model': + $headers[] = 'use Joomla\CMS\Component\ComponentHelper;'; + $headers[] = 'use Joomla\CMS\MVC\Model\ItemModel;'; + $headers[] = 'use Joomla\CMS\Plugin\PluginHelper;'; + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'use Joomla\CMS\Uri\Uri;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + + break; + case 'import.custom.model': + case 'import.model': + $headers[] = 'use Joomla\CMS\Filesystem\File;'; + $headers[] = 'use Joomla\CMS\Filesystem\Folder;'; + $headers[] = 'use Joomla\CMS\Filesystem\Path;'; + $headers[] = 'use Joomla\CMS\Filter\OutputFilter;'; + $headers[] = 'use Joomla\CMS\Installer\InstallerHelper;'; + $headers[] = 'use Joomla\CMS\MVC\Model\BaseDatabaseModel;'; + $headers[] = 'use Joomla\String\StringHelper;'; + $headers[] = 'use Joomla\Utilities\ArrayHelper;'; + $headers[] = 'use PhpOffice\PhpSpreadsheet\IOFactory;'; + break; + + case 'dashboard.view': + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + break; + + case 'dashboard.view.html': + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\MVC\View\HtmlView;'; + $headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;'; + break; + + case 'site.component': + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = 'use Joomla\CMS\MVC\Controller\BaseController;'; + break; + + case 'site.view': + case 'site.views': + $headers[] = 'use Joomla\CMS\Router\Route;'; + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + break; + + case 'form.custom.field': + $headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;'; + $headers[] = "jimport('joomla.form.helper');"; + $headers[] = "\JFormHelper::loadFieldClass('###JFORM_extends###');"; + break; + + default: + break; + } + + $this->headers[$context] = $headers; + + return $headers; + } + + /** + * set Helper Dynamic Headers + * + * @param array $headers The headers array + * @param string $target_client + * + * @return void + * @since 3.2.0 + */ + protected function setHelperClassHeader(&$headers, $target_client) + { + // add only to admin client + if ('admin' === $target_client && $this->config->get('add_eximport', false)) + { + $headers[] = 'use PhpOffice\PhpSpreadsheet\IOFactory;'; + $headers[] = 'use PhpOffice\PhpSpreadsheet\Spreadsheet;'; + $headers[] = 'use PhpOffice\PhpSpreadsheet\Writer\Xlsx;'; + } + } + + /** + * Build chosen multi selection headers for the view + * + * @param array $headers The headers array + * @param string $nameListCode The list view name + * + * @return void + * @since 3.2.0 + */ + protected function setChosenMultiSelectionHeaders(&$headers, $nameListCode) + { + // check that the filter type is the new filter option (2 = topbar) + if ($this->adminfiltertype->get($nameListCode, 1) == 2) + { + // add category switch + $add_category = false; + if ($this->category->exists("{$nameListCode}.extension") + && $this->category->get("{$nameListCode}.filter", 0) >= 1) + { + // is found so add it + $add_category = true; + } + // add accessLevels switch + $add_access_levels = false; + if ($this->accessswitchlist->exists($nameListCode)) + { + // is found so add it + $add_access_levels = true; + } + // check if this view have filters + if ($this->filter->exists($nameListCode)) + { + foreach ($this->filter->get($nameListCode) as $filter) + { + // we need this only for filters that are multi + if (isset($filter['multi']) && $filter['multi'] == 2) + { + // if this is a category we should make sure it must be added + if (!$add_category && $filter['type'] === 'category') + { + continue; + } + elseif ($add_category && $filter['type'] === 'category') + { + // already added here so no need to add again + $add_category = false; + } + // check if this was an access field + elseif ($filter['type'] === 'accesslevel') + { + // already added here so no need to add again + $add_access_levels = false; + } + // add the header + $headers[] + = 'Html::_(\'formbehavior.chosen\', \'.multiple' + . $filter['class'] + . '\', null, [\'placeholder_text_multiple\' => \'- \' . Text::_(\'' + . $filter['lang_select'] . '\') . \' -\']);'; + } + elseif ($add_category && $filter['type'] === 'category') + { + // add the header + $headers[] + = 'Html::_(\'formbehavior.chosen\', \'.multipleCategories' + . '\', null, [\'placeholder_text_multiple\' => \'- \' . Text::_(\'' + . $filter['lang_select'] . '\') . \' -\']);'; + // already added here so no need to add again + $add_category = false; + } + } + } + // add category if not already added + if ($add_category) + { + // add the header + $headers[] + = 'Html::_(\'formbehavior.chosen\', \'.multipleCategories' + . '\', null, [\'placeholder_text_multiple\' => \'- \' . Text::_(\'' + . $this->category->exists("{$nameListCode}.name", 'error') + . '\') . \' -\']);'; + } + // add accessLevels if not already added + if ($add_access_levels) + { + // set the language strings for selection + $filter_name_select = 'Select Access'; + $filter_name_select_lang = $this->config->lang_prefix . '_FILTER_' + . StringHelper::safe( + $filter_name_select, 'U' + ); + // and to translation + $this->language->set( + $this->config->lang_target, $filter_name_select_lang, $filter_name_select + ); + // add the header + $headers[] + = 'Html::_(\'formbehavior.chosen\', \'.multipleAccessLevels' + . '\', null, [\'placeholder_text_multiple\' => \'- \' . Text::_(\'' + . $filter_name_select_lang . '\') . \' -\']);'; + } + } + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaThree/History.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaThree/History.php index 2cfe3f84e..c94a42730 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaThree/History.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/JoomlaThree/History.php @@ -25,7 +25,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HistoryInterface; * * @since 3.2.0 */ -class History implements HistoryInterface +final class History implements HistoryInterface { /** * History Item Object @@ -46,23 +46,21 @@ class History implements HistoryInterface /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 */ - protected \JDatabaseDriver $db; + protected $db; /** * Constructor * - * @param Config|null $config The compiler config object. - * @param \JDatabaseDriver|null $db The Database Driver object. + * @param Config|null $config The compiler config object. * * @since 3.2.0 */ - public function __construct(?Config $config = null, ?\JDatabaseDriver $db = null) + public function __construct(?Config $config = null) { $this->config = $config ?: Compiler::_('Config'); - $this->db = $db ?: Factory::getDbo(); + $this->db = Factory::getDbo(); } /** diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Joomlamodule/Data.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Joomlamodule/Data.php index 66e329dd4..19197bb2e 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Joomlamodule/Data.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Joomlamodule/Data.php @@ -135,6 +135,13 @@ class Data */ protected Templatelayout $templatelayout; + /** + * The Database Class. + * + * @since 3.2.0 + */ + protected $db; + /** * Constructor. * @@ -149,7 +156,6 @@ class Data * @param Libraries $libraries The Libraries Class. * @param Dynamicget $dynamicget The Data Class. * @param Templatelayout $templatelayout The Data Class. - * @param \JDatabaseDriver|null $db The database object. * * @since 3.2.0 */ @@ -157,8 +163,7 @@ class Data Placeholder $placeholder, Language $language, Field $field, Fieldname $fieldname, Filesfolders $filesfolders, Libraries $libraries, - Dynamicget $dynamicget, Templatelayout $templatelayout, - ?\JDatabaseDriver $db = null) + Dynamicget $dynamicget, Templatelayout $templatelayout) { $this->config = $config; $this->customcode = $customcode; @@ -171,7 +176,7 @@ class Data $this->libraries = $libraries; $this->dynamicget = $dynamicget; $this->templatelayout = $templatelayout; - $this->db = $db ?: Factory::getDbo(); + $this->db = Factory::getDbo(); } /** diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Joomlamodule/Structure.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Joomlamodule/Structure.php index 8379e6e32..7ccbfb973 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Joomlamodule/Structure.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Joomlamodule/Structure.php @@ -716,8 +716,8 @@ class Structure $bucket[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Custom CSS"; $bucket[] = Indent::_(2) - . "\$document->addStyleSheet('" . $targetPath - . "/modules/" . $module->folder_name + . "Html::_('stylesheet', " + . "modules/" . $module->folder_name . "/css/mod_admin.css', ['version' => 'auto', 'relative' => true]);"; } } @@ -771,7 +771,7 @@ class Structure $bucket[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Custom JS"; $bucket[] = Indent::_(2) - . "\$document->addScript('" . $targetPath + . "Html::_('script', " . "/modules/" . $module->folder_name . "/js/mod_admin.js', ['version' => 'auto', 'relative' => true]);"; } @@ -839,14 +839,30 @@ class Structure if ($add_component_path) { $xml .= PHP_EOL . 'config->get('joomla_version', 3) == 3) + { + $xml .= PHP_EOL . Indent::_(1) + . 'addrulepath="/administrator/components/com_' + . $this->config->component_code_name + . '/models/rules"'; + $xml .= PHP_EOL . Indent::_(1) + . 'addfieldpath="/administrator/components/com_' + . $this->config->component_code_name + . '/models/fields"'; + } + else + { + $xml .= PHP_EOL . Indent::_(1) + . 'addruleprefix="' . $this->config->namespace_prefix + . '\Component\\' . StringHelper::safe($this->config->component_code_name, 'F') + . '\Administrator\Rule"'; + $xml .= PHP_EOL . Indent::_(1) + .'addfieldprefix="' . $this->config->namespace_prefix + . '\Component\\' . StringHelper::safe($this->config->component_code_name, 'F') + . '\Administrator\Field"'; + } + $xml .= PHP_EOL . '>'; } else diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Joomlaplugin/Data.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Joomlaplugin/Data.php index 91e47dba9..a328bd7da 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Joomlaplugin/Data.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Joomlaplugin/Data.php @@ -113,10 +113,9 @@ class Data /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 **/ - protected \JDatabaseDriver $db; + protected $db; /** * Constructor @@ -129,14 +128,13 @@ class Data * @param Field|null $field The compiler field data object. * @param FieldName|null $fieldName The compiler field name object. * @param Filesfolders|null $filesFolders The compiler files folders object. - * @param \JDatabaseDriver|null $db The database object. * * @since 3.2.0 */ public function __construct(?Config $config = null, ?Customcode $customcode = null, ?Gui $gui = null, ?Placeholder $placeholder = null, ?Language $language = null, ?Field $field = null, ?FieldName $fieldName = null, - ?Filesfolders $filesFolders = null, ?\JDatabaseDriver $db = null) + ?Filesfolders $filesFolders = null) { $this->config = $config ?: Compiler::_('Config'); $this->customcode = $customcode ?: Compiler::_('Customcode'); @@ -146,7 +144,7 @@ class Data $this->field = $field ?: Compiler::_('Field'); $this->fieldName = $fieldName ?: Compiler::_('Field.Name'); $this->filesFolders = $filesFolders ?: Compiler::_('Model.Filesfolders'); - $this->db = $db ?: Factory::getDbo(); + $this->db = Factory::getDbo(); } /** diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Joomlaplugin/Structure.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Joomlaplugin/Structure.php index 0ef09749f..99e2bde04 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Joomlaplugin/Structure.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Joomlaplugin/Structure.php @@ -325,7 +325,7 @@ class Structure * @return void * @since 3.2.0 */ - protected function setMainXmlFile(mixed $plugin): void + protected function setMainXmlFile(object $plugin): void { $file_details = [ 'path' => $plugin->folder_path . '/' . $plugin->file_name . '.xml', @@ -459,14 +459,30 @@ class Structure if ($add_component_path) { $xml .= PHP_EOL . 'config->get('joomla_version', 3) == 3) + { + $xml .= PHP_EOL . Indent::_(1) + . 'addrulepath="/administrator/components/com_' + . $this->config->component_code_name + . '/models/rules"'; + $xml .= PHP_EOL . Indent::_(1) + . 'addfieldpath="/administrator/components/com_' + . $this->config->component_code_name + . '/models/fields"'; + } + else + { + $xml .= PHP_EOL . Indent::_(1) + . 'addruleprefix="' . $this->config->namespace_prefix + . '\Component\\' . StringHelper::safe($this->config->component_code_name, 'F') + . '\Administrator\Rule"'; + $xml .= PHP_EOL . Indent::_(1) + .'addfieldprefix="' . $this->config->namespace_prefix + . '\Component\\' . StringHelper::safe($this->config->component_code_name, 'F') + . '\Administrator\Field"'; + } + $xml .= PHP_EOL . '>'; } else diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Language.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Language.php index 8370943a1..73011bbe4 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Language.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Language.php @@ -65,16 +65,13 @@ class Language implements LanguageInterface public function key($string): string { // this is there to insure we don't break already added Language strings - if (StringHelper::safe($string, 'U', '_', false, false) - === $string) + if (StringHelper::safe($string, 'U', '_', false, false) === $string) { return false; } // build language key - $key_lang = $this->config->lang_prefix . '_' . StringHelper::safe( - $string, 'U' - ); + $key_lang = $this->config->lang_prefix . '_' . StringHelper::safe($string, 'U'); // set the language string $this->set($this->config->lang_target, $key_lang, $string); @@ -97,7 +94,7 @@ class Language implements LanguageInterface { return isset($this->content[$target][$language]); } - + return isset($this->content[$target]); } @@ -165,38 +162,42 @@ class Language implements LanguageInterface */ public function set(string $target, string $language, string $string, bool $addPrefix = false) { - if ($addPrefix && empty( - $this->content[$target][$this->config->lang_prefix . '_' . $language] - )) + if ($addPrefix && empty($this->content[$target][$this->config->lang_prefix . '_' . $language])) { $this->content[$target][$this->config->lang_prefix . '_' . $language] = $this->fix($string); } elseif (empty($this->content[$target][$language])) { - $this->content[$target][$language] = $this->fix( - $string - ); + $this->content[$target][$language] = $this->fix($string); } } /** - * We need to remove all text breaks from all language strings + * Removes all types of line breaks from a given string. * - * @param string $string The language string + * This method is designed to strip out all kinds of new line characters from the input string + * to ensure a single-line output. It takes into consideration different operating systems' + * line endings, including the combination of Carriage Return and Line Feed. * - * @return string + * @param string $string The input string possibly containing line breaks. + * + * @return string The modified string with all line breaks removed. * @since 3.2.0 */ - protected function fix(string $string): string + public function fix(string $string): string { if ($this->config->remove_line_breaks) { - return trim(str_replace(array(PHP_EOL, "\r", "\n"), '', $string)); + // Using a single str_replace call to handle all variations of line breaks. + // The array includes \r\n (CR+LF used in Windows), \n (LF used in Unix/Linux), + // and \r (CR used in old Macs) to cover all bases. + $search = [PHP_EOL, "\r\n", "\n", "\r"]; + $string = str_replace($search, '', $string); } + // Trim the string to remove any leading or trailing whitespace. return trim($string); - } - + } } diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Language/Extractor.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Language/Extractor.php index 567e9afb8..7ade0652c 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Language/Extractor.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Language/Extractor.php @@ -118,7 +118,7 @@ class Extractor $js_text = []; $sc_text = []; // first get the Joomla .JText._() - if (in_array('Joomla' . '.JText._(', $lang_string_targets)) + if (in_array('Joomla' . '.JText._(', $lang_string_targets) || in_array('Joomla' . '.Text._(', $lang_string_targets)) { $js_text[] = GetHelper::allBetween( $content, "Joomla" . ".JText._('", "'" @@ -126,6 +126,12 @@ class Extractor $js_text[] = GetHelper::allBetween( $content, 'Joomla' . '.JText._("', '"' ); + $js_text[] = GetHelper::allBetween( + $content, "Joomla" . ".Text._('", "'" + ); + $js_text[] = GetHelper::allBetween( + $content, 'Joomla' . '.Text._("', '"' + ); // combine into one array $js_text = ArrayHelper::merge($js_text); // we need to add a check to insure these JavaScript lang matchup @@ -141,7 +147,7 @@ class Extractor } } // now get the JText: :script() - if (in_array('JText:' . ':script(', $lang_string_targets)) + if (in_array('JText:' . ':script(', $lang_string_targets) || in_array('Text:' . ':script(', $lang_string_targets)) { $sc_text[] = GetHelper::allBetween( $content, "JText:" . ":script('", "'" @@ -149,6 +155,12 @@ class Extractor $sc_text[] = GetHelper::allBetween( $content, 'JText:' . ':script("', '"' ); + $sc_text[] = GetHelper::allBetween( + $content, "Text:" . ":script('", "'" + ); + $sc_text[] = GetHelper::allBetween( + $content, 'Text:' . ':script("', '"' + ); // combine into one array $sc_text = ArrayHelper::merge($sc_text); // we need to add a check to insure these JavaScript lang matchup @@ -179,6 +191,7 @@ class Extractor // need some special treatment here if ($lang_string_target === 'Joomla' . '.JText._(' || $lang_string_target === 'JText:' . ':script(' + || $lang_string_target === 'Text:' . ':script(' || $lang_string_target === 'JustTEXT:' . ':_(') { continue; diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Language/Fieldset.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Language/Fieldset.php index 883d75e65..ce42c5a67 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Language/Fieldset.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Language/Fieldset.php @@ -211,6 +211,11 @@ class Fieldset "Another " . $nameSingle . " has the same alias." ); + $this->language->set( + $langTarget, $langView . '_ERROR_UNIQUE_ALIAS_TRASHED', + "A trashed " . $nameSingle + . " has the same alias ." + ); $this->language->set( $langTarget, $langView . '_CREATED_DATE_LABEL', "Created Date" ); diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Library/Data.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Library/Data.php index ab2710160..3cde60fea 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Library/Data.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Library/Data.php @@ -83,10 +83,9 @@ class Data /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 **/ - protected \JDatabaseDriver $db; + protected $db; /** * Constructor @@ -97,14 +96,12 @@ class Data * @param Gui|null $gui The compiler customcode gui. * @param FieldData|null $field The compiler field data object. * @param Filesfolders|null $filesFolders The compiler files folders object. - * @param \JDatabaseDriver|null $db The database object. * * @since 3.2.0 */ public function __construct(?Config $config = null, ?Registry $registry = null, ?Customcode $customcode = null, ?Gui $gui = null, - ?FieldData $field = null, ?Filesfolders $filesFolders = null, - ?\JDatabaseDriver $db = null) + ?FieldData $field = null, ?Filesfolders $filesFolders = null) { $this->config = $config ?: Compiler::_('Config'); $this->registry = $registry ?: Compiler::_('Registry'); @@ -112,7 +109,7 @@ class Data $this->gui = $gui ?: Compiler::_('Customcode.Gui'); $this->field = $field ?: Compiler::_('Field.Data'); $this->filesFolders = $filesFolders ?: Compiler::_('Model.Filesfolders'); - $this->db = $db ?: Factory::getDbo(); + $this->db = Factory::getDbo(); } /** diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/Customtabs.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/Customtabs.php deleted file mode 100644 index 00fecb922..000000000 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/Customtabs.php +++ /dev/null @@ -1,239 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -namespace VDM\Joomla\Componentbuilder\Compiler\Model; - - -use VDM\Joomla\Componentbuilder\Compiler\Config; -use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomTabs as BuilderCustomTabs; -use VDM\Joomla\Componentbuilder\Compiler\Language; -use VDM\Joomla\Componentbuilder\Compiler\Placeholder; -use VDM\Joomla\Componentbuilder\Compiler\Customcode; -use VDM\Joomla\Utilities\JsonHelper; -use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\StringHelper; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; - - -/** - * Model Custom Tabs Class - * - * @since 3.2.0 - */ -class Customtabs -{ - /** - * The Config Class. - * - * @var Config - * @since 3.2.0 - */ - protected Config $config; - - /** - * The CustomTabs Class. - * - * @var BuilderCustomTabs - * @since 3.2.0 - */ - protected BuilderCustomTabs $buildercustomtabs; - - /** - * The Language Class. - * - * @var Language - * @since 3.2.0 - */ - protected Language $language; - - /** - * The Placeholder Class. - * - * @var Placeholder - * @since 3.2.0 - */ - protected Placeholder $placeholder; - - /** - * The Customcode Class. - * - * @var Customcode - * @since 3.2.0 - */ - protected Customcode $customcode; - - /** - * Constructor. - * - * @param Config $config The Config Class. - * @param BuilderCustomTabs $buildercustomtabs The CustomTabs Class. - * @param Language $language The Language Class. - * @param Placeholder $placeholder The Placeholder Class. - * @param Customcode $customcode The Customcode Class. - * - * @since 3.2.0 - */ - public function __construct(Config $config, BuilderCustomTabs $buildercustomtabs, Language $language, Placeholder $placeholder, Customcode $customcode) - { - $this->config = $config; - $this->buildercustomtabs = $buildercustomtabs; - $this->language = $language; - $this->placeholder = $placeholder; - $this->customcode = $customcode; - } - - /** - * Set custom tabs - * - * @param object $item The view data - * - * @return void - * @since 3.2.0 - */ - public function set(object &$item) - { - $item->customtabs = (isset($item->customtabs) - && JsonHelper::check($item->customtabs)) - ? json_decode((string) $item->customtabs, true) : null; - - if (ArrayHelper::check($item->customtabs)) - { - // get the name - $name = $item->name_single_code; - - // setup custom tabs to global data sets - $this->buildercustomtabs->set($name, - array_map( - function ($tab) use (&$name) { - - // set the view name - $tab['view'] = $name; - - // load the dynamic data - $tab['html'] = $this->placeholder->update_( - $this->customcode->update($tab['html']) - ); - - // set the tab name - $tab['name'] = (isset($tab['name']) - && StringHelper::check( - $tab['name'] - )) ? $tab['name'] : 'Tab'; - - // set lang - $tab['lang'] = $this->config->lang_prefix . '_' - . StringHelper::safe( - $tab['view'], 'U' - ) . '_' . StringHelper::safe( - $tab['name'], 'U' - ); - $this->language->set( - 'both', $tab['lang'], $tab['name'] - ); - - // set code name - $tab['code'] = StringHelper::safe( - $tab['name'] - ); - - // check if the permissions for the tab should be added - $_tab = ''; - if (isset($tab['permission']) - && $tab['permission'] == 1) - { - $_tab = Indent::_(1); - } - - // check if the php of the tab is set, if not load it now - if (strpos((string) $tab['html'], 'bootstrap.addTab') === false - && strpos((string) $tab['html'], 'bootstrap.endTab') - === false) - { - // add the tab - $tmp = PHP_EOL . $_tab . Indent::_(1) - . ""; - $tmp .= PHP_EOL . $_tab . Indent::_(2) - . '
    '; - $tmp .= PHP_EOL . $_tab . Indent::_(3) - . '
    '; - $tmp .= PHP_EOL . $_tab . Indent::_(4) . implode( - PHP_EOL . $_tab . Indent::_(4), - (array) explode(PHP_EOL, trim((string) $tab['html'])) - ); - $tmp .= PHP_EOL . $_tab . Indent::_(3) . '
    '; - $tmp .= PHP_EOL . $_tab . Indent::_(2) . '
    '; - $tmp .= PHP_EOL . $_tab . Indent::_(1) - . ""; - - // update html - $tab['html'] = $tmp; - } - else - { - $tab['html'] = PHP_EOL . $_tab . Indent::_(1) - . implode( - PHP_EOL . $_tab . Indent::_(1), - (array) explode(PHP_EOL, trim((string) $tab['html'])) - ); - } - - // add the permissions if needed - if (isset($tab['permission']) - && $tab['permission'] == 1) - { - $tmp = PHP_EOL . Indent::_(1) - . "canDo->get('" - . $tab['view'] . "." . $tab['code'] - . ".viewtab')) : ?>"; - $tmp .= $tab['html']; - $tmp .= PHP_EOL . Indent::_(1) . ""; - // update html - $tab['html'] = $tmp; - // set lang for permissions - $tab['lang_permission'] = $tab['lang'] - . '_TAB_PERMISSION'; - $tab['lang_permission_desc'] = $tab['lang'] - . '_TAB_PERMISSION_DESC'; - $tab['lang_permission_title'] - = $this->placeholder->get('Views') . ' View ' - . $tab['name'] . ' Tab'; - $this->language->set( - 'both', $tab['lang_permission'], - $tab['lang_permission_title'] - ); - $this->language->set( - 'both', $tab['lang_permission_desc'], - 'Allow the users in this group to view ' - . $tab['name'] . ' Tab of ' - . $this->placeholder->get('views') - ); - // set the sort key - $tab['sortKey'] - = StringHelper::safe( - $tab['lang_permission_title'] - ); - } - - // return tab - return $tab; - - }, array_values($item->customtabs) - ) - ); - } - - unset($item->customtabs); - } -} - diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/Historycomponent.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/Historycomponent.php index dca3671c8..37bdb9a03 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/Historycomponent.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/Historycomponent.php @@ -96,9 +96,13 @@ class Historycomponent */ private function setAdminView(object $item) { - $old_admin_views = $this->history->get( - 'component_admin_views', $item->addadmin_views_id - ); + $old_admin_views = null; + if (isset($item->addadmin_views_id)) + { + $old_admin_views = $this->history->get( + 'component_admin_views', $item->addadmin_views_id + ); + } // add new views if found if ($old_admin_views && ObjectHelper::check($old_admin_views)) @@ -126,15 +130,19 @@ class Historycomponent */ private function setComponent(object &$item) { - $old_component = $this->history->get( - 'joomla_component', $this->config->component_id - ); + $old_component = null; + if (isset($this->config->component_id)) + { + $old_component = $this->history->get( + 'joomla_component', $this->config->component_id + ); + } // check if a new version was manually set if ($old_component && ObjectHelper::check($old_component)) { $old_component_version = preg_replace( - '/[^0-9.]+/', '', (string) $old_component->component_version + '/^v/i', '', (string) $old_component->component_version ); if ($old_component_version != $this->config->component_version) { diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaFive/Customtabs.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaFive/Customtabs.php new file mode 100644 index 000000000..3a70beaa6 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaFive/Customtabs.php @@ -0,0 +1,240 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Model\JoomlaFive; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomTabs as BuilderCustomTabs; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Customcode; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Model\CustomtabsInterface; + + +/** + * Model Custom Tabs Class + * + * @since 3.2.0 + */ +final class Customtabs implements CustomtabsInterface +{ + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The CustomTabs Class. + * + * @var BuilderCustomTabs + * @since 3.2.0 + */ + protected BuilderCustomTabs $buildercustomtabs; + + /** + * The Language Class. + * + * @var Language + * @since 3.2.0 + */ + protected Language $language; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 3.2.0 + */ + protected Placeholder $placeholder; + + /** + * The Customcode Class. + * + * @var Customcode + * @since 3.2.0 + */ + protected Customcode $customcode; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param BuilderCustomTabs $buildercustomtabs The CustomTabs Class. + * @param Language $language The Language Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Customcode $customcode The Customcode Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, BuilderCustomTabs $buildercustomtabs, Language $language, Placeholder $placeholder, Customcode $customcode) + { + $this->config = $config; + $this->buildercustomtabs = $buildercustomtabs; + $this->language = $language; + $this->placeholder = $placeholder; + $this->customcode = $customcode; + } + + /** + * Set custom tabs + * + * @param object $item The view data + * + * @return void + * @since 3.2.0 + */ + public function set(object &$item) + { + $item->customtabs = (isset($item->customtabs) + && JsonHelper::check($item->customtabs)) + ? json_decode((string) $item->customtabs, true) : null; + + if (ArrayHelper::check($item->customtabs)) + { + // get the name + $name = $item->name_single_code; + + // setup custom tabs to global data sets + $this->buildercustomtabs->set($name, + array_map( + function ($tab) use (&$name) { + + // set the view name + $tab['view'] = $name; + + // load the dynamic data + $tab['html'] = $this->placeholder->update_( + $this->customcode->update($tab['html']) + ); + + // set the tab name + $tab['name'] = (isset($tab['name']) + && StringHelper::check( + $tab['name'] + )) ? $tab['name'] : 'Tab'; + + // set lang + $tab['lang'] = $this->config->lang_prefix . '_' + . StringHelper::safe( + $tab['view'], 'U' + ) . '_' . StringHelper::safe( + $tab['name'], 'U' + ); + $this->language->set( + 'both', $tab['lang'], $tab['name'] + ); + + // set code name + $tab['code'] = StringHelper::safe( + $tab['name'] + ); + + // check if the permissions for the tab should be added + $_tab = ''; + if (isset($tab['permission']) + && $tab['permission'] == 1) + { + $_tab = Indent::_(1); + } + + // check if the php of the tab is set, if not load it now + if (strpos((string) $tab['html'], 'uitab.addTab') === false + && strpos((string) $tab['html'], 'uitab.endTab') + === false) + { + // add the tab + $tmp = PHP_EOL . $_tab . Indent::_(1) + . ""; + $tmp .= PHP_EOL . $_tab . Indent::_(2) + . '
    '; + $tmp .= PHP_EOL . $_tab . Indent::_(3) + . '
    '; + $tmp .= PHP_EOL . $_tab . Indent::_(4) . implode( + PHP_EOL . $_tab . Indent::_(4), + (array) explode(PHP_EOL, trim((string) $tab['html'])) + ); + $tmp .= PHP_EOL . $_tab . Indent::_(3) . '
    '; + $tmp .= PHP_EOL . $_tab . Indent::_(2) . '
    '; + $tmp .= PHP_EOL . $_tab . Indent::_(1) + . ""; + + // update html + $tab['html'] = $tmp; + } + else + { + $tab['html'] = PHP_EOL . $_tab . Indent::_(1) + . implode( + PHP_EOL . $_tab . Indent::_(1), + (array) explode(PHP_EOL, trim((string) $tab['html'])) + ); + } + + // add the permissions if needed + if (isset($tab['permission']) + && $tab['permission'] == 1) + { + $tmp = PHP_EOL . Indent::_(1) + . "canDo->get('" + . $tab['view'] . "." . $tab['code'] + . ".viewtab')) : ?>"; + $tmp .= $tab['html']; + $tmp .= PHP_EOL . Indent::_(1) . ""; + // update html + $tab['html'] = $tmp; + // set lang for permissions + $tab['lang_permission'] = $tab['lang'] + . '_TAB_PERMISSION'; + $tab['lang_permission_desc'] = $tab['lang'] + . '_TAB_PERMISSION_DESC'; + $tab['lang_permission_title'] + = $this->placeholder->get('Views') . ' View ' + . $tab['name'] . ' Tab'; + $this->language->set( + 'both', $tab['lang_permission'], + $tab['lang_permission_title'] + ); + $this->language->set( + 'both', $tab['lang_permission_desc'], + 'Allow the users in this group to view ' + . $tab['name'] . ' Tab of ' + . $this->placeholder->get('views') + ); + // set the sort key + $tab['sortKey'] + = StringHelper::safe( + $tab['lang_permission_title'] + ); + } + + // return tab + return $tab; + + }, array_values($item->customtabs) + ) + ); + } + + unset($item->customtabs); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaFive/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaFive/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaFive/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaFour/Customtabs.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaFour/Customtabs.php new file mode 100644 index 000000000..efa0e74a1 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaFour/Customtabs.php @@ -0,0 +1,240 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Model\JoomlaFour; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomTabs as BuilderCustomTabs; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Customcode; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Model\CustomtabsInterface; + + +/** + * Model Custom Tabs Class + * + * @since 3.2.0 + */ +final class Customtabs implements CustomtabsInterface +{ + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The CustomTabs Class. + * + * @var BuilderCustomTabs + * @since 3.2.0 + */ + protected BuilderCustomTabs $buildercustomtabs; + + /** + * The Language Class. + * + * @var Language + * @since 3.2.0 + */ + protected Language $language; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 3.2.0 + */ + protected Placeholder $placeholder; + + /** + * The Customcode Class. + * + * @var Customcode + * @since 3.2.0 + */ + protected Customcode $customcode; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param BuilderCustomTabs $buildercustomtabs The CustomTabs Class. + * @param Language $language The Language Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Customcode $customcode The Customcode Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, BuilderCustomTabs $buildercustomtabs, Language $language, Placeholder $placeholder, Customcode $customcode) + { + $this->config = $config; + $this->buildercustomtabs = $buildercustomtabs; + $this->language = $language; + $this->placeholder = $placeholder; + $this->customcode = $customcode; + } + + /** + * Set custom tabs + * + * @param object $item The view data + * + * @return void + * @since 3.2.0 + */ + public function set(object &$item) + { + $item->customtabs = (isset($item->customtabs) + && JsonHelper::check($item->customtabs)) + ? json_decode((string) $item->customtabs, true) : null; + + if (ArrayHelper::check($item->customtabs)) + { + // get the name + $name = $item->name_single_code; + + // setup custom tabs to global data sets + $this->buildercustomtabs->set($name, + array_map( + function ($tab) use (&$name) { + + // set the view name + $tab['view'] = $name; + + // load the dynamic data + $tab['html'] = $this->placeholder->update_( + $this->customcode->update($tab['html']) + ); + + // set the tab name + $tab['name'] = (isset($tab['name']) + && StringHelper::check( + $tab['name'] + )) ? $tab['name'] : 'Tab'; + + // set lang + $tab['lang'] = $this->config->lang_prefix . '_' + . StringHelper::safe( + $tab['view'], 'U' + ) . '_' . StringHelper::safe( + $tab['name'], 'U' + ); + $this->language->set( + 'both', $tab['lang'], $tab['name'] + ); + + // set code name + $tab['code'] = StringHelper::safe( + $tab['name'] + ); + + // check if the permissions for the tab should be added + $_tab = ''; + if (isset($tab['permission']) + && $tab['permission'] == 1) + { + $_tab = Indent::_(1); + } + + // check if the php of the tab is set, if not load it now + if (strpos((string) $tab['html'], 'uitab.addTab') === false + && strpos((string) $tab['html'], 'uitab.endTab') + === false) + { + // add the tab + $tmp = PHP_EOL . $_tab . Indent::_(1) + . ""; + $tmp .= PHP_EOL . $_tab . Indent::_(2) + . '
    '; + $tmp .= PHP_EOL . $_tab . Indent::_(3) + . '
    '; + $tmp .= PHP_EOL . $_tab . Indent::_(4) . implode( + PHP_EOL . $_tab . Indent::_(4), + (array) explode(PHP_EOL, trim((string) $tab['html'])) + ); + $tmp .= PHP_EOL . $_tab . Indent::_(3) . '
    '; + $tmp .= PHP_EOL . $_tab . Indent::_(2) . '
    '; + $tmp .= PHP_EOL . $_tab . Indent::_(1) + . ""; + + // update html + $tab['html'] = $tmp; + } + else + { + $tab['html'] = PHP_EOL . $_tab . Indent::_(1) + . implode( + PHP_EOL . $_tab . Indent::_(1), + (array) explode(PHP_EOL, trim((string) $tab['html'])) + ); + } + + // add the permissions if needed + if (isset($tab['permission']) + && $tab['permission'] == 1) + { + $tmp = PHP_EOL . Indent::_(1) + . "canDo->get('" + . $tab['view'] . "." . $tab['code'] + . ".viewtab')) : ?>"; + $tmp .= $tab['html']; + $tmp .= PHP_EOL . Indent::_(1) . ""; + // update html + $tab['html'] = $tmp; + // set lang for permissions + $tab['lang_permission'] = $tab['lang'] + . '_TAB_PERMISSION'; + $tab['lang_permission_desc'] = $tab['lang'] + . '_TAB_PERMISSION_DESC'; + $tab['lang_permission_title'] + = $this->placeholder->get('Views') . ' View ' + . $tab['name'] . ' Tab'; + $this->language->set( + 'both', $tab['lang_permission'], + $tab['lang_permission_title'] + ); + $this->language->set( + 'both', $tab['lang_permission_desc'], + 'Allow the users in this group to view ' + . $tab['name'] . ' Tab of ' + . $this->placeholder->get('views') + ); + // set the sort key + $tab['sortKey'] + = StringHelper::safe( + $tab['lang_permission_title'] + ); + } + + // return tab + return $tab; + + }, array_values($item->customtabs) + ) + ); + } + + unset($item->customtabs); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaFour/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaFour/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaFour/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaThree/Customtabs.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaThree/Customtabs.php new file mode 100644 index 000000000..d49e42274 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaThree/Customtabs.php @@ -0,0 +1,240 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Model\JoomlaThree; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomTabs as BuilderCustomTabs; +use VDM\Joomla\Componentbuilder\Compiler\Language; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Customcode; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Model\CustomtabsInterface; + + +/** + * Model Custom Tabs Class + * + * @since 3.2.0 + */ +final class Customtabs implements CustomtabsInterface +{ + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The CustomTabs Class. + * + * @var BuilderCustomTabs + * @since 3.2.0 + */ + protected BuilderCustomTabs $buildercustomtabs; + + /** + * The Language Class. + * + * @var Language + * @since 3.2.0 + */ + protected Language $language; + + /** + * The Placeholder Class. + * + * @var Placeholder + * @since 3.2.0 + */ + protected Placeholder $placeholder; + + /** + * The Customcode Class. + * + * @var Customcode + * @since 3.2.0 + */ + protected Customcode $customcode; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param BuilderCustomTabs $buildercustomtabs The CustomTabs Class. + * @param Language $language The Language Class. + * @param Placeholder $placeholder The Placeholder Class. + * @param Customcode $customcode The Customcode Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, BuilderCustomTabs $buildercustomtabs, Language $language, Placeholder $placeholder, Customcode $customcode) + { + $this->config = $config; + $this->buildercustomtabs = $buildercustomtabs; + $this->language = $language; + $this->placeholder = $placeholder; + $this->customcode = $customcode; + } + + /** + * Set custom tabs + * + * @param object $item The view data + * + * @return void + * @since 3.2.0 + */ + public function set(object &$item) + { + $item->customtabs = (isset($item->customtabs) + && JsonHelper::check($item->customtabs)) + ? json_decode((string) $item->customtabs, true) : null; + + if (ArrayHelper::check($item->customtabs)) + { + // get the name + $name = $item->name_single_code; + + // setup custom tabs to global data sets + $this->buildercustomtabs->set($name, + array_map( + function ($tab) use (&$name) { + + // set the view name + $tab['view'] = $name; + + // load the dynamic data + $tab['html'] = $this->placeholder->update_( + $this->customcode->update($tab['html']) + ); + + // set the tab name + $tab['name'] = (isset($tab['name']) + && StringHelper::check( + $tab['name'] + )) ? $tab['name'] : 'Tab'; + + // set lang + $tab['lang'] = $this->config->lang_prefix . '_' + . StringHelper::safe( + $tab['view'], 'U' + ) . '_' . StringHelper::safe( + $tab['name'], 'U' + ); + $this->language->set( + 'both', $tab['lang'], $tab['name'] + ); + + // set code name + $tab['code'] = StringHelper::safe( + $tab['name'] + ); + + // check if the permissions for the tab should be added + $_tab = ''; + if (isset($tab['permission']) + && $tab['permission'] == 1) + { + $_tab = Indent::_(1); + } + + // check if the php of the tab is set, if not load it now + if (strpos((string) $tab['html'], 'bootstrap.addTab') === false + && strpos((string) $tab['html'], 'bootstrap.endTab') + === false) + { + // add the tab + $tmp = PHP_EOL . $_tab . Indent::_(1) + . ""; + $tmp .= PHP_EOL . $_tab . Indent::_(2) + . '
    '; + $tmp .= PHP_EOL . $_tab . Indent::_(3) + . '
    '; + $tmp .= PHP_EOL . $_tab . Indent::_(4) . implode( + PHP_EOL . $_tab . Indent::_(4), + (array) explode(PHP_EOL, trim((string) $tab['html'])) + ); + $tmp .= PHP_EOL . $_tab . Indent::_(3) . '
    '; + $tmp .= PHP_EOL . $_tab . Indent::_(2) . '
    '; + $tmp .= PHP_EOL . $_tab . Indent::_(1) + . ""; + + // update html + $tab['html'] = $tmp; + } + else + { + $tab['html'] = PHP_EOL . $_tab . Indent::_(1) + . implode( + PHP_EOL . $_tab . Indent::_(1), + (array) explode(PHP_EOL, trim((string) $tab['html'])) + ); + } + + // add the permissions if needed + if (isset($tab['permission']) + && $tab['permission'] == 1) + { + $tmp = PHP_EOL . Indent::_(1) + . "canDo->get('" + . $tab['view'] . "." . $tab['code'] + . ".viewtab')) : ?>"; + $tmp .= $tab['html']; + $tmp .= PHP_EOL . Indent::_(1) . ""; + // update html + $tab['html'] = $tmp; + // set lang for permissions + $tab['lang_permission'] = $tab['lang'] + . '_TAB_PERMISSION'; + $tab['lang_permission_desc'] = $tab['lang'] + . '_TAB_PERMISSION_DESC'; + $tab['lang_permission_title'] + = $this->placeholder->get('Views') . ' View ' + . $tab['name'] . ' Tab'; + $this->language->set( + 'both', $tab['lang_permission'], + $tab['lang_permission_title'] + ); + $this->language->set( + 'both', $tab['lang_permission_desc'], + 'Allow the users in this group to view ' + . $tab['name'] . ' Tab of ' + . $this->placeholder->get('views') + ); + // set the sort key + $tab['sortKey'] + = StringHelper::safe( + $tab['lang_permission_title'] + ); + } + + // return tab + return $tab; + + }, array_values($item->customtabs) + ) + ); + } + + unset($item->customtabs); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaThree/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaThree/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/JoomlaThree/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/Router.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/Router.php new file mode 100644 index 000000000..87f106613 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/Router.php @@ -0,0 +1,330 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Model; + + +use VDM\Joomla\Componentbuilder\Compiler\Config; +use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Router as Builder; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\JsonHelper; + + +/** + * Model Component Site Router Class + * + * @since 3.2.0 + */ +class Router +{ + /** + * The Config Class. + * + * @var Config + * @since 3.2.0 + */ + protected Config $config; + + /** + * The Dispenser Class. + * + * @var Dispenser + * @since 3.2.0 + */ + protected Dispenser $dispenser; + + /** + * The Router Class. + * + * @var Builder + * @since 3.2.0 + */ + protected Builder $builder; + + /** + * The gui mapper array + * + * @var array + * @since 3.2.0 + */ + protected array $guiMapper = [ + 'table' => 'component_router', + 'id' => null, + 'field' => null, + 'type' => 'php' + ]; + + /** + * The field targets + * + * @var array + * @since 3.2.0 + */ + protected array $targets = [ + 'before' => 'constructor_before_parent', + 'after' => 'constructor_after_parent', + 'method' => 'methods' + ]; + + /** + * Constructor. + * + * @param Config $config The Config Class. + * @param Dispenser $dispenser The Dispenser Class. + * @param Builder $builder The Router Class. + * + * @since 3.2.0 + */ + public function __construct(Config $config, Dispenser $dispenser, Builder $builder) + { + $this->config = $config; + $this->dispenser = $dispenser; + $this->builder = $builder; + } + + /** + * Set Router + * + * @param object $item The item data + * + * @return void + * @since 3.2.0 + */ + public function set(object &$item) + { + $this->config->lang_target = 'site'; + foreach ($this->targets as $target) + { + // add the code + if ($item->{"router_mode_{$target}"} == 3 + && StringHelper::check($item->{"router_{$target}_code"})) + { + // update GUI mapper field + $this->guiMapper['field'] = "{$target}_code"; + $this->dispenser->set( + $item->{"router_{$target}_code"}, + "_site_router_", + $target, + null, + $this->guiMapper + ); + } + unset($item->{"router_{$target}_code"}); + } + + // get the site views + $views = $this->getSiteViews($item->site_views ?? [], $item->admin_views ?? []); + $edit_views = $this->getSiteEditViews($item->admin_views); + + // get the edit site views + $this->builder->set('views', + ArrayHelper::merge([$views, $edit_views]) + ); + + if ($item->router_mode_constructor_before_parent == 2 + && JsonHelper::check($item->router_constructor_before_parent_manual)) + { + // build and validate the constructor before parent call code + $this->builder->set('manual', + json_decode($item->router_constructor_before_parent_manual) + ); + } + + // clear the data from the item + foreach ($this->targets as $key => $target) + { + // set the modes + $this->builder->set("mode_{$key}", + (int) $item->{"router_mode_{$target}"} + ); + + unset($item->{"router_mode_{$target}"}); + } + + unset($item->router_constructor_before_parent_manual); + } + + /** + * Get the array of site views with additional details. + * + * This method processes each site view to enrich it with additional details such as the associated table, + * alias keys, and other relevant information. The enrichment is based on the view's settings and the admin views. + * + * @param array $siteViews The site views to be processed. + * @param array $adminViews The admin views used for fetching additional data. + * + * @return array An array of objects, each representing a site view with enriched details. + * @since 3.2.0 + */ + protected function getSiteViews(array $siteViews, array $adminViews): array + { + return array_map(function ($view) use ($adminViews) { + // Attempt to get the main selection details from the view's settings. + $selection = $this->getMainSelection($view['settings']->main_get->main_get ?? null); + + // We can only work with ID if the [main get] is a [getItem] dynamicGet for this site view. + $key = ($view['settings']->main_get->gettype == 1) ? 'id' : null; + + // Construct the enriched view object. + return (object) [ + 'view' => $view['settings']->code, + 'View' => $view['settings']->Code, + 'stable' => ($selection['view'] === $view['settings']->code), // sanity check + 'target_view' => $selection['view'], + 'table' => $selection['table'], + 'table_name' => $selection['name'], + 'alias' => $this->getSiteViewAliasKey($selection['name'] ?? null, $adminViews), + 'key' => $key, + 'form' => false + ]; + }, $siteViews); + } + + /** + * Get the array of site edit views + * + * This method processes the provided admin views to extract and return an array of site edit views. + * Each site edit view is constructed based on specific conditions from the admin view's settings. + * + * @param array|null $views The admin views to process. + * + * @return array An array of site edit views, each as an object with view, table, alias, key, and form properties. + * @since 3.2.0 + */ + protected function getSiteEditViews(?array $views): array + { + $siteEditViews = []; + + // Return early if no views are provided. + if (empty($views)) + { + return $siteEditViews; + } + + foreach ($views as $view) + { + // Check if the view is marked for edit/create on the site. + if (!empty($view['edit_create_site_view'])) + { + $siteEditViews[] = (object) [ + 'view' => $view['settings']->name_single_code, + 'View' => StringHelper::safe($view['settings']->name_single_code, 'F'), + 'stable' => true, + 'target_view' => $view['settings']->name_single_code, + 'table' => '#__' . $this->config->component_code_name . '_' . $view['settings']->name_single_code, + 'alias' => $this->getSiteEditViewAliasKey($view['settings']->fields ?? null), + 'key' => 'id', + 'form' => true + ]; + } + } + + return $siteEditViews; + } + + /** + * Get the site edit view alias key value + * + * This method fetches the alias keys for a given site edit view by matching the view name + * against a list of admin views. It processes the admin views to find a match and then + * retrieves the alias keys from the matched view's settings. + * + * @param string|null $viewName The view name to match. + * @param array $adminViews The admin views to search within. + * + * @return string|null The alias key for the site edit view, or null if not found. + * @since 3.2.0 + */ + protected function getSiteViewAliasKey(?string $viewName, array $adminViews): ?string + { + // Return early if no view name is provided or admin views are empty. + if ($viewName === null || empty($adminViews)) + { + return null; + } + + foreach ($adminViews as $view) + { + // Check if the current view matches the specified view name and has fields defined. + if ($view['settings']->name_single_code === $viewName && is_array($view['settings']->fields ?? null)) + { + // If a match is found, retrieve and return the site edit view alias keys. + return $this->getSiteEditViewAliasKey($view['settings']->fields); + } + } + + // Return an empty array if no matching view is found. + return null; + } + + /** + * Get the site view alias key value + * + * @param array|null $fields The main get object + * + * @return string|null + * @since 3.2.0 + */ + protected function getSiteEditViewAliasKey(?array $fields): ?string + { + if ($fields !== null) + { + foreach ($fields as $field) + { + if (isset($field['alias']) && $field['alias'] && $field['type_name'] === 'text') + { + return $field['base_name']; + } + } + } + + return null; + } + + /** + * Get the view (main selection) table and view name value + * from the main get object + * + * @param array|null $gets The main get objects + * + * @return array + * @since 3.2.0 + */ + protected function getMainSelection(?array $gets): array + { + if ($gets !== null) + { + foreach ($gets as $get) + { + // get the main table + if (isset($get['as']) + && $get['as'] === 'a' + && isset($get['selection']) + && ArrayHelper::check($get['selection']) + && isset($get['selection']['select_gets']) + && ArrayHelper::check($get['selection']['select_gets']) + && isset($get['selection']['name']) && isset($get['selection']['table'])) + { + $name = $get['selection']['name']; + $view = $get['selection']['view']; + $table = $get['selection']['table']; + + return ['table' => $table, 'view' => $view, 'name' => $name]; + } + } + } + + return []; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/Sqldump.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/Sqldump.php index e6ed67572..bc76ac23e 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/Sqldump.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Model/Sqldump.php @@ -38,10 +38,9 @@ class Sqldump /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 **/ - protected \JDatabaseDriver $db; + protected $db; /** * Constructor @@ -51,10 +50,10 @@ class Sqldump * @since 3.2.0 */ - public function __construct(?Registry $registry = null, ?\JDatabaseDriver $db = null) + public function __construct(?Registry $registry = null) { $this->registry = $registry ?: Compiler::_('Registry'); - $this->db = $db ?: Factory::getDbo(); + $this->db = Factory::getDbo(); } /** diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power.php index 314ae6a25..738ec5684 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power.php @@ -144,18 +144,16 @@ class Power implements PowerInterface /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 **/ - protected \JDatabaseDriver $db; + protected $db; /** * Database object to query local DB * - * @var CMSApplication * @since 3.2.0 **/ - protected CMSApplication $app; + protected $app; /** * Constructor. @@ -165,23 +163,20 @@ class Power implements PowerInterface * @param Customcode|null $customcode The compiler customcode object. * @param Gui|null $gui The compiler customcode gui object. * @param Superpower|null $superpower The JCB superpower object. - * @param \JDatabaseDriver|null $db The Database Driver object. - * @param CMSApplication|null $app The CMS Application object. * * @throws \Exception * @since 3.2.0 */ public function __construct(?Config $config = null, ?Placeholder $placeholder = null, - ?Customcode $customcode = null, ?Gui $gui = null, ?Superpower $superpower = null, - ?\JDatabaseDriver $db = null, ?CMSApplication $app = null) + ?Customcode $customcode = null, ?Gui $gui = null, ?Superpower $superpower = null) { $this->config = $config ?: Compiler::_('Config'); $this->placeholder = $placeholder ?: Compiler::_('Placeholder'); $this->customcode = $customcode ?: Compiler::_('Customcode'); $this->gui = $gui ?: Compiler::_('Customcode.Gui'); $this->superpower = $superpower ?: Compiler::_('Superpower'); - $this->db = $db ?: Factory::getDbo(); - $this->app = $app ?: Factory::getApplication(); + $this->db = Factory::getDbo(); + $this->app = Factory::getApplication(); } /** diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Autoloader.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Autoloader.php index 2a0dec87e..5135b5088 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Autoloader.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Autoloader.php @@ -282,8 +282,8 @@ class Autoloader // we start building the spl_autoload_register function call $autoload_method = []; $autoload_method[] = Indent::_($tabSpace) . '//' - . Line::_(__Line__, __Class__) . ' register this component namespace'; - $autoload_method[] = Indent::_($tabSpace) . 'spl_autoload_register(function ($class) {'; + . Line::_(__Line__, __Class__) . ' register additional namespace'; + $autoload_method[] = Indent::_($tabSpace) . '\spl_autoload_register(function ($class) {'; $autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '//' . Line::_(__Line__, __Class__) . ' project-specific base directories and namespace prefix'; $autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '$search = ['; diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Extractor.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Extractor.php index b1b0c5287..8dafcfb60 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Extractor.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Extractor.php @@ -41,20 +41,18 @@ final class Extractor /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 **/ - protected \JDatabaseDriver $db; + protected $db; /** * Constructor * - * @param \JDatabaseDriver|null $db The database object. * @since 3.2.0 */ - public function __construct(?\JDatabaseDriver $db = null) + public function __construct() { - $this->db = $db ?: Factory::getDbo(); + $this->db = Factory::getDbo(); } /** diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Infusion.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Infusion.php index ed1ed4100..41e97e7d4 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Infusion.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Infusion.php @@ -16,7 +16,6 @@ use VDM\Joomla\Componentbuilder\Compiler\Config; use VDM\Joomla\Componentbuilder\Compiler\Power; use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Content; use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentMulti as Contents; -use VDM\Joomla\Componentbuilder\Compiler\Power\Autoloader; use VDM\Joomla\Componentbuilder\Compiler\Power\Parser; use VDM\Joomla\Componentbuilder\Compiler\Power\Repo\Readme as RepoReadme; use VDM\Joomla\Componentbuilder\Compiler\Power\Repos\Readme as ReposReadme; @@ -65,14 +64,6 @@ class Infusion */ protected Contents $contents; - /** - * The Autoloader Class. - * - * @var Autoloader - * @since 3.2.0 - */ - protected Autoloader $autoloader; - /** * The Parser Class. * @@ -140,6 +131,30 @@ class Infusion 'unchanged_licensing_template' => 'licensing_template' ]; + /** + * Power Infusion Tracker + * + * @var array + * @since 3.2.0 + **/ + protected array $done = []; + + /** + * Power Content Infusion Tracker + * + * @var array + * @since 3.2.0 + **/ + protected array $content_done = []; + + /** + * Path Infusion Tracker + * + * @var array + * @since 3.2.0 + **/ + protected array $path_done = []; + /** * Constructor. * @@ -147,7 +162,6 @@ class Infusion * @param Power $power The Power Class. * @param Content $content The ContentOne Class. * @param Contents $contents The ContentMulti Class. - * @param Autoloader $autoloader The Autoloader Class. * @param Parser $parser The Parser Class. * @param RepoReadme $reporeadme The Readme Class. * @param ReposReadme $reposreadme The Readme Class. @@ -157,8 +171,7 @@ class Infusion * @since 3.2.0 */ public function __construct(Config $config, Power $power, Content $content, - Contents $contents, Autoloader $autoloader, - Parser $parser, RepoReadme $reporeadme, + Contents $contents, Parser $parser, RepoReadme $reporeadme, ReposReadme $reposreadme, Placeholder $placeholder, Event $event) { @@ -166,7 +179,6 @@ class Infusion $this->power = $power; $this->content = $content; $this->contents = $contents; - $this->autoloader = $autoloader; $this->parser = $parser; $this->reporeadme = $reporeadme; $this->reposreadme = $reposreadme; @@ -203,8 +215,13 @@ class Infusion // we only do this if super powers are active if ($this->config->add_super_powers && ArrayHelper::check($this->power->superpowers)) { - foreach ($this->power->active as $n => &$power) + foreach ($this->power->active as $guid => &$power) { + if (isset($this->done[$guid])) + { + continue; + } + if (ObjectHelper::check($power) && isset($power->main_class_code) && StringHelper::check($power->main_class_code)) { @@ -215,6 +232,9 @@ class Infusion $power->parsed_class_code = $this->parser->code($power->main_class_code); } } + + // do each power just once + $this->done[$guid] = true; } } } @@ -230,17 +250,18 @@ class Infusion // infuse super powers details if set if ($this->config->add_super_powers && ArrayHelper::check($this->power->superpowers)) { - // TODO we need to update the event signatures - $context = $this->config->component_context; - foreach ($this->power->superpowers as $path => $powers) { + if (isset($this->path_done[$path])) + { + continue; + } + $key = StringHelper::safe($path); // Trigger Event: jcb_ce_onBeforeInfuseSuperPowerDetails $this->event->trigger( - 'jcb_ce_onBeforeInfuseSuperPowerDetails', - array(&$context, &$path, &$key, &$powers) + 'jcb_ce_onBeforeInfuseSuperPowerDetails', [&$path, &$key, &$powers] ); // we add and all missing powers @@ -260,9 +281,11 @@ class Infusion // Trigger Event: jcb_ce_onAfterInfuseSuperPowerDetails $this->event->trigger( - 'jcb_ce_onAfterInfuseSuperPowerDetails', - array(&$context, &$path, &$key, &$powers) + 'jcb_ce_onAfterInfuseSuperPowerDetails', [&$path, &$key, &$powers] ); + + // do each path just once + $this->path_done[$path] = true; } } } @@ -306,17 +329,18 @@ class Infusion // infuse powers data if set if (ArrayHelper::check($this->power->active)) { - // TODO we need to update the event signatures - $context = $this->config->component_context; - - foreach ($this->power->active as $power) + foreach ($this->power->active as $guid => $power) { + if (isset($this->content_done[$guid])) + { + continue; + } + if (ObjectHelper::check($power)) { // Trigger Event: jcb_ce_onBeforeInfusePowerData $this->event->trigger( - 'jcb_ce_onBeforeInfusePowerData', - array(&$context, &$power) + 'jcb_ce_onBeforeInfusePowerData', [&$power] ); // POWERCODE @@ -333,14 +357,13 @@ class Infusion // Trigger Event: jcb_ce_onAfterInfusePowerData $this->event->trigger( - 'jcb_ce_onAfterInfusePowerData', - array(&$context, &$power) + 'jcb_ce_onAfterInfusePowerData', [&$power] ); } - } - // now set the power autoloader - $this->autoloader->set(); + // do each power just once + $this->content_done[$guid] = true; + } } } diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Injector.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Injector.php index e650f4b71..246a7acfd 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Injector.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Injector.php @@ -81,6 +81,22 @@ final class Injector */ protected array $traits = []; + /** + * Other Statements + * + * @var array + * @since 3.2.0 + */ + protected array $other = []; + + /** + * Duplicate Statements + * + * @var array + * @since 3.2.0 + */ + protected array $duplicate = []; + /** * Constructor. * @@ -138,6 +154,8 @@ final class Injector $this->map = []; $this->useStatements = []; $this->traits = []; + $this->other = []; + $this->duplicate = []; foreach ($guids as $key => $guid) { @@ -165,168 +183,200 @@ final class Injector } /** - * inspect the super power + * Inspect the super power to determine the necessary class name based on use statements and traits. + * It checks if the given power (class, trait, etc.) already has a corresponding use statement + * and handles the naming accordingly to avoid conflicts. * - * @param object|null $power The power object. - * @param array|null $useStatements The code use statments - * @param array|null $traits The code traits use statments + * @param object $power The power object containing type, namespace, and class name. + * @param array|null $useStatements Array of existing use statements in the code. + * @param array|null $traits Array of existing traits used in the code. * - * @return string|null The class name (or as name) + * @return string|null The determined class name, or null if the type is not valid. * @since 3.2.0 */ protected function inspect(object $power, ?array $useStatements, ?array $traits): ?string { - if (isset($power->type) && in_array($power->type, ['class', 'abstract class', 'final class', 'trait'])) - { - $statement = 'use ' . $power->_namespace . '\\' . $power->class_name; - // other class names - $use_other = []; - $trait_other = []; - // some tracker globals - $has_use_statement = false; // add if not found - $has_trait_statement = !('trait' === $power->type); // don't add if not trait - $name = null; - $trait_name = null; + $namespaceStatement = $this->buildNamespaceStatment($power); - // check if the name space is loaded - if ($useStatements !== null) + $use_extracted = $this->extractUseStatements($namespaceStatement, $power->class_name, $useStatements); + + $name = $use_extracted['found'] ?? $power->class_name; + + $name = $this->getUniqueName($name, $power); + + $this->handleTraitLogic($name, $power, $traits); + + if (!$use_extracted['hasStatement']) + { + $this->addUseStatement($name, $power->class_name, $namespaceStatement); + } + + return $name; + } + + /** + * Builds the namespace statement from the power object's namespace and class name. + * + * @param object $power The power object. + * + * @return string The constructed use statement. + * @since 3.2.0 + */ + protected function buildNamespaceStatment(object $power): string + { + return $power->_namespace . '\\' . $power->class_name; + } + + /** + * Extracts and processes use statements to find if the current class name is already used. + * It identifies any potential naming conflicts. + * + * @param string $useStatement The search statement of the current class. + * @param string $className The class name of the power object. + * @param array|null $useStatements The existing use statements. + * + * @return array An array with keys 'found' and 'hasStatement'. + * @since 3.2.0 + */ + protected function extractUseStatements(string $useStatement, string $className, ?array $useStatements): array + { + $results = ['found' => null, 'hasStatement' => false]; + + if ($useStatements !== null) + { + foreach ($useStatements as $use_statement) { - foreach ($useStatements as $use_statement) + $class_name = $this->extractClassNameOrAlias($use_statement); + + if ($this->isUseStatementEqual($use_statement, $useStatement)) { - if ($use_statement === $statement . ';' || strpos($use_statement, $statement . ' as ') !== false) + if ($results['found'] === null) { - $name = $this->getName($use_statement); - $has_use_statement = true; + $results['found'] = $class_name; + $results['hasStatement'] = true; } else { - $tmp = $this->getName($use_statement); - if ($power->class_name === $tmp) - { - $use_other[$tmp] = $tmp; - } + // TODO we need to backport fix these + $this->duplicate[$use_statement] = $class_name; } } - } - - // check if the trait is loaded - if (!$has_trait_statement && $traits !== null) - { - $trait_statement = $name ?? $power->class_name; - - foreach ($traits as $trait) + elseif ($className === $class_name) { - if ($trait === $trait_statement) - { - $trait_name = $trait; - $has_trait_statement = true; - } + $this->other[$className] = $class_name; } } - - // build the name - $name = $trait_name ?? $name ?? $power->class_name; - - // if we have a trait we may need to add use and trait - if ('trait' === $power->type) - { - if (!$has_trait_statement) - { - $this->traits[$name] = 'use ' . $name . ';'; - } - } - - // check if we need to update the name - if ($use_other !== []) - { - // set search namespace - $namespace = ($name !== $power->class_name) ? $power->_namespace . '\\' . $power->class_name : $power->_namespace; - - // get the unique name - $name = $this->getUniqueName($name, $namespace, $use_other); - } - - if (!$has_use_statement) - { - // if the name is not the same as class name - if ($name !== $power->class_name) - { - $statement .= ' as ' . $name . ';'; - } - else - { - $statement .= ';'; - } - - $this->useStatements[$name] = $statement; - } - - return $name; } - return null; + return $results; } /** - * Extracts the class name from a use statement. + * Checks if the namespace statement is already declared in the current use statements. * - * @param string $useStatement The use statement from which to extract the class name + * This method uses a regular expression to check for an exact match of the full statement, + * taking into account the possibility of an alias being used. * - * @return string|null The class name or null if not found + * @param string $useStatement The existing use statement to check against. + * @param string $namespaceStatement The search statement to search for (without the trailing semicolon, or use prefix). + * + * @return bool True if the full statement is found, false otherwise. + */ + protected function isUseStatementEqual(string $useStatement, string $namespaceStatement): bool + { + // Create a regular expression pattern to match the full statement + // The pattern checks for the start of the statement, optional whitespace, + // and an optional alias after the full statement. + $pattern = '/^use\s+' . preg_quote($namespaceStatement, '/') . '(?:\s+as\s+\w+)?;$/'; + + // Perform the regex match to check if the use statement is equal to the search statment + return (bool) preg_match($pattern, $useStatement); + } + + /** + * Extracts the class name or alias from a use statement. + * + * This method parses a PHP 'use' statement and extracts either the class name or its alias. + * If the statement doesn't match the expected format, or if no class name or alias is found, + * the method returns null. + * + * Example: + * - 'use Namespace\ClassName;' -> returns 'ClassName' + * - 'use Namespace\ClassName as Alias;' -> returns 'Alias' + * + * @param string $useStatement The use statement from which to extract the class name or alias. + * + * @return string|null The class name or alias if found, null otherwise. * @since 3.2.0 */ - protected function getName(string $useStatement): ?string + protected function extractClassNameOrAlias(string $useStatement): ?string { - // If the input doesn't start with 'use ', assume it's a class name without a use statement + // If the input doesn't start with 'use ', assume it's just the namespace without a use statement if (strpos($useStatement, 'use ') !== 0) { - $parts = explode('\\', $useStatement); - $result = end($parts); - - // Remove '\\' from the beginning and end of the resulting string - $result = trim($result, '\\'); - - // If the resulting string is empty, return null - return empty($result) ? null : $result; + return $this->extractLastNameFromNamespace($useStatement); } - $pattern = '/use\s+([\w\\\\]+)(?:\s+as\s+)?([\w]+)?;/'; + // Regular expression to extract the class name and alias from the use statement + $pattern = '/use\s+(?P[\w\\\\]+?)(?:\s+as\s+(?P\w+))?;/'; if (preg_match($pattern, $useStatement, $matches)) { - // If there's an alias, return it - if (!empty($matches[2])) - { - return $matches[2]; - } - - // If there's no alias, extract the class name from the namespace - $parts = explode('\\', $matches[1]); - return end($parts); + // Return the alias if it exists; otherwise, return the last part of the namespace (class name) + return $matches['alias'] ?? $this->extractLastNameFromNamespace($matches['namespace']); } + // Return null if no match is found return null; } /** - * Removes the last space from the namespace. + * Ensures the name for the use statement is unique, avoiding conflicts with other classes. * - * @param string $name The current name - * @param string $namespace The namespace - * @param array $useOther The other use names + * @param string $name The current name + * @param object $power The power object containing type, namespace, and class name. * - * @return string The namespace shortened + * @return string The unique name * @since 3.2.0 */ - protected function getUniqueName(string $name, string $namespace, array $useOther): string + protected function getUniqueName(string $name, object $power): string { - // if the name is already used - while (isset($useOther[$name])) + // set search namespace + $namespace = ($name !== $power->class_name) ? $this->buildNamespaceStatment($power) : $power->_namespace; + + // check if we need to update the name + if (isset($this->other[$name])) { - if (($tmp = $this->getName($namespace)) !== null) + // if the name is already used + while (isset($this->other[$name])) { - $name = ucfirst($tmp) . $name; - $namespace = $this->removeLastSpace($namespace); + if (($tmp = $this->extractClassNameOrAlias($namespace)) !== null) + { + $name = ucfirst($tmp) . $name; + $namespace = $this->removeLastNameFromNamespace($namespace); + } + else + { + $name = 'Unique' . $name; + } + } + } + + // also loop new found use statements + if (isset($this->useStatements[$name])) + { + // if the name is already used + while (isset($this->useStatements[$name])) + { + if (($tmp = $this->extractClassNameOrAlias($namespace)) !== null) + { + $name = ucfirst($tmp) . $name; + $namespace = $this->removeLastNameFromNamespace($namespace); + } + else + { + $name = 'Unique' . $name; + } } } @@ -334,14 +384,34 @@ final class Injector } /** - * Removes the last space from the namespace. + * Extracts the last part of a namespace string, which is typically the class name. + * + * @param string $namespace The namespace string to extract from. + * + * @return string|null The extracted class name. + * @since 3.2.0 + */ + protected function extractLastNameFromNamespace(string $namespace): ?string + { + $parts = explode('\\', $namespace); + $result = end($parts); + + // Remove '\\' from the beginning and end of the resulting string + $result = trim($result, '\\'); + + // If the resulting string is empty, return null + return empty($result) ? null : $result; + } + + /** + * Removes the last name from the namespace. * * @param string $namespace The namespace * * @return string The namespace shortened * @since 3.2.0 */ - protected function removeLastSpace(string $namespace): string + protected function removeLastNameFromNamespace(string $namespace): string { // Remove '\\' from the beginning and end of the resulting string $namespace = trim($namespace, '\\'); @@ -355,6 +425,69 @@ final class Injector return implode('\\', $parts); } + /** + * Determines whether a trait statement should be added. + * + * @param object $power The power object. + * + * @return bool True if a trait statement should be added, false otherwise. + * @since 3.2.0 + */ + protected function shouldAddTraitStatement(object $power): bool + { + return $power->type === 'trait'; + } + + /** + * Handles specific logic for traits, such as checking if the trait is already used. + * + * @param string $name The current name. + * @param object $power The power object containing type, namespace, and class name. + * @param array|null $traits The traits used in the code. + * + * @return void + * @since 3.2.0 + */ + protected function handleTraitLogic(string $name, object $power, ?array $traits): void + { + if ($this->shouldAddTraitStatement($power) && $traits !== null) + { + foreach ($traits as $trait) + { + if ($trait === $name) + { + return; + } + } + } + + // add the trait + $this->traits[$name] = 'use ' . $name . ';'; + } + + /** + * Adds a use statement to the class if it's not already present. + * + * @param string $name The name to use. + * @param string $className The class name of the power object. + * @param string $namespaceStatement The search statement to search for (without the trailing semicolon, or use prefix). + * + * @since 3.2.0 + */ + protected function addUseStatement(string &$name, string $className, string $namespaceStatement): void + { + if ($name !== $className) + { + $statement = 'use ' . $namespaceStatement . ' as ' . $name . ';'; + } + else + { + $statement = 'use ' . $namespaceStatement . ';'; + } + + $this->useStatements[$name] = $statement; + } + /** * Insert a line before the class declaration in the given class code. * @@ -405,7 +538,7 @@ final class Injector // Find the position of the comment block right before the class declaration $comment_pattern = '/\s*\*\/\s*$/m'; $insert_pos = null; - if (preg_match($comment_pattern, $code, $comment_matches, PREG_OFFSET_CAPTURE, 0, $last_newline_pos)) + if (preg_match($comment_pattern, $code, $comment_matches, PREG_OFFSET_CAPTURE, $last_newline_pos)) { $insert_pos = (int) $comment_matches[0][1] + strlen($comment_matches[0][0]); } @@ -413,7 +546,7 @@ final class Injector { // Find the last empty line before the class declaration $empty_line_pattern = '/(^|\r\n|\r|\n)[\s]*($|\r\n|\r|\n)/'; - if (preg_match($empty_line_pattern, $code, $empty_line_matches, PREG_OFFSET_CAPTURE, 0, $last_newline_pos)) + if (preg_match($empty_line_pattern, $code, $empty_line_matches, PREG_OFFSET_CAPTURE, $last_newline_pos)) { $insert_pos = (int) $empty_line_matches[0][1] + strlen($empty_line_matches[0][0]); } @@ -444,7 +577,9 @@ final class Injector // Patterns to match the defined('_JEXEC') and defined('JPATH_BASE') lines $patterns = [ "/defined\('_JEXEC'\)(.*?)\s*;/", + "/\\defined\('_JEXEC'\)(.*?)\s*;/", "/defined\('JPATH_BASE'\)(.*?)\s*;/", + "/\\defined\('JPATH_BASE'\)(.*?)\s*;/", ]; $insert_pos = null; diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Structure.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Structure.php index 6178083d6..da6862daa 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Structure.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Structure.php @@ -48,6 +48,22 @@ class Structure **/ protected array $htaccess = []; + /** + * Power Build Tracker + * + * @var array + * @since 3.2.0 + **/ + protected array $done = []; + + /** + * Path Build Tracker + * + * @var array + * @since 3.2.0 + **/ + protected array $path_done = []; + /** * Power Objects * @@ -172,22 +188,21 @@ class Structure { if (ArrayHelper::check($this->power->active)) { - // for plugin event TODO change event api signatures - $powers = $this->power->active; - $component_context = $this->config->component_context; // Trigger Event: jcb_ce_onBeforeSetModules $this->event->trigger( - 'jcb_ce_onBeforeBuildPowers', - array(&$component_context, &$powers) + 'jcb_ce_onBeforeBuildPowers' ); - // for plugin event TODO change event api signatures - $this->power->active = $powers; // set super power details $this->setSuperPowerDetails(); - foreach ($this->power->active as $power) + foreach ($this->power->active as $guid => $power) { + if (isset($this->done[$guid])) + { + continue; + } + if (ObjectHelper::check($power) && isset($power->path) && StringHelper::check( @@ -232,6 +247,9 @@ class Structure // set htaccess once per path $this->setHtaccess($power); + + // do each power just once + $this->done[$guid] = true; } } } @@ -347,6 +365,14 @@ class Structure // check if we should add the dynamic folder moving script to the installer script if (!$this->registry->get('set_move_folders_install_script')) { + $function = 'setDynamicF0ld3rs'; + $script = 'script.php'; + if ($this->config->get('joomla_version', 3) != 3) + { + $function = 'moveFolders'; + $script = 'ComponentnameInstallerScript.php'; + } + // add the setDynamicF0ld3rs() method to the install script.php file $this->registry->set('set_move_folders_install_script', true); @@ -356,7 +382,9 @@ class Structure 'Notice' ); $this->app->enqueueMessage( - Text::sprintf('COM_COMPONENTBUILDER_A_METHOD_SETDYNAMICFZEROLDTHREERS_WAS_ADDED_TO_THE_INSTALL_BSCRIPTPHPB_OF_THIS_PACKAGE_TO_INSURE_THAT_THE_FOLDERS_ARE_COPIED_INTO_THE_CORRECT_PLACE_WHEN_THIS_COMPONENT_IS_INSTALLED'), + Text::sprintf('COM_COMPONENTBUILDER_A_METHOD_S_WAS_ADDED_TO_THE_INSTALL_BSB_OF_THIS_PACKAGE_TO_INSURE_THAT_THE_FOLDERS_ARE_COPIED_INTO_THE_CORRECT_PLACE_WHEN_THIS_COMPONENT_IS_INSTALLED', + $function, $script + ), 'Notice' ); } @@ -374,6 +402,11 @@ class Structure { foreach ($this->power->superpowers as $path => $powers) { + if (isset($this->path_done[$path])) + { + continue; + } + // get existing files $this->loadExistingSuperPower($path); @@ -389,6 +422,9 @@ class Structure // set the super power index file $this->createFile(Placefix::_h('POWERINDEX'), $path, 'super-powers.json', $key); + + // do each path just once + $this->path_done[$path] = true; } } } @@ -440,7 +476,7 @@ class Structure */ private function loadExistingSuperPower(string $repository) { - if (($content = FileHelper::getContent($repository . '/super-powers.json', null)) !== null && + if (!isset($this->power->old_superpowers[$repository]) && ($content = FileHelper::getContent($repository . '/super-powers.json', null)) !== null && JsonHelper::check($content)) { $this->power->old_superpowers[$repository] = json_decode($content, true); diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/ArchitectureController.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/ArchitectureController.php new file mode 100644 index 000000000..b6c6820e2 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/ArchitectureController.php @@ -0,0 +1,221 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowAddInterface; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Controller\AllowAdd as J5ControllerAllowAdd; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Controller\AllowAdd as J4ControllerAllowAdd; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Controller\AllowAdd as J3ControllerAllowAdd; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowEditInterface; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Controller\AllowEdit as J5ControllerAllowEdit; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Controller\AllowEdit as J4ControllerAllowEdit; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Controller\AllowEdit as J3ControllerAllowEdit; + + +/** + * Architecture Controller Service Provider + * + * @since 3.2.0 + */ +class ArchitectureController implements ServiceProviderInterface +{ + /** + * Current Joomla Version Being Build + * + * @var int + * @since 3.2.0 + **/ + protected $targetVersion; + + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(AllowAddInterface::class, 'Architecture.Controller.AllowAdd') + ->share('Architecture.Controller.AllowAdd', [$this, 'getAllowAdd'], true); + + $container->alias(J5ControllerAllowAdd::class, 'Architecture.Controller.J5.AllowAdd') + ->share('Architecture.Controller.J5.AllowAdd', [$this, 'getJ5ControllerAllowAdd'], true); + + $container->alias(J4ControllerAllowAdd::class, 'Architecture.Controller.J4.AllowAdd') + ->share('Architecture.Controller.J4.AllowAdd', [$this, 'getJ4ControllerAllowAdd'], true); + + $container->alias(J3ControllerAllowAdd::class, 'Architecture.Controller.J3.AllowAdd') + ->share('Architecture.Controller.J3.AllowAdd', [$this, 'getJ3ControllerAllowAdd'], true); + + $container->alias(AllowEditInterface::class, 'Architecture.Controller.AllowEdit') + ->share('Architecture.Controller.AllowEdit', [$this, 'getAllowEdit'], true); + + $container->alias(J5ControllerAllowEdit::class, 'Architecture.Controller.J5.AllowEdit') + ->share('Architecture.Controller.J5.AllowEdit', [$this, 'getJ5ControllerAllowEdit'], true); + + $container->alias(J4ControllerAllowEdit::class, 'Architecture.Controller.J4.AllowEdit') + ->share('Architecture.Controller.J4.AllowEdit', [$this, 'getJ4ControllerAllowEdit'], true); + + $container->alias(J3ControllerAllowEdit::class, 'Architecture.Controller.J3.AllowEdit') + ->share('Architecture.Controller.J3.AllowEdit', [$this, 'getJ3ControllerAllowEdit'], true); + } + + /** + * Get The AllowAddInterface Class. + * + * @param Container $container The DI container. + * + * @return AllowAddInterface + * @since 3.2.0 + */ + public function getAllowAdd(Container $container): AllowAddInterface + { + if (empty($this->targetVersion)) + { + $this->targetVersion = $container->get('Config')->joomla_version; + } + + return $container->get('Architecture.Controller.J' . $this->targetVersion . '.AllowAdd'); + } + + /** + * Get The AllowAdd Class. + * + * @param Container $container The DI container. + * + * @return J5ControllerAllowAdd + * @since 3.2.0 + */ + public function getJ5ControllerAllowAdd(Container $container): J5ControllerAllowAdd + { + return new J5ControllerAllowAdd( + $container->get('Config'), + $container->get('Compiler.Creator.Permission'), + $container->get('Customcode.Dispenser') + ); + } + + /** + * Get The AllowAdd Class. + * + * @param Container $container The DI container. + * + * @return J4ControllerAllowAdd + * @since 3.2.0 + */ + public function getJ4ControllerAllowAdd(Container $container): J4ControllerAllowAdd + { + return new J4ControllerAllowAdd( + $container->get('Config'), + $container->get('Compiler.Creator.Permission'), + $container->get('Customcode.Dispenser') + ); + } + + /** + * Get The AllowAdd Class. + * + * @param Container $container The DI container. + * + * @return J3ControllerAllowAdd + * @since 3.2.0 + */ + public function getJ3ControllerAllowAdd(Container $container): J3ControllerAllowAdd + { + return new J3ControllerAllowAdd( + $container->get('Config'), + $container->get('Compiler.Creator.Permission'), + $container->get('Customcode.Dispenser') + ); + } + + /** + * Get The AllowEditInterface Class. + * + * @param Container $container The DI container. + * + * @return AllowEditInterface + * @since 3.2.0 + */ + public function getAllowEdit(Container $container): AllowEditInterface + { + if (empty($this->targetVersion)) + { + $this->targetVersion = $container->get('Config')->joomla_version; + } + + return $container->get('Architecture.Controller.J' . $this->targetVersion . '.AllowEdit'); + } + + /** + * Get The AllowEdit Class. + * + * @param Container $container The DI container. + * + * @return J5ControllerAllowEdit + * @since 3.2.0 + */ + public function getJ5ControllerAllowEdit(Container $container): J5ControllerAllowEdit + { + return new J5ControllerAllowEdit( + $container->get('Config'), + $container->get('Compiler.Creator.Permission'), + $container->get('Customcode.Dispenser'), + $container->get('Compiler.Builder.Category'), + $container->get('Compiler.Builder.Category.Other.Name') + ); + } + + /** + * Get The AllowEdit Class. + * + * @param Container $container The DI container. + * + * @return J4ControllerAllowEdit + * @since 3.2.0 + */ + public function getJ4ControllerAllowEdit(Container $container): J4ControllerAllowEdit + { + return new J4ControllerAllowEdit( + $container->get('Config'), + $container->get('Compiler.Creator.Permission'), + $container->get('Customcode.Dispenser'), + $container->get('Compiler.Builder.Category'), + $container->get('Compiler.Builder.Category.Other.Name') + ); + } + + /** + * Get The AllowEdit Class. + * + * @param Container $container The DI container. + * + * @return J3ControllerAllowEdit + * @since 3.2.0 + */ + public function getJ3ControllerAllowEdit(Container $container): J3ControllerAllowEdit + { + return new J3ControllerAllowEdit( + $container->get('Config'), + $container->get('Compiler.Creator.Permission'), + $container->get('Customcode.Dispenser'), + $container->get('Compiler.Builder.Category'), + $container->get('Compiler.Builder.Category.Other.Name') + ); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/ArchitectureModel.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/ArchitectureModel.php new file mode 100644 index 000000000..b3e6b762d --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/ArchitectureModel.php @@ -0,0 +1,209 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CanDeleteInterface; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Model\CanDelete as J5ModelCanDelete; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Model\CanDelete as J4ModelCanDelete; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Model\CanDelete as J3ModelCanDelete; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Model\CanEditStateInterface; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Model\CanEditState as J5ModelCanEditState; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Model\CanEditState as J4ModelCanEditState; +use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Model\CanEditState as J3ModelCanEditState; + + +/** + * Architecture Model Service Provider + * + * @since 3.2.0 + */ +class ArchitectureModel implements ServiceProviderInterface +{ + /** + * Current Joomla Version Being Build + * + * @var int + * @since 3.2.0 + **/ + protected $targetVersion; + + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(J3ModelCanDelete::class, 'Architecture.Model.J3.CanDelete') + ->share('Architecture.Model.J3.CanDelete', [$this, 'getJ3ModelCanDelete'], true); + + $container->alias(J4ModelCanDelete::class, 'Architecture.Model.J4.CanDelete') + ->share('Architecture.Model.J4.CanDelete', [$this, 'getJ4ModelCanDelete'], true); + + $container->alias(J5ModelCanDelete::class, 'Architecture.Model.J5.CanDelete') + ->share('Architecture.Model.J5.CanDelete', [$this, 'getJ5ModelCanDelete'], true); + + $container->alias(CanDeleteInterface::class, 'Architecture.Model.CanDelete') + ->share('Architecture.Model.CanDelete', [$this, 'getModelCanDelete'], true); + + $container->alias(J3ModelCanEditState::class, 'Architecture.Model.J3.CanEditState') + ->share('Architecture.Model.J3.CanEditState', [$this, 'getJ3ModelCanEditState'], true); + + $container->alias(J4ModelCanEditState::class, 'Architecture.Model.J4.CanEditState') + ->share('Architecture.Model.J4.CanEditState', [$this, 'getJ4ModelCanEditState'], true); + + $container->alias(J5ModelCanEditState::class, 'Architecture.Model.J5.CanEditState') + ->share('Architecture.Model.J5.CanEditState', [$this, 'getJ5ModelCanEditState'], true); + + $container->alias(CanEditStateInterface::class, 'Architecture.Model.CanEditState') + ->share('Architecture.Model.CanEditState', [$this, 'getModelCanEditState'], true); + } + + /** + * Get The Model CanDelete Class. + * + * @param Container $container The DI container. + * + * @return CanDeleteInterface + * @since 3.2.0 + */ + public function getModelCanDelete(Container $container): CanDeleteInterface + { + if (empty($this->targetVersion)) + { + $this->targetVersion = $container->get('Config')->joomla_version; + } + + return $container->get('Architecture.Model.J' . $this->targetVersion . '.CanDelete'); + } + + /** + * Get The Model CanDelete Class. + * + * @param Container $container The DI container. + * + * @return J5ModelCanDelete + * @since 3.2.0 + */ + public function getJ5ModelCanDelete(Container $container): J5ModelCanDelete + { + return new J5ModelCanDelete( + $container->get('Config'), + $container->get('Compiler.Creator.Permission') + ); + } + + /** + * Get The Model CanDelete Class. + * + * @param Container $container The DI container. + * + * @return J4ModelCanDelete + * @since 3.2.0 + */ + public function getJ4ModelCanDelete(Container $container): J4ModelCanDelete + { + return new J4ModelCanDelete( + $container->get('Config'), + $container->get('Compiler.Creator.Permission') + ); + } + + /** + * Get The Model CanDelete Class. + * + * @param Container $container The DI container. + * + * @return J3ModelCanDelete + * @since 3.2.0 + */ + public function getJ3ModelCanDelete(Container $container): J3ModelCanDelete + { + return new J3ModelCanDelete( + $container->get('Config'), + $container->get('Compiler.Creator.Permission') + ); + } + + /** + * Get The Model Can Edit State Class. + * + * @param Container $container The DI container. + * + * @return CanEditStateInterface + * @since 3.2.0 + */ + public function getModelCanEditState(Container $container): CanEditStateInterface + { + if (empty($this->targetVersion)) + { + $this->targetVersion = $container->get('Config')->joomla_version; + } + + return $container->get('Architecture.Model.J' . $this->targetVersion . '.CanEditState'); + } + + /** + * Get The Model Can Edit State Class. + * + * @param Container $container The DI container. + * + * @return J5ModelCanEditState + * @since 3.2.0 + */ + public function getJ5ModelCanEditState(Container $container): J5ModelCanEditState + { + return new J5ModelCanEditState( + $container->get('Config'), + $container->get('Compiler.Creator.Permission') + ); + } + + /** + * Get The Model Can Edit State Class. + * + * @param Container $container The DI container. + * + * @return J4ModelCanEditState + * @since 3.2.0 + */ + public function getJ4ModelCanEditState(Container $container): J4ModelCanEditState + { + return new J4ModelCanEditState( + $container->get('Config'), + $container->get('Compiler.Creator.Permission') + ); + } + + /** + * Get The Model Can Edit State Class. + * + * @param Container $container The DI container. + * + * @return J3ModelCanEditState + * @since 3.2.0 + */ + public function getJ3ModelCanEditState(Container $container): J3ModelCanEditState + { + return new J3ModelCanEditState( + $container->get('Config'), + $container->get('Compiler.Creator.Permission') + ); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Builder.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Builder.php deleted file mode 100644 index 8e5f73592..000000000 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Builder.php +++ /dev/null @@ -1,1550 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -namespace VDM\Joomla\Componentbuilder\Compiler\Service; - - -use Joomla\DI\Container; -use Joomla\DI\ServiceProviderInterface; -use VDM\Joomla\Componentbuilder\Compiler\Builder\AccessSwitch; -use VDM\Joomla\Componentbuilder\Compiler\Builder\AccessSwitchList; -use VDM\Joomla\Componentbuilder\Compiler\Builder\AdminFilterType; -use VDM\Joomla\Componentbuilder\Compiler\Builder\Alias; -use VDM\Joomla\Componentbuilder\Compiler\Builder\BaseSixFour; -use VDM\Joomla\Componentbuilder\Compiler\Builder\Category; -use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryCode; -use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryOtherName; -use VDM\Joomla\Componentbuilder\Compiler\Builder\CheckBox; -use VDM\Joomla\Componentbuilder\Compiler\Builder\ComponentFields; -use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentMulti; -use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne; -use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomAlias; -use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomField; -use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomFieldLinks; -use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomList; -use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomTabs; -use VDM\Joomla\Componentbuilder\Compiler\Builder\DatabaseKeys; -use VDM\Joomla\Componentbuilder\Compiler\Builder\DatabaseTables; -use VDM\Joomla\Componentbuilder\Compiler\Builder\DatabaseUniqueGuid; -use VDM\Joomla\Componentbuilder\Compiler\Builder\DatabaseUniqueKeys; -use VDM\Joomla\Componentbuilder\Compiler\Builder\DoNotEscape; -use VDM\Joomla\Componentbuilder\Compiler\Builder\DynamicFields; -use VDM\Joomla\Componentbuilder\Compiler\Builder\ExtensionCustomFields; -use VDM\Joomla\Componentbuilder\Compiler\Builder\FieldGroupControl; -use VDM\Joomla\Componentbuilder\Compiler\Builder\FieldNames; -use VDM\Joomla\Componentbuilder\Compiler\Builder\FieldRelations; -use VDM\Joomla\Componentbuilder\Compiler\Builder\Filter; -use VDM\Joomla\Componentbuilder\Compiler\Builder\FootableScripts; -use VDM\Joomla\Componentbuilder\Compiler\Builder\GetAsLookup; -use VDM\Joomla\Componentbuilder\Compiler\Builder\GetModule; -use VDM\Joomla\Componentbuilder\Compiler\Builder\GoogleChart; -use VDM\Joomla\Componentbuilder\Compiler\Builder\HasPermissions; -use VDM\Joomla\Componentbuilder\Compiler\Builder\HiddenFields; -use VDM\Joomla\Componentbuilder\Compiler\Builder\History; -use VDM\Joomla\Componentbuilder\Compiler\Builder\IntegerFields; -use VDM\Joomla\Componentbuilder\Compiler\Builder\ItemsMethodEximportString; -use VDM\Joomla\Componentbuilder\Compiler\Builder\ItemsMethodListString; -use VDM\Joomla\Componentbuilder\Compiler\Builder\JsonItem; -use VDM\Joomla\Componentbuilder\Compiler\Builder\JsonItemArray; -use VDM\Joomla\Componentbuilder\Compiler\Builder\JsonString; -use VDM\Joomla\Componentbuilder\Compiler\Builder\Layout; -use VDM\Joomla\Componentbuilder\Compiler\Builder\LayoutData; -use VDM\Joomla\Componentbuilder\Compiler\Builder\LibraryManager; -use VDM\Joomla\Componentbuilder\Compiler\Builder\ListFieldClass; -use VDM\Joomla\Componentbuilder\Compiler\Builder\ListHeadOverride; -use VDM\Joomla\Componentbuilder\Compiler\Builder\ListJoin; -use VDM\Joomla\Componentbuilder\Compiler\Builder\Lists; -use VDM\Joomla\Componentbuilder\Compiler\Builder\MainTextField; -use VDM\Joomla\Componentbuilder\Compiler\Builder\MetaData; -use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelBasicField; -use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelExpertField; -use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelExpertFieldInitiator; -use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelMediumField; -use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelWhmcsField; -use VDM\Joomla\Componentbuilder\Compiler\Builder\MovedPublishingFields; -use VDM\Joomla\Componentbuilder\Compiler\Builder\MysqlTableSetting; -use VDM\Joomla\Componentbuilder\Compiler\Builder\NewPublishingFields; -use VDM\Joomla\Componentbuilder\Compiler\Builder\OrderZero; -use VDM\Joomla\Componentbuilder\Compiler\Builder\OtherFilter; -use VDM\Joomla\Componentbuilder\Compiler\Builder\OtherGroup; -use VDM\Joomla\Componentbuilder\Compiler\Builder\OtherJoin; -use VDM\Joomla\Componentbuilder\Compiler\Builder\OtherOrder; -use VDM\Joomla\Componentbuilder\Compiler\Builder\OtherQuery; -use VDM\Joomla\Componentbuilder\Compiler\Builder\OtherWhere; -use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionAction; -use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionComponent; -use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionCore; -use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionDashboard; -use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionGlobalAction; -use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionViews; -use VDM\Joomla\Componentbuilder\Compiler\Builder\ScriptMediaSwitch; -use VDM\Joomla\Componentbuilder\Compiler\Builder\ScriptUserSwitch; -use VDM\Joomla\Componentbuilder\Compiler\Builder\Search; -use VDM\Joomla\Componentbuilder\Compiler\Builder\SelectionTranslation; -use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteDecrypt; -use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteDynamicGet; -use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteEditView; -use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteFieldData; -use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteFieldDecodeFilter; -use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteFields; -use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteMainGet; -use VDM\Joomla\Componentbuilder\Compiler\Builder\Sort; -use VDM\Joomla\Componentbuilder\Compiler\Builder\TabCounter; -use VDM\Joomla\Componentbuilder\Compiler\Builder\Tags; -use VDM\Joomla\Componentbuilder\Compiler\Builder\TemplateData; -use VDM\Joomla\Componentbuilder\Compiler\Builder\Title; -use VDM\Joomla\Componentbuilder\Compiler\Builder\UikitComp; -use VDM\Joomla\Componentbuilder\Compiler\Builder\UpdateMysql; - - -/** - * Builder Service Provider - * - * @since 3.2.0 - */ -class Builder implements ServiceProviderInterface -{ - /** - * Registers the service provider with a DI container. - * - * @param Container $container The DI container. - * - * @return void - * @since 3.2.0 - */ - public function register(Container $container) - { - $container->alias(AccessSwitch::class, 'Compiler.Builder.Access.Switch') - ->share('Compiler.Builder.Access.Switch', [$this, 'getAccessSwitch'], true); - - $container->alias(AccessSwitchList::class, 'Compiler.Builder.Access.Switch.List') - ->share('Compiler.Builder.Access.Switch.List', [$this, 'getAccessSwitchList'], true); - - $container->alias(AdminFilterType::class, 'Compiler.Builder.Admin.Filter.Type') - ->share('Compiler.Builder.Admin.Filter.Type', [$this, 'getAdminFilterType'], true); - - $container->alias(Alias::class, 'Compiler.Builder.Alias') - ->share('Compiler.Builder.Alias', [$this, 'getAlias'], true); - - $container->alias(BaseSixFour::class, 'Compiler.Builder.Base.Six.Four') - ->share('Compiler.Builder.Base.Six.Four', [$this, 'getBaseSixFour'], true); - - $container->alias(Category::class, 'Compiler.Builder.Category') - ->share('Compiler.Builder.Category', [$this, 'getCategory'], true); - - $container->alias(CategoryCode::class, 'Compiler.Builder.Category.Code') - ->share('Compiler.Builder.Category.Code', [$this, 'getCategoryCode'], true); - - $container->alias(CategoryOtherName::class, 'Compiler.Builder.Category.Other.Name') - ->share('Compiler.Builder.Category.Other.Name', [$this, 'getCategoryOtherName'], true); - - $container->alias(CheckBox::class, 'Compiler.Builder.Check.Box') - ->share('Compiler.Builder.Check.Box', [$this, 'getCheckBox'], true); - - $container->alias(ComponentFields::class, 'Compiler.Builder.Component.Fields') - ->share('Compiler.Builder.Component.Fields', [$this, 'getComponentFields'], true); - - $container->alias(ContentMulti::class, 'Compiler.Builder.Content.Multi') - ->share('Compiler.Builder.Content.Multi', [$this, 'getContentMulti'], true); - - $container->alias(ContentOne::class, 'Compiler.Builder.Content.One') - ->share('Compiler.Builder.Content.One', [$this, 'getContentOne'], true); - - $container->alias(CustomAlias::class, 'Compiler.Builder.Custom.Alias') - ->share('Compiler.Builder.Custom.Alias', [$this, 'getCustomAlias'], true); - - $container->alias(CustomField::class, 'Compiler.Builder.Custom.Field') - ->share('Compiler.Builder.Custom.Field', [$this, 'getCustomField'], true); - - $container->alias(CustomFieldLinks::class, 'Compiler.Builder.Custom.Field.Links') - ->share('Compiler.Builder.Custom.Field.Links', [$this, 'getCustomFieldLinks'], true); - - $container->alias(CustomList::class, 'Compiler.Builder.Custom.List') - ->share('Compiler.Builder.Custom.List', [$this, 'getCustomList'], true); - - $container->alias(CustomTabs::class, 'Compiler.Builder.Custom.Tabs') - ->share('Compiler.Builder.Custom.Tabs', [$this, 'getCustomTabs'], true); - - $container->alias(DatabaseKeys::class, 'Compiler.Builder.Database.Keys') - ->share('Compiler.Builder.Database.Keys', [$this, 'getDatabaseKeys'], true); - - $container->alias(DatabaseTables::class, 'Compiler.Builder.Database.Tables') - ->share('Compiler.Builder.Database.Tables', [$this, 'getDatabaseTables'], true); - - $container->alias(DatabaseUniqueGuid::class, 'Compiler.Builder.Database.Unique.Guid') - ->share('Compiler.Builder.Database.Unique.Guid', [$this, 'getDatabaseUniqueGuid'], true); - - $container->alias(DatabaseUniqueKeys::class, 'Compiler.Builder.Database.Unique.Keys') - ->share('Compiler.Builder.Database.Unique.Keys', [$this, 'getDatabaseUniqueKeys'], true); - - $container->alias(DoNotEscape::class, 'Compiler.Builder.Do.Not.Escape') - ->share('Compiler.Builder.Do.Not.Escape', [$this, 'getDoNotEscape'], true); - - $container->alias(DynamicFields::class, 'Compiler.Builder.Dynamic.Fields') - ->share('Compiler.Builder.Dynamic.Fields', [$this, 'getDynamicFields'], true); - - $container->alias(ExtensionCustomFields::class, 'Compiler.Builder.Extension.Custom.Fields') - ->share('Compiler.Builder.Extension.Custom.Fields', [$this, 'getExtensionCustomFields'], true); - - $container->alias(FieldGroupControl::class, 'Compiler.Builder.Field.Group.Control') - ->share('Compiler.Builder.Field.Group.Control', [$this, 'getFieldGroupControl'], true); - - $container->alias(FieldNames::class, 'Compiler.Builder.Field.Names') - ->share('Compiler.Builder.Field.Names', [$this, 'getFieldNames'], true); - - $container->alias(FieldRelations::class, 'Compiler.Builder.Field.Relations') - ->share('Compiler.Builder.Field.Relations', [$this, 'getFieldRelations'], true); - - $container->alias(Filter::class, 'Compiler.Builder.Filter') - ->share('Compiler.Builder.Filter', [$this, 'getFilter'], true); - - $container->alias(FootableScripts::class, 'Compiler.Builder.Footable.Scripts') - ->share('Compiler.Builder.Footable.Scripts', [$this, 'getFootableScripts'], true); - - $container->alias(GetAsLookup::class, 'Compiler.Builder.Get.As.Lookup') - ->share('Compiler.Builder.Get.As.Lookup', [$this, 'getGetAsLookup'], true); - - $container->alias(GetModule::class, 'Compiler.Builder.Get.Module') - ->share('Compiler.Builder.Get.Module', [$this, 'getGetModule'], true); - - $container->alias(GoogleChart::class, 'Compiler.Builder.Google.Chart') - ->share('Compiler.Builder.Google.Chart', [$this, 'getGoogleChart'], true); - - $container->alias(HasPermissions::class, 'Compiler.Builder.Has.Permissions') - ->share('Compiler.Builder.Has.Permissions', [$this, 'getHasPermissions'], true); - - $container->alias(HiddenFields::class, 'Compiler.Builder.Hidden.Fields') - ->share('Compiler.Builder.Hidden.Fields', [$this, 'getHiddenFields'], true); - - $container->alias(History::class, 'Compiler.Builder.History') - ->share('Compiler.Builder.History', [$this, 'getHistory'], true); - - $container->alias(IntegerFields::class, 'Compiler.Builder.Integer.Fields') - ->share('Compiler.Builder.Integer.Fields', [$this, 'getIntegerFields'], true); - - $container->alias(ItemsMethodEximportString::class, 'Compiler.Builder.Items.Method.Eximport.String') - ->share('Compiler.Builder.Items.Method.Eximport.String', [$this, 'getItemsMethodEximportString'], true); - - $container->alias(ItemsMethodListString::class, 'Compiler.Builder.Items.Method.List.String') - ->share('Compiler.Builder.Items.Method.List.String', [$this, 'getItemsMethodListString'], true); - - $container->alias(JsonItem::class, 'Compiler.Builder.Json.Item') - ->share('Compiler.Builder.Json.Item', [$this, 'getJsonItem'], true); - - $container->alias(JsonItemArray::class, 'Compiler.Builder.Json.Item.Array') - ->share('Compiler.Builder.Json.Item.Array', [$this, 'getJsonItemArray'], true); - - $container->alias(JsonString::class, 'Compiler.Builder.Json.String') - ->share('Compiler.Builder.Json.String', [$this, 'getJsonString'], true); - - $container->alias(Layout::class, 'Compiler.Builder.Layout') - ->share('Compiler.Builder.Layout', [$this, 'getLayout'], true); - - $container->alias(LayoutData::class, 'Compiler.Builder.Layout.Data') - ->share('Compiler.Builder.Layout.Data', [$this, 'getLayoutData'], true); - - $container->alias(LibraryManager::class, 'Compiler.Builder.Library.Manager') - ->share('Compiler.Builder.Library.Manager', [$this, 'getLibraryManager'], true); - - $container->alias(ListFieldClass::class, 'Compiler.Builder.List.Field.Class') - ->share('Compiler.Builder.List.Field.Class', [$this, 'getListFieldClass'], true); - - $container->alias(ListHeadOverride::class, 'Compiler.Builder.List.Head.Override') - ->share('Compiler.Builder.List.Head.Override', [$this, 'getListHeadOverride'], true); - - $container->alias(ListJoin::class, 'Compiler.Builder.List.Join') - ->share('Compiler.Builder.List.Join', [$this, 'getListJoin'], true); - - $container->alias(Lists::class, 'Compiler.Builder.Lists') - ->share('Compiler.Builder.Lists', [$this, 'getLists'], true); - - $container->alias(MainTextField::class, 'Compiler.Builder.Main.Text.Field') - ->share('Compiler.Builder.Main.Text.Field', [$this, 'getMainTextField'], true); - - $container->alias(MetaData::class, 'Compiler.Builder.Meta.Data') - ->share('Compiler.Builder.Meta.Data', [$this, 'getMetaData'], true); - - $container->alias(ModelBasicField::class, 'Compiler.Builder.Model.Basic.Field') - ->share('Compiler.Builder.Model.Basic.Field', [$this, 'getModelBasicField'], true); - - $container->alias(ModelExpertField::class, 'Compiler.Builder.Model.Expert.Field') - ->share('Compiler.Builder.Model.Expert.Field', [$this, 'getModelExpertField'], true); - - $container->alias(ModelExpertFieldInitiator::class, 'Compiler.Builder.Model.Expert.Field.Initiator') - ->share('Compiler.Builder.Model.Expert.Field.Initiator', [$this, 'getModelExpertFieldInitiator'], true); - - $container->alias(ModelMediumField::class, 'Compiler.Builder.Model.Medium.Field') - ->share('Compiler.Builder.Model.Medium.Field', [$this, 'getModelMediumField'], true); - - $container->alias(ModelWhmcsField::class, 'Compiler.Builder.Model.Whmcs.Field') - ->share('Compiler.Builder.Model.Whmcs.Field', [$this, 'getModelWhmcsField'], true); - - $container->alias(MovedPublishingFields::class, 'Compiler.Builder.Moved.Publishing.Fields') - ->share('Compiler.Builder.Moved.Publishing.Fields', [$this, 'getMovedPublishingFields'], true); - - $container->alias(MysqlTableSetting::class, 'Compiler.Builder.Mysql.Table.Setting') - ->share('Compiler.Builder.Mysql.Table.Setting', [$this, 'getMysqlTableSetting'], true); - - $container->alias(NewPublishingFields::class, 'Compiler.Builder.New.Publishing.Fields') - ->share('Compiler.Builder.New.Publishing.Fields', [$this, 'getNewPublishingFields'], true); - - $container->alias(OrderZero::class, 'Compiler.Builder.Order.Zero') - ->share('Compiler.Builder.Order.Zero', [$this, 'getOrderZero'], true); - - $container->alias(OtherFilter::class, 'Compiler.Builder.Other.Filter') - ->share('Compiler.Builder.Other.Filter', [$this, 'getOtherFilter'], true); - - $container->alias(OtherGroup::class, 'Compiler.Builder.Other.Group') - ->share('Compiler.Builder.Other.Group', [$this, 'getOtherGroup'], true); - - $container->alias(OtherJoin::class, 'Compiler.Builder.Other.Join') - ->share('Compiler.Builder.Other.Join', [$this, 'getOtherJoin'], true); - - $container->alias(OtherOrder::class, 'Compiler.Builder.Other.Order') - ->share('Compiler.Builder.Other.Order', [$this, 'getOtherOrder'], true); - - $container->alias(OtherQuery::class, 'Compiler.Builder.Other.Query') - ->share('Compiler.Builder.Other.Query', [$this, 'getOtherQuery'], true); - - $container->alias(OtherWhere::class, 'Compiler.Builder.Other.Where') - ->share('Compiler.Builder.Other.Where', [$this, 'getOtherWhere'], true); - - $container->alias(PermissionAction::class, 'Compiler.Builder.Permission.Action') - ->share('Compiler.Builder.Permission.Action', [$this, 'getPermissionAction'], true); - - $container->alias(PermissionComponent::class, 'Compiler.Builder.Permission.Component') - ->share('Compiler.Builder.Permission.Component', [$this, 'getPermissionComponent'], true); - - $container->alias(PermissionCore::class, 'Compiler.Builder.Permission.Core') - ->share('Compiler.Builder.Permission.Core', [$this, 'getPermissionCore'], true); - - $container->alias(PermissionDashboard::class, 'Compiler.Builder.Permission.Dashboard') - ->share('Compiler.Builder.Permission.Dashboard', [$this, 'getPermissionDashboard'], true); - - $container->alias(PermissionGlobalAction::class, 'Compiler.Builder.Permission.Global.Action') - ->share('Compiler.Builder.Permission.Global.Action', [$this, 'getPermissionGlobalAction'], true); - - $container->alias(PermissionViews::class, 'Compiler.Builder.Permission.Views') - ->share('Compiler.Builder.Permission.Views', [$this, 'getPermissionViews'], true); - - $container->alias(ScriptMediaSwitch::class, 'Compiler.Builder.Script.Media.Switch') - ->share('Compiler.Builder.Script.Media.Switch', [$this, 'getScriptMediaSwitch'], true); - - $container->alias(ScriptUserSwitch::class, 'Compiler.Builder.Script.User.Switch') - ->share('Compiler.Builder.Script.User.Switch', [$this, 'getScriptUserSwitch'], true); - - $container->alias(Search::class, 'Compiler.Builder.Search') - ->share('Compiler.Builder.Search', [$this, 'getSearch'], true); - - $container->alias(SelectionTranslation::class, 'Compiler.Builder.Selection.Translation') - ->share('Compiler.Builder.Selection.Translation', [$this, 'getSelectionTranslation'], true); - - $container->alias(SiteDecrypt::class, 'Compiler.Builder.Site.Decrypt') - ->share('Compiler.Builder.Site.Decrypt', [$this, 'getSiteDecrypt'], true); - - $container->alias(SiteDynamicGet::class, 'Compiler.Builder.Site.Dynamic.Get') - ->share('Compiler.Builder.Site.Dynamic.Get', [$this, 'getSiteDynamicGet'], true); - - $container->alias(SiteEditView::class, 'Compiler.Builder.Site.Edit.View') - ->share('Compiler.Builder.Site.Edit.View', [$this, 'getSiteEditView'], true); - - $container->alias(SiteFieldData::class, 'Compiler.Builder.Site.Field.Data') - ->share('Compiler.Builder.Site.Field.Data', [$this, 'getSiteFieldData'], true); - - $container->alias(SiteFieldDecodeFilter::class, 'Compiler.Builder.Site.Field.Decode.Filter') - ->share('Compiler.Builder.Site.Field.Decode.Filter', [$this, 'getSiteFieldDecodeFilter'], true); - - $container->alias(SiteFields::class, 'Compiler.Builder.Site.Fields') - ->share('Compiler.Builder.Site.Fields', [$this, 'getSiteFields'], true); - - $container->alias(SiteMainGet::class, 'Compiler.Builder.Site.Main.Get') - ->share('Compiler.Builder.Site.Main.Get', [$this, 'getSiteMainGet'], true); - - $container->alias(Sort::class, 'Compiler.Builder.Sort') - ->share('Compiler.Builder.Sort', [$this, 'getSort'], true); - - $container->alias(TabCounter::class, 'Compiler.Builder.Tab.Counter') - ->share('Compiler.Builder.Tab.Counter', [$this, 'getTabCounter'], true); - - $container->alias(Tags::class, 'Compiler.Builder.Tags') - ->share('Compiler.Builder.Tags', [$this, 'getTags'], true); - - $container->alias(TemplateData::class, 'Compiler.Builder.Template.Data') - ->share('Compiler.Builder.Template.Data', [$this, 'getTemplateData'], true); - - $container->alias(Title::class, 'Compiler.Builder.Title') - ->share('Compiler.Builder.Title', [$this, 'getTitle'], true); - - $container->alias(UikitComp::class, 'Compiler.Builder.Uikit.Comp') - ->share('Compiler.Builder.Uikit.Comp', [$this, 'getUikitComp'], true); - - $container->alias(UpdateMysql::class, 'Compiler.Builder.Update.Mysql') - ->share('Compiler.Builder.Update.Mysql', [$this, 'getUpdateMysql'], true); - } - - /** - * Get The AccessSwitch Class. - * - * @param Container $container The DI container. - * - * @return AccessSwitch - * @since 3.2.0 - */ - public function getAccessSwitch(Container $container): AccessSwitch - { - return new AccessSwitch(); - } - - /** - * Get The AccessSwitchList Class. - * - * @param Container $container The DI container. - * - * @return AccessSwitchList - * @since 3.2.0 - */ - public function getAccessSwitchList(Container $container): AccessSwitchList - { - return new AccessSwitchList(); - } - - /** - * Get The AdminFilterType Class. - * - * @param Container $container The DI container. - * - * @return AdminFilterType - * @since 3.2.0 - */ - public function getAdminFilterType(Container $container): AdminFilterType - { - return new AdminFilterType(); - } - - /** - * Get The Alias Class. - * - * @param Container $container The DI container. - * - * @return Alias - * @since 3.2.0 - */ - public function getAlias(Container $container): Alias - { - return new Alias(); - } - - /** - * Get The BaseSixFour Class. - * - * @param Container $container The DI container. - * - * @return BaseSixFour - * @since 3.2.0 - */ - public function getBaseSixFour(Container $container): BaseSixFour - { - return new BaseSixFour(); - } - - /** - * Get The Category Class. - * - * @param Container $container The DI container. - * - * @return Category - * @since 3.2.0 - */ - public function getCategory(Container $container): Category - { - return new Category(); - } - - /** - * Get The CategoryCode Class. - * - * @param Container $container The DI container. - * - * @return CategoryCode - * @since 3.2.0 - */ - public function getCategoryCode(Container $container): CategoryCode - { - return new CategoryCode(); - } - - /** - * Get The CategoryOtherName Class. - * - * @param Container $container The DI container. - * - * @return CategoryOtherName - * @since 3.2.0 - */ - public function getCategoryOtherName(Container $container): CategoryOtherName - { - return new CategoryOtherName(); - } - - /** - * Get The CheckBox Class. - * - * @param Container $container The DI container. - * - * @return CheckBox - * @since 3.2.0 - */ - public function getCheckBox(Container $container): CheckBox - { - return new CheckBox(); - } - - /** - * Get The ComponentFields Class. - * - * @param Container $container The DI container. - * - * @return ComponentFields - * @since 3.2.0 - */ - public function getComponentFields(Container $container): ComponentFields - { - return new ComponentFields(); - } - - /** - * Get The ContentMulti Class. - * - * @param Container $container The DI container. - * - * @return ContentMulti - * @since 3.2.0 - */ - public function getContentMulti(Container $container): ContentMulti - { - return new ContentMulti(); - } - - /** - * Get The ContentOne Class. - * - * @param Container $container The DI container. - * - * @return ContentOne - * @since 3.2.0 - */ - public function getContentOne(Container $container): ContentOne - { - return new ContentOne(); - } - - /** - * Get The CustomAlias Class. - * - * @param Container $container The DI container. - * - * @return CustomAlias - * @since 3.2.0 - */ - public function getCustomAlias(Container $container): CustomAlias - { - return new CustomAlias(); - } - - /** - * Get The CustomField Class. - * - * @param Container $container The DI container. - * - * @return CustomField - * @since 3.2.0 - */ - public function getCustomField(Container $container): CustomField - { - return new CustomField(); - } - - /** - * Get The CustomFieldLinks Class. - * - * @param Container $container The DI container. - * - * @return CustomFieldLinks - * @since 3.2.0 - */ - public function getCustomFieldLinks(Container $container): CustomFieldLinks - { - return new CustomFieldLinks(); - } - - /** - * Get The CustomList Class. - * - * @param Container $container The DI container. - * - * @return CustomList - * @since 3.2.0 - */ - public function getCustomList(Container $container): CustomList - { - return new CustomList(); - } - - /** - * Get The CustomTabs Class. - * - * @param Container $container The DI container. - * - * @return CustomTabs - * @since 3.2.0 - */ - public function getCustomTabs(Container $container): CustomTabs - { - return new CustomTabs(); - } - - /** - * Get The DatabaseKeys Class. - * - * @param Container $container The DI container. - * - * @return DatabaseKeys - * @since 3.2.0 - */ - public function getDatabaseKeys(Container $container): DatabaseKeys - { - return new DatabaseKeys(); - } - - /** - * Get The DatabaseTables Class. - * - * @param Container $container The DI container. - * - * @return DatabaseTables - * @since 3.2.0 - */ - public function getDatabaseTables(Container $container): DatabaseTables - { - return new DatabaseTables(); - } - - /** - * Get The DatabaseUniqueGuid Class. - * - * @param Container $container The DI container. - * - * @return DatabaseUniqueGuid - * @since 3.2.0 - */ - public function getDatabaseUniqueGuid(Container $container): DatabaseUniqueGuid - { - return new DatabaseUniqueGuid(); - } - - /** - * Get The DatabaseUniqueKeys Class. - * - * @param Container $container The DI container. - * - * @return DatabaseUniqueKeys - * @since 3.2.0 - */ - public function getDatabaseUniqueKeys(Container $container): DatabaseUniqueKeys - { - return new DatabaseUniqueKeys(); - } - - /** - * Get The DoNotEscape Class. - * - * @param Container $container The DI container. - * - * @return DoNotEscape - * @since 3.2.0 - */ - public function getDoNotEscape(Container $container): DoNotEscape - { - return new DoNotEscape(); - } - - /** - * Get The DynamicFields Class. - * - * @param Container $container The DI container. - * - * @return DynamicFields - * @since 3.2.0 - */ - public function getDynamicFields(Container $container): DynamicFields - { - return new DynamicFields(); - } - - /** - * Get The ExtensionCustomFields Class. - * - * @param Container $container The DI container. - * - * @return ExtensionCustomFields - * @since 3.2.0 - */ - public function getExtensionCustomFields(Container $container): ExtensionCustomFields - { - return new ExtensionCustomFields(); - } - - /** - * Get The FieldGroupControl Class. - * - * @param Container $container The DI container. - * - * @return FieldGroupControl - * @since 3.2.0 - */ - public function getFieldGroupControl(Container $container): FieldGroupControl - { - return new FieldGroupControl(); - } - - /** - * Get The FieldNames Class. - * - * @param Container $container The DI container. - * - * @return FieldNames - * @since 3.2.0 - */ - public function getFieldNames(Container $container): FieldNames - { - return new FieldNames(); - } - - /** - * Get The FieldRelations Class. - * - * @param Container $container The DI container. - * - * @return FieldRelations - * @since 3.2.0 - */ - public function getFieldRelations(Container $container): FieldRelations - { - return new FieldRelations(); - } - - /** - * Get The Filter Class. - * - * @param Container $container The DI container. - * - * @return Filter - * @since 3.2.0 - */ - public function getFilter(Container $container): Filter - { - return new Filter(); - } - - /** - * Get The FootableScripts Class. - * - * @param Container $container The DI container. - * - * @return FootableScripts - * @since 3.2.0 - */ - public function getFootableScripts(Container $container): FootableScripts - { - return new FootableScripts(); - } - - /** - * Get The GetAsLookup Class. - * - * @param Container $container The DI container. - * - * @return GetAsLookup - * @since 3.2.0 - */ - public function getGetAsLookup(Container $container): GetAsLookup - { - return new GetAsLookup(); - } - - /** - * Get The GetModule Class. - * - * @param Container $container The DI container. - * - * @return GetModule - * @since 3.2.0 - */ - public function getGetModule(Container $container): GetModule - { - return new GetModule(); - } - - /** - * Get The GoogleChart Class. - * - * @param Container $container The DI container. - * - * @return GoogleChart - * @since 3.2.0 - */ - public function getGoogleChart(Container $container): GoogleChart - { - return new GoogleChart(); - } - - /** - * Get The HasPermissions Class. - * - * @param Container $container The DI container. - * - * @return HasPermissions - * @since 3.2.0 - */ - public function getHasPermissions(Container $container): HasPermissions - { - return new HasPermissions(); - } - - /** - * Get The HiddenFields Class. - * - * @param Container $container The DI container. - * - * @return HiddenFields - * @since 3.2.0 - */ - public function getHiddenFields(Container $container): HiddenFields - { - return new HiddenFields(); - } - - /** - * Get The History Class. - * - * @param Container $container The DI container. - * - * @return History - * @since 3.2.0 - */ - public function getHistory(Container $container): History - { - return new History(); - } - - /** - * Get The IntegerFields Class. - * - * @param Container $container The DI container. - * - * @return IntegerFields - * @since 3.2.0 - */ - public function getIntegerFields(Container $container): IntegerFields - { - return new IntegerFields(); - } - - /** - * Get The ItemsMethodEximportString Class. - * - * @param Container $container The DI container. - * - * @return ItemsMethodEximportString - * @since 3.2.0 - */ - public function getItemsMethodEximportString(Container $container): ItemsMethodEximportString - { - return new ItemsMethodEximportString(); - } - - /** - * Get The ItemsMethodListString Class. - * - * @param Container $container The DI container. - * - * @return ItemsMethodListString - * @since 3.2.0 - */ - public function getItemsMethodListString(Container $container): ItemsMethodListString - { - return new ItemsMethodListString(); - } - - /** - * Get The JsonItem Class. - * - * @param Container $container The DI container. - * - * @return JsonItem - * @since 3.2.0 - */ - public function getJsonItem(Container $container): JsonItem - { - return new JsonItem(); - } - - /** - * Get The JsonItemArray Class. - * - * @param Container $container The DI container. - * - * @return JsonItemArray - * @since 3.2.0 - */ - public function getJsonItemArray(Container $container): JsonItemArray - { - return new JsonItemArray(); - } - - /** - * Get The JsonString Class. - * - * @param Container $container The DI container. - * - * @return JsonString - * @since 3.2.0 - */ - public function getJsonString(Container $container): JsonString - { - return new JsonString(); - } - - /** - * Get The Layout Class. - * - * @param Container $container The DI container. - * - * @return Layout - * @since 3.2.0 - */ - public function getLayout(Container $container): Layout - { - return new Layout(); - } - - /** - * Get The LayoutData Class. - * - * @param Container $container The DI container. - * - * @return LayoutData - * @since 3.2.0 - */ - public function getLayoutData(Container $container): LayoutData - { - return new LayoutData(); - } - - /** - * Get The LibraryManager Class. - * - * @param Container $container The DI container. - * - * @return LibraryManager - * @since 3.2.0 - */ - public function getLibraryManager(Container $container): LibraryManager - { - return new LibraryManager(); - } - - /** - * Get The ListFieldClass Class. - * - * @param Container $container The DI container. - * - * @return ListFieldClass - * @since 3.2.0 - */ - public function getListFieldClass(Container $container): ListFieldClass - { - return new ListFieldClass(); - } - - /** - * Get The ListHeadOverride Class. - * - * @param Container $container The DI container. - * - * @return ListHeadOverride - * @since 3.2.0 - */ - public function getListHeadOverride(Container $container): ListHeadOverride - { - return new ListHeadOverride(); - } - - /** - * Get The ListJoin Class. - * - * @param Container $container The DI container. - * - * @return ListJoin - * @since 3.2.0 - */ - public function getListJoin(Container $container): ListJoin - { - return new ListJoin(); - } - - /** - * Get The Lists Class. - * - * @param Container $container The DI container. - * - * @return Lists - * @since 3.2.0 - */ - public function getLists(Container $container): Lists - { - return new Lists(); - } - - /** - * Get The MainTextField Class. - * - * @param Container $container The DI container. - * - * @return MainTextField - * @since 3.2.0 - */ - public function getMainTextField(Container $container): MainTextField - { - return new MainTextField(); - } - - /** - * Get The MetaData Class. - * - * @param Container $container The DI container. - * - * @return MetaData - * @since 3.2.0 - */ - public function getMetaData(Container $container): MetaData - { - return new MetaData(); - } - - /** - * Get The ModelBasicField Class. - * - * @param Container $container The DI container. - * - * @return ModelBasicField - * @since 3.2.0 - */ - public function getModelBasicField(Container $container): ModelBasicField - { - return new ModelBasicField(); - } - - /** - * Get The ModelExpertField Class. - * - * @param Container $container The DI container. - * - * @return ModelExpertField - * @since 3.2.0 - */ - public function getModelExpertField(Container $container): ModelExpertField - { - return new ModelExpertField(); - } - - /** - * Get The ModelExpertFieldInitiator Class. - * - * @param Container $container The DI container. - * - * @return ModelExpertFieldInitiator - * @since 3.2.0 - */ - public function getModelExpertFieldInitiator(Container $container): ModelExpertFieldInitiator - { - return new ModelExpertFieldInitiator(); - } - - /** - * Get The ModelMediumField Class. - * - * @param Container $container The DI container. - * - * @return ModelMediumField - * @since 3.2.0 - */ - public function getModelMediumField(Container $container): ModelMediumField - { - return new ModelMediumField(); - } - - /** - * Get The ModelWhmcsField Class. - * - * @param Container $container The DI container. - * - * @return ModelWhmcsField - * @since 3.2.0 - */ - public function getModelWhmcsField(Container $container): ModelWhmcsField - { - return new ModelWhmcsField(); - } - - /** - * Get The MovedPublishingFields Class. - * - * @param Container $container The DI container. - * - * @return MovedPublishingFields - * @since 3.2.0 - */ - public function getMovedPublishingFields(Container $container): MovedPublishingFields - { - return new MovedPublishingFields(); - } - - /** - * Get The MysqlTableSetting Class. - * - * @param Container $container The DI container. - * - * @return MysqlTableSetting - * @since 3.2.0 - */ - public function getMysqlTableSetting(Container $container): MysqlTableSetting - { - return new MysqlTableSetting(); - } - - /** - * Get The NewPublishingFields Class. - * - * @param Container $container The DI container. - * - * @return NewPublishingFields - * @since 3.2.0 - */ - public function getNewPublishingFields(Container $container): NewPublishingFields - { - return new NewPublishingFields(); - } - - /** - * Get The OrderZero Class. - * - * @param Container $container The DI container. - * - * @return OrderZero - * @since 3.2.0 - */ - public function getOrderZero(Container $container): OrderZero - { - return new OrderZero(); - } - - /** - * Get The OtherFilter Class. - * - * @param Container $container The DI container. - * - * @return OtherFilter - * @since 3.2.0 - */ - public function getOtherFilter(Container $container): OtherFilter - { - return new OtherFilter(); - } - - /** - * Get The OtherGroup Class. - * - * @param Container $container The DI container. - * - * @return OtherGroup - * @since 3.2.0 - */ - public function getOtherGroup(Container $container): OtherGroup - { - return new OtherGroup(); - } - - /** - * Get The OtherJoin Class. - * - * @param Container $container The DI container. - * - * @return OtherJoin - * @since 3.2.0 - */ - public function getOtherJoin(Container $container): OtherJoin - { - return new OtherJoin(); - } - - /** - * Get The OtherOrder Class. - * - * @param Container $container The DI container. - * - * @return OtherOrder - * @since 3.2.0 - */ - public function getOtherOrder(Container $container): OtherOrder - { - return new OtherOrder(); - } - - /** - * Get The OtherQuery Class. - * - * @param Container $container The DI container. - * - * @return OtherQuery - * @since 3.2.0 - */ - public function getOtherQuery(Container $container): OtherQuery - { - return new OtherQuery(); - } - - /** - * Get The OtherWhere Class. - * - * @param Container $container The DI container. - * - * @return OtherWhere - * @since 3.2.0 - */ - public function getOtherWhere(Container $container): OtherWhere - { - return new OtherWhere(); - } - - /** - * Get The PermissionAction Class. - * - * @param Container $container The DI container. - * - * @return PermissionAction - * @since 3.2.0 - */ - public function getPermissionAction(Container $container): PermissionAction - { - return new PermissionAction(); - } - - /** - * Get The PermissionComponent Class. - * - * @param Container $container The DI container. - * - * @return PermissionComponent - * @since 3.2.0 - */ - public function getPermissionComponent(Container $container): PermissionComponent - { - return new PermissionComponent(); - } - - /** - * Get The PermissionCore Class. - * - * @param Container $container The DI container. - * - * @return PermissionCore - * @since 3.2.0 - */ - public function getPermissionCore(Container $container): PermissionCore - { - return new PermissionCore(); - } - - /** - * Get The PermissionDashboard Class. - * - * @param Container $container The DI container. - * - * @return PermissionDashboard - * @since 3.2.0 - */ - public function getPermissionDashboard(Container $container): PermissionDashboard - { - return new PermissionDashboard(); - } - - /** - * Get The PermissionGlobalAction Class. - * - * @param Container $container The DI container. - * - * @return PermissionGlobalAction - * @since 3.2.0 - */ - public function getPermissionGlobalAction(Container $container): PermissionGlobalAction - { - return new PermissionGlobalAction(); - } - - /** - * Get The PermissionViews Class. - * - * @param Container $container The DI container. - * - * @return PermissionViews - * @since 3.2.0 - */ - public function getPermissionViews(Container $container): PermissionViews - { - return new PermissionViews(); - } - - /** - * Get The ScriptMediaSwitch Class. - * - * @param Container $container The DI container. - * - * @return ScriptMediaSwitch - * @since 3.2.0 - */ - public function getScriptMediaSwitch(Container $container): ScriptMediaSwitch - { - return new ScriptMediaSwitch(); - } - - /** - * Get The ScriptUserSwitch Class. - * - * @param Container $container The DI container. - * - * @return ScriptUserSwitch - * @since 3.2.0 - */ - public function getScriptUserSwitch(Container $container): ScriptUserSwitch - { - return new ScriptUserSwitch(); - } - - /** - * Get The Search Class. - * - * @param Container $container The DI container. - * - * @return Search - * @since 3.2.0 - */ - public function getSearch(Container $container): Search - { - return new Search(); - } - - /** - * Get The SelectionTranslation Class. - * - * @param Container $container The DI container. - * - * @return SelectionTranslation - * @since 3.2.0 - */ - public function getSelectionTranslation(Container $container): SelectionTranslation - { - return new SelectionTranslation(); - } - - /** - * Get The SiteDecrypt Class. - * - * @param Container $container The DI container. - * - * @return SiteDecrypt - * @since 3.2.0 - */ - public function getSiteDecrypt(Container $container): SiteDecrypt - { - return new SiteDecrypt(); - } - - /** - * Get The SiteDynamicGet Class. - * - * @param Container $container The DI container. - * - * @return SiteDynamicGet - * @since 3.2.0 - */ - public function getSiteDynamicGet(Container $container): SiteDynamicGet - { - return new SiteDynamicGet(); - } - - /** - * Get The SiteEditView Class. - * - * @param Container $container The DI container. - * - * @return SiteEditView - * @since 3.2.0 - */ - public function getSiteEditView(Container $container): SiteEditView - { - return new SiteEditView(); - } - - /** - * Get The SiteFieldData Class. - * - * @param Container $container The DI container. - * - * @return SiteFieldData - * @since 3.2.0 - */ - public function getSiteFieldData(Container $container): SiteFieldData - { - return new SiteFieldData(); - } - - /** - * Get The SiteFieldDecodeFilter Class. - * - * @param Container $container The DI container. - * - * @return SiteFieldDecodeFilter - * @since 3.2.0 - */ - public function getSiteFieldDecodeFilter(Container $container): SiteFieldDecodeFilter - { - return new SiteFieldDecodeFilter(); - } - - /** - * Get The SiteFields Class. - * - * @param Container $container The DI container. - * - * @return SiteFields - * @since 3.2.0 - */ - public function getSiteFields(Container $container): SiteFields - { - return new SiteFields(); - } - - /** - * Get The SiteMainGet Class. - * - * @param Container $container The DI container. - * - * @return SiteMainGet - * @since 3.2.0 - */ - public function getSiteMainGet(Container $container): SiteMainGet - { - return new SiteMainGet(); - } - - /** - * Get The Sort Class. - * - * @param Container $container The DI container. - * - * @return Sort - * @since 3.2.0 - */ - public function getSort(Container $container): Sort - { - return new Sort(); - } - - /** - * Get The TabCounter Class. - * - * @param Container $container The DI container. - * - * @return TabCounter - * @since 3.2.0 - */ - public function getTabCounter(Container $container): TabCounter - { - return new TabCounter(); - } - - /** - * Get The Tags Class. - * - * @param Container $container The DI container. - * - * @return Tags - * @since 3.2.0 - */ - public function getTags(Container $container): Tags - { - return new Tags(); - } - - /** - * Get The TemplateData Class. - * - * @param Container $container The DI container. - * - * @return TemplateData - * @since 3.2.0 - */ - public function getTemplateData(Container $container): TemplateData - { - return new TemplateData(); - } - - /** - * Get The Title Class. - * - * @param Container $container The DI container. - * - * @return Title - * @since 3.2.0 - */ - public function getTitle(Container $container): Title - { - return new Title(); - } - - /** - * Get The UikitComp Class. - * - * @param Container $container The DI container. - * - * @return UikitComp - * @since 3.2.0 - */ - public function getUikitComp(Container $container): UikitComp - { - return new UikitComp(); - } - - /** - * Get The UpdateMysql Class. - * - * @param Container $container The DI container. - * - * @return UpdateMysql - * @since 3.2.0 - */ - public function getUpdateMysql(Container $container): UpdateMysql - { - return new UpdateMysql(); - } -} - diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/BuilderAJ.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/BuilderAJ.php new file mode 100644 index 000000000..61eae650f --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/BuilderAJ.php @@ -0,0 +1,870 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Componentbuilder\Compiler\Builder\AccessSwitch; +use VDM\Joomla\Componentbuilder\Compiler\Builder\AccessSwitchList; +use VDM\Joomla\Componentbuilder\Compiler\Builder\AssetsRules; +use VDM\Joomla\Componentbuilder\Compiler\Builder\AdminFilterType; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Alias; +use VDM\Joomla\Componentbuilder\Compiler\Builder\BaseSixFour; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Category; +use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryCode; +use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryOtherName; +use VDM\Joomla\Componentbuilder\Compiler\Builder\CheckBox; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ComponentFields; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsets; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ConfigFieldsetsCustomfield; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentMulti; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Contributors; +use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomAlias; +use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomField; +use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomFieldLinks; +use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomList; +use VDM\Joomla\Componentbuilder\Compiler\Builder\CustomTabs; +use VDM\Joomla\Componentbuilder\Compiler\Builder\DatabaseKeys; +use VDM\Joomla\Componentbuilder\Compiler\Builder\DatabaseTables; +use VDM\Joomla\Componentbuilder\Compiler\Builder\DatabaseUniqueGuid; +use VDM\Joomla\Componentbuilder\Compiler\Builder\DatabaseUniqueKeys; +use VDM\Joomla\Componentbuilder\Compiler\Builder\DatabaseUninstall; +use VDM\Joomla\Componentbuilder\Compiler\Builder\DoNotEscape; +use VDM\Joomla\Componentbuilder\Compiler\Builder\DynamicFields; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ExtensionCustomFields; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ExtensionsParams; +use VDM\Joomla\Componentbuilder\Compiler\Builder\FieldGroupControl; +use VDM\Joomla\Componentbuilder\Compiler\Builder\FieldNames; +use VDM\Joomla\Componentbuilder\Compiler\Builder\FieldRelations; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Filter; +use VDM\Joomla\Componentbuilder\Compiler\Builder\FootableScripts; +use VDM\Joomla\Componentbuilder\Compiler\Builder\FrontendParams; +use VDM\Joomla\Componentbuilder\Compiler\Builder\GetAsLookup; +use VDM\Joomla\Componentbuilder\Compiler\Builder\GetModule; +use VDM\Joomla\Componentbuilder\Compiler\Builder\GoogleChart; +use VDM\Joomla\Componentbuilder\Compiler\Builder\HasMenuGlobal; +use VDM\Joomla\Componentbuilder\Compiler\Builder\HasPermissions; +use VDM\Joomla\Componentbuilder\Compiler\Builder\HiddenFields; +use VDM\Joomla\Componentbuilder\Compiler\Builder\History; +use VDM\Joomla\Componentbuilder\Compiler\Builder\IntegerFields; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ItemsMethodEximportString; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ItemsMethodListString; +use VDM\Joomla\Componentbuilder\Compiler\Builder\JsonItem; +use VDM\Joomla\Componentbuilder\Compiler\Builder\JsonItemArray; +use VDM\Joomla\Componentbuilder\Compiler\Builder\JsonString; + + +/** + * Builder A-J Service Provider + * + * @since 3.2.0 + */ +class BuilderAJ implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(AccessSwitch::class, 'Compiler.Builder.Access.Switch') + ->share('Compiler.Builder.Access.Switch', [$this, 'getAccessSwitch'], true); + + $container->alias(AccessSwitchList::class, 'Compiler.Builder.Access.Switch.List') + ->share('Compiler.Builder.Access.Switch.List', [$this, 'getAccessSwitchList'], true); + + $container->alias(AssetsRules::class, 'Compiler.Builder.Assets.Rules') + ->share('Compiler.Builder.Assets.Rules', [$this, 'getAssetsRules'], true); + + $container->alias(AdminFilterType::class, 'Compiler.Builder.Admin.Filter.Type') + ->share('Compiler.Builder.Admin.Filter.Type', [$this, 'getAdminFilterType'], true); + + $container->alias(Alias::class, 'Compiler.Builder.Alias') + ->share('Compiler.Builder.Alias', [$this, 'getAlias'], true); + + $container->alias(BaseSixFour::class, 'Compiler.Builder.Base.Six.Four') + ->share('Compiler.Builder.Base.Six.Four', [$this, 'getBaseSixFour'], true); + + $container->alias(Category::class, 'Compiler.Builder.Category') + ->share('Compiler.Builder.Category', [$this, 'getCategory'], true); + + $container->alias(CategoryCode::class, 'Compiler.Builder.Category.Code') + ->share('Compiler.Builder.Category.Code', [$this, 'getCategoryCode'], true); + + $container->alias(CategoryOtherName::class, 'Compiler.Builder.Category.Other.Name') + ->share('Compiler.Builder.Category.Other.Name', [$this, 'getCategoryOtherName'], true); + + $container->alias(CheckBox::class, 'Compiler.Builder.Check.Box') + ->share('Compiler.Builder.Check.Box', [$this, 'getCheckBox'], true); + + $container->alias(ComponentFields::class, 'Compiler.Builder.Component.Fields') + ->share('Compiler.Builder.Component.Fields', [$this, 'getComponentFields'], true); + + $container->alias(ConfigFieldsets::class, 'Compiler.Builder.Config.Fieldsets') + ->share('Compiler.Builder.Config.Fieldsets', [$this, 'getConfigFieldsets'], true); + + $container->alias(ConfigFieldsetsCustomfield::class, 'Compiler.Builder.Config.Fieldsets.Customfield') + ->share('Compiler.Builder.Config.Fieldsets.Customfield', [$this, 'getConfigFieldsetsCustomfield'], true); + + $container->alias(ContentMulti::class, 'Compiler.Builder.Content.Multi') + ->share('Compiler.Builder.Content.Multi', [$this, 'getContentMulti'], true); + + $container->alias(ContentOne::class, 'Compiler.Builder.Content.One') + ->share('Compiler.Builder.Content.One', [$this, 'getContentOne'], true); + + $container->alias(Contributors::class, 'Compiler.Builder.Contributors') + ->share('Compiler.Builder.Contributors', [$this, 'getContributors'], true); + + $container->alias(CustomAlias::class, 'Compiler.Builder.Custom.Alias') + ->share('Compiler.Builder.Custom.Alias', [$this, 'getCustomAlias'], true); + + $container->alias(CustomField::class, 'Compiler.Builder.Custom.Field') + ->share('Compiler.Builder.Custom.Field', [$this, 'getCustomField'], true); + + $container->alias(CustomFieldLinks::class, 'Compiler.Builder.Custom.Field.Links') + ->share('Compiler.Builder.Custom.Field.Links', [$this, 'getCustomFieldLinks'], true); + + $container->alias(CustomList::class, 'Compiler.Builder.Custom.List') + ->share('Compiler.Builder.Custom.List', [$this, 'getCustomList'], true); + + $container->alias(CustomTabs::class, 'Compiler.Builder.Custom.Tabs') + ->share('Compiler.Builder.Custom.Tabs', [$this, 'getCustomTabs'], true); + + $container->alias(DatabaseKeys::class, 'Compiler.Builder.Database.Keys') + ->share('Compiler.Builder.Database.Keys', [$this, 'getDatabaseKeys'], true); + + $container->alias(DatabaseTables::class, 'Compiler.Builder.Database.Tables') + ->share('Compiler.Builder.Database.Tables', [$this, 'getDatabaseTables'], true); + + $container->alias(DatabaseUniqueGuid::class, 'Compiler.Builder.Database.Unique.Guid') + ->share('Compiler.Builder.Database.Unique.Guid', [$this, 'getDatabaseUniqueGuid'], true); + + $container->alias(DatabaseUniqueKeys::class, 'Compiler.Builder.Database.Unique.Keys') + ->share('Compiler.Builder.Database.Unique.Keys', [$this, 'getDatabaseUniqueKeys'], true); + + $container->alias(DatabaseUninstall::class, 'Compiler.Builder.Database.Uninstall') + ->share('Compiler.Builder.Database.Uninstall', [$this, 'getDatabaseUninstall'], true); + + $container->alias(DoNotEscape::class, 'Compiler.Builder.Do.Not.Escape') + ->share('Compiler.Builder.Do.Not.Escape', [$this, 'getDoNotEscape'], true); + + $container->alias(DynamicFields::class, 'Compiler.Builder.Dynamic.Fields') + ->share('Compiler.Builder.Dynamic.Fields', [$this, 'getDynamicFields'], true); + + $container->alias(ExtensionCustomFields::class, 'Compiler.Builder.Extension.Custom.Fields') + ->share('Compiler.Builder.Extension.Custom.Fields', [$this, 'getExtensionCustomFields'], true); + + $container->alias(ExtensionsParams::class, 'Compiler.Builder.Extensions.Params') + ->share('Compiler.Builder.Extensions.Params', [$this, 'getExtensionsParams'], true); + + $container->alias(FieldGroupControl::class, 'Compiler.Builder.Field.Group.Control') + ->share('Compiler.Builder.Field.Group.Control', [$this, 'getFieldGroupControl'], true); + + $container->alias(FieldNames::class, 'Compiler.Builder.Field.Names') + ->share('Compiler.Builder.Field.Names', [$this, 'getFieldNames'], true); + + $container->alias(FieldRelations::class, 'Compiler.Builder.Field.Relations') + ->share('Compiler.Builder.Field.Relations', [$this, 'getFieldRelations'], true); + + $container->alias(Filter::class, 'Compiler.Builder.Filter') + ->share('Compiler.Builder.Filter', [$this, 'getFilter'], true); + + $container->alias(FootableScripts::class, 'Compiler.Builder.Footable.Scripts') + ->share('Compiler.Builder.Footable.Scripts', [$this, 'getFootableScripts'], true); + + $container->alias(FrontendParams::class, 'Compiler.Builder.Frontend.Params') + ->share('Compiler.Builder.Frontend.Params', [$this, 'getFrontendParams'], true); + + $container->alias(GetAsLookup::class, 'Compiler.Builder.Get.As.Lookup') + ->share('Compiler.Builder.Get.As.Lookup', [$this, 'getGetAsLookup'], true); + + $container->alias(GetModule::class, 'Compiler.Builder.Get.Module') + ->share('Compiler.Builder.Get.Module', [$this, 'getGetModule'], true); + + $container->alias(GoogleChart::class, 'Compiler.Builder.Google.Chart') + ->share('Compiler.Builder.Google.Chart', [$this, 'getGoogleChart'], true); + + $container->alias(HasMenuGlobal::class, 'Compiler.Builder.Has.Menu.Global') + ->share('Compiler.Builder.Has.Menu.Global', [$this, 'getHasMenuGlobal'], true); + + $container->alias(HasPermissions::class, 'Compiler.Builder.Has.Permissions') + ->share('Compiler.Builder.Has.Permissions', [$this, 'getHasPermissions'], true); + + $container->alias(HiddenFields::class, 'Compiler.Builder.Hidden.Fields') + ->share('Compiler.Builder.Hidden.Fields', [$this, 'getHiddenFields'], true); + + $container->alias(History::class, 'Compiler.Builder.History') + ->share('Compiler.Builder.History', [$this, 'getHistory'], true); + + $container->alias(IntegerFields::class, 'Compiler.Builder.Integer.Fields') + ->share('Compiler.Builder.Integer.Fields', [$this, 'getIntegerFields'], true); + + $container->alias(ItemsMethodEximportString::class, 'Compiler.Builder.Items.Method.Eximport.String') + ->share('Compiler.Builder.Items.Method.Eximport.String', [$this, 'getItemsMethodEximportString'], true); + + $container->alias(ItemsMethodListString::class, 'Compiler.Builder.Items.Method.List.String') + ->share('Compiler.Builder.Items.Method.List.String', [$this, 'getItemsMethodListString'], true); + + $container->alias(JsonItem::class, 'Compiler.Builder.Json.Item') + ->share('Compiler.Builder.Json.Item', [$this, 'getJsonItem'], true); + + $container->alias(JsonItemArray::class, 'Compiler.Builder.Json.Item.Array') + ->share('Compiler.Builder.Json.Item.Array', [$this, 'getJsonItemArray'], true); + + $container->alias(JsonString::class, 'Compiler.Builder.Json.String') + ->share('Compiler.Builder.Json.String', [$this, 'getJsonString'], true); + } + + /** + * Get The AccessSwitch Class. + * + * @param Container $container The DI container. + * + * @return AccessSwitch + * @since 3.2.0 + */ + public function getAccessSwitch(Container $container): AccessSwitch + { + return new AccessSwitch(); + } + + /** + * Get The AccessSwitchList Class. + * + * @param Container $container The DI container. + * + * @return AccessSwitchList + * @since 3.2.0 + */ + public function getAccessSwitchList(Container $container): AccessSwitchList + { + return new AccessSwitchList(); + } + + /** + * Get The AssetsRules Class. + * + * @param Container $container The DI container. + * + * @return AssetsRules + * @since 3.2.0 + */ + public function getAssetsRules(Container $container): AssetsRules + { + return new AssetsRules(); + } + + /** + * Get The AdminFilterType Class. + * + * @param Container $container The DI container. + * + * @return AdminFilterType + * @since 3.2.0 + */ + public function getAdminFilterType(Container $container): AdminFilterType + { + return new AdminFilterType(); + } + + /** + * Get The Alias Class. + * + * @param Container $container The DI container. + * + * @return Alias + * @since 3.2.0 + */ + public function getAlias(Container $container): Alias + { + return new Alias(); + } + + /** + * Get The BaseSixFour Class. + * + * @param Container $container The DI container. + * + * @return BaseSixFour + * @since 3.2.0 + */ + public function getBaseSixFour(Container $container): BaseSixFour + { + return new BaseSixFour(); + } + + /** + * Get The Category Class. + * + * @param Container $container The DI container. + * + * @return Category + * @since 3.2.0 + */ + public function getCategory(Container $container): Category + { + return new Category(); + } + + /** + * Get The CategoryCode Class. + * + * @param Container $container The DI container. + * + * @return CategoryCode + * @since 3.2.0 + */ + public function getCategoryCode(Container $container): CategoryCode + { + return new CategoryCode(); + } + + /** + * Get The CategoryOtherName Class. + * + * @param Container $container The DI container. + * + * @return CategoryOtherName + * @since 3.2.0 + */ + public function getCategoryOtherName(Container $container): CategoryOtherName + { + return new CategoryOtherName(); + } + + /** + * Get The CheckBox Class. + * + * @param Container $container The DI container. + * + * @return CheckBox + * @since 3.2.0 + */ + public function getCheckBox(Container $container): CheckBox + { + return new CheckBox(); + } + + /** + * Get The ComponentFields Class. + * + * @param Container $container The DI container. + * + * @return ComponentFields + * @since 3.2.0 + */ + public function getComponentFields(Container $container): ComponentFields + { + return new ComponentFields(); + } + + /** + * Get The ConfigFieldsets Class. + * + * @param Container $container The DI container. + * + * @return ConfigFieldsets + * @since 3.2.0 + */ + public function getConfigFieldsets(Container $container): ConfigFieldsets + { + return new ConfigFieldsets(); + } + + /** + * Get The ConfigFieldsetsCustomfield Class. + * + * @param Container $container The DI container. + * + * @return ConfigFieldsetsCustomfield + * @since 3.2.0 + */ + public function getConfigFieldsetsCustomfield(Container $container): ConfigFieldsetsCustomfield + { + return new ConfigFieldsetsCustomfield(); + } + + /** + * Get The ContentMulti Class. + * + * @param Container $container The DI container. + * + * @return ContentMulti + * @since 3.2.0 + */ + public function getContentMulti(Container $container): ContentMulti + { + return new ContentMulti(); + } + + /** + * Get The ContentOne Class. + * + * @param Container $container The DI container. + * + * @return ContentOne + * @since 3.2.0 + */ + public function getContentOne(Container $container): ContentOne + { + return new ContentOne(); + } + + /** + * Get The Contributors Class. + * + * @param Container $container The DI container. + * + * @return Contributors + * @since 3.2.0 + */ + public function getContributors(Container $container): Contributors + { + return new Contributors(); + } + + /** + * Get The CustomAlias Class. + * + * @param Container $container The DI container. + * + * @return CustomAlias + * @since 3.2.0 + */ + public function getCustomAlias(Container $container): CustomAlias + { + return new CustomAlias(); + } + + /** + * Get The CustomField Class. + * + * @param Container $container The DI container. + * + * @return CustomField + * @since 3.2.0 + */ + public function getCustomField(Container $container): CustomField + { + return new CustomField(); + } + + /** + * Get The CustomFieldLinks Class. + * + * @param Container $container The DI container. + * + * @return CustomFieldLinks + * @since 3.2.0 + */ + public function getCustomFieldLinks(Container $container): CustomFieldLinks + { + return new CustomFieldLinks(); + } + + /** + * Get The CustomList Class. + * + * @param Container $container The DI container. + * + * @return CustomList + * @since 3.2.0 + */ + public function getCustomList(Container $container): CustomList + { + return new CustomList(); + } + + /** + * Get The CustomTabs Class. + * + * @param Container $container The DI container. + * + * @return CustomTabs + * @since 3.2.0 + */ + public function getCustomTabs(Container $container): CustomTabs + { + return new CustomTabs(); + } + + /** + * Get The DatabaseKeys Class. + * + * @param Container $container The DI container. + * + * @return DatabaseKeys + * @since 3.2.0 + */ + public function getDatabaseKeys(Container $container): DatabaseKeys + { + return new DatabaseKeys(); + } + + /** + * Get The DatabaseTables Class. + * + * @param Container $container The DI container. + * + * @return DatabaseTables + * @since 3.2.0 + */ + public function getDatabaseTables(Container $container): DatabaseTables + { + return new DatabaseTables(); + } + + /** + * Get The DatabaseUniqueGuid Class. + * + * @param Container $container The DI container. + * + * @return DatabaseUniqueGuid + * @since 3.2.0 + */ + public function getDatabaseUniqueGuid(Container $container): DatabaseUniqueGuid + { + return new DatabaseUniqueGuid(); + } + + /** + * Get The DatabaseUniqueKeys Class. + * + * @param Container $container The DI container. + * + * @return DatabaseUniqueKeys + * @since 3.2.0 + */ + public function getDatabaseUniqueKeys(Container $container): DatabaseUniqueKeys + { + return new DatabaseUniqueKeys(); + } + + /** + * Get The DatabaseUninstall Class. + * + * @param Container $container The DI container. + * + * @return DatabaseUninstall + * @since 3.2.0 + */ + public function getDatabaseUninstall(Container $container): DatabaseUninstall + { + return new DatabaseUninstall(); + } + + /** + * Get The DoNotEscape Class. + * + * @param Container $container The DI container. + * + * @return DoNotEscape + * @since 3.2.0 + */ + public function getDoNotEscape(Container $container): DoNotEscape + { + return new DoNotEscape(); + } + + /** + * Get The DynamicFields Class. + * + * @param Container $container The DI container. + * + * @return DynamicFields + * @since 3.2.0 + */ + public function getDynamicFields(Container $container): DynamicFields + { + return new DynamicFields(); + } + + /** + * Get The ExtensionCustomFields Class. + * + * @param Container $container The DI container. + * + * @return ExtensionCustomFields + * @since 3.2.0 + */ + public function getExtensionCustomFields(Container $container): ExtensionCustomFields + { + return new ExtensionCustomFields(); + } + + /** + * Get The ExtensionsParams Class. + * + * @param Container $container The DI container. + * + * @return ExtensionsParams + * @since 3.2.0 + */ + public function getExtensionsParams(Container $container): ExtensionsParams + { + return new ExtensionsParams(); + } + + /** + * Get The FieldGroupControl Class. + * + * @param Container $container The DI container. + * + * @return FieldGroupControl + * @since 3.2.0 + */ + public function getFieldGroupControl(Container $container): FieldGroupControl + { + return new FieldGroupControl(); + } + + /** + * Get The FieldNames Class. + * + * @param Container $container The DI container. + * + * @return FieldNames + * @since 3.2.0 + */ + public function getFieldNames(Container $container): FieldNames + { + return new FieldNames(); + } + + /** + * Get The FieldRelations Class. + * + * @param Container $container The DI container. + * + * @return FieldRelations + * @since 3.2.0 + */ + public function getFieldRelations(Container $container): FieldRelations + { + return new FieldRelations(); + } + + /** + * Get The Filter Class. + * + * @param Container $container The DI container. + * + * @return Filter + * @since 3.2.0 + */ + public function getFilter(Container $container): Filter + { + return new Filter(); + } + + /** + * Get The FootableScripts Class. + * + * @param Container $container The DI container. + * + * @return FootableScripts + * @since 3.2.0 + */ + public function getFootableScripts(Container $container): FootableScripts + { + return new FootableScripts(); + } + + /** + * Get The FrontendParams Class. + * + * @param Container $container The DI container. + * + * @return FrontendParams + * @since 3.2.0 + */ + public function getFrontendParams(Container $container): FrontendParams + { + return new FrontendParams(); + } + + /** + * Get The GetAsLookup Class. + * + * @param Container $container The DI container. + * + * @return GetAsLookup + * @since 3.2.0 + */ + public function getGetAsLookup(Container $container): GetAsLookup + { + return new GetAsLookup(); + } + + /** + * Get The GetModule Class. + * + * @param Container $container The DI container. + * + * @return GetModule + * @since 3.2.0 + */ + public function getGetModule(Container $container): GetModule + { + return new GetModule(); + } + + /** + * Get The GoogleChart Class. + * + * @param Container $container The DI container. + * + * @return GoogleChart + * @since 3.2.0 + */ + public function getGoogleChart(Container $container): GoogleChart + { + return new GoogleChart(); + } + + /** + * Get The HasMenuGlobal Class. + * + * @param Container $container The DI container. + * + * @return HasMenuGlobal + * @since 3.2.0 + */ + public function getHasMenuGlobal(Container $container): HasMenuGlobal + { + return new HasMenuGlobal(); + } + + /** + * Get The HasPermissions Class. + * + * @param Container $container The DI container. + * + * @return HasPermissions + * @since 3.2.0 + */ + public function getHasPermissions(Container $container): HasPermissions + { + return new HasPermissions(); + } + + /** + * Get The HiddenFields Class. + * + * @param Container $container The DI container. + * + * @return HiddenFields + * @since 3.2.0 + */ + public function getHiddenFields(Container $container): HiddenFields + { + return new HiddenFields(); + } + + /** + * Get The History Class. + * + * @param Container $container The DI container. + * + * @return History + * @since 3.2.0 + */ + public function getHistory(Container $container): History + { + return new History(); + } + + /** + * Get The IntegerFields Class. + * + * @param Container $container The DI container. + * + * @return IntegerFields + * @since 3.2.0 + */ + public function getIntegerFields(Container $container): IntegerFields + { + return new IntegerFields(); + } + + /** + * Get The ItemsMethodEximportString Class. + * + * @param Container $container The DI container. + * + * @return ItemsMethodEximportString + * @since 3.2.0 + */ + public function getItemsMethodEximportString(Container $container): ItemsMethodEximportString + { + return new ItemsMethodEximportString(); + } + + /** + * Get The ItemsMethodListString Class. + * + * @param Container $container The DI container. + * + * @return ItemsMethodListString + * @since 3.2.0 + */ + public function getItemsMethodListString(Container $container): ItemsMethodListString + { + return new ItemsMethodListString(); + } + + /** + * Get The JsonItem Class. + * + * @param Container $container The DI container. + * + * @return JsonItem + * @since 3.2.0 + */ + public function getJsonItem(Container $container): JsonItem + { + return new JsonItem(); + } + + /** + * Get The JsonItemArray Class. + * + * @param Container $container The DI container. + * + * @return JsonItemArray + * @since 3.2.0 + */ + public function getJsonItemArray(Container $container): JsonItemArray + { + return new JsonItemArray(); + } + + /** + * Get The JsonString Class. + * + * @param Container $container The DI container. + * + * @return JsonString + * @since 3.2.0 + */ + public function getJsonString(Container $container): JsonString + { + return new JsonString(); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/BuilderLZ.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/BuilderLZ.php new file mode 100644 index 000000000..b6421dd92 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/BuilderLZ.php @@ -0,0 +1,938 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Componentbuilder\Compiler\Builder\LanguageMessages; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Layout; +use VDM\Joomla\Componentbuilder\Compiler\Builder\LayoutData; +use VDM\Joomla\Componentbuilder\Compiler\Builder\LibraryManager; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ListFieldClass; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ListHeadOverride; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ListJoin; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Lists; +use VDM\Joomla\Componentbuilder\Compiler\Builder\MainTextField; +use VDM\Joomla\Componentbuilder\Compiler\Builder\MetaData; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelBasicField; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelExpertField; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelExpertFieldInitiator; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelMediumField; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ModelWhmcsField; +use VDM\Joomla\Componentbuilder\Compiler\Builder\MovedPublishingFields; +use VDM\Joomla\Componentbuilder\Compiler\Builder\MysqlTableSetting; +use VDM\Joomla\Componentbuilder\Compiler\Builder\NewPublishingFields; +use VDM\Joomla\Componentbuilder\Compiler\Builder\OrderZero; +use VDM\Joomla\Componentbuilder\Compiler\Builder\OtherFilter; +use VDM\Joomla\Componentbuilder\Compiler\Builder\OtherGroup; +use VDM\Joomla\Componentbuilder\Compiler\Builder\OtherJoin; +use VDM\Joomla\Componentbuilder\Compiler\Builder\OtherOrder; +use VDM\Joomla\Componentbuilder\Compiler\Builder\OtherQuery; +use VDM\Joomla\Componentbuilder\Compiler\Builder\OtherWhere; +use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionAction; +use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionComponent; +use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionCore; +use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionDashboard; +use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionFields; +use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionGlobalAction; +use VDM\Joomla\Componentbuilder\Compiler\Builder\PermissionViews; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Request; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Router; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ScriptMediaSwitch; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ScriptUserSwitch; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Search; +use VDM\Joomla\Componentbuilder\Compiler\Builder\SelectionTranslation; +use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteDecrypt; +use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteDynamicGet; +use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteEditView; +use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteFieldData; +use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteFieldDecodeFilter; +use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteFields; +use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteMainGet; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Sort; +use VDM\Joomla\Componentbuilder\Compiler\Builder\TabCounter; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Tags; +use VDM\Joomla\Componentbuilder\Compiler\Builder\TemplateData; +use VDM\Joomla\Componentbuilder\Compiler\Builder\Title; +use VDM\Joomla\Componentbuilder\Compiler\Builder\UikitComp; +use VDM\Joomla\Componentbuilder\Compiler\Builder\UpdateMysql; +use VDM\Joomla\Componentbuilder\Compiler\Builder\ViewsDefaultOrdering; + + +/** + * Builder L-Z Service Provider + * + * @since 3.2.0 + */ +class BuilderLZ implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(LanguageMessages::class, 'Compiler.Builder.Language.Messages') + ->share('Compiler.Builder.Language.Messages', [$this, 'getLanguageMessages'], true); + + $container->alias(Layout::class, 'Compiler.Builder.Layout') + ->share('Compiler.Builder.Layout', [$this, 'getLayout'], true); + + $container->alias(LayoutData::class, 'Compiler.Builder.Layout.Data') + ->share('Compiler.Builder.Layout.Data', [$this, 'getLayoutData'], true); + + $container->alias(LibraryManager::class, 'Compiler.Builder.Library.Manager') + ->share('Compiler.Builder.Library.Manager', [$this, 'getLibraryManager'], true); + + $container->alias(ListFieldClass::class, 'Compiler.Builder.List.Field.Class') + ->share('Compiler.Builder.List.Field.Class', [$this, 'getListFieldClass'], true); + + $container->alias(ListHeadOverride::class, 'Compiler.Builder.List.Head.Override') + ->share('Compiler.Builder.List.Head.Override', [$this, 'getListHeadOverride'], true); + + $container->alias(ListJoin::class, 'Compiler.Builder.List.Join') + ->share('Compiler.Builder.List.Join', [$this, 'getListJoin'], true); + + $container->alias(Lists::class, 'Compiler.Builder.Lists') + ->share('Compiler.Builder.Lists', [$this, 'getLists'], true); + + $container->alias(MainTextField::class, 'Compiler.Builder.Main.Text.Field') + ->share('Compiler.Builder.Main.Text.Field', [$this, 'getMainTextField'], true); + + $container->alias(MetaData::class, 'Compiler.Builder.Meta.Data') + ->share('Compiler.Builder.Meta.Data', [$this, 'getMetaData'], true); + + $container->alias(ModelBasicField::class, 'Compiler.Builder.Model.Basic.Field') + ->share('Compiler.Builder.Model.Basic.Field', [$this, 'getModelBasicField'], true); + + $container->alias(ModelExpertField::class, 'Compiler.Builder.Model.Expert.Field') + ->share('Compiler.Builder.Model.Expert.Field', [$this, 'getModelExpertField'], true); + + $container->alias(ModelExpertFieldInitiator::class, 'Compiler.Builder.Model.Expert.Field.Initiator') + ->share('Compiler.Builder.Model.Expert.Field.Initiator', [$this, 'getModelExpertFieldInitiator'], true); + + $container->alias(ModelMediumField::class, 'Compiler.Builder.Model.Medium.Field') + ->share('Compiler.Builder.Model.Medium.Field', [$this, 'getModelMediumField'], true); + + $container->alias(ModelWhmcsField::class, 'Compiler.Builder.Model.Whmcs.Field') + ->share('Compiler.Builder.Model.Whmcs.Field', [$this, 'getModelWhmcsField'], true); + + $container->alias(MovedPublishingFields::class, 'Compiler.Builder.Moved.Publishing.Fields') + ->share('Compiler.Builder.Moved.Publishing.Fields', [$this, 'getMovedPublishingFields'], true); + + $container->alias(MysqlTableSetting::class, 'Compiler.Builder.Mysql.Table.Setting') + ->share('Compiler.Builder.Mysql.Table.Setting', [$this, 'getMysqlTableSetting'], true); + + $container->alias(NewPublishingFields::class, 'Compiler.Builder.New.Publishing.Fields') + ->share('Compiler.Builder.New.Publishing.Fields', [$this, 'getNewPublishingFields'], true); + + $container->alias(OrderZero::class, 'Compiler.Builder.Order.Zero') + ->share('Compiler.Builder.Order.Zero', [$this, 'getOrderZero'], true); + + $container->alias(OtherFilter::class, 'Compiler.Builder.Other.Filter') + ->share('Compiler.Builder.Other.Filter', [$this, 'getOtherFilter'], true); + + $container->alias(OtherGroup::class, 'Compiler.Builder.Other.Group') + ->share('Compiler.Builder.Other.Group', [$this, 'getOtherGroup'], true); + + $container->alias(OtherJoin::class, 'Compiler.Builder.Other.Join') + ->share('Compiler.Builder.Other.Join', [$this, 'getOtherJoin'], true); + + $container->alias(OtherOrder::class, 'Compiler.Builder.Other.Order') + ->share('Compiler.Builder.Other.Order', [$this, 'getOtherOrder'], true); + + $container->alias(OtherQuery::class, 'Compiler.Builder.Other.Query') + ->share('Compiler.Builder.Other.Query', [$this, 'getOtherQuery'], true); + + $container->alias(OtherWhere::class, 'Compiler.Builder.Other.Where') + ->share('Compiler.Builder.Other.Where', [$this, 'getOtherWhere'], true); + + $container->alias(PermissionAction::class, 'Compiler.Builder.Permission.Action') + ->share('Compiler.Builder.Permission.Action', [$this, 'getPermissionAction'], true); + + $container->alias(PermissionComponent::class, 'Compiler.Builder.Permission.Component') + ->share('Compiler.Builder.Permission.Component', [$this, 'getPermissionComponent'], true); + + $container->alias(PermissionCore::class, 'Compiler.Builder.Permission.Core') + ->share('Compiler.Builder.Permission.Core', [$this, 'getPermissionCore'], true); + + $container->alias(PermissionDashboard::class, 'Compiler.Builder.Permission.Dashboard') + ->share('Compiler.Builder.Permission.Dashboard', [$this, 'getPermissionDashboard'], true); + + $container->alias(PermissionFields::class, 'Compiler.Builder.Permission.Fields') + ->share('Compiler.Builder.Permission.Fields', [$this, 'getPermissionFields'], true); + + $container->alias(PermissionGlobalAction::class, 'Compiler.Builder.Permission.Global.Action') + ->share('Compiler.Builder.Permission.Global.Action', [$this, 'getPermissionGlobalAction'], true); + + $container->alias(PermissionViews::class, 'Compiler.Builder.Permission.Views') + ->share('Compiler.Builder.Permission.Views', [$this, 'getPermissionViews'], true); + + $container->alias(Request::class, 'Compiler.Builder.Request') + ->share('Compiler.Builder.Request', [$this, 'getRequest'], true); + + $container->alias(Router::class, 'Compiler.Builder.Router') + ->share('Compiler.Builder.Router', [$this, 'getRouter'], true); + + $container->alias(ScriptMediaSwitch::class, 'Compiler.Builder.Script.Media.Switch') + ->share('Compiler.Builder.Script.Media.Switch', [$this, 'getScriptMediaSwitch'], true); + + $container->alias(ScriptUserSwitch::class, 'Compiler.Builder.Script.User.Switch') + ->share('Compiler.Builder.Script.User.Switch', [$this, 'getScriptUserSwitch'], true); + + $container->alias(Search::class, 'Compiler.Builder.Search') + ->share('Compiler.Builder.Search', [$this, 'getSearch'], true); + + $container->alias(SelectionTranslation::class, 'Compiler.Builder.Selection.Translation') + ->share('Compiler.Builder.Selection.Translation', [$this, 'getSelectionTranslation'], true); + + $container->alias(SiteDecrypt::class, 'Compiler.Builder.Site.Decrypt') + ->share('Compiler.Builder.Site.Decrypt', [$this, 'getSiteDecrypt'], true); + + $container->alias(SiteDynamicGet::class, 'Compiler.Builder.Site.Dynamic.Get') + ->share('Compiler.Builder.Site.Dynamic.Get', [$this, 'getSiteDynamicGet'], true); + + $container->alias(SiteEditView::class, 'Compiler.Builder.Site.Edit.View') + ->share('Compiler.Builder.Site.Edit.View', [$this, 'getSiteEditView'], true); + + $container->alias(SiteFieldData::class, 'Compiler.Builder.Site.Field.Data') + ->share('Compiler.Builder.Site.Field.Data', [$this, 'getSiteFieldData'], true); + + $container->alias(SiteFieldDecodeFilter::class, 'Compiler.Builder.Site.Field.Decode.Filter') + ->share('Compiler.Builder.Site.Field.Decode.Filter', [$this, 'getSiteFieldDecodeFilter'], true); + + $container->alias(SiteFields::class, 'Compiler.Builder.Site.Fields') + ->share('Compiler.Builder.Site.Fields', [$this, 'getSiteFields'], true); + + $container->alias(SiteMainGet::class, 'Compiler.Builder.Site.Main.Get') + ->share('Compiler.Builder.Site.Main.Get', [$this, 'getSiteMainGet'], true); + + $container->alias(Sort::class, 'Compiler.Builder.Sort') + ->share('Compiler.Builder.Sort', [$this, 'getSort'], true); + + $container->alias(TabCounter::class, 'Compiler.Builder.Tab.Counter') + ->share('Compiler.Builder.Tab.Counter', [$this, 'getTabCounter'], true); + + $container->alias(Tags::class, 'Compiler.Builder.Tags') + ->share('Compiler.Builder.Tags', [$this, 'getTags'], true); + + $container->alias(TemplateData::class, 'Compiler.Builder.Template.Data') + ->share('Compiler.Builder.Template.Data', [$this, 'getTemplateData'], true); + + $container->alias(Title::class, 'Compiler.Builder.Title') + ->share('Compiler.Builder.Title', [$this, 'getTitle'], true); + + $container->alias(UikitComp::class, 'Compiler.Builder.Uikit.Comp') + ->share('Compiler.Builder.Uikit.Comp', [$this, 'getUikitComp'], true); + + $container->alias(UpdateMysql::class, 'Compiler.Builder.Update.Mysql') + ->share('Compiler.Builder.Update.Mysql', [$this, 'getUpdateMysql'], true); + + $container->alias(ViewsDefaultOrdering::class, 'Compiler.Builder.Views.Default.Ordering') + ->share('Compiler.Builder.Views.Default.Ordering', [$this, 'getViewsDefaultOrdering'], true); + } + + /** + * Get The LanguageMessages Class. + * + * @param Container $container The DI container. + * + * @return LanguageMessages + * @since 3.2.0 + */ + public function getLanguageMessages(Container $container): LanguageMessages + { + return new LanguageMessages(); + } + + /** + * Get The Layout Class. + * + * @param Container $container The DI container. + * + * @return Layout + * @since 3.2.0 + */ + public function getLayout(Container $container): Layout + { + return new Layout(); + } + + /** + * Get The LayoutData Class. + * + * @param Container $container The DI container. + * + * @return LayoutData + * @since 3.2.0 + */ + public function getLayoutData(Container $container): LayoutData + { + return new LayoutData(); + } + + /** + * Get The LibraryManager Class. + * + * @param Container $container The DI container. + * + * @return LibraryManager + * @since 3.2.0 + */ + public function getLibraryManager(Container $container): LibraryManager + { + return new LibraryManager(); + } + + /** + * Get The ListFieldClass Class. + * + * @param Container $container The DI container. + * + * @return ListFieldClass + * @since 3.2.0 + */ + public function getListFieldClass(Container $container): ListFieldClass + { + return new ListFieldClass(); + } + + /** + * Get The ListHeadOverride Class. + * + * @param Container $container The DI container. + * + * @return ListHeadOverride + * @since 3.2.0 + */ + public function getListHeadOverride(Container $container): ListHeadOverride + { + return new ListHeadOverride(); + } + + /** + * Get The ListJoin Class. + * + * @param Container $container The DI container. + * + * @return ListJoin + * @since 3.2.0 + */ + public function getListJoin(Container $container): ListJoin + { + return new ListJoin(); + } + + /** + * Get The Lists Class. + * + * @param Container $container The DI container. + * + * @return Lists + * @since 3.2.0 + */ + public function getLists(Container $container): Lists + { + return new Lists(); + } + + /** + * Get The MainTextField Class. + * + * @param Container $container The DI container. + * + * @return MainTextField + * @since 3.2.0 + */ + public function getMainTextField(Container $container): MainTextField + { + return new MainTextField(); + } + + /** + * Get The MetaData Class. + * + * @param Container $container The DI container. + * + * @return MetaData + * @since 3.2.0 + */ + public function getMetaData(Container $container): MetaData + { + return new MetaData(); + } + + /** + * Get The ModelBasicField Class. + * + * @param Container $container The DI container. + * + * @return ModelBasicField + * @since 3.2.0 + */ + public function getModelBasicField(Container $container): ModelBasicField + { + return new ModelBasicField(); + } + + /** + * Get The ModelExpertField Class. + * + * @param Container $container The DI container. + * + * @return ModelExpertField + * @since 3.2.0 + */ + public function getModelExpertField(Container $container): ModelExpertField + { + return new ModelExpertField(); + } + + /** + * Get The ModelExpertFieldInitiator Class. + * + * @param Container $container The DI container. + * + * @return ModelExpertFieldInitiator + * @since 3.2.0 + */ + public function getModelExpertFieldInitiator(Container $container): ModelExpertFieldInitiator + { + return new ModelExpertFieldInitiator(); + } + + /** + * Get The ModelMediumField Class. + * + * @param Container $container The DI container. + * + * @return ModelMediumField + * @since 3.2.0 + */ + public function getModelMediumField(Container $container): ModelMediumField + { + return new ModelMediumField(); + } + + /** + * Get The ModelWhmcsField Class. + * + * @param Container $container The DI container. + * + * @return ModelWhmcsField + * @since 3.2.0 + */ + public function getModelWhmcsField(Container $container): ModelWhmcsField + { + return new ModelWhmcsField(); + } + + /** + * Get The MovedPublishingFields Class. + * + * @param Container $container The DI container. + * + * @return MovedPublishingFields + * @since 3.2.0 + */ + public function getMovedPublishingFields(Container $container): MovedPublishingFields + { + return new MovedPublishingFields(); + } + + /** + * Get The MysqlTableSetting Class. + * + * @param Container $container The DI container. + * + * @return MysqlTableSetting + * @since 3.2.0 + */ + public function getMysqlTableSetting(Container $container): MysqlTableSetting + { + return new MysqlTableSetting(); + } + + /** + * Get The NewPublishingFields Class. + * + * @param Container $container The DI container. + * + * @return NewPublishingFields + * @since 3.2.0 + */ + public function getNewPublishingFields(Container $container): NewPublishingFields + { + return new NewPublishingFields(); + } + + /** + * Get The OrderZero Class. + * + * @param Container $container The DI container. + * + * @return OrderZero + * @since 3.2.0 + */ + public function getOrderZero(Container $container): OrderZero + { + return new OrderZero(); + } + + /** + * Get The OtherFilter Class. + * + * @param Container $container The DI container. + * + * @return OtherFilter + * @since 3.2.0 + */ + public function getOtherFilter(Container $container): OtherFilter + { + return new OtherFilter(); + } + + /** + * Get The OtherGroup Class. + * + * @param Container $container The DI container. + * + * @return OtherGroup + * @since 3.2.0 + */ + public function getOtherGroup(Container $container): OtherGroup + { + return new OtherGroup(); + } + + /** + * Get The OtherJoin Class. + * + * @param Container $container The DI container. + * + * @return OtherJoin + * @since 3.2.0 + */ + public function getOtherJoin(Container $container): OtherJoin + { + return new OtherJoin(); + } + + /** + * Get The OtherOrder Class. + * + * @param Container $container The DI container. + * + * @return OtherOrder + * @since 3.2.0 + */ + public function getOtherOrder(Container $container): OtherOrder + { + return new OtherOrder(); + } + + /** + * Get The OtherQuery Class. + * + * @param Container $container The DI container. + * + * @return OtherQuery + * @since 3.2.0 + */ + public function getOtherQuery(Container $container): OtherQuery + { + return new OtherQuery(); + } + + /** + * Get The OtherWhere Class. + * + * @param Container $container The DI container. + * + * @return OtherWhere + * @since 3.2.0 + */ + public function getOtherWhere(Container $container): OtherWhere + { + return new OtherWhere(); + } + + /** + * Get The PermissionAction Class. + * + * @param Container $container The DI container. + * + * @return PermissionAction + * @since 3.2.0 + */ + public function getPermissionAction(Container $container): PermissionAction + { + return new PermissionAction(); + } + + /** + * Get The PermissionComponent Class. + * + * @param Container $container The DI container. + * + * @return PermissionComponent + * @since 3.2.0 + */ + public function getPermissionComponent(Container $container): PermissionComponent + { + return new PermissionComponent(); + } + + /** + * Get The PermissionCore Class. + * + * @param Container $container The DI container. + * + * @return PermissionCore + * @since 3.2.0 + */ + public function getPermissionCore(Container $container): PermissionCore + { + return new PermissionCore(); + } + + /** + * Get The PermissionDashboard Class. + * + * @param Container $container The DI container. + * + * @return PermissionDashboard + * @since 3.2.0 + */ + public function getPermissionDashboard(Container $container): PermissionDashboard + { + return new PermissionDashboard(); + } + + /** + * Get The PermissionFields Class. + * + * @param Container $container The DI container. + * + * @return PermissionFields + * @since 3.2.0 + */ + public function getPermissionFields(Container $container): PermissionFields + { + return new PermissionFields(); + } + + /** + * Get The PermissionGlobalAction Class. + * + * @param Container $container The DI container. + * + * @return PermissionGlobalAction + * @since 3.2.0 + */ + public function getPermissionGlobalAction(Container $container): PermissionGlobalAction + { + return new PermissionGlobalAction(); + } + + /** + * Get The PermissionViews Class. + * + * @param Container $container The DI container. + * + * @return PermissionViews + * @since 3.2.0 + */ + public function getPermissionViews(Container $container): PermissionViews + { + return new PermissionViews(); + } + + /** + * Get The Request Class. + * + * @param Container $container The DI container. + * + * @return Request + * @since 3.2.0 + */ + public function getRequest(Container $container): Request + { + return new Request(); + } + + /** + * Get The Router Class. + * + * @param Container $container The DI container. + * + * @return Router + * @since 3.2.0 + */ + public function getRouter(Container $container): Router + { + return new Router(); + } + + /** + * Get The ScriptMediaSwitch Class. + * + * @param Container $container The DI container. + * + * @return ScriptMediaSwitch + * @since 3.2.0 + */ + public function getScriptMediaSwitch(Container $container): ScriptMediaSwitch + { + return new ScriptMediaSwitch(); + } + + /** + * Get The ScriptUserSwitch Class. + * + * @param Container $container The DI container. + * + * @return ScriptUserSwitch + * @since 3.2.0 + */ + public function getScriptUserSwitch(Container $container): ScriptUserSwitch + { + return new ScriptUserSwitch(); + } + + /** + * Get The Search Class. + * + * @param Container $container The DI container. + * + * @return Search + * @since 3.2.0 + */ + public function getSearch(Container $container): Search + { + return new Search(); + } + + /** + * Get The SelectionTranslation Class. + * + * @param Container $container The DI container. + * + * @return SelectionTranslation + * @since 3.2.0 + */ + public function getSelectionTranslation(Container $container): SelectionTranslation + { + return new SelectionTranslation(); + } + + /** + * Get The SiteDecrypt Class. + * + * @param Container $container The DI container. + * + * @return SiteDecrypt + * @since 3.2.0 + */ + public function getSiteDecrypt(Container $container): SiteDecrypt + { + return new SiteDecrypt(); + } + + /** + * Get The SiteDynamicGet Class. + * + * @param Container $container The DI container. + * + * @return SiteDynamicGet + * @since 3.2.0 + */ + public function getSiteDynamicGet(Container $container): SiteDynamicGet + { + return new SiteDynamicGet(); + } + + /** + * Get The SiteEditView Class. + * + * @param Container $container The DI container. + * + * @return SiteEditView + * @since 3.2.0 + */ + public function getSiteEditView(Container $container): SiteEditView + { + return new SiteEditView(); + } + + /** + * Get The SiteFieldData Class. + * + * @param Container $container The DI container. + * + * @return SiteFieldData + * @since 3.2.0 + */ + public function getSiteFieldData(Container $container): SiteFieldData + { + return new SiteFieldData(); + } + + /** + * Get The SiteFieldDecodeFilter Class. + * + * @param Container $container The DI container. + * + * @return SiteFieldDecodeFilter + * @since 3.2.0 + */ + public function getSiteFieldDecodeFilter(Container $container): SiteFieldDecodeFilter + { + return new SiteFieldDecodeFilter(); + } + + /** + * Get The SiteFields Class. + * + * @param Container $container The DI container. + * + * @return SiteFields + * @since 3.2.0 + */ + public function getSiteFields(Container $container): SiteFields + { + return new SiteFields(); + } + + /** + * Get The SiteMainGet Class. + * + * @param Container $container The DI container. + * + * @return SiteMainGet + * @since 3.2.0 + */ + public function getSiteMainGet(Container $container): SiteMainGet + { + return new SiteMainGet(); + } + + /** + * Get The Sort Class. + * + * @param Container $container The DI container. + * + * @return Sort + * @since 3.2.0 + */ + public function getSort(Container $container): Sort + { + return new Sort(); + } + + /** + * Get The TabCounter Class. + * + * @param Container $container The DI container. + * + * @return TabCounter + * @since 3.2.0 + */ + public function getTabCounter(Container $container): TabCounter + { + return new TabCounter(); + } + + /** + * Get The Tags Class. + * + * @param Container $container The DI container. + * + * @return Tags + * @since 3.2.0 + */ + public function getTags(Container $container): Tags + { + return new Tags(); + } + + /** + * Get The TemplateData Class. + * + * @param Container $container The DI container. + * + * @return TemplateData + * @since 3.2.0 + */ + public function getTemplateData(Container $container): TemplateData + { + return new TemplateData(); + } + + /** + * Get The Title Class. + * + * @param Container $container The DI container. + * + * @return Title + * @since 3.2.0 + */ + public function getTitle(Container $container): Title + { + return new Title(); + } + + /** + * Get The UikitComp Class. + * + * @param Container $container The DI container. + * + * @return UikitComp + * @since 3.2.0 + */ + public function getUikitComp(Container $container): UikitComp + { + return new UikitComp(); + } + + /** + * Get The UpdateMysql Class. + * + * @param Container $container The DI container. + * + * @return UpdateMysql + * @since 3.2.0 + */ + public function getUpdateMysql(Container $container): UpdateMysql + { + return new UpdateMysql(); + } + + /** + * Get The ViewsDefaultOrdering Class. + * + * @param Container $container The DI container. + * + * @return ViewsDefaultOrdering + * @since 3.2.0 + */ + public function getViewsDefaultOrdering(Container $container): ViewsDefaultOrdering + { + return new ViewsDefaultOrdering(); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Component.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Component.php index b6e9b6759..093d0b655 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Component.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Component.php @@ -15,13 +15,16 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service; use Joomla\DI\Container; use Joomla\DI\ServiceProviderInterface; use VDM\Joomla\Componentbuilder\Compiler\Component as CompilerComponent; -use VDM\Joomla\Componentbuilder\Compiler\Component\Settings; +use VDM\Joomla\Componentbuilder\Compiler\Component\JoomlaThree\Settings as J3Settings; +use VDM\Joomla\Componentbuilder\Compiler\Component\JoomlaFour\Settings as J4Settings; +use VDM\Joomla\Componentbuilder\Compiler\Component\JoomlaFive\Settings as J5Settings; use VDM\Joomla\Componentbuilder\Compiler\Component\Dashboard; use VDM\Joomla\Componentbuilder\Compiler\Component\Placeholder; use VDM\Joomla\Componentbuilder\Compiler\Component\Data; use VDM\Joomla\Componentbuilder\Compiler\Component\Structure; use VDM\Joomla\Componentbuilder\Compiler\Component\Structuresingle; use VDM\Joomla\Componentbuilder\Compiler\Component\Structuremultiple; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\SettingsInterface as Settings; /** @@ -31,6 +34,14 @@ use VDM\Joomla\Componentbuilder\Compiler\Component\Structuremultiple; */ class Component implements ServiceProviderInterface { + /** + * Current Joomla Version Being Build + * + * @var int + * @since 3.2.0 + **/ + protected $targetVersion; + /** * Registers the service provider with a DI container. * @@ -42,10 +53,16 @@ class Component implements ServiceProviderInterface public function register(Container $container) { $container->alias(CompilerComponent::class, 'Component') - ->share('Component', [$this, 'getComponent'], true); + ->share('Component', [$this, 'getCompilerComponent'], true); - $container->alias(Settings::class, 'Component.Settings') - ->share('Component.Settings', [$this, 'getSettings'], true); + $container->alias(J3Settings::class, 'Component.J3.Settings') + ->share('Component.J3.Settings', [$this, 'getJ3Settings'], true); + + $container->alias(J4Settings::class, 'Component.J4.Settings') + ->share('Component.J4.Settings', [$this, 'getJ4Settings'], true); + + $container->alias(J5Settings::class, 'Component.J5.Settings') + ->share('Component.J5.Settings', [$this, 'getJ5Settings'], true); $container->alias(Dashboard::class, 'Component.Dashboard') ->share('Component.Dashboard', [$this, 'getDashboard'], true); @@ -64,17 +81,20 @@ class Component implements ServiceProviderInterface $container->alias(Structuremultiple::class, 'Component.Structure.Multiple') ->share('Component.Structure.Multiple', [$this, 'getStructuremultiple'], true); + + $container->alias(Settings::class, 'Component.Settings') + ->share('Component.Settings', [$this, 'getSettings'], true); } /** - * Get the Component + * Get The Component Class. * * @param Container $container The DI container. * * @return CompilerComponent * @since 3.2.0 */ - public function getComponent(Container $container): CompilerComponent + public function getCompilerComponent(Container $container): CompilerComponent { return new CompilerComponent( $container->get('Component.Data') @@ -82,16 +102,16 @@ class Component implements ServiceProviderInterface } /** - * Get the Compiler Component (version) Settings + * Get The Settings Class. * * @param Container $container The DI container. * - * @return Settings + * @return J3Settings * @since 3.2.0 */ - public function getSettings(Container $container): Settings + public function getJ3Settings(Container $container): J3Settings { - return new Settings( + return new J3Settings( $container->get('Config'), $container->get('Registry'), $container->get('Event'), @@ -104,7 +124,51 @@ class Component implements ServiceProviderInterface } /** - * Get the Compiler Component Dynamic Dashboard + * Get The Settings Class. + * + * @param Container $container The DI container. + * + * @return J4Settings + * @since 3.2.0 + */ + public function getJ4Settings(Container $container): J4Settings + { + return new J4Settings( + $container->get('Config'), + $container->get('Registry'), + $container->get('Event'), + $container->get('Placeholder'), + $container->get('Component'), + $container->get('Utilities.Paths'), + $container->get('Utilities.Dynamicpath'), + $container->get('Utilities.Pathfix') + ); + } + + /** + * Get The Settings Class. + * + * @param Container $container The DI container. + * + * @return J5Settings + * @since 3.2.0 + */ + public function getJ5Settings(Container $container): J5Settings + { + return new J5Settings( + $container->get('Config'), + $container->get('Registry'), + $container->get('Event'), + $container->get('Placeholder'), + $container->get('Component'), + $container->get('Utilities.Paths'), + $container->get('Utilities.Dynamicpath'), + $container->get('Utilities.Pathfix') + ); + } + + /** + * Get The Dashboard Class. * * @param Container $container The DI container. * @@ -120,7 +184,7 @@ class Component implements ServiceProviderInterface } /** - * Get the Component Placeholders + * Get The Placeholder Class. * * @param Container $container The DI container. * @@ -135,7 +199,7 @@ class Component implements ServiceProviderInterface } /** - * Get the Component Data + * Get The Data Class. * * @param Container $container The DI container. * @@ -164,12 +228,13 @@ class Component implements ServiceProviderInterface $container->get('Model.Customadminviews'), $container->get('Model.Updateserver'), $container->get('Model.Joomlamodules'), - $container->get('Model.Joomlaplugins') + $container->get('Model.Joomlaplugins'), + $container->get('Model.Router') ); } /** - * Get the Compiler Structure + * Get The Structure Class. * * @param Container $container The DI container. * @@ -186,7 +251,7 @@ class Component implements ServiceProviderInterface } /** - * Get the Compiler Structure Single + * Get The Structuresingle Class. * * @param Container $container The DI container. * @@ -198,6 +263,7 @@ class Component implements ServiceProviderInterface return new Structuresingle( $container->get('Config'), $container->get('Registry'), + $container->get('Placeholder'), $container->get('Component.Settings'), $container->get('Component'), $container->get('Compiler.Builder.Content.One'), @@ -208,7 +274,7 @@ class Component implements ServiceProviderInterface } /** - * Get the Compiler Structure Multiple + * Get The Structuremultiple Class. * * @param Container $container The DI container. * @@ -227,6 +293,23 @@ class Component implements ServiceProviderInterface $container->get('Utilities.Structure') ); } - + + /** + * Get The Settings Class. + * + * @param Container $container The DI container. + * + * @return Settings + * @since 3.2.0 + */ + public function getSettings(Container $container): Settings + { + if (empty($this->targetVersion)) + { + $this->targetVersion = $container->get('Config')->joomla_version; + } + + return $container->get('Component.J' . $this->targetVersion . '.Settings'); + } } diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Creator.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Creator.php index 67b743786..36aa47485 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Creator.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Creator.php @@ -14,11 +14,30 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service; use Joomla\DI\Container; use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Componentbuilder\Compiler\Creator\AccessSections; +use VDM\Joomla\Componentbuilder\Compiler\Creator\AccessSectionsCategory; +use VDM\Joomla\Componentbuilder\Compiler\Creator\AccessSectionsJoomlaFields; use VDM\Joomla\Componentbuilder\Compiler\Creator\Builders; use VDM\Joomla\Componentbuilder\Compiler\Creator\CustomFieldTypeFile; +use VDM\Joomla\Componentbuilder\Compiler\Creator\CustomButtonPermissions; +use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsets; +use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsCustomfield; +use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsEmailHelper; +use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsEncryption; +use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsGlobal; +use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsGooglechart; +use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsGroupControl; +use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsSiteControl; +use VDM\Joomla\Componentbuilder\Compiler\Creator\ConfigFieldsetsUikit; use VDM\Joomla\Componentbuilder\Compiler\Creator\Layout; use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission; use VDM\Joomla\Componentbuilder\Compiler\Creator\SiteFieldData; +use VDM\Joomla\Componentbuilder\Compiler\Creator\Request; +use VDM\Joomla\Componentbuilder\Compiler\Creator\Router; +use VDM\Joomla\Componentbuilder\Compiler\Creator\RouterConstructorDefault; +use VDM\Joomla\Componentbuilder\Compiler\Creator\RouterConstructorManual; +use VDM\Joomla\Componentbuilder\Compiler\Creator\RouterMethodsDefault; +use VDM\Joomla\Componentbuilder\Compiler\Creator\RouterMethodsManual; use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetString; use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetXML; use VDM\Joomla\Componentbuilder\Compiler\Creator\FieldsetDynamic; @@ -47,12 +66,51 @@ class Creator implements ServiceProviderInterface */ public function register(Container $container) { + $container->alias(AccessSections::class, 'Compiler.Creator.Access.Sections') + ->share('Compiler.Creator.Access.Sections', [$this, 'getAccessSections'], true); + + $container->alias(AccessSectionsCategory::class, 'Compiler.Creator.Access.Sections.Category') + ->share('Compiler.Creator.Access.Sections.Category', [$this, 'getAccessSectionsCategory'], true); + + $container->alias(AccessSectionsJoomlaFields::class, 'Compiler.Creator.Access.Sections.Joomla.Fields') + ->share('Compiler.Creator.Access.Sections.Joomla.Fields', [$this, 'getAccessSectionsJoomlaFields'], true); + $container->alias(Builders::class, 'Compiler.Creator.Builders') ->share('Compiler.Creator.Builders', [$this, 'getBuilders'], true); $container->alias(CustomFieldTypeFile::class, 'Compiler.Creator.Custom.Field.Type.File') ->share('Compiler.Creator.Custom.Field.Type.File', [$this, 'getCustomFieldTypeFile'], true); + $container->alias(CustomButtonPermissions::class, 'Compiler.Creator.Custom.Button.Permissions') + ->share('Compiler.Creator.Custom.Button.Permissions', [$this, 'getCustomButtonPermissions'], true); + + $container->alias(ConfigFieldsets::class, 'Compiler.Creator.Config.Fieldsets') + ->share('Compiler.Creator.Config.Fieldsets', [$this, 'getConfigFieldsets'], true); + + $container->alias(ConfigFieldsetsCustomfield::class, 'Compiler.Creator.Config.Fieldsets.Customfield') + ->share('Compiler.Creator.Config.Fieldsets.Customfield', [$this, 'getConfigFieldsetsCustomfield'], true); + + $container->alias(ConfigFieldsetsEmailHelper::class, 'Compiler.Creator.Config.Fieldsets.Email.Helper') + ->share('Compiler.Creator.Config.Fieldsets.Email.Helper', [$this, 'getConfigFieldsetsEmailHelper'], true); + + $container->alias(ConfigFieldsetsEncryption::class, 'Compiler.Creator.Config.Fieldsets.Encryption') + ->share('Compiler.Creator.Config.Fieldsets.Encryption', [$this, 'getConfigFieldsetsEncryption'], true); + + $container->alias(ConfigFieldsetsGlobal::class, 'Compiler.Creator.Config.Fieldsets.Global') + ->share('Compiler.Creator.Config.Fieldsets.Global', [$this, 'getConfigFieldsetsGlobal'], true); + + $container->alias(ConfigFieldsetsGooglechart::class, 'Compiler.Creator.Config.Fieldsets.Googlechart') + ->share('Compiler.Creator.Config.Fieldsets.Googlechart', [$this, 'getConfigFieldsetsGooglechart'], true); + + $container->alias(ConfigFieldsetsGroupControl::class, 'Compiler.Creator.Config.Fieldsets.Group.Control') + ->share('Compiler.Creator.Config.Fieldsets.Group.Control', [$this, 'getConfigFieldsetsGroupControl'], true); + + $container->alias(ConfigFieldsetsSiteControl::class, 'Compiler.Creator.Config.Fieldsets.Site.Control') + ->share('Compiler.Creator.Config.Fieldsets.Site.Control', [$this, 'getConfigFieldsetsSiteControl'], true); + + $container->alias(ConfigFieldsetsUikit::class, 'Compiler.Creator.Config.Fieldsets.Uikit') + ->share('Compiler.Creator.Config.Fieldsets.Uikit', [$this, 'getConfigFieldsetsUikit'], true); + $container->alias(Layout::class, 'Compiler.Creator.Layout') ->share('Compiler.Creator.Layout', [$this, 'getLayout'], true); @@ -62,6 +120,24 @@ class Creator implements ServiceProviderInterface $container->alias(SiteFieldData::class, 'Compiler.Creator.Site.Field.Data') ->share('Compiler.Creator.Site.Field.Data', [$this, 'getSiteFieldData'], true); + $container->alias(Request::class, 'Compiler.Creator.Request') + ->share('Compiler.Creator.Request', [$this, 'getRequest'], true); + + $container->alias(Router::class, 'Compiler.Creator.Router') + ->share('Compiler.Creator.Router', [$this, 'getRouter'], true); + + $container->alias(RouterConstructorDefault::class, 'Compiler.Creator.Router.Constructor.Default') + ->share('Compiler.Creator.Router.Constructor.Default', [$this, 'getRouterConstructorDefault'], true); + + $container->alias(RouterConstructorManual::class, 'Compiler.Creator.Router.Constructor.Manual') + ->share('Compiler.Creator.Router.Constructor.Manual', [$this, 'getRouterConstructorManual'], true); + + $container->alias(RouterMethodsDefault::class, 'Compiler.Creator.Router.Methods.Default') + ->share('Compiler.Creator.Router.Methods.Default', [$this, 'getRouterMethodsDefault'], true); + + $container->alias(RouterMethodsManual::class, 'Compiler.Creator.Router.Methods.Manual') + ->share('Compiler.Creator.Router.Methods.Manual', [$this, 'getRouterMethodsManual'], true); + $container->alias(FieldsetString::class, 'Compiler.Creator.Fieldset.String') ->share('Compiler.Creator.Fieldset.String', [$this, 'getFieldsetString'], true); @@ -90,6 +166,62 @@ class Creator implements ServiceProviderInterface ->share('Compiler.Creator.Fieldset', [$this, 'getFieldset'], true); } + /** + * Get The AccessSections Class. + * + * @param Container $container The DI container. + * + * @return AccessSections + * @since 3.2.0 + */ + public function getAccessSections(Container $container): AccessSections + { + return new AccessSections( + $container->get('Config'), + $container->get('Event'), + $container->get('Language'), + $container->get('Component'), + $container->get('Field.Name'), + $container->get('Field.Type.Name'), + $container->get('Utilities.Counter'), + $container->get('Compiler.Creator.Permission'), + $container->get('Compiler.Builder.Assets.Rules'), + $container->get('Compiler.Builder.Custom.Tabs'), + $container->get('Compiler.Builder.Permission.Views'), + $container->get('Compiler.Builder.Permission.Fields'), + $container->get('Compiler.Builder.Permission.Component'), + $container->get('Compiler.Creator.Custom.Button.Permissions') + ); + } + + /** + * Get The AccessSectionsCategory Class. + * + * @param Container $container The DI container. + * + * @return AccessSectionsCategory + * @since 3.2.0 + */ + public function getAccessSectionsCategory(Container $container): AccessSectionsCategory + { + return new AccessSectionsCategory( + $container->get('Compiler.Builder.Category.Code') + ); + } + + /** + * Get The AccessSectionsJoomlaFields Class. + * + * @param Container $container The DI container. + * + * @return AccessSectionsJoomlaFields + * @since 3.2.0 + */ + public function getAccessSectionsJoomlaFields(Container $container): AccessSectionsJoomlaFields + { + return new AccessSectionsJoomlaFields(); + } + /** * Get The Builders Class. * @@ -102,6 +234,7 @@ class Creator implements ServiceProviderInterface { return new Builders( $container->get('Config'), + $container->get('Power'), $container->get('Language'), $container->get('Placeholder'), $container->get('Compiler.Creator.Layout'), @@ -171,7 +304,212 @@ class Creator implements ServiceProviderInterface $container->get('Utilities.Structure'), $container->get('Field.Input.Button'), $container->get('Compiler.Builder.Field.Group.Control'), - $container->get('Compiler.Builder.Extension.Custom.Fields') + $container->get('Compiler.Builder.Extension.Custom.Fields'), + $container->get('Header'), + $container->get('Field.Core.Field') + ); + } + + /** + * Get The CustomButtonPermissions Class. + * + * @param Container $container The DI container. + * + * @return CustomButtonPermissions + * @since 3.2.0 + */ + public function getCustomButtonPermissions(Container $container): CustomButtonPermissions + { + return new CustomButtonPermissions( + $container->get('Config'), + $container->get('Language'), + $container->get('Compiler.Builder.Permission.Component'), + $container->get('Utilities.Counter') + ); + } + + /** + * Get The ConfigFieldsets Class. + * + * @param Container $container The DI container. + * + * @return ConfigFieldsets + * @since 3.2.0 + */ + public function getConfigFieldsets(Container $container): ConfigFieldsets + { + return new ConfigFieldsets( + $container->get('Config'), + $container->get('Component'), + $container->get('Event'), + $container->get('Placeholder'), + $container->get('Component.Placeholder'), + $container->get('Compiler.Builder.Extensions.Params'), + $container->get('Compiler.Builder.Config.Fieldsets.Customfield'), + $container->get('Compiler.Creator.Field.As.String'), + $container->get('Compiler.Creator.Config.Fieldsets.Global'), + $container->get('Compiler.Creator.Config.Fieldsets.Site.Control'), + $container->get('Compiler.Creator.Config.Fieldsets.Group.Control'), + $container->get('Compiler.Creator.Config.Fieldsets.Uikit'), + $container->get('Compiler.Creator.Config.Fieldsets.Googlechart'), + $container->get('Compiler.Creator.Config.Fieldsets.Email.Helper'), + $container->get('Compiler.Creator.Config.Fieldsets.Encryption'), + $container->get('Compiler.Creator.Config.Fieldsets.Customfield') + ); + } + + /** + * Get The ConfigFieldsetsCustomfield Class. + * + * @param Container $container The DI container. + * + * @return ConfigFieldsetsCustomfield + * @since 3.2.0 + */ + public function getConfigFieldsetsCustomfield(Container $container): ConfigFieldsetsCustomfield + { + return new ConfigFieldsetsCustomfield( + $container->get('Config'), + $container->get('Language'), + $container->get('Compiler.Builder.Config.Fieldsets.Customfield'), + $container->get('Compiler.Builder.Config.Fieldsets') + ); + } + + /** + * Get The ConfigFieldsetsEmailHelper Class. + * + * @param Container $container The DI container. + * + * @return ConfigFieldsetsEmailHelper + * @since 3.2.0 + */ + public function getConfigFieldsetsEmailHelper(Container $container): ConfigFieldsetsEmailHelper + { + return new ConfigFieldsetsEmailHelper( + $container->get('Config'), + $container->get('Language'), + $container->get('Component'), + $container->get('Compiler.Builder.Config.Fieldsets'), + $container->get('Compiler.Builder.Config.Fieldsets.Customfield') + ); + } + + /** + * Get The ConfigFieldsetsEncryption Class. + * + * @param Container $container The DI container. + * + * @return ConfigFieldsetsEncryption + * @since 3.2.0 + */ + public function getConfigFieldsetsEncryption(Container $container): ConfigFieldsetsEncryption + { + return new ConfigFieldsetsEncryption( + $container->get('Config'), + $container->get('Language'), + $container->get('Component'), + $container->get('Compiler.Builder.Config.Fieldsets'), + $container->get('Compiler.Builder.Config.Fieldsets.Customfield') + ); + } + + /** + * Get The ConfigFieldsetsGlobal Class. + * + * @param Container $container The DI container. + * + * @return ConfigFieldsetsGlobal + * @since 3.2.0 + */ + public function getConfigFieldsetsGlobal(Container $container): ConfigFieldsetsGlobal + { + return new ConfigFieldsetsGlobal( + $container->get('Config'), + $container->get('Language'), + $container->get('Component'), + $container->get('Compiler.Builder.Contributors'), + $container->get('Compiler.Builder.Config.Fieldsets'), + $container->get('Compiler.Builder.Extensions.Params'), + $container->get('Compiler.Builder.Config.Fieldsets.Customfield') + ); + } + + /** + * Get The ConfigFieldsetsGooglechart Class. + * + * @param Container $container The DI container. + * + * @return ConfigFieldsetsGooglechart + * @since 3.2.0 + */ + public function getConfigFieldsetsGooglechart(Container $container): ConfigFieldsetsGooglechart + { + return new ConfigFieldsetsGooglechart( + $container->get('Config'), + $container->get('Language'), + $container->get('Compiler.Builder.Config.Fieldsets'), + $container->get('Compiler.Builder.Config.Fieldsets.Customfield'), + $container->get('Compiler.Builder.Extensions.Params') + ); + } + + /** + * Get The ConfigFieldsetsGroupControl Class. + * + * @param Container $container The DI container. + * + * @return ConfigFieldsetsGroupControl + * @since 3.2.0 + */ + public function getConfigFieldsetsGroupControl(Container $container): ConfigFieldsetsGroupControl + { + return new ConfigFieldsetsGroupControl( + $container->get('Config'), + $container->get('Language'), + $container->get('Compiler.Builder.Field.Group.Control'), + $container->get('Compiler.Builder.Config.Fieldsets'), + $container->get('Compiler.Builder.Extensions.Params'), + $container->get('Compiler.Builder.Config.Fieldsets.Customfield') + ); + } + + /** + * Get The ConfigFieldsetsSiteControl Class. + * + * @param Container $container The DI container. + * + * @return ConfigFieldsetsSiteControl + * @since 3.2.0 + */ + public function getConfigFieldsetsSiteControl(Container $container): ConfigFieldsetsSiteControl + { + return new ConfigFieldsetsSiteControl( + $container->get('Component'), + $container->get('Compiler.Builder.Config.Fieldsets'), + $container->get('Compiler.Builder.Config.Fieldsets.Customfield'), + $container->get('Compiler.Builder.Has.Menu.Global'), + $container->get('Compiler.Builder.Frontend.Params'), + $container->get('Compiler.Creator.Request') + ); + } + + /** + * Get The ConfigFieldsetsUikit Class. + * + * @param Container $container The DI container. + * + * @return ConfigFieldsetsUikit + * @since 3.2.0 + */ + public function getConfigFieldsetsUikit(Container $container): ConfigFieldsetsUikit + { + return new ConfigFieldsetsUikit( + $container->get('Config'), + $container->get('Language'), + $container->get('Compiler.Builder.Config.Fieldsets'), + $container->get('Compiler.Builder.Extensions.Params'), + $container->get('Compiler.Builder.Config.Fieldsets.Customfield') ); } @@ -235,6 +573,102 @@ class Creator implements ServiceProviderInterface ); } + /** + * Get The Request Class. + * + * @param Container $container The DI container. + * + * @return Request + * @since 3.2.0 + */ + public function getRequest(Container $container): Request + { + return new Request( + $container->get('Compiler.Builder.Request') + ); + } + + /** + * Get The Router Class. + * + * @param Container $container The DI container. + * + * @return Router + * @since 3.2.0 + */ + public function getRouter(Container $container): Router + { + return new Router( + $container->get('Customcode.Dispenser'), + $container->get('Compiler.Builder.Request'), + $container->get('Compiler.Builder.Router'), + $container->get('Compiler.Creator.Router.Constructor.Default'), + $container->get('Compiler.Creator.Router.Constructor.Manual'), + $container->get('Compiler.Creator.Router.Methods.Default'), + $container->get('Compiler.Creator.Router.Methods.Manual') + ); + } + + /** + * Get The RouterConstructorDefault Class. + * + * @param Container $container The DI container. + * + * @return RouterConstructorDefault + * @since 3.2.0 + */ + public function getRouterConstructorDefault(Container $container): RouterConstructorDefault + { + return new RouterConstructorDefault( + $container->get('Compiler.Builder.Router') + ); + } + + /** + * Get The RouterConstructorManual Class. + * + * @param Container $container The DI container. + * + * @return RouterConstructorManual + * @since 3.2.0 + */ + public function getRouterConstructorManual(Container $container): RouterConstructorManual + { + return new RouterConstructorManual( + $container->get('Compiler.Builder.Router') + ); + } + + /** + * Get The RouterMethodsDefault Class. + * + * @param Container $container The DI container. + * + * @return RouterMethodsDefault + * @since 3.2.0 + */ + public function getRouterMethodsDefault(Container $container): RouterMethodsDefault + { + return new RouterMethodsDefault( + $container->get('Compiler.Builder.Router') + ); + } + + /** + * Get The RouterMethodsManual Class. + * + * @param Container $container The DI container. + * + * @return RouterMethodsManual + * @since 3.2.0 + */ + public function getRouterMethodsManual(Container $container): RouterMethodsManual + { + return new RouterMethodsManual( + $container->get('Compiler.Builder.Router') + ); + } + /** * Get The FieldsetString Class. * diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Event.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Event.php index 091f7c2ea..bc0c7edab 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Event.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Event.php @@ -17,6 +17,8 @@ use Joomla\DI\ServiceProviderInterface; use Joomla\CMS\Version; use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface; use VDM\Joomla\Componentbuilder\Compiler\JoomlaThree\Event as J3Event; +use VDM\Joomla\Componentbuilder\Compiler\JoomlaFour\Event as J4Event; +use VDM\Joomla\Componentbuilder\Compiler\JoomlaFive\Event as J5Event; /** @@ -47,6 +49,12 @@ class Event implements ServiceProviderInterface $container->alias(J3Event::class, 'J3.Event') ->share('J3.Event', [$this, 'getJ3Event'], true); + $container->alias(J4Event::class, 'J4.Event') + ->share('J4.Event', [$this, 'getJ4Event'], true); + + $container->alias(J5Event::class, 'J5.Event') + ->share('J5.Event', [$this, 'getJ5Event'], true); + $container->alias(EventInterface::class, 'Event') ->share('Event', [$this, 'getEvent'], true); } @@ -81,6 +89,31 @@ class Event implements ServiceProviderInterface { return new J3Event(); } - + + /** + * Get the Joomla 4 Event + * + * @param Container $container The DI container. + * + * @return J4Event + * @since 3.2.0 + */ + public function getJ4Event(Container $container): J4Event + { + return new J4Event(); + } + + /** + * Get the Joomla 5 Event + * + * @param Container $container The DI container. + * + * @return J5Event + * @since 3.2.0 + */ + public function getJ5Event(Container $container): J5Event + { + return new J5Event(); + } } diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Extension.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Extension.php index 50d751bae..1c2c5e791 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Extension.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Extension.php @@ -16,6 +16,8 @@ use Joomla\DI\Container; use Joomla\DI\ServiceProviderInterface; use VDM\Joomla\Componentbuilder\Compiler\Interfaces\GetScriptInterface; use VDM\Joomla\Componentbuilder\Compiler\Extension\JoomlaThree\InstallScript as J3InstallScript; +use VDM\Joomla\Componentbuilder\Compiler\Extension\JoomlaFour\InstallScript as J4InstallScript; +use VDM\Joomla\Componentbuilder\Compiler\Extension\JoomlaFive\InstallScript as J5InstallScript; /** @@ -48,6 +50,12 @@ class Extension implements ServiceProviderInterface $container->alias(J3InstallScript::class, 'J3.Extension.InstallScript') ->share('J3.Extension.InstallScript', [$this, 'getJ3ExtensionInstallScript'], true); + + $container->alias(J4InstallScript::class, 'J4.Extension.InstallScript') + ->share('J4.Extension.InstallScript', [$this, 'getJ4ExtensionInstallScript'], true); + + $container->alias(J5InstallScript::class, 'J5.Extension.InstallScript') + ->share('J5.Extension.InstallScript', [$this, 'getJ5ExtensionInstallScript'], true); } /** @@ -63,6 +71,32 @@ class Extension implements ServiceProviderInterface return new J3InstallScript(); } + /** + * Get the Joomla 4 Extension Install Script + * + * @param Container $container The DI container. + * + * @return J4InstallScript + * @since 3.2.0 + */ + public function getJ4ExtensionInstallScript(Container $container): J4InstallScript + { + return new J4InstallScript(); + } + + /** + * Get the Joomla 5 Extension Install Script + * + * @param Container $container The DI container. + * + * @return J5InstallScript + * @since 3.2.0 + */ + public function getJ5ExtensionInstallScript(Container $container): J5InstallScript + { + return new J5InstallScript(); + } + /** * Get the Joomla Extension Install Script * diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Field.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Field.php index e3ba24db5..01292db60 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Field.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Field.php @@ -13,7 +13,8 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service; use Joomla\DI\Container; -use Joomla\DI\ServiceProviderInterface; +use Joomla\DI\ServiceProviderInterface; +use Joomla\CMS\Version; use VDM\Joomla\Componentbuilder\Compiler\Field as CompilerField; use VDM\Joomla\Componentbuilder\Compiler\Field\Data; use VDM\Joomla\Componentbuilder\Compiler\Field\Groups; @@ -21,12 +22,21 @@ use VDM\Joomla\Componentbuilder\Compiler\Field\Attributes; use VDM\Joomla\Componentbuilder\Compiler\Field\Name; use VDM\Joomla\Componentbuilder\Compiler\Field\TypeName; use VDM\Joomla\Componentbuilder\Compiler\Field\UniqueName; -use VDM\Joomla\Componentbuilder\Compiler\Field\Validation; +use VDM\Joomla\Componentbuilder\Compiler\Field\Rule; use VDM\Joomla\Componentbuilder\Compiler\Field\Customcode; use VDM\Joomla\Componentbuilder\Compiler\Field\DatabaseName; -use VDM\Joomla\Componentbuilder\Compiler\Field\InputButton; -use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaThree\CoreValidation as J3CoreValidation; -use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreValidationInterface; +use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaThree\CoreRule as J3CoreRule; +use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFour\CoreRule as J4CoreRule; +use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFive\CoreRule as J5CoreRule; +use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaThree\CoreField as J3CoreField; +use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFour\CoreField as J4CoreField; +use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFive\CoreField as J5CoreField; +use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaThree\InputButton as J3InputButton; +use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFour\InputButton as J4InputButton; +use VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaFive\InputButton as J5InputButton; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreFieldInterface as CoreField; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreRuleInterface as CoreRule; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\InputButtonInterface as InputButton; /** @@ -44,6 +54,14 @@ class Field implements ServiceProviderInterface **/ protected $targetVersion; + /** + * Current Joomla Version We are IN + * + * @var int + * @since 3.2.0 + **/ + protected $currentVersion; + /** * Registers the service provider with a DI container. * @@ -55,7 +73,7 @@ class Field implements ServiceProviderInterface public function register(Container $container) { $container->alias(CompilerField::class, 'Field') - ->share('Field', [$this, 'getField'], true); + ->share('Field', [$this, 'getCompilerField'], true); $container->alias(Data::class, 'Field.Data') ->share('Field.Data', [$this, 'getData'], true); @@ -66,43 +84,70 @@ class Field implements ServiceProviderInterface $container->alias(Attributes::class, 'Field.Attributes') ->share('Field.Attributes', [$this, 'getAttributes'], true); - $container->alias(Validation::class, 'Field.Validation') - ->share('Field.Validation', [$this, 'getValidation'], true); + $container->alias(Name::class, 'Field.Name') + ->share('Field.Name', [$this, 'getName'], true); - $container->alias(J3CoreValidation::class, 'J3.Field.Core.Validation') - ->share('J3.Field.Core.Validation', [$this, 'getJ3CoreValidation'], true); + $container->alias(TypeName::class, 'Field.Type.Name') + ->share('Field.Type.Name', [$this, 'getTypeName'], true); - $container->alias(CoreValidationInterface::class, 'Field.Core.Validation') - ->share('Field.Core.Validation', [$this, 'getCoreValidation'], true); + $container->alias(UniqueName::class, 'Field.Unique.Name') + ->share('Field.Unique.Name', [$this, 'getUniqueName'], true); + + $container->alias(Rule::class, 'Field.Rule') + ->share('Field.Rule', [$this, 'getRule'], true); $container->alias(Customcode::class, 'Field.Customcode') ->share('Field.Customcode', [$this, 'getCustomcode'], true); - $container->alias(Name::class, 'Field.Name') - ->share('Field.Name', [$this, 'getFieldName'], true); - - $container->alias(TypeName::class, 'Field.Type.Name') - ->share('Field.Type.Name', [$this, 'getFieldTypeName'], true); - - $container->alias(UniqueName::class, 'Field.Unique.Name') - ->share('Field.Unique.Name', [$this, 'getFieldUniqueName'], true); - $container->alias(DatabaseName::class, 'Field.Database.Name') - ->share('Field.Database.Name', [$this, 'getFieldDatabaseName'], true); + ->share('Field.Database.Name', [$this, 'getDatabaseName'], true); + + $container->alias(J3CoreRule::class, 'J3.Field.Core.Rule') + ->share('J3.Field.Core.Rule', [$this, 'getJ3CoreRule'], true); + + $container->alias(J4CoreRule::class, 'J4.Field.Core.Rule') + ->share('J4.Field.Core.Rule', [$this, 'getJ4CoreRule'], true); + + $container->alias(J5CoreRule::class, 'J5.Field.Core.Rule') + ->share('J5.Field.Core.Rule', [$this, 'getJ5CoreRule'], true); + + $container->alias(J3CoreField::class, 'J3.Field.Core.Field') + ->share('J3.Field.Core.Field', [$this, 'getJ3CoreField'], true); + + $container->alias(J4CoreField::class, 'J4.Field.Core.Field') + ->share('J4.Field.Core.Field', [$this, 'getJ4CoreField'], true); + + $container->alias(J5CoreField::class, 'J5.Field.Core.Field') + ->share('J5.Field.Core.Field', [$this, 'getJ5CoreField'], true); + + $container->alias(J3InputButton::class, 'J3.Field.Input.Button') + ->share('J3.Field.Input.Button', [$this, 'getJ3InputButton'], true); + + $container->alias(J4InputButton::class, 'J4.Field.Input.Button') + ->share('J4.Field.Input.Button', [$this, 'getJ4InputButton'], true); + + $container->alias(J5InputButton::class, 'J5.Field.Input.Button') + ->share('J5.Field.Input.Button', [$this, 'getJ5InputButton'], true); + + $container->alias(CoreField::class, 'Field.Core.Field') + ->share('Field.Core.Field', [$this, 'getCoreField'], true); + + $container->alias(CoreRule::class, 'Field.Core.Rule') + ->share('Field.Core.Rule', [$this, 'getCoreRule'], true); $container->alias(InputButton::class, 'Field.Input.Button') ->share('Field.Input.Button', [$this, 'getInputButton'], true); } /** - * Get the Compiler Field + * Get The Field Class. * * @param Container $container The DI container. * * @return CompilerField * @since 3.2.0 */ - public function getField(Container $container): CompilerField + public function getCompilerField(Container $container): CompilerField { return new CompilerField( $container->get('Field.Data'), @@ -113,7 +158,7 @@ class Field implements ServiceProviderInterface } /** - * Get the Compiler Field Data + * Get The Data Class. * * @param Container $container The DI container. * @@ -129,12 +174,12 @@ class Field implements ServiceProviderInterface $container->get('Placeholder'), $container->get('Customcode'), $container->get('Field.Customcode'), - $container->get('Field.Validation') + $container->get('Field.Rule') ); } /** - * Get the Compiler Field Groups + * Get The Groups Class. * * @param Container $container The DI container. * @@ -147,7 +192,7 @@ class Field implements ServiceProviderInterface } /** - * Get the Compiler Field Attributes + * Get The Attributes Class. * * @param Container $container The DI container. * @@ -169,57 +214,71 @@ class Field implements ServiceProviderInterface } /** - * Get the Compiler Field Validation + * Get The Name Class. * * @param Container $container The DI container. * - * @return Validation + * @return Name * @since 3.2.0 */ - public function getValidation(Container $container): Validation + public function getName(Container $container): Name { - return new Validation( - $container->get('Registry'), - $container->get('Customcode.Gui'), + return new Name( $container->get('Placeholder'), - $container->get('Customcode'), - $container->get('Field.Core.Validation') + $container->get('Field.Unique.Name'), + $container->get('Compiler.Builder.Category.Other.Name') ); } /** - * Get the Compiler Field Joomla 3 Validation + * Get The TypeName Class. * * @param Container $container The DI container. * - * @return J3CoreValidation + * @return TypeName * @since 3.2.0 */ - public function getJ3CoreValidation(Container $container): J3CoreValidation + public function getTypeName(Container $container): TypeName { - return new J3CoreValidation(); + return new TypeName(); } /** - * Get the Compiler Field Core Validation + * Get The UniqueName Class. * * @param Container $container The DI container. * - * @return CoreValidationInterface + * @return UniqueName * @since 3.2.0 */ - public function getCoreValidation(Container $container): CoreValidationInterface + public function getUniqueName(Container $container): UniqueName { - if (empty($this->targetVersion)) - { - $this->targetVersion = $container->get('Config')->joomla_version; - } - - return $container->get('J' . $this->targetVersion . '.Field.Core.Validation'); + return new UniqueName( + $container->get('Registry') + ); } /** - * Get the Compiler Field Customcode + * Get The Rule Class. + * + * @param Container $container The DI container. + * + * @return Rule + * @since 3.2.0 + */ + public function getRule(Container $container): Rule + { + return new Rule( + $container->get('Registry'), + $container->get('Customcode'), + $container->get('Customcode.Gui'), + $container->get('Placeholder'), + $container->get('Field.Core.Rule') + ); + } + + /** + * Get The Customcode Class. * * @param Container $container The DI container. * @@ -234,59 +293,14 @@ class Field implements ServiceProviderInterface } /** - * Get the Compiler Field Name - * - * @param Container $container The DI container. - * - * @return Name - * @since 3.2.0 - */ - public function getFieldName(Container $container): Name - { - return new Name( - $container->get('Placeholder'), - $container->get('Field.Unique.Name'), - $container->get('Compiler.Builder.Category.Other.Name') - ); - } - - /** - * Get the Compiler Field Type Name - * - * @param Container $container The DI container. - * - * @return TypeName - * @since 3.2.0 - */ - public function getFieldTypeName(Container $container): TypeName - { - return new TypeName(); - } - - /** - * Get the Compiler Field Unique Name - * - * @param Container $container The DI container. - * - * @return UniqueName - * @since 3.2.0 - */ - public function getFieldUniqueName(Container $container): UniqueName - { - return new UniqueName( - $container->get('Registry') - ); - } - - /** - * Get the Compiler Field Database Name + * Get The DatabaseName Class. * * @param Container $container The DI container. * * @return DatabaseName * @since 3.2.0 */ - public function getFieldDatabaseName(Container $container): DatabaseName + public function getDatabaseName(Container $container): DatabaseName { return new DatabaseName( $container->get('Compiler.Builder.Lists'), @@ -294,6 +308,171 @@ class Field implements ServiceProviderInterface ); } + /** + * Get The CoreRule Class. + * + * @param Container $container The DI container. + * + * @return J3CoreRule + * @since 3.2.0 + */ + public function getJ3CoreRule(Container $container): J3CoreRule + { + return new J3CoreRule(); + } + + /** + * Get The CoreRule Class. + * + * @param Container $container The DI container. + * + * @return J4CoreRule + * @since 3.2.0 + */ + public function getJ4CoreRule(Container $container): J4CoreRule + { + return new J4CoreRule(); + } + + /** + * Get The CoreRule Class. + * + * @param Container $container The DI container. + * + * @return J5CoreRule + * @since 3.2.0 + */ + public function getJ5CoreRule(Container $container): J5CoreRule + { + return new J5CoreRule(); + } + + /** + * Get The CoreField Class. + * + * @param Container $container The DI container. + * + * @return J3CoreField + * @since 3.2.0 + */ + public function getJ3CoreField(Container $container): J3CoreField + { + return new J3CoreField(); + } + + /** + * Get The CoreField Class. + * + * @param Container $container The DI container. + * + * @return J4CoreField + * @since 3.2.0 + */ + public function getJ4CoreField(Container $container): J4CoreField + { + return new J4CoreField(); + } + + /** + * Get The CoreField Class. + * + * @param Container $container The DI container. + * + * @return J5CoreField + * @since 3.2.0 + */ + public function getJ5CoreField(Container $container): J5CoreField + { + return new J5CoreField(); + } + + /** + * Get The J3InputButton Class. + * + * @param Container $container The DI container. + * + * @return J3InputButton + * @since 3.2.0 + */ + public function getJ3InputButton(Container $container): J3InputButton + { + return new J3InputButton( + $container->get('Config'), + $container->get('Placeholder'), + $container->get('Compiler.Creator.Permission') + ); + } + + /** + * Get The J4InputButton Class. + * + * @param Container $container The DI container. + * + * @return J4InputButton + * @since 3.2.0 + */ + public function getJ4InputButton(Container $container): J4InputButton + { + return new J4InputButton( + $container->get('Config'), + $container->get('Placeholder'), + $container->get('Compiler.Creator.Permission') + ); + } + + /** + * Get The J5InputButton Class. + * + * @param Container $container The DI container. + * + * @return J5InputButton + * @since 3.2.0 + */ + public function getJ5InputButton(Container $container): J5InputButton + { + return new J5InputButton( + $container->get('Config'), + $container->get('Placeholder'), + $container->get('Compiler.Creator.Permission') + ); + } + + /** + * Get The CoreFieldInterface Class. + * + * @param Container $container The DI container. + * + * @return CoreField + * @since 3.2.0 + */ + public function getCoreField(Container $container): CoreField + { + if (empty($this->currentVersion)) + { + $this->currentVersion = Version::MAJOR_VERSION; + } + + return $container->get('J' . $this->currentVersion . '.Field.Core.Field'); + } + + /** + * Get The CoreRuleInterface Class. + * + * @param Container $container The DI container. + * + * @return CoreRule + * @since 3.2.0 + */ + public function getCoreRule(Container $container): CoreRule + { + if (empty($this->currentVersion)) + { + $this->currentVersion = Version::MAJOR_VERSION; + } + + return $container->get('J' . $this->currentVersion . '.Field.Core.Rule'); + } + /** * Get The InputButton Class. * @@ -304,11 +483,12 @@ class Field implements ServiceProviderInterface */ public function getInputButton(Container $container): InputButton { - return new InputButton( - $container->get('Config'), - $container->get('Placeholder'), - $container->get('Compiler.Creator.Permission') - ); + if (empty($this->targetVersion)) + { + $this->targetVersion = $container->get('Config')->joomla_version; + } + + return $container->get('J' . $this->targetVersion . '.Field.Input.Button'); } } diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Header.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Header.php new file mode 100644 index 000000000..6f3ee5c94 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Header.php @@ -0,0 +1,151 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HeaderInterface; +use VDM\Joomla\Componentbuilder\Compiler\JoomlaThree\Header as J3Header; +use VDM\Joomla\Componentbuilder\Compiler\JoomlaFour\Header as J4Header; +use VDM\Joomla\Componentbuilder\Compiler\JoomlaFive\Header as J5Header; + + +/** + * Header Service Provider + * + * @since 3.2.0 + */ +class Header implements ServiceProviderInterface +{ + /** + * Current Joomla Version Being Build + * + * @var int + * @since 3.2.0 + **/ + protected $targetVersion; + + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(J3Header::class, 'J3.Header') + ->share('J3.Header', [$this, 'getJ3Header'], true); + + $container->alias(J4Header::class, 'J4.Header') + ->share('J4.Header', [$this, 'getJ4Header'], true); + + $container->alias(J5Header::class, 'J5.Header') + ->share('J5.Header', [$this, 'getJ5Header'], true); + + $container->alias(HeaderInterface::class, 'Header') + ->share('Header', [$this, 'getHeader'], true); + } + + /** + * Get the Header + * + * @param Container $container The DI container. + * + * @return HeaderInterface + * @since 3.2.0 + */ + public function getHeader(Container $container): HeaderInterface + { + if (empty($this->targetVersion)) + { + $this->targetVersion = $container->get('Config')->joomla_version; + } + + return $container->get('J' . $this->targetVersion . '.Header'); + } + + /** + * Get The Header Class. + * + * @param Container $container The DI container. + * + * @return J3Header + * @since 3.2.0 + */ + public function getJ3Header(Container $container): J3Header + { + return new J3Header( + $container->get('Config'), + $container->get('Event'), + $container->get('Placeholder'), + $container->get('Language'), + $container->get('Compiler.Builder.Uikit.Comp'), + $container->get('Compiler.Builder.Admin.Filter.Type'), + $container->get('Compiler.Builder.Category'), + $container->get('Compiler.Builder.Access.Switch.List'), + $container->get('Compiler.Builder.Filter'), + $container->get('Compiler.Builder.Tags') + ); + } + + /** + * Get The Header Class. + * + * @param Container $container The DI container. + * + * @return J4Header + * @since 3.2.0 + */ + public function getJ4Header(Container $container): J4Header + { + return new J4Header( + $container->get('Config'), + $container->get('Event'), + $container->get('Placeholder'), + $container->get('Language'), + $container->get('Compiler.Builder.Uikit.Comp'), + $container->get('Compiler.Builder.Admin.Filter.Type'), + $container->get('Compiler.Builder.Category'), + $container->get('Compiler.Builder.Access.Switch.List'), + $container->get('Compiler.Builder.Filter'), + $container->get('Compiler.Builder.Tags') + ); + } + + /** + * Get The Header Class. + * + * @param Container $container The DI container. + * + * @return J5Header + * @since 3.2.0 + */ + public function getJ5Header(Container $container): J5Header + { + return new J5Header( + $container->get('Config'), + $container->get('Event'), + $container->get('Placeholder'), + $container->get('Language'), + $container->get('Compiler.Builder.Uikit.Comp'), + $container->get('Compiler.Builder.Admin.Filter.Type'), + $container->get('Compiler.Builder.Category'), + $container->get('Compiler.Builder.Access.Switch.List'), + $container->get('Compiler.Builder.Filter'), + $container->get('Compiler.Builder.Tags') + ); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/History.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/History.php index 7b3a67d4e..9beb59d9c 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/History.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/History.php @@ -17,6 +17,8 @@ use Joomla\DI\ServiceProviderInterface; use Joomla\CMS\Version; use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HistoryInterface; use VDM\Joomla\Componentbuilder\Compiler\JoomlaThree\History as J3History; +use VDM\Joomla\Componentbuilder\Compiler\JoomlaFour\History as J4History; +use VDM\Joomla\Componentbuilder\Compiler\JoomlaFive\History as J5History; /** @@ -47,6 +49,12 @@ class History implements ServiceProviderInterface $container->alias(J3History::class, 'J3.History') ->share('J3.History', [$this, 'getJ3History'], true); + $container->alias(J4History::class, 'J4.History') + ->share('J4.History', [$this, 'getJ4History'], true); + + $container->alias(J5History::class, 'J5.History') + ->share('J5.History', [$this, 'getJ5History'], true); + $container->alias(HistoryInterface::class, 'History') ->share('History', [$this, 'getHistory'], true); } @@ -83,6 +91,35 @@ class History implements ServiceProviderInterface $container->get('Config') ); } - + + /** + * Get the Joomla 4 History + * + * @param Container $container The DI container. + * + * @return J4History + * @since 3.2.0 + */ + public function getJ4History(Container $container): J4History + { + return new J4History( + $container->get('Config') + ); + } + + /** + * Get the Joomla 5 History + * + * @param Container $container The DI container. + * + * @return J5History + * @since 3.2.0 + */ + public function getJ5History(Container $container): J5History + { + return new J5History( + $container->get('Config') + ); + } } diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Model.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Model.php index fe9caea63..833398249 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Model.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Model.php @@ -44,7 +44,10 @@ use VDM\Joomla\Componentbuilder\Compiler\Model\Conditions; use VDM\Joomla\Componentbuilder\Compiler\Model\Fields; use VDM\Joomla\Componentbuilder\Compiler\Model\Updatesql; use VDM\Joomla\Componentbuilder\Compiler\Model\Tabs; -use VDM\Joomla\Componentbuilder\Compiler\Model\Customtabs; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Model\CustomtabsInterface as Customtabs; +use VDM\Joomla\Componentbuilder\Compiler\Model\JoomlaThree\Customtabs as CustomtabsJ3; +use VDM\Joomla\Componentbuilder\Compiler\Model\JoomlaFour\Customtabs as CustomtabsJ4; +use VDM\Joomla\Componentbuilder\Compiler\Model\JoomlaFive\Customtabs as CustomtabsJ5; use VDM\Joomla\Componentbuilder\Compiler\Model\Adminviews; use VDM\Joomla\Componentbuilder\Compiler\Model\Sqltweaking; use VDM\Joomla\Componentbuilder\Compiler\Model\Sqldump; @@ -52,6 +55,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Model\Whmcs; use VDM\Joomla\Componentbuilder\Compiler\Model\Filesfolders; use VDM\Joomla\Componentbuilder\Compiler\Model\Modifieddate; use VDM\Joomla\Componentbuilder\Compiler\Model\Createdate; +use VDM\Joomla\Componentbuilder\Compiler\Model\Router; use VDM\Joomla\Componentbuilder\Compiler\Model\Updateserver; @@ -62,6 +66,14 @@ use VDM\Joomla\Componentbuilder\Compiler\Model\Updateserver; */ class Model implements ServiceProviderInterface { + /** + * Current Joomla Version Being Build + * + * @var int + * @since 3.2.0 + **/ + protected $targetVersion; + /** * Registers the service provider with a DI container. * @@ -72,107 +84,122 @@ class Model implements ServiceProviderInterface */ public function register(Container $container) { + $container->alias(ServerLoad::class, 'Model.Server.Load') + ->share('Model.Server.Load', [$this, 'getServerLoad'], true); + $container->alias(Joomlaplugins::class, 'Model.Joomlaplugins') - ->share('Model.Joomlaplugins', [$this, 'getModelJoomlaplugins'], true); + ->share('Model.Joomlaplugins', [$this, 'getJoomlaplugins'], true); $container->alias(Joomlamodules::class, 'Model.Joomlamodules') - ->share('Model.Joomlamodules', [$this, 'getModelJoomlamodules'], true); + ->share('Model.Joomlamodules', [$this, 'getJoomlamodules'], true); $container->alias(Historycomponent::class, 'Model.Historycomponent') - ->share('Model.Historycomponent', [$this, 'getModelHistorycomponent'], true); + ->share('Model.Historycomponent', [$this, 'getHistorycomponent'], true); $container->alias(Customadminviews::class, 'Model.Customadminviews') - ->share('Model.Customadminviews', [$this, 'getModelCustomadminviews'], true); + ->share('Model.Customadminviews', [$this, 'getCustomadminviews'], true); $container->alias(Ajaxcustomview::class, 'Model.Ajaxcustomview') - ->share('Model.Ajaxcustomview', [$this, 'getModelAjaxcustomview'], true); + ->share('Model.Ajaxcustomview', [$this, 'getAjaxcustomview'], true); $container->alias(Javascriptcustomview::class, 'Model.Javascriptcustomview') - ->share('Model.Javascriptcustomview', [$this, 'getModelJavascriptcustomview'], true); + ->share('Model.Javascriptcustomview', [$this, 'getJavascriptcustomview'], true); $container->alias(Csscustomview::class, 'Model.Csscustomview') - ->share('Model.Csscustomview', [$this, 'getModelCsscustomview'], true); + ->share('Model.Csscustomview', [$this, 'getCsscustomview'], true); $container->alias(Phpcustomview::class, 'Model.Phpcustomview') - ->share('Model.Phpcustomview', [$this, 'getModelPhpcustomview'], true); + ->share('Model.Phpcustomview', [$this, 'getPhpcustomview'], true); $container->alias(Dynamicget::class, 'Model.Dynamicget') - ->share('Model.Dynamicget', [$this, 'getModelDynamicget'], true); + ->share('Model.Dynamicget', [$this, 'getDynamicget'], true); $container->alias(Libraries::class, 'Model.Libraries') - ->share('Model.Libraries', [$this, 'getModelLibraries'], true); + ->share('Model.Libraries', [$this, 'getLibraries'], true); $container->alias(Siteviews::class, 'Model.Siteviews') - ->share('Model.Siteviews', [$this, 'getModelSiteviews'], true); + ->share('Model.Siteviews', [$this, 'getSiteviews'], true); $container->alias(Permissions::class, 'Model.Permissions') - ->share('Model.Permissions', [$this, 'getModelPermissions'], true); + ->share('Model.Permissions', [$this, 'getPermissions'], true); $container->alias(Historyadminview::class, 'Model.Historyadminview') - ->share('Model.Historyadminview', [$this, 'getModelHistoryadminview'], true); + ->share('Model.Historyadminview', [$this, 'getHistoryadminview'], true); $container->alias(Mysqlsettings::class, 'Model.Mysqlsettings') - ->share('Model.Mysqlsettings', [$this, 'getModelMysqlsettings'], true); + ->share('Model.Mysqlsettings', [$this, 'getMysqlsettings'], true); $container->alias(Sql::class, 'Model.Sql') - ->share('Model.Sql', [$this, 'getModelSql'], true); + ->share('Model.Sql', [$this, 'getSql'], true); $container->alias(Customalias::class, 'Model.Customalias') - ->share('Model.Customalias', [$this, 'getModelCustomalias'], true); + ->share('Model.Customalias', [$this, 'getCustomalias'], true); $container->alias(Ajaxadmin::class, 'Model.Ajaxadmin') - ->share('Model.Ajaxadmin', [$this, 'getModelAjaxadmin'], true); + ->share('Model.Ajaxadmin', [$this, 'getAjaxadmin'], true); $container->alias(Customimportscripts::class, 'Model.Customimportscripts') - ->share('Model.Customimportscripts', [$this, 'getModelCustomimportscripts'], true); + ->share('Model.Customimportscripts', [$this, 'getCustomimportscripts'], true); $container->alias(Custombuttons::class, 'Model.Custombuttons') - ->share('Model.Custombuttons', [$this, 'getModelCustombuttons'], true); + ->share('Model.Custombuttons', [$this, 'getCustombuttons'], true); $container->alias(Loader::class, 'Model.Loader') - ->share('Model.Loader', [$this, 'getModelLoader'], true); + ->share('Model.Loader', [$this, 'getLoader'], true); $container->alias(Phpadminview::class, 'Model.Phpadminview') - ->share('Model.Phpadminview', [$this, 'getModelPhpadminview'], true); + ->share('Model.Phpadminview', [$this, 'getPhpadminview'], true); $container->alias(Cssadminview::class, 'Model.Cssadminview') - ->share('Model.Cssadminview', [$this, 'getModelCssadminview'], true); + ->share('Model.Cssadminview', [$this, 'getCssadminview'], true); $container->alias(Javascriptadminview::class, 'Model.Javascriptadminview') - ->share('Model.Javascriptadminview', [$this, 'getModelJavascriptadminview'], true); + ->share('Model.Javascriptadminview', [$this, 'getJavascriptadminview'], true); $container->alias(Linkedviews::class, 'Model.Linkedviews') - ->share('Model.Linkedviews', [$this, 'getModelLinkedviews'], true); + ->share('Model.Linkedviews', [$this, 'getLinkedviews'], true); $container->alias(Relations::class, 'Model.Relations') - ->share('Model.Relations', [$this, 'getModelRelations'], true); + ->share('Model.Relations', [$this, 'getRelations'], true); $container->alias(Conditions::class, 'Model.Conditions') - ->share('Model.Conditions', [$this, 'getModelConditions'], true); + ->share('Model.Conditions', [$this, 'getConditions'], true); $container->alias(Fields::class, 'Model.Fields') - ->share('Model.Fields', [$this, 'getModelFields'], true); + ->share('Model.Fields', [$this, 'getFields'], true); $container->alias(Updatesql::class, 'Model.Updatesql') - ->share('Model.Updatesql', [$this, 'getModelUpdatesql'], true); + ->share('Model.Updatesql', [$this, 'getUpdatesql'], true); $container->alias(Tabs::class, 'Model.Tabs') - ->share('Model.Tabs', [$this, 'getModelTabs'], true); + ->share('Model.Tabs', [$this, 'getTabs'], true); $container->alias(Customtabs::class, 'Model.Customtabs') - ->share('Model.Customtabs', [$this, 'getModelCustomtabs'], true); + ->share('Model.Customtabs', [$this, 'getCustomtabs'], true); + + $container->alias(CustomtabsJ3::class, 'Model.J3.Customtabs') + ->share('Model.J3.Customtabs', [$this, 'getCustomtabsJ3'], true); + + $container->alias(CustomtabsJ4::class, 'Model.J4.Customtabs') + ->share('Model.J4.Customtabs', [$this, 'getCustomtabsJ4'], true); + + $container->alias(CustomtabsJ5::class, 'Model.J5.Customtabs') + ->share('Model.J5.Customtabs', [$this, 'getCustomtabsJ5'], true); $container->alias(Adminviews::class, 'Model.Adminviews') - ->share('Model.Adminviews', [$this, 'getModelAdminviews'], true); + ->share('Model.Adminviews', [$this, 'getAdminviews'], true); $container->alias(Sqltweaking::class, 'Model.Sqltweaking') - ->share('Model.Sqltweaking', [$this, 'getModelSqltweaking'], true); + ->share('Model.Sqltweaking', [$this, 'getSqltweaking'], true); $container->alias(Sqldump::class, 'Model.Sqldump') - ->share('Model.Sqldump', [$this, 'getModelSqldump'], true); + ->share('Model.Sqldump', [$this, 'getSqldump'], true); $container->alias(Whmcs::class, 'Model.Whmcs') - ->share('Model.Whmcs', [$this, 'getModelWhmcs'], true); + ->share('Model.Whmcs', [$this, 'getWhmcs'], true); + + $container->alias(Filesfolders::class, 'Model.Filesfolders') + ->share('Model.Filesfolders', [$this, 'getFilesfolders'], true); $container->alias(Modifieddate::class, 'Model.Modifieddate') ->share('Model.Modifieddate', [$this, 'getModifieddate'], true); @@ -180,25 +207,38 @@ class Model implements ServiceProviderInterface $container->alias(Createdate::class, 'Model.Createdate') ->share('Model.Createdate', [$this, 'getCreatedate'], true); + $container->alias(Router::class, 'Model.Router') + ->share('Model.Router', [$this, 'getRouter'], true); + $container->alias(Updateserver::class, 'Model.Updateserver') ->share('Model.Updateserver', [$this, 'getUpdateserver'], true); - - $container->alias(Filesfolders::class, 'Model.Filesfolders') - ->share('Model.Filesfolders', [$this, 'getModelFilesfolders'], true); - - $container->alias(ServerLoad::class, 'Model.Server.Load') - ->share('Model.Server.Load', [$this, 'getServerLoad'], true); } /** - * Get the Joomla plugins Model + * Get The Load Class. + * + * @param Container $container The DI container. + * + * @return ServerLoad + * @since 3.2.0 + */ + public function getServerLoad(Container $container): ServerLoad + { + return new ServerLoad( + $container->get('Crypt'), + $container->get('Table') + ); + } + + /** + * Get The Joomlaplugins Class. * * @param Container $container The DI container. * * @return Joomlaplugins * @since 3.2.0 */ - public function getModelJoomlaplugins(Container $container): Joomlaplugins + public function getJoomlaplugins(Container $container): Joomlaplugins { return new Joomlaplugins( $container->get('Joomlaplugin.Data') @@ -206,14 +246,14 @@ class Model implements ServiceProviderInterface } /** - * Get the Joomla modules Model + * Get The Joomlamodules Class. * * @param Container $container The DI container. * * @return Joomlamodules * @since 3.2.0 */ - public function getModelJoomlamodules(Container $container): Joomlamodules + public function getJoomlamodules(Container $container): Joomlamodules { return new Joomlamodules( $container->get('Joomlamodule.Data') @@ -221,14 +261,14 @@ class Model implements ServiceProviderInterface } /** - * Get the history component Model + * Get The Historycomponent Class. * * @param Container $container The DI container. * * @return Historycomponent * @since 3.2.0 */ - public function getModelHistorycomponent(Container $container): Historycomponent + public function getHistorycomponent(Container $container): Historycomponent { return new Historycomponent( $container->get('Config'), @@ -238,14 +278,14 @@ class Model implements ServiceProviderInterface } /** - * Get the custom admin views Model + * Get The Customadminviews Class. * * @param Container $container The DI container. * * @return Customadminviews * @since 3.2.0 */ - public function getModelCustomadminviews(Container $container): Customadminviews + public function getCustomadminviews(Container $container): Customadminviews { return new Customadminviews( $container->get('Customview.Data'), @@ -254,14 +294,14 @@ class Model implements ServiceProviderInterface } /** - * Get the ajax custom view Model + * Get The Ajaxcustomview Class. * * @param Container $container The DI container. * * @return Ajaxcustomview * @since 3.2.0 */ - public function getModelAjaxcustomview(Container $container): Ajaxcustomview + public function getAjaxcustomview(Container $container): Ajaxcustomview { return new Ajaxcustomview( $container->get('Config'), @@ -270,14 +310,14 @@ class Model implements ServiceProviderInterface } /** - * Get the javascript custom view Model + * Get The Javascriptcustomview Class. * * @param Container $container The DI container. * * @return Javascriptcustomview * @since 3.2.0 */ - public function getModelJavascriptcustomview(Container $container): Javascriptcustomview + public function getJavascriptcustomview(Container $container): Javascriptcustomview { return new Javascriptcustomview( $container->get('Customcode'), @@ -286,14 +326,14 @@ class Model implements ServiceProviderInterface } /** - * Get the css custom view Model + * Get The Csscustomview Class. * * @param Container $container The DI container. * * @return Csscustomview * @since 3.2.0 */ - public function getModelCsscustomview(Container $container): Csscustomview + public function getCsscustomview(Container $container): Csscustomview { return new Csscustomview( $container->get('Customcode') @@ -301,14 +341,14 @@ class Model implements ServiceProviderInterface } /** - * Get the php custom view Model + * Get The Phpcustomview Class. * * @param Container $container The DI container. * * @return Phpcustomview * @since 3.2.0 */ - public function getModelPhpcustomview(Container $container): Phpcustomview + public function getPhpcustomview(Container $container): Phpcustomview { return new Phpcustomview( $container->get('Customcode'), @@ -319,14 +359,14 @@ class Model implements ServiceProviderInterface } /** - * Get the dynamic get Model + * Get The Dynamicget Class. * * @param Container $container The DI container. * * @return Dynamicget * @since 3.2.0 */ - public function getModelDynamicget(Container $container): Dynamicget + public function getDynamicget(Container $container): Dynamicget { return new Dynamicget( $container->get('Config'), @@ -340,14 +380,14 @@ class Model implements ServiceProviderInterface } /** - * Get the libraries Model + * Get The Libraries Class. * * @param Container $container The DI container. * * @return Libraries * @since 3.2.0 */ - public function getModelLibraries(Container $container): Libraries + public function getLibraries(Container $container): Libraries { return new Libraries( $container->get('Config'), @@ -357,14 +397,14 @@ class Model implements ServiceProviderInterface } /** - * Get the site views Model + * Get The Siteviews Class. * * @param Container $container The DI container. * * @return Siteviews * @since 3.2.0 */ - public function getModelSiteviews(Container $container): Siteviews + public function getSiteviews(Container $container): Siteviews { return new Siteviews( $container->get('Customview.Data'), @@ -373,27 +413,27 @@ class Model implements ServiceProviderInterface } /** - * Get the permissions Model + * Get The Permissions Class. * * @param Container $container The DI container. * * @return Permissions * @since 3.2.0 */ - public function getModelPermissions(Container $container): Permissions + public function getPermissions(Container $container): Permissions { return new Permissions(); } /** - * Get the admin view history Model + * Get The Historyadminview Class. * * @param Container $container The DI container. * * @return Historyadminview * @since 3.2.0 */ - public function getModelHistoryadminview(Container $container): Historyadminview + public function getHistoryadminview(Container $container): Historyadminview { return new Historyadminview( $container->get('Config'), @@ -403,14 +443,14 @@ class Model implements ServiceProviderInterface } /** - * Get the MySQL settings Model + * Get The Mysqlsettings Class. * * @param Container $container The DI container. * * @return Mysqlsettings * @since 3.2.0 */ - public function getModelMysqlsettings(Container $container): Mysqlsettings + public function getMysqlsettings(Container $container): Mysqlsettings { return new Mysqlsettings( $container->get('Config'), @@ -419,14 +459,14 @@ class Model implements ServiceProviderInterface } /** - * Get the Sql Model + * Get The Sql Class. * * @param Container $container The DI container. * * @return Sql * @since 3.2.0 */ - public function getModelSql(Container $container): Sql + public function getSql(Container $container): Sql { return new Sql( $container->get('Customcode.Dispenser'), @@ -435,14 +475,14 @@ class Model implements ServiceProviderInterface } /** - * Get the custom alias Model + * Get The Customalias Class. * * @param Container $container The DI container. * * @return Customalias * @since 3.2.0 */ - public function getModelCustomalias(Container $container): Customalias + public function getCustomalias(Container $container): Customalias { return new Customalias( $container->get('Compiler.Builder.Custom.Alias'), @@ -451,14 +491,14 @@ class Model implements ServiceProviderInterface } /** - * Get the Admin Ajax Model + * Get The Ajaxadmin Class. * * @param Container $container The DI container. * * @return Ajaxadmin * @since 3.2.0 */ - public function getModelAjaxadmin(Container $container): Ajaxadmin + public function getAjaxadmin(Container $container): Ajaxadmin { return new Ajaxadmin( $container->get('Config'), @@ -468,14 +508,14 @@ class Model implements ServiceProviderInterface } /** - * Get the custom import scripts Model + * Get The Customimportscripts Class. * * @param Container $container The DI container. * * @return Customimportscripts * @since 3.2.0 */ - public function getModelCustomimportscripts(Container $container): Customimportscripts + public function getCustomimportscripts(Container $container): Customimportscripts { return new Customimportscripts( $container->get('Customcode.Dispenser') @@ -483,14 +523,14 @@ class Model implements ServiceProviderInterface } /** - * Get the custom import scripts Model + * Get The Custombuttons Class. * * @param Container $container The DI container. * * @return Custombuttons * @since 3.2.0 */ - public function getModelCustombuttons(Container $container): Custombuttons + public function getCustombuttons(Container $container): Custombuttons { return new Custombuttons( $container->get('Customcode'), @@ -500,14 +540,14 @@ class Model implements ServiceProviderInterface } /** - * Get The Model Loader Class. + * Get The Loader Class. * * @param Container $container The DI container. * * @return Loader * @since 3.2.0 */ - public function getModelLoader(Container $container): Loader + public function getLoader(Container $container): Loader { return new Loader( $container->get('Config'), @@ -519,14 +559,14 @@ class Model implements ServiceProviderInterface } /** - * Get the php admin view Model + * Get The Phpadminview Class. * * @param Container $container The DI container. * * @return Phpadminview * @since 3.2.0 */ - public function getModelPhpadminview(Container $container): Phpadminview + public function getPhpadminview(Container $container): Phpadminview { return new Phpadminview( $container->get('Customcode.Dispenser'), @@ -535,14 +575,14 @@ class Model implements ServiceProviderInterface } /** - * Get the Css Adminview Model + * Get The Cssadminview Class. * * @param Container $container The DI container. * * @return Cssadminview * @since 3.2.0 */ - public function getModelCssadminview(Container $container): Cssadminview + public function getCssadminview(Container $container): Cssadminview { return new Cssadminview( $container->get('Customcode.Dispenser') @@ -550,14 +590,14 @@ class Model implements ServiceProviderInterface } /** - * Get the Javascript Adminview Model + * Get The Javascriptadminview Class. * * @param Container $container The DI container. * * @return Javascriptadminview * @since 3.2.0 */ - public function getModelJavascriptadminview(Container $container): Javascriptadminview + public function getJavascriptadminview(Container $container): Javascriptadminview { return new Javascriptadminview( $container->get('Customcode.Dispenser') @@ -565,14 +605,14 @@ class Model implements ServiceProviderInterface } /** - * Get the linked views Model + * Get The Linkedviews Class. * * @param Container $container The DI container. * * @return Linkedviews * @since 3.2.0 */ - public function getModelLinkedviews(Container $container): Linkedviews + public function getLinkedviews(Container $container): Linkedviews { return new Linkedviews( $container->get('Registry') @@ -580,14 +620,14 @@ class Model implements ServiceProviderInterface } /** - * Get the relations Model + * Get The Relations Class. * * @param Container $container The DI container. * * @return Relations * @since 3.2.0 */ - public function getModelRelations(Container $container): Relations + public function getRelations(Container $container): Relations { return new Relations( $container->get('Config'), @@ -600,14 +640,14 @@ class Model implements ServiceProviderInterface } /** - * Get the conditions Model + * Get The Conditions Class. * * @param Container $container The DI container. * * @return Conditions * @since 3.2.0 */ - public function getModelConditions(Container $container): Conditions + public function getConditions(Container $container): Conditions { return new Conditions( $container->get('Field.Type.Name'), @@ -617,14 +657,14 @@ class Model implements ServiceProviderInterface } /** - * Get the fields Model + * Get The Fields Class. * * @param Container $container The DI container. * * @return Fields * @since 3.2.0 */ - public function getModelFields(Container $container): Fields + public function getFields(Container $container): Fields { return new Fields( $container->get('Config'), @@ -639,14 +679,14 @@ class Model implements ServiceProviderInterface } /** - * Get the update sql Model + * Get The Updatesql Class. * * @param Container $container The DI container. * * @return Updatesql * @since 3.2.0 */ - public function getModelUpdatesql(Container $container): Updatesql + public function getUpdatesql(Container $container): Updatesql { return new Updatesql( $container->get('Registry') @@ -654,29 +694,47 @@ class Model implements ServiceProviderInterface } /** - * Get the tabs Model + * Get The Tabs Class. * * @param Container $container The DI container. * - * @return Updatesql + * @return Tabs * @since 3.2.0 */ - public function getModelTabs(Container $container): Tabs + public function getTabs(Container $container): Tabs { return new Tabs(); } /** - * Get the custom tabs Model + * Get The Customtabs Class. * * @param Container $container The DI container. * * @return Customtabs * @since 3.2.0 */ - public function getModelCustomtabs(Container $container): Customtabs + public function getCustomtabs(Container $container): Customtabs { - return new Customtabs( + if (empty($this->targetVersion)) + { + $this->targetVersion = $container->get('Config')->joomla_version; + } + + return $container->get('Model.J' . $this->targetVersion . '.Customtabs'); + } + + /** + * Get The CustomtabsJ3 Class. + * + * @param Container $container The DI container. + * + * @return CustomtabsJ3 + * @since 3.2.0 + */ + public function getCustomtabsJ3(Container $container): CustomtabsJ3 + { + return new CustomtabsJ3( $container->get('Config'), $container->get('Compiler.Builder.Custom.Tabs'), $container->get('Language'), @@ -686,14 +744,52 @@ class Model implements ServiceProviderInterface } /** - * Get the admin views Model + * Get The CustomtabsJ4 Class. + * + * @param Container $container The DI container. + * + * @return CustomtabsJ4 + * @since 3.2.0 + */ + public function getCustomtabsJ4(Container $container): CustomtabsJ4 + { + return new CustomtabsJ4( + $container->get('Config'), + $container->get('Compiler.Builder.Custom.Tabs'), + $container->get('Language'), + $container->get('Placeholder'), + $container->get('Customcode') + ); + } + + /** + * Get The CustomtabsJ5 Class. + * + * @param Container $container The DI container. + * + * @return CustomtabsJ5 + * @since 3.2.0 + */ + public function getCustomtabsJ5(Container $container): CustomtabsJ5 + { + return new CustomtabsJ5( + $container->get('Config'), + $container->get('Compiler.Builder.Custom.Tabs'), + $container->get('Language'), + $container->get('Placeholder'), + $container->get('Customcode') + ); + } + + /** + * Get The Adminviews Class. * * @param Container $container The DI container. * * @return Adminviews * @since 3.2.0 */ - public function getModelAdminviews(Container $container): Adminviews + public function getAdminviews(Container $container): Adminviews { return new Adminviews( $container->get('Config'), @@ -704,14 +800,14 @@ class Model implements ServiceProviderInterface } /** - * Get the SQL tweaking Model + * Get The Sqltweaking Class. * * @param Container $container The DI container. * * @return Sqltweaking * @since 3.2.0 */ - public function getModelSqltweaking(Container $container): Sqltweaking + public function getSqltweaking(Container $container): Sqltweaking { return new Sqltweaking( $container->get('Registry') @@ -719,14 +815,14 @@ class Model implements ServiceProviderInterface } /** - * Get the SQL dump Model + * Get The Sqldump Class. * * @param Container $container The DI container. * * @return Sqldump * @since 3.2.0 */ - public function getModelSqldump(Container $container): Sqldump + public function getSqldump(Container $container): Sqldump { return new Sqldump( $container->get('Registry') @@ -734,20 +830,33 @@ class Model implements ServiceProviderInterface } /** - * Get the whmcs Model + * Get The Whmcs Class. * * @param Container $container The DI container. * * @return Whmcs * @since 3.2.0 */ - public function getModelWhmcs(Container $container): Whmcs + public function getWhmcs(Container $container): Whmcs { return new Whmcs(); } /** - * Get the modified date Model + * Get The Filesfolders Class. + * + * @param Container $container The DI container. + * + * @return Filesfolders + * @since 3.2.0 + */ + public function getFilesfolders(Container $container): Filesfolders + { + return new Filesfolders(); + } + + /** + * Get The Modifieddate Class. * * @param Container $container The DI container. * @@ -760,7 +869,7 @@ class Model implements ServiceProviderInterface } /** - * Get the create date Model + * Get The Createdate Class. * * @param Container $container The DI container. * @@ -773,7 +882,24 @@ class Model implements ServiceProviderInterface } /** - * Get the update server Model + * Get The Router Class. + * + * @param Container $container The DI container. + * + * @return Router + * @since 3.2.0 + */ + public function getRouter(Container $container): Router + { + return new Router( + $container->get('Config'), + $container->get('Customcode.Dispenser'), + $container->get('Compiler.Builder.Router') + ); + } + + /** + * Get The Updateserver Class. * * @param Container $container The DI container. * @@ -783,35 +909,6 @@ class Model implements ServiceProviderInterface public function getUpdateserver(Container $container): Updateserver { return new Updateserver(); - } - - /** - * Get the files folders Model - * - * @param Container $container The DI container. - * - * @return Filesfolders - * @since 3.2.0 - */ - public function getModelFilesfolders(Container $container): Filesfolders - { - return new Filesfolders(); - } - - /** - * Get the Server Model Server Loader class - * - * @param Container $container The DI container. - * - * @return ServerLoad - * @since 3.2.0 - */ - public function getServerLoad(Container $container): ServerLoad - { - return new ServerLoad( - $container->get('Crypt'), - $container->get('Table') - ); } } diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Power.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Power.php index b03acb72a..845ce4041 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Power.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Power.php @@ -178,7 +178,6 @@ class Power implements ServiceProviderInterface $container->get('Power'), $container->get('Compiler.Builder.Content.One'), $container->get('Compiler.Builder.Content.Multi'), - $container->get('Power.Autoloader'), $container->get('Power.Parser'), $container->get('Power.Repo.Readme'), $container->get('Power.Repos.Readme'), diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Utilities.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Utilities.php index 40d4d3625..2f4b56a6d 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Utilities.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Service/Utilities.php @@ -17,6 +17,7 @@ use Joomla\DI\ServiceProviderInterface; use VDM\Joomla\Componentbuilder\Compiler\Config; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder; use VDM\Joomla\Componentbuilder\Compiler\Utilities\File; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\FileInjector; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files; @@ -50,6 +51,9 @@ class Utilities implements ServiceProviderInterface $container->alias(File::class, 'Utilities.File') ->share('Utilities.File', [$this, 'getFile'], true); + $container->alias(FileInjector::class, 'Utilities.FileInjector') + ->share('Utilities.FileInjector', [$this, 'getFileInjector'], true); + $container->alias(Counter::class, 'Utilities.Counter') ->share('Utilities.Counter', [$this, 'getCounter'], true); @@ -106,6 +110,21 @@ class Utilities implements ServiceProviderInterface ); } + /** + * Get The FileInjector Class. + * + * @param Container $container The DI container. + * + * @return FileInjector + * @since 3.2.0 + */ + public function getFileInjector(Container $container): FileInjector + { + return new FileInjector( + $container->get('Power.Injector') + ); + } + /** * Get the Compiler Counter * @@ -203,6 +222,7 @@ class Utilities implements ServiceProviderInterface public function getStructure(Container $container): Structure { return new Structure( + $container->get('Placeholder'), $container->get('Component.Settings'), $container->get('Utilities.Paths'), $container->get('Utilities.Counter'), diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Templatelayout/Data.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Templatelayout/Data.php index f0cca1754..1f15a35b8 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Templatelayout/Data.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Templatelayout/Data.php @@ -160,10 +160,10 @@ class Data { // set the Layout data $lay1 = GetHelper::allBetween( - $content, "JLayoutHelper::render('", "'," + $content, "LayoutHelper::render('", "'," ); $lay2 = GetHelper::allBetween( - $content, 'JLayoutHelper::render("', '",' + $content, 'LayoutHelper::render("', '",' ); if (ArrayHelper::check($lay1) && ArrayHelper::check($lay2)) diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Utilities/FileInjector.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Utilities/FileInjector.php new file mode 100644 index 000000000..47c9af0bf --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Utilities/FileInjector.php @@ -0,0 +1,213 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Compiler\Utilities; + + +use VDM\Joomla\Componentbuilder\Compiler\Power\Injector as Power; +use VDM\Joomla\Utilities\MathHelper; + + +/** + * File Injector + * Thanks to http://stackoverflow.com/a/16813550/1429677 + * + * @since 3.2.0 + */ +final class FileInjector +{ + /** + * The Injector Class. + * + * @var Power + * @since 3.2.0 + */ + protected Power $power; + + /** + * The pattern to get the powers + * + * @var string + * @since 3.2.0 + **/ + protected string $pattern = '/Super_'.'_'.'_[a-zA-Z0-9_]+_'.'_'.'_Power/'; + + /** + * Constructor. + * + * @param Power $power The Injector Class. + * + * @since 3.2.0 + */ + public function __construct(Power $power) + { + $this->power = $power; + } + + /** + * Inserts or replaces data in a file at a specific position. + * + * @param string $file The path of the file to modify. + * @param string $data The data to insert or replace. + * @param int $position The position in the file where the data should be inserted or replaced. + * @param int|null $replace The number of bytes to replace; if null, data will be inserted. + * + * @return void + * @throws \RuntimeException If unable to open or modify the file. + * @throws \InvalidArgumentException If the position is negative. + * @since 3.2.0 + */ + public function add(string $file, string $data, int $position, ?int $replace = null): void + { + if ($position < 0) + { + throw new \InvalidArgumentException('Position cannot be negative.'); + } + + $found_super_powers = preg_match($this->pattern, $data); + $actual_file = $this->openFileWithLock($file); + + try + { + $temp_file = fopen('php://temp', "rw+"); + if ($temp_file === false) + { + throw new \RuntimeException("Unable to open temporary file."); + } + + $this->processFile($actual_file, $temp_file, $data, $position, $replace); + + if ($found_super_powers) + { + $this->injectSuperPowers($actual_file); + } + } + finally + { + flock($actual_file, LOCK_UN); + fclose($actual_file); + if (isset($temp_file)) + { + fclose($temp_file); + } + } + } + + /** + * Opens a file and acquires an exclusive lock on it. + * + * @param string $file The file path to open. + * + * @return resource The file handle. + * @throws \RuntimeException If the file cannot be opened or locked. + * @since 3.2.0 + */ + private function openFileWithLock(string $file) + { + $actual_file = fopen($file, "rw+"); + if ($actual_file === false || !flock($actual_file, LOCK_EX)) + { + throw new \RuntimeException("Unable to open and lock the file: {$file}"); + } + return $actual_file; + } + + /** + * Processes the file for data insertion and copying the remaining data. + * + * @param resource $actual_file The file handle of the actual file. + * @param resource $temp_file The file handle of the temporary file. + * @param string $data The data to be inserted. + * @param int $position The position in the file for the data insertion. + * @param int|null $replace The number of bytes to replace; if null, data will be inserted. + * + * @return void + * @since 3.2.0 + */ + private function processFile($actual_file, $temp_file, string $data, int $position, ?int $replace): void + { + // Make a copy of the file in the temporary stream + stream_copy_to_stream($actual_file, $temp_file); + + // Move to the position where the data should be added + fseek($actual_file, $position); + + // Add the data + fwrite($actual_file, $data); + + $this->truncateIfNeeded($actual_file, $data, $position); + $this->copyRemainingData($actual_file, $temp_file, $position, $replace); + } + + /** + * Truncates the file after data insertion if necessary. + * + * @param resource $actual_file The file handle. + * @param string $data The data that was inserted. + * @param int $position The position where data was inserted. + * + * @return void + * @since 3.2.0 + */ + private function truncateIfNeeded($actual_file, string $data, int $position): void + { + // Truncate the file at the end of the added data if replacing + $data_length = mb_strlen($data, '8bit'); + $remove = MathHelper::bc('add', $position, $data_length); + ftruncate($actual_file, $remove); + } + + /** + * Copies the remaining data from the temporary stream to the actual file. + * + * @param resource $actual_file The file handle of the actual file. + * @param resource $temp_file The file handle of the temporary file. + * @param int $position The position in the file where data insertion finished. + * @param int|null $replace The number of bytes that were replaced; if null, data was inserted. + * + * @return void + * @since 3.2.0 + */ + private function copyRemainingData($actual_file, $temp_file, int $position, ?int $replace): void + { + // check if this was a replacement of data + $position = MathHelper::bc('add', $position, $replace ?: 0); + + // Move to the position of the remaining data in the temporary stream + fseek($temp_file, $position); + + // Copy the remaining data from the temporary stream to the file + stream_copy_to_stream($temp_file, $actual_file); + } + + /** + * Injects super powers into the file content, if found, and updates the file. + * + * @param resource $actual_file The file handle of the actual file. + * + * @return void + * @since 3.2.0 + */ + private function injectSuperPowers($actual_file): void + { + rewind($actual_file); + + $power_data = $this->power->power( + stream_get_contents($actual_file) + ); + + ftruncate($actual_file, 0); + rewind($actual_file); + + fwrite($actual_file, $power_data); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Utilities/Structure.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Utilities/Structure.php index ccef5d633..5cddb26f3 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Utilities/Structure.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Utilities/Structure.php @@ -17,8 +17,8 @@ use Joomla\CMS\Application\CMSApplication; use Joomla\CMS\Language\Text; use Joomla\CMS\Filesystem\File as JoomlaFile; use Joomla\CMS\Filesystem\Folder; -use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler; -use VDM\Joomla\Componentbuilder\Compiler\Component\Settings; +use VDM\Joomla\Componentbuilder\Compiler\Placeholder; +use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\SettingsInterface as Settings; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths; use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter; use VDM\Joomla\Componentbuilder\Compiler\Utilities\File; @@ -35,41 +35,49 @@ use VDM\Joomla\Utilities\StringHelper; class Structure { /** - * Compiler Component Joomla Version Settings + * The Placeholder Class. * - * @var Settings + * @var Placeholder + * @since 3.2.0 + */ + protected Placeholder $placeholder; + + /** + * The SettingsInterface Class. + * + * @var Settings * @since 3.2.0 */ protected Settings $settings; /** - * Compiler Utilities Paths + * The Paths Class. * - * @var Paths + * @var Paths * @since 3.2.0 */ protected Paths $paths; /** - * Compiler Counter + * The Counter Class. * - * @var Counter + * @var Counter * @since 3.2.0 */ protected Counter $counter; /** - * Compiler Utilities File + * The File Class. * - * @var File + * @var File * @since 3.2.0 */ protected File $file; /** - * Compiler Utilities Files + * The Files Class. * - * @var Files + * @var Files * @since 3.2.0 */ protected Files $files; @@ -85,25 +93,25 @@ class Structure /** * Constructor. * - * @param Settings|null $settings The compiler component joomla version settings object. - * @param Paths|null $paths The compiler paths object. - * @param Counter|null $counter The compiler counter object. - * @param File|null $file The compiler file object. - * @param Files|null $files The compiler files object. - * @param CMSApplication|null $app The CMS Application object. + * @param Placeholder $placeholder The Placeholder Class. + * @param Settings $settings The SettingsInterface Class. + * @param Paths $paths The Paths Class. + * @param Counter $counter The Counter Class. + * @param File $file The File Class. + * @param Files $files The Files Class. + * @param CMSApplication|null $app The CMS Application object. * * @since 3.2.0 - * @throws \Exception */ - public function __construct(?Settings $settings = null, ?Paths $paths = null, - ?Counter $counter = null, ?File $file = null, ?Files $files = null, - ?CMSApplication $app = null) + public function __construct(Placeholder $placeholder, Settings $settings, Paths $paths, + Counter $counter, File $file, Files $files, ?CMSApplication $app = null) { - $this->settings = $settings ?: Compiler::_('Component.Settings'); - $this->paths = $paths ?: Compiler::_('Utilities.Paths'); - $this->counter = $counter ?: Compiler::_('Utilities.Counter'); - $this->file = $file ?: Compiler::_('Utilities.File'); - $this->files = $files ?: Compiler::_('Utilities.Files'); + $this->placeholder = $placeholder; + $this->settings = $settings; + $this->paths = $paths; + $this->counter = $counter; + $this->file = $file; + $this->files = $files; $this->app = $app ?: Factory::getApplication(); } @@ -130,6 +138,15 @@ class Structure // search the target foreach ($target as $main => $name) { + // get the key name (either file name or name) + $key = $fileName ?? $name; + + // add to placeholders as Name and name + $this->placeholder->set('Name', StringHelper::safe($name, 'F')); + $this->placeholder->set('name', StringHelper::safe($name)); + $this->placeholder->set('Key', StringHelper::safe($key, 'F')); + $this->placeholder->set('key', StringHelper::safe($key)); + // make sure it is lower case $name = StringHelper::safe($name); @@ -157,6 +174,12 @@ class Structure } } } + + // remove the name from placeholders + $this->placeholder->remove('Name'); + $this->placeholder->remove('name'); + $this->placeholder->remove('Key'); + $this->placeholder->remove('key'); } } @@ -251,6 +274,8 @@ class Structure { $path = $details->path; } + + $path = $this->placeholder->update_($path); // make sure we have component to replace if (strpos((string) $path, 'c0mp0n3nt') !== false) @@ -291,23 +316,27 @@ class Structure if (!empty($fileName)) { $name = $name . '_' . $fileName; + } - return str_replace( + if ($details->rename === 'new') + { + $item = $details->newName; + } + elseif (!empty($fileName)) + { + $item = str_replace( $details->rename, $fileName, $item ); } - elseif ($details->rename === 'new') + else { - return $details->newName; + $item = str_replace( + $details->rename, $name, $item + ); } - - return str_replace( - $details->rename, $name, $item - ); } - return $item; - } - + return $this->placeholder->update_($item); + } } diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Extrusion/Helper/Builder.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Extrusion/Helper/Builder.php new file mode 100644 index 000000000..79a8584be --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Extrusion/Helper/Builder.php @@ -0,0 +1,287 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Extrusion\Helper; + + +use Joomla\CMS\Factory; +use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Componentbuilder\Extrusion\Helper\Mapping; + + +/** + * Builder class + * + * @since 3.2.0 + */ +class Builder extends Mapping +{ + /** + * Some default fields + */ + public $user; + public $today; + public $db; + public array $views = []; + public array $admin_fields = []; + protected array $fields = []; + protected array $title = []; + protected array $description = []; + protected array $alias = []; + protected array $list = []; + + /** + * Field that should not be used in name, alias, disc, and list view + * (TODO) We may need to set this dynamicly + */ + protected array $avoidList = ['not_required']; + + /*** + * Constructor + */ + public function __construct(&$data) + { + // first we run the perent constructor + if (parent::__construct($data)) + { + // always reset the building values if found + $data['buildcomp'] = 0; + $data['buildcompsql'] = ''; + // set some globals + $this->db = Factory::getDbo(); + $this->user = Factory::getUser(); + $this->today = Factory::getDate()->toSql(); + + // no start the building of the views and fields + if ($this->setBuild()) + { + return true; + } + } + return false; + } + + /** + * The building function + * To build the views and fields that are needed + */ + protected function setBuild() + { + foreach ($this->map as $view => $fields) + { + // set this field with all its needed data + foreach ($fields as $field) + { + $this->setField($view, $field); + } + // set this view with all its needed data + $this->setView($view); + } + return true; + } + + /** + * The building function for views + */ + protected function setView(&$name) + { + // set the view object + $object = new \stdClass(); + $object->system_name = StringHelper::check($name, 'W') . ' (dynamic build)'; + $object->name_single = $name; + $object->name_list = $name. 's'; + $object->short_description = $name. ' view (dynamic build)'; + $object->type = 1; + $object->description = $name. ' view (dynamic build)'; + $object->add_fadein = 1; + $object->add_sql = (isset($this->addSql[$name])) ? $this->addSql[$name]: 0; + $object->source = (isset($this->source[$name])) ? $this->source[$name]: 0; + $object->sql = (isset($this->sql[$name])) ? base64_encode($this->sql[$name]): ''; + $object->addpermissions = '{"action":["view.edit","view.edit.own","view.edit.state","view.create","view.delete","view.access"],"implementation":["3","3","3","3","3","3"]}'; + $object->created = $this->today; + $object->created_by = $this->user->id; + $object->published = 1; + // add to data base + if ($this->db->insertObject('#__componentbuilder_admin_view', $object)) + { + // make sure the access of asset is set + $id = $this->db->insertid(); + ComponentbuilderHelper::setAsset($id, 'admin_view'); + // load the views + $this->views[] = $id; + // load the admin view fields + return $this->addFields($name, $id); + } + return false; + } + + /** + * Add the fields to the view + */ + protected function addFields(&$view, &$view_id) + { + if (isset($this->fields[$view])) + { + // set some defaults + $addField = array (); + $fixLink = (isset($this->title[$view])) ? 0 : 1; + // build the field data... hmmm + foreach ($this->fields[$view] as $nr => $id) + { + $alignment = 1; + if ($nr % 2 == 0) + { + $alignment = 2; + } + // some defaults + $isTitle = (isset($this->title[$view]) && $this->title[$view] == $id) ? 1 : 0; + $isAlias = (isset($this->alias[$view]) && $this->alias[$view] == $id) ? 1 : 0; + $isList = ($key = array_search($id, $this->list[$view])) ? 1 : 0; + $isLink = ($isTitle) ? 1 : (($isList && $fixLink) ? 1 : 0); + if ($isLink) + { + $fixLink = 0; + } + // load the field values + $addField['addfields'.$nr]['field'] = $id; + $addField['addfields'.$nr]['list'] = $isList; + $addField['addfields'.$nr]['order_list'] = ($key) ? $key : 0; + $addField['addfields'.$nr]['title'] = $isTitle; + $addField['addfields'.$nr]['alias'] = $isAlias; + $addField['addfields'.$nr]['sort'] = $isList; + $addField['addfields'.$nr]['search'] = $isList; + $addField['addfields'.$nr]['filter'] = $isList; + $addField['addfields'.$nr]['link'] = $isLink; + $addField['addfields'.$nr]['tab'] = 1; + $addField['addfields'.$nr]['alignment'] = ($isTitle || $isAlias) ? 4 : $alignment; + $addField['addfields'.$nr]['order_edit'] = $nr; + $addField['addfields'.$nr]['permission'] = 0; + } + + // set the field object + $object = new \stdClass(); + $object->admin_view = $view_id; + $object->addfields = json_encode($addField, JSON_FORCE_OBJECT); + $object->created = $this->today; + $object->created_by = $this->user->id; + $object->published = 1; + // add to data base + return $this->db->insertObject('#__componentbuilder_admin_fields', $object); + } + return false; + } + + /** + * The building function for fields + */ + protected function setField(&$view, &$field) + { + if ($fieldType = CFactory::_('Field.Type.Name')->get($field['fieldType'])) + { + // set the field object + $object = new \stdClass(); + $object->name = $field['label'] . ' (dynamic build)'; + $object->fieldtype = $fieldType; + $object->datatype = $field['dataType']; + $object->indexes = $field['key']; + $object->null_switch = $field['null']; + $object->datalenght = $field['size']; + $object->datalenght_other = $field['sizeOther']; + $object->datadefault = $field['default']; + $object->datadefault_other = $field['defaultOther']; + $object->created = $this->today; + $object->created_by = $this->user->id; + $object->published = 1; + $object->store = 0; + $object->xml = $this->setFieldXML($field, $fieldType); + // add to data base + if ($this->db->insertObject('#__componentbuilder_field', $object)) + { + // make sure the access of asset is set + $id = $this->db->insertid(); + ComponentbuilderHelper::setAsset($id, 'field'); + // check if any field for this field was already set, if not set array + if (!isset($this->fields[$view])) + { + $this->fields[$view] = []; + } + // load the field + $this->fields[$view][] = $id; + + if (!isset($this->list[$view])) + { + $this->list[$view] = []; + } + // insure that some fields are avoided + if (!in_array($field['name'], $this->avoidList)) + { + // set the name/title field if found + if (!isset($this->title[$view]) && (stripos($field['name'], 'name') !== false || stripos($field['name'], 'title') !== false)) + { + $this->title[$view] = $id; + $this->list[$view][] = $id; + } + // set the alias field if found + elseif (!isset($this->alias[$id]) && stripos($field['name'], 'alias') !== false) + { + $this->alias[$view] = $id; + } + // set the alias field if found + elseif (!isset($this->description[$id]) && stripos($field['name'], 'desc') !== false) + { + $this->description[$view] = $id; + $this->list[$view][] = $id; + } + elseif ('Text' == $field['fieldType'] && count($this->list[$view]) < 5) + { + $this->list[$view][] = $id; + } + } + return true; + } + } + return false; + } + + /** + * get the field type id from system + */ + protected function getFieldType($fieldName) + { + // load the field settings + return GetHelper::var('fieldtype', $fieldName, 'name', 'id'); + } + + /** + * The building function for field xml + */ + protected function setFieldXML(&$field, $fieldId) + { + // load the field settings + $settings = []; + $settings['name'] = $field['name']; + $settings['description'] = 'The '.strtolower($field['label']) . ' is set here.'; + $settings['message'] = "Error! Please add some ".strtolower($field['label'])." here."; + $settings['label'] = $field['label']; + $settings['default'] = ($field['default'] == 'Other') ? $field['defaultOther'] : $field['default']; + $settings['hint'] = $field['label'] .' Here!'; + // okay set the xml field values + if ($fieldOptions = ComponentbuilderHelper::getFieldTypeProperties($fieldId, 'id', $settings)) + { + return json_encode($fieldOptions['values']); + } + return ''; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Extrusion/Helper/Extrusion.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Extrusion/Helper/Extrusion.php new file mode 100644 index 000000000..2f2a7e55c --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Extrusion/Helper/Extrusion.php @@ -0,0 +1,103 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Extrusion\Helper; + + +use Joomla\CMS\Language\Text; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Componentbuilder\Extrusion\Helper\Builder; + + +/** + * Extrusion class + * + * @since 3.2.0 + */ +class Extrusion extends Builder +{ + /*** + * Constructor + */ + public function __construct(&$data) + { + // first we run the perent constructor + if (parent::__construct($data)) + { + // link the view data to the component + if ($this->setAdminViews($data['id'])) + { + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_ALL_THE_FIELDS_AND_VIEWS_FROM_YOUR_SQL_DUMP_HAS_BEEN_CREATED_AND_LINKED_TO_THIS_COMPONENT'), + 'Success' + ); + return true; + } + } + return false; + } + + /** + * link the build views to the component + */ + protected function setAdminViews(&$component_id) + { + // check if views were set + if (ArrayHelper::check($this->views)) + { + $count = 0; + if (ArrayHelper::check($this->addadmin_views)) + { + $count = (int) count((array)$this->addadmin_views) + 3; + } + // set the admin view data linking + foreach ($this->views as $nr => $id) + { + $pointer = $count + $nr; + $this->addadmin_views['addadmin_views'.$pointer]['adminview'] = $id; + $this->addadmin_views['addadmin_views'.$pointer]['icomoon'] = 'joomla'; + $this->addadmin_views['addadmin_views'.$pointer]['mainmenu'] = 1; + $this->addadmin_views['addadmin_views'.$pointer]['dashboard_add'] = 1; + $this->addadmin_views['addadmin_views'.$pointer]['dashboard_list'] = 1; + $this->addadmin_views['addadmin_views'.$pointer]['submenu'] = 1; + $this->addadmin_views['addadmin_views'.$pointer]['checkin'] = 1; + $this->addadmin_views['addadmin_views'.$pointer]['history'] = 1; + $this->addadmin_views['addadmin_views'.$pointer]['metadata'] = 1; + $this->addadmin_views['addadmin_views'.$pointer]['access'] = 1; + $this->addadmin_views['addadmin_views'.$pointer]['port'] = 1; + $this->addadmin_views['addadmin_views'.$pointer]['edit_create_site_view'] = 0; + $this->addadmin_views['addadmin_views'.$pointer]['order'] = $pointer + 1; + } + } + if (isset($this->addadmin_views) && ArrayHelper::check($this->addadmin_views)) + { + // set the field object + $object = new \stdClass(); + $object->joomla_component = $component_id; + $object->addadmin_views = json_encode($this->addadmin_views, JSON_FORCE_OBJECT); + $object->created = $this->today; + $object->created_by = $this->user->id; + $object->published = 1; + // check if it is already set + if ($item_id = GetHelper::var('component_admin_views', $component_id, 'joomla_component', 'id')) + { + // set ID + $object->id = (int) $item_id; + return $this->db->updateObject('#__componentbuilder_component_admin_views', $object, 'id'); + } + // add to data base + return $this->db->insertObject('#__componentbuilder_component_admin_views', $object); + } + return false; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Extrusion/Helper/Mapping.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Extrusion/Helper/Mapping.php new file mode 100644 index 000000000..a40717fb7 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Extrusion/Helper/Mapping.php @@ -0,0 +1,422 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Extrusion\Helper; + + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\Database\DatabaseDriver; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Utilities\ArrayHelper; + + +/** + * Mapping class + * + * @since 3.2.0 + */ +class Mapping +{ + /** + * Some default fields + */ + protected $buildcompsql; + public $id; + public $name_code; + public array $addadmin_views; + public array $addSql = []; + public array $source = []; + public array $sql = []; + + /** + * The map of the needed fields and views + */ + public $map; + + /** + * The app to load messages mostly + */ + public $app; + + /** + * The needed set of keys needed to set + */ + protected array $setting = ['id' => 'default', 'buildcompsql' => 'base64', 'name_code' => 'safeString']; + + /** + * The needed set of keys needed to set + */ + protected array $notRequiered = [ + 'id', 'asset_id', 'published', + 'created_by', 'modified_by', 'created', 'modified', 'checked_out','checked_out_time', + 'version', 'hits', 'access', 'ordering', + 'metakey', 'metadesc', 'metadata', 'params' + ]; + + /** + * The datatypes and it linked field types (basic) + * (TODO) We may need to set this dynamicly + */ + protected array $dataTypes = [ + 'VARCHAR' => 'Text', 'CHAR' => 'Text', + 'MEDIUMTEXT' => 'Textarea', 'LONGTEXT' => 'Textarea', + 'TEXT' => 'Textarea', 'DATETIME' => 'Calendar', + 'DATE' => 'Text', 'TIME' => 'Text', 'TINYINT' => 'Text', + 'BIGINT' => 'Text', 'INT' => 'Text', 'FLOAT' => 'Text', + 'DECIMAL' => 'Text', 'DOUBLE' => 'Text' + ]; + + /** + * The datasize identifiers + */ + protected array $dataSize = [ + 'CHAR', 'VARCHAR', 'INT', 'TINYINT', + 'BIGINT', 'FLOAT', 'DECIMAL', 'DOUBLE' + ]; + + /** + * The default identifiers + */ + protected $defaults = [ + 0, 1, "CURRENT_TIMESTAMP", "DATETIME" + ]; // Other + + /** + * The sizes identifiers + */ + protected $sizes = [ + "1", "7", "10", "11", "50", "64", "100", "255", "1024", "2048" + ]; // Other + + /** + * Constructor + */ + public function __construct($data = false) + { + // set the app to insure messages can be set + $this->app = Factory::getApplication(); + + // check that we have data + if (ArrayHelper::check($data)) + { + // make sure we have an id + if (isset($data['id']) && $data['id'] > 0) + { + if (isset($data['buildcomp']) && 1 == $data['buildcomp'] && isset($data['buildcompsql'])) + { + foreach ($data as $key => $value) + { + if (isset($this->setting[$key])) + { + switch($this->setting[$key]) + { + case 'base64': + // set needed value + $this->$key = base64_decode((string) $value); + break; + case 'json': + // set needed value + $this->$key = json_decode((string) $value, true); + break; + case 'safeString': + // set needed value + $this->$key = StringHelper::check($value); + break; + default : + $this->$key = $value; + break; + } + } + } + // get linked admin views + $addadmin_views = GetHelper::var('component_admin_views', $data['id'], 'joomla_component', 'addadmin_views'); + if (JsonHelper::check($addadmin_views)) + { + $this->addadmin_views = json_decode((string)$addadmin_views, true); + } + // set the map of the views needed + if ($this->setMap()) + { + return true; + } + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_NO_CREATE_TABLE_WERE_FOUND_PLEASE_CHECK_YOUR_SQL'), + 'Error' + ); + return false; + } + return false; // not set so just return without any error + } + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_PLEASE_TRY_AGAIN_THIS_ERROR_USUALY_HAPPENS_IF_IT_IS_A_NEW_COMPONENT_BEACUES_WE_NEED_A_COMPONENT_ID_TO_DO_THIS_BUILD_WITH_YOUR_SQL_DUMP'), + 'Error' + ); + return false; + } + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_COULD_NOT_FIND_THE_DATA_NEEDED_TO_CONTINUE'), + 'Error' + ); + return false; + } + + /** + * The mapping function + * To Map the views and fields that are needed + */ + protected function setMap() + { + // start parsing the sql dump data + $queries = DatabaseDriver::splitSql($this->buildcompsql); + if (ArrayHelper::check($queries)) + { + foreach ($queries as $query) + { + // only use create table queries + if (strpos($query, 'CREATE TABLE IF NOT EXISTS') !== false || + strpos($query, 'CREATE TABLE') !== false) + { + if ($tableName = $this->getTableName($query)) + { + // now get the fields/columns of this view/table + if ($fields = $this->getFields($query)) + { + // make sure it is all lower case from here on + $tableName = strtolower($tableName); + $this->map[$tableName] = $fields; + } + } + else + { + continue; + } + } + // get the insert data if set + if (strpos($query, 'INSERT INTO `') !== false) + { + if ($tableName = $this->getTableName($query)) + { + $this->addSql[$tableName] = 1; + $this->source[$tableName] = 2; + $this->sql[$tableName] = $query; + } + } + } + // check if the mapping was done + if (ArrayHelper::check($this->map)) + { + return true; + } + } + return false; + } + + /** + * Get the table name + */ + protected function getTableName(&$query) + { + if (strpos($query, '`#__') !== false) + { + // get table name + $tableName = GetHelper::between($query, '`#__', "`"); + } + elseif (strpos($query, "'#__") !== false) + { + // get table name + $tableName = GetHelper::between($query, "'#__", "'"); + } + // if it still was not found + if (!isset($tableName) || !StringHelper::check($tableName)) + { + // skip this query + return false; + } + // clean the table name (so only view name remain) + if (strpos($tableName, $this->name_code) !== false) + { + $tableName = trim(str_replace($this->name_code, '', $tableName), '_'); + } + // if found + if (StringHelper::check($tableName)) + { + return $tableName; + } + // skip this query + return false; + } + + /** + * Get the field details + */ + protected function getFields(&$query) + { + $rows = array_map('trim', explode(PHP_EOL, $query)); + $fields = array(); + foreach ($rows as $row) + { + // make sure we have a lower case string + $row = strtoupper($row); + $field = array(); + $name = ''; + if (0 === strpos($row, '`')) + { + // get field name + $name = GetHelper::between($row, '`', '`'); + } + if (0 === strpos($row, "'")) + { + // get field name + $name = GetHelper::between($row, "'", "'"); + } + // check if the name was found + if (StringHelper::check($name)) + { + // insure we have the name in lower case from here on + $name = strtolower($name); + // only continue if field is required + if (in_array($name, $this->notRequiered)) + { + continue; + } + // check if the field type is found + if ($fieldType = $this->getType($row, $field, $name)) + { + $field['row'] = $row; + $field['name'] = $name; + $field['label'] = StringHelper::check($name, 'W'); + $field['fieldType'] = $fieldType; + $field['size'] = $this->getSize($row, $field); + $field['sizeOther'] = ''; + if (!in_array($field['size'], $this->sizes)) + { + if (StringHelper::check($field['size'])) + { + $field['sizeOther'] = $field['size']; + $field['size'] = 'Other'; + } + } + $field['default'] = $this->getDefault($row); + $field['defaultOther'] = ''; + if (!in_array($field['default'], $this->defaults)) + { + if (StringHelper::check($field['default'])) + { + $field['defaultOther'] = $field['default']; + $field['default'] = 'Other'; + } + } + $field['null'] = $this->getNullValue($row, $field); + // check if field is a key + $field['key'] = $this->getKeyStatus($rows, $name); + // load to fields + $fields[] = $field; + } + } + } + if (ArrayHelper::check($fields)) + { + return $fields; + } + return false; + } + + /** + * Get the field types + */ + protected function getType($row, &$field, &$name) + { + // first remove field name + $row = str_replace($name, '', $row); + // get the data type first + foreach ($this->dataTypes as $type => $fieldType) + { + if (strpos($row, $type) !== false) + { + $field['dataType'] = $type; + return $fieldType; + } + } + return false; + } + + /** + * Get the field size + */ + protected function getSize(&$row, $field) + { + if (in_array($field['dataType'], $this->dataSize)) + { + return GetHelper::between($row, $field['dataType'].'(', ')'); + } + return ''; + } + + /** + * Get the field default + */ + protected function getDefault(&$row) + { + // get default value + if (strpos($row, 'DEFAULT "') !== false) // to sure it this is correct... + { + return GetHelper::between($row, 'DEFAULT "', '"'); + } + // get default value + if (strpos($row, "DEFAULT '") !== false) + { + return GetHelper::between($row, "DEFAULT '", "'"); + } + return ''; + } + + /** + * Get the field Null Value + */ + protected function getNullValue(&$row, &$field) + { + // get the result of null + if (strpos($row, 'NOT NULL') !== false) + { + return 'NOT NULL'; + } + if (strpos($row, 'DEFAULT NULL') !== false) + { + $field['default'] = 'NULL'; + return ''; + } + return 'NULL'; + } + + /** + * Get the field key status + */ + protected function getKeyStatus(&$rows, &$name) + { + // get the data type first + foreach ($rows as $row) + { + if (strpos($row, 'UNIQUE KEY ') !== false && stripos($row, $name) !== false) + { + return 1; + } + if ((strpos($row, 'PRIMARY KEY ') !== false && stripos($row, $name) !== false) || (strpos($row, 'KEY ') !== false && stripos($row, $name) !== false)) + { + return 2; + } + } + return 0; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Extrusion/Helper/index.html b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Extrusion/Helper/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Extrusion/Helper/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Power/Database/Load.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Power/Database/Load.php index 42f5632d8..778fdf1f2 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Power/Database/Load.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Power/Database/Load.php @@ -73,7 +73,7 @@ final class Load { return $this->model->value( $this->load->value( - ["a.${field}" => $field], + ["a.{$field}" => $field], ['a' => 'power'], $this->prefix($keys) ), diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Search/Database/Insert.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Search/Database/Insert.php index afce63c7c..89106bf0a 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Search/Database/Insert.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Search/Database/Insert.php @@ -55,10 +55,9 @@ class Insert implements InsertInterface /** * Database object to query local DB * - * @var \JDatabaseDriver * @since 3.2.0 **/ - protected \JDatabaseDriver $db; + protected $db; /** * Constructor @@ -66,17 +65,16 @@ class Insert implements InsertInterface * @param Config|null $config The search config object. * @param Table|null $table The search table object. * @param Model|null $model The search get model object. - * @param \JDatabaseDriver|null $db The database object. * * @since 3.2.0 */ public function __construct(?Config $config = null, ?Table $table = null, - ?Model $model = null, ?\JDatabaseDriver $db = null) + ?Model $model = null) { $this->config = $config ?: Factory::_('Config'); $this->table = $table ?: Factory::_('Table'); $this->model = $model ?: Factory::_('Insert.Model'); - $this->db = $db ?: JoomlaFactory::getDbo(); + $this->db = JoomlaFactory::getDbo(); } /** diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Search/Model/Load.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Search/Model/Load.php index 07dd04bd4..a1149a26e 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Search/Model/Load.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Search/Model/Load.php @@ -119,13 +119,35 @@ class Load extends Model implements ModelInterface */ protected function validateAfter(&$value, ?string $field = null, ?string $table = null): bool { + // Start note to self + // Yes we don't search in the field->xml (field) PHP because the xml is messy + // first of all we need to change that storage method :((( seriously + // and the actual PHP is stored in the xml as base64 with a [__.o0=base64=Oo.__] key in front of it + // if I can go back and drag you around by your ear... I will, but okay you did not know better. + // Listen you have tried to fix this a few times already (I lost count) and by the time you realize how it works + // two hours have been wasted, and you usually only then realize why it's not fixed in the first place... o boy... just walk now! + // since unless you have three days don't even look further, this is a huge issue/mess + // and while I agree it needs fixing, it will not take a few hours... but days + // End note to self + // check values if (StringHelper::check($value) || ArrayHelper::check($value, true)) { return true; } + // remove empty values return false; + + // Start another note to self + // If you're still here + // the problem is not opening the PHP in the xml, + // it is storing it with the updated changes... if any are made via the search-update methods + // so the only way to fix this is to change the whole way the xml values in the field table is stored. + // Yes, that is right... all the way back to the field view... and then to update all places you open that xml values + // and get the values out of the xml string and use them, and if you've forgotten, that is nearly everywhere, + // and so let the refactoring of the foundation begin... there I saved you another 3 hours. + // End another note to self } /** diff --git a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Table.php b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Table.php index 0210aa25a..23626f62e 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Table.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Table.php @@ -67,6 +67,51 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Details', ], + 'buildcompsql' => [ + 'name' => 'buildcompsql', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BUILDCOMPSQL_LABEL', + 'type' => 'textarea', + 'title' => false, + 'list' => 'joomla_components', + 'store' => 'base64', + 'tab_name' => 'Dynamic Build (beta)', + ], + 'translation_tool' => [ + 'name' => 'translation_tool', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_TRANSLATION_TOOL_LABEL', + 'type' => 'list', + 'title' => false, + 'list' => 'joomla_components', + 'store' => NULL, + 'tab_name' => 'Dynamic Integration', + ], + 'add_sales_server' => [ + 'name' => 'add_sales_server', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_SALES_SERVER_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'joomla_components', + 'store' => NULL, + 'tab_name' => 'Dynamic Integration', + ], + 'php_method_uninstall' => [ + 'name' => 'php_method_uninstall', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_METHOD_UNINSTALL_LABEL', + 'type' => 'editor', + 'title' => false, + 'list' => 'joomla_components', + 'store' => 'base64', + 'tab_name' => 'Dash & Install', + ], + 'php_preflight_install' => [ + 'name' => 'php_preflight_install', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_PREFLIGHT_INSTALL_LABEL', + 'type' => 'editor', + 'title' => false, + 'list' => 'joomla_components', + 'store' => 'base64', + 'tab_name' => 'Dash & Install', + ], 'css_admin' => [ 'name' => 'css_admin', 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CSS_ADMIN_LABEL', @@ -76,14 +121,41 @@ class Table extends BaseTable implements Tableinterface 'store' => 'base64', 'tab_name' => 'Libs & Helpers', ], - 'php_admin_event' => [ - 'name' => 'php_admin_event', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_ADMIN_EVENT_LABEL', - 'type' => 'editor', + 'mvc_versiondate' => [ + 'name' => 'mvc_versiondate', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_MVC_VERSIONDATE_LABEL', + 'type' => 'list', 'title' => false, 'list' => 'joomla_components', - 'store' => 'base64', - 'tab_name' => 'Libs & Helpers', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'remove_line_breaks' => [ + 'name' => 'remove_line_breaks', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_REMOVE_LINE_BREAKS_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'joomla_components', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'add_placeholders' => [ + 'name' => 'add_placeholders', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PLACEHOLDERS_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'joomla_components', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'debug_linenr' => [ + 'name' => 'debug_linenr', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_DEBUG_LINENR_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'joomla_components', + 'store' => NULL, + 'tab_name' => 'Details', ], 'php_site_event' => [ 'name' => 'php_site_event', @@ -94,18 +166,18 @@ class Table extends BaseTable implements Tableinterface 'store' => 'base64', 'tab_name' => 'Libs & Helpers', ], - 'crowdin_username' => [ - 'name' => 'crowdin_username', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CROWDIN_USERNAME_LABEL', - 'type' => 'text', + 'description' => [ + 'name' => 'description', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_DESCRIPTION_LABEL', + 'type' => 'textarea', 'title' => false, 'list' => 'joomla_components', - 'store' => 'basic_encryption', - 'tab_name' => 'Dynamic Integration', + 'store' => NULL, + 'tab_name' => 'Details', ], - 'component_version' => [ - 'name' => 'component_version', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_COMPONENT_VERSION_LABEL', + 'author' => [ + 'name' => 'author', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_AUTHOR_LABEL', 'type' => 'text', 'title' => false, 'list' => 'joomla_components', @@ -121,19 +193,10 @@ class Table extends BaseTable implements Tableinterface 'store' => 'base64', 'tab_name' => 'Dash & Install', ], - 'remove_line_breaks' => [ - 'name' => 'remove_line_breaks', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_REMOVE_LINE_BREAKS_LABEL', - 'type' => 'radio', - 'title' => false, - 'list' => 'joomla_components', - 'store' => NULL, - 'tab_name' => 'Details', - ], - 'description' => [ - 'name' => 'description', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_DESCRIPTION_LABEL', - 'type' => 'textarea', + 'email' => [ + 'name' => 'email', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EMAIL_LABEL', + 'type' => 'text', 'title' => false, 'list' => 'joomla_components', 'store' => NULL, @@ -148,96 +211,6 @@ class Table extends BaseTable implements Tableinterface 'store' => 'base64', 'tab_name' => 'MySQL', ], - 'debug_linenr' => [ - 'name' => 'debug_linenr', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_DEBUG_LINENR_LABEL', - 'type' => 'radio', - 'title' => false, - 'list' => 'joomla_components', - 'store' => NULL, - 'tab_name' => 'Details', - ], - 'mvc_versiondate' => [ - 'name' => 'mvc_versiondate', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_MVC_VERSIONDATE_LABEL', - 'type' => 'list', - 'title' => false, - 'list' => 'joomla_components', - 'store' => NULL, - 'tab_name' => 'Details', - ], - 'php_preflight_install' => [ - 'name' => 'php_preflight_install', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_PREFLIGHT_INSTALL_LABEL', - 'type' => 'editor', - 'title' => false, - 'list' => 'joomla_components', - 'store' => 'base64', - 'tab_name' => 'Dash & Install', - ], - 'backup_folder_path' => [ - 'name' => 'backup_folder_path', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BACKUP_FOLDER_PATH_LABEL', - 'type' => 'text', - 'title' => false, - 'list' => 'joomla_components', - 'store' => NULL, - 'tab_name' => 'Dynamic Integration', - ], - 'php_method_uninstall' => [ - 'name' => 'php_method_uninstall', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_METHOD_UNINSTALL_LABEL', - 'type' => 'editor', - 'title' => false, - 'list' => 'joomla_components', - 'store' => 'base64', - 'tab_name' => 'Dash & Install', - ], - 'add_placeholders' => [ - 'name' => 'add_placeholders', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PLACEHOLDERS_LABEL', - 'type' => 'radio', - 'title' => false, - 'list' => 'joomla_components', - 'store' => NULL, - 'tab_name' => 'Details', - ], - 'author' => [ - 'name' => 'author', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_AUTHOR_LABEL', - 'type' => 'text', - 'title' => false, - 'list' => 'joomla_components', - 'store' => NULL, - 'tab_name' => 'Details', - ], - 'add_sales_server' => [ - 'name' => 'add_sales_server', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_SALES_SERVER_LABEL', - 'type' => 'radio', - 'title' => false, - 'list' => 'joomla_components', - 'store' => NULL, - 'tab_name' => 'Dynamic Integration', - ], - 'email' => [ - 'name' => 'email', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EMAIL_LABEL', - 'type' => 'text', - 'title' => false, - 'list' => 'joomla_components', - 'store' => NULL, - 'tab_name' => 'Details', - ], - 'translation_tool' => [ - 'name' => 'translation_tool', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_TRANSLATION_TOOL_LABEL', - 'type' => 'list', - 'title' => false, - 'list' => 'joomla_components', - 'store' => NULL, - 'tab_name' => 'Dynamic Integration', - ], 'website' => [ 'name' => 'website', 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_WEBSITE_LABEL', @@ -247,15 +220,6 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Details', ], - 'buildcompsql' => [ - 'name' => 'buildcompsql', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BUILDCOMPSQL_LABEL', - 'type' => 'textarea', - 'title' => false, - 'list' => 'joomla_components', - 'store' => 'base64', - 'tab_name' => 'Dynamic Build (beta)', - ], 'add_license' => [ 'name' => 'add_license', 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_LICENSE_LABEL', @@ -265,9 +229,36 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Details', ], - 'php_helper_admin' => [ - 'name' => 'php_helper_admin', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_HELPER_ADMIN_LABEL', + 'backup_folder_path' => [ + 'name' => 'backup_folder_path', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BACKUP_FOLDER_PATH_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'joomla_components', + 'store' => NULL, + 'tab_name' => 'Dynamic Integration', + ], + 'php_helper_both' => [ + 'name' => 'php_helper_both', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_HELPER_BOTH_LABEL', + 'type' => 'editor', + 'title' => false, + 'list' => 'joomla_components', + 'store' => 'base64', + 'tab_name' => 'Libs & Helpers', + ], + 'crowdin_username' => [ + 'name' => 'crowdin_username', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CROWDIN_USERNAME_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'joomla_components', + 'store' => 'basic_encryption', + 'tab_name' => 'Dynamic Integration', + ], + 'php_admin_event' => [ + 'name' => 'php_admin_event', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_ADMIN_EVENT_LABEL', 'type' => 'editor', 'title' => false, 'list' => 'joomla_components', @@ -283,18 +274,27 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Details', ], - 'php_helper_site' => [ - 'name' => 'php_helper_site', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_HELPER_SITE_LABEL', + 'component_version' => [ + 'name' => 'component_version', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_COMPONENT_VERSION_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'joomla_components', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'php_helper_admin' => [ + 'name' => 'php_helper_admin', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_HELPER_ADMIN_LABEL', 'type' => 'editor', 'title' => false, 'list' => 'joomla_components', 'store' => 'base64', 'tab_name' => 'Libs & Helpers', ], - 'javascript' => [ - 'name' => 'javascript', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_JAVASCRIPT_LABEL', + 'php_helper_site' => [ + 'name' => 'php_helper_site', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_HELPER_SITE_LABEL', 'type' => 'editor', 'title' => false, 'list' => 'joomla_components', @@ -310,9 +310,9 @@ class Table extends BaseTable implements Tableinterface 'store' => 'basic_encryption', 'tab_name' => 'Details', ], - 'css_site' => [ - 'name' => 'css_site', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CSS_SITE_LABEL', + 'javascript' => [ + 'name' => 'javascript', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_JAVASCRIPT_LABEL', 'type' => 'editor', 'title' => false, 'list' => 'joomla_components', @@ -328,6 +328,15 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Details', ], + 'css_site' => [ + 'name' => 'css_site', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CSS_SITE_LABEL', + 'type' => 'editor', + 'title' => false, + 'list' => 'joomla_components', + 'store' => 'base64', + 'tab_name' => 'Libs & Helpers', + ], 'whmcs_buy_link' => [ 'name' => 'whmcs_buy_link', 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_WHMCS_BUY_LINK_LABEL', @@ -337,15 +346,6 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Details', ], - 'php_preflight_update' => [ - 'name' => 'php_preflight_update', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_PREFLIGHT_UPDATE_LABEL', - 'type' => 'editor', - 'title' => false, - 'list' => 'joomla_components', - 'store' => 'base64', - 'tab_name' => 'Dash & Install', - ], 'license' => [ 'name' => 'license', 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_LICENSE_LABEL', @@ -355,9 +355,9 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Details', ], - 'php_postflight_update' => [ - 'name' => 'php_postflight_update', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_POSTFLIGHT_UPDATE_LABEL', + 'php_preflight_update' => [ + 'name' => 'php_preflight_update', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_PREFLIGHT_UPDATE_LABEL', 'type' => 'editor', 'title' => false, 'list' => 'joomla_components', @@ -373,6 +373,24 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Details', ], + 'php_postflight_update' => [ + 'name' => 'php_postflight_update', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_POSTFLIGHT_UPDATE_LABEL', + 'type' => 'editor', + 'title' => false, + 'list' => 'joomla_components', + 'store' => 'base64', + 'tab_name' => 'Dash & Install', + ], + 'image' => [ + 'name' => 'image', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_IMAGE_LABEL', + 'type' => 'media', + 'title' => false, + 'list' => 'joomla_components', + 'store' => NULL, + 'tab_name' => 'Details', + ], 'sql' => [ 'name' => 'sql', 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_SQL_LABEL', @@ -382,10 +400,10 @@ class Table extends BaseTable implements Tableinterface 'store' => 'base64', 'tab_name' => 'MySQL', ], - 'image' => [ - 'name' => 'image', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_IMAGE_LABEL', - 'type' => 'media', + 'copyright' => [ + 'name' => 'copyright', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_COPYRIGHT_LABEL', + 'type' => 'textarea', 'title' => false, 'list' => 'joomla_components', 'store' => NULL, @@ -400,10 +418,10 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Readme', ], - 'copyright' => [ - 'name' => 'copyright', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_COPYRIGHT_LABEL', - 'type' => 'textarea', + 'preferred_joomla_version' => [ + 'name' => 'preferred_joomla_version', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PREFERRED_JOOMLA_VERSION_LABEL', + 'type' => 'number', 'title' => false, 'list' => 'joomla_components', 'store' => NULL, @@ -454,6 +472,15 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'publishing', ], + 'add_php_helper_both' => [ + 'name' => 'add_php_helper_both', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_HELPER_BOTH_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'joomla_components', + 'store' => NULL, + 'tab_name' => 'Libs & Helpers', + ], 'add_php_helper_admin' => [ 'name' => 'add_php_helper_admin', 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_HELPER_ADMIN_LABEL', @@ -490,6 +517,15 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Libs & Helpers', ], + 'add_namespace_prefix' => [ + 'name' => 'add_namespace_prefix', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_NAMESPACE_PREFIX_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'joomla_components', + 'store' => NULL, + 'tab_name' => 'Settings', + ], 'add_javascript' => [ 'name' => 'add_javascript', 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_JAVASCRIPT_LABEL', @@ -499,6 +535,33 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Libs & Helpers', ], + 'namespace_prefix' => [ + 'name' => 'namespace_prefix', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NAMESPACE_PREFIX_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'joomla_components', + 'store' => NULL, + 'tab_name' => 'Settings', + ], + 'add_css_admin' => [ + 'name' => 'add_css_admin', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_CSS_ADMIN_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'joomla_components', + 'store' => NULL, + 'tab_name' => 'Libs & Helpers', + ], + 'add_css_site' => [ + 'name' => 'add_css_site', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_CSS_SITE_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'joomla_components', + 'store' => NULL, + 'tab_name' => 'Libs & Helpers', + ], 'add_menu_prefix' => [ 'name' => 'add_menu_prefix', 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_MENU_PREFIX_LABEL', @@ -508,14 +571,14 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Settings', ], - 'add_css_admin' => [ - 'name' => 'add_css_admin', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_CSS_ADMIN_LABEL', + 'dashboard_type' => [ + 'name' => 'dashboard_type', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_DASHBOARD_TYPE_LABEL', 'type' => 'radio', 'title' => false, 'list' => 'joomla_components', 'store' => NULL, - 'tab_name' => 'Libs & Helpers', + 'tab_name' => 'Dash & Install', ], 'menu_prefix' => [ 'name' => 'menu_prefix', @@ -526,24 +589,6 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Settings', ], - 'add_css_site' => [ - 'name' => 'add_css_site', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_CSS_SITE_LABEL', - 'type' => 'radio', - 'title' => false, - 'list' => 'joomla_components', - 'store' => NULL, - 'tab_name' => 'Libs & Helpers', - ], - 'dashboard_type' => [ - 'name' => 'dashboard_type', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_DASHBOARD_TYPE_LABEL', - 'type' => 'radio', - 'title' => false, - 'list' => 'joomla_components', - 'store' => NULL, - 'tab_name' => 'Dash & Install', - ], 'dashboard' => [ 'name' => 'dashboard', 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_DASHBOARD_LABEL', @@ -553,15 +598,6 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Dash & Install', ], - 'toignore' => [ - 'name' => 'toignore', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_TOIGNORE_LABEL', - 'type' => 'text', - 'title' => false, - 'list' => 'joomla_components', - 'store' => NULL, - 'tab_name' => 'Settings', - ], 'add_php_preflight_install' => [ 'name' => 'add_php_preflight_install', 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_PREFLIGHT_INSTALL_LABEL', @@ -580,6 +616,15 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Dash & Install', ], + 'toignore' => [ + 'name' => 'toignore', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_TOIGNORE_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'joomla_components', + 'store' => NULL, + 'tab_name' => 'Settings', + ], 'add_php_postflight_install' => [ 'name' => 'add_php_postflight_install', 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_POSTFLIGHT_INSTALL_LABEL', @@ -589,6 +634,24 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Dash & Install', ], + 'add_php_postflight_update' => [ + 'name' => 'add_php_postflight_update', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_POSTFLIGHT_UPDATE_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'joomla_components', + 'store' => NULL, + 'tab_name' => 'Dash & Install', + ], + 'add_php_method_uninstall' => [ + 'name' => 'add_php_method_uninstall', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_METHOD_UNINSTALL_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'joomla_components', + 'store' => NULL, + 'tab_name' => 'Dash & Install', + ], 'export_key' => [ 'name' => 'export_key', 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EXPORT_KEY_LABEL', @@ -598,14 +661,14 @@ class Table extends BaseTable implements Tableinterface 'store' => 'basic_encryption', 'tab_name' => 'Settings', ], - 'add_php_postflight_update' => [ - 'name' => 'add_php_postflight_update', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_POSTFLIGHT_UPDATE_LABEL', + 'add_sql' => [ + 'name' => 'add_sql', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_SQL_LABEL', 'type' => 'radio', 'title' => false, 'list' => 'joomla_components', 'store' => NULL, - 'tab_name' => 'Dash & Install', + 'tab_name' => 'MySQL', ], 'joomla_source_link' => [ 'name' => 'joomla_source_link', @@ -616,14 +679,14 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Settings', ], - 'add_php_method_uninstall' => [ - 'name' => 'add_php_method_uninstall', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_METHOD_UNINSTALL_LABEL', + 'add_sql_uninstall' => [ + 'name' => 'add_sql_uninstall', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_SQL_UNINSTALL_LABEL', 'type' => 'radio', 'title' => false, 'list' => 'joomla_components', 'store' => NULL, - 'tab_name' => 'Dash & Install', + 'tab_name' => 'MySQL', ], 'export_buy_link' => [ 'name' => 'export_buy_link', @@ -634,24 +697,6 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Settings', ], - 'add_sql' => [ - 'name' => 'add_sql', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_SQL_LABEL', - 'type' => 'radio', - 'title' => false, - 'list' => 'joomla_components', - 'store' => NULL, - 'tab_name' => 'MySQL', - ], - 'add_sql_uninstall' => [ - 'name' => 'add_sql_uninstall', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_SQL_UNINSTALL_LABEL', - 'type' => 'radio', - 'title' => false, - 'list' => 'joomla_components', - 'store' => NULL, - 'tab_name' => 'MySQL', - ], 'assets_table_fix' => [ 'name' => 'assets_table_fix', 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ASSETS_TABLE_FIX_LABEL', @@ -661,15 +706,6 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'MySQL', ], - 'addcontributors' => [ - 'name' => 'addcontributors', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADDCONTRIBUTORS_LABEL', - 'type' => 'subform', - 'title' => false, - 'list' => 'joomla_components', - 'store' => 'json', - 'tab_name' => 'Settings', - ], 'readme' => [ 'name' => 'readme', 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_README_LABEL', @@ -679,15 +715,6 @@ class Table extends BaseTable implements Tableinterface 'store' => 'base64', 'tab_name' => 'Readme', ], - 'emptycontributors' => [ - 'name' => 'emptycontributors', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EMPTYCONTRIBUTORS_LABEL', - 'type' => 'radio', - 'title' => false, - 'list' => 'joomla_components', - 'store' => NULL, - 'tab_name' => 'Settings', - ], 'add_update_server' => [ 'name' => 'add_update_server', 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_UPDATE_SERVER_LABEL', @@ -697,13 +724,13 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Dynamic Integration', ], - 'number' => [ - 'name' => 'number', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NUMBER_LABEL', - 'type' => 'number', + 'addcontributors' => [ + 'name' => 'addcontributors', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADDCONTRIBUTORS_LABEL', + 'type' => 'subform', 'title' => false, 'list' => 'joomla_components', - 'store' => NULL, + 'store' => 'json', 'tab_name' => 'Settings', ], 'update_server_target' => [ @@ -715,6 +742,24 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Dynamic Integration', ], + 'emptycontributors' => [ + 'name' => 'emptycontributors', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_EMPTYCONTRIBUTORS_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'joomla_components', + 'store' => NULL, + 'tab_name' => 'Settings', + ], + 'number' => [ + 'name' => 'number', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NUMBER_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'joomla_components', + 'store' => NULL, + 'tab_name' => 'Settings', + ], 'update_server' => [ 'name' => 'update_server', 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_UPDATE_SERVER_LABEL', @@ -751,24 +796,6 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Dynamic Integration', ], - 'creatuserhelper' => [ - 'name' => 'creatuserhelper', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CREATUSERHELPER_LABEL', - 'type' => 'radio', - 'title' => false, - 'list' => 'joomla_components', - 'store' => NULL, - 'tab_name' => 'Libs & Helpers', - ], - 'adduikit' => [ - 'name' => 'adduikit', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADDUIKIT_LABEL', - 'type' => 'list', - 'title' => false, - 'list' => 'joomla_components', - 'store' => NULL, - 'tab_name' => 'Libs & Helpers', - ], 'crowdin_project_api_key' => [ 'name' => 'crowdin_project_api_key', 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CROWDIN_PROJECT_API_KEY_LABEL', @@ -778,10 +805,10 @@ class Table extends BaseTable implements Tableinterface 'store' => 'basic_encryption', 'tab_name' => 'Dynamic Integration', ], - 'addfootable' => [ - 'name' => 'addfootable', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADDFOOTABLE_LABEL', - 'type' => 'list', + 'creatuserhelper' => [ + 'name' => 'creatuserhelper', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_CREATUSERHELPER_LABEL', + 'type' => 'radio', 'title' => false, 'list' => 'joomla_components', 'store' => NULL, @@ -796,10 +823,10 @@ class Table extends BaseTable implements Tableinterface 'store' => 'basic_encryption', 'tab_name' => 'Dynamic Integration', ], - 'add_email_helper' => [ - 'name' => 'add_email_helper', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_EMAIL_HELPER_LABEL', - 'type' => 'radio', + 'adduikit' => [ + 'name' => 'adduikit', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADDUIKIT_LABEL', + 'type' => 'list', 'title' => false, 'list' => 'joomla_components', 'store' => NULL, @@ -814,10 +841,10 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Dynamic Build (beta)', ], - 'add_php_helper_both' => [ - 'name' => 'add_php_helper_both', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_PHP_HELPER_BOTH_LABEL', - 'type' => 'radio', + 'addfootable' => [ + 'name' => 'addfootable', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADDFOOTABLE_LABEL', + 'type' => 'list', 'title' => false, 'list' => 'joomla_components', 'store' => NULL, @@ -832,13 +859,13 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'publishing', ], - 'php_helper_both' => [ - 'name' => 'php_helper_both', - 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PHP_HELPER_BOTH_LABEL', - 'type' => 'editor', + 'add_email_helper' => [ + 'name' => 'add_email_helper', + 'label' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT_ADD_EMAIL_HELPER_LABEL', + 'type' => 'radio', 'title' => false, 'list' => 'joomla_components', - 'store' => 'base64', + 'store' => NULL, 'tab_name' => 'Libs & Helpers', ], 'modified' => [ @@ -3478,6 +3505,15 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Main', ], + 'php_calculation' => [ + 'name' => 'php_calculation', + 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_CALCULATION_LABEL', + 'type' => 'editor', + 'title' => false, + 'list' => 'dynamic_gets', + 'store' => 'base64', + 'tab_name' => 'Abacus', + ], 'php_router_parse' => [ 'name' => 'php_router_parse', 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_ROUTER_PARSE_LABEL', @@ -3487,51 +3523,24 @@ class Table extends BaseTable implements Tableinterface 'store' => 'base64', 'tab_name' => 'Custom Script', ], - 'php_before_getitems' => [ - 'name' => 'php_before_getitems', - 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_BEFORE_GETITEMS_LABEL', - 'type' => 'editor', + 'add_php_after_getitems' => [ + 'name' => 'add_php_after_getitems', + 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_AFTER_GETITEMS_LABEL', + 'type' => 'radio', 'title' => false, 'list' => 'dynamic_gets', - 'store' => 'base64', + 'store' => NULL, 'tab_name' => 'Custom Script', ], - 'php_after_getitems' => [ - 'name' => 'php_after_getitems', - 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_AFTER_GETITEMS_LABEL', - 'type' => 'editor', + 'add_php_router_parse' => [ + 'name' => 'add_php_router_parse', + 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_ROUTER_PARSE_LABEL', + 'type' => 'radio', 'title' => false, 'list' => 'dynamic_gets', - 'store' => 'base64', + 'store' => NULL, 'tab_name' => 'Custom Script', ], - 'php_after_getitem' => [ - 'name' => 'php_after_getitem', - 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_AFTER_GETITEM_LABEL', - 'type' => 'editor', - 'title' => false, - 'list' => 'dynamic_gets', - 'store' => 'base64', - 'tab_name' => 'Custom Script', - ], - 'php_getlistquery' => [ - 'name' => 'php_getlistquery', - 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_GETLISTQUERY_LABEL', - 'type' => 'editor', - 'title' => false, - 'list' => 'dynamic_gets', - 'store' => 'base64', - 'tab_name' => 'Custom Script', - ], - 'join_db_table' => [ - 'name' => 'join_db_table', - 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_JOIN_DB_TABLE_LABEL', - 'type' => 'subform', - 'title' => false, - 'list' => 'dynamic_gets', - 'store' => 'json', - 'tab_name' => 'Joint', - ], 'view_selection' => [ 'name' => 'view_selection', 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_VIEW_SELECTION_LABEL', @@ -3541,6 +3550,33 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Main', ], + 'add_php_before_getitems' => [ + 'name' => 'add_php_before_getitems', + 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_BEFORE_GETITEMS_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'dynamic_gets', + 'store' => NULL, + 'tab_name' => 'Custom Script', + ], + 'add_php_before_getitem' => [ + 'name' => 'add_php_before_getitem', + 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_BEFORE_GETITEM_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'dynamic_gets', + 'store' => NULL, + 'tab_name' => 'Custom Script', + ], + 'add_php_after_getitem' => [ + 'name' => 'add_php_after_getitem', + 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_AFTER_GETITEM_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'dynamic_gets', + 'store' => NULL, + 'tab_name' => 'Custom Script', + ], 'db_table_main' => [ 'name' => 'db_table_main', 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_DB_TABLE_MAIN_LABEL', @@ -3577,24 +3613,6 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Main', ], - 'php_calculation' => [ - 'name' => 'php_calculation', - 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_CALCULATION_LABEL', - 'type' => 'editor', - 'title' => false, - 'list' => 'dynamic_gets', - 'store' => 'base64', - 'tab_name' => 'Abacus', - ], - 'php_before_getitem' => [ - 'name' => 'php_before_getitem', - 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_BEFORE_GETITEM_LABEL', - 'type' => 'editor', - 'title' => false, - 'list' => 'dynamic_gets', - 'store' => 'base64', - 'tab_name' => 'Custom Script', - ], 'view_table_main' => [ 'name' => 'view_table_main', 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_VIEW_TABLE_MAIN_LABEL', @@ -3604,51 +3622,6 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Main', ], - 'select_all' => [ - 'name' => 'select_all', - 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_SELECT_ALL_LABEL', - 'type' => 'radio', - 'title' => false, - 'list' => 'dynamic_gets', - 'store' => NULL, - 'tab_name' => 'Main', - ], - 'add_php_before_getitem' => [ - 'name' => 'add_php_before_getitem', - 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_BEFORE_GETITEM_LABEL', - 'type' => 'radio', - 'title' => false, - 'list' => 'dynamic_gets', - 'store' => NULL, - 'tab_name' => 'Custom Script', - ], - 'getcustom' => [ - 'name' => 'getcustom', - 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_GETCUSTOM_LABEL', - 'type' => 'text', - 'title' => false, - 'list' => 'dynamic_gets', - 'store' => NULL, - 'tab_name' => 'Main', - ], - 'add_php_after_getitem' => [ - 'name' => 'add_php_after_getitem', - 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_AFTER_GETITEM_LABEL', - 'type' => 'radio', - 'title' => false, - 'list' => 'dynamic_gets', - 'store' => NULL, - 'tab_name' => 'Custom Script', - ], - 'pagination' => [ - 'name' => 'pagination', - 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_PAGINATION_LABEL', - 'type' => 'radio', - 'title' => false, - 'list' => 'dynamic_gets', - 'store' => NULL, - 'tab_name' => 'Main', - ], 'add_php_getlistquery' => [ 'name' => 'add_php_getlistquery', 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_GETLISTQUERY_LABEL', @@ -3658,13 +3631,76 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Custom Script', ], - 'add_php_before_getitems' => [ - 'name' => 'add_php_before_getitems', - 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_BEFORE_GETITEMS_LABEL', + 'join_db_table' => [ + 'name' => 'join_db_table', + 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_JOIN_DB_TABLE_LABEL', + 'type' => 'subform', + 'title' => false, + 'list' => 'dynamic_gets', + 'store' => 'json', + 'tab_name' => 'Joint', + ], + 'select_all' => [ + 'name' => 'select_all', + 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_SELECT_ALL_LABEL', 'type' => 'radio', 'title' => false, 'list' => 'dynamic_gets', 'store' => NULL, + 'tab_name' => 'Main', + ], + 'php_before_getitem' => [ + 'name' => 'php_before_getitem', + 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_BEFORE_GETITEM_LABEL', + 'type' => 'editor', + 'title' => false, + 'list' => 'dynamic_gets', + 'store' => 'base64', + 'tab_name' => 'Custom Script', + ], + 'getcustom' => [ + 'name' => 'getcustom', + 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_GETCUSTOM_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'dynamic_gets', + 'store' => NULL, + 'tab_name' => 'Main', + ], + 'php_after_getitem' => [ + 'name' => 'php_after_getitem', + 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_AFTER_GETITEM_LABEL', + 'type' => 'editor', + 'title' => false, + 'list' => 'dynamic_gets', + 'store' => 'base64', + 'tab_name' => 'Custom Script', + ], + 'pagination' => [ + 'name' => 'pagination', + 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_PAGINATION_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'dynamic_gets', + 'store' => NULL, + 'tab_name' => 'Main', + ], + 'php_getlistquery' => [ + 'name' => 'php_getlistquery', + 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_GETLISTQUERY_LABEL', + 'type' => 'editor', + 'title' => false, + 'list' => 'dynamic_gets', + 'store' => 'base64', + 'tab_name' => 'Custom Script', + ], + 'php_before_getitems' => [ + 'name' => 'php_before_getitems', + 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_BEFORE_GETITEMS_LABEL', + 'type' => 'editor', + 'title' => false, + 'list' => 'dynamic_gets', + 'store' => 'base64', 'tab_name' => 'Custom Script', ], 'filter' => [ @@ -3676,13 +3712,13 @@ class Table extends BaseTable implements Tableinterface 'store' => 'json', 'tab_name' => 'Tweak', ], - 'add_php_after_getitems' => [ - 'name' => 'add_php_after_getitems', - 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_AFTER_GETITEMS_LABEL', - 'type' => 'radio', + 'php_after_getitems' => [ + 'name' => 'php_after_getitems', + 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_AFTER_GETITEMS_LABEL', + 'type' => 'editor', 'title' => false, 'list' => 'dynamic_gets', - 'store' => NULL, + 'store' => 'base64', 'tab_name' => 'Custom Script', ], 'where' => [ @@ -3694,15 +3730,6 @@ class Table extends BaseTable implements Tableinterface 'store' => 'json', 'tab_name' => 'Tweak', ], - 'add_php_router_parse' => [ - 'name' => 'add_php_router_parse', - 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_ROUTER_PARSE_LABEL', - 'type' => 'radio', - 'title' => false, - 'list' => 'dynamic_gets', - 'store' => NULL, - 'tab_name' => 'Custom Script', - ], 'order' => [ 'name' => 'order', 'label' => 'COM_COMPONENTBUILDER_DYNAMIC_GET_ORDER_LABEL', @@ -3804,6 +3831,15 @@ class Table extends BaseTable implements Tableinterface 'store' => NULL, 'tab_name' => 'Details', ], + 'joomla_version' => [ + 'name' => 'joomla_version', + 'label' => 'COM_COMPONENTBUILDER_CUSTOM_CODE_JOOMLA_VERSION_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'custom_codes', + 'store' => NULL, + 'tab_name' => 'Details', + ], 'function_name' => [ 'name' => 'function_name', 'label' => 'COM_COMPONENTBUILDER_CUSTOM_CODE_FUNCTION_NAME_LABEL', @@ -4830,7 +4866,7 @@ class Table extends BaseTable implements Tableinterface 'groups' => [ 'name' => 'groups', 'label' => 'COM_COMPONENTBUILDER_HELP_DOCUMENT_GROUPS_LABEL', - 'type' => 'usergroup', + 'type' => 'usergrouplist', 'title' => false, 'list' => 'help_documents', 'store' => 'json', @@ -5118,6 +5154,80 @@ class Table extends BaseTable implements Tableinterface 'tab_name' => 'Menus', ], ], + 'component_router' => [ + 'joomla_component' => [ + 'name' => 'joomla_component', + 'label' => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_JOOMLA_COMPONENT_LABEL', + 'type' => 'joomlacomponents', + 'title' => true, + 'list' => 'components_routers', + 'store' => NULL, + 'tab_name' => 'Settings', + ], + 'mode_constructor_before_parent' => [ + 'name' => 'mode_constructor_before_parent', + 'label' => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_MODE_CONSTRUCTOR_BEFORE_PARENT_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'components_routers', + 'store' => NULL, + 'tab_name' => 'Settings', + ], + 'mode_constructor_after_parent' => [ + 'name' => 'mode_constructor_after_parent', + 'label' => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_MODE_CONSTRUCTOR_AFTER_PARENT_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'components_routers', + 'store' => NULL, + 'tab_name' => 'Settings', + ], + 'mode_methods' => [ + 'name' => 'mode_methods', + 'label' => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_MODE_METHODS_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'components_routers', + 'store' => NULL, + 'tab_name' => 'Settings', + ], + 'methods_code' => [ + 'name' => 'methods_code', + 'label' => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_METHODS_CODE_LABEL', + 'type' => 'editor', + 'title' => false, + 'list' => 'components_routers', + 'store' => 'base64', + 'tab_name' => 'Settings', + ], + 'constructor_after_parent_code' => [ + 'name' => 'constructor_after_parent_code', + 'label' => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_CONSTRUCTOR_AFTER_PARENT_CODE_LABEL', + 'type' => 'editor', + 'title' => false, + 'list' => 'components_routers', + 'store' => 'base64', + 'tab_name' => 'Settings', + ], + 'constructor_before_parent_manual' => [ + 'name' => 'constructor_before_parent_manual', + 'label' => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_CONSTRUCTOR_BEFORE_PARENT_MANUAL_LABEL', + 'type' => 'subform', + 'title' => false, + 'list' => 'components_routers', + 'store' => 'json', + 'tab_name' => 'Settings', + ], + 'constructor_before_parent_code' => [ + 'name' => 'constructor_before_parent_code', + 'label' => 'COM_COMPONENTBUILDER_COMPONENT_ROUTER_CONSTRUCTOR_BEFORE_PARENT_CODE_LABEL', + 'type' => 'editor', + 'title' => false, + 'list' => 'components_routers', + 'store' => 'base64', + 'tab_name' => 'Settings', + ], + ], 'component_config' => [ 'joomla_component' => [ 'name' => 'joomla_component', diff --git a/libraries/jcb_powers/VDM.Joomla/src/Interfaces/Activeregistryinterface.php b/libraries/jcb_powers/VDM.Joomla/src/Interfaces/Activeregistryinterface.php index 9fdf2c0a4..ebf3a67b4 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Interfaces/Activeregistryinterface.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Interfaces/Activeregistryinterface.php @@ -51,15 +51,17 @@ interface Activeregistryinterface * Adds content into the registry. If a key exists, * it either appends or concatenates based on the value's type. * - * @param mixed $value The value to set. - * @param bool $asArray Determines if the new value should be treated as an array. - * @param string ...$keys The keys to determine the location. + * @param mixed $value The value to set. + * @param bool|null $asArray Determines if the new value should be treated as an array. + * Default is $addAsArray = false (if null) in base class. + * Override in child class allowed set class property $addAsArray = true. + * @param string ...$keys The keys to determine the location. * * @throws \InvalidArgumentException If any of the keys are not a number or string. * @return void * @since 3.2.0 */ - public function addActive($value, bool $asArray, string ...$keys): void; + public function addActive($value, ?bool $asArray, string ...$keys): void; /** * Retrieves a value (or sub-array) from the registry using multiple keys. diff --git a/libraries/jcb_powers/VDM.Joomla/src/Interfaces/Registryinterface.php b/libraries/jcb_powers/VDM.Joomla/src/Interfaces/Registryinterface.php index e7a8f0297..58eab826d 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Interfaces/Registryinterface.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Interfaces/Registryinterface.php @@ -35,15 +35,17 @@ interface Registryinterface * Adds content into the registry. If a key exists, * it either appends or concatenates based on $asArray switch. * - * @param string $path Registry path (e.g. vdm.content.builder) - * @param mixed $value Value of entry - * @param bool $asArray Determines if the new value should be treated as an array. Default is false. + * @param string $path Registry path (e.g. vdm.content.builder) + * @param mixed $value Value of entry + * @param bool|null $asArray Determines if the new value should be treated as an array. + * Default is $addAsArray = false (if null) in base class. + * Override in child class allowed set class property $addAsArray = true. * * @throws \InvalidArgumentException If any of the path values are not a number or string. * @return void * @since 3.2.0 */ - public function add(string $path, $value, bool $asArray = false): void; + public function add(string $path, $value, ?bool $asArray = null): void; /** * Retrieves a value (or sub-array) from the registry using multiple keys. diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities.php b/libraries/jcb_powers/VDM.Joomla/src/Utilities.php deleted file mode 100644 index b473fea4f..000000000 --- a/libraries/jcb_powers/VDM.Joomla/src/Utilities.php +++ /dev/null @@ -1,669 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -namespace VDM\Joomla; - - -use VDM\Joomla\Utilities\StringHelper; -use VDM\Joomla\Utilities\JsonHelper; -use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\ObjectHelper; -use VDM\Joomla\Utilities\MathHelper; -use VDM\Joomla\Utilities\GetHelper; -use VDM\Joomla\Utilities\GuidHelper; -use VDM\Joomla\Utilities\FileHelper; -use VDM\Joomla\Utilities\String\FieldHelper; -use VDM\Joomla\Utilities\String\TypeHelper; -use VDM\Joomla\Utilities\String\ClassfunctionHelper; -use VDM\Joomla\Utilities\String\NamespaceHelper; -use VDM\Joomla\Utilities\String\PluginHelper; -use VDM\Joomla\Utilities\Component\Helper; - - -/** - * Basic shared utilities, a legacy implementation - * - * @since 3.0.9 - */ -trait Utilities -{ - /** - * The Main Active Language - * - * @var string - * - * @since 3.0.9 - */ - public static $langTag; - - /** - * Check if have a string with a length - * - * @input string $string The string to check - * - * @returns bool true on success - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use StringHelper::check($string); - */ - public static function checkString($string): bool - { - return StringHelper::check($string); - } - - /** - * Shorten a string - * - * @input string $string That you would like to shorten - * - * @returns string on success - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use StringHelper::shorten($string, $length, $addTip); - */ - public static function shorten($string, $length = 40, $addTip = true) - { - return StringHelper::shorten($string, $length, $addTip); - } - - /** - * Making strings safe (various ways) - * - * @input string $string That you would like to make safe - * - * @returns string on success - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use StringHelper::safe($string, $type, $spacer, $replaceNumbers, $keepOnlyCharacters); - */ - public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true) - { - // set the local component option - self::setComponentOption(); - - return StringHelper::safe($string, $type, $spacer, $replaceNumbers, $keepOnlyCharacters); - } - - /** - * Making class or function name safe - * - * @input string The name you would like to make safe - * - * @returns string on success - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use ClassfunctionHelper::safe($name); - */ - public static function safeClassFunctionName($name) - { - return ClassfunctionHelper::safe($name); - } - - /** - * Making field names safe - * - * @input string The you would like to make safe - * @input boolean The switch to return an ALL UPPER CASE string - * @input string The string to use in white space - * - * @returns string on success - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use FieldHelper::safe($string, $allcap, $spacer); - */ - public static function safeFieldName($string, $allcap = false, $spacer = '_') - { - // set the local component option - self::setComponentOption(); - - return FieldHelper::safe($string, $allcap, $spacer); - } - - /** - * Making field type name safe - * - * @input string The you would like to make safe - * - * @returns string on success - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use TypeHelper::safe($string); - */ - public static function safeTypeName($string) - { - // set the local component option - self::setComponentOption(); - - return TypeHelper::safe($string); - } - - /** - * Making namespace safe - * - * @input string The you would like to make safe - * - * @returns string on success - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use NamespaceHelper::safe($string); - */ - public static function safeNamespace($string) - { - return NamespaceHelper::safe($string); - } - - /** - * @since 3.0.9 - * - * @deprecated 4.0 - Use StringHelper::transliterate($string); - */ - public static function transliterate($string) - { - // set the local component option - self::setComponentOption(); - - return StringHelper::transliterate($string); - } - - /** - * @since 3.0.9 - * - * @deprecated 4.0 - Use StringHelper::html($var, $charset, $shorten, $length); - */ - public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40) - { - // set the local component option - self::setComponentOption(); - - return StringHelper::html($var, $charset, $shorten, $length); - } - - /** - * @since 3.0.9 - * - * @deprecated 4.0 - Use StringHelper::numbers($string); - */ - public static function replaceNumbers($string) - { - return StringHelper::numbers($string); - } - - /** - * Convert an integer into an English word string - * Thanks to Tom Nicholson - * - * @input int $x an int - * - * @returns string a string - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use StringHelper::number($x); - */ - public static function numberToString($x) - { - return StringHelper::number($x); - } - - /** - * Random Key - * - * @input int $size the length of the string - * - * @returns string a string of random characters - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use StringHelper::random($size); - */ - public static function randomkey($size): string - { - return StringHelper::random($size); - } - - /** - * Check if you have a json string - * - * @input string $string The json string to check - * - * @returns bool true on success - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use JsonHelper::check($string); - */ - public static function checkJson($string): bool - { - return JsonHelper::check($string); - } - - /** - * @since 3.0.9 - * - * @deprecated 4.0 - Use JsonHelper::string($value, $sperator, $table, $id, $name); - */ - public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name') - { - return JsonHelper::string($value, $sperator, $table, $id, $name); - } - - /** - * Check if you have an array with a length - * - * @input mixed $array The array to check - * @input bool $removeEmptyString Should we remove empty values - * - * @returns int number of items in array on success - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use ArrayHelper::check($array, $removeEmptyString); - */ - public static function checkArray($array, $removeEmptyString = false): int - { - return ArrayHelper::check($array, $removeEmptyString); - } - - /** - * Merge an array of array's - * - * @input mixed $arrays The arrays you would like to merge - * - * @returns mixed array on success - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use ArrayHelper::merge($arrays); - */ - public static function mergeArrays($arrays) - { - return ArrayHelper::merge($arrays); - } - - /** - * Check if you have an object with a length - * - * @input object $object The object to check - * - * @returns bool true on success - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use ObjectHelper::check($object); - */ - public static function checkObject($object): bool - { - return ObjectHelper::check($object); - } - - /** - * Get a Variable - * - * @param string $table The table from which to get the variable - * @param string $where The value where - * @param string $whereString The target/field string where/name - * @param string $what The return field - * @param string $operator The operator between $whereString/field and $where/value - * @param string $main The component in which the table is found - * - * @return mix string/int/float - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use GetHelper::var($table, $where, $whereString, $what, $operator, $main); - */ - public static function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = null) - { - // set the local component option - self::setComponentOption(); - - return GetHelper::var($table, $where, $whereString, $what, $operator, $main); - } - - /** - * Get array of variables - * - * @param string $table The table from which to get the variables - * @param string $where The value where - * @param string $whereString The target/field string where/name - * @param string $what The return field - * @param string $operator The operator between $whereString/field and $where/value - * @param string $main The component in which the table is found - * @param bool $unique The switch to return a unique array - * - * @return array - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use GetHelper::vars($table, $where, $whereString, $what, $operator, $main, $unique); - */ - public static function getVars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = null, $unique = true) - { - // set the local component option - self::setComponentOption(); - - return GetHelper::vars($table, $where, $whereString, $what, $operator, $main, $unique); - } - - /** - * get all strings between two other strings - * - * @param string $content The content to search - * @param string $start The starting value - * @param string $end The ending value - * - * @return array On success - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use GetHelper::allBetween($content, $start, $end); - */ - public static function getAllBetween($content, $start, $end) - { - return GetHelper::allBetween($content, $start, $end); - } - - /** - * get a string between two other strings - * - * @param string $content The content to search - * @param string $start The starting value - * @param string $end The ending value - * @param string $default The default value if none found - * - * @return string On success / empty string on failure - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use GetHelper::between($content, $start, $end, $default); - */ - public static function getBetween($content, $start, $end, $default = '') - { - return GetHelper::between($content, $start, $end, $default); - } - - /** - * bc math wrapper (very basic not for accounting) - * - * @param string $type The type bc math - * @param int $val1 The first value - * @param int $val2 The second value - * @param int $scale The scale value - * - * @return float|int - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use MathHelper::bc($type, $val1, $val2, $scale); - */ - public static function bcmath($type, $val1, $val2, $scale = 0) - { - return MathHelper::bc($type, $val1, $val2, $scale); - } - - /** - * Basic sum of an array with more precision - * - * @param array $array The values to sum - * @param int $scale The scale value - * - * @return float|int - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use MathHelper::sum($array, $scale); - */ - public static function bcsum($array, $scale = 4) - { - return MathHelper::sum($array, $scale); - } - - /** - * create plugin class name - * - * @input string The group name - * @input string The name - * - * @return string - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use PluginHelper::safe($name, $group); - */ - public static function createPluginClassName($group, $name) - { - return PluginHelper::safeClassName($name, $group); - } - - /** - * Returns a GUIDv4 string - * - * Thanks to Dave Pearson (and other) - * https://www.php.net/manual/en/function.com-create-guid.php#119168 - * - * Uses the best cryptographically secure method - * for all supported platforms with fallback to an older, - * less secure version. - * - * @param bool $trim - * - * @return string - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use GuidHelper::get($trim); - */ - public static function GUID($trim = true) - { - return GuidHelper::get($trim); - } - - /** - * Validate the Globally Unique Identifier ( and check if table already has this identifier) - * - * @param string $guid - * @param string $table - * @param int $id - * @param string|null $component - * - * @return bool - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use GuidHelper::valid($guid, $table, $id, $component); - */ - public static function validGUID($guid, $table = null, $id = 0, $component = null) - { - // set the local component option - self::setComponentOption(); - - return GuidHelper::valid($guid, $table, $id, $component); - } - - /** - * get the ITEM of a GUID by table - * - * @param string $guid - * @param string $table - * @param string/array $what - * @param string|null $component - * - * @return mix - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use GuidHelper::valid($guid, $table, $id, $component); - */ - public static function getGUID($guid, $table, $what = 'a.id', $component = null) - { - // set the local component option - self::setComponentOption(); - - return GuidHelper::item($guid, $table, $what, $component); - } - - /** - * Validate the Globally Unique Identifier - * - * Thanks to Lewie - * https://stackoverflow.com/a/1515456/1429677 - * - * @param string $guid - * - * @return bool - * - * @deprecated 4.0 - Use GuidHelper::validate($guid); - */ - protected static function validateGUID($guid) - { - return GuidHelper::validate($guid); - } - - /** - * The zipper method - * - * @param string $workingDIR The directory where the items must be zipped - * @param string $filepath The path to where the zip file must be placed - * - * @return bool true On success - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use FileHelper::zip($workingDIR, $filepath); - */ - public static function zip($workingDIR, &$filepath) - { - return FileHelper::zip($workingDIR, $filepath); - } - - /** - * get the content of a file - * - * @param string $path The path to the file - * @param string/bool $none The return value if no content was found - * - * @return string On success - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use FileHelper::getContent($path, $none); - */ - public static function getFileContents($path, $none = '') - { - return FileHelper::getContent($path, $none); - } - - /** - * Write a file to the server - * - * @param string $path The path and file name where to safe the data - * @param string $data The data to safe - * - * @return bool true On success - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use FileHelper::write($path, $data); - */ - public static function writeFile($path, $data) - { - return FileHelper::write($path, $data); - } - - /** - * get all the file paths in folder and sub folders - * - * @param string $folder The local path to parse - * @param array $fileTypes The type of files to get - * - * @return void - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use FileHelper::getPaths($folder, $fileTypes , $recurse, $full); - */ - public static function getAllFilePaths($folder, $fileTypes = array('\.php', '\.js', '\.css', '\.less'), $recurse = true, $full = true) - { - return FileHelper::getPaths($folder, $fileTypes , $recurse, $full); - } - - /** - * Get the file path or url - * - * @param string $type The (url/path) type to return - * @param string $target The Params Target name (if set) - * @param string $fileType The kind of filename to generate (if not set no file name is generated) - * @param string $key The key to adjust the filename (if not set ignored) - * @param string $default The default path if not set in Params (fallback path) - * @param bool $createIfNotSet The switch to create the folder if not found - * - * @return string On success the path or url is returned based on the type requested - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use FileHelper::getPath($type, $target, $fileType, $key, $default, $createIfNotSet); - */ - public static function getFilePath($type = 'path', $target = 'filepath', $fileType = null, $key = '', $default = '', $createIfNotSet = true) - { - // set the local component option - self::setComponentOption(); - - return FileHelper::getPath($type, $target, $fileType, $key, $default, $createIfNotSet); - } - - /** - * Check if file exist - * - * @param string $path The url/path to check - * - * @return bool If exist true - * - * @since 3.0.9 - * - * @deprecated 4.0 - Use FileHelper::exists($path); - */ - public static function urlExists($path) - { - return FileHelper::exists($path); - } - - /** - * Set the component option - * - * @param String|null $option The option for the component. - * - * @since 3.0.11 - */ - public static function setComponentOption($option = null) - { - // set the local component option - if (empty($option)) - { - if (empty(Helper::$option) && property_exists(__CLASS__, 'ComponentCodeName')) - { - Helper::$option = 'com_' . self::$ComponentCodeName; - } - } - else - { - Helper::$option = $option; - } - } - -} - diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/Component/Helper.php b/libraries/jcb_powers/VDM.Joomla/src/Utilities/Component/Helper.php index 61dbf59f8..5660a4915 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Utilities/Component/Helper.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/Component/Helper.php @@ -12,9 +12,11 @@ namespace VDM\Joomla\Utilities\Component; -use Joomla\Input\Input; +use Joomla\CMS\Factory; use Joomla\CMS\Component\ComponentHelper; +use Joomla\Input\Input; use Joomla\Registry\Registry; +use VDM\Joomla\Utilities\String\NamespaceHelper; /** @@ -27,10 +29,18 @@ abstract class Helper /** * The current option * - * @var string + * @var string|null * @since 3.0.11 */ - public static string $option; + public static ?string $option = null; + + /** + * The component manifest list cache + * + * @var array + * @since 3.2.0 + */ + public static array $manifest = []; /** * The component params list cache @@ -67,27 +77,52 @@ abstract class Helper } /** - * Gets the component option + * Set the component option + * + * @param string|null $option The option + * + * @return void + * @since 3.2.0 + */ + public static function setOption(?string $option): void + { + self::$option = $option; + } + + /** + * Get the component option * * @param string|null $default The default return value if none is found * * @return string|null A component option * @since 3.0.11 */ - public static function getOption(string $default = 'empty'): ?string + public static function getOption(?string $default = 'empty'): ?string { if (empty(self::$option)) { // get the option from the url input - self::$option = (new Input)->getString('option', false); + self::$option = (new Input)->getString('option', null); } - if (self::$option) + if (empty(self::$option)) { - return self::$option; + $app = Factory::getApplication(); + + // Check if the getInput method exists in the application object + if (method_exists($app, 'getInput')) + { + // get the option from the application + self::$option = $app->getInput()->getCmd('option', $default); + } + else + { + // Use the default value if getInput method does not exist + self::$option = $default; + } } - return $default; + return self::$option; } /** @@ -125,24 +160,96 @@ abstract class Helper * * @since 3.0.11 */ - public static function get(string $option = null, string $default = null): ?string + public static function get(?string $option = null, ?string $default = null): ?string { // check that we have an option // and get the code name from it - if (($code_name = self::getCode($option, false)) !== false) + if (($code_name = self::getCode($option, null)) !== null) { // we build the helper class name $helper_name = '\\' . \ucfirst($code_name) . 'Helper'; + // check if class exist if (class_exists($helper_name)) { return $helper_name; } + + // try loading namespace + if (($namespace = self::getNamespace($option)) !== null) + { + $name = \ucfirst($code_name) . 'Helper'; + $namespace_helper = '\\' . $namespace . '\Administrator\Helper\\' . NamespaceHelper::safeSegment($name); // TODO target site or admin locations not just admin... + if (class_exists($namespace_helper)) + { + return $namespace_helper; + } + } } return $default; } + /** + * Gets the component namespace if set + * + * @param string|null $option The option for the component. + * @param string|null $default The default return value if none is found + * + * @return string|null A component namespace + * + * @since 3.0.11 + */ + public static function getNamespace(?string $option = null): ?string + { + $manifest = self::getManifest($option); + + return $manifest->namespace ?? null; + } + + /** + * Gets the component abstract helper class + * + * @param string|null $option The option for the component. + * @param string|null $default The default return value if none is found + * + * @return object|null A component helper name + * + * @since 3.0.11 + */ + public static function getManifest(?string $option = null): ?object + { + if ($option === null + && ($option = self::getOption($option)) === null) + { + return null; + } + + // get global manifest_cache values + if (!isset(self::$manifest[$option])) + { + $db = Factory::getDbo(); + $query = $db->getQuery(true); + + $query->select($db->quoteName('manifest_cache')) + ->from($db->quoteName('#__extensions')) + ->where($db->quoteName('type') . ' = ' . $db->quote('component')) + ->where($db->quoteName('element') . ' LIKE ' . $db->quote($option)); + + $db->setQuery($query); + + try { + $manifest = $db->loadResult(); + self::$manifest[$option] = json_decode($manifest); + } catch (\Exception $e) { + // Handle the database error appropriately. + self::$manifest[$option] = null; + } + } + + return self::$manifest[$option]; + } + /** * Check if the helper class of this component has a method * @@ -153,10 +260,10 @@ abstract class Helper * * @since 3.0.11 */ - public static function methodExists(string $method, string $option = null): bool + public static function methodExists(string $method, ?string $option = null): bool { // get the helper class - return ($helper = self::get($option, false)) !== false && + return ($helper = self::get($option, null)) !== null && method_exists($helper, $method); } @@ -173,7 +280,7 @@ abstract class Helper public static function _(string $method, array $arguments = [], ?string $option = null) { // get the helper class - if (($helper = self::get($option, false)) !== false && + if (($helper = self::get($option, null)) !== null && method_exists($helper, $method)) { // we know this is not ideal... diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/FileHelper.php b/libraries/jcb_powers/VDM.Joomla/src/Utilities/FileHelper.php index 0dd04d81b..7d1dd0a57 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Utilities/FileHelper.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/FileHelper.php @@ -89,8 +89,8 @@ abstract class FileHelper /** * get the content of a file * - * @param string $path The path to the file - * @param string/bool $none The return value if no content was found + * @param string $path The path to the file + * @param mixed $none The return value if no content was found * * @return string On success * @@ -150,7 +150,7 @@ abstract class FileHelper * * @since 3.0.9 */ - public static function write($path, $data) + public static function write($path, $data): bool { $klaar = false; if (StringHelper::check($data)) @@ -179,11 +179,11 @@ abstract class FileHelper * @param string $folder The local path to parse * @param array $fileTypes The type of files to get * - * @return void + * @return array|null * * @since 3.0.9 */ - public static function getPaths($folder, $fileTypes = array('\.php', '\.js', '\.css', '\.less'), $recurse = true, $full = true) + public static function getPaths($folder, $fileTypes = array('\.php', '\.js', '\.css', '\.less'), $recurse = true, $full = true): ?array { if (Folder::exists($folder)) { @@ -219,7 +219,7 @@ abstract class FileHelper // return array of files return array_map( fn($file) => str_replace('./', '/', (string) $file), (array) ArrayHelper::merge($files)); } - return false; + return null; } /** @@ -236,7 +236,7 @@ abstract class FileHelper * * @since 3.0.9 */ - public static function getPath($type = 'path', $target = 'filepath', $fileType = null, $key = '', $default = '', $createIfNotSet = true) + public static function getPath($type = 'path', $target = 'filepath', $fileType = null, $key = '', $default = '', $createIfNotSet = true): string { // make sure to always have a string/path if(!StringHelper::check($default)) @@ -316,7 +316,7 @@ abstract class FileHelper * * @since 3.0.9 */ - public static function exists($path) + public static function exists($path): bool { $exists = false; // if this is a local path diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/FormHelper.php b/libraries/jcb_powers/VDM.Joomla/src/Utilities/FormHelper.php index a2f48fd41..b21d71c3c 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Utilities/FormHelper.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/FormHelper.php @@ -75,24 +75,24 @@ abstract class FormHelper // element was not returned return; } - switch (get_class($node)) + + if ($node instanceof \stdClass) { - case 'stdClass': - if (property_exists($node, 'comment')) - { - self::comment($xml, $node->comment); - } - if (property_exists($node, 'fieldXML')) - { - self::append($xml, $node->fieldXML); - } - break; - case 'SimpleXMLElement': - $domXML = \dom_import_simplexml($xml); - $domNode = \dom_import_simplexml($node); - $domXML->appendChild($domXML->ownerDocument->importNode($domNode, true)); - $xml = \simplexml_import_dom($domXML); - break; + if (property_exists($node, 'comment')) + { + self::comment($xml, $node->comment); + } + if (property_exists($node, 'fieldXML')) + { + self::append($xml, $node->fieldXML); + } + } + elseif ($node instanceof \SimpleXMLElement) + { + $domXML = \dom_import_simplexml($xml); + $domNode = \dom_import_simplexml($node); + $domXML->appendChild($domXML->ownerDocument->importNode($domNode, true)); + $xml = \simplexml_import_dom($domXML); } } @@ -127,7 +127,7 @@ abstract class FormHelper { foreach ($attributes as $key => $value) { - $xml->addAttribute($key, $value); + $xml->addAttribute($key, $value ?? ''); } } @@ -145,7 +145,7 @@ abstract class FormHelper foreach ($options as $key => $value) { $addOption = $xml->addChild('option'); - $addOption->addAttribute('value', $key); + $addOption->addAttribute('value', $key ?? ''); $addOption[] = $value; } } diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/GetHelper.php b/libraries/jcb_powers/VDM.Joomla/src/Utilities/GetHelper.php index f58409767..1f89e7b87 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Utilities/GetHelper.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/GetHelper.php @@ -113,14 +113,14 @@ abstract class GetHelper $where = Factory::getUser()->id; } - if(is_null($main)) + if($main === null) { $main = Helper::getCode(); } if (!ArrayHelper::check($where) && $where > 0) { - $where = array($where); + $where = [$where]; } if (ArrayHelper::check($where)) diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/GuidHelper.php b/libraries/jcb_powers/VDM.Joomla/src/Utilities/GuidHelper.php index e21947347..14a114832 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Utilities/GuidHelper.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/GuidHelper.php @@ -138,7 +138,7 @@ abstract class GuidHelper * @param string|array $what * @param string|null $component * - * @return mix + * @return mixed * * @since 3.0.9 */ diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/String/NamespaceHelper.php b/libraries/jcb_powers/VDM.Joomla/src/Utilities/String/NamespaceHelper.php index 4776fb9fa..55ee2e490 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Utilities/String/NamespaceHelper.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/String/NamespaceHelper.php @@ -38,30 +38,41 @@ abstract class NamespaceHelper // Split the string into namespace segments $segments = explode('\\', $string); - foreach ($segments as &$segment) - { - // Check if segment starts with a number - if (preg_match("/^\d/", $segment)) - { - // Extract the starting number(s) - preg_match("/^\d+/", $segment, $matches); - - if (isset($matches[0])) - { - $numberWord = StringHelper::numbers($matches[0]); - $segment = str_replace($matches[0], $numberWord, $segment); - } - } - - // Transliterate string TODO: look again as this makes it lowercase - // $segment = StringHelper::transliterate($segment); - - // Make sure segment only contains valid characters - $segment = preg_replace("/[^A-Za-z0-9]/", '', $segment); - } + // make each segment safe + $segments = array_map([self::class, 'safeSegment'], $segments); // Join the namespace segments back together return implode('\\', $segments); + } + + /** + * Making one namespace segment safe + * + * @param string $string The namespace segment string you would like to make safe + * + * @return string on success + * @since 3.0.9 + */ + public static function safeSegment(string $string): string + { + // Check if segment starts with a number + if (preg_match("/^\d/", $string)) + { + // Extract the starting number(s) + preg_match("/^\d+/", $string, $matches); + + if (isset($matches[0])) + { + $numberWord = StringHelper::numbers($matches[0]); + $string = str_replace($matches[0], $numberWord, $string); + } + } + + // Transliterate string TODO: look again as this makes it lowercase + // $segment = StringHelper::transliterate($segment); + + // Make sure segment only contains valid characters + return preg_replace("/[^A-Za-z0-9]/", '', $string); } } diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/StringHelper.php b/libraries/jcb_powers/VDM.Joomla/src/Utilities/StringHelper.php index 3a37f2b9a..fad233560 100644 --- a/libraries/jcb_powers/VDM.Joomla/src/Utilities/StringHelper.php +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/StringHelper.php @@ -50,18 +50,18 @@ abstract class StringHelper /** * Shorten a string * - * @input string The you would like to shorten + * @input string The sting that you would like to shorten * * @returns string on success * - * @since 3.0.9 + * @since 3.2.0 */ public static function shorten($string, $length = 40, $addTip = true) { if (self::check($string)) { $initial = strlen((string) $string); - $words = preg_split('/([\s\n\r]+)/', (string) $string, null, PREG_SPLIT_DELIM_CAPTURE); + $words = preg_split('/([\s\n\r]+)/', (string) $string, -1, PREG_SPLIT_DELIM_CAPTURE); $words_count = count((array)$words); $word_length = 0; diff --git a/media/js/admin_custom_tabs.js b/media/js/admin_custom_tabs.js index 215a78d2d..9d6629898 100644 --- a/media/js/admin_custom_tabs.js +++ b/media/js/admin_custom_tabs.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/admin_fields.js b/media/js/admin_fields.js index 215a78d2d..9d6629898 100644 --- a/media/js/admin_fields.js +++ b/media/js/admin_fields.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/admin_fields_conditions.js b/media/js/admin_fields_conditions.js index 848e391d0..53c716c20 100644 --- a/media/js/admin_fields_conditions.js +++ b/media/js/admin_fields_conditions.js @@ -40,4 +40,4 @@ function getFieldSelectOptions(fieldKey){ } } - + diff --git a/media/js/admin_fields_relations.js b/media/js/admin_fields_relations.js index 0856e158b..957ab6c2d 100644 --- a/media/js/admin_fields_relations.js +++ b/media/js/admin_fields_relations.js @@ -73,42 +73,53 @@ function _isSet(val) return false; } -function getEditCustomCodeButtons_server(id){ +function getEditCustomCodeButtons_server(id) { var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id+'&return_here='+return_here; + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); }); } -function getEditCustomCodeButtons(){ - // get the id - id = jQuery("#jform_id").val(); - getEditCustomCodeButtons_server(id).done(function(result) { - if(isObject(result)){ - jQuery.each(result, function( field, buttons ) { - jQuery('
    ').insertBefore(".control-wrapper-"+ field); - jQuery.each(buttons, function( name, button ) { - jQuery(".control-customcode-buttons-"+field).append(button); +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; }); }); } - }) + }).catch(error => { + console.error('Error:', error); + }); } - -// check object is not empty -function isObject(obj) { - for(var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; -} - + diff --git a/media/js/admin_view.js b/media/js/admin_view.js index f431e0e77..90ddf07cd 100644 --- a/media/js/admin_view.js +++ b/media/js/admin_view.js @@ -20,7 +20,7 @@ jform_vvvvwabvwq_required = false; jform_vvvvwabvwr_required = false; // Initial Script -jQuery(document).ready(function() +document.addEventListener('DOMContentLoaded', function() { var add_css_view_vvvvvyw = jQuery("#jform_add_css_view input[type='radio']:checked").val(); vvvvvyw(add_css_view_vvvvvyw); @@ -758,7 +758,7 @@ function vvvvwad(add_custom_button_vvvvwad) // update fields required function updateFieldRequired(name, status) { // check if not_required exist - if (jQuery('#jform_not_required').length > 0) { + if (document.getElementById('jform_not_required')) { var not_required = jQuery('#jform_not_required').val().split(","); if(status == 1) @@ -985,43 +985,54 @@ function getCodeFrom_server(id, type, type_name, callingName) { }); } -function getEditCustomCodeButtons_server(id){ +function getEditCustomCodeButtons_server(id) { var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id+'&return_here='+return_here; + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); }); } -function getEditCustomCodeButtons(){ - // get the id - id = jQuery("#jform_id").val(); - getEditCustomCodeButtons_server(id).done(function(result) { - if(isObject(result)){ - jQuery.each(result, function( field, buttons ) { - jQuery('
    ').insertBefore(".control-wrapper-"+ field); - jQuery.each(buttons, function( name, button ) { - jQuery(".control-customcode-buttons-"+field).append(button); +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; }); }); } - }) -} - -// check object is not empty -function isObject(obj) { - for(var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; + }).catch(error => { + console.error('Error:', error); + }); } function addButtonID_server(type, size){ @@ -1082,4 +1093,4 @@ function getLinked(){ jQuery('#display_linked_to').html(result); } }); -} +} diff --git a/media/js/class_extends.js b/media/js/class_extends.js index 07460eb01..10c2e2aa3 100644 --- a/media/js/class_extends.js +++ b/media/js/class_extends.js @@ -19,41 +19,52 @@ jQuery(document).ready(function() setTimeout(getEditCustomCodeButtons, 300); }); -function getEditCustomCodeButtons_server(id){ +function getEditCustomCodeButtons_server(id) { var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id+'&return_here='+return_here; + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); }); } -function getEditCustomCodeButtons(){ - // get the id - id = jQuery("#jform_id").val(); - getEditCustomCodeButtons_server(id).done(function(result) { - if(isObject(result)){ - jQuery.each(result, function( field, buttons ) { - jQuery('
    ').insertBefore(".control-wrapper-"+ field); - jQuery.each(buttons, function( name, button ) { - jQuery(".control-customcode-buttons-"+field).append(button); +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; }); }); } - }) -} - -// check object is not empty -function isObject(obj) { - for(var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; -} + }).catch(error => { + console.error('Error:', error); + }); +} diff --git a/media/js/class_method.js b/media/js/class_method.js index a30791c12..bf73cebbc 100644 --- a/media/js/class_method.js +++ b/media/js/class_method.js @@ -12,7 +12,7 @@ jform_vvvvwchvxk_required = false; // Initial Script -jQuery(document).ready(function() +document.addEventListener('DOMContentLoaded', function() { var extension_type_vvvvwch = jQuery("#jform_extension_type").val(); vvvvwch(extension_type_vvvvwch); @@ -77,7 +77,7 @@ function extension_type_vvvvwch_SomeFunc(extension_type_vvvvwch) // update fields required function updateFieldRequired(name, status) { // check if not_required exist - if (jQuery('#jform_not_required').length > 0) { + if (document.getElementById('jform_not_required')) { var not_required = jQuery('#jform_not_required').val().split(","); if(status == 1) @@ -134,41 +134,52 @@ jQuery(document).ready(function() setTimeout(getEditCustomCodeButtons, 300); }); -function getEditCustomCodeButtons_server(id){ +function getEditCustomCodeButtons_server(id) { var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id+'&return_here='+return_here; + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); }); } -function getEditCustomCodeButtons(){ - // get the id - id = jQuery("#jform_id").val(); - getEditCustomCodeButtons_server(id).done(function(result) { - if(isObject(result)){ - jQuery.each(result, function( field, buttons ) { - jQuery('
    ').insertBefore(".control-wrapper-"+ field); - jQuery.each(buttons, function( name, button ) { - jQuery(".control-customcode-buttons-"+field).append(button); +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; }); }); } - }) -} - -// check object is not empty -function isObject(obj) { - for(var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; -} + }).catch(error => { + console.error('Error:', error); + }); +} diff --git a/media/js/class_property.js b/media/js/class_property.js index 5a6ecf5fd..27e899048 100644 --- a/media/js/class_property.js +++ b/media/js/class_property.js @@ -12,7 +12,7 @@ jform_vvvvwcgvxj_required = false; // Initial Script -jQuery(document).ready(function() +document.addEventListener('DOMContentLoaded', function() { var extension_type_vvvvwcg = jQuery("#jform_extension_type").val(); vvvvwcg(extension_type_vvvvwcg); @@ -77,7 +77,7 @@ function extension_type_vvvvwcg_SomeFunc(extension_type_vvvvwcg) // update fields required function updateFieldRequired(name, status) { // check if not_required exist - if (jQuery('#jform_not_required').length > 0) { + if (document.getElementById('jform_not_required')) { var not_required = jQuery('#jform_not_required').val().split(","); if(status == 1) @@ -134,41 +134,52 @@ jQuery(document).ready(function() setTimeout(getEditCustomCodeButtons, 300); }); -function getEditCustomCodeButtons_server(id){ +function getEditCustomCodeButtons_server(id) { var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id+'&return_here='+return_here; + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); }); } -function getEditCustomCodeButtons(){ - // get the id - id = jQuery("#jform_id").val(); - getEditCustomCodeButtons_server(id).done(function(result) { - if(isObject(result)){ - jQuery.each(result, function( field, buttons ) { - jQuery('
    ').insertBefore(".control-wrapper-"+ field); - jQuery.each(buttons, function( name, button ) { - jQuery(".control-customcode-buttons-"+field).append(button); +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; }); }); } - }) -} - -// check object is not empty -function isObject(obj) { - for(var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; -} + }).catch(error => { + console.error('Error:', error); + }); +} diff --git a/media/js/component_admin_views.js b/media/js/component_admin_views.js index 215a78d2d..9d6629898 100644 --- a/media/js/component_admin_views.js +++ b/media/js/component_admin_views.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/component_config.js b/media/js/component_config.js index 215a78d2d..9d6629898 100644 --- a/media/js/component_config.js +++ b/media/js/component_config.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/component_custom_admin_menus.js b/media/js/component_custom_admin_menus.js index 215a78d2d..9d6629898 100644 --- a/media/js/component_custom_admin_menus.js +++ b/media/js/component_custom_admin_menus.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/component_custom_admin_views.js b/media/js/component_custom_admin_views.js index 215a78d2d..9d6629898 100644 --- a/media/js/component_custom_admin_views.js +++ b/media/js/component_custom_admin_views.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/component_dashboard.js b/media/js/component_dashboard.js index 47682dec1..cfa526706 100644 --- a/media/js/component_dashboard.js +++ b/media/js/component_dashboard.js @@ -17,41 +17,52 @@ jQuery(document).ready(function() getEditCustomCodeButtons(); }); -function getEditCustomCodeButtons_server(id){ +function getEditCustomCodeButtons_server(id) { var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id+'&return_here='+return_here; + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); }); } -function getEditCustomCodeButtons(){ - // get the id - id = jQuery("#jform_id").val(); - getEditCustomCodeButtons_server(id).done(function(result) { - if(isObject(result)){ - jQuery.each(result, function( field, buttons ) { - jQuery('
    ').insertBefore(".control-wrapper-"+ field); - jQuery.each(buttons, function( name, button ) { - jQuery(".control-customcode-buttons-"+field).append(button); +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; }); }); } - }) -} - -// check object is not empty -function isObject(obj) { - for(var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; -} + }).catch(error => { + console.error('Error:', error); + }); +} diff --git a/media/js/component_files_folders.js b/media/js/component_files_folders.js index 215a78d2d..9d6629898 100644 --- a/media/js/component_files_folders.js +++ b/media/js/component_files_folders.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/component_modules.js b/media/js/component_modules.js index 215a78d2d..9d6629898 100644 --- a/media/js/component_modules.js +++ b/media/js/component_modules.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/component_mysql_tweaks.js b/media/js/component_mysql_tweaks.js index 215a78d2d..9d6629898 100644 --- a/media/js/component_mysql_tweaks.js +++ b/media/js/component_mysql_tweaks.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/component_placeholders.js b/media/js/component_placeholders.js index 215a78d2d..9d6629898 100644 --- a/media/js/component_placeholders.js +++ b/media/js/component_placeholders.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/component_plugins.js b/media/js/component_plugins.js index 215a78d2d..9d6629898 100644 --- a/media/js/component_plugins.js +++ b/media/js/component_plugins.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/component_router.js b/media/js/component_router.js new file mode 100644 index 000000000..ecd8d798e --- /dev/null +++ b/media/js/component_router.js @@ -0,0 +1,67 @@ +/** + * @package Joomla.Component.Builder + * + * @created 30th April, 2015 + * @author Llewellyn van der Merwe + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + + + + +document.addEventListener('DOMContentLoaded', function() { + // check and load all the customcode edit buttons + setTimeout(getEditCustomCodeButtons, 300); +}); + +function getEditCustomCodeButtons_server(id) { + var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; + } + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); + }); +} + +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; + }); + }); + } + }).catch(error => { + console.error('Error:', error); + }); +} diff --git a/media/js/component_site_views.js b/media/js/component_site_views.js index 215a78d2d..9d6629898 100644 --- a/media/js/component_site_views.js +++ b/media/js/component_site_views.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/component_updates.js b/media/js/component_updates.js index 215a78d2d..9d6629898 100644 --- a/media/js/component_updates.js +++ b/media/js/component_updates.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/custom_admin_view.js b/media/js/custom_admin_view.js index baf398a7a..b037b80a2 100644 --- a/media/js/custom_admin_view.js +++ b/media/js/custom_admin_view.js @@ -9,7 +9,7 @@ */ // Initial Script -jQuery(document).ready(function() +document.addEventListener('DOMContentLoaded', function() { var add_php_view_vvvvwae = jQuery("#jform_add_php_view input[type='radio']:checked").val(); vvvvwae(add_php_view_vvvvwae); @@ -397,41 +397,52 @@ function setSnippets(array){ jQuery('#jform_snippet').trigger('liszt:updated'); } -function getEditCustomCodeButtons_server(id){ +function getEditCustomCodeButtons_server(id) { var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id+'&return_here='+return_here; + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); }); } -function getEditCustomCodeButtons(){ - // get the id - id = jQuery("#jform_id").val(); - getEditCustomCodeButtons_server(id).done(function(result) { - if(isObject(result)){ - jQuery.each(result, function( field, buttons ) { - jQuery('
    ').insertBefore(".control-wrapper-"+ field); - jQuery.each(buttons, function( name, button ) { - jQuery(".control-customcode-buttons-"+field).append(button); +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; }); }); } - }) -} - -// check object is not empty -function isObject(obj) { - for(var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; -} + }).catch(error => { + console.error('Error:', error); + }); +} diff --git a/media/js/custom_code.js b/media/js/custom_code.js index e1f5fad84..4184e9c28 100644 --- a/media/js/custom_code.js +++ b/media/js/custom_code.js @@ -15,7 +15,7 @@ jform_vvvvwcdvxh_required = false; jform_vvvvwcdvxi_required = false; // Initial Script -jQuery(document).ready(function() +document.addEventListener('DOMContentLoaded', function() { var target_vvvvwcc = jQuery("#jform_target input[type='radio']:checked").val(); vvvvwcc(target_vvvvwcc); @@ -181,7 +181,7 @@ function vvvvwcf(type_vvvvwcf,target_vvvvwcf) // update fields required function updateFieldRequired(name, status) { // check if not_required exist - if (jQuery('#jform_not_required').length > 0) { + if (document.getElementById('jform_not_required')) { var not_required = jQuery('#jform_not_required').val().split(","); if(status == 1) @@ -372,41 +372,52 @@ function usedin_server(functioName, ide, target){ } -function getEditCustomCodeButtons_server(id){ +function getEditCustomCodeButtons_server(id) { var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id+'&return_here='+return_here; + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); }); } -function getEditCustomCodeButtons(){ - // get the id - id = jQuery("#jform_id").val(); - getEditCustomCodeButtons_server(id).done(function(result) { - if(isObject(result)){ - jQuery.each(result, function( field, buttons ) { - jQuery('
    ').insertBefore(".control-wrapper-"+ field); - jQuery.each(buttons, function( name, button ) { - jQuery(".control-customcode-buttons-"+field).append(button); +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; }); }); } - }) -} - -// check object is not empty -function isObject(obj) { - for(var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; -} + }).catch(error => { + console.error('Error:', error); + }); +} diff --git a/media/js/dynamic_get.js b/media/js/dynamic_get.js index d473cc4e8..5553fcedf 100644 --- a/media/js/dynamic_get.js +++ b/media/js/dynamic_get.js @@ -24,7 +24,7 @@ jform_vvvvwbyvxd_required = false; jform_vvvvwbzvxe_required = false; // Initial Script -jQuery(document).ready(function() +document.addEventListener('DOMContentLoaded', function() { var gettype_vvvvwbb = jQuery("#jform_gettype").val(); vvvvwbb(gettype_vvvvwbb); @@ -1352,7 +1352,7 @@ function gettype_vvvvwcb_SomeFunc(gettype_vvvvwcb) // update fields required function updateFieldRequired(name, status) { // check if not_required exist - if (jQuery('#jform_not_required').length > 0) { + if (document.getElementById('jform_not_required')) { var not_required = jQuery('#jform_not_required').val().split(","); if(status == 1) @@ -1609,43 +1609,54 @@ function getCodeFrom_server(id, type, type_name, callingName) { }); } -function getEditCustomCodeButtons_server(id){ +function getEditCustomCodeButtons_server(id) { var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id+'&return_here='+return_here; + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); }); } -function getEditCustomCodeButtons(){ - // get the id - id = jQuery("#jform_id").val(); - getEditCustomCodeButtons_server(id).done(function(result) { - if(isObject(result)){ - jQuery.each(result, function( field, buttons ) { - jQuery('
    ').insertBefore(".control-wrapper-"+ field); - jQuery.each(buttons, function( name, button ) { - jQuery(".control-customcode-buttons-"+field).append(button); +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; }); }); } - }) -} - -// check object is not empty -function isObject(obj) { - for(var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; + }).catch(error => { + console.error('Error:', error); + }); } function getLinked(){ @@ -1654,4 +1665,4 @@ function getLinked(){ jQuery('#display_linked_to').html(result); } }); -} +} diff --git a/media/js/field.js b/media/js/field.js index b004eee22..1510e6f01 100644 --- a/media/js/field.js +++ b/media/js/field.js @@ -17,7 +17,7 @@ jform_vvvvwdgvxs_required = false; jform_vvvvwdgvxt_required = false; // Initial Script -jQuery(document).ready(function() +document.addEventListener('DOMContentLoaded', function() { var datalenght_vvvvwda = jQuery("#jform_datalenght").val(); vvvvwda(datalenght_vvvvwda); @@ -479,7 +479,7 @@ function vvvvwdk(add_javascript_views_footer_vvvvwdk) // update fields required function updateFieldRequired(name, status) { // check if not_required exist - if (jQuery('#jform_not_required').length > 0) { + if (document.getElementById('jform_not_required')) { var not_required = jQuery('#jform_not_required').val().split(","); if(status == 1) @@ -881,41 +881,52 @@ function addButton(type, where, size){ }) } -function getEditCustomCodeButtons_server(id){ +function getEditCustomCodeButtons_server(id) { var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id+'&return_here='+return_here; + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); }); } -function getEditCustomCodeButtons(){ - // get the id - id = jQuery("#jform_id").val(); - getEditCustomCodeButtons_server(id).done(function(result) { - if(isObject(result)){ - jQuery.each(result, function( field, buttons ) { - jQuery('
    ').insertBefore(".control-wrapper-"+ field); - jQuery.each(buttons, function( name, button ) { - jQuery(".control-customcode-buttons-"+field).append(button); +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; }); }); } - }) -} - -// check object is not empty -function isObject(obj) { - for(var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; -} + }).catch(error => { + console.error('Error:', error); + }); +} diff --git a/media/js/fieldtype.js b/media/js/fieldtype.js index be9fab32c..df059058b 100644 --- a/media/js/fieldtype.js +++ b/media/js/fieldtype.js @@ -19,7 +19,7 @@ jform_vvvvwdyvya_required = false; jform_vvvvwdyvyb_required = false; // Initial Script -jQuery(document).ready(function() +document.addEventListener('DOMContentLoaded', function() { var datalenght_vvvvwdl = jQuery("#jform_datalenght").val(); var has_defaults_vvvvwdl = jQuery("#jform_has_defaults input[type='radio']:checked").val(); @@ -849,7 +849,7 @@ function vvvvwdy(has_defaults_vvvvwdy) // update fields required function updateFieldRequired(name, status) { // check if not_required exist - if (jQuery('#jform_not_required').length > 0) { + if (document.getElementById('jform_not_required')) { var not_required = jQuery('#jform_not_required').val().split(","); if(status == 1) @@ -904,41 +904,52 @@ jQuery(document).ready(function($) getEditCustomCodeButtons(); }); -function getEditCustomCodeButtons_server(id){ +function getEditCustomCodeButtons_server(id) { var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id+'&return_here='+return_here; + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); }); } -function getEditCustomCodeButtons(){ - // get the id - id = jQuery("#jform_id").val(); - getEditCustomCodeButtons_server(id).done(function(result) { - if(isObject(result)){ - jQuery.each(result, function( field, buttons ) { - jQuery('
    ').insertBefore(".control-wrapper-"+ field); - jQuery.each(buttons, function( name, button ) { - jQuery(".control-customcode-buttons-"+field).append(button); +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; }); }); } - }) -} - -// check object is not empty -function isObject(obj) { - for(var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; -} + }).catch(error => { + console.error('Error:', error); + }); +} diff --git a/media/js/help_document.js b/media/js/help_document.js index bbb326f91..f30a100ab 100644 --- a/media/js/help_document.js +++ b/media/js/help_document.js @@ -16,7 +16,7 @@ jform_vvvvwemvyq_required = false; jform_vvvvweovyr_required = false; // Initial Script -jQuery(document).ready(function() +document.addEventListener('DOMContentLoaded', function() { var location_vvvvwej = jQuery("#jform_location input[type='radio']:checked").val(); vvvvwej(location_vvvvwej); @@ -286,7 +286,7 @@ function vvvvweo(target_vvvvweo) // update fields required function updateFieldRequired(name, status) { // check if not_required exist - if (jQuery('#jform_not_required').length > 0) { + if (document.getElementById('jform_not_required')) { var not_required = jQuery('#jform_not_required').val().split(","); if(status == 1) @@ -332,4 +332,4 @@ function isSet(val) return true; } return false; -} +} diff --git a/media/js/joomla_component.js b/media/js/joomla_component.js index 95c37ed75..d478dba84 100644 --- a/media/js/joomla_component.js +++ b/media/js/joomla_component.js @@ -19,7 +19,7 @@ jform_vvvvvxavwb_required = false; jform_vvvvvxavwc_required = false; // Initial Script -jQuery(document).ready(function() +document.addEventListener('DOMContentLoaded', function() { var add_php_helper_admin_vvvvvvv = jQuery("#jform_add_php_helper_admin input[type='radio']:checked").val(); vvvvvvv(add_php_helper_admin_vvvvvvv); @@ -729,7 +729,7 @@ function translation_tool_vvvvvxa_SomeFunc(translation_tool_vvvvvxa) // update fields required function updateFieldRequired(name, status) { // check if not_required exist - if (jQuery('#jform_not_required').length > 0) { + if (document.getElementById('jform_not_required')) { var not_required = jQuery('#jform_not_required').val().split(","); if(status == 1) @@ -913,43 +913,54 @@ function dasboardSwitch(value){ } -function getEditCustomCodeButtons_server(id){ +function getEditCustomCodeButtons_server(id) { var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id+'&return_here='+return_here; + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); }); } -function getEditCustomCodeButtons(){ - // get the id - id = jQuery("#jform_id").val(); - getEditCustomCodeButtons_server(id).done(function(result) { - if(isObject(result)){ - jQuery.each(result, function( field, buttons ) { - jQuery('
    ').insertBefore(".control-wrapper-"+ field); - jQuery.each(buttons, function( name, button ) { - jQuery(".control-customcode-buttons-"+field).append(button); +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; }); }); } - }) -} - -// check object is not empty -function isObject(obj) { - for(var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; + }).catch(error => { + console.error('Error:', error); + }); } function addButtonID_server(type, size){ @@ -1002,4 +1013,4 @@ function addButton(type, where, size){ } } }) -} +} diff --git a/media/js/joomla_module.js b/media/js/joomla_module.js index d10ae51e8..1a3ccea7b 100644 --- a/media/js/joomla_module.js +++ b/media/js/joomla_module.js @@ -14,7 +14,7 @@ jform_vvvvvxsvwe_required = false; jform_vvvvvxtvwf_required = false; // Initial Script -jQuery(document).ready(function() +document.addEventListener('DOMContentLoaded', function() { var add_class_helper_vvvvvxb = jQuery("#jform_add_class_helper").val(); vvvvvxb(add_class_helper_vvvvvxb); @@ -479,7 +479,7 @@ function vvvvvxw(addreadme_vvvvvxw) // update fields required function updateFieldRequired(name, status) { // check if not_required exist - if (jQuery('#jform_not_required').length > 0) { + if (document.getElementById('jform_not_required')) { var not_required = jQuery('#jform_not_required').val().split(","); if(status == 1) @@ -672,43 +672,54 @@ function removeCodeFromEditor(code_string, editor_id){ } -function getEditCustomCodeButtons_server(id){ +function getEditCustomCodeButtons_server(id) { var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id+'&return_here='+return_here; + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); }); } -function getEditCustomCodeButtons(){ - // get the id - id = jQuery("#jform_id").val(); - getEditCustomCodeButtons_server(id).done(function(result) { - if(isObject(result)){ - jQuery.each(result, function( field, buttons ) { - jQuery('
    ').insertBefore(".control-wrapper-"+ field); - jQuery.each(buttons, function( name, button ) { - jQuery(".control-customcode-buttons-"+field).append(button); +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; }); }); } - }) -} - -// check object is not empty -function isObject(obj) { - for(var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; + }).catch(error => { + console.error('Error:', error); + }); } function getSnippetDetails(id){ @@ -803,4 +814,4 @@ function setSnippets(array){ jQuery('#jform_snippet').append(''); } jQuery('#jform_snippet').trigger('liszt:updated'); -} +} diff --git a/media/js/joomla_module_files_folders_urls.js b/media/js/joomla_module_files_folders_urls.js index 215a78d2d..9d6629898 100644 --- a/media/js/joomla_module_files_folders_urls.js +++ b/media/js/joomla_module_files_folders_urls.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/joomla_module_updates.js b/media/js/joomla_module_updates.js index 215a78d2d..9d6629898 100644 --- a/media/js/joomla_module_updates.js +++ b/media/js/joomla_module_updates.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/joomla_plugin.js b/media/js/joomla_plugin.js index 1c5636934..29ea9bbc6 100644 --- a/media/js/joomla_plugin.js +++ b/media/js/joomla_plugin.js @@ -14,7 +14,7 @@ jform_vvvvvyqvwh_required = false; jform_vvvvvyrvwi_required = false; // Initial Script -jQuery(document).ready(function() +document.addEventListener('DOMContentLoaded', function() { var class_extends_vvvvvxx = jQuery("#jform_class_extends").val(); var joomla_plugin_group_vvvvvxx = jQuery("#jform_joomla_plugin_group").val(); @@ -615,7 +615,7 @@ function vvvvvyu(addreadme_vvvvvyu) // update fields required function updateFieldRequired(name, status) { // check if not_required exist - if (jQuery('#jform_not_required').length > 0) { + if (document.getElementById('jform_not_required')) { var not_required = jQuery('#jform_not_required').val().split(","); if(status == 1) @@ -1099,41 +1099,52 @@ function getLinked(){ }); } -function getEditCustomCodeButtons_server(id){ +function getEditCustomCodeButtons_server(id) { var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id+'&return_here='+return_here; + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); }); } -function getEditCustomCodeButtons(){ - // get the id - id = jQuery("#jform_id").val(); - getEditCustomCodeButtons_server(id).done(function(result) { - if(isObject(result)){ - jQuery.each(result, function( field, buttons ) { - jQuery('
    ').insertBefore(".control-wrapper-"+ field); - jQuery.each(buttons, function( name, button ) { - jQuery(".control-customcode-buttons-"+field).append(button); +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; }); }); } - }) -} - -// check object is not empty -function isObject(obj) { - for(var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; -} + }).catch(error => { + console.error('Error:', error); + }); +} diff --git a/media/js/joomla_plugin_files_folders_urls.js b/media/js/joomla_plugin_files_folders_urls.js index 215a78d2d..9d6629898 100644 --- a/media/js/joomla_plugin_files_folders_urls.js +++ b/media/js/joomla_plugin_files_folders_urls.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/joomla_plugin_group.js b/media/js/joomla_plugin_group.js index 215a78d2d..9d6629898 100644 --- a/media/js/joomla_plugin_group.js +++ b/media/js/joomla_plugin_group.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/joomla_plugin_updates.js b/media/js/joomla_plugin_updates.js index 215a78d2d..9d6629898 100644 --- a/media/js/joomla_plugin_updates.js +++ b/media/js/joomla_plugin_updates.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/language.js b/media/js/language.js index 215a78d2d..9d6629898 100644 --- a/media/js/language.js +++ b/media/js/language.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/language_translation.js b/media/js/language_translation.js index 4cd0acc5e..30c301cc7 100644 --- a/media/js/language_translation.js +++ b/media/js/language_translation.js @@ -45,4 +45,4 @@ function addButton(type, where, size){ } } }) -} +} diff --git a/media/js/layout.js b/media/js/layout.js index c896419d6..248512c9f 100644 --- a/media/js/layout.js +++ b/media/js/layout.js @@ -9,7 +9,7 @@ */ // Initial Script -jQuery(document).ready(function() +document.addEventListener('DOMContentLoaded', function() { var add_php_view_vvvvwba = jQuery("#jform_add_php_view input[type='radio']:checked").val(); vvvvwba(add_php_view_vvvvwba); @@ -69,43 +69,54 @@ function getCodeFrom_server(id, type, type_name, callingName) { }); } -function getEditCustomCodeButtons_server(id){ +function getEditCustomCodeButtons_server(id) { var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id+'&return_here='+return_here; + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); }); } -function getEditCustomCodeButtons(){ - // get the id - id = jQuery("#jform_id").val(); - getEditCustomCodeButtons_server(id).done(function(result) { - if(isObject(result)){ - jQuery.each(result, function( field, buttons ) { - jQuery('
    ').insertBefore(".control-wrapper-"+ field); - jQuery.each(buttons, function( name, button ) { - jQuery(".control-customcode-buttons-"+field).append(button); +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; }); }); } - }) -} - -// check object is not empty -function isObject(obj) { - for(var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; + }).catch(error => { + console.error('Error:', error); + }); } function getSnippetDetails(id){ @@ -253,4 +264,4 @@ function setSnippets(array){ jQuery('#jform_snippet').append(''); } jQuery('#jform_snippet').trigger('liszt:updated'); -} +} diff --git a/media/js/library.js b/media/js/library.js index 72351e245..a7127b710 100644 --- a/media/js/library.js +++ b/media/js/library.js @@ -14,7 +14,7 @@ jform_vvvvwcyvxm_required = false; jform_vvvvwcyvxn_required = false; // Initial Script -jQuery(document).ready(function() +document.addEventListener('DOMContentLoaded', function() { var how_vvvvwci = jQuery("#jform_how").val(); var target_vvvvwci = jQuery("#jform_target input[type='radio']:checked").val(); @@ -798,7 +798,7 @@ function vvvvwcz(target_vvvvwcz) // update fields required function updateFieldRequired(name, status) { // check if not_required exist - if (jQuery('#jform_not_required').length > 0) { + if (document.getElementById('jform_not_required')) { var not_required = jQuery('#jform_not_required').val().split(","); if(status == 1) @@ -911,43 +911,54 @@ function getCodeFrom_server(id, type, type_name, callingName) { }); } -function getEditCustomCodeButtons_server(id){ +function getEditCustomCodeButtons_server(id) { var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id+'&return_here='+return_here; + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); }); } -function getEditCustomCodeButtons(){ - // get the id - id = jQuery("#jform_id").val(); - getEditCustomCodeButtons_server(id).done(function(result) { - if(isObject(result)){ - jQuery.each(result, function( field, buttons ) { - jQuery('
    ').insertBefore(".control-wrapper-"+ field); - jQuery.each(buttons, function( name, button ) { - jQuery(".control-customcode-buttons-"+field).append(button); +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; }); }); } - }) -} - -// check object is not empty -function isObject(obj) { - for(var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; + }).catch(error => { + console.error('Error:', error); + }); } function addButtonID_server(type, size){ @@ -1008,4 +1019,4 @@ function getLinked(){ jQuery('#display_linked_to').html(result); } }); -} +} diff --git a/media/js/library_config.js b/media/js/library_config.js index 215a78d2d..9d6629898 100644 --- a/media/js/library_config.js +++ b/media/js/library_config.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/library_files_folders_urls.js b/media/js/library_files_folders_urls.js index 215a78d2d..9d6629898 100644 --- a/media/js/library_files_folders_urls.js +++ b/media/js/library_files_folders_urls.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/placeholder.js b/media/js/placeholder.js index 0786da5b5..268b44dd7 100644 --- a/media/js/placeholder.js +++ b/media/js/placeholder.js @@ -120,4 +120,4 @@ function placedin_server(placeholder, ide, target){ jsonp: false }); } - + diff --git a/media/js/power.js b/media/js/power.js index 097fc4c67..c88562ce3 100644 --- a/media/js/power.js +++ b/media/js/power.js @@ -9,7 +9,7 @@ */ // Initial Script -jQuery(document).ready(function() +document.addEventListener('DOMContentLoaded', function() { var add_head_vvvvvyv = jQuery("#jform_add_head input[type='radio']:checked").val(); vvvvvyv(add_head_vvvvvyv); @@ -39,8 +39,7 @@ function isSet(val) } -jQuery(document).ready(function() -{ +document.addEventListener('DOMContentLoaded', function() { // get the linked details getLinked(); // load the active array values @@ -473,41 +472,52 @@ function getLinked(){ }); } -function getEditCustomCodeButtons_server(id){ +function getEditCustomCodeButtons_server(id) { var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id+'&return_here='+return_here; + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); }); } -function getEditCustomCodeButtons(){ - // get the id - id = jQuery("#jform_id").val(); - getEditCustomCodeButtons_server(id).done(function(result) { - if(isObject(result)){ - jQuery.each(result, function( field, buttons ) { - jQuery('
    ').insertBefore(".control-wrapper-"+ field); - jQuery.each(buttons, function( name, button ) { - jQuery(".control-customcode-buttons-"+field).append(button); +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; }); }); } - }) -} - -// check object is not empty -function isObject(obj) { - for(var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; -} + }).catch(error => { + console.error('Error:', error); + }); +} diff --git a/media/js/server.js b/media/js/server.js index 7b3e1011e..48e95447e 100644 --- a/media/js/server.js +++ b/media/js/server.js @@ -20,7 +20,7 @@ jform_vvvvwedvyk_required = false; jform_vvvvwefvyl_required = false; // Initial Script -jQuery(document).ready(function() +document.addEventListener('DOMContentLoaded', function() { var protocol_vvvvwdz = jQuery("#jform_protocol").val(); vvvvwdz(protocol_vvvvwdz); @@ -542,7 +542,7 @@ function authentication_vvvvweh_SomeFunc(authentication_vvvvweh) // update fields required function updateFieldRequired(name, status) { // check if not_required exist - if (jQuery('#jform_not_required').length > 0) { + if (document.getElementById('jform_not_required')) { var not_required = jQuery('#jform_not_required').val().split(","); if(status == 1) @@ -588,4 +588,4 @@ function isSet(val) return true; } return false; -} +} diff --git a/media/js/site_view.js b/media/js/site_view.js index 5dba68d7e..2d9bd9602 100644 --- a/media/js/site_view.js +++ b/media/js/site_view.js @@ -9,7 +9,7 @@ */ // Initial Script -jQuery(document).ready(function() +document.addEventListener('DOMContentLoaded', function() { var add_php_view_vvvvwao = jQuery("#jform_add_php_view input[type='radio']:checked").val(); vvvvwao(add_php_view_vvvvwao); @@ -438,41 +438,52 @@ function setSnippets(array){ jQuery('#jform_snippet').trigger('liszt:updated'); } -function getEditCustomCodeButtons_server(id){ +function getEditCustomCodeButtons_server(id) { var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id+'&return_here='+return_here; + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); }); } -function getEditCustomCodeButtons(){ - // get the id - id = jQuery("#jform_id").val(); - getEditCustomCodeButtons_server(id).done(function(result) { - if(isObject(result)){ - jQuery.each(result, function( field, buttons ) { - jQuery('
    ').insertBefore(".control-wrapper-"+ field); - jQuery.each(buttons, function( name, button ) { - jQuery(".control-customcode-buttons-"+field).append(button); +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; }); }); } - }) -} - -// check object is not empty -function isObject(obj) { - for(var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; -} + }).catch(error => { + console.error('Error:', error); + }); +} diff --git a/media/js/snippet.js b/media/js/snippet.js index 215a78d2d..9d6629898 100644 --- a/media/js/snippet.js +++ b/media/js/snippet.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/snippet_type.js b/media/js/snippet_type.js index 215a78d2d..9d6629898 100644 --- a/media/js/snippet_type.js +++ b/media/js/snippet_type.js @@ -8,4 +8,4 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ - + diff --git a/media/js/template.js b/media/js/template.js index 0329e650f..80e91901d 100644 --- a/media/js/template.js +++ b/media/js/template.js @@ -9,7 +9,7 @@ */ // Initial Script -jQuery(document).ready(function() +document.addEventListener('DOMContentLoaded', function() { var add_php_view_vvvvwaz = jQuery("#jform_add_php_view input[type='radio']:checked").val(); vvvvwaz(add_php_view_vvvvwaz); @@ -69,43 +69,54 @@ function getCodeFrom_server(id, type, type_name, callingName) { }); } -function getEditCustomCodeButtons_server(id){ +function getEditCustomCodeButtons_server(id) { var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id+'&return_here='+return_here; + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); }); } -function getEditCustomCodeButtons(){ - // get the id - id = jQuery("#jform_id").val(); - getEditCustomCodeButtons_server(id).done(function(result) { - if(isObject(result)){ - jQuery.each(result, function( field, buttons ) { - jQuery('
    ').insertBefore(".control-wrapper-"+ field); - jQuery.each(buttons, function( name, button ) { - jQuery(".control-customcode-buttons-"+field).append(button); +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; }); }); } - }) -} - -// check object is not empty -function isObject(obj) { - for(var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; + }).catch(error => { + console.error('Error:', error); + }); } function getSnippetDetails(id){ @@ -265,4 +276,4 @@ function setSnippets(array){ jQuery('#jform_snippet').append(''); } jQuery('#jform_snippet').trigger('liszt:updated'); -} +} diff --git a/media/js/validation_rule.js b/media/js/validation_rule.js index 1f8888340..252b004ad 100644 --- a/media/js/validation_rule.js +++ b/media/js/validation_rule.js @@ -97,41 +97,52 @@ function checkRuleName_server(ruleName, ide){ }); } -function getEditCustomCodeButtons_server(id){ +function getEditCustomCodeButtons_server(id) { var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getEditCustomCodeButtons&format=json&raw=true&vdm="+vastDevMod); - if(token.length > 0 && id > 0){ - var request = token+'=1&id='+id+'&return_here='+return_here; + let requestParams = ''; + if (token.length > 0 && id > 0) { + requestParams = token+'=1&id='+id+'&return_here='+return_here; } - return jQuery.ajax({ - type: 'GET', - url: getUrl, - dataType: 'json', - data: request, - jsonp: false + // Construct URL with parameters for GET request + const urlWithParams = getUrl + '&' + requestParams; + + // Using the Fetch API for the GET request + return fetch(urlWithParams, { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }).then(response => { + if (!response.ok) { + throw new Error('Network response was not ok'); + } + return response.json(); }); } -function getEditCustomCodeButtons(){ - // get the id - id = jQuery("#jform_id").val(); - getEditCustomCodeButtons_server(id).done(function(result) { - if(isObject(result)){ - jQuery.each(result, function( field, buttons ) { - jQuery('
    ').insertBefore(".control-wrapper-"+ field); - jQuery.each(buttons, function( name, button ) { - jQuery(".control-customcode-buttons-"+field).append(button); +function getEditCustomCodeButtons() { + // Get the id using pure JavaScript + const id = document.querySelector("#jform_id").value; + getEditCustomCodeButtons_server(id).then(function(result) { + if (typeof result === 'object') { + Object.entries(result).forEach(([field, buttons]) => { + // Creating the div element for buttons + const div = document.createElement('div'); + div.className = 'control-group'; + div.innerHTML = '
    '; + + // Insert the div before .control-wrapper-{field} + const insertBeforeElement = document.querySelector(".control-wrapper-"+field); + insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement); + + // Adding buttons to the div + Object.entries(buttons).forEach(([name, button]) => { + const controlsDiv = document.querySelector(".control-customcode-buttons-"+field); + controlsDiv.innerHTML += button; }); }); } - }) -} - -// check object is not empty -function isObject(obj) { - for(var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; -} + }).catch(error => { + console.error('Error:', error); + }); +} diff --git a/script.php b/script.php deleted file mode 100644 index 2ea76bcb8..000000000 --- a/script.php +++ /dev/null @@ -1,11235 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\Filesystem\File; -use Joomla\CMS\Filesystem\Folder; -use Joomla\CMS\Installer\Adapter\ComponentAdapter; -use VDM\Joomla\FOF\Encrypt\AES; -use VDM\Joomla\Utilities\StringHelper; -use VDM\Joomla\Utilities\JsonHelper; -use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\GetHelper; -JHTML::_('bootstrap.renderModal'); - -/** - * Script File of Componentbuilder Component - */ -class com_componentbuilderInstallerScript -{ - /** - * Constructor - * - * @param JAdapterInstance $parent The object responsible for running this script - */ - public function __construct(ComponentAdapter $parent) {} - - /** - * Called on installation - * - * @param ComponentAdapter $parent The object responsible for running this script - * - * @return boolean True on success - */ - public function install(ComponentAdapter $parent) {} - - /** - * Called on uninstallation - * - * @param ComponentAdapter $parent The object responsible for running this script - */ - public function uninstall(ComponentAdapter $parent) - { - // Get Application object - $app = JFactory::getApplication(); - - // Get The Database object - $db = JFactory::getDbo(); - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Joomla_component alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_component') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $joomla_component_found = $db->getNumRows(); - // Now check if there were any rows - if ($joomla_component_found) - { - // Since there are load the needed joomla_component type ids - $joomla_component_ids = $db->loadColumn(); - // Remove Joomla_component from the content type table - $joomla_component_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_component') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($joomla_component_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_component items - $joomla_component_done = $db->execute(); - if ($joomla_component_done) - { - // If successfully remove Joomla_component add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_component) type alias was removed from the #__content_type table')); - } - - // Remove Joomla_component items from the contentitem tag map table - $joomla_component_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_component') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($joomla_component_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_component items - $joomla_component_done = $db->execute(); - if ($joomla_component_done) - { - // If successfully remove Joomla_component add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_component) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Joomla_component items from the ucm content table - $joomla_component_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.joomla_component') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($joomla_component_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_component items - $joomla_component_done = $db->execute(); - if ($joomla_component_done) - { - // If successfully removed Joomla_component add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_component) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Joomla_component items are cleared from DB - foreach ($joomla_component_ids as $joomla_component_id) - { - // Remove Joomla_component items from the ucm base table - $joomla_component_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_component_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($joomla_component_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_component items - $db->execute(); - - // Remove Joomla_component items from the ucm history table - $joomla_component_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_component_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($joomla_component_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_component items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Joomla_module alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_module') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $joomla_module_found = $db->getNumRows(); - // Now check if there were any rows - if ($joomla_module_found) - { - // Since there are load the needed joomla_module type ids - $joomla_module_ids = $db->loadColumn(); - // Remove Joomla_module from the content type table - $joomla_module_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_module') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($joomla_module_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_module items - $joomla_module_done = $db->execute(); - if ($joomla_module_done) - { - // If successfully remove Joomla_module add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_module) type alias was removed from the #__content_type table')); - } - - // Remove Joomla_module items from the contentitem tag map table - $joomla_module_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_module') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($joomla_module_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_module items - $joomla_module_done = $db->execute(); - if ($joomla_module_done) - { - // If successfully remove Joomla_module add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_module) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Joomla_module items from the ucm content table - $joomla_module_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.joomla_module') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($joomla_module_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_module items - $joomla_module_done = $db->execute(); - if ($joomla_module_done) - { - // If successfully removed Joomla_module add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_module) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Joomla_module items are cleared from DB - foreach ($joomla_module_ids as $joomla_module_id) - { - // Remove Joomla_module items from the ucm base table - $joomla_module_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_module_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($joomla_module_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_module items - $db->execute(); - - // Remove Joomla_module items from the ucm history table - $joomla_module_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_module_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($joomla_module_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_module items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Joomla_plugin alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_plugin') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $joomla_plugin_found = $db->getNumRows(); - // Now check if there were any rows - if ($joomla_plugin_found) - { - // Since there are load the needed joomla_plugin type ids - $joomla_plugin_ids = $db->loadColumn(); - // Remove Joomla_plugin from the content type table - $joomla_plugin_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_plugin') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($joomla_plugin_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_plugin items - $joomla_plugin_done = $db->execute(); - if ($joomla_plugin_done) - { - // If successfully remove Joomla_plugin add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_plugin) type alias was removed from the #__content_type table')); - } - - // Remove Joomla_plugin items from the contentitem tag map table - $joomla_plugin_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_plugin') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($joomla_plugin_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_plugin items - $joomla_plugin_done = $db->execute(); - if ($joomla_plugin_done) - { - // If successfully remove Joomla_plugin add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_plugin) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Joomla_plugin items from the ucm content table - $joomla_plugin_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.joomla_plugin') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($joomla_plugin_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_plugin items - $joomla_plugin_done = $db->execute(); - if ($joomla_plugin_done) - { - // If successfully removed Joomla_plugin add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_plugin) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Joomla_plugin items are cleared from DB - foreach ($joomla_plugin_ids as $joomla_plugin_id) - { - // Remove Joomla_plugin items from the ucm base table - $joomla_plugin_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_plugin_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($joomla_plugin_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_plugin items - $db->execute(); - - // Remove Joomla_plugin items from the ucm history table - $joomla_plugin_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_plugin_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($joomla_plugin_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_plugin items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Power alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.power') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $power_found = $db->getNumRows(); - // Now check if there were any rows - if ($power_found) - { - // Since there are load the needed power type ids - $power_ids = $db->loadColumn(); - // Remove Power from the content type table - $power_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.power') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($power_condition); - $db->setQuery($query); - // Execute the query to remove Power items - $power_done = $db->execute(); - if ($power_done) - { - // If successfully remove Power add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.power) type alias was removed from the #__content_type table')); - } - - // Remove Power items from the contentitem tag map table - $power_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.power') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($power_condition); - $db->setQuery($query); - // Execute the query to remove Power items - $power_done = $db->execute(); - if ($power_done) - { - // If successfully remove Power add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.power) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Power items from the ucm content table - $power_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.power') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($power_condition); - $db->setQuery($query); - // Execute the query to remove Power items - $power_done = $db->execute(); - if ($power_done) - { - // If successfully removed Power add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.power) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Power items are cleared from DB - foreach ($power_ids as $power_id) - { - // Remove Power items from the ucm base table - $power_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $power_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($power_condition); - $db->setQuery($query); - // Execute the query to remove Power items - $db->execute(); - - // Remove Power items from the ucm history table - $power_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $power_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($power_condition); - $db->setQuery($query); - // Execute the query to remove Power items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Admin_view alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_view') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $admin_view_found = $db->getNumRows(); - // Now check if there were any rows - if ($admin_view_found) - { - // Since there are load the needed admin_view type ids - $admin_view_ids = $db->loadColumn(); - // Remove Admin_view from the content type table - $admin_view_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_view') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($admin_view_condition); - $db->setQuery($query); - // Execute the query to remove Admin_view items - $admin_view_done = $db->execute(); - if ($admin_view_done) - { - // If successfully remove Admin_view add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.admin_view) type alias was removed from the #__content_type table')); - } - - // Remove Admin_view items from the contentitem tag map table - $admin_view_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_view') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($admin_view_condition); - $db->setQuery($query); - // Execute the query to remove Admin_view items - $admin_view_done = $db->execute(); - if ($admin_view_done) - { - // If successfully remove Admin_view add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.admin_view) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Admin_view items from the ucm content table - $admin_view_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.admin_view') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($admin_view_condition); - $db->setQuery($query); - // Execute the query to remove Admin_view items - $admin_view_done = $db->execute(); - if ($admin_view_done) - { - // If successfully removed Admin_view add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.admin_view) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Admin_view items are cleared from DB - foreach ($admin_view_ids as $admin_view_id) - { - // Remove Admin_view items from the ucm base table - $admin_view_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $admin_view_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($admin_view_condition); - $db->setQuery($query); - // Execute the query to remove Admin_view items - $db->execute(); - - // Remove Admin_view items from the ucm history table - $admin_view_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $admin_view_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($admin_view_condition); - $db->setQuery($query); - // Execute the query to remove Admin_view items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Custom_admin_view alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.custom_admin_view') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $custom_admin_view_found = $db->getNumRows(); - // Now check if there were any rows - if ($custom_admin_view_found) - { - // Since there are load the needed custom_admin_view type ids - $custom_admin_view_ids = $db->loadColumn(); - // Remove Custom_admin_view from the content type table - $custom_admin_view_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.custom_admin_view') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($custom_admin_view_condition); - $db->setQuery($query); - // Execute the query to remove Custom_admin_view items - $custom_admin_view_done = $db->execute(); - if ($custom_admin_view_done) - { - // If successfully remove Custom_admin_view add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.custom_admin_view) type alias was removed from the #__content_type table')); - } - - // Remove Custom_admin_view items from the contentitem tag map table - $custom_admin_view_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.custom_admin_view') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($custom_admin_view_condition); - $db->setQuery($query); - // Execute the query to remove Custom_admin_view items - $custom_admin_view_done = $db->execute(); - if ($custom_admin_view_done) - { - // If successfully remove Custom_admin_view add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.custom_admin_view) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Custom_admin_view items from the ucm content table - $custom_admin_view_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.custom_admin_view') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($custom_admin_view_condition); - $db->setQuery($query); - // Execute the query to remove Custom_admin_view items - $custom_admin_view_done = $db->execute(); - if ($custom_admin_view_done) - { - // If successfully removed Custom_admin_view add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.custom_admin_view) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Custom_admin_view items are cleared from DB - foreach ($custom_admin_view_ids as $custom_admin_view_id) - { - // Remove Custom_admin_view items from the ucm base table - $custom_admin_view_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $custom_admin_view_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($custom_admin_view_condition); - $db->setQuery($query); - // Execute the query to remove Custom_admin_view items - $db->execute(); - - // Remove Custom_admin_view items from the ucm history table - $custom_admin_view_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $custom_admin_view_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($custom_admin_view_condition); - $db->setQuery($query); - // Execute the query to remove Custom_admin_view items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Site_view alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.site_view') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $site_view_found = $db->getNumRows(); - // Now check if there were any rows - if ($site_view_found) - { - // Since there are load the needed site_view type ids - $site_view_ids = $db->loadColumn(); - // Remove Site_view from the content type table - $site_view_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.site_view') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($site_view_condition); - $db->setQuery($query); - // Execute the query to remove Site_view items - $site_view_done = $db->execute(); - if ($site_view_done) - { - // If successfully remove Site_view add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.site_view) type alias was removed from the #__content_type table')); - } - - // Remove Site_view items from the contentitem tag map table - $site_view_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.site_view') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($site_view_condition); - $db->setQuery($query); - // Execute the query to remove Site_view items - $site_view_done = $db->execute(); - if ($site_view_done) - { - // If successfully remove Site_view add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.site_view) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Site_view items from the ucm content table - $site_view_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.site_view') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($site_view_condition); - $db->setQuery($query); - // Execute the query to remove Site_view items - $site_view_done = $db->execute(); - if ($site_view_done) - { - // If successfully removed Site_view add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.site_view) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Site_view items are cleared from DB - foreach ($site_view_ids as $site_view_id) - { - // Remove Site_view items from the ucm base table - $site_view_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $site_view_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($site_view_condition); - $db->setQuery($query); - // Execute the query to remove Site_view items - $db->execute(); - - // Remove Site_view items from the ucm history table - $site_view_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $site_view_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($site_view_condition); - $db->setQuery($query); - // Execute the query to remove Site_view items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Template alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.template') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $template_found = $db->getNumRows(); - // Now check if there were any rows - if ($template_found) - { - // Since there are load the needed template type ids - $template_ids = $db->loadColumn(); - // Remove Template from the content type table - $template_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.template') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($template_condition); - $db->setQuery($query); - // Execute the query to remove Template items - $template_done = $db->execute(); - if ($template_done) - { - // If successfully remove Template add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.template) type alias was removed from the #__content_type table')); - } - - // Remove Template items from the contentitem tag map table - $template_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.template') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($template_condition); - $db->setQuery($query); - // Execute the query to remove Template items - $template_done = $db->execute(); - if ($template_done) - { - // If successfully remove Template add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.template) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Template items from the ucm content table - $template_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.template') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($template_condition); - $db->setQuery($query); - // Execute the query to remove Template items - $template_done = $db->execute(); - if ($template_done) - { - // If successfully removed Template add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.template) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Template items are cleared from DB - foreach ($template_ids as $template_id) - { - // Remove Template items from the ucm base table - $template_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $template_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($template_condition); - $db->setQuery($query); - // Execute the query to remove Template items - $db->execute(); - - // Remove Template items from the ucm history table - $template_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $template_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($template_condition); - $db->setQuery($query); - // Execute the query to remove Template items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Layout alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.layout') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $layout_found = $db->getNumRows(); - // Now check if there were any rows - if ($layout_found) - { - // Since there are load the needed layout type ids - $layout_ids = $db->loadColumn(); - // Remove Layout from the content type table - $layout_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.layout') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($layout_condition); - $db->setQuery($query); - // Execute the query to remove Layout items - $layout_done = $db->execute(); - if ($layout_done) - { - // If successfully remove Layout add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.layout) type alias was removed from the #__content_type table')); - } - - // Remove Layout items from the contentitem tag map table - $layout_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.layout') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($layout_condition); - $db->setQuery($query); - // Execute the query to remove Layout items - $layout_done = $db->execute(); - if ($layout_done) - { - // If successfully remove Layout add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.layout) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Layout items from the ucm content table - $layout_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.layout') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($layout_condition); - $db->setQuery($query); - // Execute the query to remove Layout items - $layout_done = $db->execute(); - if ($layout_done) - { - // If successfully removed Layout add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.layout) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Layout items are cleared from DB - foreach ($layout_ids as $layout_id) - { - // Remove Layout items from the ucm base table - $layout_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $layout_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($layout_condition); - $db->setQuery($query); - // Execute the query to remove Layout items - $db->execute(); - - // Remove Layout items from the ucm history table - $layout_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $layout_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($layout_condition); - $db->setQuery($query); - // Execute the query to remove Layout items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Dynamic_get alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.dynamic_get') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $dynamic_get_found = $db->getNumRows(); - // Now check if there were any rows - if ($dynamic_get_found) - { - // Since there are load the needed dynamic_get type ids - $dynamic_get_ids = $db->loadColumn(); - // Remove Dynamic_get from the content type table - $dynamic_get_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.dynamic_get') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($dynamic_get_condition); - $db->setQuery($query); - // Execute the query to remove Dynamic_get items - $dynamic_get_done = $db->execute(); - if ($dynamic_get_done) - { - // If successfully remove Dynamic_get add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.dynamic_get) type alias was removed from the #__content_type table')); - } - - // Remove Dynamic_get items from the contentitem tag map table - $dynamic_get_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.dynamic_get') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($dynamic_get_condition); - $db->setQuery($query); - // Execute the query to remove Dynamic_get items - $dynamic_get_done = $db->execute(); - if ($dynamic_get_done) - { - // If successfully remove Dynamic_get add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.dynamic_get) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Dynamic_get items from the ucm content table - $dynamic_get_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.dynamic_get') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($dynamic_get_condition); - $db->setQuery($query); - // Execute the query to remove Dynamic_get items - $dynamic_get_done = $db->execute(); - if ($dynamic_get_done) - { - // If successfully removed Dynamic_get add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.dynamic_get) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Dynamic_get items are cleared from DB - foreach ($dynamic_get_ids as $dynamic_get_id) - { - // Remove Dynamic_get items from the ucm base table - $dynamic_get_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $dynamic_get_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($dynamic_get_condition); - $db->setQuery($query); - // Execute the query to remove Dynamic_get items - $db->execute(); - - // Remove Dynamic_get items from the ucm history table - $dynamic_get_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $dynamic_get_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($dynamic_get_condition); - $db->setQuery($query); - // Execute the query to remove Dynamic_get items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Custom_code alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.custom_code') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $custom_code_found = $db->getNumRows(); - // Now check if there were any rows - if ($custom_code_found) - { - // Since there are load the needed custom_code type ids - $custom_code_ids = $db->loadColumn(); - // Remove Custom_code from the content type table - $custom_code_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.custom_code') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($custom_code_condition); - $db->setQuery($query); - // Execute the query to remove Custom_code items - $custom_code_done = $db->execute(); - if ($custom_code_done) - { - // If successfully remove Custom_code add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.custom_code) type alias was removed from the #__content_type table')); - } - - // Remove Custom_code items from the contentitem tag map table - $custom_code_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.custom_code') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($custom_code_condition); - $db->setQuery($query); - // Execute the query to remove Custom_code items - $custom_code_done = $db->execute(); - if ($custom_code_done) - { - // If successfully remove Custom_code add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.custom_code) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Custom_code items from the ucm content table - $custom_code_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.custom_code') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($custom_code_condition); - $db->setQuery($query); - // Execute the query to remove Custom_code items - $custom_code_done = $db->execute(); - if ($custom_code_done) - { - // If successfully removed Custom_code add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.custom_code) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Custom_code items are cleared from DB - foreach ($custom_code_ids as $custom_code_id) - { - // Remove Custom_code items from the ucm base table - $custom_code_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $custom_code_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($custom_code_condition); - $db->setQuery($query); - // Execute the query to remove Custom_code items - $db->execute(); - - // Remove Custom_code items from the ucm history table - $custom_code_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $custom_code_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($custom_code_condition); - $db->setQuery($query); - // Execute the query to remove Custom_code items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Class_property alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.class_property') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $class_property_found = $db->getNumRows(); - // Now check if there were any rows - if ($class_property_found) - { - // Since there are load the needed class_property type ids - $class_property_ids = $db->loadColumn(); - // Remove Class_property from the content type table - $class_property_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.class_property') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($class_property_condition); - $db->setQuery($query); - // Execute the query to remove Class_property items - $class_property_done = $db->execute(); - if ($class_property_done) - { - // If successfully remove Class_property add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.class_property) type alias was removed from the #__content_type table')); - } - - // Remove Class_property items from the contentitem tag map table - $class_property_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.class_property') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($class_property_condition); - $db->setQuery($query); - // Execute the query to remove Class_property items - $class_property_done = $db->execute(); - if ($class_property_done) - { - // If successfully remove Class_property add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.class_property) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Class_property items from the ucm content table - $class_property_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.class_property') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($class_property_condition); - $db->setQuery($query); - // Execute the query to remove Class_property items - $class_property_done = $db->execute(); - if ($class_property_done) - { - // If successfully removed Class_property add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.class_property) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Class_property items are cleared from DB - foreach ($class_property_ids as $class_property_id) - { - // Remove Class_property items from the ucm base table - $class_property_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $class_property_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($class_property_condition); - $db->setQuery($query); - // Execute the query to remove Class_property items - $db->execute(); - - // Remove Class_property items from the ucm history table - $class_property_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $class_property_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($class_property_condition); - $db->setQuery($query); - // Execute the query to remove Class_property items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Class_method alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.class_method') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $class_method_found = $db->getNumRows(); - // Now check if there were any rows - if ($class_method_found) - { - // Since there are load the needed class_method type ids - $class_method_ids = $db->loadColumn(); - // Remove Class_method from the content type table - $class_method_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.class_method') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($class_method_condition); - $db->setQuery($query); - // Execute the query to remove Class_method items - $class_method_done = $db->execute(); - if ($class_method_done) - { - // If successfully remove Class_method add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.class_method) type alias was removed from the #__content_type table')); - } - - // Remove Class_method items from the contentitem tag map table - $class_method_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.class_method') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($class_method_condition); - $db->setQuery($query); - // Execute the query to remove Class_method items - $class_method_done = $db->execute(); - if ($class_method_done) - { - // If successfully remove Class_method add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.class_method) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Class_method items from the ucm content table - $class_method_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.class_method') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($class_method_condition); - $db->setQuery($query); - // Execute the query to remove Class_method items - $class_method_done = $db->execute(); - if ($class_method_done) - { - // If successfully removed Class_method add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.class_method) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Class_method items are cleared from DB - foreach ($class_method_ids as $class_method_id) - { - // Remove Class_method items from the ucm base table - $class_method_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $class_method_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($class_method_condition); - $db->setQuery($query); - // Execute the query to remove Class_method items - $db->execute(); - - // Remove Class_method items from the ucm history table - $class_method_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $class_method_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($class_method_condition); - $db->setQuery($query); - // Execute the query to remove Class_method items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Placeholder alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.placeholder') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $placeholder_found = $db->getNumRows(); - // Now check if there were any rows - if ($placeholder_found) - { - // Since there are load the needed placeholder type ids - $placeholder_ids = $db->loadColumn(); - // Remove Placeholder from the content type table - $placeholder_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.placeholder') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($placeholder_condition); - $db->setQuery($query); - // Execute the query to remove Placeholder items - $placeholder_done = $db->execute(); - if ($placeholder_done) - { - // If successfully remove Placeholder add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.placeholder) type alias was removed from the #__content_type table')); - } - - // Remove Placeholder items from the contentitem tag map table - $placeholder_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.placeholder') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($placeholder_condition); - $db->setQuery($query); - // Execute the query to remove Placeholder items - $placeholder_done = $db->execute(); - if ($placeholder_done) - { - // If successfully remove Placeholder add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.placeholder) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Placeholder items from the ucm content table - $placeholder_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.placeholder') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($placeholder_condition); - $db->setQuery($query); - // Execute the query to remove Placeholder items - $placeholder_done = $db->execute(); - if ($placeholder_done) - { - // If successfully removed Placeholder add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.placeholder) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Placeholder items are cleared from DB - foreach ($placeholder_ids as $placeholder_id) - { - // Remove Placeholder items from the ucm base table - $placeholder_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $placeholder_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($placeholder_condition); - $db->setQuery($query); - // Execute the query to remove Placeholder items - $db->execute(); - - // Remove Placeholder items from the ucm history table - $placeholder_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $placeholder_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($placeholder_condition); - $db->setQuery($query); - // Execute the query to remove Placeholder items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Library alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.library') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $library_found = $db->getNumRows(); - // Now check if there were any rows - if ($library_found) - { - // Since there are load the needed library type ids - $library_ids = $db->loadColumn(); - // Remove Library from the content type table - $library_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.library') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($library_condition); - $db->setQuery($query); - // Execute the query to remove Library items - $library_done = $db->execute(); - if ($library_done) - { - // If successfully remove Library add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.library) type alias was removed from the #__content_type table')); - } - - // Remove Library items from the contentitem tag map table - $library_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.library') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($library_condition); - $db->setQuery($query); - // Execute the query to remove Library items - $library_done = $db->execute(); - if ($library_done) - { - // If successfully remove Library add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.library) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Library items from the ucm content table - $library_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.library') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($library_condition); - $db->setQuery($query); - // Execute the query to remove Library items - $library_done = $db->execute(); - if ($library_done) - { - // If successfully removed Library add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.library) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Library items are cleared from DB - foreach ($library_ids as $library_id) - { - // Remove Library items from the ucm base table - $library_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $library_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($library_condition); - $db->setQuery($query); - // Execute the query to remove Library items - $db->execute(); - - // Remove Library items from the ucm history table - $library_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $library_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($library_condition); - $db->setQuery($query); - // Execute the query to remove Library items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Snippet alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.snippet') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $snippet_found = $db->getNumRows(); - // Now check if there were any rows - if ($snippet_found) - { - // Since there are load the needed snippet type ids - $snippet_ids = $db->loadColumn(); - // Remove Snippet from the content type table - $snippet_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.snippet') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($snippet_condition); - $db->setQuery($query); - // Execute the query to remove Snippet items - $snippet_done = $db->execute(); - if ($snippet_done) - { - // If successfully remove Snippet add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.snippet) type alias was removed from the #__content_type table')); - } - - // Remove Snippet items from the contentitem tag map table - $snippet_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.snippet') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($snippet_condition); - $db->setQuery($query); - // Execute the query to remove Snippet items - $snippet_done = $db->execute(); - if ($snippet_done) - { - // If successfully remove Snippet add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.snippet) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Snippet items from the ucm content table - $snippet_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.snippet') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($snippet_condition); - $db->setQuery($query); - // Execute the query to remove Snippet items - $snippet_done = $db->execute(); - if ($snippet_done) - { - // If successfully removed Snippet add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.snippet) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Snippet items are cleared from DB - foreach ($snippet_ids as $snippet_id) - { - // Remove Snippet items from the ucm base table - $snippet_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $snippet_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($snippet_condition); - $db->setQuery($query); - // Execute the query to remove Snippet items - $db->execute(); - - // Remove Snippet items from the ucm history table - $snippet_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $snippet_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($snippet_condition); - $db->setQuery($query); - // Execute the query to remove Snippet items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Validation_rule alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.validation_rule') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $validation_rule_found = $db->getNumRows(); - // Now check if there were any rows - if ($validation_rule_found) - { - // Since there are load the needed validation_rule type ids - $validation_rule_ids = $db->loadColumn(); - // Remove Validation_rule from the content type table - $validation_rule_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.validation_rule') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($validation_rule_condition); - $db->setQuery($query); - // Execute the query to remove Validation_rule items - $validation_rule_done = $db->execute(); - if ($validation_rule_done) - { - // If successfully remove Validation_rule add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.validation_rule) type alias was removed from the #__content_type table')); - } - - // Remove Validation_rule items from the contentitem tag map table - $validation_rule_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.validation_rule') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($validation_rule_condition); - $db->setQuery($query); - // Execute the query to remove Validation_rule items - $validation_rule_done = $db->execute(); - if ($validation_rule_done) - { - // If successfully remove Validation_rule add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.validation_rule) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Validation_rule items from the ucm content table - $validation_rule_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.validation_rule') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($validation_rule_condition); - $db->setQuery($query); - // Execute the query to remove Validation_rule items - $validation_rule_done = $db->execute(); - if ($validation_rule_done) - { - // If successfully removed Validation_rule add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.validation_rule) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Validation_rule items are cleared from DB - foreach ($validation_rule_ids as $validation_rule_id) - { - // Remove Validation_rule items from the ucm base table - $validation_rule_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $validation_rule_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($validation_rule_condition); - $db->setQuery($query); - // Execute the query to remove Validation_rule items - $db->execute(); - - // Remove Validation_rule items from the ucm history table - $validation_rule_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $validation_rule_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($validation_rule_condition); - $db->setQuery($query); - // Execute the query to remove Validation_rule items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Field alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.field') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $field_found = $db->getNumRows(); - // Now check if there were any rows - if ($field_found) - { - // Since there are load the needed field type ids - $field_ids = $db->loadColumn(); - // Remove Field from the content type table - $field_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.field') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($field_condition); - $db->setQuery($query); - // Execute the query to remove Field items - $field_done = $db->execute(); - if ($field_done) - { - // If successfully remove Field add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.field) type alias was removed from the #__content_type table')); - } - - // Remove Field items from the contentitem tag map table - $field_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.field') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($field_condition); - $db->setQuery($query); - // Execute the query to remove Field items - $field_done = $db->execute(); - if ($field_done) - { - // If successfully remove Field add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.field) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Field items from the ucm content table - $field_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.field') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($field_condition); - $db->setQuery($query); - // Execute the query to remove Field items - $field_done = $db->execute(); - if ($field_done) - { - // If successfully removed Field add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.field) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Field items are cleared from DB - foreach ($field_ids as $field_id) - { - // Remove Field items from the ucm base table - $field_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $field_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($field_condition); - $db->setQuery($query); - // Execute the query to remove Field items - $db->execute(); - - // Remove Field items from the ucm history table - $field_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $field_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($field_condition); - $db->setQuery($query); - // Execute the query to remove Field items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Field catid alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.field.category') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $field_catid_found = $db->getNumRows(); - // Now check if there were any rows - if ($field_catid_found) - { - // Since there are load the needed field_catid type ids - $field_catid_ids = $db->loadColumn(); - // Remove Field catid from the content type table - $field_catid_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.field.category') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($field_catid_condition); - $db->setQuery($query); - // Execute the query to remove Field catid items - $field_catid_done = $db->execute(); - if ($field_catid_done) - { - // If successfully remove Field catid add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.field.category) type alias was removed from the #__content_type table')); - } - - // Remove Field catid items from the contentitem tag map table - $field_catid_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.field.category') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($field_catid_condition); - $db->setQuery($query); - // Execute the query to remove Field catid items - $field_catid_done = $db->execute(); - if ($field_catid_done) - { - // If successfully remove Field catid add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.field.category) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Field catid items from the ucm content table - $field_catid_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.field.category') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($field_catid_condition); - $db->setQuery($query); - // Execute the query to remove Field catid items - $field_catid_done = $db->execute(); - if ($field_catid_done) - { - // If successfully removed Field catid add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.field.category) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Field catid items are cleared from DB - foreach ($field_catid_ids as $field_catid_id) - { - // Remove Field catid items from the ucm base table - $field_catid_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $field_catid_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($field_catid_condition); - $db->setQuery($query); - // Execute the query to remove Field catid items - $db->execute(); - - // Remove Field catid items from the ucm history table - $field_catid_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $field_catid_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($field_catid_condition); - $db->setQuery($query); - // Execute the query to remove Field catid items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Fieldtype alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.fieldtype') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $fieldtype_found = $db->getNumRows(); - // Now check if there were any rows - if ($fieldtype_found) - { - // Since there are load the needed fieldtype type ids - $fieldtype_ids = $db->loadColumn(); - // Remove Fieldtype from the content type table - $fieldtype_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.fieldtype') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($fieldtype_condition); - $db->setQuery($query); - // Execute the query to remove Fieldtype items - $fieldtype_done = $db->execute(); - if ($fieldtype_done) - { - // If successfully remove Fieldtype add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.fieldtype) type alias was removed from the #__content_type table')); - } - - // Remove Fieldtype items from the contentitem tag map table - $fieldtype_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.fieldtype') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($fieldtype_condition); - $db->setQuery($query); - // Execute the query to remove Fieldtype items - $fieldtype_done = $db->execute(); - if ($fieldtype_done) - { - // If successfully remove Fieldtype add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.fieldtype) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Fieldtype items from the ucm content table - $fieldtype_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.fieldtype') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($fieldtype_condition); - $db->setQuery($query); - // Execute the query to remove Fieldtype items - $fieldtype_done = $db->execute(); - if ($fieldtype_done) - { - // If successfully removed Fieldtype add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.fieldtype) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Fieldtype items are cleared from DB - foreach ($fieldtype_ids as $fieldtype_id) - { - // Remove Fieldtype items from the ucm base table - $fieldtype_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $fieldtype_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($fieldtype_condition); - $db->setQuery($query); - // Execute the query to remove Fieldtype items - $db->execute(); - - // Remove Fieldtype items from the ucm history table - $fieldtype_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $fieldtype_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($fieldtype_condition); - $db->setQuery($query); - // Execute the query to remove Fieldtype items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Fieldtype catid alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.fieldtype.category') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $fieldtype_catid_found = $db->getNumRows(); - // Now check if there were any rows - if ($fieldtype_catid_found) - { - // Since there are load the needed fieldtype_catid type ids - $fieldtype_catid_ids = $db->loadColumn(); - // Remove Fieldtype catid from the content type table - $fieldtype_catid_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.fieldtype.category') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($fieldtype_catid_condition); - $db->setQuery($query); - // Execute the query to remove Fieldtype catid items - $fieldtype_catid_done = $db->execute(); - if ($fieldtype_catid_done) - { - // If successfully remove Fieldtype catid add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.fieldtype.category) type alias was removed from the #__content_type table')); - } - - // Remove Fieldtype catid items from the contentitem tag map table - $fieldtype_catid_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.fieldtype.category') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($fieldtype_catid_condition); - $db->setQuery($query); - // Execute the query to remove Fieldtype catid items - $fieldtype_catid_done = $db->execute(); - if ($fieldtype_catid_done) - { - // If successfully remove Fieldtype catid add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.fieldtype.category) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Fieldtype catid items from the ucm content table - $fieldtype_catid_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.fieldtype.category') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($fieldtype_catid_condition); - $db->setQuery($query); - // Execute the query to remove Fieldtype catid items - $fieldtype_catid_done = $db->execute(); - if ($fieldtype_catid_done) - { - // If successfully removed Fieldtype catid add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.fieldtype.category) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Fieldtype catid items are cleared from DB - foreach ($fieldtype_catid_ids as $fieldtype_catid_id) - { - // Remove Fieldtype catid items from the ucm base table - $fieldtype_catid_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $fieldtype_catid_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($fieldtype_catid_condition); - $db->setQuery($query); - // Execute the query to remove Fieldtype catid items - $db->execute(); - - // Remove Fieldtype catid items from the ucm history table - $fieldtype_catid_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $fieldtype_catid_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($fieldtype_catid_condition); - $db->setQuery($query); - // Execute the query to remove Fieldtype catid items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Language_translation alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.language_translation') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $language_translation_found = $db->getNumRows(); - // Now check if there were any rows - if ($language_translation_found) - { - // Since there are load the needed language_translation type ids - $language_translation_ids = $db->loadColumn(); - // Remove Language_translation from the content type table - $language_translation_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.language_translation') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($language_translation_condition); - $db->setQuery($query); - // Execute the query to remove Language_translation items - $language_translation_done = $db->execute(); - if ($language_translation_done) - { - // If successfully remove Language_translation add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.language_translation) type alias was removed from the #__content_type table')); - } - - // Remove Language_translation items from the contentitem tag map table - $language_translation_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.language_translation') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($language_translation_condition); - $db->setQuery($query); - // Execute the query to remove Language_translation items - $language_translation_done = $db->execute(); - if ($language_translation_done) - { - // If successfully remove Language_translation add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.language_translation) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Language_translation items from the ucm content table - $language_translation_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.language_translation') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($language_translation_condition); - $db->setQuery($query); - // Execute the query to remove Language_translation items - $language_translation_done = $db->execute(); - if ($language_translation_done) - { - // If successfully removed Language_translation add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.language_translation) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Language_translation items are cleared from DB - foreach ($language_translation_ids as $language_translation_id) - { - // Remove Language_translation items from the ucm base table - $language_translation_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $language_translation_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($language_translation_condition); - $db->setQuery($query); - // Execute the query to remove Language_translation items - $db->execute(); - - // Remove Language_translation items from the ucm history table - $language_translation_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $language_translation_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($language_translation_condition); - $db->setQuery($query); - // Execute the query to remove Language_translation items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Language alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.language') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $language_found = $db->getNumRows(); - // Now check if there were any rows - if ($language_found) - { - // Since there are load the needed language type ids - $language_ids = $db->loadColumn(); - // Remove Language from the content type table - $language_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.language') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($language_condition); - $db->setQuery($query); - // Execute the query to remove Language items - $language_done = $db->execute(); - if ($language_done) - { - // If successfully remove Language add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.language) type alias was removed from the #__content_type table')); - } - - // Remove Language items from the contentitem tag map table - $language_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.language') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($language_condition); - $db->setQuery($query); - // Execute the query to remove Language items - $language_done = $db->execute(); - if ($language_done) - { - // If successfully remove Language add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.language) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Language items from the ucm content table - $language_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.language') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($language_condition); - $db->setQuery($query); - // Execute the query to remove Language items - $language_done = $db->execute(); - if ($language_done) - { - // If successfully removed Language add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.language) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Language items are cleared from DB - foreach ($language_ids as $language_id) - { - // Remove Language items from the ucm base table - $language_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $language_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($language_condition); - $db->setQuery($query); - // Execute the query to remove Language items - $db->execute(); - - // Remove Language items from the ucm history table - $language_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $language_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($language_condition); - $db->setQuery($query); - // Execute the query to remove Language items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Server alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.server') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $server_found = $db->getNumRows(); - // Now check if there were any rows - if ($server_found) - { - // Since there are load the needed server type ids - $server_ids = $db->loadColumn(); - // Remove Server from the content type table - $server_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.server') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($server_condition); - $db->setQuery($query); - // Execute the query to remove Server items - $server_done = $db->execute(); - if ($server_done) - { - // If successfully remove Server add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.server) type alias was removed from the #__content_type table')); - } - - // Remove Server items from the contentitem tag map table - $server_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.server') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($server_condition); - $db->setQuery($query); - // Execute the query to remove Server items - $server_done = $db->execute(); - if ($server_done) - { - // If successfully remove Server add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.server) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Server items from the ucm content table - $server_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.server') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($server_condition); - $db->setQuery($query); - // Execute the query to remove Server items - $server_done = $db->execute(); - if ($server_done) - { - // If successfully removed Server add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.server) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Server items are cleared from DB - foreach ($server_ids as $server_id) - { - // Remove Server items from the ucm base table - $server_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $server_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($server_condition); - $db->setQuery($query); - // Execute the query to remove Server items - $db->execute(); - - // Remove Server items from the ucm history table - $server_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $server_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($server_condition); - $db->setQuery($query); - // Execute the query to remove Server items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Help_document alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.help_document') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $help_document_found = $db->getNumRows(); - // Now check if there were any rows - if ($help_document_found) - { - // Since there are load the needed help_document type ids - $help_document_ids = $db->loadColumn(); - // Remove Help_document from the content type table - $help_document_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.help_document') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($help_document_condition); - $db->setQuery($query); - // Execute the query to remove Help_document items - $help_document_done = $db->execute(); - if ($help_document_done) - { - // If successfully remove Help_document add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.help_document) type alias was removed from the #__content_type table')); - } - - // Remove Help_document items from the contentitem tag map table - $help_document_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.help_document') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($help_document_condition); - $db->setQuery($query); - // Execute the query to remove Help_document items - $help_document_done = $db->execute(); - if ($help_document_done) - { - // If successfully remove Help_document add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.help_document) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Help_document items from the ucm content table - $help_document_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.help_document') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($help_document_condition); - $db->setQuery($query); - // Execute the query to remove Help_document items - $help_document_done = $db->execute(); - if ($help_document_done) - { - // If successfully removed Help_document add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.help_document) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Help_document items are cleared from DB - foreach ($help_document_ids as $help_document_id) - { - // Remove Help_document items from the ucm base table - $help_document_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $help_document_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($help_document_condition); - $db->setQuery($query); - // Execute the query to remove Help_document items - $db->execute(); - - // Remove Help_document items from the ucm history table - $help_document_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $help_document_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($help_document_condition); - $db->setQuery($query); - // Execute the query to remove Help_document items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Admin_fields alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_fields') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $admin_fields_found = $db->getNumRows(); - // Now check if there were any rows - if ($admin_fields_found) - { - // Since there are load the needed admin_fields type ids - $admin_fields_ids = $db->loadColumn(); - // Remove Admin_fields from the content type table - $admin_fields_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_fields') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($admin_fields_condition); - $db->setQuery($query); - // Execute the query to remove Admin_fields items - $admin_fields_done = $db->execute(); - if ($admin_fields_done) - { - // If successfully remove Admin_fields add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.admin_fields) type alias was removed from the #__content_type table')); - } - - // Remove Admin_fields items from the contentitem tag map table - $admin_fields_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_fields') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($admin_fields_condition); - $db->setQuery($query); - // Execute the query to remove Admin_fields items - $admin_fields_done = $db->execute(); - if ($admin_fields_done) - { - // If successfully remove Admin_fields add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.admin_fields) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Admin_fields items from the ucm content table - $admin_fields_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.admin_fields') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($admin_fields_condition); - $db->setQuery($query); - // Execute the query to remove Admin_fields items - $admin_fields_done = $db->execute(); - if ($admin_fields_done) - { - // If successfully removed Admin_fields add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.admin_fields) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Admin_fields items are cleared from DB - foreach ($admin_fields_ids as $admin_fields_id) - { - // Remove Admin_fields items from the ucm base table - $admin_fields_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $admin_fields_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($admin_fields_condition); - $db->setQuery($query); - // Execute the query to remove Admin_fields items - $db->execute(); - - // Remove Admin_fields items from the ucm history table - $admin_fields_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $admin_fields_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($admin_fields_condition); - $db->setQuery($query); - // Execute the query to remove Admin_fields items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Admin_fields_conditions alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_fields_conditions') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $admin_fields_conditions_found = $db->getNumRows(); - // Now check if there were any rows - if ($admin_fields_conditions_found) - { - // Since there are load the needed admin_fields_conditions type ids - $admin_fields_conditions_ids = $db->loadColumn(); - // Remove Admin_fields_conditions from the content type table - $admin_fields_conditions_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_fields_conditions') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($admin_fields_conditions_condition); - $db->setQuery($query); - // Execute the query to remove Admin_fields_conditions items - $admin_fields_conditions_done = $db->execute(); - if ($admin_fields_conditions_done) - { - // If successfully remove Admin_fields_conditions add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.admin_fields_conditions) type alias was removed from the #__content_type table')); - } - - // Remove Admin_fields_conditions items from the contentitem tag map table - $admin_fields_conditions_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_fields_conditions') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($admin_fields_conditions_condition); - $db->setQuery($query); - // Execute the query to remove Admin_fields_conditions items - $admin_fields_conditions_done = $db->execute(); - if ($admin_fields_conditions_done) - { - // If successfully remove Admin_fields_conditions add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.admin_fields_conditions) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Admin_fields_conditions items from the ucm content table - $admin_fields_conditions_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.admin_fields_conditions') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($admin_fields_conditions_condition); - $db->setQuery($query); - // Execute the query to remove Admin_fields_conditions items - $admin_fields_conditions_done = $db->execute(); - if ($admin_fields_conditions_done) - { - // If successfully removed Admin_fields_conditions add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.admin_fields_conditions) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Admin_fields_conditions items are cleared from DB - foreach ($admin_fields_conditions_ids as $admin_fields_conditions_id) - { - // Remove Admin_fields_conditions items from the ucm base table - $admin_fields_conditions_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $admin_fields_conditions_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($admin_fields_conditions_condition); - $db->setQuery($query); - // Execute the query to remove Admin_fields_conditions items - $db->execute(); - - // Remove Admin_fields_conditions items from the ucm history table - $admin_fields_conditions_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $admin_fields_conditions_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($admin_fields_conditions_condition); - $db->setQuery($query); - // Execute the query to remove Admin_fields_conditions items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Admin_fields_relations alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_fields_relations') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $admin_fields_relations_found = $db->getNumRows(); - // Now check if there were any rows - if ($admin_fields_relations_found) - { - // Since there are load the needed admin_fields_relations type ids - $admin_fields_relations_ids = $db->loadColumn(); - // Remove Admin_fields_relations from the content type table - $admin_fields_relations_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_fields_relations') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($admin_fields_relations_condition); - $db->setQuery($query); - // Execute the query to remove Admin_fields_relations items - $admin_fields_relations_done = $db->execute(); - if ($admin_fields_relations_done) - { - // If successfully remove Admin_fields_relations add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.admin_fields_relations) type alias was removed from the #__content_type table')); - } - - // Remove Admin_fields_relations items from the contentitem tag map table - $admin_fields_relations_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_fields_relations') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($admin_fields_relations_condition); - $db->setQuery($query); - // Execute the query to remove Admin_fields_relations items - $admin_fields_relations_done = $db->execute(); - if ($admin_fields_relations_done) - { - // If successfully remove Admin_fields_relations add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.admin_fields_relations) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Admin_fields_relations items from the ucm content table - $admin_fields_relations_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.admin_fields_relations') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($admin_fields_relations_condition); - $db->setQuery($query); - // Execute the query to remove Admin_fields_relations items - $admin_fields_relations_done = $db->execute(); - if ($admin_fields_relations_done) - { - // If successfully removed Admin_fields_relations add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.admin_fields_relations) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Admin_fields_relations items are cleared from DB - foreach ($admin_fields_relations_ids as $admin_fields_relations_id) - { - // Remove Admin_fields_relations items from the ucm base table - $admin_fields_relations_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $admin_fields_relations_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($admin_fields_relations_condition); - $db->setQuery($query); - // Execute the query to remove Admin_fields_relations items - $db->execute(); - - // Remove Admin_fields_relations items from the ucm history table - $admin_fields_relations_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $admin_fields_relations_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($admin_fields_relations_condition); - $db->setQuery($query); - // Execute the query to remove Admin_fields_relations items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Admin_custom_tabs alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_custom_tabs') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $admin_custom_tabs_found = $db->getNumRows(); - // Now check if there were any rows - if ($admin_custom_tabs_found) - { - // Since there are load the needed admin_custom_tabs type ids - $admin_custom_tabs_ids = $db->loadColumn(); - // Remove Admin_custom_tabs from the content type table - $admin_custom_tabs_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_custom_tabs') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($admin_custom_tabs_condition); - $db->setQuery($query); - // Execute the query to remove Admin_custom_tabs items - $admin_custom_tabs_done = $db->execute(); - if ($admin_custom_tabs_done) - { - // If successfully remove Admin_custom_tabs add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.admin_custom_tabs) type alias was removed from the #__content_type table')); - } - - // Remove Admin_custom_tabs items from the contentitem tag map table - $admin_custom_tabs_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_custom_tabs') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($admin_custom_tabs_condition); - $db->setQuery($query); - // Execute the query to remove Admin_custom_tabs items - $admin_custom_tabs_done = $db->execute(); - if ($admin_custom_tabs_done) - { - // If successfully remove Admin_custom_tabs add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.admin_custom_tabs) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Admin_custom_tabs items from the ucm content table - $admin_custom_tabs_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.admin_custom_tabs') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($admin_custom_tabs_condition); - $db->setQuery($query); - // Execute the query to remove Admin_custom_tabs items - $admin_custom_tabs_done = $db->execute(); - if ($admin_custom_tabs_done) - { - // If successfully removed Admin_custom_tabs add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.admin_custom_tabs) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Admin_custom_tabs items are cleared from DB - foreach ($admin_custom_tabs_ids as $admin_custom_tabs_id) - { - // Remove Admin_custom_tabs items from the ucm base table - $admin_custom_tabs_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $admin_custom_tabs_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($admin_custom_tabs_condition); - $db->setQuery($query); - // Execute the query to remove Admin_custom_tabs items - $db->execute(); - - // Remove Admin_custom_tabs items from the ucm history table - $admin_custom_tabs_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $admin_custom_tabs_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($admin_custom_tabs_condition); - $db->setQuery($query); - // Execute the query to remove Admin_custom_tabs items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Component_admin_views alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_admin_views') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $component_admin_views_found = $db->getNumRows(); - // Now check if there were any rows - if ($component_admin_views_found) - { - // Since there are load the needed component_admin_views type ids - $component_admin_views_ids = $db->loadColumn(); - // Remove Component_admin_views from the content type table - $component_admin_views_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_admin_views') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($component_admin_views_condition); - $db->setQuery($query); - // Execute the query to remove Component_admin_views items - $component_admin_views_done = $db->execute(); - if ($component_admin_views_done) - { - // If successfully remove Component_admin_views add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_admin_views) type alias was removed from the #__content_type table')); - } - - // Remove Component_admin_views items from the contentitem tag map table - $component_admin_views_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_admin_views') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($component_admin_views_condition); - $db->setQuery($query); - // Execute the query to remove Component_admin_views items - $component_admin_views_done = $db->execute(); - if ($component_admin_views_done) - { - // If successfully remove Component_admin_views add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_admin_views) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Component_admin_views items from the ucm content table - $component_admin_views_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.component_admin_views') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($component_admin_views_condition); - $db->setQuery($query); - // Execute the query to remove Component_admin_views items - $component_admin_views_done = $db->execute(); - if ($component_admin_views_done) - { - // If successfully removed Component_admin_views add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_admin_views) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Component_admin_views items are cleared from DB - foreach ($component_admin_views_ids as $component_admin_views_id) - { - // Remove Component_admin_views items from the ucm base table - $component_admin_views_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_admin_views_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($component_admin_views_condition); - $db->setQuery($query); - // Execute the query to remove Component_admin_views items - $db->execute(); - - // Remove Component_admin_views items from the ucm history table - $component_admin_views_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_admin_views_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($component_admin_views_condition); - $db->setQuery($query); - // Execute the query to remove Component_admin_views items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Component_site_views alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_site_views') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $component_site_views_found = $db->getNumRows(); - // Now check if there were any rows - if ($component_site_views_found) - { - // Since there are load the needed component_site_views type ids - $component_site_views_ids = $db->loadColumn(); - // Remove Component_site_views from the content type table - $component_site_views_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_site_views') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($component_site_views_condition); - $db->setQuery($query); - // Execute the query to remove Component_site_views items - $component_site_views_done = $db->execute(); - if ($component_site_views_done) - { - // If successfully remove Component_site_views add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_site_views) type alias was removed from the #__content_type table')); - } - - // Remove Component_site_views items from the contentitem tag map table - $component_site_views_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_site_views') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($component_site_views_condition); - $db->setQuery($query); - // Execute the query to remove Component_site_views items - $component_site_views_done = $db->execute(); - if ($component_site_views_done) - { - // If successfully remove Component_site_views add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_site_views) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Component_site_views items from the ucm content table - $component_site_views_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.component_site_views') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($component_site_views_condition); - $db->setQuery($query); - // Execute the query to remove Component_site_views items - $component_site_views_done = $db->execute(); - if ($component_site_views_done) - { - // If successfully removed Component_site_views add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_site_views) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Component_site_views items are cleared from DB - foreach ($component_site_views_ids as $component_site_views_id) - { - // Remove Component_site_views items from the ucm base table - $component_site_views_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_site_views_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($component_site_views_condition); - $db->setQuery($query); - // Execute the query to remove Component_site_views items - $db->execute(); - - // Remove Component_site_views items from the ucm history table - $component_site_views_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_site_views_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($component_site_views_condition); - $db->setQuery($query); - // Execute the query to remove Component_site_views items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Component_custom_admin_views alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_custom_admin_views') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $component_custom_admin_views_found = $db->getNumRows(); - // Now check if there were any rows - if ($component_custom_admin_views_found) - { - // Since there are load the needed component_custom_admin_views type ids - $component_custom_admin_views_ids = $db->loadColumn(); - // Remove Component_custom_admin_views from the content type table - $component_custom_admin_views_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_custom_admin_views') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($component_custom_admin_views_condition); - $db->setQuery($query); - // Execute the query to remove Component_custom_admin_views items - $component_custom_admin_views_done = $db->execute(); - if ($component_custom_admin_views_done) - { - // If successfully remove Component_custom_admin_views add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_custom_admin_views) type alias was removed from the #__content_type table')); - } - - // Remove Component_custom_admin_views items from the contentitem tag map table - $component_custom_admin_views_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_custom_admin_views') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($component_custom_admin_views_condition); - $db->setQuery($query); - // Execute the query to remove Component_custom_admin_views items - $component_custom_admin_views_done = $db->execute(); - if ($component_custom_admin_views_done) - { - // If successfully remove Component_custom_admin_views add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_custom_admin_views) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Component_custom_admin_views items from the ucm content table - $component_custom_admin_views_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.component_custom_admin_views') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($component_custom_admin_views_condition); - $db->setQuery($query); - // Execute the query to remove Component_custom_admin_views items - $component_custom_admin_views_done = $db->execute(); - if ($component_custom_admin_views_done) - { - // If successfully removed Component_custom_admin_views add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_custom_admin_views) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Component_custom_admin_views items are cleared from DB - foreach ($component_custom_admin_views_ids as $component_custom_admin_views_id) - { - // Remove Component_custom_admin_views items from the ucm base table - $component_custom_admin_views_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_custom_admin_views_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($component_custom_admin_views_condition); - $db->setQuery($query); - // Execute the query to remove Component_custom_admin_views items - $db->execute(); - - // Remove Component_custom_admin_views items from the ucm history table - $component_custom_admin_views_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_custom_admin_views_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($component_custom_admin_views_condition); - $db->setQuery($query); - // Execute the query to remove Component_custom_admin_views items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Component_updates alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_updates') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $component_updates_found = $db->getNumRows(); - // Now check if there were any rows - if ($component_updates_found) - { - // Since there are load the needed component_updates type ids - $component_updates_ids = $db->loadColumn(); - // Remove Component_updates from the content type table - $component_updates_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_updates') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($component_updates_condition); - $db->setQuery($query); - // Execute the query to remove Component_updates items - $component_updates_done = $db->execute(); - if ($component_updates_done) - { - // If successfully remove Component_updates add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_updates) type alias was removed from the #__content_type table')); - } - - // Remove Component_updates items from the contentitem tag map table - $component_updates_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_updates') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($component_updates_condition); - $db->setQuery($query); - // Execute the query to remove Component_updates items - $component_updates_done = $db->execute(); - if ($component_updates_done) - { - // If successfully remove Component_updates add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_updates) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Component_updates items from the ucm content table - $component_updates_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.component_updates') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($component_updates_condition); - $db->setQuery($query); - // Execute the query to remove Component_updates items - $component_updates_done = $db->execute(); - if ($component_updates_done) - { - // If successfully removed Component_updates add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_updates) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Component_updates items are cleared from DB - foreach ($component_updates_ids as $component_updates_id) - { - // Remove Component_updates items from the ucm base table - $component_updates_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_updates_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($component_updates_condition); - $db->setQuery($query); - // Execute the query to remove Component_updates items - $db->execute(); - - // Remove Component_updates items from the ucm history table - $component_updates_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_updates_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($component_updates_condition); - $db->setQuery($query); - // Execute the query to remove Component_updates items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Component_mysql_tweaks alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_mysql_tweaks') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $component_mysql_tweaks_found = $db->getNumRows(); - // Now check if there were any rows - if ($component_mysql_tweaks_found) - { - // Since there are load the needed component_mysql_tweaks type ids - $component_mysql_tweaks_ids = $db->loadColumn(); - // Remove Component_mysql_tweaks from the content type table - $component_mysql_tweaks_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_mysql_tweaks') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($component_mysql_tweaks_condition); - $db->setQuery($query); - // Execute the query to remove Component_mysql_tweaks items - $component_mysql_tweaks_done = $db->execute(); - if ($component_mysql_tweaks_done) - { - // If successfully remove Component_mysql_tweaks add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_mysql_tweaks) type alias was removed from the #__content_type table')); - } - - // Remove Component_mysql_tweaks items from the contentitem tag map table - $component_mysql_tweaks_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_mysql_tweaks') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($component_mysql_tweaks_condition); - $db->setQuery($query); - // Execute the query to remove Component_mysql_tweaks items - $component_mysql_tweaks_done = $db->execute(); - if ($component_mysql_tweaks_done) - { - // If successfully remove Component_mysql_tweaks add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_mysql_tweaks) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Component_mysql_tweaks items from the ucm content table - $component_mysql_tweaks_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.component_mysql_tweaks') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($component_mysql_tweaks_condition); - $db->setQuery($query); - // Execute the query to remove Component_mysql_tweaks items - $component_mysql_tweaks_done = $db->execute(); - if ($component_mysql_tweaks_done) - { - // If successfully removed Component_mysql_tweaks add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_mysql_tweaks) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Component_mysql_tweaks items are cleared from DB - foreach ($component_mysql_tweaks_ids as $component_mysql_tweaks_id) - { - // Remove Component_mysql_tweaks items from the ucm base table - $component_mysql_tweaks_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_mysql_tweaks_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($component_mysql_tweaks_condition); - $db->setQuery($query); - // Execute the query to remove Component_mysql_tweaks items - $db->execute(); - - // Remove Component_mysql_tweaks items from the ucm history table - $component_mysql_tweaks_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_mysql_tweaks_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($component_mysql_tweaks_condition); - $db->setQuery($query); - // Execute the query to remove Component_mysql_tweaks items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Component_custom_admin_menus alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_custom_admin_menus') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $component_custom_admin_menus_found = $db->getNumRows(); - // Now check if there were any rows - if ($component_custom_admin_menus_found) - { - // Since there are load the needed component_custom_admin_menus type ids - $component_custom_admin_menus_ids = $db->loadColumn(); - // Remove Component_custom_admin_menus from the content type table - $component_custom_admin_menus_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_custom_admin_menus') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($component_custom_admin_menus_condition); - $db->setQuery($query); - // Execute the query to remove Component_custom_admin_menus items - $component_custom_admin_menus_done = $db->execute(); - if ($component_custom_admin_menus_done) - { - // If successfully remove Component_custom_admin_menus add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_custom_admin_menus) type alias was removed from the #__content_type table')); - } - - // Remove Component_custom_admin_menus items from the contentitem tag map table - $component_custom_admin_menus_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_custom_admin_menus') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($component_custom_admin_menus_condition); - $db->setQuery($query); - // Execute the query to remove Component_custom_admin_menus items - $component_custom_admin_menus_done = $db->execute(); - if ($component_custom_admin_menus_done) - { - // If successfully remove Component_custom_admin_menus add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_custom_admin_menus) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Component_custom_admin_menus items from the ucm content table - $component_custom_admin_menus_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.component_custom_admin_menus') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($component_custom_admin_menus_condition); - $db->setQuery($query); - // Execute the query to remove Component_custom_admin_menus items - $component_custom_admin_menus_done = $db->execute(); - if ($component_custom_admin_menus_done) - { - // If successfully removed Component_custom_admin_menus add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_custom_admin_menus) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Component_custom_admin_menus items are cleared from DB - foreach ($component_custom_admin_menus_ids as $component_custom_admin_menus_id) - { - // Remove Component_custom_admin_menus items from the ucm base table - $component_custom_admin_menus_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_custom_admin_menus_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($component_custom_admin_menus_condition); - $db->setQuery($query); - // Execute the query to remove Component_custom_admin_menus items - $db->execute(); - - // Remove Component_custom_admin_menus items from the ucm history table - $component_custom_admin_menus_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_custom_admin_menus_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($component_custom_admin_menus_condition); - $db->setQuery($query); - // Execute the query to remove Component_custom_admin_menus items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Component_config alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_config') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $component_config_found = $db->getNumRows(); - // Now check if there were any rows - if ($component_config_found) - { - // Since there are load the needed component_config type ids - $component_config_ids = $db->loadColumn(); - // Remove Component_config from the content type table - $component_config_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_config') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($component_config_condition); - $db->setQuery($query); - // Execute the query to remove Component_config items - $component_config_done = $db->execute(); - if ($component_config_done) - { - // If successfully remove Component_config add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_config) type alias was removed from the #__content_type table')); - } - - // Remove Component_config items from the contentitem tag map table - $component_config_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_config') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($component_config_condition); - $db->setQuery($query); - // Execute the query to remove Component_config items - $component_config_done = $db->execute(); - if ($component_config_done) - { - // If successfully remove Component_config add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_config) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Component_config items from the ucm content table - $component_config_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.component_config') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($component_config_condition); - $db->setQuery($query); - // Execute the query to remove Component_config items - $component_config_done = $db->execute(); - if ($component_config_done) - { - // If successfully removed Component_config add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_config) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Component_config items are cleared from DB - foreach ($component_config_ids as $component_config_id) - { - // Remove Component_config items from the ucm base table - $component_config_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_config_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($component_config_condition); - $db->setQuery($query); - // Execute the query to remove Component_config items - $db->execute(); - - // Remove Component_config items from the ucm history table - $component_config_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_config_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($component_config_condition); - $db->setQuery($query); - // Execute the query to remove Component_config items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Component_dashboard alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_dashboard') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $component_dashboard_found = $db->getNumRows(); - // Now check if there were any rows - if ($component_dashboard_found) - { - // Since there are load the needed component_dashboard type ids - $component_dashboard_ids = $db->loadColumn(); - // Remove Component_dashboard from the content type table - $component_dashboard_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_dashboard') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($component_dashboard_condition); - $db->setQuery($query); - // Execute the query to remove Component_dashboard items - $component_dashboard_done = $db->execute(); - if ($component_dashboard_done) - { - // If successfully remove Component_dashboard add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_dashboard) type alias was removed from the #__content_type table')); - } - - // Remove Component_dashboard items from the contentitem tag map table - $component_dashboard_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_dashboard') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($component_dashboard_condition); - $db->setQuery($query); - // Execute the query to remove Component_dashboard items - $component_dashboard_done = $db->execute(); - if ($component_dashboard_done) - { - // If successfully remove Component_dashboard add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_dashboard) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Component_dashboard items from the ucm content table - $component_dashboard_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.component_dashboard') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($component_dashboard_condition); - $db->setQuery($query); - // Execute the query to remove Component_dashboard items - $component_dashboard_done = $db->execute(); - if ($component_dashboard_done) - { - // If successfully removed Component_dashboard add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_dashboard) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Component_dashboard items are cleared from DB - foreach ($component_dashboard_ids as $component_dashboard_id) - { - // Remove Component_dashboard items from the ucm base table - $component_dashboard_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_dashboard_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($component_dashboard_condition); - $db->setQuery($query); - // Execute the query to remove Component_dashboard items - $db->execute(); - - // Remove Component_dashboard items from the ucm history table - $component_dashboard_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_dashboard_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($component_dashboard_condition); - $db->setQuery($query); - // Execute the query to remove Component_dashboard items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Component_files_folders alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_files_folders') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $component_files_folders_found = $db->getNumRows(); - // Now check if there were any rows - if ($component_files_folders_found) - { - // Since there are load the needed component_files_folders type ids - $component_files_folders_ids = $db->loadColumn(); - // Remove Component_files_folders from the content type table - $component_files_folders_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_files_folders') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($component_files_folders_condition); - $db->setQuery($query); - // Execute the query to remove Component_files_folders items - $component_files_folders_done = $db->execute(); - if ($component_files_folders_done) - { - // If successfully remove Component_files_folders add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_files_folders) type alias was removed from the #__content_type table')); - } - - // Remove Component_files_folders items from the contentitem tag map table - $component_files_folders_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_files_folders') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($component_files_folders_condition); - $db->setQuery($query); - // Execute the query to remove Component_files_folders items - $component_files_folders_done = $db->execute(); - if ($component_files_folders_done) - { - // If successfully remove Component_files_folders add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_files_folders) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Component_files_folders items from the ucm content table - $component_files_folders_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.component_files_folders') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($component_files_folders_condition); - $db->setQuery($query); - // Execute the query to remove Component_files_folders items - $component_files_folders_done = $db->execute(); - if ($component_files_folders_done) - { - // If successfully removed Component_files_folders add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_files_folders) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Component_files_folders items are cleared from DB - foreach ($component_files_folders_ids as $component_files_folders_id) - { - // Remove Component_files_folders items from the ucm base table - $component_files_folders_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_files_folders_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($component_files_folders_condition); - $db->setQuery($query); - // Execute the query to remove Component_files_folders items - $db->execute(); - - // Remove Component_files_folders items from the ucm history table - $component_files_folders_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_files_folders_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($component_files_folders_condition); - $db->setQuery($query); - // Execute the query to remove Component_files_folders items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Component_placeholders alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_placeholders') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $component_placeholders_found = $db->getNumRows(); - // Now check if there were any rows - if ($component_placeholders_found) - { - // Since there are load the needed component_placeholders type ids - $component_placeholders_ids = $db->loadColumn(); - // Remove Component_placeholders from the content type table - $component_placeholders_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_placeholders') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($component_placeholders_condition); - $db->setQuery($query); - // Execute the query to remove Component_placeholders items - $component_placeholders_done = $db->execute(); - if ($component_placeholders_done) - { - // If successfully remove Component_placeholders add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_placeholders) type alias was removed from the #__content_type table')); - } - - // Remove Component_placeholders items from the contentitem tag map table - $component_placeholders_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_placeholders') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($component_placeholders_condition); - $db->setQuery($query); - // Execute the query to remove Component_placeholders items - $component_placeholders_done = $db->execute(); - if ($component_placeholders_done) - { - // If successfully remove Component_placeholders add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_placeholders) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Component_placeholders items from the ucm content table - $component_placeholders_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.component_placeholders') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($component_placeholders_condition); - $db->setQuery($query); - // Execute the query to remove Component_placeholders items - $component_placeholders_done = $db->execute(); - if ($component_placeholders_done) - { - // If successfully removed Component_placeholders add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_placeholders) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Component_placeholders items are cleared from DB - foreach ($component_placeholders_ids as $component_placeholders_id) - { - // Remove Component_placeholders items from the ucm base table - $component_placeholders_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_placeholders_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($component_placeholders_condition); - $db->setQuery($query); - // Execute the query to remove Component_placeholders items - $db->execute(); - - // Remove Component_placeholders items from the ucm history table - $component_placeholders_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_placeholders_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($component_placeholders_condition); - $db->setQuery($query); - // Execute the query to remove Component_placeholders items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Component_plugins alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_plugins') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $component_plugins_found = $db->getNumRows(); - // Now check if there were any rows - if ($component_plugins_found) - { - // Since there are load the needed component_plugins type ids - $component_plugins_ids = $db->loadColumn(); - // Remove Component_plugins from the content type table - $component_plugins_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_plugins') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($component_plugins_condition); - $db->setQuery($query); - // Execute the query to remove Component_plugins items - $component_plugins_done = $db->execute(); - if ($component_plugins_done) - { - // If successfully remove Component_plugins add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_plugins) type alias was removed from the #__content_type table')); - } - - // Remove Component_plugins items from the contentitem tag map table - $component_plugins_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_plugins') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($component_plugins_condition); - $db->setQuery($query); - // Execute the query to remove Component_plugins items - $component_plugins_done = $db->execute(); - if ($component_plugins_done) - { - // If successfully remove Component_plugins add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_plugins) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Component_plugins items from the ucm content table - $component_plugins_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.component_plugins') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($component_plugins_condition); - $db->setQuery($query); - // Execute the query to remove Component_plugins items - $component_plugins_done = $db->execute(); - if ($component_plugins_done) - { - // If successfully removed Component_plugins add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_plugins) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Component_plugins items are cleared from DB - foreach ($component_plugins_ids as $component_plugins_id) - { - // Remove Component_plugins items from the ucm base table - $component_plugins_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_plugins_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($component_plugins_condition); - $db->setQuery($query); - // Execute the query to remove Component_plugins items - $db->execute(); - - // Remove Component_plugins items from the ucm history table - $component_plugins_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_plugins_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($component_plugins_condition); - $db->setQuery($query); - // Execute the query to remove Component_plugins items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Component_modules alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_modules') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $component_modules_found = $db->getNumRows(); - // Now check if there were any rows - if ($component_modules_found) - { - // Since there are load the needed component_modules type ids - $component_modules_ids = $db->loadColumn(); - // Remove Component_modules from the content type table - $component_modules_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_modules') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($component_modules_condition); - $db->setQuery($query); - // Execute the query to remove Component_modules items - $component_modules_done = $db->execute(); - if ($component_modules_done) - { - // If successfully remove Component_modules add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_modules) type alias was removed from the #__content_type table')); - } - - // Remove Component_modules items from the contentitem tag map table - $component_modules_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_modules') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($component_modules_condition); - $db->setQuery($query); - // Execute the query to remove Component_modules items - $component_modules_done = $db->execute(); - if ($component_modules_done) - { - // If successfully remove Component_modules add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_modules) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Component_modules items from the ucm content table - $component_modules_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.component_modules') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($component_modules_condition); - $db->setQuery($query); - // Execute the query to remove Component_modules items - $component_modules_done = $db->execute(); - if ($component_modules_done) - { - // If successfully removed Component_modules add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.component_modules) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Component_modules items are cleared from DB - foreach ($component_modules_ids as $component_modules_id) - { - // Remove Component_modules items from the ucm base table - $component_modules_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_modules_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($component_modules_condition); - $db->setQuery($query); - // Execute the query to remove Component_modules items - $db->execute(); - - // Remove Component_modules items from the ucm history table - $component_modules_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $component_modules_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($component_modules_condition); - $db->setQuery($query); - // Execute the query to remove Component_modules items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Snippet_type alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.snippet_type') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $snippet_type_found = $db->getNumRows(); - // Now check if there were any rows - if ($snippet_type_found) - { - // Since there are load the needed snippet_type type ids - $snippet_type_ids = $db->loadColumn(); - // Remove Snippet_type from the content type table - $snippet_type_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.snippet_type') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($snippet_type_condition); - $db->setQuery($query); - // Execute the query to remove Snippet_type items - $snippet_type_done = $db->execute(); - if ($snippet_type_done) - { - // If successfully remove Snippet_type add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.snippet_type) type alias was removed from the #__content_type table')); - } - - // Remove Snippet_type items from the contentitem tag map table - $snippet_type_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.snippet_type') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($snippet_type_condition); - $db->setQuery($query); - // Execute the query to remove Snippet_type items - $snippet_type_done = $db->execute(); - if ($snippet_type_done) - { - // If successfully remove Snippet_type add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.snippet_type) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Snippet_type items from the ucm content table - $snippet_type_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.snippet_type') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($snippet_type_condition); - $db->setQuery($query); - // Execute the query to remove Snippet_type items - $snippet_type_done = $db->execute(); - if ($snippet_type_done) - { - // If successfully removed Snippet_type add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.snippet_type) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Snippet_type items are cleared from DB - foreach ($snippet_type_ids as $snippet_type_id) - { - // Remove Snippet_type items from the ucm base table - $snippet_type_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $snippet_type_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($snippet_type_condition); - $db->setQuery($query); - // Execute the query to remove Snippet_type items - $db->execute(); - - // Remove Snippet_type items from the ucm history table - $snippet_type_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $snippet_type_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($snippet_type_condition); - $db->setQuery($query); - // Execute the query to remove Snippet_type items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Library_config alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.library_config') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $library_config_found = $db->getNumRows(); - // Now check if there were any rows - if ($library_config_found) - { - // Since there are load the needed library_config type ids - $library_config_ids = $db->loadColumn(); - // Remove Library_config from the content type table - $library_config_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.library_config') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($library_config_condition); - $db->setQuery($query); - // Execute the query to remove Library_config items - $library_config_done = $db->execute(); - if ($library_config_done) - { - // If successfully remove Library_config add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.library_config) type alias was removed from the #__content_type table')); - } - - // Remove Library_config items from the contentitem tag map table - $library_config_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.library_config') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($library_config_condition); - $db->setQuery($query); - // Execute the query to remove Library_config items - $library_config_done = $db->execute(); - if ($library_config_done) - { - // If successfully remove Library_config add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.library_config) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Library_config items from the ucm content table - $library_config_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.library_config') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($library_config_condition); - $db->setQuery($query); - // Execute the query to remove Library_config items - $library_config_done = $db->execute(); - if ($library_config_done) - { - // If successfully removed Library_config add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.library_config) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Library_config items are cleared from DB - foreach ($library_config_ids as $library_config_id) - { - // Remove Library_config items from the ucm base table - $library_config_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $library_config_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($library_config_condition); - $db->setQuery($query); - // Execute the query to remove Library_config items - $db->execute(); - - // Remove Library_config items from the ucm history table - $library_config_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $library_config_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($library_config_condition); - $db->setQuery($query); - // Execute the query to remove Library_config items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Library_files_folders_urls alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.library_files_folders_urls') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $library_files_folders_urls_found = $db->getNumRows(); - // Now check if there were any rows - if ($library_files_folders_urls_found) - { - // Since there are load the needed library_files_folders_urls type ids - $library_files_folders_urls_ids = $db->loadColumn(); - // Remove Library_files_folders_urls from the content type table - $library_files_folders_urls_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.library_files_folders_urls') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($library_files_folders_urls_condition); - $db->setQuery($query); - // Execute the query to remove Library_files_folders_urls items - $library_files_folders_urls_done = $db->execute(); - if ($library_files_folders_urls_done) - { - // If successfully remove Library_files_folders_urls add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.library_files_folders_urls) type alias was removed from the #__content_type table')); - } - - // Remove Library_files_folders_urls items from the contentitem tag map table - $library_files_folders_urls_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.library_files_folders_urls') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($library_files_folders_urls_condition); - $db->setQuery($query); - // Execute the query to remove Library_files_folders_urls items - $library_files_folders_urls_done = $db->execute(); - if ($library_files_folders_urls_done) - { - // If successfully remove Library_files_folders_urls add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.library_files_folders_urls) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Library_files_folders_urls items from the ucm content table - $library_files_folders_urls_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.library_files_folders_urls') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($library_files_folders_urls_condition); - $db->setQuery($query); - // Execute the query to remove Library_files_folders_urls items - $library_files_folders_urls_done = $db->execute(); - if ($library_files_folders_urls_done) - { - // If successfully removed Library_files_folders_urls add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.library_files_folders_urls) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Library_files_folders_urls items are cleared from DB - foreach ($library_files_folders_urls_ids as $library_files_folders_urls_id) - { - // Remove Library_files_folders_urls items from the ucm base table - $library_files_folders_urls_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $library_files_folders_urls_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($library_files_folders_urls_condition); - $db->setQuery($query); - // Execute the query to remove Library_files_folders_urls items - $db->execute(); - - // Remove Library_files_folders_urls items from the ucm history table - $library_files_folders_urls_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $library_files_folders_urls_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($library_files_folders_urls_condition); - $db->setQuery($query); - // Execute the query to remove Library_files_folders_urls items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Class_extends alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.class_extends') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $class_extends_found = $db->getNumRows(); - // Now check if there were any rows - if ($class_extends_found) - { - // Since there are load the needed class_extends type ids - $class_extends_ids = $db->loadColumn(); - // Remove Class_extends from the content type table - $class_extends_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.class_extends') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($class_extends_condition); - $db->setQuery($query); - // Execute the query to remove Class_extends items - $class_extends_done = $db->execute(); - if ($class_extends_done) - { - // If successfully remove Class_extends add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.class_extends) type alias was removed from the #__content_type table')); - } - - // Remove Class_extends items from the contentitem tag map table - $class_extends_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.class_extends') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($class_extends_condition); - $db->setQuery($query); - // Execute the query to remove Class_extends items - $class_extends_done = $db->execute(); - if ($class_extends_done) - { - // If successfully remove Class_extends add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.class_extends) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Class_extends items from the ucm content table - $class_extends_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.class_extends') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($class_extends_condition); - $db->setQuery($query); - // Execute the query to remove Class_extends items - $class_extends_done = $db->execute(); - if ($class_extends_done) - { - // If successfully removed Class_extends add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.class_extends) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Class_extends items are cleared from DB - foreach ($class_extends_ids as $class_extends_id) - { - // Remove Class_extends items from the ucm base table - $class_extends_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $class_extends_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($class_extends_condition); - $db->setQuery($query); - // Execute the query to remove Class_extends items - $db->execute(); - - // Remove Class_extends items from the ucm history table - $class_extends_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $class_extends_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($class_extends_condition); - $db->setQuery($query); - // Execute the query to remove Class_extends items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Joomla_module_updates alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_module_updates') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $joomla_module_updates_found = $db->getNumRows(); - // Now check if there were any rows - if ($joomla_module_updates_found) - { - // Since there are load the needed joomla_module_updates type ids - $joomla_module_updates_ids = $db->loadColumn(); - // Remove Joomla_module_updates from the content type table - $joomla_module_updates_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_module_updates') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($joomla_module_updates_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_module_updates items - $joomla_module_updates_done = $db->execute(); - if ($joomla_module_updates_done) - { - // If successfully remove Joomla_module_updates add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_module_updates) type alias was removed from the #__content_type table')); - } - - // Remove Joomla_module_updates items from the contentitem tag map table - $joomla_module_updates_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_module_updates') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($joomla_module_updates_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_module_updates items - $joomla_module_updates_done = $db->execute(); - if ($joomla_module_updates_done) - { - // If successfully remove Joomla_module_updates add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_module_updates) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Joomla_module_updates items from the ucm content table - $joomla_module_updates_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.joomla_module_updates') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($joomla_module_updates_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_module_updates items - $joomla_module_updates_done = $db->execute(); - if ($joomla_module_updates_done) - { - // If successfully removed Joomla_module_updates add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_module_updates) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Joomla_module_updates items are cleared from DB - foreach ($joomla_module_updates_ids as $joomla_module_updates_id) - { - // Remove Joomla_module_updates items from the ucm base table - $joomla_module_updates_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_module_updates_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($joomla_module_updates_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_module_updates items - $db->execute(); - - // Remove Joomla_module_updates items from the ucm history table - $joomla_module_updates_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_module_updates_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($joomla_module_updates_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_module_updates items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Joomla_module_files_folders_urls alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_module_files_folders_urls') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $joomla_module_files_folders_urls_found = $db->getNumRows(); - // Now check if there were any rows - if ($joomla_module_files_folders_urls_found) - { - // Since there are load the needed joomla_module_files_folders_urls type ids - $joomla_module_files_folders_urls_ids = $db->loadColumn(); - // Remove Joomla_module_files_folders_urls from the content type table - $joomla_module_files_folders_urls_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_module_files_folders_urls') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($joomla_module_files_folders_urls_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_module_files_folders_urls items - $joomla_module_files_folders_urls_done = $db->execute(); - if ($joomla_module_files_folders_urls_done) - { - // If successfully remove Joomla_module_files_folders_urls add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_module_files_folders_urls) type alias was removed from the #__content_type table')); - } - - // Remove Joomla_module_files_folders_urls items from the contentitem tag map table - $joomla_module_files_folders_urls_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_module_files_folders_urls') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($joomla_module_files_folders_urls_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_module_files_folders_urls items - $joomla_module_files_folders_urls_done = $db->execute(); - if ($joomla_module_files_folders_urls_done) - { - // If successfully remove Joomla_module_files_folders_urls add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_module_files_folders_urls) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Joomla_module_files_folders_urls items from the ucm content table - $joomla_module_files_folders_urls_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.joomla_module_files_folders_urls') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($joomla_module_files_folders_urls_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_module_files_folders_urls items - $joomla_module_files_folders_urls_done = $db->execute(); - if ($joomla_module_files_folders_urls_done) - { - // If successfully removed Joomla_module_files_folders_urls add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_module_files_folders_urls) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Joomla_module_files_folders_urls items are cleared from DB - foreach ($joomla_module_files_folders_urls_ids as $joomla_module_files_folders_urls_id) - { - // Remove Joomla_module_files_folders_urls items from the ucm base table - $joomla_module_files_folders_urls_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_module_files_folders_urls_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($joomla_module_files_folders_urls_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_module_files_folders_urls items - $db->execute(); - - // Remove Joomla_module_files_folders_urls items from the ucm history table - $joomla_module_files_folders_urls_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_module_files_folders_urls_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($joomla_module_files_folders_urls_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_module_files_folders_urls items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Joomla_plugin_group alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_plugin_group') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $joomla_plugin_group_found = $db->getNumRows(); - // Now check if there were any rows - if ($joomla_plugin_group_found) - { - // Since there are load the needed joomla_plugin_group type ids - $joomla_plugin_group_ids = $db->loadColumn(); - // Remove Joomla_plugin_group from the content type table - $joomla_plugin_group_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_plugin_group') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($joomla_plugin_group_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_plugin_group items - $joomla_plugin_group_done = $db->execute(); - if ($joomla_plugin_group_done) - { - // If successfully remove Joomla_plugin_group add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_plugin_group) type alias was removed from the #__content_type table')); - } - - // Remove Joomla_plugin_group items from the contentitem tag map table - $joomla_plugin_group_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_plugin_group') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($joomla_plugin_group_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_plugin_group items - $joomla_plugin_group_done = $db->execute(); - if ($joomla_plugin_group_done) - { - // If successfully remove Joomla_plugin_group add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_plugin_group) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Joomla_plugin_group items from the ucm content table - $joomla_plugin_group_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.joomla_plugin_group') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($joomla_plugin_group_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_plugin_group items - $joomla_plugin_group_done = $db->execute(); - if ($joomla_plugin_group_done) - { - // If successfully removed Joomla_plugin_group add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_plugin_group) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Joomla_plugin_group items are cleared from DB - foreach ($joomla_plugin_group_ids as $joomla_plugin_group_id) - { - // Remove Joomla_plugin_group items from the ucm base table - $joomla_plugin_group_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_plugin_group_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($joomla_plugin_group_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_plugin_group items - $db->execute(); - - // Remove Joomla_plugin_group items from the ucm history table - $joomla_plugin_group_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_plugin_group_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($joomla_plugin_group_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_plugin_group items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Joomla_plugin_updates alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_plugin_updates') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $joomla_plugin_updates_found = $db->getNumRows(); - // Now check if there were any rows - if ($joomla_plugin_updates_found) - { - // Since there are load the needed joomla_plugin_updates type ids - $joomla_plugin_updates_ids = $db->loadColumn(); - // Remove Joomla_plugin_updates from the content type table - $joomla_plugin_updates_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_plugin_updates') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($joomla_plugin_updates_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_plugin_updates items - $joomla_plugin_updates_done = $db->execute(); - if ($joomla_plugin_updates_done) - { - // If successfully remove Joomla_plugin_updates add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_plugin_updates) type alias was removed from the #__content_type table')); - } - - // Remove Joomla_plugin_updates items from the contentitem tag map table - $joomla_plugin_updates_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_plugin_updates') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($joomla_plugin_updates_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_plugin_updates items - $joomla_plugin_updates_done = $db->execute(); - if ($joomla_plugin_updates_done) - { - // If successfully remove Joomla_plugin_updates add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_plugin_updates) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Joomla_plugin_updates items from the ucm content table - $joomla_plugin_updates_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.joomla_plugin_updates') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($joomla_plugin_updates_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_plugin_updates items - $joomla_plugin_updates_done = $db->execute(); - if ($joomla_plugin_updates_done) - { - // If successfully removed Joomla_plugin_updates add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_plugin_updates) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Joomla_plugin_updates items are cleared from DB - foreach ($joomla_plugin_updates_ids as $joomla_plugin_updates_id) - { - // Remove Joomla_plugin_updates items from the ucm base table - $joomla_plugin_updates_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_plugin_updates_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($joomla_plugin_updates_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_plugin_updates items - $db->execute(); - - // Remove Joomla_plugin_updates items from the ucm history table - $joomla_plugin_updates_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_plugin_updates_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($joomla_plugin_updates_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_plugin_updates items - $db->execute(); - } - } - - // Create a new query object. - $query = $db->getQuery(true); - // Select id from content type table - $query->select($db->quoteName('type_id')); - $query->from($db->quoteName('#__content_types')); - // Where Joomla_plugin_files_folders_urls alias is found - $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_plugin_files_folders_urls') ); - $db->setQuery($query); - // Execute query to see if alias is found - $db->execute(); - $joomla_plugin_files_folders_urls_found = $db->getNumRows(); - // Now check if there were any rows - if ($joomla_plugin_files_folders_urls_found) - { - // Since there are load the needed joomla_plugin_files_folders_urls type ids - $joomla_plugin_files_folders_urls_ids = $db->loadColumn(); - // Remove Joomla_plugin_files_folders_urls from the content type table - $joomla_plugin_files_folders_urls_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_plugin_files_folders_urls') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__content_types')); - $query->where($joomla_plugin_files_folders_urls_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_plugin_files_folders_urls items - $joomla_plugin_files_folders_urls_done = $db->execute(); - if ($joomla_plugin_files_folders_urls_done) - { - // If successfully remove Joomla_plugin_files_folders_urls add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_plugin_files_folders_urls) type alias was removed from the #__content_type table')); - } - - // Remove Joomla_plugin_files_folders_urls items from the contentitem tag map table - $joomla_plugin_files_folders_urls_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_plugin_files_folders_urls') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__contentitem_tag_map')); - $query->where($joomla_plugin_files_folders_urls_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_plugin_files_folders_urls items - $joomla_plugin_files_folders_urls_done = $db->execute(); - if ($joomla_plugin_files_folders_urls_done) - { - // If successfully remove Joomla_plugin_files_folders_urls add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_plugin_files_folders_urls) type alias was removed from the #__contentitem_tag_map table')); - } - - // Remove Joomla_plugin_files_folders_urls items from the ucm content table - $joomla_plugin_files_folders_urls_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.joomla_plugin_files_folders_urls') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_content')); - $query->where($joomla_plugin_files_folders_urls_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_plugin_files_folders_urls items - $joomla_plugin_files_folders_urls_done = $db->execute(); - if ($joomla_plugin_files_folders_urls_done) - { - // If successfully removed Joomla_plugin_files_folders_urls add queued success message. - $app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_plugin_files_folders_urls) type alias was removed from the #__ucm_content table')); - } - - // Make sure that all the Joomla_plugin_files_folders_urls items are cleared from DB - foreach ($joomla_plugin_files_folders_urls_ids as $joomla_plugin_files_folders_urls_id) - { - // Remove Joomla_plugin_files_folders_urls items from the ucm base table - $joomla_plugin_files_folders_urls_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_plugin_files_folders_urls_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_base')); - $query->where($joomla_plugin_files_folders_urls_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_plugin_files_folders_urls items - $db->execute(); - - // Remove Joomla_plugin_files_folders_urls items from the ucm history table - $joomla_plugin_files_folders_urls_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_plugin_files_folders_urls_id); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__ucm_history')); - $query->where($joomla_plugin_files_folders_urls_condition); - $db->setQuery($query); - // Execute the query to remove Joomla_plugin_files_folders_urls items - $db->execute(); - } - } - - // If All related items was removed queued success message. - $app->enqueueMessage(JText::_('All related items was removed from the #__ucm_base table')); - $app->enqueueMessage(JText::_('All related items was removed from the #__ucm_history table')); - - // Remove componentbuilder assets from the assets table - $componentbuilder_condition = array( $db->quoteName('name') . ' LIKE ' . $db->quote('com_componentbuilder%') ); - - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__assets')); - $query->where($componentbuilder_condition); - $db->setQuery($query); - $joomla_plugin_files_folders_urls_done = $db->execute(); - if ($joomla_plugin_files_folders_urls_done) - { - // If successfully removed componentbuilder add queued success message. - $app->enqueueMessage(JText::_('All related items was removed from the #__assets table')); - } - - // Get the biggest rule column in the assets table at this point. - $get_rule_length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1"; - $db->setQuery($get_rule_length); - if ($db->execute()) - { - $rule_length = $db->loadResult(); - // Check the size of the rules column - if ($rule_length < 5120) - { - // Revert the assets table rules column back to the default - $revert_rule = "ALTER TABLE `#__assets` CHANGE `rules` `rules` varchar(5120) NOT NULL COMMENT 'JSON encoded access control.';"; - $db->setQuery($revert_rule); - $db->execute(); - $app->enqueueMessage(JText::_('Reverted the #__assets table rules column back to its default size of varchar(5120)')); - } - else - { - - $app->enqueueMessage(JText::_('Could not revert the #__assets table rules column back to its default size of varchar(5120), since there is still one or more components that still requires the column to be larger.')); - } - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // 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); - $query->delete($db->quoteName('#__action_logs_extensions')); - $query->where($componentbuilder_action_logs_extensions); - $db->setQuery($query); - // Execute the query to remove Componentbuilder - $componentbuilder_removed_done = $db->execute(); - if ($componentbuilder_removed_done) - { - // If successfully remove Componentbuilder add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder extension was removed from the #__action_logs_extensions table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Joomla_component from the action_log_config table - $joomla_component_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_component') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($joomla_component_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.joomla_component - $joomla_component_action_log_config_done = $db->execute(); - if ($joomla_component_action_log_config_done) - { - // If successfully removed Componentbuilder Joomla_component add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.joomla_component type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Joomla_module from the action_log_config table - $joomla_module_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_module') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($joomla_module_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.joomla_module - $joomla_module_action_log_config_done = $db->execute(); - if ($joomla_module_action_log_config_done) - { - // If successfully removed Componentbuilder Joomla_module add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.joomla_module type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Joomla_plugin from the action_log_config table - $joomla_plugin_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_plugin') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($joomla_plugin_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.joomla_plugin - $joomla_plugin_action_log_config_done = $db->execute(); - if ($joomla_plugin_action_log_config_done) - { - // If successfully removed Componentbuilder Joomla_plugin add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.joomla_plugin type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Power from the action_log_config table - $power_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.power') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($power_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.power - $power_action_log_config_done = $db->execute(); - if ($power_action_log_config_done) - { - // If successfully removed Componentbuilder Power add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.power type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Admin_view from the action_log_config table - $admin_view_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_view') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($admin_view_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.admin_view - $admin_view_action_log_config_done = $db->execute(); - if ($admin_view_action_log_config_done) - { - // If successfully removed Componentbuilder Admin_view add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.admin_view type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Custom_admin_view from the action_log_config table - $custom_admin_view_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.custom_admin_view') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($custom_admin_view_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.custom_admin_view - $custom_admin_view_action_log_config_done = $db->execute(); - if ($custom_admin_view_action_log_config_done) - { - // If successfully removed Componentbuilder Custom_admin_view add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.custom_admin_view type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Site_view from the action_log_config table - $site_view_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.site_view') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($site_view_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.site_view - $site_view_action_log_config_done = $db->execute(); - if ($site_view_action_log_config_done) - { - // If successfully removed Componentbuilder Site_view add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.site_view type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Template from the action_log_config table - $template_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.template') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($template_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.template - $template_action_log_config_done = $db->execute(); - if ($template_action_log_config_done) - { - // If successfully removed Componentbuilder Template add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.template type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Layout from the action_log_config table - $layout_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.layout') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($layout_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.layout - $layout_action_log_config_done = $db->execute(); - if ($layout_action_log_config_done) - { - // If successfully removed Componentbuilder Layout add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.layout type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Dynamic_get from the action_log_config table - $dynamic_get_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.dynamic_get') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($dynamic_get_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.dynamic_get - $dynamic_get_action_log_config_done = $db->execute(); - if ($dynamic_get_action_log_config_done) - { - // If successfully removed Componentbuilder Dynamic_get add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.dynamic_get type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Custom_code from the action_log_config table - $custom_code_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.custom_code') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($custom_code_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.custom_code - $custom_code_action_log_config_done = $db->execute(); - if ($custom_code_action_log_config_done) - { - // If successfully removed Componentbuilder Custom_code add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.custom_code type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Class_property from the action_log_config table - $class_property_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.class_property') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($class_property_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.class_property - $class_property_action_log_config_done = $db->execute(); - if ($class_property_action_log_config_done) - { - // If successfully removed Componentbuilder Class_property add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.class_property type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Class_method from the action_log_config table - $class_method_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.class_method') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($class_method_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.class_method - $class_method_action_log_config_done = $db->execute(); - if ($class_method_action_log_config_done) - { - // If successfully removed Componentbuilder Class_method add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.class_method type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Placeholder from the action_log_config table - $placeholder_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.placeholder') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($placeholder_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.placeholder - $placeholder_action_log_config_done = $db->execute(); - if ($placeholder_action_log_config_done) - { - // If successfully removed Componentbuilder Placeholder add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.placeholder type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Library from the action_log_config table - $library_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.library') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($library_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.library - $library_action_log_config_done = $db->execute(); - if ($library_action_log_config_done) - { - // If successfully removed Componentbuilder Library add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.library type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Snippet from the action_log_config table - $snippet_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.snippet') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($snippet_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.snippet - $snippet_action_log_config_done = $db->execute(); - if ($snippet_action_log_config_done) - { - // If successfully removed Componentbuilder Snippet add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.snippet type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Validation_rule from the action_log_config table - $validation_rule_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.validation_rule') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($validation_rule_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.validation_rule - $validation_rule_action_log_config_done = $db->execute(); - if ($validation_rule_action_log_config_done) - { - // If successfully removed Componentbuilder Validation_rule add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.validation_rule type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Field from the action_log_config table - $field_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.field') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($field_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.field - $field_action_log_config_done = $db->execute(); - if ($field_action_log_config_done) - { - // If successfully removed Componentbuilder Field add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.field type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Fieldtype from the action_log_config table - $fieldtype_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.fieldtype') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($fieldtype_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.fieldtype - $fieldtype_action_log_config_done = $db->execute(); - if ($fieldtype_action_log_config_done) - { - // If successfully removed Componentbuilder Fieldtype add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.fieldtype type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Language_translation from the action_log_config table - $language_translation_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.language_translation') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($language_translation_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.language_translation - $language_translation_action_log_config_done = $db->execute(); - if ($language_translation_action_log_config_done) - { - // If successfully removed Componentbuilder Language_translation add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.language_translation type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Language from the action_log_config table - $language_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.language') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($language_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.language - $language_action_log_config_done = $db->execute(); - if ($language_action_log_config_done) - { - // If successfully removed Componentbuilder Language add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.language type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Server from the action_log_config table - $server_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.server') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($server_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.server - $server_action_log_config_done = $db->execute(); - if ($server_action_log_config_done) - { - // If successfully removed Componentbuilder Server add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.server type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Help_document from the action_log_config table - $help_document_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.help_document') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($help_document_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.help_document - $help_document_action_log_config_done = $db->execute(); - if ($help_document_action_log_config_done) - { - // If successfully removed Componentbuilder Help_document add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.help_document type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Admin_fields from the action_log_config table - $admin_fields_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_fields') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($admin_fields_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.admin_fields - $admin_fields_action_log_config_done = $db->execute(); - if ($admin_fields_action_log_config_done) - { - // If successfully removed Componentbuilder Admin_fields add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.admin_fields type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Admin_fields_conditions from the action_log_config table - $admin_fields_conditions_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_fields_conditions') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($admin_fields_conditions_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.admin_fields_conditions - $admin_fields_conditions_action_log_config_done = $db->execute(); - if ($admin_fields_conditions_action_log_config_done) - { - // If successfully removed Componentbuilder Admin_fields_conditions add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.admin_fields_conditions type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Admin_fields_relations from the action_log_config table - $admin_fields_relations_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_fields_relations') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($admin_fields_relations_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.admin_fields_relations - $admin_fields_relations_action_log_config_done = $db->execute(); - if ($admin_fields_relations_action_log_config_done) - { - // If successfully removed Componentbuilder Admin_fields_relations add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.admin_fields_relations type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Admin_custom_tabs from the action_log_config table - $admin_custom_tabs_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_custom_tabs') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($admin_custom_tabs_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.admin_custom_tabs - $admin_custom_tabs_action_log_config_done = $db->execute(); - if ($admin_custom_tabs_action_log_config_done) - { - // If successfully removed Componentbuilder Admin_custom_tabs add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.admin_custom_tabs type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Component_admin_views from the action_log_config table - $component_admin_views_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_admin_views') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($component_admin_views_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.component_admin_views - $component_admin_views_action_log_config_done = $db->execute(); - if ($component_admin_views_action_log_config_done) - { - // If successfully removed Componentbuilder Component_admin_views add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.component_admin_views type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Component_site_views from the action_log_config table - $component_site_views_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_site_views') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($component_site_views_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.component_site_views - $component_site_views_action_log_config_done = $db->execute(); - if ($component_site_views_action_log_config_done) - { - // If successfully removed Componentbuilder Component_site_views add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.component_site_views type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Component_custom_admin_views from the action_log_config table - $component_custom_admin_views_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_custom_admin_views') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($component_custom_admin_views_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.component_custom_admin_views - $component_custom_admin_views_action_log_config_done = $db->execute(); - if ($component_custom_admin_views_action_log_config_done) - { - // If successfully removed Componentbuilder Component_custom_admin_views add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.component_custom_admin_views type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Component_updates from the action_log_config table - $component_updates_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_updates') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($component_updates_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.component_updates - $component_updates_action_log_config_done = $db->execute(); - if ($component_updates_action_log_config_done) - { - // If successfully removed Componentbuilder Component_updates add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.component_updates type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Component_mysql_tweaks from the action_log_config table - $component_mysql_tweaks_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_mysql_tweaks') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($component_mysql_tweaks_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.component_mysql_tweaks - $component_mysql_tweaks_action_log_config_done = $db->execute(); - if ($component_mysql_tweaks_action_log_config_done) - { - // If successfully removed Componentbuilder Component_mysql_tweaks add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.component_mysql_tweaks type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Component_custom_admin_menus from the action_log_config table - $component_custom_admin_menus_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_custom_admin_menus') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($component_custom_admin_menus_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.component_custom_admin_menus - $component_custom_admin_menus_action_log_config_done = $db->execute(); - if ($component_custom_admin_menus_action_log_config_done) - { - // If successfully removed Componentbuilder Component_custom_admin_menus add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.component_custom_admin_menus type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Component_config from the action_log_config table - $component_config_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_config') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($component_config_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.component_config - $component_config_action_log_config_done = $db->execute(); - if ($component_config_action_log_config_done) - { - // If successfully removed Componentbuilder Component_config add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.component_config type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Component_dashboard from the action_log_config table - $component_dashboard_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_dashboard') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($component_dashboard_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.component_dashboard - $component_dashboard_action_log_config_done = $db->execute(); - if ($component_dashboard_action_log_config_done) - { - // If successfully removed Componentbuilder Component_dashboard add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.component_dashboard type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Component_files_folders from the action_log_config table - $component_files_folders_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_files_folders') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($component_files_folders_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.component_files_folders - $component_files_folders_action_log_config_done = $db->execute(); - if ($component_files_folders_action_log_config_done) - { - // If successfully removed Componentbuilder Component_files_folders add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.component_files_folders type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Component_placeholders from the action_log_config table - $component_placeholders_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_placeholders') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($component_placeholders_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.component_placeholders - $component_placeholders_action_log_config_done = $db->execute(); - if ($component_placeholders_action_log_config_done) - { - // If successfully removed Componentbuilder Component_placeholders add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.component_placeholders type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Component_plugins from the action_log_config table - $component_plugins_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_plugins') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($component_plugins_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.component_plugins - $component_plugins_action_log_config_done = $db->execute(); - if ($component_plugins_action_log_config_done) - { - // If successfully removed Componentbuilder Component_plugins add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.component_plugins type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Component_modules from the action_log_config table - $component_modules_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.component_modules') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($component_modules_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.component_modules - $component_modules_action_log_config_done = $db->execute(); - if ($component_modules_action_log_config_done) - { - // If successfully removed Componentbuilder Component_modules add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.component_modules type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Snippet_type from the action_log_config table - $snippet_type_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.snippet_type') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($snippet_type_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.snippet_type - $snippet_type_action_log_config_done = $db->execute(); - if ($snippet_type_action_log_config_done) - { - // If successfully removed Componentbuilder Snippet_type add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.snippet_type type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Library_config from the action_log_config table - $library_config_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.library_config') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($library_config_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.library_config - $library_config_action_log_config_done = $db->execute(); - if ($library_config_action_log_config_done) - { - // If successfully removed Componentbuilder Library_config add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.library_config type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Library_files_folders_urls from the action_log_config table - $library_files_folders_urls_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.library_files_folders_urls') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($library_files_folders_urls_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.library_files_folders_urls - $library_files_folders_urls_action_log_config_done = $db->execute(); - if ($library_files_folders_urls_action_log_config_done) - { - // If successfully removed Componentbuilder Library_files_folders_urls add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.library_files_folders_urls type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Class_extends from the action_log_config table - $class_extends_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.class_extends') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($class_extends_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.class_extends - $class_extends_action_log_config_done = $db->execute(); - if ($class_extends_action_log_config_done) - { - // If successfully removed Componentbuilder Class_extends add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.class_extends type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Joomla_module_updates from the action_log_config table - $joomla_module_updates_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_module_updates') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($joomla_module_updates_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.joomla_module_updates - $joomla_module_updates_action_log_config_done = $db->execute(); - if ($joomla_module_updates_action_log_config_done) - { - // If successfully removed Componentbuilder Joomla_module_updates add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.joomla_module_updates type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Joomla_module_files_folders_urls from the action_log_config table - $joomla_module_files_folders_urls_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_module_files_folders_urls') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($joomla_module_files_folders_urls_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.joomla_module_files_folders_urls - $joomla_module_files_folders_urls_action_log_config_done = $db->execute(); - if ($joomla_module_files_folders_urls_action_log_config_done) - { - // If successfully removed Componentbuilder Joomla_module_files_folders_urls add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.joomla_module_files_folders_urls type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Joomla_plugin_group from the action_log_config table - $joomla_plugin_group_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_plugin_group') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($joomla_plugin_group_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.joomla_plugin_group - $joomla_plugin_group_action_log_config_done = $db->execute(); - if ($joomla_plugin_group_action_log_config_done) - { - // If successfully removed Componentbuilder Joomla_plugin_group add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.joomla_plugin_group type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Joomla_plugin_updates from the action_log_config table - $joomla_plugin_updates_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_plugin_updates') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($joomla_plugin_updates_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.joomla_plugin_updates - $joomla_plugin_updates_action_log_config_done = $db->execute(); - if ($joomla_plugin_updates_action_log_config_done) - { - // If successfully removed Componentbuilder Joomla_plugin_updates add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.joomla_plugin_updates type alias was removed from the #__action_log_config table')); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Set app if not set already. - if (!isset($app)) - { - $app = JFactory::getApplication(); - } - // Remove Componentbuilder Joomla_plugin_files_folders_urls from the action_log_config table - $joomla_plugin_files_folders_urls_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_plugin_files_folders_urls') ); - // Create a new query object. - $query = $db->getQuery(true); - $query->delete($db->quoteName('#__action_log_config')); - $query->where($joomla_plugin_files_folders_urls_action_log_config); - $db->setQuery($query); - // Execute the query to remove com_componentbuilder.joomla_plugin_files_folders_urls - $joomla_plugin_files_folders_urls_action_log_config_done = $db->execute(); - if ($joomla_plugin_files_folders_urls_action_log_config_done) - { - // If successfully removed Componentbuilder Joomla_plugin_files_folders_urls add queued success message. - $app->enqueueMessage(JText::_('The com_componentbuilder.joomla_plugin_files_folders_urls type alias was removed from the #__action_log_config table')); - } - // little notice as after service, in case of bad experience with component. - echo '

    Did something go wrong? Are you disappointed?

    -

    Please let me know at joomla@vdm.io. -
    We at Vast Development Method are committed to building extensions that performs proficiently! You can help us, really! -
    Send me your thoughts on improvements that is needed, trust me, I will be very grateful! -
    Visit us at https://dev.vdm.io today!

    '; - } - - /** - * Called on update - * - * @param ComponentAdapter $parent The object responsible for running this script - * - * @return boolean True on success - */ - public function update(ComponentAdapter $parent){} - - /** - * Called before any type of action - * - * @param string $type Which action is happening (install|uninstall|discover_install|update) - * @param ComponentAdapter $parent The object responsible for running this script - * - * @return boolean True on success - */ - public function preflight($type, ComponentAdapter $parent) - { - // get application - $app = JFactory::getApplication(); - // is redundant or so it seems ...hmmm let me know if it works again - if ($type === 'uninstall') - { - return true; - } - // the default for both install and update - $jversion = new JVersion(); - if (!$jversion->isCompatible('3.8.0')) - { - $app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error'); - return false; - } - // do any updates needed - if ($type === 'update') - { - - // load the helper class - JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'); - // check the version of JCB - $manifest = ComponentbuilderHelper::manifest(); - if (isset($manifest->version) && strpos($manifest->version, '.') !== false) - { - // get the version - $this->JCBversion = explode('.', $manifest->version); - // Get a db connection. - $db = JFactory::getDbo(); - - // target version less then 2.5.2 - if (count($this->JCBversion) == 3 && $this->JCBversion[0] <= 2 && $this->JCBversion[1] <= 5 && (($this->JCBversion[1] == 5 && $this->JCBversion[2] <= 1) || ($this->JCBversion[1] < 5))) - { - // the set values - $this->setFtpValues = array(); - // Create a new query object. - $query = $db->getQuery(true); - // get all Joomla Component FTP values - $query->select($db->quoteName(array('id', 'sales_server_ftp', 'update_server_ftp'))); - $query->from($db->quoteName('#__componentbuilder_joomla_component')); - // Reset the query using our newly populated query object. - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - $rows = $db->loadObjectList(); - // Get the basic encryption. - $basickey = ComponentbuilderHelper::getCryptKey('basic'); - // Get the encryption object. - $basic = new AES($basickey, 128); - foreach ($rows as $row) - { - if (StringHelper::check($row->sales_server_ftp) || StringHelper::check($row->update_server_ftp)) - { - $updatevalue = null; - // update the update_server_ftp - if (StringHelper::check($row->update_server_ftp) && !is_numeric($row->update_server_ftp) && $basickey && $row->update_server_ftp === base64_encode(base64_decode($row->update_server_ftp, true))) - { - $updatevalue = rtrim($basic->decryptString($row->update_server_ftp), "\0"); - } - elseif (StringHelper::check($row->update_server_ftp)) - { - $updatevalue = $row->update_server_ftp; - } - $salesvalue = null; - // update the sales_server_ftp - if (StringHelper::check($row->sales_server_ftp) && !is_numeric($row->sales_server_ftp) && $basickey && $row->sales_server_ftp === base64_encode(base64_decode($row->sales_server_ftp, true))) - { - $salesvalue = rtrim($basic->decryptString($row->sales_server_ftp), "\0"); - } - elseif (StringHelper::check($row->sales_server_ftp)) - { - $salesvalue = $row->sales_server_ftp; - } - // set update Values - if ($updatevalue) - { - $hash = md5($updatevalue) . '__update_server_ftp'; - if (!isset($this->setFtpValues[$hash])) - { - $this->setFtpValues[$hash] = array(); - $this->setFtpValues[$hash]['ids'] = array(); - $this->setFtpValues[$hash]['ftp'] = $updatevalue; - $this->setFtpValues[$hash]['signature'] = $row->update_server_ftp; - } - $this->setFtpValues[$hash]['ids'][] = $row->id; - } - // set sales Values - if ($salesvalue) - { - $hash = md5($salesvalue) . '__sales_server_ftp'; - if (!isset($this->setFtpValues[$hash])) - { - $this->setFtpValues[$hash] = array(); - $this->setFtpValues[$hash]['ids'] = array(); - $this->setFtpValues[$hash]['ftp'] = $salesvalue; - $this->setFtpValues[$hash]['signature'] = $row->sales_server_ftp; - } - $this->setFtpValues[$hash]['ids'][] = $row->id; - } - } - } - } - } - /* - * Convert repeatable fields in a table - * - * @param string $table The table where the fields are updated - * @param array $select The fields +id that should be updated - * @param array $convert The array options used to convert the fields - * check => the array of values in the repeatable field that must exist - * key => the name of the field - * - * @return void - */ - $convertRepeatable = function($db, $table, $select, $convert) - { - // update the properties in the field types - $query = $db->getQuery(true); - // update all JCB fieldtype properties - $query->select($db->quoteName($select)); - $query->from($db->quoteName('#__componentbuilder_' . $table)); - // Reset the query using our newly populated query object. - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - $rows = $db->loadObjectList(); - foreach ($rows as $row) - { - $update = false; - foreach ($convert as $target => $field) - { - // check if it has needed values (it should but just in case) - $continue = false; - if (isset($row->{$target}) && JsonHelper::check($row->{$target})) - { - // open the target and convert - $jsonArray = json_decode($row->{$target}, true); - // test if we can do conversion - $continue = true; - if (ArrayHelper::check($jsonArray)) - { - foreach($field['check'] as $check) - { - if (!isset($jsonArray[$check]) || !ArrayHelper::check($jsonArray[$check])) - { - $continue = false; - } - // if found but not an array, then clear out the target - if (isset($jsonArray[$check]) && !ArrayHelper::check($jsonArray[$check])) - { - $row->{$target} = ''; - $update = true; - } - } - } - else - { - $row->{$target} = ''; - $update = true; - } - } - // do the conversion - if ($continue) - { - $bucket = array(); - foreach ($jsonArray as $key => $values) - { - foreach ($values as $nr => $value) - { - if (!isset($bucket[$field['key'] . $nr]) || !ArrayHelper::check($bucket[$field['key'] . $nr])) - { - $bucket[$field['key'] . $nr] = array(); - } - $bucket[$field['key'] . $nr][$key] = $value; - } - } - // set the bucket back to properties - $row->{$target} = json_encode($bucket); - $update = true; - } - } - // update with the new values - if ($update) - { - $db->updateObject('#__componentbuilder_' . $table, $row, 'id'); - } - } - } - }; - // target version less then 2.5.5 (we need to change the language translation values & the fieldtype properties) - if (count($this->JCBversion) == 3 && $this->JCBversion[0] <= 2 && $this->JCBversion[1] <= 5 && (($this->JCBversion[1] == 5 && $this->JCBversion[2] <= 4) || ($this->JCBversion[1] < 5))) - { - // do some conversions in the translations table - $convertRepeatable($db, 'language_translation', array('id', 'translation'), array('translation' => array('check' => array('translation'), 'key' => 'translation'))); - // do some conversions in the fieldtype table - $convertRepeatable($db, 'fieldtype', array('id', 'properties'), array('properties' => array('check' => array('name'), 'key' => 'properties'))); - } - // target version less then 2.5.6 - if (count($this->JCBversion) == 3 && $this->JCBversion[0] <= 2 && $this->JCBversion[1] <= 5 && (($this->JCBversion[1] == 5 && $this->JCBversion[2] <= 5) || ($this->JCBversion[1] < 5))) - { - // do some conversions in the dynamic get table - $convertRepeatable($db, 'dynamic_get', array('id', 'join_view_table', 'join_db_table', 'filter', 'where', 'order', 'global'), - array( - 'join_view_table' => array('check' => array('view_table'), 'key' => 'join_view_table'), - 'join_db_table' => array('check' => array('db_table'), 'key' => 'join_db_table'), - 'filter' => array('check' => array('filter_type'), 'key' => 'filter'), - 'where' => array('check' => array('table_key'), 'key' => 'where'), - 'order' => array('check' => array('table_key'), 'key' => 'order'), - 'global' => array('check' => array('name'), 'key' => 'global') - ) - ); - } - // start the active table array - $activeTable = array(); - // get table columns to confirm that this is an old installation - $activeTable['admin_view'] = $db->getTableColumns('#__componentbuilder_admin_view'); - // target version less then 2.5.7 - if (isset($activeTable['admin_view']['addfields']) && (count($this->JCBversion) == 3 && $this->JCBversion[0] <= 2 && $this->JCBversion[1] <= 5 && (($this->JCBversion[1] == 5 && $this->JCBversion[2] <= 6) || ($this->JCBversion[1] < 5)))) - { - // do some conversions in the admin_view table - $convertRepeatable($db, 'admin_view', array('id', 'ajax_input', 'custom_button', 'addtables', 'addlinked_views', 'addconditions', 'addfields', 'addtabs', 'addpermissions'), - array( - 'ajax_input' => array('check' => array('value_name'), 'key' => 'ajax_input'), - 'custom_button' => array('check' => array('name'), 'key' => 'custom_button'), - 'addtables' => array('check' => array('table'), 'key' => 'addtables'), - 'addlinked_views' => array('check' => array('adminview'), 'key' => 'addlinked_views'), - 'addconditions' => array('check' => array('target_field'), 'key' => 'addconditions'), - 'addfields' => array('check' => array('field'), 'key' => 'addfields'), - 'addtabs' => array('check' => array('name'), 'key' => 'addtabs'), - 'addpermissions' => array('check' => array('action'), 'key' => 'addpermissions') - ) - ); - - // do some conversions in the site_view table - $convertRepeatable($db, 'site_view', array('id', 'ajax_input', 'custom_button'), - array( - 'ajax_input' => array('check' => array('value_name'), 'key' => 'ajax_input'), - 'custom_button' => array('check' => array('name'), 'key' => 'custom_button') - ) - ); - - // do some conversions in the custom_admin_view table - $convertRepeatable($db, 'custom_admin_view', array('id', 'custom_button'), - array( - 'custom_button' => array('check' => array('name'), 'key' => 'custom_button') - ) - ); - } - // the set move values - $this->setMoveValues = array(); - // get table columns to confirm that this is an old installation - $activeTable['joomla_component'] = $db->getTableColumns('#__componentbuilder_joomla_component'); - // target version less then 2.6.0 - if (isset($activeTable['joomla_component']['addadmin_views']) && (count($this->JCBversion) == 3 && $this->JCBversion[0] <= 2 && $this->JCBversion[1] <= 5 && (($this->JCBversion[1] == 5 && $this->JCBversion[2] <= 9) || ($this->JCBversion[1] < 6)))) - { - // do some conversions in the admin_view table - $convertRepeatable($db, 'joomla_component', array('id', 'addadmin_views', 'addconfig', 'addcontributors', 'addcustom_admin_views', 'addcustommenus', 'addfiles', 'addfolders', 'addsite_views', 'dashboard_tab', 'sql_tweak', 'version_update'), - array( - 'addadmin_views' => array('check' => array('adminview'), 'key' => 'addadmin_views'), - 'addconfig' => array('check' => array('field'), 'key' => 'addconfig'), - 'addcontributors' => array('check' => array('name'), 'key' => 'addcontributors'), - 'addcustom_admin_views' => array('check' => array('customadminview'), 'key' => 'addcustom_admin_views'), - 'addcustommenus' => array('check' => array('name'), 'key' => 'addcustommenus'), - 'addfiles' => array('check' => array('file'), 'key' => 'addfiles'), - 'addfolders' => array('check' => array('folder'), 'key' => 'addfolders'), - 'addsite_views' => array('check' => array('siteview'), 'key' => 'addsite_views'), - 'dashboard_tab' => array('check' => array('name'), 'key' => 'dashboard_tab'), - 'sql_tweak' => array('check' => array('adminview'), 'key' => 'sql_tweak'), - 'version_update' => array('check' => array('version'), 'key' => 'version_update') - ) - ); - // move values to their own tables - $tables = array( - 'admin_fields' => array('id' => 'admin_view', 'addfields' => 'addfields'), - 'admin_fields_conditions' => array('id' => 'admin_view', 'addconditions' => 'addconditions'), - 'component_admin_views' => array('id' => 'joomla_component', 'addadmin_views' => 'addadmin_views'), - 'component_site_views' => array('id' => 'joomla_component', 'addsite_views' => 'addsite_views'), - 'component_custom_admin_views' => array('id' => 'joomla_component', 'addcustom_admin_views' => 'addcustom_admin_views'), - 'component_updates' => array('id' => 'joomla_component', 'version_update' => 'version_update'), - 'component_mysql_tweaks' => array('id' => 'joomla_component', 'sql_tweak' => 'sql_tweak'), - 'component_custom_admin_menus' => array('id' => 'joomla_component', 'addcustommenus' => 'addcustommenus'), - 'component_config' => array('id' => 'joomla_component', 'addconfig' => 'addconfig'), - 'component_dashboard' => array('id' => 'joomla_component', 'dashboard_tab' => 'dashboard_tab', 'php_dashboard_methods' => 'php_dashboard_methods'), - 'component_files_folders' => array('id' => 'joomla_component', 'addfiles' => 'addfiles', 'addfolders' => 'addfolders') - ); - $this->dynamicTable = array( - 'admin_fields' => 'admin_view', - 'admin_fields_conditions' => 'admin_view', - 'component_admin_views' => 'joomla_component', - 'component_site_views' => 'joomla_component', - 'component_custom_admin_views' => 'joomla_component', - 'component_updates' => 'joomla_component', - 'component_mysql_tweaks' => 'joomla_component', - 'component_custom_admin_menus' => 'joomla_component', - 'component_config' => 'joomla_component', - 'component_dashboard' => 'joomla_component', - 'component_files_folders' => 'joomla_component'); - foreach ($tables as $move => $array) - { - // we must first check if the fields are still there - $columns = $db->getTableColumns('#__componentbuilder_'.$this->dynamicTable[$move]); - foreach ($array as $column => $as) - { - if (!isset($columns[$column])) - { - // remove this column since it is no longer found - unset($array[$column]); - } - } - // do we still need to move any - if (ArrayHelper::check($array)) - { - // move all diverged data - $query = $db->getQuery(true); - // update all JCB fieldtype properties - $query->select($db->quoteName(array_keys($array),array_values($array))); - $query->from($db->quoteName('#__componentbuilder_'.$this->dynamicTable[$move])); - // Reset the query using our newly populated query object. - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - $this->setMoveValues[$move] = $db->loadObjectList(); - } - } - } - } - // target version less then 2.9.7 - if (count($this->JCBversion) == 3 && $this->JCBversion[0] <= 2 && (($this->JCBversion[1] == 9 && $this->JCBversion[2] <= 6) || $this->JCBversion[1] < 9)) - { - // we basically just dump the unused columns from #__componentbuilder_joomla_component - $columnToDrop['joomla_component'] = array( - 'addconfig', - 'addadmin_views', - 'addcustom_admin_views', - 'addsite_views', - 'version_update', - 'sql_tweak', - 'addcustommenus', - 'dashboard_tab', - 'php_dashboard_methods', - 'addfiles', - 'addfolders'); - // and from from #__componentbuilder_admin_view - $columnToDrop['admin_view'] = array( - 'addfields', - 'addconditions'); - // only drop those that exist - foreach ($columnToDrop as $table => $columns) - { - // start drop array - $drop = array(); - foreach ($columns as $column) - { - if (isset($activeTable[$table][$column])) - { - // load the column - $drop[$column] = $column; - } - } - // now run query if needed - if (ArrayHelper::check($drop)) - { - // build query - $query = 'ALTER TABLE `#__componentbuilder_' . $table . '` DROP `' . implode('`, DROP `', $drop) . '`'; - // set query - $db->setQuery($query); - $db->execute(); - } - } - } - // target version less then 2.9.8 - if (count($this->JCBversion) == 3 && $this->JCBversion[0] <= 2 && (($this->JCBversion[1] == 9 && $this->JCBversion[2] <= 7) || $this->JCBversion[1] < 9)) - { - // check if this install has the wiki file (just remove it) - $wiki_menu = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/wiki_menu.txt'; - if (JFile::exists($wiki_menu)) - { - JFile::delete($wiki_menu); - } - } - // target version less then or equal to 2.11.2 - if (count($this->JCBversion) == 3 && $this->JCBversion[0] <= 2 && ($this->JCBversion[1] < 11 || ($this->JCBversion[1] == 11 && $this->JCBversion[2] <= 2))) - { - // we need to make a database correction for the field categories and the fieldtype categories - $fix_categories = array( - 'com_componentbuilder.fields' => 'com_componentbuilder.field', - 'com_componentbuilder.fieldtypes' => 'com_componentbuilder.fieldtype' - ); - - // targeted tables (to fix all places categories are mapped into Joomla) - $fix_tables = array( - 'content_types' => array( - 'id' => 'type_id', - 'key' => 'type_alias', - 'suffix' => '.category'), - 'contentitem_tag_map' => array( - 'id' => 'type_id', - 'key' => 'type_alias', - 'suffix' => '.category'), - 'ucm_content' => array( - 'id' => 'core_content_id', - 'key' => 'core_type_alias', - 'suffix' => '.category'), - 'categories' => array( - 'id' => 'id', - 'key' => 'extension', - 'suffix' => '') - ); - // the script that does the work - foreach ($fix_categories as $fix => $category) - { - // loop over the targeted tables - foreach ($fix_tables as $_table => $_update) - { - // Create a new query object. - $query = $db->getQuery(true); - // get all type_ids - $query->select($db->quoteName($_update['id'])); - $query->from($db->quoteName('#__' . $_table)); - $query->where( $db->quoteName($_update['key']) . ' = ' . $db->quote($fix . $_update['suffix'])); - // Reset the query using our newly populated query object. - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - - // all these must be updated - $ids = $db->loadColumn(); - // Fields to update. - $fields = array( - $db->quoteName($_update['key']) . ' = ' . $db->quote($category . $_update['suffix']) - ); - // Conditions for which records should be updated. - $conditions = array( - $db->quoteName($_update['id']) . ' IN (' . implode(', ', $ids) . ')' - ); - $query->update($db->quoteName('#__' . $_table))->set($fields)->where($conditions); - $db->setQuery($query); - $result = $db->execute(); - // on success - if ($result) - { - $app->enqueueMessage("

    Updated #__$_table - " . $_update['key'] . " from $fix" . $_update['suffix'] . " to $category" . $_update['suffix'] . "!

    ", 'Notice'); - } - - } - } - } - } - } - // path to the new compiler - $jcb_powers = JPATH_LIBRARIES . '/jcb_powers/VDM.Joomla/src/Componentbuilder'; - // we always remove all the old files to avoid mismatching - ComponentbuilderHelper::removeFolder($jcb_powers); - } - // do any install needed - if ($type === 'install') - { - } - // check if the PHPExcel stuff is still around - if (File::exists(JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/PHPExcel.php')) - { - // We need to remove this old PHPExcel folder - $this->removeFolder(JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/PHPExcel'); - // We need to remove this old PHPExcel file - File::delete(JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/PHPExcel.php'); - } - return true; - } - - /** - * Called after any type of action - * - * @param string $type Which action is happening (install|uninstall|discover_install|update) - * @param ComponentAdapter $parent The object responsible for running this script - * - * @return boolean True on success - */ - public function postflight($type, ComponentAdapter $parent) - { - // get application - $app = JFactory::getApplication(); - // We check if we have dynamic folders to copy - $this->setDynamicF0ld3rs($app, $parent); - // set the default component settings - if ($type === 'install') - { - - // Get The Database object - $db = JFactory::getDbo(); - - // Create the joomla_component content type object. - $joomla_component = new stdClass(); - $joomla_component->type_title = 'Componentbuilder Joomla_component'; - $joomla_component->type_alias = 'com_componentbuilder.joomla_component'; - $joomla_component->table = '{"special": {"dbtable": "#__componentbuilder_joomla_component","key": "id","type": "Joomla_component","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $joomla_component->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "system_name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "css_admin","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "metadata","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "metakey","core_metadesc": "metadesc","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","name_code":"name_code","short_description":"short_description","companyname":"companyname","css_admin":"css_admin","php_admin_event":"php_admin_event","php_site_event":"php_site_event","crowdin_username":"crowdin_username","component_version":"component_version","php_postflight_install":"php_postflight_install","remove_line_breaks":"remove_line_breaks","description":"description","sql_uninstall":"sql_uninstall","debug_linenr":"debug_linenr","mvc_versiondate":"mvc_versiondate","php_preflight_install":"php_preflight_install","backup_folder_path":"backup_folder_path","php_method_uninstall":"php_method_uninstall","add_placeholders":"add_placeholders","author":"author","add_sales_server":"add_sales_server","email":"email","translation_tool":"translation_tool","website":"website","buildcompsql":"buildcompsql","add_license":"add_license","php_helper_admin":"php_helper_admin","license_type":"license_type","php_helper_site":"php_helper_site","javascript":"javascript","whmcs_key":"whmcs_key","css_site":"css_site","whmcs_url":"whmcs_url","whmcs_buy_link":"whmcs_buy_link","php_preflight_update":"php_preflight_update","license":"license","php_postflight_update":"php_postflight_update","bom":"bom","sql":"sql","image":"image","addreadme":"addreadme","copyright":"copyright","update_server_url":"update_server_url","add_powers":"add_powers","add_backup_folder_path":"add_backup_folder_path","crowdin_project_identifier":"crowdin_project_identifier","add_php_helper_admin":"add_php_helper_admin","add_admin_event":"add_admin_event","add_php_helper_site":"add_php_helper_site","add_site_event":"add_site_event","add_javascript":"add_javascript","add_menu_prefix":"add_menu_prefix","add_css_admin":"add_css_admin","menu_prefix":"menu_prefix","add_css_site":"add_css_site","dashboard_type":"dashboard_type","dashboard":"dashboard","toignore":"toignore","add_php_preflight_install":"add_php_preflight_install","add_php_preflight_update":"add_php_preflight_update","add_php_postflight_install":"add_php_postflight_install","export_key":"export_key","add_php_postflight_update":"add_php_postflight_update","joomla_source_link":"joomla_source_link","add_php_method_uninstall":"add_php_method_uninstall","export_buy_link":"export_buy_link","add_sql":"add_sql","add_sql_uninstall":"add_sql_uninstall","assets_table_fix":"assets_table_fix","readme":"readme","emptycontributors":"emptycontributors","add_update_server":"add_update_server","number":"number","update_server_target":"update_server_target","update_server":"update_server","sales_server":"sales_server","add_git_folder_path":"add_git_folder_path","git_folder_path":"git_folder_path","creatuserhelper":"creatuserhelper","adduikit":"adduikit","crowdin_project_api_key":"crowdin_project_api_key","addfootable":"addfootable","crowdin_account_api_key":"crowdin_account_api_key","add_email_helper":"add_email_helper","buildcomp":"buildcomp","add_php_helper_both":"add_php_helper_both","guid":"guid","php_helper_both":"php_helper_both","name":"name"}}'; - $joomla_component->router = 'ComponentbuilderHelperRoute::getJoomla_componentRoute'; - $joomla_component->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/joomla_component.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","remove_line_breaks","debug_linenr","mvc_versiondate","add_placeholders","add_sales_server","translation_tool","add_license","license_type","addreadme","add_powers","add_backup_folder_path","add_php_helper_admin","add_admin_event","add_php_helper_site","add_site_event","add_javascript","add_css_admin","add_css_site","dashboard_type","add_php_preflight_install","add_php_preflight_update","add_php_postflight_install","add_php_postflight_update","add_php_method_uninstall","add_sql","add_sql_uninstall","assets_table_fix","emptycontributors","add_update_server","number","update_server_target","update_server","sales_server","add_git_folder_path","creatuserhelper","adduikit","addfootable","add_email_helper","buildcomp","add_php_helper_both"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "dashboard","targetTable": "#__componentbuilder_custom_admin_view","targetColumn": "","displayColumn": "system_name"},{"sourceColumn": "update_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "sales_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $joomla_component_Inserted = $db->insertObject('#__content_types', $joomla_component); - - // Create the joomla_module content type object. - $joomla_module = new stdClass(); - $joomla_module->type_title = 'Componentbuilder Joomla_module'; - $joomla_module->type_alias = 'com_componentbuilder.joomla_module'; - $joomla_module->table = '{"special": {"dbtable": "#__componentbuilder_joomla_module","key": "id","type": "Joomla_module","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $joomla_module->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "system_name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "default","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","target":"target","description":"description","add_php_method_uninstall":"add_php_method_uninstall","add_php_postflight_update":"add_php_postflight_update","add_php_postflight_install":"add_php_postflight_install","add_php_preflight_uninstall":"add_php_preflight_uninstall","addreadme":"addreadme","default":"default","snippet":"snippet","add_sql":"add_sql","update_server_target":"update_server_target","add_sql_uninstall":"add_sql_uninstall","update_server":"update_server","add_update_server":"add_update_server","libraries":"libraries","module_version":"module_version","sales_server":"sales_server","custom_get":"custom_get","php_preflight_update":"php_preflight_update","php_preflight_uninstall":"php_preflight_uninstall","mod_code":"mod_code","php_postflight_install":"php_postflight_install","add_class_helper":"add_class_helper","php_postflight_update":"php_postflight_update","add_class_helper_header":"add_class_helper_header","php_method_uninstall":"php_method_uninstall","class_helper_header":"class_helper_header","sql":"sql","class_helper_code":"class_helper_code","sql_uninstall":"sql_uninstall","readme":"readme","add_php_script_construct":"add_php_script_construct","update_server_url":"update_server_url","php_script_construct":"php_script_construct","add_php_preflight_install":"add_php_preflight_install","php_preflight_install":"php_preflight_install","add_sales_server":"add_sales_server","add_php_preflight_update":"add_php_preflight_update","guid":"guid","name":"name"}}'; - $joomla_module->router = 'ComponentbuilderHelperRoute::getJoomla_moduleRoute'; - $joomla_module->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/joomla_module.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","target","add_php_method_uninstall","add_php_postflight_update","add_php_postflight_install","add_php_preflight_uninstall","addreadme","snippet","add_sql","update_server_target","add_sql_uninstall","update_server","add_update_server","sales_server","add_class_helper","add_class_helper_header","add_php_script_construct","add_php_preflight_install","add_sales_server","add_php_preflight_update"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "snippet","targetTable": "#__componentbuilder_snippet","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "update_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "sales_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "custom_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $joomla_module_Inserted = $db->insertObject('#__content_types', $joomla_module); - - // Create the joomla_plugin content type object. - $joomla_plugin = new stdClass(); - $joomla_plugin->type_title = 'Componentbuilder Joomla_plugin'; - $joomla_plugin->type_alias = 'com_componentbuilder.joomla_plugin'; - $joomla_plugin->table = '{"special": {"dbtable": "#__componentbuilder_joomla_plugin","key": "id","type": "Joomla_plugin","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $joomla_plugin->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "system_name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "head","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","class_extends":"class_extends","joomla_plugin_group":"joomla_plugin_group","add_sql":"add_sql","add_php_method_uninstall":"add_php_method_uninstall","add_php_postflight_update":"add_php_postflight_update","add_php_postflight_install":"add_php_postflight_install","sales_server":"sales_server","add_update_server":"add_update_server","add_head":"add_head","add_sql_uninstall":"add_sql_uninstall","addreadme":"addreadme","head":"head","update_server_target":"update_server_target","main_class_code":"main_class_code","update_server":"update_server","description":"description","php_postflight_install":"php_postflight_install","plugin_version":"plugin_version","php_postflight_update":"php_postflight_update","php_method_uninstall":"php_method_uninstall","add_php_script_construct":"add_php_script_construct","sql":"sql","php_script_construct":"php_script_construct","sql_uninstall":"sql_uninstall","add_php_preflight_install":"add_php_preflight_install","readme":"readme","php_preflight_install":"php_preflight_install","update_server_url":"update_server_url","add_php_preflight_update":"add_php_preflight_update","php_preflight_update":"php_preflight_update","add_php_preflight_uninstall":"add_php_preflight_uninstall","add_sales_server":"add_sales_server","php_preflight_uninstall":"php_preflight_uninstall","guid":"guid","name":"name"}}'; - $joomla_plugin->router = 'ComponentbuilderHelperRoute::getJoomla_pluginRoute'; - $joomla_plugin->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/joomla_plugin.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","class_extends","joomla_plugin_group","add_sql","add_php_method_uninstall","add_php_postflight_update","add_php_postflight_install","sales_server","add_update_server","add_head","add_sql_uninstall","addreadme","update_server_target","update_server","add_php_script_construct","add_php_preflight_install","add_php_preflight_update","add_php_preflight_uninstall","add_sales_server"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "class_extends","targetTable": "#__componentbuilder_class_extends","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_plugin_group","targetTable": "#__componentbuilder_joomla_plugin_group","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "sales_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "update_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $joomla_plugin_Inserted = $db->insertObject('#__content_types', $joomla_plugin); - - // Create the power content type object. - $power = new stdClass(); - $power->type_title = 'Componentbuilder Power'; - $power->type_alias = 'com_componentbuilder.power'; - $power->table = '{"special": {"dbtable": "#__componentbuilder_power","key": "id","type": "Power","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $power->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "system_name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "head","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","namespace":"namespace","type":"type","power_version":"power_version","licensing_template":"licensing_template","description":"description","extends":"extends","approved":"approved","add_head":"add_head","extends_custom":"extends_custom","implements_custom":"implements_custom","implements":"implements","head":"head","approved_paths":"approved_paths","main_class_code":"main_class_code","add_licensing_template":"add_licensing_template","guid":"guid","name":"name"}}'; - $power->router = 'ComponentbuilderHelperRoute::getPowerRoute'; - $power->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/power.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","approved","add_head","add_licensing_template"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "extends","targetTable": "#__componentbuilder_power","targetColumn": "guid","displayColumn": "name"},{"sourceColumn": "implements","targetTable": "#__componentbuilder_power","targetColumn": "guid","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $power_Inserted = $db->insertObject('#__content_types', $power); - - // Create the admin_view content type object. - $admin_view = new stdClass(); - $admin_view->type_title = 'Componentbuilder Admin_view'; - $admin_view->type_alias = 'com_componentbuilder.admin_view'; - $admin_view->table = '{"special": {"dbtable": "#__componentbuilder_admin_view","key": "id","type": "Admin_view","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $admin_view->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "null","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "php_allowedit","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","name_single":"name_single","short_description":"short_description","php_allowedit":"php_allowedit","php_postsavehook":"php_postsavehook","php_before_save":"php_before_save","php_getlistquery":"php_getlistquery","php_import_ext":"php_import_ext","icon":"icon","php_after_publish":"php_after_publish","add_fadein":"add_fadein","description":"description","icon_category":"icon_category","icon_add":"icon_add","php_after_cancel":"php_after_cancel","mysql_table_charset":"mysql_table_charset","php_batchmove":"php_batchmove","type":"type","php_after_delete":"php_after_delete","source":"source","php_import":"php_import","php_getitems_after_all":"php_getitems_after_all","php_getform":"php_getform","php_save":"php_save","php_allowadd":"php_allowadd","php_before_cancel":"php_before_cancel","php_batchcopy":"php_batchcopy","php_before_publish":"php_before_publish","alias_builder_type":"alias_builder_type","php_before_delete":"php_before_delete","php_document":"php_document","mysql_table_row_format":"mysql_table_row_format","alias_builder":"alias_builder","sql":"sql","php_import_display":"php_import_display","add_category_submenu":"add_category_submenu","php_import_setdata":"php_import_setdata","name_list":"name_list","add_php_getlistquery":"add_php_getlistquery","add_css_view":"add_css_view","add_php_getform":"add_php_getform","css_view":"css_view","add_php_before_save":"add_php_before_save","add_css_views":"add_css_views","add_php_save":"add_php_save","css_views":"css_views","add_php_postsavehook":"add_php_postsavehook","add_javascript_view_file":"add_javascript_view_file","add_php_allowadd":"add_php_allowadd","javascript_view_file":"javascript_view_file","add_php_allowedit":"add_php_allowedit","add_javascript_view_footer":"add_javascript_view_footer","add_php_before_cancel":"add_php_before_cancel","javascript_view_footer":"javascript_view_footer","add_php_after_cancel":"add_php_after_cancel","add_javascript_views_file":"add_javascript_views_file","add_php_batchcopy":"add_php_batchcopy","javascript_views_file":"javascript_views_file","add_php_batchmove":"add_php_batchmove","add_javascript_views_footer":"add_javascript_views_footer","add_php_before_publish":"add_php_before_publish","javascript_views_footer":"javascript_views_footer","add_php_after_publish":"add_php_after_publish","add_custom_button":"add_custom_button","add_php_before_delete":"add_php_before_delete","add_php_after_delete":"add_php_after_delete","php_controller":"php_controller","add_php_document":"add_php_document","php_model":"php_model","mysql_table_engine":"mysql_table_engine","php_controller_list":"php_controller_list","mysql_table_collate":"mysql_table_collate","php_model_list":"php_model_list","add_sql":"add_sql","add_php_ajax":"add_php_ajax","php_ajaxmethod":"php_ajaxmethod","add_custom_import":"add_custom_import","add_php_getitem":"add_php_getitem","html_import_view":"html_import_view","php_getitem":"php_getitem","php_import_headers":"php_import_headers","add_php_getitems":"add_php_getitems","php_import_save":"php_import_save","php_getitems":"php_getitems","guid":"guid","add_php_getitems_after_all":"add_php_getitems_after_all"}}'; - $admin_view->router = 'ComponentbuilderHelperRoute::getAdmin_viewRoute'; - $admin_view->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/admin_view.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","add_fadein","type","source","add_category_submenu","add_php_getlistquery","add_css_view","add_php_getform","add_php_before_save","add_css_views","add_php_save","add_php_postsavehook","add_javascript_view_file","add_php_allowadd","add_php_allowedit","add_javascript_view_footer","add_php_before_cancel","add_php_after_cancel","add_javascript_views_file","add_php_batchcopy","add_php_batchmove","add_javascript_views_footer","add_php_before_publish","add_php_after_publish","add_custom_button","add_php_before_delete","add_php_after_delete","add_php_document","add_sql","add_php_ajax","add_custom_import","add_php_getitem","add_php_getitems","add_php_getitems_after_all"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "alias_builder","targetTable": "#__componentbuilder_field","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $admin_view_Inserted = $db->insertObject('#__content_types', $admin_view); - - // Create the custom_admin_view content type object. - $custom_admin_view = new stdClass(); - $custom_admin_view->type_title = 'Componentbuilder Custom_admin_view'; - $custom_admin_view->type_alias = 'com_componentbuilder.custom_admin_view'; - $custom_admin_view->table = '{"special": {"dbtable": "#__componentbuilder_custom_admin_view","key": "id","type": "Custom_admin_view","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $custom_admin_view->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "css_document","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","name":"name","description":"description","main_get":"main_get","add_php_jview_display":"add_php_jview_display","css_document":"css_document","css":"css","js_document":"js_document","javascript_file":"javascript_file","codename":"codename","default":"default","snippet":"snippet","icon":"icon","add_php_jview":"add_php_jview","context":"context","add_js_document":"add_js_document","custom_get":"custom_get","add_javascript_file":"add_javascript_file","php_ajaxmethod":"php_ajaxmethod","add_css_document":"add_css_document","add_php_document":"add_php_document","add_css":"add_css","add_php_view":"add_php_view","add_php_ajax":"add_php_ajax","libraries":"libraries","dynamic_get":"dynamic_get","php_document":"php_document","php_view":"php_view","add_custom_button":"add_custom_button","php_jview_display":"php_jview_display","php_jview":"php_jview","php_controller":"php_controller","guid":"guid","php_model":"php_model"}}'; - $custom_admin_view->router = 'ComponentbuilderHelperRoute::getCustom_admin_viewRoute'; - $custom_admin_view->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/custom_admin_view.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","main_get","add_php_jview_display","snippet","add_php_jview","add_js_document","add_javascript_file","add_css_document","add_php_document","add_css","add_php_view","add_php_ajax","dynamic_get","add_custom_button"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "main_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "snippet","targetTable": "#__componentbuilder_snippet","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "custom_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "dynamic_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $custom_admin_view_Inserted = $db->insertObject('#__content_types', $custom_admin_view); - - // Create the site_view content type object. - $site_view = new stdClass(); - $site_view->type_title = 'Componentbuilder Site_view'; - $site_view->type_alias = 'com_componentbuilder.site_view'; - $site_view->table = '{"special": {"dbtable": "#__componentbuilder_site_view","key": "id","type": "Site_view","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $site_view->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "js_document","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","name":"name","description":"description","main_get":"main_get","add_php_jview_display":"add_php_jview_display","add_php_document":"add_php_document","add_php_view":"add_php_view","js_document":"js_document","codename":"codename","javascript_file":"javascript_file","context":"context","default":"default","snippet":"snippet","add_php_jview":"add_php_jview","custom_get":"custom_get","css_document":"css_document","add_javascript_file":"add_javascript_file","css":"css","add_js_document":"add_js_document","php_ajaxmethod":"php_ajaxmethod","add_css_document":"add_css_document","libraries":"libraries","add_css":"add_css","dynamic_get":"dynamic_get","add_php_ajax":"add_php_ajax","add_custom_button":"add_custom_button","php_document":"php_document","button_position":"button_position","php_view":"php_view","php_jview_display":"php_jview_display","php_jview":"php_jview","php_controller":"php_controller","guid":"guid","php_model":"php_model"}}'; - $site_view->router = 'ComponentbuilderHelperRoute::getSite_viewRoute'; - $site_view->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/site_view.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","main_get","add_php_jview_display","add_php_document","add_php_view","snippet","add_php_jview","add_javascript_file","add_js_document","add_css_document","add_css","dynamic_get","add_php_ajax","add_custom_button","button_position"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "main_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "snippet","targetTable": "#__componentbuilder_snippet","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "custom_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "dynamic_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $site_view_Inserted = $db->insertObject('#__content_types', $site_view); - - // Create the template content type object. - $template = new stdClass(); - $template->type_title = 'Componentbuilder Template'; - $template->type_alias = 'com_componentbuilder.template'; - $template->table = '{"special": {"dbtable": "#__componentbuilder_template","key": "id","type": "Template","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $template->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "php_view","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description","dynamic_get":"dynamic_get","php_view":"php_view","add_php_view":"add_php_view","template":"template","snippet":"snippet","libraries":"libraries","alias":"alias"}}'; - $template->router = 'ComponentbuilderHelperRoute::getTemplateRoute'; - $template->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/template.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","dynamic_get","add_php_view","snippet"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "dynamic_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "snippet","targetTable": "#__componentbuilder_snippet","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $template_Inserted = $db->insertObject('#__content_types', $template); - - // Create the layout content type object. - $layout = new stdClass(); - $layout->type_title = 'Componentbuilder Layout'; - $layout->type_alias = 'com_componentbuilder.layout'; - $layout->table = '{"special": {"dbtable": "#__componentbuilder_layout","key": "id","type": "Layout","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $layout->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "php_view","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description","dynamic_get":"dynamic_get","snippet":"snippet","php_view":"php_view","add_php_view":"add_php_view","layout":"layout","libraries":"libraries","alias":"alias"}}'; - $layout->router = 'ComponentbuilderHelperRoute::getLayoutRoute'; - $layout->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/layout.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","dynamic_get","snippet","add_php_view"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "dynamic_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "snippet","targetTable": "#__componentbuilder_snippet","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $layout_Inserted = $db->insertObject('#__content_types', $layout); - - // Create the dynamic_get content type object. - $dynamic_get = new stdClass(); - $dynamic_get->type_title = 'Componentbuilder Dynamic_get'; - $dynamic_get->type_alias = 'com_componentbuilder.dynamic_get'; - $dynamic_get->table = '{"special": {"dbtable": "#__componentbuilder_dynamic_get","key": "id","type": "Dynamic_get","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $dynamic_get->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "php_before_getitems","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","main_source":"main_source","gettype":"gettype","php_router_parse":"php_router_parse","php_before_getitems":"php_before_getitems","php_after_getitems":"php_after_getitems","php_after_getitem":"php_after_getitem","php_getlistquery":"php_getlistquery","view_selection":"view_selection","db_table_main":"db_table_main","php_custom_get":"php_custom_get","plugin_events":"plugin_events","db_selection":"db_selection","php_calculation":"php_calculation","php_before_getitem":"php_before_getitem","view_table_main":"view_table_main","select_all":"select_all","add_php_before_getitem":"add_php_before_getitem","getcustom":"getcustom","add_php_after_getitem":"add_php_after_getitem","pagination":"pagination","add_php_getlistquery":"add_php_getlistquery","add_php_before_getitems":"add_php_before_getitems","add_php_after_getitems":"add_php_after_getitems","add_php_router_parse":"add_php_router_parse","addcalculation":"addcalculation","guid":"guid"}}'; - $dynamic_get->router = 'ComponentbuilderHelperRoute::getDynamic_getRoute'; - $dynamic_get->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/dynamic_get.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","main_source","gettype","view_table_main","select_all","add_php_before_getitem","add_php_after_getitem","pagination","add_php_getlistquery","add_php_before_getitems","add_php_after_getitems","add_php_router_parse"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "view_table_main","targetTable": "#__componentbuilder_admin_view","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $dynamic_get_Inserted = $db->insertObject('#__content_types', $dynamic_get); - - // Create the custom_code content type object. - $custom_code = new stdClass(); - $custom_code->type_title = 'Componentbuilder Custom_code'; - $custom_code->type_alias = 'com_componentbuilder.custom_code'; - $custom_code->table = '{"special": {"dbtable": "#__componentbuilder_custom_code","key": "id","type": "Custom_code","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $custom_code->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "code","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"component":"component","path":"path","target":"target","type":"type","comment_type":"comment_type","function_name":"function_name","system_name":"system_name","code":"code","hashendtarget":"hashendtarget","to_line":"to_line","from_line":"from_line","hashtarget":"hashtarget"}}'; - $custom_code->router = 'ComponentbuilderHelperRoute::getCustom_codeRoute'; - $custom_code->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/custom_code.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","component","target","type","comment_type"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $custom_code_Inserted = $db->insertObject('#__content_types', $custom_code); - - // Create the class_property content type object. - $class_property = new stdClass(); - $class_property->type_title = 'Componentbuilder Class_property'; - $class_property->type_alias = 'com_componentbuilder.class_property'; - $class_property->table = '{"special": {"dbtable": "#__componentbuilder_class_property","key": "id","type": "Class_property","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $class_property->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","visibility":"visibility","extension_type":"extension_type","guid":"guid","comment":"comment","joomla_plugin_group":"joomla_plugin_group","default":"default"}}'; - $class_property->router = 'ComponentbuilderHelperRoute::getClass_propertyRoute'; - $class_property->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/class_property.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_plugin_group"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_plugin_group","targetTable": "#__componentbuilder_joomla_plugin_group","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $class_property_Inserted = $db->insertObject('#__content_types', $class_property); - - // Create the class_method content type object. - $class_method = new stdClass(); - $class_method->type_title = 'Componentbuilder Class_method'; - $class_method->type_alias = 'com_componentbuilder.class_method'; - $class_method->table = '{"special": {"dbtable": "#__componentbuilder_class_method","key": "id","type": "Class_method","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $class_method->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "code","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","visibility":"visibility","extension_type":"extension_type","guid":"guid","code":"code","comment":"comment","joomla_plugin_group":"joomla_plugin_group","arguments":"arguments"}}'; - $class_method->router = 'ComponentbuilderHelperRoute::getClass_methodRoute'; - $class_method->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/class_method.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_plugin_group"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_plugin_group","targetTable": "#__componentbuilder_joomla_plugin_group","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $class_method_Inserted = $db->insertObject('#__content_types', $class_method); - - // Create the placeholder content type object. - $placeholder = new stdClass(); - $placeholder->type_title = 'Componentbuilder Placeholder'; - $placeholder->type_alias = 'com_componentbuilder.placeholder'; - $placeholder->table = '{"special": {"dbtable": "#__componentbuilder_placeholder","key": "id","type": "Placeholder","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $placeholder->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "target","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"target":"target","value":"value"}}'; - $placeholder->router = 'ComponentbuilderHelperRoute::getPlaceholderRoute'; - $placeholder->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/placeholder.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $placeholder_Inserted = $db->insertObject('#__content_types', $placeholder); - - // Create the library content type object. - $library = new stdClass(); - $library->type_title = 'Componentbuilder Library'; - $library->type_alias = 'com_componentbuilder.library'; - $library->table = '{"special": {"dbtable": "#__componentbuilder_library","key": "id","type": "Library","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $library->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","target":"target","how":"how","type":"type","description":"description","libraries":"libraries","php_setdocument":"php_setdocument","guid":"guid"}}'; - $library->router = 'ComponentbuilderHelperRoute::getLibraryRoute'; - $library->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/library.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","target","how","type"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $library_Inserted = $db->insertObject('#__content_types', $library); - - // Create the snippet content type object. - $snippet = new stdClass(); - $snippet->type_title = 'Componentbuilder Snippet'; - $snippet->type_alias = 'com_componentbuilder.snippet'; - $snippet->table = '{"special": {"dbtable": "#__componentbuilder_snippet","key": "id","type": "Snippet","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $snippet->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","url":"url","type":"type","heading":"heading","library":"library","guid":"guid","contributor_email":"contributor_email","contributor_name":"contributor_name","contributor_website":"contributor_website","contributor_company":"contributor_company","snippet":"snippet","usage":"usage","description":"description"}}'; - $snippet->router = 'ComponentbuilderHelperRoute::getSnippetRoute'; - $snippet->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/snippet.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","type","library"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "type","targetTable": "#__componentbuilder_snippet_type","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "library","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $snippet_Inserted = $db->insertObject('#__content_types', $snippet); - - // Create the validation_rule content type object. - $validation_rule = new stdClass(); - $validation_rule->type_title = 'Componentbuilder Validation_rule'; - $validation_rule->type_alias = 'com_componentbuilder.validation_rule'; - $validation_rule->table = '{"special": {"dbtable": "#__componentbuilder_validation_rule","key": "id","type": "Validation_rule","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $validation_rule->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","short_description":"short_description","inherit":"inherit","php":"php"}}'; - $validation_rule->router = 'ComponentbuilderHelperRoute::getValidation_ruleRoute'; - $validation_rule->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/validation_rule.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "inherit","targetTable": "#__componentbuilder_validation_rule","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $validation_rule_Inserted = $db->insertObject('#__content_types', $validation_rule); - - // Create the field content type object. - $field = new stdClass(); - $field->type_title = 'Componentbuilder Field'; - $field->type_alias = 'com_componentbuilder.field'; - $field->table = '{"special": {"dbtable": "#__componentbuilder_field","key": "id","type": "Field","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $field->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "css_views","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "catid","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","fieldtype":"fieldtype","datatype":"datatype","indexes":"indexes","null_switch":"null_switch","store":"store","on_save_model_field":"on_save_model_field","initiator_on_get_model":"initiator_on_get_model","initiator_on_save_model":"initiator_on_save_model","xml":"xml","datalenght":"datalenght","css_views":"css_views","css_view":"css_view","datadefault_other":"datadefault_other","datadefault":"datadefault","datalenght_other":"datalenght_other","on_get_model_field":"on_get_model_field","javascript_view_footer":"javascript_view_footer","javascript_views_footer":"javascript_views_footer","add_css_view":"add_css_view","add_css_views":"add_css_views","add_javascript_view_footer":"add_javascript_view_footer","add_javascript_views_footer":"add_javascript_views_footer","guid":"guid"}}'; - $field->router = 'ComponentbuilderHelperRoute::getFieldRoute'; - $field->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/field.xml","hideFields": ["asset_id","checked_out","checked_out_time","version","xml"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","fieldtype","store","catid","add_css_view","add_css_views","add_javascript_view_footer","add_javascript_views_footer"],"displayLookup": [{"sourceColumn": "catid","targetTable": "#__categories","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "fieldtype","targetTable": "#__componentbuilder_fieldtype","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $field_Inserted = $db->insertObject('#__content_types', $field); - - // Create the field category content type object. - $field_category = new stdClass(); - $field_category->type_title = 'Componentbuilder Field Catid'; - $field_category->type_alias = 'com_componentbuilder.field.category'; - $field_category->table = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}'; - $field_category->field_mappings = '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}'; - $field_category->router = 'ComponentbuilderHelperRoute::getCategoryRoute'; - $field_category->content_history_options = '{"formFile":"administrator\/components\/com_categories\/models\/forms\/category.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"], "ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version", "hits", "path"],"convertToInt":["publish_up", "publish_down"], "displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}'; - - // Set the object into the content types table. - $field_category_Inserted = $db->insertObject('#__content_types', $field_category); - - // Create the fieldtype content type object. - $fieldtype = new stdClass(); - $fieldtype->type_title = 'Componentbuilder Fieldtype'; - $fieldtype->type_alias = 'com_componentbuilder.fieldtype'; - $fieldtype->table = '{"special": {"dbtable": "#__componentbuilder_fieldtype","key": "id","type": "Fieldtype","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $fieldtype->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "catid","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","store":"store","null_switch":"null_switch","indexes":"indexes","datadefault_other":"datadefault_other","datadefault":"datadefault","short_description":"short_description","datatype":"datatype","has_defaults":"has_defaults","description":"description","datalenght":"datalenght","datalenght_other":"datalenght_other","guid":"guid"}}'; - $fieldtype->router = 'ComponentbuilderHelperRoute::getFieldtypeRoute'; - $fieldtype->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/fieldtype.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","store","has_defaults","catid"],"displayLookup": [{"sourceColumn": "catid","targetTable": "#__categories","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $fieldtype_Inserted = $db->insertObject('#__content_types', $fieldtype); - - // Create the fieldtype category content type object. - $fieldtype_category = new stdClass(); - $fieldtype_category->type_title = 'Componentbuilder Fieldtype Catid'; - $fieldtype_category->type_alias = 'com_componentbuilder.fieldtype.category'; - $fieldtype_category->table = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}'; - $fieldtype_category->field_mappings = '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}'; - $fieldtype_category->router = 'ComponentbuilderHelperRoute::getCategoryRoute'; - $fieldtype_category->content_history_options = '{"formFile":"administrator\/components\/com_categories\/models\/forms\/category.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"], "ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version", "hits", "path"],"convertToInt":["publish_up", "publish_down"], "displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}'; - - // Set the object into the content types table. - $fieldtype_category_Inserted = $db->insertObject('#__content_types', $fieldtype_category); - - // Create the language_translation content type object. - $language_translation = new stdClass(); - $language_translation->type_title = 'Componentbuilder Language_translation'; - $language_translation->type_alias = 'com_componentbuilder.language_translation'; - $language_translation->table = '{"special": {"dbtable": "#__componentbuilder_language_translation","key": "id","type": "Language_translation","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $language_translation->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "source","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"source":"source","plugins":"plugins","modules":"modules","components":"components"}}'; - $language_translation->router = 'ComponentbuilderHelperRoute::getLanguage_translationRoute'; - $language_translation->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/language_translation.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "plugins","targetTable": "#__componentbuilder_joomla_plugin","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "modules","targetTable": "#__componentbuilder_joomla_module","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "components","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $language_translation_Inserted = $db->insertObject('#__content_types', $language_translation); - - // Create the language content type object. - $language = new stdClass(); - $language->type_title = 'Componentbuilder Language'; - $language->type_alias = 'com_componentbuilder.language'; - $language->table = '{"special": {"dbtable": "#__componentbuilder_language","key": "id","type": "Language","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $language->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","langtag":"langtag"}}'; - $language->router = 'ComponentbuilderHelperRoute::getLanguageRoute'; - $language->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/language.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $language_Inserted = $db->insertObject('#__content_types', $language); - - // Create the server content type object. - $server = new stdClass(); - $server->type_title = 'Componentbuilder Server'; - $server->type_alias = 'com_componentbuilder.server'; - $server->table = '{"special": {"dbtable": "#__componentbuilder_server","key": "id","type": "Server","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $server->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","protocol":"protocol","signature":"signature","private_key":"private_key","secret":"secret","password":"password","private":"private","authentication":"authentication","path":"path","port":"port","host":"host","username":"username"}}'; - $server->router = 'ComponentbuilderHelperRoute::getServerRoute'; - $server->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/server.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","protocol","authentication"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $server_Inserted = $db->insertObject('#__content_types', $server); - - // Create the help_document content type object. - $help_document = new stdClass(); - $help_document->type_title = 'Componentbuilder Help_document'; - $help_document->type_alias = 'com_componentbuilder.help_document'; - $help_document->table = '{"special": {"dbtable": "#__componentbuilder_help_document","key": "id","type": "Help_document","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $help_document->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "title","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "content","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "null","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"title":"title","type":"type","groups":"groups","location":"location","admin_view":"admin_view","site_view":"site_view","not_required":"not_required","content":"content","article":"article","url":"url","target":"target","alias":"alias"}}'; - $help_document->router = 'ComponentbuilderHelperRoute::getHelp_documentRoute'; - $help_document->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/help_document.xml","hideFields": ["asset_id","checked_out","checked_out_time","version","not_required"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","type","location","not_required","article","target"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "article","targetTable": "#__content","targetColumn": "id","displayColumn": "title"}]}'; - - // Set the object into the content types table. - $help_document_Inserted = $db->insertObject('#__content_types', $help_document); - - // Create the admin_fields content type object. - $admin_fields = new stdClass(); - $admin_fields->type_title = 'Componentbuilder Admin_fields'; - $admin_fields->type_alias = 'com_componentbuilder.admin_fields'; - $admin_fields->table = '{"special": {"dbtable": "#__componentbuilder_admin_fields","key": "id","type": "Admin_fields","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $admin_fields->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "admin_view","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"admin_view":"admin_view"}}'; - $admin_fields->router = 'ComponentbuilderHelperRoute::getAdmin_fieldsRoute'; - $admin_fields->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/admin_fields.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","admin_view"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "admin_view","targetTable": "#__componentbuilder_admin_view","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $admin_fields_Inserted = $db->insertObject('#__content_types', $admin_fields); - - // Create the admin_fields_conditions content type object. - $admin_fields_conditions = new stdClass(); - $admin_fields_conditions->type_title = 'Componentbuilder Admin_fields_conditions'; - $admin_fields_conditions->type_alias = 'com_componentbuilder.admin_fields_conditions'; - $admin_fields_conditions->table = '{"special": {"dbtable": "#__componentbuilder_admin_fields_conditions","key": "id","type": "Admin_fields_conditions","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $admin_fields_conditions->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "admin_view","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"admin_view":"admin_view"}}'; - $admin_fields_conditions->router = 'ComponentbuilderHelperRoute::getAdmin_fields_conditionsRoute'; - $admin_fields_conditions->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/admin_fields_conditions.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","admin_view"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "admin_view","targetTable": "#__componentbuilder_admin_view","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $admin_fields_conditions_Inserted = $db->insertObject('#__content_types', $admin_fields_conditions); - - // Create the admin_fields_relations content type object. - $admin_fields_relations = new stdClass(); - $admin_fields_relations->type_title = 'Componentbuilder Admin_fields_relations'; - $admin_fields_relations->type_alias = 'com_componentbuilder.admin_fields_relations'; - $admin_fields_relations->table = '{"special": {"dbtable": "#__componentbuilder_admin_fields_relations","key": "id","type": "Admin_fields_relations","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $admin_fields_relations->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "admin_view","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"admin_view":"admin_view"}}'; - $admin_fields_relations->router = 'ComponentbuilderHelperRoute::getAdmin_fields_relationsRoute'; - $admin_fields_relations->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/admin_fields_relations.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","admin_view"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "admin_view","targetTable": "#__componentbuilder_admin_view","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $admin_fields_relations_Inserted = $db->insertObject('#__content_types', $admin_fields_relations); - - // Create the admin_custom_tabs content type object. - $admin_custom_tabs = new stdClass(); - $admin_custom_tabs->type_title = 'Componentbuilder Admin_custom_tabs'; - $admin_custom_tabs->type_alias = 'com_componentbuilder.admin_custom_tabs'; - $admin_custom_tabs->table = '{"special": {"dbtable": "#__componentbuilder_admin_custom_tabs","key": "id","type": "Admin_custom_tabs","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $admin_custom_tabs->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "admin_view","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"admin_view":"admin_view"}}'; - $admin_custom_tabs->router = 'ComponentbuilderHelperRoute::getAdmin_custom_tabsRoute'; - $admin_custom_tabs->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/admin_custom_tabs.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","admin_view"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "admin_view","targetTable": "#__componentbuilder_admin_view","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $admin_custom_tabs_Inserted = $db->insertObject('#__content_types', $admin_custom_tabs); - - // Create the component_admin_views content type object. - $component_admin_views = new stdClass(); - $component_admin_views->type_title = 'Componentbuilder Component_admin_views'; - $component_admin_views->type_alias = 'com_componentbuilder.component_admin_views'; - $component_admin_views->table = '{"special": {"dbtable": "#__componentbuilder_component_admin_views","key": "id","type": "Component_admin_views","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_admin_views->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_admin_views->router = 'ComponentbuilderHelperRoute::getComponent_admin_viewsRoute'; - $component_admin_views->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_admin_views.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $component_admin_views_Inserted = $db->insertObject('#__content_types', $component_admin_views); - - // Create the component_site_views content type object. - $component_site_views = new stdClass(); - $component_site_views->type_title = 'Componentbuilder Component_site_views'; - $component_site_views->type_alias = 'com_componentbuilder.component_site_views'; - $component_site_views->table = '{"special": {"dbtable": "#__componentbuilder_component_site_views","key": "id","type": "Component_site_views","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_site_views->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_site_views->router = 'ComponentbuilderHelperRoute::getComponent_site_viewsRoute'; - $component_site_views->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_site_views.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $component_site_views_Inserted = $db->insertObject('#__content_types', $component_site_views); - - // Create the component_custom_admin_views content type object. - $component_custom_admin_views = new stdClass(); - $component_custom_admin_views->type_title = 'Componentbuilder Component_custom_admin_views'; - $component_custom_admin_views->type_alias = 'com_componentbuilder.component_custom_admin_views'; - $component_custom_admin_views->table = '{"special": {"dbtable": "#__componentbuilder_component_custom_admin_views","key": "id","type": "Component_custom_admin_views","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_custom_admin_views->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_custom_admin_views->router = 'ComponentbuilderHelperRoute::getComponent_custom_admin_viewsRoute'; - $component_custom_admin_views->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_custom_admin_views.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $component_custom_admin_views_Inserted = $db->insertObject('#__content_types', $component_custom_admin_views); - - // Create the component_updates content type object. - $component_updates = new stdClass(); - $component_updates->type_title = 'Componentbuilder Component_updates'; - $component_updates->type_alias = 'com_componentbuilder.component_updates'; - $component_updates->table = '{"special": {"dbtable": "#__componentbuilder_component_updates","key": "id","type": "Component_updates","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_updates->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_updates->router = 'ComponentbuilderHelperRoute::getComponent_updatesRoute'; - $component_updates->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_updates.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $component_updates_Inserted = $db->insertObject('#__content_types', $component_updates); - - // Create the component_mysql_tweaks content type object. - $component_mysql_tweaks = new stdClass(); - $component_mysql_tweaks->type_title = 'Componentbuilder Component_mysql_tweaks'; - $component_mysql_tweaks->type_alias = 'com_componentbuilder.component_mysql_tweaks'; - $component_mysql_tweaks->table = '{"special": {"dbtable": "#__componentbuilder_component_mysql_tweaks","key": "id","type": "Component_mysql_tweaks","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_mysql_tweaks->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_mysql_tweaks->router = 'ComponentbuilderHelperRoute::getComponent_mysql_tweaksRoute'; - $component_mysql_tweaks->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_mysql_tweaks.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $component_mysql_tweaks_Inserted = $db->insertObject('#__content_types', $component_mysql_tweaks); - - // Create the component_custom_admin_menus content type object. - $component_custom_admin_menus = new stdClass(); - $component_custom_admin_menus->type_title = 'Componentbuilder Component_custom_admin_menus'; - $component_custom_admin_menus->type_alias = 'com_componentbuilder.component_custom_admin_menus'; - $component_custom_admin_menus->table = '{"special": {"dbtable": "#__componentbuilder_component_custom_admin_menus","key": "id","type": "Component_custom_admin_menus","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_custom_admin_menus->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_custom_admin_menus->router = 'ComponentbuilderHelperRoute::getComponent_custom_admin_menusRoute'; - $component_custom_admin_menus->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_custom_admin_menus.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $component_custom_admin_menus_Inserted = $db->insertObject('#__content_types', $component_custom_admin_menus); - - // Create the component_config content type object. - $component_config = new stdClass(); - $component_config->type_title = 'Componentbuilder Component_config'; - $component_config->type_alias = 'com_componentbuilder.component_config'; - $component_config->table = '{"special": {"dbtable": "#__componentbuilder_component_config","key": "id","type": "Component_config","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_config->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_config->router = 'ComponentbuilderHelperRoute::getComponent_configRoute'; - $component_config->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_config.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $component_config_Inserted = $db->insertObject('#__content_types', $component_config); - - // Create the component_dashboard content type object. - $component_dashboard = new stdClass(); - $component_dashboard->type_title = 'Componentbuilder Component_dashboard'; - $component_dashboard->type_alias = 'com_componentbuilder.component_dashboard'; - $component_dashboard->table = '{"special": {"dbtable": "#__componentbuilder_component_dashboard","key": "id","type": "Component_dashboard","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_dashboard->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component","php_dashboard_methods":"php_dashboard_methods"}}'; - $component_dashboard->router = 'ComponentbuilderHelperRoute::getComponent_dashboardRoute'; - $component_dashboard->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_dashboard.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $component_dashboard_Inserted = $db->insertObject('#__content_types', $component_dashboard); - - // Create the component_files_folders content type object. - $component_files_folders = new stdClass(); - $component_files_folders->type_title = 'Componentbuilder Component_files_folders'; - $component_files_folders->type_alias = 'com_componentbuilder.component_files_folders'; - $component_files_folders->table = '{"special": {"dbtable": "#__componentbuilder_component_files_folders","key": "id","type": "Component_files_folders","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_files_folders->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_files_folders->router = 'ComponentbuilderHelperRoute::getComponent_files_foldersRoute'; - $component_files_folders->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_files_folders.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $component_files_folders_Inserted = $db->insertObject('#__content_types', $component_files_folders); - - // Create the component_placeholders content type object. - $component_placeholders = new stdClass(); - $component_placeholders->type_title = 'Componentbuilder Component_placeholders'; - $component_placeholders->type_alias = 'com_componentbuilder.component_placeholders'; - $component_placeholders->table = '{"special": {"dbtable": "#__componentbuilder_component_placeholders","key": "id","type": "Component_placeholders","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_placeholders->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_placeholders->router = 'ComponentbuilderHelperRoute::getComponent_placeholdersRoute'; - $component_placeholders->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_placeholders.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $component_placeholders_Inserted = $db->insertObject('#__content_types', $component_placeholders); - - // Create the component_plugins content type object. - $component_plugins = new stdClass(); - $component_plugins->type_title = 'Componentbuilder Component_plugins'; - $component_plugins->type_alias = 'com_componentbuilder.component_plugins'; - $component_plugins->table = '{"special": {"dbtable": "#__componentbuilder_component_plugins","key": "id","type": "Component_plugins","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_plugins->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_plugins->router = 'ComponentbuilderHelperRoute::getComponent_pluginsRoute'; - $component_plugins->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_plugins.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $component_plugins_Inserted = $db->insertObject('#__content_types', $component_plugins); - - // Create the component_modules content type object. - $component_modules = new stdClass(); - $component_modules->type_title = 'Componentbuilder Component_modules'; - $component_modules->type_alias = 'com_componentbuilder.component_modules'; - $component_modules->table = '{"special": {"dbtable": "#__componentbuilder_component_modules","key": "id","type": "Component_modules","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_modules->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_modules->router = 'ComponentbuilderHelperRoute::getComponent_modulesRoute'; - $component_modules->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_modules.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $component_modules_Inserted = $db->insertObject('#__content_types', $component_modules); - - // Create the snippet_type content type object. - $snippet_type = new stdClass(); - $snippet_type->type_title = 'Componentbuilder Snippet_type'; - $snippet_type->type_alias = 'com_componentbuilder.snippet_type'; - $snippet_type->table = '{"special": {"dbtable": "#__componentbuilder_snippet_type","key": "id","type": "Snippet_type","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $snippet_type->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description"}}'; - $snippet_type->router = 'ComponentbuilderHelperRoute::getSnippet_typeRoute'; - $snippet_type->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/snippet_type.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $snippet_type_Inserted = $db->insertObject('#__content_types', $snippet_type); - - // Create the library_config content type object. - $library_config = new stdClass(); - $library_config->type_title = 'Componentbuilder Library_config'; - $library_config->type_alias = 'com_componentbuilder.library_config'; - $library_config->table = '{"special": {"dbtable": "#__componentbuilder_library_config","key": "id","type": "Library_config","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $library_config->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "library","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"library":"library"}}'; - $library_config->router = 'ComponentbuilderHelperRoute::getLibrary_configRoute'; - $library_config->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/library_config.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","library"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "library","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $library_config_Inserted = $db->insertObject('#__content_types', $library_config); - - // Create the library_files_folders_urls content type object. - $library_files_folders_urls = new stdClass(); - $library_files_folders_urls->type_title = 'Componentbuilder Library_files_folders_urls'; - $library_files_folders_urls->type_alias = 'com_componentbuilder.library_files_folders_urls'; - $library_files_folders_urls->table = '{"special": {"dbtable": "#__componentbuilder_library_files_folders_urls","key": "id","type": "Library_files_folders_urls","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $library_files_folders_urls->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "library","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"library":"library"}}'; - $library_files_folders_urls->router = 'ComponentbuilderHelperRoute::getLibrary_files_folders_urlsRoute'; - $library_files_folders_urls->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/library_files_folders_urls.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","library"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "library","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $library_files_folders_urls_Inserted = $db->insertObject('#__content_types', $library_files_folders_urls); - - // Create the class_extends content type object. - $class_extends = new stdClass(); - $class_extends->type_title = 'Componentbuilder Class_extends'; - $class_extends->type_alias = 'com_componentbuilder.class_extends'; - $class_extends->table = '{"special": {"dbtable": "#__componentbuilder_class_extends","key": "id","type": "Class_extends","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $class_extends->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "head","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","extension_type":"extension_type","head":"head","comment":"comment"}}'; - $class_extends->router = 'ComponentbuilderHelperRoute::getClass_extendsRoute'; - $class_extends->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/class_extends.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $class_extends_Inserted = $db->insertObject('#__content_types', $class_extends); - - // Create the joomla_module_updates content type object. - $joomla_module_updates = new stdClass(); - $joomla_module_updates->type_title = 'Componentbuilder Joomla_module_updates'; - $joomla_module_updates->type_alias = 'com_componentbuilder.joomla_module_updates'; - $joomla_module_updates->table = '{"special": {"dbtable": "#__componentbuilder_joomla_module_updates","key": "id","type": "Joomla_module_updates","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $joomla_module_updates->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_module","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_module":"joomla_module"}}'; - $joomla_module_updates->router = 'ComponentbuilderHelperRoute::getJoomla_module_updatesRoute'; - $joomla_module_updates->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/joomla_module_updates.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_module"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_module","targetTable": "#__componentbuilder_joomla_module","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $joomla_module_updates_Inserted = $db->insertObject('#__content_types', $joomla_module_updates); - - // Create the joomla_module_files_folders_urls content type object. - $joomla_module_files_folders_urls = new stdClass(); - $joomla_module_files_folders_urls->type_title = 'Componentbuilder Joomla_module_files_folders_urls'; - $joomla_module_files_folders_urls->type_alias = 'com_componentbuilder.joomla_module_files_folders_urls'; - $joomla_module_files_folders_urls->table = '{"special": {"dbtable": "#__componentbuilder_joomla_module_files_folders_urls","key": "id","type": "Joomla_module_files_folders_urls","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $joomla_module_files_folders_urls->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_module","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_module":"joomla_module"}}'; - $joomla_module_files_folders_urls->router = 'ComponentbuilderHelperRoute::getJoomla_module_files_folders_urlsRoute'; - $joomla_module_files_folders_urls->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/joomla_module_files_folders_urls.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_module"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_module","targetTable": "#__componentbuilder_joomla_module","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $joomla_module_files_folders_urls_Inserted = $db->insertObject('#__content_types', $joomla_module_files_folders_urls); - - // Create the joomla_plugin_group content type object. - $joomla_plugin_group = new stdClass(); - $joomla_plugin_group->type_title = 'Componentbuilder Joomla_plugin_group'; - $joomla_plugin_group->type_alias = 'com_componentbuilder.joomla_plugin_group'; - $joomla_plugin_group->table = '{"special": {"dbtable": "#__componentbuilder_joomla_plugin_group","key": "id","type": "Joomla_plugin_group","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $joomla_plugin_group->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","class_extends":"class_extends"}}'; - $joomla_plugin_group->router = 'ComponentbuilderHelperRoute::getJoomla_plugin_groupRoute'; - $joomla_plugin_group->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/joomla_plugin_group.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","class_extends"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "class_extends","targetTable": "#__componentbuilder_class_extends","targetColumn": "id","displayColumn": "name"}]}'; - - // Set the object into the content types table. - $joomla_plugin_group_Inserted = $db->insertObject('#__content_types', $joomla_plugin_group); - - // Create the joomla_plugin_updates content type object. - $joomla_plugin_updates = new stdClass(); - $joomla_plugin_updates->type_title = 'Componentbuilder Joomla_plugin_updates'; - $joomla_plugin_updates->type_alias = 'com_componentbuilder.joomla_plugin_updates'; - $joomla_plugin_updates->table = '{"special": {"dbtable": "#__componentbuilder_joomla_plugin_updates","key": "id","type": "Joomla_plugin_updates","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $joomla_plugin_updates->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_plugin","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_plugin":"joomla_plugin"}}'; - $joomla_plugin_updates->router = 'ComponentbuilderHelperRoute::getJoomla_plugin_updatesRoute'; - $joomla_plugin_updates->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/joomla_plugin_updates.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_plugin"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_plugin","targetTable": "#__componentbuilder_joomla_plugin","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $joomla_plugin_updates_Inserted = $db->insertObject('#__content_types', $joomla_plugin_updates); - - // Create the joomla_plugin_files_folders_urls content type object. - $joomla_plugin_files_folders_urls = new stdClass(); - $joomla_plugin_files_folders_urls->type_title = 'Componentbuilder Joomla_plugin_files_folders_urls'; - $joomla_plugin_files_folders_urls->type_alias = 'com_componentbuilder.joomla_plugin_files_folders_urls'; - $joomla_plugin_files_folders_urls->table = '{"special": {"dbtable": "#__componentbuilder_joomla_plugin_files_folders_urls","key": "id","type": "Joomla_plugin_files_folders_urls","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $joomla_plugin_files_folders_urls->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_plugin","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_plugin":"joomla_plugin"}}'; - $joomla_plugin_files_folders_urls->router = 'ComponentbuilderHelperRoute::getJoomla_plugin_files_folders_urlsRoute'; - $joomla_plugin_files_folders_urls->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/joomla_plugin_files_folders_urls.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_plugin"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_plugin","targetTable": "#__componentbuilder_joomla_plugin","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Set the object into the content types table. - $joomla_plugin_files_folders_urls_Inserted = $db->insertObject('#__content_types', $joomla_plugin_files_folders_urls); - - - // Install the global extension params. - $query = $db->getQuery(true); - // Field to update. - $fields = array( - $db->quoteName('params') . ' = ' . $db->quote('{"autorName":"Llewellyn van der Merwe","autorEmail":"joomla@vdm.io","subform_layouts":"default","editor":"none","manage_jcb_package_directories":"2","set_browser_storage":"1","storage_time_to_live":"global","super_powers_documentation":"0","powers_repository":"0","super_powers_repositories":"0","approved_paths":"default","add_custom_gitea_url":"1","custom_gitea_url":"https://git.vdm.dev","super_powers_core_organisation":"joomla","super_powers_core":"joomla/super-powers","builder_gif_size":"480-272","compiler_plugin":["componentbuilderactionlogcompiler","componentbuilderfieldorderingcompiler","componentbuilderheaderscompiler","componentbuilderpowersautoloadercompiler","componentbuilderprivacycompiler"],"add_menu_prefix":"1","menu_prefix":"»","minify":"0","language":"en-GB","percentagelanguageadd":"30","assets_table_fix":"2","compiler_field_builder_type":"2","field_name_builder":"1","type_name_builder":"1","import_guid_only":"1","export_language_strings":"1","development_method":"1","expansion":"0","return_options_build":"2","cronjob_backup_type":"1","cronjob_backup_server":"0","backup_package_name":"JCB_Backup_[YEAR]_[MONTH]_[DAY]","export_license":"GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html","export_copyright":"Copyright (C) 2015. All Rights Reserved","check_in":"-1 day","save_history":"1","history_limit":"10","add_jquery_framework":"1","uikit_load":"1","uikit_min":"","uikit_style":""}'), - ); - // Condition. - $conditions = array( - $db->quoteName('element') . ' = ' . $db->quote('com_componentbuilder') - ); - $query->update($db->quoteName('#__extensions'))->set($fields)->where($conditions); - $db->setQuery($query); - $allDone = $db->execute(); - - // Get the biggest rule column in the assets table at this point. - $get_rule_length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1"; - $db->setQuery($get_rule_length); - if ($db->execute()) - { - $rule_length = $db->loadResult(); - // Check the size of the rules column - if ($rule_length <= 97600) - { - // Fix the assets table rules column size - $fix_rules_size = "ALTER TABLE `#__assets` CHANGE `rules` `rules` MEDIUMTEXT NOT NULL COMMENT 'JSON encoded access control. Enlarged to MEDIUMTEXT by JCB';"; - $db->setQuery($fix_rules_size); - $db->execute(); - $app->enqueueMessage(JText::_('The #__assets table rules column was resized to the MEDIUMTEXT datatype for the components possible large permission rules.')); - } - } - echo ' - - '; - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the componentbuilder action logs extensions object. - $componentbuilder_action_logs_extensions = new stdClass(); - $componentbuilder_action_logs_extensions->extension = 'com_componentbuilder'; - - // Set the object into the action logs extensions table. - $componentbuilder_action_logs_extensions_Inserted = $db->insertObject('#__action_logs_extensions', $componentbuilder_action_logs_extensions); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the joomla_component action log config object. - $joomla_component_action_log_config = new stdClass(); - $joomla_component_action_log_config->type_title = 'JOOMLA_COMPONENT'; - $joomla_component_action_log_config->type_alias = 'com_componentbuilder.joomla_component'; - $joomla_component_action_log_config->id_holder = 'id'; - $joomla_component_action_log_config->title_holder = 'system_name'; - $joomla_component_action_log_config->table_name = '#__componentbuilder_joomla_component'; - $joomla_component_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $joomla_component_Inserted = $db->insertObject('#__action_log_config', $joomla_component_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the joomla_module action log config object. - $joomla_module_action_log_config = new stdClass(); - $joomla_module_action_log_config->type_title = 'JOOMLA_MODULE'; - $joomla_module_action_log_config->type_alias = 'com_componentbuilder.joomla_module'; - $joomla_module_action_log_config->id_holder = 'id'; - $joomla_module_action_log_config->title_holder = 'system_name'; - $joomla_module_action_log_config->table_name = '#__componentbuilder_joomla_module'; - $joomla_module_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $joomla_module_Inserted = $db->insertObject('#__action_log_config', $joomla_module_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the joomla_plugin action log config object. - $joomla_plugin_action_log_config = new stdClass(); - $joomla_plugin_action_log_config->type_title = 'JOOMLA_PLUGIN'; - $joomla_plugin_action_log_config->type_alias = 'com_componentbuilder.joomla_plugin'; - $joomla_plugin_action_log_config->id_holder = 'id'; - $joomla_plugin_action_log_config->title_holder = 'system_name'; - $joomla_plugin_action_log_config->table_name = '#__componentbuilder_joomla_plugin'; - $joomla_plugin_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $joomla_plugin_Inserted = $db->insertObject('#__action_log_config', $joomla_plugin_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the power action log config object. - $power_action_log_config = new stdClass(); - $power_action_log_config->type_title = 'POWER'; - $power_action_log_config->type_alias = 'com_componentbuilder.power'; - $power_action_log_config->id_holder = 'id'; - $power_action_log_config->title_holder = 'system_name'; - $power_action_log_config->table_name = '#__componentbuilder_power'; - $power_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $power_Inserted = $db->insertObject('#__action_log_config', $power_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the admin_view action log config object. - $admin_view_action_log_config = new stdClass(); - $admin_view_action_log_config->type_title = 'ADMIN_VIEW'; - $admin_view_action_log_config->type_alias = 'com_componentbuilder.admin_view'; - $admin_view_action_log_config->id_holder = 'id'; - $admin_view_action_log_config->title_holder = 'system_name'; - $admin_view_action_log_config->table_name = '#__componentbuilder_admin_view'; - $admin_view_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $admin_view_Inserted = $db->insertObject('#__action_log_config', $admin_view_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the custom_admin_view action log config object. - $custom_admin_view_action_log_config = new stdClass(); - $custom_admin_view_action_log_config->type_title = 'CUSTOM_ADMIN_VIEW'; - $custom_admin_view_action_log_config->type_alias = 'com_componentbuilder.custom_admin_view'; - $custom_admin_view_action_log_config->id_holder = 'id'; - $custom_admin_view_action_log_config->title_holder = 'name'; - $custom_admin_view_action_log_config->table_name = '#__componentbuilder_custom_admin_view'; - $custom_admin_view_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $custom_admin_view_Inserted = $db->insertObject('#__action_log_config', $custom_admin_view_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the site_view action log config object. - $site_view_action_log_config = new stdClass(); - $site_view_action_log_config->type_title = 'SITE_VIEW'; - $site_view_action_log_config->type_alias = 'com_componentbuilder.site_view'; - $site_view_action_log_config->id_holder = 'id'; - $site_view_action_log_config->title_holder = 'name'; - $site_view_action_log_config->table_name = '#__componentbuilder_site_view'; - $site_view_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $site_view_Inserted = $db->insertObject('#__action_log_config', $site_view_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the template action log config object. - $template_action_log_config = new stdClass(); - $template_action_log_config->type_title = 'TEMPLATE'; - $template_action_log_config->type_alias = 'com_componentbuilder.template'; - $template_action_log_config->id_holder = 'id'; - $template_action_log_config->title_holder = 'name'; - $template_action_log_config->table_name = '#__componentbuilder_template'; - $template_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $template_Inserted = $db->insertObject('#__action_log_config', $template_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the layout action log config object. - $layout_action_log_config = new stdClass(); - $layout_action_log_config->type_title = 'LAYOUT'; - $layout_action_log_config->type_alias = 'com_componentbuilder.layout'; - $layout_action_log_config->id_holder = 'id'; - $layout_action_log_config->title_holder = 'name'; - $layout_action_log_config->table_name = '#__componentbuilder_layout'; - $layout_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $layout_Inserted = $db->insertObject('#__action_log_config', $layout_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the dynamic_get action log config object. - $dynamic_get_action_log_config = new stdClass(); - $dynamic_get_action_log_config->type_title = 'DYNAMIC_GET'; - $dynamic_get_action_log_config->type_alias = 'com_componentbuilder.dynamic_get'; - $dynamic_get_action_log_config->id_holder = 'id'; - $dynamic_get_action_log_config->title_holder = 'name'; - $dynamic_get_action_log_config->table_name = '#__componentbuilder_dynamic_get'; - $dynamic_get_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $dynamic_get_Inserted = $db->insertObject('#__action_log_config', $dynamic_get_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the custom_code action log config object. - $custom_code_action_log_config = new stdClass(); - $custom_code_action_log_config->type_title = 'CUSTOM_CODE'; - $custom_code_action_log_config->type_alias = 'com_componentbuilder.custom_code'; - $custom_code_action_log_config->id_holder = 'id'; - $custom_code_action_log_config->title_holder = 'component'; - $custom_code_action_log_config->table_name = '#__componentbuilder_custom_code'; - $custom_code_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $custom_code_Inserted = $db->insertObject('#__action_log_config', $custom_code_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the class_property action log config object. - $class_property_action_log_config = new stdClass(); - $class_property_action_log_config->type_title = 'CLASS_PROPERTY'; - $class_property_action_log_config->type_alias = 'com_componentbuilder.class_property'; - $class_property_action_log_config->id_holder = 'id'; - $class_property_action_log_config->title_holder = 'name'; - $class_property_action_log_config->table_name = '#__componentbuilder_class_property'; - $class_property_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $class_property_Inserted = $db->insertObject('#__action_log_config', $class_property_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the class_method action log config object. - $class_method_action_log_config = new stdClass(); - $class_method_action_log_config->type_title = 'CLASS_METHOD'; - $class_method_action_log_config->type_alias = 'com_componentbuilder.class_method'; - $class_method_action_log_config->id_holder = 'id'; - $class_method_action_log_config->title_holder = 'name'; - $class_method_action_log_config->table_name = '#__componentbuilder_class_method'; - $class_method_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $class_method_Inserted = $db->insertObject('#__action_log_config', $class_method_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the placeholder action log config object. - $placeholder_action_log_config = new stdClass(); - $placeholder_action_log_config->type_title = 'PLACEHOLDER'; - $placeholder_action_log_config->type_alias = 'com_componentbuilder.placeholder'; - $placeholder_action_log_config->id_holder = 'id'; - $placeholder_action_log_config->title_holder = 'target'; - $placeholder_action_log_config->table_name = '#__componentbuilder_placeholder'; - $placeholder_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $placeholder_Inserted = $db->insertObject('#__action_log_config', $placeholder_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the library action log config object. - $library_action_log_config = new stdClass(); - $library_action_log_config->type_title = 'LIBRARY'; - $library_action_log_config->type_alias = 'com_componentbuilder.library'; - $library_action_log_config->id_holder = 'id'; - $library_action_log_config->title_holder = 'name'; - $library_action_log_config->table_name = '#__componentbuilder_library'; - $library_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $library_Inserted = $db->insertObject('#__action_log_config', $library_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the snippet action log config object. - $snippet_action_log_config = new stdClass(); - $snippet_action_log_config->type_title = 'SNIPPET'; - $snippet_action_log_config->type_alias = 'com_componentbuilder.snippet'; - $snippet_action_log_config->id_holder = 'id'; - $snippet_action_log_config->title_holder = 'name'; - $snippet_action_log_config->table_name = '#__componentbuilder_snippet'; - $snippet_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $snippet_Inserted = $db->insertObject('#__action_log_config', $snippet_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the validation_rule action log config object. - $validation_rule_action_log_config = new stdClass(); - $validation_rule_action_log_config->type_title = 'VALIDATION_RULE'; - $validation_rule_action_log_config->type_alias = 'com_componentbuilder.validation_rule'; - $validation_rule_action_log_config->id_holder = 'id'; - $validation_rule_action_log_config->title_holder = 'name'; - $validation_rule_action_log_config->table_name = '#__componentbuilder_validation_rule'; - $validation_rule_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $validation_rule_Inserted = $db->insertObject('#__action_log_config', $validation_rule_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the field action log config object. - $field_action_log_config = new stdClass(); - $field_action_log_config->type_title = 'FIELD'; - $field_action_log_config->type_alias = 'com_componentbuilder.field'; - $field_action_log_config->id_holder = 'id'; - $field_action_log_config->title_holder = 'name'; - $field_action_log_config->table_name = '#__componentbuilder_field'; - $field_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $field_Inserted = $db->insertObject('#__action_log_config', $field_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the fieldtype action log config object. - $fieldtype_action_log_config = new stdClass(); - $fieldtype_action_log_config->type_title = 'FIELDTYPE'; - $fieldtype_action_log_config->type_alias = 'com_componentbuilder.fieldtype'; - $fieldtype_action_log_config->id_holder = 'id'; - $fieldtype_action_log_config->title_holder = 'name'; - $fieldtype_action_log_config->table_name = '#__componentbuilder_fieldtype'; - $fieldtype_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $fieldtype_Inserted = $db->insertObject('#__action_log_config', $fieldtype_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the language_translation action log config object. - $language_translation_action_log_config = new stdClass(); - $language_translation_action_log_config->type_title = 'LANGUAGE_TRANSLATION'; - $language_translation_action_log_config->type_alias = 'com_componentbuilder.language_translation'; - $language_translation_action_log_config->id_holder = 'id'; - $language_translation_action_log_config->title_holder = 'source'; - $language_translation_action_log_config->table_name = '#__componentbuilder_language_translation'; - $language_translation_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $language_translation_Inserted = $db->insertObject('#__action_log_config', $language_translation_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the language action log config object. - $language_action_log_config = new stdClass(); - $language_action_log_config->type_title = 'LANGUAGE'; - $language_action_log_config->type_alias = 'com_componentbuilder.language'; - $language_action_log_config->id_holder = 'id'; - $language_action_log_config->title_holder = 'name'; - $language_action_log_config->table_name = '#__componentbuilder_language'; - $language_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $language_Inserted = $db->insertObject('#__action_log_config', $language_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the server action log config object. - $server_action_log_config = new stdClass(); - $server_action_log_config->type_title = 'SERVER'; - $server_action_log_config->type_alias = 'com_componentbuilder.server'; - $server_action_log_config->id_holder = 'id'; - $server_action_log_config->title_holder = 'name'; - $server_action_log_config->table_name = '#__componentbuilder_server'; - $server_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $server_Inserted = $db->insertObject('#__action_log_config', $server_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the help_document action log config object. - $help_document_action_log_config = new stdClass(); - $help_document_action_log_config->type_title = 'HELP_DOCUMENT'; - $help_document_action_log_config->type_alias = 'com_componentbuilder.help_document'; - $help_document_action_log_config->id_holder = 'id'; - $help_document_action_log_config->title_holder = 'title'; - $help_document_action_log_config->table_name = '#__componentbuilder_help_document'; - $help_document_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $help_document_Inserted = $db->insertObject('#__action_log_config', $help_document_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the admin_fields action log config object. - $admin_fields_action_log_config = new stdClass(); - $admin_fields_action_log_config->type_title = 'ADMIN_FIELDS'; - $admin_fields_action_log_config->type_alias = 'com_componentbuilder.admin_fields'; - $admin_fields_action_log_config->id_holder = 'id'; - $admin_fields_action_log_config->title_holder = 'admin_view'; - $admin_fields_action_log_config->table_name = '#__componentbuilder_admin_fields'; - $admin_fields_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $admin_fields_Inserted = $db->insertObject('#__action_log_config', $admin_fields_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the admin_fields_conditions action log config object. - $admin_fields_conditions_action_log_config = new stdClass(); - $admin_fields_conditions_action_log_config->type_title = 'ADMIN_FIELDS_CONDITIONS'; - $admin_fields_conditions_action_log_config->type_alias = 'com_componentbuilder.admin_fields_conditions'; - $admin_fields_conditions_action_log_config->id_holder = 'id'; - $admin_fields_conditions_action_log_config->title_holder = 'admin_view'; - $admin_fields_conditions_action_log_config->table_name = '#__componentbuilder_admin_fields_conditions'; - $admin_fields_conditions_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $admin_fields_conditions_Inserted = $db->insertObject('#__action_log_config', $admin_fields_conditions_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the admin_fields_relations action log config object. - $admin_fields_relations_action_log_config = new stdClass(); - $admin_fields_relations_action_log_config->type_title = 'ADMIN_FIELDS_RELATIONS'; - $admin_fields_relations_action_log_config->type_alias = 'com_componentbuilder.admin_fields_relations'; - $admin_fields_relations_action_log_config->id_holder = 'id'; - $admin_fields_relations_action_log_config->title_holder = 'admin_view'; - $admin_fields_relations_action_log_config->table_name = '#__componentbuilder_admin_fields_relations'; - $admin_fields_relations_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $admin_fields_relations_Inserted = $db->insertObject('#__action_log_config', $admin_fields_relations_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the admin_custom_tabs action log config object. - $admin_custom_tabs_action_log_config = new stdClass(); - $admin_custom_tabs_action_log_config->type_title = 'ADMIN_CUSTOM_TABS'; - $admin_custom_tabs_action_log_config->type_alias = 'com_componentbuilder.admin_custom_tabs'; - $admin_custom_tabs_action_log_config->id_holder = 'id'; - $admin_custom_tabs_action_log_config->title_holder = 'admin_view'; - $admin_custom_tabs_action_log_config->table_name = '#__componentbuilder_admin_custom_tabs'; - $admin_custom_tabs_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $admin_custom_tabs_Inserted = $db->insertObject('#__action_log_config', $admin_custom_tabs_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_admin_views action log config object. - $component_admin_views_action_log_config = new stdClass(); - $component_admin_views_action_log_config->type_title = 'COMPONENT_ADMIN_VIEWS'; - $component_admin_views_action_log_config->type_alias = 'com_componentbuilder.component_admin_views'; - $component_admin_views_action_log_config->id_holder = 'id'; - $component_admin_views_action_log_config->title_holder = 'joomla_component'; - $component_admin_views_action_log_config->table_name = '#__componentbuilder_component_admin_views'; - $component_admin_views_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $component_admin_views_Inserted = $db->insertObject('#__action_log_config', $component_admin_views_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_site_views action log config object. - $component_site_views_action_log_config = new stdClass(); - $component_site_views_action_log_config->type_title = 'COMPONENT_SITE_VIEWS'; - $component_site_views_action_log_config->type_alias = 'com_componentbuilder.component_site_views'; - $component_site_views_action_log_config->id_holder = 'id'; - $component_site_views_action_log_config->title_holder = 'joomla_component'; - $component_site_views_action_log_config->table_name = '#__componentbuilder_component_site_views'; - $component_site_views_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $component_site_views_Inserted = $db->insertObject('#__action_log_config', $component_site_views_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_custom_admin_views action log config object. - $component_custom_admin_views_action_log_config = new stdClass(); - $component_custom_admin_views_action_log_config->type_title = 'COMPONENT_CUSTOM_ADMIN_VIEWS'; - $component_custom_admin_views_action_log_config->type_alias = 'com_componentbuilder.component_custom_admin_views'; - $component_custom_admin_views_action_log_config->id_holder = 'id'; - $component_custom_admin_views_action_log_config->title_holder = 'joomla_component'; - $component_custom_admin_views_action_log_config->table_name = '#__componentbuilder_component_custom_admin_views'; - $component_custom_admin_views_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $component_custom_admin_views_Inserted = $db->insertObject('#__action_log_config', $component_custom_admin_views_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_updates action log config object. - $component_updates_action_log_config = new stdClass(); - $component_updates_action_log_config->type_title = 'COMPONENT_UPDATES'; - $component_updates_action_log_config->type_alias = 'com_componentbuilder.component_updates'; - $component_updates_action_log_config->id_holder = 'id'; - $component_updates_action_log_config->title_holder = 'joomla_component'; - $component_updates_action_log_config->table_name = '#__componentbuilder_component_updates'; - $component_updates_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $component_updates_Inserted = $db->insertObject('#__action_log_config', $component_updates_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_mysql_tweaks action log config object. - $component_mysql_tweaks_action_log_config = new stdClass(); - $component_mysql_tweaks_action_log_config->type_title = 'COMPONENT_MYSQL_TWEAKS'; - $component_mysql_tweaks_action_log_config->type_alias = 'com_componentbuilder.component_mysql_tweaks'; - $component_mysql_tweaks_action_log_config->id_holder = 'id'; - $component_mysql_tweaks_action_log_config->title_holder = 'joomla_component'; - $component_mysql_tweaks_action_log_config->table_name = '#__componentbuilder_component_mysql_tweaks'; - $component_mysql_tweaks_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $component_mysql_tweaks_Inserted = $db->insertObject('#__action_log_config', $component_mysql_tweaks_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_custom_admin_menus action log config object. - $component_custom_admin_menus_action_log_config = new stdClass(); - $component_custom_admin_menus_action_log_config->type_title = 'COMPONENT_CUSTOM_ADMIN_MENUS'; - $component_custom_admin_menus_action_log_config->type_alias = 'com_componentbuilder.component_custom_admin_menus'; - $component_custom_admin_menus_action_log_config->id_holder = 'id'; - $component_custom_admin_menus_action_log_config->title_holder = 'joomla_component'; - $component_custom_admin_menus_action_log_config->table_name = '#__componentbuilder_component_custom_admin_menus'; - $component_custom_admin_menus_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $component_custom_admin_menus_Inserted = $db->insertObject('#__action_log_config', $component_custom_admin_menus_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_config action log config object. - $component_config_action_log_config = new stdClass(); - $component_config_action_log_config->type_title = 'COMPONENT_CONFIG'; - $component_config_action_log_config->type_alias = 'com_componentbuilder.component_config'; - $component_config_action_log_config->id_holder = 'id'; - $component_config_action_log_config->title_holder = 'joomla_component'; - $component_config_action_log_config->table_name = '#__componentbuilder_component_config'; - $component_config_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $component_config_Inserted = $db->insertObject('#__action_log_config', $component_config_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_dashboard action log config object. - $component_dashboard_action_log_config = new stdClass(); - $component_dashboard_action_log_config->type_title = 'COMPONENT_DASHBOARD'; - $component_dashboard_action_log_config->type_alias = 'com_componentbuilder.component_dashboard'; - $component_dashboard_action_log_config->id_holder = 'id'; - $component_dashboard_action_log_config->title_holder = 'joomla_component'; - $component_dashboard_action_log_config->table_name = '#__componentbuilder_component_dashboard'; - $component_dashboard_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $component_dashboard_Inserted = $db->insertObject('#__action_log_config', $component_dashboard_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_files_folders action log config object. - $component_files_folders_action_log_config = new stdClass(); - $component_files_folders_action_log_config->type_title = 'COMPONENT_FILES_FOLDERS'; - $component_files_folders_action_log_config->type_alias = 'com_componentbuilder.component_files_folders'; - $component_files_folders_action_log_config->id_holder = 'id'; - $component_files_folders_action_log_config->title_holder = 'joomla_component'; - $component_files_folders_action_log_config->table_name = '#__componentbuilder_component_files_folders'; - $component_files_folders_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $component_files_folders_Inserted = $db->insertObject('#__action_log_config', $component_files_folders_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_placeholders action log config object. - $component_placeholders_action_log_config = new stdClass(); - $component_placeholders_action_log_config->type_title = 'COMPONENT_PLACEHOLDERS'; - $component_placeholders_action_log_config->type_alias = 'com_componentbuilder.component_placeholders'; - $component_placeholders_action_log_config->id_holder = 'id'; - $component_placeholders_action_log_config->title_holder = 'joomla_component'; - $component_placeholders_action_log_config->table_name = '#__componentbuilder_component_placeholders'; - $component_placeholders_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $component_placeholders_Inserted = $db->insertObject('#__action_log_config', $component_placeholders_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_plugins action log config object. - $component_plugins_action_log_config = new stdClass(); - $component_plugins_action_log_config->type_title = 'COMPONENT_PLUGINS'; - $component_plugins_action_log_config->type_alias = 'com_componentbuilder.component_plugins'; - $component_plugins_action_log_config->id_holder = 'id'; - $component_plugins_action_log_config->title_holder = 'joomla_component'; - $component_plugins_action_log_config->table_name = '#__componentbuilder_component_plugins'; - $component_plugins_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $component_plugins_Inserted = $db->insertObject('#__action_log_config', $component_plugins_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_modules action log config object. - $component_modules_action_log_config = new stdClass(); - $component_modules_action_log_config->type_title = 'COMPONENT_MODULES'; - $component_modules_action_log_config->type_alias = 'com_componentbuilder.component_modules'; - $component_modules_action_log_config->id_holder = 'id'; - $component_modules_action_log_config->title_holder = 'joomla_component'; - $component_modules_action_log_config->table_name = '#__componentbuilder_component_modules'; - $component_modules_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $component_modules_Inserted = $db->insertObject('#__action_log_config', $component_modules_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the snippet_type action log config object. - $snippet_type_action_log_config = new stdClass(); - $snippet_type_action_log_config->type_title = 'SNIPPET_TYPE'; - $snippet_type_action_log_config->type_alias = 'com_componentbuilder.snippet_type'; - $snippet_type_action_log_config->id_holder = 'id'; - $snippet_type_action_log_config->title_holder = 'name'; - $snippet_type_action_log_config->table_name = '#__componentbuilder_snippet_type'; - $snippet_type_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $snippet_type_Inserted = $db->insertObject('#__action_log_config', $snippet_type_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the library_config action log config object. - $library_config_action_log_config = new stdClass(); - $library_config_action_log_config->type_title = 'LIBRARY_CONFIG'; - $library_config_action_log_config->type_alias = 'com_componentbuilder.library_config'; - $library_config_action_log_config->id_holder = 'id'; - $library_config_action_log_config->title_holder = 'library'; - $library_config_action_log_config->table_name = '#__componentbuilder_library_config'; - $library_config_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $library_config_Inserted = $db->insertObject('#__action_log_config', $library_config_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the library_files_folders_urls action log config object. - $library_files_folders_urls_action_log_config = new stdClass(); - $library_files_folders_urls_action_log_config->type_title = 'LIBRARY_FILES_FOLDERS_URLS'; - $library_files_folders_urls_action_log_config->type_alias = 'com_componentbuilder.library_files_folders_urls'; - $library_files_folders_urls_action_log_config->id_holder = 'id'; - $library_files_folders_urls_action_log_config->title_holder = 'library'; - $library_files_folders_urls_action_log_config->table_name = '#__componentbuilder_library_files_folders_urls'; - $library_files_folders_urls_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $library_files_folders_urls_Inserted = $db->insertObject('#__action_log_config', $library_files_folders_urls_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the class_extends action log config object. - $class_extends_action_log_config = new stdClass(); - $class_extends_action_log_config->type_title = 'CLASS_EXTENDS'; - $class_extends_action_log_config->type_alias = 'com_componentbuilder.class_extends'; - $class_extends_action_log_config->id_holder = 'id'; - $class_extends_action_log_config->title_holder = 'name'; - $class_extends_action_log_config->table_name = '#__componentbuilder_class_extends'; - $class_extends_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $class_extends_Inserted = $db->insertObject('#__action_log_config', $class_extends_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the joomla_module_updates action log config object. - $joomla_module_updates_action_log_config = new stdClass(); - $joomla_module_updates_action_log_config->type_title = 'JOOMLA_MODULE_UPDATES'; - $joomla_module_updates_action_log_config->type_alias = 'com_componentbuilder.joomla_module_updates'; - $joomla_module_updates_action_log_config->id_holder = 'id'; - $joomla_module_updates_action_log_config->title_holder = 'joomla_module'; - $joomla_module_updates_action_log_config->table_name = '#__componentbuilder_joomla_module_updates'; - $joomla_module_updates_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $joomla_module_updates_Inserted = $db->insertObject('#__action_log_config', $joomla_module_updates_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the joomla_module_files_folders_urls action log config object. - $joomla_module_files_folders_urls_action_log_config = new stdClass(); - $joomla_module_files_folders_urls_action_log_config->type_title = 'JOOMLA_MODULE_FILES_FOLDERS_URLS'; - $joomla_module_files_folders_urls_action_log_config->type_alias = 'com_componentbuilder.joomla_module_files_folders_urls'; - $joomla_module_files_folders_urls_action_log_config->id_holder = 'id'; - $joomla_module_files_folders_urls_action_log_config->title_holder = 'joomla_module'; - $joomla_module_files_folders_urls_action_log_config->table_name = '#__componentbuilder_joomla_module_files_folders_urls'; - $joomla_module_files_folders_urls_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $joomla_module_files_folders_urls_Inserted = $db->insertObject('#__action_log_config', $joomla_module_files_folders_urls_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the joomla_plugin_group action log config object. - $joomla_plugin_group_action_log_config = new stdClass(); - $joomla_plugin_group_action_log_config->type_title = 'JOOMLA_PLUGIN_GROUP'; - $joomla_plugin_group_action_log_config->type_alias = 'com_componentbuilder.joomla_plugin_group'; - $joomla_plugin_group_action_log_config->id_holder = 'id'; - $joomla_plugin_group_action_log_config->title_holder = 'name'; - $joomla_plugin_group_action_log_config->table_name = '#__componentbuilder_joomla_plugin_group'; - $joomla_plugin_group_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $joomla_plugin_group_Inserted = $db->insertObject('#__action_log_config', $joomla_plugin_group_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the joomla_plugin_updates action log config object. - $joomla_plugin_updates_action_log_config = new stdClass(); - $joomla_plugin_updates_action_log_config->type_title = 'JOOMLA_PLUGIN_UPDATES'; - $joomla_plugin_updates_action_log_config->type_alias = 'com_componentbuilder.joomla_plugin_updates'; - $joomla_plugin_updates_action_log_config->id_holder = 'id'; - $joomla_plugin_updates_action_log_config->title_holder = 'joomla_plugin'; - $joomla_plugin_updates_action_log_config->table_name = '#__componentbuilder_joomla_plugin_updates'; - $joomla_plugin_updates_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $joomla_plugin_updates_Inserted = $db->insertObject('#__action_log_config', $joomla_plugin_updates_action_log_config); - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the joomla_plugin_files_folders_urls action log config object. - $joomla_plugin_files_folders_urls_action_log_config = new stdClass(); - $joomla_plugin_files_folders_urls_action_log_config->type_title = 'JOOMLA_PLUGIN_FILES_FOLDERS_URLS'; - $joomla_plugin_files_folders_urls_action_log_config->type_alias = 'com_componentbuilder.joomla_plugin_files_folders_urls'; - $joomla_plugin_files_folders_urls_action_log_config->id_holder = 'id'; - $joomla_plugin_files_folders_urls_action_log_config->title_holder = 'joomla_plugin'; - $joomla_plugin_files_folders_urls_action_log_config->table_name = '#__componentbuilder_joomla_plugin_files_folders_urls'; - $joomla_plugin_files_folders_urls_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Set the object into the action log config table. - $joomla_plugin_files_folders_urls_Inserted = $db->insertObject('#__action_log_config', $joomla_plugin_files_folders_urls_action_log_config); - } - // do any updates needed - if ($type === 'update') - { - - // Get The Database object - $db = JFactory::getDbo(); - - // Create the joomla_component content type object. - $joomla_component = new stdClass(); - $joomla_component->type_title = 'Componentbuilder Joomla_component'; - $joomla_component->type_alias = 'com_componentbuilder.joomla_component'; - $joomla_component->table = '{"special": {"dbtable": "#__componentbuilder_joomla_component","key": "id","type": "Joomla_component","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $joomla_component->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "system_name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "css_admin","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "metadata","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "metakey","core_metadesc": "metadesc","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","name_code":"name_code","short_description":"short_description","companyname":"companyname","css_admin":"css_admin","php_admin_event":"php_admin_event","php_site_event":"php_site_event","crowdin_username":"crowdin_username","component_version":"component_version","php_postflight_install":"php_postflight_install","remove_line_breaks":"remove_line_breaks","description":"description","sql_uninstall":"sql_uninstall","debug_linenr":"debug_linenr","mvc_versiondate":"mvc_versiondate","php_preflight_install":"php_preflight_install","backup_folder_path":"backup_folder_path","php_method_uninstall":"php_method_uninstall","add_placeholders":"add_placeholders","author":"author","add_sales_server":"add_sales_server","email":"email","translation_tool":"translation_tool","website":"website","buildcompsql":"buildcompsql","add_license":"add_license","php_helper_admin":"php_helper_admin","license_type":"license_type","php_helper_site":"php_helper_site","javascript":"javascript","whmcs_key":"whmcs_key","css_site":"css_site","whmcs_url":"whmcs_url","whmcs_buy_link":"whmcs_buy_link","php_preflight_update":"php_preflight_update","license":"license","php_postflight_update":"php_postflight_update","bom":"bom","sql":"sql","image":"image","addreadme":"addreadme","copyright":"copyright","update_server_url":"update_server_url","add_powers":"add_powers","add_backup_folder_path":"add_backup_folder_path","crowdin_project_identifier":"crowdin_project_identifier","add_php_helper_admin":"add_php_helper_admin","add_admin_event":"add_admin_event","add_php_helper_site":"add_php_helper_site","add_site_event":"add_site_event","add_javascript":"add_javascript","add_menu_prefix":"add_menu_prefix","add_css_admin":"add_css_admin","menu_prefix":"menu_prefix","add_css_site":"add_css_site","dashboard_type":"dashboard_type","dashboard":"dashboard","toignore":"toignore","add_php_preflight_install":"add_php_preflight_install","add_php_preflight_update":"add_php_preflight_update","add_php_postflight_install":"add_php_postflight_install","export_key":"export_key","add_php_postflight_update":"add_php_postflight_update","joomla_source_link":"joomla_source_link","add_php_method_uninstall":"add_php_method_uninstall","export_buy_link":"export_buy_link","add_sql":"add_sql","add_sql_uninstall":"add_sql_uninstall","assets_table_fix":"assets_table_fix","readme":"readme","emptycontributors":"emptycontributors","add_update_server":"add_update_server","number":"number","update_server_target":"update_server_target","update_server":"update_server","sales_server":"sales_server","add_git_folder_path":"add_git_folder_path","git_folder_path":"git_folder_path","creatuserhelper":"creatuserhelper","adduikit":"adduikit","crowdin_project_api_key":"crowdin_project_api_key","addfootable":"addfootable","crowdin_account_api_key":"crowdin_account_api_key","add_email_helper":"add_email_helper","buildcomp":"buildcomp","add_php_helper_both":"add_php_helper_both","guid":"guid","php_helper_both":"php_helper_both","name":"name"}}'; - $joomla_component->router = 'ComponentbuilderHelperRoute::getJoomla_componentRoute'; - $joomla_component->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/joomla_component.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","remove_line_breaks","debug_linenr","mvc_versiondate","add_placeholders","add_sales_server","translation_tool","add_license","license_type","addreadme","add_powers","add_backup_folder_path","add_php_helper_admin","add_admin_event","add_php_helper_site","add_site_event","add_javascript","add_css_admin","add_css_site","dashboard_type","add_php_preflight_install","add_php_preflight_update","add_php_postflight_install","add_php_postflight_update","add_php_method_uninstall","add_sql","add_sql_uninstall","assets_table_fix","emptycontributors","add_update_server","number","update_server_target","update_server","sales_server","add_git_folder_path","creatuserhelper","adduikit","addfootable","add_email_helper","buildcomp","add_php_helper_both"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "dashboard","targetTable": "#__componentbuilder_custom_admin_view","targetColumn": "","displayColumn": "system_name"},{"sourceColumn": "update_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "sales_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if joomla_component type is already in content_type DB. - $joomla_component_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($joomla_component->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $joomla_component->type_id = $db->loadResult(); - $joomla_component_Updated = $db->updateObject('#__content_types', $joomla_component, 'type_id'); - } - else - { - $joomla_component_Inserted = $db->insertObject('#__content_types', $joomla_component); - } - - // Create the joomla_module content type object. - $joomla_module = new stdClass(); - $joomla_module->type_title = 'Componentbuilder Joomla_module'; - $joomla_module->type_alias = 'com_componentbuilder.joomla_module'; - $joomla_module->table = '{"special": {"dbtable": "#__componentbuilder_joomla_module","key": "id","type": "Joomla_module","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $joomla_module->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "system_name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "default","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","target":"target","description":"description","add_php_method_uninstall":"add_php_method_uninstall","add_php_postflight_update":"add_php_postflight_update","add_php_postflight_install":"add_php_postflight_install","add_php_preflight_uninstall":"add_php_preflight_uninstall","addreadme":"addreadme","default":"default","snippet":"snippet","add_sql":"add_sql","update_server_target":"update_server_target","add_sql_uninstall":"add_sql_uninstall","update_server":"update_server","add_update_server":"add_update_server","libraries":"libraries","module_version":"module_version","sales_server":"sales_server","custom_get":"custom_get","php_preflight_update":"php_preflight_update","php_preflight_uninstall":"php_preflight_uninstall","mod_code":"mod_code","php_postflight_install":"php_postflight_install","add_class_helper":"add_class_helper","php_postflight_update":"php_postflight_update","add_class_helper_header":"add_class_helper_header","php_method_uninstall":"php_method_uninstall","class_helper_header":"class_helper_header","sql":"sql","class_helper_code":"class_helper_code","sql_uninstall":"sql_uninstall","readme":"readme","add_php_script_construct":"add_php_script_construct","update_server_url":"update_server_url","php_script_construct":"php_script_construct","add_php_preflight_install":"add_php_preflight_install","php_preflight_install":"php_preflight_install","add_sales_server":"add_sales_server","add_php_preflight_update":"add_php_preflight_update","guid":"guid","name":"name"}}'; - $joomla_module->router = 'ComponentbuilderHelperRoute::getJoomla_moduleRoute'; - $joomla_module->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/joomla_module.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","target","add_php_method_uninstall","add_php_postflight_update","add_php_postflight_install","add_php_preflight_uninstall","addreadme","snippet","add_sql","update_server_target","add_sql_uninstall","update_server","add_update_server","sales_server","add_class_helper","add_class_helper_header","add_php_script_construct","add_php_preflight_install","add_sales_server","add_php_preflight_update"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "snippet","targetTable": "#__componentbuilder_snippet","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "update_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "sales_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "custom_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if joomla_module type is already in content_type DB. - $joomla_module_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($joomla_module->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $joomla_module->type_id = $db->loadResult(); - $joomla_module_Updated = $db->updateObject('#__content_types', $joomla_module, 'type_id'); - } - else - { - $joomla_module_Inserted = $db->insertObject('#__content_types', $joomla_module); - } - - // Create the joomla_plugin content type object. - $joomla_plugin = new stdClass(); - $joomla_plugin->type_title = 'Componentbuilder Joomla_plugin'; - $joomla_plugin->type_alias = 'com_componentbuilder.joomla_plugin'; - $joomla_plugin->table = '{"special": {"dbtable": "#__componentbuilder_joomla_plugin","key": "id","type": "Joomla_plugin","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $joomla_plugin->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "system_name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "head","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","class_extends":"class_extends","joomla_plugin_group":"joomla_plugin_group","add_sql":"add_sql","add_php_method_uninstall":"add_php_method_uninstall","add_php_postflight_update":"add_php_postflight_update","add_php_postflight_install":"add_php_postflight_install","sales_server":"sales_server","add_update_server":"add_update_server","add_head":"add_head","add_sql_uninstall":"add_sql_uninstall","addreadme":"addreadme","head":"head","update_server_target":"update_server_target","main_class_code":"main_class_code","update_server":"update_server","description":"description","php_postflight_install":"php_postflight_install","plugin_version":"plugin_version","php_postflight_update":"php_postflight_update","php_method_uninstall":"php_method_uninstall","add_php_script_construct":"add_php_script_construct","sql":"sql","php_script_construct":"php_script_construct","sql_uninstall":"sql_uninstall","add_php_preflight_install":"add_php_preflight_install","readme":"readme","php_preflight_install":"php_preflight_install","update_server_url":"update_server_url","add_php_preflight_update":"add_php_preflight_update","php_preflight_update":"php_preflight_update","add_php_preflight_uninstall":"add_php_preflight_uninstall","add_sales_server":"add_sales_server","php_preflight_uninstall":"php_preflight_uninstall","guid":"guid","name":"name"}}'; - $joomla_plugin->router = 'ComponentbuilderHelperRoute::getJoomla_pluginRoute'; - $joomla_plugin->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/joomla_plugin.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","class_extends","joomla_plugin_group","add_sql","add_php_method_uninstall","add_php_postflight_update","add_php_postflight_install","sales_server","add_update_server","add_head","add_sql_uninstall","addreadme","update_server_target","update_server","add_php_script_construct","add_php_preflight_install","add_php_preflight_update","add_php_preflight_uninstall","add_sales_server"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "class_extends","targetTable": "#__componentbuilder_class_extends","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_plugin_group","targetTable": "#__componentbuilder_joomla_plugin_group","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "sales_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "update_server","targetTable": "#__componentbuilder_server","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if joomla_plugin type is already in content_type DB. - $joomla_plugin_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($joomla_plugin->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $joomla_plugin->type_id = $db->loadResult(); - $joomla_plugin_Updated = $db->updateObject('#__content_types', $joomla_plugin, 'type_id'); - } - else - { - $joomla_plugin_Inserted = $db->insertObject('#__content_types', $joomla_plugin); - } - - // Create the power content type object. - $power = new stdClass(); - $power->type_title = 'Componentbuilder Power'; - $power->type_alias = 'com_componentbuilder.power'; - $power->table = '{"special": {"dbtable": "#__componentbuilder_power","key": "id","type": "Power","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $power->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "system_name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "head","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","namespace":"namespace","type":"type","power_version":"power_version","licensing_template":"licensing_template","description":"description","extends":"extends","approved":"approved","add_head":"add_head","extends_custom":"extends_custom","implements_custom":"implements_custom","implements":"implements","head":"head","approved_paths":"approved_paths","main_class_code":"main_class_code","add_licensing_template":"add_licensing_template","guid":"guid","name":"name"}}'; - $power->router = 'ComponentbuilderHelperRoute::getPowerRoute'; - $power->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/power.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","approved","add_head","add_licensing_template"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "extends","targetTable": "#__componentbuilder_power","targetColumn": "guid","displayColumn": "name"},{"sourceColumn": "implements","targetTable": "#__componentbuilder_power","targetColumn": "guid","displayColumn": "name"}]}'; - - // Check if power type is already in content_type DB. - $power_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($power->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $power->type_id = $db->loadResult(); - $power_Updated = $db->updateObject('#__content_types', $power, 'type_id'); - } - else - { - $power_Inserted = $db->insertObject('#__content_types', $power); - } - - // Create the admin_view content type object. - $admin_view = new stdClass(); - $admin_view->type_title = 'Componentbuilder Admin_view'; - $admin_view->type_alias = 'com_componentbuilder.admin_view'; - $admin_view->table = '{"special": {"dbtable": "#__componentbuilder_admin_view","key": "id","type": "Admin_view","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $admin_view->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "null","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "php_allowedit","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","name_single":"name_single","short_description":"short_description","php_allowedit":"php_allowedit","php_postsavehook":"php_postsavehook","php_before_save":"php_before_save","php_getlistquery":"php_getlistquery","php_import_ext":"php_import_ext","icon":"icon","php_after_publish":"php_after_publish","add_fadein":"add_fadein","description":"description","icon_category":"icon_category","icon_add":"icon_add","php_after_cancel":"php_after_cancel","mysql_table_charset":"mysql_table_charset","php_batchmove":"php_batchmove","type":"type","php_after_delete":"php_after_delete","source":"source","php_import":"php_import","php_getitems_after_all":"php_getitems_after_all","php_getform":"php_getform","php_save":"php_save","php_allowadd":"php_allowadd","php_before_cancel":"php_before_cancel","php_batchcopy":"php_batchcopy","php_before_publish":"php_before_publish","alias_builder_type":"alias_builder_type","php_before_delete":"php_before_delete","php_document":"php_document","mysql_table_row_format":"mysql_table_row_format","alias_builder":"alias_builder","sql":"sql","php_import_display":"php_import_display","add_category_submenu":"add_category_submenu","php_import_setdata":"php_import_setdata","name_list":"name_list","add_php_getlistquery":"add_php_getlistquery","add_css_view":"add_css_view","add_php_getform":"add_php_getform","css_view":"css_view","add_php_before_save":"add_php_before_save","add_css_views":"add_css_views","add_php_save":"add_php_save","css_views":"css_views","add_php_postsavehook":"add_php_postsavehook","add_javascript_view_file":"add_javascript_view_file","add_php_allowadd":"add_php_allowadd","javascript_view_file":"javascript_view_file","add_php_allowedit":"add_php_allowedit","add_javascript_view_footer":"add_javascript_view_footer","add_php_before_cancel":"add_php_before_cancel","javascript_view_footer":"javascript_view_footer","add_php_after_cancel":"add_php_after_cancel","add_javascript_views_file":"add_javascript_views_file","add_php_batchcopy":"add_php_batchcopy","javascript_views_file":"javascript_views_file","add_php_batchmove":"add_php_batchmove","add_javascript_views_footer":"add_javascript_views_footer","add_php_before_publish":"add_php_before_publish","javascript_views_footer":"javascript_views_footer","add_php_after_publish":"add_php_after_publish","add_custom_button":"add_custom_button","add_php_before_delete":"add_php_before_delete","add_php_after_delete":"add_php_after_delete","php_controller":"php_controller","add_php_document":"add_php_document","php_model":"php_model","mysql_table_engine":"mysql_table_engine","php_controller_list":"php_controller_list","mysql_table_collate":"mysql_table_collate","php_model_list":"php_model_list","add_sql":"add_sql","add_php_ajax":"add_php_ajax","php_ajaxmethod":"php_ajaxmethod","add_custom_import":"add_custom_import","add_php_getitem":"add_php_getitem","html_import_view":"html_import_view","php_getitem":"php_getitem","php_import_headers":"php_import_headers","add_php_getitems":"add_php_getitems","php_import_save":"php_import_save","php_getitems":"php_getitems","guid":"guid","add_php_getitems_after_all":"add_php_getitems_after_all"}}'; - $admin_view->router = 'ComponentbuilderHelperRoute::getAdmin_viewRoute'; - $admin_view->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/admin_view.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","add_fadein","type","source","add_category_submenu","add_php_getlistquery","add_css_view","add_php_getform","add_php_before_save","add_css_views","add_php_save","add_php_postsavehook","add_javascript_view_file","add_php_allowadd","add_php_allowedit","add_javascript_view_footer","add_php_before_cancel","add_php_after_cancel","add_javascript_views_file","add_php_batchcopy","add_php_batchmove","add_javascript_views_footer","add_php_before_publish","add_php_after_publish","add_custom_button","add_php_before_delete","add_php_after_delete","add_php_document","add_sql","add_php_ajax","add_custom_import","add_php_getitem","add_php_getitems","add_php_getitems_after_all"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "alias_builder","targetTable": "#__componentbuilder_field","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if admin_view type is already in content_type DB. - $admin_view_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($admin_view->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $admin_view->type_id = $db->loadResult(); - $admin_view_Updated = $db->updateObject('#__content_types', $admin_view, 'type_id'); - } - else - { - $admin_view_Inserted = $db->insertObject('#__content_types', $admin_view); - } - - // Create the custom_admin_view content type object. - $custom_admin_view = new stdClass(); - $custom_admin_view->type_title = 'Componentbuilder Custom_admin_view'; - $custom_admin_view->type_alias = 'com_componentbuilder.custom_admin_view'; - $custom_admin_view->table = '{"special": {"dbtable": "#__componentbuilder_custom_admin_view","key": "id","type": "Custom_admin_view","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $custom_admin_view->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "css_document","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","name":"name","description":"description","main_get":"main_get","add_php_jview_display":"add_php_jview_display","css_document":"css_document","css":"css","js_document":"js_document","javascript_file":"javascript_file","codename":"codename","default":"default","snippet":"snippet","icon":"icon","add_php_jview":"add_php_jview","context":"context","add_js_document":"add_js_document","custom_get":"custom_get","add_javascript_file":"add_javascript_file","php_ajaxmethod":"php_ajaxmethod","add_css_document":"add_css_document","add_php_document":"add_php_document","add_css":"add_css","add_php_view":"add_php_view","add_php_ajax":"add_php_ajax","libraries":"libraries","dynamic_get":"dynamic_get","php_document":"php_document","php_view":"php_view","add_custom_button":"add_custom_button","php_jview_display":"php_jview_display","php_jview":"php_jview","php_controller":"php_controller","guid":"guid","php_model":"php_model"}}'; - $custom_admin_view->router = 'ComponentbuilderHelperRoute::getCustom_admin_viewRoute'; - $custom_admin_view->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/custom_admin_view.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","main_get","add_php_jview_display","snippet","add_php_jview","add_js_document","add_javascript_file","add_css_document","add_php_document","add_css","add_php_view","add_php_ajax","dynamic_get","add_custom_button"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "main_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "snippet","targetTable": "#__componentbuilder_snippet","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "custom_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "dynamic_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if custom_admin_view type is already in content_type DB. - $custom_admin_view_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($custom_admin_view->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $custom_admin_view->type_id = $db->loadResult(); - $custom_admin_view_Updated = $db->updateObject('#__content_types', $custom_admin_view, 'type_id'); - } - else - { - $custom_admin_view_Inserted = $db->insertObject('#__content_types', $custom_admin_view); - } - - // Create the site_view content type object. - $site_view = new stdClass(); - $site_view->type_title = 'Componentbuilder Site_view'; - $site_view->type_alias = 'com_componentbuilder.site_view'; - $site_view->table = '{"special": {"dbtable": "#__componentbuilder_site_view","key": "id","type": "Site_view","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $site_view->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "js_document","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"system_name":"system_name","name":"name","description":"description","main_get":"main_get","add_php_jview_display":"add_php_jview_display","add_php_document":"add_php_document","add_php_view":"add_php_view","js_document":"js_document","codename":"codename","javascript_file":"javascript_file","context":"context","default":"default","snippet":"snippet","add_php_jview":"add_php_jview","custom_get":"custom_get","css_document":"css_document","add_javascript_file":"add_javascript_file","css":"css","add_js_document":"add_js_document","php_ajaxmethod":"php_ajaxmethod","add_css_document":"add_css_document","libraries":"libraries","add_css":"add_css","dynamic_get":"dynamic_get","add_php_ajax":"add_php_ajax","add_custom_button":"add_custom_button","php_document":"php_document","button_position":"button_position","php_view":"php_view","php_jview_display":"php_jview_display","php_jview":"php_jview","php_controller":"php_controller","guid":"guid","php_model":"php_model"}}'; - $site_view->router = 'ComponentbuilderHelperRoute::getSite_viewRoute'; - $site_view->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/site_view.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","main_get","add_php_jview_display","add_php_document","add_php_view","snippet","add_php_jview","add_javascript_file","add_js_document","add_css_document","add_css","dynamic_get","add_php_ajax","add_custom_button","button_position"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "main_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "snippet","targetTable": "#__componentbuilder_snippet","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "custom_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "dynamic_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if site_view type is already in content_type DB. - $site_view_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($site_view->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $site_view->type_id = $db->loadResult(); - $site_view_Updated = $db->updateObject('#__content_types', $site_view, 'type_id'); - } - else - { - $site_view_Inserted = $db->insertObject('#__content_types', $site_view); - } - - // Create the template content type object. - $template = new stdClass(); - $template->type_title = 'Componentbuilder Template'; - $template->type_alias = 'com_componentbuilder.template'; - $template->table = '{"special": {"dbtable": "#__componentbuilder_template","key": "id","type": "Template","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $template->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "php_view","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description","dynamic_get":"dynamic_get","php_view":"php_view","add_php_view":"add_php_view","template":"template","snippet":"snippet","libraries":"libraries","alias":"alias"}}'; - $template->router = 'ComponentbuilderHelperRoute::getTemplateRoute'; - $template->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/template.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","dynamic_get","add_php_view","snippet"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "dynamic_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "snippet","targetTable": "#__componentbuilder_snippet","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if template type is already in content_type DB. - $template_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($template->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $template->type_id = $db->loadResult(); - $template_Updated = $db->updateObject('#__content_types', $template, 'type_id'); - } - else - { - $template_Inserted = $db->insertObject('#__content_types', $template); - } - - // Create the layout content type object. - $layout = new stdClass(); - $layout->type_title = 'Componentbuilder Layout'; - $layout->type_alias = 'com_componentbuilder.layout'; - $layout->table = '{"special": {"dbtable": "#__componentbuilder_layout","key": "id","type": "Layout","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $layout->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "php_view","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description","dynamic_get":"dynamic_get","snippet":"snippet","php_view":"php_view","add_php_view":"add_php_view","layout":"layout","libraries":"libraries","alias":"alias"}}'; - $layout->router = 'ComponentbuilderHelperRoute::getLayoutRoute'; - $layout->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/layout.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","dynamic_get","snippet","add_php_view"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "dynamic_get","targetTable": "#__componentbuilder_dynamic_get","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "snippet","targetTable": "#__componentbuilder_snippet","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if layout type is already in content_type DB. - $layout_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($layout->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $layout->type_id = $db->loadResult(); - $layout_Updated = $db->updateObject('#__content_types', $layout, 'type_id'); - } - else - { - $layout_Inserted = $db->insertObject('#__content_types', $layout); - } - - // Create the dynamic_get content type object. - $dynamic_get = new stdClass(); - $dynamic_get->type_title = 'Componentbuilder Dynamic_get'; - $dynamic_get->type_alias = 'com_componentbuilder.dynamic_get'; - $dynamic_get->table = '{"special": {"dbtable": "#__componentbuilder_dynamic_get","key": "id","type": "Dynamic_get","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $dynamic_get->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "php_before_getitems","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","main_source":"main_source","gettype":"gettype","php_router_parse":"php_router_parse","php_before_getitems":"php_before_getitems","php_after_getitems":"php_after_getitems","php_after_getitem":"php_after_getitem","php_getlistquery":"php_getlistquery","view_selection":"view_selection","db_table_main":"db_table_main","php_custom_get":"php_custom_get","plugin_events":"plugin_events","db_selection":"db_selection","php_calculation":"php_calculation","php_before_getitem":"php_before_getitem","view_table_main":"view_table_main","select_all":"select_all","add_php_before_getitem":"add_php_before_getitem","getcustom":"getcustom","add_php_after_getitem":"add_php_after_getitem","pagination":"pagination","add_php_getlistquery":"add_php_getlistquery","add_php_before_getitems":"add_php_before_getitems","add_php_after_getitems":"add_php_after_getitems","add_php_router_parse":"add_php_router_parse","addcalculation":"addcalculation","guid":"guid"}}'; - $dynamic_get->router = 'ComponentbuilderHelperRoute::getDynamic_getRoute'; - $dynamic_get->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/dynamic_get.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","main_source","gettype","view_table_main","select_all","add_php_before_getitem","add_php_after_getitem","pagination","add_php_getlistquery","add_php_before_getitems","add_php_after_getitems","add_php_router_parse"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "view_table_main","targetTable": "#__componentbuilder_admin_view","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if dynamic_get type is already in content_type DB. - $dynamic_get_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($dynamic_get->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $dynamic_get->type_id = $db->loadResult(); - $dynamic_get_Updated = $db->updateObject('#__content_types', $dynamic_get, 'type_id'); - } - else - { - $dynamic_get_Inserted = $db->insertObject('#__content_types', $dynamic_get); - } - - // Create the custom_code content type object. - $custom_code = new stdClass(); - $custom_code->type_title = 'Componentbuilder Custom_code'; - $custom_code->type_alias = 'com_componentbuilder.custom_code'; - $custom_code->table = '{"special": {"dbtable": "#__componentbuilder_custom_code","key": "id","type": "Custom_code","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $custom_code->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "code","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"component":"component","path":"path","target":"target","type":"type","comment_type":"comment_type","function_name":"function_name","system_name":"system_name","code":"code","hashendtarget":"hashendtarget","to_line":"to_line","from_line":"from_line","hashtarget":"hashtarget"}}'; - $custom_code->router = 'ComponentbuilderHelperRoute::getCustom_codeRoute'; - $custom_code->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/custom_code.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","component","target","type","comment_type"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if custom_code type is already in content_type DB. - $custom_code_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($custom_code->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $custom_code->type_id = $db->loadResult(); - $custom_code_Updated = $db->updateObject('#__content_types', $custom_code, 'type_id'); - } - else - { - $custom_code_Inserted = $db->insertObject('#__content_types', $custom_code); - } - - // Create the class_property content type object. - $class_property = new stdClass(); - $class_property->type_title = 'Componentbuilder Class_property'; - $class_property->type_alias = 'com_componentbuilder.class_property'; - $class_property->table = '{"special": {"dbtable": "#__componentbuilder_class_property","key": "id","type": "Class_property","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $class_property->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","visibility":"visibility","extension_type":"extension_type","guid":"guid","comment":"comment","joomla_plugin_group":"joomla_plugin_group","default":"default"}}'; - $class_property->router = 'ComponentbuilderHelperRoute::getClass_propertyRoute'; - $class_property->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/class_property.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_plugin_group"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_plugin_group","targetTable": "#__componentbuilder_joomla_plugin_group","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if class_property type is already in content_type DB. - $class_property_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($class_property->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $class_property->type_id = $db->loadResult(); - $class_property_Updated = $db->updateObject('#__content_types', $class_property, 'type_id'); - } - else - { - $class_property_Inserted = $db->insertObject('#__content_types', $class_property); - } - - // Create the class_method content type object. - $class_method = new stdClass(); - $class_method->type_title = 'Componentbuilder Class_method'; - $class_method->type_alias = 'com_componentbuilder.class_method'; - $class_method->table = '{"special": {"dbtable": "#__componentbuilder_class_method","key": "id","type": "Class_method","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $class_method->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "code","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","visibility":"visibility","extension_type":"extension_type","guid":"guid","code":"code","comment":"comment","joomla_plugin_group":"joomla_plugin_group","arguments":"arguments"}}'; - $class_method->router = 'ComponentbuilderHelperRoute::getClass_methodRoute'; - $class_method->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/class_method.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_plugin_group"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_plugin_group","targetTable": "#__componentbuilder_joomla_plugin_group","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if class_method type is already in content_type DB. - $class_method_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($class_method->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $class_method->type_id = $db->loadResult(); - $class_method_Updated = $db->updateObject('#__content_types', $class_method, 'type_id'); - } - else - { - $class_method_Inserted = $db->insertObject('#__content_types', $class_method); - } - - // Create the placeholder content type object. - $placeholder = new stdClass(); - $placeholder->type_title = 'Componentbuilder Placeholder'; - $placeholder->type_alias = 'com_componentbuilder.placeholder'; - $placeholder->table = '{"special": {"dbtable": "#__componentbuilder_placeholder","key": "id","type": "Placeholder","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $placeholder->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "target","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"target":"target","value":"value"}}'; - $placeholder->router = 'ComponentbuilderHelperRoute::getPlaceholderRoute'; - $placeholder->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/placeholder.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if placeholder type is already in content_type DB. - $placeholder_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($placeholder->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $placeholder->type_id = $db->loadResult(); - $placeholder_Updated = $db->updateObject('#__content_types', $placeholder, 'type_id'); - } - else - { - $placeholder_Inserted = $db->insertObject('#__content_types', $placeholder); - } - - // Create the library content type object. - $library = new stdClass(); - $library->type_title = 'Componentbuilder Library'; - $library->type_alias = 'com_componentbuilder.library'; - $library->table = '{"special": {"dbtable": "#__componentbuilder_library","key": "id","type": "Library","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $library->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","target":"target","how":"how","type":"type","description":"description","libraries":"libraries","php_setdocument":"php_setdocument","guid":"guid"}}'; - $library->router = 'ComponentbuilderHelperRoute::getLibraryRoute'; - $library->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/library.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","target","how","type"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "libraries","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if library type is already in content_type DB. - $library_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($library->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $library->type_id = $db->loadResult(); - $library_Updated = $db->updateObject('#__content_types', $library, 'type_id'); - } - else - { - $library_Inserted = $db->insertObject('#__content_types', $library); - } - - // Create the snippet content type object. - $snippet = new stdClass(); - $snippet->type_title = 'Componentbuilder Snippet'; - $snippet->type_alias = 'com_componentbuilder.snippet'; - $snippet->table = '{"special": {"dbtable": "#__componentbuilder_snippet","key": "id","type": "Snippet","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $snippet->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","url":"url","type":"type","heading":"heading","library":"library","guid":"guid","contributor_email":"contributor_email","contributor_name":"contributor_name","contributor_website":"contributor_website","contributor_company":"contributor_company","snippet":"snippet","usage":"usage","description":"description"}}'; - $snippet->router = 'ComponentbuilderHelperRoute::getSnippetRoute'; - $snippet->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/snippet.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","type","library"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "type","targetTable": "#__componentbuilder_snippet_type","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "library","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if snippet type is already in content_type DB. - $snippet_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($snippet->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $snippet->type_id = $db->loadResult(); - $snippet_Updated = $db->updateObject('#__content_types', $snippet, 'type_id'); - } - else - { - $snippet_Inserted = $db->insertObject('#__content_types', $snippet); - } - - // Create the validation_rule content type object. - $validation_rule = new stdClass(); - $validation_rule->type_title = 'Componentbuilder Validation_rule'; - $validation_rule->type_alias = 'com_componentbuilder.validation_rule'; - $validation_rule->table = '{"special": {"dbtable": "#__componentbuilder_validation_rule","key": "id","type": "Validation_rule","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $validation_rule->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","short_description":"short_description","inherit":"inherit","php":"php"}}'; - $validation_rule->router = 'ComponentbuilderHelperRoute::getValidation_ruleRoute'; - $validation_rule->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/validation_rule.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "inherit","targetTable": "#__componentbuilder_validation_rule","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if validation_rule type is already in content_type DB. - $validation_rule_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($validation_rule->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $validation_rule->type_id = $db->loadResult(); - $validation_rule_Updated = $db->updateObject('#__content_types', $validation_rule, 'type_id'); - } - else - { - $validation_rule_Inserted = $db->insertObject('#__content_types', $validation_rule); - } - - // Create the field content type object. - $field = new stdClass(); - $field->type_title = 'Componentbuilder Field'; - $field->type_alias = 'com_componentbuilder.field'; - $field->table = '{"special": {"dbtable": "#__componentbuilder_field","key": "id","type": "Field","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $field->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "css_views","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "catid","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","fieldtype":"fieldtype","datatype":"datatype","indexes":"indexes","null_switch":"null_switch","store":"store","on_save_model_field":"on_save_model_field","initiator_on_get_model":"initiator_on_get_model","initiator_on_save_model":"initiator_on_save_model","xml":"xml","datalenght":"datalenght","css_views":"css_views","css_view":"css_view","datadefault_other":"datadefault_other","datadefault":"datadefault","datalenght_other":"datalenght_other","on_get_model_field":"on_get_model_field","javascript_view_footer":"javascript_view_footer","javascript_views_footer":"javascript_views_footer","add_css_view":"add_css_view","add_css_views":"add_css_views","add_javascript_view_footer":"add_javascript_view_footer","add_javascript_views_footer":"add_javascript_views_footer","guid":"guid"}}'; - $field->router = 'ComponentbuilderHelperRoute::getFieldRoute'; - $field->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/field.xml","hideFields": ["asset_id","checked_out","checked_out_time","version","xml"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","fieldtype","store","catid","add_css_view","add_css_views","add_javascript_view_footer","add_javascript_views_footer"],"displayLookup": [{"sourceColumn": "catid","targetTable": "#__categories","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "fieldtype","targetTable": "#__componentbuilder_fieldtype","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if field type is already in content_type DB. - $field_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($field->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $field->type_id = $db->loadResult(); - $field_Updated = $db->updateObject('#__content_types', $field, 'type_id'); - } - else - { - $field_Inserted = $db->insertObject('#__content_types', $field); - } - - // Create the field category content type object. - $field_category = new stdClass(); - $field_category->type_title = 'Componentbuilder Field Catid'; - $field_category->type_alias = 'com_componentbuilder.field.category'; - $field_category->table = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}'; - $field_category->field_mappings = '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}'; - $field_category->router = 'ComponentbuilderHelperRoute::getCategoryRoute'; - $field_category->content_history_options = '{"formFile":"administrator\/components\/com_categories\/models\/forms\/category.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"], "ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version", "hits", "path"],"convertToInt":["publish_up", "publish_down"], "displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}'; - - // Check if field category type is already in content_type DB. - $field_category_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($field_category->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $field_category->type_id = $db->loadResult(); - $field_category_Updated = $db->updateObject('#__content_types', $field_category, 'type_id'); - } - else - { - $field_category_Inserted = $db->insertObject('#__content_types', $field_category); - } - - // Create the fieldtype content type object. - $fieldtype = new stdClass(); - $fieldtype->type_title = 'Componentbuilder Fieldtype'; - $fieldtype->type_alias = 'com_componentbuilder.fieldtype'; - $fieldtype->table = '{"special": {"dbtable": "#__componentbuilder_fieldtype","key": "id","type": "Fieldtype","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $fieldtype->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "catid","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","store":"store","null_switch":"null_switch","indexes":"indexes","datadefault_other":"datadefault_other","datadefault":"datadefault","short_description":"short_description","datatype":"datatype","has_defaults":"has_defaults","description":"description","datalenght":"datalenght","datalenght_other":"datalenght_other","guid":"guid"}}'; - $fieldtype->router = 'ComponentbuilderHelperRoute::getFieldtypeRoute'; - $fieldtype->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/fieldtype.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","store","has_defaults","catid"],"displayLookup": [{"sourceColumn": "catid","targetTable": "#__categories","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if fieldtype type is already in content_type DB. - $fieldtype_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($fieldtype->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $fieldtype->type_id = $db->loadResult(); - $fieldtype_Updated = $db->updateObject('#__content_types', $fieldtype, 'type_id'); - } - else - { - $fieldtype_Inserted = $db->insertObject('#__content_types', $fieldtype); - } - - // Create the fieldtype category content type object. - $fieldtype_category = new stdClass(); - $fieldtype_category->type_title = 'Componentbuilder Fieldtype Catid'; - $fieldtype_category->type_alias = 'com_componentbuilder.fieldtype.category'; - $fieldtype_category->table = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}'; - $fieldtype_category->field_mappings = '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}'; - $fieldtype_category->router = 'ComponentbuilderHelperRoute::getCategoryRoute'; - $fieldtype_category->content_history_options = '{"formFile":"administrator\/components\/com_categories\/models\/forms\/category.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"], "ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version", "hits", "path"],"convertToInt":["publish_up", "publish_down"], "displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}'; - - // Check if fieldtype category type is already in content_type DB. - $fieldtype_category_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($fieldtype_category->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $fieldtype_category->type_id = $db->loadResult(); - $fieldtype_category_Updated = $db->updateObject('#__content_types', $fieldtype_category, 'type_id'); - } - else - { - $fieldtype_category_Inserted = $db->insertObject('#__content_types', $fieldtype_category); - } - - // Create the language_translation content type object. - $language_translation = new stdClass(); - $language_translation->type_title = 'Componentbuilder Language_translation'; - $language_translation->type_alias = 'com_componentbuilder.language_translation'; - $language_translation->table = '{"special": {"dbtable": "#__componentbuilder_language_translation","key": "id","type": "Language_translation","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $language_translation->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "source","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"source":"source","plugins":"plugins","modules":"modules","components":"components"}}'; - $language_translation->router = 'ComponentbuilderHelperRoute::getLanguage_translationRoute'; - $language_translation->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/language_translation.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "plugins","targetTable": "#__componentbuilder_joomla_plugin","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "modules","targetTable": "#__componentbuilder_joomla_module","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "components","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if language_translation type is already in content_type DB. - $language_translation_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($language_translation->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $language_translation->type_id = $db->loadResult(); - $language_translation_Updated = $db->updateObject('#__content_types', $language_translation, 'type_id'); - } - else - { - $language_translation_Inserted = $db->insertObject('#__content_types', $language_translation); - } - - // Create the language content type object. - $language = new stdClass(); - $language->type_title = 'Componentbuilder Language'; - $language->type_alias = 'com_componentbuilder.language'; - $language->table = '{"special": {"dbtable": "#__componentbuilder_language","key": "id","type": "Language","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $language->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","langtag":"langtag"}}'; - $language->router = 'ComponentbuilderHelperRoute::getLanguageRoute'; - $language->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/language.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if language type is already in content_type DB. - $language_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($language->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $language->type_id = $db->loadResult(); - $language_Updated = $db->updateObject('#__content_types', $language, 'type_id'); - } - else - { - $language_Inserted = $db->insertObject('#__content_types', $language); - } - - // Create the server content type object. - $server = new stdClass(); - $server->type_title = 'Componentbuilder Server'; - $server->type_alias = 'com_componentbuilder.server'; - $server->table = '{"special": {"dbtable": "#__componentbuilder_server","key": "id","type": "Server","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $server->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","protocol":"protocol","signature":"signature","private_key":"private_key","secret":"secret","password":"password","private":"private","authentication":"authentication","path":"path","port":"port","host":"host","username":"username"}}'; - $server->router = 'ComponentbuilderHelperRoute::getServerRoute'; - $server->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/server.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","protocol","authentication"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if server type is already in content_type DB. - $server_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($server->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $server->type_id = $db->loadResult(); - $server_Updated = $db->updateObject('#__content_types', $server, 'type_id'); - } - else - { - $server_Inserted = $db->insertObject('#__content_types', $server); - } - - // Create the help_document content type object. - $help_document = new stdClass(); - $help_document->type_title = 'Componentbuilder Help_document'; - $help_document->type_alias = 'com_componentbuilder.help_document'; - $help_document->table = '{"special": {"dbtable": "#__componentbuilder_help_document","key": "id","type": "Help_document","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $help_document->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "title","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "content","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "null","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"title":"title","type":"type","groups":"groups","location":"location","admin_view":"admin_view","site_view":"site_view","not_required":"not_required","content":"content","article":"article","url":"url","target":"target","alias":"alias"}}'; - $help_document->router = 'ComponentbuilderHelperRoute::getHelp_documentRoute'; - $help_document->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/help_document.xml","hideFields": ["asset_id","checked_out","checked_out_time","version","not_required"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","type","location","not_required","article","target"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "article","targetTable": "#__content","targetColumn": "id","displayColumn": "title"}]}'; - - // Check if help_document type is already in content_type DB. - $help_document_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($help_document->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $help_document->type_id = $db->loadResult(); - $help_document_Updated = $db->updateObject('#__content_types', $help_document, 'type_id'); - } - else - { - $help_document_Inserted = $db->insertObject('#__content_types', $help_document); - } - - // Create the admin_fields content type object. - $admin_fields = new stdClass(); - $admin_fields->type_title = 'Componentbuilder Admin_fields'; - $admin_fields->type_alias = 'com_componentbuilder.admin_fields'; - $admin_fields->table = '{"special": {"dbtable": "#__componentbuilder_admin_fields","key": "id","type": "Admin_fields","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $admin_fields->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "admin_view","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"admin_view":"admin_view"}}'; - $admin_fields->router = 'ComponentbuilderHelperRoute::getAdmin_fieldsRoute'; - $admin_fields->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/admin_fields.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","admin_view"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "admin_view","targetTable": "#__componentbuilder_admin_view","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if admin_fields type is already in content_type DB. - $admin_fields_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($admin_fields->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $admin_fields->type_id = $db->loadResult(); - $admin_fields_Updated = $db->updateObject('#__content_types', $admin_fields, 'type_id'); - } - else - { - $admin_fields_Inserted = $db->insertObject('#__content_types', $admin_fields); - } - - // Create the admin_fields_conditions content type object. - $admin_fields_conditions = new stdClass(); - $admin_fields_conditions->type_title = 'Componentbuilder Admin_fields_conditions'; - $admin_fields_conditions->type_alias = 'com_componentbuilder.admin_fields_conditions'; - $admin_fields_conditions->table = '{"special": {"dbtable": "#__componentbuilder_admin_fields_conditions","key": "id","type": "Admin_fields_conditions","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $admin_fields_conditions->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "admin_view","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"admin_view":"admin_view"}}'; - $admin_fields_conditions->router = 'ComponentbuilderHelperRoute::getAdmin_fields_conditionsRoute'; - $admin_fields_conditions->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/admin_fields_conditions.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","admin_view"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "admin_view","targetTable": "#__componentbuilder_admin_view","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if admin_fields_conditions type is already in content_type DB. - $admin_fields_conditions_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($admin_fields_conditions->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $admin_fields_conditions->type_id = $db->loadResult(); - $admin_fields_conditions_Updated = $db->updateObject('#__content_types', $admin_fields_conditions, 'type_id'); - } - else - { - $admin_fields_conditions_Inserted = $db->insertObject('#__content_types', $admin_fields_conditions); - } - - // Create the admin_fields_relations content type object. - $admin_fields_relations = new stdClass(); - $admin_fields_relations->type_title = 'Componentbuilder Admin_fields_relations'; - $admin_fields_relations->type_alias = 'com_componentbuilder.admin_fields_relations'; - $admin_fields_relations->table = '{"special": {"dbtable": "#__componentbuilder_admin_fields_relations","key": "id","type": "Admin_fields_relations","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $admin_fields_relations->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "admin_view","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"admin_view":"admin_view"}}'; - $admin_fields_relations->router = 'ComponentbuilderHelperRoute::getAdmin_fields_relationsRoute'; - $admin_fields_relations->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/admin_fields_relations.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","admin_view"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "admin_view","targetTable": "#__componentbuilder_admin_view","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if admin_fields_relations type is already in content_type DB. - $admin_fields_relations_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($admin_fields_relations->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $admin_fields_relations->type_id = $db->loadResult(); - $admin_fields_relations_Updated = $db->updateObject('#__content_types', $admin_fields_relations, 'type_id'); - } - else - { - $admin_fields_relations_Inserted = $db->insertObject('#__content_types', $admin_fields_relations); - } - - // Create the admin_custom_tabs content type object. - $admin_custom_tabs = new stdClass(); - $admin_custom_tabs->type_title = 'Componentbuilder Admin_custom_tabs'; - $admin_custom_tabs->type_alias = 'com_componentbuilder.admin_custom_tabs'; - $admin_custom_tabs->table = '{"special": {"dbtable": "#__componentbuilder_admin_custom_tabs","key": "id","type": "Admin_custom_tabs","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $admin_custom_tabs->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "admin_view","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"admin_view":"admin_view"}}'; - $admin_custom_tabs->router = 'ComponentbuilderHelperRoute::getAdmin_custom_tabsRoute'; - $admin_custom_tabs->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/admin_custom_tabs.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","admin_view"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "admin_view","targetTable": "#__componentbuilder_admin_view","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if admin_custom_tabs type is already in content_type DB. - $admin_custom_tabs_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($admin_custom_tabs->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $admin_custom_tabs->type_id = $db->loadResult(); - $admin_custom_tabs_Updated = $db->updateObject('#__content_types', $admin_custom_tabs, 'type_id'); - } - else - { - $admin_custom_tabs_Inserted = $db->insertObject('#__content_types', $admin_custom_tabs); - } - - // Create the component_admin_views content type object. - $component_admin_views = new stdClass(); - $component_admin_views->type_title = 'Componentbuilder Component_admin_views'; - $component_admin_views->type_alias = 'com_componentbuilder.component_admin_views'; - $component_admin_views->table = '{"special": {"dbtable": "#__componentbuilder_component_admin_views","key": "id","type": "Component_admin_views","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_admin_views->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_admin_views->router = 'ComponentbuilderHelperRoute::getComponent_admin_viewsRoute'; - $component_admin_views->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_admin_views.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if component_admin_views type is already in content_type DB. - $component_admin_views_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_admin_views->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_admin_views->type_id = $db->loadResult(); - $component_admin_views_Updated = $db->updateObject('#__content_types', $component_admin_views, 'type_id'); - } - else - { - $component_admin_views_Inserted = $db->insertObject('#__content_types', $component_admin_views); - } - - // Create the component_site_views content type object. - $component_site_views = new stdClass(); - $component_site_views->type_title = 'Componentbuilder Component_site_views'; - $component_site_views->type_alias = 'com_componentbuilder.component_site_views'; - $component_site_views->table = '{"special": {"dbtable": "#__componentbuilder_component_site_views","key": "id","type": "Component_site_views","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_site_views->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_site_views->router = 'ComponentbuilderHelperRoute::getComponent_site_viewsRoute'; - $component_site_views->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_site_views.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if component_site_views type is already in content_type DB. - $component_site_views_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_site_views->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_site_views->type_id = $db->loadResult(); - $component_site_views_Updated = $db->updateObject('#__content_types', $component_site_views, 'type_id'); - } - else - { - $component_site_views_Inserted = $db->insertObject('#__content_types', $component_site_views); - } - - // Create the component_custom_admin_views content type object. - $component_custom_admin_views = new stdClass(); - $component_custom_admin_views->type_title = 'Componentbuilder Component_custom_admin_views'; - $component_custom_admin_views->type_alias = 'com_componentbuilder.component_custom_admin_views'; - $component_custom_admin_views->table = '{"special": {"dbtable": "#__componentbuilder_component_custom_admin_views","key": "id","type": "Component_custom_admin_views","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_custom_admin_views->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_custom_admin_views->router = 'ComponentbuilderHelperRoute::getComponent_custom_admin_viewsRoute'; - $component_custom_admin_views->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_custom_admin_views.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if component_custom_admin_views type is already in content_type DB. - $component_custom_admin_views_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_custom_admin_views->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_custom_admin_views->type_id = $db->loadResult(); - $component_custom_admin_views_Updated = $db->updateObject('#__content_types', $component_custom_admin_views, 'type_id'); - } - else - { - $component_custom_admin_views_Inserted = $db->insertObject('#__content_types', $component_custom_admin_views); - } - - // Create the component_updates content type object. - $component_updates = new stdClass(); - $component_updates->type_title = 'Componentbuilder Component_updates'; - $component_updates->type_alias = 'com_componentbuilder.component_updates'; - $component_updates->table = '{"special": {"dbtable": "#__componentbuilder_component_updates","key": "id","type": "Component_updates","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_updates->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_updates->router = 'ComponentbuilderHelperRoute::getComponent_updatesRoute'; - $component_updates->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_updates.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if component_updates type is already in content_type DB. - $component_updates_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_updates->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_updates->type_id = $db->loadResult(); - $component_updates_Updated = $db->updateObject('#__content_types', $component_updates, 'type_id'); - } - else - { - $component_updates_Inserted = $db->insertObject('#__content_types', $component_updates); - } - - // Create the component_mysql_tweaks content type object. - $component_mysql_tweaks = new stdClass(); - $component_mysql_tweaks->type_title = 'Componentbuilder Component_mysql_tweaks'; - $component_mysql_tweaks->type_alias = 'com_componentbuilder.component_mysql_tweaks'; - $component_mysql_tweaks->table = '{"special": {"dbtable": "#__componentbuilder_component_mysql_tweaks","key": "id","type": "Component_mysql_tweaks","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_mysql_tweaks->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_mysql_tweaks->router = 'ComponentbuilderHelperRoute::getComponent_mysql_tweaksRoute'; - $component_mysql_tweaks->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_mysql_tweaks.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if component_mysql_tweaks type is already in content_type DB. - $component_mysql_tweaks_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_mysql_tweaks->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_mysql_tweaks->type_id = $db->loadResult(); - $component_mysql_tweaks_Updated = $db->updateObject('#__content_types', $component_mysql_tweaks, 'type_id'); - } - else - { - $component_mysql_tweaks_Inserted = $db->insertObject('#__content_types', $component_mysql_tweaks); - } - - // Create the component_custom_admin_menus content type object. - $component_custom_admin_menus = new stdClass(); - $component_custom_admin_menus->type_title = 'Componentbuilder Component_custom_admin_menus'; - $component_custom_admin_menus->type_alias = 'com_componentbuilder.component_custom_admin_menus'; - $component_custom_admin_menus->table = '{"special": {"dbtable": "#__componentbuilder_component_custom_admin_menus","key": "id","type": "Component_custom_admin_menus","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_custom_admin_menus->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_custom_admin_menus->router = 'ComponentbuilderHelperRoute::getComponent_custom_admin_menusRoute'; - $component_custom_admin_menus->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_custom_admin_menus.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if component_custom_admin_menus type is already in content_type DB. - $component_custom_admin_menus_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_custom_admin_menus->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_custom_admin_menus->type_id = $db->loadResult(); - $component_custom_admin_menus_Updated = $db->updateObject('#__content_types', $component_custom_admin_menus, 'type_id'); - } - else - { - $component_custom_admin_menus_Inserted = $db->insertObject('#__content_types', $component_custom_admin_menus); - } - - // Create the component_config content type object. - $component_config = new stdClass(); - $component_config->type_title = 'Componentbuilder Component_config'; - $component_config->type_alias = 'com_componentbuilder.component_config'; - $component_config->table = '{"special": {"dbtable": "#__componentbuilder_component_config","key": "id","type": "Component_config","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_config->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_config->router = 'ComponentbuilderHelperRoute::getComponent_configRoute'; - $component_config->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_config.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if component_config type is already in content_type DB. - $component_config_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_config->type_id = $db->loadResult(); - $component_config_Updated = $db->updateObject('#__content_types', $component_config, 'type_id'); - } - else - { - $component_config_Inserted = $db->insertObject('#__content_types', $component_config); - } - - // Create the component_dashboard content type object. - $component_dashboard = new stdClass(); - $component_dashboard->type_title = 'Componentbuilder Component_dashboard'; - $component_dashboard->type_alias = 'com_componentbuilder.component_dashboard'; - $component_dashboard->table = '{"special": {"dbtable": "#__componentbuilder_component_dashboard","key": "id","type": "Component_dashboard","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_dashboard->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component","php_dashboard_methods":"php_dashboard_methods"}}'; - $component_dashboard->router = 'ComponentbuilderHelperRoute::getComponent_dashboardRoute'; - $component_dashboard->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_dashboard.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if component_dashboard type is already in content_type DB. - $component_dashboard_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_dashboard->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_dashboard->type_id = $db->loadResult(); - $component_dashboard_Updated = $db->updateObject('#__content_types', $component_dashboard, 'type_id'); - } - else - { - $component_dashboard_Inserted = $db->insertObject('#__content_types', $component_dashboard); - } - - // Create the component_files_folders content type object. - $component_files_folders = new stdClass(); - $component_files_folders->type_title = 'Componentbuilder Component_files_folders'; - $component_files_folders->type_alias = 'com_componentbuilder.component_files_folders'; - $component_files_folders->table = '{"special": {"dbtable": "#__componentbuilder_component_files_folders","key": "id","type": "Component_files_folders","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_files_folders->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_files_folders->router = 'ComponentbuilderHelperRoute::getComponent_files_foldersRoute'; - $component_files_folders->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_files_folders.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if component_files_folders type is already in content_type DB. - $component_files_folders_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_files_folders->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_files_folders->type_id = $db->loadResult(); - $component_files_folders_Updated = $db->updateObject('#__content_types', $component_files_folders, 'type_id'); - } - else - { - $component_files_folders_Inserted = $db->insertObject('#__content_types', $component_files_folders); - } - - // Create the component_placeholders content type object. - $component_placeholders = new stdClass(); - $component_placeholders->type_title = 'Componentbuilder Component_placeholders'; - $component_placeholders->type_alias = 'com_componentbuilder.component_placeholders'; - $component_placeholders->table = '{"special": {"dbtable": "#__componentbuilder_component_placeholders","key": "id","type": "Component_placeholders","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_placeholders->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_placeholders->router = 'ComponentbuilderHelperRoute::getComponent_placeholdersRoute'; - $component_placeholders->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_placeholders.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if component_placeholders type is already in content_type DB. - $component_placeholders_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_placeholders->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_placeholders->type_id = $db->loadResult(); - $component_placeholders_Updated = $db->updateObject('#__content_types', $component_placeholders, 'type_id'); - } - else - { - $component_placeholders_Inserted = $db->insertObject('#__content_types', $component_placeholders); - } - - // Create the component_plugins content type object. - $component_plugins = new stdClass(); - $component_plugins->type_title = 'Componentbuilder Component_plugins'; - $component_plugins->type_alias = 'com_componentbuilder.component_plugins'; - $component_plugins->table = '{"special": {"dbtable": "#__componentbuilder_component_plugins","key": "id","type": "Component_plugins","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_plugins->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_plugins->router = 'ComponentbuilderHelperRoute::getComponent_pluginsRoute'; - $component_plugins->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_plugins.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if component_plugins type is already in content_type DB. - $component_plugins_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_plugins->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_plugins->type_id = $db->loadResult(); - $component_plugins_Updated = $db->updateObject('#__content_types', $component_plugins, 'type_id'); - } - else - { - $component_plugins_Inserted = $db->insertObject('#__content_types', $component_plugins); - } - - // Create the component_modules content type object. - $component_modules = new stdClass(); - $component_modules->type_title = 'Componentbuilder Component_modules'; - $component_modules->type_alias = 'com_componentbuilder.component_modules'; - $component_modules->table = '{"special": {"dbtable": "#__componentbuilder_component_modules","key": "id","type": "Component_modules","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $component_modules->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_component","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_component":"joomla_component"}}'; - $component_modules->router = 'ComponentbuilderHelperRoute::getComponent_modulesRoute'; - $component_modules->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/component_modules.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_component"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_component","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"},{"sourceColumn": "clone_me","targetTable": "#__componentbuilder_joomla_component","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if component_modules type is already in content_type DB. - $component_modules_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_modules->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_modules->type_id = $db->loadResult(); - $component_modules_Updated = $db->updateObject('#__content_types', $component_modules, 'type_id'); - } - else - { - $component_modules_Inserted = $db->insertObject('#__content_types', $component_modules); - } - - // Create the snippet_type content type object. - $snippet_type = new stdClass(); - $snippet_type->type_title = 'Componentbuilder Snippet_type'; - $snippet_type->type_alias = 'com_componentbuilder.snippet_type'; - $snippet_type->table = '{"special": {"dbtable": "#__componentbuilder_snippet_type","key": "id","type": "Snippet_type","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $snippet_type->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description"}}'; - $snippet_type->router = 'ComponentbuilderHelperRoute::getSnippet_typeRoute'; - $snippet_type->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/snippet_type.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if snippet_type type is already in content_type DB. - $snippet_type_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($snippet_type->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $snippet_type->type_id = $db->loadResult(); - $snippet_type_Updated = $db->updateObject('#__content_types', $snippet_type, 'type_id'); - } - else - { - $snippet_type_Inserted = $db->insertObject('#__content_types', $snippet_type); - } - - // Create the library_config content type object. - $library_config = new stdClass(); - $library_config->type_title = 'Componentbuilder Library_config'; - $library_config->type_alias = 'com_componentbuilder.library_config'; - $library_config->table = '{"special": {"dbtable": "#__componentbuilder_library_config","key": "id","type": "Library_config","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $library_config->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "library","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"library":"library"}}'; - $library_config->router = 'ComponentbuilderHelperRoute::getLibrary_configRoute'; - $library_config->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/library_config.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","library"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "library","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if library_config type is already in content_type DB. - $library_config_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($library_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $library_config->type_id = $db->loadResult(); - $library_config_Updated = $db->updateObject('#__content_types', $library_config, 'type_id'); - } - else - { - $library_config_Inserted = $db->insertObject('#__content_types', $library_config); - } - - // Create the library_files_folders_urls content type object. - $library_files_folders_urls = new stdClass(); - $library_files_folders_urls->type_title = 'Componentbuilder Library_files_folders_urls'; - $library_files_folders_urls->type_alias = 'com_componentbuilder.library_files_folders_urls'; - $library_files_folders_urls->table = '{"special": {"dbtable": "#__componentbuilder_library_files_folders_urls","key": "id","type": "Library_files_folders_urls","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $library_files_folders_urls->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "library","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"library":"library"}}'; - $library_files_folders_urls->router = 'ComponentbuilderHelperRoute::getLibrary_files_folders_urlsRoute'; - $library_files_folders_urls->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/library_files_folders_urls.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","library"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "library","targetTable": "#__componentbuilder_library","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if library_files_folders_urls type is already in content_type DB. - $library_files_folders_urls_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($library_files_folders_urls->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $library_files_folders_urls->type_id = $db->loadResult(); - $library_files_folders_urls_Updated = $db->updateObject('#__content_types', $library_files_folders_urls, 'type_id'); - } - else - { - $library_files_folders_urls_Inserted = $db->insertObject('#__content_types', $library_files_folders_urls); - } - - // Create the class_extends content type object. - $class_extends = new stdClass(); - $class_extends->type_title = 'Componentbuilder Class_extends'; - $class_extends->type_alias = 'com_componentbuilder.class_extends'; - $class_extends->table = '{"special": {"dbtable": "#__componentbuilder_class_extends","key": "id","type": "Class_extends","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $class_extends->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "head","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","extension_type":"extension_type","head":"head","comment":"comment"}}'; - $class_extends->router = 'ComponentbuilderHelperRoute::getClass_extendsRoute'; - $class_extends->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/class_extends.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if class_extends type is already in content_type DB. - $class_extends_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($class_extends->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $class_extends->type_id = $db->loadResult(); - $class_extends_Updated = $db->updateObject('#__content_types', $class_extends, 'type_id'); - } - else - { - $class_extends_Inserted = $db->insertObject('#__content_types', $class_extends); - } - - // Create the joomla_module_updates content type object. - $joomla_module_updates = new stdClass(); - $joomla_module_updates->type_title = 'Componentbuilder Joomla_module_updates'; - $joomla_module_updates->type_alias = 'com_componentbuilder.joomla_module_updates'; - $joomla_module_updates->table = '{"special": {"dbtable": "#__componentbuilder_joomla_module_updates","key": "id","type": "Joomla_module_updates","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $joomla_module_updates->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_module","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_module":"joomla_module"}}'; - $joomla_module_updates->router = 'ComponentbuilderHelperRoute::getJoomla_module_updatesRoute'; - $joomla_module_updates->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/joomla_module_updates.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_module"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_module","targetTable": "#__componentbuilder_joomla_module","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if joomla_module_updates type is already in content_type DB. - $joomla_module_updates_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($joomla_module_updates->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $joomla_module_updates->type_id = $db->loadResult(); - $joomla_module_updates_Updated = $db->updateObject('#__content_types', $joomla_module_updates, 'type_id'); - } - else - { - $joomla_module_updates_Inserted = $db->insertObject('#__content_types', $joomla_module_updates); - } - - // Create the joomla_module_files_folders_urls content type object. - $joomla_module_files_folders_urls = new stdClass(); - $joomla_module_files_folders_urls->type_title = 'Componentbuilder Joomla_module_files_folders_urls'; - $joomla_module_files_folders_urls->type_alias = 'com_componentbuilder.joomla_module_files_folders_urls'; - $joomla_module_files_folders_urls->table = '{"special": {"dbtable": "#__componentbuilder_joomla_module_files_folders_urls","key": "id","type": "Joomla_module_files_folders_urls","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $joomla_module_files_folders_urls->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_module","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_module":"joomla_module"}}'; - $joomla_module_files_folders_urls->router = 'ComponentbuilderHelperRoute::getJoomla_module_files_folders_urlsRoute'; - $joomla_module_files_folders_urls->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/joomla_module_files_folders_urls.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_module"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_module","targetTable": "#__componentbuilder_joomla_module","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if joomla_module_files_folders_urls type is already in content_type DB. - $joomla_module_files_folders_urls_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($joomla_module_files_folders_urls->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $joomla_module_files_folders_urls->type_id = $db->loadResult(); - $joomla_module_files_folders_urls_Updated = $db->updateObject('#__content_types', $joomla_module_files_folders_urls, 'type_id'); - } - else - { - $joomla_module_files_folders_urls_Inserted = $db->insertObject('#__content_types', $joomla_module_files_folders_urls); - } - - // Create the joomla_plugin_group content type object. - $joomla_plugin_group = new stdClass(); - $joomla_plugin_group->type_title = 'Componentbuilder Joomla_plugin_group'; - $joomla_plugin_group->type_alias = 'com_componentbuilder.joomla_plugin_group'; - $joomla_plugin_group->table = '{"special": {"dbtable": "#__componentbuilder_joomla_plugin_group","key": "id","type": "Joomla_plugin_group","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $joomla_plugin_group->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","class_extends":"class_extends"}}'; - $joomla_plugin_group->router = 'ComponentbuilderHelperRoute::getJoomla_plugin_groupRoute'; - $joomla_plugin_group->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/joomla_plugin_group.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","class_extends"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "class_extends","targetTable": "#__componentbuilder_class_extends","targetColumn": "id","displayColumn": "name"}]}'; - - // Check if joomla_plugin_group type is already in content_type DB. - $joomla_plugin_group_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($joomla_plugin_group->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $joomla_plugin_group->type_id = $db->loadResult(); - $joomla_plugin_group_Updated = $db->updateObject('#__content_types', $joomla_plugin_group, 'type_id'); - } - else - { - $joomla_plugin_group_Inserted = $db->insertObject('#__content_types', $joomla_plugin_group); - } - - // Create the joomla_plugin_updates content type object. - $joomla_plugin_updates = new stdClass(); - $joomla_plugin_updates->type_title = 'Componentbuilder Joomla_plugin_updates'; - $joomla_plugin_updates->type_alias = 'com_componentbuilder.joomla_plugin_updates'; - $joomla_plugin_updates->table = '{"special": {"dbtable": "#__componentbuilder_joomla_plugin_updates","key": "id","type": "Joomla_plugin_updates","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $joomla_plugin_updates->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_plugin","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_plugin":"joomla_plugin"}}'; - $joomla_plugin_updates->router = 'ComponentbuilderHelperRoute::getJoomla_plugin_updatesRoute'; - $joomla_plugin_updates->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/joomla_plugin_updates.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_plugin"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_plugin","targetTable": "#__componentbuilder_joomla_plugin","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if joomla_plugin_updates type is already in content_type DB. - $joomla_plugin_updates_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($joomla_plugin_updates->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $joomla_plugin_updates->type_id = $db->loadResult(); - $joomla_plugin_updates_Updated = $db->updateObject('#__content_types', $joomla_plugin_updates, 'type_id'); - } - else - { - $joomla_plugin_updates_Inserted = $db->insertObject('#__content_types', $joomla_plugin_updates); - } - - // Create the joomla_plugin_files_folders_urls content type object. - $joomla_plugin_files_folders_urls = new stdClass(); - $joomla_plugin_files_folders_urls->type_title = 'Componentbuilder Joomla_plugin_files_folders_urls'; - $joomla_plugin_files_folders_urls->type_alias = 'com_componentbuilder.joomla_plugin_files_folders_urls'; - $joomla_plugin_files_folders_urls->table = '{"special": {"dbtable": "#__componentbuilder_joomla_plugin_files_folders_urls","key": "id","type": "Joomla_plugin_files_folders_urls","prefix": "componentbuilderTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}'; - $joomla_plugin_files_folders_urls->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "joomla_plugin","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"joomla_plugin":"joomla_plugin"}}'; - $joomla_plugin_files_folders_urls->router = 'ComponentbuilderHelperRoute::getJoomla_plugin_files_folders_urlsRoute'; - $joomla_plugin_files_folders_urls->content_history_options = '{"formFile": "administrator/components/com_componentbuilder/models/forms/joomla_plugin_files_folders_urls.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","joomla_plugin"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "joomla_plugin","targetTable": "#__componentbuilder_joomla_plugin","targetColumn": "id","displayColumn": "system_name"}]}'; - - // Check if joomla_plugin_files_folders_urls type is already in content_type DB. - $joomla_plugin_files_folders_urls_id = null; - $query = $db->getQuery(true); - $query->select($db->quoteName(array('type_id'))); - $query->from($db->quoteName('#__content_types')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($joomla_plugin_files_folders_urls->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $joomla_plugin_files_folders_urls->type_id = $db->loadResult(); - $joomla_plugin_files_folders_urls_Updated = $db->updateObject('#__content_types', $joomla_plugin_files_folders_urls, 'type_id'); - } - else - { - $joomla_plugin_files_folders_urls_Inserted = $db->insertObject('#__content_types', $joomla_plugin_files_folders_urls); - } - - - - - // target version less then 2.6.5 - if ((count($this->JCBversion) == 3 && $this->JCBversion[0] <= 2 && $this->JCBversion[1] <= 6 && (($this->JCBversion[1] == 6 && $this->JCBversion[2] <= 4) || ($this->JCBversion[1] < 6)))) - { - // add libraries to the snippets - $libraries = array( - 2 => array('have' => array('getbootstrap.com/docs/4.0', 'v4-alpha.getbootstrap.com')), // Bootstrap v4 - 3 => array('have' => array('getuikit.com/docs/'), 'not' => '.html'), // Uikit v3 - 4 => array('have' => array('getuikit.com/docs/', 'getuikit.com/v2/'), 'and' => '.html'), // Uikit v2 - 5 => array('have' => array('fooplugins.com/footable-demos')) // FooTable - ); - // Create a new query object. - $query = $db->getQuery(true); - // get all Joomla Component FTP values - $query->select($db->quoteName(array('id', 'url'))); - $query->from($db->quoteName('#__componentbuilder_snippet')); - $query->where($db->quoteName('library') . ' < 1'); // only snippets with no lib set - // Reset the query using our newly populated query object. - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - $updater = array(); - $rows = $db->loadObjectList(); - foreach ($rows as $row) - { - foreach ($libraries as $id => $library) - { - if (!isset($updater[$row->id]) && StringHelper::check($row->url)) - { - foreach($library['have'] as $url) - { - if (strpos($row->url, $url) !== false) - { - if (isset($library['not'])) - { - if (strpos($row->url, $library['not']) === false) - { - // Create an object. - $updater[$row->id] = new stdClass(); - $updater[$row->id]->id = $row->id; - $updater[$row->id]->library = $id; - } - } - elseif (isset($library['and'])) - { - if (strpos($row->url, $library['and']) !== false) - { - // Create an object. - $updater[$row->id] = new stdClass(); - $updater[$row->id]->id = $row->id; - $updater[$row->id]->library = $id; - } - } - else - { - // Create an object. - $updater[$row->id] = new stdClass(); - $updater[$row->id]->id = $row->id; - $updater[$row->id]->library = $id; - } - } - } - } - } - // if still not found - if (!isset($updater[$row->id])) - { - // Create an object. - $updater[$row->id] = new stdClass(); - $updater[$row->id]->id = $row->id; - $updater[$row->id]->library = 1; // default (no library) - } - } - // update if set - if (ArrayHelper::check($updater)) - { - foreach($updater as $item) - { - // add contributor details to those made by JCB - if ($item->id < 94) - { - $item->contributor_company = 'Vast Development Method'; - $item->contributor_name = 'Llewellyn van der Merwe'; - $item->contributor_email = 'joomla@vdm.io'; - $item->contributor_website = 'https://www.vdm.io/'; - } - // update the snippets table with the new library ids - $db->updateObject('#__componentbuilder_snippet', $item, 'id'); - } - } - } - } - // set some defaults - if ((isset($this->setFtpValues) && ArrayHelper::check($this->setFtpValues)) || (isset($this->setMoveValues) && ArrayHelper::check($this->setMoveValues))) - { - // Get the date - $today = JFactory::getDate()->toSql(); - // Get the user object - $user = JFactory::getUser(); - } - // check if we have stuff to move - if (isset($this->setMoveValues) && ArrayHelper::check($this->setMoveValues)) - { - // moving data now... but first check if data not already set - foreach ($this->setMoveValues as $table => $items) - { - if (ArrayHelper::check($items)) - { - foreach($items as $item) - { - // okay if found ignore move - if (isset($item->{$this->dynamicTable[$table]}) && $item->{$this->dynamicTable[$table]} > 0 && !ComponentbuilderHelper::getVar($table, (int) $item->{$this->dynamicTable[$table]}, $this->dynamicTable[$table], 'id')) - { - $item->published = 1; - $item->version = 2; - $item->created = $today; - $item->created_by = (int) $user->id; - $done = $db->insertObject('#__componentbuilder_'.$table, $item); - // update the component if stored - if ($done) - { - // get the last ID - $newId = $db->insertid(); - // make sure the access of asset is set - ComponentbuilderHelper::setAsset($newId,$table); - } - } - } - } - } - } - // check if any links were found - if (isset($this->setFtpValues) && ArrayHelper::check($this->setFtpValues)) - { - // build the storage buckets - foreach ($this->setFtpValues as $hash => $item) - { - // get host name - $hostusername = GetHelper::between($item['ftp'], 'username=', '&'); - // get key - $keys = explode('__', $hash); - $key = $keys[1]; - if (StringHelper::check($hostusername) && $hostusername !== 'user@name.com' && strpos($hostusername, '@') !== false && strpos($hostusername, '.') !== false) - { - $name = explode('.', $hostusername); - // Create an object. - $object = new stdClass(); - $object->signature = $item['signature']; // the still locked version (if there is a basic key) - $object->name = str_replace('@', ' ', $name[0]); - $object->published = 1; - $object->version = 2; - $object->created = $today; - $object->created_by = (int) $user->id; - // safe the FTP server - $done = $db->insertObject('#__componentbuilder_ftp', $object); - // update the component if stored - if ($done) - { - // get the last ID - $newId = $db->insertid(); - // make sure the access of asset is set - ComponentbuilderHelper::setAsset($newId,'ftp'); - // now update the components - if (ArrayHelper::check($item['ids'])) - { - foreach ($item['ids'] as $compId) - { - // Create an object. - $object = new stdClass(); - $object->id = $compId; - $object->{$key} = $newId; - // Update with the object the joomla_component table. - $db->updateObject('#__componentbuilder_joomla_component', $object, 'id'); - } - } - } - } - else - { - // now update the components - if (ArrayHelper::check($item['ids'])) - { - foreach ($item['ids'] as $compId) - { - // Create an object. - $object = new stdClass(); - $object->id = $compId; - $object->{$key} = ''; // remove all values to insure stability - // Insert the object into the joomla_component table. - $db->updateObject('#__componentbuilder_joomla_component', $object, 'id'); - } - } - } - } - } - // target version less then or equal to 2.11.1 - if (count($this->JCBversion) == 3 && $this->JCBversion[0] <= 2 && ($this->JCBversion[1] < 11 || ($this->JCBversion[1] == 11 && $this->JCBversion[2] <= 1))) - { - // keep track of used - $usedGUID = array(); - /** - * Returns a GUIDv4 string - * - * Thanks to Dave Pearson (and other) - * https://www.php.net/manual/en/function.com-create-guid.php#119168 - * - * Uses the best cryptographically secure method - * for all supported platforms with fallback to an older, - * less secure version. - * - * @param bool $trim - * @return string - */ - function GUID($trim = true) - { - // Windows - if (function_exists('com_create_guid') === true) - { - if ($trim === true) - { - return trim(com_create_guid(), '{}'); - } - return com_create_guid(); - } - - // set the braces if needed - $lbrace = $trim ? "" : chr(123); // "{" - $rbrace = $trim ? "" : chr(125); // "}" - - // OSX/Linux - if (function_exists('openssl_random_pseudo_bytes') === true) - { - $data = openssl_random_pseudo_bytes(16); - $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100 - $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10 - return $lbrace . vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)) . $lbrace; - } - - // Fallback (PHP 4.2+) - mt_srand((double)microtime() * 10000); - $charid = strtolower(md5(uniqid(rand(), true))); - $hyphen = chr(45); // "-" - $guidv4 = $lbrace. - substr($charid, 0, 8).$hyphen. - substr($charid, 8, 4).$hyphen. - substr($charid, 12, 4).$hyphen. - substr($charid, 16, 4).$hyphen. - substr($charid, 20, 12). - $rbrace; - return $guidv4; - } - - /** - * Validate the Globally Unique Identifier - * - * Thanks to Lewie - * https://stackoverflow.com/a/1515456/1429677 - * - * @param string $guid - * @return bool - */ - function validateGUID ($guid) - { - // check if we have a string - if (StringHelper::check($guid)) - { - return preg_match("/^(\{)?[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}(?(1)\})$/i", $guid); - } - return false; - } - - /** - * Validate the Globally Unique Identifier - * - * @param string $guid - * @return bool - */ - function validGUID ($guid, &$usedGUID) - { - // check if we have a string - if (validateGUID($guid) && !isset($usedGUID[$guid])) - { - $usedGUID[$guid] = true; - return true; - } - return false; - } - - // we must update all GUID's for future use :) - $guid_tables = array( - 'joomla_component', - 'joomla_module', - 'joomla_plugin', - 'admin_view', - 'custom_admin_view', - 'site_view', - 'dynamic_get', - 'class_property', - 'class_method', - 'library', - 'snippet', - 'field', - 'fieldtype' - ); - - // update all GUID tables - foreach ($guid_tables as $guid_table) - { - // Create a new query object. - $query = $db->getQuery(true); - // get all ids and guids of each table - $query->select($db->quoteName(array('id', 'guid'))); - $query->from($db->quoteName('#__componentbuilder_' . $guid_table)); - // Reset the query using our newly populated query object. - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - // keep track of used - $usedGUID = array(); - // get the rows - $rows = $db->loadObjectList(); - foreach ($rows as $row) - { - // load value not to use it again - if (!validGUID($row->guid, $usedGUID)) - { - // Create a new query object. - $query = $db->getQuery(true); - // load the guid - $fields = array( - $db->quoteName('guid') . ' = ' . $db->quote(GUID()) - ); - // Conditions for which records should be updated. - $conditions = array( - $db->quoteName('id') . ' = ' . (int) $row->id - ); - // update the row - $query->update($db->quoteName('#__componentbuilder_'. $guid_table))->set($fields)->where($conditions); - $db->setQuery($query); - $db->execute(); - } - } - } - } - } - // check if this install has the libraries in the helper folder, if so remove it - $vendorPath = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/vendor'; - if (JFolder::exists($vendorPath)) - { - ComponentbuilderHelper::removeFolder($vendorPath); - // set a notice that this was done - $app->enqueueMessage('

    Best Practice!
    We have removed the composer-vendor folder from the /administrator/components/com_componentbuilder/helpers/ folder and placed it in the /libraries/vdm_io/ folder.

    ', 'Notice'); - } - // check if this install has the libraries in the helper folder, if so remove it - $vendorPath = JPATH_ROOT . '/libraries/vdm_io'; - if (JFolder::exists($vendorPath)) - { - ComponentbuilderHelper::removeFolder($vendorPath); - // set a notice that this was done - $app->enqueueMessage('

    Best Practice!
    We have removed the internal JCB composer-vendor folder /libraries/vdm_io/ and placed the targeted library (phpseclib) in its own folder /libraries/phpseclib/.

    ', 'Notice'); - } - // check if we still have the old Gitea Classes - $giteaPath = JPATH_ROOT . '/libraries/jcb_powers/VDM.Gitea'; - if (JFolder::exists($giteaPath)) - { - ComponentbuilderHelper::removeFolder($giteaPath); - // set a notice that this was done - $app->enqueueMessage('

    Clean-up!
    We have removed the internal old Gitea folder /libraries/jcb_powers/VDM.Gitea that is no longer used.
    The new Gitea classes are now found here /libraries/jcb_powers/VDM.Joomla.Gitea and is available to any JCB project from the following super power: https://git.vdm.dev/joomla/gitea

    ', 'Notice'); - } - echo ' - - -

    Upgrade to Version 3.1.28 Was Successful! Let us know if anything is not working as expected.

    '; - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the componentbuilder action logs extensions object. - $componentbuilder_action_logs_extensions = new stdClass(); - $componentbuilder_action_logs_extensions->extension = 'com_componentbuilder'; - - // Check if componentbuilder action log extension is already in action logs extensions DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_logs_extensions')); - $query->where($db->quoteName('extension') . ' LIKE '. $db->quote($componentbuilder_action_logs_extensions->extension)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the action logs extensions table if not found. - if (!$db->getNumRows()) - { - $componentbuilder_action_logs_extensions_Inserted = $db->insertObject('#__action_logs_extensions', $componentbuilder_action_logs_extensions); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the joomla_component action log config object. - $joomla_component_action_log_config = new stdClass(); - $joomla_component_action_log_config->id = null; - $joomla_component_action_log_config->type_title = 'JOOMLA_COMPONENT'; - $joomla_component_action_log_config->type_alias = 'com_componentbuilder.joomla_component'; - $joomla_component_action_log_config->id_holder = 'id'; - $joomla_component_action_log_config->title_holder = 'system_name'; - $joomla_component_action_log_config->table_name = '#__componentbuilder_joomla_component'; - $joomla_component_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if joomla_component action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($joomla_component_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $joomla_component_action_log_config->id = $db->loadResult(); - $joomla_component_action_log_config_Updated = $db->updateObject('#__action_log_config', $joomla_component_action_log_config, 'id'); - } - else - { - $joomla_component_action_log_config_Inserted = $db->insertObject('#__action_log_config', $joomla_component_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the joomla_module action log config object. - $joomla_module_action_log_config = new stdClass(); - $joomla_module_action_log_config->id = null; - $joomla_module_action_log_config->type_title = 'JOOMLA_MODULE'; - $joomla_module_action_log_config->type_alias = 'com_componentbuilder.joomla_module'; - $joomla_module_action_log_config->id_holder = 'id'; - $joomla_module_action_log_config->title_holder = 'system_name'; - $joomla_module_action_log_config->table_name = '#__componentbuilder_joomla_module'; - $joomla_module_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if joomla_module action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($joomla_module_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $joomla_module_action_log_config->id = $db->loadResult(); - $joomla_module_action_log_config_Updated = $db->updateObject('#__action_log_config', $joomla_module_action_log_config, 'id'); - } - else - { - $joomla_module_action_log_config_Inserted = $db->insertObject('#__action_log_config', $joomla_module_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the joomla_plugin action log config object. - $joomla_plugin_action_log_config = new stdClass(); - $joomla_plugin_action_log_config->id = null; - $joomla_plugin_action_log_config->type_title = 'JOOMLA_PLUGIN'; - $joomla_plugin_action_log_config->type_alias = 'com_componentbuilder.joomla_plugin'; - $joomla_plugin_action_log_config->id_holder = 'id'; - $joomla_plugin_action_log_config->title_holder = 'system_name'; - $joomla_plugin_action_log_config->table_name = '#__componentbuilder_joomla_plugin'; - $joomla_plugin_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if joomla_plugin action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($joomla_plugin_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $joomla_plugin_action_log_config->id = $db->loadResult(); - $joomla_plugin_action_log_config_Updated = $db->updateObject('#__action_log_config', $joomla_plugin_action_log_config, 'id'); - } - else - { - $joomla_plugin_action_log_config_Inserted = $db->insertObject('#__action_log_config', $joomla_plugin_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the power action log config object. - $power_action_log_config = new stdClass(); - $power_action_log_config->id = null; - $power_action_log_config->type_title = 'POWER'; - $power_action_log_config->type_alias = 'com_componentbuilder.power'; - $power_action_log_config->id_holder = 'id'; - $power_action_log_config->title_holder = 'system_name'; - $power_action_log_config->table_name = '#__componentbuilder_power'; - $power_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if power action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($power_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $power_action_log_config->id = $db->loadResult(); - $power_action_log_config_Updated = $db->updateObject('#__action_log_config', $power_action_log_config, 'id'); - } - else - { - $power_action_log_config_Inserted = $db->insertObject('#__action_log_config', $power_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the admin_view action log config object. - $admin_view_action_log_config = new stdClass(); - $admin_view_action_log_config->id = null; - $admin_view_action_log_config->type_title = 'ADMIN_VIEW'; - $admin_view_action_log_config->type_alias = 'com_componentbuilder.admin_view'; - $admin_view_action_log_config->id_holder = 'id'; - $admin_view_action_log_config->title_holder = 'system_name'; - $admin_view_action_log_config->table_name = '#__componentbuilder_admin_view'; - $admin_view_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if admin_view action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($admin_view_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $admin_view_action_log_config->id = $db->loadResult(); - $admin_view_action_log_config_Updated = $db->updateObject('#__action_log_config', $admin_view_action_log_config, 'id'); - } - else - { - $admin_view_action_log_config_Inserted = $db->insertObject('#__action_log_config', $admin_view_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the custom_admin_view action log config object. - $custom_admin_view_action_log_config = new stdClass(); - $custom_admin_view_action_log_config->id = null; - $custom_admin_view_action_log_config->type_title = 'CUSTOM_ADMIN_VIEW'; - $custom_admin_view_action_log_config->type_alias = 'com_componentbuilder.custom_admin_view'; - $custom_admin_view_action_log_config->id_holder = 'id'; - $custom_admin_view_action_log_config->title_holder = 'name'; - $custom_admin_view_action_log_config->table_name = '#__componentbuilder_custom_admin_view'; - $custom_admin_view_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if custom_admin_view action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($custom_admin_view_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $custom_admin_view_action_log_config->id = $db->loadResult(); - $custom_admin_view_action_log_config_Updated = $db->updateObject('#__action_log_config', $custom_admin_view_action_log_config, 'id'); - } - else - { - $custom_admin_view_action_log_config_Inserted = $db->insertObject('#__action_log_config', $custom_admin_view_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the site_view action log config object. - $site_view_action_log_config = new stdClass(); - $site_view_action_log_config->id = null; - $site_view_action_log_config->type_title = 'SITE_VIEW'; - $site_view_action_log_config->type_alias = 'com_componentbuilder.site_view'; - $site_view_action_log_config->id_holder = 'id'; - $site_view_action_log_config->title_holder = 'name'; - $site_view_action_log_config->table_name = '#__componentbuilder_site_view'; - $site_view_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if site_view action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($site_view_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $site_view_action_log_config->id = $db->loadResult(); - $site_view_action_log_config_Updated = $db->updateObject('#__action_log_config', $site_view_action_log_config, 'id'); - } - else - { - $site_view_action_log_config_Inserted = $db->insertObject('#__action_log_config', $site_view_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the template action log config object. - $template_action_log_config = new stdClass(); - $template_action_log_config->id = null; - $template_action_log_config->type_title = 'TEMPLATE'; - $template_action_log_config->type_alias = 'com_componentbuilder.template'; - $template_action_log_config->id_holder = 'id'; - $template_action_log_config->title_holder = 'name'; - $template_action_log_config->table_name = '#__componentbuilder_template'; - $template_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if template action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($template_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $template_action_log_config->id = $db->loadResult(); - $template_action_log_config_Updated = $db->updateObject('#__action_log_config', $template_action_log_config, 'id'); - } - else - { - $template_action_log_config_Inserted = $db->insertObject('#__action_log_config', $template_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the layout action log config object. - $layout_action_log_config = new stdClass(); - $layout_action_log_config->id = null; - $layout_action_log_config->type_title = 'LAYOUT'; - $layout_action_log_config->type_alias = 'com_componentbuilder.layout'; - $layout_action_log_config->id_holder = 'id'; - $layout_action_log_config->title_holder = 'name'; - $layout_action_log_config->table_name = '#__componentbuilder_layout'; - $layout_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if layout action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($layout_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $layout_action_log_config->id = $db->loadResult(); - $layout_action_log_config_Updated = $db->updateObject('#__action_log_config', $layout_action_log_config, 'id'); - } - else - { - $layout_action_log_config_Inserted = $db->insertObject('#__action_log_config', $layout_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the dynamic_get action log config object. - $dynamic_get_action_log_config = new stdClass(); - $dynamic_get_action_log_config->id = null; - $dynamic_get_action_log_config->type_title = 'DYNAMIC_GET'; - $dynamic_get_action_log_config->type_alias = 'com_componentbuilder.dynamic_get'; - $dynamic_get_action_log_config->id_holder = 'id'; - $dynamic_get_action_log_config->title_holder = 'name'; - $dynamic_get_action_log_config->table_name = '#__componentbuilder_dynamic_get'; - $dynamic_get_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if dynamic_get action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($dynamic_get_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $dynamic_get_action_log_config->id = $db->loadResult(); - $dynamic_get_action_log_config_Updated = $db->updateObject('#__action_log_config', $dynamic_get_action_log_config, 'id'); - } - else - { - $dynamic_get_action_log_config_Inserted = $db->insertObject('#__action_log_config', $dynamic_get_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the custom_code action log config object. - $custom_code_action_log_config = new stdClass(); - $custom_code_action_log_config->id = null; - $custom_code_action_log_config->type_title = 'CUSTOM_CODE'; - $custom_code_action_log_config->type_alias = 'com_componentbuilder.custom_code'; - $custom_code_action_log_config->id_holder = 'id'; - $custom_code_action_log_config->title_holder = 'component'; - $custom_code_action_log_config->table_name = '#__componentbuilder_custom_code'; - $custom_code_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if custom_code action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($custom_code_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $custom_code_action_log_config->id = $db->loadResult(); - $custom_code_action_log_config_Updated = $db->updateObject('#__action_log_config', $custom_code_action_log_config, 'id'); - } - else - { - $custom_code_action_log_config_Inserted = $db->insertObject('#__action_log_config', $custom_code_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the class_property action log config object. - $class_property_action_log_config = new stdClass(); - $class_property_action_log_config->id = null; - $class_property_action_log_config->type_title = 'CLASS_PROPERTY'; - $class_property_action_log_config->type_alias = 'com_componentbuilder.class_property'; - $class_property_action_log_config->id_holder = 'id'; - $class_property_action_log_config->title_holder = 'name'; - $class_property_action_log_config->table_name = '#__componentbuilder_class_property'; - $class_property_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if class_property action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($class_property_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $class_property_action_log_config->id = $db->loadResult(); - $class_property_action_log_config_Updated = $db->updateObject('#__action_log_config', $class_property_action_log_config, 'id'); - } - else - { - $class_property_action_log_config_Inserted = $db->insertObject('#__action_log_config', $class_property_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the class_method action log config object. - $class_method_action_log_config = new stdClass(); - $class_method_action_log_config->id = null; - $class_method_action_log_config->type_title = 'CLASS_METHOD'; - $class_method_action_log_config->type_alias = 'com_componentbuilder.class_method'; - $class_method_action_log_config->id_holder = 'id'; - $class_method_action_log_config->title_holder = 'name'; - $class_method_action_log_config->table_name = '#__componentbuilder_class_method'; - $class_method_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if class_method action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($class_method_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $class_method_action_log_config->id = $db->loadResult(); - $class_method_action_log_config_Updated = $db->updateObject('#__action_log_config', $class_method_action_log_config, 'id'); - } - else - { - $class_method_action_log_config_Inserted = $db->insertObject('#__action_log_config', $class_method_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the placeholder action log config object. - $placeholder_action_log_config = new stdClass(); - $placeholder_action_log_config->id = null; - $placeholder_action_log_config->type_title = 'PLACEHOLDER'; - $placeholder_action_log_config->type_alias = 'com_componentbuilder.placeholder'; - $placeholder_action_log_config->id_holder = 'id'; - $placeholder_action_log_config->title_holder = 'target'; - $placeholder_action_log_config->table_name = '#__componentbuilder_placeholder'; - $placeholder_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if placeholder action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($placeholder_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $placeholder_action_log_config->id = $db->loadResult(); - $placeholder_action_log_config_Updated = $db->updateObject('#__action_log_config', $placeholder_action_log_config, 'id'); - } - else - { - $placeholder_action_log_config_Inserted = $db->insertObject('#__action_log_config', $placeholder_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the library action log config object. - $library_action_log_config = new stdClass(); - $library_action_log_config->id = null; - $library_action_log_config->type_title = 'LIBRARY'; - $library_action_log_config->type_alias = 'com_componentbuilder.library'; - $library_action_log_config->id_holder = 'id'; - $library_action_log_config->title_holder = 'name'; - $library_action_log_config->table_name = '#__componentbuilder_library'; - $library_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if library action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($library_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $library_action_log_config->id = $db->loadResult(); - $library_action_log_config_Updated = $db->updateObject('#__action_log_config', $library_action_log_config, 'id'); - } - else - { - $library_action_log_config_Inserted = $db->insertObject('#__action_log_config', $library_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the snippet action log config object. - $snippet_action_log_config = new stdClass(); - $snippet_action_log_config->id = null; - $snippet_action_log_config->type_title = 'SNIPPET'; - $snippet_action_log_config->type_alias = 'com_componentbuilder.snippet'; - $snippet_action_log_config->id_holder = 'id'; - $snippet_action_log_config->title_holder = 'name'; - $snippet_action_log_config->table_name = '#__componentbuilder_snippet'; - $snippet_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if snippet action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($snippet_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $snippet_action_log_config->id = $db->loadResult(); - $snippet_action_log_config_Updated = $db->updateObject('#__action_log_config', $snippet_action_log_config, 'id'); - } - else - { - $snippet_action_log_config_Inserted = $db->insertObject('#__action_log_config', $snippet_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the validation_rule action log config object. - $validation_rule_action_log_config = new stdClass(); - $validation_rule_action_log_config->id = null; - $validation_rule_action_log_config->type_title = 'VALIDATION_RULE'; - $validation_rule_action_log_config->type_alias = 'com_componentbuilder.validation_rule'; - $validation_rule_action_log_config->id_holder = 'id'; - $validation_rule_action_log_config->title_holder = 'name'; - $validation_rule_action_log_config->table_name = '#__componentbuilder_validation_rule'; - $validation_rule_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if validation_rule action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($validation_rule_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $validation_rule_action_log_config->id = $db->loadResult(); - $validation_rule_action_log_config_Updated = $db->updateObject('#__action_log_config', $validation_rule_action_log_config, 'id'); - } - else - { - $validation_rule_action_log_config_Inserted = $db->insertObject('#__action_log_config', $validation_rule_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the field action log config object. - $field_action_log_config = new stdClass(); - $field_action_log_config->id = null; - $field_action_log_config->type_title = 'FIELD'; - $field_action_log_config->type_alias = 'com_componentbuilder.field'; - $field_action_log_config->id_holder = 'id'; - $field_action_log_config->title_holder = 'name'; - $field_action_log_config->table_name = '#__componentbuilder_field'; - $field_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if field action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($field_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $field_action_log_config->id = $db->loadResult(); - $field_action_log_config_Updated = $db->updateObject('#__action_log_config', $field_action_log_config, 'id'); - } - else - { - $field_action_log_config_Inserted = $db->insertObject('#__action_log_config', $field_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the fieldtype action log config object. - $fieldtype_action_log_config = new stdClass(); - $fieldtype_action_log_config->id = null; - $fieldtype_action_log_config->type_title = 'FIELDTYPE'; - $fieldtype_action_log_config->type_alias = 'com_componentbuilder.fieldtype'; - $fieldtype_action_log_config->id_holder = 'id'; - $fieldtype_action_log_config->title_holder = 'name'; - $fieldtype_action_log_config->table_name = '#__componentbuilder_fieldtype'; - $fieldtype_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if fieldtype action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($fieldtype_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $fieldtype_action_log_config->id = $db->loadResult(); - $fieldtype_action_log_config_Updated = $db->updateObject('#__action_log_config', $fieldtype_action_log_config, 'id'); - } - else - { - $fieldtype_action_log_config_Inserted = $db->insertObject('#__action_log_config', $fieldtype_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the language_translation action log config object. - $language_translation_action_log_config = new stdClass(); - $language_translation_action_log_config->id = null; - $language_translation_action_log_config->type_title = 'LANGUAGE_TRANSLATION'; - $language_translation_action_log_config->type_alias = 'com_componentbuilder.language_translation'; - $language_translation_action_log_config->id_holder = 'id'; - $language_translation_action_log_config->title_holder = 'source'; - $language_translation_action_log_config->table_name = '#__componentbuilder_language_translation'; - $language_translation_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if language_translation action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($language_translation_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $language_translation_action_log_config->id = $db->loadResult(); - $language_translation_action_log_config_Updated = $db->updateObject('#__action_log_config', $language_translation_action_log_config, 'id'); - } - else - { - $language_translation_action_log_config_Inserted = $db->insertObject('#__action_log_config', $language_translation_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the language action log config object. - $language_action_log_config = new stdClass(); - $language_action_log_config->id = null; - $language_action_log_config->type_title = 'LANGUAGE'; - $language_action_log_config->type_alias = 'com_componentbuilder.language'; - $language_action_log_config->id_holder = 'id'; - $language_action_log_config->title_holder = 'name'; - $language_action_log_config->table_name = '#__componentbuilder_language'; - $language_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if language action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($language_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $language_action_log_config->id = $db->loadResult(); - $language_action_log_config_Updated = $db->updateObject('#__action_log_config', $language_action_log_config, 'id'); - } - else - { - $language_action_log_config_Inserted = $db->insertObject('#__action_log_config', $language_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the server action log config object. - $server_action_log_config = new stdClass(); - $server_action_log_config->id = null; - $server_action_log_config->type_title = 'SERVER'; - $server_action_log_config->type_alias = 'com_componentbuilder.server'; - $server_action_log_config->id_holder = 'id'; - $server_action_log_config->title_holder = 'name'; - $server_action_log_config->table_name = '#__componentbuilder_server'; - $server_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if server action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($server_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $server_action_log_config->id = $db->loadResult(); - $server_action_log_config_Updated = $db->updateObject('#__action_log_config', $server_action_log_config, 'id'); - } - else - { - $server_action_log_config_Inserted = $db->insertObject('#__action_log_config', $server_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the help_document action log config object. - $help_document_action_log_config = new stdClass(); - $help_document_action_log_config->id = null; - $help_document_action_log_config->type_title = 'HELP_DOCUMENT'; - $help_document_action_log_config->type_alias = 'com_componentbuilder.help_document'; - $help_document_action_log_config->id_holder = 'id'; - $help_document_action_log_config->title_holder = 'title'; - $help_document_action_log_config->table_name = '#__componentbuilder_help_document'; - $help_document_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if help_document action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($help_document_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $help_document_action_log_config->id = $db->loadResult(); - $help_document_action_log_config_Updated = $db->updateObject('#__action_log_config', $help_document_action_log_config, 'id'); - } - else - { - $help_document_action_log_config_Inserted = $db->insertObject('#__action_log_config', $help_document_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the admin_fields action log config object. - $admin_fields_action_log_config = new stdClass(); - $admin_fields_action_log_config->id = null; - $admin_fields_action_log_config->type_title = 'ADMIN_FIELDS'; - $admin_fields_action_log_config->type_alias = 'com_componentbuilder.admin_fields'; - $admin_fields_action_log_config->id_holder = 'id'; - $admin_fields_action_log_config->title_holder = 'admin_view'; - $admin_fields_action_log_config->table_name = '#__componentbuilder_admin_fields'; - $admin_fields_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if admin_fields action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($admin_fields_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $admin_fields_action_log_config->id = $db->loadResult(); - $admin_fields_action_log_config_Updated = $db->updateObject('#__action_log_config', $admin_fields_action_log_config, 'id'); - } - else - { - $admin_fields_action_log_config_Inserted = $db->insertObject('#__action_log_config', $admin_fields_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the admin_fields_conditions action log config object. - $admin_fields_conditions_action_log_config = new stdClass(); - $admin_fields_conditions_action_log_config->id = null; - $admin_fields_conditions_action_log_config->type_title = 'ADMIN_FIELDS_CONDITIONS'; - $admin_fields_conditions_action_log_config->type_alias = 'com_componentbuilder.admin_fields_conditions'; - $admin_fields_conditions_action_log_config->id_holder = 'id'; - $admin_fields_conditions_action_log_config->title_holder = 'admin_view'; - $admin_fields_conditions_action_log_config->table_name = '#__componentbuilder_admin_fields_conditions'; - $admin_fields_conditions_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if admin_fields_conditions action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($admin_fields_conditions_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $admin_fields_conditions_action_log_config->id = $db->loadResult(); - $admin_fields_conditions_action_log_config_Updated = $db->updateObject('#__action_log_config', $admin_fields_conditions_action_log_config, 'id'); - } - else - { - $admin_fields_conditions_action_log_config_Inserted = $db->insertObject('#__action_log_config', $admin_fields_conditions_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the admin_fields_relations action log config object. - $admin_fields_relations_action_log_config = new stdClass(); - $admin_fields_relations_action_log_config->id = null; - $admin_fields_relations_action_log_config->type_title = 'ADMIN_FIELDS_RELATIONS'; - $admin_fields_relations_action_log_config->type_alias = 'com_componentbuilder.admin_fields_relations'; - $admin_fields_relations_action_log_config->id_holder = 'id'; - $admin_fields_relations_action_log_config->title_holder = 'admin_view'; - $admin_fields_relations_action_log_config->table_name = '#__componentbuilder_admin_fields_relations'; - $admin_fields_relations_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if admin_fields_relations action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($admin_fields_relations_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $admin_fields_relations_action_log_config->id = $db->loadResult(); - $admin_fields_relations_action_log_config_Updated = $db->updateObject('#__action_log_config', $admin_fields_relations_action_log_config, 'id'); - } - else - { - $admin_fields_relations_action_log_config_Inserted = $db->insertObject('#__action_log_config', $admin_fields_relations_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the admin_custom_tabs action log config object. - $admin_custom_tabs_action_log_config = new stdClass(); - $admin_custom_tabs_action_log_config->id = null; - $admin_custom_tabs_action_log_config->type_title = 'ADMIN_CUSTOM_TABS'; - $admin_custom_tabs_action_log_config->type_alias = 'com_componentbuilder.admin_custom_tabs'; - $admin_custom_tabs_action_log_config->id_holder = 'id'; - $admin_custom_tabs_action_log_config->title_holder = 'admin_view'; - $admin_custom_tabs_action_log_config->table_name = '#__componentbuilder_admin_custom_tabs'; - $admin_custom_tabs_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if admin_custom_tabs action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($admin_custom_tabs_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $admin_custom_tabs_action_log_config->id = $db->loadResult(); - $admin_custom_tabs_action_log_config_Updated = $db->updateObject('#__action_log_config', $admin_custom_tabs_action_log_config, 'id'); - } - else - { - $admin_custom_tabs_action_log_config_Inserted = $db->insertObject('#__action_log_config', $admin_custom_tabs_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_admin_views action log config object. - $component_admin_views_action_log_config = new stdClass(); - $component_admin_views_action_log_config->id = null; - $component_admin_views_action_log_config->type_title = 'COMPONENT_ADMIN_VIEWS'; - $component_admin_views_action_log_config->type_alias = 'com_componentbuilder.component_admin_views'; - $component_admin_views_action_log_config->id_holder = 'id'; - $component_admin_views_action_log_config->title_holder = 'joomla_component'; - $component_admin_views_action_log_config->table_name = '#__componentbuilder_component_admin_views'; - $component_admin_views_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if component_admin_views action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_admin_views_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_admin_views_action_log_config->id = $db->loadResult(); - $component_admin_views_action_log_config_Updated = $db->updateObject('#__action_log_config', $component_admin_views_action_log_config, 'id'); - } - else - { - $component_admin_views_action_log_config_Inserted = $db->insertObject('#__action_log_config', $component_admin_views_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_site_views action log config object. - $component_site_views_action_log_config = new stdClass(); - $component_site_views_action_log_config->id = null; - $component_site_views_action_log_config->type_title = 'COMPONENT_SITE_VIEWS'; - $component_site_views_action_log_config->type_alias = 'com_componentbuilder.component_site_views'; - $component_site_views_action_log_config->id_holder = 'id'; - $component_site_views_action_log_config->title_holder = 'joomla_component'; - $component_site_views_action_log_config->table_name = '#__componentbuilder_component_site_views'; - $component_site_views_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if component_site_views action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_site_views_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_site_views_action_log_config->id = $db->loadResult(); - $component_site_views_action_log_config_Updated = $db->updateObject('#__action_log_config', $component_site_views_action_log_config, 'id'); - } - else - { - $component_site_views_action_log_config_Inserted = $db->insertObject('#__action_log_config', $component_site_views_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_custom_admin_views action log config object. - $component_custom_admin_views_action_log_config = new stdClass(); - $component_custom_admin_views_action_log_config->id = null; - $component_custom_admin_views_action_log_config->type_title = 'COMPONENT_CUSTOM_ADMIN_VIEWS'; - $component_custom_admin_views_action_log_config->type_alias = 'com_componentbuilder.component_custom_admin_views'; - $component_custom_admin_views_action_log_config->id_holder = 'id'; - $component_custom_admin_views_action_log_config->title_holder = 'joomla_component'; - $component_custom_admin_views_action_log_config->table_name = '#__componentbuilder_component_custom_admin_views'; - $component_custom_admin_views_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if component_custom_admin_views action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_custom_admin_views_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_custom_admin_views_action_log_config->id = $db->loadResult(); - $component_custom_admin_views_action_log_config_Updated = $db->updateObject('#__action_log_config', $component_custom_admin_views_action_log_config, 'id'); - } - else - { - $component_custom_admin_views_action_log_config_Inserted = $db->insertObject('#__action_log_config', $component_custom_admin_views_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_updates action log config object. - $component_updates_action_log_config = new stdClass(); - $component_updates_action_log_config->id = null; - $component_updates_action_log_config->type_title = 'COMPONENT_UPDATES'; - $component_updates_action_log_config->type_alias = 'com_componentbuilder.component_updates'; - $component_updates_action_log_config->id_holder = 'id'; - $component_updates_action_log_config->title_holder = 'joomla_component'; - $component_updates_action_log_config->table_name = '#__componentbuilder_component_updates'; - $component_updates_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if component_updates action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_updates_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_updates_action_log_config->id = $db->loadResult(); - $component_updates_action_log_config_Updated = $db->updateObject('#__action_log_config', $component_updates_action_log_config, 'id'); - } - else - { - $component_updates_action_log_config_Inserted = $db->insertObject('#__action_log_config', $component_updates_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_mysql_tweaks action log config object. - $component_mysql_tweaks_action_log_config = new stdClass(); - $component_mysql_tweaks_action_log_config->id = null; - $component_mysql_tweaks_action_log_config->type_title = 'COMPONENT_MYSQL_TWEAKS'; - $component_mysql_tweaks_action_log_config->type_alias = 'com_componentbuilder.component_mysql_tweaks'; - $component_mysql_tweaks_action_log_config->id_holder = 'id'; - $component_mysql_tweaks_action_log_config->title_holder = 'joomla_component'; - $component_mysql_tweaks_action_log_config->table_name = '#__componentbuilder_component_mysql_tweaks'; - $component_mysql_tweaks_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if component_mysql_tweaks action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_mysql_tweaks_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_mysql_tweaks_action_log_config->id = $db->loadResult(); - $component_mysql_tweaks_action_log_config_Updated = $db->updateObject('#__action_log_config', $component_mysql_tweaks_action_log_config, 'id'); - } - else - { - $component_mysql_tweaks_action_log_config_Inserted = $db->insertObject('#__action_log_config', $component_mysql_tweaks_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_custom_admin_menus action log config object. - $component_custom_admin_menus_action_log_config = new stdClass(); - $component_custom_admin_menus_action_log_config->id = null; - $component_custom_admin_menus_action_log_config->type_title = 'COMPONENT_CUSTOM_ADMIN_MENUS'; - $component_custom_admin_menus_action_log_config->type_alias = 'com_componentbuilder.component_custom_admin_menus'; - $component_custom_admin_menus_action_log_config->id_holder = 'id'; - $component_custom_admin_menus_action_log_config->title_holder = 'joomla_component'; - $component_custom_admin_menus_action_log_config->table_name = '#__componentbuilder_component_custom_admin_menus'; - $component_custom_admin_menus_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if component_custom_admin_menus action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_custom_admin_menus_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_custom_admin_menus_action_log_config->id = $db->loadResult(); - $component_custom_admin_menus_action_log_config_Updated = $db->updateObject('#__action_log_config', $component_custom_admin_menus_action_log_config, 'id'); - } - else - { - $component_custom_admin_menus_action_log_config_Inserted = $db->insertObject('#__action_log_config', $component_custom_admin_menus_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_config action log config object. - $component_config_action_log_config = new stdClass(); - $component_config_action_log_config->id = null; - $component_config_action_log_config->type_title = 'COMPONENT_CONFIG'; - $component_config_action_log_config->type_alias = 'com_componentbuilder.component_config'; - $component_config_action_log_config->id_holder = 'id'; - $component_config_action_log_config->title_holder = 'joomla_component'; - $component_config_action_log_config->table_name = '#__componentbuilder_component_config'; - $component_config_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if component_config action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_config_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_config_action_log_config->id = $db->loadResult(); - $component_config_action_log_config_Updated = $db->updateObject('#__action_log_config', $component_config_action_log_config, 'id'); - } - else - { - $component_config_action_log_config_Inserted = $db->insertObject('#__action_log_config', $component_config_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_dashboard action log config object. - $component_dashboard_action_log_config = new stdClass(); - $component_dashboard_action_log_config->id = null; - $component_dashboard_action_log_config->type_title = 'COMPONENT_DASHBOARD'; - $component_dashboard_action_log_config->type_alias = 'com_componentbuilder.component_dashboard'; - $component_dashboard_action_log_config->id_holder = 'id'; - $component_dashboard_action_log_config->title_holder = 'joomla_component'; - $component_dashboard_action_log_config->table_name = '#__componentbuilder_component_dashboard'; - $component_dashboard_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if component_dashboard action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_dashboard_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_dashboard_action_log_config->id = $db->loadResult(); - $component_dashboard_action_log_config_Updated = $db->updateObject('#__action_log_config', $component_dashboard_action_log_config, 'id'); - } - else - { - $component_dashboard_action_log_config_Inserted = $db->insertObject('#__action_log_config', $component_dashboard_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_files_folders action log config object. - $component_files_folders_action_log_config = new stdClass(); - $component_files_folders_action_log_config->id = null; - $component_files_folders_action_log_config->type_title = 'COMPONENT_FILES_FOLDERS'; - $component_files_folders_action_log_config->type_alias = 'com_componentbuilder.component_files_folders'; - $component_files_folders_action_log_config->id_holder = 'id'; - $component_files_folders_action_log_config->title_holder = 'joomla_component'; - $component_files_folders_action_log_config->table_name = '#__componentbuilder_component_files_folders'; - $component_files_folders_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if component_files_folders action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_files_folders_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_files_folders_action_log_config->id = $db->loadResult(); - $component_files_folders_action_log_config_Updated = $db->updateObject('#__action_log_config', $component_files_folders_action_log_config, 'id'); - } - else - { - $component_files_folders_action_log_config_Inserted = $db->insertObject('#__action_log_config', $component_files_folders_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_placeholders action log config object. - $component_placeholders_action_log_config = new stdClass(); - $component_placeholders_action_log_config->id = null; - $component_placeholders_action_log_config->type_title = 'COMPONENT_PLACEHOLDERS'; - $component_placeholders_action_log_config->type_alias = 'com_componentbuilder.component_placeholders'; - $component_placeholders_action_log_config->id_holder = 'id'; - $component_placeholders_action_log_config->title_holder = 'joomla_component'; - $component_placeholders_action_log_config->table_name = '#__componentbuilder_component_placeholders'; - $component_placeholders_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if component_placeholders action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_placeholders_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_placeholders_action_log_config->id = $db->loadResult(); - $component_placeholders_action_log_config_Updated = $db->updateObject('#__action_log_config', $component_placeholders_action_log_config, 'id'); - } - else - { - $component_placeholders_action_log_config_Inserted = $db->insertObject('#__action_log_config', $component_placeholders_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_plugins action log config object. - $component_plugins_action_log_config = new stdClass(); - $component_plugins_action_log_config->id = null; - $component_plugins_action_log_config->type_title = 'COMPONENT_PLUGINS'; - $component_plugins_action_log_config->type_alias = 'com_componentbuilder.component_plugins'; - $component_plugins_action_log_config->id_holder = 'id'; - $component_plugins_action_log_config->title_holder = 'joomla_component'; - $component_plugins_action_log_config->table_name = '#__componentbuilder_component_plugins'; - $component_plugins_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if component_plugins action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_plugins_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_plugins_action_log_config->id = $db->loadResult(); - $component_plugins_action_log_config_Updated = $db->updateObject('#__action_log_config', $component_plugins_action_log_config, 'id'); - } - else - { - $component_plugins_action_log_config_Inserted = $db->insertObject('#__action_log_config', $component_plugins_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the component_modules action log config object. - $component_modules_action_log_config = new stdClass(); - $component_modules_action_log_config->id = null; - $component_modules_action_log_config->type_title = 'COMPONENT_MODULES'; - $component_modules_action_log_config->type_alias = 'com_componentbuilder.component_modules'; - $component_modules_action_log_config->id_holder = 'id'; - $component_modules_action_log_config->title_holder = 'joomla_component'; - $component_modules_action_log_config->table_name = '#__componentbuilder_component_modules'; - $component_modules_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if component_modules action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($component_modules_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $component_modules_action_log_config->id = $db->loadResult(); - $component_modules_action_log_config_Updated = $db->updateObject('#__action_log_config', $component_modules_action_log_config, 'id'); - } - else - { - $component_modules_action_log_config_Inserted = $db->insertObject('#__action_log_config', $component_modules_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the snippet_type action log config object. - $snippet_type_action_log_config = new stdClass(); - $snippet_type_action_log_config->id = null; - $snippet_type_action_log_config->type_title = 'SNIPPET_TYPE'; - $snippet_type_action_log_config->type_alias = 'com_componentbuilder.snippet_type'; - $snippet_type_action_log_config->id_holder = 'id'; - $snippet_type_action_log_config->title_holder = 'name'; - $snippet_type_action_log_config->table_name = '#__componentbuilder_snippet_type'; - $snippet_type_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if snippet_type action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($snippet_type_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $snippet_type_action_log_config->id = $db->loadResult(); - $snippet_type_action_log_config_Updated = $db->updateObject('#__action_log_config', $snippet_type_action_log_config, 'id'); - } - else - { - $snippet_type_action_log_config_Inserted = $db->insertObject('#__action_log_config', $snippet_type_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the library_config action log config object. - $library_config_action_log_config = new stdClass(); - $library_config_action_log_config->id = null; - $library_config_action_log_config->type_title = 'LIBRARY_CONFIG'; - $library_config_action_log_config->type_alias = 'com_componentbuilder.library_config'; - $library_config_action_log_config->id_holder = 'id'; - $library_config_action_log_config->title_holder = 'library'; - $library_config_action_log_config->table_name = '#__componentbuilder_library_config'; - $library_config_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if library_config action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($library_config_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $library_config_action_log_config->id = $db->loadResult(); - $library_config_action_log_config_Updated = $db->updateObject('#__action_log_config', $library_config_action_log_config, 'id'); - } - else - { - $library_config_action_log_config_Inserted = $db->insertObject('#__action_log_config', $library_config_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the library_files_folders_urls action log config object. - $library_files_folders_urls_action_log_config = new stdClass(); - $library_files_folders_urls_action_log_config->id = null; - $library_files_folders_urls_action_log_config->type_title = 'LIBRARY_FILES_FOLDERS_URLS'; - $library_files_folders_urls_action_log_config->type_alias = 'com_componentbuilder.library_files_folders_urls'; - $library_files_folders_urls_action_log_config->id_holder = 'id'; - $library_files_folders_urls_action_log_config->title_holder = 'library'; - $library_files_folders_urls_action_log_config->table_name = '#__componentbuilder_library_files_folders_urls'; - $library_files_folders_urls_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if library_files_folders_urls action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($library_files_folders_urls_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $library_files_folders_urls_action_log_config->id = $db->loadResult(); - $library_files_folders_urls_action_log_config_Updated = $db->updateObject('#__action_log_config', $library_files_folders_urls_action_log_config, 'id'); - } - else - { - $library_files_folders_urls_action_log_config_Inserted = $db->insertObject('#__action_log_config', $library_files_folders_urls_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the class_extends action log config object. - $class_extends_action_log_config = new stdClass(); - $class_extends_action_log_config->id = null; - $class_extends_action_log_config->type_title = 'CLASS_EXTENDS'; - $class_extends_action_log_config->type_alias = 'com_componentbuilder.class_extends'; - $class_extends_action_log_config->id_holder = 'id'; - $class_extends_action_log_config->title_holder = 'name'; - $class_extends_action_log_config->table_name = '#__componentbuilder_class_extends'; - $class_extends_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if class_extends action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($class_extends_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $class_extends_action_log_config->id = $db->loadResult(); - $class_extends_action_log_config_Updated = $db->updateObject('#__action_log_config', $class_extends_action_log_config, 'id'); - } - else - { - $class_extends_action_log_config_Inserted = $db->insertObject('#__action_log_config', $class_extends_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the joomla_module_updates action log config object. - $joomla_module_updates_action_log_config = new stdClass(); - $joomla_module_updates_action_log_config->id = null; - $joomla_module_updates_action_log_config->type_title = 'JOOMLA_MODULE_UPDATES'; - $joomla_module_updates_action_log_config->type_alias = 'com_componentbuilder.joomla_module_updates'; - $joomla_module_updates_action_log_config->id_holder = 'id'; - $joomla_module_updates_action_log_config->title_holder = 'joomla_module'; - $joomla_module_updates_action_log_config->table_name = '#__componentbuilder_joomla_module_updates'; - $joomla_module_updates_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if joomla_module_updates action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($joomla_module_updates_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $joomla_module_updates_action_log_config->id = $db->loadResult(); - $joomla_module_updates_action_log_config_Updated = $db->updateObject('#__action_log_config', $joomla_module_updates_action_log_config, 'id'); - } - else - { - $joomla_module_updates_action_log_config_Inserted = $db->insertObject('#__action_log_config', $joomla_module_updates_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the joomla_module_files_folders_urls action log config object. - $joomla_module_files_folders_urls_action_log_config = new stdClass(); - $joomla_module_files_folders_urls_action_log_config->id = null; - $joomla_module_files_folders_urls_action_log_config->type_title = 'JOOMLA_MODULE_FILES_FOLDERS_URLS'; - $joomla_module_files_folders_urls_action_log_config->type_alias = 'com_componentbuilder.joomla_module_files_folders_urls'; - $joomla_module_files_folders_urls_action_log_config->id_holder = 'id'; - $joomla_module_files_folders_urls_action_log_config->title_holder = 'joomla_module'; - $joomla_module_files_folders_urls_action_log_config->table_name = '#__componentbuilder_joomla_module_files_folders_urls'; - $joomla_module_files_folders_urls_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if joomla_module_files_folders_urls action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($joomla_module_files_folders_urls_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $joomla_module_files_folders_urls_action_log_config->id = $db->loadResult(); - $joomla_module_files_folders_urls_action_log_config_Updated = $db->updateObject('#__action_log_config', $joomla_module_files_folders_urls_action_log_config, 'id'); - } - else - { - $joomla_module_files_folders_urls_action_log_config_Inserted = $db->insertObject('#__action_log_config', $joomla_module_files_folders_urls_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the joomla_plugin_group action log config object. - $joomla_plugin_group_action_log_config = new stdClass(); - $joomla_plugin_group_action_log_config->id = null; - $joomla_plugin_group_action_log_config->type_title = 'JOOMLA_PLUGIN_GROUP'; - $joomla_plugin_group_action_log_config->type_alias = 'com_componentbuilder.joomla_plugin_group'; - $joomla_plugin_group_action_log_config->id_holder = 'id'; - $joomla_plugin_group_action_log_config->title_holder = 'name'; - $joomla_plugin_group_action_log_config->table_name = '#__componentbuilder_joomla_plugin_group'; - $joomla_plugin_group_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if joomla_plugin_group action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($joomla_plugin_group_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $joomla_plugin_group_action_log_config->id = $db->loadResult(); - $joomla_plugin_group_action_log_config_Updated = $db->updateObject('#__action_log_config', $joomla_plugin_group_action_log_config, 'id'); - } - else - { - $joomla_plugin_group_action_log_config_Inserted = $db->insertObject('#__action_log_config', $joomla_plugin_group_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the joomla_plugin_updates action log config object. - $joomla_plugin_updates_action_log_config = new stdClass(); - $joomla_plugin_updates_action_log_config->id = null; - $joomla_plugin_updates_action_log_config->type_title = 'JOOMLA_PLUGIN_UPDATES'; - $joomla_plugin_updates_action_log_config->type_alias = 'com_componentbuilder.joomla_plugin_updates'; - $joomla_plugin_updates_action_log_config->id_holder = 'id'; - $joomla_plugin_updates_action_log_config->title_holder = 'joomla_plugin'; - $joomla_plugin_updates_action_log_config->table_name = '#__componentbuilder_joomla_plugin_updates'; - $joomla_plugin_updates_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if joomla_plugin_updates action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($joomla_plugin_updates_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $joomla_plugin_updates_action_log_config->id = $db->loadResult(); - $joomla_plugin_updates_action_log_config_Updated = $db->updateObject('#__action_log_config', $joomla_plugin_updates_action_log_config, 'id'); - } - else - { - $joomla_plugin_updates_action_log_config_Inserted = $db->insertObject('#__action_log_config', $joomla_plugin_updates_action_log_config); - } - - // Set db if not set already. - if (!isset($db)) - { - $db = JFactory::getDbo(); - } - // Create the joomla_plugin_files_folders_urls action log config object. - $joomla_plugin_files_folders_urls_action_log_config = new stdClass(); - $joomla_plugin_files_folders_urls_action_log_config->id = null; - $joomla_plugin_files_folders_urls_action_log_config->type_title = 'JOOMLA_PLUGIN_FILES_FOLDERS_URLS'; - $joomla_plugin_files_folders_urls_action_log_config->type_alias = 'com_componentbuilder.joomla_plugin_files_folders_urls'; - $joomla_plugin_files_folders_urls_action_log_config->id_holder = 'id'; - $joomla_plugin_files_folders_urls_action_log_config->title_holder = 'joomla_plugin'; - $joomla_plugin_files_folders_urls_action_log_config->table_name = '#__componentbuilder_joomla_plugin_files_folders_urls'; - $joomla_plugin_files_folders_urls_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; - - // Check if joomla_plugin_files_folders_urls action log config is already in action_log_config DB. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__action_log_config')); - $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($joomla_plugin_files_folders_urls_action_log_config->type_alias)); - $db->setQuery($query); - $db->execute(); - - // Set the object into the content types table. - if ($db->getNumRows()) - { - $joomla_plugin_files_folders_urls_action_log_config->id = $db->loadResult(); - $joomla_plugin_files_folders_urls_action_log_config_Updated = $db->updateObject('#__action_log_config', $joomla_plugin_files_folders_urls_action_log_config, 'id'); - } - else - { - $joomla_plugin_files_folders_urls_action_log_config_Inserted = $db->insertObject('#__action_log_config', $joomla_plugin_files_folders_urls_action_log_config); - } - } - return true; - } - - /** - * Remove folders with files - * - * @param string $dir The path to folder to remove - * @param boolean $ignore The folders and files to ignore and not remove - * - * @return boolean True in all is removed - * - */ - protected function removeFolder($dir, $ignore = false) - { - if (Folder::exists($dir)) - { - $it = new RecursiveDirectoryIterator($dir); - $it = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST); - // remove ending / - $dir = rtrim($dir, '/'); - // now loop the files & folders - foreach ($it as $file) - { - if ('.' === $file->getBasename() || '..' === $file->getBasename()) continue; - // set file dir - $file_dir = $file->getPathname(); - // check if this is a dir or a file - if ($file->isDir()) - { - $keeper = false; - if ($this->checkArray($ignore)) - { - foreach ($ignore as $keep) - { - if (strpos($file_dir, $dir.'/'.$keep) !== false) - { - $keeper = true; - } - } - } - if ($keeper) - { - continue; - } - Folder::delete($file_dir); - } - else - { - $keeper = false; - if ($this->checkArray($ignore)) - { - foreach ($ignore as $keep) - { - if (strpos($file_dir, $dir.'/'.$keep) !== false) - { - $keeper = true; - } - } - } - if ($keeper) - { - continue; - } - File::delete($file_dir); - } - } - // delete the root folder if not ignore found - if (!$this->checkArray($ignore)) - { - return Folder::delete($dir); - } - return true; - } - return false; - } - - /** - * Check if have an array with a length - * - * @input array The array to check - * - * @returns bool/int number of items in array on success - */ - protected function checkArray($array, $removeEmptyString = false) - { - if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0) - { - // also make sure the empty strings are removed - if ($removeEmptyString) - { - foreach ($array as $key => $string) - { - if (empty($string)) - { - unset($array[$key]); - } - } - return $this->checkArray($array, false); - } - return $nr; - } - return false; - } - - /** - * Method to set/copy dynamic folders into place (use with caution) - * - * @return void - */ - protected function setDynamicF0ld3rs($app, $parent) - { - // get the instalation path - $installer = $parent->getParent(); - $installPath = $installer->getPath('source'); - // get all the folders - $folders = Folder::folders($installPath); - // check if we have folders we may want to copy - $doNotCopy = array('media','admin','site'); // Joomla already deals with these - if (count((array) $folders) > 1) - { - foreach ($folders as $folder) - { - // Only copy if not a standard folders - if (!in_array($folder, $doNotCopy)) - { - // set the source path - $src = $installPath.'/'.$folder; - // set the destination path - $dest = JPATH_ROOT.'/'.$folder; - // now try to copy the folder - if (!Folder::copy($src, $dest, '', true)) - { - $app->enqueueMessage('Could not copy '.$folder.' folder into place, please make sure destination is writable!', 'error'); - } - } - } - } - } -} diff --git a/site/assets/css/site.css b/site/assets/css/site.css deleted file mode 100644 index 967eb359e..000000000 --- a/site/assets/css/site.css +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -/* CSS Document */ -.no-click { - pointer-events: none; -} - diff --git a/site/assets/js/site.js b/site/assets/js/site.js deleted file mode 100644 index af995345e..000000000 --- a/site/assets/js/site.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -/* JS Document */ diff --git a/site/componentbuilder.php b/site/componentbuilder.php deleted file mode 100644 index d5fd77db9..000000000 --- a/site/componentbuilder.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// add the autoloader for the composer classes -$composer_autoloader = JPATH_LIBRARIES . '/phpseclib3/vendor/autoload.php'; -if (file_exists($composer_autoloader)) -{ - require_once $composer_autoloader; -} - -// register this component namespace -spl_autoload_register(function ($class) { - // project-specific base directories and namespace prefix - $search = [ - 'libraries/jcb_powers/VDM.Joomla.Openai' => 'VDM\\Joomla\\Openai', - 'libraries/jcb_powers/VDM.Joomla.Gitea' => 'VDM\\Joomla\\Gitea', - 'libraries/jcb_powers/VDM.Joomla.FOF' => 'VDM\\Joomla\\FOF', - 'libraries/jcb_powers/VDM.Joomla' => 'VDM\\Joomla', - 'libraries/jcb_powers/VDM.Minify' => 'VDM\\Minify', - 'libraries/jcb_powers/VDM.Psr' => 'VDM\\Psr' - ]; - // Start the search and load if found - $found = false; - $found_base_dir = ""; - $found_len = 0; - foreach ($search as $base_dir => $prefix) - { - // does the class use the namespace prefix? - $len = strlen($prefix); - if (strncmp($prefix, $class, $len) === 0) - { - // we have a match so load the values - $found = true; - $found_base_dir = $base_dir; - $found_len = $len; - // done here - break; - } - } - // check if we found a match - if (!$found) - { - // not found so move to the next registered autoloader - return; - } - // get the relative class name - $relative_class = substr($class, $found_len); - // replace the namespace prefix with the base directory, replace namespace - // separators with directory separators in the relative class name, append - // with .php - $file = JPATH_ROOT . '/' . $found_base_dir . '/src' . str_replace('\\', '/', $relative_class) . '.php'; - // if the file exists, require it - if (file_exists($file)) - { - require $file; - } -}); - - - -// Set the component css/js -$document = JFactory::getDocument(); -$document->addStyleSheet('components/com_componentbuilder/assets/css/site.css'); -$document->addScript('components/com_componentbuilder/assets/js/site.js'); - -// Require helper files -JLoader::register('ComponentbuilderHelper', __DIR__ . '/helpers/componentbuilder.php'); -JLoader::register('ComponentbuilderEmail', JPATH_COMPONENT_ADMINISTRATOR . '/helpers/componentbuilderemail.php'); -JLoader::register('ComponentbuilderHelperRoute', __DIR__ . '/helpers/route.php'); - -// Trigger the Global Site Event -ComponentbuilderHelper::globalEvent($document); - -// Get an instance of the controller prefixed by Componentbuilder -$controller = JControllerLegacy::getInstance('Componentbuilder'); - -// Perform the request task -$controller->execute(JFactory::getApplication()->input->get('task')); - -// Redirect if set by the controller -$controller->redirect(); diff --git a/site/controller.php b/site/controller.php deleted file mode 100644 index 90bb61f97..000000000 --- a/site/controller.php +++ /dev/null @@ -1,123 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\BaseController; -use Joomla\Utilities\ArrayHelper; - -/** - * Componentbuilder Component Base Controller - */ -class ComponentbuilderController extends BaseController -{ - /** - * Method to display a view. - * - * @param boolean $cachable If true, the view output will be cached. - * @param boolean $urlparams An array of safe URL parameters and their variable types, for valid values see {@link JFilterInput::clean()}. - * - * @return JController This object to support chaining. - * - */ - function display($cachable = false, $urlparams = false) - { - // set default view if not set - $view = $this->input->getCmd('view', ''); - $this->input->set('view', $view); - $isEdit = $this->checkEditView($view); - $layout = $this->input->get('layout', null, 'WORD'); - $id = $this->input->getInt('id'); - // $cachable = true; (TODO) working on a fix [gh-238](https://github.com/vdm-io/Joomla-Component-Builder/issues/238) - - // insure that the view is not cashable if edit view or if user is logged in - $user = JFactory::getUser(); - if ($user->get('id') || $isEdit) - { - $cachable = false; - } - - // Check for edit form. - if($isEdit) - { - if ($layout == 'edit' && !$this->checkEditId('com_componentbuilder.edit.'.$view, $id)) - { - // Somehow the person just went to the form - we don't allow that. - $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); - $this->setMessage($this->getError(), 'error'); - // check if item was opend from other then its own list view - $ref = $this->input->getCmd('ref', 0); - $refid = $this->input->getInt('refid', 0); - // set redirect - if ($refid > 0 && ComponentbuilderHelper::checkString($ref)) - { - // redirect to item of ref - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view='.(string)$ref.'&layout=edit&id='.(int)$refid, false)); - } - elseif (ComponentbuilderHelper::checkString($ref)) - { - // redirect to ref - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view='.(string)$ref, false)); - } - else - { - // normal redirect back to the list default site view - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=', false)); - } - return false; - } - } - - // we may need to make this more dynamic in the future. (TODO) - $safeurlparams = array( - 'catid' => 'INT', - 'id' => 'INT', - 'cid' => 'ARRAY', - 'year' => 'INT', - 'month' => 'INT', - 'limit' => 'UINT', - 'limitstart' => 'UINT', - 'showall' => 'INT', - 'return' => 'BASE64', - 'filter' => 'STRING', - 'filter_order' => 'CMD', - 'filter_order_Dir' => 'CMD', - 'filter-search' => 'STRING', - 'print' => 'BOOLEAN', - 'lang' => 'CMD', - 'Itemid' => 'INT'); - - // should these not merge? - if (ComponentbuilderHelper::checkArray($urlparams)) - { - $safeurlparams = ComponentbuilderHelper::mergeArrays(array($urlparams, $safeurlparams)); - } - - return parent::display($cachable, $safeurlparams); - } - - protected function checkEditView($view) - { - if (ComponentbuilderHelper::checkString($view)) - { - $views = array( - - ); - // check if this is a edit view - if (in_array($view,$views)) - { - return true; - } - } - return false; - } -} diff --git a/site/controllers/api.php b/site/controllers/api.php deleted file mode 100644 index 02d3a67fe..000000000 --- a/site/controllers/api.php +++ /dev/null @@ -1,554 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\FormController; -use Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; -use VDM\Joomla\Utilities\ObjectHelper; -use VDM\Joomla\Utilities\StringHelper; - -/** - * Componentbuilder Api Form Controller - */ -class ComponentbuilderControllerApi extends FormController -{ - /** - * Current or most recently performed task. - * - * @var string - * @since 12.2 - * @note Replaces _task. - */ - protected $task; - - public function __construct($config = array()) - { - $this->view_list = ''; // safeguard for setting the return view listing to the default site view. - parent::__construct($config); - } - - /** - * The methods that are allowed to be called - * - * @var array - */ - protected $allowedMethods = array('compileInstall', 'translate'); - - /** - * The local methods that should be triggered - * - * @var array - */ - protected $localMethodTrigger = array('compileInstall' => '_autoloader'); - - /** - * Run the Translator - * - * @return mix - */ - public function translator() - { - // get params first - if (!isset($this->params) || !ComponentbuilderHelper::checkObject($this->params)) - { - $this->params = JComponentHelper::getParams('com_componentbuilder'); - } - // get model - $model = $this->getModel('api'); - // check if user has the right - $user = $this->getApiUser(); - // get components that have translation tools - if ($user->authorise('core.admin', 'com_componentbuilder') && ($components = $model->getTranslationLinkedComponents()) !== false) - { - // the message package - $message = array(); - // make sure to not unlock - $unlock = false; - // get messages - $callback = function($messages) use (&$message, &$unlock) { - // unlock messages if needed - if ($unlock) { - $messages = ComponentbuilderHelper::unlock($messages); - } - // check if we have any messages - if (UtilitiesArrayHelper::check($messages)) { - $message[] = implode("
    \n", $messages); - } else { - // var_dump($messages); // error debug message - } - }; - // we have two options, doing them one at a time, or using curl to do them somewhat asynchronously - if (count ( (array) $components) > 1 && function_exists('curl_version')) - { - // line up the translations - foreach ($components as $component) - { - ComponentbuilderHelper::setWorker($component, 'translate'); - } - // make sure to unlock - $unlock = true; - // run workers - ComponentbuilderHelper::runWorker('translate', 1, $callback); - } - else - { - foreach ($components as $component) - { - $model->translate($component); - } - // check if we have any messages - $callback($model->messages); - } - // return messages if found - if (UtilitiesArrayHelper::check($message)) - { - echo implode("
    \n", $message); - } - else - { - echo 1; - } - // clear session - JFactory::getApplication()->getSession()->destroy(); - jexit(); - } - // clear session - JFactory::getApplication()->getSession()->destroy(); - // return bool - echo 0; - jexit(); - } - - /** - * Run the Expansion - * - * @return mix - */ - public function expand() - { - // get params first - if (!isset($this->params) || !ObjectHelper::check($this->params)) - { - $this->params = JComponentHelper::getParams('com_componentbuilder'); - } - // check if expansion is enabled - $method = $this->params->get('development_method', 1); - // check what kind of return values show we give - $returnOptionsBuild = $this->params->get('return_options_build', 2); - if (2 == $method) - { - // get expansion components - $expansion = $this->params->get('expansion', null); - // check if they are set - if (ObjectHelper::check($expansion)) - { - // check if user has the right - $user = $this->getApiUser(); - // the message package - $message = array(); - if ($user->authorise('core.admin', 'com_componentbuilder')) - { - // make sure to not unlock - $unlock = false; - // get messages - $callback = function($messages) use (&$message, &$unlock) { - // unlock messages if needed - if ($unlock) { - $messages = ComponentbuilderHelper::unlock($messages); - } - // check if we have any messages - if (UtilitiesArrayHelper::check($messages)) { - $message[] = implode("
    \n", $messages); - } else { - // var_dump($messages); // error debug message - } - }; - // we have two options, doing them one at a time, or using curl to do them somewhat asynchronously - if (count ( (array) $expansion) > 1 && function_exists('curl_version')) - { - // set workers - foreach ($expansion as $component) - { - ComponentbuilderHelper::setWorker($component, 'compileInstall'); - } - // make sure to unlock - $unlock = true; - // run workers - ComponentbuilderHelper::runWorker('compileInstall', 1, $callback); - } - else - { - // get model - $model = $this->getModel('api'); - // load the compiler - $this->_autoloader(); - // set workers - foreach ($expansion as $component) - { - // compile and install - $model->compileInstall($component); - } - // check if we have any messages - $callback($model->messages); - } - // return messages if found - if (1== $returnOptionsBuild && UtilitiesArrayHelper::check($message)) - { - echo implode("
    \n", $message); - } - else - { - echo 1; - } - // clear session - JFactory::getApplication()->getSession()->destroy(); - jexit(); - } - // check if message is to be returned - if (1== $returnOptionsBuild) - { - // clear session - JFactory::getApplication()->getSession()->destroy(); - jexit('Access Denied!'); - } - } - } - // clear session - JFactory::getApplication()->getSession()->destroy(); - // check if message is to be returned - if (1== $returnOptionsBuild) - { - jexit('Expansion Disabled! Expansion can be enabled by your system administrator in the global Options of JCB under the Development Method tab.'); - } - // return bool - echo 0; - jexit(); - } - - /** - * Get API User - * - * @return object - */ - protected function getApiUser() - { - // return user object - return JFactory::getUser($this->params->get('api', 0, 'INT')); - } - - /** - * Load the needed script - * - * @return void - */ - protected function _autoloader() - { - // include component compiler - require_once JPATH_ADMINISTRATOR.'/components/com_componentbuilder/helpers/compiler.php'; - } - - public function backup() - { - // get params first - if (!isset($this->params) || !ObjectHelper::check($this->params)) - { - $this->params = JComponentHelper::getParams('com_componentbuilder'); - } - // Get the model - $model = componentbuilderHelper::getModel('joomla_components', JPATH_ADMINISTRATOR . '/components/com_componentbuilder'); - // set user - $model->user = $this->getApiUser(); - // make sure to set active type (adding this script from custom code :) - $model->activeType = 'backup'; - // check if export is allowed for this user. (we need this sorry) - if ($model->user->authorise('joomla_component.export_jcb_packages', 'com_componentbuilder') && $model->user->authorise('core.export', 'com_componentbuilder')) - { - // get all component IDs to backup - $pks = componentbuilderHelper::getComponentIDs(); - // set auto loader - ComponentbuilderHelper::autoLoader('smart'); - // manual backup message - $backupNotice = array(); - // get the data to export - if (UtilitiesArrayHelper::check($pks) && $model->getSmartExport($pks)) - { - $backupNotice[] = JText::_('COM_COMPONENTBUILDER_BACKUP_WAS_DONE_SUCCESSFULLY'); - $backupNoticeStatus = 'Success'; - // set the key string - if (StringHelper::check($model->key) && strlen($model->key) == 32) - { - $textNotice = array(); - $keyNotice = '

    ' . JText::sprintf('COM_COMPONENTBUILDER_THE_PACKAGE_KEY_IS_CODESCODE', $model->key) . '

    '; - $keyNotice .= '

    ' . JText::_('COM_COMPONENTBUILDER_YOUR_DATA_IS_ENCRYPTED_WITH_A_AES_TWO_HUNDRED_AND_FIFTY_SIX_BIT_ENCRYPTION_USING_THE_ABOVE_THIRTY_TWO_CHARACTER_KEY') . '

    '; - $textNotice[] = JText::sprintf('COM_COMPONENTBUILDER_THE_PACKAGE_KEY_IS_S', $model->key); - // set the package owner info - if ((isset($model->info['getKeyFrom']['company']) && StringHelper::check($model->info['getKeyFrom']['company'])) || (isset($model->info['getKeyFrom']['owner']) && StringHelper::check($model->info['getKeyFrom']['owner']))) - { - $ownerDetails = '

    ' . JText::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS') . '

    '; - $textNotice[] = '# ' . JText::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS'); - $ownerDetails .= '
      '; - if (isset($model->info['getKeyFrom']['company']) && StringHelper::check($model->info['getKeyFrom']['company'])) - { - $ownerDetails .= '
    • ' . JText::sprintf('COM_COMPONENTBUILDER_EMCOMPANYEM_BSB', $model->info['getKeyFrom']['company']) . '
    • '; - $textNotice[] = '- ' . JText::sprintf('COM_COMPONENTBUILDER_COMPANY_S', $model->info['getKeyFrom']['company']); - } - // add value only if set - if (isset($model->info['getKeyFrom']['owner']) && StringHelper::check($model->info['getKeyFrom']['owner'])) - { - $ownerDetails .= '
    • ' . JText::sprintf('COM_COMPONENTBUILDER_EMOWNEREM_BSB', $model->info['getKeyFrom']['owner']) . '
    • '; - $textNotice[] = '- ' . JText::sprintf('COM_COMPONENTBUILDER_OWNER_S', $model->info['getKeyFrom']['owner']); - } - // add value only if set - if (isset($model->info['getKeyFrom']['website']) && StringHelper::check($model->info['getKeyFrom']['website'])) - { - $ownerDetails .= '
    • ' . JText::sprintf('COM_COMPONENTBUILDER_EMWEBSITEEM_BSB', $model->info['getKeyFrom']['website']) . '
    • '; - $textNotice[] = '- ' . JText::sprintf('COM_COMPONENTBUILDER_WEBSITE_S', $model->info['getKeyFrom']['website']); - } - // add value only if set - if (isset($model->info['getKeyFrom']['email']) && StringHelper::check($model->info['getKeyFrom']['email'])) - { - $ownerDetails .= '
    • ' . JText::sprintf('COM_COMPONENTBUILDER_EMEMAILEM_BSB', $model->info['getKeyFrom']['email']) . '
    • '; - $textNotice[] = '- ' . JText::sprintf('COM_COMPONENTBUILDER_EMAIL_S', $model->info['getKeyFrom']['email']); - } - // add value only if set - if (isset($model->info['getKeyFrom']['license']) && StringHelper::check($model->info['getKeyFrom']['license'])) - { - $ownerDetails .= '
    • ' . JText::sprintf('COM_COMPONENTBUILDER_EMLICENSEEM_BSB', $model->info['getKeyFrom']['license']) . '
    • '; - $textNotice[] = '- ' . JText::sprintf('COM_COMPONENTBUILDER_LICENSE_S', $model->info['getKeyFrom']['license']); - } - // add value only if set - if (isset($model->info['getKeyFrom']['copyright']) && StringHelper::check($model->info['getKeyFrom']['copyright'])) - { - $ownerDetails .= '
    • ' . JText::sprintf('COM_COMPONENTBUILDER_EMCOPYRIGHTEM_BSB', $model->info['getKeyFrom']['copyright']) . '
    • '; - $textNotice[] = '- ' . JText::sprintf('COM_COMPONENTBUILDER_COPYRIGHT_S', $model->info['getKeyFrom']['copyright']); - } - $ownerDetails .= '
    '; - $backupNotice[] = JText::_('COM_COMPONENTBUILDER_OWNER_DETAILS_WAS_SET'); - } - else - { - $ownerDetails = '

    ' . JText::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_NOT_SET') . '

    '; - $textNotice[] = '# ' . JText::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS'); - $ownerDetails .= JText::_('COM_COMPONENTBUILDER_TO_CHANGE_THE_PACKAGE_OWNER_DEFAULTS_OPEN_THE_BJCB_GLOBAL_OPTIONSB_GO_TO_THE_BCOMPANYB_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE') . '
    '; - $textNotice[] = JText::_('COM_COMPONENTBUILDER_TO_CHANGE_THE_PACKAGE_OWNER_DEFAULTS_OPEN_THE_JCB_GLOBAL_OPTIONS_GO_TO_THE_COMPANY_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE'); - $ownerDetails .= '

    ' . JText::_('COM_COMPONENTBUILDER_YOU_SHOULD_ADD_THE_CORRECT_OWNER_DETAILS') . '

    '; - $textNotice[] = '## ' . JText::_('COM_COMPONENTBUILDER_YOU_SHOULD_ADD_THE_CORRECT_OWNER_DETAILS'); - $ownerDetails .= JText::_('COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_BIMPORT_PROCESSB_BEFORE_ADDING_THE_KEY_THIS_WAY_IF_THE_USERDEV_BDOES_NOTB_HAVE_THE_KEY_THEY_CAN_SEE_BWHERE_TO_GET_ITB') . '
    '; - $textNotice[] = JText::_('COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_IMPORT_PROCESS_BEFORE_ADDING_THE_KEY_THIS_WAY_IF_THE_USERDEV_DOES_NOT_HAVE_THE_KEY_THEY_CAN_SEE_WHERE_TO_GET_IT'); - $backupNotice[] = JText::_('COM_COMPONENTBUILDER_CHECK_YOUR_OWNER_DETAILS_IT_HAS_NOT_BEEN_SET_OPEN_THE_JCB_GLOBAL_OPTIONS_GO_TO_THE_COMPANY_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE'); - } - } - else - { - $keyNotice = '

    ' . JText::_('COM_COMPONENTBUILDER_THIS_PACKAGE_HAS_NO_KEY') . '

    '; - $textNotice[] = '# ' . JText::_('COM_COMPONENTBUILDER_THIS_PACKAGE_HAS_NO_KEY'); - $ownerDetails = JText::_('COM_COMPONENTBUILDER_THAT_MEANS_ANYONE_WHO_HAS_THIS_PACKAGE_CAN_INSTALL_IT_INTO_JCB_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_BSETTINGSB_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_BEXPORT_KEYB') . '
    '; - $textNotice[] = JText::_('COM_COMPONENTBUILDER_THAT_MEANS_ANYONE_WHO_HAS_THIS_PACKAGE_CAN_INSTALL_IT_INTO_JCB_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_SETTINGS_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_EXPORT_KEY'); - $backupNotice[] = JText::_('COM_COMPONENTBUILDER_NO_KEYS_WERE_FOUND_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_SETTINGS_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_EXPORT_KEY'); - } - // get email - if ($email = $this->params->get('backup_email', null)) - { - // plain text - $plainText = implode("\n", $textNotice); - // set hash to track changes - $hashTracker = md5($plainText); - if (ComponentbuilderHelper::newHash($hashTracker)) - { - // Build final massage. - $message = $keyNotice . $ownerDetails . '
    HASH: ' . $hashTracker . ''; - // set the subject - $subject = JText::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BUILDER_BACKUP_KEY'); - // email the message - componentbuilderEmail::send($email, $subject, componentbuilderEmail::setTableBody($message, $subject), $plainText, 1); - $backupNotice[] = JText::_('COM_COMPONENTBUILDER_EMAIL_WITH_THE_NEW_KEY_WAS_SENT'); - } - else - { - $backupNotice[] = JText::_('COM_COMPONENTBUILDER_KEY_HAS_NOT_CHANGED'); - } - } - } - else - { - $backupNotice[] = JText::_('COM_COMPONENTBUILDER_BACKUP_FAILED_PLEASE_TRY_AGAIN_IF_THE_ERROR_CONTINUE_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR'); - $backupNoticeStatus = 'Error'; - if (StringHelper::check($model->packagePath)) - { - // clear all if not successful - ComponentbuilderHelper::removeFolder($model->packagePath); - } - if (StringHelper::check($model->zipPath)) - { - // clear all if not successful - JFile::delete($model->zipPath); - } - } - // quite only if auto backup (adding this script from custom code :) - if ('backup' === $model->activeType) - { - echo "# " . $backupNoticeStatus . "\n" .implode("\n", $backupNotice); - // clear session - JFactory::getApplication()->getSession()->destroy(); - jexit(); - } - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), implode("
    ", $backupNotice), $backupNoticeStatus); - return; - } - // quite only if auto backup (adding this script from custom code :) - if ('backup' === $model->activeType) - { - echo "# Error\n" . JText::_('COM_COMPONENTBUILDER_ACCESS_DENIED'); - // clear session - JFactory::getApplication()->getSession()->destroy(); - jexit(); - } - $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), JText::_('COM_COMPONENTBUILDER_ACCESS_DENIED'), 'Error'); - return; - } - - - /** - * Run worker request - * - * @return mix - */ - public function worker() - { - // get input values - $input = JFactory::getApplication()->input; - // get DATA - $DATA = $input->post->get('VDM_DATA', null, 'STRING'); - // get TASK - $TASK = $input->server->get('HTTP_VDM_TASK', null, 'STRING'); - // get TYPE - $TYPE = $input->server->get('HTTP_VDM_VALUE_TYPE', null, 'STRING'); - // check if correct value is given - if (StringHelper::check($DATA) && StringHelper::check($TASK) && StringHelper::check($TYPE)) - { - // get the type of values we are working with ( 2 = array; 1 = string) - $type = ComponentbuilderHelper::unlock($TYPE); - // get data value - $dataValues = ComponentbuilderHelper::unlock($DATA); - // get the task - $task = ComponentbuilderHelper::unlock($TASK); - // check the for a string - if (1 == $type && ObjectHelper::check($dataValues) && StringHelper::check($task)) - { - // get model - $model = $this->getModel('api'); - // check if allowed and method exist and is callable - if (in_array($task, $this->allowedMethods) && method_exists($model, $task) && is_callable(array($model, $task))) - { - // trigger local method - if (isset($this->localMethodTrigger[$task])) - { - // run the local method - $this->{$this->localMethodTrigger[$task]}(); - } - // run the model method - $result = $model->{$task}($dataValues); - // check if we have messages - if (UtilitiesArrayHelper::check($model->messages)) - { - // return locked values - echo ComponentbuilderHelper::lock($model->messages); - // clear session - JFactory::getApplication()->getSession()->destroy(); - jexit(); - } - elseif ($result) - { - echo 1; - // clear session - JFactory::getApplication()->getSession()->destroy(); - jexit(); - } - } - } - } - // not success - echo 0; - // clear session - JFactory::getApplication()->getSession()->destroy(); - jexit(); - } - - - /** - * Method to check if you can edit an existing record. - * - * Extended classes can override this if necessary. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key; default is id. - * - * @return boolean - * - * @since 12.2 - */ - protected function allowEdit($data = array(), $key = 'id') - { - // to insure no other tampering - return false; - } - - /** - * Method override to check if you can add a new record. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 1.6 - */ - protected function allowAdd($data = array()) - { - // to insure no other tampering - return false; - } - - /** - * Method to check if you can save a new or existing record. - * - * Extended classes can override this if necessary. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 12.2 - */ - protected function allowSave($data, $key = 'id') - { - // to insure no other tampering - return false; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModelLegacy $model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 12.2 - */ - protected function postSaveHook(JModelLegacy $model, $validData = array()) - { - } -} diff --git a/site/controllers/help.php b/site/controllers/help.php deleted file mode 100644 index 8beb6bb23..000000000 --- a/site/controllers/help.php +++ /dev/null @@ -1,117 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Controller\BaseController; -use Joomla\Utilities\ArrayHelper; - -/** - * Componentbuilder Help Base Controller - */ -class ComponentbuilderControllerHelp extends BaseController -{ - public function __construct($config) - { - parent::__construct($config); - // load the tasks - $this->registerTask('getText', 'help'); - } - - public function help() - { - $user = JFactory::getUser(); - $jinput = JFactory::getApplication()->input; - // Check Token! - $token = JSession::getFormToken(); - $call_token = $jinput->get('token', 0, 'ALNUM'); - if($token == $call_token) - { - $task = $this->getTask(); - switch($task){ - case 'getText': - try - { - $idValue = $jinput->get('id', 0, 'INT'); - if($idValue) - { - $result = $this->getHelpDocumentText($idValue); - } - else - { - $result = ''; - } - echo $result; - // stop execution gracefully - jexit(); - } - catch(Exception $e) - { - // stop execution gracefully - jexit(); - } - break; - } - } - else - { - // stop execution gracefully - jexit(); - } - } - - protected function getHelpDocumentText($id) - { - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $query->select(array('a.title','a.content')); - $query->from('#__componentbuilder_help_document AS a'); - $query->where('a.id = '.(int) $id); - $query->where('a.published = 1'); - $query->where('a.location = 2'); - $db->setQuery($query); - $db->execute(); - if($db->getNumRows()) - { - $text = array(); - $document = $db->loadObject(); - // fix image issue - $images['src="images'] = 'src="'.JURI::root().'images'; - $images["src='images"] = "src='".JURI::root()."images"; - $images['src="/images'] = 'src="'.JURI::root().'images'; - $images["src='/images"] = "src='".JURI::root()."images"; - // set document template - $text[] = ""; - $text[] = ''; - $text[] = ""; - $text[] = ''; - $text[] = "".$document->title.""; - $text[] = ''; - $text[] = ''; - $text[] = ""; - $text[] = '
    '; - $text[] = '
    '; - $text[] = '
    '; - // build the help text - $text[] = '

    '.$document->title."

    "; - $text[] = str_replace(array_keys($images),array_values($images),$document->content); - // end template - $text[] = '


    '; - $text[] = '
    '; - $text[] = ""; - $text[] = ""; - - return implode("\n",$text); - } - return false; - } -} diff --git a/site/helpers/category.php b/site/helpers/category.php deleted file mode 100644 index 7d012bfbf..000000000 --- a/site/helpers/category.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Componentbuilder Component Category Tree - */ - -//Insure this view category file is loaded. -$classname = 'ComponentbuilderFieldCategories'; -if (!class_exists($classname)) -{ - $path = JPATH_SITE . '/components/com_componentbuilder/helpers/categoryfield.php'; - if (is_file($path)) - { - include_once $path; - } -} -//Insure this view category file is loaded. -$classname = 'ComponentbuilderFieldtypeCategories'; -if (!class_exists($classname)) -{ - $path = JPATH_SITE . '/components/com_componentbuilder/helpers/categoryfieldtype.php'; - if (is_file($path)) - { - include_once $path; - } -} diff --git a/site/helpers/categoryfield.php b/site/helpers/categoryfield.php deleted file mode 100644 index 1f1c5bbb2..000000000 --- a/site/helpers/categoryfield.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Componentbuilder Field Component Category Tree - */ -class ComponentbuilderFieldCategories extends JCategories -{ - /** - * Class constructor - * - * @param array $options Array of options - * - */ - public function __construct($options = array()) - { - $options['table'] = '#__componentbuilder_field'; - $options['extension'] = 'com_componentbuilder.field'; - - parent::__construct($options); - } -} diff --git a/site/helpers/categoryfieldtype.php b/site/helpers/categoryfieldtype.php deleted file mode 100644 index fc72564d9..000000000 --- a/site/helpers/categoryfieldtype.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Componentbuilder Fieldtype Component Category Tree - */ -class ComponentbuilderFieldtypeCategories extends JCategories -{ - /** - * Class constructor - * - * @param array $options Array of options - * - */ - public function __construct($options = array()) - { - $options['table'] = '#__componentbuilder_fieldtype'; - $options['extension'] = 'com_componentbuilder.fieldtype'; - - parent::__construct($options); - } -} diff --git a/site/helpers/componentbuilder.php b/site/helpers/componentbuilder.php deleted file mode 100644 index d645a8600..000000000 --- a/site/helpers/componentbuilder.php +++ /dev/null @@ -1,6393 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -// add the autoloader for the composer classes -$composer_autoloader = JPATH_LIBRARIES . '/phpseclib3/vendor/autoload.php'; -if (file_exists($composer_autoloader)) -{ - require_once $composer_autoloader; -} - -// register this component namespace -spl_autoload_register(function ($class) { - // project-specific base directories and namespace prefix - $search = [ - 'libraries/jcb_powers/VDM.Joomla.Openai' => 'VDM\\Joomla\\Openai', - 'libraries/jcb_powers/VDM.Joomla.Gitea' => 'VDM\\Joomla\\Gitea', - 'libraries/jcb_powers/VDM.Joomla.FOF' => 'VDM\\Joomla\\FOF', - 'libraries/jcb_powers/VDM.Joomla' => 'VDM\\Joomla', - 'libraries/jcb_powers/VDM.Minify' => 'VDM\\Minify', - 'libraries/jcb_powers/VDM.Psr' => 'VDM\\Psr' - ]; - // Start the search and load if found - $found = false; - $found_base_dir = ""; - $found_len = 0; - foreach ($search as $base_dir => $prefix) - { - // does the class use the namespace prefix? - $len = strlen($prefix); - if (strncmp($prefix, $class, $len) === 0) - { - // we have a match so load the values - $found = true; - $found_base_dir = $base_dir; - $found_len = $len; - // done here - break; - } - } - // check if we found a match - if (!$found) - { - // not found so move to the next registered autoloader - return; - } - // get the relative class name - $relative_class = substr($class, $found_len); - // replace the namespace prefix with the base directory, replace namespace - // separators with directory separators in the relative class name, append - // with .php - $file = JPATH_ROOT . '/' . $found_base_dir . '/src' . str_replace('\\', '/', $relative_class) . '.php'; - // if the file exists, require it - if (file_exists($file)) - { - require $file; - } -}); - -use Joomla\CMS\Filesystem\File; -use Joomla\CMS\Language\Language; -use Joomla\Registry\Registry; -use Joomla\String\StringHelper; -use Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities; -use Joomla\Archive\Archive; -use Joomla\CMS\Filesystem\Folder; -use Joomla\CMS\Filesystem\Path; -use VDM\Joomla\Componentbuilder\Compiler\Factory; -use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; -use VDM\Joomla\Utilities\GetHelper; -use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; -use VDM\Joomla\Utilities\JsonHelper; -use VDM\Joomla\Utilities\FileHelper; -use VDM\Joomla\Utilities\ObjectHelper; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\FieldHelper; -use VDM\Joomla\Utilities\Base64Helper; -use VDM\Joomla\FOF\Encrypt\AES; -use VDM\Joomla\Utilities\FormHelper; - -/** - * Componentbuilder component helper - */ -abstract class ComponentbuilderHelper -{ - /** - * Adding the utilities trait to this class - * - * @deprecated 4.0 - Check the trait methods for details, a legacy implementation - */ - use Utilities; - - /** - * get the Component Code Name - */ - public static $ComponentCodeName = 'componentbuilder'; - - /** - * Composer Switch - * - * @var array - */ - protected static $composer = array(); - - /** - * The Global Site Event Method. - **/ - public static function globalEvent($document) - { - // the Session keeps track of all data related to the current session of this user - self::loadSession(); - } - - - /** - * Just to Add the OPEN AI api to JCB (soon) - * Factory - **/ - - /** - * Locked Libraries (we can not have these change) - **/ - public static $libraryNames = array(1 => 'No Library', 2 => 'Bootstrap v4', 3 => 'Uikit v3', 4 => 'Uikit v2', 5 => 'FooTable v2', 6 => 'FooTable v3'); - - /** - * Array of php fields Allowed (16) - **/ - public static $phpFieldArray = array('', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'x', 'HEADER'); - - /** - * The global params - **/ - protected static $params = false; - - /** - * The global updater - **/ - protected static $globalUpdater = array(); - - /** - * The local company details - **/ - protected static $localCompany = array(); - - /** - * The excluded powers - **/ - protected static $exPowers= array(); - - /** - * The snippet paths - **/ - public static $snippetPath = 'https://raw.githubusercontent.com/vdm-io/Joomla-Component-Builder-Snippets/master/'; - public static $snippetsPath = 'https://api.github.com/repos/vdm-io/Joomla-Component-Builder-Snippets/git/trees/master'; - - /** - * The VDM packages paths - **/ - public static $vdmGithubPackageUrl = "https://github.com/vdm-io/JCB-Packages/raw/master/"; - public static $vdmGithubPackagesUrl = "https://api.github.com/repos/vdm-io/JCB-Packages/git/trees/master"; - - /** - * The JCB packages paths - **/ - public static $jcbGithubPackageUrl = "https://github.com/vdm-io/JCB-Community-Packages/raw/master/"; - public static $jcbGithubPackagesUrl = "https://api.github.com/repos/vdm-io/JCB-Community-Packages/git/trees/master"; - - /** - * The bolerplate paths - **/ - public static $bolerplatePath = 'https://raw.githubusercontent.com/vdm-io/boilerplate/jcb/'; - public static $bolerplateAPI = 'https://api.github.com/repos/vdm-io/boilerplate/git/trees/jcb'; - - /** - * The array of constant paths - * - * JPATH_SITE is meant to represent the root path of the JSite application, - * just as JPATH_ADMINISTRATOR is mean to represent the root path of the JAdministrator application. - * - * JPATH_BASE is the root path for the current requested application.... so if you are in the administrator application: - * - * JPATH_BASE == JPATH_ADMINISTRATOR - * - * If you are in the site application: - * - * JPATH_BASE == JPATH_SITE - * - * If you are in the installation application: - * - * JPATH_BASE == JPATH_INSTALLATION. - * - * JPATH_ROOT is the root path for the Joomla install and does not depend upon any application. - * - * @var array - */ - public static $constantPaths = array( - // The path to the administrator folder. - 'JPATH_ADMINISTRATOR' => JPATH_ADMINISTRATOR, - // The path to the installed Joomla! site, or JPATH_ROOT/administrator if executed from the backend. - 'JPATH_BASE' => JPATH_BASE, - // The path to the cache folder. - 'JPATH_CACHE' => JPATH_CACHE, - // The path to the administration folder of the current component being executed. - 'JPATH_COMPONENT_ADMINISTRATOR' => JPATH_COMPONENT_ADMINISTRATOR, - // The path to the site folder of the current component being executed. - 'JPATH_COMPONENT_SITE' => JPATH_COMPONENT_SITE, - // The path to the current component being executed. - 'JPATH_COMPONENT' => JPATH_COMPONENT, - // The path to folder containing the configuration.php file. - 'JPATH_CONFIGURATION' => JPATH_CONFIGURATION, - // The path to the installation folder. - 'JPATH_INSTALLATION' => JPATH_INSTALLATION, - // The path to the libraries folder. - 'JPATH_LIBRARIES' => JPATH_LIBRARIES, - // The path to the plugins folder. - 'JPATH_PLUGINS' => JPATH_PLUGINS, - // The path to the installed Joomla! site. - 'JPATH_ROOT' => JPATH_ROOT, - // The path to the installed Joomla! site. - 'JPATH_SITE' => JPATH_SITE, - // The path to the templates folder. - 'JPATH_THEMES' => JPATH_THEMES - ); - - /** - * get the class method or property - * - * @input int The method/property ID - * @input string The target type - * - * @returns string on success - **/ - public static function getClassCode($id, $type) - { - if ('property' === $type || 'method' === $type) - { - // Get a db connection. - $db = JFactory::getDbo(); - // Get user object - $user = JFactory::getUser(); - // Create a new query object. - $query = $db->getQuery(true); - // get method - if ('method' === $type) - { - $query->select($db->quoteName(array('a.comment','a.name','a.visibility','a.arguments','a.code'))); - } - // get property - elseif ('property' === $type) - { - $query->select($db->quoteName(array('a.comment','a.name','a.visibility','a.default'))); - } - $query->from($db->quoteName('#__componentbuilder_class_' . $type,'a')); - $query->where($db->quoteName('a.id') . ' = ' . (int) $id); - // Implement View Level Access - if (!$user->authorise('core.options', 'com_componentbuilder')) - { - $columns = $db->getTableColumns('#__componentbuilder_class_' . $type); - if(isset($columns['access'])) - { - $groups = implode(',', $user->getAuthorisedViewLevels()); - $query->where('a.access IN (' . $groups . ')'); - } - } - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - // get the code - $code = $db->loadObject(); - // combine method values - $combinded = array(); - // add comment if set - if (UtilitiesStringHelper::check($code->comment)) - { - $comment = array_map('trim', (array) explode(PHP_EOL, base64_decode($code->comment))); - $combinded[] = "\t" . implode(PHP_EOL . "\t ", $comment); - } - // build method - if ('method' === $type) - { - // set the method signature - if (UtilitiesStringHelper::check($code->arguments)) - { - $combinded[] = "\t" . $code->visibility . ' function ' . $code->name . '(' . base64_decode($code->arguments) . ')'; - } - else - { - $combinded[] = "\t" . $code->visibility . ' function ' . $code->name . '()'; - } - // set the method code - $combinded[] = "\t" . "{"; - // add code if set - if (UtilitiesStringHelper::check(trim($code->code))) - { - $combinded[] = base64_decode($code->code); - } - else - { - $combinded[] = "\t\t// add your code here"; - } - $combinded[] = "\t" . "}"; - } - else - { - if (UtilitiesStringHelper::check($code->default)) - { - $code->default = base64_decode($code->default); - if (is_int($code->default)) - { - // set the class property - $combinded[] = "\t" . $code->visibility . ' $' . $code->name . ' = ' . (int) $code->default . ';'; - } - elseif (is_float($code->default)) - { - // set the class property - $combinded[] = "\t" . $code->visibility . ' $' . $code->name . ' = ' . (float) $code->default . ';'; - } - elseif (('false' === $code->default || 'true' === $code->default) - || (UtilitiesStringHelper::check($code->default) && (strpos($code->default, 'array(') !== false || strpos($code->default, '"') !== false))) - { - // set the class property - $combinded[] = "\t" . $code->visibility . ' $' . $code->name . ' = ' . $code->default . ';'; - } - elseif (UtilitiesStringHelper::check($code->default) && strpos($code->default, '"') === false) - { - // set the class property - $combinded[] = "\t" . $code->visibility . ' $' . $code->name . ' = "' . $code->default . '";'; - } - else - { - // set the class property - $combinded[] = "\t" . $code->visibility . ' $' . $code->name . ';'; - } - } - else - { - // set the class property - $combinded[] = "\t" . $code->visibility . ' $' . $code->name . ';'; - } - } - // return the code - return implode(PHP_EOL, $combinded); - } - } - return false; - } - - /** - * extract Boilerplate Class Extends - * - * @input string The class as a string - * @input string The type of class/extension - * - * @returns string on success - **/ - public static function extractBoilerplateClassExtends(&$class, $type) - { - if (($strings = GetHelper::allBetween($class, 'class ', '}')) !== false && UtilitiesArrayHelper::check($strings)) - { - foreach ($strings as $string) - { - if (($extends = GetHelper::between($string, 'extends ', '{')) !== false && UtilitiesStringHelper::check($extends)) - { - return trim($extends); - } - } - } - return false; - } - - /** - * extract Boilerplate Class Header - * - * @input string The class as a string - * @input string The class being extended - * @input string The type of class/extension - * - * @returns string on success - **/ - public static function extractBoilerplateClassHeader(&$class, $extends, $type) - { - if (($string = GetHelper::between($class, "defined('_JEXEC')", 'extends ' . $extends)) !== false && UtilitiesStringHelper::check($string)) - { - $headArray = explode(PHP_EOL, $string); - if (UtilitiesArrayHelper::check($headArray) && count($headArray) > 3) - { - // remove first since it still has the [or die;] string in it - array_shift($headArray); - // remove the last since it has the class declaration - array_pop($headArray); - // at this point we have the class comment still in as part of the header, lets remove that - $last = count($headArray); - while ($last > 0) - { - $last--; - if (isset($headArray[$last]) && strpos($headArray[$last], '*') !== false) - { - unset($headArray[$last]); - } - else - { - // moment the comment stops, we break out - $last = 0; - } - } - // make sure we only return if we have values - if (UtilitiesArrayHelper::check($headArray)) - { - return implode(PHP_EOL, $headArray); - } - } - } - return false; - } - - /** - * extract Boilerplate Class Comment - * - * @input string The class as a string - * @input string The class being extended - * @input string The type of class/extension - * - * @returns string on success - **/ - public static function extractBoilerplateClassComment(&$class, $extends, $type) - { - if (($string = GetHelper::between($class, "defined('_JEXEC')", 'extends ' . $extends)) !== false && UtilitiesStringHelper::check($string)) - { - $headArray = explode(PHP_EOL, $string); - if (UtilitiesArrayHelper::check($headArray) && count($headArray) > 3) - { - $comment = array(); - // remove the last since it has the class declaration - array_pop($headArray); - // at this point we have the class comment still in as part of the header, lets remove that - $last = count($headArray); - while ($last > 0) - { - $last--; - if (isset($headArray[$last]) && strpos($headArray[$last], '*') !== false) - { - $comment[$last] = $headArray[$last]; - } - else - { - // moment the comment stops, we break out - $last = 0; - } - } - // make sure we only return if we have values - if (UtilitiesArrayHelper::check($comment)) - { - // set the correct order - ksort($comment); - $replace = array('Foo' => '[[[Plugin_name]]]', '[PACKAGE_NAME]' => '[[[Plugin]]]', '1.0.0' => '[[[plugin.version]]]', '1.0' => '[[[plugin.version]]]'); - // now update with JCB placeholders - return str_replace(array_keys($replace), array_values($replace), implode(PHP_EOL, $comment)); - } - } - } - return false; - } - - /** - * extract Boilerplate Class Properties & Methods - * - * @input string The class as a string - * @input string The class being extended - * @input string The type of class/extension - * @input int The plugin groups - * - * @returns string on success - **/ - public static function extractBoilerplateClassPropertiesMethods(&$class, $extends, $type, $plugin_group = null) - { - $bucket = array('property' => array(), 'method' => array()); - // get the class code, and remove the head - $codeArrayTmp = explode('extends ' . $extends, $class); - // make sure we have the correct result - if (UtilitiesArrayHelper::check($codeArrayTmp) && count($codeArrayTmp) == 2) - { - // the triggers - $triggers = array('public' => 1, 'protected' => 2, 'private' => 3); - $codeArray = explode(PHP_EOL, $codeArrayTmp[1]); - unset($codeArrayTmp); - // clean the code - self::cleanBoilerplateCode($codeArray); - // temp bucket - $name = null; - $arg = null; - $target = null; - $visibility = null; - $tmp = array(); - $comment = array(); - // load method - $loadCode = function (&$bucket, &$target, &$name, &$arg, &$visibility, &$tmp, &$comment) use($type, $plugin_group){ - $_tmp = array( - 'name' => $name, - 'visibility' => $visibility, - 'extension_type' => $type - ); - // build filter - $filters = array('extension_type' => $type); - // add more data based on target - if ('method' === $target && UtilitiesArrayHelper::check($tmp)) - { - // clean the code - self::cleanBoilerplateCode($tmp); - // only load if there are values - if (UtilitiesArrayHelper::check($tmp, true)) - { - $_tmp['code'] = implode(PHP_EOL, $tmp); - } - else - { - $_tmp['code'] = ''; - } - // load arguments only if set - if (UtilitiesStringHelper::check($arg)) - { - $_tmp['arguments'] = $arg; - } - } - elseif ('property' === $target) - { - // load default only if set - if (UtilitiesStringHelper::check($arg)) - { - $_tmp['default'] = $arg; - } - } - // load comment only if set - if (UtilitiesArrayHelper::check($comment, true)) - { - $_tmp['comment'] = implode(PHP_EOL, $comment); - } - // load the group target - if ($plugin_group) - { - $_tmp['joomla_plugin_group'] = $plugin_group; - $filters['joomla_plugin_group'] = $plugin_group; - } - // load the local values - if (($locals = self::getLocalBoilerplate($name, $target, $type, $filters)) !== false) - { - foreach ($locals as $key => $value) - { - $_tmp[$key] = $value; - } - } - else - { - $_tmp['id'] = 0; - $_tmp['published'] = 1; - $_tmp['version'] = 1; - } - // store the data based on target - $bucket[$target][] = $_tmp; - }; - // now we start loading - foreach($codeArray as $line) - { - if ($visibility && $target && $name && strpos($line, '/**') !== false) - { - $loadCode($bucket, $target, $name, $arg, $visibility, $tmp, $comment); - // reset loop buckets - $name = null; - $arg = null; - $target = null; - $visibility = null; - $tmp = array(); - $comment = array(); - } - // load the comment before method/property - if (!$visibility && !$target && !$name && strpos($line, '*') !== false) - { - $comment[] = rtrim($line); - } - else - { - if (!$visibility && !$target && !$name) - { - // get the line values - $lineArray = array_values(array_map('trim', preg_split('/\s+/', trim($line)))); - // check if we are at the main line - if (isset($lineArray[0]) && isset($triggers[$lineArray[0]])) - { - $visibility = $lineArray[0]; - if (strpos($line, 'function') !== false) - { - $target = 'method'; - // get the name - $name = trim(GetHelper::between($line, 'function ', '(')); - // get the arguments - $arg = trim(GetHelper::between($line, ' ' . $name . '(', ')')); - } - else - { - $target = 'property'; - if (strpos($line, '=') !== false) - { - // get the name - $name = trim(GetHelper::between($line, '$', '=')); - // get the default - $arg = trim(GetHelper::between($line, '=', ';')); - } - else - { - // get the name - $name = trim(GetHelper::between($line, '$', ';')); - } - } - } - } - else - { - $tmp[] = rtrim($line); - } - } - } - // check if a last method is still around - if ($visibility && $target && $name) - { - $loadCode($bucket, $target, $name, $arg, $visibility, $tmp, $comment); - // reset loop buckets - $name = null; - $arg = null; - $target = null; - $visibility = null; - $tmp = array(); - $comment = array(); - } - return $bucket; - } - return false; - } - - protected static function getLocalBoilerplate($name, $table, $extension_type, $filters = array()) - { - if ('property' === $table || 'method' === $table) - { - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - // get method - $query->select($db->quoteName(array('a.id','a.published','a.version'))); - $query->from($db->quoteName('#__componentbuilder_class_' . $table,'a')); - $query->where($db->quoteName('a.name') . ' = ' . $db->quote($name)); - $query->where($db->quoteName('a.extension_type') . ' = ' . $db->quote($extension_type)); - // add more filters - if (UtilitiesArrayHelper::check($filters)) - { - foreach($filters as $where => $value) - { - if (is_numeric($value)) - { - $query->where($db->quoteName('a.' . $where) . ' = ' . $value); - } - else - { - $query->where($db->quoteName('a.' . $where) . ' = ' . $db->quote($value)); - } - } - } - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - // get the code - return $db->loadAssoc(); - } - } - return false; - } - - protected static function cleanBoilerplateCode(&$code) - { - // remove the first lines until a { is found - $key = 0; - $found = false; - while (!$found) - { - if (isset($code[$key])) - { - if (strpos($code[$key], '{') !== false) - { - unset($code[$key]); - // only remove the first } found - $found = true; - } - // remove empty lines - elseif (!UtilitiesStringHelper::check(trim($code[$key]))) - { - unset($code[$key]); - } - } - // check next line - $key++; - // stop loop at line 30 (really this should never happen) - if ($key > 30) - { - $found = true; - } - } - // reset all keys - $code = array_values($code); - // remove last lines until } - $last = count($code); - while ($last > 0) - { - $last--; - if (isset($code[$last])) - { - if (strpos($code[$last], '}') !== false) - { - unset($code[$last]); - // only remove the first } found - $last = 0; - } - // remove empty lines - elseif (!UtilitiesStringHelper::check(trim($code[$last]))) - { - unset($code[$last]); - } - } - } - } - - /* - * Get the Array of Existing Validation Rule Names - * - * @return array - */ - public static function getExistingValidationRuleNames($lowercase = false) - { - // get the items - $items = self::get('_existing_validation_rules_VDM', null); - if (!$items) - { - // load the file class - jimport('joomla.filesystem.file'); - jimport('joomla.filesystem.folder'); - // set the path to the form validation rules - $path = JPATH_LIBRARIES . '/src/Form/Rule'; - // check if the path exist - if (!Folder::exists($path)) - { - return false; - } - // we must first store the current working directory - $joomla = getcwd(); - // go to that folder - chdir($path); - // load all the files in this path - $items = Folder::files('.', '\.php', true, true); - // change back to Joomla working directory - chdir($joomla); - // make sure we have an array - if (!UtilitiesArrayHelper::check($items)) - { - return false; - } - // remove the Rule.php from the name - $items = array_map( function ($name) { - return str_replace(array('./','Rule.php'), '', $name); - }, $items); - // store the names for next run - self::set('_existing_validation_rules_VDM', json_encode($items)); - } - // make sure it is no longer json - if (JsonHelper::check($items)) - { - $items = json_decode($items, true); - } - // check if the names should be all lowercase - if ($lowercase) - { - $items = array_map( function($item) { - return strtolower($item); - }, $items); - } - return $items; - } - - /** - * Get the snippet contributor details - * - * @param string $filename The file name - * @param string $type The type of file - * - * @return array On success the contributor details - * - */ - public static function getContributorDetails($filename, $type = 'snippet') - { - // start loading the contributor details - $contributor = array(); - // get the path & content - switch ($type) - { - case 'snippet': - $path = self::$snippetPath.$filename; - // get the file if available - $content = FileHelper::getContent($path); - if (JsonHelper::check($content)) - { - $content = json_decode($content, true); - } - break; - default: - // only allow types that are being targeted - return false; - break; - } - // see if we have content and all needed details - if (isset($content) && UtilitiesArrayHelper::check($content) - && isset($content['contributor_company']) - && isset($content['contributor_name']) - && isset($content['contributor_email']) - && isset($content['contributor_website'])) - { - // got the details from file - return array('contributor_company' => $content['contributor_company'] ,'contributor_name' => $content['contributor_name'], 'contributor_email' => $content['contributor_email'], 'contributor_website' => $content['contributor_website'], 'origin' => 'file'); - } - // get the global settings - if (!ObjectHelper::check(self::$params)) - { - self::$params = JComponentHelper::getParams('com_componentbuilder'); - } - // get the global company details - if (!UtilitiesArrayHelper::check(self::$localCompany)) - { - // Set the person sharing information (default VDM ;) - self::$localCompany['company'] = self::$params->get('export_company', 'Vast Development Method'); - self::$localCompany['owner'] = self::$params->get('export_owner', 'Llewellyn van der Merwe'); - self::$localCompany['email'] = self::$params->get('export_email', 'joomla@vdm.io'); - self::$localCompany['website'] = self::$params->get('export_website', 'https://www.vdm.io/'); - } - // default global - return array('contributor_company' => self::$localCompany['company'] ,'contributor_name' => self::$localCompany['owner'], 'contributor_email' => self::$localCompany['email'], 'contributor_website' => self::$localCompany['website'], 'origin' => 'global'); - } - - /** - * Get the library files - * - * @param int $id The library id to target - * - * @return array On success the array of files that belong to this library - * - */ - public static function getLibraryFiles($id) - { - // get the library files, folders, and urls - $files = array(); - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('b.name','a.addurls','a.addfolders','a.addfiles'))); - $query->from($db->quoteName('#__componentbuilder_library_files_folders_urls','a')); - $query->join('LEFT', $db->quoteName('#__componentbuilder_library', 'b') . ' ON (' . $db->quoteName('a.library') . ' = ' . $db->quoteName('b.id') . ')'); - $query->where($db->quoteName('a.library') . ' = ' . (int) $id); - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - // prepare the files - $result = $db->loadObject(); - // first we load the URLs - if (JsonHelper::check($result->addurls)) - { - // convert to array - $result->addurls = json_decode($result->addurls, true); - // set urls - if (UtilitiesArrayHelper::check($result->addurls)) - { - // build media folder path - $mediaPath = '/media/' . strtolower( preg_replace('/\s+/', '-', UtilitiesStringHelper::safe($result->name, 'filename', ' ', false))); - // load the urls - foreach($result->addurls as $url) - { - if (isset($url['url']) && UtilitiesStringHelper::check($url['url'])) - { - // set the path if needed - if (isset($url['type']) && $url['type'] > 1) - { - $fileName = basename($url['url']); - // build sub path - if (strpos($fileName, '.js') !== false) - { - $path = '/js'; - } - elseif (strpos($fileName, '.css') !== false) - { - $path = '/css'; - } - else - { - $path = ''; - } - // set the path to library file - $url['path'] = $mediaPath . $path . '/' . $fileName; // we need this for later - } - // if local path is set, then use it first - if (isset($url['path'])) - { - // load document script - $files[md5($url['path'])] = '(' . JText::_('URL') . ') ' . basename($url['url']) . ' - ' . JText::_('COM_COMPONENTBUILDER_LOCAL'); - } - // check if link must be added - if (isset($url['url']) && ((isset($url['type']) && $url['type'] == 1) || (isset($url['type']) && $url['type'] == 3) || !isset($url['type']))) - { - // load url also if not building document - $files[md5($url['url'])] = '(' . JText::_('URL') . ') ' . basename($url['url']) . ' - ' . JText::_('COM_COMPONENTBUILDER_LINK'); - } - } - } - } - } - // load the local files - if (JsonHelper::check($result->addfiles)) - { - // convert to array - $result->addfiles = json_decode($result->addfiles, true); - // set files - if (UtilitiesArrayHelper::check($result->addfiles)) - { - foreach($result->addfiles as $file) - { - if (isset($file['file']) && isset($file['path'])) - { - $path = '/'.trim($file['path'], '/'); - // check if path has new file name (has extetion) - $pathInfo = pathinfo($path); - if (isset($pathInfo['extension']) && $pathInfo['extension']) - { - // load document script - $files[md5($path)] = '(' . JText::_('COM_COMPONENTBUILDER_FILE') . ') ' . $file['file']; - } - else - { - // load document script - $files[md5($path.'/'.trim($file['file'],'/'))] = '(' . JText::_('COM_COMPONENTBUILDER_FILE') . ') ' . $file['file']; - } - } - } - } - } - // load the files in the folder - if (JsonHelper::check($result->addfolders)) - { - // convert to array - $result->addfolders = json_decode($result->addfolders, true); - // set folder - if (UtilitiesArrayHelper::check($result->addfolders)) - { - // get the global settings - if (!ObjectHelper::check(self::$params)) - { - self::$params = JComponentHelper::getParams('com_componentbuilder'); - } - // reset bucket - $bucket = array(); - // get custom folder path - $customPath = '/'.trim(self::$params->get('custom_folder_path', JPATH_COMPONENT_ADMINISTRATOR.'/custom'), '/'); - // get all the file paths - foreach ($result->addfolders as $folder) - { - if (isset($folder['path']) && isset($folder['folder'])) - { - $_path = '/'.trim($folder['path'], '/'); - $customFolder = '/'.trim($folder['folder'], '/'); - if (isset($folder['rename']) && 1 == $folder['rename']) - { - if ($_paths = FileHelper::getPaths($customPath.$customFolder)) - { - $bucket[$_path] = $_paths; - } - } - else - { - $path = $_path.$customFolder; - if ($_paths = FileHelper::getPaths($customPath.$customFolder)) - { - $bucket[$path] = $_paths; - } - } - } - } - // now load the script - if (UtilitiesArrayHelper::check($bucket)) - { - foreach ($bucket as $root => $paths) - { - // load per path - foreach($paths as $path) - { - $files[md5($root.'/'.trim($path, '/'))] = '(' . JText::_('COM_COMPONENTBUILDER_FOLDER') . ') ' . basename($path) . ' - ' . basename($root); - } - } - } - } - } - // return files if found - if (UtilitiesArrayHelper::check($files)) - { - return $files; - } - } - return false; - } - - /** - * Fix the path to work in the JCB script <-- (main issue here) - * Since we need / slash in all paths, for the JCB script even if it is Windows - * and since MS works with both forward and back slashes - * we just convert all slashes to forward slashes - * - * THIS is just my hack (fix) if you know a better way! speak-up! - * - * @param mix $values the array of paths or the path as a string - * @param array $targets paths to target - * - * @return string - * - */ - public static function fixPath(&$values, $targets = array()) - { - // if multiple to gets searched and fixed - if (UtilitiesArrayHelper::check($values) && UtilitiesArrayHelper::check($targets)) - { - foreach ($targets as $target) - { - if (isset($values[$target]) && strpos($values[$target], '\\') !== false) - { - $values[$target] = str_replace('\\', '/', $values[$target]); - } - } - } - // if just a string - elseif (UtilitiesStringHelper::check($values) && strpos($values, '\\') !== false) - { - $values = str_replace('\\', '/', $values); - } - } - - /** - * get all component IDs - */ - public static function getComponentIDs() - { - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id'))); - $query->from($db->quoteName('#__componentbuilder_joomla_component')); - $query->where($db->quoteName('published') . ' >= 1'); // do not backup trash - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - return $db->loadColumn(); - } - return false; - } - - /** - * Autoloader - */ - public static function autoLoader($type = 'compiler') - { - // load the type classes - if ('smart' !== $type) - { - foreach (glob(JPATH_ADMINISTRATOR."/components/com_componentbuilder/helpers/".$type."/*.php") as $autoFile) - { - require_once $autoFile; - } - } - // load only if compiler - if ('compiler' === $type) - { - // import the Joomla librarys - jimport('joomla.application.component.modellist'); - } - // load only if smart - if ('smart' === $type) - { - // import the Joomla libraries - jimport('joomla.application.component.modellist'); - } - // load this for all - jimport('joomla.application'); - } - - /** - * The dynamic builder of views, tables and fields - **/ - public static function dynamicBuilder(&$data, $type) - { - self::autoLoader('extrusion'); - $extruder = new Extrusion($data); - } - - /* - * Convert repeatable field to subform - * - * @param array $item The array to convert - * @param string $name The main field name - * - * @return array - */ - public static function convertRepeatable($item, $name) - { - // continue only if we have an array - if (UtilitiesArrayHelper::check($item)) - { - $bucket = array(); - foreach ($item as $key => $values) - { - foreach ($values as $nr => $value) - { - if (!isset($bucket[$name . $nr]) || !UtilitiesArrayHelper::check($bucket[$name . $nr])) - { - $bucket[$name . $nr] = array(); - } - $bucket[$name . $nr][$key] = $value; - } - } - return $bucket; - } - return $item; - } - - /* - * Convert repeatable field to subform - * - * @param object $item The item to update - * @param array $searcher The fields to check and update - * @param array $updater To update the local table - * - * @return void - */ - public static function convertRepeatableFields($object, $searcher, $updater = array()) - { - // update the repeatable fields - foreach ($searcher as $key => $sleutel) - { - if (isset($object->{$key})) - { - $isJson = false; - if (JsonHelper::check($object->{$key})) - { - $object->{$key} = json_decode($object->{$key}, true); - $isJson = true; - } - // check if this is old values for repeatable fields - if (UtilitiesArrayHelper::check($object->{$key}) && isset($object->{$key}[$sleutel])) - { - // load it back - $object->{$key} = self::convertRepeatable($object->{$key}, $key); - // add to global updater - if ( - UtilitiesArrayHelper::check($object->{$key}) && UtilitiesArrayHelper::check($updater) && - ( - ( isset($updater['table']) && isset($updater['val']) && isset($updater['key']) ) || - ( isset($updater['unique']) && isset($updater['unique'][$key]) && isset($updater['unique'][$key]['table']) && isset($updater['unique'][$key]['val']) && isset($updater['unique'][$key]['key']) ) - ) - ) - { - $_key = null; - $_value = null; - $_table = null; - // check if we have unique id table for this repeatable/subform field - if ( isset($updater['unique']) && isset($updater['unique'][$key]) && isset($updater['unique'][$key]['table']) && isset($updater['unique'][$key]['val']) && isset($updater['unique'][$key]['key']) ) - { - $_key = $updater['unique'][$key]['key']; - $_value = $updater['unique'][$key]['val']; - $_table = $updater['unique'][$key]['table']; - } - elseif ( isset($updater['table']) && isset($updater['val']) && isset($updater['key']) ) - { - $_key = $updater['key']; - $_value = $updater['val']; - $_table = $updater['table']; - } - // continue only if values are valid - if (UtilitiesStringHelper::check($_table) && UtilitiesStringHelper::check($_key) && $_value > 0) - { - // set target table & item - $target = trim($_table) . '.' . trim($_key) . '.' . trim($_value); - if (!isset(self::$globalUpdater[$target])) - { - self::$globalUpdater[$target] = new stdClass; - self::$globalUpdater[$target]->{$_key} = (int) $_value; - } - // load the new subform values to global updater - self::$globalUpdater[$target]->{$key} = json_encode($object->{$key}); - } - } - } - // no set back to json if came in as json - if ($isJson && UtilitiesArrayHelper::check($object->{$key})) - { - $object->{$key} = json_encode($object->{$key}); - } - // remove if not json or array - elseif (!UtilitiesArrayHelper::check($object->{$key}) && !JsonHelper::check($object->{$key})) - { - unset($object->{$key}); - } - } - } - return $object; - } - - /** - * Run Global Updater if any are set - * - * @return void - * - */ - public static function runGlobalUpdater() - { - // check if any updates are set to run - if (UtilitiesArrayHelper::check(self::$globalUpdater)) - { - // get the database object - $db = JFactory::getDbo(); - foreach (self::$globalUpdater as $tableKeyID => $object) - { - // get the table - $table = explode('.', $tableKeyID); - // update the item - $db->updateObject('#__componentbuilder_' . (string) $table[0] , $object, (string) $table[1]); - } - // rest updater - self::$globalUpdater = array(); - } - } - - /** - * Copy Any Item (only use for direct database copying) - * - * @param int $id The item to copy - * @param string $table The table and model to copy from and with - * @param array $config The values that should change - * - * @return boolean True if success - * - */ - public static function copyItem($id, $type, $config = array()) - { - // only continue if we have an id - if ((int) $id > 0) - { - // get the model - $model = self::getModel($type); - $app = \JFactory::getApplication(); - // get item - if ($item = $model->getItem($id)) - { - // update values that should change - if (UtilitiesArrayHelper::check($config)) - { - foreach($config as $key => $value) - { - if (isset($item->{$key})) - { - $item->{$key} = $value; - } - } - } - // clone the object - $data = array(); - foreach ($item as $key => $value) - { - $data[$key] = $value; - } - // reset some values - $data['id'] = 0; - $data['version'] = 1; - if (isset($data['tags'])) - { - $data['tags'] = null; - } - if (isset($data['associations'])) - { - $data['associations'] = array(); - } - // remove some unneeded values - unset($data['params']); - unset($data['asset_id']); - unset($data['checked_out']); - unset($data['checked_out_time']); - // Attempt to save the data. - if ($model->save($data)) - { - return true; - } - } - } - return false; - } - - /** - * the basic localkey - **/ - protected static $localkey = false; - - /** - * get the localkey - **/ - public static function getLocalKey() - { - if (!self::$localkey) - { - // get the basic key - self::$localkey = md5(self::getCryptKey('basic', 'localKey34fdWEkl')); - } - return self::$localkey; - } - - /** - * indent HTML - */ - public static function indent($html) - { - // load the class - require_once JPATH_ADMINISTRATOR.'/components/com_componentbuilder/helpers/indenter.php'; - // set new indenter - $indenter = new Indenter(); - // return indented html - return $indenter->indent($html); - } - - public static function checkFileType($file, $sufix) - { - // now check if the file ends with the sufix - return $sufix === "" || ($sufix == substr(strrchr($file, "."), -strlen($sufix))); - } - - public static function imageInfo($path, $request = 'type') - { - // set image - $image = JPATH_SITE.'/'.$path; - // check if exists - if (file_exists($image) && $result = @getimagesize($image)) - { - // return type request - switch ($request) - { - case 'width': - return $result[0]; - break; - case 'height': - return $result[1]; - break; - case 'type': - $extensions = array( - IMAGETYPE_GIF => "gif", - IMAGETYPE_JPEG => "jpg", - IMAGETYPE_PNG => "png", - IMAGETYPE_SWF => "swf", - IMAGETYPE_PSD => "psd", - IMAGETYPE_BMP => "bmp", - IMAGETYPE_TIFF_II => "tiff", - IMAGETYPE_TIFF_MM => "tiff", - IMAGETYPE_JPC => "jpc", - IMAGETYPE_JP2 => "jp2", - IMAGETYPE_JPX => "jpx", - IMAGETYPE_JB2 => "jb2", - IMAGETYPE_SWC => "swc", - IMAGETYPE_IFF => "iff", - IMAGETYPE_WBMP => "wbmp", - IMAGETYPE_XBM => "xbm", - IMAGETYPE_ICO => "ico" - ); - return $extensions[$result[2]]; - break; - case 'attr': - return $result[3]; - break; - case 'all': - default: - return $result; - break; - } - } - return false; - } - - /** - * set the session defaults if not set - **/ - protected static function setSessionDefaults() - { - // noting for now - return true; - } - - /** - * check if it is a new hash - **/ - public static function newHash($hash, $name = 'backup', $type = 'hash', $key = '', $fileType = 'txt') - { - // make sure we have a hash - if (UtilitiesStringHelper::check($hash)) - { - // first get the file path - $path_filename = FileHelper::getPath('path', $name.$type, $fileType, $key, JPATH_COMPONENT_ADMINISTRATOR); - // set as read if not already set - if ($content = FileHelper::getContent($path_filename, false)) - { - if ($hash == $content) - { - return false; - } - } - // set the hash - return FileHelper::write($path_filename, $hash); - } - return false; - } - - protected static $pkOwnerSearch = array( - 'company' => 'COM_COMPONENTBUILDER_DTCOMPANYDTDDSDD', - 'owner' => 'COM_COMPONENTBUILDER_DTOWNERDTDDSDD', - 'email' => 'COM_COMPONENTBUILDER_DTEMAILDTDDSDD', - 'website' => 'COM_COMPONENTBUILDER_DTWEBSITEDTDDSDD', - 'license' => 'COM_COMPONENTBUILDER_DTLICENSEDTDDSDD', - 'copyright' => 'COM_COMPONENTBUILDER_DTCOPYRIGHTDTDDSDD' - ); - - /** - * get the JCB package owner details display - **/ - public static function getPackageOwnerDetailsDisplay(&$info, $trust = false) - { - $hasOwner = false; - $ownerDetails = ''; - $ownerDetails .= '
    '; - // load the list items - foreach (self::$pkOwnerSearch as $key => $dd) - { - if ($value = self::getPackageOwnerValue($key, $info)) - { - $ownerDetails .= JText::sprintf($dd, $value); - // check if we have a owner/source name - if (('owner' === $key || 'company' === $key) && !$hasOwner) - { - $hasOwner = true; - $owner = $value; - } - } - } - $ownerDetails .= '
    '; - - // provide some details to how the user can get a key - if ($hasOwner && isset($info['getKeyFrom']['buy_link']) && UtilitiesStringHelper::check($info['getKeyFrom']['buy_link'])) - { - $ownerDetails .= '
    '; - $ownerDetails .= JText::sprintf('COM_COMPONENTBUILDER_BGET_THE_KEY_FROMB_A_SSA', 'class="btn btn-primary" href="'.$info['getKeyFrom']['buy_link'].'" target="_blank" title="get a key from '.$owner.'"', $owner); - } - // add more custom links - elseif ($hasOwner && isset($info['getKeyFrom']['buy_links']) && UtilitiesArrayHelper::check($info['getKeyFrom']['buy_links'])) - { - $buttons = array(); - foreach ($info['getKeyFrom']['buy_links'] as $keyName => $link) - { - $buttons[] = JText::sprintf('COM_COMPONENTBUILDER_BGET_THE_KEY_FROM_SB_FOR_A_SSA', $owner, 'class="btn btn-primary" href="'.$link.'" target="_blank" title="get a key from '.$owner.'"', $keyName); - } - $ownerDetails .= '
    '; - $ownerDetails .= implode('
    ', $buttons); - } - // return the owner details - if (!$hasOwner) - { - $ownerDetails = '

    ' . JText::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS_NOT_FOUND') . '

    '; - if (!$trust) - { - $ownerDetails .= '

    ' . JText::_('COM_COMPONENTBUILDER_BE_CAUTIOUS_DO_NOT_CONTINUE_UNLESS_YOU_TRUST_THE_ORIGIN_OF_THIS_PACKAGE') . '

    '; - } - } - return '
    '.$ownerDetails.'
    '; - } - - public static function getPackageOwnerValue($key, &$info) - { - $source = (isset($info['source']) && isset($info['source'][$key])) ? 'source' : ((isset($info['getKeyFrom']) && isset($info['getKeyFrom'][$key])) ? 'getKeyFrom' : false); - if ($source && UtilitiesStringHelper::check($info[$source][$key])) - { - return $info[$source][$key]; - } - return false; - } - - /** - * get the JCB package component key status - **/ - public static function getPackageComponentsKeyStatus(&$info) - { - // check the package key status - if (!isset($info['key'])) - { - if (isset($info['getKeyFrom']) && isset($info['getKeyFrom']['owner'])) - { - // this just confirms it for older packages - $info['key'] = true; - } - else - { - // this just confirms it for older packages - $info['key'] = false; - } - } - return $info['key']; - } - - protected static $compOwnerSearch = array( - 'ul' => array ( - 'companyname' => 'COM_COMPONENTBUILDER_ICOMPANYI_BSB', - 'author' => 'COM_COMPONENTBUILDER_IAUTHORI_BSB', - 'email' => 'COM_COMPONENTBUILDER_IEMAILI_BSB', - 'website' => 'COM_COMPONENTBUILDER_IWEBSITEI_BSB', - ), - 'other' => array( - 'license' => 'COM_COMPONENTBUILDER_HFOUR_CLASSNAVHEADERLICENSEHFOURPSP', - 'copyright' => 'COM_COMPONENTBUILDER_HFOUR_CLASSNAVHEADERCOPYRIGHTHFOURPSP' - ) - ); - - /** - * get the JCB package component details display - **/ - public static function getPackageComponentsDetailsDisplay(&$info) - { - // check if these components need a key - $needKey = self::getPackageComponentsKeyStatus($info); - if (isset($info['name']) && UtilitiesArrayHelper::check($info['name'])) - { - $cAmount = count((array) $info['name']); - $class2 = ($cAmount == 1) ? 'span12' : 'span6'; - $counter = 1; - $display = array(); - foreach ($info['name'] as $key => $value) - { - // set the name - $name= $value . ' v' . $info['component_version'][$key]; - if ($cAmount > 1 && $counter == 3) - { - $display[] = '
    '; - $counter = 1; - } - if ($cAmount > 1 && $counter == 1) - { - $display[] = '
    '; - } - $display[] = '
    '; - $display[] = '

    '; - $display[] = $name; - if ($needKey) - { - $display[] = ' - ' . JText::sprintf('COM_COMPONENTBUILDER_PAIDLOCKED') . ''; - } - else - { - $display[] = ' - ' . JText::sprintf('COM_COMPONENTBUILDER_FREEOPEN') . ''; - } - $display[] = '

    '; - $display[] = $info['short_description'][$key]; - $display[] = '

    '; - $display[] = '
      '; - // load the list items - foreach (self::$compOwnerSearch['ul'] as $li => $value) - { - if (isset($info[$li]) && isset($info[$li][$key])) - { - $display[] = '
    • '.JText::sprintf($value, $info[$li][$key]).'
    • '; - } - } - $display[] = '
    '; - // if we have a source link we add it - if (isset($info['joomla_source_link']) && UtilitiesArrayHelper::check($info['joomla_source_link']) && isset($info['joomla_source_link'][$key]) && UtilitiesStringHelper::check($info['joomla_source_link'][$key])) - { - $display[] = 'source code'; - } - // load other - foreach (self::$compOwnerSearch['other'] as $other => $value) - { - if (isset($info[$other]) && isset($info[$other][$key])) - { - $display[] = JText::sprintf($value, $info[$other][$key]); - } - } - $display[] = '
    '; - - $counter++; - } - // close the div if needed - if ($cAmount > 1) - { - $display[] = '
    '; - } - return implode("\n",$display); - } - return '
    '.JText::_('COM_COMPONENTBUILDER_NO_COMPONENT_DETAILS_FOUND_SO_IT_IS_NOT_SAFE_TO_CONTINUE').'
    '; - } - - /** - * get the database table columns - **/ - public static function getDbTableColumns($tableName, $as, $type) - { - // Get a db connection. - $db = JFactory::getDbo(); - // get the columns - $columns = $db->getTableColumns("#__" . $tableName); - // set the type (multi or single) - $unique = ''; - if (1 == $type) - { - $unique = UtilitiesStringHelper::safe($tableName) . '_'; - } - if (UtilitiesArrayHelper::check($columns)) - { - // build the return string - $tableColumns = array(); - foreach ($columns as $column => $typeCast) - { - $tableColumns[] = $as . "." . $column . ' AS ' . $unique . $column; - } - return implode("\n", $tableColumns); - } - return false; - } - - /** - * get the view table columns - **/ - public static function getViewTableColumns($admin_view, $as, $type) - { - // Get a db connection. - $db = JFactory::getDbo(); - - // Create a new query object. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('a.addfields', 'b.name_single'))); - $query->from($db->quoteName('#__componentbuilder_admin_fields', 'a')); - $query->join('LEFT', $db->quoteName('#__componentbuilder_admin_view', 'b') . ' ON (' . $db->quoteName('a.admin_view') . ' = ' . $db->quoteName('b.id') . ')'); - $query->where($db->quoteName('b.published') . ' = 1'); - $query->where($db->quoteName('a.admin_view') . ' = ' . (int) $admin_view); - - // Reset the query using our newly populated query object. - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - $result = $db->loadObject(); - $tableName = ''; - if (1 == $type) - { - $tableName = UtilitiesStringHelper::safe($result->name_single) . '_'; - } - $addfields = json_decode($result->addfields, true); - if (UtilitiesArrayHelper::check($addfields)) - { - // reset all buckets - $field = array(); - $fields = array(); - // get data - foreach ($addfields as $nr => $value) - { - $tmp = self::getFieldNameAndType((int) $value['field']); - if (UtilitiesArrayHelper::check($tmp)) - { - $field[$nr] = $tmp; - } - // insure it is set to alias if needed - if (isset($value['alias']) && $value['alias'] == 1) - { - $field[$nr]['name'] = 'alias'; - } - // remove a field that is not being stored in the database - if (!isset($value['list']) || $value['list'] == 2) - { - unset($field[$nr]); - } - } - // add the basic defaults - $fields[] = $as . ".id AS " . $tableName . "id"; - $fields[] = $as . ".asset_id AS " . $tableName . "asset_id"; - // load data - foreach ($field as $n => $f) - { - if (UtilitiesArrayHelper::check($f)) - { - $fields[] = $as . "." . $f['name'] . " AS " . $tableName . $f['name']; - } - } - // add the basic defaults - $fields[] = $as . ".published AS " . $tableName . "published"; - $fields[] = $as . ".created_by AS " . $tableName . "created_by"; - $fields[] = $as . ".modified_by AS " . $tableName . "modified_by"; - $fields[] = $as . ".created AS " . $tableName . "created"; - $fields[] = $as . ".modified AS " . $tableName . "modified"; - $fields[] = $as . ".version AS " . $tableName . "version"; - $fields[] = $as . ".hits AS " . $tableName . "hits"; - if (0) // TODO access is not set here but per/view in the form linking this admin view to which these field belong to the components (boooo I know but that is the case and so we can't ever really know at this point if this view has access set) - { - $fields[] = $as . ".access AS " . $tableName . "access"; - } - $fields[] = $as . ".ordering AS " . $tableName . "ordering"; - // return the field of this view - return implode("\n", $fields); - } - } - return false; - } - - public static function getFieldNameAndType($id, $spacers = false) - { - // Get a db connection. - $db = JFactory::getDbo(); - - // Create a new query object. - $query = $db->getQuery(true); - - // Order it by the ordering field. - $query->select($db->quoteName(array('a.name', 'a.xml'))); - $query->select($db->quoteName(array('c.name'), array('type_name'))); - $query->from('#__componentbuilder_field AS a'); - $query->join('LEFT', $db->quoteName('#__componentbuilder_fieldtype', 'c') . ' ON (' . $db->quoteName('a.fieldtype') . ' = ' . $db->quoteName('c.id') . ')'); - $query->where($db->quoteName('a.id') . ' = '. $db->quote($id)); - - // Reset the query using our newly populated query object. - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - // Load the results as a list of stdClass objects (see later for more options on retrieving data). - $field = $db->loadObject(); - // load the values form params - $field->xml = json_decode($field->xml); - $field->type_name = self::safeTypeName($field->type_name); - $load = true; - // if category then name must be catid (only one per view) - if ($field->type_name === 'category') - { - $name = 'catid'; - } - // if tag is set then enable all tag options for this view (only one per view) - elseif ($field->type_name === 'tag') - { - $name = 'tags'; - } - // don't add spacers or notes - elseif (!$spacers && ($field->type_name == 'spacer' || $field->type_name == 'note')) - { - // make sure the name is unique - return false; - } - else - { - $name = self::safeFieldName(GetHelper::between($field->xml,'name="','"')); - } - - // use field core name only if not found in xml - if (!UtilitiesStringHelper::check($name)) - { - $name = self::safeFieldName($field->name); - } - return array('name' => $name, 'type' => $field->type_name); - } - return false; - } - - /** - * validate that a placeholder is unique - **/ - public static function validateUniquePlaceholder($id, $name, $bool = false) - { - // make sure no padding is set - $name = preg_replace("/[^A-Za-z0-9_]/", '', $name); - // this list may grow as we find more cases that break the compiler (just open an issue on github) - if (in_array($name, array('component', 'view', 'views'))) - { - // check if we must return boolean - if (!$bool) - { - return array ( - 'message' => JText::_('COM_COMPONENTBUILDER_SORRY_THIS_PLACEHOLDER_IS_ALREADY_IN_USE_IN_THE_COMPILER'), - 'status' => 'danger'); - } - return false; - } - // add the padding (needed) - $name = '[[[' . trim($name) . ']]]'; - if (self::placeholderIsSet($id, $name)) - { - // check if we must return boolean - if (!$bool) - { - return array ( - 'message' => JText::_('COM_COMPONENTBUILDER_SORRY_THIS_PLACEHOLDER_IS_ALREADY_IN_USE'), - 'status' => 'danger'); - } - return false; - } - // check if we must return boolean - if (!$bool) - { - return array ( - 'name' => $name, - 'message' => JText::_('COM_COMPONENTBUILDER_GREAT_THIS_PLACEHOLDER_WILL_WORK'), - 'status' => 'success'); - } - return true; - } - - /** - * search for placeholder in table - **/ - protected static function placeholderIsSet($id, $name) - { - // query the table for result array - if (($results = self::getPlaceholderTarget($id, $name)) !== false) - { - // check if we must continue the search - foreach ($results as $_id => $target) - { - if ($name === $target) - { - return true; - } - } - } - return false; - } - - /** - * get placeholder target - **/ - protected static function getPlaceholderTarget($id, $name) - { - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id', 'target'))); - $query->from($db->quoteName('#__componentbuilder_placeholder')); - $query->where($db->quoteName('target') . ' = '. $db->quote($name)); - // check if we have id - if (is_numeric($id)) - { - $query->where($db->quoteName('id') . ' <> ' . (int) $id); - } - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - return $db->loadAssocList('id', 'target'); - } - return false; - } - - /** - * Powers to exclude - **/ - public static function excludePowers($id) - { - // first check if this power set is already found - if (!isset(self::$exPowers[$id])) - { - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('a.id'))); - $query->from($db->quoteName('#__componentbuilder_power', 'a')); - $query->join('LEFT', $db->quoteName('#__componentbuilder_power', 'b') . ' ON (' . $db->quoteName('a.name') . ' = ' . $db->quoteName('b.name') . ' AND ' . $db->quoteName('a.namespace') . ' = ' . $db->quoteName('b.namespace') . ')'); - $query->where($db->quoteName('b.id') . ' = ' . (int) $id); - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - self::$exPowers[$id] = $db->loadColumn(); - } - // all ways add itself aswell - self::$exPowers[$id][] = $id; - } - // if found return - if (isset(self::$exPowers[$id])) - { - return self::$exPowers[$id]; - } - return false; - } - /** - * The array of dynamic content - * - * @var array - */ - protected static array $dynamicContent = [ - // The banners by size (width - height) - 'banner' => [ - '728-90' => [ - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/banner/joomla-heart-wide.gif', - 'hash' => 'f857e3a38facaeac9eba3cffa912b620', - 'html' => 'Joomla! Volunteers Portal'], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/banner/JCM_2010_120x600.png', - 'hash' => '5389cf3be8569cb3f6793e8bd4013d19', - 'html' => 'Joomla! Community Magazine | Because community matters...'], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/banner/tlwebdesign_jcb_sponsor_728_90.png', - 'hash' => 'd19be1f9f5b2049ff901096aafc246be', - 'html' => 'tlwebdesign a JCB sponsor | Because community matters...'], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/banner/vdm_jcb_sponsor_728_90.gif', - 'hash' => '84478dfa0cd880395815e0ee026812a4', - 'html' => 'VDM a JCB sponsor | Because community matters...'], - [ - 'url' => 'https://cms-experts.org/images/banners/agerix/agerix-loves-jcb-728-90.gif', - 'hash' => 'b24c0726aa809cdcc04bcffe7e1e1529', - 'html' => 'Agerix a JCB sponsor | Because community matters...'] - ], - '160-600' => [ - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/banner/joomla-heart-tall.gif', - 'hash' => '9a75e4929b86c318128b53cf78251678', - 'html' => 'Joomla! Volunteers Portal'], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/banner/JCM_2010_120x600.png', - 'hash' => '5389cf3be8569cb3f6793e8bd4013d19', - 'html' => 'Joomla! Community Magazine | Because community matters...'] - ] - ], - // The build-gif by size (width - height) - 'builder-gif' => [ - // original gif ;) - '480-272' => [ - [ - 'url' => 'https://www.joomlacomponentbuilder.com/images/builder/original.gif', - 'hash' => '676e37a949add8f4573381195cd1061c', - 'html' => '' - ] - ], - // new gif artwork since 2021 - '480-540' => [ - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/1.gif', - 'hash' => 'ce6e36456fa794ba95d981547b2f54f8', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/2.gif', - 'hash' => '0a54dbc393359747e33db90cabb1e2d7', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/3.gif', - 'hash' => '4e5498713ff69a64a0a79dbf620372a3', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/4.gif', - 'hash' => '3554ffab2a6df95a116fd9f0db63925c', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/5.gif', - 'hash' => '08f0cdf188593eca65c6dafd7af27ef9', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/6.gif', - 'hash' => '103b46a7ac3fcb974e25d06f417a4e87', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/7.gif', - 'hash' => 'ffa8547099b7286f89ab7ff5a140dd90', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/8.gif', - 'hash' => '316df780f9e4ce81200a65d3c4303c41', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/9.gif', - 'hash' => '9ab6ba78b6e63a285fdef2ff5e447c93', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/10.gif', - 'hash' => 'cd9abaa1cb95f51a70916da6b70614f2', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/11.gif', - 'hash' => 'cfe53095b5249618e2348223b89262b9', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/12.gif', - 'hash' => '15a6690647d5160d67c80ce4dd1f5602', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/13.gif', - 'hash' => '2f77562e92c8a3b7c47664c98f551fe8', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/14.gif', - 'hash' => '46db15517ef5bd063be85134e1cc575d', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/15.gif', - 'hash' => 'e6c96eff157ea648ceb1583f2cc22544', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/16.gif', - 'hash' => '76010b7d1f99952eb9645df660467ae8', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/17.gif', - 'hash' => '021219ddd72d8fcfc7f80bd4a874d651', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/18.gif', - 'hash' => '383af3179d4ae27301c1292e630d7155', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/19.gif', - 'hash' => '8537e6d7be93447241b521f851e8a61d', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/20.gif', - 'hash' => '10d96f70e3d43086a925b00a7dc0022e', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/21.gif', - 'hash' => '161de9865b171b44039353b8d50491d3', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/22.gif', - 'hash' => '6a2354e43eb97d278d74bb2c12890988', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/23.gif', - 'hash' => '2cb6e2f9562a8dc8eef6d5d8d1a84f5e', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '], - [ - 'url' => 'https://git.vdm.dev/joomla/jcb-external/raw/branch/master/src/images/builder/24.gif', - 'hash' => '745b3fb5e16515689132432bf02ab1b4', - 'html' => '
    Animation produced with 3D Particle Explorations by Jack Rugile.
    '] - ] - ] - ]; - - /** - * get the dynamic content array size - * - * @param string $type The type of content - * @param string $size The size of the content - * - * @return int on success number of items in array type,size - * - */ - public static function getDynamicContentSize(string $type, string $size): int - { - if (isset(self::$dynamicContent[$type]) && isset(self::$dynamicContent[$type][$size]) - && ($nr = UtilitiesArrayHelper::check(self::$dynamicContent[$type][$size]))) - { - return $nr; - } - return 0; - } - - /** - * get the dynamic content - * - * @param string $type The type of content - * @param string $size The size of the content - * @param mixed $default The default to return - * @param int $try Retry tracker (when bigger then array size it stops) - * @param mixed $getter The specific getter number (not zero based) - * - * @return string on success html string - * - */ - public static function getDynamicContent(string $type, string $size, $default = '', int $try = 1, $getter = null) - { - if (($nr = self::getDynamicContentSize($type, $size)) !== 0) - { - // use specific getter - if ($getter) - { - $get = --$getter; - } - // get the random getter number - elseif ($nr > 1) - { - $get = (int) rand(0, --$nr); - } - else - { - $get = 0; - } - // get the current target if found - if (isset(self::$dynamicContent[$type][$size][$get])) - { - $target = self::$dynamicContent[$type][$size][$get]; - // set file name - $file_name = basename($target['url']); - // set the local path (in admin area so when the component uninstall these images get removed as well) - $path = JPATH_ROOT . "/administrator/components/com_componentbuilder/assets/images/$type/$file_name"; - // check if file exist or if it changed - if (($image_data = FileHelper::getContent($path, false)) === false || - md5($image_data) !== $target['hash']) - { - // since the file does not exist or has changed (so we have a new hash) - // therefore we download it to validate - if (($image_data = FileHelper::getContent($target['url'], false)) !== false && - md5($image_data) === $target['hash']) - { - // create the JCB type path if it does not exist - if (!Folder::exists(JPATH_ROOT . "/administrator/components/com_componentbuilder/assets/images/$type")) - { - Folder::create(JPATH_ROOT . "/administrator/components/com_componentbuilder/assets/images/$type"); - } - // only set the image if the data match the hash - FileHelper::write($path, $image_data); - } - // we retry array size times (unless specific getter is used) - elseif ($try <= $nr && !$getter) - { - // the first time around failed so we try again (the size of the array times) - return self::getDynamicContent($type, $size, $default, ++$try); - } - } - // return found content - return str_replace('[[[ROOT-URL]]]', JURI::root(), $target['html']); - } - } - 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 - **/ - public static $session = array(); - - /** - * the Butler Assistant - **/ - protected static $localSession = array(); - - /** - * start a session if not already set, and load with data - **/ - public static function loadSession() - { - if (!isset(self::$session) || !ObjectHelper::check(self::$session)) - { - self::$session = JFactory::getSession(); - } - // set the defaults - self::setSessionDefaults(); - } - - /** - * give Session more to keep - **/ - public static function set($key, $value) - { - if (!isset(self::$session) || !ObjectHelper::check(self::$session)) - { - self::$session = JFactory::getSession(); - } - // set to local memory to speed up program - self::$localSession[$key] = $value; - // load to session for later use - return self::$session->set($key, self::$localSession[$key]); - } - - /** - * get info from Session - **/ - public static function get($key, $default = null) - { - if (!isset(self::$session) || !ObjectHelper::check(self::$session)) - { - self::$session = JFactory::getSession(); - } - // check if in local memory - if (!isset(self::$localSession[$key])) - { - // set to local memory to speed up program - self::$localSession[$key] = self::$session->get($key, $default); - } - return self::$localSession[$key]; - } - - - /** - * get field type properties - * - * @return array on success - * - */ - public static function getFieldTypeProperties($value, $type, $settings = array(), $xml = null, $dbDefaults = false) - { - // Get a db connection. - $db = JFactory::getDbo(); - - // Create a new query object. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('properties', 'short_description', 'description'))); - // load database default values - if ($dbDefaults) - { - $query->select($db->quoteName(array('datadefault', 'datadefault_other', 'datalenght', 'datalenght_other', 'datatype', 'has_defaults', 'indexes', 'null_switch', 'store'))); - } - $query->from($db->quoteName('#__componentbuilder_fieldtype')); - $query->where($db->quoteName('published') . ' = 1'); - $query->where($db->quoteName($type) . ' = '. $value); - - // Reset the query using our newly populated query object. - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - $result = $db->loadObject(); - $properties = json_decode($result->properties, true); - $field = array( - 'subform' => array(), - 'nameListOptions' => array(), - 'php' => array(), - 'values' => " '
    '; + $head .= PHP_EOL . Indent::_(3) . ""; + $head .= PHP_EOL . Indent::_(2) . "'; + $head .= PHP_EOL . Indent::_(3) . ""; + $head .= PHP_EOL . Indent::_(2) . "
    ', - 'short_description' => $result->short_description, - 'description' => $result->description); - // number pointer - $nr = 0; - // php tracker (we must try to load alteast 17 rows - $phpTracker = array(); - // force load all properties - $forceAll = false; - if ($xml && strpos($xml, '..__FORCE_LOAD_ALL_PROPERTIES__..') !== false) - { - $forceAll = true; - } - // value to check since there are false and null values even 0 in the values returned - $confirmation = '8qvZHoyuFYQqpj0YQbc6F3o5DhBlmS-_-a8pmCZfOVSfANjkmV5LG8pCdAY2JNYu6cB'; - // set the headers - $field['values_description'] .= ''; - foreach ($properties as $property) - { - $example = (isset($property['example']) && UtilitiesStringHelper::check($property['example'])) ? $property['example'] : ''; - $field['values_description'] .= ''; - // check if we should load the value - $value = FieldHelper::getValue($xml, $property['name'], $confirmation); - // check if this is a php field - $addPHP = false; - if (strpos($property['name'], 'type_php') !== false) - { - $addPHP = true; - // set the line number - $phpLine = (int) preg_replace('/[^0-9]/', '', $property['name']); - // set the key - $phpKey = trim(preg_replace('/[0-9]+/', '', $property['name']), '_'); - // start array if not already set - if (!isset($field['php'][$phpKey])) - { - $field['php'][$phpKey] = array(); - $field['php'][$phpKey]['value'] = array(); - $field['php'][$phpKey]['desc'] = $property['description']; - // start tracker - $phpTracker[$phpKey] = 1; - } - } - // was the settings for the property passed - if(UtilitiesArrayHelper::check($settings) && isset($settings[$property['name']])) - { - // add the xml values - $field['values'] .= PHP_EOL . "\t" . $property['name'] . '="'. $settings[$property['name']] . '" '; - // add the json values - if ($addPHP) - { - $field['php'][$phpKey]['value'][$phpLine] = $settings[$property['name']]; - $phpTracker[$phpKey]++; - } - else - { - $field['subform']['properties'.$nr] = array('name' => $property['name'], 'value' => $settings[$property['name']], 'desc' => $property['description']); - } - } - elseif ($forceAll || !$xml || $confirmation !== $value) - { - // add the xml values - $field['values'] .= PHP_EOL."\t" . $property['name'] . '="' . ($confirmation !== $value) ? $value : $example .'" '; - // add the json values - if ($addPHP) - { - $field['php'][$phpKey]['value'][$phpLine] = ($confirmation !== $value) ? $value : $example; - $phpTracker[$phpKey]++; - } - else - { - $field['subform']['properties' . $nr] = array('name' => $property['name'], 'value' => ($confirmation !== $value) ? $value : $example, 'desc' => $property['description']); - } - } - // add the name List Options - if (!$addPHP) - { - $field['nameListOptions'][$property['name']] = $property['name']; - } - // increment the number - $nr++; - } - // check if all php is loaded using the tracker - if (UtilitiesStringHelper::check($xml) && isset($phpTracker) && UtilitiesArrayHelper::check($phpTracker)) - { - foreach ($phpTracker as $phpKey => $start) - { - if ($start < 30) - { - // we must search for more code in the xml just incase - foreach(range(2, 30) as $t_nr) - { - $get_ = $phpKey . '_' . $t_nr; - if (!isset($field['php'][$phpKey]['value'][$t_nr]) && ($value = FieldHelper::getValue($xml, $get_, $confirmation)) !== $confirmation) - { - $field['php'][$phpKey]['value'][$t_nr] = $value; - } - } - } - } - } - $field['values'] .= PHP_EOL . "/>"; - $field['values_description'] .= '
    ' . JText::_('COM_COMPONENTBUILDER_PROPERTY') . '' . JText::_('COM_COMPONENTBUILDER_EXAMPLE') . '' . JText::_('COM_COMPONENTBUILDER_DESCRIPTION') . '
    ' . $property['name'] . '' . $example . '' . $property['description'] . '
    '; - // load the database defaults if set and wanted - if ($dbDefaults && isset($result->has_defaults) && $result->has_defaults == 1) - { - $field['database'] = array( - 'datatype' => $result->datatype, - 'datadefault' => $result->datadefault, - 'datadefault_other' => $result->datadefault_other, - 'datalenght' => $result->datalenght, - 'datalenght_other' => $result->datalenght_other, - 'indexes' => $result->indexes, - 'null_switch' => $result->null_switch, - 'store' => $result->store - ); - } - // return found field options - return $field; - } - return false; - } - - /** - * Get a field value from the XML stored string - * - * @param string $xml The xml string of the field - * @param string $get The value key to get from the string - * @param string $confirmation The value to confirm found value - * - * @return string The field value from xml - * @deprecated 3.3 Use FieldHelper::getValue($xml, $get, $confirmation); - */ - public static function getValueFromXMLstring(&$xml, &$get, $confirmation = '') - { - return FieldHelper::getValue($xml, $get, $confirmation); - } - - - /** - * get field types properties - * - * @return array on success - * - */ - public static function getFieldTypesProperties($targets = array(), $filter = array(), $exclude = array(), $type = 'id', $operator = 'IN') - { - // Get a db connection. - $db = JFactory::getDbo(); - - // Create a new query object. - $query = $db->getQuery(true); - $query->select($db->quoteName(array('id','properties'))); - $query->from($db->quoteName('#__componentbuilder_fieldtype')); - $query->where($db->quoteName('published') . ' = 1'); - // make sure we have ids (or get all) - if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator) - { - $query->where($db->quoteName($type) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","',$targets) . '")'); - } - else - { - $query->where($db->quoteName($type) . ' ' . $operator . ' (' . implode(',',$targets) . ')'); - } - // Reset the query using our newly populated query object. - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - $_types = array(); - $_properties = array(); - $types = $db->loadObjectList('id'); - foreach ($types as $id => $type) - { - $properties = json_decode($type->properties); - foreach ($properties as $property) - { - if (!isset($_types[$id])) - { - $_types[$id] = array(); - } - // add if no objection is found - $add = true; - // check if we have exclude - if (UtilitiesArrayHelper::check($exclude) && in_array($property->name, $exclude)) - { - continue; - } - // check if we have filter - if (UtilitiesArrayHelper::check($filter)) - { - foreach($filter as $key => $val) - { - if (!isset($property->$key) || $property->$key != $val) - { - $add = false; - } - } - } - // now add the property - if ($add) - { - $_types[$id][$property->name] = array('name' => ucfirst($property->name), 'example' => $property->example, 'description' => $property->description); - // set mandatory - if (isset($property->mandatory) && $property->mandatory == 1) - { - $_types[$id][$property->name]['mandatory'] = true; - } - else - { - $_types[$id][$property->name]['mandatory'] = false; - } - // set translatable - if (isset($property->translatable) && $property->translatable == 1) - { - $_types[$id][$property->name]['translatable'] = true; - } - else - { - $_types[$id][$property->name]['translatable'] = false; - } - $_properties[$property->name] = $_types[$id][$property->name]['name']; - } - } - } - - // return found types & properties - return array('types' => $_types, 'properties' => $_properties); - } - return false; - } - - - /** - * Remove folders with files - * - * @param string $path The path to folder to remove - * @param array|null $ignore The folders and files to ignore and not remove - * - * @return bool True if all are removed - */ - public static function removeFolder(string $path, ?array $ignore = null): bool - { - if (!Folder::exists($path)) - { - return false; - } - - $it = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS); - $files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST); - - // Prepare a base path without trailing slash for comparison - $basePath = rtrim($path, '/'); - - foreach ($files as $fileinfo) - { - $filePath = $fileinfo->getRealPath(); - - if (self::removeFolderShouldIgnore($basePath, $filePath, $ignore)) - { - continue; - } - - if ($fileinfo->isDir()) - { - Folder::delete($filePath); - } - else - { - File::delete($filePath); - } - } - - // Delete the root folder if ignore not set - if (!UtilitiesArrayHelper::check($ignore)) - { - return Folder::delete($path); - } - - return true; - } - - /** - * Check if the current path should be ignored. - * - * @param string $basePath The base directory path - * @param string $filePath The current file or directory path - * @param array|null $ignore List of items to ignore - * - * @return boolean True if the path should be ignored - * @since 3.2.0 - */ - protected static function removeFolderShouldIgnore(string $basePath, string $filePath, ?array $ignore = null): bool - { - if (!$ignore || !UtilitiesArrayHelper::check($ignore)) - { - return false; - } - - foreach ($ignore as $item) - { - if (strpos($filePath, $basePath . '/' . $item) !== false) - { - return true; - } - } - - return false; - } - - /** - * The github access token - **/ - protected static $gitHubAccessToken = ""; - - /** - * The github repo get data errors - **/ - public static $githubRepoDataErrors = array(); - - /** - * get the github repo file list - * - * @return array on success - * - */ - public static function getGithubRepoFileList($type, $target) - { - // get the repo data - if (($repoData = self::getGithubRepoData($type, $target, 'tree')) !== false) - { - return $repoData->tree; - } - return false; - } - - /** - * get the github repo file list - * - * @return array on success - * - */ - public static function getGithubRepoData($type, $url, $target = null, $return_type = 'object') - { - // always reset errors per/request - self::$githubRepoDataErrors = array(); - // get the current Packages (public) - if ('nomemory' === $type || !$repoData = self::get($type)) - { - // add the token if not already added - $_url = self::setGithubToken($url); - // check if the url exist - if (self::urlExists($_url)) - { - // get the data from github - if (($repoData = FileHelper::getContent($_url)) !== false && JsonHelper::check($repoData)) - { - $github_returned = json_decode($repoData); - if (UtilitiesStringHelper::check($target) && - ( (ObjectHelper::check($github_returned) && isset($github_returned->{$target}) && UtilitiesArrayHelper::check($github_returned->{$target})) || - (UtilitiesArrayHelper::check($github_returned) && isset($github_returned[$target]) && UtilitiesArrayHelper::check($github_returned[$target])) )) - { - if ('nomemory' !== $type) - { - // remember to set it - self::set($type, $repoData); - } - } - elseif (!UtilitiesStringHelper::check($target) && (UtilitiesArrayHelper::check($github_returned) || (ObjectHelper::check($github_returned) && !isset($github_returned->message)))) - { - if ('nomemory' !== $type) - { - // remember to set it - self::set($type, $repoData); - } - } - // check if we have error message from github - elseif (($errorMessage = self::githubErrorHandeler(array('error' => null), $github_returned, $type)) !== false) - { - if (isset($errorMessage['error']) && UtilitiesStringHelper::check($errorMessage['error'])) - { - // set the error in the application - JFactory::getApplication()->enqueueMessage($errorMessage['error'], 'Error'); - // set the error also in the class encase it is and Ajax call - self::$githubRepoDataErrors[] = $errorMessage['error']; - } - return false; - } - elseif (UtilitiesStringHelper::check($target)) - { - // setup error string - $error = JText::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DID_NOT_RETURN_S_DATA', $url, $target); - // set the error in the application - JFactory::getApplication()->enqueueMessage($error, 'Error'); - // set the error also in the class encase it is and Ajax call - self::$githubRepoDataErrors[] = $error; - // we are done here - return false; - } - elseif ('nomemory' !== $type) - { - // setup error string - $error = JText::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DID_NOT_RETURN_S_DATA', $url, $type); - // set the error in the application - JFactory::getApplication()->enqueueMessage($error, 'Error'); - // set the error also in the class encase it is and Ajax call - self::$githubRepoDataErrors[] = $error; - // we are done here - return false; - } - else - { - // setup error string - $error = JText::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DID_NOT_RETURN_VALID_DATA', $url, $type); - // set the error in the application - JFactory::getApplication()->enqueueMessage($error, 'Error'); - // set the error also in the class encase it is and Ajax call - self::$githubRepoDataErrors[] = $error; - // we are done here - return false; - } - } - else - { - // setup error string - $error = JText::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DOES_NOT_RETURN_ANY_DATA', $url); - // set the error in the application - JFactory::getApplication()->enqueueMessage($error, 'Error'); - // set the error also in the class encase it is and Ajax call - self::$githubRepoDataErrors[] = $error; - // we are done here - return false; - } - } - else - { - // setup error string - $error = JText::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DOES_NOT_EXIST', $url); - // set the error in the application - JFactory::getApplication()->enqueueMessage($error, 'Error'); - // set the error also in the class encase it is and Ajax call - self::$githubRepoDataErrors[] = $error; - // we are done here - return false; - } - } - // check if we could find packages - if (isset($repoData) && JsonHelper::check($repoData)) - { - if ('object' === $return_type) - { - return json_decode($repoData); - } - elseif ('array' === $return_type) - { - return json_decode($repoData, true); - } - return $repoData; - } - return false; - } - - /** - * get the github error messages - * - * @return array of errors on success - * - */ - protected static function githubErrorHandeler($message, &$github, $type) - { - if (ObjectHelper::check($github) && isset($github->message) && UtilitiesStringHelper::check($github->message)) - { - // set the message - $errorMessage = $github->message; - // add the documentation URL - if (isset($github->documentation_url) && UtilitiesStringHelper::check($github->documentation_url)) - { - $errorMessage = $errorMessage . '
    ' . $github->documentation_url; - } - // check the message - if (strpos($errorMessage, 'Authenticated') !== false) - { - if ('nomemory' === $type) - { - $type = 'data'; - } - // add little more help if it is an access token issue - $errorMessage = JText::sprintf('COM_COMPONENTBUILDER_SBR_YOU_CAN_ADD_A_BGITHUB_ACCESS_TOKENB_TO_COMPONENTBUILDER_GLOBAL_OPTIONS_TO_MAKE_AUTHENTICATED_REQUESTS_TO_GITHUB_AN_ACCESS_TOKEN_WITH_ONLY_PUBLIC_ACCESS_WILL_DO_TO_RETRIEVE_S', $errorMessage, $type); - } - // set error notice - $message['error'] = $errorMessage; - // we have error message - return $message; - } - return false; - } - - /** - * set the github token - * - * @return array of errors on success - * - */ - protected static function setGithubToken($url) - { - // first check if token already set - if (strpos($url, 'access_token=') !== false) - { - // make sure the token is loaded - if (!UtilitiesStringHelper::check(self::$gitHubAccessToken)) - { - // get the global settings - if (!ObjectHelper::check(self::$params)) - { - self::$params = JComponentHelper::getParams('com_componentbuilder'); - } - self::$gitHubAccessToken = self::$params->get('github_access_token', null); - } - // make sure the token is loaded at this point - if (UtilitiesStringHelper::check(self::$gitHubAccessToken)) - { - $url .= '&access_token=' . self::$gitHubAccessToken; - } - } - return $url; - } - - - /** - * 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 - if ($fieldName) - { - $fieldNames = array( - 'php_import_display' => 'display', - 'php_import_setdata' => 'setdata', - 'php_import_save' => 'save', - 'html_import_view' => 'view', - 'php_import' => 'import', - 'php_import_ext' => 'ext', - 'php_import_headers' => 'headers' - ); - // first check if the field name is found - if (isset($fieldNames[$type])) - { - $type = $fieldNames[$type]; - } - else - { - return ''; - } - } - $script = array(); - if ('display' === $type) - { - // set the display script - $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'][] = 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"; - $script['setdata'][] = self::_t(3) . "[[[-#-#-Component]]]Helper::composerAutoload('phpspreadsheet');"; - $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) . "if ((\$column = \$jinput->getString(\$header, false)) !== false ||"; - $script['setdata'][] = self::_t(5) . "(\$column = \$jinput->getString(strtolower(\$header), false)) !== false)"; - $script['setdata'][] = self::_t(4) . "{"; - $script['setdata'][] = self::_t(5) . "\$data['target_headers'][\$header] = \$column;"; - $script['setdata'][] = self::_t(4) . "}"; - $script['setdata'][] = self::_t(4) . "else"; - $script['setdata'][] = self::_t(4) . "{"; - $script['setdata'][] = self::_t(5) . "\$data['target_headers'][\$header] = null;"; - $script['setdata'][] = self::_t(4) . "}"; - $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 = IOFactory::identify(\$package['dir']);"; - $script['setdata'][] = self::_t(4) . "\$excelReader = 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'][] = 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'][] = 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'][] = 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'][] = ""; - $script['view'][] = PHP_EOL . "
    "; - $script['view'][] = "
    \" method=\"post\" name=\"adminForm\" id=\"adminForm\" class=\"form-horizontal form-validate\">"; - $script['view'][] = ""; - $script['view'][] = PHP_EOL . self::_t(1) . "sidebar)) : ?>"; - $script['view'][] = self::_t(2) . "
    "; - $script['view'][] = self::_t(3) . "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'][] = 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(3) . ""; - $script['view'][] = self::_t(3) . "
    "; - $script['view'][] = self::_t(4) . ""; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(5) . ""; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(3) . "
    "; - $script['view'][] = self::_t(3) . "headerList as \$name => \$title): ?>"; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(5) . ""; - $script['view'][] = self::_t(5) . "
    "; - $script['view'][] = self::_t(6) . ""; - $script['view'][] = self::_t(5) . "
    "; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(3) . ""; - $script['view'][] = self::_t(3) . "
    "; - $script['view'][] = self::_t(4) . "\" onclick=\"Joomla.continueImport()\" />"; - $script['view'][] = self::_t(3) . "
    "; - $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(4) . ""; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(5) . ""; - $script['view'][] = self::_t(5) . "
    "; - $script['view'][] = self::_t(6) . ""; - $script['view'][] = self::_t(5) . "
    "; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(5) . "\" onclick=\"Joomla.submitbutton()\" />    (.csv .xls .ods)"; - $script['view'][] = self::_t(4) . "
    "; - $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(4) . ""; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(5) . ""; - $script['view'][] = self::_t(5) . "
    "; - $script['view'][] = self::_t(6) . "state->get('import.directory'); ?>\" />"; - $script['view'][] = self::_t(5) . "
    "; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(5) . "\" onclick=\"Joomla.submitbutton3()\" />    (.csv .xls .ods)"; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(2) . ""; - $script['view'][] = ""; - $script['view'][] = PHP_EOL . self::_t(2) . ""; - $script['view'][] = self::_t(3) . "
    "; - $script['view'][] = self::_t(4) . ""; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(5) . ""; - $script['view'][] = self::_t(5) . "
    "; - $script['view'][] = self::_t(6) . ""; - $script['view'][] = self::_t(5) . "
    "; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(4) . "
    "; - $script['view'][] = self::_t(5) . "\" onclick=\"Joomla.submitbutton4()\" />    (.csv .xls .ods)"; - $script['view'][] = self::_t(4) . "
    "; - $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'][] = 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'][] = 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'][] = 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(PHP_EOL, $script[$type])); - } - return false; - } - - /** - * Field Grouping https://docs.joomla.org/Form_field - * @deprecated 3.3 - **/ - protected static $fieldGroups = array( - 'default' => array( - 'accesslevel', 'cachehandler', 'calendar', 'captcha', 'category', 'checkbox', 'checkboxes', 'chromestyle', - 'color', 'combo', 'componentlayout', 'contentlanguage', 'contenttype', 'databaseconnection', 'components', - 'editor', 'editors', 'email', 'file', 'file', 'filelist', 'folderlist', 'groupedlist', 'headertag', 'helpsite', 'hidden', 'imagelist', - 'integer', 'language', 'list', 'media', 'menu', 'modal_menu', 'menuitem', 'meter', 'modulelayout', 'moduleorder', 'moduleposition', - 'moduletag', 'note', 'number', 'password', 'plugins', 'predefinedlist', 'radio', 'range', 'repeatable', 'rules', - 'sessionhandler', 'spacer', 'sql', 'subform', 'tag', 'tel', 'templatestyle', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup' - ), - 'plain' => array( - 'cachehandler', 'calendar', 'checkbox', 'chromestyle', 'color', 'componentlayout', 'contenttype', 'editor', 'editors', 'captcha', - 'email', 'file', 'headertag', 'helpsite', 'hidden', 'integer', 'language', 'media', 'menu', 'modal_menu', 'menuitem', 'meter', 'modulelayout', 'templatestyle', - 'moduleorder', 'moduletag', 'number', 'password', 'range', 'rules', 'tag', 'tel', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup' - ), - 'option' => array( - 'accesslevel', 'category', 'checkboxes', 'combo', 'contentlanguage', 'databaseconnection', 'components', - 'filelist', 'folderlist', 'imagelist', 'list', 'plugins', 'predefinedlist', 'radio', 'sessionhandler', 'sql', 'groupedlist' - ), - 'text' => array( - 'calendar', 'color', 'editor', 'email', 'number', 'password', 'range', 'tel', 'text', 'textarea', 'url' - ), - 'list' => array( - 'checkbox', 'checkboxes', 'list', 'radio', 'groupedlist', 'combo' - ), - 'dynamic' => array( - 'category', 'file', 'filelist', 'folderlist', 'headertag', 'imagelist', 'integer', 'media', 'meter', 'rules', 'tag', 'timezone', 'user' - ), - 'spacer' => array( - 'note', 'spacer' - ), - 'special' => array( - 'contentlanguage', 'moduleposition', 'plugin', 'repeatable', 'subform' - ), - 'search' => array( - 'editor', 'email', 'tel', 'text', 'textarea', 'url', 'subform' - ) - ); - - /** - * Field Checker - * - * @param string $type The field type - * @param boolean $option The field grouping - * - * @return boolean if the field was found - * @deprecated 3.3 Use Factory::_('Field.Groups')->check($type, $option); - */ - public static function fieldCheck($type, $option = 'default') - { - return Factory::_('Field.Groups')->check($type, $option); - } - - /** - * get the field types id -> name of a group or groups - * - * @return array ids of the spacer field types - * @deprecated 3.3 Use Factory::_('Field.Groups')->types($groups); - */ - public static function getFieldTypesByGroup($groups = array()) - { - return Factory::_('Field.Groups')->types($groups); - } - - /** - * get the field types IDs of a group or groups - * - * @return array ids of the spacer field types - * @deprecated 3.3 Use Factory::_('Field.Groups')->typesIds($groups); - */ - public static function getFieldTypesIdsByGroup($groups = array()) - { - return Factory::_('Field.Groups')->typesIds($groups); - } - - /** - * get the spacer IDs - * - * @return array ids of the spacer field types - * @deprecated 3.3 Use Factory::_('Field.Groups')->spacerIds(); - */ - public static function getSpacerIds() - { - return Factory::_('Field.Groups')->spacerIds(); - } - - - /** - * open base64 string if stored as base64 - * - * @param string $data The base64 string - * @param string $key We store the string with that suffix :) - * @param string $default The default switch - * - * @return string The opened string - * @deprecated 3.3 Use Base64Helper::open($data, $key, $default); - */ - public static function openValidBase64($data, $key = '__.o0=base64=Oo.__', $default = 'string') - { - return Base64Helper::open($data, $key, $default); - } - - /** - * prepare base64 string for url - * - * @deprecate Use urlencode(); - */ - public static function base64_urlencode($string, $encode = false) - { - if ($encode) - { - $string = base64_encode($string); - } - return str_replace(array('+', '/'), array('-', '_'), $string); - } - - /** - * prepare base64 string form url - * - * @deprecate - */ - public static function base64_urldecode($string, $decode = false) - { - $string = str_replace(array('-', '_'), array('+', '/'), $string); - if ($decode) - { - $string = base64_decode($string); - } - return $string; - } - - - /** - * Get the file path or url - * - * @param string $type The (url/path) type to return - * @param string $target The Params Target name (if set) - * @param string $default The default path if not set in Params (fallback path) - * @param bool $createIfNotSet The switch to create the folder if not found - * - * @return string On success the path or url is returned based on the type requested - * - */ - public static function getFolderPath($type = 'path', $target = 'folderpath', $default = '', $createIfNotSet = true) - { - // make sure to always have a string/path - if(!UtilitiesStringHelper::check($default)) - { - $default = JPATH_SITE . '/images/'; - } - // get the global settings - if (!ObjectHelper::check(self::$params)) - { - self::$params = JComponentHelper::getParams('com_componentbuilder'); - } - $folderPath = self::$params->get($target, $default); - // create the folder if it does not exist - if ($createIfNotSet && !Folder::exists($folderPath)) - { - Folder::create($folderPath); - } - // return the url - if ('url' === $type) - { - if (strpos($folderPath, JPATH_SITE) !== false) - { - $folderPath = trim( str_replace( JPATH_SITE, '', $folderPath), '/'); - return JURI::root() . $folderPath . '/'; - } - // since the path is behind the root folder of the site, return only the root url (may be used to build the link) - return JURI::root(); - } - // sanitize the path - return '/' . trim( $folderPath, '/' ) . '/'; - } - - - /** - * the Crypt objects - **/ - protected static $CRYPT = array(); - - /** - * the Cipher MODE switcher (list of ciphers) - **/ - protected static $setCipherMode = array( - 'AES' => true, - 'Rijndael' => true, - 'Twofish' => false, // can but not good idea - 'Blowfish' => false, // can but not good idea - 'RC4' => false, // nope - 'RC2' => false, // can but not good idea - 'TripleDES' => false, // can but not good idea - 'DES' => true - ); - - /** - * get the Crypt object - * - * @return object on success with Crypt power - **/ - public static function crypt($type, $mode = null) - { - // set key based on mode - if ($mode) - { - $key = $type . $mode; - } - else - { - $key = $type; - } - // check if it was already set - if (isset(self::$CRYPT[$key]) && ObjectHelper::check(self::$CRYPT[$key])) - { - return self::$CRYPT[$key]; - } - // make sure we have the composer classes loaded - self::composerAutoload('phpseclib'); - // build class name - $CLASS = '\phpseclib\Crypt\\' . $type; - // make sure we have the phpseclib classes - if (!class_exists($CLASS)) - { - // class not in place so send out error - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_BSB_LIBRARYCLASS_IS_NOT_AVAILABLE_THIS_LIBRARYCLASS_SHOULD_HAVE_BEEN_ADDED_TO_YOUR_BLIBRARIESPHPSECLIBVENDORB_FOLDER_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFO', $CLASS), 'Error'); - return false; - } - // does this crypt class use mode - if ($mode && isset(self::$setCipherMode[$type]) && self::$setCipherMode[$type]) - { - switch ($mode) - { - case 'CTR': - self::$CRYPT[$key] = new $CLASS('ctr'); - break; - case 'ECB': - self::$CRYPT[$key] = new $CLASS('ecb'); - break; - case 'CBC': - self::$CRYPT[$key] = new $CLASS('cbc'); - break; - case 'CBC3': - self::$CRYPT[$key] = new $CLASS('cbc3'); - break; - case 'CFB': - self::$CRYPT[$key] = new $CLASS('cfb'); - break; - case 'CFB8': - self::$CRYPT[$key] = new $CLASS('cfb8'); - break; - case 'OFB': - self::$CRYPT[$key] = new $CLASS('ofb'); - break; - case 'GCM': - self::$CRYPT[$key] = new $CLASS('gcm'); - break; - case 'STREAM': - self::$CRYPT[$key] = new $CLASS('stream'); - break; - default: - // No valid mode has been specified - JFactory::getApplication()->enqueueMessage(JText::_('COM_COMPONENTBUILDER_NO_VALID_MODE_HAS_BEEN_SPECIFIED'), 'Error'); - return false; - break; - } - } - else - { - // set the default - self::$CRYPT[$key] = new $CLASS(); - } - // return the object - return self::$CRYPT[$key]; - } - - /** - * Move File to Server - * - * @param string $localPath The local path to the file - * @param string $fileName The the actual file name - * @param int $serverID The server local id to use - * @param int $protocol The server protocol to use - * @param string $permission The permission validation area - * - * @return bool true on success - **/ - public static function moveToServer($localPath, $fileName, $serverID, $protocol = null, $permission = 'core.export') - { - // get the server - if ($server = self::getServer( (int) $serverID, $protocol, $permission)) - { - // use the FTP protocol - if (1 == $server->jcb_protocol) - { - // now move the file - if (!$server->store($localPath, $fileName)) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_SERVER', $fileName, $server->jcb_remote_server_name[(int) $serverID]), 'Error'); - return false; - } - // close the connection - $server->quit(); - } - // use the SFTP protocol - elseif (2 == $server->jcb_protocol) - { - // get the remote path - $remote_path = '/' . trim($server->jcb_remote_server_path[(int) $serverID], '/') . '/' . $fileName; - // now move the file - if (!$server->put($remote_path, FileHelper::getContent($localPath, null))) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_PATH_ON_BSB_SERVER', $fileName, $server->jcb_remote_server_path[(int) $serverID], $server->jcb_remote_server_name[(int) $serverID]), 'Error'); - return false; - } - } - return true; - } - return false; - } - - /** - * the SFTP objects - **/ - protected static $sftp = array(); - - /** - * the FTP objects - **/ - protected static $ftp = array(); - - /** - * get the server object - * - * @param int $serverID The server local id to use - * @param int $protocol The server protocol to use - * @param string $permission The permission validation area - * - * @return object on success server object - **/ - public static function getServer($serverID, $protocol = null, $permission = 'core.export') - { - // if not protocol is given get it (sad I know) - if (!$protocol) - { - $protocol = self::getVar('server', (int) $serverID, 'id', 'protocol'); - } - // return the server object - switch ($protocol) - { - case 1: // FTP - return self::getFtp($serverID, $permission); - break; - case 2: // SFTP - return self::getSftp($serverID, $permission); - break; - } - return false; - } - - /** - * get the sftp object - * - * @param int $serverID The server local id to use - * @param string $permission The permission validation area - * - * @return object on success with sftp power - **/ - public static function getSftp($serverID, $permission = 'core.export') - { - // check if we have a server with that id - if ($server = self::getServerDetails($serverID, 2, $permission)) - { - // check if it was already set - if (!isset(self::$sftp[$server->cache]) || !ObjectHelper::check(self::$sftp[$server->cache])) - { - // make sure we have the composer classes loaded - self::composerAutoload('phpseclib'); - // make sure we have the phpseclib classes - if (!class_exists('\phpseclib\Net\SFTP')) - { - // class not in place so send out error - JFactory::getApplication()->enqueueMessage(JText::_('COM_COMPONENTBUILDER_THE_BPHPSECLIBNETSFTPB_LIBRARYCLASS_IS_NOT_AVAILABLE_THIS_LIBRARYCLASS_SHOULD_HAVE_BEEN_ADDED_TO_YOUR_BLIBRARIESVDM_IOVENDORB_FOLDER_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFO'), 'Error'); - return false; - } - // insure the port is set - $server->port = (isset($server->port) && is_numeric($server->port) && $server->port > 0) ? (int) $server->port : 22; - // open the connection - self::$sftp[$server->cache] = new phpseclib\Net\SFTP($server->host, $server->port); - // heads-up on protocol - self::$sftp[$server->cache]->jcb_protocol = 2; // SFTP <-- if called not knowing what type of protocol is being used - // now login based on authentication type - switch($server->authentication) - { - case 1: // password - if (!self::$sftp[$server->cache]->login($server->username, $server->password)) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_LOGIN_TO_BSB_HAS_FAILED_PLEASE_CHECK_THAT_YOUR_DETAILS_ARE_CORRECT', $server->name), 'Error'); - unset(self::$sftp[$server->cache]); - return false; - } - break; - case 2: // private key file - if (ObjectHelper::check(self::crypt('RSA'))) - { - // check if we have a passprase - if (UtilitiesStringHelper::check($server->secret)) - { - self::crypt('RSA')->setPassword($server->secret); - } - // now load the key file - if (!self::crypt('RSA')->loadKey(FileHelper::getContent($server->private, null))) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_PRIVATE_KEY_FILE_COULD_NOT_BE_LOADEDFOUND_FOR_BSB_SERVER', $server->name), 'Error'); - unset(self::$sftp[$server->cache]); - return false; - } - // now login - if (!self::$sftp[$server->cache]->login($server->username, self::crypt('RSA'))) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_LOGIN_TO_BSB_HAS_FAILED_PLEASE_CHECK_THAT_YOUR_DETAILS_ARE_CORRECT', $server->name), 'Error'); - unset(self::$sftp[$server->cache]); - return false; - } - } - break; - case 3: // both password and private key file - if (ObjectHelper::check(self::crypt('RSA'))) - { - // check if we have a passphrase - if (UtilitiesStringHelper::check($server->secret)) - { - self::crypt('RSA')->setPassword($server->secret); - } - // now load the key file - if (!self::crypt('RSA')->loadKey(FileHelper::getContent($server->private, null))) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_PRIVATE_KEY_FILE_COULD_NOT_BE_LOADEDFOUND_FOR_BSB_SERVER', $server->name), 'Error'); - unset(self::$sftp[$server->cache]); - return false; - } - // now login - if (!self::$sftp[$server->cache]->login($server->username, $server->password, self::crypt('RSA'))) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_LOGIN_TO_BSB_HAS_FAILED_PLEASE_CHECK_THAT_YOUR_DETAILS_ARE_CORRECT', $server->name), 'Error'); - unset(self::$sftp[$server->cache]); - return false; - } - } - break; - case 4: // private key field - if (ObjectHelper::check(self::crypt('RSA'))) - { - // check if we have a passprase - if (UtilitiesStringHelper::check($server->secret)) - { - self::crypt('RSA')->setPassword($server->secret); - } - // now load the key field - if (!self::crypt('RSA')->loadKey($server->private_key)) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_PRIVATE_KEY_FIELD_COULD_NOT_BE_LOADED_FOR_BSB_SERVER', $server->name), 'Error'); - unset(self::$sftp[$server->cache]); - return false; - } - // now login - if (!self::$sftp[$server->cache]->login($server->username, self::crypt('RSA'))) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_LOGIN_TO_BSB_HAS_FAILED_PLEASE_CHECK_THAT_YOUR_DETAILS_ARE_CORRECT', $server->name), 'Error'); - unset(self::$sftp[$server->cache]); - return false; - } - } - break; - case 5: // both password and private key field - if (ObjectHelper::check(self::crypt('RSA'))) - { - // check if we have a passphrase - if (UtilitiesStringHelper::check($server->secret)) - { - self::crypt('RSA')->setPassword($server->secret); - } - // now load the key file - if (!self::crypt('RSA')->loadKey($server->private_key)) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_PRIVATE_KEY_FIELD_COULD_NOT_BE_LOADED_FOR_BSB_SERVER', $server->name), 'Error'); - unset(self::$sftp[$server->cache]); - return false; - } - // now login - if (!self::$sftp[$server->cache]->login($server->username, $server->password, self::crypt('RSA'))) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_LOGIN_TO_BSB_HAS_FAILED_PLEASE_CHECK_THAT_YOUR_DETAILS_ARE_CORRECT', $server->name), 'Error'); - unset(self::$sftp[$server->cache]); - return false; - } - } - break; - } - } - // only continue if object is set - if (isset(self::$sftp[$server->cache]) && ObjectHelper::check(self::$sftp[$server->cache])) - { - // set the unique buckets - if (!isset(self::$sftp[$server->cache]->jcb_remote_server_name)) - { - self::$sftp[$server->cache]->jcb_remote_server_name = array(); - self::$sftp[$server->cache]->jcb_remote_server_path = array(); - } - // always set the name and remote server path - self::$sftp[$server->cache]->jcb_remote_server_name[$serverID] = $server->name; - self::$sftp[$server->cache]->jcb_remote_server_path[$serverID] = (UtilitiesStringHelper::check($server->path) && $server->path !== '/') ? $server->path : ''; - // return the sftp object - return self::$sftp[$server->cache]; - } - } - return false; - } - - /** - * get the JClientFtp object - * - * @param int $serverID The server local id to use - * @param string $permission The permission validation area - * - * @return object on success with ftp power - **/ - public static function getFtp($serverID, $permission) - { - // check if we have a server with that id - if ($server = self::getServerDetails($serverID, 1, $permission)) - { - // check if we already have the server instance - if (isset(self::$ftp[$server->cache]) && self::$ftp[$server->cache] instanceof JClientFtp) - { - // always set the name and remote server path - self::$ftp[$server->cache]->jcb_remote_server_name[$serverID] = $server->name; - // if still connected we are ready to go - if (self::$ftp[$server->cache]->isConnected()) - { - // return the FTP instance - return self::$ftp[$server->cache]; - } - // check if we can reinitialise the server - if (self::$ftp[$server->cache]->reinit()) - { - // return the FTP instance - return self::$ftp[$server->cache]; - } - } - // make sure we have a string and it is not default or empty - if (UtilitiesStringHelper::check($server->signature)) - { - // turn into variables - parse_str($server->signature); // because of this I am using strange variable naming to avoid any collisions. - // set options - if (isset($options) && UtilitiesArrayHelper::check($options)) - { - foreach ($options as $o__p0t1on => $vAln3) - { - if ('timeout' === $o__p0t1on) - { - $options[$o__p0t1on] = (int) $vAln3; - } - if ('type' === $o__p0t1on) - { - $options[$o__p0t1on] = (string) $vAln3; - } - } - } - else - { - $options = array(); - } - // get ftp object - if (isset($host) && $host != 'HOSTNAME' && isset($port) && $port != 'PORT_INT' && isset($username) && $username != 'user@name.com' && isset($password) && $password != 'password') - { - // load for reuse - self::$ftp[$server->cache] = JClientFtp::getInstance($host, $port, $options, $username, $password); - } - else - { - // load error to indicate signature was in error - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_FTP_SIGNATURE_FOR_BSB_WAS_NOT_WELL_FORMED_PLEASE_CHECK_YOUR_SIGNATURE_DETAILS', $server->name), 'Error'); - return false; - } - // check if we are connected - if (self::$ftp[$server->cache] instanceof JClientFtp && self::$ftp[$server->cache]->isConnected()) - { - // heads-up on protocol - self::$ftp[$server->cache]->jcb_protocol = 1; // FTP <-- if called not knowing what type of protocol is being used - // set the unique buckets - if (!isset(self::$ftp[$server->cache]->jcb_remote_server_name)) - { - self::$ftp[$server->cache]->jcb_remote_server_name = array(); - } - // always set the name and remote server path - self::$ftp[$server->cache]->jcb_remote_server_name[$serverID] = $server->name; - // return the FTP instance - return self::$ftp[$server->cache]; - } - // reset since we have no connection - unset(self::$ftp[$server->cache]); - } - // load error to indicate signature was in error - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_FTP_CONNECTION_FOR_BSB_COULD_NOT_BE_MADE_PLEASE_CHECK_YOUR_SIGNATURE_DETAILS', $server->name), 'Error'); - } - return false; - } - - /** - * get the server details - * - * @param int $serverID The server local id to use - * @param int $protocol The server protocol to use - * @param string $permission The permission validation area - * - * @return object on success with server details - **/ - public static function getServerDetails($serverID, $protocol = 2, $permission = 'core.export') - { - // check if this user has permission to access items - if (!JFactory::getUser()->authorise($permission, 'com_componentbuilder')) - { - // set message to inform the user that permission was denied - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_ACCESS_THE_SERVER_DETAILS_BS_DENIEDB_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFO', UtilitiesStringHelper::safe($permission, 'w')), 'Error'); - return false; - } - // now insure we have correct values - if (is_int($serverID) && is_int($protocol)) - { - // Get a db connection - $db = JFactory::getDbo(); - // start the query - $query = $db->getQuery(true); - // select based to protocol - if (2 == $protocol) - { - // SFTP - $query->select($db->quoteName(array('name','authentication','username','host','password','path','port','private','private_key','secret'))); - // cache builder - $cache = array('authentication','username','host','password','port','private','private_key','secret'); - } - else - { - // FTP - $query->select($db->quoteName(array('name','signature'))); - // cache builder - $cache = array('signature'); - } - $query->from($db->quoteName('#__componentbuilder_server')); - $query->where($db->quoteName('id') . ' = ' . (int) $serverID); - $query->where($db->quoteName('protocol') . ' = ' . (int) $protocol); - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - $server = $db->loadObject(); - // Get the basic encryption. - $basickey = self::getCryptKey('basic', 'Th1sMnsTbL0ck@d'); - // Get the encryption object. - $basic = new AES($basickey, 128); - // start cache keys - $keys = array(); - // unlock the needed fields - foreach($server as $name => &$value) - { - // unlock the needed fields - if ($name !== 'name' && !empty($value) && $basickey && !is_numeric($value) && $value === base64_encode(base64_decode($value, true))) - { - // basic decrypt of data - $value = rtrim($basic->decryptString($value), "\0"); - } - // build cache (keys) for lower connection latency - if (in_array($name, $cache)) - { - $keys[] = $value; - } - } - // check if cache keys were found - if (UtilitiesArrayHelper::check($keys)) - { - // now set cache - $server->cache = md5(implode('', $keys)); - } - else - { - // default is ID - $server->cache = $serverID; - } - // return the server details - return $server; - } - } - JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_SERVER_DETAILS_FOR_BID_SB_COULD_NOT_BE_RETRIEVED', $serverID), 'Error'); - return false; - } - - /** - * Load the Composer Vendor phpseclib - */ - protected static function composephpseclib() - { - // load the autoloader for phpseclib - require_once JPATH_SITE . '/libraries/phpseclib/vendor/autoload.php'; - // do not load again - self::$composer['phpseclib'] = true; - - return true; - } - - - /** - * the locker - * - * @var array - **/ - protected static $locker = array(); - - /** - * the dynamic replacement salt - * - * @var array - **/ - protected static $globalSalt = array(); - - /** - * the timer - * - * @var object - **/ - protected static $keytimer; - - /** - * To Lock string - * - * @param string $string The string/array to lock - * @param string $key The custom key to use - * @param int $salt The switch to add salt and type of salt - * @param int $dynamic The dynamic replacement array of salt build string - * @param int $urlencode The switch to control url encoding - * - * @return string Encrypted String - * - **/ - public static function lock($string, $key = null, $salt = 2, $dynamic = null, $urlencode = true) - { - // get the global settings - if (!$key || !UtilitiesStringHelper::check($key)) - { - // set temp timer - $timer = 2; - // if we have a timer use it - if ($salt > 0) - { - $timer = $salt; - } - // set the default key - $key = self::salt($timer, $dynamic); - // try getting the system key - if (method_exists(get_called_class(), "getCryptKey")) - { - // try getting the medium key first the fall back to basic, and then default - $key = self::getCryptKey('medium', self::getCryptKey('basic', $key)); - } - } - // check if we have a salt timer - if ($salt > 0) - { - $key .= self::salt($salt, $dynamic); - } - // get the locker settings - if (!isset(self::$locker[$key]) || !ObjectHelper::check(self::$locker[$key])) - { - self::$locker[$key] = new AES($key, 128); - } - // convert array or object to string - if (UtilitiesArrayHelper::check($string) || ObjectHelper::check($string)) - { - $string = serialize($string); - } - // prep for url - if ($urlencode && method_exists(get_called_class(), "base64_urlencode")) - { - return self::base64_urlencode(self::$locker[$key]->encryptString($string)); - } - return self::$locker[$key]->encryptString($string); - } - - /** - * To un-Lock string - * - * @param string $string The string to unlock - * @param string $key The custom key to use - * @param int $salt The switch to add salt and type of salt - * @param int $dynamic The dynamic replacement array of salt build string - * @param int $urlencode The switch to control url decoding - * - * @return string Decrypted String - * - **/ - public static function unlock($string, $key = null, $salt = 2, $dynamic = null, $urlencode = true) - { - // get the global settings - if (!$key || !UtilitiesStringHelper::check($key)) - { - // set temp timer - $timer = 2; - // if we have a timer use it - if ($salt > 0) - { - $timer = $salt; - } - // set the default key - $key = self::salt($timer, $dynamic); - // try getting the system key - if (method_exists(get_called_class(), "getCryptKey")) - { - // try getting the medium key first the fall back to basic, and then default - $key = self::getCryptKey('medium', self::getCryptKey('basic', $key)); - } - } - // check if we have a salt timer - if ($salt > 0) - { - $key .= self::salt($salt, $dynamic); - } - // get the locker settings - if (!isset(self::$locker[$key]) || !ObjectHelper::check(self::$locker[$key])) - { - self::$locker[$key] = new AES($key, 128); - } - // make sure we have real base64 - if ($urlencode && method_exists(get_called_class(), "base64_urldecode")) - { - $string = self::base64_urldecode($string); - } - // basic decrypt string. - if (!empty($string) && !is_numeric($string) && $string === base64_encode(base64_decode($string, true))) - { - $string = rtrim(self::$locker[$key]->decryptString($string), "\0"); - // convert serial string to array - if (self::is_serial($string)) - { - $string = unserialize($string); - } - } - return $string; - } - - /** - * The Salt - * - * @param int $type The type of length the salt should be valid - * @param int $dynamic The dynamic replacement array of salt build string - * - * @return string - * - **/ - public static function salt($type = 1, $dynamic = null) - { - // get dynamic replacement salt - $dynamic = self::getDynamicSalt($dynamic); - // get the key timer - if (!ObjectHelper::check(self::$keytimer)) - { - // load the date time object - self::$keytimer = new DateTime; - // set the correct time stamp - $vdmLocalTime = new DateTimeZone('Africa/Windhoek'); - self::$keytimer->setTimezone($vdmLocalTime); - } - // set type - if ($type == 2) - { - // hour - $format = 'Y-m-d \o\n ' . self::periodFix(self::$keytimer->format('H')); - } - elseif ($type == 3) - { - // day - $format = 'Y-m-' . self::periodFix(self::$keytimer->format('d')); - } - elseif ($type == 4) - { - // month - $format = 'Y-' . self::periodFix(self::$keytimer->format('m')); - } - else - { - // minute - $format = 'Y-m-d \o\n H:' . self::periodFix(self::$keytimer->format('i')); - } - // get key - if (UtilitiesArrayHelper::check($dynamic)) - { - return md5(str_replace(array_keys($dynamic), array_values($dynamic), self::$keytimer->format($format) . ' @ VDM.I0')); - } - return md5(self::$keytimer->format($format) . ' @ VDM.I0'); - } - - /** - * The function to insure the salt is valid within the given period (third try) - * - * @param int $main The main number - */ - protected static function periodFix($main) - { - return round($main / 3) * 3; - } - - /** - * Check if a string is serialized - * - * @param string $string - * - * @return Boolean - * - */ - public static function is_serial($string) - { - return (@unserialize($string) !== false); - } - - /** - * Get dynamic replacement salt - */ - public static function getDynamicSalt($dynamic = null) - { - // load global if not manually set - if (!UtilitiesArrayHelper::check($dynamic)) - { - return self::getGlobalSalt(); - } - // return manual values if set - else - { - return $dynamic; - } - } - - /** - * The random or dynamic secret salt - */ - public static function getSecretSalt($string = null, $size = 9) - { - // set the string - if (!$string) - { - // get random string - $string = self::randomkey($size); - } - // convert string to array - $string = UtilitiesStringHelper::safe($string); - // convert string to array - $array = str_split($string); - // insure only unique values are used - $array = array_unique($array); - // set the size - $size = ($size <= count($array)) ? $size : count($array); - // down size the - return array_slice($array, 0, $size); - } - - /** - * Get global replacement salt - */ - public static function getGlobalSalt() - { - // load from memory if found - if (!UtilitiesArrayHelper::check(self::$globalSalt)) - { - // get the global settings - if (!ObjectHelper::check(self::$params)) - { - self::$params = JComponentHelper::getParams('com_componentbuilder'); - } - // check if we have a global dynamic replacement array available (format --> ' 1->!,3->E,4->A') - $tmp = self::$params->get('dynamic_salt', null); - if (UtilitiesStringHelper::check($tmp) && strpos($tmp, ',') !== false && strpos($tmp, '->') !== false) - { - $salt = array_map('trim', (array) explode(',', $tmp)); - if (UtilitiesArrayHelper::check($salt )) - { - foreach($salt as $replace) - { - $dynamic = array_map('trim', (array) explode('->', $replace)); - if (isset($dynamic[0]) && isset($dynamic[1])) - { - self::$globalSalt[$dynamic[0]] = $dynamic[1]; - } - } - } - } - } - // return global if found - if (UtilitiesArrayHelper::check(self::$globalSalt)) - { - return self::$globalSalt; - } - // return default as fail safe - return array('1' => '!', '3' => 'E', '4' => 'A'); - } - - /** - * Close public protocol - */ - public static function closePublicProtocol($id, $public) - { - // get secret salt - $secretSalt = self::getSecretSalt(self::salt(1,array('4' => 'R','1' => 'E','2' => 'G','7' => 'J','8' => 'A'))); - // get the key - $key = self::salt(1, $secretSalt); - // get secret salt - $secret = self::getSecretSalt(); - // set the secret - $close['SECRET'] = self::lock($secret, $key, 1, array('1' => 's', '3' => 'R', '4' => 'D')); - // get the key - $key = self::salt(1, $secret); - // get the public key - $close['PUBLIC'] = self::lock($public, $key, 1, array('1' => '!', '3' => 'E', '4' => 'A')); - // get secret salt - $secretSalt = self::getSecretSalt($public); - // get the key - $key = self::salt(1, $secretSalt); - // get the ID - $close['ID'] = self::unlock($id, $key, 1, array('1' => 'i', '3' => 'e', '4' => 'B')); - // return closed values - return $close; - } - - /** - * Open public protocol - */ - public static function openPublicProtocol($SECRET, $ID, $PUBLIC) - { - // get secret salt - $secretSalt = self::getSecretSalt(self::salt(1,array('4' => 'R','1' => 'E','2' => 'G','7' => 'J','8' => 'A'))); - // get the key - $key = self::salt(1, $secretSalt); - // get the $SECRET - $SECRET = self::unlock($SECRET, $key, 1, array('1' => 's', '3' => 'R', '4' => 'D')); - // get the key - $key = self::salt(1, $SECRET); - // get the public key - $open['public'] = self::unlock($PUBLIC, $key, 1, array('1' => '!', '3' => 'E', '4' => 'A')); - // get secret salt - $secretSalt = self::getSecretSalt($open['public']); - // get the key - $key = self::salt(1, $secretSalt); - // get the ID - $open['id'] = self::unlock($ID, $key, 1, array('1' => 'i', '3' => 'e', '4' => 'B')); - // return opened values - return $open; - } - - /** - * Workers to load tasks - * - * @var array - */ - protected static $worker = array(); - - /** - * Set a worker dynamic URLs - * - * @var array - */ - protected static $workerURL = array(); - - /** - * Set a worker dynamic HEADERs - * - * @var array - */ - protected static $workerHEADER = array(); - - /** - * Curl Error Notice - * - * @var bool - */ - protected static $curlErrorLoaded = false; - - /** - * check if a worker has more work - * - * @param string $function The function to target to perform the task - * - * @return bool - * - */ - public static function hasWork(&$function) - { - if (isset(self::$worker[$function]) && UtilitiesArrayHelper::check(self::$worker[$function])) - { - return count( (array) self::$worker[$function]); - } - return false; - } - - /** - * Set a worker url - * - * @param string $function The function to target to perform the task - * @param string $url The url of where the task is to be performed - * - * @return void - * - */ - public static function setWorkerUrl(&$function, &$url) - { - // set the URL if found - if (UtilitiesStringHelper::check($url)) - { - // make sure task function url is up - self::$workerURL[$function] = $url; - } - } - - /** - * Set a worker headers - * - * @param string $function The function to target to perform the task - * @param array $headers The headers needed for these workers/function - * - * @return void - * - */ - public static function setWorkerHeaders(&$function, &$headers) - { - // set the Headers if found - if (UtilitiesArrayHelper::check($headers)) - { - // make sure task function headers are set - self::$workerHEADER[$function] = $headers; - } - } - - /** - * Set a worker that needs to perform a task - * - * @param mixed $data The data to pass to the task - * @param string $function The function to target to perform the task - * @param string $url The url of where the task is to be performed - * @param array $headers The headers needed for these workers/function - * - * @return void - * - */ - public static function setWorker($data, $function, $url = null, $headers = null) - { - // make sure task function is up - if (!isset(self::$worker[$function])) - { - self::$worker[$function] = array(); - } - // load the task - self::$worker[$function][] = self::lock($data); - // set the Headers if found - if ($headers && !isset(self::$workerHEADER[$function])) - { - self::setWorkerHeaders($function, $headers); - } - // set the URL if found - if ($url && !isset(self::$workerURL[$function])) - { - self::setWorkerUrl($function, $url); - } - } - - /** - * Run set Workers - * - * @param string $function The function to target to perform the task - * @param string $perTask The amount of task per worker - * @param function $callback The option to do a call back when task is completed - * @param int $threadSize The size of the thread - * - * @return bool true On success - * - */ - public static function runWorker($function, $perTask = 50, $callback = null, $threadSize = 20) - { - // set task - $task = self::lock($function); - // build headers - $headers = array('VDM-TASK: ' .$task); - // build dynamic headers - if (isset(self::$workerHEADER[$function]) && UtilitiesArrayHelper::check(self::$workerHEADER[$function])) - { - foreach (self::$workerHEADER[$function] as $header) - { - $headers[] = $header; - } - } - // build worker options - $options = array(); - // make sure worker is up - if (isset(self::$worker[$function]) && UtilitiesArrayHelper::check(self::$worker[$function])) - { - // this load method is for each - if (1 == $perTask) - { - // working with a string = 1 - $headers[] = 'VDM-VALUE-TYPE: ' .self::lock(1); - // now load the options - foreach (self::$worker[$function] as $data) - { - $options[] = array(CURLOPT_HTTPHEADER => $headers, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => 'VDM_DATA='. $data); - } - } - // this load method is for bundles - else - { - // working with an array = 2 - $headers[] = 'VDM-VALUE-TYPE: ' .self::lock(2); - // now load the options - $work = array_chunk(self::$worker[$function], $perTask); - foreach ($work as $data) - { - $options[] = array(CURLOPT_HTTPHEADER => $headers, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => 'VDM_DATA='. implode('___VDM___', $data)); - } - } - // relieve worker of task/function - self::$worker[$function] = array(); - } - // do the execution - if (UtilitiesArrayHelper::check($options)) - { - if (isset(self::$workerURL[$function])) - { - $url = self::$workerURL[$function]; - } - else - { - $url = JURI::root() . '/index.php?option=com_componentbuilder&task=api.worker'; - } - return self::curlMultiExec($url, $options, $callback, $threadSize); - } - return false; - } - - /** - * Do a multi curl execution of tasks - * - * @param string $url The url of where the task is to be performed - * @param array $_options The array of curl options/headers to set - * @param function $callback The option to do a call back when task is completed - * @param int $threadSize The size of the thread - * - * @return bool true On success - * - */ - public static function curlMultiExec(&$url, &$_options, $callback = null, $threadSize = 20) - { - // make sure we have curl available - if (!function_exists('curl_version')) - { - if (!self::$curlErrorLoaded) - { - // set the notice - JFactory::getApplication()->enqueueMessage(JText::_('COM_COMPONENTBUILDER_HTWOCURL_NOT_FOUNDHTWOPPLEASE_SETUP_CURL_ON_YOUR_SYSTEM_OR_BCOMPONENTBUILDERB_WILL_NOT_FUNCTION_CORRECTLYP'), 'Error'); - // load the notice only once - self::$curlErrorLoaded = true; - } - return false; - } - // make sure we have an url - if (UtilitiesStringHelper::check($url)) - { - // make sure the thread size isn't greater than the # of _options - $threadSize = (count($_options) < $threadSize) ? count($_options) : $threadSize; - // set the options - $options = array(); - $options[CURLOPT_URL] = $url; - $options[CURLOPT_USERAGENT] = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12'; - $options[CURLOPT_RETURNTRANSFER] = TRUE; - $options[CURLOPT_SSL_VERIFYPEER] = FALSE; - // start multi threading :) - $handle = curl_multi_init(); - // start the first batch of requests - for ($i = 0; $i < $threadSize; $i++) - { - if (isset($_options[$i])) - { - $ch = curl_init(); - foreach ($_options[$i] as $curlopt => $string) - { - $options[$curlopt] = $string; - } - curl_setopt_array($ch, $options); - curl_multi_add_handle($handle, $ch); - } - } - // we wait for all the calls to finish (should not take long) - do { - while(($execrun = curl_multi_exec($handle, $working)) == CURLM_CALL_MULTI_PERFORM); - if($execrun != CURLM_OK) - break; - // a request was just completed -- find out which one - while($done = curl_multi_info_read($handle)) - { - if (is_callable($callback)) - { - // $info = curl_getinfo($done['handle']); - // request successful. process output using the callback function. - $output = curl_multi_getcontent($done['handle']); - $callback($output); - } - $key = $i + 1; - if(isset($_options[$key])) - { - // start a new request (it's important to do this before removing the old one) - $ch = curl_init(); $i++; - // add options - foreach ($_options[$key] as $curlopt => $string) - { - $options[$curlopt] = $string; - } - curl_setopt_array($ch, $options); - curl_multi_add_handle($handle, $ch); - // remove options again - foreach ($_options[$key] as $curlopt => $string) - { - unset($options[$curlopt]); - } - } - // remove the curl handle that just completed - curl_multi_remove_handle($handle, $done['handle']); - } - // stop wasting CPU cycles and rest for a couple ms - usleep(10000); - } while ($working); - // close the curl multi thread - curl_multi_close($handle); - // okay done - return true; - } - return false; - } - - /** - * Get an edit button - * - * @param int $item The item to edit - * @param string $view The type of item to edit - * @param string $views The list view controller name - * @param string $ref The return path - * @param string $component The component these views belong to - * @param string $headsup The message to show on click of button - * - * @return string On success the full html link - * - */ - public static function getEditButton(&$item, $view, $views, $ref = '', $component = 'com_componentbuilder', $headsup = 'COM_COMPONENTBUILDER_ALL_UNSAVED_WORK_ON_THIS_PAGE_WILL_BE_LOST_ARE_YOU_SURE_YOU_WANT_TO_CONTINUE') - { - // get URL - $url = self::getEditURL($item, $view, $views, $ref, $component); - // check if we found any - if (UtilitiesStringHelper::check($url)) - { - // get the global settings - if (!ObjectHelper::check(self::$params)) - { - self::$params = JComponentHelper::getParams('com_componentbuilder'); - } - // get UIKIT version - $uikit = self::$params->get('uikit_version', 2); - // check that we have the ID - if (ObjectHelper::check($item) && isset($item->id)) - { - // check if the checked_out is available - if (isset($item->checked_out)) - { - $checked_out = (int) $item->checked_out; - } - else - { - $checked_out = self::getVar($view, $item->id, 'id', 'checked_out', '=', str_replace('com_', '', $component)); - } - } - elseif (UtilitiesArrayHelper::check($item) && isset($item['id'])) - { - // check if the checked_out is available - if (isset($item['checked_out'])) - { - $checked_out = (int) $item['checked_out']; - } - else - { - $checked_out = self::getVar($view, $item['id'], 'id', 'checked_out', '=', str_replace('com_', '', $component)); - } - } - elseif (is_numeric($item) && $item > 0) - { - $checked_out = self::getVar($view, $item, 'id', 'checked_out', '=', str_replace('com_', '', $component)); - } - // set the link title - $title = UtilitiesStringHelper::safe(JText::_('COM_COMPONENTBUILDER_EDIT') . ' ' . $view, 'W'); - // check that there is a check message - if (UtilitiesStringHelper::check($headsup)) - { - if (3 == $uikit) - { - $href = 'onclick="UIkit.modal.confirm(\''.JText::_($headsup).'\').then( function(){ window.location.href = \'' . $url . '\' } )" href="javascript:void(0)"'; - } - else - { - $href = 'onclick="UIkit2.modal.confirm(\''.JText::_($headsup).'\', function(){ window.location.href = \'' . $url . '\' })" href="javascript:void(0)"'; - } - } - else - { - $href = 'href="' . $url . '"'; - } - // return UIKIT version 3 - if (3 == $uikit) - { - // check if it is checked out - if (isset($checked_out) && $checked_out > 0) - { - // is this user the one who checked it out - if ($checked_out == JFactory::getUser()->id) - { - return ' '; - } - return ' '; - } - // return normal edit link - return ' '; - } - // check if it is checked out (return UIKIT version 2) - if (isset($checked_out) && $checked_out > 0) - { - // is this user the one who checked it out - if ($checked_out == JFactory::getUser()->id) - { - return ' '; - } - return ' '; - } - // return normal edit link - return ' '; - } - return ''; - } - - /** - * Get an edit text button - * - * @param string $text The button text - * @param int $item The item to edit - * @param string $view The type of item to edit - * @param string $views The list view controller name - * @param string $ref The return path - * @param string $component The component these views belong to - * @param string $headsup The message to show on click of button - * - * @return string On success the full html link - * - */ - public static function getEditTextButton($text, &$item, $view, $views, $ref = '', $component = 'com_componentbuilder', $jRoute = true, $class = 'uk-button', $headsup = 'COM_COMPONENTBUILDER_ALL_UNSAVED_WORK_ON_THIS_PAGE_WILL_BE_LOST_ARE_YOU_SURE_YOU_WANT_TO_CONTINUE') - { - // make sure we have text - if (!UtilitiesStringHelper::check($text)) - { - return self::getEditButton($item, $view, $views, $ref, $component, $headsup); - } - // get URL - $url = self::getEditURL($item, $view, $views, $ref, $component, $jRoute); - // check if we found any - if (UtilitiesStringHelper::check($url)) - { - // get the global settings - if (!ObjectHelper::check(self::$params)) - { - self::$params = JComponentHelper::getParams('com_componentbuilder'); - } - // get UIKIT version - $uikit = self::$params->get('uikit_version', 2); - // check that we have the ID - if (ObjectHelper::check($item) && isset($item->id)) - { - // check if the checked_out is available - if (isset($item->checked_out)) - { - $checked_out = (int) $item->checked_out; - } - else - { - $checked_out = self::getVar($view, $item->id, 'id', 'checked_out', '=', str_replace('com_', '', $component)); - } - } - elseif (UtilitiesArrayHelper::check($item) && isset($item['id'])) - { - // check if the checked_out is available - if (isset($item['checked_out'])) - { - $checked_out = (int) $item['checked_out']; - } - else - { - $checked_out = self::getVar($view, $item['id'], 'id', 'checked_out', '=', str_replace('com_', '', $component)); - } - } - elseif (is_numeric($item) && $item > 0) - { - $checked_out = self::getVar($view, $item, 'id', 'checked_out', '=', str_replace('com_', '', $component)); - } - // set the link title - $title = UtilitiesStringHelper::safe(JText::_('COM_COMPONENTBUILDER_EDIT') . ' ' . $view, 'W'); - // check that there is a check message - if (UtilitiesStringHelper::check($headsup)) - { - if (3 == $uikit) - { - $href = 'onclick="UIkit.modal.confirm(\''.JText::_($headsup).'\').then( function(){ window.location.href = \'' . $url . '\' } )" href="javascript:void(0)"'; - } - else - { - $href = 'onclick="UIkit2.modal.confirm(\''.JText::_($headsup).'\', function(){ window.location.href = \'' . $url . '\' })" href="javascript:void(0)"'; - } - } - else - { - $href = 'href="' . $url . '"'; - } - // return UIKIT version 3 - if (3 == $uikit) - { - // check if it is checked out - if (isset($checked_out) && $checked_out > 0) - { - // is this user the one who checked it out - if ($checked_out == JFactory::getUser()->id) - { - return ' ' . $text . ''; - } - return ' ' . $text . ''; - } - // return normal edit link - return ' ' . $text . ''; - } - // check if it is checked out (return UIKIT version 2) - if (isset($checked_out) && $checked_out > 0) - { - // is this user the one who checked it out - if ($checked_out == JFactory::getUser()->id) - { - return ' ' . $text . ''; - } - return ' ' . $text . ''; - } - // return normal edit link - return ' ' . $text . ''; - } - return ''; - } - - /** - * Get the edit URL - * - * @param int $item The item to edit - * @param string $view The type of item to edit - * @param string $views The list view controller name - * @param string $ref The return path - * @param string $component The component these views belong to - * @param bool $jRoute The switch to add use JRoute or not - * - * @return string On success the edit url - * - */ - public static function getEditURL(&$item, $view, $views, $ref = '', $component = 'com_componentbuilder', $jRoute = true) - { - // build record - $record = new stdClass(); - // check if user can edit - if (self::canEditItem($record, $item, $view, $views, $component)) - { - // set the edit link - if ($jRoute) - { - return JRoute::_("index.php?option=" . $component . "&view=" . $views . "&task=" . $view . ".edit&id=" . $record->id . $ref); - } - return "index.php?option=" . $component . "&view=" . $views . "&task=" . $view . ".edit&id=" . $record->id . $ref; - } - return false; - } - - /** - * Can Edit (either any, or own) - * - * @param int $item The item to edit - * @param string $view The type of item to edit - * @param string $views The list view controller name - * @param string $component The component these views belong to - * - * @return bool if user can edit returns true els - * - */ - public static function allowEdit(&$item, $view, $views, $component = 'com_componentbuilder') - { - // build record - $record = new stdClass(); - return self::canEditItem($record, $item, $view, $views, $component); - } - - - /** - * Can Edit (either any, or own) - * - * @param int $item The item to edit - * @param string $view The type of item to edit - * @param string $views The list view controller name - * @param string $component The component these views belong to - * - * @return bool if user can edit returns true els - * - */ - protected static function canEditItem(&$record, &$item, $view, $views, $component = 'com_componentbuilder') - { - // make sure the user has access to view - if (!JFactory::getUser()->authorise($view. '.access', $component)) - { - return false; - } - // we start with false. - $can_edit = false; - // check that we have the ID - if (ObjectHelper::check($item) && isset($item->id)) - { - $record->id = (int) $item->id; - // check if created_by is available - if (isset($item->created_by) && $item->created_by > 0) - { - $record->created_by = (int) $item->created_by; - } - } - elseif (UtilitiesArrayHelper::check($item) && isset($item['id'])) - { - $record->id = (int) $item['id']; - // check if created_by is available - if (isset($item['created_by']) && $item['created_by'] > 0) - { - $record->created_by = (int) $item['created_by']; - } - } - elseif (is_numeric($item)) - { - $record->id = (int) $item; - } - // check ID - if (isset($record->id) && $record->id > 0) - { - // get user action permission to edit - $action = self::getActions($view, $record, $views, 'edit', str_replace('com_', '', $component)); - // check if the view permission is set - if (($can_edit = $action->get($view . '.edit', 'none-set')) === 'none-set') - { - // fall back on the core permission then (this can be an issue) - $can_edit = ($action->get('core.edit', false) || $action->get('core.edit.own', false)); - } - } - return $can_edit; - } - - /** - * set subform type table - * - * @param array $head The header names - * @param array $rows The row values - * @param string $idName The prefix to the table id - * - * @return string - * - */ - public static function setSubformTable($head, $rows, $idName) - { - $table[] = "
    "; - $table[] = "\t
    "; - $table[] = "\t\t
    "; - $table[] = "\t\t\t"; - $table[] = "\t\t\t\t"; - $table[] = "\t\t\t\t\t"; - $table[] = "\t\t\t\t\t\t"; - $table[] = "\t\t\t\t\t"; - $table[] = "\t\t\t\t"; - $table[] = "\t\t\t\t"; - foreach ($rows as $row) - { - $table[] = "\t\t\t\t\t"; - $table[] = "\t\t\t\t\t\t" . $row; - $table[] = "\t\t\t\t\t"; - } - $table[] = "\t\t\t\t"; - $table[] = "\t\t\t
    " . implode("", $head) . "
    "; - $table[] = "\t\t
    "; - $table[] = "\t
    "; - $table[] = "
    "; - // return the table - return implode("\n", $table); - } - - - /** - * Change to nice fancy date - */ - public static function fancyDate($date, $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($date)) - { - $date = strtotime($date); - } - return date('jS \o\f F Y',$date); - } - - /** - * get date based in period past - */ - public static function fancyDynamicDate($date, $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($date)) - { - $date = strtotime($date); - } - // older then year - $lastyear = date("Y", strtotime("-1 year")); - $tragetyear = date("Y", $date); - if ($tragetyear <= $lastyear) - { - return date('m/d/y', $date); - } - // same day - $yesterday = strtotime("-1 day"); - if ($date > $yesterday) - { - return date('g:i A', $date); - } - // just month day - return date('M j', $date); - } - - /** - * Change to nice fancy day time and date - */ - public static function fancyDayTimeDate($time, $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($time)) - { - $time = strtotime($time); - } - return date('D ga jS \o\f F Y',$time); - } - - /** - * Change to nice fancy time and date - */ - public static function fancyDateTime($time, $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($time)) - { - $time = strtotime($time); - } - return date('(G:i) jS \o\f F Y',$time); - } - - /** - * Change to nice hour:minutes time - */ - public static function fancyTime($time, $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($time)) - { - $time = strtotime($time); - } - return date('G:i',$time); - } - - /** - * set the date day as Sunday through Saturday - */ - public static function setDayName($date, $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($date)) - { - $date = strtotime($date); - } - return date('l', $date); - } - - /** - * set the date month as January through December - */ - public static function setMonthName($date, $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($date)) - { - $date = strtotime($date); - } - return date('F', $date); - } - - /** - * set the date day as 1st - */ - public static function setDay($date, $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($date)) - { - $date = strtotime($date); - } - return date('jS', $date); - } - - /** - * set the date month as 5 - */ - public static function setMonth($date, $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($date)) - { - $date = strtotime($date); - } - return date('n', $date); - } - - /** - * set the date year as 2004 (for charts) - */ - public static function setYear($date, $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($date)) - { - $date = strtotime($date); - } - return date('Y', $date); - } - - /** - * set the date as 2004/05 (for charts) - */ - public static function setYearMonth($date, $spacer = '/', $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($date)) - { - $date = strtotime($date); - } - return date('Y' . $spacer . 'm', $date); - } - - /** - * set the date as 2004/05/03 (for charts) - */ - public static function setYearMonthDay($date, $spacer = '/', $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($date)) - { - $date = strtotime($date); - } - return date('Y' . $spacer . 'm' . $spacer . 'd', $date); - } - - /** - * set the date as 03/05/2004 - */ - public static function setDayMonthYear($date, $spacer = '/', $check_stamp = true) - { - if ($check_stamp && !self::isValidTimeStamp($date)) - { - $date = strtotime($date); - } - return date('d' . $spacer . 'm' . $spacer . 'Y', $date); - } - - /** - * Check if string is a valid time stamp - */ - public static function isValidTimeStamp($timestamp) - { - return ((int) $timestamp === $timestamp) - && ($timestamp <= PHP_INT_MAX) - && ($timestamp >= ~PHP_INT_MAX); - } - - /** - * Check if string is a valid date - * https://www.php.net/manual/en/function.checkdate.php#113205 - */ - public static function isValidateDate($date, $format = 'Y-m-d H:i:s') - { - $d = DateTime::createFromFormat($format, $date); - return $d && $d->format($format) == $date; - } - - - /** - * The subform layouts - **/ - protected static $subformLayouts = false; - - /** - * get the subform layout - * - * @input string The view name - * @input string The string name - * - * @returns string on success - **/ - public static function getSubformLayout($view, $field, $default = 'repeatablejcb') - { - // get global values - if (self::$subformLayouts === false) - { - self::$subformLayouts = JComponentHelper::getParams('com_componentbuilder')->get('subform_layouts', false); - } - // check what we found (else) return default - if (ObjectHelper::check(self::$subformLayouts)) - { - // looking for - $target = $view . '.' . $field; - foreach (self::$subformLayouts as $subform) - { - if ($target === $subform->view_field) - { - return $subform->layout; - } - elseif ('default' === $subform->view_field) - { - $default = $subform->layout; - } - } - } - return $default; - } - - - /** - * Check if a row already exist - * - * @param string $table The table from which to get the variable - * @param array $where The value where - * @param string $main The component in which the table is found - * - * @return int the id, or false - * - */ - public static function checkExist($table, $where, $what = 'id', $operator = '=', $main = 'componentbuilder') - { - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - $query->select($db->quoteName(array($what))); - if (empty($table)) - { - $query->from($db->quoteName('#__'.$main)); - } - else - { - $query->from($db->quoteName('#__'.$main.'_'.$table)); - } - if (UtilitiesArrayHelper::check($where)) - { - foreach ($where as $key => $value) - { - if (is_numeric($value)) - { - if (is_float($value + 0)) - { - $query->where($db->quoteName($key) . ' ' . $operator . ' ' . (float) $value); - } - else - { - $query->where($db->quoteName($key) . ' ' . $operator . ' ' . (int) $value); - } - } - elseif (is_bool($value)) - { - $query->where($db->quoteName($key) . ' ' . $operator . ' ' . (bool) $value); - } - // we do not allow arrays at this point - elseif (!UtilitiesArrayHelper::check($value)) - { - $query->where($db->quoteName($key) . ' ' . $operator . ' ' . $db->quote( (string) $value)); - } - else - { - return false; - } - } - } - else - { - return false; - } - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - return $db->loadResult(); - } - return false; - } - - - /** - * Load the Composer Vendors - */ - public static function composerAutoload($target) - { - // insure we load the composer vendor only once - if (!isset(self::$composer[$target])) - { - // get the function name - $functionName = self::safeString('compose' . $target); - // check if method exist - if (method_exists(__CLASS__, $functionName)) - { - return self::{$functionName}(); - } - return false; - } - return self::$composer[$target]; - } - - /** - * Load the Component xml manifest. - */ - public static function manifest() - { - $manifestUrl = JPATH_ADMINISTRATOR."/components/com_componentbuilder/componentbuilder.xml"; - return simplexml_load_file($manifestUrl); - } - - /** - * Joomla version object - */ - protected static $JVersion; - - /** - * set/get Joomla version - */ - public static function jVersion() - { - // check if set - if (!self::checkObject(self::$JVersion)) - { - self::$JVersion = new JVersion(); - } - return self::$JVersion; - } - - /** - * Load the Contributors details. - */ - public static function getContributors() - { - // get params - $params = JComponentHelper::getParams('com_componentbuilder'); - // start contributors array - $contributors = array(); - // get all Contributors (max 20) - $searchArray = range('0','20'); - foreach($searchArray as $nr) - { - if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 2 || $params->get("showContributor".$nr) == 3)) - { - // set link based of selected option - if($params->get("useContributor".$nr) == 1) - { - $link_front = ''; - $link_back = ''; - } - elseif($params->get("useContributor".$nr) == 2) - { - $link_front = ''; - $link_back = ''; - } - else - { - $link_front = ''; - $link_back = ''; - } - $contributors[$nr]['title'] = self::htmlEscape($params->get("titleContributor".$nr)); - $contributors[$nr]['name'] = $link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back; - } - } - return $contributors; - } - - /** - * Load the Component Help URLs. - **/ - public static function getHelpUrl($view) - { - $user = JFactory::getUser(); - $groups = $user->get('groups'); - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $query->select(array('a.id','a.groups','a.target','a.type','a.article','a.url')); - $query->from('#__componentbuilder_help_document AS a'); - $query->where('a.site_view = '.$db->quote($view)); - $query->where('a.location = 2'); - $query->where('a.published = 1'); - $db->setQuery($query); - $db->execute(); - if($db->getNumRows()) - { - $helps = $db->loadObjectList(); - if (self::checkArray($helps)) - { - foreach ($helps as $nr => $help) - { - if ($help->target == 1) - { - $targetgroups = json_decode($help->groups, true); - if (!array_intersect($targetgroups, $groups)) - { - // if user not in those target groups then remove the item - unset($helps[$nr]); - continue; - } - } - // set the return type - switch ($help->type) - { - // set joomla article - case 1: - return self::loadArticleLink($help->article); - break; - // set help text - case 2: - return self::loadHelpTextLink($help->id); - break; - // set Link - case 3: - return $help->url; - break; - } - } - } - } - return false; - } - - /** - * Get the Article Link. - **/ - protected static function loadArticleLink($id) - { - return JURI::root().'index.php?option=com_content&view=article&id='.$id.'&tmpl=component&layout=modal'; - } - - /** - * Get the Help Text Link. - **/ - protected static function loadHelpTextLink($id) - { - $token = JSession::getFormToken(); - return 'index.php?option=com_componentbuilder&task=help.getText&id=' . (int) $id . '&token=' . $token; - } - - /** - * Get any component's model - */ - public static function getModel($name, $path = JPATH_COMPONENT_SITE, $Component = 'Componentbuilder', $config = array()) - { - // fix the name - $name = self::safeString($name); - // full path to models - $fullPathModels = $path . '/models'; - // load the model file - JModelLegacy::addIncludePath($fullPathModels, $Component . 'Model'); - // make sure the table path is loaded - if (!isset($config['table_path']) || !self::checkString($config['table_path'])) - { - // This is the JCB default path to tables in Joomla 3.x - $config['table_path'] = JPATH_ADMINISTRATOR . '/components/com_' . strtolower($Component) . '/tables'; - } - // get instance - $model = JModelLegacy::getInstance($name, $Component . 'Model', $config); - // if model not found (strange) - if ($model == false) - { - jimport('joomla.filesystem.file'); - // get file path - $filePath = $path . '/' . $name . '.php'; - $fullPathModel = $fullPathModels . '/' . $name . '.php'; - // check if it exists - if (File::exists($filePath)) - { - // get the file - require_once $filePath; - } - elseif (File::exists($fullPathModel)) - { - // get the file - require_once $fullPathModel; - } - // build class names - $modelClass = $Component . 'Model' . $name; - if (class_exists($modelClass)) - { - // initialize the model - return new $modelClass($config); - } - } - return $model; - } - - /** - * Add to asset Table - */ - public static function setAsset($id, $table, $inherit = true) - { - $parent = JTable::getInstance('Asset'); - $parent->loadByName('com_componentbuilder'); - - $parentId = $parent->id; - $name = 'com_componentbuilder.'.$table.'.'.$id; - $title = ''; - - $asset = JTable::getInstance('Asset'); - $asset->loadByName($name); - - // Check for an error. - $error = $asset->getError(); - - if ($error) - { - return false; - } - else - { - // Specify how a new or moved node asset is inserted into the tree. - if ($asset->parent_id != $parentId) - { - $asset->setLocation($parentId, 'last-child'); - } - - // Prepare the asset to be stored. - $asset->parent_id = $parentId; - $asset->name = $name; - $asset->title = $title; - // get the default asset rules - $rules = self::getDefaultAssetRules('com_componentbuilder', $table, $inherit); - if ($rules instanceof JAccessRules) - { - $asset->rules = (string) $rules; - } - - if (!$asset->check() || !$asset->store()) - { - JFactory::getApplication()->enqueueMessage($asset->getError(), 'warning'); - return false; - } - else - { - // Create an asset_id or heal one that is corrupted. - $object = new stdClass(); - - // Must be a valid primary key value. - $object->id = $id; - $object->asset_id = (int) $asset->id; - - // Update their asset_id to link to the asset table. - return JFactory::getDbo()->updateObject('#__componentbuilder_'.$table, $object, 'id'); - } - } - return false; - } - - /** - * Gets the default asset Rules for a component/view. - */ - protected static function getDefaultAssetRules($component, $view, $inherit = true) - { - // if new or inherited - $assetId = 0; - // Only get the actual item rules if not inheriting - if (!$inherit) - { - // Need to find the asset id by the name of the component. - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__assets')) - ->where($db->quoteName('name') . ' = ' . $db->quote($component)); - $db->setQuery($query); - $db->execute(); - // check that there is a value - if ($db->getNumRows()) - { - // asset already set so use saved rules - $assetId = (int) $db->loadResult(); - } - } - // get asset rules - $result = JAccess::getAssetRules($assetId); - if ($result instanceof JAccessRules) - { - $_result = (string) $result; - $_result = json_decode($_result); - foreach ($_result as $name => &$rule) - { - $v = explode('.', $name); - if ($view !== $v[0]) - { - // remove since it is not part of this view - unset($_result->$name); - } - elseif ($inherit) - { - // clear the value since we inherit - $rule = array(); - } - } - // check if there are any view values remaining - if (count((array) $_result)) - { - $_result = json_encode($_result); - $_result = array($_result); - // Instantiate and return the JAccessRules object for the asset rules. - $rules = new JAccessRules($_result); - // return filtered rules - return $rules; - } - } - return $result; - } - - /** - * xmlAppend - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement - * - * @return void - * @deprecated 3.3 Use FormHelper::append($xml, $node); - */ - public static function xmlAppend(&$xml, $node) - { - FormHelper::append($xml, $node); - } - - /** - * xmlComment - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param string $comment The comment to inject - * - * @return void - * @deprecated 3.3 Use FormHelper::comment($xml, $comment); - */ - public static function xmlComment(&$xml, $comment) - { - FormHelper::comment($xml, $comment); - } - - /** - * xmlAddAttributes - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param array $attributes The attributes to apply to the XML element - * - * @return void - * @deprecated 3.3 Use FormHelper::attributes($xml, $attributes); - */ - public static function xmlAddAttributes(&$xml, $attributes = array()) - { - FormHelper::attributes($xml, $attributes); - } - - /** - * xmlAddOptions - * - * @param SimpleXMLElement $xml The XML element reference in which to inject a comment - * @param array $options The options to apply to the XML element - * - * @return void - * @deprecated 3.3 Use FormHelper::options($xml, $options); - */ - public static function xmlAddOptions(&$xml, $options = array()) - { - FormHelper::options($xml, $options); - } - - /** - * get the field object - * - * @param array $attributes The array of attributes - * @param string $default The default of the field - * @param array $options The options to apply to the XML element - * - * @return object - * @deprecated 3.3 Use FormHelper::field($attributes, $default, $options); - */ - public static function getFieldObject(&$attributes, $default = '', $options = null) - { - return FormHelper::field($attributes, $default, $options); - } - - /** - * get the field xml - * - * @param array $attributes The array of attributes - * @param array $options The options to apply to the XML element - * - * @return object - * @deprecated 3.3 Use FormHelper::xml($attributes, $options); - */ - public static function getFieldXML(&$attributes, $options = null) - { - return FormHelper::xml($attributes, $options); - } - - /** - * Render Bool Button - * - * @param array $args All the args for the button - * 0) name - * 1) additional (options class) // not used at this time - * 2) default - * 3) yes (name) - * 4) no (name) - * - * @return string The input html of the button - * - */ - public static function renderBoolButton() - { - $args = func_get_args(); - // check if there is additional button class - $additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time - // button attributes - $buttonAttributes = array( - 'type' => 'radio', - 'name' => isset($args[0]) ? self::htmlEscape($args[0]) : 'bool_button', - 'label' => isset($args[0]) ? self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool Button', // not seen anyway - 'class' => 'btn-group', - 'filter' => 'INT', - 'default' => isset($args[2]) ? (int) $args[2] : 0); - // set the button options - $buttonOptions = array( - '1' => isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES', - '0' => isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO'); - // return the input - return self::getFieldObject($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input; - } - - /** - * UIKIT Component Classes - **/ - public static $uk_components = array( - 'data-uk-grid' => array( - 'grid' ), - 'uk-accordion' => array( - 'accordion' ), - 'uk-autocomplete' => array( - 'autocomplete' ), - 'data-uk-datepicker' => array( - 'datepicker' ), - 'uk-form-password' => array( - 'form-password' ), - 'uk-form-select' => array( - 'form-select' ), - 'data-uk-htmleditor' => array( - 'htmleditor' ), - 'data-uk-lightbox' => array( - 'lightbox' ), - 'uk-nestable' => array( - 'nestable' ), - 'UIkit.notify' => array( - 'notify' ), - 'data-uk-parallax' => array( - 'parallax' ), - 'uk-search' => array( - 'search' ), - 'uk-slider' => array( - 'slider' ), - 'uk-slideset' => array( - 'slideset' ), - 'uk-slideshow' => array( - 'slideshow', - 'slideshow-fx' ), - 'uk-sortable' => array( - 'sortable' ), - 'data-uk-sticky' => array( - 'sticky' ), - 'data-uk-timepicker' => array( - 'timepicker' ), - 'data-uk-tooltip' => array( - 'tooltip' ), - 'uk-placeholder' => array( - 'placeholder' ), - 'uk-dotnav' => array( - 'dotnav' ), - 'uk-slidenav' => array( - 'slidenav' ), - 'uk-form' => array( - 'form-advanced' ), - 'uk-progress' => array( - 'progress' ), - 'upload-drop' => array( - 'upload', 'form-file' ) - ); - - /** - * Add UIKIT Components - **/ - public static $uikit = false; - - /** - * Get UIKIT Components - **/ - public static function getUikitComp($content,$classes = array()) - { - if (strpos($content,'class="uk-') !== false) - { - // reset - $temp = array(); - foreach (self::$uk_components as $looking => $add) - { - if (strpos($content,$looking) !== false) - { - $temp[] = $looking; - } - } - // make sure uikit is loaded to config - if (strpos($content,'class="uk-') !== false) - { - self::$uikit = true; - } - // sorter - if (self::checkArray($temp)) - { - // merger - if (self::checkArray($classes)) - { - $newTemp = array_merge($temp,$classes); - $temp = array_unique($newTemp); - } - return $temp; - } - } - if (self::checkArray($classes)) - { - return $classes; - } - return false; - } - - public static function isPublished($id,$type) - { - if ($type == 'raw') - { - $type = 'item'; - } - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $query->select(array('a.published')); - $query->from('#__componentbuilder_'.$type.' AS a'); - $query->where('a.id = '. (int) $id); - $query->where('a.published = 1'); - $db->setQuery($query); - $db->execute(); - $found = $db->getNumRows(); - if($found) - { - return true; - } - return false; - } - - public static function getGroupName($id) - { - $db = JFactory::getDBO(); - $query = $db->getQuery(true); - $query->select(array('a.title')); - $query->from('#__usergroups AS a'); - $query->where('a.id = '. (int) $id); - $db->setQuery($query); - $db->execute(); - $found = $db->getNumRows(); - if($found) - { - return $db->loadResult(); - } - return $id; - } - - /** - * Get the action permissions - * - * @param string $view The related view name - * @param int $record The item to act upon - * @param string $views The related list view name - * @param mixed $target Only get this permission (like edit, create, delete) - * @param string $component The target component - * @param object $user The user whose permissions we are loading - * - * @return object The JObject of permission/authorised actions - * - */ - public static function getActions($view, &$record = null, $views = null, $target = null, $component = 'componentbuilder', $user = 'null') - { - // load the user if not given - if (!self::checkObject($user)) - { - // get the user object - $user = JFactory::getUser(); - } - // load the JObject - $result = new JObject; - // make view name safe (just incase) - $view = self::safeString($view); - if (self::checkString($views)) - { - $views = self::safeString($views); - } - // get all actions from component - $actions = JAccess::getActionsFromFile( - JPATH_ADMINISTRATOR . '/components/com_' . $component . '/access.xml', - "/access/section[@name='component']/" - ); - // if non found then return empty JObject - if (empty($actions)) - { - return $result; - } - // get created by if not found - if (self::checkObject($record) && !isset($record->created_by) && isset($record->id)) - { - $record->created_by = self::getVar($view, $record->id, 'id', 'created_by', '=', $component); - } - // set actions only set in component settings - $componentActions = array('core.admin', 'core.manage', 'core.options', 'core.export'); - // check if we have a target - $checkTarget = false; - if ($target) - { - // convert to an array - if (self::checkString($target)) - { - $target = array($target); - } - // check if we are good to go - if (self::checkArray($target)) - { - $checkTarget = true; - } - } - // loop the actions and set the permissions - foreach ($actions as $action) - { - // check target action filter - if ($checkTarget && self::filterActions($view, $action->name, $target)) - { - continue; - } - // set to use component default - $fallback = true; - // reset permission per/action - $permission = false; - $catpermission = false; - // set area - $area = 'comp'; - // check if the record has an ID and the action is item related (not a component action) - if (self::checkObject($record) && isset($record->id) && $record->id > 0 && !in_array($action->name, $componentActions) && - (strpos($action->name, 'core.') !== false || strpos($action->name, $view . '.') !== false)) - { - // we are in item - $area = 'item'; - // The record has been set. Check the record permissions. - $permission = $user->authorise($action->name, 'com_' . $component . '.' . $view . '.' . (int) $record->id); - // if no permission found, check edit own - if (!$permission) - { - // With edit, if the created_by matches current user then dig deeper. - if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) - { - // the correct target - $coreCheck = (array) explode('.', $action->name); - // check that we have both local and global access - if ($user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component . '.' . $view . '.' . (int) $record->id) && - $user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component)) - { - // allow edit - $result->set($action->name, true); - // set not to use global default - // because we already validated it - $fallback = false; - } - else - { - // do not allow edit - $result->set($action->name, false); - $fallback = false; - } - } - } - elseif (self::checkString($views) && isset($record->catid) && $record->catid > 0) - { - // we are in item - $area = 'category'; - // set the core check - $coreCheck = explode('.', $action->name); - $core = $coreCheck[0]; - // make sure we use the core. action check for the categories - if (strpos($action->name, $view) !== false && strpos($action->name, 'core.') === false ) - { - $coreCheck[0] = 'core'; - $categoryCheck = implode('.', $coreCheck); - } - else - { - $categoryCheck = $action->name; - } - // The record has a category. Check the category permissions. - $catpermission = $user->authorise($categoryCheck, 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid); - if (!$catpermission && !is_null($catpermission)) - { - // With edit, if the created_by matches current user then dig deeper. - if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) - { - // check that we have both local and global access - if ($user->authorise('core.edit.own', 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid) && - $user->authorise($core . '.edit.own', 'com_' . $component)) - { - // allow edit - $result->set($action->name, true); - // set not to use global default - // because we already validated it - $fallback = false; - } - else - { - // do not allow edit - $result->set($action->name, false); - $fallback = false; - } - } - } - } - } - // if allowed then fallback on component global settings - if ($fallback) - { - // if item/category blocks access then don't fall back on global - if ((($area === 'item') && !$permission) || (($area === 'category') && !$catpermission)) - { - // do not allow - $result->set($action->name, false); - } - // Finally remember the global settings have the final say. (even if item allow) - // The local item permissions can block, but it can't open and override of global permissions. - // Since items are created by users and global permissions is set by system admin. - else - { - $result->set($action->name, $user->authorise($action->name, 'com_' . $component)); - } - } - } - return $result; - } - - /** - * Filter the action permissions - * - * @param string $action The action to check - * @param array $targets The array of target actions - * - * @return boolean true if action should be filtered out - * - */ - protected static function filterActions(&$view, &$action, &$targets) - { - foreach ($targets as $target) - { - if (strpos($action, $view . '.' . $target) !== false || - strpos($action, 'core.' . $target) !== false) - { - return false; - break; - } - } - return true; - } - - /** - * Check if we are connected - * Thanks https://stackoverflow.com/a/4860432/1429677 - * - * @returns bool true on success - */ - public static function isConnected() - { - // If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right? - $connected = @fsockopen("www.example.com", 80); - // website, port (try 80 or 443) - if ($connected) - { - //action when connected - $is_conn = true; - fclose($connected); - } - else - { - //action in connection failure - $is_conn = false; - } - return $is_conn; - } - - // typo sorry! - public static function sorten($string, $length = 40, $addTip = true) - { - return self::shorten($string, $length, $addTip); - } - - /** - * Get The Encryption Keys - * - * @param string $type The type of key - * @param string/bool $default The return value if no key was found - * - * @return string On success - * - **/ - public static function getCryptKey($type, $default = false) - { - // Get the global params - $params = JComponentHelper::getParams('com_componentbuilder', true); - // Basic Encryption Type - if ('basic' === $type) - { - $basic_key = $params->get('basic_key', $default); - if (self::checkString($basic_key)) - { - return $basic_key; - } - } - - return $default; - } -} diff --git a/site/helpers/headercheck.php b/site/helpers/headercheck.php deleted file mode 100644 index 707708464..000000000 --- a/site/helpers/headercheck.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -class componentbuilderHeaderCheck -{ - function js_loaded($script_name) - { - // UIkit check point - if (strpos($script_name,'uikit') !== false) - { - $app = JFactory::getApplication(); - $getTemplateName = $app->getTemplate('template')->template; - - if (strpos($getTemplateName,'yoo') !== false) - { - return true; - } - } - - $document = JFactory::getDocument(); - $head_data = $document->getHeadData(); - foreach (array_keys($head_data['scripts']) as $script) - { - if (stristr($script, $script_name)) - { - return true; - } - } - - return false; - } - - function css_loaded($script_name) - { - // UIkit check point - if (strpos($script_name,'uikit') !== false) - { - $app = JFactory::getApplication(); - $getTemplateName = $app->getTemplate('template')->template; - - if (strpos($getTemplateName,'yoo') !== false) - { - return true; - } - } - - $document = JFactory::getDocument(); - $head_data = $document->getHeadData(); - - foreach (array_keys($head_data['styleSheets']) as $script) - { - if (stristr($script, $script_name)) - { - return true; - } - } - - return false; - } -} \ No newline at end of file diff --git a/site/helpers/route.php b/site/helpers/route.php deleted file mode 100644 index 05b86176f..000000000 --- a/site/helpers/route.php +++ /dev/null @@ -1,257 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Componentbuilder Route Helper - **/ -abstract class ComponentbuilderHelperRoute -{ - protected static $lookup; - - /** - * @param int The route of the Api - */ - public static function getApiRoute($id = 0, $catid = 0) - { - if ($id > 0) - { - // Initialize the needel array. - $needles = array( - 'api' => array((int) $id) - ); - // Create the link - $link = 'index.php?option=com_componentbuilder&view=api&id='. $id; - } - else - { - // Initialize the needel array. - $needles = array( - 'api' => array() - ); - // Create the link but don't add the id. - $link = 'index.php?option=com_componentbuilder&view=api'; - } - if ($catid > 1) - { - $categories = JCategories::getInstance('componentbuilder.api'); - $category = $categories->get($catid); - if ($category) - { - $needles['category'] = array_reverse($category->getPath()); - $needles['categories'] = $needles['category']; - $link .= '&catid='.$catid; - } - } - - if ($item = self::_findItem($needles)) - { - $link .= '&Itemid='.$item; - } - - return $link; - } - - /** - * Get the URL route for componentbuilder category from a category ID and language - * - * @param mixed $catid The id of the items's category either an integer id or a instance of JCategoryNode - * @param mixed $language The id of the language being used. - * - * @return string The link to the contact - * - * @since 1.5 - */ - public static function getCategoryRoute_keep_for_later($catid, $language = 0) - { - if ($catid instanceof JCategoryNode) - { - $id = $catid->id; - $category = $catid; - } - else - { - throw new Exception('First parameter must be JCategoryNode'); - } - - $views = array( - "com_componentbuilder.field" => "field", - "com_componentbuilder.fieldtype" => "fieldtype"); - $view = $views[$category->extension]; - - if ($id < 1 || !($category instanceof JCategoryNode)) - { - $link = ''; - } - else - { - //Create the link - $link = 'index.php?option=com_componentbuilder&view='.$view.'&category='.$category->slug; - - $needles = array( - $view => array($id), - 'category' => array($id) - ); - - if ($language && $language != "*" && JLanguageMultilang::isEnabled()) - { - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select('a.sef AS sef') - ->select('a.lang_code AS lang_code') - ->from('#__languages AS a'); - - $db->setQuery($query); - $langs = $db->loadObjectList(); - foreach ($langs as $lang) - { - if ($language == $lang->lang_code) - { - $link .= '&lang='.$lang->sef; - $needles['language'] = $language; - } - } - } - - if ($item = self::_findItem($needles,'category')) - { - - $link .= '&Itemid='.$item; - } - else - { - if ($category) - { - $catids = array_reverse($category->getPath()); - $needles = array( - 'category' => $catids - ); - if ($item = self::_findItem($needles,'category')) - { - $link .= '&Itemid='.$item; - } - elseif ($item = self::_findItem(null, 'category')) - { - $link .= '&Itemid='.$item; - } - } - } - } - return $link; - } - - protected static function _findItem($needles = null,$type = null) - { - $app = JFactory::getApplication(); - $menus = $app->getMenu('site'); - $language = isset($needles['language']) ? $needles['language'] : '*'; - - // Prepare the reverse lookup array. - if (!isset(self::$lookup[$language])) - { - self::$lookup[$language] = array(); - - $component = JComponentHelper::getComponent('com_componentbuilder'); - - $attributes = array('component_id'); - $values = array($component->id); - - if ($language != '*') - { - $attributes[] = 'language'; - $values[] = array($needles['language'], '*'); - } - - $items = $menus->getItems($attributes, $values); - - foreach ($items as $item) - { - if (isset($item->query) && isset($item->query['view'])) - { - $view = $item->query['view']; - - if (!isset(self::$lookup[$language][$view])) - { - self::$lookup[$language][$view] = array(); - } - - if (isset($item->query['id'])) - { - /** - * Here it will become a bit tricky - * language != * can override existing entries - * language == * cannot override existing entries - */ - if (!isset(self::$lookup[$language][$view][$item->query['id']]) || $item->language != '*') - { - self::$lookup[$language][$view][$item->query['id']] = $item->id; - } - } - else - { - self::$lookup[$language][$view][0] = $item->id; - } - } - } - } - - if ($needles) - { - foreach ($needles as $view => $ids) - { - if (isset(self::$lookup[$language][$view])) - { - if (ComponentbuilderHelper::checkArray($ids)) - { - foreach ($ids as $id) - { - if (isset(self::$lookup[$language][$view][(int) $id])) - { - return self::$lookup[$language][$view][(int) $id]; - } - } - } - elseif (isset(self::$lookup[$language][$view][0])) - { - return self::$lookup[$language][$view][0]; - } - } - } - } - - if ($type) - { - // Check if the global menu item has been set. - $params = JComponentHelper::getParams('com_componentbuilder'); - if ($item = $params->get($type.'_menu', 0)) - { - return $item; - } - } - - // Check if the active menuitem matches the requested language - $active = $menus->getActive(); - - if ($active - && $active->component == 'com_componentbuilder' - && ($language == '*' || in_array($active->language, array('*', $language)) || !JLanguageMultilang::isEnabled())) - { - return $active->id; - } - - // If not found, return language specific home link - $default = $menus->getDefault($language); - - return !empty($default->id) ? $default->id : null; - } -} diff --git a/site/language/en-GB/en-GB.com_componentbuilder.ini b/site/language/en-GB/en-GB.com_componentbuilder.ini deleted file mode 100644 index 0c1f65c4c..000000000 --- a/site/language/en-GB/en-GB.com_componentbuilder.ini +++ /dev/null @@ -1,162 +0,0 @@ -COM_COMPONENTBUILDER="Component Builder" -COM_COMPONENTBUILDER_ACCESS_DENIED="Access denied!" -COM_COMPONENTBUILDER_ALL_UNSAVED_WORK_ON_THIS_PAGE_WILL_BE_LOST_ARE_YOU_SURE_YOU_WANT_TO_CONTINUE="All unsaved work on this page will be lost, are you sure you want to continue?" -COM_COMPONENTBUILDER_API="Api" -COM_COMPONENTBUILDER_API_DESC="Sync Portal API" -COM_COMPONENTBUILDER_A_METHOD_SETDYNAMICFZEROLDTHREERS_WAS_ADDED_TO_THE_INSTALL_BSCRIPTPHPB_OF_THIS_PACKAGE_TO_INSURE_THAT_THE_FOLDERS_ARE_COPIED_INTO_THE_CORRECT_PLACE_WHEN_THIS_COMPONENT_IS_INSTALLED="A method (setDynamicF0ld3rs) was added to the install script.php of this package to insure that the folder(s) are copied into the correct place when this component is installed!" -COM_COMPONENTBUILDER_BACKUP_FAILED_PLEASE_TRY_AGAIN_IF_THE_ERROR_CONTINUE_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR="Backup failed, please try again. If the error continue, please contact your system administrator." -COM_COMPONENTBUILDER_BACKUP_WAS_DONE_SUCCESSFULLY="Backup was done successfully" -COM_COMPONENTBUILDER_BE_CAUTIOUS_DO_NOT_CONTINUE_UNLESS_YOU_TRUST_THE_ORIGIN_OF_THIS_PACKAGE="Be cautious! Do not continue unless you trust the origin of this package!" -COM_COMPONENTBUILDER_BGET_THE_KEY_FROMB_A_SSA="Get the key from %s" -COM_COMPONENTBUILDER_BGET_THE_KEY_FROM_SB_FOR_A_SSA="Get the key from %s for %s" -COM_COMPONENTBUILDER_CHECK_YOUR_OWNER_DETAILS_IT_HAS_NOT_BEEN_SET_OPEN_THE_JCB_GLOBAL_OPTIONS_GO_TO_THE_COMPANY_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE="Check your owner details, it has not been set. Open the JCB Global Options, go to the Company tab and add the correct company details there." -COM_COMPONENTBUILDER_COMPANY_S="Company: %s" -COM_COMPONENTBUILDER_COMPONENT="Component" -COM_COMPONENTBUILDER_COMPONENT_DID_NOT_COMPILE="Component did not compile!" -COM_COMPONENTBUILDER_COMPONENT_IS_NOT_PUBLISHED_OR_IS_CHECKED_OUT="Component is not published, or is checked out!" -COM_COMPONENTBUILDER_COMPONENT_WAS_NOT_FOUND="Component was not found!" -COM_COMPONENTBUILDER_COPYRIGHT_S="Copyright: %s" -COM_COMPONENTBUILDER_CREATE_NEW_S="Create New %s" -COM_COMPONENTBUILDER_DESCRIPTION="Description" -COM_COMPONENTBUILDER_DTCOMPANYDTDDSDD="
    Company
    %s
    " -COM_COMPONENTBUILDER_DTCOPYRIGHTDTDDSDD="
    Copyright
    %s
    " -COM_COMPONENTBUILDER_DTEMAILDTDDSDD="
    Email
    %s
    " -COM_COMPONENTBUILDER_DTLICENSEDTDDSDD="
    License
    %s
    " -COM_COMPONENTBUILDER_DTOWNERDTDDSDD="
    Owner
    %s
    " -COM_COMPONENTBUILDER_DTWEBSITEDTDDSDD="
    Website
    %s
    " -COM_COMPONENTBUILDER_EDIT="Edit" -COM_COMPONENTBUILDER_EDIT_S="Edit %s" -COM_COMPONENTBUILDER_EDIT_S_S_DIRECTLY="Edit %s (%s) directly" -COM_COMPONENTBUILDER_EMAIL_S="Email: %s" -COM_COMPONENTBUILDER_EMAIL_WITH_THE_NEW_KEY_WAS_SENT="Email with the new key was sent" -COM_COMPONENTBUILDER_EMCOMPANYEM_BSB="Company: %s" -COM_COMPONENTBUILDER_EMCOPYRIGHTEM_BSB="Copyright: %s" -COM_COMPONENTBUILDER_EMEMAILEM_BSB="Email: %s" -COM_COMPONENTBUILDER_EMLICENSEEM_BSB="License: %s" -COM_COMPONENTBUILDER_EMOWNEREM_BSB="Owner: %s" -COM_COMPONENTBUILDER_EMWEBSITEEM_BSB="Website: %s" -COM_COMPONENTBUILDER_ERROR="Error!" -COM_COMPONENTBUILDER_EXAMPLE="Example" -COM_COMPONENTBUILDER_FILE="File" -COM_COMPONENTBUILDER_FOLDER="Folder" -COM_COMPONENTBUILDER_FREEOPEN="Free/Open" -COM_COMPONENTBUILDER_GREAT_THIS_PLACEHOLDER_WILL_WORK="Great, this placeholder will work!" -COM_COMPONENTBUILDER_HFOUR_CLASSNAVHEADERCOPYRIGHTHFOURPSP="

    %s

    " -COM_COMPONENTBUILDER_HFOUR_CLASSNAVHEADERLICENSEHFOURPSP="

    %s

    " -COM_COMPONENTBUILDER_HR_HTHREECUSTOM_CODES_WARNINGHTHREE="

    Custom Codes Warning

    " -COM_COMPONENTBUILDER_HR_HTHREECZEROMPZERONTHREENT_ISSUE_FOUNDHTHREEPTHE_PATH_S_COULD_NOT_BE_USEDP="

    c0mp0n3nt issue found

    The path (%s) could not be used.

    " -COM_COMPONENTBUILDER_HR_HTHREEDASHBOARD_ERRORHTHREE="

    Dashboard Error

    " -COM_COMPONENTBUILDER_HR_HTHREEDYNAMIC_BUTTON_ERRORHTHREE="

    Dynamic Button Error

    " -COM_COMPONENTBUILDER_HR_HTHREEDYNAMIC_FOLDERS_WERE_DETECTEDHTHREE="

    Dynamic folder(s) were detected.

    " -COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_ERRORHTHREE="

    External Code Error

    " -COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_NOTICEHTHREE="

    External Code Notice

    " -COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_WARNINGHTHREE="

    External Code Warning

    " -COM_COMPONENTBUILDER_HR_HTHREEFIELD_NOTICEHTHREE="

    Field Notice

    " -COM_COMPONENTBUILDER_HR_HTHREEFILE_PATH_ERRORHTHREE="

    File Path Error

    " -COM_COMPONENTBUILDER_HR_HTHREEFOLDER_PATH_ERRORHTHREE="

    Folder Path Error

    " -COM_COMPONENTBUILDER_HR_HTHREETIDY_ERRORHTHREE="

    Tidy Error

    " -COM_COMPONENTBUILDER_HTHREES_NAMESPACE_ERROR_SHTHREEPYOU_MUST_ATLEAST_HAVE_TWO_SECTIONS_IN_YOUR_NAMESPACE_YOU_JUST_HAVE_ONE_S_THIS_IS_AN_UNACCEPTABLE_ACTION_PLEASE_SEE_A_HREFS_PSRFOURA_FOR_MORE_INFOPPTHIS_S_WAS_THEREFORE_REMOVED_A_HREFSCLICK_HEREA_TO_FIX_THIS_ISSUEP="

    %s namespace error (%s)

    You must at-least have two sections in your namespace, you just have one (%s). This is an unacceptable action, please see psr-4 for more info.

    This %s was therefore removed, click here to fix this issue.

    " -COM_COMPONENTBUILDER_HTHREES_NAMESPACE_ERROR_SHTHREEPYOU_MUST_ATLEAST_HAVE_TWO_SECTIONS_IN_YOUR_NAMESPACE_YOU_JUST_HAVE_ONE_THIS_IS_AN_UNACCEPTABLE_ACTION_PLEASE_SEE_A_HREFS_PSRFOURA_FOR_MORE_INFOPPTHIS_S_WAS_THEREFORE_REMOVED_A_HREFSCLICK_HEREA_TO_FIX_THIS_ISSUEP="

    %s namespace error (%s)

    You must at-least have two sections in your namespace, you just have one. This is an unacceptable action, please see psr-4 for more info.

    This %s was therefore removed, click here to fix this issue.

    " -COM_COMPONENTBUILDER_HTWOCURL_NOT_FOUNDHTWOPPLEASE_SETUP_CURL_ON_YOUR_SYSTEM_OR_BCOMPONENTBUILDERB_WILL_NOT_FUNCTION_CORRECTLYP="

    Curl Not Found!

    Please setup curl on your system, or componentbuilder will not function correctly!

    " -COM_COMPONENTBUILDER_IAUTHORI_BSB="Author: %s" -COM_COMPONENTBUILDER_ICOMPANYI_BSB="Company: %s" -COM_COMPONENTBUILDER_ID_MISMATCH_WAS_DETECTED_WITH_THE_SSSS_GUI_CODE_FIELD_SO_THE_PLACEHOLDER_WAS_NOT_SET="ID mismatch was detected with the %s.%s.%s.%s GUI code field. So the placeholder was not set." -COM_COMPONENTBUILDER_IEMAILI_BSB="Email: %s" -COM_COMPONENTBUILDER_IWEBSITEI_BSB="Website: %s" -COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BUILDER_BACKUP_KEY="Joomla Component Builder - Backup Key" -COM_COMPONENTBUILDER_KEY_HAS_NOT_CHANGED="Key has not changed" -COM_COMPONENTBUILDER_LICENSE_S="License: %s" -COM_COMPONENTBUILDER_LINK="Link" -COM_COMPONENTBUILDER_LOADING_THE_PRIVATE_KEY_FILE_FAILED="Loading the private key file failed" -COM_COMPONENTBUILDER_LOADING_THE_PRIVATE_KEY_TEXT_FAILED="Loading the private key text failed" -COM_COMPONENTBUILDER_LOCAL="Local" -COM_COMPONENTBUILDER_LOGIN_FAILED="Login failed" -COM_COMPONENTBUILDER_MODULE="Module" -COM_COMPONENTBUILDER_MOVING_OF_THE_S_FAILED="Moving of the %s failed" -COM_COMPONENTBUILDER_NEW="New" -COM_COMPONENTBUILDER_NONE="None" -COM_COMPONENTBUILDER_NOT_FOUND_OR_ACCESS_DENIED="Not found or access denied!" -COM_COMPONENTBUILDER_NO_ACCESS_GRANTED="No Access Granted!" -COM_COMPONENTBUILDER_NO_COMPONENT_DETAILS_FOUND_SO_IT_IS_NOT_SAFE_TO_CONTINUE="No component details found, so it is not safe to continue!" -COM_COMPONENTBUILDER_NO_KEYS_WERE_FOUND_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_SETTINGS_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_EXPORT_KEY="No keys were found. To add an export key simply open the component, go to the tab called settings, bottom right there is a field called Export Key." -COM_COMPONENTBUILDER_NO_VALID_MODE_HAS_BEEN_SPECIFIED="No valid mode has been specified!" -COM_COMPONENTBUILDER_OWNER_DETAILS_WAS_SET="Owner details was set" -COM_COMPONENTBUILDER_OWNER_S="Owner: %s" -COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS="Package Owner Details" -COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS_NOT_FOUND="Package owner details not found!" -COM_COMPONENTBUILDER_PACKAGE_OWNER_NOT_SET="Package Owner Not Set" -COM_COMPONENTBUILDER_PAIDLOCKED="Paid/Locked" -COM_COMPONENTBUILDER_PFILE_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP="

    File at %s/%s gave the following error!
    %s

    " -COM_COMPONENTBUILDER_PLUGIN="Plugin" -COM_COMPONENTBUILDER_PPOWER_BGUIDSB_NOT_FOUNDP="

    Power guid:%s not found!

    " -COM_COMPONENTBUILDER_PROPERTY="Property" -COM_COMPONENTBUILDER_PSUPER_POWERB_REPOSITORY_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP="

    Super Power repository at %s/%s gave the following error!
    %s

    " -COM_COMPONENTBUILDER_PS_NAMING_MISMATCH_ERROR_SPPTHE_S_NAME_IS_BSB_AND_THE_ENDING_FILE_NAME_IN_THE_NAMESPACE_IS_BSB_THIS_IS_BAD_CONVENTION_PLEASE_SEE_A_HREFS_PSRFOURA_FOR_MORE_INFOPPA_HREFSCLICK_HEREA_TO_FIX_THIS_ISSUEP="

    %s naming mismatch error (%s)

    The %s name is %s and the ending file name in the namespace is %s. This is bad convention, please see psr-4 for more info.

    Click here to fix this issue.

    " -COM_COMPONENTBUILDER_SBR_YOU_CAN_ADD_A_BGITHUB_ACCESS_TOKENB_TO_COMPONENTBUILDER_GLOBAL_OPTIONS_TO_MAKE_AUTHENTICATED_REQUESTS_TO_GITHUB_AN_ACCESS_TOKEN_WITH_ONLY_PUBLIC_ACCESS_WILL_DO_TO_RETRIEVE_S="%s
    You can add a gitHub Access Token to Componentbuilder global options to make authenticated requests to gitHub. An access token with only public access will do to retrieve %s." -COM_COMPONENTBUILDER_SELECT_EXTENSION="Select Extension" -COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_BIMPORT_PROCESSB_BEFORE_ADDING_THE_KEY_THIS_WAY_IF_THE_USERDEV_BDOES_NOTB_HAVE_THE_KEY_THEY_CAN_SEE_BWHERE_TO_GET_ITB="Since the owner details are displayed during import process before adding the key, this way if the user/dev does not have the key they can see where to get it." -COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_IMPORT_PROCESS_BEFORE_ADDING_THE_KEY_THIS_WAY_IF_THE_USERDEV_DOES_NOT_HAVE_THE_KEY_THEY_CAN_SEE_WHERE_TO_GET_IT="Since the owner details are displayed during import process before adding the key, this way if the user/dev does not have the key they can see where to get it." -COM_COMPONENTBUILDER_SORRY_THIS_PLACEHOLDER_IS_ALREADY_IN_USE="Sorry this placeholder is already in use!" -COM_COMPONENTBUILDER_SORRY_THIS_PLACEHOLDER_IS_ALREADY_IN_USE_IN_THE_COMPILER="Sorry this placeholder is already in use in the compiler!" -COM_COMPONENTBUILDER_SOURCE_CODE="source code" -COM_COMPONENTBUILDER_SOURCE_CODE_FOR_JOOMLA_COMPONENT="Source Code for Joomla Component" -COM_COMPONENTBUILDER_S_WE_DETECTED_A_CHANGE_IN_BEXTERNALCODEB_BUT_YOU_DO_NOT_HAVE_PERMISSION_TO_ALLOW_THIS_CHANGE_SO_BSB_WAS_REMOVED_FROM_THE_COMPILATION_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFOBR_SMALLADMIN_ACCESS_REQUIREDSMALL="%s, we detected a change in EXTERNALCODE, but you do not have permission to allow this change so %s was removed from the compilation. Please contact your system administrator for more info!
    (admin access required)" -COM_COMPONENTBUILDER_S_WE_DETECTED_BNEW_EXTERNALCODEB_BUT_YOU_DO_NOT_HAVE_PERMISSION_TO_ALLOW_THIS_NEW_CODESTRING_SO_BSB_WAS_REMOVED_FROM_THE_COMPILATION_PLEASE_CONTACT_YOU_SYSTEM_ADMINISTRATOR_FOR_MORE_INFOBR_SMALLADMIN_ACCESS_REQUIREDSMALL="%s, we detected NEW EXTERNALCODE, but you do not have permission to allow this new code/string so %s was removed from the compilation. Please contact you system administrator for more info!
    (admin access required)" -COM_COMPONENTBUILDER_THAT_MEANS_ANYONE_WHO_HAS_THIS_PACKAGE_CAN_INSTALL_IT_INTO_JCB_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_BSETTINGSB_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_BEXPORT_KEYB="That means anyone who has this package can install it into JCB. To add an export key simply open the component, go to the tab called settings, bottom right there is a field called Export Key." -COM_COMPONENTBUILDER_THAT_MEANS_ANYONE_WHO_HAS_THIS_PACKAGE_CAN_INSTALL_IT_INTO_JCB_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_SETTINGS_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_EXPORT_KEY="That means anyone who has this package can install it into JCB. To add an export key simply open the component, go to the tab called settings, bottom right there is a field called Export Key." -COM_COMPONENTBUILDER_THE_BPHPSECLIBNETSFTPB_LIBRARYCLASS_IS_NOT_AVAILABLE_THIS_LIBRARYCLASS_SHOULD_HAVE_BEEN_ADDED_TO_YOUR_BLIBRARIESVDM_IOVENDORB_FOLDER_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFO="The phpseclib\NET\SFTP library\class is not available! This library\class should have been added to your libraries/vdm_io/vendor folder. Please contact your system administrator for more info" -COM_COMPONENTBUILDER_THE_BSB_BSB_IS_NOT_AVAILABLE_IN_YOUR_COMPONENT_PLEASE_INSURE_TO_ONLY_USED_S_FOR_A_DYNAMIC_DASHBOARD_THAT_ARE_STILL_LINKED_TO_YOUR_COMPONENT="The %s (%s) is not available in your component! Please insure to only used %s, for a dynamic dashboard, that are still linked to your component." -COM_COMPONENTBUILDER_THE_BSB_CUT_SEQUENCE_FAILED_ON_THE_RETURNED_EXTERNAL_CODESTRING_AS_MORE_LINES_HAS_TO_BE_CUT_THEN_WAS_FOUND_IN_THE_CODESTRING_WE_HAVE_COMPLETELY_REMOVED_THE_CODE_PLEASE_CHECK_THIS_CODESTRING="The %s cut sequence failed on the returned external code/string as more lines has to be cut then was found in the code/string. We have completely removed the code. Please check this code/string!" -COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_PATH_ON_BSB_SERVER="The %s file could not be moved to %s path on %s server." -COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_SERVER="The %s file could not be moved to %s server." -COM_COMPONENTBUILDER_THE_BSB_IS_NOT_A_VALID_URLPATH="The %s is not a valid url/path!" -COM_COMPONENTBUILDER_THE_BSB_LIBRARYCLASS_IS_NOT_AVAILABLE_THIS_LIBRARYCLASS_SHOULD_HAVE_BEEN_ADDED_TO_YOUR_BLIBRARIESPHPSECLIBVENDORB_FOLDER_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFO="The %s library\class is not available! This library\class should have been added to your libraries/phpseclib/vendor folder. Please contact your system administrator for more info!" -COM_COMPONENTBUILDER_THE_BSB_RETURNED_AN_INVALID_STRING="The %s returned an invalid string!" -COM_COMPONENTBUILDER_THE_BSB_VALUE_FOR_THE_DYNAMIC_DASHBOARD_IS_INVALID="The %s value for the dynamic dashboard is invalid." -COM_COMPONENTBUILDER_THE_CODESTRING_FROM_BSB_HAS_BEEN_ADDED_FOR_THE_BFIRST_TIMEB_PLEASE_IINVESTIGATEI_TO_ENSURE_THE_CORRECT_CODESTRING_WAS_USED_BSHOULD_YOU_NOT_KNOW_ABOUT_THIS_NEW_EXTERNAL_CODESTRING_BEING_ADDED_THEN_THIS_IS_A_SERIOUS_DANGER_AND_REQUIRES_IMMEDIATE_ATTENTIONB_DO_NOT_IGNORE_THIS_WARNING_AS_IT_WILL_ONLY_SHOW_BONCEB="The code/string from %s has been added for the first time. Please investigate to ensure the correct code/string was used! Should you not know about this NEW external code/string being added, then this is a serious danger! and requires immediate attention! Do not ignore this warning as it will only show once." -COM_COMPONENTBUILDER_THE_CODESTRING_FROM_BSB_HAS_BEEN_BCHANGEDB_SINCE_THE_LAST_COMPILATION_PLEASE_INVESTIGATE_TO_ENSURE_THE_CHANGES_ARE_SAFE_BSHOULD_YOU_NOT_EXPECT_THIS_CHANGE_TO_THE_EXTERNAL_CODESTRING_BEING_ADDED_THEN_THIS_IS_A_SERIOUS_ISSUE_AND_REQUIRES_IMMEDIATE_ATTENTIONB_DO_NOT_IGNORE_THIS_WARNING_AS_IT_WILL_ONLY_SHOW_BONCEB="The code/string from %s has been changed since the last compilation. Please investigate to ensure the changes are safe! Should you not expect this change to the external code/string being added, then this is a serious issue! and requires immediate attention! Do not ignore this warning as it will only show once." -COM_COMPONENTBUILDER_THE_FILE_PATH_BSB_DOES_NOT_EXIST_AND_WAS_NOT_ADDED="The file path: %s does not exist, and was not added!" -COM_COMPONENTBUILDER_THE_FOLDER_PATH_BSB_DOES_NOT_EXIST_AND_WAS_NOT_ADDED="The folder path: %s does not exist, and was not added!" -COM_COMPONENTBUILDER_THE_FTP_CONNECTION_FOR_BSB_COULD_NOT_BE_MADE_PLEASE_CHECK_YOUR_SIGNATURE_DETAILS="The FTP connection for %s could not be made. Please check your signature details!" -COM_COMPONENTBUILDER_THE_FTP_SIGNATURE_FOR_BSB_WAS_NOT_WELL_FORMED_PLEASE_CHECK_YOUR_SIGNATURE_DETAILS="The FTP signature for %s was not well formed, please check your signature details!" -COM_COMPONENTBUILDER_THE_LOGIN_TO_BSB_HAS_FAILED_PLEASE_CHECK_THAT_YOUR_DETAILS_ARE_CORRECT="The login to %s has failed, please check that your details are correct!" -COM_COMPONENTBUILDER_THE_OPTION_TO_ADD_A_DYNAMIC_BUTTON_IS_NOT_AVAILABLE_IN_BOWN_CUSTOM_FIELD_TYPESB_YOU_WILL_HAVE_TO_CUSTOM_CODE_IT="The option to add a dynamic button is not available in own custom field types, you will have to custom code it." -COM_COMPONENTBUILDER_THE_PACKAGE_KEY_IS_CODESCODE="The package key is: %s" -COM_COMPONENTBUILDER_THE_PACKAGE_KEY_IS_S="The package key is: %s" -COM_COMPONENTBUILDER_THE_PRIVATE_KEY_FIELD_COULD_NOT_BE_LOADED_FOR_BSB_SERVER="The private key field could not be loaded for %s server!" -COM_COMPONENTBUILDER_THE_PRIVATE_KEY_FILE_COULD_NOT_BE_LOADEDFOUND_FOR_BSB_SERVER="The private key file could not be loaded/found for %s server!" -COM_COMPONENTBUILDER_THE_SERVER_DETAILS_FOR_BID_SB_COULD_NOT_BE_RETRIEVED="The server details for (ID: %s) could not be retrieved!" -COM_COMPONENTBUILDER_THE_S_WAS_NOT_INSTALLED_AND_IS_STILL_IN_THE_TEMP_FOLDER="The %s was not Installed and is still in the temp folder." -COM_COMPONENTBUILDER_THE_S_WAS_NOT_INSTALLED_BY_YOUR_REQUEST_AND_IS_ALSO_REMOVED_FROM_TEMP_FOLDER="The %s was not Installed by your request and is also removed from temp folder." -COM_COMPONENTBUILDER_THE_S_WAS_NOT_INSTALLED_BY_YOUR_REQUEST_AND_IS_STILL_IN_THE_TEMP_FOLDER="The %s was not Installed by your request and is still in the temp folder." -COM_COMPONENTBUILDER_THE_S_WAS_SUCCESSFULLY_COMPILED="The %s was successfully compiled." -COM_COMPONENTBUILDER_THE_S_WAS_SUCCESSFULLY_INSTALLED_AND_REMOVED_FROM_TEMP_FOLDER="The %s was successfully Installed and removed from temp folder." -COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DID_NOT_RETURN_S_DATA="The url (%s) set to retrieve the packages did not return %s data!" -COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DID_NOT_RETURN_VALID_DATA="The url (%s) set to retrieve the packages did not return valid data!" -COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DOES_NOT_EXIST="The url (%s) set to retrieve the packages does not exist!" -COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DOES_NOT_RETURN_ANY_DATA="The url (%s) set to retrieve the packages does not return any data!" -COM_COMPONENTBUILDER_THIS_PACKAGE_HAS_NO_KEY="This package has no key." -COM_COMPONENTBUILDER_TO_CHANGE_THE_PACKAGE_OWNER_DEFAULTS_OPEN_THE_BJCB_GLOBAL_OPTIONSB_GO_TO_THE_BCOMPANYB_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE="To change the package owner defaults. Open the JCB Global Options, go to the Company tab and add the correct company details there." -COM_COMPONENTBUILDER_TO_CHANGE_THE_PACKAGE_OWNER_DEFAULTS_OPEN_THE_JCB_GLOBAL_OPTIONS_GO_TO_THE_COMPANY_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE="To change the package owner defaults. Open the JCB Global Options, go to the Company tab and add the correct company details there." -COM_COMPONENTBUILDER_TRANSLATOR_MODULE_NOT_READYBR_THIS_AREA_IS_STILL_UNDER_PRODUCTION_HOPEFULLY_WITH_NEXT_UPDATE="Translator Module not ready!
    This area is still under production, hopefully with next update." -COM_COMPONENTBUILDER_VJRZDESSMHBTRWFIFTYTWVZEROAESFLVVXJTMTHREEJTWOIXM="VjRzdE%ssMHBtRW50TWV0aE%sFlvVXJTM3J2IXM=" -COM_COMPONENTBUILDER_WEBSITE_S="Website: %s" -COM_COMPONENTBUILDER_WE_FOUND_DYNAMIC_CODE_BALL_IN_ONE_LINEB_AND_IGNORED_IT_PLEASE_REVIEW_S_FOR_MORE_DETAILS="We found dynamic code all in one line, and ignored it! Please review (%s) for more details!" -COM_COMPONENTBUILDER_YOUR_DATA_IS_ENCRYPTED_WITH_A_AES_TWO_HUNDRED_AND_FIFTY_SIX_BIT_ENCRYPTION_USING_THE_ABOVE_THIRTY_TWO_CHARACTER_KEY="Your data is encrypted with a AES 256 bit encryption using the above 32 character key." -COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_ACCESS_THE_SERVER_DETAILS_BS_DENIEDB_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFO="You do not have permission to access the server details (%s - denied), please contact your system administrator for more info." -COM_COMPONENTBUILDER_YOU_MUST_ENABLE_THE_BTIDYB_EXTENSION_IN_YOUR_PHPINI_FILE_SO_WE_CAN_TIDY_UP_YOUR_XML_IF_YOU_NEED_HELP_PLEASE_A_SSTART_HEREA="You must enable the Tidy extension in your php.ini file so we can tidy up your xml! If you need help please start here!" -COM_COMPONENTBUILDER_YOU_SHOULD_ADD_THE_CORRECT_OWNER_DETAILS="You should add the correct owner details." -COM_COMPONENTBUILDER__HAS_BEEN_CHECKED_OUT_BY_S="% has been checked out by %s" -COM_CONTENT_FIELD_MODIFIED_DESC="The last date this item was modified." -JGLOBAL_FIELD_ID_DESC="Record number in the database." -JGLOBAL_FIELD_ID_LABEL="ID" -JGLOBAL_FIELD_MODIFIED_BY_DESC="The user who did the last modification." -JGLOBAL_FIELD_MODIFIED_BY_LABEL="Modified By" -JGLOBAL_FIELD_MODIFIED_LABEL="Modified Date" -JTOOLBAR_APPLY="Save" -JTOOLBAR_CANCEL="Cancel" -JTOOLBAR_CLOSE="Close" -JTOOLBAR_HELP="Help" -JTOOLBAR_SAVE="Save & Close" -JTOOLBAR_SAVE_AND_NEW="Save & New" -JTOOLBAR_SAVE_AS_COPY="Save as Copy" \ No newline at end of file diff --git a/site/language/en-GB/en-GB.com_componentbuilder.sys.ini b/site/language/en-GB/en-GB.com_componentbuilder.sys.ini deleted file mode 100644 index d442612e9..000000000 --- a/site/language/en-GB/en-GB.com_componentbuilder.sys.ini +++ /dev/null @@ -1,3 +0,0 @@ -COM_COMPONENTBUILDER="Component Builder" -COM_COMPONENTBUILDER_NOT_FOUND_OR_ACCESS_DENIED="Not found or access denied!" -COM_COMPONENTBUILDER_NO_ACCESS_GRANTED="No Access Granted!" \ No newline at end of file diff --git a/site/models/api.php b/site/models/api.php deleted file mode 100644 index 2e4c557b5..000000000 --- a/site/models/api.php +++ /dev/null @@ -1,276 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\Model\ItemModel; -use Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory; - -/** - * Componentbuilder Api Item Model - */ -class ComponentbuilderModelApi extends ItemModel -{ - /** - * Model context string. - * - * @var string - */ - protected $_context = 'com_componentbuilder.api'; - - /** - * Model user data. - * - * @var strings - */ - protected $user; - protected $userId; - protected $guest; - protected $groups; - protected $levels; - protected $app; - protected $input; - protected $uikitComp; - - /** - * @var object item - */ - protected $item; - - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @since 1.6 - * - * @return void - */ - protected function populateState() - { - $this->app = JFactory::getApplication(); - $this->input = $this->app->input; - // Get the itme main id - $id = $this->input->getInt('id', null); - $this->setState('api.id', $id); - - // Load the parameters. - $params = $this->app->getParams(); - $this->setState('params', $params); - parent::populateState(); - } - - /** - * Method to get article data. - * - * @param integer $pk The id of the article. - * - * @return mixed Menu item data object on success, false on failure. - */ - public function getItem($pk = null) - { - $this->user = JFactory::getUser(); - $this->userId = $this->user->get('id'); - $this->guest = $this->user->get('guest'); - $this->groups = $this->user->get('groups'); - $this->authorisedGroups = $this->user->getAuthorisedGroups(); - $this->levels = $this->user->getAuthorisedViewLevels(); - $this->initSet = true; - - $pk = (!empty($pk)) ? $pk : (int) $this->getState('api.id'); - - if ($this->_item === null) - { - $this->_item = array(); - } - - if (!isset($this->_item[$pk])) - { - try - { - // Get a db connection. - $db = JFactory::getDbo(); - - // Create a new query object. - $query = $db->getQuery(true); - - // Get from #__componentbuilder_joomla_component as a - $query->select($db->quoteName( - array('a.ordering'), - array('ordering'))); - $query->from($db->quoteName('#__componentbuilder_joomla_component', 'a')); - - // Reset the query using our newly populated query object. - $db->setQuery($query); - // Load the results as a stdClass object. - $data = $db->loadObject(); - - if (empty($data)) - { - $app = JFactory::getApplication(); - // If no data is found redirect to default page and show warning. - $app->enqueueMessage(JText::_('COM_COMPONENTBUILDER_NOT_FOUND_OR_ACCESS_DENIED'), 'warning'); - $app->redirect(JURI::root()); - return false; - } - - // set data object to item. - $this->_item[$pk] = $data; - } - catch (Exception $e) - { - if ($e->getCode() == 404) - { - // Need to go thru the error handler to allow Redirect to work. - JError::raiseWarning(404, $e->getMessage()); - } - else - { - $this->setError($e); - $this->_item[$pk] = false; - } - } - } - - return $this->_item[$pk]; - } - - /** - * Get the uikit needed components - * - * @return mixed An array of objects on success. - * - */ - public function getUikitComp() - { - if (isset($this->uikitComp) && ComponentbuilderHelper::checkArray($this->uikitComp)) - { - return $this->uikitComp; - } - return false; - } - - public $messages = array(); - public $model; - - protected $compiler; - - public function getTranslationLinkedComponents() - { - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - // for now we only have crowdin - $query->select($db->quoteName(array('id', 'translation_tool', 'crowdin_account_api_key', 'crowdin_project_api_key' ,'crowdin_project_identifier', 'crowdin_username'))); - $query->from($db->quoteName('#__componentbuilder_joomla_component')); - $query->where($db->quoteName('translation_tool') . ' > 0'); - $query->where($db->quoteName('published') . ' >= 1'); - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - return $db->loadObjectList(); - } - return false; - } - - public function translate($component) - { - $this->messages[] = JText::_('COM_COMPONENTBUILDER_TRANSLATOR_MODULE_NOT_READYBR_THIS_AREA_IS_STILL_UNDER_PRODUCTION_HOPEFULLY_WITH_NEXT_UPDATE'); - return false; - } - - public function compileInstall($component) - { - $values = array( - 'joomla_version' => 3, - 'install' => 0, - 'component_id' => 0, - 'backup' => 0, - 'repository' => 0, - 'add_placeholders' => 0, - 'debug_line_nr' => 0, - 'minify' => 0 - ); - // set the values - foreach ($values as $key => $val) - { - if (isset($component->{$key})) - { - $values[$key] = $component->{$key}; - } - } - // make sure we have a component - if (isset($values['component_id']) && $values['component_id'] > 1) - { - // make sure the component is published - $published = ComponentbuilderHelper::getVar('joomla_component', (int) $values['component_id'], 'id', 'published'); - // make sure the component is checked in - $checked_out = ComponentbuilderHelper::getVar('joomla_component', (int) $values['component_id'], 'id', 'checked_out'); - if (1 == $published && $checked_out == 0) - { - // load the config values - CFactory::_('Config')->loadArray($values, true); - // start up Compiler - $this->compiler = new Compiler(); - if($this->compiler) - { - // component was compiled - $this->messages[] = JText::sprintf('COM_COMPONENTBUILDER_THE_S_WAS_SUCCESSFULLY_COMPILED', $this->compiler->componentFolderName); - // get compiler model to run the installer - $model = ComponentbuilderHelper::getModel('compiler', JPATH_COMPONENT_ADMINISTRATOR); - // now install components - if (1 == CFactory::_('Config')->install && $model->install($this->compiler->componentFolderName.'.zip')) - { - // component was installed - $this->messages[] = JText::sprintf('COM_COMPONENTBUILDER_THE_S_WAS_SUCCESSFULLY_INSTALLED_AND_REMOVED_FROM_TEMP_FOLDER', $this->compiler->componentFolderName); - } - elseif (1 != CFactory::_('Config')->install) - { - jimport('joomla.filesystem.file'); - $config = JFactory::getConfig(); - $package = $config->get('tmp_path') . '/' . $this->compiler->componentFolderName.'.zip'; - // just remove from temp - if (JFile::delete($package) && !is_file($package)) - { - // component was installed - $this->messages[] = JText::sprintf('COM_COMPONENTBUILDER_THE_S_WAS_NOT_INSTALLED_BY_YOUR_REQUEST_AND_IS_ALSO_REMOVED_FROM_TEMP_FOLDER', $this->compiler->componentFolderName); - } - else - { - // component was not installed - $this->messages[] = JText::sprintf('COM_COMPONENTBUILDER_THE_S_WAS_NOT_INSTALLED_BY_YOUR_REQUEST_AND_IS_STILL_IN_THE_TEMP_FOLDER', $this->compiler->componentFolderName); - } - } - else - { - // component was not installed - $this->messages[] = JText::sprintf('COM_COMPONENTBUILDER_THE_S_WAS_NOT_INSTALLED_AND_IS_STILL_IN_THE_TEMP_FOLDER', $this->compiler->componentFolderName); - } - // get all the messages from application (TODO) - return true; - } - // set that the component was not found - $this->messages[] = JText::_('COM_COMPONENTBUILDER_COMPONENT_DID_NOT_COMPILE'); - return false; - } - // set that the component was not found - $this->messages[] = JText::_('COM_COMPONENTBUILDER_COMPONENT_IS_NOT_PUBLISHED_OR_IS_CHECKED_OUT'); - return false; - } - // set that the component was not found - $this->messages[] = JText::_('COM_COMPONENTBUILDER_COMPONENT_WAS_NOT_FOUND'); - return false; - } -} diff --git a/site/router.php b/site/router.php deleted file mode 100644 index 5b01543c8..000000000 --- a/site/router.php +++ /dev/null @@ -1,228 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Routing class from com_componentbuilder - * - * @since 3.3 - */ -class ComponentbuilderRouter extends JComponentRouterBase -{ - /** - * Build the route for the com_componentbuilder component - * - * @param array &$query An array of URL arguments - * - * @return array The URL arguments to use to assemble the subsequent URL. - * - * @since 3.3 - */ - public function build(&$query) - { - $segments = array(); - - // Get a menu item based on Itemid or currently active - $params = JComponentHelper::getParams('com_componentbuilder'); - - if (empty($query['Itemid'])) - { - $menuItem = $this->menu->getActive(); - } - else - { - $menuItem = $this->menu->getItem($query['Itemid']); - } - - $mView = (empty($menuItem->query['view'])) ? null : $menuItem->query['view']; - $mId = (empty($menuItem->query['id'])) ? null : $menuItem->query['id']; - - if (isset($query['view'])) - { - $view = $query['view']; - - if (empty($query['Itemid']) && !(isset($view) && isset($query['id']) && ($view === 'api'))) - { - $segments[] = $query['view']; - } - - unset($query['view']); - } - - // Are we dealing with a item that is attached to a menu item? - if (isset($view) && ($mView == $view) and (isset($query['id'])) and ($mId == (int) $query['id'])) - { - unset($query['view']); - unset($query['catid']); - unset($query['id']); - return $segments; - } - - if (isset($view) && isset($query['id']) && ($view === 'api')) - { - if ($mId != (int) $query['id'] || $mView != $view) - { - if (($view === 'api')) - { - $segments[] = $view; - $id = explode(':', $query['id']); - if (count($id) == 2) - { - $segments[] = $id[1]; - } - else - { - $segments[] = $id[0]; - } - } - } - unset($query['id']); - } - - $total = count($segments); - - for ($i = 0; $i < $total; $i++) - { - $segments[$i] = str_replace(':', '-', $segments[$i]); - } - - return $segments; - - } - - /** - * Parse the segments of a URL. - * - * @param array &$segments The segments of the URL to parse. - * - * @return array The URL attributes to be used by the application. - * - * @since 3.3 - */ - public function parse(&$segments) - { - $count = count($segments); - $vars = array(); - - // Handle View and Identifier - switch($segments[0]) - { - case 'api': - $vars['view'] = 'api'; - if (is_numeric($segments[$count-1])) - { - $vars['id'] = (int) $segments[$count-1]; - } - elseif ($segments[$count-1]) - { - $id = $this->getVar('joomla_component', $segments[$count-1], 'alias', 'id'); - if($id) - { - $vars['id'] = $id; - } - } - break; - } - - return $vars; - } - - protected function getVar($table, $where = null, $whereString = null, $what = null, $category = false, $operator = '=', $main = 'componentbuilder') - { - if(!$where || !$what || !$whereString) - { - return false; - } - // Get a db connection. - $db = JFactory::getDbo(); - // Create a new query object. - $query = $db->getQuery(true); - - $query->select($db->quoteName(array($what))); - if ('categories' == $table || 'category' == $table || $category) - { - $getTable = '#__categories'; - $query->from($db->quoteName($getTable)); - // we need this to target the components categories (TODO will keep an eye on this) - $query->where($db->quoteName('extension') . ' LIKE '. $db->quote((string)'com_' . $main . '%')); - } - else - { - // we must check if the table exist (TODO not ideal) - $tables = $db->getTableList(); - $app = JFactory::getApplication(); - $prefix = $app->get('dbprefix'); - $check = $prefix.$main.'_'.$table; - if (in_array($check, $tables)) - { - $getTable = '#__'.$main.'_'.$table; - $query->from($db->quoteName($getTable)); - } - else - { - return false; - } - } - if (is_numeric($where)) - { - return false; - } - elseif ($this->checkString($where)) - { - // we must first check if this table has the column - $columns = $db->getTableColumns($getTable); - if (isset($columns[$whereString])) - { - $query->where($db->quoteName($whereString) . ' '.$operator.' '. $db->quote((string)$where)); - } - else - { - return false; - } - } - else - { - return false; - } - $db->setQuery($query); - $db->execute(); - if ($db->getNumRows()) - { - return $db->loadResult(); - } - return false; - } - - protected function checkString($string) - { - if (isset($string) && is_string($string) && strlen($string) > 0) - { - return true; - } - return false; - } -} - -function ComponentbuilderBuildRoute(&$query) -{ - $router = new ComponentbuilderRouter; - - return $router->build($query); -} - -function ComponentbuilderParseRoute($segments) -{ - $router = new ComponentbuilderRouter; - - return $router->parse($segments); -} \ No newline at end of file diff --git a/site/views/api/submitbutton.js b/site/views/api/submitbutton.js deleted file mode 100644 index 2458be89e..000000000 --- a/site/views/api/submitbutton.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @package Joomla.Component.Builder - * - * @created 30th April, 2015 - * @author Llewellyn van der Merwe - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -Joomla.submitbutton = function(task) -{ - if (task == ''){ - return false; - } else { - var action = task.split('.'); - if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ - Joomla.submitform(task, document.getElementById("adminForm")); - return true; - } else { - alert(Joomla.JText._('api, some values are not acceptable.','Some values are unacceptable')); - return false; - } - } -} \ No newline at end of file diff --git a/site/views/api/tmpl/default.php b/site/views/api/tmpl/default.php deleted file mode 100644 index b087fc387..000000000 --- a/site/views/api/tmpl/default.php +++ /dev/null @@ -1,20 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - - -?> - -
    -

    -
    diff --git a/site/views/api/view.html.php b/site/views/api/view.html.php deleted file mode 100644 index 5d346fc42..000000000 --- a/site/views/api/view.html.php +++ /dev/null @@ -1,116 +0,0 @@ - - * @git Joomla Component Builder - * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\CMS\MVC\View\HtmlView; - -/** - * Componentbuilder Html View class for the Api - */ -class ComponentbuilderViewApi extends HtmlView -{ - // Overwriting JView display method - function display($tpl = null) - { - // get combined params of both component and menu - $this->app = JFactory::getApplication(); - $this->params = $this->app->getParams(); - $this->menu = $this->app->getMenu()->getActive(); - // get the user object - $this->user = JFactory::getUser(); - // Initialise variables. - $this->item = $this->get('Item'); - // do not load the display - jexit('Access Denied!'); - - // Set the toolbar - $this->addToolBar(); - - // set the document - $this->_prepareDocument(); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode(PHP_EOL, $errors), 500); - } - - parent::display($tpl); - } - - /** - * Prepares the document - */ - protected function _prepareDocument() - { - - // Only load jQuery if needed. (default is true) - if ($this->params->get('add_jquery_framework', 1) == 1) - { - JHtml::_('jquery.framework'); - } - // Load the header checker class. - require_once( JPATH_COMPONENT_SITE.'/helpers/headercheck.php' ); - // Initialize the header checker. - $HeaderCheck = new componentbuilderHeaderCheck; - - // Load uikit options. - $uikit = $this->params->get('uikit_load'); - // Set script size. - $size = $this->params->get('uikit_min'); - // Set css style. - $style = $this->params->get('uikit_style'); - - // The uikit css. - if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) - { - JHtml::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit'.$style.$size.'.css', ['version' => 'auto']); - } - // The uikit js. - if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) - { - JHtml::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit'.$size.'.js', ['version' => 'auto']); - } - // add the document default css file - JHtml::_('stylesheet', 'components/com_componentbuilder/assets/css/api.css', ['version' => 'auto']); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - - // set help url for this view if found - $this->help_url = ComponentbuilderHelper::getHelpUrl('api'); - if (ComponentbuilderHelper::checkString($this->help_url)) - { - JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url); - } - // now initiate the toolbar - $this->toolbar = JToolbar::getInstance(); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var, $sorten = false, $length = 40) - { - // use the helper htmlEscape method instead. - return ComponentbuilderHelper::htmlEscape($var, $this->_charset, $sorten, $length); - } -}